diff --git a/architecture/webapp-frontend.md b/architecture/webapp-frontend.md index b3325e6..e1ce690 100644 --- a/architecture/webapp-frontend.md +++ b/architecture/webapp-frontend.md @@ -113,7 +113,7 @@ classDiagram +fetchBlobText(url) BlobText +fileURLFor(apiBase, path, version) string } - note for lib "collab.ts is the Yjs provider: SSE down, POST up, over the same pair /events already uses — no websocket dependency, no upgrade handshake, nothing special asked of a proxy that already carries the change stream. Only the client the hub calls `seed` builds the document from the file text; everyone else rebuilds from the relay log, because two independent seeds of the same text are two DIFFERENT Yjs documents and merging them duplicates every character. Awareness is posted separately and never logged. peerCount() is what tells a co-editor's snapshot (already in my buffer) from an outside write (a CLI, another device), which is the only case the peer-wrote banner should fire for" + note for lib "collab.ts is a thin wrapper over y-websocket, and used to be ~250 lines of hand-rolled provider. The document is held by the hub, so the client neither seeds it nor replays a log to catch up: it connects, the sync protocol hands over what it is missing, and `sync` firing is the moment the editor may mount. What went with the relay is every compensation for not owning the document — the seed claim and its grace timer, the byte cap, the rebuild-on-full, the resync frame, and solo mode, which let a disconnected client edit its own copy and overwrite a teammate. A hub that cannot serve the route still leaves the editor open and saving; what it loses is LIVE collaboration, not the ability to write, and that is deliberately not a second CRDT path. peerCount() still tells a co-editor's presence from an outside write (a CLI, another device), which is the only case the peer-wrote banner should fire for" note for hooks "usePresence beats every 10s with the path you are on and renders the roster the hub pushes back — the roster ARRIVES on useProjectEvents' stream (onPresence), not on the POST, which is used only for first paint so a tab opening into a quiet project still sees who is there. One EventSource carries both frame types: presence invalidates nothing. The path is read through a ref so navigating does not tear the timer down, and the unmount beat sends leave:true as courtesy — the 15s TTL is the real guarantee. Every failure is swallowed: presence is decoration and must never surface an error" note for hooks "useProjectEvents is the one non-polling source: an EventSource on {apiBase}events whose frames invalidate exactly what a peer's write touched (tree/history/heat always; render per named path; text wholesale). It is what makes an OPEN file update at all — useTextAt has no refetchInterval, so before this a body fetched once stayed on screen until the reader navigated away. A resync frame, a truncated path list, or an unparseable frame all fall back to invalidating every body rather than guessing. Errors are deliberately silent: EventSource retries itself and a 5-minute tree refetch is still underneath, so a hub restart or a sleeping laptop must not write a log line. That interval used to be 15s, for tree AND heat AND projects — belt-and-braces from before this stream existed, and on a real project it re-sent the whole 1.65 MB tree four times a minute to a client that already knew nothing had changed. What remains is insurance against a stream that dies quietly on a tab nobody touches, not a freshness mechanism (docs/network-efficiency-prd.md)" note for hooks "ONE stream per browser, not per tab. Every tab of a project gets the identical fan-out, so tab two onward cost a slot at both ends for nothing: a permanently in-flight request against the hub's per-instance concurrency, and one of the browser's ~6 per-origin HTTP/1.1 sockets — which is how six tabs wedged the whole app, not just live updates. One tab holds the EventSource and relays each frame verbatim over a BroadcastChannel keyed per project; followers run the same handler on the same raw data string. Leadership is a Web Lock held for the leader's lifetime, so the browser reassigns it when that tab dies — a crash or force-quit included, which is the case a heartbeat-and-TTL scheme gets wrong. Frames lost in the handover gap are the poll's job, as they always were. Web Locks needs a secure context, so a plain-http LAN hub falls back to a stream per tab. /collab is deliberately NOT shared: two tabs editing one document are two distinct CRDT peers with their own awareness state" @@ -136,7 +136,6 @@ classDiagram note for components "VisualEdit is click-to-edit for a synced HTML file: the page is rendered by the server's ?edit=1 view inside the SAME sandboxed iframe reading uses, and the editor is injected into it as a separate bundle (src/inline-edit.ts, built IIFE by vite.inline-edit.config.ts — an opaque-origin iframe cannot load a module script without CORS the hub has no business growing). Nothing here serializes the document: the iframe reports ONE element's inner HTML and the source range it belongs to, and this splices that range into the shared Y.Text, which is why the rest of the file survives byte-for-byte. Those ranges are held as Y.RelativePosition, never offsets — a peer's edit earlier in the file moves every number — and they are anchored against the CRDT ITSELF, never openSharedFile.current(), whose seed fallback reports a full document while the Y.Text being measured is empty and collapses every anchor onto index 0 (one edit then replaced an entire file). A patch whose resolved range would swallow a document the stamped range was only part of is refused outright. The iframe does NOT debounce its patch: for 700ms the edit lived only inside it, and Done tears the iframe down — typing and pressing Done is what finishing an edit looks like, and it silently lost the text" note for components "FileView's HtmlView re-mounts its iframe on the change stream. An iframe loads once, so leaving the editor rendered the file as it was when Done was pressed — BEFORE the save landed — and then sat there with the edit saved on the hub and invisible on screen; the same reload makes a teammate's edit appear in a page you are already looking at. EditView's banner is raised by the MERGE VERDICT for the source editor and by the change stream only for the visual one: the verdict knows whether the write could be folded in and the event cannot, so raising a banner on the event would flash the wrong answer ahead of it. For that visual path `mine` is a COUNT, not a flag: the change stream announces a write as soon as the hub journals it, often before the PUT's own response, so openSharedFile reports a write BEFORE it goes out, and two saves in flight (routine — clicking between paragraphs saves each) left the second event with nothing to claim it and raised the peer banner on the user's own edit" note for lib "A save carries the version its buffer was read at (If-Match), and a 409 is not an error to retry — it means somebody else's write is already the file. By then merge() has necessarily declined, because a save only happens when this buffer has changes of its own, so there is nothing left to reconcile: the losing version is written BESIDE the file as .bdrive-conflict--, the same name the sync path has used since the beginning and the same one ConflictBanner already explains. conflictName is therefore a second implementation of a pure function that lives in Go (syncer.go) — round-tripped through parseConflict in the unit tests, because two formats for one filename would be two explanations for one reader." - note for lib "collab.ts publishes a caret at most every 200ms, only its OWN client state, and not at all when nobody else is in the room. Every awareness change used to be its own POST, so arrow-keying around a file spent a request per keypress drawing a caret for nobody. Staying quiet while alone is only safe with the two forced announcements around it — the first one, and an answer to each new arrival — because awareness is relayed and never logged, so an announcement is lost to anyone who shows up after it and two people would otherwise stay invisible to each other forever." note for lib "sharedfile.merge is how an agent's write reaches a document somebody is typing in. The editor still never re-seeds itself from the server — that resets the buffer under a cursor — so the write arrives as textEdit's single splice instead: everything it does not change is untouched, and so is the caret sitting in it. It REFUSES in the two cases where a splice destroys something, and the refusal is FileView's banner: unsaved local edits (never overwrite half a sentence), and a co-editor in the room (both clients would compute the same splice, and two identical splices into one CRDT is the change applied twice). `saved` moves to the incoming text BEFORE the splice, or the document change it causes schedules a save that writes back what was just read. A relay-less surface has no Y.Text to splice, so it passes soloApply — without one merge reports blocked rather than claiming a change it could not make" note for lib "sharedfile.ts is everything about having a file open that is not about a keyboard — join the room, hold the CRDT, save on idle, save once more on the way out. Both surfaces sit on it: Editor binds CodeMirror to the Y.Text, VisualEdit splices ranges into the same one, so somebody typing markup and somebody clicking a headline are in one room and neither has to know the other exists" note for components "components/ui — shadcn/ui primitives (Radix, copied in), themed from BearDrive tokens in tw.css; rendered markdown is transformed as a string before mounting, link clicks delegated on the container — never patch the dangerouslySetInnerHTML subtree" @@ -152,7 +151,7 @@ classDiagram +heat.ts placeLabels LABEL_MAX (scatter danger-dot labels) +heat.ts HOT_READS STALE_DAYS isDanger daysSince agoLabel staleNote +conflict.ts parseConflict conflictName Conflict - +collab.ts CollabDoc peerCount (Yjs over SSE + POST) + +collab.ts CollabDoc peerCount (y-websocket to the hub-held document) +sharedfile.ts openSharedFile SharedFile SAVE_IDLE_MS +sharedfile.ts merge MergeResult (an outside write, offered to an open document) +sharedfile.ts preserve (a save that lost, parked beside the file) diff --git a/architecture/webapp-server.md b/architecture/webapp-server.md index 46d400b..7d205ab 100644 --- a/architecture/webapp-server.md +++ b/architecture/webapp-server.md @@ -54,7 +54,7 @@ classDiagram note for gzipWriter "Everything the viewer serves went out raw to browsers that asked for gzip on every request: a 1.65 MB tree that is 148 KB compressed, a 1.34 MB script bundle that is 431 KB. Outermost in Handler, so it covers what authGate and the rate limiter write themselves. Content types are an ALLOWLIST — an unknown type is left alone rather than compressed hopefully, and everything already compressed is binary with a type of its own. What it refuses to touch is the interesting part. text/event-stream: excluded outright, and this implements Flush AND Unwrap, because a wrapper implementing neither is how live updates and co-editing died behind an analytics middleware once (refuseUnstreamable exists because of it). /store/*: skipped by PATH, not merely when a body is already encoded — syncer.pull skips a journal that did not grow and then resumes at a BYTE OFFSET, so a length meaning anything other than bytes-on-this-socket re-downloads forever. 206/Content-Range: skipped, since a range is an offset into the plaintext and http.FileServerFS answers ranges for the embedded assets. Content-Length: kept as X-Uncompressed-Length, because the file viewer decides too-large-to-render BEFORE reading the body (useBlob.ts) and compressing would have silently disarmed that." note for Server "writeJSONCached is writeJSON for a response worth revalidating rather than re-sending: tree and heat carry an ETag over the encoded bytes plus Cache-Control: no-cache, and answer If-None-Match with a bodiless 304. The body is still built and hashed to answer one — the saving is the transfer, not the work, and the work was already being done." note for recordingMux "Exists for one caller: cmd/bdrive/desktop.go must classify every per-project route this hub serves, because a route it does not know falls through to local state and answers plausibly and WRONGLY. That has shipped twice. Recording beats parsing server.go: the per-project block builds eight patterns at runtime by concatenating a prefix, so a source scanner would silently miss exactly the routes it is meant to police." - note for Server "upload/content is CONDITIONAL when the caller asks. A browser sends If-Match carrying the sha its buffer was read at (the ETag the read already returned), and a mismatch is a 409 carrying the sha that replaced it — because the alternative, taking the body wholesale, is what two browsers holding different documents did to each other every few seconds when one of them lost the co-editing relay: six characters typed by one editor gone, no conflict copy, no warning (e2e/concurrent-edit.spec.ts). Optional by design: a caller that sends no If-Match gets the old behaviour, so the MCP tools, older clients and every other writer here are untouched. The check and the write are serialized per path (lockPath), or both halves of a simultaneous save pass a check that the other invalidates and the second still erases the first — the same single-writer assumption the journal read-modify-write already makes. The sha reported back is READ BACK, never the content sha just uploaded: a DirSource identifies a file by mtime and size, so handing the caller what it sent would hand it a value the next comparison could never match, and every save after the first on `bdrive serve --dir` would be parked as a conflict copy." + note for Server "upload/content is CONDITIONAL when the caller asks. A browser sends If-Match carrying the sha its buffer was read at (the ETag the read already returned), and a mismatch is a 409 carrying the sha that replaced it — because the alternative, taking the body wholesale, is what two browsers holding different documents did to each other every few seconds when one of them lost the co-editing relay: six characters typed by one editor gone, no conflict copy, no warning. The relay is gone and those two browsers now share one document, so that particular divergence cannot recur — but this door still guards the file against every writer that never touches a CRDT at all: an agent, the CLI, a device syncing. A stale base carrying the SAME content is not a conflict, it is a late arrival, and answering it 409 made the editor park copies of text nobody disputed. Optional by design: a caller that sends no If-Match gets the old behaviour, so the MCP tools, older clients and every other writer here are untouched. The check and the write are serialized per path (lockPath), or both halves of a simultaneous save pass a check that the other invalidates and the second still erases the first — the same single-writer assumption the journal read-modify-write already makes. The sha reported back is READ BACK, never the content sha just uploaded: a DirSource identifies a file by mtime and size, so handing the caller what it sent would hand it a value the next comparison could never match, and every save after the first on `bdrive serve --dir` would be parked as a conflict copy." note for Server "ReportRead is the desktop's read seam, dead on a hub. The sidecar keeps no ReadLedger and answers the viewer routes locally, so a person reading in the Mac app reached no ledger at all while the same file in the web app counted. The hook hands each viewer read to the sidecar, which forwards it to the project's own hub as HUMAN traffic — routing it through the agent report route instead would have filed a person's browsing as a device's." note for Server "Desktop marks the loopback sidecar posture (`bdrive desktop`), NOT a hub: the server fronts this machine's own volume stores. It is set in exactly one production place — cmd/bdrive/desktop.go — so on a deployed hub it stays false and both branches below are dead code, leaving /api/config byte-identical to a hub without it. DesktopMe supplies `me` from the device's saved sign-in (settings.json), a func because the tray can change it at runtime; the desktop has no AuthProvider" note for Server "clientIP is a METHOD now, not a package func: X-Forwarded-For is honored when the PEER is loopback/private (the operator's own proxy) or TrustProxy is set, and then only its LAST hop. Every caller that gates on an IP — the auth rate limiter, /s/*, device rows, share telemetry — goes through it, so a client-supplied header cannot forge the identity a limiter counts" @@ -191,27 +191,6 @@ classDiagram -ch chan of frames -lost atomic.Bool } - class collabHub { - <> - -rooms per project and path - +room(key) collabRoom - } - class collabRoom { - -updates opaque Yjs updates - -subs subscriber to the client id it declared - -key project and path, for log lines - -seeded claimed at join - -claimed when, so a dead claim can expire - +join(sub) backlog, first - +identify(sub, cid) - +subFor(cid) subscriber - +post(update, from) ok - +relay(frame) not logged - +relayExcept(frame, from) - +reset() - } - note for collabHub "GET and POST {prefix}collab?path=, proj(PermWrite) — the editing channel, so a read-only member has nothing to send on it. The hub is a RELAY and an append-only log: it never parses a Yjs update, holds no document, and links no CRDT library, which is what keeps the build pure Go (a cgo y-crdt would break the cross-compiled release the way a cgo sqlite would). Nothing here touches the journal — the DOCUMENT is a CRDT between browsers, the FILE is still an ordinary blob written by an ordinary upload/content call from whichever client stopped typing last, so journal.Less and Replay are untouched and every desktop device, agent and older client converges as before. The log is deliberately NOT durable; the file is" - note for collabRoom "`seeded` is CLAIMED at join under the room lock, never inferred from an empty log: the log only fills once the seeding client has POSTED, so every joiner arriving inside that window was told to seed too — 32 of 32 in the test that found it — and two clients seeding the same text build two DIFFERENT Yjs documents whose merge duplicates every character. The claim is released when the last editor leaves without having posted, or a tab opened and closed would leave the room claimed but empty and the next joiner would snapshot that emptiness over a real file — and because leave() only fires for a stream that is CLEANLY torn down, a claim that has produced nothing for seedClaimGrace expires on its own: a killed tab otherwise leaves a phantom subscriber holding the room forever, every later joiner is handed a blank document, the visual editor silently refuses to save and the source editor writes that blankness to the file. relay() is the awareness path: broadcast, never recorded, because a caret position replayed to a joiner paints cursors for people who have left. The POST is a DIFFERENT request from the stream, so the room has no sender to skip unless the browser names one: each stream declares a client id (identify), every POST carries it, and subFor resolves it back to that subscriber — without it the relay mails every editor its own keystrokes, which is 1 of N fan-out wasted and fills the sender's own 32-frame queue. An unknown or absent id means no sender and fans out to everyone, which is what an older frontend gets and stays correct because Yjs updates are idempotent. A drop is logged once per EPISODE, not per frame: a backed-up editor sheds hundreds in a row and the useful signal is that someone in this room fell behind" class presenceHub { <> @@ -223,6 +202,14 @@ classDiagram +Name string +Path string } + class ydocs { + <<reearth/ygo, embedded>> + +ServeHTTP websocket, behind proj(PermRead) + +Authorize per connection, ReadOnly for a reader + +OnLoadDocument seed from the file + +OnLastPeer / OnUnloadDocument snapshot to the file + } + note for ydocs "GET {prefix}ycollab, proj(PermRead) — the hub HOLDS the co-editing document now rather than relaying frames between browsers, which is what retired an entire category of machinery: a seed CLAIM with a grace timer, a byte cap on a log that only grows, a rebuild when that cap was hit, a resync-and-replay reconnect, and a solo fallback that let a disconnected client edit its own copy and then overwrite everyone else (six characters of a real user's work, #234). None of that is disabled; it is deleted, because the property each piece faked — somebody owns the document — is now simply true. PermRead and not PermWrite: a read-only member may OPEN a file and watch it being edited, and the CONNECTION carries ReadOnly so their writes are dropped server-side. The room name is DERIVED from (project, path) after proj() resolves the project and never taken from the caller, or the project id in the URL would be decoration — any member of any project could join any other project's document by asking for its name. The hub parses client-supplied CRDT updates to do this, which it never did before: a deliberate, recorded decision (docs/collab-provider-prd.md), possible at all because a pure-Go port removed the cgo that would have broken the cross-compiled release. Snapshotting RE-ENTERS the API rather than calling the uploader, so quota, folder permissions, the no-op check and journaling are the same code every other write goes through, and it is attributed to the human who was editing — a version authored by the server is a regression in History even when the server holds the pen." note for presenceHub "POST {prefix}presence, proj(PermRead) — saying "I am reading this" is not a write, and a read-only member is precisely who a teammate most wants to see on a file. NOT persisted and deliberately not a MetaStore repo: presence is true for 15s and then it is a lie, so storing it would only create something to serve staler than the thing it describes. The actor key is an account email and the roster reaches every member of the project, so the key is a MAP KEY ONLY and never serialized — rosterOf emits display name + path, the same pair History already shows them. A claimed path is untrusted text echoed to teammates, so it goes through journal.SafePath. Expiry is LAZY, computed in mark rather than by a sweeper: the only people who need to know a roster shrank are the ones still in it, and they are exactly the ones still heartbeating. rosterOf sorts because Go map order is random and an unstable roster would look like a change on every beat" class changeEvent { @@ -633,9 +620,6 @@ classDiagram Backend <|-- Watcher : optional capability Server *-- eventHub : live change fan-out Server *-- presenceHub : who is looking at what - Server *-- collabHub : per-document editing relay - collabHub *-- collabRoom - collabRoom o-- subscriber : reuses the event fan-out eventHub *-- subscriber presenceHub ..> eventHub : publishes roster on the SAME stream presenceHub ..> person : rosterOf diff --git a/cmd/bdrive/desktop.go b/cmd/bdrive/desktop.go index b13ef4f..7e0c8bd 100644 --- a/cmd/bdrive/desktop.go +++ b/cmd/bdrive/desktop.go @@ -146,18 +146,13 @@ var desktopRoutes = []struct { // Live surfaces. Hub state for the same reason every write is: the desktop // never journals locally, so nothing here would ever publish, and a stream // served from local state would be a connection that is open and silent - // forever. /collab carries the shared editing document — without it the - // app's editor opens on a document that never arrives, because it mounts - // on the relay's first frame. + // forever. {"GET /api/p/{project}/events", routeProxy, ""}, {"POST /api/p/{project}/presence", routeProxy, ""}, - {"GET /api/p/{project}/collab", routeProxy, ""}, - {"POST /api/p/{project}/collab", routeProxy, ""}, - // /ycollab is the same surface with the document held by the hub instead - // of relayed between browsers. Proxied for a sharper reason than the - // relay's: the document IS hub state now, so a desktop that answered from - // local state would hand the editor a second, private document — and the - // first thing that document does is get saved over the file. + // /ycollab carries the co-editing document. Proxied for a sharper reason + // than a stream: the document IS hub state, so a desktop that answered + // from local state would hand the editor a second, private document — + // and the first thing that document does is get saved over the file. {"GET /api/p/{project}/ycollab", routeProxy, ""}, // The same route one segment deeper: y-websocket appends its room // argument to the URL. Decoration — the hub names the room itself — but @@ -764,7 +759,6 @@ func proxyHub(w http.ResponseWriter, r *http.Request, server string) { // answer — the client has to be chosen before the answer exists. func streaming(r *http.Request) bool { return strings.HasSuffix(r.URL.Path, "/events") || - (r.Method == http.MethodGet && strings.HasSuffix(r.URL.Path, "/collab")) || // A websocket is long-lived in the way that matters here — the client // asks for a connection, not an answer — even though it is an upgrade // rather than a stream of frames the proxy can read. diff --git a/docs/collab-provider-prd.md b/docs/collab-provider-prd.md index ff42394..5eaeb87 100644 --- a/docs/collab-provider-prd.md +++ b/docs/collab-provider-prd.md @@ -263,16 +263,38 @@ client leaving at once. ### Stage 4 — delete the compensations -- [ ] `seedClaimGrace`, the seed claim, `maxRoomBytes`/`full`, and the - reconnect-and-replay path removed -- [ ] The awareness announce/re-announce dance removed — the server knows the - roster -- [ ] `architecture/webapp-server.md` and `webapp-frontend.md` updated; the - `collabRoom` notes are the largest single block of "why this is hard" in - either diagram and most of it should stop being true +- [x] `internal/webapp/collab.go` **deleted** (441 lines), with its two test + files: the relay, its rooms, the seed claim, `seedClaimGrace`, + `maxRoomBytes`, the `full` rebuild and the resync frame +- [x] `lib/collab.ts` reduced from a hand-rolled provider to a thin wrapper + over `y-websocket`; the SSE/POST transport, the log replay, the + announce/re-announce dance and `soloText`/`soloApply` are gone +- [x] `/api/config`'s `collab.held` removed too — with one transport there is + nothing left to choose, and a capability flag nobody reads is exactly + the "new mechanism replacing one that went away" this stage forbids +- [x] Solo mode survives only as *no live collaboration*: an unreachable hub + leaves the editor open and saving through `upload/content`. That is not + a second CRDT path — a client editing its own COPY of a shared document + is precisely what let two browsers overwrite each other +- [x] Both architecture diagrams updated and parse-checked. The `collabRoom` + note was the largest single block of "why this is hard" in either file; + it is now one note about a hub that owns the document **Success criteria:** net lines deleted, and no new mechanism replacing one -that went away. +that went away. ✅ **1,669 deletions against 68 insertions.** + +### What the deletion is worth, concretely + +`e2e/concurrent-edit.spec.ts` used to assert that a relay-less editor's work +was *preserved beside* a teammate's, because the two held different documents. +It now asserts they **converge**: every character both people typed is in the +file, and no conflict copy was needed to get it there. The stress spec agrees +— `1 paths, 2 versions`, where it used to report three paths and two conflict +copies. + +The conflict-copy machinery stays. It guards the file against writers that +never touch a CRDT at all — an agent, the CLI, a device syncing — which is a +door the relay's removal does not close. ## Risks @@ -287,8 +309,9 @@ that went away. ## Status -_Stage 0's decision is made (below): the hub may parse client-supplied CRDT -updates. Implementation proceeds._ +_All five stages are implemented. The hub holds the document, seeds it from +the file, writes it back, and the compensations the relay needed are deleted +rather than disabled._ | Stage | State | Notes | |---|---|---| @@ -296,7 +319,7 @@ updates. Implementation proceeds._ | 1 — hub holds the document | **done** | behind proj(); hub seeds from the file; wire fixtures in CI | | 2 — client stops being a provider | **done** | y-websocket; editor mounts on the hub-held document; 25 editor e2e pass | | 3 — server writes the file | **done** | snapshot on last peer; attributed to the human; re-enters the API | -| 4 — delete the compensations | next | | +| 4 — delete the compensations | **done** | -1669/+68; two browsers now converge instead of conflicting | ### The decision diff --git a/internal/webapp/collab.go b/internal/webapp/collab.go deleted file mode 100644 index f0087d3..0000000 --- a/internal/webapp/collab.go +++ /dev/null @@ -1,441 +0,0 @@ -package webapp - -import ( - "encoding/base64" - "encoding/json" - "io" - "log" - "net/http" - "strings" - "sync" - "time" - - "github.com/runbear-io/beardrive/internal/journal" -) - -// Collaborative editing: two people typing in one document at the same time. -// -// The hub is a RELAY and an append-only update log. It never parses a Yjs -// update, never holds a document, and has no CRDT library linked into it — -// which is what keeps the build pure Go (a cgo y-crdt would break the -// cross-compiled release the same way a cgo sqlite would). -// -// Nothing here touches the journal. A room's updates are ephemeral; the -// DOCUMENT is still an ordinary file, written by an ordinary upload/content -// call from whichever client is holding the pen (Editor.tsx). So every -// desktop device, every agent and every older client sees exactly what they -// saw before: a path with a blob behind it. journal.Less and Replay are -// untouched, and a peer that has never heard of collab converges identically. -// -// The one piece of coordination the relay cannot avoid: a Yjs document seeded -// independently by two clients from the same text is NOT the same document — -// the items carry different ids, and merging them duplicates the text. So the -// room tells exactly one joiner that it is first, under the room lock, and -// everyone else rebuilds from the log that joiner produced. - -const ( - // maxRoomBytes bounds one document's update log. Yjs updates are small - // (a keystroke is tens of bytes) but a long session is unbounded, and - // this is memory a member can grow by typing. Past it the room asks its - // clients to snapshot and start over. - maxRoomBytes = 8 << 20 - // seedClaimGrace is how long a seeding client has to actually post the - // document before its claim is treated as abandoned. - // - // leave() releases a claim when the last subscriber goes, but a stream - // that is never cleanly torn down — a killed tab, a dropped connection a - // proxy still holds open — leaves a subscriber behind forever. The room is - // then claimed, permanently empty, and every later joiner is told it is - // not the seeder and hands its editor a BLANK document: the visual editor - // silently refuses to save, and the source editor will happily snapshot - // that blankness over the file. Two orders of magnitude longer than the - // 60ms a real client takes to post its seed, so this never races one. - seedClaimGrace = 10 * time.Second - // roomIdle is how long a room with no subscribers is kept before its log - // is dropped. The file is the durable copy — the log only has to outlive - // a reload or a flaky connection. - roomIdle = 10 * time.Minute - // maxUpdateBytes bounds one POSTed update. - maxUpdateBytes = 1 << 20 -) - -type collabRoom struct { - mu sync.Mutex - key string // project\x00path, for log lines - updates [][]byte // opaque Yjs updates, in arrival order - bytes int - // subs maps each subscriber to the client id it declared, or "" for a - // client that declared none (an older frontend). The id is what lets a - // POST — a separate request from the stream — be recognised as coming - // from one of the room's own subscribers, so its update is not mailed - // back to it. - subs map[*subscriber]string - touched time.Time - // seeded is CLAIMED at join, not inferred from the log being non-empty. - // The log only fills once the seeding client has posted, and every joiner - // arriving inside that window would otherwise be told to seed too — each - // building a different Yjs document from the same text, which on merge - // duplicates every character. - seeded bool - // claimed is when that claim was made, so a claim that never produced - // anything can expire. See seedClaimGrace. - claimed time.Time -} - -type collabHub struct { - mu sync.Mutex - rooms map[string]*collabRoom -} - -func (s *Server) collab() *collabHub { - s.colOnce.Do(func() { s.col = &collabHub{rooms: map[string]*collabRoom{}} }) - return s.col -} - -// roomKey is (project, path). NUL-separated because it cannot appear in -// either: journal.SafePath refuses it in a path, and a project id is a -// restricted charset. -func roomKey(project, path string) string { return project + "\x00" + path } - -func (h *collabHub) room(key string) *collabRoom { - h.mu.Lock() - defer h.mu.Unlock() - h.sweepLocked() - r := h.rooms[key] - if r == nil { - r = &collabRoom{key: key, subs: map[*subscriber]string{}, touched: time.Now()} - h.rooms[key] = r - } - return r -} - -// sweepLocked drops rooms nobody has been in for roomIdle. Lazy, like -// presence expiry: the only thing that needs a room is a client arriving, and -// that is when this runs. -func (h *collabHub) sweepLocked() { - now := time.Now() - for k, r := range h.rooms { - r.mu.Lock() - idle := len(r.subs) == 0 && now.Sub(r.touched) > roomIdle - r.mu.Unlock() - if idle { - delete(h.rooms, k) - } - } -} - -// join adds a subscriber and reports the log so far, plus whether this client -// is the one that must seed the document from the file. Both under one lock: -// "am I first" and "here is what exists" have to be answered together or two -// clients both seed and the text doubles. -func (r *collabRoom) join(sub *subscriber) (backlog [][]byte, first bool) { - r.mu.Lock() - defer r.mu.Unlock() - r.subs[sub] = "" - r.touched = time.Now() - // Claimed but still empty well past the grace: whoever took it is not - // coming back with content, and somebody has to seed or this document can - // never be edited again. - stale := r.seeded && len(r.updates) == 0 && time.Since(r.claimed) > seedClaimGrace - first = !r.seeded || stale - if first { - r.seeded = true - r.claimed = time.Now() - } - backlog = make([][]byte, len(r.updates)) - copy(backlog, r.updates) - return backlog, first -} - -// identify records the client id a subscriber declared on its stream. Kept -// separate from join so join stays the one call that answers "am I the -// seeder", which is the question the whole room is built around. -func (r *collabRoom) identify(sub *subscriber, cid string) { - if cid == "" { - return - } - r.mu.Lock() - defer r.mu.Unlock() - if _, ok := r.subs[sub]; ok { - r.subs[sub] = cid - } -} - -// subFor resolves a client id to the subscriber holding that stream, so a -// POST can be attributed to it. Returns nil for an unknown or empty id, which -// post() reads as "no sender" and fans out to everyone — the old behaviour, -// which stays correct because Yjs updates are idempotent. -func (r *collabRoom) subFor(cid string) *subscriber { - if cid == "" { - return nil - } - r.mu.Lock() - defer r.mu.Unlock() - for sub, id := range r.subs { - if id == cid { - return sub - } - } - return nil -} - -func (r *collabRoom) leave(sub *subscriber) { - r.mu.Lock() - defer r.mu.Unlock() - delete(r.subs, sub) - r.touched = time.Now() - // The claim is released when the last editor leaves WITHOUT having posted - // anything. Otherwise a client that opened the document and closed it - // before typing would leave the room permanently claimed but empty, and - // the next joiner — told it is not first — would open a blank document - // and then snapshot that emptiness over the file. - if len(r.subs) == 0 && len(r.updates) == 0 { - r.seeded = false - } -} - -// post records an update and fans it out. Returns false when the room is full, -// which the client turns into "snapshot and rejoin". -func (r *collabRoom) post(update []byte, from *subscriber) bool { - r.mu.Lock() - if r.bytes+len(update) > maxRoomBytes { - r.mu.Unlock() - return false - } - r.updates = append(r.updates, update) - r.bytes += len(update) - r.touched = time.Now() - peers := make([]*subscriber, 0, len(r.subs)) - for sub := range r.subs { - if sub != from { // the sender already has it - peers = append(peers, sub) - } - } - r.mu.Unlock() - - frame, err := json.Marshal(collabFrame{Type: "update", Update: b64(update)}) - if err != nil { - return true - } - for _, sub := range peers { - select { - case sub.ch <- frame: - default: - // A client that cannot keep up with a document's edits has lost - // the thread of it: dropping one update is not recoverable for a - // CRDT peer the way a dropped file-change notification is, so it - // is told to rebuild rather than left silently diverged. - // - // Swap, not Store, so this logs once per episode rather than once - // per dropped frame: a backed-up editor drops hundreds in a row, - // and the useful signal is "someone in this room fell behind", - // not a line for each frame. Cleared when the stream writes the - // resync, so the next episode says so again. - if !sub.lost.Swap(true) { - proj, path, _ := strings.Cut(r.key, "\x00") - log.Printf("collab: editor fell behind in %s/%s (%d in room); told to rebuild", - proj, path, len(peers)+1) - } - } - } - return true -} - -// relay fans a frame out without recording it. Used for awareness, which is -// true for a moment and then is not. -func (r *collabRoom) relay(ev collabFrame) { r.relayExcept(ev, nil) } - -// relayExcept is relay, skipping one subscriber — the sender, who already -// knows where its own caret is. -func (r *collabRoom) relayExcept(ev collabFrame, from *subscriber) { - frame, err := json.Marshal(ev) - if err != nil { - return - } - r.mu.Lock() - peers := make([]*subscriber, 0, len(r.subs)) - for sub := range r.subs { - if sub != from { - peers = append(peers, sub) - } - } - r.touched = time.Now() - r.mu.Unlock() - for _, sub := range peers { - select { - case sub.ch <- frame: - default: - // A dropped cursor position is not worth a resync: the next one - // is along in a moment and corrects it. - } - } -} - -// reset empties a full room so the clients that just snapshotted can rebuild -// it from the file. -func (r *collabRoom) reset() { - r.mu.Lock() - defer r.mu.Unlock() - r.updates, r.bytes = nil, 0 - r.seeded = false // the log is gone; someone has to rebuild from the file - r.touched = time.Now() -} - -type collabFrame struct { - Type string `json:"type"` // "hello" | "update" | "awareness" | "resync" - // Seed is set on hello: this client must build the document from the - // file's current text, because the room is empty and someone has to. - Seed bool `json:"seed,omitempty"` - // Log is the room's updates so far, on hello for a non-seeding client. - Log []string `json:"log,omitempty"` - // Update is one Yjs update, base64. The hub never looks inside it. - Update string `json:"update,omitempty"` - // Awareness is a cursor/selection/identity update. Relayed but NEVER - // logged: it describes where someone's caret is this second, so replaying - // it to a joiner would paint cursors for people who have left, and storing - // it would grow the room without bound for something with no history. - Awareness string `json:"awareness,omitempty"` -} - -func b64(b []byte) string { return base64.StdEncoding.EncodeToString(b) } - -// handleCollabStream serves GET {prefix}collab?path= — the document's update -// stream. PermWrite, not PermRead: this is the editing channel, and a -// read-only member has nothing to send on it. -func (s *Server) handleCollabStream(v *volume, w http.ResponseWriter, r *http.Request) { - path := r.URL.Query().Get("path") - if path == "" || !journal.SafePath(path) { - http.Error(w, "collab needs a valid path", http.StatusBadRequest) - return - } - // The folder gate, not just the project one. A member with project write - // but read on this folder could otherwise join the room and type: their - // keystrokes would relay to every co-editor and then fail to persist, - // because the snapshot goes through upload/content, which runs the same - // check. Better to refuse the session than to show people text that is - // never going to survive. - if !s.writablePath(w, r, path) { - return - } - if refuseUnstreamable(w, r) { - return - } - rc := http.NewResponseController(w) - key := roomKey(projectID(r), path) - room := s.collab().room(key) - - sub, ok := s.events().subscribe("collab:" + key) - if !ok { - http.Error(w, "too many editing sessions open; try again shortly", http.StatusServiceUnavailable) - return - } - defer s.events().unsubscribe("collab:"+key, sub) - backlog, first := room.join(sub) - defer room.leave(sub) - // The id this browser also puts on its POSTs, so its own updates are not - // relayed back to it. Optional: an older frontend sends none and simply - // keeps receiving its own echoes, as it always did. - room.identify(sub, r.URL.Query().Get("cid")) - - h := w.Header() - h.Set("Content-Type", "text/event-stream") - h.Set("Content-Encoding", "identity") - h.Set("Cache-Control", "no-cache") - h.Set("X-Accel-Buffering", "no") - w.WriteHeader(http.StatusOK) - if err := rc.Flush(); err != nil { - return - } - - hello := collabFrame{Type: "hello", Seed: first} - for _, u := range backlog { - hello.Log = append(hello.Log, b64(u)) - } - frame, err := json.Marshal(hello) - if err != nil || !writeFrame(w, rc, frame) { - return - } - - tick := time.NewTicker(keepalive) - defer tick.Stop() - old := time.NewTimer(streamMaxAge) - defer old.Stop() - for { - select { - case <-r.Context().Done(): - return - case <-old.C: - return - case f := <-sub.ch: - if sub.lost.Swap(false) { - if !writeFrame(w, rc, []byte(`{"type":"resync"}`)) { - return - } - } - if !writeFrame(w, rc, f) { - return - } - case <-tick.C: - if sub.lost.Swap(false) { - if !writeFrame(w, rc, []byte(`{"type":"resync"}`)) { - return - } - continue - } - if _, err := w.Write([]byte(": keepalive\n\n")); err != nil { - return - } - if err := rc.Flush(); err != nil { - return - } - } - } -} - -// handleCollabPost serves POST {prefix}collab?path= — one Yjs update from an -// editor, relayed to everyone else in the document. -func (s *Server) handleCollabPost(v *volume, w http.ResponseWriter, r *http.Request) { - path := r.URL.Query().Get("path") - if path == "" || !journal.SafePath(path) { - http.Error(w, "collab needs a valid path", http.StatusBadRequest) - return - } - if !s.writablePath(w, r, path) { - return - } - var req struct { - Update string `json:"update"` - Awareness string `json:"awareness"` - // CID identifies the caller's own stream in this room; see identify. - CID string `json:"cid"` - } - if err := json.NewDecoder(io.LimitReader(r.Body, maxUpdateBytes*2)).Decode(&req); err != nil { - http.Error(w, "bad request: "+err.Error(), http.StatusBadRequest) - return - } - // Awareness is the ephemeral half: broadcast to the room, never stored. - if req.Awareness != "" { - aw, err := base64.StdEncoding.DecodeString(req.Awareness) - if err != nil || len(aw) == 0 || len(aw) > maxUpdateBytes { - http.Error(w, "awareness must be base64 and under the size limit", http.StatusBadRequest) - return - } - room := s.collab().room(roomKey(projectID(r), path)) - room.relayExcept(collabFrame{Type: "awareness", Awareness: b64(aw)}, - room.subFor(req.CID)) - writeJSON(w, map[string]any{"ok": true}) - return - } - update, err := base64.StdEncoding.DecodeString(req.Update) - if err != nil || len(update) == 0 || len(update) > maxUpdateBytes { - http.Error(w, "update must be base64 and under the size limit", http.StatusBadRequest) - return - } - room := s.collab().room(roomKey(projectID(r), path)) - if !room.post(update, room.subFor(req.CID)) { - room.reset() - writeJSON(w, map[string]any{"ok": true, "full": true}) - return - } - writeJSON(w, map[string]any{"ok": true}) -} diff --git a/internal/webapp/collab_concurrent_test.go b/internal/webapp/collab_concurrent_test.go deleted file mode 100644 index 7d2fe62..0000000 --- a/internal/webapp/collab_concurrent_test.go +++ /dev/null @@ -1,446 +0,0 @@ -package webapp - -import ( - "bufio" - "bytes" - "context" - "encoding/base64" - "encoding/json" - "fmt" - "log" - "net/http" - "net/http/httptest" - "os" - "strings" - "sync" - "sync/atomic" - "testing" - "time" -) - -// collabClient is one browser sitting in the editor: an SSE stream it reads -// continuously, plus updates it POSTs. -type collabClient struct { - id int - // Written by this client's stream goroutine, read by the summary below - // while those goroutines are still draining: close(stop) asks them to - // finish, it does not wait for them. Every field they touch is therefore - // read the way it is written. - seed atomic.Bool - updates int32 // frames of type "update" received - resyncs int32 // forced rebuilds — the symptom we are hunting - badPost int32 // non-200 from a POST - posted int32 -} - -// awaitResync waits for the rebuild notice a dropped client is owed. -// -// The dropped frames themselves are gone — post() only ever queued 32 and -// discarded the rest — so the notice cannot ride them. It goes out just -// before the NEXT frame the stream writes, or on the keepalive tick if the -// room fell silent, which is up to 20s away. A busy CI box reaches that -// second case (the typists finish, nothing more is queued, and the notice -// waits for the tick) where a fast laptop never does. -func awaitResync(c *collabClient, d time.Duration) { - deadline := time.Now().Add(d) - for time.Now().Before(deadline) { - if atomic.LoadInt32(&c.resyncs) > 0 { - return - } - time.Sleep(200 * time.Millisecond) - } -} - -// TestCollabSevenEditorsOneFile drives seven real HTTP clients editing one file -// at once and reports what the relay did: who seeded, how many updates each -// peer actually received, and whether anyone was told to resync (a dropped -// frame, which costs that editor a full rebuild). -func TestCollabSevenEditorsOneFile(t *testing.T) { - var logBuf bytes.Buffer - log.SetOutput(&logBuf) - defer log.SetOutput(os.Stderr) - - srv, p, _ := newHub(t, true, nil) - ts := httptest.NewServer(srv.Handler()) - defer ts.Close() - // Cancel before Close (defers are LIFO): the SSE streams never end on - // their own, and httptest.Close waits for every outstanding request. - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - const ( - editors = 7 - updatesPerEdit = 20 - ) - url := ts.URL + "/api/p/" + p.ID + "/collab?path=doc.md" - - clients := make([]*collabClient, editors) - cid := func(i int) string { return fmt.Sprintf("client-%d", i) } - var streamsUp sync.WaitGroup - var readers sync.WaitGroup - stop := make(chan struct{}) - - for i := 0; i < editors; i++ { - c := &collabClient{id: i} - clients[i] = c - streamsUp.Add(1) - readers.Add(1) - go func() { - defer readers.Done() - req, _ := http.NewRequestWithContext(ctx, "GET", url+"&cid="+cid(c.id), nil) - resp, err := http.DefaultClient.Do(req) - if err != nil { - t.Errorf("client %d: stream: %v", c.id, err) - streamsUp.Done() - return - } - defer resp.Body.Close() - if resp.StatusCode != 200 { - t.Errorf("client %d: stream status %d", c.id, resp.StatusCode) - streamsUp.Done() - return - } - sc := bufio.NewScanner(resp.Body) - sc.Buffer(make([]byte, 1<<20), 1<<20) - gotHello := false - for sc.Scan() { - line := sc.Text() - if !strings.HasPrefix(line, "data: ") { - continue // keepalive comment or blank separator - } - var f collabFrame - if err := json.Unmarshal([]byte(strings.TrimPrefix(line, "data: ")), &f); err != nil { - t.Errorf("client %d: bad frame: %v", c.id, err) - continue - } - switch f.Type { - case "hello": - c.seed.Store(f.Seed) - if !gotHello { - gotHello = true - streamsUp.Done() - } - case "update": - atomic.AddInt32(&c.updates, 1) - case "resync": - atomic.AddInt32(&c.resyncs, 1) - } - select { - case <-stop: - return - default: - } - } - }() - // Join in order so the seed claim is unambiguous, as a real room fills. - streamsUp.Wait() - } - - // Everyone types at once. - var typing sync.WaitGroup - for i := 0; i < editors; i++ { - typing.Add(1) - go func(c *collabClient) { - defer typing.Done() - for n := 0; n < updatesPerEdit; n++ { - body, _ := json.Marshal(map[string]string{ - "cid": cid(c.id), - "update": base64.StdEncoding.EncodeToString( - []byte(fmt.Sprintf("client-%d-update-%d", c.id, n))), - }) - resp, err := http.Post(url, "application/json", bytes.NewReader(body)) - if err != nil { - atomic.AddInt32(&c.badPost, 1) - continue - } - resp.Body.Close() - if resp.StatusCode != 200 { - atomic.AddInt32(&c.badPost, 1) - continue - } - atomic.AddInt32(&c.posted, 1) - time.Sleep(3 * time.Millisecond) // keystroke cadence - } - }(clients[i]) - } - typing.Wait() - time.Sleep(500 * time.Millisecond) // let fan-out drain - close(stop) - - // Every editor sees every update EXCEPT its own. The client id each - // stream declares is what makes that possible over HTTP, where the POST - // is a different request from the stream; without it the relay has no - // sender to skip and mails everyone their own keystrokes back. - want := (editors - 1) * updatesPerEdit - seeders := 0 - for _, c := range clients { - if c.seed.Load() { - seeders++ - } - t.Logf("client %d: seed=%v posted=%d received=%d (want %d) resyncs=%d badPost=%d", - c.id, c.seed.Load(), atomic.LoadInt32(&c.posted), - atomic.LoadInt32(&c.updates), want, atomic.LoadInt32(&c.resyncs), - atomic.LoadInt32(&c.badPost)) - } - if seeders != 1 { - t.Errorf("seeders = %d, want exactly 1", seeders) - } - for _, c := range clients { - if bad := atomic.LoadInt32(&c.badPost); bad != 0 { - t.Errorf("client %d: %d POSTs failed", c.id, bad) - } - got := int(atomic.LoadInt32(&c.updates)) - switch { - case got > want: - t.Errorf("client %d: received %d updates, want %d — the relay is "+ - "echoing this client its own updates", c.id, got, want) - case got < want && func() bool { - awaitResync(c, 30*time.Second) - return atomic.LoadInt32(&c.resyncs) == 0 - }(): - // The invariant that matters for a CRDT peer: frames may be - // dropped when a client falls behind, but it must always be TOLD, - // or it is silently diverged from everyone else. - t.Errorf("client %d: received %d of %d updates and was never told "+ - "to resync — silent divergence", c.id, got, want) - } - } - if logBuf.Len() > 0 { - t.Logf("server log output:\n%s", logBuf.String()) - } else { - t.Logf("server log: (silent)") - } -} - -// TestCollabSlowEditorAmongSeven is the mechanism that scales with the number -// of editors: fan-out is N-per-update, each subscriber queue holds subBuffer -// (32) frames, and a client that cannot drain that fast is marked lost and -// told to resync — which in collab.ts tears the EventSource down and opens a -// new one. Seven people typing at once is when a merely-busy browser starts -// missing that window. -func TestCollabSlowEditorAmongSeven(t *testing.T) { - var logBuf bytes.Buffer - log.SetOutput(&logBuf) - defer log.SetOutput(os.Stderr) - - srv, p, _ := newHub(t, true, nil) - ts := httptest.NewServer(srv.Handler()) - defer ts.Close() - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - const ( - editors = 7 - burst = 300 - slowIdx = 6 // one busy browser among seven - // Big enough that the kernel socket buffer cannot hide the backlog: - // with small frames everything fits in TCP and nothing is ever - // dropped, it is just read late. - payload = 4 << 10 - ) - url := ts.URL + "/api/p/" + p.ID + "/collab?path=doc.md" - - clients := make([]*collabClient, editors) - cid := func(i int) string { return fmt.Sprintf("client-%d", i) } - var up sync.WaitGroup - for i := 0; i < editors; i++ { - c := &collabClient{id: i} - clients[i] = c - up.Add(1) - go func() { - req, _ := http.NewRequestWithContext(ctx, "GET", url+"&cid="+cid(c.id), nil) - resp, err := http.DefaultClient.Do(req) - if err != nil { - up.Done() - return - } - defer resp.Body.Close() - sc := bufio.NewScanner(resp.Body) - sc.Buffer(make([]byte, 1<<20), 1<<20) - hello := false - for sc.Scan() { - line := sc.Text() - if !strings.HasPrefix(line, "data: ") { - continue - } - var f collabFrame - if json.Unmarshal([]byte(strings.TrimPrefix(line, "data: ")), &f) != nil { - continue - } - switch f.Type { - case "hello": - if !hello { - hello = true - up.Done() - } - case "update": - atomic.AddInt32(&c.updates, 1) - case "resync": - atomic.AddInt32(&c.resyncs, 1) - } - if c.id == slowIdx { - time.Sleep(20 * time.Millisecond) // parsing + applying Yjs - } - } - }() - up.Wait() - } - - var typing sync.WaitGroup - for i := 0; i < editors; i++ { - if i == slowIdx { - continue // the slow one is reading, not typing - } - typing.Add(1) - go func(c *collabClient) { - defer typing.Done() - for n := 0; n < burst; n++ { - body, _ := json.Marshal(map[string]string{ - "cid": cid(c.id), - "update": base64.StdEncoding.EncodeToString( - []byte(fmt.Sprintf("c%d-n%d-%s", c.id, n, strings.Repeat("x", payload)))), - }) - resp, err := http.Post(url, "application/json", bytes.NewReader(body)) - if err != nil { - atomic.AddInt32(&c.badPost, 1) - continue - } - resp.Body.Close() - if resp.StatusCode != 200 { - atomic.AddInt32(&c.badPost, 1) - continue - } - atomic.AddInt32(&c.posted, 1) - } - }(clients[i]) - } - typing.Wait() - // Drain until quiet: a slow reader is still working through TCP buffers - // long after the last POST, and calling that a drop would be wrong. - // The slow client types nothing, so it should receive every typist's - // burst; a typist receives everyone's but its own. - sent := (editors - 1) * burst - typistWant := (editors - 2) * burst - prev, quiet := int32(-1), 0 - for i := 0; i < 600 && quiet < 10; i++ { - time.Sleep(100 * time.Millisecond) - now := atomic.LoadInt32(&clients[slowIdx].updates) - if now == prev { - quiet++ - } else { - quiet = 0 - } - prev = now - if int(now) >= sent { - break - } - } - - for _, c := range clients { - want := typistWant - if c.id == slowIdx { - want = sent - } - t.Logf("client %d%s: posted=%d received=%d/%d resyncs=%d badPost=%d", - c.id, map[bool]string{true: " (SLOW)"}[c.id == slowIdx], - atomic.LoadInt32(&c.posted), atomic.LoadInt32(&c.updates), want, - atomic.LoadInt32(&c.resyncs), atomic.LoadInt32(&c.badPost)) - // A busy machine can back any client up past the 32-frame queue, so - // "received everything" is not a safe assertion. What must hold is - // that a client which missed frames was told to rebuild. - got := int(atomic.LoadInt32(&c.updates)) - if got > want { - t.Errorf("client %d: received %d, want at most %d — self-echo", - c.id, got, want) - } - if got < want { - awaitResync(c, 30*time.Second) - if atomic.LoadInt32(&c.resyncs) == 0 { - t.Errorf("client %d: received %d of %d and was never told to "+ - "resync — silent divergence", c.id, got, want) - } - } - } - slow := clients[slowIdx] - if r := atomic.LoadInt32(&slow.resyncs); r > 0 { - t.Logf("CONFIRMED: the slow editor was told to resync %d times "+ - "(each one tears down its EventSource and re-subscribes)", r) - } - if logBuf.Len() > 0 { - t.Logf("server log output:\n%s", logBuf.String()) - } else { - t.Logf("server log: (silent)") - } -} - -// TestCollabRoomFullWithSevenEditors exercises the one limit seven people can -// genuinely reach by typing: maxRoomBytes (8 MiB of update log). N editors -// fill it N times faster, and the answer is a reset plus "everyone rebuild" — -// so the thing to check is that the reset is safe while four other people are -// still posting into it. -func TestCollabRoomFullWithSevenEditors(t *testing.T) { - var logBuf bytes.Buffer - log.SetOutput(&logBuf) - defer log.SetOutput(os.Stderr) - - srv, p, _ := newHub(t, true, nil) - ts := httptest.NewServer(srv.Handler()) - defer ts.Close() - url := ts.URL + "/api/p/" + p.ID + "/collab?path=doc.md" - - chunk := base64.StdEncoding.EncodeToString(bytes.Repeat([]byte("y"), 900<<10)) - post := func() (full bool, code int) { - body, _ := json.Marshal(map[string]string{"update": chunk}) - resp, err := http.Post(url, "application/json", bytes.NewReader(body)) - if err != nil { - return false, 0 - } - defer resp.Body.Close() - var out struct { - OK bool `json:"ok"` - Full bool `json:"full"` - } - json.NewDecoder(resp.Body).Decode(&out) - return out.Full, resp.StatusCode - } - - // Five editors hammering one room, concurrently, past the cap. - var wg sync.WaitGroup - var fulls, bad int32 - for i := 0; i < 7; i++ { - wg.Add(1) - go func() { - defer wg.Done() - for n := 0; n < 6; n++ { - full, code := post() - if code != 200 { - atomic.AddInt32(&bad, 1) - continue - } - if full { - atomic.AddInt32(&fulls, 1) - } - } - }() - } - wg.Wait() - - t.Logf("42 posts x 900KB across 7 editors: full=%d badStatus=%d", fulls, bad) - if bad != 0 { - t.Errorf("%d posts returned a non-200 — seven editors should never be refused", bad) - } - if fulls == 0 { - t.Errorf("room never reported full; cap not reached, test is not exercising it") - } - // After the reset the room must still work: a fresh post is accepted. - if full, code := post(); code != 200 { - t.Errorf("post after reset: status %d", code) - } else { - t.Logf("post after reset: ok (full=%v)", full) - } - if logBuf.Len() > 0 { - t.Logf("server log output:\n%s", logBuf.String()) - } else { - t.Logf("server log: (silent)") - } -} diff --git a/internal/webapp/collab_test.go b/internal/webapp/collab_test.go deleted file mode 100644 index b32ee25..0000000 --- a/internal/webapp/collab_test.go +++ /dev/null @@ -1,279 +0,0 @@ -package webapp - -import ( - "net/http" - "net/http/httptest" - "strings" - "sync" - "testing" - "time" -) - -// The rule the whole relay rests on: exactly one joiner is told to seed. Two -// clients each building a Yjs document from the same file text produce two -// DIFFERENT documents, and merging them duplicates every character — so this -// is a correctness test, not a tidiness one. -func TestCollabExactlyOneJoinerSeeds(t *testing.T) { - room := &collabRoom{subs: map[*subscriber]string{}} - const n = 32 - var wg sync.WaitGroup - seeds := make([]bool, n) - for i := 0; i < n; i++ { - wg.Add(1) - go func(i int) { - defer wg.Done() - _, first := room.join(&subscriber{ch: make(chan []byte, 1)}) - seeds[i] = first - }(i) - } - wg.Wait() - got := 0 - for _, s := range seeds { - if s { - got++ - } - } - if got != 1 { - t.Fatalf("%d of %d joiners were told to seed, want exactly 1", got, n) - } -} - -/* -A claim that never produced a document must not hold the room forever. - - leave() releases a claim when the last subscriber goes, but a stream that is - never cleanly torn down — a killed tab, a connection a proxy still holds — - leaves a phantom subscriber behind. The room is then claimed, permanently - empty, and every later joiner is told it is NOT the seeder: the visual - editor hands out no anchors and silently refuses to save, and the source - editor mounts a blank buffer that will snapshot its blankness over the file. - - This was not hypothetical. It is what "I edited and nothing happened" turned - out to be, and it survives a page reload because the state is the hub's. -*/ -func TestCollabAbandonedSeedClaimExpires(t *testing.T) { - room := &collabRoom{subs: map[*subscriber]string{}} - - ghost := &subscriber{ch: make(chan []byte, 1)} - if _, first := room.join(ghost); !first { - t.Fatal("the first joiner was not told to seed") - } - // It never posts, and it never leaves. - - if _, first := room.join(&subscriber{ch: make(chan []byte, 1)}); first { - t.Fatal("a joiner inside the grace was told to seed — that is the race the claim exists to prevent") - } - - // Past the grace, with the room still empty, the claim is up for grabs. - room.mu.Lock() - room.claimed = time.Now().Add(-seedClaimGrace - time.Second) - room.mu.Unlock() - - if _, first := room.join(&subscriber{ch: make(chan []byte, 1)}); !first { - t.Fatal("an abandoned claim still owns the room; every editor of this file gets a blank document") - } -} - -// The other half: a claim that DID produce a document keeps the room, however -// long ago it was made. Expiring that one would tell a joiner to seed a room -// that already has content, and the two documents merge into doubled text. -func TestCollabLiveRoomKeepsItsClaimForever(t *testing.T) { - room := &collabRoom{subs: map[*subscriber]string{}} - seeder := &subscriber{ch: make(chan []byte, 8)} - room.join(seeder) - room.post([]byte("the document"), seeder) - - room.mu.Lock() - room.claimed = time.Now().Add(-100 * seedClaimGrace) - room.mu.Unlock() - - if _, first := room.join(&subscriber{ch: make(chan []byte, 8)}); first { - t.Fatal("a room with content told a joiner to seed; that duplicates every character on merge") - } -} - -// A joiner after the first gets the log, which is what lets it rebuild the -// same document instead of seeding a second one. -func TestCollabLaterJoinerGetsTheLog(t *testing.T) { - room := &collabRoom{subs: map[*subscriber]string{}} - first := &subscriber{ch: make(chan []byte, 8)} - if _, seed := room.join(first); !seed { - t.Fatal("the first joiner into an empty room must seed") - } - room.post([]byte("update-one"), first) - room.post([]byte("update-two"), first) - - log, seed := room.join(&subscriber{ch: make(chan []byte, 8)}) - if seed { - t.Fatal("a joiner into a non-empty room must NOT seed") - } - if len(log) != 2 || string(log[0]) != "update-one" || string(log[1]) != "update-two" { - t.Fatalf("log = %v, want both updates in order", log) - } -} - -// An update reaches the other editors and is not echoed to its sender. -func TestCollabPostFansOutButNotToSender(t *testing.T) { - room := &collabRoom{subs: map[*subscriber]string{}} - a := &subscriber{ch: make(chan []byte, 4)} - b := &subscriber{ch: make(chan []byte, 4)} - room.join(a) - room.join(b) - - if !room.post([]byte("hello"), a) { - t.Fatal("post refused") - } - select { - case f := <-b.ch: - if !strings.Contains(string(f), "aGVsbG8=") { // base64("hello") - t.Fatalf("peer frame = %s", f) - } - default: - t.Fatal("the other editor received nothing") - } - select { - case f := <-a.ch: - t.Fatalf("the sender was echoed its own update: %s", f) - default: - } -} - -// A CRDT peer that misses an update is silently diverged, which is worse than -// a missed file notification: it is told to rebuild. -func TestCollabSlowEditorIsToldToResync(t *testing.T) { - room := &collabRoom{subs: map[*subscriber]string{}} - slow := &subscriber{ch: make(chan []byte, 2)} - room.join(slow) - for i := 0; i < 10; i++ { - room.post([]byte("x"), nil) - } - if !slow.lost.Load() { - t.Fatal("an editor that overflowed was not marked lost") - } -} - -// The log is memory a member grows by typing, so it is bounded — and the -// answer to a full room is "everyone rebuild", not a silent truncation that -// would diverge every peer. -func TestCollabRoomIsBounded(t *testing.T) { - room := &collabRoom{subs: map[*subscriber]string{}} - big := make([]byte, 1<<20) - n := 0 - for room.post(big, nil) { - n++ - if n > maxRoomBytes/len(big)+2 { - t.Fatal("room accepted more than its byte cap") - } - } - if room.bytes > maxRoomBytes { - t.Fatalf("room holds %d bytes, cap is %d", room.bytes, maxRoomBytes) - } - room.reset() - if room.bytes != 0 || len(room.updates) != 0 { - t.Fatal("reset left the log behind") - } -} - -// An idle room is dropped; a room with someone in it never is. -func TestCollabIdleRoomsAreSwept(t *testing.T) { - h := &collabHub{rooms: map[string]*collabRoom{}} - stale := h.room("p\x00old.md") - stale.touched = time.Now().Add(-2 * roomIdle) - occupied := h.room("p\x00busy.md") - occupied.touched = time.Now().Add(-2 * roomIdle) - occupied.join(&subscriber{ch: make(chan []byte, 1)}) - - h.room("p\x00trigger.md") // any join runs the sweep - - h.mu.Lock() - defer h.mu.Unlock() - if _, ok := h.rooms["p\x00old.md"]; ok { - t.Error("an empty idle room was kept") - } - if _, ok := h.rooms["p\x00busy.md"]; !ok { - t.Error("a room with an editor in it was swept") - } -} - -// The path is a room key and comes from the caller. -func TestCollabRefusesAnUnsafePath(t *testing.T) { - srv, p, _ := newHub(t, true, nil) - h := srv.Handler() - for _, bad := range []string{"", "../../etc/passwd", "/abs"} { - rec := do(t, h, "POST", "/api/p/"+p.ID+"/collab?path="+bad, map[string]any{"update": "AAA="}) - if rec.Code != 400 { - t.Errorf("path %q: %d, want 400", bad, rec.Code) - } - } -} - -// The relay never interprets an update, but it must not accept an unbounded -// or malformed one either. -func TestCollabRejectsBadUpdates(t *testing.T) { - srv, p, _ := newHub(t, true, nil) - h := srv.Handler() - url := "/api/p/" + p.ID + "/collab?path=a.md" - for name, body := range map[string]any{ - "not base64": map[string]any{"update": "!!!not-base64!!!"}, - "empty": map[string]any{"update": ""}, - "oversized": map[string]any{"update": strings.Repeat("A", (maxUpdateBytes+64)*2)}, - } { - rec := do(t, h, "POST", url, body) - if rec.Code != 400 { - t.Errorf("%s: %d, want 400", name, rec.Code) - } - } -} - -// The claim must be released if the client that made it leaves without -// typing: otherwise the room stays claimed but empty, and the next joiner -// opens a blank document and snapshots that emptiness over a real file. -func TestCollabSeedClaimIsReleasedByAnEditorWhoNeverTyped(t *testing.T) { - room := &collabRoom{subs: map[*subscriber]string{}} - a := &subscriber{ch: make(chan []byte, 1)} - if _, first := room.join(a); !first { - t.Fatal("first joiner should seed") - } - room.leave(a) // opened the file, typed nothing, closed it - - b := &subscriber{ch: make(chan []byte, 1)} - if _, first := room.join(b); !first { - t.Fatal("after an empty room is abandoned the next joiner must seed") - } -} - -// But a room that HAS content stays claimed, so a joiner rebuilds from the -// log rather than seeding a second document over it. -func TestCollabSeedClaimSurvivesWhenTheLogHasContent(t *testing.T) { - room := &collabRoom{subs: map[*subscriber]string{}} - a := &subscriber{ch: make(chan []byte, 4)} - room.join(a) - room.post([]byte("typed something"), a) - room.leave(a) - - b := &subscriber{ch: make(chan []byte, 4)} - log, first := room.join(b) - if first { - t.Fatal("a room with a log must not be re-seeded") - } - if len(log) != 1 { - t.Fatalf("log = %v, want the one update", log) - } -} - -func TestCollabStreamSetsEventStreamHeaders(t *testing.T) { - srv, p, _ := newHub(t, true, nil) - ts := httptest.NewServer(srv.Handler()) - defer ts.Close() - resp, err := http.Get(ts.URL + "/api/p/" + p.ID + "/collab?path=a.md") - if err != nil { - t.Fatal(err) - } - defer resp.Body.Close() - if resp.StatusCode != 200 { - t.Fatalf("collab stream: %d", resp.StatusCode) - } - if ct := resp.Header.Get("Content-Type"); ct != "text/event-stream" { - t.Fatalf("content-type = %q", ct) - } -} diff --git a/internal/webapp/frontend/e2e/concurrent-edit.spec.ts b/internal/webapp/frontend/e2e/concurrent-edit.spec.ts index 892eb56..25dba8d 100644 --- a/internal/webapp/frontend/e2e/concurrent-edit.spec.ts +++ b/internal/webapp/frontend/e2e/concurrent-edit.spec.ts @@ -1,18 +1,25 @@ import { test, expect, Page } from "@playwright/test"; import { login, ADMIN, MEMBER } from "./helpers"; -/* Two people editing one file, and one of them cannot reach the relay. - - The co-editing CRDT makes concurrent typing merge — while the room works. - When a client loses the relay (a dropped EventSource, a laptop changing - networks) it falls back to single-writer editing over its OWN buffer, and - until this suite existed the two browsers simply took turns overwriting - each other through upload/content: no conflict copy, no warning, work - gone. A real history feed showed it as versions alternating between two - sizes, several times a minute. - - The guarantee asserted here is the one the sync path has always made: - whichever version loses is preserved beside the winner, never dropped. */ +/* Two people editing one file at the same time. + + This spec was written against the relay, where a client that lost its + connection fell back to editing its OWN buffer — so two browsers held two + documents and took turns overwriting each other through upload/content: no + conflict copy, no warning, work gone. A real history feed showed it as + versions alternating between two sizes several times a minute, and the fix + at the time was to preserve the loser beside the winner. + + The hub holds the document now, so there is no second document to diverge + into and nothing to preserve: concurrent typing CONVERGES. That is the + stronger guarantee, and this asserts it directly — every character both + people typed is in the file, and no conflict copy was needed to get it + there. + + The conflict-copy machinery has not gone anywhere. It protects the file + from writers that never touch a CRDT at all — an agent, the CLI, a device + syncing — and internal/webapp/upload_ifmatch_test.go is where that lives + now. */ const PROJECT = "zz-concurrent-edit"; let projectId = ""; @@ -42,7 +49,7 @@ test.afterAll(async ({ browser }) => { projectId = ""; }); -test("a relay-less editor cannot overwrite a teammate's work", async ({ browser }) => { +test("two editors of one file converge instead of overwriting", async ({ browser }) => { test.setTimeout(90_000); const a = await (await browser.newContext()).newPage(); await login(a, ADMIN); @@ -55,9 +62,6 @@ test("a relay-less editor cannot overwrite a teammate's work", async ({ browser const b = await (await browser.newContext()).newPage(); await login(b, MEMBER); - // B never reaches the relay — what a dropped EventSource leaves behind once - // it stops retrying. B is now editing its own buffer, alone. - await b.route("**/collab*", (route) => route.abort()); for (const pg of [a, b]) { await pg.goto(`/${id}/edit/${file}`); @@ -84,19 +88,17 @@ test("a relay-less editor cannot overwrite a teammate's work", async ({ browser const paths: string[] = [ ...new Set(feed.entries.map((e: { path: string }) => e.path)), ]; - const copy = paths.find((p) => p.includes(".bdrive-conflict-")); - expect(copy, `no conflict copy was written; paths: ${paths.join(", ")}`).toBeTruthy(); - - // Neither version was dropped: one is the file, the other is beside it. - const both = (await read(file)) + "\n" + (await read(copy!)); - expect(both).toContain("AAAAAA"); - expect(both).toContain("BBBBBB"); - - // And the copy is named the way the sync path names one, so the reader - // meets the same explanation wherever it came from (lib/conflict.ts). - expect(copy).toMatch( - new RegExp(`^${file}\\.bdrive-conflict-[A-Za-z0-9_-]{0,32}-\\d{8}T\\d{6}Z$`), - ); + + // Everything both people typed is in THE FILE. Not split across a winner + // and a conflict copy — in one document, which is what a shared document + // is for. + const text = await read(file); + expect(text, `A's characters are missing from ${file}`).toContain("AAAAAA"); + expect(text, `B's characters are missing from ${file}`).toContain("BBBBBB"); + + // And nothing had to be parked to achieve it. + const copies = paths.filter((p) => p.includes(".bdrive-conflict-")); + expect(copies, `converged text still produced ${copies.join(", ")}`).toHaveLength(0); }); /* The ordinary case must stay ordinary: one person editing alone keeps diff --git a/internal/webapp/frontend/src/api/types.ts b/internal/webapp/frontend/src/api/types.ts index 3d2ebff..9c0876e 100644 --- a/internal/webapp/frontend/src/api/types.ts +++ b/internal/webapp/frontend/src/api/types.ts @@ -18,12 +18,6 @@ export interface ServerConfig { admin?: boolean; }; reads: { enabled: boolean }; - /* Whether this hub HOLDS the co-editing document or only relays frames - between browsers. Not inferable from the client: a hub too old to serve - the route and a proxy that refuses to upgrade a websocket fail the same - way, and guessing wrong means either an editor waiting for a document - nobody will send, or two clients seeding two documents of one file. */ - collab?: { held: boolean }; // The BearDrive Desktop sidecar (`bdrive desktop`): a loopback server over // this machine's own mounts. Projects report perm "read" (local state is // never written through the viewer), but hub-backed surfaces — heat, diff --git a/internal/webapp/frontend/src/components/Editor.tsx b/internal/webapp/frontend/src/components/Editor.tsx index 829d33a..583c72e 100644 --- a/internal/webapp/frontend/src/components/Editor.tsx +++ b/internal/webapp/frontend/src/components/Editor.tsx @@ -19,7 +19,6 @@ import { } from "@codemirror/language"; import { yCollab } from "y-codemirror.next"; import { type CollabStatus } from "../lib/collab"; -import { useConfig } from "../hooks/useConfig"; import { openSharedFile, SAVE_IDLE_MS, @@ -87,7 +86,6 @@ export function Editor({ // tell a co-editor's snapshot from an outside write. onPeers?: (n: number) => void; }) { - const { data: config } = useConfig(); const host = useRef(null); const timer = useRef | null>(null); @@ -204,7 +202,6 @@ export function Editor({ apiBase, path, seed: seed.current, - held: !!config?.collab?.held, baseSha: shaRef.current, who: meRef.current?.name, me: meRef.current, diff --git a/internal/webapp/frontend/src/components/VisualEdit.tsx b/internal/webapp/frontend/src/components/VisualEdit.tsx index 7548d27..172469c 100644 --- a/internal/webapp/frontend/src/components/VisualEdit.tsx +++ b/internal/webapp/frontend/src/components/VisualEdit.tsx @@ -2,7 +2,6 @@ import { useEffect, useRef, useState } from "react"; import * as Y from "yjs"; import { openSharedFile, type SaveState } from "../lib/sharedfile"; import { type CollabStatus } from "../lib/collab"; -import { useConfig } from "../hooks/useConfig"; /* Click-to-edit for a synced HTML file: the app's half. @@ -80,7 +79,6 @@ export function VisualEdit({ onWriting?: () => void; onRendered?: () => void; }) { - const { data: config } = useConfig(); const frame = useRef(null); const [warning, setWarning] = useState(null); /* Whether clicks will actually do anything yet. @@ -145,7 +143,6 @@ export function VisualEdit({ apiBase, path, seed: seed.current, - held: !!config?.collab?.held, baseSha: shaRef.current, who: meRef.current?.name, me: meRef.current, diff --git a/internal/webapp/frontend/src/lib/collab.ts b/internal/webapp/frontend/src/lib/collab.ts index 83dfe4e..832637e 100644 --- a/internal/webapp/frontend/src/lib/collab.ts +++ b/internal/webapp/frontend/src/lib/collab.ts @@ -1,96 +1,50 @@ import * as Y from "yjs"; import { WebsocketProvider } from "y-websocket"; -import { - Awareness, - applyAwarenessUpdate, - encodeAwarenessUpdate, -} from "y-protocols/awareness"; +import { Awareness } from "y-protocols/awareness"; -/* A Yjs provider over the hub's collab relay. +/* A Yjs document, held by the hub. - Not y-websocket: the transport is the same SSE-down / POST-up pair the rest - of the app already uses, which needs no new server dependency, no upgrade - handshake, and nothing special from a proxy that already carries /events. - Typing latency is one POST, batched — for a document that is well inside - what a person notices. + This file used to be a hand-rolled provider: SSE down, POST up, and ~250 + lines of machinery that existed because nobody owned the document. A seed + CLAIM with a grace timer, because two clients seeding one file build two + documents that duplicate every character on merge. A byte cap on a log that + only grows, and a rebuild-from-scratch when it was hit. A resync frame for + a reader that fell behind. A solo fallback that let a client edit its own + buffer and then overwrite everyone else's work. - The hub never parses these bytes. It stores them in arrival order and hands - the log to whoever joins next, which is all a Yjs peer needs to converge. + All of it was compensation for a missing owner, and the hub is the owner + now (webapp/ycollab.go): it builds the document from the file before anyone + attaches, holds the one copy everybody converges on, and writes it back. + So the compensations are not disabled, they are gone — and what is left is + a provider somebody else maintains, doing a state-vector handshake on + reconnect instead of replaying a room's entire history. - The one rule that matters: a Yjs document seeded independently by two - clients from the same text is NOT the same document — the items carry - different ids and a merge duplicates every character. So only the client the - hub calls `seed` builds from the file; everyone else builds from the log. */ + What remains here is the shape the editors already expect (`text`, + `awareness`, `peerCount`, `connect`, `destroy`), so swapping the transport + underneath them changed almost nothing above. */ export type CollabStatus = "connecting" | "live" | "offline"; -/* Updates are coalesced into one POST per tick. Long enough to batch a burst - of keystrokes, short enough that a watcher sees you type. - - 120ms, not 60: at 60 a fast typist put ~16 POSTs a second on the wire, and - nobody can see the difference between a caret that lags 60ms and one that - lags 120. This is the uplink's whole cost model — the stream only carries - the DOWNlink, so every byte this client produces leaves as an HTTP request - (see docs/collab-provider-prd.md, where that is the argument for replacing - the transport rather than tuning it). */ -const FLUSH_MS = 120; - -/* Cursor moves are coalesced harder, and not sent at all when nobody is - looking. - - A caret is a courtesy; the document is the point. Every arrow key used to - be its own POST — holding one down is a request per repeat, and moving - around a file you are editing ALONE spent a request per keypress drawing a - caret for nobody. Nothing downstream can tell 5 updates a second from 16. */ -const CURSOR_MS = 200; - export class CollabDoc { readonly doc = new Y.Doc(); readonly text: Y.Text; readonly awareness: Awareness; - private es: EventSource | null = null; - private pending: Uint8Array[] = []; - private timer: ReturnType | null = null; - private closed = false; - private cursorTimer: ReturnType | null = null; - // Whether a POST of document updates is in flight. See flush(). - private sending = false; - // Whether this client has ever said it is here. Until it has, staying quiet - // would make it invisible rather than cheap. - private announced = false; - // Whether a `hello` has ever arrived. Distinguishes a dropped connection - // (retry, keep the document) from a relay that does not exist (give up on - // co-editing and let the editor open solo). - private everConnected = false; - // Updates that came FROM the relay must not be echoed back to it. - private applying = false; - // Identifies this stream to the relay, so our own updates and cursor moves - // are not mailed back to us. Sent on the stream URL and on every POST; the - // relay treats an unknown id as "no sender" and fans out to everyone, which - // is what an older hub does anyway. - private readonly cid = - globalThis.crypto?.randomUUID?.() ?? String(Math.random()).slice(2); - // Set when the HUB holds this document (ycollab.go). Then none of the - // relay machinery below runs: no seed claim, no log to replay, no resync - // frame, no solo fallback — the provider does the sync protocol and the - // server is the one copy everybody converges on. private ws: WebsocketProvider | null = null; + private closed = false; constructor( private readonly url: string, - private readonly seedText: string, private readonly onStatus: (s: CollabStatus) => void, - private readonly onSeeded: () => void, - // Called when the relay turns out not to be reachable at all, so the - // caller can fall back to plain single-writer editing. + private readonly onReady: () => void, + // Called when the document cannot be reached at all — an older hub with + // no such route, or a proxy that will not upgrade a websocket. The editor + // still opens and still saves; what it loses is LIVE collaboration, not + // the ability to write. That is deliberately not a second CRDT path: a + // client editing its own copy of a shared document is how two browsers + // came to overwrite each other. private readonly onUnavailable: () => void, private readonly me?: { name: string; colour: string }, - // Whether the HUB holds this document (/api/config collab.held). Not - // sniffed: a hub too old to serve the route and a proxy that refuses the - // upgrade fail identically, and guessing wrong means an editor waiting - // for a document nobody will send. - private readonly held = false, ) { this.text = this.doc.getText("body"); this.awareness = new Awareness(this.doc); @@ -104,233 +58,45 @@ export class CollabDoc { colorLight: this.me.colour + "33", }); } - this.awareness.on("update", this.onAwareness); - this.doc.on("update", (u: Uint8Array) => { - // When the hub holds the document the provider IS the transport: it - // sends updates over the socket and answers sync step 1 with state - // vectors. Queueing them for the relay's POST as well would be the - // same bytes twice, at a route that only serves GET — which is what - // the 405s in the console were. - if (this.held || this.applying) return; - this.pending.push(u); - if (!this.timer) this.timer = setTimeout(() => this.flush(), FLUSH_MS); - }); } - // Awareness is relayed, never logged: it says where a caret is this second, - // so a joiner replaying it would get cursors for people who have gone home. - private onAwareness = ({ - added, - updated, - removed, - }: { - added: number[]; - updated: number[]; - removed: number[]; - }) => { - const changed = added.concat(updated, removed); - if (!changed.length || this.closed) return; - // Only our own state is ours to publish. The rest of `changed` is what - // just arrived FROM the relay, and re-broadcasting it sends every peer's - // caret back to every peer — the relay already fans out to everyone. - if (!changed.includes(this.doc.clientID)) return; - if (this.cursorTimer) return; // one POST per window, carrying the latest - this.cursorTimer = setTimeout(() => { - this.cursorTimer = null; - this.publishAwareness(); - }, CURSOR_MS); - }; - - /* Publish where this client's caret is. - - `force` is for the two moments that are about existence rather than - position: the first announcement, and a new arrival. Awareness is relayed - and never logged (a joiner replaying it would get cursors for people who - have gone home), so our announcement is lost to anyone who shows up after - it — if both clients stayed quiet while they each believed they were - alone, two people in one document would never discover each other. */ - private publishAwareness(force = false) { - // Same reason as the doc updates above: y-websocket carries awareness on - // the socket, so the relay's POST is both redundant and a 405. - if (this.closed || this.held) return; - if (!force && this.announced && this.awareness.getStates().size <= 1) return; - this.announced = true; - const update = encodeAwarenessUpdate(this.awareness, [this.doc.clientID]); - void fetch(this.url, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ awareness: bytesToB64(update), cid: this.cid }), - }).catch(() => { - // A lost cursor position corrects itself on the next keystroke. - }); - } - - /* The hub holds the document. - - y-websocket rather than the hand-rolled SSE-down/POST-up provider below, - and rather than @hocuspocus/provider which the plan named: ygo speaks - y-websocket natively and Hocuspocus only behind a server flag, so this is - one fewer thing that has to agree. What it buys is the part that was - hand-rolled badly — a state-vector handshake instead of replaying the - whole room log on every reconnect, and backoff that is somebody else's - problem. - - Nothing seeds here. The server built the document from the file before - anyone attached (fileSeed.LoadDoc), which is what makes the seed claim, - its grace timer, and the blank-document failure it papered over all - unnecessary. */ - private connectHeld() { + connect() { + this.onStatus("connecting"); const u = new URL(this.url, location.href); const path = u.searchParams.get("path") ?? ""; const base = (u.protocol === "https:" ? "wss://" : "ws://") + u.host + u.pathname; - // The room argument is decoration: the hub names the room itself from - // (project, path) after it has resolved who is asking, because a caller - // who could name it could join any project's document by asking for it. + + /* The room argument is decoration. + + y-websocket appends it to the URL, but the hub names the room itself + from (project, path) after it has resolved who is asking — because a + caller who could name the room could join any project's document by + asking for its name. */ const provider = new WebsocketProvider(base, "held", this.doc, { params: { path }, awareness: this.awareness, connect: true, }); this.ws = provider; + provider.on("status", (e: { status: string }) => { + if (this.closed) return; this.onStatus(e.status === "connected" ? "live" : "offline"); }); provider.on("sync", (synced: boolean) => { // "Synced" is the document having arrived, which is the moment the - // editor may mount on it — the same moment the relay signalled with - // its `hello`. - if (synced) this.onSeeded(); + // editor may mount on it. Nothing is seeded here: the hub built it from + // the file before this client existed. + if (synced && !this.closed) this.onReady(); }); - } - - connect() { - this.onStatus("connecting"); - if (this.held) return this.connectHeld(); - const es = new EventSource( - this.url + (this.url.includes("?") ? "&" : "?") + "cid=" + this.cid, - ); - this.es = es; - es.onmessage = (e) => { - let f: { - type: string; - seed?: boolean; - log?: string[]; - update?: string; - awareness?: string; - }; - try { - f = JSON.parse(e.data); - } catch { - return; - } - if (f.type === "hello") { - this.everConnected = true; - this.applying = true; - try { - for (const u of f.log ?? []) Y.applyUpdate(this.doc, b64ToBytes(u)); - } finally { - this.applying = false; - } - // Empty room: somebody has to put the file's text into the document, - // and the hub picked us. Done OUTSIDE `applying` so it is broadcast. - if (f.seed && this.text.length === 0 && this.seedText) { - this.text.insert(0, this.seedText); - } - this.onSeeded(); - this.onStatus("live"); - return; - } - if (f.type === "update" && f.update) { - this.applying = true; - try { - Y.applyUpdate(this.doc, b64ToBytes(f.update)); - } finally { - this.applying = false; - } - return; - } - if (f.type === "awareness" && f.awareness) { - const before = this.awareness.getStates().size; - applyAwarenessUpdate(this.awareness, b64ToBytes(f.awareness), this); - // Somebody new. They cannot have heard our announcement — it went out - // before they arrived and nothing replays it — so answer with one. - if (this.awareness.getStates().size > before) this.publishAwareness(true); - return; - } - if (f.type === "resync") { - // We missed updates, so this document is no longer trustworthy. - // Reconnecting re-reads the whole log. - this.reconnect(); - } - }; - es.onerror = () => { - this.onStatus("offline"); - // EventSource retries on its own. But if it has never once connected, - // the relay is not there at all — an older hub with no such route, or a - // 403 — and something has to let the editor open anyway, or the caller - // waits forever for a `hello` that is not coming. - if (!this.everConnected) this.onUnavailable(); - }; - } - - private reconnect() { - this.es?.close(); - if (this.closed) return; - // A fresh doc, or the replayed log would merge into the one we have and - // double every character it already contains. - this.connect(); - } - - /* One POST in flight at a time. - - `timer` was cleared before the await, so a keystroke landing mid-request - armed a SECOND flush that started while the first was still going: fast - typing put several POSTs on the wire at once, each with its own headers, - cookie and round trip. - - Serialized, not cancelled. Yjs updates are DELTAS — dropping one in - flight deletes those keystrokes from every peer and silently diverges the - document — so anything typed during a send is merged into the next one - instead. (A cursor position is the opposite kind of value, which is why - publishAwareness coalesces to the latest and this does not.) */ - private async flush() { - this.timer = null; - if (this.sending || !this.pending.length || this.closed) return; - this.sending = true; - const merged = Y.mergeUpdates(this.pending); - this.pending = []; - let failed = false; - try { - const res = await fetch(this.url, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ update: bytesToB64(merged), cid: this.cid }), - }); - if (res.ok) { - const out = await res.json().catch(() => ({})); - // The room filled up and was emptied: everyone rebuilds from the file - // the snapshotter just wrote. - if (out.full) this.reconnect(); - } - } catch { - // Put it back: an update that never reached the relay is an edit no - // peer will ever see, which is worse than sending it twice (Yjs - // updates are idempotent). - this.pending.unshift(merged); - this.onStatus("offline"); - failed = true; - } finally { - this.sending = false; - // Whatever was typed while that request was in flight, as one more - // request rather than one per keystroke. Deliberately not armed on the - // failure path: a dead relay would turn into a POST every 120ms, and a - // failed update already waits for the next keystroke the way it always - // has. - if (!this.closed && !this.timer && this.pending.length && !failed) { - this.timer = setTimeout(() => this.flush(), FLUSH_MS); - } - } + /* A connection that never succeeds has to be reported, or the editor + waits forever for a document that is not coming. y-websocket retries on + its own — which is right, a flaky network should heal — so this asks + only once, well past the first few attempts. */ + setTimeout(() => { + if (!this.closed && !provider.synced) this.onUnavailable(); + }, UNREACHABLE_MS); } /* How many OTHER editors are in this document right now, from awareness. @@ -346,24 +112,12 @@ export class CollabDoc { this.closed = true; this.ws?.destroy(); this.ws = null; - this.awareness.off("update", this.onAwareness); - if (this.timer) clearTimeout(this.timer); - if (this.cursorTimer) clearTimeout(this.cursorTimer); - this.es?.close(); this.awareness.destroy(); this.doc.destroy(); } } -function b64ToBytes(s: string): Uint8Array { - const bin = atob(s); - const out = new Uint8Array(bin.length); - for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i); - return out; -} - -function bytesToB64(b: Uint8Array): string { - let s = ""; - for (let i = 0; i < b.length; i++) s += String.fromCharCode(b[i]); - return btoa(s); -} +// How long to let the provider retry before telling the caller the document +// is unreachable. Long enough to cover a reconnect on a bad network, short +// enough that a hub without the route does not leave an editor waiting. +const UNREACHABLE_MS = 8_000; diff --git a/internal/webapp/frontend/src/lib/sharedfile.ts b/internal/webapp/frontend/src/lib/sharedfile.ts index cfd0825..94882dd 100644 --- a/internal/webapp/frontend/src/lib/sharedfile.ts +++ b/internal/webapp/frontend/src/lib/sharedfile.ts @@ -59,16 +59,16 @@ export function openSharedFile(opts: { /** Names this client in a conflict copy's filename, the way a device id does on the sync path. */ who?: string; - /** Whether the hub holds the document rather than relaying frames. */ - held?: boolean; /** A concurrent edit could not be merged, so this client's version was preserved beside the file instead of being dropped. */ onConflictCopy?: (path: string) => void; me?: { name: string; colour: string }; - /** The relay answered: the shared document is live and holds the truth. */ + /** The document arrived: it is live and holds the truth. */ onReady: (collab: CollabDoc) => void; - /** No relay at all — an older hub, or a desktop build that does not proxy - the route. The caller falls back to single-writer editing. */ + /** The document could not be reached — an older hub, or a proxy that will + not upgrade a websocket. The caller falls back to single-writer editing: + the editor still opens and still saves, it just has no live + collaboration. Deliberately NOT a second CRDT path. */ onSolo: () => void; onState?: (s: SaveState) => void; onCollab?: (s: CollabStatus) => void; @@ -181,19 +181,11 @@ export function openSharedFile(opts: { }; const collab = new CollabDoc( - // Two different surfaces, named apart rather than one route that behaves - // two ways: ycollab is the hub-held document over a websocket, collab is - // the SSE-down/POST-up relay it will replace. - opts.apiBase + - (opts.held ? "ycollab" : "collab") + - "?path=" + - encodeURIComponent(opts.path), - opts.seed, + opts.apiBase + "ycollab?path=" + encodeURIComponent(opts.path), (s) => opts.onCollab?.(s), () => opts.onReady(collab), () => opts.onSolo(), opts.me, - opts.held, ); // Any change to the shared document — mine or a peer's — restarts the idle diff --git a/internal/webapp/server.go b/internal/webapp/server.go index 6b63c6a..331e6ed 100644 --- a/internal/webapp/server.go +++ b/internal/webapp/server.go @@ -191,8 +191,6 @@ type Server struct { presOnce sync.Once pres *presenceHub // who is looking at what (presence.go) - colOnce sync.Once - col *collabHub // per-document editing relay (collab.go) resMu sync.Mutex grants []grant // outstanding presigned upload reservations (reserve.go) @@ -948,13 +946,11 @@ func (s *Server) Handler() http.Handler { mux.HandleFunc("POST "+prefix+"presence", resolve(PermRead, s.handlePresence)) // Co-editing is a write channel: a read-only member has nothing to // send on it, so both halves need write rather than read. - mux.HandleFunc("GET "+prefix+"collab", resolve(PermWrite, s.handleCollabStream)) - mux.HandleFunc("POST "+prefix+"collab", resolve(PermWrite, s.handleCollabPost)) - // The hub-held document (ycollab.go), beside the relay rather than - // instead of it: PermRead, because a read-only member may OPEN a file - // and watch it being edited — the connection itself is marked - // read-only and their writes are dropped server-side. The relay's - // PermWrite is the older, coarser answer to the same question. + // The co-editing document (ycollab.go). PermRead, because a read-only + // member may OPEN a file and watch it being edited — the connection + // itself is marked read-only and their writes are dropped + // server-side. The relay this replaced asked for PermWrite, which was + // the older and coarser answer to the same question. mux.HandleFunc("GET "+prefix+"ycollab", resolve(PermRead, s.handleYCollab)) // y-websocket appends its room argument to the URL, so the request // arrives one segment deeper. The segment is DECORATION — handleYCollab @@ -1203,13 +1199,6 @@ func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) { }, "auth": auth, "reads": map[string]any{"enabled": s.Reads != nil || s.Desktop}, - // Whether this hub HOLDS the co-editing document (ycollab.go) or only - // relays frames between browsers (collab.go). The client cannot infer - // it: a missing route and a proxy that will not upgrade a websocket - // fail the same way, and guessing wrong means either an editor that - // waits for a document nobody is going to send, or two clients - // seeding two documents of one file. The hub knows, so it says. - "collab": map[string]any{"held": s.Root != nil && s.Projects != nil}, // The starting structures the create dialog offers. Served rather // than hardcoded in the frontend so a hub that ships another one // needs no frontend change. diff --git a/internal/webapp/static/assets/index-BNwF_DU_.js b/internal/webapp/static/assets/index-BNwF_DU_.js deleted file mode 100644 index d1fcc62..0000000 --- a/internal/webapp/static/assets/index-BNwF_DU_.js +++ /dev/null @@ -1,152 +0,0 @@ -import{g as XA}from"./_commonjsHelpers-CqkleIqs.js";import{h as WI,r as KI}from"./mermaid-DQuCJ8Gi.js";function JI(t,e){for(var n=0;ni[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();var Nv={exports:{}},qd={};var XT;function eX(){if(XT)return qd;XT=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(i,r,s){var o=null;if(s!==void 0&&(o=""+s),r.key!==void 0&&(o=""+r.key),"key"in r){s={};for(var l in r)l!=="key"&&(s[l]=r[l])}else s=r;return r=s.ref,{$$typeof:t,type:i,key:o,ref:r!==void 0?r:null,props:s}}return qd.Fragment=e,qd.jsx=n,qd.jsxs=n,qd}var VT;function tX(){return VT||(VT=1,Nv.exports=eX()),Nv.exports}var m=tX(),zv={exports:{}},Je={};var BT;function nX(){if(BT)return Je;BT=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),O=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=O&&D[O]||D["@@iterator"],typeof D=="function"?D:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,k={};function C(D,P,I){this.props=D,this.context=P,this.refs=k,this.updater=I||v}C.prototype.isReactComponent={},C.prototype.setState=function(D,P){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,P,"setState")},C.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function $(){}$.prototype=C.prototype;function T(D,P,I){this.props=D,this.context=P,this.refs=k,this.updater=I||v}var Q=T.prototype=new $;Q.constructor=T,S(Q,C.prototype),Q.isPureReactComponent=!0;var A=Array.isArray;function R(){}var j={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function ne(D,P,I){var X=I.ref;return{$$typeof:t,type:D,key:P,ref:X!==void 0?X:null,props:I}}function G(D,P){return ne(D.type,P,D.props)}function H(D){return typeof D=="object"&&D!==null&&D.$$typeof===t}function Y(D){var P={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(I){return P[I]})}var re=/\/+/g;function K(D,P){return typeof D=="object"&&D!==null&&D.key!=null?Y(""+D.key):P.toString(36)}function ye(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(R,R):(D.status="pending",D.then(function(P){D.status==="pending"&&(D.status="fulfilled",D.value=P)},function(P){D.status==="pending"&&(D.status="rejected",D.reason=P)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function N(D,P,I,X,V){var J=typeof D;(J==="undefined"||J==="boolean")&&(D=null);var se=!1;if(D===null)se=!0;else switch(J){case"bigint":case"string":case"number":se=!0;break;case"object":switch(D.$$typeof){case t:case e:se=!0;break;case h:return se=D._init,N(se(D._payload),P,I,X,V)}}if(se)return V=V(D),se=X===""?"."+K(D,0):X,A(V)?(I="",se!=null&&(I=se.replace(re,"$&/")+"/"),N(V,P,I,"",function(Ze){return Ze})):V!=null&&(H(V)&&(V=G(V,I+(V.key==null||D&&D.key===V.key?"":(""+V.key).replace(re,"$&/")+"/")+se)),P.push(V)),1;se=0;var pe=X===""?".":X+":";if(A(D))for(var xe=0;xe>>1,le=N[oe];if(0>>1;oer(I,ce))Xr(V,I)?(N[oe]=V,N[X]=ce,oe=X):(N[oe]=I,N[P]=ce,oe=P);else if(Xr(V,ce))N[oe]=V,N[X]=ce,oe=X;else break e}}return W}function r(N,W){var ce=N.sortIndex-W.sortIndex;return ce!==0?ce:N.id-W.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var u=[],f=[],h=1,p=null,O=3,y=!1,v=!1,S=!1,k=!1,C=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function Q(N){for(var W=n(f);W!==null;){if(W.callback===null)i(f);else if(W.startTime<=N)i(f),W.sortIndex=W.expirationTime,e(u,W);else break;W=n(f)}}function A(N){if(S=!1,Q(N),!v)if(n(u)!==null)v=!0,R||(R=!0,Y());else{var W=n(f);W!==null&&ye(A,W.startTime-N)}}var R=!1,j=-1,L=5,ne=-1;function G(){return k?!0:!(t.unstable_now()-neN&&G());){var oe=p.callback;if(typeof oe=="function"){p.callback=null,O=p.priorityLevel;var le=oe(p.expirationTime<=N);if(N=t.unstable_now(),typeof le=="function"){p.callback=le,Q(N),W=!0;break t}p===n(u)&&i(u),Q(N)}else i(u);p=n(u)}if(p!==null)W=!0;else{var D=n(f);D!==null&&ye(A,D.startTime-N),W=!1}}break e}finally{p=null,O=ce,y=!1}W=void 0}}finally{W?Y():R=!1}}}var Y;if(typeof T=="function")Y=function(){T(H)};else if(typeof MessageChannel<"u"){var re=new MessageChannel,K=re.port2;re.port1.onmessage=H,Y=function(){K.postMessage(null)}}else Y=function(){C(H,0)};function ye(N,W){j=C(function(){N(t.unstable_now())},W)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(N){N.callback=null},t.unstable_forceFrameRate=function(N){0>N||125oe?(N.sortIndex=ce,e(f,N),n(u)===null&&N===n(f)&&(S?($(j),j=-1):S=!0,ye(A,ce-oe))):(N.sortIndex=le,e(u,N),v||y||(v=!0,R||(R=!0,Y()))),N},t.unstable_shouldYield=G,t.unstable_wrapCallback=function(N){var W=O;return function(){var ce=O;O=W;try{return N.apply(this,arguments)}finally{O=ce}}}})(Iv)),Iv}var YT;function rX(){return YT||(YT=1,Zv.exports=iX()),Zv.exports}var Xv={exports:{}},oi={};var FT;function sX(){if(FT)return oi;FT=1;var t=yw();function e(u){var f="https://react.dev/errors/"+u;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Xv.exports=sX(),Xv.exports}var HT;function oX(){if(HT)return Yd;HT=1;var t=rX(),e=yw(),n=VA();function i(a){var c="https://react.dev/errors/"+a;if(1le||(a.current=oe[le],oe[le]=null,le--)}function I(a,c){le++,oe[le]=a.current,a.current=c}var X=D(null),V=D(null),J=D(null),se=D(null);function pe(a,c){switch(I(J,c),I(V,a),I(X,null),c.nodeType){case 9:case 11:a=(a=c.documentElement)&&(a=a.namespaceURI)?dT(a):0;break;default:if(a=c.tagName,c=c.namespaceURI)c=dT(c),a=fT(c,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}P(X),I(X,a)}function xe(){P(X),P(V),P(J)}function Ze(a){a.memoizedState!==null&&I(se,a);var c=X.current,d=fT(c,a.type);c!==d&&(I(V,a),I(X,d))}function Xe(a){V.current===a&&(P(X),P(V)),se.current===a&&(P(se),Xd._currentValue=ce)}var Ge,Qt;function lt(a){if(Ge===void 0)try{throw Error()}catch(d){var c=d.stack.trim().match(/\n( *(at )?)/);Ge=c&&c[1]||"",Qt=-1)":-1b||z[g]!==te[b]){var ue=` -`+z[g].replace(" at new "," at ");return a.displayName&&ue.includes("")&&(ue=ue.replace("",a.displayName)),ue}while(1<=g&&0<=b);break}}}finally{ti=!1,Error.prepareStackTrace=d}return(d=a?a.displayName||a.name:"")?lt(d):""}function At(a,c){switch(a.tag){case 26:case 27:case 5:return lt(a.type);case 16:return lt("Lazy");case 13:return a.child!==c&&c!==null?lt("Suspense Fallback"):lt("Suspense");case 19:return lt("SuspenseList");case 0:case 15:return Oi(a.type,!1);case 11:return Oi(a.type.render,!1);case 1:return Oi(a.type,!0);case 31:return lt("Activity");default:return""}}function pr(a){try{var c="",d=null;do c+=At(a,d),d=a,a=a.return;while(a);return c}catch(g){return` -Error generating stack: `+g.message+` -`+g.stack}}var zn=Object.prototype.hasOwnProperty,gr=t.unstable_scheduleCallback,Ri=t.unstable_cancelCallback,sn=t.unstable_shouldYield,Yi=t.unstable_requestPaint,xn=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,mr=t.unstable_ImmediatePriority,qs=t.unstable_UserBlockingPriority,Fi=t.unstable_NormalPriority,jo=t.unstable_LowPriority,ii=t.unstable_IdlePriority,M=t.log,U=t.unstable_setDisableYieldValue,q=null,he=null;function me(a){if(typeof M=="function"&&U(a),he&&typeof he.setStrictMode=="function")try{he.setStrictMode(q,a)}catch{}}var Se=Math.clz32?Math.clz32:Ae,ke=Math.log,_e=Math.LN2;function Ae(a){return a>>>=0,a===0?32:31-(ke(a)/_e|0)|0}var dt=256,Zt=262144,on=4194304;function an(a){var c=a&42;if(c!==0)return c;switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function Ve(a,c,d){var g=a.pendingLanes;if(g===0)return 0;var b=0,x=a.suspendedLanes,_=a.pingedLanes;a=a.warmLanes;var E=g&134217727;return E!==0?(g=E&~x,g!==0?b=an(g):(_&=E,_!==0?b=an(_):d||(d=E&~a,d!==0&&(b=an(d))))):(E=g&~x,E!==0?b=an(E):_!==0?b=an(_):d||(d=g&~a,d!==0&&(b=an(d)))),b===0?0:c!==0&&c!==b&&(c&x)===0&&(x=b&-b,d=c&-c,x>=d||x===32&&(d&4194048)!==0)?c:b}function Ct(a,c){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&c)===0}function qt(a,c){switch(a){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32: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 c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ln(){var a=on;return on<<=1,(on&62914560)===0&&(on=4194304),a}function yi(a){for(var c=[],d=0;31>d;d++)c.push(a);return c}function It(a,c){a.pendingLanes|=c,c!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function ri(a,c,d,g,b,x){var _=a.pendingLanes;a.pendingLanes=d,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=d,a.entangledLanes&=d,a.errorRecoveryDisabledLanes&=d,a.shellSuspendCounter=0;var E=a.entanglements,z=a.expirationTimes,te=a.hiddenUpdates;for(d=_&~d;0"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var UZ=/[\n"\\]/g;function yr(a){return a.replace(UZ,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function Qy(a,c,d,g,b,x,_,E){a.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?a.type=_:a.removeAttribute("type"),c!=null?_==="number"?(c===0&&a.value===""||a.value!=c)&&(a.value=""+Or(c)):a.value!==""+Or(c)&&(a.value=""+Or(c)):_!=="submit"&&_!=="reset"||a.removeAttribute("value"),c!=null?Ay(a,_,Or(c)):d!=null?Ay(a,_,Or(d)):g!=null&&a.removeAttribute("value"),b==null&&x!=null&&(a.defaultChecked=!!x),b!=null&&(a.checked=b&&typeof b!="function"&&typeof b!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?a.name=""+Or(E):a.removeAttribute("name")}function sC(a,c,d,g,b,x,_,E){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(a.type=x),c!=null||d!=null){if(!(x!=="submit"&&x!=="reset"||c!=null)){Ry(a);return}d=d!=null?""+Or(d):"",c=c!=null?""+Or(c):d,E||c===a.value||(a.value=c),a.defaultValue=c}g=g??b,g=typeof g!="function"&&typeof g!="symbol"&&!!g,a.checked=E?a.checked:!!g,a.defaultChecked=!!g,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(a.name=_),Ry(a)}function Ay(a,c,d){c==="number"&&Uh(a.ownerDocument)===a||a.defaultValue===""+d||(a.defaultValue=""+d)}function ec(a,c,d,g){if(a=a.options,c){c={};for(var b=0;b"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ny=!1;if(Hs)try{var od={};Object.defineProperty(od,"passive",{get:function(){Ny=!0}}),window.addEventListener("test",od,od),window.removeEventListener("test",od,od)}catch{Ny=!1}var zo=null,zy=null,Yh=null;function fC(){if(Yh)return Yh;var a,c=zy,d=c.length,g,b="value"in zo?zo.value:zo.textContent,x=b.length;for(a=0;a=cd),yC=" ",vC=!1;function bC(a,c){switch(a){case"keyup":return v4.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function SC(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var rc=!1;function S4(a,c){switch(a){case"compositionend":return SC(c);case"keypress":return c.which!==32?null:(vC=!0,yC);case"textInput":return a=c.data,a===yC&&vC?null:a;default:return null}}function x4(a,c){if(rc)return a==="compositionend"||!Vy&&bC(a,c)?(a=fC(),Yh=zy=zo=null,rc=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1=c)return{node:d,offset:c-a};a=g}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=EC(d)}}function QC(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?QC(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function AC(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var c=Uh(a.document);c instanceof a.HTMLIFrameElement;){try{var d=typeof c.contentWindow.location.href=="string"}catch{d=!1}if(d)a=c.contentWindow;else break;c=Uh(a.document)}return c}function qy(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c&&(c==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||c==="textarea"||a.contentEditable==="true")}var R4=Hs&&"documentMode"in document&&11>=document.documentMode,sc=null,Yy=null,hd=null,Fy=!1;function PC(a,c,d){var g=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Fy||sc==null||sc!==Uh(g)||(g=sc,"selectionStart"in g&&qy(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),hd&&fd(hd,g)||(hd=g,g=Zp(Yy,"onSelect"),0>=_,b-=_,cs=1<<32-Se(c)+b|d<it?(ht=Me,Me=null):ht=Me.sibling;var bt=ie(F,Me,ee[it],de);if(bt===null){Me===null&&(Me=ht);break}a&&Me&&bt.alternate===null&&c(F,Me),B=x(bt,B,it),vt===null?Ie=bt:vt.sibling=bt,vt=bt,Me=ht}if(it===ee.length)return d(F,Me),pt&&Ks(F,it),Ie;if(Me===null){for(;itit?(ht=Me,Me=null):ht=Me.sibling;var oa=ie(F,Me,bt.value,de);if(oa===null){Me===null&&(Me=ht);break}a&&Me&&oa.alternate===null&&c(F,Me),B=x(oa,B,it),vt===null?Ie=oa:vt.sibling=oa,vt=oa,Me=ht}if(bt.done)return d(F,Me),pt&&Ks(F,it),Ie;if(Me===null){for(;!bt.done;it++,bt=ee.next())bt=fe(F,bt.value,de),bt!==null&&(B=x(bt,B,it),vt===null?Ie=bt:vt.sibling=bt,vt=bt);return pt&&Ks(F,it),Ie}for(Me=g(Me);!bt.done;it++,bt=ee.next())bt=ae(Me,F,it,bt.value,de),bt!==null&&(a&&bt.alternate!==null&&Me.delete(bt.key===null?it:bt.key),B=x(bt,B,it),vt===null?Ie=bt:vt.sibling=bt,vt=bt);return a&&Me.forEach(function(HI){return c(F,HI)}),pt&&Ks(F,it),Ie}function Dt(F,B,ee,de){if(typeof ee=="object"&&ee!==null&&ee.type===S&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case y:e:{for(var Ie=ee.key;B!==null;){if(B.key===Ie){if(Ie=ee.type,Ie===S){if(B.tag===7){d(F,B.sibling),de=b(B,ee.props.children),de.return=F,F=de;break e}}else if(B.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===L&&il(Ie)===B.type){d(F,B.sibling),de=b(B,ee.props),vd(de,ee),de.return=F,F=de;break e}d(F,B);break}else c(F,B);B=B.sibling}ee.type===S?(de=Ka(ee.props.children,F.mode,de,ee.key),de.return=F,F=de):(de=ip(ee.type,ee.key,ee.props,null,F.mode,de),vd(de,ee),de.return=F,F=de)}return _(F);case v:e:{for(Ie=ee.key;B!==null;){if(B.key===Ie)if(B.tag===4&&B.stateNode.containerInfo===ee.containerInfo&&B.stateNode.implementation===ee.implementation){d(F,B.sibling),de=b(B,ee.children||[]),de.return=F,F=de;break e}else{d(F,B);break}else c(F,B);B=B.sibling}de=t0(ee,F.mode,de),de.return=F,F=de}return _(F);case L:return ee=il(ee),Dt(F,B,ee,de)}if(ye(ee))return Qe(F,B,ee,de);if(Y(ee)){if(Ie=Y(ee),typeof Ie!="function")throw Error(i(150));return ee=Ie.call(ee),qe(F,B,ee,de)}if(typeof ee.then=="function")return Dt(F,B,up(ee),de);if(ee.$$typeof===T)return Dt(F,B,op(F,ee),de);dp(F,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,B!==null&&B.tag===6?(d(F,B.sibling),de=b(B,ee),de.return=F,F=de):(d(F,B),de=e0(ee,F.mode,de),de.return=F,F=de),_(F)):d(F,B)}return function(F,B,ee,de){try{yd=0;var Ie=Dt(F,B,ee,de);return mc=null,Ie}catch(Me){if(Me===gc||Me===lp)throw Me;var vt=Hi(29,Me,null,F.mode);return vt.lanes=de,vt.return=F,vt}}}var sl=n_(!0),i_=n_(!1),Vo=!1;function h0(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function p0(a,c){a=a.updateQueue,c.updateQueue===a&&(c.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function Bo(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function Uo(a,c,d){var g=a.updateQueue;if(g===null)return null;if(g=g.shared,(xt&2)!==0){var b=g.pending;return b===null?c.next=c:(c.next=b.next,b.next=c),g.pending=c,c=np(a),ZC(a,null,d),c}return tp(a,g,c,d),np(a)}function bd(a,c,d){if(c=c.updateQueue,c!==null&&(c=c.shared,(d&4194048)!==0)){var g=c.lanes;g&=a.pendingLanes,d|=g,c.lanes=d,Ln(a,d)}}function g0(a,c){var d=a.updateQueue,g=a.alternate;if(g!==null&&(g=g.updateQueue,d===g)){var b=null,x=null;if(d=d.firstBaseUpdate,d!==null){do{var _={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};x===null?b=x=_:x=x.next=_,d=d.next}while(d!==null);x===null?b=x=c:x=x.next=c}else b=x=c;d={baseState:g.baseState,firstBaseUpdate:b,lastBaseUpdate:x,shared:g.shared,callbacks:g.callbacks},a.updateQueue=d;return}a=d.lastBaseUpdate,a===null?d.firstBaseUpdate=c:a.next=c,d.lastBaseUpdate=c}var m0=!1;function Sd(){if(m0){var a=pc;if(a!==null)throw a}}function xd(a,c,d,g){m0=!1;var b=a.updateQueue;Vo=!1;var x=b.firstBaseUpdate,_=b.lastBaseUpdate,E=b.shared.pending;if(E!==null){b.shared.pending=null;var z=E,te=z.next;z.next=null,_===null?x=te:_.next=te,_=z;var ue=a.alternate;ue!==null&&(ue=ue.updateQueue,E=ue.lastBaseUpdate,E!==_&&(E===null?ue.firstBaseUpdate=te:E.next=te,ue.lastBaseUpdate=z))}if(x!==null){var fe=b.baseState;_=0,ue=te=z=null,E=x;do{var ie=E.lane&-536870913,ae=ie!==E.lane;if(ae?(ft&ie)===ie:(g&ie)===ie){ie!==0&&ie===hc&&(m0=!0),ue!==null&&(ue=ue.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Qe=a,qe=E;ie=c;var Dt=d;switch(qe.tag){case 1:if(Qe=qe.payload,typeof Qe=="function"){fe=Qe.call(Dt,fe,ie);break e}fe=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=qe.payload,ie=typeof Qe=="function"?Qe.call(Dt,fe,ie):Qe,ie==null)break e;fe=p({},fe,ie);break e;case 2:Vo=!0}}ie=E.callback,ie!==null&&(a.flags|=64,ae&&(a.flags|=8192),ae=b.callbacks,ae===null?b.callbacks=[ie]:ae.push(ie))}else ae={lane:ie,tag:E.tag,payload:E.payload,callback:E.callback,next:null},ue===null?(te=ue=ae,z=fe):ue=ue.next=ae,_|=ie;if(E=E.next,E===null){if(E=b.shared.pending,E===null)break;ae=E,E=ae.next,ae.next=null,b.lastBaseUpdate=ae,b.shared.pending=null}}while(!0);ue===null&&(z=fe),b.baseState=z,b.firstBaseUpdate=te,b.lastBaseUpdate=ue,x===null&&(b.shared.lanes=0),Ho|=_,a.lanes=_,a.memoizedState=fe}}function r_(a,c){if(typeof a!="function")throw Error(i(191,a));a.call(c)}function s_(a,c){var d=a.callbacks;if(d!==null)for(a.callbacks=null,a=0;ax?x:8;var _=N.T,E={};N.T=E,M0(a,!1,c,d);try{var z=b(),te=N.S;if(te!==null&&te(E,z),z!==null&&typeof z=="object"&&typeof z.then=="function"){var ue=L4(z,g);Cd(a,c,ue,tr(a))}else Cd(a,c,g,tr(a))}catch(fe){Cd(a,c,{then:function(){},status:"rejected",reason:fe},tr())}finally{W.p=x,_!==null&&E.types!==null&&(_.types=E.types),N.T=_}}function U4(){}function P0(a,c,d,g){if(a.tag!==5)throw Error(i(476));var b=N_(a).queue;D_(a,b,c,ce,d===null?U4:function(){return z_(a),d(g)})}function N_(a){var c=a.memoizedState;if(c!==null)return c;c={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:no,lastRenderedState:ce},next:null};var d={};return c.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:no,lastRenderedState:d},next:null},a.memoizedState=c,a=a.alternate,a!==null&&(a.memoizedState=c),c}function z_(a){var c=N_(a);c.next===null&&(c=a.alternate.memoizedState),Cd(a,c.next.queue,{},tr())}function j0(){return qn(Xd)}function L_(){return gn().memoizedState}function Z_(){return gn().memoizedState}function q4(a){for(var c=a.return;c!==null;){switch(c.tag){case 24:case 3:var d=tr();a=Bo(d);var g=Uo(c,a,d);g!==null&&(Ni(g,c,d),bd(g,c,d)),c={cache:c0()},a.payload=c;return}c=c.return}}function Y4(a,c,d){var g=tr();d={lane:g,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Sp(a)?X_(c,d):(d=Ky(a,c,d,g),d!==null&&(Ni(d,a,g),V_(d,c,g)))}function I_(a,c,d){var g=tr();Cd(a,c,d,g)}function Cd(a,c,d,g){var b={lane:g,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(Sp(a))X_(c,b);else{var x=a.alternate;if(a.lanes===0&&(x===null||x.lanes===0)&&(x=c.lastRenderedReducer,x!==null))try{var _=c.lastRenderedState,E=x(_,d);if(b.hasEagerState=!0,b.eagerState=E,Gi(E,_))return tp(a,c,b,0),Xt===null&&ep(),!1}catch{}if(d=Ky(a,c,b,g),d!==null)return Ni(d,a,g),V_(d,c,g),!0}return!1}function M0(a,c,d,g){if(g={lane:2,revertLane:hv(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},Sp(a)){if(c)throw Error(i(479))}else c=Ky(a,d,g,2),c!==null&&Ni(c,a,2)}function Sp(a){var c=a.alternate;return a===tt||c!==null&&c===tt}function X_(a,c){yc=pp=!0;var d=a.pending;d===null?c.next=c:(c.next=d.next,d.next=c),a.pending=c}function V_(a,c,d){if((d&4194048)!==0){var g=c.lanes;g&=a.pendingLanes,d|=g,c.lanes=d,Ln(a,d)}}var _d={readContext:qn,use:Op,useCallback:cn,useContext:cn,useEffect:cn,useImperativeHandle:cn,useLayoutEffect:cn,useInsertionEffect:cn,useMemo:cn,useReducer:cn,useRef:cn,useState:cn,useDebugValue:cn,useDeferredValue:cn,useTransition:cn,useSyncExternalStore:cn,useId:cn,useHostTransitionStatus:cn,useFormState:cn,useActionState:cn,useOptimistic:cn,useMemoCache:cn,useCacheRefresh:cn};_d.useEffectEvent=cn;var B_={readContext:qn,use:Op,useCallback:function(a,c){return bi().memoizedState=[a,c===void 0?null:c],a},useContext:qn,useEffect:$_,useImperativeHandle:function(a,c,d){d=d!=null?d.concat([a]):null,vp(4194308,4,Q_.bind(null,c,a),d)},useLayoutEffect:function(a,c){return vp(4194308,4,a,c)},useInsertionEffect:function(a,c){vp(4,2,a,c)},useMemo:function(a,c){var d=bi();c=c===void 0?null:c;var g=a();if(ol){me(!0);try{a()}finally{me(!1)}}return d.memoizedState=[g,c],g},useReducer:function(a,c,d){var g=bi();if(d!==void 0){var b=d(c);if(ol){me(!0);try{d(c)}finally{me(!1)}}}else b=c;return g.memoizedState=g.baseState=b,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:b},g.queue=a,a=a.dispatch=Y4.bind(null,tt,a),[g.memoizedState,a]},useRef:function(a){var c=bi();return a={current:a},c.memoizedState=a},useState:function(a){a=T0(a);var c=a.queue,d=I_.bind(null,tt,c);return c.dispatch=d,[a.memoizedState,d]},useDebugValue:Q0,useDeferredValue:function(a,c){var d=bi();return A0(d,a,c)},useTransition:function(){var a=T0(!1);return a=D_.bind(null,tt,a.queue,!0,!1),bi().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,c,d){var g=tt,b=bi();if(pt){if(d===void 0)throw Error(i(407));d=d()}else{if(d=c(),Xt===null)throw Error(i(349));(ft&127)!==0||d_(g,c,d)}b.memoizedState=d;var x={value:d,getSnapshot:c};return b.queue=x,$_(h_.bind(null,g,x,a),[a]),g.flags|=2048,bc(9,{destroy:void 0},f_.bind(null,g,x,d,c),null),d},useId:function(){var a=bi(),c=Xt.identifierPrefix;if(pt){var d=us,g=cs;d=(g&~(1<<32-Se(g)-1)).toString(32)+d,c="_"+c+"R_"+d,d=gp++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof g.is=="string"?_.createElement("select",{is:g.is}):_.createElement("select"),g.multiple?x.multiple=!0:g.size&&(x.size=g.size);break;default:x=typeof g.is=="string"?_.createElement(b,{is:g.is}):_.createElement(b)}}x[Rn]=c,x[Qn]=g;e:for(_=c.child;_!==null;){if(_.tag===5||_.tag===6)x.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===c)break e;for(;_.sibling===null;){if(_.return===null||_.return===c)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}c.stateNode=x;e:switch(Fn(x,b,g),b){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&ro(c)}}return Gt(c),G0(c,c.type,a===null?null:a.memoizedProps,c.pendingProps,d),null;case 6:if(a&&c.stateNode!=null)a.memoizedProps!==g&&ro(c);else{if(typeof g!="string"&&c.stateNode===null)throw Error(i(166));if(a=J.current,dc(c)){if(a=c.stateNode,d=c.memoizedProps,g=null,b=Un,b!==null)switch(b.tag){case 27:case 5:g=b.memoizedProps}a[Rn]=c,a=!!(a.nodeValue===d||g!==null&&g.suppressHydrationWarning===!0||cT(a.nodeValue,d)),a||Io(c,!0)}else a=Ip(a).createTextNode(g),a[Rn]=c,c.stateNode=a}return Gt(c),null;case 31:if(d=c.memoizedState,a===null||a.memoizedState!==null){if(g=dc(c),d!==null){if(a===null){if(!g)throw Error(i(318));if(a=c.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(i(557));a[Rn]=c}else Ja(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Gt(c),a=!1}else d=s0(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=d),a=!0;if(!a)return c.flags&256?(Ki(c),c):(Ki(c),null);if((c.flags&128)!==0)throw Error(i(558))}return Gt(c),null;case 13:if(g=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(b=dc(c),g!==null&&g.dehydrated!==null){if(a===null){if(!b)throw Error(i(318));if(b=c.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(i(317));b[Rn]=c}else Ja(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Gt(c),b=!1}else b=s0(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=b),b=!0;if(!b)return c.flags&256?(Ki(c),c):(Ki(c),null)}return Ki(c),(c.flags&128)!==0?(c.lanes=d,c):(d=g!==null,a=a!==null&&a.memoizedState!==null,d&&(g=c.child,b=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(b=g.alternate.memoizedState.cachePool.pool),x=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(x=g.memoizedState.cachePool.pool),x!==b&&(g.flags|=2048)),d!==a&&d&&(c.child.flags|=8192),_p(c,c.updateQueue),Gt(c),null);case 4:return xe(),a===null&&Ov(c.stateNode.containerInfo),Gt(c),null;case 10:return eo(c.type),Gt(c),null;case 19:if(P(pn),g=c.memoizedState,g===null)return Gt(c),null;if(b=(c.flags&128)!==0,x=g.rendering,x===null)if(b)Td(g,!1);else{if(un!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(x=hp(a),x!==null){for(c.flags|=128,Td(g,!1),a=x.updateQueue,c.updateQueue=a,_p(c,a),c.subtreeFlags=0,a=d,d=c.child;d!==null;)IC(d,a),d=d.sibling;return I(pn,pn.current&1|2),pt&&Ks(c,g.treeForkCount),c.child}a=a.sibling}g.tail!==null&&xn()>Qp&&(c.flags|=128,b=!0,Td(g,!1),c.lanes=4194304)}else{if(!b)if(a=hp(x),a!==null){if(c.flags|=128,b=!0,a=a.updateQueue,c.updateQueue=a,_p(c,a),Td(g,!0),g.tail===null&&g.tailMode==="hidden"&&!x.alternate&&!pt)return Gt(c),null}else 2*xn()-g.renderingStartTime>Qp&&d!==536870912&&(c.flags|=128,b=!0,Td(g,!1),c.lanes=4194304);g.isBackwards?(x.sibling=c.child,c.child=x):(a=g.last,a!==null?a.sibling=x:c.child=x,g.last=x)}return g.tail!==null?(a=g.tail,g.rendering=a,g.tail=a.sibling,g.renderingStartTime=xn(),a.sibling=null,d=pn.current,I(pn,b?d&1|2:d&1),pt&&Ks(c,g.treeForkCount),a):(Gt(c),null);case 22:case 23:return Ki(c),y0(),g=c.memoizedState!==null,a!==null?a.memoizedState!==null!==g&&(c.flags|=8192):g&&(c.flags|=8192),g?(d&536870912)!==0&&(c.flags&128)===0&&(Gt(c),c.subtreeFlags&6&&(c.flags|=8192)):Gt(c),d=c.updateQueue,d!==null&&_p(c,d.retryQueue),d=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==d&&(c.flags|=2048),a!==null&&P(nl),null;case 24:return d=null,a!==null&&(d=a.memoizedState.cache),c.memoizedState.cache!==d&&(c.flags|=2048),eo(wn),Gt(c),null;case 25:return null;case 30:return null}throw Error(i(156,c.tag))}function K4(a,c){switch(i0(c),c.tag){case 1:return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return eo(wn),xe(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 26:case 27:case 5:return Xe(c),null;case 31:if(c.memoizedState!==null){if(Ki(c),c.alternate===null)throw Error(i(340));Ja()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 13:if(Ki(c),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(i(340));Ja()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return P(pn),null;case 4:return xe(),null;case 10:return eo(c.type),null;case 22:case 23:return Ki(c),y0(),a!==null&&P(nl),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 24:return eo(wn),null;case 25:return null;default:return null}}function p$(a,c){switch(i0(c),c.tag){case 3:eo(wn),xe();break;case 26:case 27:case 5:Xe(c);break;case 4:xe();break;case 31:c.memoizedState!==null&&Ki(c);break;case 13:Ki(c);break;case 19:P(pn);break;case 10:eo(c.type);break;case 22:case 23:Ki(c),y0(),a!==null&&P(nl);break;case 24:eo(wn)}}function Ed(a,c){try{var d=c.updateQueue,g=d!==null?d.lastEffect:null;if(g!==null){var b=g.next;d=b;do{if((d.tag&a)===a){g=void 0;var x=d.create,_=d.inst;g=x(),_.destroy=g}d=d.next}while(d!==b)}}catch(E){Rt(c,c.return,E)}}function Fo(a,c,d){try{var g=c.updateQueue,b=g!==null?g.lastEffect:null;if(b!==null){var x=b.next;g=x;do{if((g.tag&a)===a){var _=g.inst,E=_.destroy;if(E!==void 0){_.destroy=void 0,b=c;var z=d,te=E;try{te()}catch(ue){Rt(b,z,ue)}}}g=g.next}while(g!==x)}}catch(ue){Rt(c,c.return,ue)}}function g$(a){var c=a.updateQueue;if(c!==null){var d=a.stateNode;try{s_(c,d)}catch(g){Rt(a,a.return,g)}}}function m$(a,c,d){d.props=al(a.type,a.memoizedProps),d.state=a.memoizedState;try{d.componentWillUnmount()}catch(g){Rt(a,c,g)}}function Rd(a,c){try{var d=a.ref;if(d!==null){switch(a.tag){case 26:case 27:case 5:var g=a.stateNode;break;case 30:g=a.stateNode;break;default:g=a.stateNode}typeof d=="function"?a.refCleanup=d(g):d.current=g}}catch(b){Rt(a,c,b)}}function ds(a,c){var d=a.ref,g=a.refCleanup;if(d!==null)if(typeof g=="function")try{g()}catch(b){Rt(a,c,b)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(b){Rt(a,c,b)}else d.current=null}function O$(a){var c=a.type,d=a.memoizedProps,g=a.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":d.autoFocus&&g.focus();break e;case"img":d.src?g.src=d.src:d.srcSet&&(g.srcset=d.srcSet)}}catch(b){Rt(a,a.return,b)}}function H0(a,c,d){try{var g=a.stateNode;bI(g,a.type,d,c),g[Qn]=c}catch(b){Rt(a,a.return,b)}}function y$(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&ta(a.type)||a.tag===4}function W0(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||y$(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&ta(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function K0(a,c,d){var g=a.tag;if(g===5||g===6)a=a.stateNode,c?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(a,c):(c=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,c.appendChild(a),d=d._reactRootContainer,d!=null||c.onclick!==null||(c.onclick=Gs));else if(g!==4&&(g===27&&ta(a.type)&&(d=a.stateNode,c=null),a=a.child,a!==null))for(K0(a,c,d),a=a.sibling;a!==null;)K0(a,c,d),a=a.sibling}function $p(a,c,d){var g=a.tag;if(g===5||g===6)a=a.stateNode,c?d.insertBefore(a,c):d.appendChild(a);else if(g!==4&&(g===27&&ta(a.type)&&(d=a.stateNode),a=a.child,a!==null))for($p(a,c,d),a=a.sibling;a!==null;)$p(a,c,d),a=a.sibling}function v$(a){var c=a.stateNode,d=a.memoizedProps;try{for(var g=a.type,b=c.attributes;b.length;)c.removeAttributeNode(b[0]);Fn(c,g,d),c[Rn]=a,c[Qn]=d}catch(x){Rt(a,a.return,x)}}var so=!1,_n=!1,J0=!1,b$=typeof WeakSet=="function"?WeakSet:Set,Zn=null;function J4(a,c){if(a=a.containerInfo,bv=Fp,a=AC(a),qy(a)){if("selectionStart"in a)var d={start:a.selectionStart,end:a.selectionEnd};else e:{d=(d=a.ownerDocument)&&d.defaultView||window;var g=d.getSelection&&d.getSelection();if(g&&g.rangeCount!==0){d=g.anchorNode;var b=g.anchorOffset,x=g.focusNode;g=g.focusOffset;try{d.nodeType,x.nodeType}catch{d=null;break e}var _=0,E=-1,z=-1,te=0,ue=0,fe=a,ie=null;t:for(;;){for(var ae;fe!==d||b!==0&&fe.nodeType!==3||(E=_+b),fe!==x||g!==0&&fe.nodeType!==3||(z=_+g),fe.nodeType===3&&(_+=fe.nodeValue.length),(ae=fe.firstChild)!==null;)ie=fe,fe=ae;for(;;){if(fe===a)break t;if(ie===d&&++te===b&&(E=_),ie===x&&++ue===g&&(z=_),(ae=fe.nextSibling)!==null)break;fe=ie,ie=fe.parentNode}fe=ae}d=E===-1||z===-1?null:{start:E,end:z}}else d=null}d=d||{start:0,end:0}}else d=null;for(Sv={focusedElem:a,selectionRange:d},Fp=!1,Zn=c;Zn!==null;)if(c=Zn,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,Zn=a;else for(;Zn!==null;){switch(c=Zn,x=c.alternate,a=c.flags,c.tag){case 0:if((a&4)!==0&&(a=c.updateQueue,a=a!==null?a.events:null,a!==null))for(d=0;d title"))),Fn(x,g,d),x[Rn]=a,Pt(x),g=x;break e;case"link":var _=_T("link","href",b).get(g+(d.href||""));if(_){for(var E=0;E<_.length;E++)if(x=_[E],x.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&x.getAttribute("rel")===(d.rel==null?null:d.rel)&&x.getAttribute("title")===(d.title==null?null:d.title)&&x.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){_.splice(E,1);break t}}x=b.createElement(g),Fn(x,g,d),b.head.appendChild(x);break;case"meta":if(_=_T("meta","content",b).get(g+(d.content||""))){for(E=0;E<_.length;E++)if(x=_[E],x.getAttribute("content")===(d.content==null?null:""+d.content)&&x.getAttribute("name")===(d.name==null?null:d.name)&&x.getAttribute("property")===(d.property==null?null:d.property)&&x.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&x.getAttribute("charset")===(d.charSet==null?null:d.charSet)){_.splice(E,1);break t}}x=b.createElement(g),Fn(x,g,d),b.head.appendChild(x);break;default:throw Error(i(468,g))}x[Rn]=a,Pt(x),g=x}a.stateNode=g}else $T(b,a.type,a.stateNode);else a.stateNode=CT(b,g,a.memoizedProps);else x!==g?(x===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):x.count--,g===null?$T(b,a.type,a.stateNode):CT(b,g,a.memoizedProps)):g===null&&a.stateNode!==null&&H0(a,a.memoizedProps,d.memoizedProps)}break;case 27:ji(c,a),Mi(a),g&512&&(_n||d===null||ds(d,d.return)),d!==null&&g&4&&H0(a,a.memoizedProps,d.memoizedProps);break;case 5:if(ji(c,a),Mi(a),g&512&&(_n||d===null||ds(d,d.return)),a.flags&32){b=a.stateNode;try{tc(b,"")}catch(Qe){Rt(a,a.return,Qe)}}g&4&&a.stateNode!=null&&(b=a.memoizedProps,H0(a,b,d!==null?d.memoizedProps:b)),g&1024&&(J0=!0);break;case 6:if(ji(c,a),Mi(a),g&4){if(a.stateNode===null)throw Error(i(162));g=a.memoizedProps,d=a.stateNode;try{d.nodeValue=g}catch(Qe){Rt(a,a.return,Qe)}}break;case 3:if(Bp=null,b=Vr,Vr=Xp(c.containerInfo),ji(c,a),Vr=b,Mi(a),g&4&&d!==null&&d.memoizedState.isDehydrated)try{Ac(c.containerInfo)}catch(Qe){Rt(a,a.return,Qe)}J0&&(J0=!1,$$(a));break;case 4:g=Vr,Vr=Xp(a.stateNode.containerInfo),ji(c,a),Mi(a),Vr=g;break;case 12:ji(c,a),Mi(a);break;case 31:ji(c,a),Mi(a),g&4&&(g=a.updateQueue,g!==null&&(a.updateQueue=null,Tp(a,g)));break;case 13:ji(c,a),Mi(a),a.child.flags&8192&&a.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&(Rp=xn()),g&4&&(g=a.updateQueue,g!==null&&(a.updateQueue=null,Tp(a,g)));break;case 22:b=a.memoizedState!==null;var z=d!==null&&d.memoizedState!==null,te=so,ue=_n;if(so=te||b,_n=ue||z,ji(c,a),_n=ue,so=te,Mi(a),g&8192)e:for(c=a.stateNode,c._visibility=b?c._visibility&-2:c._visibility|1,b&&(d===null||z||so||_n||ll(a)),d=null,c=a;;){if(c.tag===5||c.tag===26){if(d===null){z=d=c;try{if(x=z.stateNode,b)_=x.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{E=z.stateNode;var fe=z.memoizedProps.style,ie=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;E.style.display=ie==null||typeof ie=="boolean"?"":(""+ie).trim()}}catch(Qe){Rt(z,z.return,Qe)}}}else if(c.tag===6){if(d===null){z=c;try{z.stateNode.nodeValue=b?"":z.memoizedProps}catch(Qe){Rt(z,z.return,Qe)}}}else if(c.tag===18){if(d===null){z=c;try{var ae=z.stateNode;b?mT(ae,!0):mT(z.stateNode,!1)}catch(Qe){Rt(z,z.return,Qe)}}}else if((c.tag!==22&&c.tag!==23||c.memoizedState===null||c===a)&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===a)break e;for(;c.sibling===null;){if(c.return===null||c.return===a)break e;d===c&&(d=null),c=c.return}d===c&&(d=null),c.sibling.return=c.return,c=c.sibling}g&4&&(g=a.updateQueue,g!==null&&(d=g.retryQueue,d!==null&&(g.retryQueue=null,Tp(a,d))));break;case 19:ji(c,a),Mi(a),g&4&&(g=a.updateQueue,g!==null&&(a.updateQueue=null,Tp(a,g)));break;case 30:break;case 21:break;default:ji(c,a),Mi(a)}}function Mi(a){var c=a.flags;if(c&2){try{for(var d,g=a.return;g!==null;){if(y$(g)){d=g;break}g=g.return}if(d==null)throw Error(i(160));switch(d.tag){case 27:var b=d.stateNode,x=W0(a);$p(a,x,b);break;case 5:var _=d.stateNode;d.flags&32&&(tc(_,""),d.flags&=-33);var E=W0(a);$p(a,E,_);break;case 3:case 4:var z=d.stateNode.containerInfo,te=W0(a);K0(a,te,z);break;default:throw Error(i(161))}}catch(ue){Rt(a,a.return,ue)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function $$(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var c=a;$$(c),c.tag===5&&c.flags&1024&&c.stateNode.reset(),a=a.sibling}}function ao(a,c){if(c.subtreeFlags&8772)for(c=c.child;c!==null;)S$(a,c.alternate,c),c=c.sibling}function ll(a){for(a=a.child;a!==null;){var c=a;switch(c.tag){case 0:case 11:case 14:case 15:Fo(4,c,c.return),ll(c);break;case 1:ds(c,c.return);var d=c.stateNode;typeof d.componentWillUnmount=="function"&&m$(c,c.return,d),ll(c);break;case 27:Ld(c.stateNode);case 26:case 5:ds(c,c.return),ll(c);break;case 22:c.memoizedState===null&&ll(c);break;case 30:ll(c);break;default:ll(c)}a=a.sibling}}function lo(a,c,d){for(d=d&&(c.subtreeFlags&8772)!==0,c=c.child;c!==null;){var g=c.alternate,b=a,x=c,_=x.flags;switch(x.tag){case 0:case 11:case 15:lo(b,x,d),Ed(4,x);break;case 1:if(lo(b,x,d),g=x,b=g.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(te){Rt(g,g.return,te)}if(g=x,b=g.updateQueue,b!==null){var E=g.stateNode;try{var z=b.shared.hiddenCallbacks;if(z!==null)for(b.shared.hiddenCallbacks=null,b=0;bDt&&(_=Dt,Dt=qe,qe=_);var F=RC(E,qe),B=RC(E,Dt);if(F&&B&&(ae.rangeCount!==1||ae.anchorNode!==F.node||ae.anchorOffset!==F.offset||ae.focusNode!==B.node||ae.focusOffset!==B.offset)){var ee=fe.createRange();ee.setStart(F.node,F.offset),ae.removeAllRanges(),qe>Dt?(ae.addRange(ee),ae.extend(B.node,B.offset)):(ee.setEnd(B.node,B.offset),ae.addRange(ee))}}}}for(fe=[],ae=E;ae=ae.parentNode;)ae.nodeType===1&&fe.push({element:ae,left:ae.scrollLeft,top:ae.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;Ed?32:d,N.T=null,d=ov,ov=null;var x=Ko,_=uo;if(An=0,Cc=Ko=null,uo=0,(xt&6)!==0)throw Error(i(331));var E=xt;if(xt|=4,Q$(x.current),T$(x,x.current,_,d),xt=E,Dd(0,!1),he&&typeof he.onPostCommitFiberRoot=="function")try{he.onPostCommitFiberRoot(q,x)}catch{}return!0}finally{W.p=b,N.T=g,G$(a,c)}}function W$(a,c,d){c=br(d,c),c=L0(a.stateNode,c,2),a=Uo(a,c,2),a!==null&&(It(a,2),fs(a))}function Rt(a,c,d){if(a.tag===3)W$(a,a,d);else for(;c!==null;){if(c.tag===3){W$(c,a,d);break}else if(c.tag===1){var g=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Wo===null||!Wo.has(g))){a=br(d,a),d=K_(2),g=Uo(c,d,2),g!==null&&(J_(d,g,c,a),It(g,2),fs(g));break}}c=c.return}}function uv(a,c,d){var g=a.pingCache;if(g===null){g=a.pingCache=new nI;var b=new Set;g.set(c,b)}else b=g.get(c),b===void 0&&(b=new Set,g.set(c,b));b.has(d)||(nv=!0,b.add(d),a=aI.bind(null,a,c,d),c.then(a,a))}function aI(a,c,d){var g=a.pingCache;g!==null&&g.delete(c),a.pingedLanes|=a.suspendedLanes&d,a.warmLanes&=~d,Xt===a&&(ft&d)===d&&(un===4||un===3&&(ft&62914560)===ft&&300>xn()-Rp?(xt&2)===0&&_c(a,0):iv|=d,kc===ft&&(kc=0)),fs(a)}function K$(a,c){c===0&&(c=ln()),a=Wa(a,c),a!==null&&(It(a,c),fs(a))}function lI(a){var c=a.memoizedState,d=0;c!==null&&(d=c.retryLane),K$(a,d)}function cI(a,c){var d=0;switch(a.tag){case 31:case 13:var g=a.stateNode,b=a.memoizedState;b!==null&&(d=b.retryLane);break;case 19:g=a.stateNode;break;case 22:g=a.stateNode._retryCache;break;default:throw Error(i(314))}g!==null&&g.delete(c),K$(a,d)}function uI(a,c){return gr(a,c)}var Np=null,Tc=null,dv=!1,zp=!1,fv=!1,ea=0;function fs(a){a!==Tc&&a.next===null&&(Tc===null?Np=Tc=a:Tc=Tc.next=a),zp=!0,dv||(dv=!0,fI())}function Dd(a,c){if(!fv&&zp){fv=!0;do for(var d=!1,g=Np;g!==null;){if(a!==0){var b=g.pendingLanes;if(b===0)var x=0;else{var _=g.suspendedLanes,E=g.pingedLanes;x=(1<<31-Se(42|a)+1)-1,x&=b&~(_&~E),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(d=!0,nT(g,x))}else x=ft,x=Ve(g,g===Xt?x:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(x&3)===0||Ct(g,x)||(d=!0,nT(g,x));g=g.next}while(d);fv=!1}}function dI(){J$()}function J$(){zp=dv=!1;var a=0;ea!==0&&xI()&&(a=ea);for(var c=xn(),d=null,g=Np;g!==null;){var b=g.next,x=eT(g,c);x===0?(g.next=null,d===null?Np=b:d.next=b,b===null&&(Tc=d)):(d=g,(a!==0||(x&3)!==0)&&(zp=!0)),g=b}An!==0&&An!==5||Dd(a),ea!==0&&(ea=0)}function eT(a,c){for(var d=a.suspendedLanes,g=a.pingedLanes,b=a.expirationTimes,x=a.pendingLanes&-62914561;0E)break;var ue=z.transferSize,fe=z.initiatorType;ue&&uT(fe)&&(z=z.responseEnd,_+=ue*(z"u"?null:document;function xT(a,c,d){var g=Ec;if(g&&typeof c=="string"&&c){var b=yr(c);b='link[rel="'+a+'"][href="'+b+'"]',typeof d=="string"&&(b+='[crossorigin="'+d+'"]'),ST.has(b)||(ST.add(b),a={rel:a,crossOrigin:d,href:c},g.querySelector(b)===null&&(c=g.createElement("link"),Fn(c,"link",a),Pt(c),g.head.appendChild(c)))}}function QI(a){fo.D(a),xT("dns-prefetch",a,null)}function AI(a,c){fo.C(a,c),xT("preconnect",a,c)}function PI(a,c,d){fo.L(a,c,d);var g=Ec;if(g&&a&&c){var b='link[rel="preload"][as="'+yr(c)+'"]';c==="image"&&d&&d.imageSrcSet?(b+='[imagesrcset="'+yr(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(b+='[imagesizes="'+yr(d.imageSizes)+'"]')):b+='[href="'+yr(a)+'"]';var x=b;switch(c){case"style":x=Rc(a);break;case"script":x=Qc(a)}_r.has(x)||(a=p({rel:"preload",href:c==="image"&&d&&d.imageSrcSet?void 0:a,as:c},d),_r.set(x,a),g.querySelector(b)!==null||c==="style"&&g.querySelector(Zd(x))||c==="script"&&g.querySelector(Id(x))||(c=g.createElement("link"),Fn(c,"link",a),Pt(c),g.head.appendChild(c)))}}function jI(a,c){fo.m(a,c);var d=Ec;if(d&&a){var g=c&&typeof c.as=="string"?c.as:"script",b='link[rel="modulepreload"][as="'+yr(g)+'"][href="'+yr(a)+'"]',x=b;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Qc(a)}if(!_r.has(x)&&(a=p({rel:"modulepreload",href:a},c),_r.set(x,a),d.querySelector(b)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(Id(x)))return}g=d.createElement("link"),Fn(g,"link",a),Pt(g),d.head.appendChild(g)}}}function MI(a,c,d){fo.S(a,c,d);var g=Ec;if(g&&a){var b=_t(g).hoistableStyles,x=Rc(a);c=c||"default";var _=b.get(x);if(!_){var E={loading:0,preload:null};if(_=g.querySelector(Zd(x)))E.loading=5;else{a=p({rel:"stylesheet",href:a,"data-precedence":c},d),(d=_r.get(x))&&Tv(a,d);var z=_=g.createElement("link");Pt(z),Fn(z,"link",a),z._p=new Promise(function(te,ue){z.onload=te,z.onerror=ue}),z.addEventListener("load",function(){E.loading|=1}),z.addEventListener("error",function(){E.loading|=2}),E.loading|=4,Vp(_,c,g)}_={type:"stylesheet",instance:_,count:1,state:E},b.set(x,_)}}}function DI(a,c){fo.X(a,c);var d=Ec;if(d&&a){var g=_t(d).hoistableScripts,b=Qc(a),x=g.get(b);x||(x=d.querySelector(Id(b)),x||(a=p({src:a,async:!0},c),(c=_r.get(b))&&Ev(a,c),x=d.createElement("script"),Pt(x),Fn(x,"link",a),d.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},g.set(b,x))}}function NI(a,c){fo.M(a,c);var d=Ec;if(d&&a){var g=_t(d).hoistableScripts,b=Qc(a),x=g.get(b);x||(x=d.querySelector(Id(b)),x||(a=p({src:a,async:!0,type:"module"},c),(c=_r.get(b))&&Ev(a,c),x=d.createElement("script"),Pt(x),Fn(x,"link",a),d.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},g.set(b,x))}}function wT(a,c,d,g){var b=(b=J.current)?Xp(b):null;if(!b)throw Error(i(446));switch(a){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(c=Rc(d.href),d=_t(b).hoistableStyles,g=d.get(c),g||(g={type:"style",instance:null,count:0,state:null},d.set(c,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){a=Rc(d.href);var x=_t(b).hoistableStyles,_=x.get(a);if(_||(b=b.ownerDocument||b,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(a,_),(x=b.querySelector(Zd(a)))&&!x._p&&(_.instance=x,_.state.loading=5),_r.has(a)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},_r.set(a,d),x||zI(b,a,d,_.state))),c&&g===null)throw Error(i(528,""));return _}if(c&&g!==null)throw Error(i(529,""));return null;case"script":return c=d.async,d=d.src,typeof d=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=Qc(d),d=_t(b).hoistableScripts,g=d.get(c),g||(g={type:"script",instance:null,count:0,state:null},d.set(c,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,a))}}function Rc(a){return'href="'+yr(a)+'"'}function Zd(a){return'link[rel="stylesheet"]['+a+"]"}function kT(a){return p({},a,{"data-precedence":a.precedence,precedence:null})}function zI(a,c,d,g){a.querySelector('link[rel="preload"][as="style"]['+c+"]")?g.loading=1:(c=a.createElement("link"),g.preload=c,c.addEventListener("load",function(){return g.loading|=1}),c.addEventListener("error",function(){return g.loading|=2}),Fn(c,"link",d),Pt(c),a.head.appendChild(c))}function Qc(a){return'[src="'+yr(a)+'"]'}function Id(a){return"script[async]"+a}function CT(a,c,d){if(c.count++,c.instance===null)switch(c.type){case"style":var g=a.querySelector('style[data-href~="'+yr(d.href)+'"]');if(g)return c.instance=g,Pt(g),g;var b=p({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return g=(a.ownerDocument||a).createElement("style"),Pt(g),Fn(g,"style",b),Vp(g,d.precedence,a),c.instance=g;case"stylesheet":b=Rc(d.href);var x=a.querySelector(Zd(b));if(x)return c.state.loading|=4,c.instance=x,Pt(x),x;g=kT(d),(b=_r.get(b))&&Tv(g,b),x=(a.ownerDocument||a).createElement("link"),Pt(x);var _=x;return _._p=new Promise(function(E,z){_.onload=E,_.onerror=z}),Fn(x,"link",g),c.state.loading|=4,Vp(x,d.precedence,a),c.instance=x;case"script":return x=Qc(d.src),(b=a.querySelector(Id(x)))?(c.instance=b,Pt(b),b):(g=d,(b=_r.get(x))&&(g=p({},d),Ev(g,b)),a=a.ownerDocument||a,b=a.createElement("script"),Pt(b),Fn(b,"link",g),a.head.appendChild(b),c.instance=b);case"void":return null;default:throw Error(i(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(g=c.instance,c.state.loading|=4,Vp(g,d.precedence,a));return c.instance}function Vp(a,c,d){for(var g=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=g.length?g[g.length-1]:null,x=b,_=0;_ title"):null)}function LI(a,c,d){if(d===1||c.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;return c.rel==="stylesheet"?(a=c.disabled,typeof c.precedence=="string"&&a==null):!0;case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function TT(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function ZI(a,c,d,g){if(d.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var b=Rc(g.href),x=c.querySelector(Zd(b));if(x){c=x._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(a.count++,a=Up.bind(a),c.then(a,a)),d.state.loading|=4,d.instance=x,Pt(x);return}x=c.ownerDocument||c,g=kT(g),(b=_r.get(b))&&Tv(g,b),x=x.createElement("link"),Pt(x);var _=x;_._p=new Promise(function(E,z){_.onload=E,_.onerror=z}),Fn(x,"link",g),d.instance=x}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(d,c),(c=d.state.preload)&&(d.state.loading&3)===0&&(a.count++,d=Up.bind(a),c.addEventListener("load",d),c.addEventListener("error",d))}}var Rv=0;function II(a,c){return a.stylesheets&&a.count===0&&Yp(a,a.stylesheets),0Rv?50:800)+c);return a.unsuspend=d,function(){a.unsuspend=null,clearTimeout(g),clearTimeout(b)}}:null}function Up(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Yp(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var qp=null;function Yp(a,c){a.stylesheets=null,a.unsuspend!==null&&(a.count++,qp=new Map,c.forEach(XI,a),qp=null,Up.call(a))}function XI(a,c){if(!(c.state.loading&4)){var d=qp.get(a);if(d)var g=d.get(null);else{d=new Map,qp.set(a,d);for(var b=a.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Lv.exports=oX(),Lv.exports}var lX=aX(),Xu=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},cX=class extends Xu{#e;#t;#n;constructor(){super(),this.#n=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},vw=new cX,uX={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},dX=class{#e=uX;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},yl=new dX;function fX(t){setTimeout(t,0)}var hX=typeof window>"u"||"Deno"in globalThis;function xi(){}function pX(t,e){return typeof t=="function"?t(e):t}function yS(t){return typeof t=="number"&&t>=0&&t!==1/0}function BA(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ba(t,e){return typeof t=="function"?t(e):t}function ar(t,e){return typeof t=="function"?t(e):t}function KT(t,e){const{type:n="all",exact:i,fetchStatus:r,predicate:s,queryKey:o,stale:l}=t;if(o){if(i){if(e.queryHash!==bw(o,e.options))return!1}else if(!Tf(e.queryKey,o))return!1}if(n!=="all"){const u=e.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||r&&r!==e.state.fetchStatus||s&&!s(e))}function JT(t,e){const{exact:n,status:i,predicate:r,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(El(e.options.mutationKey)!==El(s))return!1}else if(!Tf(e.options.mutationKey,s))return!1}return!(i&&e.state.status!==i||r&&!r(e))}function bw(t,e){return(e?.queryKeyHashFn||El)(t)}function El(t){return JSON.stringify(t,(e,n)=>vS(n)?Object.keys(n).sort().reduce((i,r)=>(i[r]=n[r],i),{}):n)}function Tf(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Tf(t[n],e[n])):!1}var gX=Object.prototype.hasOwnProperty;function UA(t,e,n=0){if(t===e)return t;if(n>500)return e;const i=e2(t)&&e2(e);if(!i&&!(vS(t)&&vS(e)))return e;const s=(i?t:Object.keys(t)).length,o=i?e:Object.keys(e),l=o.length,u=i?new Array(l):{};let f=0;for(let h=0;h{yl.setTimeout(e,t)})}function bS(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?UA(t,e):e}function OX(t,e,n=0){const i=[...t,e];return n&&i.length>n?i.slice(1):i}function yX(t,e,n=0){const i=[e,...t];return n&&i.length>n?i.slice(0,-1):i}var Sw=Symbol();function qA(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Sw?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function xw(t,e){return typeof t=="function"?t(...e):!!t}function vX(t,e,n){let i=!1,r;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(r??=e(),i||(i=!0,r.aborted?n():r.addEventListener("abort",n,{once:!0})),r)}),t}var Ef=(()=>{let t=()=>hX;return{isServer(){return t()},setIsServer(e){t=e}}})();function SS(){let t,e;const n=new Promise((r,s)=>{t=r,e=s});n.status="pending",n.catch(()=>{});function i(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{i({status:"fulfilled",value:r}),t(r)},n.reject=r=>{i({status:"rejected",reason:r}),e(r)},n}var bX=fX;function SX(){let t=[],e=0,n=l=>{l()},i=l=>{l()},r=bX;const s=l=>{e?t.push(l):r(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&r(()=>{i(()=>{l.forEach(u=>{n(u)})})})};return{batch:l=>{let u;e++;try{u=l()}finally{e--,e||o()}return u},batchCalls:l=>(...u)=>{s(()=>{l(...u)})},schedule:s,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{i=l},setScheduler:l=>{r=l}}}var Mn=SX(),xX=class extends Xu{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},um=new xX;function wX(t){return Math.min(1e3*2**t,3e4)}function YA(t){return(t??"online")==="online"?um.isOnline():!0}var xS=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function FA(t){let e=!1,n=0,i;const r=SS(),s=()=>r.status!=="pending",o=S=>{if(!s()){const k=new xS(S);O(k),t.onCancel?.(k)}},l=()=>{e=!0},u=()=>{e=!1},f=()=>vw.isFocused()&&(t.networkMode==="always"||um.isOnline())&&t.canRun(),h=()=>YA(t.networkMode)&&t.canRun(),p=S=>{s()||(i?.(),r.resolve(S))},O=S=>{s()||(i?.(),r.reject(S))},y=()=>new Promise(S=>{i=k=>{(s()||f())&&S(k)},t.onPause?.()}).then(()=>{i=void 0,s()||t.onContinue?.()}),v=()=>{if(s())return;let S;const k=n===0?t.initialPromise:void 0;try{S=k??t.fn()}catch(C){S=Promise.reject(C)}Promise.resolve(S).then(p).catch(C=>{if(s())return;const $=t.retry??(Ef.isServer()?0:3),T=t.retryDelay??wX,Q=typeof T=="function"?T(n,C):T,A=$===!0||typeof $=="number"&&n<$||typeof $=="function"&&$(n,C);if(e||!A){O(C);return}n++,t.onFail?.(n,C),mX(Q).then(()=>f()?void 0:y()).then(()=>{e?O(C):v()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(i?.(),r),cancelRetry:l,continueRetry:u,canStart:h,start:()=>(h()?v():y().then(v),r)}}var GA=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),yS(this.gcTime)&&(this.#e=yl.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Ef.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(yl.clearTimeout(this.#e),this.#e=void 0)}};function kX(t){return{onFetch:(e,n)=>{const i=e.options,r=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},u=0;const f=async()=>{let h=!1;const p=v=>{vX(v,()=>e.signal,()=>h=!0)},O=qA(e.options,e.fetchOptions),y=async(v,S,k)=>{if(h)return Promise.reject(e.signal.reason);if(S==null&&v.pages.length)return Promise.resolve(v);const $=(()=>{const R={client:e.client,queryKey:e.queryKey,pageParam:S,direction:k?"backward":"forward",meta:e.options.meta};return p(R),R})(),T=await O($),{maxPages:Q}=e.options,A=k?yX:OX;return{pages:A(v.pages,T,Q),pageParams:A(v.pageParams,S,Q)}};if(r&&s.length){const v=r==="backward",S=v?HA:wS,k={pages:s,pageParams:o},C=S(i,k);l=await y(k,C,v)}else{const v=t??s.length;do{const S=u===0?o[0]??i.initialPageParam:wS(i,l);if(u>0&&S==null)break;l=await y(l,S),u++}while(ue.options.persister?.(f,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=f}}}function wS(t,{pages:e,pageParams:n}){const i=e.length-1;return e.length>0?t.getNextPageParam(e[i],e,n[i],n):void 0}function HA(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}function CX(t,e){return e?wS(t,e)!=null:!1}function _X(t,e){return!e||!t.getPreviousPageParam?!1:HA(t,e)!=null}var $X=class extends GA{#e;#t;#n;#i;#s;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#s=t.client,this.#i=this.#s.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=i2(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#a,...t},t?._type&&(this.#e=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=i2(this.options);e.data!==void 0&&(this.setState(n2(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#i.remove(this)}setData(t,e){const n=bS(this.state.data,t,this.options);return this.#l({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t){this.#l({type:"setState",state:t})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(xi).catch(xi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>ar(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Sw||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>ba(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!BA(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#i.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o||this.#u()?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#i.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#u(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const u=this.observers.find(f=>f.options.queryFn);u&&this.setOptions(u.options)}const n=new AbortController,i=u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},r=()=>{const u=qA(this.options,e),h=(()=>{const p={client:this.#s,queryKey:this.queryKey,meta:this.meta};return i(p),p})();return this.#o=!1,this.options.persister?this.options.persister(u,h,this):u(h)},o=(()=>{const u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#s,state:this.state,fetchFn:r};return i(u),u})();(this.#e==="infinite"?kX(this.options.pages):this.options.behavior)?.onFetch(o,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#l({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=FA({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:u=>{u instanceof xS&&u.revert&&this.setState({...this.#n,fetchStatus:"idle"}),n.abort()},onFail:(u,f)=>{this.#l({type:"failed",failureCount:u,error:f})},onPause:()=>{this.#l({type:"pause"})},onContinue:()=>{this.#l({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const u=await this.#r.start();if(u===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#i.config.onSuccess?.(u,this),this.#i.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof xS){if(u.silent)return this.#r.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#l({type:"error",error:u}),this.#i.config.onError?.(u,this),this.#i.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#l(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...WA(n.data,this.options),fetchMeta:t.meta??null};case"success":const i={...n,...n2(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=t.manual?i:void 0,i;case"error":const r=t.error;return{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),Mn.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#i.notify({query:this,type:"updated",action:t})})}};function WA(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:YA(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function n2(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function i2(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,i=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var KA=class extends Xu{constructor(t,e){super(),this.options=e,this.#e=t,this.#o=null,this.#a=SS(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#s;#r;#a;#o;#u;#l;#p;#d;#f;#c;#g=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),r2(this.#t,this.options)?this.#h():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return kS(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return kS(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#S(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ar(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#t.setOptions(this.options),e._defaulted&&!cm(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&s2(this.#t,n,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==n||ar(this.options.enabled,this.#t)!==ar(e.enabled,this.#t)||ba(this.options.staleTime,this.#t)!==ba(e.staleTime,this.#t))&&this.#m();const r=this.#O();i&&(this.#t!==n||ar(this.options.enabled,this.#t)!==ar(e.enabled,this.#t)||r!==this.#c)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return EX(this,n)&&(this.#i=n,this.#r=this.options,this.#s=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,i)=>(this.trackProp(i),e?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,i))})}trackProp(t){this.#g.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#h(t){this.#x();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(xi)),e}#m(){this.#b();const t=ba(this.options.staleTime,this.#t);if(Ef.isServer()||this.#i.isStale||!yS(t))return;const n=BA(this.#i.dataUpdatedAt,t)+1;this.#d=yl.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#O(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#S(),this.#c=t,!(Ef.isServer()||ar(this.options.enabled,this.#t)===!1||!yS(this.#c)||this.#c===0)&&(this.#f=yl.setInterval(()=>{(this.options.refetchIntervalInBackground||vw.isFocused())&&this.#h()},this.#c))}#v(){this.#m(),this.#y(this.#O())}#b(){this.#d!==void 0&&(yl.clearTimeout(this.#d),this.#d=void 0)}#S(){this.#f!==void 0&&(yl.clearInterval(this.#f),this.#f=void 0)}createResult(t,e){const n=this.#t,i=this.options,r=this.#i,s=this.#s,o=this.#r,u=t!==n?t.state:this.#n,{state:f}=t;let h={...f},p=!1,O;if(e._optimisticResults){const L=this.hasListeners(),ne=!L&&r2(t,e),G=L&&s2(t,n,e,i);(ne||G)&&(h={...h,...WA(f.data,t.options)}),e._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:y,errorUpdatedAt:v,status:S}=h;O=h.data;let k=!1;if(e.placeholderData!==void 0&&O===void 0&&S==="pending"){let L;r?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(L=r.data,k=!0):L=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,L!==void 0&&(S="success",O=bS(r?.data,L,e),p=!0)}if(e.select&&O!==void 0&&!k)if(r&&O===s?.data&&e.select===this.#u)O=this.#l;else try{this.#u=e.select,O=e.select(O),O=bS(r?.data,O,e),this.#l=O,this.#o=null}catch(L){this.#o=L}this.#o&&(y=this.#o,O=this.#l,v=Date.now(),S="error");const C=h.fetchStatus==="fetching",$=S==="pending",T=S==="error",Q=$&&C,A=O!==void 0,j={status:S,fetchStatus:h.fetchStatus,isPending:$,isSuccess:S==="success",isError:T,isInitialLoading:Q,isLoading:Q,data:O,dataUpdatedAt:h.dataUpdatedAt,error:y,errorUpdatedAt:v,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:C,isRefetching:C&&!$,isLoadingError:T&&!A,isPaused:h.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:T&&A,isStale:ww(t,e),refetch:this.refetch,promise:this.#a,isEnabled:ar(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const L=j.data!==void 0,ne=j.status==="error"&&!L,G=re=>{ne?re.reject(j.error):L&&re.resolve(j.data)},H=()=>{const re=this.#a=j.promise=SS();G(re)},Y=this.#a;switch(Y.status){case"pending":t.queryHash===n.queryHash&&G(Y);break;case"fulfilled":(ne||j.data!==Y.value)&&H();break;case"rejected":(!ne||j.error!==Y.reason)&&H();break}}return j}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#s=this.#t.state,this.#r=this.options,this.#s.data!==void 0&&(this.#p=this.#t),cm(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,r=typeof i=="function"?i():i;if(r==="all"||!r&&!this.#g.size)return!0;const s=new Set(r??this.#g);return this.options.throwOnError&&s.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&s.has(l)})};this.#w({listeners:n()})}#x(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#w(t){Mn.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function TX(t,e){return ar(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&ar(e.retryOnMount,t)===!1)}function r2(t,e){return TX(t,e)||t.state.data!==void 0&&kS(t,e,e.refetchOnMount)}function kS(t,e,n){if(ar(e.enabled,t)!==!1&&ba(e.staleTime,t)!=="static"){const i=typeof n=="function"?n(t):n;return i==="always"||i!==!1&&ww(t,e)}return!1}function s2(t,e,n,i){return(t!==e||ar(i.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&ww(t,n)}function ww(t,e){return ar(e.enabled,t)!==!1&&t.isStaleByTime(ba(e.staleTime,t))}function EX(t,e){return!cm(t.getCurrentResult(),e)}var RX=class extends KA{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){t._type="infinite",super.setOptions(t)}getOptimisticResult(t){return t._type="infinite",super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){const{state:n}=t,i=super.createResult(t,e),{isFetching:r,isRefetching:s,isError:o,isRefetchError:l}=i,u=n.fetchMeta?.fetchMore?.direction,f=o&&u==="forward",h=r&&u==="forward",p=o&&u==="backward",O=r&&u==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:CX(e,n.data),hasPreviousPage:_X(e,n.data),isFetchNextPageError:f,isFetchingNextPage:h,isFetchPreviousPageError:p,isFetchingPreviousPage:O,isRefetchError:l&&!f&&!p,isRefetching:s&&!h&&!O}}},QX=class extends GA{#e;#t;#n;#i;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#t=[],this.state=t.state||JA(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#s({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=FA({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,o)=>{this.#s({type:"failed",failureCount:s,error:o})},onPause:()=>{this.#s({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const i=this.state.status==="pending",r=!this.#i.canStart();try{if(i)e();else{this.#s({type:"pending",variables:t,isPaused:r}),this.#n.config.onMutate&&await this.#n.config.onMutate(t,this,n);const o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#s({type:"pending",context:o,variables:t,isPaused:r})}const s=await this.#i.start();return await this.#n.config.onSuccess?.(s,t,this.state.context,this,n),await this.options.onSuccess?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,t,this.state.context,n),this.#s({type:"success",data:s}),s}catch(s){try{await this.#n.config.onError?.(s,t,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onError?.(s,t,this.state.context,n)}catch(o){Promise.reject(o)}try{await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,s,t,this.state.context,n)}catch(o){Promise.reject(o)}throw this.#s({type:"error",error:s}),s}finally{this.#n.runNext(this)}}#s(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),Mn.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function JA(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var AX=class extends Xu{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,n){const i=new QX({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(i),i}add(t){this.#e.add(t);const e=tg(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=tg(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const i=n.indexOf(t);i!==-1&&n.splice(i,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=tg(t);if(typeof e=="string"){const i=this.#t.get(e)?.find(r=>r.state.status==="pending");return!i||i===t}else return!0}runNext(t){const e=tg(t);return typeof e=="string"?this.#t.get(e)?.find(i=>i!==t&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Mn.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>JT(e,n))}findAll(t={}){return this.getAll().filter(e=>JT(t,e))}notify(t){Mn.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Mn.batch(()=>Promise.all(t.map(e=>e.continue().catch(xi))))}};function tg(t){return t.options.scope?.id}var PX=class extends Xu{#e;#t=void 0;#n;#i;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#s()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),cm(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&El(n.mutationKey)!==El(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#s(),this.#r(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#s(),this.#r()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#s(){const e=this.#n?.state??JA();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#r(e){Mn.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,i=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#i.onSuccess?.(e.data,n,i,r)}catch(s){Promise.reject(s)}try{this.#i.onSettled?.(e.data,null,n,i,r)}catch(s){Promise.reject(s)}}else if(e?.type==="error"){try{this.#i.onError?.(e.error,n,i,r)}catch(s){Promise.reject(s)}try{this.#i.onSettled?.(void 0,e.error,n,i,r)}catch(s){Promise.reject(s)}}}this.listeners.forEach(n=>{n(this.#t)})})}},jX=class extends Xu{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const i=e.queryKey,r=e.queryHash??bw(i,e);let s=this.get(r);return s||(s=new $X({client:t,queryKey:i,queryHash:r,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(i)}),this.add(s)),s}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Mn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>KT(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>KT(t,n)):e}notify(t){Mn.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Mn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Mn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},MX=class{#e;#t;#n;#i;#s;#r;#a;#o;constructor(t={}){this.#e=t.queryCache||new jX,this.#t=t.mutationCache||new AX,this.#n=t.defaultOptions||{},this.#i=new Map,this.#s=new Map,this.#r=0}mount(){this.#r++,this.#r===1&&(this.#a=vw.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#o=um.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#r--,this.#r===0&&(this.#a?.(),this.#a=void 0,this.#o?.(),this.#o=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),i=n.state.data;return i===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(ba(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const i=n.data;return[e,i]})}setQueryData(t,e,n){const i=this.defaultQueryOptions({queryKey:t}),s=this.#e.get(i.queryHash)?.state.data,o=pX(e,s);if(o!==void 0)return this.#e.build(this,i).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Mn.batch(()=>this.#e.findAll(t).map(({queryKey:i})=>[i,this.setQueryData(i,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;Mn.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return Mn.batch(()=>(n.findAll(t).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},i=Mn.batch(()=>this.#e.findAll(t).map(r=>r.cancel(n)));return Promise.all(i).then(xi).catch(xi)}invalidateQueries(t,e={}){return Mn.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},i=Mn.batch(()=>this.#e.findAll(t).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let s=r.fetch(void 0,n);return n.throwOnError||(s=s.catch(xi)),r.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(i).then(xi)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(ba(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(xi).catch(xi)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(xi).catch(xi)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return um.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(El(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(i=>{Tf(t,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(t,e){this.#s.set(El(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#s.values()],n={};return e.forEach(i=>{Tf(t,i.mutationKey)&&Object.assign(n,i.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=bw(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Sw&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},eP=w.createContext(void 0),fr=t=>{const e=w.useContext(eP);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},DX=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),m.jsx(eP.Provider,{value:t,children:e})),tP=w.createContext(!1),NX=()=>w.useContext(tP);tP.Provider;function zX(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var LX=w.createContext(zX()),ZX=()=>w.useContext(LX),IX=(t,e,n)=>{const i=n?.state.error&&typeof t.throwOnError=="function"?xw(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||i)&&(e.isReset()||(t.retryOnMount=!1))},XX=t=>{w.useEffect(()=>{t.clearReset()},[t])},VX=({result:t,errorResetBoundary:e,throwOnError:n,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||xw(n,[t.error,i])),BX=t=>{if(t.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>n(i(...r)):n(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},UX=(t,e)=>t.isLoading&&t.isFetching&&!e,qX=(t,e)=>t?.suspense&&e.isPending,o2=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function nP(t,e,n){const i=NX(),r=ZX(),s=fr(),o=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=s.getQueryCache().get(o.queryHash),u=t.subscribed!==!1;o._optimisticResults=i?"isRestoring":u?"optimistic":void 0,BX(o),IX(o,r,l),XX(r);const f=!s.getQueryCache().get(o.queryHash),[h]=w.useState(()=>new e(s,o)),p=h.getOptimisticResult(o),O=!i&&u;if(w.useSyncExternalStore(w.useCallback(y=>{const v=O?h.subscribe(Mn.batchCalls(y)):xi;return h.updateResult(),v},[h,O]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),w.useEffect(()=>{h.setOptions(o)},[o,h]),qX(o,p))throw o2(o,h,r);if(VX({result:p,errorResetBoundary:r,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw p.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(o,p),o.experimental_prefetchInRender&&!Ef.isServer()&&UX(p,i)&&(f?o2(o,h,r):l?.promise)?.catch(xi).finally(()=>{h.updateResult()}),o.notifyOnChangeProps?p:h.trackResult(p)}function nn(t,e){return nP(t,KA)}function YX(t,e){const n=fr(),[i]=w.useState(()=>new PX(n,t));w.useEffect(()=>{i.setOptions(t)},[i,t]);const r=w.useSyncExternalStore(w.useCallback(o=>i.subscribe(Mn.batchCalls(o)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),s=w.useCallback((o,l)=>{i.mutate(o,l).catch(xi)},[i]);if(r.error&&xw(i.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:s,mutateAsync:r.mutate}}function FX(t,e){return nP(t,RX)}let a2=!1;function GX(t){const e=t.analytics;if(!e?.key||a2)return;a2=!0;const n=document.createElement("script");n.src=e.host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",n.async=!0,n.onload=()=>{const i=window.posthog;i&&(i.init(e.key,{api_host:e.host,defaults:"2026-05-30",capture_pageview:"history_change",session_recording:{maskAllInputs:!0,maskTextSelector:"*"}}),t.me&&i.identify(t.me.email,{email:t.me.email,name:t.me.name,...t.billing?{plan:t.billing.plan}:{}}))},document.head.appendChild(n)}function iP(t,e){window.posthog?.capture(t,e)}const HX=[[/^POST \/api\/projects$/,"project_created"],[/^DELETE \/api\/projects\//,"project_deleted"],[/^POST \/api\/p\/[^/]+\/restore$/,"file_restored"],[/^DELETE \/api\/shares\//,"share_revoked"],[/^PATCH \/api\/shares\//,"share_expiry_changed"],[/^POST \/api\/orgs\/[^/]+\/invites$/,"invite_created"],[/^DELETE \/api\/orgs\/[^/]+\/invites\//,"invite_revoked"],[/^POST \/api\/invites\//,"invite_accepted"],[/^PUT \/api\/p\/[^/]+\/permissions\/./,"project_access_granted"],[/^DELETE \/api\/p\/[^/]+\/permissions\/./,"project_access_revoked"]];function gO(t,e){const n=t+" "+e.split("?")[0],i=HX.find(([r])=>r.test(n));i&&iP(i[1])}function mO(){throw location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),new Error("signing in…")}function WX(t,e){const n=e.trim();switch(t){case 403:return n.includes("seat")?"This plan is out of seats. Upgrade to add more people.":n.includes("owner")?"Only owners can do that.":"You don't have access to that.";case 409:return n?n[0].toUpperCase()+n.slice(1):"That is managed outside this hub.";case 404:return"That is gone — it may have been removed already.";case 413:return"This project is over its plan limit.";case 429:return"Too many requests. Give it a moment.";default:return t>=500?"The server had a problem. Try again.":n?n[0].toUpperCase()+n.slice(1):"Something went wrong."}}class kw extends Error{constructor(e,n,i=""){super(n),this.status=e,this.body=i,this.name="HttpError"}status;body}async function fh(t){const e=await t.text();throw new kw(t.status,WX(t.status,e),e)}async function Wt(t){const e=await fetch(t,{headers:{Accept:"application/json"}});return e.status===401&&mO(),e.ok||await fh(e),e.json()}async function KX(t){const e=await fetch(t);return e.status===401&&mO(),e.ok||await fh(e),e}async function di(t,e,n){const i={method:t};n!==void 0&&(i.headers={"Content-Type":"application/json"},i.body=JSON.stringify(n));const r=await fetch(e,i);return r.ok||await fh(r),gO(t,e),r.status===204?{}:r.json()}async function dm(t,e){const n=await fetch(t,{method:"POST",headers:{"X-Bdrive-Desktop":"1","Content-Type":"application/json"},body:e===void 0?void 0:JSON.stringify(e)});return n.ok&&gO("POST",t),n}async function Wr(t,e){const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e||{})});return n.status===401&&mO(),n.ok||await fh(n),gO("POST",t),n.json()}async function l2(t,e,n){const i=await fetch(t,{method:"PUT",headers:{"Content-Type":"text/plain; charset=utf-8",...n?{"If-Match":n}:{}},body:e});return i.status===401&&mO(),i.ok||await fh(i),gO("PUT",t),await i.json().catch(()=>({}))}function Cw(){return nn({queryKey:["config"],queryFn:async()=>{const t=await Wt("/api/config");return t.auth.enabled&&!t.me&&(location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),await new Promise(()=>{})),GX(t),t},staleTime:1/0})}var ql=VA();const JX=XA(ql);function c2(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function vu(...t){return e=>{let n=!1;const i=t.map(r=>{const s=c2(r,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r{let{children:r,...s}=n,o=null,l=!1;const u=[];u2(r)&&typeof ng=="function"&&(r=ng(r._payload)),w.Children.forEach(r,O=>{if(sV(O)){l=!0;const y=O;let v="child"in y.props?y.props.child:y.props.children;u2(v)&&typeof ng=="function"&&(v=ng(v._payload)),o=nV(y,v),u.push(o?.props?.children)}else u.push(O)}),o?o=w.cloneElement(o,void 0,u):!l&&w.Children.count(r)===1&&w.isValidElement(r)&&(o=r);const f=o?rV(o):void 0,h=kt(i,f);if(!o){if(r||r===0)throw new Error(l?cV(t):lV(t));return r}const p=iV(s,o.props??{});return o.type!==w.Fragment&&(p.ref=i?h:f),w.cloneElement(o,p)});return e.displayName=`${t}.Slot`,e}var eV=Rl("Slot"),rP=Symbol.for("radix.slottable");function tV(t){const e=n=>"child"in n?n.children(n.child):n.children;return e.displayName=`${t}.Slottable`,e.__radixId=rP,e}var nV=(t,e)=>{if("child"in t.props){const n=t.props.child;return w.isValidElement(n)?w.cloneElement(n,void 0,t.props.children(n.props.children)):null}return w.isValidElement(e)?e:null};function iV(t,e){const n={...e};for(const i in e){const r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...l)=>{const u=s(...l);return r(...l),u}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function rV(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function sV(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===rP}var oV=Symbol.for("react.lazy");function u2(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===oV&&"_payload"in t&&aV(t._payload)}function aV(t){return typeof t=="object"&&t!==null&&"then"in t}var lV=t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,cV=t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,ng=pO[" use ".trim().toString()],uV=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ke=uV.reduce((t,e)=>{const n=Rl(`Primitive.${e}`),i=w.forwardRef((r,s)=>{const{asChild:o,...l}=r,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(u,{...l,ref:s})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{});function sP(t,e){t&&ql.flushSync(()=>t.dispatchEvent(e))}var oP=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),dV="VisuallyHidden",aP=w.forwardRef((t,e)=>m.jsx(Ke.span,{...t,ref:e,style:{...oP,...t.style}}));aP.displayName=dV;var fV=aP;function Da(t,e=[]){let n=[];function i(s,o){const l=w.createContext(o);l.displayName=s+"Context";const u=n.length;n=[...n,o];const f=p=>{const{scope:O,children:y,...v}=p,S=O?.[t]?.[u]||l,k=w.useMemo(()=>v,Object.values(v));return m.jsx(S.Provider,{value:k,children:y})};f.displayName=s+"Provider";function h(p,O,y={}){const{optional:v=!1}=y,S=O?.[t]?.[u]||l,k=w.useContext(S);if(k)return k;if(o!==void 0)return o;if(!v)throw new Error(`\`${p}\` must be used within \`${s}\``)}return[f,h]}const r=()=>{const s=n.map(o=>w.createContext(o));return function(l){const u=l?.[t]||s;return w.useMemo(()=>({[`__scope${t}`]:{...l,[t]:u}}),[l,u])}};return r.scopeName=t,[i,hV(r,...e)]}function hV(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const i=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(s){const o=i.reduce((l,{useScope:u,scopeName:f})=>{const p=u(s)[`__scope${f}`];return{...l,...p}},{});return w.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}function _w(t){const e=t+"CollectionProvider",[n,i]=Da(e),[r,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=S=>{const{scope:k,children:C}=S,$=w.useRef(null),T=w.useRef(new Map).current;return m.jsx(r,{scope:k,itemMap:T,collectionRef:$,children:C})};o.displayName=e;const l=t+"CollectionSlot",u=Rl(l),f=w.forwardRef((S,k)=>{const{scope:C,children:$}=S,T=s(l,C),Q=kt(k,T.collectionRef);return m.jsx(u,{ref:Q,children:$})});f.displayName=l;const h=t+"CollectionItemSlot",p="data-radix-collection-item",O=Rl(h),y=w.forwardRef((S,k)=>{const{scope:C,children:$,...T}=S,Q=w.useRef(null),A=kt(k,Q),R=s(h,C);return w.useEffect(()=>(R.itemMap.set(Q,{ref:Q,...T}),()=>{R.itemMap.delete(Q)})),m.jsx(O,{[p]:"",ref:A,children:$})});y.displayName=h;function v(S){const k=s(t+"CollectionConsumer",S);return w.useCallback(()=>{const $=k.collectionRef.current;if(!$)return[];const T=Array.from($.querySelectorAll(`[${p}]`));return Array.from(k.itemMap.values()).sort((R,j)=>T.indexOf(R.ref.current)-T.indexOf(j.ref.current))},[k.collectionRef,k.itemMap])}return[{Provider:o,Slot:f,ItemSlot:y},v,i]}function je(t,e,{checkForDefaultPrevented:n=!0}={}){return function(r){if(t?.(r),n===!1||!r||!r.defaultPrevented)return e?.(r)}}var Xn=globalThis?.document?w.useLayoutEffect:()=>{},pV=pO[" useInsertionEffect ".trim().toString()]||Xn;function bu({prop:t,defaultProp:e,onChange:n=()=>{},caller:i}){const[r,s,o]=gV({defaultProp:e,onChange:n}),l=t!==void 0,u=l?t:r;{const h=w.useRef(t!==void 0);w.useEffect(()=>{const p=h.current;p!==l&&console.warn(`${i} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=l},[l,i])}const f=w.useCallback(h=>{if(l){const p=mV(h)?h(t):h;p!==t&&o.current?.(p)}else s(h)},[l,t,s,o]);return[u,f]}function gV({defaultProp:t,onChange:e}){const[n,i]=w.useState(t),r=w.useRef(n),s=w.useRef(e);return pV(()=>{s.current=e},[e]),w.useEffect(()=>{r.current!==n&&(s.current?.(n),r.current=n)},[n,r]),[n,i,s]}function mV(t){return typeof t=="function"}function OV(t,e){return w.useReducer((n,i)=>e[n][i]??n,t)}var is=t=>{const{present:e,children:n}=t,i=yV(e),r=typeof n=="function"?n({present:i.isPresent}):w.Children.only(n),s=vV(i.ref,bV(r));return typeof n=="function"||i.isPresent?w.cloneElement(r,{ref:s}):null};is.displayName="Presence";function yV(t){const[e,n]=w.useState(),i=w.useRef(null),r=w.useRef(t),s=w.useRef("none"),o=w.useRef(void 0),l=t?"mounted":"unmounted",[u,f]=OV(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return w.useEffect(()=>{u==="mounted"?(s.current=o.current??Fd(i.current),o.current=void 0):s.current="none"},[u]),Xn(()=>{const h=i.current,p=r.current;if(p!==t){const y=s.current,v=Fd(h);t?(o.current=v,f("MOUNT")):v==="none"||h?.display==="none"?f("UNMOUNT"):f(p&&y!==v?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,f]),Xn(()=>{if(e){let h;const p=e.ownerDocument.defaultView??window,O=v=>{const k=Fd(i.current).includes(CSS.escape(v.animationName));if(v.target===e&&k&&(f("ANIMATION_END"),!r.current)){const C=e.style.animationFillMode;e.style.animationFillMode="forwards",h=p.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=C)})}},y=v=>{v.target===e&&(s.current=Fd(i.current))};return e.addEventListener("animationstart",y),e.addEventListener("animationcancel",O),e.addEventListener("animationend",O),()=>{p.clearTimeout(h),e.removeEventListener("animationstart",y),e.removeEventListener("animationcancel",O),e.removeEventListener("animationend",O)}}else f("ANIMATION_END")},[e,f]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:w.useCallback(h=>{if(h){const p=getComputedStyle(h);i.current=p,o.current=Fd(p)}else i.current=null;n(h)},[])}}function d2(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function vV(...t){const e=w.useRef(t);return e.current=t,w.useCallback(n=>{const i=e.current;let r=!1;const s=i.map(o=>{const l=d2(o,n);return!r&&typeof l=="function"&&(r=!0),l});if(r)return()=>{for(let o=0;o{}),xV=0;function hi(t){const[e,n]=w.useState(SV());return Xn(()=>{n(i=>i??String(xV++))},[t]),e?`radix-${e}`:""}var wV=w.createContext(void 0);function $w(t){const e=w.useContext(wV);return t||e||"ltr"}function Mr(t){const e=w.useRef(t);return w.useEffect(()=>{e.current=t}),w.useMemo(()=>((...n)=>e.current?.(...n)),[])}var kV="DismissableLayer",CS="dismissableLayer.update",CV="dismissableLayer.pointerDownOutside",_V="dismissableLayer.focusOutside",f2,Tw=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),hh=w.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:l,onDismiss:u,...f}=t,h=w.useContext(Tw),[p,O]=w.useState(null),y=p?.ownerDocument??globalThis?.document,[,v]=w.useState({}),S=kt(e,O),k=Array.from(h.layers),[C]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),$=C?k.indexOf(C):-1,T=p?k.indexOf(p):-1,Q=h.layersWithOutsidePointerEventsDisabled.size>0,A=T>=$,R=w.useRef(!1),j=QV(H=>{s?.(H),l?.(H),H.defaultPrevented||u?.()},{ownerDocument:y,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:R,dismissableSurfaces:h.dismissableSurfaces,shouldHandlePointerDownOutside:w.useCallback(H=>{if(!(H instanceof Node))return!1;const Y=[...h.branches].some(re=>re.contains(H));return A&&!Y},[h.branches,A])}),L=AV(H=>{if(i&&R.current)return;const Y=H.target;[...h.branches].some(K=>K.contains(Y))||(o?.(H),l?.(H),H.defaultPrevented||u?.())},y),ne=p?T===k.length-1:!1,G=Mr(H=>{H.key==="Escape"&&(r?.(H),!H.defaultPrevented&&u&&(H.preventDefault(),u()))});return w.useEffect(()=>{if(ne)return y.addEventListener("keydown",G,{capture:!0}),()=>y.removeEventListener("keydown",G,{capture:!0})},[y,ne,G]),w.useEffect(()=>{if(p)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(f2=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(p)),h.layers.add(p),h2(),()=>{n&&(h.layersWithOutsidePointerEventsDisabled.delete(p),h.layersWithOutsidePointerEventsDisabled.size===0&&(y.body.style.pointerEvents=f2))}},[p,y,n,h]),w.useEffect(()=>()=>{p&&(h.layers.delete(p),h.layersWithOutsidePointerEventsDisabled.delete(p),h2())},[p,h]),w.useEffect(()=>{const H=()=>v({});return document.addEventListener(CS,H),()=>document.removeEventListener(CS,H)},[]),m.jsx(Ke.div,{...f,ref:S,style:{pointerEvents:Q?A?"auto":"none":void 0,...t.style},onFocusCapture:je(t.onFocusCapture,L.onFocusCapture),onBlurCapture:je(t.onBlurCapture,L.onBlurCapture),onPointerDownCapture:je(t.onPointerDownCapture,j.onPointerDownCapture)})});hh.displayName=kV;var $V="DismissableLayerBranch",TV=w.forwardRef((t,e)=>{const n=w.useContext(Tw),i=w.useRef(null),r=kt(e,i);return w.useEffect(()=>{const s=i.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),m.jsx(Ke.div,{...t,ref:r})});TV.displayName=$V;function EV(){const t=w.useContext(Tw),[e,n]=w.useState(null);return w.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}var RV=()=>!0;function QV(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:s,shouldHandlePointerDownOutside:o=RV}=e,l=Mr(t),u=w.useRef(!1),f=w.useRef(!1),h=w.useRef(new Map),p=w.useRef(()=>{});return w.useEffect(()=>{function O(){f.current=!1,r.current=!1,h.current.clear()}function y(){return Array.from(h.current.values()).some(Boolean)}function v(T){if(!f.current)return;const Q=T.target;Q instanceof Node&&[...s].some(R=>R.contains(Q))||h.current.set(T.type,!0),T.type==="click"&&window.setTimeout(()=>{f.current&&p.current()},0)}function S(T){f.current&&h.current.set(T.type,!1)}const k=T=>{if(T.target&&!u.current){let Q=function(){n.removeEventListener("click",p.current);const R=y();O(),R||lP(CV,l,A,{discrete:!0})};if(!o(T.target)){n.removeEventListener("click",p.current),O(),u.current=!1;return}const A={originalEvent:T};f.current=!0,r.current=i&&T.button===0,h.current.clear(),!i||T.button!==0?Q():(n.removeEventListener("click",p.current),p.current=Q,n.addEventListener("click",p.current,{once:!0}))}else n.removeEventListener("click",p.current),O();u.current=!1},C=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const T of C)n.addEventListener(T,v,!0),n.addEventListener(T,S);const $=window.setTimeout(()=>{n.addEventListener("pointerdown",k)},0);return()=>{window.clearTimeout($),n.removeEventListener("pointerdown",k),n.removeEventListener("click",p.current);for(const T of C)n.removeEventListener(T,v,!0),n.removeEventListener(T,S)}},[n,l,i,r,s,o]),{onPointerDownCapture:()=>u.current=!0}}function AV(t,e=globalThis?.document){const n=Mr(t),i=w.useRef(!1);return w.useEffect(()=>{const r=s=>{s.target&&!i.current&&lP(_V,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,n]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function h2(){const t=new CustomEvent(CS);document.dispatchEvent(t)}function lP(t,e,n,{discrete:i}){const r=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&r.addEventListener(t,e,{once:!0}),i?sP(r,s):r.dispatchEvent(s)}var Vv="focusScope.autoFocusOnMount",Bv="focusScope.autoFocusOnUnmount",p2={bubbles:!1,cancelable:!0},PV="FocusScope",OO=w.forwardRef((t,e)=>{const{loop:n=!1,trapped:i=!1,onMountAutoFocus:r,onUnmountAutoFocus:s,...o}=t,[l,u]=w.useState(null),f=Mr(r),h=Mr(s),p=w.useRef(null),O=kt(e,u),y=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(i){let S=function(T){if(y.paused||!l)return;const Q=T.target;l.contains(Q)?p.current=Q:ca(p.current,{select:!0})},k=function(T){if(y.paused||!l)return;const Q=T.relatedTarget;Q!==null&&(l.contains(Q)||ca(p.current,{select:!0}))},C=function(T){if(document.activeElement===document.body)for(const A of T)A.removedNodes.length>0&&ca(l)};document.addEventListener("focusin",S),document.addEventListener("focusout",k);const $=new MutationObserver(C);return l&&$.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",S),document.removeEventListener("focusout",k),$.disconnect()}}},[i,l,y.paused]),w.useEffect(()=>{if(l){m2.add(y);const S=document.activeElement;if(!l.contains(S)){const C=new CustomEvent(Vv,p2);l.addEventListener(Vv,f),l.dispatchEvent(C),C.defaultPrevented||(jV(LV(cP(l)),{select:!0}),document.activeElement===S&&ca(l))}return()=>{l.removeEventListener(Vv,f),setTimeout(()=>{const C=new CustomEvent(Bv,p2);l.addEventListener(Bv,h),l.dispatchEvent(C),C.defaultPrevented||ca(S??document.body,{select:!0}),l.removeEventListener(Bv,h),m2.remove(y)},0)}}},[l,f,h,y]);const v=w.useCallback(S=>{if(!n&&!i||y.paused)return;const k=S.key==="Tab"&&!S.altKey&&!S.ctrlKey&&!S.metaKey,C=document.activeElement;if(k&&C){const $=S.currentTarget,[T,Q]=MV($);T&&Q?!S.shiftKey&&C===Q?(S.preventDefault(),n&&ca(T,{select:!0})):S.shiftKey&&C===T&&(S.preventDefault(),n&&ca(Q,{select:!0})):C===$&&S.preventDefault()}},[n,i,y.paused]);return m.jsx(Ke.div,{tabIndex:-1,...o,ref:O,onKeyDown:v})});OO.displayName=PV;function jV(t,{select:e=!1}={}){const n=document.activeElement;for(const i of t)if(ca(i,{select:e}),document.activeElement!==n)return}function MV(t){const e=cP(t),n=g2(e,t),i=g2(e.reverse(),t);return[n,i]}function cP(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const r=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||r?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function g2(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const i of t)if(!(n?!i.checkVisibility({checkVisibilityCSS:!0}):DV(i,{upTo:e})))return i}function DV(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function NV(t){return t instanceof HTMLInputElement&&"select"in t}function ca(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&NV(t)&&e&&t.select()}}var m2=zV();function zV(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=O2(t,e),t.unshift(e)},remove(e){t=O2(t,e),t[0]?.resume()}}}function O2(t,e){const n=[...t],i=n.indexOf(e);return i!==-1&&n.splice(i,1),n}function LV(t){return t.filter(e=>e.tagName!=="A")}var ZV="Portal",ph=w.forwardRef((t,e)=>{const{container:n,...i}=t,[r,s]=w.useState(!1);Xn(()=>s(!0),[]);const o=n||r&&globalThis?.document?.body;return o?ql.createPortal(m.jsx(Ke.div,{...i,ref:e}),o):null});ph.displayName=ZV;var ig=0,Pc=null;function Ew(){w.useEffect(()=>{Pc||(Pc={start:y2(),end:y2()});const{start:t,end:e}=Pc;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),ig++,()=>{ig===1&&(Pc?.start.remove(),Pc?.end.remove(),Pc=null),ig=Math.max(0,ig-1)}},[])}function y2(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var xs=function(){return xs=Object.assign||function(e){for(var n,i=1,r=arguments.length;i"u")return iB;var e=rB(t),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,i-n+e[2]-e[0])}},oB=hP(),tu="data-scroll-locked",aB=function(t,e,n,i){var r=t.left,s=t.top,o=t.right,l=t.gap;return n===void 0&&(n="margin"),` - .`.concat(XV,` { - overflow: hidden `).concat(i,`; - padding-right: `).concat(l,"px ").concat(i,`; - } - body[`).concat(tu,`] { - overflow: hidden `).concat(i,`; - overscroll-behavior: contain; - `).concat([e&&"position: relative ".concat(i,";"),n==="margin"&&` - padding-left: `.concat(r,`px; - padding-top: `).concat(s,`px; - padding-right: `).concat(o,`px; - margin-left:0; - margin-top:0; - margin-right: `).concat(l,"px ").concat(i,`; - `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(i,";")].filter(Boolean).join(""),` - } - - .`).concat(Ig,` { - right: `).concat(l,"px ").concat(i,`; - } - - .`).concat(Xg,` { - margin-right: `).concat(l,"px ").concat(i,`; - } - - .`).concat(Ig," .").concat(Ig,` { - right: 0 `).concat(i,`; - } - - .`).concat(Xg," .").concat(Xg,` { - margin-right: 0 `).concat(i,`; - } - - body[`).concat(tu,`] { - `).concat(VV,": ").concat(l,`px; - } -`)},b2=function(){var t=parseInt(document.body.getAttribute(tu)||"0",10);return isFinite(t)?t:0},lB=function(){w.useEffect(function(){return document.body.setAttribute(tu,(b2()+1).toString()),function(){var t=b2()-1;t<=0?document.body.removeAttribute(tu):document.body.setAttribute(tu,t.toString())}},[])},cB=function(t){var e=t.noRelative,n=t.noImportant,i=t.gapMode,r=i===void 0?"margin":i;lB();var s=w.useMemo(function(){return sB(r)},[r]);return w.createElement(oB,{styles:aB(s,!e,r,n?"":"!important")})},_S=!1;if(typeof window<"u")try{var rg=Object.defineProperty({},"passive",{get:function(){return _S=!0,!0}});window.addEventListener("test",rg,rg),window.removeEventListener("test",rg,rg)}catch{_S=!1}var jc=_S?{passive:!1}:!1,uB=function(t){return t.tagName==="TEXTAREA"},pP=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!uB(t)&&n[e]==="visible")},dB=function(t){return pP(t,"overflowY")},fB=function(t){return pP(t,"overflowX")},S2=function(t,e){var n=e.ownerDocument,i=e;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var r=gP(t,i);if(r){var s=mP(t,i),o=s[1],l=s[2];if(o>l)return!0}i=i.parentNode}while(i&&i!==n.body);return!1},hB=function(t){var e=t.scrollTop,n=t.scrollHeight,i=t.clientHeight;return[e,n,i]},pB=function(t){var e=t.scrollLeft,n=t.scrollWidth,i=t.clientWidth;return[e,n,i]},gP=function(t,e){return t==="v"?dB(e):fB(e)},mP=function(t,e){return t==="v"?hB(e):pB(e)},gB=function(t,e){return t==="h"&&e==="rtl"?-1:1},mB=function(t,e,n,i,r){var s=gB(t,window.getComputedStyle(e).direction),o=s*i,l=n.target,u=e.contains(l),f=!1,h=o>0,p=0,O=0;do{if(!l)break;var y=mP(t,l),v=y[0],S=y[1],k=y[2],C=S-k-s*v;(v||C)&&gP(t,l)&&(p+=C,O+=v);var $=l.parentNode;l=$&&$.nodeType===Node.DOCUMENT_FRAGMENT_NODE?$.host:$}while(!u&&l!==document.body||u&&(e.contains(l)||e===l));return(h&&Math.abs(p)<1||!h&&Math.abs(O)<1)&&(f=!0),f},sg=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},x2=function(t){return[t.deltaX,t.deltaY]},w2=function(t){return t&&"current"in t?t.current:t},OB=function(t,e){return t[0]===e[0]&&t[1]===e[1]},yB=function(t){return` - .block-interactivity-`.concat(t,` {pointer-events: none;} - .allow-interactivity-`).concat(t,` {pointer-events: all;} -`)},vB=0,Mc=[];function bB(t){var e=w.useRef([]),n=w.useRef([0,0]),i=w.useRef(),r=w.useState(vB++)[0],s=w.useState(hP)[0],o=w.useRef(t);w.useEffect(function(){o.current=t},[t]),w.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(r));var S=IV([t.lockRef.current],(t.shards||[]).map(w2),!0).filter(Boolean);return S.forEach(function(k){return k.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),S.forEach(function(k){return k.classList.remove("allow-interactivity-".concat(r))})}}},[t.inert,t.lockRef.current,t.shards]);var l=w.useCallback(function(S,k){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!o.current.allowPinchZoom;var C=sg(S),$=n.current,T="deltaX"in S?S.deltaX:$[0]-C[0],Q="deltaY"in S?S.deltaY:$[1]-C[1],A,R=S.target,j=Math.abs(T)>Math.abs(Q)?"h":"v";if("touches"in S&&j==="h"&&R.type==="range")return!1;var L=window.getSelection(),ne=L&&L.anchorNode,G=ne?ne===R||ne.contains(R):!1;if(G)return!1;var H=S2(j,R);if(!H)return!0;if(H?A=j:(A=j==="v"?"h":"v",H=S2(j,R)),!H)return!1;if(!i.current&&"changedTouches"in S&&(T||Q)&&(i.current=A),!A)return!0;var Y=i.current||A;return mB(Y,k,S,Y==="h"?T:Q)},[]),u=w.useCallback(function(S){var k=S;if(!(!Mc.length||Mc[Mc.length-1]!==s)){var C="deltaY"in k?x2(k):sg(k),$=e.current.filter(function(A){return A.name===k.type&&(A.target===k.target||k.target===A.shadowParent)&&OB(A.delta,C)})[0];if($&&$.should){k.cancelable&&k.preventDefault();return}if(!$){var T=(o.current.shards||[]).map(w2).filter(Boolean).filter(function(A){return A.contains(k.target)}),Q=T.length>0?l(k,T[0]):!o.current.noIsolation;Q&&k.cancelable&&k.preventDefault()}}},[]),f=w.useCallback(function(S,k,C,$){var T={name:S,delta:k,target:C,should:$,shadowParent:SB(C)};e.current.push(T),setTimeout(function(){e.current=e.current.filter(function(Q){return Q!==T})},1)},[]),h=w.useCallback(function(S){n.current=sg(S),i.current=void 0},[]),p=w.useCallback(function(S){f(S.type,x2(S),S.target,l(S,t.lockRef.current))},[]),O=w.useCallback(function(S){f(S.type,sg(S),S.target,l(S,t.lockRef.current))},[]);w.useEffect(function(){return Mc.push(s),t.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:O}),document.addEventListener("wheel",u,jc),document.addEventListener("touchmove",u,jc),document.addEventListener("touchstart",h,jc),function(){Mc=Mc.filter(function(S){return S!==s}),document.removeEventListener("wheel",u,jc),document.removeEventListener("touchmove",u,jc),document.removeEventListener("touchstart",h,jc)}},[]);var y=t.removeScrollBar,v=t.inert;return w.createElement(w.Fragment,null,v?w.createElement(s,{styles:yB(r)}):null,y?w.createElement(cB,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function SB(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const xB=HV(fP,bB);var vO=w.forwardRef(function(t,e){return w.createElement(yO,xs({},t,{ref:e,sideCar:xB}))});vO.classNames=yO.classNames;var wB=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Dc=new WeakMap,og=new WeakMap,ag={},Fv=0,OP=function(t){return t&&(t.host||OP(t.parentNode))},kB=function(t,e){return e.map(function(n){if(t.contains(n))return n;var i=OP(n);return i&&t.contains(i)?i:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},CB=function(t,e,n,i){var r=kB(e,Array.isArray(t)?t:[t]);ag[n]||(ag[n]=new WeakMap);var s=ag[n],o=[],l=new Set,u=new Set(r),f=function(p){!p||l.has(p)||(l.add(p),f(p.parentNode))};r.forEach(f);var h=function(p){!p||u.has(p)||Array.prototype.forEach.call(p.children,function(O){if(l.has(O))h(O);else try{var y=O.getAttribute(i),v=y!==null&&y!=="false",S=(Dc.get(O)||0)+1,k=(s.get(O)||0)+1;Dc.set(O,S),s.set(O,k),o.push(O),S===1&&v&&og.set(O,!0),k===1&&O.setAttribute(n,"true"),v||O.setAttribute(i,"true")}catch(C){console.error("aria-hidden: cannot operate on ",O,C)}})};return h(e),l.clear(),Fv++,function(){o.forEach(function(p){var O=Dc.get(p)-1,y=s.get(p)-1;Dc.set(p,O),s.set(p,y),O||(og.has(p)||p.removeAttribute(i),og.delete(p)),y||p.removeAttribute(n)}),Fv--,Fv||(Dc=new WeakMap,Dc=new WeakMap,og=new WeakMap,ag={})}},Rw=function(t,e,n){n===void 0&&(n="data-aria-hidden");var i=Array.from(Array.isArray(t)?t:[t]),r=wB(t);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),CB(i,r,n,"aria-hidden")):function(){return null}},bO="Dialog",[yP]=Da(bO),[_B,rs]=yP(bO),Qw=t=>{const{__scopeDialog:e,children:n,open:i,defaultOpen:r,onOpenChange:s,modal:o=!0}=t,l=w.useRef(null),u=w.useRef(null),[f,h]=bu({prop:i,defaultProp:r??!1,onChange:s,caller:bO});return m.jsx(_B,{scope:e,triggerRef:l,contentRef:u,contentId:hi(),titleId:hi(),descriptionId:hi(),open:f,onOpenChange:h,onOpenToggle:w.useCallback(()=>h(p=>!p),[h]),modal:o,children:n})};Qw.displayName=bO;var vP="DialogTrigger",$B=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(vP,n),s=kt(e,r.triggerRef);return m.jsx(Ke.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":Dw(r.open),...i,ref:s,onClick:je(t.onClick,r.onOpenToggle)})});$B.displayName=vP;var Aw="DialogPortal",[TB,bP]=yP(Aw,{forceMount:void 0}),Pw=t=>{const{__scopeDialog:e,forceMount:n,children:i,container:r}=t,s=rs(Aw,e);return m.jsx(TB,{scope:e,forceMount:n,children:w.Children.map(i,o=>m.jsx(is,{present:n||s.open,children:m.jsx(ph,{asChild:!0,container:r,children:o})}))})};Pw.displayName=Aw;var fm="DialogOverlay",jw=w.forwardRef((t,e)=>{const n=bP(fm,t.__scopeDialog),{forceMount:i=n.forceMount,...r}=t,s=rs(fm,t.__scopeDialog);return s.modal?m.jsx(is,{present:i||s.open,children:m.jsx(RB,{...r,ref:e})}):null});jw.displayName=fm;var EB=Rl("DialogOverlay.RemoveScroll"),RB=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(fm,n),s=EV(),o=kt(e,s);return m.jsx(vO,{as:EB,allowPinchZoom:!0,shards:[r.contentRef],children:m.jsx(Ke.div,{"data-state":Dw(r.open),...i,ref:o,style:{pointerEvents:"auto",...i.style}})})}),Su="DialogContent",Mw=w.forwardRef((t,e)=>{const n=bP(Su,t.__scopeDialog),{forceMount:i=n.forceMount,...r}=t,s=rs(Su,t.__scopeDialog);return m.jsx(is,{present:i||s.open,children:s.modal?m.jsx(QB,{...r,ref:e}):m.jsx(AB,{...r,ref:e})})});Mw.displayName=Su;var QB=w.forwardRef((t,e)=>{const n=rs(Su,t.__scopeDialog),i=w.useRef(null),r=kt(e,n.contentRef,i);return w.useEffect(()=>{const s=i.current;if(s)return Rw(s)},[]),m.jsx(SP,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:je(t.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:je(t.onPointerDownOutside,s=>{const o=s.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&s.preventDefault()}),onFocusOutside:je(t.onFocusOutside,s=>s.preventDefault())})}),AB=w.forwardRef((t,e)=>{const n=rs(Su,t.__scopeDialog),i=w.useRef(!1),r=w.useRef(!1);return m.jsx(SP,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{t.onCloseAutoFocus?.(s),s.defaultPrevented||(i.current||n.triggerRef.current?.focus(),s.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:s=>{t.onInteractOutside?.(s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const o=s.target;n.triggerRef.current?.contains(o)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&r.current&&s.preventDefault()}})}),SP=w.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:s,...o}=t,l=rs(Su,n);return Ew(),m.jsx(m.Fragment,{children:m.jsx(OO,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:s,children:m.jsx(hh,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Dw(l.open),...o,ref:e,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),xP="DialogTitle",wP=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(xP,n);return m.jsx(Ke.h2,{id:r.titleId,...i,ref:e})});wP.displayName=xP;var kP="DialogDescription",PB=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(kP,n);return m.jsx(Ke.p,{id:r.descriptionId,...i,ref:e})});PB.displayName=kP;var CP="DialogClose",_P=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(CP,n);return m.jsx(Ke.button,{type:"button",...i,ref:e,onClick:je(t.onClick,()=>r.onOpenChange(!1))})});_P.displayName=CP;function Dw(t){return t?"open":"closed"}function jB(t){const e=w.useRef({value:t,previous:t});return w.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function MB(t){const[e,n]=w.useState(void 0);return Xn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const s=r[0];let o,l;if("borderBoxSize"in s){const u=s.borderBoxSize,f=Array.isArray(u)?u[0]:u;o=f.inlineSize,l=f.blockSize}else o=t.offsetWidth,l=t.offsetHeight;n({width:o,height:l})});return i.observe(t,{box:"border-box"}),()=>i.unobserve(t)}else n(void 0)},[t]),e}const DB=["top","right","bottom","left"],wa=Math.min,So=Math.max,hm=Math.round,lg=Math.floor,xo=t=>({x:t,y:t}),NB={left:"right",right:"left",bottom:"top",top:"bottom"};function $P(t,e,n){return So(t,wa(e,n))}function $o(t,e){return typeof t=="function"?t(e):t}function ka(t){return t.split("-")[0]}function Vu(t){return t.split("-")[1]}function Nw(t){return t==="x"?"y":"x"}function zw(t){return t==="y"?"height":"width"}function Cs(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function Lw(t){return Nw(Cs(t))}function zB(t,e,n){n===void 0&&(n=!1);const i=Vu(t),r=Lw(t),s=zw(r);let o=r==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=pm(o)),[o,pm(o)]}function LB(t){const e=pm(t);return[$S(t),e,$S(e)]}function $S(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const k2=["left","right"],C2=["right","left"],ZB=["top","bottom"],IB=["bottom","top"];function XB(t,e,n){switch(t){case"top":case"bottom":return n?e?C2:k2:e?k2:C2;case"left":case"right":return e?ZB:IB;default:return[]}}function VB(t,e,n,i){const r=Vu(t);let s=XB(ka(t),n==="start",i);return r&&(s=s.map(o=>o+"-"+r),e&&(s=s.concat(s.map($S)))),s}function pm(t){const e=ka(t);return NB[e]+t.slice(e.length)}function BB(t){var e,n,i,r;return{top:(e=t.top)!=null?e:0,right:(n=t.right)!=null?n:0,bottom:(i=t.bottom)!=null?i:0,left:(r=t.left)!=null?r:0}}function TP(t){return typeof t!="number"?BB(t):{top:t,right:t,bottom:t,left:t}}function gm(t){const{x:e,y:n,width:i,height:r}=t;return{width:i,height:r,top:n,left:e,right:e+i,bottom:n+r,x:e,y:n}}function _2(t,e,n){let{reference:i,floating:r}=t;const s=Cs(e),o=Lw(e),l=zw(o),u=ka(e),f=s==="y",h=i.x+i.width/2-r.width/2,p=i.y+i.height/2-r.height/2,O=i[l]/2-r[l]/2;let y;switch(u){case"top":y={x:h,y:i.y-r.height};break;case"bottom":y={x:h,y:i.y+i.height};break;case"right":y={x:i.x+i.width,y:p};break;case"left":y={x:i.x-r.width,y:p};break;default:y={x:i.x,y:i.y}}const v=Vu(e);return v&&(y[o]+=O*(v==="end"?1:-1)*(n&&f?-1:1)),y}async function UB(t,e){var n;e===void 0&&(e={});const{x:i,y:r,platform:s,rects:o,elements:l,strategy:u}=t,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:p="floating",altBoundary:O=!1,padding:y=0}=$o(e,t),v=TP(y),k=l[O?p==="floating"?"reference":"floating":p],C=gm(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(k)))==null||n?k:k.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:f,rootBoundary:h,strategy:u})),$=p==="floating"?{x:i,y:r,width:o.floating.width,height:o.floating.height}:o.reference,T=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),Q=await(s.isElement==null?void 0:s.isElement(T))&&await(s.getScale==null?void 0:s.getScale(T))||{x:1,y:1},A=gm(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:$,offsetParent:T,strategy:u}):$);return{top:(C.top-A.top+v.top)/Q.y,bottom:(A.bottom-C.bottom+v.bottom)/Q.y,left:(C.left-A.left+v.left)/Q.x,right:(A.right-C.right+v.right)/Q.x}}const qB=50,YB=async(t,e,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:UB},u=await(o.isRTL==null?void 0:o.isRTL(e));let f=await o.getElementRects({reference:t,floating:e,strategy:r}),{x:h,y:p}=_2(f,i,u),O=i,y=0;const v={};for(let S=0;S({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:s,platform:o,elements:l,middlewareData:u}=e,{element:f,padding:h=0}=$o(t,e)||{};if(f==null)return{};const p=TP(h),O={x:n,y:i},y=Lw(r),v=zw(y),S=await o.getDimensions(f),k=y==="y",C=k?"top":"left",$=k?"bottom":"right",T=k?"clientHeight":"clientWidth",Q=s.reference[v]+s.reference[y]-O[y]-s.floating[v],A=O[y]-s.reference[y],R=await(o.getOffsetParent==null?void 0:o.getOffsetParent(f));let j=R?R[T]:0;(!j||!await(o.isElement==null?void 0:o.isElement(R)))&&(j=l.floating[T]||s.floating[v]);const L=Q/2-A/2,ne=j/2-S[v]/2-1,G=wa(p[C],ne),H=wa(p[$],ne),Y=j-S[v]-H,re=j/2-S[v]/2+L,K=$P(G,re,Y),ye=!u.arrow&&Vu(r)!=null&&re!==K&&s.reference[v]/2-(reK<=0)){var H,Y;const K=(((H=s.flip)==null?void 0:H.index)||0)+1,ye=j[K];if(ye&&(!(p==="alignment"?$!==Cs(ye):!1)||G.every(ce=>Cs(ce.placement)===$?ce.overflows[0]>0:!0)))return{data:{index:K,overflows:G},reset:{placement:ye}};let N=(Y=G.filter(W=>W.overflows[0]<=0).sort((W,ce)=>W.overflows[1]-ce.overflows[1])[0])==null?void 0:Y.placement;if(!N)switch(y){case"bestFit":{var re;const W=(re=G.filter(ce=>{if(R){const oe=Cs(ce.placement);return oe===$||oe==="y"}return!0}).map(ce=>[ce.placement,ce.overflows.filter(oe=>oe>0).reduce((oe,le)=>oe+le,0)]).sort((ce,oe)=>ce[1]-oe[1])[0])==null?void 0:re[0];W&&(N=W);break}case"initialPlacement":N=l;break}if(r!==N)return{reset:{placement:N}}}return{}}}};function $2(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function T2(t){return DB.some(e=>t[e]>=0)}const HB=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:i}=e,{strategy:r="referenceHidden",...s}=$o(t,e);switch(r){case"referenceHidden":{const o=await i.detectOverflow(e,{...s,elementContext:"reference"}),l=$2(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:T2(l)}}}case"escaped":{const o=await i.detectOverflow(e,{...s,altBoundary:!0}),l=$2(o,n.floating);return{data:{escapedOffsets:l,escaped:T2(l)}}}default:return{}}}}},EP=new Set(["left","top"]);async function WB(t,e){const{placement:n,platform:i,elements:r}=t,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),o=ka(n),l=Vu(n),u=Cs(n)==="y",f=EP.has(o)?-1:1,h=s&&u?-1:1,p=$o(e,t);let{mainAxis:O,crossAxis:y,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof v=="number"&&(y=l==="end"?v*-1:v),u?{x:y*h,y:O*f}:{x:O*f,y:y*h}}const KB=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:r,y:s,placement:o,middlewareData:l}=e,u=await WB(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:r+u.x,y:s+u.y,data:{...u,placement:o}}}}},JB=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:r,platform:s}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:u={fn:$=>{let{x:T,y:Q}=$;return{x:T,y:Q}}},...f}=$o(t,e),h={x:n,y:i},p=await s.detectOverflow(e,f),O=Cs(r),y=Nw(O);let v=h[y],S=h[O];const k=($,T)=>$P(T+p[$==="y"?"top":"left"],T,T-p[$==="y"?"bottom":"right"]);o&&(v=k(y,v)),l&&(S=k(O,S));const C=u.fn({...e,[y]:v,[O]:S});return{...C,data:{x:C.x-n,y:C.y-i,enabled:{[y]:o,[O]:l}}}}}},e6=function(t){return t===void 0&&(t={}),{options:t,fn(e){var n,i;const{x:r,y:s,placement:o,rects:l,middlewareData:u}=e,{offset:f=0,mainAxis:h=!0,crossAxis:p=!0}=$o(t,e),O={x:r,y:s},y=Cs(o),v=Nw(y);let S=O[v],k=O[y];const C=$o(f,e),$=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:(n=C.mainAxis)!=null?n:0,crossAxis:(i=C.crossAxis)!=null?i:0};if(h){const A=v==="y"?"height":"width",R=l.reference[v]-l.floating[A]+$.mainAxis,j=l.reference[v]+l.reference[A]-$.mainAxis;Sj&&(S=j)}if(p){var T,Q;const A=v==="y"?"width":"height",R=EP.has(ka(o)),j=l.reference[y]-l.floating[A]+(R&&((T=u.offset)==null?void 0:T[y])||0)+(R?0:$.crossAxis),L=l.reference[y]+l.reference[A]+(R?0:((Q=u.offset)==null?void 0:Q[y])||0)-(R?$.crossAxis:0);kL&&(k=L)}return{[v]:S,[y]:k}}}},t6=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:i,platform:r,elements:s}=e,{apply:o=()=>{},...l}=$o(t,e),u=await r.detectOverflow(e,l),f=ka(n),h=Vu(n),p=Cs(n)==="y",{width:O,height:y}=i.floating;let v,S;f==="top"||f==="bottom"?(v=f,S=h===(await(r.isRTL==null?void 0:r.isRTL(s.floating))?"start":"end")?"left":"right"):(S=f,v=h==="end"?"top":"bottom");const k=y-u.top-u.bottom,C=O-u.left-u.right,$=wa(y-u[v],k),T=wa(O-u[S],C),Q=e.middlewareData.shift,A=!Q;let R=$,j=T;Q!=null&&Q.enabled.x&&(j=C),Q!=null&&Q.enabled.y&&(R=k),A&&!h&&(p?j=O-2*So(u.left,u.right):R=y-2*So(u.top,u.bottom)),await o({...e,availableWidth:j,availableHeight:R});const L=await r.getDimensions(s.floating);return O!==L.width||y!==L.height?{reset:{rects:!0}}:{}}}};function SO(){return typeof window<"u"}function Bu(t){return RP(t)?(t.nodeName||"").toLowerCase():"#document"}function Bi(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Qo(t){var e;return(e=(RP(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function RP(t){return SO()?t instanceof Node||t instanceof Bi(t).Node:!1}function Ds(t){return SO()?t instanceof Element||t instanceof Bi(t).Element:!1}function Na(t){return SO()?t instanceof HTMLElement||t instanceof Bi(t).HTMLElement:!1}function E2(t){return!SO()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Bi(t).ShadowRoot}function xO(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=Ns(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&r!=="inline"&&r!=="contents"}function n6(t){return/^(table|td|th)$/.test(Bu(t))}function wO(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const i6=/transform|translate|scale|rotate|perspective|filter/,r6=/paint|layout|strict|content/,ul=t=>!!t&&t!=="none";let Gv;function Zw(t){const e=Ds(t)?Ns(t):t;return ul(e.transform)||ul(e.translate)||ul(e.scale)||ul(e.rotate)||ul(e.perspective)||!Iw()&&(ul(e.backdropFilter)||ul(e.filter))||i6.test(e.willChange||"")||r6.test(e.contain||"")}function s6(t){let e=Ql(t);for(;Na(e)&&!Rf(e);){if(Zw(e))return e;if(wO(e))return null;e=Ql(e)}return null}function Iw(){return Gv==null&&(Gv=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Gv}function Rf(t){return/^(html|body|#document)$/.test(Bu(t))}function Ns(t){return Bi(t).getComputedStyle(t)}function kO(t){return Ds(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Ql(t){if(Bu(t)==="html")return t;const e=t.assignedSlot||t.parentNode||E2(t)&&t.host||Qo(t);return E2(e)?e.host:e}function QP(t){const e=Ql(t);return Rf(e)?(t.ownerDocument||t).body:Na(e)&&xO(e)?e:QP(e)}function Qf(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=QP(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),o=Bi(r);if(s){const l=TS(o);return e.concat(o,o.visualViewport||[],xO(r)?r:[],l&&n?Qf(l):[])}else return e.concat(r,Qf(r,[],n))}function TS(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function AP(t){const e=Ns(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=Na(t),s=r?t.offsetWidth:n,o=r?t.offsetHeight:i,l=hm(n)!==s||hm(i)!==o;return l&&(n=s,i=o),{width:n,height:i,$:l}}function Xw(t){return Ds(t)?t:t.contextElement}function nu(t){const e=Xw(t);if(!Na(e))return xo(1);const n=e.getBoundingClientRect(),{width:i,height:r,$:s}=AP(e);let o=(s?hm(n.width):n.width)/i,l=(s?hm(n.height):n.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const o6=xo(0);function PP(t){const e=Bi(t);return!Iw()||!e.visualViewport?o6:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function a6(t,e,n){return e===void 0&&(e=!1),!!n&&e&&n===Bi(t)}function Al(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),s=Xw(t);let o=xo(1);e&&(i?Ds(i)&&(o=nu(i)):o=nu(t));const l=a6(s,n,i)?PP(s):xo(0);let u=(r.left+l.x)/o.x,f=(r.top+l.y)/o.y,h=r.width/o.x,p=r.height/o.y;if(s&&i){const O=Bi(s),y=Ds(i)?Bi(i):i;let v=O,S=TS(v);for(;S&&y!==v;){const k=nu(S),C=S.getBoundingClientRect(),$=Ns(S),T=C.left+(S.clientLeft+parseFloat($.paddingLeft))*k.x,Q=C.top+(S.clientTop+parseFloat($.paddingTop))*k.y;u*=k.x,f*=k.y,h*=k.x,p*=k.y,u+=T,f+=Q,v=Bi(S),S=TS(v)}}return gm({width:h,height:p,x:u,y:f})}function CO(t,e){const n=kO(t).scrollLeft;return e?e.left+n:Al(Qo(t)).left+n}function jP(t,e){const n=t.getBoundingClientRect(),i=n.left+e.scrollLeft-CO(t,n),r=n.top+e.scrollTop;return{x:i,y:r}}function l6(t){let{elements:e,rect:n,offsetParent:i,strategy:r}=t;const s=r==="fixed",o=Qo(i),l=e?wO(e.floating):!1;if(i===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},f=xo(1);const h=xo(0),p=Na(i);if((p||!s)&&((Bu(i)!=="body"||xO(o))&&(u=kO(i)),p)){const y=Al(i);f=nu(i),h.x=y.x+i.clientLeft,h.y=y.y+i.clientTop}const O=o&&!p&&!s?jP(o,u):xo(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+h.x+O.x,y:n.y*f.y-u.scrollTop*f.y+h.y+O.y}}function c6(t){return t.getClientRects?Array.from(t.getClientRects()):[]}function u6(t){const e=kO(t),n=t.ownerDocument.body,i=So(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),r=So(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-e.scrollLeft+CO(t);const o=-e.scrollTop;return Ns(n).direction==="rtl"&&(s+=So(t.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:o}}const d6=25;function f6(t,e,n){n===void 0&&(n="viewport");const i=n==="layoutViewport",r=Bi(t),s=Qo(t),o=r.visualViewport;let l=s.clientWidth,u=s.clientHeight,f=0,h=0;if(o){const O=!Iw()||e==="fixed";i?O||(f=-o.offsetLeft,h=-o.offsetTop):(l=o.width,u=o.height,O&&(f=o.offsetLeft,h=o.offsetTop))}if(CO(s)<=0){const O=s.ownerDocument,y=O.body,v=getComputedStyle(y),S=O.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,k=Math.abs(s.clientWidth-y.clientWidth-S),C=getComputedStyle(s).scrollbarGutter==="stable both-edges"?k/2:k;C<=d6&&(l-=C)}return{width:l,height:u,x:f,y:h}}function h6(t,e){const n=Al(t,!0,e==="fixed"),i=n.top+t.clientTop,r=n.left+t.clientLeft,s=nu(t),o=t.clientWidth*s.x,l=t.clientHeight*s.y,u=r*s.x,f=i*s.y;return{width:o,height:l,x:u,y:f}}function R2(t,e,n){let i;if(e==="viewport"||e==="layoutViewport")i=f6(t,n,e);else if(e==="document")i=u6(Qo(t));else if(Ds(e))i=h6(e,n);else{const r=PP(t);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return gm(i)}function p6(t,e){const n=e.get(t);if(n)return n;let i=Qf(t,[],!1).filter(l=>Ds(l)&&Bu(l)!=="body"),r=null;const s=Ns(t).position==="fixed";let o=s?Ql(t):t;for(;Ds(o)&&!Rf(o);){const l=Ns(o),u=Zw(o),f=r?r.position:s?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&l.position==="static")?i=i.filter(p=>p!==o):r=l,o=Ql(o)}return e.set(t,i),i}function g6(t){let{element:e,boundary:n,rootBoundary:i,strategy:r}=t;const o=[...n==="clippingAncestors"?wO(e)?[]:p6(e,this._c):[].concat(n),i],l=R2(e,o[0],r);let u=l.top,f=l.right,h=l.bottom,p=l.left;for(let O=1;O{l(!1,1e-7)},1e3)}j=!1}try{i=new IntersectionObserver(L,{...R,root:s.ownerDocument})}catch{i=new IntersectionObserver(L,R)}i.observe(t)}const u=Bi(t),f=()=>l(n);return u.addEventListener("resize",f),l(!0),()=>{u.removeEventListener("resize",f),o()}}function x6(t,e,n,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=i,f=Xw(t),h=r||s?[...f?Qf(f):[],...e?Qf(e):[]]:[];h.forEach(C=>{r&&C.addEventListener("scroll",n),s&&C.addEventListener("resize",n)});const p=f&&l?S6(f,n,s):null;let O=-1,y=null;o&&(y=new ResizeObserver(C=>{let[$]=C;$&&$.target===f&&y&&e&&(y.unobserve(e),cancelAnimationFrame(O),O=requestAnimationFrame(()=>{var T;(T=y)==null||T.observe(e)})),n()}),f&&!u&&y.observe(f),e&&y.observe(e));let v,S=u?Al(t):null;u&&k();function k(){const C=Al(t);S&&!DP(S,C)&&n(),S=C,v=requestAnimationFrame(k)}return n(),()=>{var C;h.forEach($=>{r&&$.removeEventListener("scroll",n),s&&$.removeEventListener("resize",n)}),p?.(),(C=y)==null||C.disconnect(),y=null,u&&cancelAnimationFrame(v)}}const w6=KB,k6=JB,C6=GB,_6=t6,$6=HB,A2=FB,T6=e6,E6=(t,e,n)=>{const i=new Map,r=n??{},s={...b6,...r.platform,_c:i};return YB(t,e,{...r,platform:s})};var R6=typeof document<"u",Q6=function(){},Vg=R6?w.useLayoutEffect:Q6;function mm(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,i,r;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(i=n;i--!==0;)if(!mm(t[i],e[i]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(e).length)return!1;for(i=n;i--!==0;)if(!{}.hasOwnProperty.call(e,r[i]))return!1;for(i=n;i--!==0;){const s=r[i];if(!(s==="_owner"&&t.$$typeof)&&!mm(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function NP(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function P2(t,e){const n=NP(t);return Math.round(e*n)/n}function Wv(t){const e=w.useRef(t);return Vg(()=>{e.current=t}),e}function A6(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:i=[],platform:r,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:u,open:f}=t,[h,p]=w.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[O,y]=w.useState(i);mm(O,i)||y(i);const[v,S]=w.useState(null),[k,C]=w.useState(null),$=w.useCallback(ce=>{ce!==R.current&&(R.current=ce,S(ce))},[]),T=w.useCallback(ce=>{ce!==j.current&&(j.current=ce,C(ce))},[]),Q=s||v,A=o||k,R=w.useRef(null),j=w.useRef(null),L=w.useRef(h),ne=u!=null,G=Wv(u),H=Wv(r),Y=Wv(f),re=w.useCallback(()=>{if(!R.current||!j.current)return;const ce={placement:e,strategy:n,middleware:O};H.current&&(ce.platform=H.current),E6(R.current,j.current,ce).then(oe=>{const le={...oe,isPositioned:Y.current!==!1};K.current&&!mm(L.current,le)&&(L.current=le,ql.flushSync(()=>{p(le)}))})},[O,e,n,H,Y]);Vg(()=>{f===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,p(ce=>({...ce,isPositioned:!1})))},[f]);const K=w.useRef(!1);Vg(()=>(K.current=!0,()=>{K.current=!1}),[]),Vg(()=>{if(Q&&(R.current=Q),A&&(j.current=A),Q&&A){if(G.current)return G.current(Q,A,re);re()}},[Q,A,re,G,ne]);const ye=w.useMemo(()=>({reference:R,floating:j,setReference:$,setFloating:T}),[$,T]),N=w.useMemo(()=>({reference:Q,floating:A}),[Q,A]),W=w.useMemo(()=>{const ce={position:n,left:0,top:0};if(!N.floating)return ce;const oe=P2(N.floating,h.x),le=P2(N.floating,h.y);return l?{...ce,transform:"translate("+oe+"px, "+le+"px)",...NP(N.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:oe,top:le}},[n,l,N.floating,h.x,h.y]);return w.useMemo(()=>({...h,update:re,refs:ye,elements:N,floatingStyles:W}),[h,re,ye,N,W])}const P6=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:i,padding:r}=typeof t=="function"?t(n):t;return i&&e(i)?i.current!=null?A2({element:i.current,padding:r}).fn(n):{}:i?A2({element:i,padding:r}).fn(n):{}}}},j6=(t,e)=>{const n=w6(t);return{name:n.name,fn:n.fn,options:[t,e]}},M6=(t,e)=>{const n=k6(t);return{name:n.name,fn:n.fn,options:[t,e]}},D6=(t,e)=>({fn:T6(t).fn,options:[t,e]}),N6=(t,e)=>{const n=C6(t);return{name:n.name,fn:n.fn,options:[t,e]}},z6=(t,e)=>{const n=_6(t);return{name:n.name,fn:n.fn,options:[t,e]}},L6=(t,e)=>{const n=$6(t);return{name:n.name,fn:n.fn,options:[t,e]}},Z6=(t,e)=>{const n=P6(t);return{name:n.name,fn:n.fn,options:[t,e]}};var I6="Arrow",zP=w.forwardRef((t,e)=>{const{children:n,width:i=10,height:r=5,...s}=t;return m.jsx(Ke.svg,{...s,ref:e,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});zP.displayName=I6;var X6=zP,Vw="Popper",[LP,Uu]=Da(Vw),[V6,ZP]=LP(Vw),IP=t=>{const{__scopePopper:e,children:n}=t,[i,r]=w.useState(null),[s,o]=w.useState(void 0);return m.jsx(V6,{scope:e,anchor:i,onAnchorChange:r,placementState:s,setPlacementState:o,children:n})};IP.displayName=Vw;var XP="PopperAnchor",VP=w.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:i,...r}=t,s=ZP(XP,n),o=w.useRef(null),l=s.onAnchorChange,u=w.useCallback(v=>{o.current=v,v&&l(v)},[l]),f=kt(e,u),h=w.useRef(null);w.useEffect(()=>{if(!i)return;const v=h.current;h.current=i.current,v!==h.current&&l(h.current)});const p=s.placementState&&Uw(s.placementState),O=p?.[0],y=p?.[1];return i?null:m.jsx(Ke.div,{"data-radix-popper-side":O,"data-radix-popper-align":y,...r,ref:f})});VP.displayName=XP;var Bw="PopperContent",[B6,U6]=LP(Bw),BP=w.forwardRef((t,e)=>{const{__scopePopper:n,side:i="bottom",sideOffset:r=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:h=0,sticky:p="partial",hideWhenDetached:O=!1,updatePositionStrategy:y="optimized",onPlaced:v,...S}=t,k=ZP(Bw,n),[C,$]=w.useState(null),T=kt(e,$),[Q,A]=w.useState(null),R=MB(Q),j=R?.width??0,L=R?.height??0,ne=i+(s!=="center"?"-"+s:""),G=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},H=Array.isArray(f)?f:[f],Y=H.length>0,re={padding:G,boundary:H.filter(Y6),altBoundary:Y},{refs:K,floatingStyles:ye,placement:N,isPositioned:W,middlewareData:ce}=A6({strategy:"fixed",placement:ne,whileElementsMounted:(...pe)=>x6(...pe,{animationFrame:y==="always"}),elements:{reference:k.anchor},middleware:[j6({mainAxis:r+L,alignmentAxis:o}),u&&M6({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?D6():void 0,...re}),u&&N6({...re}),z6({...re,apply:({elements:pe,rects:xe,availableWidth:Ze,availableHeight:Xe})=>{const{width:Ge,height:Qt}=xe.reference,lt=pe.floating.style;lt.setProperty("--radix-popper-available-width",`${Ze}px`),lt.setProperty("--radix-popper-available-height",`${Xe}px`),lt.setProperty("--radix-popper-anchor-width",`${Ge}px`),lt.setProperty("--radix-popper-anchor-height",`${Qt}px`)}}),Q&&Z6({element:Q,padding:l}),F6({arrowWidth:j,arrowHeight:L}),O&&L6({strategy:"referenceHidden",...re,boundary:Y?re.boundary:void 0})]}),oe=k.setPlacementState;Xn(()=>(oe(N),()=>{oe(void 0)}),[N,oe]);const[le,D]=Uw(N),P=Mr(v);Xn(()=>{W&&P?.()},[W,P]);const I=ce.arrow?.x,X=ce.arrow?.y,V=ce.arrow?.centerOffset!==0,[J,se]=w.useState();return Xn(()=>{C&&se(window.getComputedStyle(C).zIndex)},[C]),m.jsx("div",{ref:K.setFloating,"data-radix-popper-content-wrapper":"",style:{...ye,transform:W?ye.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[ce.transformOrigin?.x,ce.transformOrigin?.y].join(" "),...ce.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:m.jsx(B6,{scope:n,placedSide:le,placedAlign:D,onArrowChange:A,arrowX:I,arrowY:X,shouldHideArrow:V,children:m.jsx(Ke.div,{"data-side":le,"data-align":D,...S,ref:T,style:{...S.style,animation:W?void 0:"none"}})})})});BP.displayName=Bw;var UP="PopperArrow",q6={top:"bottom",right:"left",bottom:"top",left:"right"},qP=w.forwardRef(function(e,n){const{__scopePopper:i,...r}=e,s=U6(UP,i),o=q6[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(X6,{...r,ref:n,style:{...r.style,display:"block"}})})});qP.displayName=UP;function Y6(t){return t!==null}var F6=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:i,middlewareData:r}=e,o=r.arrow?.centerOffset!==0,l=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[f,h]=Uw(n),p={start:"0%",center:"50%",end:"100%"}[h],O=(r.arrow?.x??0)+l/2,y=(r.arrow?.y??0)+u/2;let v="",S="";return f==="bottom"?(v=o?p:`${O}px`,S=`${-u}px`):f==="top"?(v=o?p:`${O}px`,S=`${i.floating.height+u}px`):f==="right"?(v=`${-u}px`,S=o?p:`${y}px`):f==="left"&&(v=`${i.floating.width+u}px`,S=o?p:`${y}px`),{data:{x:v,y:S}}}});function Uw(t){const[e,n="center"]=t.split("-");return[e,n]}var qw=IP,Yw=VP,Fw=BP,Gw=qP,Kv=!1;function G6(){const[t,e]=w.useState(Kv);return w.useEffect(()=>{Kv||(Kv=!0,e(!0))},[]),t}var YP=pO[" useSyncExternalStore ".trim().toString()];function H6(){return()=>{}}function W6(){return YP(H6,()=>!0,()=>!1)}var K6=typeof YP=="function"?W6:G6,Jv="rovingFocusGroup.onEntryFocus",J6={bubbles:!1,cancelable:!0},gh="RovingFocusGroup",[ES,FP,e8]=_w(gh),[t8,GP]=Da(gh,[e8]),[n8,i8]=t8(gh),HP=w.forwardRef((t,e)=>m.jsx(ES.Provider,{scope:t.__scopeRovingFocusGroup,children:m.jsx(ES.Slot,{scope:t.__scopeRovingFocusGroup,children:m.jsx(r8,{...t,ref:e})})}));HP.displayName=gh;var r8=w.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:i,loop:r=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:h=!1,...p}=t,O=w.useRef(null),y=kt(e,O),v=$w(s),[S,k]=bu({prop:o,defaultProp:l??null,onChange:u,caller:gh}),[C,$]=w.useState(!1),T=Mr(f),Q=FP(n),A=w.useRef(!1),[R,j]=w.useState(0);return w.useEffect(()=>{const L=O.current;if(L)return L.addEventListener(Jv,T),()=>L.removeEventListener(Jv,T)},[T]),m.jsx(n8,{scope:n,orientation:i,dir:v,loop:r,currentTabStopId:S,onItemFocus:w.useCallback(L=>k(L),[k]),onItemShiftTab:w.useCallback(()=>$(!0),[]),onFocusableItemAdd:w.useCallback(()=>j(L=>L+1),[]),onFocusableItemRemove:w.useCallback(()=>j(L=>L-1),[]),children:m.jsx(Ke.div,{tabIndex:C||R===0?-1:0,"data-orientation":i,...p,ref:y,style:{outline:"none",...t.style},onMouseDown:je(t.onMouseDown,()=>{A.current=!0}),onFocus:je(t.onFocus,L=>{const ne=!A.current;if(L.target===L.currentTarget&&ne&&!C){const G=new CustomEvent(Jv,J6);if(L.currentTarget.dispatchEvent(G),!G.defaultPrevented){const H=Q().filter(N=>N.focusable),Y=H.find(N=>N.active),re=H.find(N=>N.id===S),ye=[Y,re,...H].filter(Boolean).map(N=>N.ref.current);JP(ye,h)}}A.current=!1}),onBlur:je(t.onBlur,()=>$(!1))})})}),WP="RovingFocusGroupItem",KP=w.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:i=!0,active:r=!1,tabStopId:s,children:o,...l}=t,u=hi(),f=s||u,h=i8(WP,n),p=h.currentTabStopId===f,O=FP(n),{onFocusableItemAdd:y,onFocusableItemRemove:v,currentTabStopId:S}=h,k=K6();return Xn(()=>{if(!(!k||!i))return y(),()=>v()},[k,i,y,v]),w.useEffect(()=>{if(!(k||!i))return y(),()=>v()},[k,i,y,v]),m.jsx(ES.ItemSlot,{scope:n,id:f,focusable:i,active:r,children:m.jsx(Ke.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...l,ref:e,onMouseDown:je(t.onMouseDown,C=>{i?h.onItemFocus(f):C.preventDefault()}),onFocus:je(t.onFocus,()=>h.onItemFocus(f)),onKeyDown:je(t.onKeyDown,C=>{if(C.key==="Tab"&&C.shiftKey){h.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const $=a8(C,h.orientation,h.dir);if($!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let Q=O().filter(A=>A.focusable).map(A=>A.ref.current);if($==="last")Q.reverse();else if($==="prev"||$==="next"){$==="prev"&&Q.reverse();const A=Q.indexOf(C.currentTarget);Q=h.loop?l8(Q,A+1):Q.slice(A+1)}setTimeout(()=>JP(Q))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:S!=null}):o})})});KP.displayName=WP;var s8={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function o8(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function a8(t,e,n){const i=o8(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return s8[i]}function JP(t,e=!1){const n=document.activeElement;for(const i of t)if(i===n||(i.focus({preventScroll:e}),document.activeElement!==n))return}function l8(t,e){return t.map((n,i)=>t[(e+i)%t.length])}var c8=HP,u8=KP,RS=["Enter"," "],d8=["ArrowDown","PageUp","Home"],ej=["ArrowUp","PageDown","End"],f8=[...d8,...ej],h8={ltr:[...RS,"ArrowRight"],rtl:[...RS,"ArrowLeft"]},p8={ltr:["ArrowLeft"],rtl:["ArrowRight"]},mh="Menu",[Af,g8,m8]=_w(mh),[Yl,tj]=Da(mh,[m8,Uu,GP]),_O=Uu(),nj=GP(),[O8,Fl]=Yl(mh),[y8,Oh]=Yl(mh),ij=t=>{const{__scopeMenu:e,open:n=!1,children:i,dir:r,onOpenChange:s,modal:o=!0}=t,l=_O(e),[u,f]=w.useState(null),h=w.useRef(!1),p=Mr(s),O=$w(r);return w.useEffect(()=>{const y=()=>{h.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>h.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),w.useEffect(()=>{if(!n)return;const y=()=>p(!1);return window.addEventListener("blur",y),()=>window.removeEventListener("blur",y)},[n,p]),m.jsx(qw,{...l,children:m.jsx(O8,{scope:e,open:n,onOpenChange:p,content:u,onContentChange:f,children:m.jsx(y8,{scope:e,onClose:w.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:h,dir:O,modal:o,children:i})})})};ij.displayName=mh;var v8="MenuAnchor",Hw=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t,r=_O(n);return m.jsx(Yw,{...r,...i,ref:e})});Hw.displayName=v8;var Ww="MenuPortal",[b8,rj]=Yl(Ww,{forceMount:void 0}),sj=t=>{const{__scopeMenu:e,forceMount:n,children:i,container:r}=t,s=Fl(Ww,e);return m.jsx(b8,{scope:e,forceMount:n,children:m.jsx(is,{present:n||s.open,children:m.jsx(ph,{asChild:!0,container:r,children:i})})})};sj.displayName=Ww;var jr="MenuContent",[S8,Kw]=Yl(jr),oj=w.forwardRef((t,e)=>{const n=rj(jr,t.__scopeMenu),{forceMount:i=n.forceMount,...r}=t,s=Fl(jr,t.__scopeMenu),o=Oh(jr,t.__scopeMenu);return m.jsx(Af.Provider,{scope:t.__scopeMenu,children:m.jsx(is,{present:i||s.open,children:m.jsx(Af.Slot,{scope:t.__scopeMenu,children:o.modal?m.jsx(x8,{...r,ref:e}):m.jsx(w8,{...r,ref:e})})})})}),x8=w.forwardRef((t,e)=>{const n=Fl(jr,t.__scopeMenu),i=w.useRef(null),r=kt(e,i);return w.useEffect(()=>{const s=i.current;if(s)return Rw(s)},[]),m.jsx(Jw,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:je(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),w8=w.forwardRef((t,e)=>{const n=Fl(jr,t.__scopeMenu);return m.jsx(Jw,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),k8=Rl("MenuContent.ScrollLock"),Jw=w.forwardRef((t,e)=>{const{__scopeMenu:n,loop:i=!1,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:O,onDismiss:y,disableOutsideScroll:v,...S}=t,k=Fl(jr,n),C=Oh(jr,n),$=_O(n),T=nj(n),Q=g8(n),[A,R]=w.useState(null),j=w.useRef(null),L=kt(e,j,k.onContentChange),ne=w.useRef(0),G=w.useRef(""),H=w.useRef(0),Y=w.useRef(null),re=w.useRef("right"),K=w.useRef(0),ye=v?vO:w.Fragment,N=v?{as:k8,allowPinchZoom:!0}:void 0,W=oe=>{const le=G.current+oe,D=Q().filter(se=>!se.disabled),P=document.activeElement,I=D.find(se=>se.ref.current===P)?.textValue,X=D.map(se=>se.textValue),V=D8(X,le,I),J=D.find(se=>se.textValue===V)?.ref.current;(function se(pe){G.current=pe,window.clearTimeout(ne.current),pe!==""&&(ne.current=window.setTimeout(()=>se(""),1e3))})(le),J&&setTimeout(()=>J.focus())};w.useEffect(()=>()=>window.clearTimeout(ne.current),[]),Ew();const ce=w.useCallback(oe=>re.current===Y.current?.side&&z8(oe,Y.current?.area),[]);return m.jsx(S8,{scope:n,searchRef:G,onItemEnter:w.useCallback(oe=>{ce(oe)&&oe.preventDefault()},[ce]),onItemLeave:w.useCallback(oe=>{ce(oe)||(j.current?.focus(),R(null))},[ce]),onTriggerLeave:w.useCallback(oe=>{ce(oe)&&oe.preventDefault()},[ce]),pointerGraceTimerRef:H,onPointerGraceIntentChange:w.useCallback(oe=>{Y.current=oe},[]),children:m.jsx(ye,{...N,children:m.jsx(OO,{asChild:!0,trapped:r,onMountAutoFocus:je(s,oe=>{oe.preventDefault(),j.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:m.jsx(hh,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:O,onDismiss:y,children:m.jsx(c8,{asChild:!0,...T,dir:C.dir,orientation:"vertical",loop:i,currentTabStopId:A,onCurrentTabStopIdChange:R,onEntryFocus:je(u,oe=>{C.isUsingKeyboardRef.current||oe.preventDefault()}),preventScrollOnEntryFocus:!0,children:m.jsx(Fw,{role:"menu","aria-orientation":"vertical","data-state":xj(k.open),"data-radix-menu-content":"",dir:C.dir,...$,...S,ref:L,style:{outline:"none",...S.style},onKeyDown:je(S.onKeyDown,oe=>{const D=oe.target.closest("[data-radix-menu-content]")===oe.currentTarget,P=oe.ctrlKey||oe.altKey||oe.metaKey,I=oe.key.length===1;D&&(oe.key==="Tab"&&oe.preventDefault(),!P&&I&&W(oe.key));const X=j.current;if(oe.target!==X||!f8.includes(oe.key))return;oe.preventDefault();const J=Q().filter(se=>!se.disabled).map(se=>se.ref.current);ej.includes(oe.key)&&J.reverse(),j8(J)}),onBlur:je(t.onBlur,oe=>{oe.currentTarget.contains(oe.target)||(window.clearTimeout(ne.current),G.current="")}),onPointerMove:je(t.onPointerMove,Pf(oe=>{const le=oe.target,D=K.current!==oe.clientX;if(oe.currentTarget.contains(le)&&D){const P=oe.clientX>K.current?"right":"left";re.current=P,K.current=oe.clientX}}))})})})})})})});oj.displayName=jr;var C8="MenuGroup",e1=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t;return m.jsx(Ke.div,{role:"group",...i,ref:e})});e1.displayName=C8;var _8="MenuLabel",aj=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t;return m.jsx(Ke.div,{...i,ref:e})});aj.displayName=_8;var Om="MenuItem",j2="menu.itemSelect",$O=w.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:i,...r}=t,s=w.useRef(null),o=Oh(Om,t.__scopeMenu),l=Kw(Om,t.__scopeMenu),u=kt(e,s),f=w.useRef(!1),h=()=>{const p=s.current;if(!n&&p){const O=new CustomEvent(j2,{bubbles:!0,cancelable:!0});p.addEventListener(j2,y=>i?.(y),{once:!0}),sP(p,O),O.defaultPrevented?f.current=!1:o.onClose()}};return m.jsx(lj,{...r,ref:u,disabled:n,onClick:je(t.onClick,h),onPointerDown:p=>{t.onPointerDown?.(p),f.current=!0},onPointerUp:je(t.onPointerUp,p=>{f.current||p.currentTarget?.click()}),onKeyDown:je(t.onKeyDown,p=>{n||p.target!==p.currentTarget||l.searchRef.current!==""&&p.key===" "||RS.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});$O.displayName=Om;var lj=w.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:i=!1,textValue:r,...s}=t,o=Kw(Om,n),l=nj(n),u=w.useRef(null),f=kt(e,u),[h,p]=w.useState(!1),[O,y]=w.useState("");return w.useEffect(()=>{const v=u.current;v&&y((v.textContent??"").trim())},[s.children]),m.jsx(Af.ItemSlot,{scope:n,disabled:i,textValue:r??O,children:m.jsx(u8,{asChild:!0,...l,focusable:!i,children:m.jsx(Ke.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...s,ref:f,onPointerMove:je(t.onPointerMove,Pf(v=>{i?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:je(t.onPointerLeave,Pf(v=>o.onItemLeave(v))),onFocus:je(t.onFocus,()=>p(!0)),onBlur:je(t.onBlur,()=>p(!1))})})})}),$8="MenuCheckboxItem",cj=w.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:i,...r}=t;return m.jsx(pj,{scope:t.__scopeMenu,checked:n,children:m.jsx($O,{role:"menuitemcheckbox","aria-checked":ym(n)?"mixed":n,...r,ref:e,"data-state":n1(n),onSelect:je(r.onSelect,()=>i?.(ym(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cj.displayName=$8;var uj="MenuRadioGroup",[T8,E8]=Yl(uj,{value:void 0,onValueChange:()=>{}}),dj=w.forwardRef((t,e)=>{const{value:n,onValueChange:i,...r}=t,s=Mr(i);return m.jsx(T8,{scope:t.__scopeMenu,value:n,onValueChange:s,children:m.jsx(e1,{...r,ref:e})})});dj.displayName=uj;var fj="MenuRadioItem",hj=w.forwardRef((t,e)=>{const{value:n,...i}=t,r=E8(fj,t.__scopeMenu),s=n===r.value;return m.jsx(pj,{scope:t.__scopeMenu,checked:s,children:m.jsx($O,{role:"menuitemradio","aria-checked":s,...i,ref:e,"data-state":n1(s),onSelect:je(i.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});hj.displayName=fj;var t1="MenuItemIndicator",[pj,R8]=Yl(t1,{checked:!1}),gj=w.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:i,...r}=t,s=R8(t1,n);return m.jsx(is,{present:i||ym(s.checked)||s.checked===!0,children:m.jsx(Ke.span,{...r,ref:e,"data-state":n1(s.checked)})})});gj.displayName=t1;var Q8="MenuSeparator",mj=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t;return m.jsx(Ke.div,{role:"separator","aria-orientation":"horizontal",...i,ref:e})});mj.displayName=Q8;var A8="MenuArrow",Oj=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t,r=_O(n);return m.jsx(Gw,{...r,...i,ref:e})});Oj.displayName=A8;var P8="MenuSub",[Jge,yj]=Yl(P8),cf="MenuSubTrigger",vj=w.forwardRef((t,e)=>{const n=Fl(cf,t.__scopeMenu),i=Oh(cf,t.__scopeMenu),r=yj(cf,t.__scopeMenu),s=Kw(cf,t.__scopeMenu),o=w.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=s,f={__scopeMenu:t.__scopeMenu},h=w.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);w.useEffect(()=>h,[h]),w.useEffect(()=>{const O=l.current;return()=>{window.clearTimeout(O),u(null)}},[l,u]);const p=kt(e,r.onTriggerChange);return m.jsx(Hw,{asChild:!0,...f,children:m.jsx(lj,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":n.open?r.contentId:void 0,"data-state":xj(n.open),...t,ref:p,onClick:O=>{t.onClick?.(O),!(t.disabled||O.defaultPrevented)&&(O.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:je(t.onPointerMove,Pf(O=>{s.onItemEnter(O),!O.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:je(t.onPointerLeave,Pf(O=>{h();const y=n.content?.getBoundingClientRect();if(y){const v=n.content?.dataset.side,S=v==="right",k=S?-5:5,C=y[S?"left":"right"],$=y[S?"right":"left"];s.onPointerGraceIntentChange({area:[{x:O.clientX+k,y:O.clientY},{x:C,y:y.top},{x:$,y:y.top},{x:$,y:y.bottom},{x:C,y:y.bottom}],side:v}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(O),O.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:je(t.onKeyDown,O=>{t.disabled||O.target!==O.currentTarget||s.searchRef.current!==""&&O.key===" "||h8[i.dir].includes(O.key)&&(n.onOpenChange(!0),n.content?.focus(),O.preventDefault())})})})});vj.displayName=cf;var bj="MenuSubContent",Sj=w.forwardRef((t,e)=>{const n=rj(jr,t.__scopeMenu),{forceMount:i=n.forceMount,align:r="start",...s}=t,o=Fl(jr,t.__scopeMenu),l=Oh(jr,t.__scopeMenu),u=yj(bj,t.__scopeMenu),f=w.useRef(null),h=kt(e,f);return m.jsx(Af.Provider,{scope:t.__scopeMenu,children:m.jsx(is,{present:i||o.open,children:m.jsx(Af.Slot,{scope:t.__scopeMenu,children:m.jsx(Jw,{id:u.contentId,"aria-labelledby":u.triggerId,...s,ref:h,align:r,side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{l.isUsingKeyboardRef.current&&f.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:je(t.onFocusOutside,p=>{p.target!==u.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:je(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:je(t.onKeyDown,p=>{const O=p.currentTarget.contains(p.target),y=p8[l.dir].includes(p.key);O&&y&&(o.onOpenChange(!1),u.trigger?.focus(),p.preventDefault())})})})})})});Sj.displayName=bj;function xj(t){return t?"open":"closed"}function ym(t){return t==="indeterminate"}function n1(t){return ym(t)?"indeterminate":t?"checked":"unchecked"}function j8(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function M8(t,e){return t.map((n,i)=>t[(e+i)%t.length])}function D8(t,e,n){const r=e.length>1&&Array.from(e).every(f=>f===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=M8(t,Math.max(s,0));r.length===1&&(o=o.filter(f=>f!==n));const u=o.find(f=>f.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function N8(t,e){const{x:n,y:i}=t;let r=!1;for(let s=0,o=e.length-1;si!=O>i&&n<(p-f)*(i-h)/(O-h)+f&&(r=!r)}return r}function z8(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return N8(n,e)}function Pf(t){return e=>e.pointerType==="mouse"?t(e):void 0}var L8=ij,Z8=Hw,I8=sj,X8=oj,V8=e1,B8=aj,U8=$O,q8=cj,Y8=dj,F8=hj,G8=gj,H8=mj,W8=Oj,K8=vj,J8=Sj,TO="DropdownMenu",[eU]=Da(TO,[tj]),Ti=tj(),[tU,wj]=eU(TO),kj=t=>{const{__scopeDropdownMenu:e,children:n,dir:i,open:r,defaultOpen:s,onOpenChange:o,modal:l=!0}=t,u=Ti(e),f=w.useRef(null),[h,p]=bu({prop:r,defaultProp:s??!1,onChange:o,caller:TO});return m.jsx(tU,{scope:e,triggerId:hi(),triggerRef:f,contentId:hi(),open:h,onOpenChange:p,onOpenToggle:w.useCallback(()=>p(O=>!O),[p]),modal:l,children:m.jsx(L8,{...u,open:h,onOpenChange:p,dir:i,modal:l,children:n})})};kj.displayName=TO;var Cj="DropdownMenuTrigger",_j=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:i=!1,...r}=t,s=wj(Cj,n),o=Ti(n),l=kt(e,s.triggerRef);return m.jsx(Z8,{asChild:!0,...o,children:m.jsx(Ke.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...r,ref:l,onPointerDown:je(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(s.onOpenToggle(),s.open||u.preventDefault())}),onKeyDown:je(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&s.onOpenToggle(),u.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})});_j.displayName=Cj;var nU="DropdownMenuPortal",$j=t=>{const{__scopeDropdownMenu:e,...n}=t,i=Ti(e);return m.jsx(I8,{...i,...n})};$j.displayName=nU;var Tj="DropdownMenuContent",Ej=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=wj(Tj,n),s=Ti(n),o=w.useRef(!1);return m.jsx(X8,{id:r.contentId,"aria-labelledby":r.triggerId,...s,...i,ref:e,onCloseAutoFocus:je(t.onCloseAutoFocus,l=>{o.current||r.triggerRef.current?.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:je(t.onInteractOutside,l=>{const u=l.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,h=u.button===2||f;(!r.modal||h)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Ej.displayName=Tj;var iU="DropdownMenuGroup",rU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(V8,{...r,...i,ref:e})});rU.displayName=iU;var sU="DropdownMenuLabel",Rj=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(B8,{...r,...i,ref:e})});Rj.displayName=sU;var oU="DropdownMenuItem",Qj=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(U8,{...r,...i,ref:e})});Qj.displayName=oU;var aU="DropdownMenuCheckboxItem",lU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(q8,{...r,...i,ref:e})});lU.displayName=aU;var cU="DropdownMenuRadioGroup",uU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(Y8,{...r,...i,ref:e})});uU.displayName=cU;var dU="DropdownMenuRadioItem",fU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(F8,{...r,...i,ref:e})});fU.displayName=dU;var hU="DropdownMenuItemIndicator",pU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(G8,{...r,...i,ref:e})});pU.displayName=hU;var gU="DropdownMenuSeparator",mU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(H8,{...r,...i,ref:e})});mU.displayName=gU;var OU="DropdownMenuArrow",yU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(W8,{...r,...i,ref:e})});yU.displayName=OU;var vU="DropdownMenuSubTrigger",bU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(K8,{...r,...i,ref:e})});bU.displayName=vU;var SU="DropdownMenuSubContent",xU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(J8,{...r,...i,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xU.displayName=SU;var wU=kj,kU=_j,CU=$j,_U=Ej,$U=Rj,TU=Qj,EU="Label",Aj=w.forwardRef((t,e)=>m.jsx(Ke.label,{...t,ref:e,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Aj.displayName=EU;var RU=Aj;function M2(t,[e,n]){return Math.min(n,Math.max(e,t))}var QU=[" ","Enter","ArrowUp","ArrowDown"],AU=[" ","Enter"],Pl="Select",[EO,RO,PU]=_w(Pl),[Gl]=Da(Pl,[PU,Uu]),QO=Uu(),[jU,za]=Gl(Pl),[MU,DU]=Gl(Pl),NU="SelectProvider";function Pj(t){const{__scopeSelect:e,children:n,open:i,defaultOpen:r,onOpenChange:s,value:o,defaultValue:l,onValueChange:u,dir:f,name:h,autoComplete:p,disabled:O,required:y,form:v,internal_do_not_use_render:S}=t,k=QO(e),[C,$]=w.useState(null),[T,Q]=w.useState(null),[A,R]=w.useState(!1),j=$w(f),[L,ne]=bu({prop:i,defaultProp:r??!1,onChange:s,caller:Pl}),[G,H]=bu({prop:o,defaultProp:l,onChange:u,caller:Pl}),Y=w.useRef(null),re=w.useRef(G);w.useEffect(()=>{const P=v?C?.ownerDocument.getElementById(v):C?.form;if(P instanceof HTMLFormElement){const I=()=>H(re.current);return P.addEventListener("reset",I),()=>P.removeEventListener("reset",I)}},[v,C,H]);const K=C?!!v||!!C.closest("form"):!0,[ye,N]=w.useState(new Set),W=hi(),ce=Array.from(ye).map(P=>P.props.value).join(";"),oe=w.useCallback(P=>{N(I=>new Set(I).add(P))},[]),le=w.useCallback(P=>{N(I=>{const X=new Set(I);return X.delete(P),X})},[]),D={required:y,trigger:C,onTriggerChange:$,valueNode:T,onValueNodeChange:Q,valueNodeHasChildren:A,onValueNodeHasChildrenChange:R,contentId:W,value:G,onValueChange:H,open:L,onOpenChange:ne,dir:j,triggerPointerDownPosRef:Y,disabled:O,name:h,autoComplete:p,form:v,nativeOptions:ye,nativeSelectKey:ce,isFormControl:K};return m.jsx(qw,{...k,children:m.jsx(jU,{scope:e,...D,children:m.jsx(EO.Provider,{scope:e,children:m.jsx(MU,{scope:e,onNativeOptionAdd:oe,onNativeOptionRemove:le,children:e9(S)?S(D):n})})})})}Pj.displayName=NU;var jj=t=>{const{__scopeSelect:e,children:n,...i}=t;return m.jsx(Pj,{__scopeSelect:e,...i,internal_do_not_use_render:({isFormControl:r})=>m.jsxs(m.Fragment,{children:[n,r?m.jsx(oM,{__scopeSelect:e}):null]})})};jj.displayName=Pl;var Mj="SelectTrigger",Dj=w.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:i=!1,...r}=t,s=QO(n),o=za(Mj,n),l=o.disabled||i,u=kt(e,o.onTriggerChange),f=RO(n),h=w.useRef("touch"),[p,O,y]=aM(S=>{const k=f().filter(T=>!T.disabled),C=k.find(T=>T.value===o.value),$=lM(k,S,C);$!==void 0&&o.onValueChange($.value)}),v=S=>{l||(o.onOpenChange(!0),y()),S&&(o.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return m.jsx(Yw,{asChild:!0,...s,children:m.jsx(Ke.button,{type:"button",role:"combobox","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":AO(o.value)?"":void 0,...r,ref:u,onClick:je(r.onClick,S=>{S.currentTarget.focus(),h.current!=="mouse"&&v(S)}),onPointerDown:je(r.onPointerDown,S=>{h.current=S.pointerType;const k=S.target;k.hasPointerCapture(S.pointerId)&&k.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(v(S),S.preventDefault())}),onKeyDown:je(r.onKeyDown,S=>{const k=p.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&O(S.key),!(k&&S.key===" ")&&QU.includes(S.key)&&(v(),S.preventDefault())})})})});Dj.displayName=Mj;var Nj="SelectValue",zj=w.forwardRef((t,e)=>{const{__scopeSelect:n,className:i,style:r,children:s,placeholder:o="",...l}=t,u=za(Nj,n),{onValueNodeHasChildrenChange:f}=u,h=s!==void 0,p=kt(e,u.onValueNodeChange);Xn(()=>{f(h)},[f,h]);const O=AO(u.value);return m.jsx(Ke.span,{...l,asChild:O?!1:l.asChild,ref:p,style:{pointerEvents:"none"},children:m.jsx(w.Fragment,{children:O?o:s},O?"placeholder":"value")})});zj.displayName=Nj;var zU="SelectIcon",Lj=w.forwardRef((t,e)=>{const{__scopeSelect:n,children:i,...r}=t;return m.jsx(Ke.span,{"aria-hidden":!0,...r,ref:e,children:i||"▼"})});Lj.displayName=zU;var Zj="SelectPortal",[LU,ZU]=Gl(Zj,{forceMount:void 0}),Ij=t=>{const{__scopeSelect:e,forceMount:n,...i}=t;return m.jsx(LU,{scope:t.__scopeSelect,forceMount:n,children:m.jsx(ph,{asChild:!0,...i})})};Ij.displayName=Zj;var Ca="SelectContent",Xj=w.forwardRef((t,e)=>{const n=ZU(Ca,t.__scopeSelect),{forceMount:i=n.forceMount,...r}=t,s=za(Ca,t.__scopeSelect),[o,l]=w.useState();return Xn(()=>{l(new DocumentFragment)},[]),m.jsx(is,{present:i||s.open,children:({present:u})=>u?m.jsx(Uj,{...r,ref:e}):m.jsx(Vj,{...r,fragment:o})})});Xj.displayName=Ca;var Vj=w.forwardRef((t,e)=>{const{__scopeSelect:n,children:i,fragment:r}=t;return r?ql.createPortal(m.jsx(Bj,{scope:n,children:m.jsx(EO.Slot,{scope:n,children:m.jsx("div",{ref:e,children:i})})}),r):null});Vj.displayName="SelectContentFragment";var Ur=10,[Bj,La]=Gl(Ca),IU="SelectContentImpl",XU=Rl("SelectContent.RemoveScroll"),Uj=w.forwardRef((t,e)=>{const{__scopeSelect:n}=t,{position:i="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:s,onPointerDownOutside:o,side:l,sideOffset:u,align:f,alignOffset:h,arrowPadding:p,collisionBoundary:O,collisionPadding:y,sticky:v,hideWhenDetached:S,avoidCollisions:k,...C}=t,$=za(Ca,n),[T,Q]=w.useState(null),[A,R]=w.useState(null),j=kt(e,Q),[L,ne]=w.useState(null),[G,H]=w.useState(null),Y=RO(n),[re,K]=w.useState(!1),ye=w.useRef(!1);w.useEffect(()=>{if(T)return Rw(T)},[T]),Ew();const N=w.useCallback(se=>{const[pe,...xe]=Y().map(Ge=>Ge.ref.current),[Ze]=xe.slice(-1),Xe=document.activeElement;for(const Ge of se)if(Ge===Xe||(Ge?.scrollIntoView({block:"nearest"}),Ge===pe&&A&&(A.scrollTop=0),Ge===Ze&&A&&(A.scrollTop=A.scrollHeight),Ge?.focus(),document.activeElement!==Xe))return},[Y,A]),W=w.useCallback(()=>N([L,T]),[N,L,T]);w.useEffect(()=>{re&&W()},[re,W]);const{onOpenChange:ce,triggerPointerDownPosRef:oe}=$;w.useEffect(()=>{if(T){let se={x:0,y:0};const pe=Ze=>{se={x:Math.abs(Math.round(Ze.pageX)-(oe.current?.x??0)),y:Math.abs(Math.round(Ze.pageY)-(oe.current?.y??0))}},xe=Ze=>{se.x<=10&&se.y<=10?Ze.preventDefault():Ze.composedPath().includes(T)||ce(!1),document.removeEventListener("pointermove",pe),oe.current=null};return oe.current!==null&&(document.addEventListener("pointermove",pe),document.addEventListener("pointerup",xe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",pe),document.removeEventListener("pointerup",xe,{capture:!0})}}},[T,ce,oe]),w.useEffect(()=>{const se=()=>ce(!1);return window.addEventListener("blur",se),window.addEventListener("resize",se),()=>{window.removeEventListener("blur",se),window.removeEventListener("resize",se)}},[ce]);const[le,D]=aM(se=>{const pe=Y().filter(Xe=>!Xe.disabled),xe=pe.find(Xe=>Xe.ref.current===document.activeElement),Ze=lM(pe,se,xe);Ze&&setTimeout(()=>Ze.ref.current?.focus())}),P=w.useCallback((se,pe,xe)=>{const Ze=!ye.current&&!xe;($.value!==void 0&&$.value===pe||Ze)&&(ne(se),Ze&&(ye.current=!0))},[$.value]),I=w.useCallback(()=>T?.focus(),[T]),X=w.useCallback((se,pe,xe)=>{const Ze=!ye.current&&!xe;($.value!==void 0&&$.value===pe||Ze)&&H(se)},[$.value]),V=i==="popper"?QS:qj,J=V===QS?{side:l,sideOffset:u,align:f,alignOffset:h,arrowPadding:p,collisionBoundary:O,collisionPadding:y,sticky:v,hideWhenDetached:S,avoidCollisions:k}:{};return m.jsx(Bj,{scope:n,content:T,viewport:A,onViewportChange:R,itemRefCallback:P,selectedItem:L,onItemLeave:I,itemTextRefCallback:X,focusSelectedItem:W,selectedItemText:G,position:i,isPositioned:re,searchRef:le,children:m.jsx(vO,{as:XU,allowPinchZoom:!0,children:m.jsx(OO,{asChild:!0,trapped:$.open,onMountAutoFocus:se=>{se.preventDefault()},onUnmountAutoFocus:je(r,se=>{$.trigger?.focus({preventScroll:!0}),se.preventDefault()}),children:m.jsx(hh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:se=>se.preventDefault(),onDismiss:()=>$.onOpenChange(!1),children:m.jsx(V,{role:"listbox",id:$.contentId,"data-state":$.open?"open":"closed",dir:$.dir,onContextMenu:se=>se.preventDefault(),...C,...J,onPlaced:()=>K(!0),ref:j,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:je(C.onKeyDown,se=>{const pe=se.ctrlKey||se.altKey||se.metaKey;if(se.key==="Tab"&&se.preventDefault(),!pe&&se.key.length===1&&D(se.key),["ArrowUp","ArrowDown","Home","End"].includes(se.key)){let Ze=Y().filter(Xe=>!Xe.disabled).map(Xe=>Xe.ref.current);if(["ArrowUp","End"].includes(se.key)&&(Ze=Ze.slice().reverse()),["ArrowUp","ArrowDown"].includes(se.key)){const Xe=se.target,Ge=Ze.indexOf(Xe);Ze=Ze.slice(Ge+1)}setTimeout(()=>N(Ze)),se.preventDefault()}})})})})})})});Uj.displayName=IU;var VU="SelectItemAlignedPosition",qj=w.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:i,...r}=t,s=za(Ca,n),o=La(Ca,n),[l,u]=w.useState(null),[f,h]=w.useState(null),p=kt(e,h),O=RO(n),y=w.useRef(!1),v=w.useRef(!0),{viewport:S,selectedItem:k,selectedItemText:C,focusSelectedItem:$}=o,T=w.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&f&&S&&k&&C){const j=s.trigger.getBoundingClientRect(),L=f.getBoundingClientRect(),ne=s.valueNode.getBoundingClientRect(),G=C.getBoundingClientRect();if(s.dir!=="rtl"){const Xe=G.left-L.left,Ge=ne.left-Xe,Qt=j.left-Ge,lt=j.width+Qt,ti=Math.max(lt,L.width),Oi=window.innerWidth-Ur,At=M2(Ge,[Ur,Math.max(Ur,Oi-ti)]);l.style.minWidth=lt+"px",l.style.left=At+"px"}else{const Xe=L.right-G.right,Ge=window.innerWidth-ne.right-Xe,Qt=window.innerWidth-j.right-Ge,lt=j.width+Qt,ti=Math.max(lt,L.width),Oi=window.innerWidth-Ur,At=M2(Ge,[Ur,Math.max(Ur,Oi-ti)]);l.style.minWidth=lt+"px",l.style.right=At+"px"}const H=O(),Y=window.innerHeight-Ur*2,re=S.scrollHeight,K=window.getComputedStyle(f),ye=parseInt(K.borderTopWidth,10),N=parseInt(K.paddingTop,10),W=parseInt(K.borderBottomWidth,10),ce=parseInt(K.paddingBottom,10),oe=ye+N+re+ce+W,le=Math.min(k.offsetHeight*5,oe),D=window.getComputedStyle(S),P=parseInt(D.paddingTop,10),I=parseInt(D.paddingBottom,10),X=j.top+j.height/2-Ur,V=Y-X,J=k.offsetHeight/2,se=k.offsetTop+J,pe=ye+N+se,xe=oe-pe;if(pe<=X){const Xe=H.length>0&&k===H[H.length-1].ref.current;l.style.bottom="0px";const Ge=f.clientHeight-S.offsetTop-S.offsetHeight,Qt=Math.max(V,J+(Xe?I:0)+Ge+W),lt=pe+Qt;l.style.height=lt+"px"}else{const Xe=H.length>0&&k===H[0].ref.current;l.style.top="0px";const Qt=Math.max(X,ye+S.offsetTop+(Xe?P:0)+J)+xe;l.style.height=Qt+"px",S.scrollTop=pe-X+S.offsetTop}l.style.margin=`${Ur}px 0`,l.style.minHeight=le+"px",l.style.maxHeight=Y+"px",i?.(),requestAnimationFrame(()=>y.current=!0)}},[O,s.trigger,s.valueNode,l,f,S,k,C,s.dir,i]);Xn(()=>T(),[T]);const[Q,A]=w.useState();Xn(()=>{f&&A(window.getComputedStyle(f).zIndex)},[f]);const R=w.useCallback(j=>{j&&v.current===!0&&(T(),$?.(),v.current=!1)},[T,$]);return m.jsx(UU,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:y,onScrollButtonChange:R,children:m.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:Q},children:m.jsx(Ke.div,{...r,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});qj.displayName=VU;var BU="SelectPopperPosition",QS=w.forwardRef((t,e)=>{const{__scopeSelect:n,align:i="start",collisionPadding:r=Ur,...s}=t,o=QO(n);return m.jsx(Fw,{...o,...s,ref:e,align:i,collisionPadding:r,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});QS.displayName=BU;var[UU,i1]=Gl(Ca,{}),AS="SelectViewport",Yj=w.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:i,...r}=t,s=La(AS,n),o=i1(AS,n),l=kt(e,s.onViewportChange),u=w.useRef(0);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),m.jsx(EO.Slot,{scope:n,children:m.jsx(Ke.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:je(r.onScroll,f=>{const h=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:O}=o;if(O?.current&&p){const y=Math.abs(u.current-h.scrollTop);if(y>0){const v=window.innerHeight-Ur*2,S=parseFloat(p.style.minHeight),k=parseFloat(p.style.height),C=Math.max(S,k);if(C0?Q:0,p.style.justifyContent="flex-end")}}}u.current=h.scrollTop})})})]})});Yj.displayName=AS;var Fj="SelectGroup",[qU,YU]=Gl(Fj),FU=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t,r=hi();return m.jsx(qU,{scope:n,id:r,children:m.jsx(Ke.div,{role:"group","aria-labelledby":r,...i,ref:e})})});FU.displayName=Fj;var Gj="SelectLabel",GU=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t,r=YU(Gj,n);return m.jsx(Ke.div,{id:r.id,...i,ref:e})});GU.displayName=Gj;var vm="SelectItem",[HU,Hj]=Gl(vm),Wj=w.forwardRef((t,e)=>{const{__scopeSelect:n,value:i,disabled:r=!1,textValue:s,...o}=t,l=za(vm,n),u=La(vm,n),f=l.value===i,[h,p]=w.useState(s??""),[O,y]=w.useState(!1),v=Mr(T=>u.itemRefCallback?.(T,i,r)),S=kt(e,v),k=hi(),C=w.useRef("touch"),$=()=>{r||(l.onValueChange(i),l.onOpenChange(!1))};return m.jsx(HU,{scope:n,value:i,disabled:r,textId:k,isSelected:f,onItemTextChange:w.useCallback(T=>{p(Q=>Q||(T?.textContent??"").trim())},[]),children:m.jsx(EO.ItemSlot,{scope:n,value:i,disabled:r,textValue:h,children:m.jsx(Ke.div,{role:"option","aria-labelledby":k,"data-highlighted":O?"":void 0,"aria-selected":f&&O,"data-state":f?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...o,ref:S,onFocus:je(o.onFocus,()=>y(!0)),onBlur:je(o.onBlur,()=>y(!1)),onClick:je(o.onClick,()=>{C.current!=="mouse"&&$()}),onPointerUp:je(o.onPointerUp,()=>{C.current==="mouse"&&$()}),onPointerDown:je(o.onPointerDown,T=>{C.current=T.pointerType}),onPointerMove:je(o.onPointerMove,T=>{C.current=T.pointerType,r?u.onItemLeave?.():C.current==="mouse"&&T.currentTarget.focus({preventScroll:!0})}),onPointerLeave:je(o.onPointerLeave,T=>{T.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:je(o.onKeyDown,T=>{r||T.target!==T.currentTarget||u.searchRef?.current!==""&&T.key===" "||(AU.includes(T.key)&&$(),T.key===" "&&T.preventDefault())})})})})});Wj.displayName=vm;var uf="SelectItemText",Kj=w.forwardRef((t,e)=>{const{__scopeSelect:n,className:i,style:r,...s}=t,o=za(uf,n),l=La(uf,n),u=Hj(uf,n),f=DU(uf,n),[h,p]=w.useState(null),O=Mr($=>l.itemTextRefCallback?.($,u.value,u.disabled)),y=kt(e,p,u.onItemTextChange,O),v=h?.textContent,S=w.useMemo(()=>m.jsx("option",{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:k,onNativeOptionRemove:C}=f;return Xn(()=>(k(S),()=>C(S)),[k,C,S]),m.jsxs(m.Fragment,{children:[m.jsx(Ke.span,{id:u.textId,...s,ref:y}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!AO(o.value)?ql.createPortal(s.children,o.valueNode):null]})});Kj.displayName=uf;var Jj="SelectItemIndicator",eM=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t;return Hj(Jj,n).isSelected?m.jsx(Ke.span,{"aria-hidden":!0,...i,ref:e}):null});eM.displayName=Jj;var PS="SelectScrollUpButton",tM=w.forwardRef((t,e)=>{const n=La(PS,t.__scopeSelect),i=i1(PS,t.__scopeSelect),[r,s]=w.useState(!1),o=kt(e,i.onScrollButtonChange);return Xn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=u.scrollTop>0;s(f)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),r?m.jsx(iM,{...t,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});tM.displayName=PS;var jS="SelectScrollDownButton",nM=w.forwardRef((t,e)=>{const n=La(jS,t.__scopeSelect),i=i1(jS,t.__scopeSelect),[r,s]=w.useState(!1),o=kt(e,i.onScrollButtonChange);return Xn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=u.scrollHeight-u.clientHeight,h=Math.ceil(u.scrollTop)u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),r?m.jsx(iM,{...t,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});nM.displayName=jS;var iM=w.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:i,...r}=t,s=La("SelectScrollButton",n),o=w.useRef(null),l=RO(n),u=w.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return w.useEffect(()=>()=>u(),[u]),Xn(()=>{l().find(h=>h.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),m.jsx(Ke.div,{"aria-hidden":!0,...r,ref:e,style:{flexShrink:0,...r.style},onPointerDown:je(r.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(i,50))}),onPointerMove:je(r.onPointerMove,()=>{s.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(i,50))}),onPointerLeave:je(r.onPointerLeave,()=>{u()})})}),WU="SelectSeparator",KU=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t;return m.jsx(Ke.div,{"aria-hidden":!0,...i,ref:e})});KU.displayName=WU;var rM="SelectArrow",JU=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t,r=QO(n);return La(rM,n).position==="popper"?m.jsx(Gw,{...r,...i,ref:e}):null});JU.displayName=rM;var sM="SelectBubbleInput",oM=w.forwardRef(({__scopeSelect:t,...e},n)=>{const i=za(sM,t),{value:r,onValueChange:s,required:o,disabled:l,name:u,autoComplete:f,form:h}=i,{nativeOptions:p,nativeSelectKey:O}=i,y=w.useRef(null),v=kt(n,y),S=r??"",k=jB(S),C=Array.from(p).some($=>($.props.value??"")==="");return w.useEffect(()=>{const $=y.current;if(!$)return;const T=window.HTMLSelectElement.prototype,A=Object.getOwnPropertyDescriptor(T,"value").set;if(k!==S&&A){const R=new Event("change",{bubbles:!0});A.call($,S),$.dispatchEvent(R)}},[k,S]),m.jsxs(Ke.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:u,autoComplete:f,disabled:l,form:h,onChange:$=>s($.target.value),...e,style:{...oP,...e.style},ref:v,defaultValue:S,children:[AO(r)&&!C?m.jsx("option",{value:""}):null,Array.from(p)]},O)});oM.displayName=sM;function e9(t){return typeof t=="function"}function AO(t){return t===""||t===void 0}function aM(t){const e=Mr(t),n=w.useRef(""),i=w.useRef(0),r=w.useCallback(o=>{const l=n.current+o;e(l),(function u(f){n.current=f,window.clearTimeout(i.current),f!==""&&(i.current=window.setTimeout(()=>u(""),1e3))})(l)},[e]),s=w.useCallback(()=>{n.current="",window.clearTimeout(i.current)},[]);return w.useEffect(()=>()=>window.clearTimeout(i.current),[]),[n,r,s]}function lM(t,e,n){const r=e.length>1&&Array.from(e).every(f=>f===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=t9(t,Math.max(s,0));r.length===1&&(o=o.filter(f=>f!==n));const u=o.find(f=>f.textValue.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function t9(t,e){return t.map((n,i)=>t[(e+i)%t.length])}var n9="Separator",D2="horizontal",i9=["horizontal","vertical"],cM=w.forwardRef((t,e)=>{const{decorative:n,orientation:i=D2,...r}=t,s=r9(i)?i:D2,l=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return m.jsx(Ke.div,{"data-orientation":s,...l,...r,ref:e})});cM.displayName=n9;function r9(t){return i9.includes(t)}var s9=cM,[PO]=Da("Tooltip",[Uu]),jO=Uu(),uM="TooltipProvider",o9=700,MS="tooltip.open",[a9,r1]=PO(uM),dM=t=>{const{__scopeTooltip:e,delayDuration:n=o9,skipDelayDuration:i=300,disableHoverableContent:r=!1,children:s}=t,o=w.useRef(!0),l=w.useRef(!1),u=w.useRef(0);return w.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),m.jsx(a9,{scope:e,isOpenDelayedRef:o,delayDuration:n,onOpen:w.useCallback(()=>{i<=0||(window.clearTimeout(u.current),o.current=!1)},[i]),onClose:w.useCallback(()=>{i<=0||(window.clearTimeout(u.current),u.current=window.setTimeout(()=>o.current=!0,i))},[i]),isPointerInTransitRef:l,onPointerInTransitChange:w.useCallback(f=>{l.current=f},[]),disableHoverableContent:r,children:s})};dM.displayName=uM;var jf="Tooltip",[l9,yh]=PO(jf),fM=t=>{const{__scopeTooltip:e,children:n,open:i,defaultOpen:r,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=t,u=r1(jf,t.__scopeTooltip),f=jO(e),[h,p]=w.useState(null),O=hi(),y=w.useRef(0),v=o??u.disableHoverableContent,S=l??u.delayDuration,k=w.useRef(!1),[C,$]=bu({prop:i,defaultProp:r??!1,onChange:j=>{j?(u.onOpen(),document.dispatchEvent(new CustomEvent(MS))):u.onClose(),s?.(j)},caller:jf}),T=w.useMemo(()=>C?k.current?"delayed-open":"instant-open":"closed",[C]),Q=w.useCallback(()=>{window.clearTimeout(y.current),y.current=0,k.current=!1,$(!0)},[$]),A=w.useCallback(()=>{window.clearTimeout(y.current),y.current=0,$(!1)},[$]),R=w.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{k.current=!0,$(!0),y.current=0},S)},[S,$]);return w.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),m.jsx(qw,{...f,children:m.jsx(l9,{scope:e,contentId:O,open:C,stateAttribute:T,trigger:h,onTriggerChange:p,onTriggerEnter:w.useCallback(()=>{u.isOpenDelayedRef.current?R():Q()},[u.isOpenDelayedRef,R,Q]),onTriggerLeave:w.useCallback(()=>{v?A():(window.clearTimeout(y.current),y.current=0)},[A,v]),onOpen:Q,onClose:A,disableHoverableContent:v,children:n})})};fM.displayName=jf;var DS="TooltipTrigger",hM=w.forwardRef((t,e)=>{const{__scopeTooltip:n,...i}=t,r=yh(DS,n),s=r1(DS,n),o=jO(n),l=w.useRef(null),u=kt(e,l,r.onTriggerChange),f=w.useRef(!1),h=w.useRef(!1),p=w.useCallback(()=>f.current=!1,[]);return w.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),m.jsx(Yw,{asChild:!0,...o,children:m.jsx(Ke.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...i,ref:u,onPointerMove:je(t.onPointerMove,O=>{O.pointerType!=="touch"&&!h.current&&!s.isPointerInTransitRef.current&&(r.onTriggerEnter(),h.current=!0)}),onPointerLeave:je(t.onPointerLeave,()=>{r.onTriggerLeave(),h.current=!1}),onPointerDown:je(t.onPointerDown,()=>{r.open&&r.onClose(),f.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:je(t.onFocus,()=>{f.current||r.onOpen()}),onBlur:je(t.onBlur,r.onClose),onClick:je(t.onClick,r.onClose)})})});hM.displayName=DS;var s1="TooltipPortal",[c9,u9]=PO(s1,{forceMount:void 0}),pM=t=>{const{__scopeTooltip:e,forceMount:n,children:i,container:r}=t,s=yh(s1,e);return m.jsx(c9,{scope:e,forceMount:n,children:m.jsx(is,{present:n||s.open,children:m.jsx(ph,{asChild:!0,container:r,children:i})})})};pM.displayName=s1;var xu="TooltipContent",gM=w.forwardRef((t,e)=>{const n=u9(xu,t.__scopeTooltip),{forceMount:i=n.forceMount,side:r="top",...s}=t,o=yh(xu,t.__scopeTooltip);return m.jsx(is,{present:i||o.open,children:o.disableHoverableContent?m.jsx(mM,{side:r,...s,ref:e}):m.jsx(d9,{side:r,...s,ref:e})})}),d9=w.forwardRef((t,e)=>{const n=yh(xu,t.__scopeTooltip),i=r1(xu,t.__scopeTooltip),r=w.useRef(null),s=kt(e,r),[o,l]=w.useState(null),{trigger:u,onClose:f}=n,h=r.current,{onPointerInTransitChange:p}=i,O=w.useCallback(()=>{l(null),p(!1)},[p]),y=w.useCallback((v,S)=>{const k=v.currentTarget,C={x:v.clientX,y:v.clientY},$=g9(C,k.getBoundingClientRect()),T=m9(C,$),Q=O9(S.getBoundingClientRect()),A=v9([...T,...Q]);l(A),p(!0)},[p]);return w.useEffect(()=>()=>O(),[O]),w.useEffect(()=>{if(u&&h){const v=k=>y(k,h),S=k=>y(k,u);return u.addEventListener("pointerleave",v),h.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",v),h.removeEventListener("pointerleave",S)}}},[u,h,y,O]),w.useEffect(()=>{if(o){const v=S=>{const k=S.target,C={x:S.clientX,y:S.clientY},$=u?.contains(k)||h?.contains(k),T=!y9(C,o);$?O():T&&(O(),f())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,h,o,f,O]),m.jsx(mM,{...t,ref:s})}),[f9,h9]=PO(jf,{isInside:!1}),p9=tV("TooltipContent"),mM=w.forwardRef((t,e)=>{const{__scopeTooltip:n,children:i,"aria-label":r,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=t,u=yh(xu,n),f=jO(n),{onClose:h}=u;return w.useEffect(()=>(document.addEventListener(MS,h),()=>document.removeEventListener(MS,h)),[h]),w.useEffect(()=>{if(u.trigger){const p=O=>{O.target instanceof Node&&O.target.contains(u.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[u.trigger,h]),m.jsx(hh,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:m.jsxs(Fw,{"data-state":u.stateAttribute,...f,...l,ref:e,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(p9,{children:i}),m.jsx(f9,{scope:n,isInside:!0,children:m.jsx(fV,{id:u.contentId,role:"tooltip",children:r||i})})]})})});gM.displayName=xu;var OM="TooltipArrow",yM=w.forwardRef((t,e)=>{const{__scopeTooltip:n,...i}=t,r=jO(n);return h9(OM,n).isInside?null:m.jsx(Gw,{...r,...i,ref:e})});yM.displayName=OM;function g9(t,e){const n=Math.abs(e.top-t.y),i=Math.abs(e.bottom-t.y),r=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,i,r,s)){case s:return"left";case r:return"right";case n:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function m9(t,e,n=5){const i=[];switch(e){case"top":i.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":i.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":i.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":i.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return i}function O9(t){const{top:e,right:n,bottom:i,left:r}=t;return[{x:r,y:e},{x:n,y:e},{x:n,y:i},{x:r,y:i}]}function y9(t,e){const{x:n,y:i}=t;let r=!1;for(let s=0,o=e.length-1;si!=O>i&&n<(p-f)*(i-h)/(O-h)+f&&(r=!r)}return r}function v9(t){const e=t.slice();return e.sort((n,i)=>n.xi.x?1:n.yi.y?1:0),b9(e)}function b9(t){if(t.length<=1)return t.slice();const e=[];for(let i=0;i=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(r.y-o.y)>=(s.y-o.y)*(r.x-o.x))e.pop();else break}e.push(r)}e.pop();const n=[];for(let i=t.length-1;i>=0;i--){const r=t[i];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(r.y-o.y)>=(s.y-o.y)*(r.x-o.x))n.pop();else break}n.push(r)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var S9=dM,x9=fM,w9=hM,k9=pM,C9=gM,_9=yM;function vM(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e{const n=new Array(t.length+e.length);for(let i=0;i({classGroupId:t,validator:e}),SM=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),bm="-",N2=[],E9="arbitrary..",R9=t=>{const e=A9(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return Q9(o);const l=o.split(bm),u=l[0]===""&&l.length>1?1:0;return xM(l,u,e)},getConflictingClassGroupIds:(o,l)=>{if(l){const u=i[o],f=n[o];return u?f?$9(f,u):u:f||N2}return n[o]||N2}}},xM=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const r=t[e],s=n.nextPart.get(r);if(s){const f=xM(t,e+1,s);if(f)return f}const o=n.validators;if(o===null)return;const l=e===0?t.join(bm):t.slice(e).join(bm),u=o.length;for(let f=0;ft.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),i=e.slice(0,n);return i?E9+i:void 0})(),A9=t=>{const{theme:e,classGroups:n}=t;return P9(n,e)},P9=(t,e)=>{const n=SM();for(const i in t){const r=t[i];o1(r,n,i,e)}return n},o1=(t,e,n,i)=>{const r=t.length;for(let s=0;s{if(typeof t=="string"){M9(t,e,n);return}if(typeof t=="function"){D9(t,e,n,i);return}N9(t,e,n,i)},M9=(t,e,n)=>{const i=t===""?e:wM(e,t);i.classGroupId=n},D9=(t,e,n,i)=>{if(z9(t)){o1(t(i),e,n,i);return}e.validators===null&&(e.validators=[]),e.validators.push(T9(n,t))},N9=(t,e,n,i)=>{const r=Object.entries(t),s=r.length;for(let o=0;o{let n=t;const i=e.split(bm),r=i.length;for(let s=0;s"isThemeGetter"in t&&t.isThemeGetter===!0,L9=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),i=Object.create(null);const r=(s,o)=>{n[s]=o,e++,e>t&&(e=0,i=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=i[s])!==void 0)return r(s,o),o},set(s,o){s in n?n[s]=o:r(s,o)}}},NS="!",z2=":",Z9=[],L2=(t,e,n,i,r)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:i,isExternal:r}),I9=t=>{const{prefix:e,experimentalParseClassName:n}=t;let i=r=>{const s=[];let o=0,l=0,u=0,f;const h=r.length;for(let S=0;Su?f-u:void 0;return L2(s,y,O,v)};if(e){const r=e+z2,s=i;i=o=>o.startsWith(r)?s(o.slice(r.length)):L2(Z9,!1,o,void 0,!0)}if(n){const r=i;i=s=>n({className:s,parseClassName:r})}return i},X9=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,i)=>{e.set(n,1e6+i)}),n=>{const i=[];let r=[];for(let s=0;s0&&(r.sort(),i.push(...r),r=[]),i.push(o)):r.push(o)}return r.length>0&&(r.sort(),i.push(...r)),i}},V9=t=>({cache:L9(t.cacheSize),parseClassName:I9(t),sortModifiers:X9(t),postfixLookupClassGroupIds:B9(t),...R9(t)}),B9=t=>{const e=Object.create(null),n=t.postfixLookupClassGroups;if(n)for(let i=0;i{const{parseClassName:n,getClassGroupId:i,getConflictingClassGroupIds:r,sortModifiers:s,postfixLookupClassGroupIds:o}=e,l=[],u=t.trim().split(U9);let f="";for(let h=u.length-1;h>=0;h-=1){const p=u[h],{isExternal:O,modifiers:y,hasImportantModifier:v,baseClassName:S,maybePostfixModifierPosition:k}=n(p);if(O){f=p+(f.length>0?" "+f:f);continue}let C=!!k,$;if(C){const j=S.substring(0,k);$=i(j);const L=$&&o[$]?i(S):void 0;L&&L!==$&&($=L,C=!1)}else $=i(S);if(!$){if(!C){f=p+(f.length>0?" "+f:f);continue}if($=i(S),!$){f=p+(f.length>0?" "+f:f);continue}C=!1}const T=y.length===0?"":y.length===1?y[0]:s(y).join(":"),Q=v?T+NS:T,A=Q+$;if(l.indexOf(A)>-1)continue;l.push(A);const R=r($,C);for(let j=0;j0?" "+f:f)}return f},Y9=(...t)=>{let e=0,n,i,r="";for(;e{if(typeof t=="string")return t;let e,n="";for(let i=0;i{let n,i,r,s;const o=u=>{const f=e.reduce((h,p)=>p(h),t());return n=V9(f),i=n.cache.get,r=n.cache.set,s=l,l(u)},l=u=>{const f=i(u);if(f)return f;const h=q9(u,n);return r(u,h),h};return s=o,(...u)=>s(Y9(...u))},G9=[],Pn=t=>{const e=n=>n[t]||G9;return e.isThemeGetter=!0,e},CM=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,_M=/^\((?:(\w[\w-]*):)?(.+)\)$/i,H9=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,W9=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,K9=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,J9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,eq=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,tq=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,aa=t=>H9.test(t),ot=t=>!!t&&!Number.isNaN(Number(t)),hs=t=>!!t&&Number.isInteger(Number(t)),eb=t=>t.endsWith("%")&&ot(t.slice(0,-1)),ho=t=>W9.test(t),$M=()=>!0,nq=t=>K9.test(t)&&!J9.test(t),a1=()=>!1,iq=t=>eq.test(t),rq=t=>tq.test(t),sq=t=>!Ee(t)&&!Re(t),oq=t=>t.startsWith("@container")&&(t[10]==="/"&&t[11]!==void 0||t[11]==="s"&&t[16]!==void 0&&t.startsWith("-size/",10)||t[11]==="n"&&t[18]!==void 0&&t.startsWith("-normal/",10)),aq=t=>Za(t,RM,a1),Ee=t=>CM.test(t),dl=t=>Za(t,QM,nq),Z2=t=>Za(t,gq,ot),lq=t=>Za(t,PM,$M),cq=t=>Za(t,AM,a1),I2=t=>Za(t,TM,a1),uq=t=>Za(t,EM,rq),cg=t=>Za(t,jM,iq),Re=t=>_M.test(t),Gd=t=>Hl(t,QM),dq=t=>Hl(t,AM),X2=t=>Hl(t,TM),fq=t=>Hl(t,RM),hq=t=>Hl(t,EM),ug=t=>Hl(t,jM,!0),pq=t=>Hl(t,PM,!0),Za=(t,e,n)=>{const i=CM.exec(t);return i?i[1]?e(i[1]):n(i[2]):!1},Hl=(t,e,n=!1)=>{const i=_M.exec(t);return i?i[1]?e(i[1]):n:!1},TM=t=>t==="position"||t==="percentage",EM=t=>t==="image"||t==="url",RM=t=>t==="length"||t==="size"||t==="bg-size",QM=t=>t==="length",gq=t=>t==="number",AM=t=>t==="family-name",PM=t=>t==="number"||t==="weight",jM=t=>t==="shadow",mq=()=>{const t=Pn("color"),e=Pn("font"),n=Pn("text"),i=Pn("font-weight"),r=Pn("tracking"),s=Pn("leading"),o=Pn("breakpoint"),l=Pn("container"),u=Pn("spacing"),f=Pn("radius"),h=Pn("shadow"),p=Pn("inset-shadow"),O=Pn("text-shadow"),y=Pn("drop-shadow"),v=Pn("blur"),S=Pn("perspective"),k=Pn("aspect"),C=Pn("ease"),$=Pn("animate"),T=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Q=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...Q(),Re,Ee],R=()=>["auto","hidden","clip","visible","scroll"],j=()=>["auto","contain","none"],L=()=>[Re,Ee,u],ne=()=>[aa,"full","auto",...L()],G=()=>[hs,"none","subgrid",Re,Ee],H=()=>["auto",{span:["full",hs,Re,Ee]},hs,Re,Ee],Y=()=>[hs,"auto",Re,Ee],re=()=>["auto","min","max","fr",Re,Ee],K=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],ye=()=>["start","end","center","stretch","center-safe","end-safe"],N=()=>["auto",...L()],W=()=>[aa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],ce=()=>[aa,"screen","full","dvw","lvw","svw","min","max","fit",...L()],oe=()=>[aa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],le=()=>[t,Re,Ee],D=()=>[...Q(),X2,I2,{position:[Re,Ee]}],P=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",fq,aq,{size:[Re,Ee]}],X=()=>[eb,Gd,dl],V=()=>["","none","full",f,Re,Ee],J=()=>["",ot,Gd,dl],se=()=>["solid","dashed","dotted","double"],pe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],xe=()=>[ot,eb,X2,I2],Ze=()=>["","none",v,Re,Ee],Xe=()=>["none",ot,Re,Ee],Ge=()=>["none",ot,Re,Ee],Qt=()=>[ot,Re,Ee],lt=()=>[aa,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ho],breakpoint:[ho],color:[$M],container:[ho],"drop-shadow":[ho],ease:["in","out","in-out"],font:[sq],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ho],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ho],shadow:[ho],spacing:["px",ot],text:[ho],"text-shadow":[ho],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",aa,Ee,Re,k]}],container:["container"],"container-type":[{"@container":["","normal","size",Re,Ee]}],"container-named":[oq],columns:[{columns:[ot,Ee,Re,l]}],"break-after":[{"break-after":T()}],"break-before":[{"break-before":T()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:ne()}],"inset-x":[{"inset-x":ne()}],"inset-y":[{"inset-y":ne()}],start:[{"inset-s":ne(),start:ne()}],end:[{"inset-e":ne(),end:ne()}],"inset-bs":[{"inset-bs":ne()}],"inset-be":[{"inset-be":ne()}],top:[{top:ne()}],right:[{right:ne()}],bottom:[{bottom:ne()}],left:[{left:ne()}],visibility:["visible","invisible","collapse"],z:[{z:[hs,"auto",Re,Ee]}],basis:[{basis:[aa,"full","auto",l,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ot,aa,"auto","initial","none",Ee]}],grow:[{grow:["",ot,Re,Ee]}],shrink:[{shrink:["",ot,Re,Ee]}],order:[{order:[hs,"first","last","none",Re,Ee]}],"grid-cols":[{"grid-cols":G()}],"col-start-end":[{col:H()}],"col-start":[{"col-start":Y()}],"col-end":[{"col-end":Y()}],"grid-rows":[{"grid-rows":G()}],"row-start-end":[{row:H()}],"row-start":[{"row-start":Y()}],"row-end":[{"row-end":Y()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":re()}],"auto-rows":[{"auto-rows":re()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...K(),"normal"]}],"justify-items":[{"justify-items":[...ye(),"normal"]}],"justify-self":[{"justify-self":["auto",...ye()]}],"align-content":[{content:["normal",...K()]}],"align-items":[{items:[...ye(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...ye(),{baseline:["","last"]}]}],"place-content":[{"place-content":K()}],"place-items":[{"place-items":[...ye(),"baseline"]}],"place-self":[{"place-self":["auto",...ye()]}],p:[{p:L()}],px:[{px:L()}],py:[{py:L()}],ps:[{ps:L()}],pe:[{pe:L()}],pbs:[{pbs:L()}],pbe:[{pbe:L()}],pt:[{pt:L()}],pr:[{pr:L()}],pb:[{pb:L()}],pl:[{pl:L()}],m:[{m:N()}],mx:[{mx:N()}],my:[{my:N()}],ms:[{ms:N()}],me:[{me:N()}],mbs:[{mbs:N()}],mbe:[{mbe:N()}],mt:[{mt:N()}],mr:[{mr:N()}],mb:[{mb:N()}],ml:[{ml:N()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:W()}],"inline-size":[{inline:["auto",...ce()]}],"min-inline-size":[{"min-inline":["auto",...ce()]}],"max-inline-size":[{"max-inline":["none",...ce()]}],"block-size":[{block:["auto",...oe()]}],"min-block-size":[{"min-block":["auto",...oe()]}],"max-block-size":[{"max-block":["none",...oe()]}],w:[{w:[l,"screen",...W()]}],"min-w":[{"min-w":[l,"screen","none",...W()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...W()]}],h:[{h:["screen","lh",...W()]}],"min-h":[{"min-h":["screen","lh","none",...W()]}],"max-h":[{"max-h":["screen","lh",...W()]}],"font-size":[{text:["base",n,Gd,dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,pq,lq]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",eb,Ee]}],"font-family":[{font:[dq,cq,e]}],"font-features":[{"font-features":[Ee]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,Re,Ee]}],"line-clamp":[{"line-clamp":[ot,"none",Re,Z2]}],leading:[{leading:[s,...L()]}],"list-image":[{"list-image":["none",Re,Ee]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Re,Ee]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:le()}],"text-color":[{text:le()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...se(),"wavy"]}],"text-decoration-thickness":[{decoration:[ot,"from-font","auto",Re,dl]}],"text-decoration-color":[{decoration:le()}],"underline-offset":[{"underline-offset":[ot,"auto",Re,Ee]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"tab-size":[{tab:[hs,Re,Ee]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Re,Ee]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Re,Ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:P()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},hs,Re,Ee],radial:["",Re,Ee],conic:[hs,Re,Ee]},hq,uq]}],"bg-color":[{bg:le()}],"gradient-from-pos":[{from:X()}],"gradient-via-pos":[{via:X()}],"gradient-to-pos":[{to:X()}],"gradient-from":[{from:le()}],"gradient-via":[{via:le()}],"gradient-to":[{to:le()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-bs":[{"border-bs":J()}],"border-w-be":[{"border-be":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...se(),"hidden","none"]}],"divide-style":[{divide:[...se(),"hidden","none"]}],"border-color":[{border:le()}],"border-color-x":[{"border-x":le()}],"border-color-y":[{"border-y":le()}],"border-color-s":[{"border-s":le()}],"border-color-e":[{"border-e":le()}],"border-color-bs":[{"border-bs":le()}],"border-color-be":[{"border-be":le()}],"border-color-t":[{"border-t":le()}],"border-color-r":[{"border-r":le()}],"border-color-b":[{"border-b":le()}],"border-color-l":[{"border-l":le()}],"divide-color":[{divide:le()}],"outline-style":[{outline:[...se(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ot,Re,Ee]}],"outline-w":[{outline:["",ot,Gd,dl]}],"outline-color":[{outline:le()}],shadow:[{shadow:["","none",h,ug,cg]}],"shadow-color":[{shadow:le()}],"inset-shadow":[{"inset-shadow":["none",p,ug,cg]}],"inset-shadow-color":[{"inset-shadow":le()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:le()}],"ring-offset-w":[{"ring-offset":[ot,dl]}],"ring-offset-color":[{"ring-offset":le()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":le()}],"text-shadow":[{"text-shadow":["none",O,ug,cg]}],"text-shadow-color":[{"text-shadow":le()}],opacity:[{opacity:[ot,Re,Ee]}],"mix-blend":[{"mix-blend":[...pe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":pe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ot]}],"mask-image-linear-from-pos":[{"mask-linear-from":xe()}],"mask-image-linear-to-pos":[{"mask-linear-to":xe()}],"mask-image-linear-from-color":[{"mask-linear-from":le()}],"mask-image-linear-to-color":[{"mask-linear-to":le()}],"mask-image-t-from-pos":[{"mask-t-from":xe()}],"mask-image-t-to-pos":[{"mask-t-to":xe()}],"mask-image-t-from-color":[{"mask-t-from":le()}],"mask-image-t-to-color":[{"mask-t-to":le()}],"mask-image-r-from-pos":[{"mask-r-from":xe()}],"mask-image-r-to-pos":[{"mask-r-to":xe()}],"mask-image-r-from-color":[{"mask-r-from":le()}],"mask-image-r-to-color":[{"mask-r-to":le()}],"mask-image-b-from-pos":[{"mask-b-from":xe()}],"mask-image-b-to-pos":[{"mask-b-to":xe()}],"mask-image-b-from-color":[{"mask-b-from":le()}],"mask-image-b-to-color":[{"mask-b-to":le()}],"mask-image-l-from-pos":[{"mask-l-from":xe()}],"mask-image-l-to-pos":[{"mask-l-to":xe()}],"mask-image-l-from-color":[{"mask-l-from":le()}],"mask-image-l-to-color":[{"mask-l-to":le()}],"mask-image-x-from-pos":[{"mask-x-from":xe()}],"mask-image-x-to-pos":[{"mask-x-to":xe()}],"mask-image-x-from-color":[{"mask-x-from":le()}],"mask-image-x-to-color":[{"mask-x-to":le()}],"mask-image-y-from-pos":[{"mask-y-from":xe()}],"mask-image-y-to-pos":[{"mask-y-to":xe()}],"mask-image-y-from-color":[{"mask-y-from":le()}],"mask-image-y-to-color":[{"mask-y-to":le()}],"mask-image-radial":[{"mask-radial":[Re,Ee]}],"mask-image-radial-from-pos":[{"mask-radial-from":xe()}],"mask-image-radial-to-pos":[{"mask-radial-to":xe()}],"mask-image-radial-from-color":[{"mask-radial-from":le()}],"mask-image-radial-to-color":[{"mask-radial-to":le()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":Q()}],"mask-image-conic-pos":[{"mask-conic":[ot]}],"mask-image-conic-from-pos":[{"mask-conic-from":xe()}],"mask-image-conic-to-pos":[{"mask-conic-to":xe()}],"mask-image-conic-from-color":[{"mask-conic-from":le()}],"mask-image-conic-to-color":[{"mask-conic-to":le()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:P()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Re,Ee]}],filter:[{filter:["","none",Re,Ee]}],blur:[{blur:Ze()}],brightness:[{brightness:[ot,Re,Ee]}],contrast:[{contrast:[ot,Re,Ee]}],"drop-shadow":[{"drop-shadow":["","none",y,ug,cg]}],"drop-shadow-color":[{"drop-shadow":le()}],grayscale:[{grayscale:["",ot,Re,Ee]}],"hue-rotate":[{"hue-rotate":[ot,Re,Ee]}],invert:[{invert:["",ot,Re,Ee]}],saturate:[{saturate:[ot,Re,Ee]}],sepia:[{sepia:["",ot,Re,Ee]}],"backdrop-filter":[{"backdrop-filter":["","none",Re,Ee]}],"backdrop-blur":[{"backdrop-blur":Ze()}],"backdrop-brightness":[{"backdrop-brightness":[ot,Re,Ee]}],"backdrop-contrast":[{"backdrop-contrast":[ot,Re,Ee]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ot,Re,Ee]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ot,Re,Ee]}],"backdrop-invert":[{"backdrop-invert":["",ot,Re,Ee]}],"backdrop-opacity":[{"backdrop-opacity":[ot,Re,Ee]}],"backdrop-saturate":[{"backdrop-saturate":[ot,Re,Ee]}],"backdrop-sepia":[{"backdrop-sepia":["",ot,Re,Ee]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":L()}],"border-spacing-x":[{"border-spacing-x":L()}],"border-spacing-y":[{"border-spacing-y":L()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Re,Ee]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ot,"initial",Re,Ee]}],ease:[{ease:["linear","initial",C,Re,Ee]}],delay:[{delay:[ot,Re,Ee]}],animate:[{animate:["none",$,Re,Ee]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[S,Re,Ee]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:Xe()}],"rotate-x":[{"rotate-x":Xe()}],"rotate-y":[{"rotate-y":Xe()}],"rotate-z":[{"rotate-z":Xe()}],scale:[{scale:Ge()}],"scale-x":[{"scale-x":Ge()}],"scale-y":[{"scale-y":Ge()}],"scale-z":[{"scale-z":Ge()}],"scale-3d":["scale-3d"],skew:[{skew:Qt()}],"skew-x":[{"skew-x":Qt()}],"skew-y":[{"skew-y":Qt()}],transform:[{transform:[Re,Ee,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:lt()}],"translate-x":[{"translate-x":lt()}],"translate-y":[{"translate-y":lt()}],"translate-z":[{"translate-z":lt()}],"translate-none":["translate-none"],zoom:[{zoom:[hs,Re,Ee]}],accent:[{accent:le()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:le()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Re,Ee]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":le()}],"scrollbar-track-color":[{"scrollbar-track":le()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mbs":[{"scroll-mbs":L()}],"scroll-mbe":[{"scroll-mbe":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pbs":[{"scroll-pbs":L()}],"scroll-pbe":[{"scroll-pbe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Re,Ee]}],fill:[{fill:["none",...le()]}],"stroke-w":[{stroke:[ot,Gd,dl,Z2]}],stroke:[{stroke:["none",...le()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Oq=F9(mq);function yt(...t){return Oq(bM(t))}function yq({delayDuration:t=0,...e}){return m.jsx(S9,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function MM({...t}){return m.jsx(x9,{"data-slot":"tooltip",...t})}function DM({...t}){return m.jsx(w9,{"data-slot":"tooltip-trigger",...t})}function NM({className:t,sideOffset:e=0,children:n,...i}){return m.jsx(k9,{children:m.jsxs(C9,{"data-slot":"tooltip-content",sideOffset:e,className:yt("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",t),...i,children:[n,m.jsx(_9,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}const zS=new Set;function vq(t){return zS.add(t),()=>zS.delete(t)}function bq(){for(const t of zS)t()}const zM=/\.(md|markdown)$/i,LM=/\.(png|jpe?g|gif|svg|webp|ico|bmp|avif)$/i,Fc=/\.html?$/i,Bg=/\.pdf$/i,Sq=/\.(csv|tsv)$/i,xq=/\.(txt|log|json|ya?ml|toml|csv|go|py|js|ts|jsx|tsx|sh|bash|zsh|rb|rs|c|h|cpp|java|kt|swift|sql|css|xml|ini|conf|env|mod|sum|jsonl)$/i,wq=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform||navigator.userAgent||"");function l1(t){if(t<1024)return t+" B";const e=["KB","MB","GB","TB"];let n=-1;do t/=1024,n++;while(t>=1024&&ni.path.toLowerCase()===n||i.path.toLowerCase()===n+".md")||e.find(i=>{const r=i.name.toLowerCase();return r===n||r===n+".md"})}async function zs(t){try{if(navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}return!1}const IM="bdrive.lastProject";function Cq(){try{return localStorage.getItem(IM)||""}catch{return""}}function _q(t){try{localStorage.setItem(IM,t)}catch{}}const XM="bdrive.fmPanel",$q="(min-width: 1400px)";function Tq(){try{const t=localStorage.getItem(XM);if(t!==null)return t==="1"}catch{}return window.matchMedia($q).matches}function Eq(t){try{localStorage.setItem(XM,t?"1":"0")}catch{}}function MO(t){return t.user_name?`${t.user_name} <${t.user}>`:t.user||t.author||"unknown"}const VM=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim();const Rq=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Qq=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase());const V2=t=>{const e=Qq(t);return e.charAt(0).toUpperCase()+e.slice(1)};var tb={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Aq=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},Pq=w.createContext({}),jq=()=>w.useContext(Pq),Mq=w.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:i,className:r="",children:s,iconNode:o,...l},u)=>{const{size:f=24,strokeWidth:h=2,absoluteStrokeWidth:p=!1,color:O="currentColor",className:y=""}=jq()??{},v=i??p?Number(n??h)*24/Number(e??f):n??h;return w.createElement("svg",{ref:u,...tb,width:e??f??tb.width,height:e??f??tb.height,stroke:t??O,strokeWidth:v,className:VM("lucide",y,r),...!s&&!Aq(l)&&{"aria-hidden":"true"},...l},[...o.map(([S,k])=>w.createElement(S,k)),...Array.isArray(s)?s:[s]])});const De=(t,e)=>{const n=w.forwardRef(({className:i,...r},s)=>w.createElement(Mq,{ref:s,iconNode:e,className:VM(`lucide-${Rq(V2(t))}`,`lucide-${t}`,i),...r}));return n.displayName=V2(t),n};const Dq=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],Nq=De("beaker",Dq);const zq=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Lq=De("book-open",zq);const Zq=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],Iq=De("briefcase",Zq);const Xq=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],Vq=De("bug",Xq);const Bq=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Uq=De("calendar",Bq);const qq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],BM=De("check",qq);const Yq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],c1=De("chevron-down",Yq);const Fq=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Gq=De("chevron-left",Fq);const Hq=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Wq=De("chevron-right",Hq);const Kq=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Jq=De("chevron-up",Kq);const e7=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],t7=De("circle-check",e7);const n7=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],UM=De("clock",n7);const i7=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],r7=De("code",i7);const s7=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],o7=De("compass",s7);const a7=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],l7=De("copy",a7);const c7=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],u7=De("credit-card",c7);const d7=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],f7=De("database",d7);const h7=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],p7=De("download",h7);const g7=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],m7=De("ellipsis",g7);const O7=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],qM=De("file-text",O7);const y7=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],v7=De("flag",y7);const b7=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],u1=De("folder",b7);const S7=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],x7=De("gauge",S7);const w7=[["path",{d:"m14 13-8.381 8.38a1 1 0 0 1-3.001-3l8.384-8.381",key:"pgg06f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m21.5 10.5-8-8",key:"a17d9x"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m8.5 7.5 8 8",key:"1oyaui"}]],k7=De("gavel",w7);const C7=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],YM=De("globe",C7);const _7=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],$7=De("graduation-cap",_7);const T7=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],E7=De("heart",T7);const R7=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Q7=De("history",R7);const A7=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],P7=De("image",A7);const j7=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],M7=De("info",j7);const D7=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],N7=De("layout-dashboard",D7);const z7=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],L7=De("lightbulb",z7);const Z7=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],I7=De("link",Z7);const X7=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],V7=De("loader-circle",X7);const B7=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],FM=De("lock",B7);const U7=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],q7=De("log-out",U7);const Y7=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],F7=De("maximize-2",Y7);const G7=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],H7=De("megaphone",G7);const W7=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],K7=De("menu",W7);const J7=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],eY=De("minimize-2",J7);const tY=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],nY=De("music",tY);const iY=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],rY=De("octagon-x",iY);const sY=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],oY=De("package",sY);const aY=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],lY=De("panel-left",aY);const cY=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],uY=De("pen-line",cY);const dY=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],fY=De("plug",dY);const hY=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],pY=De("plus",hY);const gY=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],mY=De("printer",gY);const OY=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],yY=De("rocket",OY);const vY=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],GM=De("search",vY);const bY=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],SY=De("settings",bY);const xY=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],wY=De("share-2",xY);const kY=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],HM=De("shield",kY);const CY=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],WM=De("square-terminal",CY);const _Y=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],$Y=De("star",_Y);const TY=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],EY=De("trash-2",TY);const RY=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],KM=De("triangle-alert",RY);const QY=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],AY=De("upload",QY);const PY=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],JM=De("users",PY);const jY=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],MY=De("wrench",jY);const DY=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],eD=De("x",DY),tD="bdrive.sbCollapsed";function nD(){window.innerWidth<=d1?NY():zY(!document.body.classList.contains("sb-collapsed"))}function NY(){const t=!document.body.classList.contains("sb-open");document.body.classList.toggle("sb-open"),jl(),t?document.getElementById("sidebar")?.querySelector(LY)?.focus():document.getElementById("menu-btn")?.focus()}function zY(t){document.body.classList.toggle("sb-collapsed",t);try{localStorage.setItem(tD,t?"1":"0")}catch{}jl()}const LY='a[href], button:not(:disabled), select, input, [tabindex]:not([tabindex="-1"])';function Fr(){const t=document.body.classList.contains("sb-open");document.body.classList.remove("sb-open"),jl(),t&&window.innerWidth<=d1&&document.getElementById("menu-btn")?.focus()}function ZY(t){const e=t;if(!e||typeof e.tagName!="string")return!1;const n=e.tagName;return n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||e.isContentEditable?!0:!!e.closest?.(".cm-editor")}const d1=900;function jl(){const t=document.getElementById("sidebar");if(!t)return;const e=window.innerWidth<=d1,n=document.body.classList.contains("sb-open"),i=document.body.classList.contains("sb-collapsed"),r=e?!n:i;r?t.setAttribute("inert",""):t.removeAttribute("inert");const s=document.getElementById("main");s&&(n&&e?s.setAttribute("inert",""):s.removeAttribute("inert")),t.setAttribute("aria-modal",String(n&&e)),document.getElementById("menu-btn")?.setAttribute("aria-expanded",String(!r))}if(typeof window<"u"){try{document.body&&localStorage.getItem(tD)==="1"&&document.body.classList.add("sb-collapsed")}catch{}window.addEventListener("resize",jl),window.addEventListener("keydown",t=>{if(t.key==="Escape"&&document.body.classList.contains("sb-open")){Fr();return}if((t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey&&t.key.toLowerCase()==="b"){if(ZY(t.target))return;t.preventDefault(),nD()}})}const IY={alert:KM,card:u7,check:BM,chev:Wq,chevd:c1,chevl:Gq,clock:UM,copy:l7,doc:qM,dots:m7,download:p7,expand:F7,folder:u1,dashboard:N7,gear:SY,globe:YM,hist:Q7,link:I7,lock:FM,menu:K7,plug:fY,plus:pY,power:q7,printer:mY,search:GM,share:wY,sidebar:lY,shield:HM,shrink:eY,terminal:WM,trash:EY,upload:AY,users:JM,x:eD};function st({name:t}){const e=IY[t];return e?m.jsx(e,{className:"ico","aria-hidden":"true"}):null}const LS={folder:u1,"book-open":Lq,"file-text":qM,"pen-line":uY,users:JM,briefcase:Iq,megaphone:H7,rocket:yY,lightbulb:L7,flag:v7,star:$Y,heart:E7,code:r7,"square-terminal":WM,bug:Vq,wrench:MY,database:f7,package:oY,beaker:Nq,gauge:x7,shield:HM,lock:FM,gavel:k7,globe:YM,compass:o7,calendar:Uq,clock:UM,"graduation-cap":$7,image:P7,music:nY};function iu({name:t,className:e}){const n=t??"",i=Object.hasOwn(LS,n)?LS[n]:u1;return m.jsx(i,{className:e,"aria-hidden":"true"})}function XY({size:t=22}){return m.jsxs("svg",{width:t,height:t,viewBox:"0 0 32 32",fill:"currentColor",role:"img","aria-label":"BearDrive",children:[m.jsx("rect",{x:"4",y:"4",width:"5.6",height:"24"}),m.jsx("rect",{x:"11.2",y:"4",width:"14.4",height:"11.2"}),m.jsx("rect",{x:"11.2",y:"16.8",width:"16.8",height:"11.2"})]})}function Gc(t){const e=["page",t.width??"app",t.className].filter(Boolean).join(" ");return m.jsx("div",{className:e,children:t.children})}function VY(t){t&&jl()}function vl(t){return m.jsxs(m.Fragment,{children:[m.jsx("div",{id:"sb-backdrop",onClick:Fr}),m.jsxs("aside",{id:"sidebar",ref:VY,children:[t.vault,t.projectsNav,t.tree??m.jsx("nav",{id:"tree","aria-label":"Files"}),t.orgBar]}),m.jsxs("main",{id:"main",children:[t.topbar,t.exit,m.jsx("article",{id:"content",ref:t.contentRef,onScroll:t.onContentScroll,children:t.children})]})]})}function DO(t){const{name:e,onHome:n,showSignout:i,search:r,beta:s}=t;return m.jsxs("header",{id:"vault",children:[m.jsx("span",{id:"vault-badge",children:m.jsx(XY,{size:22})}),m.jsx("span",{id:"vault-name",className:n?"vault-link":void 0,onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:o=>{n&&(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n())},children:e}),s&&m.jsx("span",{id:"vault-beta",children:"Beta"}),m.jsxs("div",{className:"vault-actions",children:[r&&m.jsxs(MM,{delayDuration:150,children:[m.jsx(DM,{asChild:!0,children:m.jsx("button",{id:"search-btn",className:"icon-btn2","aria-label":"Search",onClick:()=>{bq(),Fr()},children:m.jsx(st,{name:"search"})})}),m.jsxs(NM,{className:"tipcard",sideOffset:6,children:["Search ",m.jsx("kbd",{children:"⌘K"})]})]}),i&&m.jsx("a",{id:"signout",href:"/auth/logout",title:"Sign out","aria-label":"Sign out",children:m.jsx(st,{name:"power"})})]})]})}function bl(t){return m.jsxs("header",{id:"topbar",children:[m.jsxs(MM,{delayDuration:150,children:[m.jsx(DM,{asChild:!0,children:m.jsx("button",{id:"menu-btn",className:"icon-btn","aria-label":"Toggle sidebar","aria-controls":"sidebar","aria-expanded":"false",onClick:nD,children:m.jsx(st,{name:"sidebar"})})}),m.jsxs(NM,{className:"tipcard",sideOffset:6,children:["Toggle sidebar ",m.jsx("kbd",{children:wq?"⌘B":"Ctrl+B"})]})]}),t.nav,m.jsx("span",{id:"crumb",children:t.crumb}),m.jsx("span",{id:"meta",children:t.meta}),t.actions]})}function BY(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}const UY=t=>{switch(t){case"success":return FY;case"info":return HY;case"warning":return GY;case"error":return WY;default:return null}},qY=Array(12).fill(0),YY=({visible:t,className:e})=>be.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},be.createElement("div",{className:"sonner-spinner"},qY.map((n,i)=>be.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${i}`})))),FY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},be.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),GY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},be.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),HY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},be.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),WY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},be.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),KY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},be.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),be.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),JY=()=>{const[t,e]=be.useState(document.hidden);return be.useEffect(()=>{const n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t};let ZS=1;class eF{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const n=this.subscribers.indexOf(e);this.subscribers.splice(n,1)}),this.publish=e=>{this.subscribers.forEach(n=>n(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var n;const{message:i,...r}=e,s=typeof e?.id=="number"||((n=e.id)==null?void 0:n.length)>0?e.id:ZS++,o=this.toasts.find(u=>u.id===s),l=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),o?this.toasts=this.toasts.map(u=>u.id===s?(this.publish({...u,...e,id:s,title:i}),{...u,...e,id:s,dismissible:l,title:i}):u):this.addToast({title:i,...r,dismissible:l,id:s}),s},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:e,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(i=>i({id:n.id,dismiss:!0}))}),e),this.message=(e,n)=>this.create({...n,message:e}),this.error=(e,n)=>this.create({...n,message:e,type:"error"}),this.success=(e,n)=>this.create({...n,type:"success",message:e}),this.info=(e,n)=>this.create({...n,type:"info",message:e}),this.warning=(e,n)=>this.create({...n,type:"warning",message:e}),this.loading=(e,n)=>this.create({...n,type:"loading",message:e}),this.promise=(e,n)=>{if(!n)return;let i;n.loading!==void 0&&(i=this.create({...n,promise:e,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let s=i!==void 0,o;const l=r.then(async f=>{if(o=["resolve",f],be.isValidElement(f))s=!1,this.create({id:i,type:"default",message:f});else if(nF(f)&&!f.ok){s=!1;const p=typeof n.error=="function"?await n.error(`HTTP error! status: ${f.status}`):n.error,O=typeof n.description=="function"?await n.description(`HTTP error! status: ${f.status}`):n.description,v=typeof p=="object"&&!be.isValidElement(p)?p:{message:p};this.create({id:i,type:"error",description:O,...v})}else if(f instanceof Error){s=!1;const p=typeof n.error=="function"?await n.error(f):n.error,O=typeof n.description=="function"?await n.description(f):n.description,v=typeof p=="object"&&!be.isValidElement(p)?p:{message:p};this.create({id:i,type:"error",description:O,...v})}else if(n.success!==void 0){s=!1;const p=typeof n.success=="function"?await n.success(f):n.success,O=typeof n.description=="function"?await n.description(f):n.description,v=typeof p=="object"&&!be.isValidElement(p)?p:{message:p};this.create({id:i,type:"success",description:O,...v})}}).catch(async f=>{if(o=["reject",f],n.error!==void 0){s=!1;const h=typeof n.error=="function"?await n.error(f):n.error,p=typeof n.description=="function"?await n.description(f):n.description,y=typeof h=="object"&&!be.isValidElement(h)?h:{message:h};this.create({id:i,type:"error",description:p,...y})}}).finally(()=>{s&&(this.dismiss(i),i=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((f,h)=>l.then(()=>o[0]==="reject"?h(o[1]):f(o[1])).catch(h));return typeof i!="string"&&typeof i!="number"?{unwrap:u}:Object.assign(i,{unwrap:u})},this.custom=(e,n)=>{const i=n?.id||ZS++;return this.create({jsx:e(i),id:i,...n}),i},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Li=new eF,tF=(t,e)=>{const n=e?.id||ZS++;return Li.addToast({title:t,...e,id:n}),n},nF=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",iF=tF,rF=()=>Li.toasts,sF=()=>Li.getActiveToasts(),B2=Object.assign(iF,{success:Li.success,info:Li.info,warning:Li.warning,error:Li.error,custom:Li.custom,message:Li.message,promise:Li.promise,dismiss:Li.dismiss,loading:Li.loading},{getHistory:rF,getToasts:sF});BY("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function dg(t){return t.label!==void 0}const oF=3,aF="24px",lF="16px",U2=4e3,cF=356,uF=14,dF=45,fF=200;function ps(...t){return t.filter(Boolean).join(" ")}function hF(t){const[e,n]=t.split("-"),i=[];return e&&i.push(e),n&&i.push(n),i}const pF=t=>{var e,n,i,r,s,o,l,u,f;const{invert:h,toast:p,unstyled:O,interacting:y,setHeights:v,visibleToasts:S,heights:k,index:C,toasts:$,expanded:T,removeToast:Q,defaultRichColors:A,closeButton:R,style:j,cancelButtonStyle:L,actionButtonStyle:ne,className:G="",descriptionClassName:H="",duration:Y,position:re,gap:K,expandByDefault:ye,classNames:N,icons:W,closeButtonAriaLabel:ce="Close toast"}=t,[oe,le]=be.useState(null),[D,P]=be.useState(null),[I,X]=be.useState(!1),[V,J]=be.useState(!1),[se,pe]=be.useState(!1),[xe,Ze]=be.useState(!1),[Xe,Ge]=be.useState(!1),[Qt,lt]=be.useState(0),[ti,Oi]=be.useState(0),At=be.useRef(p.duration||Y||U2),pr=be.useRef(null),zn=be.useRef(null),gr=C===0,Ri=C+1<=S,sn=p.type,Yi=p.dismissible!==!1,xn=p.className||"",ni=p.descriptionClassName||"",mr=be.useMemo(()=>k.findIndex(Ve=>Ve.toastId===p.id)||0,[k,p.id]),qs=be.useMemo(()=>{var Ve;return(Ve=p.closeButton)!=null?Ve:R},[p.closeButton,R]),Fi=be.useMemo(()=>p.duration||Y||U2,[p.duration,Y]),jo=be.useRef(0),ii=be.useRef(0),M=be.useRef(0),U=be.useRef(null),[q,he]=re.split("-"),me=be.useMemo(()=>k.reduce((Ve,Ct,qt)=>qt>=mr?Ve:Ve+Ct.height,0),[k,mr]),Se=JY(),ke=p.invert||h,_e=sn==="loading";ii.current=be.useMemo(()=>mr*K+me,[mr,me]),be.useEffect(()=>{At.current=Fi},[Fi]),be.useEffect(()=>{X(!0)},[]),be.useEffect(()=>{const Ve=zn.current;if(Ve){const Ct=Ve.getBoundingClientRect().height;return Oi(Ct),v(qt=>[{toastId:p.id,height:Ct,position:p.position},...qt]),()=>v(qt=>qt.filter(ln=>ln.toastId!==p.id))}},[v,p.id]),be.useLayoutEffect(()=>{if(!I)return;const Ve=zn.current,Ct=Ve.style.height;Ve.style.height="auto";const qt=Ve.getBoundingClientRect().height;Ve.style.height=Ct,Oi(qt),v(ln=>ln.find(It=>It.toastId===p.id)?ln.map(It=>It.toastId===p.id?{...It,height:qt}:It):[{toastId:p.id,height:qt,position:p.position},...ln])},[I,p.title,p.description,v,p.id,p.jsx,p.action,p.cancel]);const Ae=be.useCallback(()=>{J(!0),lt(ii.current),v(Ve=>Ve.filter(Ct=>Ct.toastId!==p.id)),setTimeout(()=>{Q(p)},fF)},[p,Q,v,ii]);be.useEffect(()=>{if(p.promise&&sn==="loading"||p.duration===1/0||p.type==="loading")return;let Ve;return T||y||Se?(()=>{if(M.current{p.onAutoClose==null||p.onAutoClose.call(p,p),Ae()},At.current)),()=>clearTimeout(Ve)},[T,y,p,sn,Se,Ae]),be.useEffect(()=>{p.delete&&(Ae(),p.onDismiss==null||p.onDismiss.call(p,p))},[Ae,p.delete]);function dt(){var Ve;if(W?.loading){var Ct;return be.createElement("div",{className:ps(N?.loader,p==null||(Ct=p.classNames)==null?void 0:Ct.loader,"sonner-loader"),"data-visible":sn==="loading"},W.loading)}return be.createElement(YY,{className:ps(N?.loader,p==null||(Ve=p.classNames)==null?void 0:Ve.loader),visible:sn==="loading"})}const Zt=p.icon||W?.[sn]||UY(sn);var on,an;return be.createElement("li",{tabIndex:0,ref:zn,className:ps(G,xn,N?.toast,p==null||(e=p.classNames)==null?void 0:e.toast,N?.default,N?.[sn],p==null||(n=p.classNames)==null?void 0:n[sn]),"data-sonner-toast":"","data-rich-colors":(on=p.richColors)!=null?on:A,"data-styled":!(p.jsx||p.unstyled||O),"data-mounted":I,"data-promise":!!p.promise,"data-swiped":Xe,"data-removed":V,"data-visible":Ri,"data-y-position":q,"data-x-position":he,"data-index":C,"data-front":gr,"data-swiping":se,"data-dismissible":Yi,"data-type":sn,"data-invert":ke,"data-swipe-out":xe,"data-swipe-direction":D,"data-expanded":!!(T||ye&&I),"data-testid":p.testId,style:{"--index":C,"--toasts-before":C,"--z-index":$.length-C,"--offset":`${V?Qt:ii.current}px`,"--initial-height":ye?"auto":`${ti}px`,...j,...p.style},onDragEnd:()=>{pe(!1),le(null),U.current=null},onPointerDown:Ve=>{Ve.button!==2&&(_e||!Yi||(pr.current=new Date,lt(ii.current),Ve.target.setPointerCapture(Ve.pointerId),Ve.target.tagName!=="BUTTON"&&(pe(!0),U.current={x:Ve.clientX,y:Ve.clientY})))},onPointerUp:()=>{var Ve,Ct,qt;if(xe||!Yi)return;U.current=null;const ln=Number(((Ve=zn.current)==null?void 0:Ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),yi=Number(((Ct=zn.current)==null?void 0:Ct.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),It=new Date().getTime()-((qt=pr.current)==null?void 0:qt.getTime()),ri=oe==="x"?ln:yi,ls=Math.abs(ri)/It;if(Math.abs(ri)>=dF||ls>.11){lt(ii.current),p.onDismiss==null||p.onDismiss.call(p,p),P(oe==="x"?ln>0?"right":"left":yi>0?"down":"up"),Ae(),Ze(!0);return}else{var Ln,si;(Ln=zn.current)==null||Ln.style.setProperty("--swipe-amount-x","0px"),(si=zn.current)==null||si.style.setProperty("--swipe-amount-y","0px")}Ge(!1),pe(!1),le(null)},onPointerMove:Ve=>{var Ct,qt,ln;if(!U.current||!Yi||((Ct=window.getSelection())==null?void 0:Ct.toString().length)>0)return;const It=Ve.clientY-U.current.y,ri=Ve.clientX-U.current.x;var ls;const Ln=(ls=t.swipeDirections)!=null?ls:hF(re);!oe&&(Math.abs(ri)>1||Math.abs(It)>1)&&le(Math.abs(ri)>Math.abs(It)?"x":"y");let si={x:0,y:0};const Mo=Qi=>1/(1.5+Math.abs(Qi)/20);if(oe==="y"){if(Ln.includes("top")||Ln.includes("bottom"))if(Ln.includes("top")&&It<0||Ln.includes("bottom")&&It>0)si.y=It;else{const Qi=It*Mo(It);si.y=Math.abs(Qi)0)si.x=ri;else{const Qi=ri*Mo(ri);si.x=Math.abs(Qi)0||Math.abs(si.y)>0)&&Ge(!0),(qt=zn.current)==null||qt.style.setProperty("--swipe-amount-x",`${si.x}px`),(ln=zn.current)==null||ln.style.setProperty("--swipe-amount-y",`${si.y}px`)}},qs&&!p.jsx&&sn!=="loading"?be.createElement("button",{"aria-label":ce,"data-disabled":_e,"data-close-button":!0,onClick:_e||!Yi?()=>{}:()=>{Ae(),p.onDismiss==null||p.onDismiss.call(p,p)},className:ps(N?.closeButton,p==null||(i=p.classNames)==null?void 0:i.closeButton)},(an=W?.close)!=null?an:KY):null,(sn||p.icon||p.promise)&&p.icon!==null&&(W?.[sn]!==null||p.icon)?be.createElement("div",{"data-icon":"",className:ps(N?.icon,p==null||(r=p.classNames)==null?void 0:r.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||dt():null,p.type!=="loading"?Zt:null):null,be.createElement("div",{"data-content":"",className:ps(N?.content,p==null||(s=p.classNames)==null?void 0:s.content)},be.createElement("div",{"data-title":"",className:ps(N?.title,p==null||(o=p.classNames)==null?void 0:o.title)},p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title),p.description?be.createElement("div",{"data-description":"",className:ps(H,ni,N?.description,p==null||(l=p.classNames)==null?void 0:l.description)},typeof p.description=="function"?p.description():p.description):null),be.isValidElement(p.cancel)?p.cancel:p.cancel&&dg(p.cancel)?be.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||L,onClick:Ve=>{dg(p.cancel)&&Yi&&(p.cancel.onClick==null||p.cancel.onClick.call(p.cancel,Ve),Ae())},className:ps(N?.cancelButton,p==null||(u=p.classNames)==null?void 0:u.cancelButton)},p.cancel.label):null,be.isValidElement(p.action)?p.action:p.action&&dg(p.action)?be.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||ne,onClick:Ve=>{dg(p.action)&&(p.action.onClick==null||p.action.onClick.call(p.action,Ve),!Ve.defaultPrevented&&Ae())},className:ps(N?.actionButton,p==null||(f=p.classNames)==null?void 0:f.actionButton)},p.action.label):null)};function q2(){if(typeof window>"u"||typeof document>"u")return"ltr";const t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function gF(t,e){const n={};return[t,e].forEach((i,r)=>{const s=r===1,o=s?"--mobile-offset":"--offset",l=s?lF:aF;function u(f){["top","right","bottom","left"].forEach(h=>{n[`${o}-${h}`]=typeof f=="number"?`${f}px`:f})}typeof i=="number"||typeof i=="string"?u(i):typeof i=="object"?["top","right","bottom","left"].forEach(f=>{i[f]===void 0?n[`${o}-${f}`]=l:n[`${o}-${f}`]=typeof i[f]=="number"?`${i[f]}px`:i[f]}):u(l)}),n}const mF=be.forwardRef(function(e,n){const{id:i,invert:r,position:s="bottom-right",hotkey:o=["altKey","KeyT"],expand:l,closeButton:u,className:f,offset:h,mobileOffset:p,theme:O="light",richColors:y,duration:v,style:S,visibleToasts:k=oF,toastOptions:C,dir:$=q2(),gap:T=uF,icons:Q,containerAriaLabel:A="Notifications"}=e,[R,j]=be.useState([]),L=be.useMemo(()=>i?R.filter(I=>I.toasterId===i):R.filter(I=>!I.toasterId),[R,i]),ne=be.useMemo(()=>Array.from(new Set([s].concat(L.filter(I=>I.position).map(I=>I.position)))),[L,s]),[G,H]=be.useState([]),[Y,re]=be.useState(!1),[K,ye]=be.useState(!1),[N,W]=be.useState(O!=="system"?O:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ce=be.useRef(null),oe=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),le=be.useRef(null),D=be.useRef(!1),P=be.useCallback(I=>{j(X=>{var V;return(V=X.find(J=>J.id===I.id))!=null&&V.delete||Li.dismiss(I.id),X.filter(({id:J})=>J!==I.id)})},[]);return be.useEffect(()=>Li.subscribe(I=>{if(I.dismiss){requestAnimationFrame(()=>{j(X=>X.map(V=>V.id===I.id?{...V,delete:!0}:V))});return}setTimeout(()=>{JX.flushSync(()=>{j(X=>{const V=X.findIndex(J=>J.id===I.id);return V!==-1?[...X.slice(0,V),{...X[V],...I},...X.slice(V+1)]:[I,...X]})})})}),[R]),be.useEffect(()=>{if(O!=="system"){W(O);return}if(O==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?W("dark"):W("light")),typeof window>"u")return;const I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:X})=>{W(X?"dark":"light")})}catch{I.addListener(({matches:V})=>{try{W(V?"dark":"light")}catch(J){console.error(J)}})}},[O]),be.useEffect(()=>{R.length<=1&&re(!1)},[R]),be.useEffect(()=>{const I=X=>{var V;if(o.every(pe=>X[pe]||X.code===pe)){var se;re(!0),(se=ce.current)==null||se.focus()}X.code==="Escape"&&(document.activeElement===ce.current||(V=ce.current)!=null&&V.contains(document.activeElement))&&re(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[o]),be.useEffect(()=>{if(ce.current)return()=>{le.current&&(le.current.focus({preventScroll:!0}),le.current=null,D.current=!1)}},[ce.current]),be.createElement("section",{ref:n,"aria-label":`${A} ${oe}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},ne.map((I,X)=>{var V;const[J,se]=I.split("-");return L.length?be.createElement("ol",{key:I,dir:$==="auto"?q2():$,tabIndex:-1,ref:ce,className:f,"data-sonner-toaster":!0,"data-sonner-theme":N,"data-y-position":J,"data-x-position":se,style:{"--front-toast-height":`${((V=G[0])==null?void 0:V.height)||0}px`,"--width":`${cF}px`,"--gap":`${T}px`,...S,...gF(h,p)},onBlur:pe=>{D.current&&!pe.currentTarget.contains(pe.relatedTarget)&&(D.current=!1,le.current&&(le.current.focus({preventScroll:!0}),le.current=null))},onFocus:pe=>{pe.target instanceof HTMLElement&&pe.target.dataset.dismissible==="false"||D.current||(D.current=!0,le.current=pe.relatedTarget)},onMouseEnter:()=>re(!0),onMouseMove:()=>re(!0),onMouseLeave:()=>{K||re(!1)},onDragEnd:()=>re(!1),onPointerDown:pe=>{pe.target instanceof HTMLElement&&pe.target.dataset.dismissible==="false"||ye(!0)},onPointerUp:()=>ye(!1)},L.filter(pe=>!pe.position&&X===0||pe.position===I).map((pe,xe)=>{var Ze,Xe;return be.createElement(pF,{key:pe.id,icons:Q,index:xe,toast:pe,defaultRichColors:y,duration:(Ze=C?.duration)!=null?Ze:v,className:C?.className,descriptionClassName:C?.descriptionClassName,invert:r,visibleToasts:k,closeButton:(Xe=C?.closeButton)!=null?Xe:u,interacting:K,position:I,style:C?.style,unstyled:C?.unstyled,classNames:C?.classNames,cancelButtonStyle:C?.cancelButtonStyle,actionButtonStyle:C?.actionButtonStyle,closeButtonAriaLabel:C?.closeButtonAriaLabel,removeToast:P,toasts:L.filter(Ge=>Ge.position==pe.position),heights:G.filter(Ge=>Ge.position==pe.position),setHeights:H,expandByDefault:l,gap:T,expanded:Y,swipeDirections:e.swipeDirections})})):null}))}),OF=({...t})=>m.jsx(mF,{theme:"dark",className:"toaster group",icons:{success:m.jsx(t7,{className:"size-4"}),info:m.jsx(M7,{className:"size-4"}),warning:m.jsx(KM,{className:"size-4"}),error:m.jsx(rY,{className:"size-4"}),loading:m.jsx(V7,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius-ctl)"},...t});function Be(t,e=!1){e?B2.error(t,{duration:1/0,closeButton:!0}):B2(t)}function yF(){return m.jsx(OF,{position:"bottom-center"})}const Y2=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,F2=bM,vF=(t,e)=>n=>{var i;if(e?.variants==null)return F2(t,n?.class,n?.className);const{variants:r,defaultVariants:s}=e,o=Object.keys(r).map(f=>{const h=n?.[f],p=s?.[f];if(h===null)return null;const O=Y2(h)||Y2(p);return r[f][O]}),l=n&&Object.entries(n).reduce((f,h)=>{let[p,O]=h;return O===void 0||(f[p]=O),f},{}),u=e==null||(i=e.compoundVariants)===null||i===void 0?void 0:i.reduce((f,h)=>{let{class:p,className:O,...y}=h;return Object.entries(y).every(v=>{let[S,k]=v;return Array.isArray(k)?k.includes({...s,...l}[S]):{...s,...l}[S]===k})?[...f,p,O]:f},[]);return F2(t,o,u,n?.class,n?.className)},bF=vF("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[background-color,border-color,color] disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",primary:"pbtn",danger:"danger-btn",subtle:"ai-btn",toolbar:"btn",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function at({className:t,variant:e="default",size:n="default",asChild:i=!1,...r}){const s=i?eV:"button";return m.jsx(s,{"data-slot":"button","data-variant":e,"data-size":n,className:yt(bF({variant:e,size:n,className:t})),...r})}function NO({...t}){return m.jsx(Qw,{"data-slot":"dialog",...t})}function SF({...t}){return m.jsx(Pw,{"data-slot":"dialog-portal",...t})}function xF({className:t,...e}){return m.jsx(jw,{"data-slot":"dialog-overlay",className:yt("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",t),...e})}function zO({className:t,children:e,showCloseButton:n=!0,...i}){return m.jsxs(SF,{"data-slot":"dialog-portal",children:[m.jsx(xF,{}),m.jsxs(Mw,{"data-slot":"dialog-content",className:yt("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",t),...i,children:[e,n&&m.jsxs(_P,{"data-slot":"dialog-close",className:"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[m.jsx(eD,{}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function vh({className:t,...e}){return m.jsx(wP,{"data-slot":"dialog-title",className:yt("text-lg leading-none font-semibold",t),...e})}let iD=null,Ug=[];function bh(t){iD=t,Ug.forEach(e=>e())}function rD(t,e,n="",i="OK",r={}){return new Promise(s=>bh({kind:"prompt",title:t,label:e,value:n,okLabel:i,...r,resolve:s}))}function kl(t,e,n="Confirm",i=!1){return new Promise(r=>bh({kind:"confirm",title:t,message:e,confirmLabel:n,danger:i,resolve:r}))}function wF(){const t=w.useSyncExternalStore(n=>(Ug.push(n),()=>{Ug=Ug.filter(i=>i!==n)}),()=>iD);if(!t)return null;const e=()=>{bh(null),t.kind==="prompt"?t.resolve(null):t.resolve(!1)};return m.jsx(NO,{open:!0,onOpenChange:n=>!n&&e(),children:m.jsx(zO,{className:"modal",showCloseButton:!1,children:t.kind==="prompt"?m.jsx(kF,{m:t}):m.jsx(CF,{m:t})})})}function kF({m:t}){const e=w.useRef(null),n=f=>{bh(null),t.resolve(f)},[i,r]=w.useState(""),[s,o]=w.useState(t.value),l=t.match===void 0||s.trim()===t.match,u=()=>{const f=s;if(l){if(!f.trim()){r("Give it a name."),e.current.focus();return}n(f)}};return m.jsxs(m.Fragment,{children:[m.jsx(vh,{asChild:!0,children:m.jsx("h3",{children:t.title})}),m.jsx("label",{className:"modal-label",htmlFor:"modal-input",children:t.label}),m.jsx("input",{className:"modal-input",type:"text",autoComplete:"off",value:s,ref:e,id:"modal-input",autoFocus:!0,onFocus:f=>f.currentTarget.select(),"aria-invalid":!!i,"aria-describedby":i?"modal-input-err":void 0,onChange:f=>{o(f.currentTarget.value),i&&r("")},onKeyDown:f=>f.key==="Enter"&&u()}),i&&m.jsx("span",{id:"modal-input-err",role:"alert",className:"field-err",children:i}),m.jsxs("div",{className:"modal-actions",children:[m.jsx(at,{variant:"subtle",onClick:()=>n(null),children:"Cancel"}),m.jsx(at,{variant:t.danger?"danger":"primary",onClick:u,disabled:!l,children:t.okLabel})]})]})}function CF({m:t}){const e=n=>{bh(null),t.resolve(n)};return m.jsxs(m.Fragment,{children:[m.jsx(vh,{asChild:!0,children:m.jsx("h3",{children:t.title})}),m.jsx("div",{className:"modal-msg",children:t.message}),m.jsxs("div",{className:"modal-actions",children:[m.jsx(at,{variant:"subtle",onClick:()=>e(!1),autoFocus:t.danger,children:"Cancel"}),m.jsx(at,{variant:t.danger?"danger":"primary",onClick:()=>e(!0),autoFocus:!t.danger,children:t.confirmLabel})]})]})}const sD={queryKey:["projects"],queryFn:()=>Wt("/api/projects")};function _F(t){return nn({...sD,enabled:t,select:e=>e.projects||[]})}function $F(){const t=fr();return()=>t.fetchQuery(sD)}function oD(t){return nn({queryKey:["orgs"],queryFn:()=>Wt("/api/orgs"),enabled:t,select:e=>e.orgs||[]})}function f1(t){return nn({queryKey:["permissions",t],queryFn:()=>Wt(`/api/p/${t}/permissions`),enabled:!!t})}function aD(t){return nn({queryKey:["folders",t],queryFn:()=>Wt(`/api/p/${t}/folders`),enabled:!!t})}function lD(t,e=!0){return nn({queryKey:["shares",t],queryFn:()=>Wt(`/api/p/${t}/shares`),enabled:!!t&&e,select:n=>n.shares||[]})}function cD(t){return nn({queryKey:["admin","pending"],queryFn:()=>Wt("/api/admin/pending"),enabled:t,select:e=>e.pending||[]})}function uD(){const t=fr();return()=>Promise.all([t.invalidateQueries({queryKey:["projects"]}),t.invalidateQueries({queryKey:["orgs"]})]).then(()=>{})}function dD(t){return t.split("/").map(encodeURIComponent).join("/")}function TF(t){try{return decodeURIComponent(t)}catch{return t}}function LO(t){return t.split("/").map(TF).join("/")}const EF=new Set(["dashboard","history","install","settings"]),G2={insights:"dashboard"};function RF(t){return Object.hasOwn(G2,t)?G2[t]:void 0}const h1=["q","user","since","until"];function p1(t){return!!t&&h1.some(e=>!!t[e])}function fD(t){const e=new URLSearchParams;for(const i of h1)t?.[i]&&e.set(i,t[i]);const n=e.toString();return n?"?"+n:""}const QF={dashboard:"Dashboard",history:"History",install:"Install",settings:"Settings"};function hD(t,e){let n="";return t.view?(n=QF[t.view],t.viewTarget&&(n=`${t.viewTarget} · ${n}`)):t.path&&(n=t.path+(t.editing?" · Editing":t.version?" · Version":"")),n?`${n} — ${e}`:e}function pD(t,e){const n=t.indexOf("?"),i=n===-1?null:new URLSearchParams(t.slice(n)),r=i?.get("v")||"",s=i?.get("connect")||"",o=AF(n===-1?t:t.slice(0,n),e);r&&(o.version=r),s&&(o.connect=s),i?.has("full")&&(o.full=!0);const l={};for(const u of h1){const f=i?.get(u);f&&(l[u]=f)}if(p1(l)&&(o.filters=l),o.view==="history"&&!o.viewTarget){const u=(i?.get("path")||i?.get("prefix")||"").replace(/^\/+|\/+$/g,"");u&&(o.viewTarget=LO(u),o.queryTarget=!0)}return o}function H2(t,e){const n=e.replace(/\/+$/,"");return n!==e&&(t.trailingSlash=!0),t.path=n?LO(n):"",t}function W2(t){return t.path.split("/")[0]!=="edit"||(t.editing=!0,t.path=t.path.slice(5).replace(/\/+$/,"")),t}function AF(t,e){const n=t.replace(/^\/+/,"");if(e!=="hub")return W2(H2({path:""},n));if(n==="orgs"||n.startsWith("orgs/"))return{org:n.slice(5).replace(/\/+$/,""),path:""};if(n==="billing"||n.startsWith("billing/"))return{billing:!0,path:""};if(n==="connections"||n.startsWith("connections/"))return{connections:!0,path:""};const i=n.indexOf("/");if(i===-1)return{project:n,path:""};const r=H2({project:n.slice(0,i),path:""},n.slice(i+1)),s=r.path.indexOf("/"),o=s===-1?r.path:r.path.slice(0,s);if(o==="edit")return W2(r);const l=RF(o);return(EF.has(o)||l)&&(r.view=l||o,l&&(r.legacyView=!0),r.viewTarget=s===-1?"":r.path.slice(s+1).replace(/\/+$/,""),r.path=""),r}function Yr(t,e,n,i,r){const s=dD(t),o=s&&r?"edit/"+s:s,l=(n?"?v="+n:"")+(i?(n?"&":"?")+"full=1":"");return e?"/"+e+(o?"/"+o:"")+l:"/"+o+l}function PF(t){const e=t.indexOf("?");if(e===-1)return t;const n=new URLSearchParams(t.slice(e+1));if(!n.has("full"))return t;n.delete("full");const i=n.toString();return t.slice(0,e)+(i?"?"+i:"")}function Zi(t,e,n,i){let r=(e?"/"+e:"")+"/"+t;return n&&(r+="/"+dD(n.replace(/\/+$/,""))),r+(t==="history"?fD(i):"")}function jF(t,e){const n=LO(e).toLowerCase(),i=t.filter(r=>r.name.toLowerCase()===n);return i.length===1?i[0].id:void 0}let g1="POP";const IS=new Set;function gD(){for(const t of IS)t()}window.addEventListener("popstate",()=>{g1="POP",gD()});function zt(t,e){const n=location.pathname+location.search;!e?.replace&&n===t||(history[e?.replace?"replaceState":"pushState"](null,"",t),g1=e?.replace?"REPLACE":"PUSH",gD())}function m1(){return w.useSyncExternalStore(t=>(IS.add(t),()=>{IS.delete(t)}),()=>location.pathname+location.search)}function MF(){return g1}function Cl(t){return t.startsWith("/")&&!t.startsWith("//")?{href:t,onClick:n=>{n.defaultPrevented||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0||(n.preventDefault(),zt(t),document.body.classList.remove("sb-open"))}}:{href:t,target:"_blank",rel:"noopener noreferrer"}}function hl({to:t}){return w.useEffect(()=>{zt(t,{replace:!0})},[t]),null}function mD(){return{accessor:(t,e)=>typeof t=="function"?{...e,accessorFn:t}:{...e,accessorKey:t},display:t=>t,group:t=>t}}function ma(t,e){return typeof t=="function"?t(e):t}function ur(t,e){return n=>{e.setState(i=>({...i,[t]:ma(n,i[t])}))}}function ZO(t){return t instanceof Function}function DF(t){return Array.isArray(t)&&t.every(e=>typeof e=="number")}function NF(t,e){const n=[],i=r=>{r.forEach(s=>{n.push(s);const o=e(s);o!=null&&o.length&&i(o)})};return i(t),n}function Ye(t,e,n){let i=[],r;return s=>{let o;n.key&&n.debug&&(o=Date.now());const l=t(s);if(!(l.length!==i.length||l.some((h,p)=>i[p]!==h)))return r;i=l;let f;if(n.key&&n.debug&&(f=Date.now()),r=e(...l),n==null||n.onChange==null||n.onChange(r),n.key&&n.debug&&n!=null&&n.debug()){const h=Math.round((Date.now()-o)*100)/100,p=Math.round((Date.now()-f)*100)/100,O=p/16,y=(v,S)=>{for(v=String(v);v.length{var r;return(r=t?.debugAll)!=null?r:t[e]},key:!1,onChange:i}}function zF(t,e,n,i){const r=()=>{var o;return(o=s.getValue())!=null?o:t.options.renderFallbackValue},s={id:`${e.id}_${n.id}`,row:e,column:n,getValue:()=>e.getValue(i),renderValue:r,getContext:Ye(()=>[t,n,e,s],(o,l,u,f)=>({table:o,column:l,row:u,cell:f,getValue:f.getValue,renderValue:f.renderValue}),Fe(t.options,"debugCells"))};return t._features.forEach(o=>{o.createCell==null||o.createCell(s,n,e,t)},{}),s}function LF(t,e,n,i){var r,s;const l={...t._getDefaultColumnDef(),...e},u=l.accessorKey;let f=(r=(s=l.id)!=null?s:u?typeof String.prototype.replaceAll=="function"?u.replaceAll(".","_"):u.replace(/\./g,"_"):void 0)!=null?r:typeof l.header=="string"?l.header:void 0,h;if(l.accessorFn?h=l.accessorFn:u&&(u.includes(".")?h=O=>{let y=O;for(const S of u.split(".")){var v;y=(v=y)==null?void 0:v[S]}return y}:h=O=>O[l.accessorKey]),!f)throw new Error;let p={id:`${String(f)}`,accessorFn:h,parent:i,depth:n,columnDef:l,columns:[],getFlatColumns:Ye(()=>[!0],()=>{var O;return[p,...(O=p.columns)==null?void 0:O.flatMap(y=>y.getFlatColumns())]},Fe(t.options,"debugColumns")),getLeafColumns:Ye(()=>[t._getOrderColumnsFn()],O=>{var y;if((y=p.columns)!=null&&y.length){let v=p.columns.flatMap(S=>S.getLeafColumns());return O(v)}return[p]},Fe(t.options,"debugColumns"))};for(const O of t._features)O.createColumn==null||O.createColumn(p,t);return p}const ai="debugHeaders";function K2(t,e,n){var i;let s={id:(i=n.id)!=null?i:e.id,column:e,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const o=[],l=u=>{u.subHeaders&&u.subHeaders.length&&u.subHeaders.map(l),o.push(u)};return l(s),o},getContext:()=>({table:t,header:s,column:e})};return t._features.forEach(o=>{o.createHeader==null||o.createHeader(s,t)}),s}const ZF={createTable:t=>{t.getHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,i,r)=>{var s,o;const l=(s=i?.map(p=>n.find(O=>O.id===p)).filter(Boolean))!=null?s:[],u=(o=r?.map(p=>n.find(O=>O.id===p)).filter(Boolean))!=null?o:[],f=n.filter(p=>!(i!=null&&i.includes(p.id))&&!(r!=null&&r.includes(p.id)));return fg(e,[...l,...f,...u],t)},Fe(t.options,ai)),t.getCenterHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,i,r)=>(n=n.filter(s=>!(i!=null&&i.includes(s.id))&&!(r!=null&&r.includes(s.id))),fg(e,n,t,"center")),Fe(t.options,ai)),t.getLeftHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left],(e,n,i)=>{var r;const s=(r=i?.map(o=>n.find(l=>l.id===o)).filter(Boolean))!=null?r:[];return fg(e,s,t,"left")},Fe(t.options,ai)),t.getRightHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.right],(e,n,i)=>{var r;const s=(r=i?.map(o=>n.find(l=>l.id===o)).filter(Boolean))!=null?r:[];return fg(e,s,t,"right")},Fe(t.options,ai)),t.getFooterGroups=Ye(()=>[t.getHeaderGroups()],e=>[...e].reverse(),Fe(t.options,ai)),t.getLeftFooterGroups=Ye(()=>[t.getLeftHeaderGroups()],e=>[...e].reverse(),Fe(t.options,ai)),t.getCenterFooterGroups=Ye(()=>[t.getCenterHeaderGroups()],e=>[...e].reverse(),Fe(t.options,ai)),t.getRightFooterGroups=Ye(()=>[t.getRightHeaderGroups()],e=>[...e].reverse(),Fe(t.options,ai)),t.getFlatHeaders=Ye(()=>[t.getHeaderGroups()],e=>e.map(n=>n.headers).flat(),Fe(t.options,ai)),t.getLeftFlatHeaders=Ye(()=>[t.getLeftHeaderGroups()],e=>e.map(n=>n.headers).flat(),Fe(t.options,ai)),t.getCenterFlatHeaders=Ye(()=>[t.getCenterHeaderGroups()],e=>e.map(n=>n.headers).flat(),Fe(t.options,ai)),t.getRightFlatHeaders=Ye(()=>[t.getRightHeaderGroups()],e=>e.map(n=>n.headers).flat(),Fe(t.options,ai)),t.getCenterLeafHeaders=Ye(()=>[t.getCenterFlatHeaders()],e=>e.filter(n=>{var i;return!((i=n.subHeaders)!=null&&i.length)}),Fe(t.options,ai)),t.getLeftLeafHeaders=Ye(()=>[t.getLeftFlatHeaders()],e=>e.filter(n=>{var i;return!((i=n.subHeaders)!=null&&i.length)}),Fe(t.options,ai)),t.getRightLeafHeaders=Ye(()=>[t.getRightFlatHeaders()],e=>e.filter(n=>{var i;return!((i=n.subHeaders)!=null&&i.length)}),Fe(t.options,ai)),t.getLeafHeaders=Ye(()=>[t.getLeftHeaderGroups(),t.getCenterHeaderGroups(),t.getRightHeaderGroups()],(e,n,i)=>{var r,s,o,l,u,f;return[...(r=(s=e[0])==null?void 0:s.headers)!=null?r:[],...(o=(l=n[0])==null?void 0:l.headers)!=null?o:[],...(u=(f=i[0])==null?void 0:f.headers)!=null?u:[]].map(h=>h.getLeafHeaders()).flat()},Fe(t.options,ai))}};function fg(t,e,n,i){var r,s;let o=0;const l=function(O,y){y===void 0&&(y=1),o=Math.max(o,y),O.filter(v=>v.getIsVisible()).forEach(v=>{var S;(S=v.columns)!=null&&S.length&&l(v.columns,y+1)},0)};l(t);let u=[];const f=(O,y)=>{const v={depth:y,id:[i,`${y}`].filter(Boolean).join("_"),headers:[]},S=[];O.forEach(k=>{const C=[...S].reverse()[0],$=k.column.depth===v.depth;let T,Q=!1;if($&&k.column.parent?T=k.column.parent:(T=k.column,Q=!0),C&&C?.column===T)C.subHeaders.push(k);else{const A=K2(n,T,{id:[i,y,T.id,k?.id].filter(Boolean).join("_"),isPlaceholder:Q,placeholderId:Q?`${S.filter(R=>R.column===T).length}`:void 0,depth:y,index:S.length});A.subHeaders.push(k),S.push(A)}v.headers.push(k),k.headerGroup=v}),u.push(v),y>0&&f(S,y-1)},h=e.map((O,y)=>K2(n,O,{depth:o,index:y}));f(h,o-1),u.reverse();const p=O=>O.filter(v=>v.column.getIsVisible()).map(v=>{let S=0,k=0,C=[0];v.subHeaders&&v.subHeaders.length?(C=[],p(v.subHeaders).forEach(T=>{let{colSpan:Q,rowSpan:A}=T;S+=Q,C.push(A)})):S=1;const $=Math.min(...C);return k=k+$,v.colSpan=S,v.rowSpan=k,{colSpan:S,rowSpan:k}});return p((r=(s=u[0])==null?void 0:s.headers)!=null?r:[]),u}const IF=(t,e,n,i,r,s,o)=>{let l={id:e,index:i,original:n,depth:r,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:u=>{if(l._valuesCache.hasOwnProperty(u))return l._valuesCache[u];const f=t.getColumn(u);if(f!=null&&f.accessorFn)return l._valuesCache[u]=f.accessorFn(l.original,i),l._valuesCache[u]},getUniqueValues:u=>{if(l._uniqueValuesCache.hasOwnProperty(u))return l._uniqueValuesCache[u];const f=t.getColumn(u);if(f!=null&&f.accessorFn)return f.columnDef.getUniqueValues?(l._uniqueValuesCache[u]=f.columnDef.getUniqueValues(l.original,i),l._uniqueValuesCache[u]):(l._uniqueValuesCache[u]=[l.getValue(u)],l._uniqueValuesCache[u])},renderValue:u=>{var f;return(f=l.getValue(u))!=null?f:t.options.renderFallbackValue},subRows:[],getLeafRows:()=>NF(l.subRows,u=>u.subRows),getParentRow:()=>l.parentId?t.getRow(l.parentId,!0):void 0,getParentRows:()=>{let u=[],f=l;for(;;){const h=f.getParentRow();if(!h)break;u.push(h),f=h}return u.reverse()},getAllCells:Ye(()=>[t.getAllLeafColumns()],u=>u.map(f=>zF(t,l,f,f.id)),Fe(t.options,"debugRows")),_getAllCellsByColumnId:Ye(()=>[l.getAllCells()],u=>u.reduce((f,h)=>(f[h.column.id]=h,f),{}),Fe(t.options,"debugRows"))};for(let u=0;u{t._getFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,t.id),t.getFacetedRowModel=()=>t._getFacetedRowModel?t._getFacetedRowModel():e.getPreFilteredRowModel(),t._getFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,t.id),t.getFacetedUniqueValues=()=>t._getFacetedUniqueValues?t._getFacetedUniqueValues():new Map,t._getFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,t.id),t.getFacetedMinMaxValues=()=>{if(t._getFacetedMinMaxValues)return t._getFacetedMinMaxValues()}}},OD=(t,e,n)=>{var i,r;const s=n==null||(i=n.toString())==null?void 0:i.toLowerCase();return!!(!((r=t.getValue(e))==null||(r=r.toString())==null||(r=r.toLowerCase())==null)&&r.includes(s))};OD.autoRemove=t=>Jr(t);const yD=(t,e,n)=>{var i;return!!(!((i=t.getValue(e))==null||(i=i.toString())==null)&&i.includes(n))};yD.autoRemove=t=>Jr(t);const vD=(t,e,n)=>{var i;return((i=t.getValue(e))==null||(i=i.toString())==null?void 0:i.toLowerCase())===n?.toLowerCase()};vD.autoRemove=t=>Jr(t);const bD=(t,e,n)=>{var i;return(i=t.getValue(e))==null?void 0:i.includes(n)};bD.autoRemove=t=>Jr(t);const SD=(t,e,n)=>!n.some(i=>{var r;return!((r=t.getValue(e))!=null&&r.includes(i))});SD.autoRemove=t=>Jr(t)||!(t!=null&&t.length);const xD=(t,e,n)=>n.some(i=>{var r;return(r=t.getValue(e))==null?void 0:r.includes(i)});xD.autoRemove=t=>Jr(t)||!(t!=null&&t.length);const wD=(t,e,n)=>t.getValue(e)===n;wD.autoRemove=t=>Jr(t);const kD=(t,e,n)=>t.getValue(e)==n;kD.autoRemove=t=>Jr(t);const O1=(t,e,n)=>{let[i,r]=n;const s=t.getValue(e);return s>=i&&s<=r};O1.resolveFilterValue=t=>{let[e,n]=t,i=typeof e!="number"?parseFloat(e):e,r=typeof n!="number"?parseFloat(n):n,s=e===null||Number.isNaN(i)?-1/0:i,o=n===null||Number.isNaN(r)?1/0:r;if(s>o){const l=s;s=o,o=l}return[s,o]};O1.autoRemove=t=>Jr(t)||Jr(t[0])&&Jr(t[1]);const go={includesString:OD,includesStringSensitive:yD,equalsString:vD,arrIncludes:bD,arrIncludesAll:SD,arrIncludesSome:xD,equals:wD,weakEquals:kD,inNumberRange:O1};function Jr(t){return t==null||t===""}const VF={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:t=>({columnFilters:[],...t}),getDefaultOptions:t=>({onColumnFiltersChange:ur("columnFilters",t),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(t,e)=>{t.getAutoFilterFn=()=>{const n=e.getCoreRowModel().flatRows[0],i=n?.getValue(t.id);return typeof i=="string"?go.includesString:typeof i=="number"?go.inNumberRange:typeof i=="boolean"||i!==null&&typeof i=="object"?go.equals:Array.isArray(i)?go.arrIncludes:go.weakEquals},t.getFilterFn=()=>{var n,i;return ZO(t.columnDef.filterFn)?t.columnDef.filterFn:t.columnDef.filterFn==="auto"?t.getAutoFilterFn():(n=(i=e.options.filterFns)==null?void 0:i[t.columnDef.filterFn])!=null?n:go[t.columnDef.filterFn]},t.getCanFilter=()=>{var n,i,r;return((n=t.columnDef.enableColumnFilter)!=null?n:!0)&&((i=e.options.enableColumnFilters)!=null?i:!0)&&((r=e.options.enableFilters)!=null?r:!0)&&!!t.accessorFn},t.getIsFiltered=()=>t.getFilterIndex()>-1,t.getFilterValue=()=>{var n;return(n=e.getState().columnFilters)==null||(n=n.find(i=>i.id===t.id))==null?void 0:n.value},t.getFilterIndex=()=>{var n,i;return(n=(i=e.getState().columnFilters)==null?void 0:i.findIndex(r=>r.id===t.id))!=null?n:-1},t.setFilterValue=n=>{e.setColumnFilters(i=>{const r=t.getFilterFn(),s=i?.find(h=>h.id===t.id),o=ma(n,s?s.value:void 0);if(J2(r,o,t)){var l;return(l=i?.filter(h=>h.id!==t.id))!=null?l:[]}const u={id:t.id,value:o};if(s){var f;return(f=i?.map(h=>h.id===t.id?u:h))!=null?f:[]}return i!=null&&i.length?[...i,u]:[u]})}},createRow:(t,e)=>{t.columnFilters={},t.columnFiltersMeta={}},createTable:t=>{t.setColumnFilters=e=>{const n=t.getAllLeafColumns(),i=r=>{var s;return(s=ma(e,r))==null?void 0:s.filter(o=>{const l=n.find(u=>u.id===o.id);if(l){const u=l.getFilterFn();if(J2(u,o.value,l))return!1}return!0})};t.options.onColumnFiltersChange==null||t.options.onColumnFiltersChange(i)},t.resetColumnFilters=e=>{var n,i;t.setColumnFilters(e?[]:(n=(i=t.initialState)==null?void 0:i.columnFilters)!=null?n:[])},t.getPreFilteredRowModel=()=>t.getCoreRowModel(),t.getFilteredRowModel=()=>(!t._getFilteredRowModel&&t.options.getFilteredRowModel&&(t._getFilteredRowModel=t.options.getFilteredRowModel(t)),t.options.manualFiltering||!t._getFilteredRowModel?t.getPreFilteredRowModel():t._getFilteredRowModel())}};function J2(t,e,n){return(t&&t.autoRemove?t.autoRemove(e,n):!1)||typeof e>"u"||typeof e=="string"&&!e}const BF=(t,e,n)=>n.reduce((i,r)=>{const s=r.getValue(t);return i+(typeof s=="number"?s:0)},0),UF=(t,e,n)=>{let i;return n.forEach(r=>{const s=r.getValue(t);s!=null&&(i>s||i===void 0&&s>=s)&&(i=s)}),i},qF=(t,e,n)=>{let i;return n.forEach(r=>{const s=r.getValue(t);s!=null&&(i=s)&&(i=s)}),i},YF=(t,e,n)=>{let i,r;return n.forEach(s=>{const o=s.getValue(t);o!=null&&(i===void 0?o>=o&&(i=r=o):(i>o&&(i=o),r{let n=0,i=0;if(e.forEach(r=>{let s=r.getValue(t);s!=null&&(s=+s)>=s&&(++n,i+=s)}),n)return i/n},GF=(t,e)=>{if(!e.length)return;const n=e.map(s=>s.getValue(t));if(!DF(n))return;if(n.length===1)return n[0];const i=Math.floor(n.length/2),r=n.sort((s,o)=>s-o);return n.length%2!==0?r[i]:(r[i-1]+r[i])/2},HF=(t,e)=>Array.from(new Set(e.map(n=>n.getValue(t))).values()),WF=(t,e)=>new Set(e.map(n=>n.getValue(t))).size,KF=(t,e)=>e.length,nb={sum:BF,min:UF,max:qF,extent:YF,mean:FF,median:GF,unique:HF,uniqueCount:WF,count:KF},JF={getDefaultColumnDef:()=>({aggregatedCell:t=>{var e,n;return(e=(n=t.getValue())==null||n.toString==null?void 0:n.toString())!=null?e:null},aggregationFn:"auto"}),getInitialState:t=>({grouping:[],...t}),getDefaultOptions:t=>({onGroupingChange:ur("grouping",t),groupedColumnMode:"reorder"}),createColumn:(t,e)=>{t.toggleGrouping=()=>{e.setGrouping(n=>n!=null&&n.includes(t.id)?n.filter(i=>i!==t.id):[...n??[],t.id])},t.getCanGroup=()=>{var n,i;return((n=t.columnDef.enableGrouping)!=null?n:!0)&&((i=e.options.enableGrouping)!=null?i:!0)&&(!!t.accessorFn||!!t.columnDef.getGroupingValue)},t.getIsGrouped=()=>{var n;return(n=e.getState().grouping)==null?void 0:n.includes(t.id)},t.getGroupedIndex=()=>{var n;return(n=e.getState().grouping)==null?void 0:n.indexOf(t.id)},t.getToggleGroupingHandler=()=>{const n=t.getCanGroup();return()=>{n&&t.toggleGrouping()}},t.getAutoAggregationFn=()=>{const n=e.getCoreRowModel().flatRows[0],i=n?.getValue(t.id);if(typeof i=="number")return nb.sum;if(Object.prototype.toString.call(i)==="[object Date]")return nb.extent},t.getAggregationFn=()=>{var n,i;if(!t)throw new Error;return ZO(t.columnDef.aggregationFn)?t.columnDef.aggregationFn:t.columnDef.aggregationFn==="auto"?t.getAutoAggregationFn():(n=(i=e.options.aggregationFns)==null?void 0:i[t.columnDef.aggregationFn])!=null?n:nb[t.columnDef.aggregationFn]}},createTable:t=>{t.setGrouping=e=>t.options.onGroupingChange==null?void 0:t.options.onGroupingChange(e),t.resetGrouping=e=>{var n,i;t.setGrouping(e?[]:(n=(i=t.initialState)==null?void 0:i.grouping)!=null?n:[])},t.getPreGroupedRowModel=()=>t.getFilteredRowModel(),t.getGroupedRowModel=()=>(!t._getGroupedRowModel&&t.options.getGroupedRowModel&&(t._getGroupedRowModel=t.options.getGroupedRowModel(t)),t.options.manualGrouping||!t._getGroupedRowModel?t.getPreGroupedRowModel():t._getGroupedRowModel())},createRow:(t,e)=>{t.getIsGrouped=()=>!!t.groupingColumnId,t.getGroupingValue=n=>{if(t._groupingValuesCache.hasOwnProperty(n))return t._groupingValuesCache[n];const i=e.getColumn(n);return i!=null&&i.columnDef.getGroupingValue?(t._groupingValuesCache[n]=i.columnDef.getGroupingValue(t.original),t._groupingValuesCache[n]):t.getValue(n)},t._groupingValuesCache={}},createCell:(t,e,n,i)=>{t.getIsGrouped=()=>e.getIsGrouped()&&e.id===n.groupingColumnId,t.getIsPlaceholder=()=>!t.getIsGrouped()&&e.getIsGrouped(),t.getIsAggregated=()=>{var r;return!t.getIsGrouped()&&!t.getIsPlaceholder()&&!!((r=n.subRows)!=null&&r.length)}}};function eG(t,e,n){if(!(e!=null&&e.length)||!n)return t;const i=t.filter(s=>!e.includes(s.id));return n==="remove"?i:[...e.map(s=>t.find(o=>o.id===s)).filter(Boolean),...i]}const tG={getInitialState:t=>({columnOrder:[],...t}),getDefaultOptions:t=>({onColumnOrderChange:ur("columnOrder",t)}),createColumn:(t,e)=>{t.getIndex=Ye(n=>[yf(e,n)],n=>n.findIndex(i=>i.id===t.id),Fe(e.options,"debugColumns")),t.getIsFirstColumn=n=>{var i;return((i=yf(e,n)[0])==null?void 0:i.id)===t.id},t.getIsLastColumn=n=>{var i;const r=yf(e,n);return((i=r[r.length-1])==null?void 0:i.id)===t.id}},createTable:t=>{t.setColumnOrder=e=>t.options.onColumnOrderChange==null?void 0:t.options.onColumnOrderChange(e),t.resetColumnOrder=e=>{var n;t.setColumnOrder(e?[]:(n=t.initialState.columnOrder)!=null?n:[])},t._getOrderColumnsFn=Ye(()=>[t.getState().columnOrder,t.getState().grouping,t.options.groupedColumnMode],(e,n,i)=>r=>{let s=[];if(!(e!=null&&e.length))s=r;else{const o=[...e],l=[...r];for(;l.length&&o.length;){const u=o.shift(),f=l.findIndex(h=>h.id===u);f>-1&&s.push(l.splice(f,1)[0])}s=[...s,...l]}return eG(s,n,i)},Fe(t.options,"debugTable"))}},ib=()=>({left:[],right:[]}),nG={getInitialState:t=>({columnPinning:ib(),...t}),getDefaultOptions:t=>({onColumnPinningChange:ur("columnPinning",t)}),createColumn:(t,e)=>{t.pin=n=>{const i=t.getLeafColumns().map(r=>r.id).filter(Boolean);e.setColumnPinning(r=>{var s,o;if(n==="right"){var l,u;return{left:((l=r?.left)!=null?l:[]).filter(p=>!(i!=null&&i.includes(p))),right:[...((u=r?.right)!=null?u:[]).filter(p=>!(i!=null&&i.includes(p))),...i]}}if(n==="left"){var f,h;return{left:[...((f=r?.left)!=null?f:[]).filter(p=>!(i!=null&&i.includes(p))),...i],right:((h=r?.right)!=null?h:[]).filter(p=>!(i!=null&&i.includes(p)))}}return{left:((s=r?.left)!=null?s:[]).filter(p=>!(i!=null&&i.includes(p))),right:((o=r?.right)!=null?o:[]).filter(p=>!(i!=null&&i.includes(p)))}})},t.getCanPin=()=>t.getLeafColumns().some(i=>{var r,s,o;return((r=i.columnDef.enablePinning)!=null?r:!0)&&((s=(o=e.options.enableColumnPinning)!=null?o:e.options.enablePinning)!=null?s:!0)}),t.getIsPinned=()=>{const n=t.getLeafColumns().map(l=>l.id),{left:i,right:r}=e.getState().columnPinning,s=n.some(l=>i?.includes(l)),o=n.some(l=>r?.includes(l));return s?"left":o?"right":!1},t.getPinnedIndex=()=>{var n,i;const r=t.getIsPinned();return r?(n=(i=e.getState().columnPinning)==null||(i=i[r])==null?void 0:i.indexOf(t.id))!=null?n:-1:0}},createRow:(t,e)=>{t.getCenterVisibleCells=Ye(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,i,r)=>{const s=[...i??[],...r??[]];return n.filter(o=>!s.includes(o.column.id))},Fe(e.options,"debugRows")),t.getLeftVisibleCells=Ye(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left],(n,i)=>(i??[]).map(s=>n.find(o=>o.column.id===s)).filter(Boolean).map(s=>({...s,position:"left"})),Fe(e.options,"debugRows")),t.getRightVisibleCells=Ye(()=>[t._getAllVisibleCells(),e.getState().columnPinning.right],(n,i)=>(i??[]).map(s=>n.find(o=>o.column.id===s)).filter(Boolean).map(s=>({...s,position:"right"})),Fe(e.options,"debugRows"))},createTable:t=>{t.setColumnPinning=e=>t.options.onColumnPinningChange==null?void 0:t.options.onColumnPinningChange(e),t.resetColumnPinning=e=>{var n,i;return t.setColumnPinning(e?ib():(n=(i=t.initialState)==null?void 0:i.columnPinning)!=null?n:ib())},t.getIsSomeColumnsPinned=e=>{var n;const i=t.getState().columnPinning;if(!e){var r,s;return!!((r=i.left)!=null&&r.length||(s=i.right)!=null&&s.length)}return!!((n=i[e])!=null&&n.length)},t.getLeftLeafColumns=Ye(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left],(e,n)=>(n??[]).map(i=>e.find(r=>r.id===i)).filter(Boolean),Fe(t.options,"debugColumns")),t.getRightLeafColumns=Ye(()=>[t.getAllLeafColumns(),t.getState().columnPinning.right],(e,n)=>(n??[]).map(i=>e.find(r=>r.id===i)).filter(Boolean),Fe(t.options,"debugColumns")),t.getCenterLeafColumns=Ye(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,i)=>{const r=[...n??[],...i??[]];return e.filter(s=>!r.includes(s.id))},Fe(t.options,"debugColumns"))}};function iG(t){return t||(typeof document<"u"?document:null)}const hg={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},rb=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),rG={getDefaultColumnDef:()=>hg,getInitialState:t=>({columnSizing:{},columnSizingInfo:rb(),...t}),getDefaultOptions:t=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:ur("columnSizing",t),onColumnSizingInfoChange:ur("columnSizingInfo",t)}),createColumn:(t,e)=>{t.getSize=()=>{var n,i,r;const s=e.getState().columnSizing[t.id];return Math.min(Math.max((n=t.columnDef.minSize)!=null?n:hg.minSize,(i=s??t.columnDef.size)!=null?i:hg.size),(r=t.columnDef.maxSize)!=null?r:hg.maxSize)},t.getStart=Ye(n=>[n,yf(e,n),e.getState().columnSizing],(n,i)=>i.slice(0,t.getIndex(n)).reduce((r,s)=>r+s.getSize(),0),Fe(e.options,"debugColumns")),t.getAfter=Ye(n=>[n,yf(e,n),e.getState().columnSizing],(n,i)=>i.slice(t.getIndex(n)+1).reduce((r,s)=>r+s.getSize(),0),Fe(e.options,"debugColumns")),t.resetSize=()=>{e.setColumnSizing(n=>{let{[t.id]:i,...r}=n;return r})},t.getCanResize=()=>{var n,i;return((n=t.columnDef.enableResizing)!=null?n:!0)&&((i=e.options.enableColumnResizing)!=null?i:!0)},t.getIsResizing=()=>e.getState().columnSizingInfo.isResizingColumn===t.id},createHeader:(t,e)=>{t.getSize=()=>{let n=0;const i=r=>{if(r.subHeaders.length)r.subHeaders.forEach(i);else{var s;n+=(s=r.column.getSize())!=null?s:0}};return i(t),n},t.getStart=()=>{if(t.index>0){const n=t.headerGroup.headers[t.index-1];return n.getStart()+n.getSize()}return 0},t.getResizeHandler=n=>{const i=e.getColumn(t.column.id),r=i?.getCanResize();return s=>{if(!i||!r||(s.persist==null||s.persist(),sb(s)&&s.touches&&s.touches.length>1))return;const o=t.getSize(),l=t?t.getLeafHeaders().map(C=>[C.column.id,C.column.getSize()]):[[i.id,i.getSize()]],u=sb(s)?Math.round(s.touches[0].clientX):s.clientX,f={},h=(C,$)=>{typeof $=="number"&&(e.setColumnSizingInfo(T=>{var Q,A;const R=e.options.columnResizeDirection==="rtl"?-1:1,j=($-((Q=T?.startOffset)!=null?Q:0))*R,L=Math.max(j/((A=T?.startSize)!=null?A:0),-.999999);return T.columnSizingStart.forEach(ne=>{let[G,H]=ne;f[G]=Math.round(Math.max(H+H*L,0)*100)/100}),{...T,deltaOffset:j,deltaPercentage:L}}),(e.options.columnResizeMode==="onChange"||C==="end")&&e.setColumnSizing(T=>({...T,...f})))},p=C=>h("move",C),O=C=>{h("end",C),e.setColumnSizingInfo($=>({...$,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},y=iG(n),v={moveHandler:C=>p(C.clientX),upHandler:C=>{y?.removeEventListener("mousemove",v.moveHandler),y?.removeEventListener("mouseup",v.upHandler),O(C.clientX)}},S={moveHandler:C=>(C.cancelable&&(C.preventDefault(),C.stopPropagation()),p(C.touches[0].clientX),!1),upHandler:C=>{var $;y?.removeEventListener("touchmove",S.moveHandler),y?.removeEventListener("touchend",S.upHandler),C.cancelable&&(C.preventDefault(),C.stopPropagation()),O(($=C.touches[0])==null?void 0:$.clientX)}},k=sG()?{passive:!1}:!1;sb(s)?(y?.addEventListener("touchmove",S.moveHandler,k),y?.addEventListener("touchend",S.upHandler,k)):(y?.addEventListener("mousemove",v.moveHandler,k),y?.addEventListener("mouseup",v.upHandler,k)),e.setColumnSizingInfo(C=>({...C,startOffset:u,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:i.id}))}}},createTable:t=>{t.setColumnSizing=e=>t.options.onColumnSizingChange==null?void 0:t.options.onColumnSizingChange(e),t.setColumnSizingInfo=e=>t.options.onColumnSizingInfoChange==null?void 0:t.options.onColumnSizingInfoChange(e),t.resetColumnSizing=e=>{var n;t.setColumnSizing(e?{}:(n=t.initialState.columnSizing)!=null?n:{})},t.resetHeaderSizeInfo=e=>{var n;t.setColumnSizingInfo(e?rb():(n=t.initialState.columnSizingInfo)!=null?n:rb())},t.getTotalSize=()=>{var e,n;return(e=(n=t.getHeaderGroups()[0])==null?void 0:n.headers.reduce((i,r)=>i+r.getSize(),0))!=null?e:0},t.getLeftTotalSize=()=>{var e,n;return(e=(n=t.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((i,r)=>i+r.getSize(),0))!=null?e:0},t.getCenterTotalSize=()=>{var e,n;return(e=(n=t.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((i,r)=>i+r.getSize(),0))!=null?e:0},t.getRightTotalSize=()=>{var e,n;return(e=(n=t.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((i,r)=>i+r.getSize(),0))!=null?e:0}}};let pg=null;function sG(){if(typeof pg=="boolean")return pg;let t=!1;try{const e={get passive(){return t=!0,!1}},n=()=>{};window.addEventListener("test",n,e),window.removeEventListener("test",n)}catch{t=!1}return pg=t,pg}function sb(t){return t.type==="touchstart"}const oG={getInitialState:t=>({columnVisibility:{},...t}),getDefaultOptions:t=>({onColumnVisibilityChange:ur("columnVisibility",t)}),createColumn:(t,e)=>{t.toggleVisibility=n=>{t.getCanHide()&&e.setColumnVisibility(i=>({...i,[t.id]:n??!t.getIsVisible()}))},t.getIsVisible=()=>{var n,i;const r=t.columns;return(n=r.length?r.some(s=>s.getIsVisible()):(i=e.getState().columnVisibility)==null?void 0:i[t.id])!=null?n:!0},t.getCanHide=()=>{var n,i;return((n=t.columnDef.enableHiding)!=null?n:!0)&&((i=e.options.enableHiding)!=null?i:!0)},t.getToggleVisibilityHandler=()=>n=>{t.toggleVisibility==null||t.toggleVisibility(n.target.checked)}},createRow:(t,e)=>{t._getAllVisibleCells=Ye(()=>[t.getAllCells(),e.getState().columnVisibility],n=>n.filter(i=>i.column.getIsVisible()),Fe(e.options,"debugRows")),t.getVisibleCells=Ye(()=>[t.getLeftVisibleCells(),t.getCenterVisibleCells(),t.getRightVisibleCells()],(n,i,r)=>[...n,...i,...r],Fe(e.options,"debugRows"))},createTable:t=>{const e=(n,i)=>Ye(()=>[i(),i().filter(r=>r.getIsVisible()).map(r=>r.id).join("_")],r=>r.filter(s=>s.getIsVisible==null?void 0:s.getIsVisible()),Fe(t.options,"debugColumns"));t.getVisibleFlatColumns=e("getVisibleFlatColumns",()=>t.getAllFlatColumns()),t.getVisibleLeafColumns=e("getVisibleLeafColumns",()=>t.getAllLeafColumns()),t.getLeftVisibleLeafColumns=e("getLeftVisibleLeafColumns",()=>t.getLeftLeafColumns()),t.getRightVisibleLeafColumns=e("getRightVisibleLeafColumns",()=>t.getRightLeafColumns()),t.getCenterVisibleLeafColumns=e("getCenterVisibleLeafColumns",()=>t.getCenterLeafColumns()),t.setColumnVisibility=n=>t.options.onColumnVisibilityChange==null?void 0:t.options.onColumnVisibilityChange(n),t.resetColumnVisibility=n=>{var i;t.setColumnVisibility(n?{}:(i=t.initialState.columnVisibility)!=null?i:{})},t.toggleAllColumnsVisible=n=>{var i;n=(i=n)!=null?i:!t.getIsAllColumnsVisible(),t.setColumnVisibility(t.getAllLeafColumns().reduce((r,s)=>({...r,[s.id]:n||!(s.getCanHide!=null&&s.getCanHide())}),{}))},t.getIsAllColumnsVisible=()=>!t.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),t.getIsSomeColumnsVisible=()=>t.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),t.getToggleAllColumnsVisibilityHandler=()=>n=>{var i;t.toggleAllColumnsVisible((i=n.target)==null?void 0:i.checked)}}};function yf(t,e){return e?e==="center"?t.getCenterVisibleLeafColumns():e==="left"?t.getLeftVisibleLeafColumns():t.getRightVisibleLeafColumns():t.getVisibleLeafColumns()}const aG={createTable:t=>{t._getGlobalFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,"__global__"),t.getGlobalFacetedRowModel=()=>t.options.manualFiltering||!t._getGlobalFacetedRowModel?t.getPreFilteredRowModel():t._getGlobalFacetedRowModel(),t._getGlobalFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,"__global__"),t.getGlobalFacetedUniqueValues=()=>t._getGlobalFacetedUniqueValues?t._getGlobalFacetedUniqueValues():new Map,t._getGlobalFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,"__global__"),t.getGlobalFacetedMinMaxValues=()=>{if(t._getGlobalFacetedMinMaxValues)return t._getGlobalFacetedMinMaxValues()}}},lG={getInitialState:t=>({globalFilter:void 0,...t}),getDefaultOptions:t=>({onGlobalFilterChange:ur("globalFilter",t),globalFilterFn:"auto",getColumnCanGlobalFilter:e=>{var n;const i=(n=t.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[e.id])==null?void 0:n.getValue();return typeof i=="string"||typeof i=="number"}}),createColumn:(t,e)=>{t.getCanGlobalFilter=()=>{var n,i,r,s;return((n=t.columnDef.enableGlobalFilter)!=null?n:!0)&&((i=e.options.enableGlobalFilter)!=null?i:!0)&&((r=e.options.enableFilters)!=null?r:!0)&&((s=e.options.getColumnCanGlobalFilter==null?void 0:e.options.getColumnCanGlobalFilter(t))!=null?s:!0)&&!!t.accessorFn}},createTable:t=>{t.getGlobalAutoFilterFn=()=>go.includesString,t.getGlobalFilterFn=()=>{var e,n;const{globalFilterFn:i}=t.options;return ZO(i)?i:i==="auto"?t.getGlobalAutoFilterFn():(e=(n=t.options.filterFns)==null?void 0:n[i])!=null?e:go[i]},t.setGlobalFilter=e=>{t.options.onGlobalFilterChange==null||t.options.onGlobalFilterChange(e)},t.resetGlobalFilter=e=>{t.setGlobalFilter(e?void 0:t.initialState.globalFilter)}}},cG={getInitialState:t=>({expanded:{},...t}),getDefaultOptions:t=>({onExpandedChange:ur("expanded",t),paginateExpandedRows:!0}),createTable:t=>{let e=!1,n=!1;t._autoResetExpanded=()=>{var i,r;if(!e){t._queue(()=>{e=!0});return}if((i=(r=t.options.autoResetAll)!=null?r:t.options.autoResetExpanded)!=null?i:!t.options.manualExpanding){if(n)return;n=!0,t._queue(()=>{t.resetExpanded(),n=!1})}},t.setExpanded=i=>t.options.onExpandedChange==null?void 0:t.options.onExpandedChange(i),t.toggleAllRowsExpanded=i=>{i??!t.getIsAllRowsExpanded()?t.setExpanded(!0):t.setExpanded({})},t.resetExpanded=i=>{var r,s;t.setExpanded(i?{}:(r=(s=t.initialState)==null?void 0:s.expanded)!=null?r:{})},t.getCanSomeRowsExpand=()=>t.getPrePaginationRowModel().flatRows.some(i=>i.getCanExpand()),t.getToggleAllRowsExpandedHandler=()=>i=>{i.persist==null||i.persist(),t.toggleAllRowsExpanded()},t.getIsSomeRowsExpanded=()=>{const i=t.getState().expanded;return i===!0||Object.values(i).some(Boolean)},t.getIsAllRowsExpanded=()=>{const i=t.getState().expanded;return typeof i=="boolean"?i===!0:!(!Object.keys(i).length||t.getRowModel().flatRows.some(r=>!r.getIsExpanded()))},t.getExpandedDepth=()=>{let i=0;return(t.getState().expanded===!0?Object.keys(t.getRowModel().rowsById):Object.keys(t.getState().expanded)).forEach(s=>{const o=s.split(".");i=Math.max(i,o.length)}),i},t.getPreExpandedRowModel=()=>t.getSortedRowModel(),t.getExpandedRowModel=()=>(!t._getExpandedRowModel&&t.options.getExpandedRowModel&&(t._getExpandedRowModel=t.options.getExpandedRowModel(t)),t.options.manualExpanding||!t._getExpandedRowModel?t.getPreExpandedRowModel():t._getExpandedRowModel())},createRow:(t,e)=>{t.toggleExpanded=n=>{e.setExpanded(i=>{var r;const s=i===!0?!0:!!(i!=null&&i[t.id]);let o={};if(i===!0?Object.keys(e.getRowModel().rowsById).forEach(l=>{o[l]=!0}):o=i,n=(r=n)!=null?r:!s,!s&&n)return{...o,[t.id]:!0};if(s&&!n){const{[t.id]:l,...u}=o;return u}return i})},t.getIsExpanded=()=>{var n;const i=e.getState().expanded;return!!((n=e.options.getIsRowExpanded==null?void 0:e.options.getIsRowExpanded(t))!=null?n:i===!0||i?.[t.id])},t.getCanExpand=()=>{var n,i,r;return(n=e.options.getRowCanExpand==null?void 0:e.options.getRowCanExpand(t))!=null?n:((i=e.options.enableExpanding)!=null?i:!0)&&!!((r=t.subRows)!=null&&r.length)},t.getIsAllParentsExpanded=()=>{let n=!0,i=t;for(;n&&i.parentId;)i=e.getRow(i.parentId,!0),n=i.getIsExpanded();return n},t.getToggleExpandedHandler=()=>{const n=t.getCanExpand();return()=>{n&&t.toggleExpanded()}}}},XS=0,VS=10,ob=()=>({pageIndex:XS,pageSize:VS}),uG={getInitialState:t=>({...t,pagination:{...ob(),...t?.pagination}}),getDefaultOptions:t=>({onPaginationChange:ur("pagination",t)}),createTable:t=>{let e=!1,n=!1;t._autoResetPageIndex=()=>{var i,r;if(!e){t._queue(()=>{e=!0});return}if((i=(r=t.options.autoResetAll)!=null?r:t.options.autoResetPageIndex)!=null?i:!t.options.manualPagination){if(n)return;n=!0,t._queue(()=>{t.resetPageIndex(),n=!1})}},t.setPagination=i=>{const r=s=>ma(i,s);return t.options.onPaginationChange==null?void 0:t.options.onPaginationChange(r)},t.resetPagination=i=>{var r;t.setPagination(i?ob():(r=t.initialState.pagination)!=null?r:ob())},t.setPageIndex=i=>{t.setPagination(r=>{let s=ma(i,r.pageIndex);const o=typeof t.options.pageCount>"u"||t.options.pageCount===-1?Number.MAX_SAFE_INTEGER:t.options.pageCount-1;return s=Math.max(0,Math.min(s,o)),{...r,pageIndex:s}})},t.resetPageIndex=i=>{var r,s;t.setPageIndex(i?XS:(r=(s=t.initialState)==null||(s=s.pagination)==null?void 0:s.pageIndex)!=null?r:XS)},t.resetPageSize=i=>{var r,s;t.setPageSize(i?VS:(r=(s=t.initialState)==null||(s=s.pagination)==null?void 0:s.pageSize)!=null?r:VS)},t.setPageSize=i=>{t.setPagination(r=>{const s=Math.max(1,ma(i,r.pageSize)),o=r.pageSize*r.pageIndex,l=Math.floor(o/s);return{...r,pageIndex:l,pageSize:s}})},t.setPageCount=i=>t.setPagination(r=>{var s;let o=ma(i,(s=t.options.pageCount)!=null?s:-1);return typeof o=="number"&&(o=Math.max(-1,o)),{...r,pageCount:o}}),t.getPageOptions=Ye(()=>[t.getPageCount()],i=>{let r=[];return i&&i>0&&(r=[...new Array(i)].fill(null).map((s,o)=>o)),r},Fe(t.options,"debugTable")),t.getCanPreviousPage=()=>t.getState().pagination.pageIndex>0,t.getCanNextPage=()=>{const{pageIndex:i}=t.getState().pagination,r=t.getPageCount();return r===-1?!0:r===0?!1:it.setPageIndex(i=>i-1),t.nextPage=()=>t.setPageIndex(i=>i+1),t.firstPage=()=>t.setPageIndex(0),t.lastPage=()=>t.setPageIndex(t.getPageCount()-1),t.getPrePaginationRowModel=()=>t.getExpandedRowModel(),t.getPaginationRowModel=()=>(!t._getPaginationRowModel&&t.options.getPaginationRowModel&&(t._getPaginationRowModel=t.options.getPaginationRowModel(t)),t.options.manualPagination||!t._getPaginationRowModel?t.getPrePaginationRowModel():t._getPaginationRowModel()),t.getPageCount=()=>{var i;return(i=t.options.pageCount)!=null?i:Math.ceil(t.getRowCount()/t.getState().pagination.pageSize)},t.getRowCount=()=>{var i;return(i=t.options.rowCount)!=null?i:t.getPrePaginationRowModel().rows.length}}},ab=()=>({top:[],bottom:[]}),dG={getInitialState:t=>({rowPinning:ab(),...t}),getDefaultOptions:t=>({onRowPinningChange:ur("rowPinning",t)}),createRow:(t,e)=>{t.pin=(n,i,r)=>{const s=i?t.getLeafRows().map(u=>{let{id:f}=u;return f}):[],o=r?t.getParentRows().map(u=>{let{id:f}=u;return f}):[],l=new Set([...o,t.id,...s]);e.setRowPinning(u=>{var f,h;if(n==="bottom"){var p,O;return{top:((p=u?.top)!=null?p:[]).filter(S=>!(l!=null&&l.has(S))),bottom:[...((O=u?.bottom)!=null?O:[]).filter(S=>!(l!=null&&l.has(S))),...Array.from(l)]}}if(n==="top"){var y,v;return{top:[...((y=u?.top)!=null?y:[]).filter(S=>!(l!=null&&l.has(S))),...Array.from(l)],bottom:((v=u?.bottom)!=null?v:[]).filter(S=>!(l!=null&&l.has(S)))}}return{top:((f=u?.top)!=null?f:[]).filter(S=>!(l!=null&&l.has(S))),bottom:((h=u?.bottom)!=null?h:[]).filter(S=>!(l!=null&&l.has(S)))}})},t.getCanPin=()=>{var n;const{enableRowPinning:i,enablePinning:r}=e.options;return typeof i=="function"?i(t):(n=i??r)!=null?n:!0},t.getIsPinned=()=>{const n=[t.id],{top:i,bottom:r}=e.getState().rowPinning,s=n.some(l=>i?.includes(l)),o=n.some(l=>r?.includes(l));return s?"top":o?"bottom":!1},t.getPinnedIndex=()=>{var n,i;const r=t.getIsPinned();if(!r)return-1;const s=(n=r==="top"?e.getTopRows():e.getBottomRows())==null?void 0:n.map(o=>{let{id:l}=o;return l});return(i=s?.indexOf(t.id))!=null?i:-1}},createTable:t=>{t.setRowPinning=e=>t.options.onRowPinningChange==null?void 0:t.options.onRowPinningChange(e),t.resetRowPinning=e=>{var n,i;return t.setRowPinning(e?ab():(n=(i=t.initialState)==null?void 0:i.rowPinning)!=null?n:ab())},t.getIsSomeRowsPinned=e=>{var n;const i=t.getState().rowPinning;if(!e){var r,s;return!!((r=i.top)!=null&&r.length||(s=i.bottom)!=null&&s.length)}return!!((n=i[e])!=null&&n.length)},t._getPinnedRows=(e,n,i)=>{var r;return((r=t.options.keepPinnedRows)==null||r?(n??[]).map(o=>{const l=t.getRow(o,!0);return l.getIsAllParentsExpanded()?l:null}):(n??[]).map(o=>e.find(l=>l.id===o))).filter(Boolean).map(o=>({...o,position:i}))},t.getTopRows=Ye(()=>[t.getRowModel().rows,t.getState().rowPinning.top],(e,n)=>t._getPinnedRows(e,n,"top"),Fe(t.options,"debugRows")),t.getBottomRows=Ye(()=>[t.getRowModel().rows,t.getState().rowPinning.bottom],(e,n)=>t._getPinnedRows(e,n,"bottom"),Fe(t.options,"debugRows")),t.getCenterRows=Ye(()=>[t.getRowModel().rows,t.getState().rowPinning.top,t.getState().rowPinning.bottom],(e,n,i)=>{const r=new Set([...n??[],...i??[]]);return e.filter(s=>!r.has(s.id))},Fe(t.options,"debugRows"))}},fG={getInitialState:t=>({rowSelection:{},...t}),getDefaultOptions:t=>({onRowSelectionChange:ur("rowSelection",t),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:t=>{t.setRowSelection=e=>t.options.onRowSelectionChange==null?void 0:t.options.onRowSelectionChange(e),t.resetRowSelection=e=>{var n;return t.setRowSelection(e?{}:(n=t.initialState.rowSelection)!=null?n:{})},t.toggleAllRowsSelected=e=>{t.setRowSelection(n=>{e=typeof e<"u"?e:!t.getIsAllRowsSelected();const i={...n},r=t.getPreGroupedRowModel().flatRows;return e?r.forEach(s=>{s.getCanSelect()&&(i[s.id]=!0)}):r.forEach(s=>{delete i[s.id]}),i})},t.toggleAllPageRowsSelected=e=>t.setRowSelection(n=>{const i=typeof e<"u"?e:!t.getIsAllPageRowsSelected(),r={...n};return t.getRowModel().rows.forEach(s=>{BS(r,s.id,i,!0,t)}),r}),t.getPreSelectedRowModel=()=>t.getCoreRowModel(),t.getSelectedRowModel=Ye(()=>[t.getState().rowSelection,t.getCoreRowModel()],(e,n)=>Object.keys(e).length?lb(t,n):{rows:[],flatRows:[],rowsById:{}},Fe(t.options,"debugTable")),t.getFilteredSelectedRowModel=Ye(()=>[t.getState().rowSelection,t.getFilteredRowModel()],(e,n)=>Object.keys(e).length?lb(t,n):{rows:[],flatRows:[],rowsById:{}},Fe(t.options,"debugTable")),t.getGroupedSelectedRowModel=Ye(()=>[t.getState().rowSelection,t.getSortedRowModel()],(e,n)=>Object.keys(e).length?lb(t,n):{rows:[],flatRows:[],rowsById:{}},Fe(t.options,"debugTable")),t.getIsAllRowsSelected=()=>{const e=t.getFilteredRowModel().flatRows,{rowSelection:n}=t.getState();let i=!!(e.length&&Object.keys(n).length);return i&&e.some(r=>r.getCanSelect()&&!n[r.id])&&(i=!1),i},t.getIsAllPageRowsSelected=()=>{const e=t.getPaginationRowModel().flatRows.filter(r=>r.getCanSelect()),{rowSelection:n}=t.getState();let i=!!e.length;return i&&e.some(r=>!n[r.id])&&(i=!1),i},t.getIsSomeRowsSelected=()=>{var e;const n=Object.keys((e=t.getState().rowSelection)!=null?e:{}).length;return n>0&&n{const e=t.getPaginationRowModel().flatRows;return t.getIsAllPageRowsSelected()?!1:e.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},t.getToggleAllRowsSelectedHandler=()=>e=>{t.toggleAllRowsSelected(e.target.checked)},t.getToggleAllPageRowsSelectedHandler=()=>e=>{t.toggleAllPageRowsSelected(e.target.checked)}},createRow:(t,e)=>{t.toggleSelected=(n,i)=>{const r=t.getIsSelected();e.setRowSelection(s=>{var o;if(n=typeof n<"u"?n:!r,t.getCanSelect()&&r===n)return s;const l={...s};return BS(l,t.id,n,(o=i?.selectChildren)!=null?o:!0,e),l})},t.getIsSelected=()=>{const{rowSelection:n}=e.getState();return y1(t,n)},t.getIsSomeSelected=()=>{const{rowSelection:n}=e.getState();return US(t,n)==="some"},t.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=e.getState();return US(t,n)==="all"},t.getCanSelect=()=>{var n;return typeof e.options.enableRowSelection=="function"?e.options.enableRowSelection(t):(n=e.options.enableRowSelection)!=null?n:!0},t.getCanSelectSubRows=()=>{var n;return typeof e.options.enableSubRowSelection=="function"?e.options.enableSubRowSelection(t):(n=e.options.enableSubRowSelection)!=null?n:!0},t.getCanMultiSelect=()=>{var n;return typeof e.options.enableMultiRowSelection=="function"?e.options.enableMultiRowSelection(t):(n=e.options.enableMultiRowSelection)!=null?n:!0},t.getToggleSelectedHandler=()=>{const n=t.getCanSelect();return i=>{var r;n&&t.toggleSelected((r=i.target)==null?void 0:r.checked)}}}},BS=(t,e,n,i,r)=>{var s;const o=r.getRow(e,!0);n?(o.getCanMultiSelect()||Object.keys(t).forEach(l=>delete t[l]),o.getCanSelect()&&(t[e]=!0)):delete t[e],i&&(s=o.subRows)!=null&&s.length&&o.getCanSelectSubRows()&&o.subRows.forEach(l=>BS(t,l.id,n,i,r))};function lb(t,e){const n=t.getState().rowSelection,i=[],r={},s=function(o,l){return o.map(u=>{var f;const h=y1(u,n);if(h&&(i.push(u),r[u.id]=u),(f=u.subRows)!=null&&f.length&&(u={...u,subRows:s(u.subRows)}),h)return u}).filter(Boolean)};return{rows:s(e.rows),flatRows:i,rowsById:r}}function y1(t,e){var n;return(n=e[t.id])!=null?n:!1}function US(t,e,n){var i;if(!((i=t.subRows)!=null&&i.length))return!1;let r=!0,s=!1;return t.subRows.forEach(o=>{if(!(s&&!r)&&(o.getCanSelect()&&(y1(o,e)?s=!0:r=!1),o.subRows&&o.subRows.length)){const l=US(o,e);l==="all"?s=!0:(l==="some"&&(s=!0),r=!1)}}),r?"all":s?"some":!1}const qS=/([0-9]+)/gm,hG=(t,e,n)=>CD(_a(t.getValue(n)).toLowerCase(),_a(e.getValue(n)).toLowerCase()),pG=(t,e,n)=>CD(_a(t.getValue(n)),_a(e.getValue(n))),gG=(t,e,n)=>v1(_a(t.getValue(n)).toLowerCase(),_a(e.getValue(n)).toLowerCase()),mG=(t,e,n)=>v1(_a(t.getValue(n)),_a(e.getValue(n))),OG=(t,e,n)=>{const i=t.getValue(n),r=e.getValue(n);return i>r?1:iv1(t.getValue(n),e.getValue(n));function v1(t,e){return t===e?0:t>e?1:-1}function _a(t){return typeof t=="number"?isNaN(t)||t===1/0||t===-1/0?"":String(t):typeof t=="string"?t:""}function CD(t,e){const n=t.split(qS).filter(Boolean),i=e.split(qS).filter(Boolean);for(;n.length&&i.length;){const r=n.shift(),s=i.shift(),o=parseInt(r,10),l=parseInt(s,10),u=[o,l].sort();if(isNaN(u[0])){if(r>s)return 1;if(s>r)return-1;continue}if(isNaN(u[1]))return isNaN(o)?-1:1;if(o>l)return 1;if(l>o)return-1}return n.length-i.length}const Hd={alphanumeric:hG,alphanumericCaseSensitive:pG,text:gG,textCaseSensitive:mG,datetime:OG,basic:yG},vG={getInitialState:t=>({sorting:[],...t}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:t=>({onSortingChange:ur("sorting",t),isMultiSortEvent:e=>e.shiftKey}),createColumn:(t,e)=>{t.getAutoSortingFn=()=>{const n=e.getFilteredRowModel().flatRows.slice(10);let i=!1;for(const r of n){const s=r?.getValue(t.id);if(Object.prototype.toString.call(s)==="[object Date]")return Hd.datetime;if(typeof s=="string"&&(i=!0,s.split(qS).length>1))return Hd.alphanumeric}return i?Hd.text:Hd.basic},t.getAutoSortDir=()=>{const n=e.getFilteredRowModel().flatRows[0];return typeof n?.getValue(t.id)=="string"?"asc":"desc"},t.getSortingFn=()=>{var n,i;if(!t)throw new Error;return ZO(t.columnDef.sortingFn)?t.columnDef.sortingFn:t.columnDef.sortingFn==="auto"?t.getAutoSortingFn():(n=(i=e.options.sortingFns)==null?void 0:i[t.columnDef.sortingFn])!=null?n:Hd[t.columnDef.sortingFn]},t.toggleSorting=(n,i)=>{const r=t.getNextSortingOrder(),s=typeof n<"u"&&n!==null;e.setSorting(o=>{const l=o?.find(y=>y.id===t.id),u=o?.findIndex(y=>y.id===t.id);let f=[],h,p=s?n:r==="desc";if(o!=null&&o.length&&t.getCanMultiSort()&&i?l?h="toggle":h="add":o!=null&&o.length&&u!==o.length-1?h="replace":l?h="toggle":h="replace",h==="toggle"&&(s||r||(h="remove")),h==="add"){var O;f=[...o,{id:t.id,desc:p}],f.splice(0,f.length-((O=e.options.maxMultiSortColCount)!=null?O:Number.MAX_SAFE_INTEGER))}else h==="toggle"?f=o.map(y=>y.id===t.id?{...y,desc:p}:y):h==="remove"?f=o.filter(y=>y.id!==t.id):f=[{id:t.id,desc:p}];return f})},t.getFirstSortDir=()=>{var n,i;return((n=(i=t.columnDef.sortDescFirst)!=null?i:e.options.sortDescFirst)!=null?n:t.getAutoSortDir()==="desc")?"desc":"asc"},t.getNextSortingOrder=n=>{var i,r;const s=t.getFirstSortDir(),o=t.getIsSorted();return o?o!==s&&((i=e.options.enableSortingRemoval)==null||i)&&(!(n&&(r=e.options.enableMultiRemove)!=null)||r)?!1:o==="desc"?"asc":"desc":s},t.getCanSort=()=>{var n,i;return((n=t.columnDef.enableSorting)!=null?n:!0)&&((i=e.options.enableSorting)!=null?i:!0)&&!!t.accessorFn},t.getCanMultiSort=()=>{var n,i;return(n=(i=t.columnDef.enableMultiSort)!=null?i:e.options.enableMultiSort)!=null?n:!!t.accessorFn},t.getIsSorted=()=>{var n;const i=(n=e.getState().sorting)==null?void 0:n.find(r=>r.id===t.id);return i?i.desc?"desc":"asc":!1},t.getSortIndex=()=>{var n,i;return(n=(i=e.getState().sorting)==null?void 0:i.findIndex(r=>r.id===t.id))!=null?n:-1},t.clearSorting=()=>{e.setSorting(n=>n!=null&&n.length?n.filter(i=>i.id!==t.id):[])},t.getToggleSortingHandler=()=>{const n=t.getCanSort();return i=>{n&&(i.persist==null||i.persist(),t.toggleSorting==null||t.toggleSorting(void 0,t.getCanMultiSort()?e.options.isMultiSortEvent==null?void 0:e.options.isMultiSortEvent(i):!1))}}},createTable:t=>{t.setSorting=e=>t.options.onSortingChange==null?void 0:t.options.onSortingChange(e),t.resetSorting=e=>{var n,i;t.setSorting(e?[]:(n=(i=t.initialState)==null?void 0:i.sorting)!=null?n:[])},t.getPreSortedRowModel=()=>t.getGroupedRowModel(),t.getSortedRowModel=()=>(!t._getSortedRowModel&&t.options.getSortedRowModel&&(t._getSortedRowModel=t.options.getSortedRowModel(t)),t.options.manualSorting||!t._getSortedRowModel?t.getPreSortedRowModel():t._getSortedRowModel())}},bG=[ZF,oG,tG,nG,XF,VF,aG,lG,vG,JF,cG,uG,dG,fG,rG];function SG(t){var e,n;const i=[...bG,...(e=t._features)!=null?e:[]];let r={_features:i};const s=r._features.reduce((O,y)=>Object.assign(O,y.getDefaultOptions==null?void 0:y.getDefaultOptions(r)),{}),o=O=>r.options.mergeOptions?r.options.mergeOptions(s,O):{...s,...O};let u={...{},...(n=t.initialState)!=null?n:{}};r._features.forEach(O=>{var y;u=(y=O.getInitialState==null?void 0:O.getInitialState(u))!=null?y:u});const f=[];let h=!1;const p={_features:i,options:{...s,...t},initialState:u,_queue:O=>{f.push(O),h||(h=!0,Promise.resolve().then(()=>{for(;f.length;)f.shift()();h=!1}).catch(y=>setTimeout(()=>{throw y})))},reset:()=>{r.setState(r.initialState)},setOptions:O=>{const y=ma(O,r.options);r.options=o(y)},getState:()=>r.options.state,setState:O=>{r.options.onStateChange==null||r.options.onStateChange(O)},_getRowId:(O,y,v)=>{var S;return(S=r.options.getRowId==null?void 0:r.options.getRowId(O,y,v))!=null?S:`${v?[v.id,y].join("."):y}`},getCoreRowModel:()=>(r._getCoreRowModel||(r._getCoreRowModel=r.options.getCoreRowModel(r)),r._getCoreRowModel()),getRowModel:()=>r.getPaginationRowModel(),getRow:(O,y)=>{let v=(y?r.getPrePaginationRowModel():r.getRowModel()).rowsById[O];if(!v&&(v=r.getCoreRowModel().rowsById[O],!v))throw new Error;return v},_getDefaultColumnDef:Ye(()=>[r.options.defaultColumn],O=>{var y;return O=(y=O)!=null?y:{},{header:v=>{const S=v.header.column.columnDef;return S.accessorKey?S.accessorKey:S.accessorFn?S.id:null},cell:v=>{var S,k;return(S=(k=v.renderValue())==null||k.toString==null?void 0:k.toString())!=null?S:null},...r._features.reduce((v,S)=>Object.assign(v,S.getDefaultColumnDef==null?void 0:S.getDefaultColumnDef()),{}),...O}},Fe(t,"debugColumns")),_getColumnDefs:()=>r.options.columns,getAllColumns:Ye(()=>[r._getColumnDefs()],O=>{const y=function(v,S,k){return k===void 0&&(k=0),v.map(C=>{const $=LF(r,C,k,S),T=C;return $.columns=T.columns?y(T.columns,$,k+1):[],$})};return y(O)},Fe(t,"debugColumns")),getAllFlatColumns:Ye(()=>[r.getAllColumns()],O=>O.flatMap(y=>y.getFlatColumns()),Fe(t,"debugColumns")),_getAllFlatColumnsById:Ye(()=>[r.getAllFlatColumns()],O=>O.reduce((y,v)=>(y[v.id]=v,y),{}),Fe(t,"debugColumns")),getAllLeafColumns:Ye(()=>[r.getAllColumns(),r._getOrderColumnsFn()],(O,y)=>{let v=O.flatMap(S=>S.getLeafColumns());return y(v)},Fe(t,"debugColumns")),getColumn:O=>r._getAllFlatColumnsById()[O]};Object.assign(r,p);for(let O=0;OYe(()=>[t.options.data],e=>{const n={rows:[],flatRows:[],rowsById:{}},i=function(r,s,o){s===void 0&&(s=0);const l=[];for(let f=0;ft._autoResetPageIndex()))}function $D(){return t=>Ye(()=>[t.getState().sorting,t.getPreSortedRowModel()],(e,n)=>{if(!n.rows.length||!(e!=null&&e.length))return n;const i=t.getState().sorting,r=[],s=i.filter(u=>{var f;return(f=t.getColumn(u.id))==null?void 0:f.getCanSort()}),o={};s.forEach(u=>{const f=t.getColumn(u.id);f&&(o[u.id]={sortUndefined:f.columnDef.sortUndefined,invertSorting:f.columnDef.invertSorting,sortingFn:f.getSortingFn()})});const l=u=>{const f=u.map(h=>({...h}));return f.sort((h,p)=>{for(let y=0;y{var p;r.push(h),(p=h.subRows)!=null&&p.length&&(h.subRows=l(h.subRows))}),f};return{rows:l(n.rows),flatRows:r,rowsById:n.rowsById}},Fe(t.options,"debugTable","getSortedRowModel",()=>t._autoResetPageIndex()))}function YS(t,e){return t?xG(t)?w.createElement(t,e):t:null}function xG(t){return wG(t)||typeof t=="function"||kG(t)}function wG(t){return typeof t=="function"&&(()=>{const e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}function kG(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}function TD(t){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[n]=w.useState(()=>({current:SG(e)})),[i,r]=w.useState(()=>n.current.initialState);return n.current.setOptions(s=>({...s,...t,state:{...i,...t.state},onStateChange:o=>{r(o),t.onStateChange==null||t.onStateChange(o)}})),n.current}var Sh=t=>t.type==="checkbox",Oa=t=>t instanceof Date,Wn=t=>t==null;const b1=t=>typeof t=="object";var dn=t=>!Wn(t)&&!Array.isArray(t)&&b1(t)&&!Oa(t),CG=t=>dn(t)&&t.target?Sh(t.target)?t.target.checked:t.target.value:t,_G=(t,e)=>e.split(".").some((n,i,r)=>!isNaN(Number(n))&&t.has(r.slice(0,i).join("."))),ED=t=>{const e=t.constructor&&t.constructor.prototype;return dn(e)&&e.hasOwnProperty("isPrototypeOf")},IO=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function mn(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(IO&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(dn(t)&&ED(t)))return t;const i=n?[]:Object.create(Object.getPrototypeOf(t));for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=mn(t[r]));return i}const Nc={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},Gr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},qr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},RD="root",S1=["__proto__","constructor","prototype"],$G=/^\w*$/;var xh=t=>$G.test(t),Ht=t=>t===void 0;const TG=/[.[\]'"]/;var XO=t=>t.split(TG).filter(Boolean),$e=(t,e,n)=>{if(!e||!dn(t))return n;const i=xh(e)?[e]:XO(e);if(i.some(s=>S1.includes(s)))return n;const r=i.reduce((s,o)=>Wn(s)?void 0:s[o],t);return Ht(r)||r===t?Ht(t[e])?n:t[e]:r},bs=t=>typeof t=="boolean",$r=t=>typeof t=="function",Nt=(t,e,n)=>{let i=-1;const r=xh(e)?[e]:XO(e),s=r.length,o=s-1;for(;++i{const r={};for(const s in t)Object.defineProperty(r,s,{get:()=>{const o=s;return e._proxyFormState[o]!==Gr.all&&(e._proxyFormState[o]=!i||Gr.all),t[o]}});return r};const QG=IO?be.useLayoutEffect:be.useEffect;var Kn=t=>typeof t=="string",AG=(t,e,n,i,r)=>Kn(t)?(i&&e.watch.add(t),$e(n,t,r)):Array.isArray(t)?t.map(s=>(i&&e.watch.add(s),$e(n,s))):(i&&(e.watchAll=!0),n),FS=t=>Wn(t)||!b1(t);const eE=(t,e)=>e.length===0&&!Array.isArray(t)&&!ED(t);function Ss(t,e,n=new WeakMap){if(t===e)return!0;if(FS(t)||FS(e))return Object.is(t,e);if(Oa(t)&&Oa(e))return Object.is(t.getTime(),e.getTime());const i=Object.keys(t),r=Object.keys(e);if(i.length!==r.length)return!1;if(eE(t,i)||eE(e,r))return Object.is(t,e);if(!i.length&&Array.isArray(t)!==Array.isArray(e))return!1;const s=n.get(t);if(s&&s.has(e))return!0;if(s)s.add(e);else{const o=new WeakSet;o.add(e),n.set(t,o)}for(const o of i){const l=t[o];if(!(o in e))return!1;if(o!=="ref"){const u=e[o];if(Oa(l)&&Oa(u)||(dn(l)||Array.isArray(l))&&(dn(u)||Array.isArray(u))?!Ss(l,u,n):!Object.is(l,u))return!1}}return!0}var gg=t=>({isOnSubmit:!t||t===Gr.onSubmit,isOnBlur:t===Gr.onBlur,isOnChange:t===Gr.onChange,isOnAll:t===Gr.all,isOnTouch:t===Gr.onTouched}),cb=(t,e,n)=>{if(n)return!1;if(e.watchAll||e.watch.has(t))return!0;for(const i of e.watch)if(t.startsWith(i)&&t.charAt(i.length)===".")return!0;return!1};const vf=(t,e,n,i)=>{for(const r of n||Object.keys(t)){const s=$e(t,r);if(s){const{_f:o,...l}=s;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],r)&&!i)return!0;if(o.ref&&e(o.ref,o.name)&&!i)return!0;if(vf(l,e))break}else if(dn(l)&&vf(l,e))break}}};var tE=(t,e,n)=>{const i=$e(t,n),r=Array.isArray(i)?i:[];return Nt(r,RD,e[n]),Nt(t,n,r),t},Gn=t=>dn(t)&&!Object.keys(t).length,x1=t=>t.type==="file",Sm=t=>{if(!IO)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},w1=t=>t.type==="radio",xm=t=>t instanceof RegExp,k1=(t,e,n,i,r)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[i]:r||!0}}:{};const nE={value:!1,isValid:!1},iE={value:!0,isValid:!0};var QD=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!Ht(t[0].attributes.value)?Ht(t[0].value)||t[0].value===""?iE:{value:t[0].value,isValid:!0}:iE:nE}return nE};const rE={isValid:!1,value:null};var AD=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,rE):rE;function sE(t,e,n="validate"){if(Kn(t)||Array.isArray(t)&&t.every(Kn)||bs(t)&&!t)return{type:n,message:Kn(t)?t:"",ref:e}}var zc=t=>dn(t)&&!xm(t)?t:{value:t,message:""},oE=async(t,e,n,i,r,s)=>{const{ref:o,refs:l,required:u,maxLength:f,minLength:h,min:p,max:O,pattern:y,validate:v,name:S,valueAsNumber:k,mount:C}=t._f,$=$e(n,S);if(!C||e.has(S))return{};const T=l?l[0]:o,Q=Y=>{if(r&&T.reportValidity){const re=bs(Y)?"":Y||"";l?l.forEach(K=>K.setCustomValidity(re)):T.setCustomValidity(re),T.reportValidity()}},A={},R=w1(o),j=Sh(o),L=R||j,ne=(k||x1(o))&&Ht(o.value)&&Ht($)||Sm(o)&&o.value===""||$===""||Array.isArray($)&&!$.length,G=k1.bind(null,S,i,A),H=(Y,re,K,ye=qr.maxLength,N=qr.minLength)=>{const W=Y?re:K;A[S]={type:Y?ye:N,message:W,ref:o,...G(Y?ye:N,W)}};if(s?!Array.isArray($)||!$.length:u&&(!L&&(ne||Wn($))||bs($)&&!$||j&&!QD(l).isValid||R&&!AD(l).isValid)){const{value:Y,message:re}=Kn(u)?{value:!!u,message:u}:zc(u);if(Y&&(A[S]={type:qr.required,message:re,ref:T,...G(qr.required,re)},!i))return Q(re),A}if(!ne&&(!Wn(p)||!Wn(O))){let Y,re;const K=zc(O),ye=zc(p);if(!Wn($)&&!isNaN($)){const N=o.valueAsNumber||$&&+$;Wn(K.value)||(Y=N>K.value),Wn(ye.value)||(re=Nnew Date(new Date().toDateString()+" "+le),ce=o.type=="time",oe=o.type=="week";Kn(K.value)&&$&&(Y=ce?W($)>W(K.value):oe?$>K.value:N>new Date(K.value)),Kn(ye.value)&&$&&(re=ce?W($)+Y.value,ye=!Wn(re.value)&&$.length<+re.value;if((K||ye)&&(H(K,Y.message,re.message),!i))return Q(A[S].message),A}if(y&&!ne&&Kn($)){const{value:Y,message:re}=zc(y);if(xm(Y)&&!$.match(Y)&&(A[S]={type:qr.pattern,message:re,ref:o,...G(qr.pattern,re)},!i))return Q(re),A}if(v){if($r(v)){const Y=await v($,n),re=sE(Y,T);if(re&&(A[S]={...re,...G(qr.validate,re.message)},!i))return Q(re.message),A}else if(dn(v)){let Y={};for(const re in v){if(!Gn(Y)&&!i)break;const K=sE(await v[re]($,n),T,re);K&&(Y={...K,...G(re,K.message)},Q(K.message),i&&(A[S]=Y))}if(!Gn(Y)&&(A[S]={ref:T,...Y},!i))return A}}return Q(!0),A},qg=t=>Array.isArray(t)?t:[t],PD=t=>Array.isArray(t)?t.filter(Boolean):[];function PG(t,e){const n=e.slice(0,-1).length;let i=0;for(;iS1.includes(String(o))))return t;const i=n.length===1?t:PG(t,n),r=n.length-1,s=n[r];return i&&delete i[s],r!==0&&(dn(i)&&Gn(i)||Array.isArray(i)&&jG(i))&&On(t,n.slice(0,-1)),t}const jD=t=>{const e={};for(const n of Object.keys(t))if(b1(t[n])&&t[n]!==null&&!Oa(t[n])){const i=jD(t[n]);for(const r of Object.keys(i))e[`${n}.${r}`]=i[r]}else e[n]=t[n];return e},MG=be.createContext(null);MG.displayName="HookFormContext";var aE=()=>{let t=[];return{get observers(){return t},next:r=>{for(const s of t)s.next&&s.next(r)},subscribe:r=>(t.push(r),{unsubscribe:()=>{t=t.filter(s=>s!==r)}}),unsubscribe:()=>{t=[]}}};function MD(t,e){const n={};for(const i in t)if(t.hasOwnProperty(i)){const r=t[i],s=e[i];if(r&&dn(r)&&s){const o=MD(r,s);dn(o)&&(n[i]=o)}else t[i]&&(n[i]=s)}return n}var DD=t=>t.type==="select-multiple",DG=t=>w1(t)||Sh(t),ub=t=>Sm(t)&&t.isConnected,NG=t=>{for(const e in t)if($r(t[e]))return!0;return!1};function ND(t){return Array.isArray(t)||dn(t)&&!NG(t)}function zD(t){return!!(t&&"_f"in t)}function LD(t){return Array.isArray(t)?!t.some(e=>!Ht(e)):!Object.keys(t).length}function GS(t,e){Array.isArray(t)?t[e]=void 0:delete t[e]}function HS(t,e={},n){for(const i in t){const r=t[i],s=n&&n[i];ND(r)&&(!Array.isArray(r)||!zD(s))?(e[i]=Array.isArray(r)?[]:{},HS(r,e[i],s),LD(e[i])&&GS(e,i)):Ht(r)||(e[i]=!0)}return e}function pl(t,e,n,i){n||(n=HS(e,{},i));for(const r in t){const s=t[r],o=i&&i[r];ND(s)&&(!Array.isArray(s)||!zD(o))?(Ht(e)||FS(n[r])?n[r]=HS(s,Array.isArray(s)?[]:{},o):pl(s,Wn(e)?{}:e[r],n[r],o),LD(n[r])&&GS(n,r)):Ss(s,e[r])?GS(n,r):n[r]=!0}return n}var ZD=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:i})=>Ht(t)?t:e?t===""?NaN:t&&+t:n&&Kn(t)?new Date(t):i?i(t):t;function lE(t){const e=t.ref;return x1(e)?e.files:w1(e)?AD(t.refs).value:DD(e)?[...e.selectedOptions].map(({value:n})=>n):Sh(e)?QD(t.refs).value:ZD(Ht(e.value)?t.ref.value:e.value,t)}var zG=(t,e,n,i)=>{const r={};for(const s of t){const o=$e(e,s);o&&Nt(r,s,o._f)}return{criteriaMode:n,names:[...t],fields:r,shouldUseNativeValidation:i}},Wd=t=>Ht(t)?t:xm(t)?t.source:dn(t)?xm(t.value)?t.value.source:t.value:t;const cE="AsyncFunction";var LG=t=>{if(!t||!t.validate)return!1;if($r(t.validate))return t.validate.constructor.name===cE;if(dn(t.validate)){for(const e in t.validate)if(t.validate[e].constructor.name===cE)return!0}return!1},ZG=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate);function uE(t,e,n){const i=$e(t,n);if(i||xh(n))return{error:i,name:n};const r=n.split(".");for(;r.length;){const s=r.join("."),o=$e(e,s),l=$e(t,s);if(o&&!Array.isArray(o)&&n!==s)return{name:n};if(l&&l.type)return{name:s,error:l};if(l&&l.root&&l.root.type)return{name:`${s}.root`,error:l.root};r.pop()}return{name:n}}var IG=(t,e,n,i)=>{n(t);const{name:r,...s}=t,o=Object.keys(s);return!o.length||i&&o.length>=Object.keys(e).length||o.find(l=>e[l]===(!i||Gr.all))},XG=(t,e,n)=>!t||!e||t===e||qg(t).some(i=>i&&(n?i===e||i.startsWith(e+"."):i.startsWith(e)||e.startsWith(i))),VG=(t,e,n,i,r)=>r.isOnAll?!1:!n&&r.isOnTouch?!(e||t):(n?i.isOnBlur:r.isOnBlur)?!t:(n?i.isOnChange:r.isOnChange)?t:!0,BG=(t,e)=>!PD($e(t,e)).length&&On(t,e);const UG={mode:Gr.onSubmit,reValidateMode:Gr.onChange,shouldFocusError:!0},db="form",ID={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function qG(t={}){let e={...UG,...t},n={...mn(ID),isLoading:$r(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1},i={},r=dn(e.defaultValues)||dn(e.values)?mn(e.defaultValues||e.values)||{}:{},s=e.shouldUnregister?{}:mn(r),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const u={},f={};let h=0,p=gg(e.mode),O=gg(e.reValidateMode);const y={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},v={...y};let S={...v};const k={array:aE(),state:aE()};let C=0;const $=e.criteriaMode===Gr.all,T=(M,U)=>q=>{clearTimeout(f[M]),f[M]=setTimeout(U,q)},Q=async M=>{if(!o.keepIsValid&&!e.disabled&&(v.isValid||S.isValid||M)){const U=++C;let q;e.resolver?(q=Gn((await K()).errors),U===C&&A()):q=await W({fields:i,onlyCheckValid:!0,eventType:Nc.VALID}),U===C&&q!==n.isValid&&k.state.next({isValid:q})}},A=(M,U)=>{!e.disabled&&(v.isValidating||v.validatingFields||S.isValidating||S.validatingFields)&&((M||Array.from(l.mount)).forEach(q=>{q&&(U?Nt(n.validatingFields,q,U):On(n.validatingFields,q))}),k.state.next({validatingFields:n.validatingFields,isValidating:!Gn(n.validatingFields)}))},R=()=>{n.dirtyFields=pl(r,s,void 0,i)},j=(M,U=[],q,he,me=!0,Se=!0)=>{if(he&&q&&!e.disabled){if(o.action=!0,Se&&Array.isArray($e(i,M))){const ke=q($e(i,M),he.argA,he.argB);me&&Nt(i,M,ke)}if(Se&&Array.isArray($e(n.errors,M))){const ke=q($e(n.errors,M),he.argA,he.argB);me&&Nt(n.errors,M,ke),BG(n.errors,M)}if((v.touchedFields||S.touchedFields)&&Se&&Array.isArray($e(n.touchedFields,M))){const ke=q($e(n.touchedFields,M),he.argA,he.argB);me&&Nt(n.touchedFields,M,ke)}(v.dirtyFields||S.dirtyFields)&&R(),k.state.next({name:M,isDirty:oe(M,U),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Nt(s,M,U)},L=(M,U)=>{Nt(n.errors,M,U),n.errors={...n.errors},k.state.next({errors:n.errors})},ne=M=>{n.errors=M,k.state.next({errors:n.errors,isValid:!1})},G=M=>{const U=xh(M)?[M]:XO(M);let q=s,he=r;for(let me=0;me{const me=$e(i,M);if(me){if(G(M))return;const Se=Ht($e(s,M)),ke=$e(s,M,Ht(q)?$e(r,M):q);Ht(ke)||he&&he.defaultChecked||U?Nt(s,M,U?ke:lE(me._f)):P(M,ke),o.mount&&!o.action&&(Q(),Se&&n.isDirty&&(v.isDirty||S.isDirty)&&(oe()||(n.isDirty=!1,k.state.next({...n}))),t.shouldUnregister&&Se&&!Ht($e(s,M))&&cb(M,l)&&(o.watch=!0))}},Y=(M,U,q,he,me)=>{let Se=!1,ke=!1;const _e={name:M};if(!e.disabled||he===!0){if(!q||he){const Ae=Ss($e(r,M),U);(v.isDirty||S.isDirty)&&(ke=n.isDirty,n.isDirty=_e.isDirty=!Ae||oe(),Se=ke!==_e.isDirty),ke=!!$e(n.dirtyFields,M),Ae!==n.isDirty?n.dirtyFields=pl(r,s,void 0,i):Ae?On(n.dirtyFields,M):Nt(n.dirtyFields,M,!0),_e.dirtyFields=n.dirtyFields,Se=Se||(v.dirtyFields||S.dirtyFields)&&ke!==!Ae}if(q){const Ae=$e(n.touchedFields,M);Ae||(Nt(n.touchedFields,M,q),_e.touchedFields=n.touchedFields,Se=Se||(v.touchedFields||S.touchedFields)&&Ae!==q)}Se&&me&&k.state.next(_e)}return Se?_e:{}},re=(M,U,q,he)=>{const me=$e(n.errors,M),Se=(v.isValid||S.isValid)&&bs(U)&&n.isValid!==U;if(e.delayError&&q?(u[M]=T(M,()=>L(M,q)),u[M](e.delayError)):(clearTimeout(f[M]),delete u[M],q?Nt(n.errors,M,q):On(n.errors,M),n.errors={...n.errors}),(q?!Ss(me,q):me)||!Gn(he)||Se){const ke={...he,...Se&&bs(U)?{isValid:U}:{},errors:n.errors,name:M};n={...n,...ke},k.state.next(ke)}},K=async M=>(A(M,!0),await e.resolver(s,e.context,zG(M||l.mount,i,e.criteriaMode,e.shouldUseNativeValidation))),ye=async M=>{const{errors:U}=await K(M);if(A(M),M){for(const q of M){const he=$e(U,q);he?l.array.has(q)&&dn(he)&&!Object.keys(he).some(me=>!Number.isNaN(Number(me)))?tE(n.errors,{[q]:he},q):Nt(n.errors,q,he):On(n.errors,q)}n.errors={...n.errors}}else n.errors=U;return U},N=async({name:M,eventType:U})=>{if(t.validate){const q=await t.validate({formValues:s,formState:n,name:M,eventType:U});if(dn(q))for(const he in q){const me=q[he];me&&Qt(`${db}.${he}`,{message:Kn(me.message)?me.message:"",type:me.type||qr.validate})}else Kn(q)||!q?Qt(db,{message:q||"",type:qr.validate}):Ge(db);return q}return!0},W=async({fields:M,onlyCheckValid:U,name:q,eventType:he,context:me={valid:!0,runRootValidation:!1}})=>{if(t.validate&&(me.runRootValidation=!0,!await N({name:q,eventType:he})&&(me.valid=!1,U)))return me.valid;for(const Se in M){const ke=M[Se];if(ke){const{_f:_e,...Ae}=ke;if(_e){const dt=l.array.has(_e.name),Zt=ke._f&&LG(ke._f),on=v.validatingFields||v.isValidating||S.validatingFields||S.isValidating;Zt&&on&&A([_e.name],!0);const an=await oE(ke,l.disabled,s,$,e.shouldUseNativeValidation&&!U,dt);if(Zt&&on&&A([_e.name]),an[_e.name]&&(me.valid=!1,U)||(!U&&($e(an,_e.name)?dt?tE(n.errors,an,_e.name):Nt(n.errors,_e.name,an[_e.name]):On(n.errors,_e.name)),t.shouldUseNativeValidation&&an[_e.name]))break}!Gn(Ae)&&await W({context:me,onlyCheckValid:U,fields:Ae,name:Se,eventType:he})}}return me.valid},ce=()=>{for(const M of l.unMount){const U=$e(i,M);U&&(U._f.refs?U._f.refs.every(q=>!ub(q)):!ub(U._f.ref))&&At(M)}l.unMount=new Set},oe=(M,U)=>(M&&U&&Nt(s,M,U),!Ss(o.mount?s:r,r)),le=(M,U,q)=>AG(M,l,{...o.mount?s:Ht(U)?r:Kn(M)?{[M]:U}:U},q,U),D=M=>PD($e(o.mount?s:r,M,e.shouldUnregister?$e(r,M,[]):[])),P=(M,U,q={},he=!1,me=!1)=>{const Se=$e(i,M);let ke=U;if(Se){const _e=Se._f;_e&&(!_e.disabled&&Nt(s,M,ZD(U,_e)),ke=Sm(_e.ref)&&Wn(U)?"":U,DD(_e.ref)?[..._e.ref.options].forEach(Ae=>Ae.selected=ke.includes(Ae.value)):_e.refs?Sh(_e.ref)?_e.refs.forEach(Ae=>{(!Ae.defaultChecked||!Ae.disabled)&&(Array.isArray(ke)?Ae.checked=!!ke.find(dt=>dt===Ae.value):Ae.checked=ke===Ae.value||!!ke)}):_e.refs.forEach(Ae=>Ae.checked=Ae.value===ke):x1(_e.ref)?_e.ref.value="":(_e.ref.value=ke,!_e.ref.type&&!me&&k.state.next({name:M,values:he?s:mn(s)})))}(q.shouldDirty||q.shouldTouch)&&Y(M,ke,q.shouldTouch,q.shouldDirty,!me),q.shouldValidate&&xe(M,{delayError:q.delayError})},I=(M,U,q,he=!1,me=!1)=>{for(const Se in U){if(!U.hasOwnProperty(Se))return;const ke=U[Se],_e=M+"."+Se,Ae=$e(i,_e);(l.array.has(M)||dn(ke)||Ae&&!Ae._f)&&!Oa(ke)?I(_e,ke,q,he,me):P(_e,ke,q,he,me)}},X=(M,U,q,he,me=!1)=>{const Se=$e(i,M),ke=l.array.has(M),_e=he?U:mn(U),Ae=$e(s,M),dt=Ss(Ae,_e);if(dt||Nt(s,M,_e),ke)k.array.next({name:M,values:he?s:mn(s)}),(v.isDirty||v.dirtyFields||S.isDirty||S.dirtyFields)&&q.shouldDirty&&(R(),me||k.state.next({name:M,dirtyFields:n.dirtyFields,isDirty:oe(M,_e)}));else{const Zt=Array.isArray(_e)&&!_e.length||Gn(_e);!Se||Se._f||Wn(_e)||Zt?P(M,_e,q,he,me):I(M,_e,q,he,me)}if(!dt&&!me){const Zt=cb(M,l),on=he?s:mn(s);k.state.next({...Zt&&n,name:o.mount||Zt?M:void 0,values:on})}},V=(M,U,q={})=>X(M,U,q,!1),J=(M,U={})=>{const q=$r(M)?M(s):M;if(!Ss(s,q)){s={...s,...q};const he=jD(q);for(const me of l.mount)me in he&&X(me,he[me],U,!0,!0);k.state.next({...n,name:void 0,type:void 0,...h?{values:s}:{}}),U.shouldValidate&&Q()}},se=async M=>{o.mount=!0;const U=M.target;let q=U.name,he=!0;const me=$e(i,q),Se=ke=>{he=Number.isNaN(ke)||Oa(ke)&&isNaN(ke.getTime())||Ss(ke,$e(s,q,ke))};if(me){let ke,_e;const Ae=U.type?lE(me._f):CG(M),dt=M.type===Nc.BLUR||M.type===Nc.FOCUS_OUT,Zt=!ZG(me._f)&&!t.validate&&!e.resolver&&!$e(n.errors,q)&&!me._f.deps,on=Zt||VG(dt,$e(n.touchedFields,q),n.isSubmitted,O,p),an=cb(q,l,dt);if(Nt(s,q,Ae),dt){if(!U||!U.readOnly){me._f.onBlur&&me._f.onBlur(M);const qt=u[q];qt&&qt(0)}}else me._f.onChange&&me._f.onChange(M);const Ve=Y(q,Ae,dt),Ct=!Gn(Ve)||an;if(!dt&&k.state.next({name:q,type:M.type,...h?{values:mn(s)}:{}}),on)return(!Zt||!n.isValid)&&(v.isValid||S.isValid)&&(e.mode==="onBlur"?dt&&Q():dt||Q()),Ct&&k.state.next({name:q,...an?{}:Ve});if(!e.resolver&&t.validate&&await N({name:q,eventType:M.type}),!dt&&an&&k.state.next({...n}),e.resolver){const{errors:qt}=await K([q]);if(A([q]),Se(Ae),!he){!Gn(Ve)&&k.state.next(Ve);return}const ln=uE(n.errors,i,q),yi=uE(qt,i,ln.name||q);ke=yi.error,q=yi.name,_e=Gn(qt)}else A([q],!0),ke=(await oE(me,l.disabled,s,$,e.shouldUseNativeValidation))[q],A([q]),Se(Ae),he&&(ke?_e=!1:(v.isValid||S.isValid)&&(_e=await W({fields:i,onlyCheckValid:!0,name:q,eventType:M.type})));he&&(me._f.deps&&(!Array.isArray(me._f.deps)||me._f.deps.length>0)&&xe(me._f.deps),re(q,_e,ke,Ve))}},pe=(M,U)=>{if($e(n.errors,U)&&M.focus)return M.focus(),1},xe=async(M,U={})=>{let q,he;const me=qg(M);if(e.resolver){const Se=await ye(Ht(M)?M:me);q=Gn(Se),he=M?!me.some(ke=>$e(Se,ke)):q}else M?(he=(await Promise.all(me.map(async Se=>{const ke=$e(i,Se);return await W({fields:ke&&ke._f?{[Se]:ke}:ke,eventType:Nc.TRIGGER})}))).every(Boolean),!(!he&&!n.isValid)&&Q()):he=q=await W({fields:i,name:M,eventType:Nc.TRIGGER});if(U.delayError&&e.delayError&&Kn(M)){const Se=$e(n.errors,M);Se?(On(n.errors,M),u[M]=T(M,()=>L(M,Se)),u[M](e.delayError)):(clearTimeout(f[M]),delete u[M])}return k.state.next({...!Kn(M)||(v.isValid||S.isValid)&&q!==n.isValid?{}:{name:M},...e.resolver||!M?{isValid:q}:{},errors:n.errors}),U.shouldFocus&&!he&&vf(i,pe,M?me:l.mount),he},Ze=(M,U)=>{let q={...o.mount?s:r};return U&&(q=MD(U.dirtyFields?n.dirtyFields:n.touchedFields,q)),Ht(M)?q:Kn(M)?$e(q,M):M.map(he=>$e(q,he))},Xe=(M,U)=>({invalid:!!$e((U||n).errors,M),isDirty:!!$e((U||n).dirtyFields,M),error:$e((U||n).errors,M),isValidating:!!$e(n.validatingFields,M),isTouched:!!$e((U||n).touchedFields,M)}),Ge=M=>{const U=M?qg(M):void 0;U?.forEach(q=>On(n.errors,q)),U?U.forEach(q=>{k.state.next({name:q,errors:n.errors})}):k.state.next({errors:{}})},Qt=(M,U,q)=>{const he=($e(i,M,{_f:{}})._f||{}).ref,me=$e(n.errors,M)||{},{ref:Se,message:ke,type:_e,...Ae}=me;Nt(n.errors,M,{...Ae,...U,ref:he}),k.state.next({name:M,errors:n.errors,isValid:!1}),q&&q.shouldFocus&&he&&he.focus&&he.focus()},lt=(M,U)=>{if($r(M)){h++;const{unsubscribe:q}=k.state.subscribe({next:me=>"values"in me&&M(me.values||le(void 0,U),me)});let he=!1;return{unsubscribe:()=>{he||(he=!0,h--,q())}}}return le(M,U,!0)},ti=M=>{var U;const q=!!(!((U=M.formState)===null||U===void 0)&&U.values);q&&h++;const{unsubscribe:he}=k.state.subscribe({next:Se=>{if(XG(M.name,Se.name,M.exact)&&IG(Se,M.formState||v,qs,M.reRenderRoot)){const ke={...s};M.callback({values:ke,...n,...Se,defaultValues:r})}}});if(!q)return he;let me=!1;return()=>{me||(me=!0,h--,he())}},Oi=M=>(o.mount=!0,S={...S,...M.formState},ti({...M,formState:{...y,...M.formState}})),At=(M,U={})=>{for(const q of M?qg(M):l.mount)l.mount.delete(q),l.array.delete(q),U.keepValue||(On(i,q),On(s,q)),!U.keepError&&On(n.errors,q),!U.keepDirty&&On(n.dirtyFields,q),!U.keepTouched&&On(n.touchedFields,q),!U.keepIsValidating&&On(n.validatingFields,q),!e.shouldUnregister&&!U.keepDefaultValue&&On(r,q);k.state.next({values:mn(s)}),k.state.next({...n,...U.keepDirty?{isDirty:oe()}:{}}),!U.keepIsValid&&Q()},pr=({disabled:M,name:U})=>{if(bs(M)&&o.mount||M||l.disabled.has(U)){const me=l.disabled.has(U)!==!!M;M?l.disabled.add(U):l.disabled.delete(U),me&&o.mount&&!o.action&&Q()}},zn=(M,U={})=>{let q=$e(i,M);const he=bs(U.disabled)||bs(e.disabled),me=!l.registerName.has(M)&&q&&q._f&&!q._f.mount;return Nt(i,M,{...q||{},_f:{...q&&q._f?q._f:{ref:{name:M}},name:M,mount:!0,...U}}),l.mount.add(M),q&&!me?pr({disabled:bs(U.disabled)?U.disabled:e.disabled,name:M}):H(M,!0,U.value),{...he?{disabled:U.disabled||e.disabled}:{},...e.progressive?{required:!!U.required,min:Wd(U.min),max:Wd(U.max),minLength:Wd(U.minLength),maxLength:Wd(U.maxLength),pattern:Wd(U.pattern)}:{},name:M,onChange:se,onBlur:se,ref:Se=>{if(Se){l.registerName.add(M),zn(M,U),l.registerName.delete(M),q=$e(i,M);const ke=Ht(Se.value)&&Se.querySelectorAll&&Se.querySelectorAll("input,select,textarea")[0]||Se,_e=DG(ke),Ae=q._f.refs||[];if(_e?Ae.find(dt=>dt===ke):ke===q._f.ref)return;Nt(i,M,{_f:{...q._f,..._e?{refs:[...Ae.filter(ub),ke,...Array.isArray($e(r,M))?[{}]:[]],ref:{type:ke.type,name:M}}:{ref:ke}}}),H(M,!1,void 0,ke)}else q=$e(i,M,{}),q._f&&(q._f.mount=!1),(e.shouldUnregister||U.shouldUnregister)&&!(_G(l.array,M)&&o.action)&&l.unMount.add(M)}}},gr=()=>e.shouldFocusError&&!e.shouldUseNativeValidation&&vf(i,pe,l.mount),Ri=M=>{bs(M)&&(k.state.next({disabled:M}),vf(i,(U,q)=>{const he=$e(i,q);he&&(U.disabled=he._f.disabled||M,Array.isArray(he._f.refs)&&he._f.refs.forEach(me=>{me.disabled=he._f.disabled||M}))},0,!1))},sn=(M,U)=>async q=>{let he;q&&(q.preventDefault&&q.preventDefault(),q.persist&&q.persist());let me=mn(s);if(k.state.next({isSubmitting:!0}),e.resolver){const{errors:Se,values:ke}=await K();A(),n.errors=Se,me=mn(ke)}else await W({fields:i,eventType:Nc.SUBMIT});if(l.disabled.size)for(const Se of l.disabled)On(me,Se);if(On(n.errors,RD),Gn(n.errors)){k.state.next({errors:{}});try{await M(me,q)}catch(Se){he=Se}}else U&&await U({...n.errors},q),gr(),setTimeout(gr);if(k.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Gn(n.errors)&&!he,submitCount:n.submitCount+1,errors:n.errors}),he)throw he},Yi=(M,U={})=>{$e(i,M)&&(Ht(U.defaultValue)?V(M,mn($e(r,M))):(V(M,U.defaultValue),Nt(r,M,mn(U.defaultValue))),U.keepTouched||On(n.touchedFields,M),U.keepDirty||(On(n.dirtyFields,M),n.isDirty=U.defaultValue?oe(M,mn($e(r,M))):oe()),U.keepError||(On(n.errors,M),v.isValid&&Q()),k.state.next({...n}))},xn=(M,U={})=>{const q=M?mn(M):r,he=mn(q),me=Gn(M),Se=he,ke=i;if(U.keepDefaultValues||(r=q),!U.keepValues){if(U.keepDirtyValues){const _e=new Set([...l.mount,...Object.keys(pl(r,s,void 0,ke))]);for(const Ae of Array.from(_e)){const dt=$e(n.dirtyFields,Ae),Zt=$e(s,Ae),on=$e(Se,Ae);dt&&!Ht(Zt)?Nt(Se,Ae,Zt):!dt&&!Ht(on)&&V(Ae,on)}}else{if(IO&&Ht(M))for(const _e of l.mount){const Ae=$e(i,_e);if(Ae&&Ae._f){const dt=Array.isArray(Ae._f.refs)?Ae._f.refs[0]:Ae._f.ref;if(Sm(dt)){const Zt=dt.closest("form");if(Zt){Zt.reset();break}}}}if(U.keepFieldsRef)for(const _e of l.mount)V(_e,$e(Se,_e));else i={}}if(e.shouldUnregister){if(s=U.keepDefaultValues?mn(r):{},U.keepFieldsRef)for(const _e of l.mount)Nt(s,_e,$e(Se,_e))}else s=mn(Se);k.array.next({values:{...Se}}),k.state.next({name:void 0,type:void 0,values:{...Se}})}l={mount:U.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!v.isValid||!!U.keepIsValid||!!U.keepDirtyValues||!e.shouldUnregister&&!Gn(Se),o.watch=!!e.shouldUnregister,o.keepIsValid=!!U.keepIsValid,o.action=!1,U.keepErrors||(n.errors={}),k.state.next({submitCount:U.keepSubmitCount?n.submitCount:0,isDirty:me?!1:U.keepDirty?n.isDirty:U.keepValues?oe():!!(U.keepDefaultValues&&!Ss(M,r)),isSubmitted:U.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:me?{}:U.keepDirtyValues?U.keepDefaultValues&&s?pl(r,s,void 0,ke):n.dirtyFields:U.keepDefaultValues&&M?pl(r,M,void 0,ke):U.keepDirty?n.dirtyFields:{},touchedFields:U.keepTouched?n.touchedFields:{},errors:U.keepErrors?n.errors:{},isSubmitSuccessful:U.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:r})},ni=(M,U)=>xn($r(M)?M(s):M,{...e.resetOptions,...U}),mr=(M,U={})=>{const q=$e(i,M),he=q&&q._f;if(he){const me=he.refs?he.refs[0]:he.ref;me.focus&&setTimeout(()=>{me.focus(),U.shouldSelect&&$r(me.select)&&me.select()})}},qs=M=>{const{name:U,type:q,values:he,...me}=M;n={...n,...me}},ii={control:{register:zn,unregister:At,getFieldState:Xe,handleSubmit:sn,setError:Qt,_subscribe:ti,_runSchema:K,_updateIsValidating:A,_focusError:gr,_getWatch:le,_getDirty:oe,_setValid:Q,_setFieldArray:j,_setDisabledField:pr,_setErrors:ne,_getFieldArray:D,_reset:xn,_resetDefaultValues:()=>$r(e.defaultValues)&&e.defaultValues().then(M=>{ni(M,e.resetOptions),k.state.next({isLoading:!1})}),_removeUnmounted:ce,_disableForm:Ri,_subjects:k,_proxyFormState:v,get _fields(){return i},get _formValues(){return s},get _state(){return o},set _state(M){o=M},get _defaultValues(){return r},get _names(){return l},set _names(M){l=M},get _formState(){return n},get _options(){return e},set _options(M){e={...e,...M},p=gg(e.mode),O=gg(e.reValidateMode)}},subscribe:Oi,trigger:xe,register:zn,handleSubmit:sn,watch:lt,setValue:V,setValues:J,getValues:Ze,reset:ni,resetField:Yi,resetDefaultValues:(M,U={})=>{if(r=mn(M),!U.keepDirty){const q=pl(r,s,void 0,i);n.dirtyFields=q,n.isDirty=!Gn(q)}U.keepIsValid||Q(),k.state.next({...n,defaultValues:r})},clearErrors:Ge,unregister:At,setError:Qt,setFocus:mr,getFieldState:Xe};return{...ii,formControl:ii}}function C1(t={}){const e=be.useRef(void 0),n=be.useRef(void 0),i=be.useRef(t.formControl),[r,s]=be.useState(()=>({...mn(ID),isLoading:$r(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1,defaultValues:$r(t.defaultValues)?void 0:t.defaultValues}));if(!e.current||t.formControl&&i.current!==t.formControl)if(i.current=t.formControl,t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!$r(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...u}=qG(t);e.current={...u,formState:r}}const o=e.current.control;return o._options=t,QG(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>s({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return s(u=>({...u,isReady:!0})),o._formState.isReady=!0,l},[o]),be.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),be.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),be.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),be.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),be.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==r.isDirty&&o._subjects.state.next({isDirty:l})}},[o,r.isDirty]),be.useEffect(()=>{var l;t.values&&!Ss(t.values,n.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=t.values,s(u=>({...u}))):o._resetDefaultValues()},[o,t.values]),be.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),e.current.formState=be.useMemo(()=>RG(r,o),[o,r]),e.current}const dE=(t,e,n)=>{if(t&&"reportValidity"in t){const i=$e(n,e);t.setCustomValidity(i&&i.message||""),t.reportValidity()}},WS=(t,e)=>{for(const n in e.fields){const i=e.fields[n];i&&i.ref&&"reportValidity"in i.ref?dE(i.ref,n,t):i&&i.refs&&i.refs.forEach(r=>dE(r,n,t))}},fE=(t,e)=>{e.shouldUseNativeValidation&&WS(t,e);const n={};for(const i in t){const r=$e(e.fields,i),s=Object.assign(t[i]||{},{ref:r&&r.ref});if(YG(e.names||Object.keys(t),i)){const o=Object.assign({},$e(n,i));Nt(o,"root",s),Nt(n,i,o)}else Nt(n,i,s)}return n},YG=(t,e)=>{const n=hE(e).replace(/[.*+?^${}()|\\]/g,"\\$&");return t.some(i=>hE(i).match(`^${n}\\.\\d+`))};function hE(t){return t.replace(/[\[\]]/g,"")}var pE;function ge(t,e,n){function i(l,u){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:u,constr:o,traits:new Set},enumerable:!1}),l._zod.traits.has(t))return;l._zod.traits.add(t),e(l,u);const f=o.prototype,h=Object.keys(f);for(let p=0;pn?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}class ru extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class XD extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(pE=globalThis).__zod_globalConfig??(pE.__zod_globalConfig={});const _1=globalThis.__zod_globalConfig;function Ml(t){return _1}function VD(t){const e=Object.values(t).filter(i=>typeof i=="number");return Object.entries(t).filter(([i,r])=>e.indexOf(+i)===-1).map(([i,r])=>r)}function KS(t,e){return typeof e=="bigint"?e.toString():e}function $1(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function T1(t){return t==null}function E1(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}const gE=Symbol("evaluating");function Lt(t,e,n){let i;Object.defineProperty(t,e,{get(){if(i!==gE)return i===void 0&&(i=gE,i=n()),i},set(r){Object.defineProperty(t,e,{value:r})},configurable:!0})}function Wl(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ia(...t){const e={};for(const n of t){const i=Object.getOwnPropertyDescriptors(n);Object.assign(e,i)}return Object.defineProperties({},e)}function mE(t){return JSON.stringify(t)}function FG(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const BD="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function wm(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const GG=$1(()=>{if(_1.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Mf(t){if(wm(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(wm(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function UD(t){return Mf(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}const HG=new Set(["string","number","symbol"]);function VO(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xa(t,e,n){const i=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(i._zod.parent=t),i}function He(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function WG(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function KG(t,e){const n=t._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Ia(t._zod.def,{get shape(){const o={};for(const l in e){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);e[l]&&(o[l]=n.shape[l])}return Wl(this,"shape",o),o},checks:[]});return Xa(t,s)}function JG(t,e){const n=t._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Ia(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const l in e){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);e[l]&&delete o[l]}return Wl(this,"shape",o),o},checks:[]});return Xa(t,s)}function eH(t,e){if(!Mf(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const s=t._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=Ia(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return Wl(this,"shape",s),s}});return Xa(t,r)}function tH(t,e){if(!Mf(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ia(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Wl(this,"shape",i),i}});return Xa(t,n)}function nH(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Ia(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e._zod.def.shape};return Wl(this,"shape",i),i},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Xa(t,n)}function iH(t,e,n){const r=e._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Ia(e._zod.def,{get shape(){const l=e._zod.def.shape,u={...l};if(n)for(const f in n){if(!(f in l))throw new Error(`Unrecognized key: "${f}"`);n[f]&&(u[f]=t?new t({type:"optional",innerType:l[f]}):l[f])}else for(const f in l)u[f]=t?new t({type:"optional",innerType:l[f]}):l[f];return Wl(this,"shape",u),u},checks:[]});return Xa(e,o)}function rH(t,e,n){const i=Ia(e._zod.def,{get shape(){const r=e._zod.def.shape,s={...r};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new t({type:"nonoptional",innerType:r[o]}))}else for(const o in r)s[o]=new t({type:"nonoptional",innerType:r[o]});return Wl(this,"shape",s),s}});return Xa(e,i)}function Hc(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n{var i;return(i=n).path??(i.path=[]),n.path.unshift(t),n})}function mg(t){return typeof t=="string"?t:t?.message}function Dl(t,e,n){const i=t.message?t.message:mg(t.inst?._zod.def?.error?.(t))??mg(e?.error?.(t))??mg(n.customError?.(t))??mg(n.localeError?.(t))??"Invalid input",{inst:r,continue:s,input:o,...l}=t;return l.path??(l.path=[]),l.message=i,e?.reportInput&&(l.input=o),l}function R1(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Df(...t){const[e,n,i]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:i}:{...e}}const YD=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,KS,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Q1=ge("$ZodError",YD),BO=ge("$ZodError",YD,{Parent:Error});function oH(t,e=n=>n.message){const n={},i=[];for(const r of t.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):i.push(e(r));return{formErrors:i,fieldErrors:n}}function aH(t,e=n=>n.message){const n={_errors:[]},i=(r,s=[])=>{for(const o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>i({issues:l},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{const l=[...s,...o.path];if(l.length===0)n._errors.push(e(o));else{let u=n,f=0;for(;f(e,n,i,r)=>{const s=i?{...i,async:!1}:{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new ru;if(o.issues.length){const l=new(r?.Err??t)(o.issues.map(u=>Dl(u,s,Ml())));throw BD(l,r?.callee),l}return o.value},lH=UO(BO),qO=t=>async(e,n,i,r)=>{const s=i?{...i,async:!0}:{async:!0};let o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const l=new(r?.Err??t)(o.issues.map(u=>Dl(u,s,Ml())));throw BD(l,r?.callee),l}return o.value},cH=qO(BO),YO=t=>(e,n,i)=>{const r=i?{...i,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new ru;return s.issues.length?{success:!1,error:new(t??Q1)(s.issues.map(o=>Dl(o,r,Ml())))}:{success:!0,data:s.value}},uH=YO(BO),FO=t=>async(e,n,i)=>{const r=i?{...i,async:!0}:{async:!0};let s=e._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>Dl(o,r,Ml())))}:{success:!0,data:s.value}},dH=FO(BO),fH=t=>(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return UO(t)(e,n,r)},hH=t=>(e,n,i)=>UO(t)(e,n,i),pH=t=>async(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return qO(t)(e,n,r)},gH=t=>async(e,n,i)=>qO(t)(e,n,i),mH=t=>(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return YO(t)(e,n,r)},OH=t=>(e,n,i)=>YO(t)(e,n,i),yH=t=>async(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return FO(t)(e,n,r)},vH=t=>async(e,n,i)=>FO(t)(e,n,i),bH=/^[cC][0-9a-z]{6,}$/,SH=/^[0-9a-z]+$/,xH=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,wH=/^[0-9a-vA-V]{20}$/,kH=/^[A-Za-z0-9]{27}$/,CH=/^[a-zA-Z0-9_-]{21}$/,_H=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,$H=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,OE=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,TH=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,EH="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function RH(){return new RegExp(EH,"u")}const QH=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,AH=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,PH=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,jH=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,MH=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,FD=/^[A-Za-z0-9_-]*$/,DH=/^https?$/,NH=/^\+[1-9]\d{6,14}$/,GD="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",zH=new RegExp(`^${GD}$`);function HD(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function LH(t){return new RegExp(`^${HD(t)}$`)}function ZH(t){const e=HD({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${e}(?:${n.join("|")})`;return new RegExp(`^${GD}T(?:${i})$`)}const IH=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},XH=/^(?:true|false)$/i,VH=/^[^A-Z]*$/,BH=/^[^a-z]*$/,Xs=ge("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),UH=ge("$ZodCheckMaxLength",(t,e)=>{var n;Xs.init(t,e),(n=t._zod.def).when??(n.when=i=>{const r=i.value;return!T1(r)&&r.length!==void 0}),t._zod.onattach.push(i=>{const r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum{const r=i.value;if(r.length<=e.maximum)return;const o=R1(r);i.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:r,inst:t,continue:!e.abort})}}),qH=ge("$ZodCheckMinLength",(t,e)=>{var n;Xs.init(t,e),(n=t._zod.def).when??(n.when=i=>{const r=i.value;return!T1(r)&&r.length!==void 0}),t._zod.onattach.push(i=>{const r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>r&&(i._zod.bag.minimum=e.minimum)}),t._zod.check=i=>{const r=i.value;if(r.length>=e.minimum)return;const o=R1(r);i.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:r,inst:t,continue:!e.abort})}}),YH=ge("$ZodCheckLengthEquals",(t,e)=>{var n;Xs.init(t,e),(n=t._zod.def).when??(n.when=i=>{const r=i.value;return!T1(r)&&r.length!==void 0}),t._zod.onattach.push(i=>{const r=i._zod.bag;r.minimum=e.length,r.maximum=e.length,r.length=e.length}),t._zod.check=i=>{const r=i.value,s=r.length;if(s===e.length)return;const o=R1(r),l=s>e.length;i.issues.push({origin:o,...l?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:i.value,inst:t,continue:!e.abort})}}),GO=ge("$ZodCheckStringFormat",(t,e)=>{var n,i;Xs.init(t,e),t._zod.onattach.push(r=>{const s=r._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:e.format,input:r.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(i=t._zod).check??(i.check=()=>{})}),FH=ge("$ZodCheckRegex",(t,e)=>{GO.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),GH=ge("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=VH),GO.init(t,e)}),HH=ge("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=BH),GO.init(t,e)}),WH=ge("$ZodCheckIncludes",(t,e)=>{Xs.init(t,e);const n=VO(e.includes),i=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=i,t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(i)}),t._zod.check=r=>{r.value.includes(e.includes,e.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:r.value,inst:t,continue:!e.abort})}}),KH=ge("$ZodCheckStartsWith",(t,e)=>{Xs.init(t,e);const n=new RegExp(`^${VO(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),t._zod.check=i=>{i.value.startsWith(e.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:i.value,inst:t,continue:!e.abort})}}),JH=ge("$ZodCheckEndsWith",(t,e)=>{Xs.init(t,e);const n=new RegExp(`.*${VO(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),t._zod.check=i=>{i.value.endsWith(e.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:i.value,inst:t,continue:!e.abort})}}),eW=ge("$ZodCheckOverwrite",(t,e)=>{Xs.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});let tW=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const i=e.split(` -`).filter(o=>o),r=Math.min(...i.map(o=>o.length-o.trimStart().length)),s=i.map(o=>o.slice(r)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,n=this?.args,r=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...n,r.join(` -`))}};const nW={major:4,minor:4,patch:3},$n=ge("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=nW;const i=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&i.unshift(t);for(const r of i)for(const s of r._zod.onattach)s(t);if(i.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const r=(o,l,u)=>{let f=Hc(o),h;for(const p of l){if(p._zod.def.when){if(sH(o)||!p._zod.def.when(o))continue}else if(f)continue;const O=o.issues.length,y=p._zod.check(o);if(y instanceof Promise&&u?.async===!1)throw new ru;if(h||y instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await y,o.issues.length!==O&&(f||(f=Hc(o,O)))});else{if(o.issues.length===O)continue;f||(f=Hc(o,O))}}return h?h.then(()=>o):o},s=(o,l,u)=>{if(Hc(o))return o.aborted=!0,o;const f=r(l,i,u);if(f instanceof Promise){if(u.async===!1)throw new ru;return f.then(h=>t._zod.parse(h,u))}return t._zod.parse(f,u)};t._zod.run=(o,l)=>{if(l.skipChecks)return t._zod.parse(o,l);if(l.direction==="backward"){const f=t._zod.parse({value:o.value,issues:[]},{...l,skipChecks:!0});return f instanceof Promise?f.then(h=>s(h,o,l)):s(f,o,l)}const u=t._zod.parse(o,l);if(u instanceof Promise){if(l.async===!1)throw new ru;return u.then(f=>r(f,i,l))}return r(u,i,l)}}Lt(t,"~standard",()=>({validate:r=>{try{const s=uH(t,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return dH(t,r).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),A1=ge("$ZodString",(t,e)=>{$n.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??IH(t._zod.bag),t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),en=ge("$ZodStringFormat",(t,e)=>{GO.init(t,e),A1.init(t,e)}),iW=ge("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=$H),en.init(t,e)}),rW=ge("$ZodUUID",(t,e)=>{if(e.version){const i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(i===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=OE(i))}else e.pattern??(e.pattern=OE());en.init(t,e)}),sW=ge("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=TH),en.init(t,e)}),oW=ge("$ZodURL",(t,e)=>{en.init(t,e),t._zod.check=n=>{try{const i=n.value.trim();if(!e.normalize&&e.protocol?.source===DH.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:t,continue:!e.abort});return}const r=new URL(i);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=r.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),aW=ge("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=RH()),en.init(t,e)}),lW=ge("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=CH),en.init(t,e)}),cW=ge("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=bH),en.init(t,e)}),uW=ge("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=SH),en.init(t,e)}),dW=ge("$ZodULID",(t,e)=>{e.pattern??(e.pattern=xH),en.init(t,e)}),fW=ge("$ZodXID",(t,e)=>{e.pattern??(e.pattern=wH),en.init(t,e)}),hW=ge("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=kH),en.init(t,e)}),pW=ge("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=ZH(e)),en.init(t,e)}),gW=ge("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=zH),en.init(t,e)}),mW=ge("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=LH(e)),en.init(t,e)}),OW=ge("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=_H),en.init(t,e)}),yW=ge("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=QH),en.init(t,e),t._zod.bag.format="ipv4"}),vW=ge("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=AH),en.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),bW=ge("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=PH),en.init(t,e)}),SW=ge("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=jH),en.init(t,e),t._zod.check=n=>{const i=n.value.split("/");try{if(i.length!==2)throw new Error;const[r,s]=i;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function WD(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const xW=ge("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=MH),en.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{WD(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function wW(t){if(!FD.test(t))return!1;const e=t.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return WD(n)}const kW=ge("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=FD),en.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{wW(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),CW=ge("$ZodE164",(t,e)=>{e.pattern??(e.pattern=NH),en.init(t,e)});function _W(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[i]=n;if(!i)return!1;const r=JSON.parse(atob(i));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||e&&(!("alg"in r)||r.alg!==e))}catch{return!1}}const $W=ge("$ZodJWT",(t,e)=>{en.init(t,e),t._zod.check=n=>{_W(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),TW=ge("$ZodBoolean",(t,e)=>{$n.init(t,e),t._zod.pattern=XH,t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:t}),n}}),EW=ge("$ZodUnknown",(t,e)=>{$n.init(t,e),t._zod.parse=n=>n}),RW=ge("$ZodNever",(t,e)=>{$n.init(t,e),t._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function yE(t,e,n){t.issues.length&&e.issues.push(...qD(n,t.issues)),e.value[n]=t.value}const QW=ge("$ZodArray",(t,e)=>{$n.init(t,e),t._zod.parse=(n,i)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:t}),n;n.value=Array(r.length);const s=[];for(let o=0;oyE(f,n,o))):yE(u,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function km(t,e,n,i,r,s){const o=n in i;if(t.issues.length){if(r&&s&&!o)return;e.issues.push(...qD(n,t.issues))}if(!o&&!r){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}t.value===void 0?o&&(e.value[n]=void 0):e.value[n]=t.value}function KD(t){const e=Object.keys(t.shape);for(const i of e)if(!t.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const n=WG(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function JD(t,e,n,i,r,s){const o=[],l=r.keySet,u=r.catchall._zod,f=u.def.type,h=u.optin==="optional",p=u.optout==="optional";for(const O in e){if(O==="__proto__"||l.has(O))continue;if(f==="never"){o.push(O);continue}const y=u.run({value:e[O],issues:[]},i);y instanceof Promise?t.push(y.then(v=>km(v,n,O,e,h,p))):km(y,n,O,e,h,p)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}const AW=ge("$ZodObject",(t,e)=>{if($n.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){const l=e.shape;Object.defineProperty(e,"shape",{get:()=>{const u={...l};return Object.defineProperty(e,"shape",{value:u}),u}})}const i=$1(()=>KD(e));Lt(t._zod,"propValues",()=>{const l=e.shape,u={};for(const f in l){const h=l[f]._zod;if(h.values){u[f]??(u[f]=new Set);for(const p of h.values)u[f].add(p)}}return u});const r=wm,s=e.catchall;let o;t._zod.parse=(l,u)=>{o??(o=i.value);const f=l.value;if(!r(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:t}),l;l.value={};const h=[],p=o.shape;for(const O of o.keys){const y=p[O],v=y._zod.optin==="optional",S=y._zod.optout==="optional",k=y._zod.run({value:f[O],issues:[]},u);k instanceof Promise?h.push(k.then(C=>km(C,l,O,f,v,S))):km(k,l,O,f,v,S)}return s?JD(h,f,l,u,i.value,t):h.length?Promise.all(h).then(()=>l):l}}),PW=ge("$ZodObjectJIT",(t,e)=>{AW.init(t,e);const n=t._zod.parse,i=$1(()=>KD(e)),r=O=>{const y=new tW(["shape","payload","ctx"]),v=i.value,S=T=>{const Q=mE(T);return`shape[${Q}]._zod.run({ value: input[${Q}], issues: [] }, ctx)`};y.write("const input = payload.value;");const k=Object.create(null);let C=0;for(const T of v.keys)k[T]=`key_${C++}`;y.write("const newResult = {};");for(const T of v.keys){const Q=k[T],A=mE(T),R=O[T],j=R?._zod?.optin==="optional",L=R?._zod?.optout==="optional";y.write(`const ${Q} = ${S(T)};`),j&&L?y.write(` - if (${Q}.issues.length) { - if (${A} in input) { - payload.issues = payload.issues.concat(${Q}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${A}, ...iss.path] : [${A}] - }))); - } - } - - if (${Q}.value === undefined) { - if (${A} in input) { - newResult[${A}] = undefined; - } - } else { - newResult[${A}] = ${Q}.value; - } - - `):j?y.write(` - if (${Q}.issues.length) { - payload.issues = payload.issues.concat(${Q}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${A}, ...iss.path] : [${A}] - }))); - } - - if (${Q}.value === undefined) { - if (${A} in input) { - newResult[${A}] = undefined; - } - } else { - newResult[${A}] = ${Q}.value; - } - - `):y.write(` - const ${Q}_present = ${A} in input; - if (${Q}.issues.length) { - payload.issues = payload.issues.concat(${Q}.issues.map(iss => ({ - ...iss, - path: iss.path ? [${A}, ...iss.path] : [${A}] - }))); - } - if (!${Q}_present && !${Q}.issues.length) { - payload.issues.push({ - code: "invalid_type", - expected: "nonoptional", - input: undefined, - path: [${A}] - }); - } - - if (${Q}_present) { - if (${Q}.value === undefined) { - newResult[${A}] = undefined; - } else { - newResult[${A}] = ${Q}.value; - } - } - - `)}y.write("payload.value = newResult;"),y.write("return payload;");const $=y.compile();return(T,Q)=>$(O,T,Q)};let s;const o=wm,l=!_1.jitless,f=l&&GG.value,h=e.catchall;let p;t._zod.parse=(O,y)=>{p??(p=i.value);const v=O.value;return o(v)?l&&f&&y?.async===!1&&y.jitless!==!0?(s||(s=r(e.shape)),O=s(O,y),h?JD([],v,O,y,p,t):O):n(O,y):(O.issues.push({expected:"object",code:"invalid_type",input:v,inst:t}),O)}});function vE(t,e,n,i){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;const r=t.filter(s=>!Hc(s));return r.length===1?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>Dl(o,i,Ml())))}),e)}const jW=ge("$ZodUnion",(t,e)=>{$n.init(t,e),Lt(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Lt(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Lt(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),Lt(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(r=>r._zod.pattern);return new RegExp(`^(${i.map(r=>E1(r.source)).join("|")})$`)}});const n=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1;const o=[];for(const l of e.options){const u=l._zod.run({value:i.value,issues:[]},r);if(u instanceof Promise)o.push(u),s=!0;else{if(u.issues.length===0)return u;o.push(u)}}return s?Promise.all(o).then(l=>vE(l,i,t,r)):vE(o,i,t,r)}}),MW=ge("$ZodIntersection",(t,e)=>{$n.init(t,e),t._zod.parse=(n,i)=>{const r=n.value,s=e.left._zod.run({value:r,issues:[]},i),o=e.right._zod.run({value:r,issues:[]},i);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([u,f])=>bE(n,u,f)):bE(n,s,o)}});function JS(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Mf(t)&&Mf(e)){const n=Object.keys(e),i=Object.keys(t).filter(s=>n.indexOf(s)!==-1),r={...t,...e};for(const s of i){const o=JS(t[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;il.l&&l.r).map(([l])=>l);if(s.length&&r&&t.issues.push({...r,keys:s}),Hc(t))return t;const o=JS(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const DW=ge("$ZodEnum",(t,e)=>{$n.init(t,e);const n=VD(e.entries),i=new Set(n);t._zod.values=i,t._zod.pattern=new RegExp(`^(${n.filter(r=>HG.has(typeof r)).map(r=>typeof r=="string"?VO(r):r.toString()).join("|")})$`),t._zod.parse=(r,s)=>{const o=r.value;return i.has(o)||r.issues.push({code:"invalid_value",values:n,input:o,inst:t}),r}}),NW=ge("$ZodTransform",(t,e)=>{$n.init(t,e),t._zod.optin="optional",t._zod.parse=(n,i)=>{if(i.direction==="backward")throw new XD(t.constructor.name);const r=e.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(o=>(n.value=o,n.fallback=!0,n));if(r instanceof Promise)throw new ru;return n.value=r,n.fallback=!0,n}});function SE(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}const eN=ge("$ZodOptional",(t,e)=>{$n.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Lt(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Lt(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${E1(n.source)})?$`):void 0}),t._zod.parse=(n,i)=>{if(e.innerType._zod.optin==="optional"){const r=n.value,s=e.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>SE(o,r)):SE(s,r)}return n.value===void 0?n:e.innerType._zod.run(n,i)}}),zW=ge("$ZodExactOptional",(t,e)=>{eN.init(t,e),Lt(t._zod,"values",()=>e.innerType._zod.values),Lt(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,i)=>e.innerType._zod.run(n,i)}),LW=ge("$ZodNullable",(t,e)=>{$n.init(t,e),Lt(t._zod,"optin",()=>e.innerType._zod.optin),Lt(t._zod,"optout",()=>e.innerType._zod.optout),Lt(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${E1(n.source)}|null)$`):void 0}),Lt(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,i)=>n.value===null?n:e.innerType._zod.run(n,i)}),ZW=ge("$ZodDefault",(t,e)=>{$n.init(t,e),t._zod.optin="optional",Lt(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,i)=>{if(i.direction==="backward")return e.innerType._zod.run(n,i);if(n.value===void 0)return n.value=e.defaultValue,n;const r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>xE(s,e)):xE(r,e)}});function xE(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const IW=ge("$ZodPrefault",(t,e)=>{$n.init(t,e),t._zod.optin="optional",Lt(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,i))}),XW=ge("$ZodNonOptional",(t,e)=>{$n.init(t,e),Lt(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),t._zod.parse=(n,i)=>{const r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>wE(s,t)):wE(r,t)}});function wE(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const VW=ge("$ZodCatch",(t,e)=>{$n.init(t,e),t._zod.optin="optional",Lt(t._zod,"optout",()=>e.innerType._zod.optout),Lt(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,i)=>{if(i.direction==="backward")return e.innerType._zod.run(n,i);const r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(o=>Dl(o,i,Ml()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=r.value,r.issues.length&&(n.value=e.catchValue({...n,error:{issues:r.issues.map(s=>Dl(s,i,Ml()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),BW=ge("$ZodPipe",(t,e)=>{$n.init(t,e),Lt(t._zod,"values",()=>e.in._zod.values),Lt(t._zod,"optin",()=>e.in._zod.optin),Lt(t._zod,"optout",()=>e.out._zod.optout),Lt(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,i)=>{if(i.direction==="backward"){const s=e.out._zod.run(n,i);return s instanceof Promise?s.then(o=>Og(o,e.in,i)):Og(s,e.in,i)}const r=e.in._zod.run(n,i);return r instanceof Promise?r.then(s=>Og(s,e.out,i)):Og(r,e.out,i)}});function Og(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},n)}const UW=ge("$ZodReadonly",(t,e)=>{$n.init(t,e),Lt(t._zod,"propValues",()=>e.innerType._zod.propValues),Lt(t._zod,"values",()=>e.innerType._zod.values),Lt(t._zod,"optin",()=>e.innerType?._zod?.optin),Lt(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(n,i)=>{if(i.direction==="backward")return e.innerType._zod.run(n,i);const r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(kE):kE(r)}});function kE(t){return t.value=Object.freeze(t.value),t}const qW=ge("$ZodCustom",(t,e)=>{Xs.init(t,e),$n.init(t,e),t._zod.parse=(n,i)=>n,t._zod.check=n=>{const i=n.value,r=e.fn(i);if(r instanceof Promise)return r.then(s=>CE(s,n,i,t));CE(r,n,i,t)}});function CE(t,e,n,i){if(!t){const r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),e.issues.push(Df(r))}}var _E;class YW{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const i=n[0];return this._map.set(e,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const i={...this.get(n)??{}};delete i.id;const r={...i,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function FW(){return new YW}(_E=globalThis).__zod_globalRegistry??(_E.__zod_globalRegistry=FW());const df=globalThis.__zod_globalRegistry;function GW(t,e){return new t({type:"string",...He(e)})}function HW(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...He(e)})}function $E(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...He(e)})}function WW(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...He(e)})}function KW(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...He(e)})}function JW(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...He(e)})}function eK(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...He(e)})}function tK(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...He(e)})}function nK(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...He(e)})}function iK(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...He(e)})}function rK(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...He(e)})}function sK(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...He(e)})}function oK(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...He(e)})}function aK(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...He(e)})}function lK(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...He(e)})}function cK(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...He(e)})}function uK(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...He(e)})}function dK(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...He(e)})}function fK(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...He(e)})}function hK(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...He(e)})}function pK(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...He(e)})}function gK(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...He(e)})}function mK(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...He(e)})}function OK(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...He(e)})}function yK(t,e){return new t({type:"string",format:"date",check:"string_format",...He(e)})}function vK(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...He(e)})}function bK(t,e){return new t({type:"string",format:"duration",check:"string_format",...He(e)})}function SK(t,e){return new t({type:"boolean",...He(e)})}function xK(t){return new t({type:"unknown"})}function wK(t,e){return new t({type:"never",...He(e)})}function tN(t,e){return new UH({check:"max_length",...He(e),maximum:t})}function Cm(t,e){return new qH({check:"min_length",...He(e),minimum:t})}function nN(t,e){return new YH({check:"length_equals",...He(e),length:t})}function kK(t,e){return new FH({check:"string_format",format:"regex",...He(e),pattern:t})}function CK(t){return new GH({check:"string_format",format:"lowercase",...He(t)})}function _K(t){return new HH({check:"string_format",format:"uppercase",...He(t)})}function $K(t,e){return new WH({check:"string_format",format:"includes",...He(e),includes:t})}function TK(t,e){return new KH({check:"string_format",format:"starts_with",...He(e),prefix:t})}function EK(t,e){return new JH({check:"string_format",format:"ends_with",...He(e),suffix:t})}function qu(t){return new eW({check:"overwrite",tx:t})}function RK(t){return qu(e=>e.normalize(t))}function QK(){return qu(t=>t.trim())}function AK(){return qu(t=>t.toLowerCase())}function PK(){return qu(t=>t.toUpperCase())}function jK(){return qu(t=>FG(t))}function MK(t,e,n){return new t({type:"array",element:e,...He(n)})}function DK(t,e,n){return new t({type:"custom",check:"custom",fn:e,...He(n)})}function NK(t,e){const n=zK(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(Df(r,i.value,n._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=i.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Df(s))}},t(i.value,i)),e);return n}function zK(t,e){const n=new Xs({check:"custom",...He(e)});return n._zod.check=t,n}function iN(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??df,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function ei(t,e,n={path:[],schemaPath:[]}){var i;const r=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const l=t._zod.toJSONSchema?.();if(l)o.schema=l;else{const h={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,h);else{const O=o.schema,y=e.processors[r.type];if(!y)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);y(t,e,O,h)}const p=t._zod.parent;p&&(o.ref||(o.ref=p),ei(p,e,h),e.seen.get(p).isParent=!0)}const u=e.metadataRegistry.get(t);return u&&Object.assign(o.schema,u),e.io==="input"&&Si(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function rN(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const o of t.seen.entries()){const l=t.metadataRegistry.get(o[0])?.id;if(l){const u=i.get(l);if(u&&u!==o[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(l,o[0])}}const r=o=>{const l=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const p=t.external.registry.get(o[0])?.id,O=t.external.uri??(v=>v);if(p)return{ref:O(p)};const y=o[1].defId??o[1].schema.id??`schema${t.counter++}`;return o[1].defId=y,{defId:y,ref:`${O("__shared")}#/${l}/${y}`}}if(o[1]===n)return{ref:"#"};const f=`#/${l}/`,h=o[1].schema.id??`__schema${t.counter++}`;return{defId:h,ref:f+h}},s=o=>{if(o[1].schema.$ref)return;const l=o[1],{ref:u,defId:f}=r(o);l.def={...l.schema},f&&(l.defId=f);const h=l.schema;for(const p in h)delete h[p];h.$ref=u};if(t.cycles==="throw")for(const o of t.seen.entries()){const l=o[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/ - -Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const o of t.seen.entries()){const l=o[1];if(e===o[0]){s(o);continue}if(t.external){const f=t.external.registry.get(o[0])?.id;if(e!==o[0]&&f){s(o);continue}}if(t.metadataRegistry.get(o[0])?.id){s(o);continue}if(l.cycle){s(o);continue}if(l.count>1&&t.reused==="ref"){s(o);continue}}}function sN(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=l=>{const u=t.seen.get(l);if(u.ref===null)return;const f=u.def??u.schema,h={...f},p=u.ref;if(u.ref=null,p){i(p);const y=t.seen.get(p),v=y.schema;if(v.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(v)):Object.assign(f,v),Object.assign(f,h),l._zod.parent===p)for(const k in f)k==="$ref"||k==="allOf"||k in h||delete f[k];if(v.$ref&&y.def)for(const k in f)k==="$ref"||k==="allOf"||k in y.def&&JSON.stringify(f[k])===JSON.stringify(y.def[k])&&delete f[k]}const O=l._zod.parent;if(O&&O!==p){i(O);const y=t.seen.get(O);if(y?.schema.$ref&&(f.$ref=y.schema.$ref,y.def))for(const v in f)v==="$ref"||v==="allOf"||v in y.def&&JSON.stringify(f[v])===JSON.stringify(y.def[v])&&delete f[v]}t.override({zodSchema:l,jsonSchema:f,path:u.path??[]})};for(const l of[...t.seen.entries()].reverse())i(l[0]);const r={};if(t.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const l=t.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");r.$id=t.external.uri(l)}Object.assign(r,n.def??n.schema);const s=t.metadataRegistry.get(e)?.id;s!==void 0&&r.id===s&&delete r.id;const o=t.external?.defs??{};for(const l of t.seen.entries()){const u=l[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,o[u.defId]=u.def)}t.external||Object.keys(o).length>0&&(t.target==="draft-2020-12"?r.$defs=o:r.definitions=o);try{const l=JSON.parse(JSON.stringify(r));return Object.defineProperty(l,"~standard",{value:{...e["~standard"],jsonSchema:{input:_m(e,"input",t.processors),output:_m(e,"output",t.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function Si(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const i=t._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Si(i.element,n);if(i.type==="set")return Si(i.valueType,n);if(i.type==="lazy")return Si(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Si(i.innerType,n);if(i.type==="intersection")return Si(i.left,n)||Si(i.right,n);if(i.type==="record"||i.type==="map")return Si(i.keyType,n)||Si(i.valueType,n);if(i.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:Si(i.in,n)||Si(i.out,n);if(i.type==="object"){for(const r in i.shape)if(Si(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(const r of i.options)if(Si(r,n))return!0;return!1}if(i.type==="tuple"){for(const r of i.items)if(Si(r,n))return!0;return!!(i.rest&&Si(i.rest,n))}return!1}const LK=(t,e={})=>n=>{const i=iN({...n,processors:e});return ei(t,i),rN(i,t),sN(i,t)},_m=(t,e,n={})=>i=>{const{libraryOptions:r,target:s}=i??{},o=iN({...r??{},target:s,io:e,processors:n});return ei(t,o),rN(o,t),sN(o,t)},ZK={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},IK=(t,e,n,i)=>{const r=n;r.type="string";const{minimum:s,maximum:o,format:l,patterns:u,contentEncoding:f}=t._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof o=="number"&&(r.maxLength=o),l&&(r.format=ZK[l]??l,r.format===""&&delete r.format,l==="time"&&delete r.format),f&&(r.contentEncoding=f),u&&u.size>0){const h=[...u];h.length===1?r.pattern=h[0].source:h.length>1&&(r.allOf=[...h.map(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},XK=(t,e,n,i)=>{n.type="boolean"},VK=(t,e,n,i)=>{n.not={}},BK=(t,e,n,i)=>{},UK=(t,e,n,i)=>{const r=t._zod.def,s=VD(r.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},qK=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},YK=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},FK=(t,e,n,i)=>{const r=n,s=t._zod.def,{minimum:o,maximum:l}=t._zod.bag;typeof o=="number"&&(r.minItems=o),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=ei(s.element,e,{...i,path:[...i.path,"items"]})},GK=(t,e,n,i)=>{const r=n,s=t._zod.def;r.type="object",r.properties={};const o=s.shape;for(const f in o)r.properties[f]=ei(o[f],e,{...i,path:[...i.path,"properties",f]});const l=new Set(Object.keys(o)),u=new Set([...l].filter(f=>{const h=s.shape[f]._zod;return e.io==="input"?h.optin===void 0:h.optout===void 0}));u.size>0&&(r.required=Array.from(u)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=ei(s.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},HK=(t,e,n,i)=>{const r=t._zod.def,s=r.inclusive===!1,o=r.options.map((l,u)=>ei(l,e,{...i,path:[...i.path,s?"oneOf":"anyOf",u]}));s?n.oneOf=o:n.anyOf=o},WK=(t,e,n,i)=>{const r=t._zod.def,s=ei(r.left,e,{...i,path:[...i.path,"allOf",0]}),o=ei(r.right,e,{...i,path:[...i.path,"allOf",1]}),l=f=>"allOf"in f&&Object.keys(f).length===1,u=[...l(s)?s.allOf:[s],...l(o)?o.allOf:[o]];n.allOf=u},KK=(t,e,n,i)=>{const r=t._zod.def,s=ei(r.innerType,e,i),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},JK=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType},eJ=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},tJ=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},nJ=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},iJ=(t,e,n,i)=>{const r=t._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=e.io==="input"?s?r.out:r.in:r.out;ei(o,e,i);const l=e.seen.get(t);l.ref=o},rJ=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType,n.readOnly=!0},oN=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType};function ex(){return ex=Object.assign?Object.assign.bind():function(t){for(var e=1;e0){var u=r.errors[0][0];n[l]={message:u.message,type:u.code}}else n[l]={message:o,type:s};if(r.code==="invalid_union"&&r.errors.forEach(function(p){return p.forEach(function(O){return t.push(ex({},O,{path:[].concat(r.path,O.path)}))})}),e){var f=n[l].types,h=f&&f[r.code];n[l]=k1(l,e,n,s,h?[].concat(h,r.message):r.message)}t.shift()};t.length;)i();return n}function P1(t,e,n){if(n===void 0&&(n={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(t))return function(i,r,s){try{return Promise.resolve(TE(function(){return Promise.resolve(t[n.mode==="sync"?"parse":"parseAsync"](i,e)).then(function(o){return s.shouldUseNativeValidation&&WS({},s),{errors:{},values:n.raw?Object.assign({},i):o}})},function(o){if((function(l){return Array.isArray(l?.issues)})(o))return{values:{},errors:fE(sJ(o.errors,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw o}))}catch(o){return Promise.reject(o)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(t))return function(i,r,s){try{return Promise.resolve(TE(function(){return Promise.resolve((n.mode==="sync"?lH:cH)(t,i,e)).then(function(o){return s.shouldUseNativeValidation&&WS({},s),{errors:{},values:n.raw?Object.assign({},i):o}})},function(o){if((function(l){return l instanceof Q1})(o))return{values:{},errors:fE(oJ(o.issues,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const aJ=ge("ZodISODateTime",(t,e)=>{pW.init(t,e),rn.init(t,e)});function lJ(t){return OK(aJ,t)}const cJ=ge("ZodISODate",(t,e)=>{gW.init(t,e),rn.init(t,e)});function uJ(t){return yK(cJ,t)}const dJ=ge("ZodISOTime",(t,e)=>{mW.init(t,e),rn.init(t,e)});function fJ(t){return vK(dJ,t)}const hJ=ge("ZodISODuration",(t,e)=>{OW.init(t,e),rn.init(t,e)});function pJ(t){return bK(hJ,t)}const gJ=(t,e)=>{Q1.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>aH(t,n)},flatten:{value:n=>oH(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,KS,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,KS,2)}},isEmpty:{get(){return t.issues.length===0}}})},Nr=ge("ZodError",gJ,{Parent:Error}),mJ=UO(Nr),OJ=qO(Nr),yJ=YO(Nr),vJ=FO(Nr),bJ=fH(Nr),SJ=hH(Nr),xJ=pH(Nr),wJ=gH(Nr),kJ=mH(Nr),CJ=OH(Nr),_J=yH(Nr),$J=vH(Nr),EE=new WeakMap;function HO(t,e,n){const i=Object.getPrototypeOf(t);let r=EE.get(i);if(r||(r=new Set,EE.set(i,r)),!r.has(e)){r.add(e);for(const s in n){const o=n[s];Object.defineProperty(i,s,{configurable:!0,enumerable:!1,get(){const l=o.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const Tn=ge("ZodType",(t,e)=>($n.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:_m(t,"input"),output:_m(t,"output")}}),t.toJSONSchema=LK(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(n,i)=>mJ(t,n,i,{callee:t.parse}),t.safeParse=(n,i)=>yJ(t,n,i),t.parseAsync=async(n,i)=>OJ(t,n,i,{callee:t.parseAsync}),t.safeParseAsync=async(n,i)=>vJ(t,n,i),t.spa=t.safeParseAsync,t.encode=(n,i)=>bJ(t,n,i),t.decode=(n,i)=>SJ(t,n,i),t.encodeAsync=async(n,i)=>xJ(t,n,i),t.decodeAsync=async(n,i)=>wJ(t,n,i),t.safeEncode=(n,i)=>kJ(t,n,i),t.safeDecode=(n,i)=>CJ(t,n,i),t.safeEncodeAsync=async(n,i)=>_J(t,n,i),t.safeDecodeAsync=async(n,i)=>$J(t,n,i),HO(t,"ZodType",{check(...n){const i=this.def;return this.clone(Ia(i,{checks:[...i.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,i){return Xa(this,n,i)},brand(){return this},register(n,i){return n.add(this,i),this},refine(n,i){return this.check(bee(n,i))},superRefine(n,i){return this.check(See(n,i))},overwrite(n){return this.check(qu(n))},optional(){return PE(this)},exactOptional(){return aee(this)},nullable(){return jE(this)},nullish(){return PE(jE(this))},nonoptional(n){return hee(this,n)},array(){return WJ(this)},or(n){return eee([this,n])},and(n){return nee(this,n)},transform(n){return ME(this,see(n))},default(n){return uee(this,n)},prefault(n){return fee(this,n)},catch(n){return gee(this,n)},pipe(n){return ME(this,n)},readonly(){return yee(this)},describe(n){const i=this.clone();return df.add(i,{description:n}),i},meta(...n){if(n.length===0)return df.get(this);const i=this.clone();return df.add(i,n[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(t,"description",{get(){return df.get(t)?.description},configurable:!0}),t)),aN=ge("_ZodString",(t,e)=>{A1.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(i,r,s)=>IK(t,i,r);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,HO(t,"_ZodString",{regex(...i){return this.check(kK(...i))},includes(...i){return this.check($K(...i))},startsWith(...i){return this.check(TK(...i))},endsWith(...i){return this.check(EK(...i))},min(...i){return this.check(Cm(...i))},max(...i){return this.check(tN(...i))},length(...i){return this.check(nN(...i))},nonempty(...i){return this.check(Cm(1,...i))},lowercase(i){return this.check(CK(i))},uppercase(i){return this.check(_K(i))},trim(){return this.check(QK())},normalize(...i){return this.check(RK(...i))},toLowerCase(){return this.check(AK())},toUpperCase(){return this.check(PK())},slugify(){return this.check(jK())}})}),TJ=ge("ZodString",(t,e)=>{A1.init(t,e),aN.init(t,e),t.email=n=>t.check(HW(EJ,n)),t.url=n=>t.check(tK(RJ,n)),t.jwt=n=>t.check(mK(UJ,n)),t.emoji=n=>t.check(nK(QJ,n)),t.guid=n=>t.check($E(RE,n)),t.uuid=n=>t.check(WW(yg,n)),t.uuidv4=n=>t.check(KW(yg,n)),t.uuidv6=n=>t.check(JW(yg,n)),t.uuidv7=n=>t.check(eK(yg,n)),t.nanoid=n=>t.check(iK(AJ,n)),t.guid=n=>t.check($E(RE,n)),t.cuid=n=>t.check(rK(PJ,n)),t.cuid2=n=>t.check(sK(jJ,n)),t.ulid=n=>t.check(oK(MJ,n)),t.base64=n=>t.check(hK(XJ,n)),t.base64url=n=>t.check(pK(VJ,n)),t.xid=n=>t.check(aK(DJ,n)),t.ksuid=n=>t.check(lK(NJ,n)),t.ipv4=n=>t.check(cK(zJ,n)),t.ipv6=n=>t.check(uK(LJ,n)),t.cidrv4=n=>t.check(dK(ZJ,n)),t.cidrv6=n=>t.check(fK(IJ,n)),t.e164=n=>t.check(gK(BJ,n)),t.datetime=n=>t.check(lJ(n)),t.date=n=>t.check(uJ(n)),t.time=n=>t.check(fJ(n)),t.duration=n=>t.check(pJ(n))});function Yg(t){return GW(TJ,t)}const rn=ge("ZodStringFormat",(t,e)=>{en.init(t,e),aN.init(t,e)}),EJ=ge("ZodEmail",(t,e)=>{sW.init(t,e),rn.init(t,e)}),RE=ge("ZodGUID",(t,e)=>{iW.init(t,e),rn.init(t,e)}),yg=ge("ZodUUID",(t,e)=>{rW.init(t,e),rn.init(t,e)}),RJ=ge("ZodURL",(t,e)=>{oW.init(t,e),rn.init(t,e)}),QJ=ge("ZodEmoji",(t,e)=>{aW.init(t,e),rn.init(t,e)}),AJ=ge("ZodNanoID",(t,e)=>{lW.init(t,e),rn.init(t,e)}),PJ=ge("ZodCUID",(t,e)=>{cW.init(t,e),rn.init(t,e)}),jJ=ge("ZodCUID2",(t,e)=>{uW.init(t,e),rn.init(t,e)}),MJ=ge("ZodULID",(t,e)=>{dW.init(t,e),rn.init(t,e)}),DJ=ge("ZodXID",(t,e)=>{fW.init(t,e),rn.init(t,e)}),NJ=ge("ZodKSUID",(t,e)=>{hW.init(t,e),rn.init(t,e)}),zJ=ge("ZodIPv4",(t,e)=>{yW.init(t,e),rn.init(t,e)}),LJ=ge("ZodIPv6",(t,e)=>{vW.init(t,e),rn.init(t,e)}),ZJ=ge("ZodCIDRv4",(t,e)=>{bW.init(t,e),rn.init(t,e)}),IJ=ge("ZodCIDRv6",(t,e)=>{SW.init(t,e),rn.init(t,e)}),XJ=ge("ZodBase64",(t,e)=>{xW.init(t,e),rn.init(t,e)}),VJ=ge("ZodBase64URL",(t,e)=>{kW.init(t,e),rn.init(t,e)}),BJ=ge("ZodE164",(t,e)=>{CW.init(t,e),rn.init(t,e)}),UJ=ge("ZodJWT",(t,e)=>{$W.init(t,e),rn.init(t,e)}),qJ=ge("ZodBoolean",(t,e)=>{TW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>XK(t,n,i)});function QE(t){return SK(qJ,t)}const YJ=ge("ZodUnknown",(t,e)=>{EW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>BK()});function AE(){return xK(YJ)}const FJ=ge("ZodNever",(t,e)=>{RW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>VK(t,n,i)});function GJ(t){return wK(FJ,t)}const HJ=ge("ZodArray",(t,e)=>{QW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>FK(t,n,i,r),t.element=e.element,HO(t,"ZodArray",{min(n,i){return this.check(Cm(n,i))},nonempty(n){return this.check(Cm(1,n))},max(n,i){return this.check(tN(n,i))},length(n,i){return this.check(nN(n,i))},unwrap(){return this.element}})});function WJ(t,e){return MK(HJ,t,e)}const KJ=ge("ZodObject",(t,e)=>{PW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>GK(t,n,i,r),Lt(t,"shape",()=>e.shape),HO(t,"ZodObject",{keyof(){return iee(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:AE()})},loose(){return this.clone({...this._zod.def,catchall:AE()})},strict(){return this.clone({...this._zod.def,catchall:GJ()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return eH(this,n)},safeExtend(n){return tH(this,n)},merge(n){return nH(this,n)},pick(n){return KG(this,n)},omit(n){return JG(this,n)},partial(...n){return iH(lN,this,n[0])},required(...n){return rH(cN,this,n[0])}})});function j1(t,e){const n={type:"object",shape:t??{},...He(e)};return new KJ(n)}const JJ=ge("ZodUnion",(t,e)=>{jW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>HK(t,n,i,r),t.options=e.options});function eee(t,e){return new JJ({type:"union",options:t,...He(e)})}const tee=ge("ZodIntersection",(t,e)=>{MW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>WK(t,n,i,r)});function nee(t,e){return new tee({type:"intersection",left:t,right:e})}const tx=ge("ZodEnum",(t,e)=>{DW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(i,r,s)=>UK(t,i,r),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(i,r)=>{const s={};for(const o of i)if(n.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new tx({...e,checks:[],...He(r),entries:s})},t.exclude=(i,r)=>{const s={...e.entries};for(const o of i)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new tx({...e,checks:[],...He(r),entries:s})}});function iee(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new tx({type:"enum",entries:n,...He(e)})}const ree=ge("ZodTransform",(t,e)=>{NW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>YK(t,n),t._zod.parse=(n,i)=>{if(i.direction==="backward")throw new XD(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Df(s,n.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(Df(o))}};const r=e.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=r,n.fallback=!0,n)}});function see(t){return new ree({type:"transform",transform:t})}const lN=ge("ZodOptional",(t,e)=>{eN.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>oN(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function PE(t){return new lN({type:"optional",innerType:t})}const oee=ge("ZodExactOptional",(t,e)=>{zW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>oN(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function aee(t){return new oee({type:"optional",innerType:t})}const lee=ge("ZodNullable",(t,e)=>{LW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>KK(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function jE(t){return new lee({type:"nullable",innerType:t})}const cee=ge("ZodDefault",(t,e)=>{ZW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>eJ(t,n,i,r),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function uee(t,e){return new cee({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():UD(e)}})}const dee=ge("ZodPrefault",(t,e)=>{IW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>tJ(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function fee(t,e){return new dee({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():UD(e)}})}const cN=ge("ZodNonOptional",(t,e)=>{XW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>JK(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function hee(t,e){return new cN({type:"nonoptional",innerType:t,...He(e)})}const pee=ge("ZodCatch",(t,e)=>{VW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>nJ(t,n,i,r),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function gee(t,e){return new pee({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const mee=ge("ZodPipe",(t,e)=>{BW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>iJ(t,n,i,r),t.in=e.in,t.out=e.out});function ME(t,e){return new mee({type:"pipe",in:t,out:e})}const Oee=ge("ZodReadonly",(t,e)=>{UW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>rJ(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function yee(t){return new Oee({type:"readonly",innerType:t})}const vee=ge("ZodCustom",(t,e)=>{qW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>qK(t,n)});function bee(t,e={}){return DK(vee,t,e)}function See(t,e){return NK(t,e)}function xee({className:t,...e}){return m.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:m.jsx("table",{"data-slot":"table",className:yt("w-full caption-bottom text-sm",t),...e})})}function wee({className:t,...e}){return m.jsx("thead",{"data-slot":"table-header",className:yt("[&_tr]:border-b",t),...e})}function kee({className:t,...e}){return m.jsx("tbody",{"data-slot":"table-body",className:yt("[&_tr:last-child]:border-0",t),...e})}function DE({className:t,...e}){return m.jsx("tr",{"data-slot":"table-row",className:yt("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),...e})}function NE({className:t,...e}){return m.jsx("th",{"data-slot":"table-head",className:yt("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}function Cee({className:t,...e}){return m.jsx("td",{"data-slot":"table-cell",className:yt("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}function _ee({header:t}){const e=t.column.getIsSorted();return t.column.getCanSort()?m.jsx(NE,{"data-sort":e||void 0,"aria-sort":e==="asc"?"ascending":e==="desc"?"descending":"none",children:m.jsxs("button",{type:"button",className:"th-sort",onClick:t.column.getToggleSortingHandler(),children:[YS(t.column.columnDef.header,t.getContext()),e==="asc"?" ↑":e==="desc"?" ↓":""]})}):m.jsx(NE,{children:YS(t.column.columnDef.header,t.getContext())})}function uN({table:t,className:e}){return m.jsx("div",{className:"admin-list admin-card-table"+(e?" "+e:""),children:m.jsxs(xee,{className:"admin-table",children:[m.jsx(wee,{children:t.getHeaderGroups().map(n=>m.jsx(DE,{children:n.headers.map(i=>m.jsx(_ee,{header:i},i.id))},n.id))}),m.jsx(kee,{children:t.getRowModel().rows.map(n=>m.jsx(DE,{className:"admin-item",children:n.getVisibleCells().map(i=>m.jsx(Cee,{children:YS(i.column.columnDef.cell,i.getContext())},i.id))},n.id))})]})})}function dN(t){return t?"expires "+new Date(t).toLocaleDateString():"no expiry"}function $ee(t){if(t.opens===void 0)return null;if(t.opens===0)return"not opened yet";const e=`${t.opens} open${t.opens===1?"":"s"}`;return t.last_opened?`${e} · last opened ${new Date(t.last_opened).toLocaleDateString()}`:e}function fN(t,e){const n=[];e&&t.project_name&&n.push(t.project_name),t.creator&&n.push("by "+t.creator),t.created&&n.push(new Date(t.created).toLocaleDateString()),n.push(dN(t.expires));const i=$ee(t);return i&&n.push(i),n.join(" · ")}const hN="Opens count how many times a file has been read through a public link. Repeat opens from the same browser and network within 10 minutes count once — two people on one network using the same browser still count as one.";function pN({shares:t,onChanged:e,showProject:n=!1,canRevoke:i=!0,empty:r="No public shares.",loading:s=!1}){const[o,l]=w.useState([]),u=w.useMemo(()=>mD(),[]),f=w.useMemo(()=>[u.accessor("path",{header:"Path",cell:p=>m.jsx("a",{className:"ai-main mono",title:p.getValue(),...Cl(Yr(p.getValue(),p.row.original.project)),children:p.getValue()})}),u.accessor(p=>fN(p,n),{id:"detail",header:n?"Project":"Shared",cell:p=>m.jsx("span",{className:"ai-tag",children:p.getValue()})}),u.display({id:"actions",header:"",cell:p=>m.jsxs("span",{className:"share-acts",children:[m.jsx("button",{className:"ai-btn","aria-label":`Copy the public link to ${p.row.original.path}`,title:"Copy link",onClick:()=>zs(p.row.original.url).then(O=>Be(O?"Copied.":"Select and copy the link.")),children:m.jsx(st,{name:"copy"})}),i&&m.jsx("button",{className:"ai-del","aria-label":`Revoke the share of ${p.row.original.path}`,onClick:()=>gN(p.row.original,e),children:"Revoke"})]})})],[u,e,n,i]),h=TD({data:t,columns:f,state:{sorting:o},onSortingChange:l,getCoreRowModel:_D(),getSortedRowModel:$D()});return s?m.jsx("div",{className:"admin-list",children:m.jsx("div",{className:"admin-empty",children:"Loading…"})}):t.length===0?m.jsx("div",{className:"admin-list",children:m.jsx("div",{className:"admin-empty",children:r})}):m.jsx(uN,{table:h,className:"shares-table"})}async function gN(t,e){if(await kl("Revoke share link",`Revoke the public link to “${t.path}”? Anyone with the URL will lose access.`,"Revoke",!0))try{await di("DELETE","/api/shares/"+t.token),Be("Share revoked."),e()}catch(n){Be(n.message,!0)}}const Tee=j1({name:Yg().trim().min(1,"Give the organization a name.").max(60,"Keep it under 60 characters.")});function Eee({org:t,projects:e,myEmail:n}){const i=fr(),r=t.role==="owner",s=()=>i.invalidateQueries({queryKey:["orgs"]}),o=()=>i.invalidateQueries({queryKey:["invites",t.id]}),l=()=>i.invalidateQueries({queryKey:["orgShares",t.id]}),u=C1({resolver:P1(Tee),values:{name:t.name}}),{data:f}=nn({queryKey:["invites",t.id],queryFn:()=>Wt(`/api/orgs/${t.id}/invites`),enabled:r,select:y=>y.invites||[]}),{data:h,isLoading:p}=nn({queryKey:["orgShares",t.id],queryFn:()=>Wt(`/api/orgs/${t.id}/shares`),enabled:r,select:y=>y.shares||[]}),O=e.filter(y=>y.org===t.id);return m.jsxs("div",{className:"admin",children:[m.jsx("h1",{id:"org-title",children:t.name}),!r&&m.jsx("p",{className:"role-chip-row",children:m.jsx("span",{className:"ai-tag role-chip",children:"Member"})}),!r&&m.jsx("p",{className:"admin-sub",children:"Only owners can rename this organization, manage members, or issue invite links."}),r&&m.jsxs("form",{className:"admin-row",onSubmit:u.handleSubmit(async({name:y})=>{try{await di("PATCH","/api/orgs/"+t.id,{name:y}),Be("Renamed."),s()}catch(v){Be(v.message,!0)}}),children:[m.jsx("label",{className:"admin-lbl",htmlFor:"org-rename",children:"Organization name"}),m.jsx("input",{id:"org-rename",type:"text","aria-invalid":!!u.formState.errors.name,"aria-describedby":u.formState.errors.name?"org-rename-err":void 0,...u.register("name")}),m.jsx(at,{variant:"subtle",id:"org-rename-btn",type:"submit",disabled:!u.formState.isDirty,children:"Rename org"}),u.formState.errors.name&&m.jsx("span",{id:"org-rename-err",role:"alert",className:"field-err",children:u.formState.errors.name.message})]}),m.jsx("h3",{children:"Members"}),m.jsx(Ree,{org:t,owner:r,myEmail:n,onChanged:s}),m.jsx("h3",{children:"Projects"}),m.jsxs("div",{className:"admin-list",children:[O.length===0&&m.jsx("div",{className:"admin-empty",children:"No projects yet."}),O.map(y=>m.jsx("div",{className:"admin-item",children:m.jsx("span",{className:"ai-main",title:y.name,children:y.name})},y.id))]}),r&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"admin-h",children:[m.jsx("h3",{children:"Invite links"}),m.jsx(at,{variant:"primary",onClick:async()=>{try{const y=await Wr(`/api/orgs/${t.id}/invites`),v=await zs(y.url);Be(v?"Invite link copied to clipboard.":"Invite created — copy it from the list below."),o()}catch(y){Be(y.message,!0)}},children:"New invite"})]}),m.jsxs("div",{className:"admin-list",children:[f&&f.length===0&&m.jsx("div",{className:"admin-empty",children:"No active invite links."}),(f||[]).map(y=>m.jsxs("div",{className:"admin-item",children:[m.jsx("button",{type:"button",className:"ai-main mono ai-copy","aria-label":`Copy invite link ${y.url}`,title:y.url,onClick:()=>zs(y.url).then(v=>Be(v?"Copied.":"Select and copy the link.")),children:y.url}),m.jsx("span",{className:"ai-tag",children:(y.creator?"by "+y.creator+" · ":"")+(y.uses?y.uses+" joined · ":"unused · ")+"expires "+new Date(y.expires).toLocaleDateString()}),m.jsx("button",{className:"ai-del","aria-label":`Revoke invite ${y.token.slice(0,8)}`,onClick:async()=>{if(await kl("Revoke invite",`Revoke the link starting ${y.token.slice(0,8)}…? Anyone still holding it won't be able to join.`,"Revoke",!0))try{await di("DELETE",`/api/orgs/${t.id}/invites/${y.token}`),Be("Revoked."),o()}catch(v){Be(v.message,!0)}},children:"Revoke"})]},y.token))]}),m.jsx("h3",{children:"Public share links"}),m.jsx("p",{className:"admin-sub",children:"Every live link across this organization's projects. A project's own links are on its Settings page, and on the file itself."}),m.jsx(pN,{shares:h||[],loading:p,onChanged:l,showProject:!0})]})]})}function Ree({org:t,owner:e,myEmail:n,onChanged:i}){const[r,s]=w.useState([{id:"email",desc:!1}]),o=w.useMemo(()=>mD(),[]),l=w.useMemo(()=>[o.accessor("email",{id:"email",header:"Member",cell:f=>{const h=!!n&&f.getValue().toLowerCase()===n.toLowerCase();return m.jsx("span",{className:"ai-main",title:f.getValue(),children:f.getValue()+(h?" (you)":"")})}}),o.accessor("role",{id:"role",header:"Role",cell:f=>{const h=f.row.original,p=!!n&&h.email.toLowerCase()===n.toLowerCase();return!e||p?m.jsx("span",{className:"ai-tag role-static",children:h.role}):m.jsxs("span",{className:"role-cell",children:[m.jsxs("select",{"aria-label":`Role for ${h.email}`,value:h.role,onChange:async O=>{try{await di("PATCH",`/api/orgs/${t.id}/members/${encodeURIComponent(h.email)}`,{role:O.target.value}),Be("Role updated.")}catch(y){Be(y.message,!0)}i()},children:[m.jsx("option",{value:"owner",children:"owner"}),m.jsx("option",{value:"member",children:"member"})]}),m.jsx("button",{className:"ai-del","aria-label":`Remove ${h.email}`,onClick:async()=>{if(await kl("Remove member",`Remove ${h.email} from ${t.name}?`,"Remove",!0))try{await di("DELETE",`/api/orgs/${t.id}/members/${encodeURIComponent(h.email)}`),Be("Removed."),i()}catch(O){Be(O.message,!0)}},children:"Remove"})]})}})],[o,t.id,t.name,e,n]),u=TD({data:t.members,columns:l,state:{sorting:r},onSortingChange:s,getCoreRowModel:_D(),getSortedRowModel:$D()});return m.jsx(uN,{table:u})}const Qee=j1({require_verification:QE(),require_approval:QE()});function Aee(){const t=fr(),{data:e,error:n}=nn({queryKey:["admin","policy"],queryFn:()=>Wt("/api/admin/policy")}),{data:i}=cD(!0),r=C1({resolver:P1(Qee),values:e?{require_verification:e.require_verification&&e.mailer,require_approval:e.require_approval}:{require_verification:!1,require_approval:!1}});if(w.useEffect(()=>{n&&Be(n.message,!0)},[n]),!e)return null;const s=async(o,l,u)=>{try{await Wr(`/api/admin/pending/${o}/${l}`),Be((l==="approve"?"Approved ":"Denied ")+u),t.invalidateQueries({queryKey:["admin","pending"]})}catch(f){Be(f.message,!0)}};return m.jsxs("div",{className:"admin",children:[m.jsx("h1",{children:"Signup & access"}),m.jsx("p",{className:"admin-sub",children:"Who can create an account on this hub, and how new accounts are vetted."}),m.jsx("h3",{children:"New-account vetting"}),m.jsxs("form",{onSubmit:r.handleSubmit(async o=>{try{await Wr("/api/admin/policy",o),Be("Signup policy saved."),t.invalidateQueries({queryKey:["admin","policy"]})}catch(l){Be(l.message,!0)}}),children:[m.jsxs("div",{className:"admin-list",children:[m.jsx(zE,{label:"Require email verification",desc:e.mailer?"New accounts must click an emailed link before they can sign in — proves they control the address.":"Configure SMTP on the server (auth.smtp) to enable email verification.",disabled:!e.mailer,inputProps:r.register("require_verification")}),m.jsx(zE,{label:"Require admin approval",desc:"New accounts wait for a hub admin to approve them before they gain access.",inputProps:r.register("require_approval")})]}),m.jsx(at,{variant:"primary",type:"submit",style:{marginTop:14},disabled:!r.formState.isDirty,children:"Save policy"})]}),m.jsx("h3",{children:"Who can sign up"}),m.jsxs("div",{className:"admin-list",children:[m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"ai-main",children:"Allowed email domains"}),m.jsx("span",{className:"ai-tag",children:e.allowed_domains&&e.allowed_domains.length?e.allowed_domains.map(o=>"@"+o).join(", "):"any"})]}),m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"ai-main",children:"Self-signup"}),m.jsx("span",{className:"ai-tag",children:e.allow_signup?"open":"invite-only"})]}),m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"ai-main",children:"Hub admins"}),m.jsx("span",{className:"ai-tag",children:e.admins&&e.admins.length?e.admins.join(", "):"none"})]})]}),m.jsx("p",{className:"admin-sub",children:"Domains and admins are set in the server config file (they can't be widened from the browser)."}),m.jsx("h3",{children:"Pending signups"}),m.jsxs("div",{className:"admin-list",children:[(!i||i.length===0)&&m.jsx("div",{className:"admin-empty",children:"No one is waiting for approval."}),(i||[]).map(o=>m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"ai-main",children:(o.name?o.name+" · ":"")+o.email}),m.jsx(at,{variant:"primary",onClick:()=>s(o.id,"approve",o.email),children:"Approve"}),m.jsx("button",{className:"ai-del",onClick:()=>s(o.id,"deny",o.email),children:"Deny"})]},o.id))]})]})}function zE({label:t,desc:e,disabled:n,inputProps:i}){return m.jsxs("label",{className:"admin-item toggle",style:n?{opacity:.55}:void 0,children:[m.jsxs("span",{className:"ai-main",children:[m.jsx("div",{className:"tg-label",children:t}),m.jsx("div",{className:"tg-desc",children:e})]}),m.jsx("input",{type:"checkbox",disabled:n,...i})]})}function Qs({className:t,...e}){return m.jsx("div",{"data-slot":"card",className:yt("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...e})}function As({className:t,...e}){return m.jsx("div",{"data-slot":"card-header",className:yt("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...e})}function Ps({className:t,...e}){return m.jsx("div",{"data-slot":"card-title",className:yt("leading-none font-semibold",t),...e})}function Sa({className:t,...e}){return m.jsx("div",{"data-slot":"card-description",className:yt("text-muted-foreground text-sm",t),...e})}function wo({className:t,...e}){return m.jsx("div",{"data-slot":"card-content",className:yt("px-6",t),...e})}function LE(t){if(!t||t.startsWith("0001-"))return"never";const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function Pee({projects:t}){const e=fr(),n=nn({queryKey:["mcp","grants"],queryFn:()=>Wt("/api/mcp/grants")}),i=YX({mutationFn:o=>di("DELETE",`/api/mcp/grants/${encodeURIComponent(o)}`),onSuccess:()=>{Be("Disconnected. The agent's access stopped immediately."),e.invalidateQueries({queryKey:["mcp","grants"]})},onError:o=>Be(o.message,!0)}),r=o=>t.find(l=>l.id===o)?.name||o;if(n.isLoading)return m.jsx("div",{className:"empty",children:"Loading…"});if(n.error)return m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"Connections are unavailable"}),m.jsx("p",{children:n.error.message})]});const s=n.data?.grants??[];return m.jsxs("div",{className:"project-settings",id:"mcp-connections",children:[m.jsx("h2",{children:"Connected agents"}),m.jsxs("p",{className:"admin-sub",children:["Agents you have connected to this hub over"," ",m.jsx("a",{href:"https://modelcontextprotocol.io",target:"_blank",rel:"noreferrer",children:"MCP"}),". Each one reads and changes files in the projects you chose, acting as you — so its changes appear in History under your name, and it can never do more than you can."]}),s.length===0?m.jsx(Qs,{children:m.jsxs(As,{children:[m.jsx(Ps,{children:"No agents connected"}),m.jsxs(Sa,{children:["Point an MCP client (Claude, ChatGPT, Cursor, …) at"," ",m.jsxs("code",{children:[window.location.origin,"/mcp"]}),". It will send you back here to pick which projects it may use."]})]})}):s.map(o=>m.jsxs(Qs,{className:"mcp-grant",children:[m.jsxs(As,{children:[m.jsx(Ps,{children:o.client_name||"Unnamed client"}),m.jsxs(Sa,{children:["Connected ",LE(o.created)," · last used ",LE(o.last_used)]})]}),m.jsxs(wo,{children:[m.jsx("div",{className:"mcp-projects",children:o.projects.map(l=>m.jsx("span",{className:"ps-chip",children:r(l)},l))}),m.jsx(at,{variant:"destructive",disabled:i.isPending,onClick:()=>{i.mutate(o.id)},children:"Disconnect"})]})]},o.id))]})}function jee({...t}){return m.jsx(jj,{"data-slot":"select",...t})}function Mee({...t}){return m.jsx(zj,{"data-slot":"select-value",...t})}function Dee({className:t,size:e="default",children:n,...i}){return m.jsxs(Dj,{"data-slot":"select-trigger","data-size":e,className:yt("flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...i,children:[n,m.jsx(Lj,{asChild:!0,children:m.jsx(c1,{className:"size-4 opacity-50"})})]})}function Nee({className:t,children:e,position:n="item-aligned",align:i="center",...r}){return m.jsx(Ij,{children:m.jsxs(Xj,{"data-slot":"select-content",className:yt("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,align:i,...r,children:[m.jsx(Lee,{}),m.jsx(Yj,{className:yt("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),m.jsx(Zee,{})]})})}function zee({className:t,children:e,...n}){return m.jsxs(Wj,{"data-slot":"select-item",className:yt("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[m.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:m.jsx(eM,{children:m.jsx(BM,{className:"size-4"})})}),m.jsx(Kj,{children:e})]})}function Lee({className:t,...e}){return m.jsx(tM,{"data-slot":"select-scroll-up-button",className:yt("flex cursor-default items-center justify-center py-1",t),...e,children:m.jsx(Jq,{className:"size-4"})})}function Zee({className:t,...e}){return m.jsx(nM,{"data-slot":"select-scroll-down-button",className:yt("flex cursor-default items-center justify-center py-1",t),...e,children:m.jsx(c1,{className:"size-4"})})}const ZE=["#5b8def","#f5a623","#4cc38a","#e0679b","#8b7bf0","#3ec8c8","#e6934a"];function wu(t){let e=0;for(const n of t)e=e*31+n.charCodeAt(0)>>>0;return ZE[e%ZE.length]}function fb({projects:t,currentId:e,menu:n,onNew:i}){const r=t.find(s=>s.id===e);return m.jsxs("nav",{id:"projects","aria-label":"Projects",children:[m.jsxs("div",{className:"nav-head",children:[m.jsx("span",{children:"Projects"}),m.jsx("button",{className:"nav-add",title:"New project","aria-label":"New project",onClick:i,children:"+"})]}),m.jsx("div",{className:"proj-row",children:m.jsxs(jee,{value:e||"",onValueChange:s=>{s&&s!==e&&(zt("/"+s),Fr())},children:[m.jsxs(Dee,{id:"project-select","aria-label":`Switch project — current: ${r?.name??"none"}`,title:r?.name,className:"proj-trigger",children:[r&&m.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:wu(r.name)},children:m.jsx(iu,{name:r.icon})}),r?m.jsx("span",{"data-slot":"select-value",children:r.name}):m.jsx(Mee,{placeholder:"Select a project"})]}),m.jsx(Nee,{className:"proj-menu",position:"popper",sideOffset:4,children:t.map(s=>m.jsxs(zee,{value:s.id,children:[m.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:wu(s.name)},children:m.jsx(iu,{name:s.icon})}),s.name]},s.id))})]})}),n&&m.jsx("ul",{className:"nav-menu","aria-label":"Project pages",children:[["dashboard","Dashboard","dashboard",n.onDashboard],["install","Installation","terminal",n.onInstall],["history","History","hist",n.onHistory],["settings","Settings","gear",n.onSettings]].map(([s,o,l,u])=>m.jsx("li",{children:m.jsxs("div",{id:"nav-"+s,className:"row"+(n.active===s?" active":""),role:"button",tabIndex:0,onClick:u,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),u())},children:[m.jsx(st,{name:l}),m.jsx("span",{className:"label",children:o})]})},s))})]})}function mN({...t}){return m.jsx(wU,{"data-slot":"dropdown-menu",...t})}function ON({...t}){return m.jsx(kU,{"data-slot":"dropdown-menu-trigger",...t})}function yN({className:t,sideOffset:e=4,...n}){return m.jsx(CU,{children:m.jsx(_U,{"data-slot":"dropdown-menu-content",sideOffset:e,className:yt("z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",t),...n})})}function ua({className:t,inset:e,variant:n="default",...i}){return m.jsx(TU,{"data-slot":"dropdown-menu-item","data-inset":e,"data-variant":n,className:yt("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",t),...i})}function hb({className:t,inset:e,...n}){return m.jsx($U,{"data-slot":"dropdown-menu-label","data-inset":e,className:yt("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})}const Iee="https://github.com/runbear-io/beardrive";function Xee(){return m.jsx("svg",{viewBox:"0 0 16 16",className:"gh-mark",fill:"currentColor","aria-hidden":"true",children:m.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})}function vN(){return m.jsxs("a",{className:"gh-star",href:Iee,target:"_blank",rel:"noreferrer",children:[m.jsx(Xee,{}),m.jsx("span",{children:"Star on GitHub"}),m.jsx("span",{className:"ext","aria-hidden":"true",children:"↗"}),m.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})}function Vee({me:t,org:e,admin:n,orgActive:i,billing:r,mcp:s,signOut:o}){const l=t.name||t.email,[u,f]=w.useState(!1),h=e?Cl(e.manage_url):null,p=r?Cl(r.url):null,O=Cl("/connections");return m.jsxs("footer",{id:"accountbar",children:[m.jsx(vN,{}),m.jsxs(mN,{modal:!1,open:u,onOpenChange:f,children:[m.jsx(ON,{asChild:!0,children:m.jsxs("button",{id:"account-btn",className:i?"active":void 0,"aria-label":"Account menu",children:[m.jsx("span",{className:"avatar",style:{background:wu(t.email)},"aria-hidden":"true",children:(l.trim()[0]||"?").toUpperCase()}),m.jsxs("span",{className:"acct",children:[m.jsx("b",{children:l}),t.name&&m.jsx("small",{children:t.email})]}),m.jsx(st,{name:"chev"})]})}),m.jsxs(yN,{id:"account-menu",side:"top",align:"start",sideOffset:6,className:"acct-menu",children:[e&&m.jsxs(m.Fragment,{children:[m.jsx(hb,{className:"menu-sec",children:"Organization"}),m.jsx(ua,{asChild:!0,children:m.jsxs("a",{id:"menu-org-settings","aria-current":i?"page":void 0,...h,onClick:y=>{h?.onClick?.(y),f(!1)},children:[m.jsx(st,{name:"gear"}),m.jsxs("span",{children:[m.jsx("b",{children:e.name})," Settings"]}),!e.manage_url.startsWith("/")&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"ext","aria-hidden":"true",children:"↗"}),m.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})]})}),r&&m.jsx(ua,{asChild:!0,children:m.jsxs("a",{id:"menu-billing",...p,onClick:y=>{p?.onClick?.(y),f(!1)},children:[m.jsx(st,{name:"card"}),m.jsx("span",{children:"Billing"}),m.jsx("span",{className:"ps-chip plan-chip",children:r.plan})]})})]}),n&&m.jsxs(m.Fragment,{children:[m.jsx(hb,{className:"menu-sec",children:"Hub"}),m.jsxs(ua,{id:"menu-hub-admin",onSelect:n.onClick,children:[m.jsx(st,{name:"shield"}),m.jsxs("span",{children:["Signup & access",n.pending?` · ${n.pending}`:""]})]})]}),m.jsx(hb,{className:"menu-sec",children:"Account"}),s&&m.jsx(ua,{asChild:!0,children:m.jsxs("a",{id:"menu-connections",...O,onClick:y=>{O.onClick?.(y),f(!1)},children:[m.jsx(st,{name:"plug"}),m.jsx("span",{children:"Connected agents"})]})}),o?m.jsxs(ua,{id:"signout",onSelect:o,children:[m.jsx(st,{name:"power"}),m.jsx("span",{children:"Sign out"})]}):m.jsx(ua,{asChild:!0,children:m.jsxs("a",{id:"signout",href:"/auth/logout",children:[m.jsx(st,{name:"power"}),m.jsx("span",{children:"Log out"})]})})]})]})]})}function Bee({onSignIn:t}){return m.jsxs("footer",{id:"accountbar",children:[m.jsx(vN,{}),m.jsxs("button",{id:"account-btn",onClick:t,"aria-label":"Sign in",children:[m.jsx("span",{className:"avatar",style:{background:"var(--hover)"},"aria-hidden":"true",children:"?"}),m.jsxs("span",{className:"acct",children:[m.jsx("b",{children:"Sign in…"}),m.jsx("small",{children:"connect to your hub"})]})]})]})}function yo({className:t,orientation:e="horizontal",decorative:n=!0,...i}){return m.jsx(s9,{"data-slot":"separator",decorative:n,orientation:e,className:yt("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...i})}function Uee({url:t}){const e=nn({queryKey:["billing"],queryFn:()=>Wt(t)});if(e.isLoading)return m.jsx("div",{className:"empty",children:"Loading…"});if(e.error||!e.data)return m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"Billing is unavailable"}),m.jsx("p",{children:e.error?.message||"Try again shortly."})]});const n=e.data;return m.jsxs("div",{className:"project-settings",id:"billing-view",children:[m.jsxs("h2",{children:["Billing",m.jsx("span",{className:"ps-chip plan-chip",children:n.plan.name})]}),m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsxs(Ps,{children:[n.plan.name," plan",n.plan.status?` (${n.plan.status})`:""]}),m.jsxs(Sa,{children:["Organization ",n.org," · ",n.usage.used," of ",n.usage.cap," used · ",n.seats.used," of ",n.seats.cap," ",n.seats.cap===1?"seat":"seats"]})]}),m.jsx(yo,{}),m.jsx(wo,{children:m.jsx("div",{className:"usage-bar",children:m.jsx("div",{style:{width:`${n.usage.pct}%`}})})})]}),n.owner?m.jsx("div",{className:"plan-grid",children:n.plans.map(i=>m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsx(Ps,{children:i.name}),m.jsx(Sa,{children:i.blurb})]}),m.jsx(yo,{}),m.jsxs(wo,{children:[m.jsxs("p",{className:"plan-price",children:[i.price,m.jsx("small",{children:" / user / month"})]}),m.jsxs("form",{method:"post",action:n.checkout_url,children:[m.jsx("input",{type:"hidden",name:"plan",value:i.id}),m.jsx(at,{type:"submit",disabled:i.current,variant:i.current?"subtle":"default",children:i.current?"Current plan":`Upgrade to ${i.name}`})]})]})]},i.id))}):m.jsx("p",{className:"muted-note",children:"Only an organization owner can change the plan."}),n.owner&&n.has_customer&&m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsx(Ps,{children:"Manage subscription"}),m.jsx(Sa,{children:"Change seats, update the card, download invoices, or cancel."})]}),m.jsx(yo,{}),m.jsx(wo,{children:m.jsx("form",{method:"post",action:n.portal_url,children:m.jsx(at,{type:"submit",variant:"subtle",children:"Open the billing portal"})})})]})]})}function Fg({className:t,type:e,...n}){return m.jsx("input",{type:e,"data-slot":"input",className:yt("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30","focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",t),...n})}function pb({className:t,...e}){return m.jsx(RU,{"data-slot":"label",className:yt("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}function qee({className:t,...e}){return m.jsx("textarea",{"data-slot":"textarea",className:yt("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...e})}const IE={read:1,write:2,admin:3};function _s(t,e){return(IE[t||""]||0)>=(IE[e]||0)}const nx=280,Yee=j1({name:Yg().trim().min(1,"Give the project a name.").max(120,"Keep the name under 120 characters."),description:Yg().max(nx,`Keep the description under ${nx} characters.`),icon:Yg()});function Fee({project:t,org:e,onDeleted:n}){const i=uD(),r=_s(t.perm,"admin"),s=C1({resolver:P1(Yee),defaultValues:{name:t.name,description:t.description??"",icon:t.icon??""}});w.useEffect(()=>{s.reset({name:t.name,description:t.description??"",icon:t.icon??""})},[t.id,t.name,t.description,t.icon]);const o=s.watch("icon"),l=s.watch("description"),u=s.handleSubmit(async f=>{const h=s.formState.dirtyFields,p={};if(h.name&&(p.name=f.name.trim()),h.description&&(p.description=f.description),h.icon&&(p.icon=f.icon),Object.keys(p).length!==0)try{await di("PATCH","/api/projects/"+t.id,p),Be("Saved."),s.reset({...f,name:f.name.trim()}),await i()}catch(O){Be(O.message,!0)}});return m.jsxs("div",{className:"project-settings",children:[m.jsxs("h2",{children:[t.name,!_s(t.perm,"write")&&m.jsx("span",{className:"ps-chip",children:"Read-only"})]}),m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsx(Ps,{children:"General"}),m.jsx(Sa,{children:"Name, description and icon for this project."})]}),m.jsx(yo,{}),m.jsx(wo,{children:m.jsxs("form",{className:"ps-form",onSubmit:u,children:[m.jsxs("div",{className:"ps-field",children:[m.jsx(pb,{htmlFor:"ps-icon-btn",children:"Icon"}),m.jsxs("div",{className:"ps-icon-row",children:[m.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:wu(t.name)},children:m.jsx(iu,{name:o})}),m.jsxs(mN,{children:[m.jsx(ON,{asChild:!0,children:m.jsx(at,{id:"ps-icon-btn",type:"button",variant:"subtle",disabled:!r,children:"Change"})}),m.jsxs(yN,{align:"start",className:"ps-icon-grid",children:[m.jsx(ua,{className:"ps-icon-cell"+(o===""?" active":""),title:"Default","aria-label":"Default icon",onSelect:()=>s.setValue("icon","",{shouldDirty:!0}),children:m.jsx(iu,{})}),Object.keys(LS).map(f=>m.jsx(ua,{className:"ps-icon-cell"+(o===f?" active":""),title:f,"aria-label":f,onSelect:()=>s.setValue("icon",f,{shouldDirty:!0}),children:m.jsx(iu,{name:f})},f))]})]})]})]}),m.jsxs("div",{className:"ps-field",children:[m.jsx(pb,{htmlFor:"ps-name",children:"Name"}),m.jsx(Fg,{id:"ps-name",disabled:!r,"aria-invalid":!!s.formState.errors.name,"aria-describedby":s.formState.errors.name?"ps-name-err":void 0,...s.register("name")}),s.formState.errors.name&&m.jsx("span",{id:"ps-name-err",role:"alert",className:"field-err",children:s.formState.errors.name.message})]}),m.jsxs("div",{className:"ps-field",children:[m.jsxs(pb,{htmlFor:"ps-desc",children:["Description ",m.jsx("span",{className:"ps-opt",children:"(optional)"})]}),m.jsx(qee,{id:"ps-desc",rows:2,disabled:!r,placeholder:"What this project is for.","aria-invalid":!!s.formState.errors.description,"aria-describedby":s.formState.errors.description?"ps-desc-err":void 0,...s.register("description")}),m.jsxs("div",{className:"ps-meta",children:[s.formState.errors.description?m.jsx("span",{id:"ps-desc-err",role:"alert",className:"field-err",children:s.formState.errors.description.message}):m.jsx("span",{}),m.jsxs("span",{className:"ps-count",children:[l.length," / ",nx]})]})]}),r&&m.jsxs(m.Fragment,{children:[m.jsx(yo,{}),m.jsx("div",{className:"ps-actions",children:m.jsx(at,{id:"ps-save",type:"submit",variant:"primary",disabled:!s.formState.isDirty||s.formState.isSubmitting,children:"Save changes"})})]})]})})]}),m.jsx(Gee,{project:t}),m.jsx(Wee,{project:t,org:e}),m.jsxs(Qs,{children:[m.jsx(As,{children:m.jsx(Ps,{children:"About"})}),m.jsx(yo,{}),m.jsxs(wo,{children:[m.jsxs("dl",{className:"ps-facts",children:[m.jsx("dt",{children:"Project id"}),m.jsx("dd",{children:m.jsx("code",{children:t.id})}),e&&m.jsxs(m.Fragment,{children:[m.jsx("dt",{children:"Workspace"}),m.jsx("dd",{children:e.name})]}),t.created&&m.jsxs(m.Fragment,{children:[m.jsx("dt",{children:"Created"}),m.jsx("dd",{children:new Date(t.created).toLocaleDateString()})]})]}),m.jsxs("p",{className:"ps-note ps-export",children:[m.jsx("strong",{children:"Take your files elsewhere."})," Run ",m.jsx("code",{children:"bdrive export"})," in the synced folder to write the whole project — every device's journal and every content blob, so full history and authorship — into a single archive. ",m.jsx("code",{children:"bdrive import"})," restores it into any other BearDrive hub, self-hosted or cloud. Export warns first if this device still has changes it hasn't pushed."," ",m.jsx("a",{href:"https://docs.beardrive.ai/reference/migration/",target:"_blank",rel:"noreferrer",children:"How migration works →"})]})]})]}),r&&m.jsxs(Qs,{className:"ps-danger",children:[m.jsx(As,{children:m.jsx(Ps,{children:"Danger zone"})}),m.jsx(yo,{}),m.jsxs(wo,{children:[m.jsx("p",{children:"Deleting removes the project from this hub. Its files stay in storage. This can't be undone."}),m.jsx(at,{variant:"danger",onClick:async()=>{if(await rD(`Delete “${t.name}”?`,"This can't be undone. Type the project name to confirm:","","Delete project",{match:t.name,danger:!0})!==null)try{await di("DELETE","/api/projects/"+t.id),Be(`Deleted “${t.name}”.`),await n()}catch(h){Be(h.message,!0)}},children:"Delete project"})]})]})]})}function Gee({project:t}){const e=fr(),{data:n,error:i,isLoading:r}=lD(t.id);return i?null:m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsx(Ps,{children:"Public links"}),m.jsxs(Sa,{children:["Files in this project that anyone with the URL can read — no account needed.",(n||[]).some(s=>s.opens!==void 0)&&m.jsxs(m.Fragment,{children:[" ",hN]})]})]}),m.jsx(yo,{}),m.jsx(wo,{children:m.jsx(pN,{shares:n||[],loading:r,canRevoke:_s(t.perm,"write"),onChanged:()=>e.invalidateQueries({queryKey:["shares",t.id]}),empty:"No public links."})})]})}const ix=[{value:"admin",label:"Admin"},{value:"write",label:"Write"},{value:"read",label:"Read"},{value:"none",label:"No access"}],Hee=Object.fromEntries(ix.map(t=>[t.value,t.label]));function Wee({project:t,org:e}){const n=fr(),{data:i,error:r}=f1(t.id),s=_s(t.perm,"admin"),o=()=>{n.invalidateQueries({queryKey:["permissions",t.id]}),n.invalidateQueries({queryKey:["projects"]})},l=async(y,v)=>{try{await y(),Be(v)}catch(S){Be(S.message,!0)}o()};if(r||!i)return null;const u=i,f=`/api/p/${t.id}/permissions`,h=new Set((e?.members||[]).filter(y=>y.role==="owner").map(y=>y.email.toLowerCase())),p=[...u.grants.filter(y=>!h.has(y.email.toLowerCase())),...[...h].sort().map(y=>({email:y,level:"admin",owner:!0}))],O=async()=>{const y=await rD("Add an exception","Email of a workspace member. They get Read access; change it in the table.","","Add");y===null||!y.trim()||await l(()=>di("PUT",`${f}/${encodeURIComponent(y.trim())}`,{level:"read"}),"Added.")};return m.jsxs(Qs,{className:"ps-people",children:[m.jsxs(As,{children:[m.jsx(Ps,{children:"People"}),m.jsx(Sa,{children:"Who can see and change this project."})]}),m.jsx(yo,{}),m.jsxs(wo,{children:[e?.role==="owner"&&m.jsxs("p",{className:"ps-row",children:[m.jsxs("span",{children:["Not in ",e.name," yet?"]}),m.jsx(at,{id:"ps-invite",type:"button",variant:"subtle",onClick:async()=>{try{const y=await Wr(`/api/orgs/${e.id}/invites`),v=await zs(y.url+"?p="+t.id);Be(v?"Invite link copied — it opens this project.":"Invite created — copy it from Organization settings.")}catch(y){Be(y.message,!0)}},children:"Invite a teammate"})]}),m.jsxs("p",{className:"ps-row",children:[m.jsxs("span",{children:["Everyone in ",e?.name||"this workspace"," can"]}),m.jsx("select",{"aria-label":"Default access for workspace members",disabled:!s,value:u.default,onChange:async y=>{const v=y.target.value;if(v==="none"&&!await kl("Make this project invite-only?","Only people listed below (and workspace owners) will see this project.","Make invite-only")){o();return}await l(()=>di("PUT",f,{default:v}),"Default access updated.")},children:ix.filter(y=>y.value!=="admin").map(y=>m.jsx("option",{value:y.value,children:y.label},y.value))})]}),u.default==="none"&&m.jsx("p",{className:"ps-note",children:"This project is invite-only: only the people below and workspace owners can see it."}),m.jsxs("div",{className:"ps-people-head",children:[m.jsx("h4",{children:"Exceptions"}),s&&m.jsx(at,{type:"button",variant:"subtle",onClick:O,children:"+ Add"})]}),p.length===0?m.jsx("p",{className:"ps-note",children:"No exceptions — everyone gets the access above."}):m.jsx("div",{className:"admin-list",children:p.map(y=>{const v="owner"in y;return m.jsxs("div",{className:"admin-item",children:[m.jsxs("span",{className:"ai-main",title:y.email,children:[y.email,u.creator&&y.email.toLowerCase()===u.creator.toLowerCase()&&m.jsx("span",{className:"ai-tag",children:" (creator)"})]}),v?m.jsx("span",{className:"ai-tag",children:"Workspace owner — always admin"}):m.jsxs("span",{className:"role-cell",children:[m.jsx("select",{"aria-label":`Access for ${y.email}`,disabled:!s,value:y.level,onChange:S=>l(()=>di("PUT",`${f}/${encodeURIComponent(y.email)}`,{level:S.target.value}),`${y.email} is now ${Hee[S.target.value]||S.target.value}.`),children:ix.map(S=>m.jsx("option",{value:S.value,children:S.label},S.value))}),s&&m.jsx("button",{className:"ai-del","aria-label":`Remove exception for ${y.email}`,onClick:()=>l(()=>di("DELETE",`${f}/${encodeURIComponent(y.email)}`),"Reverted to the default access."),children:"Remove"})]})]},y.email)})})]})]})}const Kee="https://raw.githubusercontent.com/runbear-io/beardrive/main/INSTALL_FOR_AGENTS.md";function M1(t,e={}){const{project:n,folder:i,existing:r}=e,s=n?"BearDrive project "+n.id:i?`the shared ${i}/ folder in my project`:"a new BearDrive project",o=r?"I already have a folder of notes — ask me which one to sync":"Ask me which folder to sync",l=n?` (the project is named "${n.name}")`:"";return`Follow ${Kee} -to set up ${s} on ${t}. ${o}${l}.`}function bN({project:t,existing:e}){const n=window.location.origin,i=M1(n,{project:t,existing:e}),r=`brew install runbear-io/tap/beardrive -bdrive init --server `+n+" --project "+t.id;return m.jsxs("div",{className:"guide",children:[m.jsxs("h1",{className:"in-title gd-head",children:[m.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:wu(t.name)},children:m.jsx(iu,{name:t.icon})}),t.name]}),t.description&&m.jsx("p",{className:"in-desc",children:t.description}),m.jsxs("div",{className:"gd-body",children:[m.jsx("p",{className:"gd-desc",children:e?"Paste into your coding agent — Claude Code, Cowork, Codex, Gemini CLI, Hermes — in the folder you already have:":"Paste into your coding agent — Claude Code, Cowork, Codex, Gemini CLI, Hermes — in the folder where you want the files:"}),e&&m.jsx("p",{className:"gd-note",children:"Your files stay exactly where they are. Connecting a folder never moves, renames or overwrites anything in it — it uploads what is there and keeps it in sync."}),m.jsx($m,{code:i}),m.jsx("p",{className:"gd-desc",children:"The agent installs the CLI, signs this machine in, and registers the sync hooks — asking before anything it changes."}),m.jsx("p",{className:"gd-desc",children:"Runs on macOS and Linux. Windows is not supported yet."}),m.jsxs("details",{className:"gd-manual",children:[m.jsx("summary",{children:"What exactly happens"}),m.jsxs("ul",{className:"gd-desc gd-list",children:[m.jsx("li",{children:"Sign-in uses a device code you approve in this browser — the folder itself never holds credentials."}),m.jsx("li",{children:"Sync hooks pull the latest before every agent turn, push edits seconds after they happen, and stamp each change with the session that made it; agent reads feed Insights. They register once per machine in your agent's own config, so every session is covered and nothing is written into the synced folder."}),m.jsx("li",{children:"Codex hooks are off by default: set [features] codex_hooks = true in ~/.codex/config.toml."})]})]}),m.jsxs("details",{className:"gd-manual",children:[m.jsx("summary",{children:"Or run it yourself"}),m.jsx("p",{className:"gd-desc",children:"Same result, in the folder you want the files. Install the CLI, point it at this hub, then bdrive init registers the sync hooks and starts syncing."}),m.jsx($m,{code:r}),m.jsx("p",{className:"gd-desc",children:m.jsx("a",{href:"https://docs.beardrive.ai/manual/install/",target:"_blank",rel:"noreferrer",children:"Full manual setup guide →"})})]})]})]})}function $m({code:t}){const[e,n]=w.useState("Copy");return m.jsxs("pre",{className:"gd-code",children:[m.jsx("code",{children:t}),m.jsx("button",{className:"gd-copy",onClick:async()=>{n(await zs(t)?"Copied":"Copy failed"),setTimeout(()=>n("Copy"),1400)},children:e})]})}function Jee({onNew:t,canCreate:e}){return m.jsxs("div",{className:"onboard",children:[m.jsx("h1",{children:"Welcome to BearDrive"}),m.jsx("p",{children:"You're signed in, but you're not part of any project yet."}),e&&m.jsxs("div",{className:"ob-card ob-start",children:[m.jsx("h3",{children:"Start a project"}),m.jsx("p",{children:"Name it and pick what it starts from — a structure, or nothing at all. Then connect a folder on any machine and it stays in sync."}),m.jsx(at,{variant:"primary",id:"ob-new",onClick:t,children:"New project"})]}),m.jsxs("div",{className:"ob-card ob-agent",children:[m.jsx("h3",{children:e?"Or let your agent do it":"Connect a new drive to your project"}),m.jsx("p",{children:"Paste into your coding agent — Claude Code, Cowork, Codex, Gemini CLI, Hermes — in the folder where you want the files. It creates the project and starts syncing:"}),m.jsx($m,{code:M1(window.location.origin)}),m.jsx("p",{className:"ob-alt",children:m.jsx("a",{href:"https://docs.beardrive.ai/manual/setup-by-hand/",target:"_blank",rel:"noreferrer",children:"Or start a project manually →"})})]})]})}function ete({onStart:t}){return m.jsxs("div",{className:"onboard setup-welcome",children:[m.jsx("h1",{children:"Welcome to BearDrive"}),m.jsx("p",{children:"One shared drive for your team and your AI agents — every folder you connect stays in sync, with full history."}),m.jsx(at,{variant:"primary",id:"setup-start",onClick:t,children:"Get started"}),m.jsx("p",{className:"setup-foot",children:"Takes about two minutes · works offline afterwards"})]})}function tte({data:t,name:e}){const n=t?.entries??[],i=t?.root_name||"your project";return m.jsxs("div",{className:"setup-tree","aria-label":"How it will look",children:[m.jsx("div",{className:"setup-tree-head",children:"HOW IT WILL LOOK"}),m.jsxs("div",{className:"setup-tree-root",children:[i,"/ ",m.jsx("span",{className:"setup-dim",children:"· private"})]}),n.map(r=>m.jsxs("div",{className:"setup-dim",children:["├── ",r]},r)),t?.entries_truncated&&m.jsx("div",{className:"setup-dim",children:"├── …"}),m.jsxs("div",{className:"setup-tree-shared",children:["└── ",e||"team","/ ",m.jsx("span",{className:"setup-shared-tag",children:"shared"})]}),m.jsxs("p",{className:"setup-tree-foot",children:["Only ",e||"team","/ syncs. Everything else never leaves this Mac. Teammates get the same"," ",e||"team","/ inside their own projects."]})]})}function nte({onStarted:t}){const[e,n]=w.useState(""),[i,r]=w.useState("team"),[s,o]=w.useState(!0),[l,u]=w.useState(null),[f,h]=w.useState(!1),[p,O]=w.useState(""),[y,v]=w.useState(!1),S=w.useCallback(async Q=>{const A=window.__TAURI__?.core?.invoke;if(!(!A||!Q))try{await A("prime_folder_access",{path:Q})}catch{}},[]);w.useEffect(()=>{if(!e){u(null);return}const Q=setTimeout(async()=>{await S(e),Wt(`/api/desktop/inspect?path=${encodeURIComponent(e)}&name=${encodeURIComponent(i)}`).then(u).catch(()=>u(null))},200);return()=>clearTimeout(Q)},[e,i,S]);const k=w.useCallback(async()=>{const Q=await dm("/api/desktop/choose-folder");if(!Q.ok)return;const A=await Q.json();A.path&&(await S(A.path),n(A.path))},[S]),C=w.useCallback(async()=>{h(!0),O("");const Q=await dm("/api/desktop/init",{root:e,name:i,hooks:s});if(h(!1),!Q.ok){O((await Q.text()).trim()||"could not connect that folder");return}t(i)},[e,i,s,t]),$=!!l?.join,T=!e||!!l?.error||!!l?.conflict||f;return m.jsxs("div",{className:"setup-connect",children:[m.jsxs("header",{children:[m.jsxs("h2",{children:["Add a shared folder to your project",!$&&m.jsx("span",{className:"setup-badge",children:"RECOMMENDED"})]}),m.jsxs("p",{children:["Your project stays yours. One folder inside it is shared — your agent reads it in every session."," ",m.jsx("a",{href:"#why",onClick:Q=>(Q.preventDefault(),v(!y)),children:"Why this layout?"})]}),y&&m.jsxs("ul",{className:"setup-why",children:[m.jsx("li",{children:"Claude sessions here read and write it automatically — shared memory, no setup."}),m.jsx("li",{children:"Everything outside it stays on this Mac. Your code never syncs."}),m.jsx("li",{children:"Teammates get the same folder inside their own projects — one shared space."})]})]}),m.jsxs("div",{className:"setup-body",children:[m.jsxs("div",{className:"setup-form",children:[m.jsxs("label",{className:"setup-field",children:[m.jsx("span",{children:"Your project folder"}),m.jsxs("div",{className:"setup-root",children:[m.jsx("input",{id:"setup-root",value:e,spellCheck:!1,placeholder:"/Users/you/work/your-project",onChange:Q=>n(Q.target.value)}),m.jsx("button",{type:"button",id:"setup-choose",onClick:k,children:"Choose…"})]})]}),m.jsxs("label",{className:"setup-field",children:[m.jsx("span",{children:"Shared folder name"}),m.jsx("input",{id:"setup-name",value:i,spellCheck:!1,onChange:Q=>r(Q.target.value)})]}),m.jsxs("label",{className:"setup-toggle",children:[m.jsx("input",{type:"checkbox",id:"setup-hooks",checked:s,onChange:Q=>o(Q.target.checked)}),m.jsx("span",{children:"Claude Code integration"})]}),l?.is_claude_project&&!l?.error&&m.jsxs("p",{className:"setup-ok",children:["Claude Code project detected — ",(l.markers??[]).join(", ")]}),$&&m.jsxs("p",{className:"setup-ok",children:["Your team already shares a “",l.join.name,"” space — you'll join it."]}),(l?.error||l?.conflict||p)&&m.jsx("p",{className:"setup-err",children:p||l?.conflict||l?.error}),l?.warning&&!l?.error&&!l?.conflict&&m.jsxs("div",{className:"setup-warn",children:[m.jsx("p",{children:l.warning}),l.helper&&m.jsxs("p",{className:"setup-helper",children:["Full Disk Access wants this binary:"," ",m.jsx("code",{children:l.helper})," ",m.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(l.helper),children:"Copy path"})]})]}),m.jsx(at,{variant:"primary",id:"setup-go",disabled:T,onClick:C,children:$?`Join ${i}/ and start syncing`:`Create ${i}/ and start syncing`}),m.jsxs("p",{className:"setup-foot",children:["Prefer to share the whole folder?"," ",m.jsx("a",{href:"https://docs.beardrive.ai/manual/setup-by-hand/",target:"_blank",rel:"noreferrer",children:"Advanced"})]})]}),m.jsx(tte,{data:l,name:i})]})]})}function ite({onDone:t}){const e=new URLSearchParams(window.location.search).get("name")||"",[n,i]=w.useState({phase:"creating",name:e}),r=w.useRef(!1);w.useEffect(()=>{const l=setInterval(async()=>{try{const u=await Wt("/api/desktop/init/status");i({...u,name:u.name||e}),!r.current&&(u.phase==="done"||u.phase==="error")&&(r.current=!0,clearInterval(l),u.phase==="done"&&t(u))}catch{}},400);return()=>clearInterval(l)},[t]);const s=["creating","connecting","syncing","done"],o=Math.max(0,s.indexOf(n.phase));return m.jsxs("div",{className:"setup-syncing",children:[m.jsxs("h2",{children:["Syncing ",n.name?n.name+"/":"your folder"]}),m.jsx("div",{className:"setup-bar",children:m.jsx("div",{style:{width:`${(o+1)/s.length*100}%`}})}),m.jsxs("ul",{className:"setup-log",children:[m.jsx("li",{className:o>0?"ok":"",children:"created the shared folder"}),m.jsx("li",{className:o>1?"ok":"",children:n.joined?"joined the project":"created the project"}),m.jsx("li",{className:o>2?"ok":"",children:"first sync"})]}),n.phase==="error"?m.jsx("p",{className:"setup-err",id:"setup-error",children:n.error}):m.jsx("p",{className:"setup-foot",children:"You can close this window — syncing continues from the menu bar."})]})}function rte({st:t}){const[e,n]=w.useState(""),[i,r]=w.useState(!1),[s,o]=w.useState(""),l=t.name||"team",u=M1(window.location.origin,{folder:l}),f=async(p,O)=>{try{await navigator.clipboard.writeText(O),n(p)}catch{n("")}},h=async()=>{r(!0),o("");try{const O=(await Wt("/api/orgs")).orgs[0]?.id;if(!O)throw new Error("no organization on this hub");const y=await dm(`/api/orgs/${O}/invites`,{});if(!y.ok)throw new Error((await y.text()).trim());const v=await y.json();await navigator.clipboard.writeText(v.url),n("invite")}catch(p){o(p.message||"could not create an invite link")}finally{r(!1)}};return m.jsxs("div",{className:"setup-done",children:[m.jsxs("h2",{children:[l,"/ is live"]}),m.jsxs("p",{className:"setup-foot",children:["shared inside ",t.root?t.root.split("/").pop():"your project"," · history from here on"]}),t.error&&m.jsx("p",{className:"setup-err",children:t.error}),m.jsxs("div",{className:"setup-cards",children:[m.jsxs("div",{className:"setup-card",children:[m.jsx("h3",{children:"Open the dashboard"}),m.jsx("p",{children:"Browse files, history, and who reads what."}),m.jsx(at,{id:"setup-open",onClick:()=>zt(t.project?"/"+t.project:"/"),children:"Open"})]}),m.jsxs("div",{className:"setup-card setup-card-lead",children:[m.jsx("h3",{children:"Tell your agent"}),m.jsx("p",{children:"Claude sessions in this folder now share context with your team."}),m.jsx($m,{code:u}),m.jsx(at,{id:"setup-copy-prompt",onClick:()=>f("prompt",u),children:e==="prompt"?"Copied":"Copy prompt"})]}),m.jsxs("div",{className:"setup-card",children:[m.jsx("h3",{children:"Invite teammates"}),m.jsx("p",{children:"A link that signs them up straight into this project."}),m.jsx(at,{id:"setup-invite",disabled:i,onClick:h,children:e==="invite"?"Copied":i?"…":"Copy invite link"}),s&&m.jsx("p",{className:"setup-err",id:"setup-invite-err",children:s})]})]})]})}function ste({step:t,signedIn:e,onSignIn:n}){const[i,r]=w.useState(null);return w.useEffect(()=>{t==="welcome"&&e&&zt("/setup/connect"),t!=="welcome"&&!e&&zt("/setup")},[t,e]),m.jsxs("div",{className:"setup",children:[t==="welcome"&&m.jsx(ete,{onStart:n}),t==="connect"&&m.jsx(nte,{onStarted:s=>zt("/setup/syncing?name="+encodeURIComponent(s))}),t==="syncing"&&m.jsx(ite,{onDone:s=>{r(s),zt("/setup/done")}}),t==="done"&&m.jsx(rte,{st:i??{}})]})}const SN="__existing__";function ote({templates:t,onCreate:e,onClose:n}){const i=[...t.map(y=>({value:y.name,title:y.title,blurb:y.blurb,rule:!1})),{value:SN,title:"I already have a folder",blurb:"nothing is seeded — connect it and your files stay as they are",rule:!0},{value:"",title:"Empty project",blurb:"just the folder",rule:!1}],[r,s]=w.useState(""),[o,l]=w.useState(i[0].value),[u,f]=w.useState(""),[h,p]=w.useState(!1),O=async()=>{if(!h){if(!r.trim()){f("Give it a name.");return}p(!0);try{await e(r.trim(),o)}finally{p(!1)}}};return m.jsx(NO,{open:!0,onOpenChange:y=>!y&&n(),children:m.jsxs(zO,{className:"modal",showCloseButton:!1,children:[m.jsx(vh,{asChild:!0,children:m.jsx("h3",{children:"New project"})}),m.jsx("label",{className:"modal-label",htmlFor:"modal-input",children:"Name"}),m.jsx("input",{className:"modal-input",type:"text",autoComplete:"off",id:"modal-input",autoFocus:!0,value:r,"aria-invalid":!!u,"aria-describedby":u?"modal-input-err":void 0,onChange:y=>{s(y.currentTarget.value),u&&f("")},onKeyDown:y=>y.key==="Enter"&&O()}),u&&m.jsx("span",{id:"modal-input-err",role:"alert",className:"field-err",children:u}),i.length>1&&m.jsxs("fieldset",{className:"start-points",children:[m.jsx("legend",{className:"modal-label",children:"Starting point"}),i.map((y,v)=>m.jsxs("label",{className:"start-point"+(o===y.value?" on":"")+(y.rule?" sp-rule":""),children:[m.jsx("input",{type:"radio",name:"template",value:y.value,checked:o===y.value,onChange:()=>l(y.value)}),m.jsxs("span",{className:"sp-text",children:[m.jsxs("span",{className:"sp-title",children:[y.title,v===0&&m.jsx("span",{className:"sp-rec",children:"Recommended"})]}),m.jsx("span",{className:"sp-blurb",children:y.blurb})]})]},y.value))]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx(at,{variant:"subtle",onClick:n,children:"Cancel"}),m.jsx(at,{variant:"primary",onClick:O,disabled:h,children:"Create"})]})]})})}function gb(t,e,n){if(!t)return null;if(!n)return t[e]||null;const i={human:0,agent:0,share:0};for(const[r,s]of Object.entries(t))r.startsWith(e+"/")&&(i.human+=s.human||0,i.agent+=s.agent||0,i.share+=s.share||0);return i.human||i.agent||i.share?i:null}function vo(t){return(t.human||0)+(t.agent||0)+(t.share||0)}function ff(t){const e=vo(t);if(!e)return"";const n=e+(e===1?" read":" reads");if(!t.agent&&!t.share)return n;const i=[];return t.human&&i.push(t.human+" human"),t.agent&&i.push(t.agent+" agent"),t.share&&i.push(t.share+" shared"),n+" ("+i.join(", ")+")"}const _l="Includes your own views. Repeat opens by the same reader inside 10 minutes count once.";function ate(t){const e=vo(t);return e?e<3?1:e<10?2:e<30?3:4:0}function lte(t){const e=vo(t);return e?{agent:(t.agent||0)/e,human:(t.human||0)/e,share:(t.share||0)/e}:{agent:0,human:0,share:0}}function cte(t,e){return t?Object.keys(t).filter(n=>!e.has(n)).sort():[]}const ute=7;function dte(t){if(!t.length)return null;let e=t[0],n=t[0];for(const i of t)in&&(n=i);return{min:e,max:n}}const fte=(t,e)=>e-ts.reads-r.reads).slice(0,pte)){const r=i.path.split("/").pop();let s=i.cx+i.r+4,o="start";s+r.length*gte>e.right&&(s=i.cx-i.r-4,o="end");const l=f=>n.every(h=>Math.abs(h.y-f)>=mb);let u=i.cy;for(;u<=e.bottom&&!l(u);)u+=mb;if(u>e.bottom)for(u=i.cy;u>=e.top&&!l(u);)u-=mb;n.push({path:i.path,name:r,x:s,y:Math.min(e.bottom,Math.max(e.top,u)),anchor:o})}return n}const hf=3,Ic=30,xN=(t,e)=>t>=hf&&e>=Ic;function Ote(t,e=Date.now()){if(!t)return null;const n=new Date(t).getTime();return Number.isFinite(n)?Math.max(0,(e-n)/864e5):null}function yte(t){const e=new Intl.RelativeTimeFormat("en",{numeric:"always"});return t<30?e.format(-Math.round(t),"day"):t<365?e.format(-Math.round(t/30),"month"):e.format(-Math.round(t/365),"year")}function wN(t,e){const n=Ote(e);return!t||n===null||!xN(vo(t),n)?"":`stale · last changed ${yte(n)}`}function vte(t,e=!0){const n=nn({queryKey:["tree",t],queryFn:()=>Wt(t+"tree?slim=1"),enabled:e,refetchInterval:3e5}),i=w.useMemo(()=>{const r=[],s=new Map,o=(l,u)=>{for(const f of l.children||[])f.path=u?u+"/"+f.name:f.name,f.dir?(s.set(f.path,f),o(f,f.path)):r.push(f)};return n.data&&o(n.data,""),{flatFiles:r,dirIndex:s}},[n.data]);return{tree:n.data,...i,loaded:!!n.data}}function bte(t,e){return nn({queryKey:["heat",t],queryFn:()=>Wt(t+"heat?days=30"),enabled:e,staleTime:6e4}).data?.entries??null}function Ste(t,e,n){return nn({queryKey:["history",t,"prefix",e,20],queryFn:()=>Wt(t+"history?prefix="+encodeURIComponent(e)+"&n=20"),enabled:n,staleTime:15e3}).data?.entries??null}const kN=1<<20,xte=8192;function wte(t){if(t.byteLength>kN)return{kind:"too-large",size:t.byteLength};if(t.subarray(0,xte).includes(0))return{kind:"binary"};try{return{kind:"text",text:new TextDecoder("utf-8",{fatal:!0}).decode(t)}}catch{return{kind:"binary"}}}function Tm(t,e,n,i){let r=t+"blob?sha="+encodeURIComponent(e);return n&&(r+="&name="+encodeURIComponent(n)),i&&(r+="&download=1"),r}async function CN(t){const e=await KX(t),n=Number(e.headers.get("Content-Length")??e.headers.get("X-Uncompressed-Length"));if(n>kN)return{kind:"too-large",size:n};const i=wte(new Uint8Array(await e.arrayBuffer())),r=e.headers.get("ETag")?.replace(/^W\/|"/g,"");return i.kind==="text"&&r?{...i,sha:r}:i}function Nf(t,e,n){return n?Tm(t,n,e):t+"file?path="+encodeURIComponent(e)}function kte(t){return!(t instanceof kw)||t.status===429||t.status>=500}function D1(t,e,n,i){return nn({queryKey:e,queryFn:()=>CN(t),enabled:n,...i?{staleTime:1/0,gcTime:1/0}:{},retry:i?!1:(r,s)=>r<3&&kte(s),retryDelay:r=>Math.min(1e3*2**r,8e3)})}function XE(t,e,n){return D1(e?Tm(t,e):"",["blob",t,e],!!e,!0)}function Cte(t,e=!0,n){const i=fr(),r=w.useRef(n);r.current=n,w.useEffect(()=>{if(!e||typeof EventSource>"u")return;const s=2e3;let o=null;const l=()=>{o||(o=setTimeout(()=>{o=null,i.invalidateQueries({queryKey:["tree",t]}),i.invalidateQueries({queryKey:["history",t]})},s))},u=k=>{let C;try{C=JSON.parse(k)}catch{return}if(C.type==="presence"){r.current?.(C.people??[]);return}if(window.dispatchEvent(new CustomEvent("bdrive:changed",{detail:C.paths??[]})),l(),C.type==="resync"||C.more||!C.paths?.length){i.invalidateQueries({queryKey:["render",t]}),i.invalidateQueries({queryKey:["text"]});return}for(const $ of C.paths)i.invalidateQueries({queryKey:["render",t,$]}),i.invalidateQueries({queryKey:["text",Nf(t,$)]})},f=`bdrive:events:${t}`;let h=null,p=null,O=null;const y=new AbortController;let v=!1;const S=()=>{h=new EventSource(t+"events"),h.onmessage=k=>{p?.postMessage(k.data),u(k.data)},h.onerror=()=>{}};return typeof BroadcastChannel>"u"||!navigator.locks?S():(p=new BroadcastChannel(f),p.onmessage=k=>u(k.data),navigator.locks.request(`${f}:leader`,{signal:y.signal},()=>new Promise(k=>{if(v)return k();O=k,S()})).catch(()=>{})),()=>{v=!0,y.abort(),O?.(),h?.close(),p?.close()}},[t,e,i])}const _te=1e4;function $te(t,e,n=!0){const[i,r]=w.useState([]),s=w.useRef(e);return s.current=e,w.useEffect(()=>{if(!n)return;let o=!0;const l=async(f=!1)=>{try{const h=await Wr(t+"presence",{path:s.current,...f?{leave:!0}:{}});o&&!f&&r(h.people??[])}catch{}};l();const u=setInterval(l,_te);return()=>{o=!1,clearInterval(u),l(!0)}},[t,n]),{people:i,setPeople:r}}function Tte(t){const e=t.trim().split(/[\s@._-]+/).filter(Boolean);return e.length?(e[0][0]+(e[1]?.[0]??"")).toUpperCase():"?"}function VE(t){let e=0;for(let n=0;n{const l=e&&s.path===e?0:1,u=e&&o.path===e?0:1;return l-u}),i=n.slice(0,5),r=n.length-i.length;return m.jsxs("div",{id:"presence",className:"flex items-center gap-1","aria-label":"People viewing this project",children:[i.map((s,o)=>m.jsx("span",{title:s.path?`${s.name} — ${s.path}`:s.name,className:"inline-flex h-6 w-6 items-center justify-center rounded-full text-[10px] font-medium ring-1 ring-black/10",style:{backgroundColor:`hsl(${VE(s.name)} 70% 88%)`,color:`hsl(${VE(s.name)} 60% 28%)`,outline:e&&s.path===e?"2px solid hsl(var(--ring))":void 0,outlineOffset:"1px"},children:Tte(s.name)},s.name+o)),r>0&&m.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",r]})]})}function _N(t,e){let n;for(const i of t)e.startsWith(i.prefix)&&(!n||i.prefix.length>n.prefix.length)&&(n=i);return n}function Rte(t,e,n){const i=new Array(t);return new Proxy(i,{get(r,s,o){if(typeof s=="string"){const l=s.charCodeAt(0);if(l>=48&&l<=57){const u=+s;if(Number.isInteger(u)&&u>=0&&ui[h]!==f))&&(i=l,r=e(...l),n?.onChange&&!(s&&n.skipInitialOnChange)&&n.onChange(r),s=!1),r}return o.updateDeps=l=>{i=l},o}function BE(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const Qte=(t,e)=>Math.abs(t-e)<1.01,Ate=(t,e,n)=>{let i;return function(...r){t.clearTimeout(i),i=t.setTimeout(()=>e.apply(this,r),n)}};let Kd;const Ob=()=>{if(Kd!==void 0)return Kd;if(typeof navigator>"u")return Kd=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Kd=!0;const t=navigator.maxTouchPoints;return Kd=navigator.platform==="MacIntel"&&t!==void 0&&t>0},UE=t=>{const{offsetWidth:e,offsetHeight:n}=t;return{width:e,height:n}},Pte=t=>t,jte=t=>{const e=Math.max(t.startIndex-t.overscan,0),i=Math.min(t.endIndex+t.overscan,t.count-1)-e+1,r=new Array(i);for(let s=0;s{const n=t.scrollElement;if(!n)return;const i=t.targetWindow;if(!i)return;const r=o=>{const{width:l,height:u}=o;e({width:Math.round(l),height:Math.round(u)})};if(r(UE(n)),!i.ResizeObserver)return()=>{};const s=new i.ResizeObserver(o=>{const l=()=>{const u=o[0];if(u?.borderBoxSize){const f=u.borderBoxSize[0];if(f){r({width:f.inlineSize,height:f.blockSize});return}}r(UE(n))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},Em={passive:!0},Dte=typeof window>"u"?!0:"onscrollend"in window,Nte=(t,e,n)=>{const i=t.scrollElement;if(!i)return;const r=t.targetWindow;if(!r)return;const s=t.options.useScrollendEvent&&Dte;let o=0;const l=s?null:Ate(r,()=>e(o,!1),t.options.isScrollingResetDelay),u=p=>()=>{o=n(i),l?.(),e(o,p)},f=u(!0),h=u(!1);return i.addEventListener("scroll",f,Em),s&&i.addEventListener("scrollend",h,Em),()=>{i.removeEventListener("scroll",f),s&&i.removeEventListener("scrollend",h)}},zte=(t,e)=>Nte(t,e,n=>{const{horizontal:i,isRtl:r}=t.options;return i?n.scrollLeft*(r&&-1||1):n.scrollTop}),Lte=(t,e,n)=>{if(n.options.useCachedMeasurements){const i=n.indexFromElement(t),r=n.options.getItemKey(i);return n.itemSizeCache.get(r)??n.options.estimateSize(i)}if(e?.borderBoxSize){const i=e.borderBoxSize[0];if(i)return Math.round(i[n.options.horizontal?"inlineSize":"blockSize"])}if(!e){const i=n.indexFromElement(t),r=n.options.getItemKey(i),s=n.itemSizeCache.get(r);if(s!==void 0)return s}return t[n.options.horizontal?"offsetWidth":"offsetHeight"]},Zte=(t,{adjustments:e=0,behavior:n},i)=>{var r,s;(s=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||s.call(r,{[i.options.horizontal?"left":"top"]:t+e,behavior:n})},Ite=Zte;class Xte{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,i,r;return((r=(i=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let n=null;const i=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(s=>{const o=()=>{const l=s.target,u=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[f,h]of this.elementsCache)if(h===l){this.elementsCache.delete(f);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(l,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),n=null},observe:r=>{var s;return(s=i())==null?void 0:s.observe(r,{box:"border-box"})},unobserve:r=>{var s;return(s=i())==null?void 0:s.unobserve(r)}}})(),this.range=null,this.setOptions=n=>{var i,r;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Pte,rangeExtractor:jte,onChange:()=>{},measureElement:Lte,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const O in n){const y=n[O];y!==void 0&&(s[O]=y)}const o=this.options;let l=null,u=null,f=!1;if(o!==void 0&&o.enabled&&s.enabled&&s.anchorTo==="end"&&this.scrollElement!==null){const O=o.count,y=s.count,v=this.getMeasurements(),S=O>0?((i=v[0])==null?void 0:i.key)??o.getItemKey(0):null,k=O>0?((r=v[O-1])==null?void 0:r.key)??o.getItemKey(O-1):null;if(y!==O||O>0&&y>0&&(s.getItemKey(0)!==S||s.getItemKey(y-1)!==k)){f=!0;const T=O>0?this.getVirtualItemForOffset(this.getScrollOffset())??v[0]:null;T&&(l=[T.key,this.getScrollOffset()-T.start]);const Q=s.followOnAppend===!0?"auto":s.followOnAppend||null;Q&&y>O&&this.isAtEnd(o.scrollEndThreshold)&&(O===0||s.getItemKey(y-1)!==k)&&(u=Q)}}this.options=s,f&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,p=0;if(l&&this.scrollOffset!==null){const[O,y]=l,v=this.getMeasurements(),{count:S,getItemKey:k}=this.options;let C=0;for(;C{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,n)},this.maybeNotify=Lc(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}if(this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{if(o&&this._intendedScrollOffset===null&&s===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const l=this.getScrollOffset();this.scrollDirection=o?l===s?this.scrollDirection:l{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},l=()=>{this._iosTouching=!1,!(!Ob()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,Em),s.addEventListener("touchend",l,Em),this.unsubs.push(()=>{s.removeEventListener("touchstart",o),s.removeEventListener("touchend",l),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[s,o,l,u]=r;s!==null&&!l&&(Ob()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),i=this.getMaxScrollOffset();if(n<0||n>i)return;const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Lc(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,i,r,s,o,l,u,f)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:i,scrollMargin:r,getItemKey:s,enabled:o,lanes:l,laneAssignmentMode:u,gap:f}),{key:!1}),this.getMeasurements=Lc(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:i,scrollMargin:r,getItemKey:s,enabled:o,lanes:l,laneAssignmentMode:u,gap:f},h)=>{const p=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const C of this.laneAssignments.keys())C>=n&&this.laneAssignments.delete(C);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(C=>{this.itemSizeCache.set(C.key,C.size)}));const O=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),l===1){const C=n*2;let $=this._flatMeasurements;if(!$||$.length0&&A.set($.subarray(0,O*2)),$=A,this._flatMeasurements=$}let T;if(O===0)T=i+r;else{const A=O-1;T=$[A*2]+$[A*2+1]+f}for(let A=O;A1){Q=T;const G=v[Q],H=G!==void 0?y[G]:void 0;A=H?H.end+f:i+r}else if(k===l){let G=0,H=S[0],Y=v[0];for(let re=1;rethis.options.debug}),this.calculateRange=Lc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,i,r,s)=>n.length===0||i===0?(this.range=null,null):(this.range=Bte(n,i,r,s,s===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Lc(()=>{let n=null,i=null;const r=this.calculateRange();return r&&(n=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,i]},(n,i,r,s,o)=>s===null||o===null?[]:n({startIndex:s,endIndex:o,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const i=this.options.indexAttribute,r=n.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,r-s),l=Math.min(this.options.count-1,r+s);return n>=o&&n<=l}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,l)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(l))});return}const i=this.indexFromElement(n),r=this.options.getItemKey(i),s=this.elementsCache.get(r);s!==n&&(s&&this.observer.unobserve(s),this.observer.observe(n),this.elementsCache.set(r,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,i)=>{var r,s;if(n<0||n>=this.options.count)return;let o,l,u;const f=this._flatMeasurements;if(this.options.lanes===1&&f!==null)u=this.options.getItemKey(n),l=f[n*2],o=f[n*2+1];else{const O=this.measurementsCache[n];if(!O)return;u=O.key,l=O.start,o=O.size}const h=this.itemSizeCache.get(u)??o,p=i-h;if(p!==0){const O=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,y=O?this.getTotalSize():0,v=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:u,start:l,size:o,end:l+o,lane:0},p,this):l[this.getVirtualIndexes(),this.getMeasurements()],(n,i)=>{const r=[];for(let s=0,o=n.length;sthis.options.debug}),this.getVirtualItemForOffset=n=>{const i=this.getMeasurements();if(i.length===0)return;const r=this._flatMeasurements,s=this.options.lanes===1&&r!=null,o=$N(0,i.length-1,s?l=>r[l*2]:l=>BE(i[l]).start,n);return BE(i[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,i,r=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),o=this.getScrollOffset();i==="auto"&&(i=n>=o+s?"end":"start"),i==="center"?n+=(r-s)/2:i==="end"&&(n-=s);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,i="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getSize(),s=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(i==="auto")if(o.end>=s+r-this.options.scrollPaddingEnd)i="end";else if(o.start<=s+this.options.scrollPaddingStart)i="start";else return[s,i];if(i==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),i];const l=i==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,i,o.size),i]},this.scrollToOffset=(n,{align:i="start",behavior:r="auto"}={})=>{const s=this.getOffsetForAlignment(n,i),o=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:o,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:i="auto",behavior:r="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.getOffsetForIndex(n,i);if(!s)return;const[o,l]=s,u=this.now();this.scrollState={index:n,align:l,behavior:r,startedAt:u,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+n,s=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:s,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const i=this.getMeasurements();let r;if(i.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const s=i.length-1,o=this._flatMeasurements;o!=null?r=o[s*2]+o[s*2+1]:r=((n=i[s])==null?void 0:n.end)??0}else{const s=Array(this.options.lanes).fill(null);let o=i.length-1;for(;o>=0&&s.some(l=>l===null);){const l=i[o];s[l.lane]===null&&(s[l.lane]=l.end),o--}r=Math.max(...s.filter(l=>l!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const i=this.getMeasurements();for(const r of i)r&&this.itemSizeCache.has(r.key)&&n.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return n},this._scrollToOffset=(n,{adjustments:i,behavior:r})=>{this._intendedScrollOffset=n+(i??0),this.options.scrollToFn(n,{behavior:r,adjustments:i},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,n){e!==0&&(Ob()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,s=1,o=r!==this.scrollState.lastTargetOffset;if(!o&&Qte(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const l=this.getSize()||600,u=Math.abs(r-this.getScrollOffset()),f=this.scrollState.behavior==="smooth"&&u>l;this.scrollState.lastTargetOffset=r,f||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:f?"smooth":"auto"})}this.scheduleScrollReconcile()}}const $N=(t,e,n,i)=>{for(;t<=e;){const r=(t+e)/2|0,s=n(r);if(si)e=r-1;else return r}return t>0?t-1:0};function Vte(t,e,n){let i=0;for(;i<=e;){const r=(i+e)/2|0,s=t[r*2];if(sn)e=r-1;else return r}return i>0?i-1:0}function Bte(t,e,n,i,r){const s=t.length-1;if(t.length<=i)return{startIndex:0,endIndex:s};if(i===1&&r!==null){const f=Vte(r,s,n);let h=f;const p=n+e;for(;ht[f].start,n),u=l;if(i===1)for(;u1){const f=Array(i).fill(0);for(;up=0&&h.some(p=>p>=n);){const p=t[l];h[p.lane]=p.start,l--}l=Math.max(0,l-l%i),u=Math.min(s,u+(i-1-u%i))}return{startIndex:l,endIndex:u}}const yb=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Ute({useFlushSync:t=!0,directDomUpdates:e=!1,directDomUpdatesMode:n="transform",...i}){const r=w.useReducer(f=>f+1,0)[1],s=w.useRef({enabled:e,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});s.current.enabled=e,s.current.mode=n;const o=f=>{const h=s.current;if(!h.enabled||!h.container)return;const p=f.getTotalSize();if(p!==h.lastSize){h.lastSize=p;const C=f.options.horizontal?"width":"height";h.container.style[C]=`${p}px`}const O=!!f.options.horizontal,y=h.mode==="transform",v=O?"left":"top",S=f.options.scrollMargin,k=f.getVirtualItems();for(const C of k){const $=C.start-S,T=f.elementsCache.get(C.key);T&&h.lastPositions.get(T)!==$&&(h.lastPositions.set(T,$),y?T.style.transform=O?`translate3d(${$}px, 0, 0)`:`translate3d(0, ${$}px, 0)`:T.style[v]=`${$}px`)}},l={...i,onChange:(f,h)=>{var p;const O=s.current;let y=!0;if(O.enabled){o(f);const v=f.range,S=O.prevRange;y=!S||S.isScrolling!==f.isScrolling||S.startIndex!==v?.startIndex||S.endIndex!==v?.endIndex,y&&(O.prevRange=v?{startIndex:v.startIndex,endIndex:v.endIndex,isScrolling:f.isScrolling}:null)}y&&(t&&h?ql.flushSync(r):r()),(p=i.onChange)==null||p.call(i,f,h)}},[u]=w.useState(()=>{const f=new Xte(l);return Object.assign(f,{containerRef:h=>{const p=s.current;if(p.container=h,p.lastSize=null,h&&p.enabled){const O=f.getTotalSize();p.lastSize=O;const y=f.options.horizontal?"width":"height";h.style[y]=`${O}px`}}})});return u.setOptions(l),yb(()=>u._didMount(),[]),yb(()=>u._willUpdate()),yb(()=>{o(u)}),u}function qte(t){return Ute({observeElementRect:Mte,observeElementOffset:zte,scrollToFn:Ite,...t})}function Yte(t,e){const n=[],i=(r,s)=>{for(const o of r)n.push({node:o,depth:s}),o.dir&&e.has(o.path)&&i(o.children||[],s+1)};return i(t?.children||[],0),n}function Fte(t){const{root:e,expanded:n,onToggle:i,currentPath:r,listingShowing:s,restricted:o,onOpen:l}=t,u=w.useRef(null),f=w.useMemo(()=>Yte(e,n),[e,n]),h=qte({count:f.length,getScrollElement:()=>u.current,estimateSize:()=>window.matchMedia("(max-width: 768px)").matches?44:28,overscan:12,getItemKey:p=>f[p].node.path});return w.useEffect(()=>{if(!r)return;const p=f.findIndex(O=>O.node.path===r);p>=0&&h.scrollToIndex(p,{align:"auto"})},[r,f]),m.jsx("nav",{id:"tree","aria-label":"Files",ref:u,children:m.jsx("div",{style:{height:h.getTotalSize(),position:"relative"},children:h.getVirtualItems().map(p=>{const{node:O,depth:y}=f[p.index],v=O.dir?n.has(O.path):!1,S=()=>{if(O.dir&&r===O.path&&s){i(O.path);return}l(O.path),O.dir||Fr()};return m.jsxs("div",{className:"row "+(O.dir?"dir":"file")+(r===O.path?" active":"")+(O.dir&&!v?" collapsed":""),"data-path":O.path,tabIndex:0,role:"button",title:O.name,"aria-expanded":O.dir?v:void 0,style:{position:"absolute",top:0,left:0,right:0,transform:`translateY(${p.start}px)`,paddingLeft:8+y*13},onClick:S,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),S())},children:[Array.from({length:y},(k,C)=>m.jsx("span",{className:"tguide",style:{left:8+C*13+5},"aria-hidden":"true"},C)),m.jsx("span",{className:"chev",onClick:k=>{O.dir&&(k.stopPropagation(),i(O.path))},children:m.jsx(st,{name:"chevd"})}),m.jsx("span",{className:"ticon",children:m.jsx(st,{name:O.dir?"folder":"doc"})}),m.jsx("span",{className:"label",children:O.name}),O.dir&&o.has(O.path)&&m.jsx("span",{className:"trestricted",role:"img","aria-label":O.name+" is a restricted folder",title:"Restricted — not everyone in the workspace has the same access here",children:m.jsx(st,{name:"lock"})})]},p.key)})})})}function Gte(t){const e=t.split("/"),n=[];let i="";for(let r=0;r{i=i?i+"/"+r:r;const o=i,l=s===n.length-1;return m.jsxs("span",{children:[s>0&&m.jsx("span",{className:"crumb-sep",children:"/"}),l?m.jsx("span",{children:r}):m.jsx("span",{className:"crumb-seg",title:o,onClick:()=>e(o),children:r})]},o)})})}const Wte=/\.bdrive-conflict-([A-Za-z0-9_-]{0,32})-(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;function TN(t){const e=Wte.exec(t);if(!e)return null;const[,n,i,r,s,o,l,u]=e,f=new Date(Date.UTC(+i,+r-1,+s,+o,+l,+u));return f.getUTCFullYear()!==+i||f.getUTCMonth()!==+r-1||f.getUTCDate()!==+s||f.getUTCHours()!==+o||f.getUTCMinutes()!==+l||f.getUTCSeconds()!==+u?null:{original:t.slice(0,e.index),device:n,when:f}}function Kte(t,e,n){const i=f=>String(f).padStart(2,"0"),r=String(n.getUTCFullYear())+i(n.getUTCMonth()+1)+i(n.getUTCDate())+"T"+i(n.getUTCHours())+i(n.getUTCMinutes())+i(n.getUTCSeconds())+"Z",s=".bdrive-conflict-"+e.replace(/[^A-Za-z0-9_-]/g,"-").slice(0,32)+"-"+r,o=t.lastIndexOf("/"),l=o<0?"":t.slice(0,o+1),u=o<0?t:t.slice(o+1);return l+u.slice(0,Math.max(0,255-s.length))+s}function qE(t){if(t==="")return[];const e=t.split(` -`);return e[e.length-1]===""&&e.pop(),e}const Jte=4e6;function ene(t,e){let n=0;for(;nr.push({op:"-",line:s[p],an:n+p+1}),h=p=>r.push({op:"+",line:o[p],bn:n+p+1});if(l*u>Jte){for(let p=0;p=0;v--)for(let S=u-1;S>=0;S--)p[v][S]=s[v]===o[S]?p[v+1][S+1]+1:Math.max(p[v+1][S],p[v][S+1]);let O=0,y=0;for(;O=p[O][y+1]?f(O++):h(y++);for(;Oi.op==="+").length,del:n.filter(i=>i.op==="-").length}}function nne(t,e){if(t===e)return null;const n=Math.min(t.length,e.length);let i=0;for(;ir.data?.kind==="text"&&s.data?.kind==="text"?tne(r.data.text,s.data.text):null,[r.data,s.data]);if(r.error||s.error)return m.jsx("div",{className:"dv dv-msg",children:"Could not load one of the versions."});if(!r.data||!s.data)return m.jsx("div",{className:"dv dv-msg",children:"Loading changes…"});if(!o){const p=r.data.kind==="too-large"||s.data.kind==="too-large";return m.jsxs("div",{className:"dv dv-msg",children:[p?"Too large to diff — download to compare.":"Binary file — no diff available.",m.jsx(rne,{apiBase:t,path:e,prev:n,cur:i})]})}const{lines:u,add:f,del:h}=l;return m.jsxs("div",{className:"dv",children:[m.jsxs("div",{className:"dv-head",children:[m.jsxs("span",{className:"dv-stat",children:[m.jsxs("span",{className:"dv-add",children:["+",f]})," ",m.jsxs("span",{className:"dv-del",children:["−",h]})]}),f===0&&h===0&&m.jsx("span",{className:"dv-same",children:"No line changes"})]}),m.jsx("div",{className:"dv-body",children:u.map((p,O)=>m.jsxs("div",{className:"dv-line dv-"+(p.op==="="?"ctx":p.op==="+"?"ins":"rm"),children:[m.jsx("span",{className:"dv-n",children:p.an??""}),m.jsx("span",{className:"dv-n",children:p.bn??""}),m.jsx("span",{className:"dv-mark",children:p.op==="="?" ":p.op}),m.jsx("span",{className:"dv-text",children:p.line||" "})]},O))})]})}const one={add:"added",edit:"edited",delete:"deleted"};function EN({text:t}){return m.jsx(m.Fragment,{children:t.split(/(https?:\/\/\S+)/).map((e,n)=>/^https?:\/\//.test(e)?m.jsx("a",{href:e,target:"_blank",rel:"noopener",children:e},n):e)})}function N1({entry:t,apiBase:e,onOpen:n,diff:i,restore:r,remove:s,restoreSha:o,recreates:l,inRun:u,read:f}){const[h,p]=w.useState(!1),[O,y]=w.useState(!1),v=t.kind==="put"?"edit":t.kind,S=MO(t),k=[t.device.name||t.device.id,t.device.os].filter(Boolean).join(" · "),C=v!=="delete",$=!!i&&v!=="delete"&&!!t.blob,T=!!u&&v==="add",Q=!!r&&!!o&&!T,A=!!s&&T,R=!!r?.busy&&r.busy===t.path+o,j=!!s?.busy&&s.busy===t.path,L=C&&!!t.blob,ne=t.path.split("/").pop()||t.path,G=new Date(t.time).toLocaleString(),H=e+"blob?sha="+t.blob+"&name="+encodeURIComponent(ne)+"&download=1",Y=()=>y(!O),re=K=>{K.target.tagName!=="A"&&C&&n(t.path,t.blob)};return m.jsxs("div",{className:"hentry "+v+(C?" clickable":""),tabIndex:C?0:void 0,role:C?"button":void 0,onClick:re,onKeyDown:K=>{C&&(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),n(t.path,t.blob))},children:[m.jsxs("div",{className:"hline",children:[m.jsx("span",{className:"hkind",children:one[v]||v}),f&&m.jsx("span",{className:"hread",title:"This run read this file before changing it",children:"read"}),m.jsx("span",{className:"hpath",children:t.path}),m.jsx("span",{className:"htime",children:G})]}),m.jsxs("div",{className:"hmeta",children:[m.jsx("span",{className:"hwho",children:S}),m.jsx("span",{className:"hdev",children:k}),m.jsx("span",{className:"hsize",children:t.size?l1(t.size):""}),Q&&m.jsxs("button",{type:"button",className:"hrestore-btn",disabled:R,title:"Put this version of "+t.path+" back as a new change",onClick:K=>{K.stopPropagation(),r.onRestore(t.path,o,!!l)},onKeyDown:K=>K.stopPropagation(),children:[m.jsx(st,{name:"hist"}),R?"restoring…":"restore"]}),A&&m.jsxs("button",{type:"button",className:"hremove-btn",disabled:j,title:"Remove "+t.path+" — this run created it",onClick:K=>{K.stopPropagation(),s.onRemove(t.path)},onKeyDown:K=>K.stopPropagation(),children:[m.jsx(st,{name:"trash"}),j?"removing…":"undo — remove file"]})]}),t.note&&!u&&m.jsx("div",{className:"hnote"+(h?" open":""),tabIndex:0,role:"button",title:h?"Collapse note":"Show full note","aria-expanded":h,onClick:K=>{K.stopPropagation(),K.target.tagName!=="A"&&p(!h)},onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),K.stopPropagation(),p(!h))},children:m.jsx(EN,{text:t.note})}),($||L)&&m.jsxs("div",{className:"hactions",children:[$&&(i.prev?m.jsxs("button",{type:"button",className:"hdiff-btn"+(O?" open":""),"aria-expanded":O,onClick:K=>{K.stopPropagation(),Y()},onKeyDown:K=>K.stopPropagation(),children:[m.jsx(st,{name:O?"chevd":"chev"}),O?"hide changes":"show changes"]}):m.jsx("div",{className:"hdiff-none",children:"First version — nothing to compare against"})),L&&m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",className:"hver-btn","aria-label":`Open ${ne} as of ${G}`,onClick:K=>{K.stopPropagation(),n(t.path,t.blob)},onKeyDown:K=>K.stopPropagation(),children:[m.jsx(st,{name:"clock"}),"Open this version"]}),m.jsxs("a",{className:"hver-btn",download:!0,href:H,"aria-label":`Download ${ne} as of ${G}`,onClick:K=>K.stopPropagation(),onKeyDown:K=>{K.stopPropagation(),K.key===" "&&(K.preventDefault(),K.currentTarget.click())},children:[m.jsx(st,{name:"download"}),"Download"]})]})]}),$&&i.prev&&O&&m.jsx("div",{onClick:K=>K.stopPropagation(),children:m.jsx(sne,{apiBase:i.apiBase,path:t.path,prev:i.prev,cur:t.blob})})]})}function ane(t){const{node:e,heatMap:n,folders:i,onOpen:r}=t,s=(e.children||[]).slice().sort((p,O)=>Number(O.dir||!1)-Number(p.dir||!1)||p.name.localeCompare(O.name)),o=s.filter(p=>p.dir).length,l=s.length-o,u=[];o&&u.push(o+(o===1?" folder":" folders")),l&&u.push(l+(l===1?" file":" files"));const f=gb(n,e.path,!0);f&&u.push(ff(f)+" in 30 days");const h=!!f||s.some(p=>gb(n,p.path,!!p.dir));return m.jsxs("div",{className:"dirlist",children:[m.jsxs("h1",{className:"dl-title",children:[m.jsx("span",{className:"dl-title-icon",children:m.jsx(st,{name:"folder"})}),m.jsx("span",{children:e.name})]}),m.jsx("p",{className:"dl-sub",children:u.join(" · ")||"Empty folder"}),h&&m.jsx("p",{className:"dl-heatnote",children:_l}),s.length===0?m.jsx("div",{className:"dl-empty",children:"Nothing in this folder yet."}):m.jsx("div",{className:"dl-items",children:s.map(p=>{let O="";if(p.dir){const C=(p.children||[]).length;O=C+(C===1?" item":" items")}else O=[p.size?l1(p.size):"",p.time?new Date(p.time).toLocaleDateString():""].filter(Boolean).join(" · ");const y=gb(n,p.path,!!p.dir);y&&(O=ff(y)+(O?" · "+O:""));const v=p.dir?null:TN(p.path),S=p.dir?i.find(C=>C.prefix===p.path+"/"):void 0,k=p.dir?"":wN(y,p.time);return m.jsxs("div",{className:"dl-row",tabIndex:0,role:"button",title:p.path,onClick:()=>r(p.path),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),r(p.path))},children:[m.jsx("span",{className:"ticon",children:m.jsx(st,{name:p.dir?"folder":"doc"})}),m.jsx("span",{className:"dl-name",children:p.name}),S&&m.jsx("span",{className:"dl-restricted","aria-label":S.default==="none"?"Restricted folder: not shared with everyone in this workspace.":"Restricted folder: everyone in this workspace can "+(S.default||"read")+" here.",title:S.default==="none"?"Not shared with everyone — only the people on its list.":"Everyone in this workspace can "+(S.default||"read")+" here.",children:S.default==="none"?"restricted":S.default||"shared"}),v&&m.jsx("span",{className:"dl-conflict","aria-label":"Conflict copy: a concurrent edit from "+(v.device||"another device")+" that beardrive preserved instead of dropping.",title:"A concurrent edit from "+(v.device||"another device")+" that beardrive preserved instead of dropping.",children:"conflict copy"}),k&&m.jsx("span",{className:"stalemark",role:"img","aria-label":"Warning: "+k,title:"Read often, but "+k,children:"⚠"}),y&&m.jsx("span",{className:"heatdot lvl"+ate(y),role:"img","aria-label":ff(y)+" in 30 days. "+_l,title:ff(y)+" in 30 days. "+_l}),m.jsx("span",{className:"dl-meta",children:O})]},p.path)})}),t.hub&&m.jsx(lne,{apiBase:t.apiBase,prefix:e.path+"/",onOpen:r,onFullHistory:()=>t.onFullHistory(e.path+"/"),onRendered:t.onRendered})]})}function lne(t){const e=Ste(t.apiBase,t.prefix,!0),{onRendered:n}=t;return w.useEffect(()=>{e&&e.length&&n&&n()},[e,n]),!e||e.length===0?null:m.jsxs("div",{className:"dl-history",children:[m.jsx("h3",{className:"dl-h3",children:"Recent changes"}),m.jsx("div",{className:"history dl-hlist",children:e.map((i,r)=>m.jsx(N1,{entry:i,apiBase:t.apiBase,onOpen:t.onOpen},r))}),m.jsx("button",{className:"ai-btn dl-more",onClick:t.onFullHistory,children:"Full history"})]})}const RN=5e3;function cne(t,e,n=RN){const i=[];let r=[],s="",o=!1,l=0;const u=()=>{r.push(s),s="",i.length1?e.slice(0,-1).join(", ")+" and "+e[e.length-1]:e[0]||"something credential-shaped"}function fne(t=[]){return`BearDrive found ${QN(t)} in this file. The check covers the file at the moment you share it — a link always serves the file's latest content, so later changes are never checked. Share anyway?`}function hne(t=[]){return`This file contains ${QN(t)}.`}let rx=[],AN=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=AN[i])e=i+1;else return!0;if(e==n)return!1}}function YE(t){return t>=127462&&t<=127487}const FE=8205;function gne(t,e,n=!0,i=!0){return(n?PN:mne)(t,e,i)}function PN(t,e,n){if(e==t.length)return e;e&&jN(t.charCodeAt(e))&&MN(t.charCodeAt(e-1))&&e--;let i=vb(t,e);for(e+=GE(i);e=0&&YE(vb(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function mne(t,e,n){for(;e>1;){let i=PN(t,e-2,n);if(i=56320&&t<57344}function MN(t){return t>=55296&&t<56320}function GE(t){return t<65536?1:2}class Ot{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,i){[e,n]=ku(this,e,n);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),ws.from(r,this.length-(n-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=ku(this,e,n);let i=[];return this.decompose(e,n,i,0),ws.from(i,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new bf(this),s=new bf(e);for(let o=n,l=n;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new bf(this,e)}iterRange(e,n=this.length){return new DN(this,e,n)}iterLines(e,n){let i;if(e==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new NN(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Ot.empty:e.length<=32?new vn(e):ws.from(vn.split(e,[]))}}class vn extends Ot{constructor(e,n=One(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((n?i:l)>=e)return new yne(r,l,i,o);r=l+1,i++}}decompose(e,n,i,r){let s=e<=0&&n>=this.length?this:new vn(HE(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Gg(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new vn(l,o.length+s.length));else{let u=l.length>>1;i.push(new vn(l.slice(0,u)),new vn(l.slice(u)))}}else i.push(s)}replace(e,n,i){if(!(i instanceof vn))return super.replace(e,n,i);[e,n]=ku(this,e,n);let r=Gg(this.text,Gg(i.text,HE(this.text,0,e)),n),s=this.length+i.length-(n-e);return r.length<=32?new vn(r,s):ws.from(vn.split(r,[]),s)}sliceString(e,n=this.length,i=` -`){[e,n]=ku(this,e,n);let r="";for(let s=0,o=0;s<=n&&oe&&o&&(r+=i),es&&(r+=l.slice(Math.max(0,e-s),n-s)),s=u+1}return r}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(n.push(new vn(i,r)),i=[],r=-1);return r>-1&&n.push(new vn(i,r)),n}}class ws extends Ot{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,u=i+o.lines-1;if((n?u:l)>=e)return o.lineInner(e,n,i,r);r=l+1,i=u+1}}decompose(e,n,i,r){for(let s=0,o=0;o<=n&&s=o){let f=r&((o<=e?1:0)|(u>=n?2:0));o>=e&&u<=n&&!f?i.push(l):l.decompose(e-o,n-o,i,f)}o=u+1}}replace(e,n,i){if([e,n]=ku(this,e,n),i.lines=s&&n<=l){let u=o.replace(e-s,n-s,i),f=this.lines-o.lines+u.lines;if(u.lines>4&&u.lines>f>>6){let h=this.children.slice();return h[r]=u,new ws(h,this.length-(n-e)+i.length)}return super.replace(s,l,u)}s=l+1}return super.replace(e,n,i)}sliceString(e,n=this.length,i=` -`){[e,n]=ku(this,e,n);let r="";for(let s=0,o=0;se&&s&&(r+=i),eo&&(r+=l.sliceString(e-o,n-o,i)),o=u+1}return r}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof ws))return 0;let i=0,[r,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=n,s+=n){if(r==o||s==l)return i;let u=this.children[r],f=e.children[s];if(u!=f)return i+u.scanIdentical(f,n);i+=u.length+1}}static from(e,n=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let y of e)i+=y.lines;if(i<32){let y=[];for(let v of e)v.flatten(y);return new vn(y,n)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],u=0,f=-1,h=[];function p(y){let v;if(y.lines>s&&y instanceof ws)for(let S of y.children)p(S);else y.lines>o&&(u>o||!u)?(O(),l.push(y)):y instanceof vn&&u&&(v=h[h.length-1])instanceof vn&&y.lines+v.lines<=32?(u+=y.lines,f+=y.length+1,h[h.length-1]=new vn(v.text.concat(y.text),v.length+1+y.length)):(u+y.lines>r&&O(),u+=y.lines,f+=y.length+1,h.push(y))}function O(){u!=0&&(l.push(h.length==1?h[0]:ws.from(h,f)),f=-1,u=h.length=0)}for(let y of e)p(y);return O(),l.length==1?l[0]:new ws(l,n)}}Ot.empty=new vn([""],0);function One(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Gg(t,e,n=0,i=1e9){for(let r=0,s=0,o=!0;s=n&&(u>i&&(l=l.slice(0,i-r)),r0?1:(e instanceof vn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof vn?r.text.length:r.children.length;if(o==(n>0?l:0)){if(i==0)return this.done=!0,this.value="",this;n>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[i]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(r instanceof vn){let u=r.text[o+(n<0?-1:0)];if(this.offsets[i]+=n,u.length>Math.max(0,e))return this.value=e==0?u:n>0?u.slice(e):u.slice(0,u.length-e),this;e-=u.length}else{let u=r.children[o+(n<0?-1:0)];e>u.length?(e-=u.length,this.offsets[i]+=n):(n<0&&this.offsets[i]--,this.nodes.push(u),this.offsets.push(n>0?1:(u instanceof vn?u.text.length:u.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class DN{constructor(e,n,i){this.value="",this.done=!1,this.cursor=new bf(e,n>i?-1:1),this.pos=n>i?e.length:0,this.from=Math.min(n,i),this.to=Math.max(n,i)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let i=n<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*n,this.value=r.length<=i?r:n<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class NN{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:i,value:r}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Ot.prototype[Symbol.iterator]=function(){return this.iter()},bf.prototype[Symbol.iterator]=DN.prototype[Symbol.iterator]=NN.prototype[Symbol.iterator]=function(){return this});let yne=class{constructor(e,n,i,r){this.from=e,this.to=n,this.number=i,this.text=r}get length(){return this.to-this.from}};function ku(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function fi(t,e,n=!0,i=!0){return gne(t,e,n,i)}function vne(t){return t>=56320&&t<57344}function bne(t){return t>=55296&&t<56320}function Sne(t,e){let n=t.charCodeAt(e);if(!bne(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return vne(i)?(n-55296<<10)+(i-56320)+65536:n}function xne(t){return t<65536?1:2}const sx=/\r\n?|\n/;var ki=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(ki||(ki={}));class js{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-r);s+=l}else{if(i!=ki.Simple&&f>=e&&(i==ki.TrackDel&&re||i==ki.TrackBefore&&re))return null;if(f>e||f==e&&n<0&&!l)return e==r||n<0?s:s+u;s+=u}r=f}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,n=e){for(let i=0,r=0;i=0&&r<=n&&l>=e)return rn?"cover":!0;r=l}return!1}toString(){let e="";for(let n=0;n=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new js(e)}static create(e){return new js(e)}}class jn extends js{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return ox(this,(n,i,r,s,o)=>e=e.replace(r,r+(i-n),o),!1),e}mapDesc(e,n=!1){return ax(this,e,n,!0)}invert(e){let n=this.sections.slice(),i=[];for(let r=0,s=0;r=0){n[r]=l,n[r+1]=o;let u=r>>1;for(;i.length0&&ya(i,n,s.text),s.forward(h),l+=h}let f=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,i){let r=[],s=[],o=0,l=null;function u(h=!1){if(!h&&!r.length)return;oO||p<0||O>n)throw new RangeError(`Invalid change range ${p} to ${O} (in doc of length ${n})`);let v=y?typeof y=="string"?Ot.of(y.split(i||sx)):y:Ot.empty,S=v.length;if(p==O&&S==0)return;po&&ui(r,p-o,-1),ui(r,O-p,S),ya(s,r,v),o=O}}return f(e),u(!l),l}static empty(e){return new jn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],i=[];for(let r=0;rl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;i.length=0&&n<=0&&n==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=n:i?(t[r]+=e,t[r+1]+=n):t.push(e,n)}function ya(t,e,n){if(n.length==0)return;let i=e.length-2>>1;if(i>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],u=t.sections[o++];e(r,f,s,h,p),r=f,s=h}}}function ax(t,e,n,i=!1){let r=[],s=i?[]:null,o=new zf(t),l=new zf(e);for(let u=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let f=Math.min(o.len,l.len);ui(r,f,-1),o.forward(f),l.forward(f)}else if(l.ins>=0&&(o.ins<0||u==o.i||o.off==0&&(l.len=0&&u=0){let f=0,h=o.len;for(;h;)if(l.ins==-1){let p=Math.min(h,l.len);f+=p,h-=p,l.forward(p)}else if(l.ins==0&&l.lenu||o.ins>=0&&o.len>u)&&(l||i.length>f),s.forward2(u),o.forward(u)}}}}class zf{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?Ot.empty:e[n]}textBit(e){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!e?Ot.empty:n[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ha{constructor(e,n,i,r){this.from=e,this.to=n,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,n):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new ha(i,r,this.flags,this.goalColumn)}extend(e,n=e,i=0){if(e<=this.anchor&&n>=this.anchor)return Oe.range(e,n,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Oe.range(this.anchor,r,void 0,void 0,i)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Oe.range(e.anchor,e.head)}static create(e,n,i,r){return new ha(e,n,i,r)}}class Oe{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Oe.create(this.ranges.map(i=>i.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Oe(e.ranges.map(n=>ha.fromJSON(n)),e.main)}static single(e,n=e){return new Oe([Oe.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;rr.from-s.from),n=e.indexOf(i);for(let r=1;rs.head?Oe.range(u,l):Oe.range(l,u))}}return new Oe(e,n)}}function LN(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let z1=0;class Ne{constructor(e,n,i,r,s){this.combine=e,this.compareInput=n,this.compare=i,this.isStatic=r,this.id=z1++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Ne(e.combine||(n=>n),e.compareInput||((n,i)=>n===i),e.compare||(e.combine?(n,i)=>n===i:L1),!!e.static,e.enables)}of(e){return new Hg([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Hg(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Hg(e,this,2,n)}from(e,n){return n||(n=i=>i),this.compute([e],i=>n(i.field(e)))}}function L1(t,e){return t==e||t.length==e.length&&t.every((n,i)=>n===e[i])}class Hg{constructor(e,n,i,r){this.dependencies=e,this.facet=n,this.type=i,this.value=r,this.id=z1++}dynamicSlot(e){var n;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,u=!1,f=!1,h=[];for(let p of this.dependencies)p=="doc"?u=!0:p=="selection"?f=!0:(((n=e[p.id])!==null&&n!==void 0?n:1)&1)==0&&h.push(e[p.id]);return{create(p){return p.values[o]=i(p),1},update(p,O){if(u&&O.docChanged||f&&(O.docChanged||O.selection)||lx(p,h)){let y=i(p);if(l?!WE(y,p.values[o],r):!r(y,p.values[o]))return p.values[o]=y,1}return 0},reconfigure:(p,O)=>{let y,v=O.config.address[s];if(v!=null){let S=Qm(O,v);if(this.dependencies.every(k=>k instanceof Ne?O.facet(k)===p.facet(k):k instanceof Ao?O.field(k,!1)==p.field(k,!1):!0)||(l?WE(y=i(p),S,r):r(y=i(p),S)))return p.values[o]=S,0}else y=i(p);return p.values[o]=y,1}}}get extension(){return this}}function WE(t,e,n){if(t.length!=e.length)return!1;for(let i=0;it[u.id]),r=n.map(u=>u.type),s=i.filter(u=>!(u&1)),o=t[e.id]>>1;function l(u){let f=[];for(let h=0;hi===r),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(vg).find(i=>i.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:i=>(i.values[n]=this.create(i),1),update:(i,r)=>{let s=i.values[n],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[n]=o,1)},reconfigure:(i,r)=>{let s=i.facet(vg),o=r.facet(vg),l;return(l=s.find(u=>u.field==this))&&l!=o.find(u=>u.field==this)?(i.values[n]=l.create(i),1):r.config.address[this.id]!=null?(i.values[n]=r.field(this),0):(i.values[n]=this.create(i),1)}}}init(e){return[this,vg.of({field:this,create:e})]}get extension(){return this}}const ml={lowest:4,low:3,default:2,high:1,highest:0};function Jd(t){return e=>new ZN(e,t)}const wh={highest:Jd(ml.highest),high:Jd(ml.high),default:Jd(ml.default),low:Jd(ml.low),lowest:Jd(ml.lowest)};class ZN{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class WO{of(e){return new cx(this,e)}reconfigure(e){return WO.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class cx{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Rm{constructor(e,n,i,r,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,i){let r=[],s=Object.create(null),o=new Map;for(let O of kne(e,n,o))O instanceof Ao?r.push(O):(s[O.facet.id]||(s[O.facet.id]=[])).push(O);let l=Object.create(null),u=[],f=[];for(let O of r)l[O.id]=f.length<<1,f.push(y=>O.slot(y));let h=i?.config.facets;for(let O in s){let y=s[O],v=y[0].facet,S=h&&h[O]||[];if(y.every(k=>k.type==0))if(l[v.id]=u.length<<1|1,L1(S,y))u.push(i.facet(v));else{let k=v.combine(y.map(C=>C.value));u.push(i&&v.compare(k,i.facet(v))?i.facet(v):k)}else{for(let k of y)k.type==0?(l[k.id]=u.length<<1|1,u.push(k.value)):(l[k.id]=f.length<<1,f.push(C=>k.dynamicSlot(C)));l[v.id]=f.length<<1,f.push(k=>wne(k,v,y))}}let p=f.map(O=>O(l));return new Rm(e,o,p,l,u,s)}}function kne(t,e,n){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let u=r.get(o);if(u!=null){if(u<=l)return;let f=i[u].indexOf(o);f>-1&&i[u].splice(f,1),o instanceof cx&&n.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let f of o)s(f,l);else if(o instanceof cx){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let f=e.get(o.compartment)||o.inner;n.set(o.compartment,f),s(f,l)}else if(o instanceof ZN)s(o.inner,o.prec);else if(o instanceof Ao)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Hg)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,ml.default);else{let f=o.extension;if(!f)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(f==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(f,l)}}return s(t,ml.default),i.reduce((o,l)=>o.concat(l))}function Sf(t,e){if(e&1)return 2;let n=e>>1,i=t.status[n];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;t.status[n]=4;let r=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|r}function Qm(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const IN=Ne.define(),ux=Ne.define({combine:t=>t.some(e=>e),static:!0}),XN=Ne.define({combine:t=>t.length?t[0]:void 0,static:!0}),VN=Ne.define(),BN=Ne.define(),UN=Ne.define(),qN=Ne.define({combine:t=>t.length?t[0]:!1});class ss{constructor(e,n){this.type=e,this.value=n}static define(){return new Cne}}class Cne{of(e){return new ss(this,e)}}class _ne{constructor(e){this.map=e}of(e){return new Jt(this,e)}}class Jt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Jt(this.type,n)}is(e){return this.type==e}static define(e={}){return new _ne(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(n);s&&i.push(s)}return i}}Jt.reconfigure=Jt.define();Jt.appendConfig=Jt.define();let Ci=class pf{constructor(e,n,i,r,s,o){this.startState=e,this.changes=n,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&LN(i,n.newLength),s.some(l=>l.type==pf.time)||(this.annotations=s.concat(pf.time.of(Date.now())))}static create(e,n,i,r,s,o){return new pf(e,n,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(pf.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}};Ci.time=ss.define();Ci.userEvent=ss.define();Ci.addToHistory=ss.define();Ci.remote=ss.define();function $ne(t,e){let n=[];for(let i=0,r=0;;){let s,o;if(i=t[i]))s=t[i++],o=t[i++];else if(r=0;r--){let s=i[r](t);s instanceof Ci?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Ci?t=s[0]:t=FN(e,su(s),!1)}return t}function Ene(t){let e=t.startState,n=e.facet(UN),i=t;for(let r=n.length-1;r>=0;r--){let s=n[r](t);s&&Object.keys(s).length&&(i=YN(i,dx(e,s,t.changes.newLength),!0))}return i==t?t:Ci.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}const Rne=[];function su(t){return t==null?Rne:Array.isArray(t)?t:[t]}var bo=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(bo||(bo={}));const Qne=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let fx;try{fx=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Ane(t){if(fx)return fx.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||Qne.test(n)))return!0}return!1}function Pne(t){return e=>{if(!/\S/.test(e))return bo.Space;if(Ane(e))return bo.Word;for(let n=0;n-1)return bo.Word;return bo.Other}}class St{constructor(e,n,i,r,s,o){this.config=e,this.doc=n,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;lr.set(f,u)),n=null),r.set(l.value.compartment,l.value.extension)):l.is(Jt.reconfigure)?(n=null,i=l.value):l.is(Jt.appendConfig)&&(n=null,i=su(i).concat(l.value));let s;n?s=e.startState.values.slice():(n=Rm.resolve(i,r,this),s=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(u,f)=>f.reconfigure(u,this),null).values);let o=e.startState.facet(ux)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,o,s,(l,u)=>u.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Oe.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,i=e(n.ranges[0]),r=this.changes(i.changes),s=[i.range],o=su(i.effects);for(let l=1;lo.spec.fromJSON(l,u)))}}return St.create({doc:e.doc,selection:Oe.fromJSON(e.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(e={}){let n=Rm.resolve(e.extensions||[],new Map),i=e.doc instanceof Ot?e.doc:Ot.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||sx)),r=e.selection?e.selection instanceof Oe?e.selection:Oe.single(e.selection.anchor,e.selection.head):Oe.single(0);return LN(r,i.length),n.staticFacet(ux)||(r=r.asSingle()),new St(n,i,r,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` -`}get readOnly(){return this.facet(qN)}phrase(e,...n){for(let i of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>n.length?i:n[s-1]})),e}languageDataAt(e,n,i=-1){let r=[];for(let s of this.facet(IN))for(let o of s(this,n,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return Pne(n.length?n[0]:"")}wordAt(e){let{text:n,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let u=fi(n,o,!1);if(s(n.slice(u,o))!=bo.Word)break;o=u}for(;lt.length?t[0]:4});St.lineSeparator=XN;St.readOnly=qN;St.phrases=Ne.define({compare(t,e){let n=Object.keys(t),i=Object.keys(e);return n.length==i.length&&n.every(r=>t[r]==e[r])}});St.languageData=IN;St.changeFilter=VN;St.transactionFilter=BN;St.transactionExtender=UN;WO.reconfigure=Jt.define();function GN(t,e,n={}){let i={};for(let r of t)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))i[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}class $a{eq(e){return this==e}range(e,n=e){return hx.create(e,n,this)}}$a.prototype.startSide=$a.prototype.endSide=0;$a.prototype.point=!1;$a.prototype.mapMode=ki.TrackDel;function Z1(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let hx=class HN{constructor(e,n,i){this.from=e,this.to=n,this.value=i}static create(e,n,i){return new HN(e,n,i)}};function px(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class I1{constructor(e,n,i,r){this.from=e,this.to=n,this.value=i,this.maxPoint=r}get length(){return Xc(this.to)}findIndex(e,n,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let u=o+l>>1,f=s[u]-e||(i?this.value[u].endSide:this.value[u].startSide)-n;if(u==o)return f>=0?o:l;f>=0?l=u:o=u+1}}between(e,n,i,r){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(i,1e9,!1,s);sk||S==k&&O.startSide>0&&O.endSide<=0)continue;if(!((k-S||O.endSide-O.startSide)<0))if(f<0&&(f=S),O.point&&(h=Math.max(h,k-S)),(S-i||O.startSide-r)>=0)o.push(O),l.push(S-f),u.push(k-f),i=k,r=O.endSide;else{if(S==k)for(let C=o.length;C>0;C--){if((S-(u[C-1]+f)||O.startSide-o[C-1].endSide)>=0){o.splice(C,0,O),l.splice(C,0,S-f),u.splice(C,0,k-f);continue e}if((S-(l[C-1]+f)||O.endSide-o[C-1].startSide)>0)break}s(S,k,O)}}return{mapped:o.length?new I1(l,u,o,h):null,pos:f}}}class mt{constructor(e,n,i,r){this.chunkPos=e,this.chunk=n,this.nextLayer=i,this.maxPoint=r}static create(e,n,i,r){return new mt(e,n,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(i&&(n=n.slice().sort(px)),this.isEmpty)return n.length?mt.of(n):this;let l=new WN(this,null,-1).goto(0),u=0,f=[],h=new ou;for(;l.value||u=0){let p=n[u++];h.addInner(p.from,p.to,p.value,!1)||f.push(p)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s{s||(s=new ou),s.addRange(u,f,h,!1)};for(let u=0;u=s&&e<=s+o.length&&o.between(s,e-s,n-s,i)===!1)return}this.nextLayer.between(e,n,i)}}iter(e=0){return Lf.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Lf.from(e).goto(n)}static compare(e,n,i,r,s=-1){let o=e.filter(p=>p.maxPoint>0||!p.isEmpty&&p.maxPoint>=s),l=n.filter(p=>p.maxPoint>0||!p.isEmpty&&p.maxPoint>=s),u=KE(o,l,i),f=new ef(o,u,s),h=new ef(l,u,s);i.iterGaps((p,O,y)=>JE(f,p,h,O,y,r)),i.empty&&i.length==0&&JE(f,0,h,0,0,r)}static eq(e,n,i=0,r){r==null&&(r=999999999);let s=e.filter(h=>!h.isEmpty&&n.indexOf(h)<0),o=n.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=KE(s,o),u=new ef(s,l,0).goto(i),f=new ef(o,l,0).goto(i);for(;;){if(u.to!=f.to||!gx(u.active,f.active)||u.point&&(!f.point||!Z1(u.point,f.point)))return!1;if(u.to>r)return!0;u.next(),f.next()}}static spans(e,n,i,r,s=-1){let o=new ef(e,null,s).goto(n),l=n,u=o.openStart;for(;;){let f=Math.min(o.to,i);if(o.point){let h=o.activeForPoint(o.to),p=o.pointFroml&&(r.span(l,f,o.active,u),u=o.openEnd(f));if(o.to>i)return u+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,n=!1){let i=new ou;for(let r of e instanceof hx?[e]:n?jne(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return mt.empty;let n=Xc(e);for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=mt.empty;r=r.nextLayer)n=new mt(r.chunkPos,r.chunk,n,Math.max(r.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function Xc(t){return t[t.length-1]}function jne(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(px);e=i}return t}mt.empty.nextLayer=mt.empty;class ou{finishChunk(e){this.chunks.push(new I1(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,i){this.addRange(e,n,i,!0)}addRange(e,n,i,r){this.addInner(e,n,i,r)||(this.nextLayer||(this.nextLayer=new ou)).addRange(e,n,i,r)}addInner(e,n,i,r){let s=e-this.lastTo||i.startSide-this.last.endSide;if(r&&s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=n,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let i=n.value.length-1;return this.last=n.value[i],this.lastFrom=n.from[i]+e,this.lastTo=n.to[i]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function KE(t,e,n){let i=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&r.push(new WN(o,n,i,s));return r.length==1?r[0]:new Lf(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let i of this.heap)i.goto(e,n);for(let i=this.heap.length>>1;i>=0;i--)bb(this.heap,i);return this.next(),this}forward(e,n){for(let i of this.heap)i.forward(e,n);for(let i=this.heap.length>>1;i>=0;i--)bb(this.heap,i);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),bb(this.heap,0)}}}function bb(t,e){for(let n=t[e];;){let i=(e<<1)+1;if(i>=t.length)break;let r=t[i];if(i+1=0&&(r=t[i+1],i++),n.compare(r)<0)break;t[i]=n,t[e]=r,e=i}}class ef{constructor(e,n,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Lf.from(e,n,i)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){bg(this.active,e),bg(this.activeTo,e),bg(this.activeRank,e),this.minActive=eR(this.active,this.activeTo)}addActive(e){let n=0,{value:i,to:r,rank:s}=this.cursor;for(;n0;)n++;Sg(this.active,n,i),Sg(this.activeTo,n,r),Sg(this.activeRank,n,s),e&&Sg(e,n,this.cursor.from),this.minActive=eR(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&bg(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&i[r]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&n.push(this.active[i]);return n.reverse()}openEnd(e){let n=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)n++;return n}}function JE(t,e,n,i,r,s){t.goto(e),n.goto(i);let o=i+r,l=i,u=i-e,f=!!s.boundChange;for(let h=!1;;){let p=t.to+u-n.to,O=p||t.endSide-n.endSide,y=O<0?t.to+u:n.to,v=Math.min(y,o);if(t.point||n.point?(t.point&&n.point&&Z1(t.point,n.point)&&gx(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,v,t.point,n.point),h=!1):(h&&s.boundChange(l),v>l&&!gx(t.active,n.active)&&s.compareRange(l,v,t.active,n.active),f&&vo)break;l=y,O<=0&&t.next(),O>=0&&n.next()}}function gx(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;i--)t[i+1]=t[i];t[e]=n}function eR(t,e){let n=-1,i=1e9;for(let r=0;r=e)return r;if(r==t.length)break;s+=t.charCodeAt(r)==9?n-s%n:1,r=fi(t,r)}return t.length}const mx="ͼ",tR=typeof Symbol>"u"?"__"+mx:Symbol.for(mx),Ox=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),nR=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Ta{constructor(e,n){this.rules=[];let{finish:i}=n||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,u,f){let h=[],p=/^@(\w+)\b/.exec(o[0]),O=p&&p[1]=="keyframes";if(p&&l==null)return u.push(o[0]+";");for(let y in l){let v=l[y];if(/&/.test(y))s(y.split(/,\s*/).map(S=>o.map(k=>S.replace(/&/,k))).reduce((S,k)=>S.concat(k)),v,u);else if(v&&typeof v=="object"){if(!p)throw new RangeError("The value of a property ("+y+") should be a primitive value.");s(r(y),v,h,O)}else v!=null&&h.push(y.replace(/_.*/,"").replace(/[A-Z]/g,S=>"-"+S.toLowerCase())+": "+v+";")}(h.length||O)&&u.push((i&&!p&&!f?o.map(i):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=nR[tR]||1;return nR[tR]=e+1,mx+e.toString(36)}static mount(e,n,i){let r=e[Ox],s=i&&i.nonce;r?s&&r.setNonce(s):r=new Dne(e,s),r.mount(Array.isArray(n)?n:[n],e)}}let iR=new Map;class Dne{constructor(e,n){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=iR.get(i);if(s)return e[Ox]=s;this.sheet=new r.CSSStyleSheet,iR.set(i,this)}else this.styleTag=i.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[Ox]=this}mount(e,n){let i=this.sheet,r=0,s=0;for(let o=0;o-1&&(this.modules.splice(u,1),s--,u=-1),u==-1){if(this.modules.splice(s++,0,l),i)for(let f=0;f",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nne=typeof navigator<"u"&&/Mac/.test(navigator.platform),zne=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Jn=0;Jn<10;Jn++)Ea[48+Jn]=Ea[96+Jn]=String(Jn);for(var Jn=1;Jn<=24;Jn++)Ea[Jn+111]="F"+Jn;for(var Jn=65;Jn<=90;Jn++)Ea[Jn]=String.fromCharCode(Jn+32),Zf[Jn]=String.fromCharCode(Jn);for(var Sb in Ea)Zf.hasOwnProperty(Sb)||(Zf[Sb]=Ea[Sb]);function Lne(t){var e=Nne&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zne&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Zf:Ea)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let wi=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},yx=typeof document<"u"?document:{documentElement:{style:{}}};const vx=/Edge\/(\d+)/.exec(wi.userAgent),KN=/MSIE \d/.test(wi.userAgent),bx=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wi.userAgent),KO=!!(KN||bx||vx),rR=!KO&&/gecko\/(\d+)/i.test(wi.userAgent),xb=!KO&&/Chrome\/(\d+)/.exec(wi.userAgent),sR="webkitFontSmoothing"in yx.documentElement.style,Sx=!KO&&/Apple Computer/.test(wi.vendor),oR=Sx&&(/Mobile\/\w+/.test(wi.userAgent)||wi.maxTouchPoints>2);var Te={mac:oR||/Mac/.test(wi.platform),windows:/Win/.test(wi.platform),linux:/Linux|X11/.test(wi.platform),ie:KO,ie_version:KN?yx.documentMode||6:bx?+bx[1]:vx?+vx[1]:0,gecko:rR,gecko_version:rR?+(/Firefox\/(\d+)/.exec(wi.userAgent)||[0,0])[1]:0,chrome:!!xb,chrome_version:xb?+xb[1]:0,ios:oR,android:/Android\b/.test(wi.userAgent),webkit:sR,webkit_version:sR?+(/\bAppleWebKit\/(\d+)/.exec(wi.userAgent)||[0,0])[1]:0,safari:Sx,safari_version:Sx?+(/\bVersion\/(\d+(\.\d+)?)/.exec(wi.userAgent)||[0,0])[1]:0,tabSize:yx.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function X1(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const Am=Object.create(null);function V1(t,e,n){if(t==e)return!0;t||(t=Am),e||(e=Am);let i=Object.keys(t),r=Object.keys(e);if(i.length-0!=r.length-0)return!1;for(let s of i)if(s!=n&&(r.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function Zne(t,e){for(let n=t.attributes.length-1;n>=0;n--){let i=t.attributes[n].name;e[i]==null&&t.removeAttribute(i)}for(let n in e){let i=e[n];n=="style"?t.style.cssText=i:t.getAttribute(n)!=i&&t.setAttribute(n,i)}}function aR(t,e,n){let i=!1;if(e)for(let r in e)n&&r in n||(i=!0,r=="style"?t.style.cssText="":t.removeAttribute(r));if(n)for(let r in n)e&&e[r]==n[r]||(i=!0,r=="style"?t.style.cssText=n[r]:t.setAttribute(r,n[r]));return i}function Ine(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new Nl(e,n,n,i,e.widget||null,!1)}static replace(e){let n=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=JN(e,n);i=(s?n?-3e8:-1:5e8)-1,r=(o?n?2e8:1:-6e8)+1}return new Nl(e,i,r,n,e.widget||null,!0)}static line(e){return new Ch(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Tt.none=mt.empty;class kh extends Tt{constructor(e){let{start:n,end:i}=JN(e);super(n?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?X1(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Am}eq(e){return this==e||e instanceof kh&&this.tagName==e.tagName&&V1(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}kh.prototype.point=!1;class Ch extends Tt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ch&&this.spec.class==e.spec.class&&V1(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Ch.prototype.mapMode=ki.TrackBefore;Ch.prototype.point=!0;class Nl extends Tt{constructor(e,n,i,r,s,o){super(n,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?n<=0?ki.TrackBefore:ki.TrackAfter:ki.TrackDel}get type(){return this.startSide!=this.endSide?Ui.WidgetRange:this.startSide<=0?Ui.WidgetBefore:Ui.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Nl&&Xne(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}Nl.prototype.point=!0;function JN(t,e=!1){let{inclusiveStart:n,inclusiveEnd:i}=t;return n==null&&(n=t.inclusive),i==null&&(i=t.inclusive),{start:n??e,end:i??e}}function Xne(t,e){return t==e||!!(t&&e&&t.compare(e))}function au(t,e,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=t?n[r]=Math.max(n[r],e):n.push(t,e)}class If extends $a{constructor(e,n,i){super(),this.tagName=e,this.attributes=n,this.rank=i}eq(e){return e==this||e instanceof If&&this.tagName==e.tagName&&V1(this.attributes,e.attributes)}static create(e){return new If(e.tagName,e.attributes||Am,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}If.prototype.startSide=If.prototype.endSide=-1;function Xf(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function xx(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function xf(t,e){if(!e.anchorNode)return!1;try{return xx(t,e.anchorNode)}catch{return!1}}function Wg(t){return t.nodeType==3?Vf(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function wf(t,e,n,i){return n?lR(t,e,n,i,-1)||lR(t,e,n,i,1):!1}function Ra(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Pm(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function lR(t,e,n,i,r){for(;;){if(t==n&&e==i)return!0;if(e==(r<0?0:Eo(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Ra(t)+(r<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(r<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=r<0?Eo(t):0}else return!1}}function Eo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function jm(t,e){let{left:n,right:i}=t;if(n==i)return t;let r=e?n:i;return{left:r,right:r,top:t.top,bottom:t.bottom}}function Vne(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function ez(t,e){let n=e.width/t.offsetWidth,i=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-t.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function Bne(t,e,n,i,r,s,o,l){let u=t.ownerDocument,f=u.defaultView||window;for(let h=t,p=!1;h&&!p;)if(h.nodeType==1){let O,y=h==u.body,v=1,S=1;if(y)O=Vne(f);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(p=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let $=h.getBoundingClientRect();({scaleX:v,scaleY:S}=ez(h,$)),O={left:$.left,right:$.left+h.clientWidth*v,top:$.top,bottom:$.top+h.clientHeight*S}}let k=0,C=0;if(r=="nearest")e.top0&&e.bottom>O.bottom+C&&(C=e.bottom-O.bottom+o)):e.bottom>O.bottom-o&&(C=e.bottom-O.bottom+o,n<0&&e.top-C0&&e.right>O.right+k&&(k=e.right-O.right+s)):e.right>O.right-s&&(k=e.right-O.right+s,n<0&&e.leftO.bottom||e.leftO.right)&&(e={left:Math.max(e.left,O.left),right:Math.min(e.right,O.right),top:Math.max(e.top,O.top),bottom:Math.min(e.bottom,O.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function tz(t,e=!0){let n=t.ownerDocument,i=null,r=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}class Une{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:i}=e;this.set(n,Math.min(e.anchorOffset,n?Eo(n):0),i,Math.min(e.focusOffset,i?Eo(i):0))}set(e,n,i,r){this.anchorNode=e,this.anchorOffset=n,this.focusNode=i,this.focusOffset=r}}function nz(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function iz(t,e=!0){for(let{node:n,left:i,top:r}of t)e&&n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}let gl=null;Te.safari&&Te.safari_version>=26&&(gl=!1);function rz(t){if(t.setActive)return t.setActive();if(gl)return t.focus(gl);let e=nz(t);t.focus(gl==null?{get preventScroll(){return gl={preventScroll:!0},!0}}:void 0),gl||(gl=!1,iz(e))}let cR;function Vf(t,e,n=e){let i=cR||(cR=document.createRange());return i.setEnd(t,n),i.setStart(t,e),i}function lu(t,e,n,i){let r={key:e,code:e,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function qne(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function Yne(t,e){let n=e.focusNode,i=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=i)return!1;for(i=Math.min(i,Eo(n));;)if(i){if(n.nodeType!=1)return!1;let r=n.childNodes[i-1];r.contentEditable=="false"?i--:(n=r,i=Eo(n))}else{if(n==t)return!0;i=Ra(n),n=n.parentNode}}function sz(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function oz(t,e){for(let n=t,i=e;;){if(n.nodeType==3&&i>0)return{node:n,offset:i};if(n.nodeType==1&&i>0){if(n.contentEditable=="false")return null;n=n.childNodes[i-1],i=Eo(n)}else if(n.parentNode&&!Pm(n))i=Ra(n),n=n.parentNode;else return null}}function az(t,e){for(let n=t,i=e;;){if(n.nodeType==3&&i=n){if(l.level==i)return o;(s<0||(r!=0?r<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function uz(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;S-=3)if(gs[S+1]==-y){let k=gs[S+2],C=k&2?r:k&4?k&1?s:r:0;C&&(Vt[p]=Vt[gs[S]]=C),l=S;break}}else{if(gs.length==189)break;gs[l++]=p,gs[l++]=O,gs[l++]=u}else if((v=Vt[p])==2||v==1){let S=v==r;u=S?0:1;for(let k=l-3;k>=0;k-=3){let C=gs[k+2];if(C&2)break;if(S)gs[k+2]|=2;else{if(C&4)break;gs[k+2]|=4}}}}}function Jne(t,e,n,i){for(let r=0,s=i;r<=n.length;r++){let o=r?n[r-1].to:t,l=ru;)v==k&&(v=n[--S].from,k=S?n[S-1].to:t),Vt[--v]=y;u=h}else s=f,u++}}}function kx(t,e,n,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let u=e,f=0;uu&&o.push(new $s(u,S.from,y));let k=S.direction==zl!=!(y%2);Cx(t,k?i+1:i,r,S.inner,S.from,S.to,o),u=S.to}v=S.to}else{if(v==n||(h?Vt[v]!=l:Vt[v]==l))break;v++}O?kx(t,u,v,i+1,r,O,o):ue;){let h=!0,p=!1;if(!f||u>s[f-1].to){let S=Vt[u-1];S!=l&&(h=!1,p=S==16)}let O=!h&&l==1?[]:null,y=h?i:i+1,v=u;e:for(;;)if(f&&v==s[f-1].to){if(p)break e;let S=s[--f];if(!h)for(let k=S.from,C=f;;){if(k==e)break e;if(C&&s[C-1].to==k)k=s[--C].from;else{if(Vt[k-1]==l)break e;break}}if(O)O.push(S);else{S.toVt.length;)Vt[Vt.length]=256;let i=[],r=e==zl?0:1;return Cx(t,r,r,n,0,t.length,i),i}function dz(t){return[new $s(0,t,0)]}let fz="";function tie(t,e,n,i,r){var s;let o=i.head-t.from,l=$s.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),u=e[l],f=u.side(r,n);if(o==f){let O=l+=r?1:-1;if(O<0||O>=e.length)return null;u=e[l=O],o=u.side(!r,n),f=u.side(r,n)}let h=fi(t.text,o,u.forward(r,n));(hu.to)&&(h=f),fz=t.text.slice(Math.min(o,h),Math.max(o,h));let p=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return p&&h==f&&p.level+(r?0:1)t.some(e=>e)}),iie=Ne.define({combine:t=>t.some(e=>e)}),bz=Ne.define();class cu{constructor(e,n,i,r,s,o=!1){this.range=e,this.y=n,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new cu(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new cu(Oe.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const xg=Jt.define({map:(t,e)=>t.map(e)}),Sz=Jt.define();function Ts(t,e,n){let i=t.facet(mz);i.length?i[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Oo=Ne.define({combine:t=>t.length?t[0]:!0});let rie=0;const Wc=Ne.define({combine(t){return t.filter((e,n)=>{for(let i=0;i{let u=[];return o&&u.push(JO.of(f=>{let h=f.plugin(l);return h?o(h):Tt.none})),s&&u.push(s(l)),u})}static fromClass(e,n){return Dr.define((i,r)=>new e(i,r),n)}}class wb{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(i){if(Ts(n.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Ts(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(i){Ts(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const xz=Ne.define(),Y1=Ne.define(),JO=Ne.define(),wz=Ne.define(),F1=Ne.define(),_h=Ne.define(),kz=Ne.define();function uR(t,e){let n=t.state.facet(kz);if(!n.length)return n;let i=n.map(s=>s instanceof Function?s(t):s),r=[];return mt.spans(i,e.from,e.to,{point(){},span(s,o,l,u){let f=s-e.from,h=o-e.from,p=r;for(let O=l.length-1;O>=0;O--,u--){let y=l[O].spec.bidiIsolate,v;if(y==null&&(y=nie(e.text,f,h)),u>0&&p.length&&(v=p[p.length-1]).to==f&&v.direction==y)v.to=h,p=v.inner;else{let S={from:f,to:h,direction:y,inner:[]};p.push(S),p=S.inner}}}}),r}const Cz=Ne.define();function _z(t){let e=0,n=0,i=0,r=0;for(let s of t.state.facet(Cz)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:n,top:i,bottom:r}}const gf=Ne.define();class Rr{constructor(e,n,i,r){this.fromA=e,this.toA=n,this.fromB=i,this.toB=r}join(e){return new Rr(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,i=this;for(;n>0;n--){let r=e[n-1];if(!(r.fromA>i.toA)){if(r.toAr.push(new Rr(s,o,l,u))),this.changedRanges=r}static create(e,n,i){return new Mm(e,n,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const sie=[];class fn{constructor(e,n,i=0){this.dom=e,this.length=n,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return sie}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&Zne(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let i=n;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,i){return null}domPosFor(e,n){let i=Ra(this.dom),r=this.length?e>0:n>0;return new Kr(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof ty)return e;return null}static get(e){return e.cmTile}}class ey extends fn{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,i=null,r,s=e?.node==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:n.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;r&&r!=l.dom;)r=dR(r);else n.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:n.firstChild,s&&r&&(s.written=!0);r;)r=dR(r);this.length=o}}function dR(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class ty extends ey{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=fn.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!n.length)return;i=i.parent,i.breakAfter&&s++,r=n.pop()}else{let o=i.children[r++];if(o instanceof ko)n.push(r),i=o,r=0;else{let l=s+o.length,u=e(o,s);if(u!==void 0)return u;s=l+o.breakAfter}}}resolveBlock(e,n){let i,r=-1,s,o=-1;if(this.blockTiles((l,u)=>{let f=u+l.length;if(e>=u&&e<=f){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(ue||e==u&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-u)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&n<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}}class ko extends ey{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let i=new ko(n||document.createElement(e.tagName),e);return n||(i.flags|=4),i}}class Cu extends ey{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,i){let r=new Cu(n||document.createElement("div"),e);return(!n||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,n,i){let r=null,s=-1,o=null,l=-1;function u(h,p){for(let O=0,y=0;O=p&&(v.isComposite()?u(v,p-y):(!o||o.isHidden&&(n>0&&!(o.flags&32)||i&&aie(o,v)))&&(S>p||v.flags&32&&n<=1)?(o=v,l=p-y):(y=-1)&&(r=v,s=p-y)),y=S}}u(this,e);let f=(n<0?r:o)||r||o;return f?{tile:f,offset:f==r?s:l}:null}coordsIn(e,n,i){let r=this.resolveInline(e,n,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),n,i):oie(this)}domIn(e,n){let i=this.resolveInline(e,n);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new Kr(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:n);let o=i.tile.parent,l=!1;for(let u of o.children){if(l)return new Kr(u.dom,0);u==i.tile&&(l=!0)}}return new Kr(this.dom,0)}}function oie(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=Wg(e);return n[n.length-1]||null}function aie(t,e){let n=t.coordsIn(0,1),i=e.coordsIn(0,1);return n&&i&&i.topr&&(e=r);let s=e,o=e,l=0;e==0&&n<0||e==r&&n>=0?Te.chrome||Te.gecko||(e?(s--,l=1):o=0)?0:u.length-1];return Te.safari&&!l&&f.width==0&&(f=Array.prototype.find.call(u,h=>h.width)||f),i==null?f:jm(f,(l?l>0:n<0)==i)}static of(e,n){let i=new Sl(n||document.createTextNode(e),e);return n||(i.flags|=2),i}}class Ll extends fn{constructor(e,n,i,r){super(e,n,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,i){let r=this.widget.coordsAt(this.dom,e,n);if(r)return r;if(i)return jm(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let u=l?s.length-1:0;o=s[u],!(e>0?u==0:u==s.length-1||o.top0==i)}}class lie{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let u=r.children[s],f=u.breakAfter;(n>0?u.length<=e:u.length=0;l--){let u=n.marks[l],f=r.lastChild;if(f instanceof Ii&&f.mark.eq(u.mark))f.dom!=u.dom&&f.setDOM(kb(u.dom)),r=f;else{if(this.cache.reused.get(u)){let p=fn.get(u.dom);p&&p.setDOM(kb(u.dom))}let h=Ii.of(u.mark,u.dom);r.append(h),r=h}this.cache.reused.set(u,2)}let s=fn.get(e.text);s&&this.cache.reused.set(s,2);let o=new Sl(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,n,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(n,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,i){this.flushBuffer(),this.ensureMarks(n,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var i;e||(e=$z);let r=Cu.start(e,n||((i=this.cache.find(Cu))===null||i===void 0?void 0:i.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=r.lastChild)&&l instanceof Ii&&l.mark.eq(o))r=l,n--;else{let u=Ii.of(o,(i=this.cache.find(Ii,f=>f.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(u),r=u,n=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!fR(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Te.ios&&fR(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Cb,0,32)||new Ll(Cb.toDOM(),0,Cb,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,i=new cie(e.from,e.to,e.value,n),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let i of this.wrappers){let r=n.lastChild;if(i.fromo.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),i=this.cache.find(Dm,void 0,1);return i&&(i.flags=n),i||new Dm(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class die{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,n);return this.textOff=n,i}}const Nm=[Ll,Cu,Sl,Ii,Dm,ko,ty];for(let t=0;t[]),this.index=Nm.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,i=this.buckets[n];i.length<6?i.push(e):i[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let i=n&&this.getCompositionContext(n.text);for(let r=0,s=0,o=0;;){let l=or){let f=u-r;this.preserve(f,!o,!l),r=u,s+=f}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(u-l);else{let f=u>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Ii&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof Ii&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let i=null,r=this.builder,s=-1,o=mt.spans(this.decorations,e,n,{point:(l,u,f,h,p,O)=>{if(f instanceof Nl){if(this.disallowBlockEffectsFor[O]){if(f.block)throw new RangeError("Block decorations may not be specified via plugins");if(u>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=h.length,p>h.length)r.continueWidget(u-l);else{let y=f.widget||(f.block?_u.block:_u.inline),v=pie(f),S=this.cache.findWidget(y,u-l,v)||Ll.of(y,this.view,u-l,v);f.block?(f.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(S)):(r.ensureLine(i),r.addInlineWidget(S,h,p))}i=null}else i=gie(i,f);u>l&&this.text.skip(u-l)},span:(l,u,f,h)=>{for(let p=l;p-1&&(this.openWidget=o>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,n,i=1){n-e<=10?this.old.advance(n-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let n=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=fn.get(r);if(r==this.view.contentDOM)break;s instanceof Ii?n.push(s):s?.isLine()?i=s:s instanceof ko||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new Cu(r,$z):i||n.push(Ii.of(new kh({tagName:r.nodeName.toLowerCase(),attributes:Ine(r)}),r)))}return{line:i,marks:n}}}function fR(t,e){let n=i=>{for(let r of i.children)if((e?r.isText():r.length)||n(r))return!0;return!1};return n(t)}function pie(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const $z={class:"cm-line"};function gie(t,e){let n=e.spec.attributes,i=e.spec.class;return!n&&!i||(t||(t={class:"cm-line"}),n&&X1(n,t),i&&(t.class+=" "+i)),t}function mie(t){let e=[];for(let n=t.parents.length;n>1;n--){let i=n==t.parents.length?t.tile:t.parents[n].tile;i instanceof Ii&&e.push(i.mark)}return e}function kb(t){let e=fn.get(t);return e&&e.setDOM(t.cloneNode()),t}class _u extends Yu{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}_u.inline=new _u("span");_u.block=new _u("div");const Cb=new class extends Yu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class hR{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Tt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new ty(e,e.contentDOM),this.updateInner([new Rr(0,0,0,e.state.doc.length)],null)}update(e){var n;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:p})=>pthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?r=this.domChanged.newSel.head:!Cie(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?yie(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:p}=this.hasComposition;i=new Rr(h,p,e.changes.mapPos(h,-1),e.changes.mapPos(p,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Te.ie||Te.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let u=Sie(o,this.decorations,e.changes);u.length&&(i=Rr.extendWithRanges(i,u));let f=wie(l,this.blockWrappers,e.changes);return f.length&&(i=Rr.extendWithRanges(i,f)),s&&!i.some(h=>h.fromA<=s.range.fromA&&h.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(n||e.length){let o=this.tile,l=new hie(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&fn.get(n.text)&&l.cache.reused.set(fn.get(n.text),2),this.tile=l.run(e,n),$x(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Te.chrome||Te.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&xf(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let u=this.view.state.selection.main,f,h;if(u.empty?h=f=this.inlineDOMNearPos(u.anchor,u.assoc||1):(h=this.inlineDOMNearPos(u.head,u.head==u.from?1:-1),f=this.inlineDOMNearPos(u.anchor,u.anchor==u.from?1:-1)),Te.gecko&&u.empty&&!this.hasComposition&&Oie(f)){let O=document.createTextNode("");this.view.observer.ignore(()=>f.node.insertBefore(O,f.node.childNodes[f.offset]||null)),f=h=new Kr(O,0),l=!0}let p=this.view.observer.selectionRange;(l||!p.focusNode||(!wf(f.node,f.offset,p.anchorNode,p.anchorOffset)||!wf(h.node,h.offset,p.focusNode,p.focusOffset))&&!this.suppressWidgetCursorChange(p,u))&&(this.view.observer.ignore(()=>{Te.android&&Te.chrome&&i.contains(p.focusNode)&&kie(p.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let O=Xf(this.view.root);if(O)if(u.empty){if(Te.gecko){let y=vie(f.node,f.offset);if(y&&y!=3){let v=(y==1?oz:az)(f.node,f.offset);v&&(f=new Kr(v.node,v.offset))}}O.collapse(f.node,f.offset),u.bidiLevel!=null&&O.caretBidiLevel!==void 0&&(O.caretBidiLevel=u.bidiLevel)}else if(O.extend){O.collapse(f.node,f.offset);try{O.extend(h.node,h.offset)}catch{}}else{let y=document.createRange();u.anchor>u.head&&([f,h]=[h,f]),y.setEnd(h.node,h.offset),y.setStart(f.node,f.offset),O.removeAllRanges(),O.addRange(y)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(f,h)),this.impreciseAnchor=f.precise?null:new Kr(p.anchorNode,p.anchorOffset),this.impreciseHead=h.precise?null:new Kr(p.focusNode,p.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&wf(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,i=Xf(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!n.empty||!n.assoc||!i.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let u=this.coordsAt(n.head,-1),f=this.coordsAt(n.head,1);if(!u||!f||u.bottom>f.top)return;let h=this.domAtPos(n.head+n.assoc,n.assoc);i.collapse(h.node,h.offset),i.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let p=e.observer.selectionRange;e.docView.posFromDOM(p.anchorNode,p.anchorOffset)!=n.from&&i.collapse(r,s)}posFromDOM(e,n){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[n];else{let o=Eo(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!fn.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let u=i.children[o];if(u.dom==s)return l;l+=u.length+u.breakAfter}}else return i.isText()?e==i.dom?r+n:r+(n?i.length:0):r}domAtPos(e,n){let{tile:i,offset:r}=this.tile.resolveBlock(e,n);return i.isWidget()?i.domPosFor(r,n):i.domIn(r,n)}inlineDOMNearPos(e,n){let i,r=-1,s=!1,o,l=-1,u=!1;return this.tile.blockTiles((f,h)=>{if(f.isWidget()){if(f.flags&32&&h>=e)return!0;f.flags&16&&(s=!0)}else{let p=h+f.length;if(h<=e&&(i=f,r=e-h,s=p=e&&!o&&(o=f,l=e-h,u=h>e),h>e&&o)return!0}}),!i&&!o?this.domAtPos(e,n):(s&&o?i=null:u&&i&&(o=null),i&&n<0||!o?i.domIn(r,n):o.domIn(l,n))}coordsAt(e,n,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.widget instanceof _b?null:r.coordsInWidget(s,n,!0):r.coordsIn(s,n,i)}lineAt(e,n){let{tile:i}=this.tile.resolveBlock(e,n);return i.isLine()?i:null}coordsForChar(e){let{tile:n,offset:i}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let u=r(l,o);if(u)return u}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,u=this.view.textDirection==bn.LTR,f=0,h=(p,O,y)=>{for(let v=0;vr);v++){let S=p.children[v],k=O+S.length,C=S.dom.getBoundingClientRect(),{height:$}=C;if(y&&!v&&(f+=C.top-y.top),S instanceof ko)k>i&&h(S,O,C);else if(O>=i&&(f>0&&n.push(-f),n.push($+f),f=0,o)){let T=S.dom.lastChild,Q=T?Wg(T):[];if(Q.length){let A=Q[Q.length-1],R=u?A.right-C.left:C.right-A.left;R>l&&(l=R,this.minWidth=s,this.minWidthFrom=O,this.minWidthTo=k)}}y&&v==p.children.length-1&&(f+=y.bottom-C.bottom),O=k+S.breakAfter}};return h(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?bn.RTL:bn.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,u;for(let f of o.children){if(!f.isText()||/[^ -~]/.test(f.text))return;let h=Wg(f.dom);if(h.length!=1)return;l+=h[0].width,u=h[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:u}}});if(e)return e;let n=document.createElement("div"),i,r,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=Wg(n.firstChild)[0];i=n.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,n.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let i=0,r=0;;r++){let s=r==n.viewports.length?null:n.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(i).top)/this.view.scaleY;e.push(Tt.replace({widget:new _b(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Tt.set(e)}updateDeco(){let e=1,n=this.view.state.facet(JO).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(F1).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,n.push(mt.join(r))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let f=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=f.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let f of this.view.state.facet(bz))try{if(f(this.view,e.range,e))return!0}catch(h){Ts(this.view.state,h,"scroll handler")}let{range:n}=e,i=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),r;if(!i)return;!n.empty&&(r=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=_z(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:u}=this.view.scrollDOM;if(Bne(this.view.scrollDOM,o,n.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){$x(this.tile)}}function $x(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let i of t.children)$x(i,e)}}function Oie(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function Tz(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let i=oz(n.focusNode,n.focusOffset),r=az(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=fn.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(t.docView.lastCompositionAfterCursor){let u=fn.get(i.node);!u||u.isText()&&u.text!=i.node.nodeValue||(s=r)}}if(t.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function yie(t,e,n){let i=Tz(t,n);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(i.from,i.to)!=l)return null;let u=e.invertedDesc;return{range:new Rr(u.mapPos(s),u.mapPos(o),s,o),text:r}}function vie(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(n=!0)}),n}class _b extends Yu{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function _ie(t,e,n=1){let i=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(r.length==0)return Oe.cursor(e);s==0?n=1:s==r.length&&(n=-1);let o=s,l=s;n<0?o=fi(r.text,s,!1):l=fi(r.text,s);let u=i(r.text.slice(o,l));for(;o>0;){let f=fi(r.text,o,!1);if(i(r.text.slice(f,o))!=u)break;o=f}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,u=Math.floor((r-n.top-(t.defaultLineHeight-l)*.5)/l);s+=u*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+Mne(o,s,t.state.tabSize)}function Tie(t,e,n){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.toe)return s;(!r||s.type==Ui.Text&&(r.type!=s.type||(n<0?s.frome)))&&(r=s)}}return r||i}return i}function Eie(t,e,n,i){let r=Tie(t,e.head,e.assoc||-1),s=!i||r.type!=Ui.Text||!(t.lineWrapping||r.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(r.from),u=t.posAtCoords({x:n==(l==bn.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(u!=null)return Oe.cursor(u,n?-1:1)}return Oe.cursor(n?r.to:r.from,n?-1:1)}function pR(t,e,n,i){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let l=e,u=null;;){let f=tie(r,s,o,l,n),h=fz;if(!f){if(r.number==(n?t.state.doc.lines:1))return l;h=` -`,r=t.state.doc.line(r.number+(n?1:-1)),s=t.bidiSpans(r),f=t.visualLineSide(r,!n)}if(u){if(!u(h))return l}else{if(!i)return f;u=i(h)}l=f}}function Rie(t,e,n){let i=t.state.charCategorizer(e),r=i(n);return s=>{let o=i(s);return r==bo.Space&&(r=o),r==o}}function Qie(t,e,n,i){let r=e.head,s=n?1:-1;if(r==(n?t.state.doc.length:0))return Oe.cursor(r,e.assoc);let o=e.goalColumn,l,u=t.contentDOM.getBoundingClientRect(),f=t.coordsAtPos(r,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),h=t.documentTop;if(f)o==null&&(o=f.left-u.left),l=s<0?f.top:f.bottom;else{let v=t.viewState.lineBlockAt(r);o==null&&(o=Math.min(u.right-u.left,t.defaultCharacterWidth*(r-v.from))),l=(s<0?v.top:v.bottom)+h}let p=u.left+o,O=t.viewState.heightOracle.textHeight>>1,y=i??O;for(let v=0;;v+=O){let S=l+(y+v)*s,k=Tx(t,{x:p,y:S},!1,s);if(n?S>u.bottom:Sl:${if(e>s&&er(t)),n.from,e.head>n.from?-1:1);return i==n.from?n:Oe.cursor(i,it.viewState.docHeight)return new ks(t.state.doc.length,-1);if(f=t.elementAtHeight(u),i==null)break;if(f.type==Ui.Text){if(i<0?f.tot.viewport.to)break;let O=t.docView.coordsAt(i<0?f.from:f.to,i>0?-1:1);if(O&&(i<0?O.top<=u+s:O.bottom>=u+s))break}let p=t.viewState.heightOracle.textHeight/2;u=i>0?f.bottom+p:f.top-p}if(t.viewport.from>=f.to||t.viewport.to<=f.from){if(n)return null;if(f.type==Ui.Text){let p=$ie(t,r,f,o,l);return new ks(p,p==f.from?1:-1)}}if(f.type!=Ui.Text)return u<(f.top+f.bottom)/2?new ks(f.from,1):new ks(f.to,-1);let h=t.docView.lineAt(f.from,2);return(!h||h.length!=f.length)&&(h=t.docView.lineAt(f.from,-2)),new Aie(t,o,l,t.textDirectionAt(f.from)).scanTile(h,f.from)}class Aie{constructor(e,n,i,r){this.view=e,this.x=n,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from>1;t:if(o.has(S)){for(let $=1;$=s&&(T-=v),!o.has(T)){S=T;break t}}break e}o.add(S);let k=n(S),C=0;if(k)for(let $=0;$1))if(T.bottomthis.y)(!f||f.top>T.top)&&(f=T),C=-1;else{let Q=T.left>this.x?this.x-T.left:T.right(v+v+S)/3)return this.y=u.bottom-1,this.scan(e,n,!0);if(f&&f.top<(v+S+S)/3)return this.y=f.top+1,this.scan(e,n,!0)}let y=(l?this.dirAt(e[h],1):this.baseDir)==bn.LTR;return{i:h,after:this.x>(O.left+O.right)/2==y}}scanText(e,n){let i=[];for(let s=0;s{let o=i[s]-n,l=i[s+1]-n;return Vf(e.dom,o,l).getClientRects()});return r.after?new ks(i[r.i+1],-1):new ks(i[r.i],1)}scanTile(e,n){if(!e.length)return new ks(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let i=[n];for(let l=0,u=n;l{let u=e.children[l];return u.flags&48?null:(u.dom.nodeType==1?u.dom:Vf(u.dom,0,u.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new ks(i[r.i+1],-1):new ks(o,1)}}const Vc="￿";class Pie{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Vc}readRange(e,n){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=fn.get(r),l=r.nextSibling;if(l==n){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let u=fn.get(l);(o&&u?o.breakAfter:(o?o.breakAfter:Pm(r))||Pm(l)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!Mie(l,n)&&this.lineBreak(),r=l}return this.findPointBefore(i,n),this}readTextNode(e){let n=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,n.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(i,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let u of this.points)u.node==e&&u.pos>this.text.length&&(u.pos-=o-1);i=s+o}}readNode(e){let n=fn.get(e),i=n&&n.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==n&&(i.pos=this.text.length)}findPointInside(e,n){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(jie(e,i.node,i.offset)?n:0))}}function jie(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Rz(e.docView.tile,n,i,0))){let u=s||o?[]:zie(e),f=new Pie(u,e);f.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=f.text,this.newSel=Lie(u,this.bounds.from)}else{let u=e.observer.selectionRange,f=s&&s.node==u.focusNode&&s.offset==u.focusOffset||!xx(e.contentDOM,u.focusNode)?l.main.head:e.docView.posFromDOM(u.focusNode,u.focusOffset),h=o&&o.node==u.anchorNode&&o.offset==u.anchorOffset||!xx(e.contentDOM,u.anchorNode)?l.main.anchor:e.docView.posFromDOM(u.anchorNode,u.anchorOffset),p=e.viewport;if((Te.ios||Te.chrome)&&f!=h&&Math.min(f,h)<=l.main.from&&Math.max(f,h)>=l.main.to&&(p.from>0||p.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(Oe.range(h,f));else if(e.lineWrapping&&h==f&&!(l.main.empty&&l.main.head==f)&&e.inputState.lastTouchTime>Date.now()-100){let O=e.coordsAtPos(f,-1),y=0;O&&(y=e.inputState.lastTouchY<=O.bottom?-1:1),this.newSel=Oe.create([Oe.cursor(f,y)])}else this.newSel=Oe.single(h,f)}}}function Rz(t,e,n,i){if(t.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let u=0,f=i,h=i;un)return Rz(p,e,n,f);if(O>=e&&r==-1&&(r=u,s=f),f>n&&p.dom.parentNode==t.dom){o=u,l=h;break}h=O,f=O+p.breakAfter}return{from:s,to:l<0?i+t.length:l,startDOM:(r?t.children[r-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:i,to:i+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Qz(t,e){let n,{newSel:i}=e,{state:r}=t,s=r.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:u}=e.bounds,f=s.from,h=null;(o===8||Te.android&&e.text.length=l&&s.to<=u&&(e.typeOver||p!=e.text)&&p.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&p.slice(s.to-l)==e.text.slice(O=e.text.length-(p.length-(s.to-l)))?n={from:s.from,to:s.to,insert:Ot.of(e.text.slice(s.from-l,O).split(Vc))}:(y=Az(p,e.text,f-l,h))&&(Te.chrome&&o==13&&y.toB==y.from+2&&e.text.slice(y.from,y.toB)==Vc+Vc&&y.toB--,n={from:l+y.from,to:l+y.toA,insert:Ot.of(e.text.slice(y.from,y.toB).split(Vc))})}else i&&(!t.hasFocus&&r.facet(Oo)||zm(i,s))&&(i=null);if(!n&&!i)return!1;if((Te.mac||Te.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(i&&n.insert.length==2&&(i=Oe.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:Ot.of([n.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:r.toText(t.inputState.insertingText)}:Te.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` - `&&t.lineWrapping&&(i&&(i=Oe.single(i.main.anchor-1,i.main.head-1)),n={from:s.from,to:s.to,insert:Ot.of([" "])}),n)return G1(t,n,i,o);if(i&&!zm(i,s)){let l=!1,u="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),u=t.inputState.lastSelectionOrigin,u=="select.pointer"&&(i=Ez(r.facet(_h).map(f=>f(t)),i))),t.dispatch({selection:i,scrollIntoView:l,userEvent:u}),!0}else return!1}function G1(t,e,n,i=-1){if(Te.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(Te.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&lu(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.lengthr.head)&&lu(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&lu(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=Nie(t,e,n));return t.state.facet(Oz).some(u=>u(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function Nie(t,e,n){let i,r=t.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let u=e.fromp(t)),f,u);e.from==h&&(o=h)}if(o>-1)i={changes:e,selection:Oe.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let u=s.frome.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(t.state.toText(u+e.insert.sliceString(0,void 0,t.state.lineBreak)+f))}else{let u=r.changes(e),f=n&&n.main.to<=u.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let h=t.state.sliceDoc(e.from,e.to),p,O=n&&Tz(t,n.main.head);if(O){let v=e.insert.length-(e.to-e.from);p={from:O.from,to:O.to-v}}else p=t.state.doc.lineAt(s.head);let y=s.to-e.to;i=r.changeByRange(v=>{if(v.from==s.from&&v.to==s.to)return{changes:u,range:f||v.map(u)};let S=v.to-y,k=S-h.length;if(t.state.sliceDoc(k,S)!=h||S>=p.from&&k<=p.to)return{range:v};let C=r.changes({from:k,to:S,insert:e.insert}),$=v.to-s.to;return{changes:C,range:f?Oe.range(Math.max(0,f.anchor+$),Math.max(0,f.head+$)):v.map(C)}})}else i={changes:u,selection:f&&r.selection.replaceRange(f)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function Az(t,e,n,i){let r=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let u=Math.max(0,s-Math.min(o,l));n-=o+u-s}if(o=o?s-n:0;s-=u,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=u,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function zie(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new gR(n,i)),(r!=n||s!=i)&&e.push(new gR(r,s))),e}function Lie(t,e){if(t.length==0)return null;let n=t[0].pos,i=t.length==2?t[1].pos:n;return n>-1&&i>-1?Oe.single(n+e,i+e):null}function zm(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class Zie{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Te.safari&&e.contentDOM.addEventListener("input",()=>null),Te.gecko&&nre(e.contentDOM.ownerDocument)}handleEvent(e){!Gie(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,n);for(let r of i.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=Xie(e),i=this.handlers,r=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!n[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&jz.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Te.android&&Te.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Te.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Pz.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||Vie.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Te.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&Iie(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Te.safari&&!Te.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Iie(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function mR(t,e){return(n,i)=>{try{return e.call(t,i,n)}catch(r){Ts(n.state,r)}}}function Xie(t){let e=Object.create(null);function n(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of t){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let u=s[l];u&&n(l).handlers.push(mR(i.value,u))}if(o)for(let l in o){let u=o[l];u&&n(l).observers.push(mR(i.value,u))}}for(let i in ts)n(i).handlers.push(ts[i]);for(let i in $i)n(i).observers.push($i[i]);return e}const Pz=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Vie="dthko",jz=[16,17,18,20,91,92,224,225],wg=6;function kg(t){return Math.max(0,t)*.7+8}function Bie(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class Uie{constructor(e,n,i,r){this.view=e,this.startEvent=n,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=tz(e.contentDOM),this.atoms=e.state.facet(_h).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&qie(e,n),this.dragging=Fie(e,n)&&Nz(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Bie(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let u=_z(this.view);e.clientX-u.left<=r+wg?n=-kg(r-e.clientX):e.clientX+u.right>=o-wg&&(n=kg(e.clientX-o)),e.clientY-u.top<=s+wg?i=-kg(s-e.clientY):e.clientY+u.bottom>=l-wg&&(i=kg(e.clientY-l)),this.setScrollSpeed(n,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,i=Ez(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function qie(t,e){let n=t.state.facet(hz);return n.length?n[0](e):Te.mac?e.metaKey:e.ctrlKey}function Yie(t,e){let n=t.state.facet(pz);return n.length?n[0](e):Te.mac?!e.altKey:!e.ctrlKey}function Fie(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let i=Xf(t.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Gie(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,i;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(i=fn.get(n))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const ts=Object.create(null),$i=Object.create(null),Mz=Te.ie&&Te.ie_version<15||Te.ios&&Te.webkit_version<604;function Hie(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Dz(t,n.value)},50)}function ny(t,e,n){for(let i of t.facet(e))n=i(n,t);return n}function Dz(t,e){e=ny(t.state,U1,e);let{state:n}=t,i,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(Ex!=null&&n.selection.ranges.every(u=>u.empty)&&Ex==s.toString()){let u=-1;i=n.changeByRange(f=>{let h=n.doc.lineAt(f.from);if(h.from==u)return{range:f};u=h.from;let p=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:p},range:Oe.cursor(f.from+p.length)}})}else o?i=n.changeByRange(u=>{let f=s.line(r++);return{changes:{from:u.from,to:u.to,insert:f.text},range:Oe.cursor(u.from+f.length)}}):i=n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}$i.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Te.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};$i.wheel=$i.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};ts.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);$i.touchstart=(t,e)=>{let n=t.inputState,i=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")};$i.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};$i.touchend=(t,e)=>{t.inputState.touchActive=!1};ts.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of t.state.facet(gz))if(n=i(t,e),n)break;if(!n&&e.button==0&&(n=Kie(t,e)),n){let i=!t.hasFocus;t.inputState.startMouseSelection(new Uie(t,e,n,i)),i&&t.observer.ignore(()=>{rz(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function OR(t,e,n,i){if(i==1)return Oe.cursor(e,n);if(i==2)return _ie(t.state,e,n);{let r=t.docView.lineAt(e,n),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(vR+1)%3:1}function Kie(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Nz(e),r=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),r=r.map(s.changes))},get(s,o,l){let u=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),f,h=OR(t,u.pos,u.assoc,i);if(n.pos!=u.pos&&!o){let p=OR(t,n.pos,n.assoc,i),O=Math.min(p.from,h.from),y=Math.max(p.to,h.to);h=O1&&(f=Jie(r,u.pos))?f:l?r.addRange(h):Oe.create([h])}}}function Jie(t,e){for(let n=0;n=e)return Oe.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}ts.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let r=t.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=n.to||o<=n.from)&&(n=Oe.undirectionalRange(s,o))}}let{inputState:i}=t;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",ny(t.state,q1,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};ts.dragend=t=>(t.inputState.draggedContent=null,!1);function SR(t,e,n,i){if(n=ny(t.state,U1,n),!n)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=i&&s&&Yie(t,e)?{from:s.from,to:s.to}:null,l={from:r,insert:n},u=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:u,selection:{anchor:u.mapPos(r,-1),head:u.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}ts.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&SR(t,e,i.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return SR(t,e,i,!0),!0}return!1};ts.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Mz?null:e.clipboardData;return n?(Dz(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(Hie(t),!1)};function ere(t,e){let n=t.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),t.focus()},50)}function tre(t){let e=[],n=[],i=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),n.push(r));if(!e.length){let r=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>r&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),r=o.number}i=!0}return{text:ny(t,q1,e.join(t.lineBreak)),ranges:n,linewise:i}}let Ex=null;ts.copy=ts.cut=(t,e)=>{if(!xf(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=tre(t.state);if(!n&&!r)return!1;Ex=r?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=Mz?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(ere(t,n),!1)};const zz=ss.define();function Lz(t,e){let n=[];for(let i of t.facet(yz)){let r=i(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:zz.of(!0)}):null}function Zz(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=Lz(t.state,e);n?t.dispatch(n):t.update([])}},10)}$i.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Zz(t)};$i.blur=t=>{t.observer.clearSelectionRange(),Zz(t)};$i.compositionstart=$i.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};$i.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Te.chrome&&Te.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};$i.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};ts.beforeinput=(t,e)=>{var n,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],u=t.posAtDOM(l.startContainer,l.startOffset),f=t.posAtDOM(l.endContainer,l.endOffset);return G1(t,{from:u,to:f,insert:t.state.toText(s)},null),!0}}let r;if(Te.chrome&&Te.android&&(r=Pz.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Te.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Te.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>$i.compositionend(t,e),20),!1};const xR=new Set;function nre(t){xR.has(t)||(xR.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const wR=["pre-wrap","normal","pre-line","break-spaces"];let $u=!1;function kR(){$u=!1}class ire{constructor(e){this.lineWrapping=e,this.doc=Ot.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let i=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((n-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return wR.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let i=0;i-1,u=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=i,this.textHeight=r,this.lineLength=s,u){this.heightSamples={};for(let f=0;f0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Kg&&($u=!0),this.height=e)}replace(e,n,i){return _i.of(i)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:u,toA:f,fromB:h,toB:p}=r[l],O=s.lineAt(u,Yt.ByPosNoHeight,i.setDoc(n),0,0),y=O.to>=f?O:s.lineAt(f,Yt.ByPosNoHeight,i,0,0);for(p+=y.to-f,f=y.to;l>0&&O.from<=r[l-1].toA;)u=r[l-1].fromA,h=r[l-1].fromB,l--,us*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r=s&&o(this.lineAt(0,Yt.ByPos,i,r,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class sr extends Iz{constructor(e,n,i){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,n){return new Hr(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,i){let r=i[0];return i.length==1&&(r instanceof sr||r instanceof Hn&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Hn?r=new sr(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):_i.of(i)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Hn extends _i{constructor(e){super(e,0)}heightMetrics(e,n){let i=e.doc.lineAt(n).number,r=e.doc.lineAt(n+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let u=Math.min(this.height,e.lineHeight*s);o=u/s,this.length>s+1&&(l=(this.height-u)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,n,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:u}=this.heightMetrics(n,r);if(n.lineWrapping){let f=r+(e0){let s=i[i.length-1];s instanceof Hn?i[i.length-1]=new Hn(s.length+r):i.push(null,new Hn(r-1))}if(e>0){let s=i[0];s instanceof Hn?i[0]=new Hn(e+s.length):i.unshift(new Hn(e-1),null)}return _i.of(i)}decomposeLeft(e,n){n.push(new Hn(e-1),null)}decomposeRight(e,n){n.push(null,new Hn(this.length-e-1))}updateHeight(e,n=0,i=!1,r){let s=n+this.length;if(r&&r.from<=n+this.length&&r.more){let o=[],l=Math.max(n,r.from),u=-1;for(r.from>n&&o.push(new Hn(r.from-n-1).updateHeight(e,n));l<=s&&r.more;){let h=e.doc.lineAt(l).length;o.length&&o.push(null);let p=r.heights[r.index++],O=0;p<0&&(O=-p,p=r.heights[r.index++]),u==-1?u=p:Math.abs(p-u)>=Kg&&(u=-2);let y=new sr(h,p,O);y.outdated=!1,o.push(y),l+=h+1}l<=s&&o.push(null,new Hn(s-l).updateHeight(e,l));let f=_i.of(o);return(u<0||Math.abs(f.height-this.height)>=Kg||Math.abs(u-this.heightMetrics(e,n).perLine)>=Kg)&&($u=!0),Lm(this,f)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class ore extends _i{constructor(e,n,i){super(e.length+n+i.length,e.height+i.height,n|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,n,i,r){let s=i+this.left.height;return el))return f;let h=n==Yt.ByPosNoHeight?Yt.ByPosNoHeight:Yt.ByPos;return u?f.join(this.right.lineAt(l,h,i,o,l)):this.left.lineAt(l,h,i,r,s).join(f)}forEachLine(e,n,i,r,s,o){let l=r+this.left.height,u=s+this.left.length+this.break;if(this.break)e=u&&this.right.forEachLine(e,n,i,l,u,o);else{let f=this.lineAt(u,Yt.ByPos,i,r,s);e=e&&f.from<=n&&o(f),n>f.to&&this.right.forEachLine(f.to+1,n,i,l,u,o)}}replace(e,n,i){let r=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-r,n-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&CR(s,o-1),n=i&&n.push(null)),e>i&&this.right.decomposeLeft(e-i,n)}decomposeRight(e,n){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,n);e2*n.size||n.size>2*e.size?_i.of(this.break?[e,null,n]:[e,n]):(this.left=Lm(this.left,e),this.right=Lm(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,i=!1,r){let{left:s,right:o}=this,l=n+s.length+this.break,u=null;return r&&r.from<=n+s.length&&r.more?u=s=s.updateHeight(e,n,i,r):s.updateHeight(e,n,i),r&&r.from<=l+o.length&&r.more?u=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),u?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function CR(t,e){let n,i;t[e]==null&&(n=t[e-1])instanceof Hn&&(i=t[e+1])instanceof Hn&&t.splice(e-1,3,new Hn(n.length+1+i.length))}const are=5;class H1{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let i=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof sr?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new sr(i-this.pos,-1,0)),this.writtenTo=i,n>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,i){if(e=are)&&this.addLineDeco(r,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new sr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let i=new Hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof sr)return e;let n=new sr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=n,this.writtenTo=this.pos=this.pos+i}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof sr)&&!this.isCovered?this.nodes.push(new sr(0,-1,0)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&p.overflow!="visible"){let O=h.getBoundingClientRect();s=Math.max(s,O.left),o=Math.min(o,O.right),l=Math.max(l,O.top),u=Math.min(f==t.parentNode?r.innerHeight:u,O.bottom)}f=p.position=="absolute"||p.position=="fixed"?h.offsetParent:h.parentNode}else if(f.nodeType==11)f=f.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,u)-(n.top+e)}}function dre(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function fre(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class Tb{constructor(e,n,i,r){this.from=e,this.to=n,this.size=i,this.displaySize=r}static same(e,n){if(e.length!=n.length)return!1;for(let i=0;itypeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new ire(i),this.stateDeco=TR(n),this.heightMap=_i.empty().applyChanges(this.stateDeco,Ot.empty,this.heightOracle.setDoc(n.doc),[new Rr(0,0,0,n.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Tt.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let i=0;i<=1;i++){let r=i?n.head:n.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Cg(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?$R:new W1(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(mf(e,this.scaler))})}update(e,n=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=TR(this.state);let r=e.changedRanges,s=Rr.extendWithRanges(r,lre(i,this.stateDeco,e?e.changes:jn.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);kR(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||$u)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let u=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headu.to)||!this.viewportIsAppropriate(u))&&(u=this.getViewport(0,n));let f=u.from!=this.viewport.from||u.to!=this.viewport.to;this.viewport=u,e.flags|=this.updateForViewport(),(f||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(iie)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,i=window.getComputedStyle(n),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?bn.RTL:bn.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),u=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let f=0,h=0;if(l.width&&l.height){let{scaleX:A,scaleY:R}=ez(n,l);(A>.005&&Math.abs(this.scaleX-A)>.005||R>.005&&Math.abs(this.scaleY-R)>.005)&&(this.scaleX=A,this.scaleY=R,f|=16,o=u=!0)}let p=(parseInt(i.paddingTop)||0)*this.scaleY,O=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=O)&&(this.paddingTop=p,this.paddingBottom=O,f|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(u=!0),this.editorWidth=e.scrollDOM.clientWidth,f|=16);let y=tz(this.view.contentDOM,!1).y;y!=this.scrollParent&&(this.scrollParent=y,this.scrollAnchorHeight=-1,this.scrollOffset=0);let v=this.getScrollOffset();this.scrollOffset!=v&&(this.scrollAnchorHeight=-1,this.scrollOffset=v),this.scrolledToBottom=sz(this.scrollParent||e.win);let S=(this.printing?fre:ure)(n,this.paddingTop),k=S.top-this.pixelViewport.top,C=S.bottom-this.pixelViewport.bottom;this.pixelViewport=S;let $=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if($!=this.inView&&(this.inView=$,$&&(u=!0)),!this.inView&&!this.scrollTarget&&!dre(e.dom))return 0;let T=l.width;if((this.contentDOMWidth!=T||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,f|=16),u){let A=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(A)&&(o=!0),o||r.lineWrapping&&Math.abs(T-this.contentDOMWidth)>r.charWidth){let{lineHeight:R,charWidth:j,textHeight:L}=e.docView.measureTextSize();o=R>0&&r.refresh(s,R,j,L,Math.max(5,T/j),A),o&&(e.docView.minWidth=0,f|=16)}k>0&&C>0?h=Math.max(k,C):k<0&&C<0&&(h=Math.min(k,C)),kR();for(let R of this.viewports){let j=R.from==this.viewport.from?A:e.docView.measureVisibleLineHeights(R);this.heightMap=(o?_i.empty().applyChanges(this.stateDeco,Ot.empty,this.heightOracle,[new Rr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new rre(R.from,j))}$u&&(f|=2)}let Q=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return Q&&(f&2&&(f|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),f|=this.updateForViewport()),(f&2||Q)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,u=new Cg(r.lineAt(o-i*1e3,Yt.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,Yt.ByHeight,s,0,0).to);if(n){let{head:f}=n.range;if(fu.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),p=r.lineAt(f,Yt.ByPos,s,0,0),O;n.y=="center"?O=(p.top+p.bottom)/2-h/2:n.y=="start"||n.y=="nearest"&&f=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=bn.LTR&&!i)return[];let l=[],u=(h,p,O,y)=>{if(p-hh&&CC.from>=O.from&&C.to<=O.to&&Math.abs(C.from-h)C.from<$&&C.to>$));if(!k){if(pT.from<=p&&T.to>=p)){let T=n.moveToLineBoundary(Oe.cursor(p),!1,!0).head;T>h&&(p=T)}let C=this.gapSize(O,h,p,y),$=i||C<2e6?C:2e6;k=new Tb(h,p,C,$)}l.push(k)},f=h=>{if(h.length2e6)for(let R of e)R.from>=h.from&&R.fromh.from&&u(h.from,y,h,p),vn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let i=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||mf(this.heightMap.lineAt(e,Yt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||mf(this.heightMap.lineAt(this.scaler.fromDOM(e),Yt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return mf(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Cg{constructor(e,n){this.from=e,this.to=n}}function pre(t,e,n){let i=[],r=t,s=0;return mt.spans(n,t,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r=1)return e[e.length-1].to;let i=Math.floor(t*n);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function $g(t,e){let n=0;for(let{from:i,to:r}of t.ranges){if(e<=r){n+=e-i;break}n+=r-i}return n/t.total}function gre(t,e){for(let n of t)if(e(n))return n}const $R={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function TR(t){let e=t.facet(JO).filter(i=>typeof i!="function"),n=t.facet(F1).filter(i=>typeof i!="function");return n.length&&e.push(mt.join(n)),e}class W1{constructor(e,n,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:u})=>{let f=n.lineAt(l,Yt.ByPos,e,0,0).top,h=n.lineAt(u,Yt.ByPos,e,0,0).bottom;return r+=h-f,{from:l,to:u,top:f,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,i=0,r=0;;n++){let s=nn.from==e.viewports[i].from&&n.to==e.viewports[i].to):!1}}function mf(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),i=e.toDOM(t.bottom);return new Hr(t.from,t.length,n,i-n,Array.isArray(t._content)?t._content.map(r=>mf(r,e)):t._content)}const Tg=Ne.define({combine:t=>t.join(" ")}),Rx=Ne.define({combine:t=>t.indexOf(!0)>-1}),Qx=Ta.newName(),Xz=Ta.newName(),Vz=Ta.newName(),Bz={"&light":"."+Xz,"&dark":"."+Vz};function Ax(t,e,n){return new Ta(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return t;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):t+" "+i}})}const mre=Ax("."+Qx,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Bz),Ore={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Eb=Te.ie&&Te.ie_version<=11;class yre{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Une,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let i of n)this.queue.push(i);(Te.ie&&Te.ie_version<=11||Te.ios&&e.composing)&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Te.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Te.chrome&&Te.chrome_version<126)&&(this.editContext=new bre(e),e.state.facet(Oo)&&(e.contentDOM.editContext=this.editContext.editContext)),Eb&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,i)=>n!=e[i]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Oo)?i.root.activeElement!=this.dom:!xf(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Te.ie&&Te.ie_version<=11||Te.android&&Te.chrome)&&!i.state.selection.main.empty&&r.focusNode&&wf(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Xf(e.root);if(!n)return!1;let i=Te.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vre(this.view,n)||n;if(!i||this.selectionRange.eq(i))return!1;let r=xf(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&lu(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),n==-1?{from:n,to:i}=o:(n=Math.min(o.from,n),i=Math.max(o.to,i)))}return{from:n,to:i,typeOver:r}}readChange(){let{from:e,to:n,typeOver:i}=this.processRecords(),r=this.selectionChanged&&xf(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Die(this.view,e,n,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let i=this.view.state,r=Qz(this.view,n);return this.view.state==i&&(n.domChanged||n.newSel&&!zm(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let i=ER(n,e.previousSibling||e.target.previousSibling,-1),r=ER(n,e.nextSibling||e.target.nextSibling,1);return{from:i?n.posAfter(i):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Oo)!=e.state.facet(Oo)&&(e.view.contentDOM.editContext=e.state.facet(Oo)?this.editContext.editContext:null))}destroy(){var e,n,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function ER(t,e,n){for(;e;){let i=fn.get(e);if(i&&i.parent==t)return i;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function RR(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return wf(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}function vre(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return RR(t,r)}let n=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),n?RR(t,n):null}class bre{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),u=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let f=u-l>i.text.length;l==this.from&&sthis.to&&(u=s);let h=Az(e.state.sliceDoc(l,u),i.text,(f?r.from:r.to)-l,f?"end":null);if(!h){let O=Oe.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));zm(O,r)||e.dispatch({selection:O,userEvent:"select"});return}let p={from:h.from+l,to:h.toA+l,insert:Ot.of(i.text.slice(h.from,h.toB).split(` -`))};if((Te.mac||Te.android)&&p.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(p={from:l,to:u,insert:Ot.of([i.text.replace("."," ")])}),this.pendingContextChange=p,!e.state.readOnly){let O=this.to-this.from+(p.to-p.from+p.insert.length);G1(e,p,Oe.single(this.toEditorPos(i.selectionStart,O),this.toEditorPos(i.selectionEnd,O)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),p.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(n.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let u=this.toEditorPos(s.rangeStart),f=this.toEditorPos(s.rangeEnd);if(u{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)n.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=Xf(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,u,f)=>{if(i)return;let h=f.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(f)){r=this.pendingContextChange=null,n+=h,this.to+=h;return}else r=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=h,this.to+=h;else if(sthis.to||this.to-this.from+f.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),f.toString()),this.to+=h}n+=h}),r&&!i&&this.revertPending(e.state),!i}update(e){let n=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Le{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||qne(e.parent)||document,this.viewState=new _R(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(xg)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Wc).map(r=>new wb(r));for(let r of this.plugins)r.update(this);this.observer=new yre(this),this.inputState=new Zie(this),this.inputState.ensureHandlers(this.plugins),this.docView=new hR(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Ci?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,i=!1,r,s=this.state;for(let O of e){if(O.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=O.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,u=null;e.some(O=>O.annotation(zz))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,u=Lz(s,o),u||(l=1));let f=this.observer.delayedAndroidKey,h=null;if(f?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(s);r=Mm.create(this,s,e),r.flags|=l;let p=this.viewState.scrollTarget;try{this.updateState=2;for(let O of e){if(p&&(p=p.map(O.changes)),O.scrollIntoView){let{main:y}=O.state.selection,{x:v,y:S}=this.state.facet(Le.cursorScrollMargin);p=new cu(y.empty?y:Oe.cursor(y.head,y.head>y.anchor?-1:1),"nearest","nearest",S,v)}for(let y of O.effects)y.is(xg)&&(p=y.value.clip(this.state))}this.viewState.update(r,p),this.bidiCache=Zm.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(gf)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(O=>O.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Tg)!=r.state.facet(Tg)&&(this.viewState.mustMeasureContent=!0),(n||i||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let O of this.state.facet(_x))try{O(r)}catch(y){Ts(this.state,y,"update listener")}(u||h)&&Promise.resolve().then(()=>{u&&this.state==u.startState&&this.dispatch(u),h&&!Qz(this,h)&&f.force&&lu(this.contentDOM,f.key,f.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new _R(this,e),this.plugins=e.facet(Wc).map(i=>new wb(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new hR(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(Wc),i=e.state.facet(Wc);if(n!=i){let r=[];for(let s of i){let o=n.indexOf(s);if(o<0)r.push(new wb(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let u=0;;u++){if(o<0){if(sz(i||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let v=this.viewState.scrollAnchorAt(r);s=v.from,o=v.top}l=this.viewState.scaleY}this.updateState=1;let f=this.viewState.measure();if(!f&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(u>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];f&4||([this.measureRequests,h]=[h,this.measureRequests]);let p=h.map(v=>{try{return v.read(this)}catch(S){return Ts(this.state,S),QR}}),O=Mm.create(this,this.state,[]),y=!1;O.flags|=f,n?n.flags|=f:n=O,this.updateState=2,O.empty||(this.updatePlugins(O),this.inputState.update(O),this.updateAttrs(),y=this.docView.update(O),y&&this.docViewUpdate());for(let v=0;v1||S<-1)&&!(Te.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+S,i?s<0?i.scrollTop=i.scrollHeight:i.scrollTop+=S:this.win.scrollBy(0,S),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let u of this.state.facet(_x))u(n)}get themeClasses(){return Qx+" "+(this.state.facet(Rx)?Vz:Xz)+" "+this.state.facet(Tg)}updateAttrs(){let e=AR(this,xz,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Oo)?"true":"false",class:"cm-content",style:`${Te.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),AR(this,Y1,n);let i=this.observer.ignore(()=>{let r=aR(this.contentDOM,this.contentAttrs,n),s=aR(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=n,i}showAnnouncements(e){let n=!0;for(let i of e)for(let r of i.effects)if(r.is(Le.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(gf);let e=this.state.facet(Le.cspNonce);Ta.mount(this.root,this.styleModules.concat(mre).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;ni.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,i){return $b(this,e,pR(this,e,n,i))}moveByGroup(e,n){return $b(this,e,pR(this,e,n,i=>Rie(this,e.head,i)))}visualLineSide(e,n){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[n?i.length-1:0];return Oe.cursor(s.side(n,r)+e.from,s.forward(!n,r)?1:-1)}moveToLineBoundary(e,n,i=!0){return Eie(this,e,n,i)}moveVertically(e,n,i){return $b(this,e,Qie(this,e,n,i))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let i=Tx(this,e,n);return i&&i.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),Tx(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let i=this.state.doc.lineAt(e),r=this.bidiSpans(i),s=r[$s.find(r,e-i.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==bn.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(vz)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sre)return dz(e.length);let n=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||uz(s.isolates,i=uR(this,e))))return s.order;i||(i=uR(this,e));let r=eie(e.text,n,i);return this.bidiCache.push(new Zm(e.from,e.to,n,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Te.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{rz(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var i,r,s,o;return xg.of(new cu(typeof e=="number"?Oe.cursor(e):e,(i=n.y)!==null&&i!==void 0?i:"nearest",(r=n.x)!==null&&r!==void 0?r:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return xg.of(new cu(Oe.cursor(i.from),"start","start",i.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Dr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Dr.define(()=>({}),{eventObservers:e})}static theme(e,n){let i=Ta.newName(),r=[Tg.of(i),gf.of(Ax(`.${i}`,e))];return n&&n.dark&&r.push(Rx.of(!0)),r}static baseTheme(e){return wh.lowest(gf.of(Ax("."+Qx,e,Bz)))}static findFromDOM(e){var n;let i=e.querySelector(".cm-content"),r=i&&fn.get(i)||fn.get(e);return((n=r?.root)===null||n===void 0?void 0:n.view)||null}}Le.styleModule=gf;Le.inputHandler=Oz;Le.clipboardInputFilter=U1;Le.clipboardOutputFilter=q1;Le.scrollHandler=bz;Le.focusChangeEffect=yz;Le.perLineTextDirection=vz;Le.exceptionSink=mz;Le.updateListener=_x;Le.editable=Oo;Le.mouseSelectionStyle=gz;Le.dragMovesSelection=pz;Le.clickAddsSelectionRange=hz;Le.decorations=JO;Le.blockWrappers=wz;Le.outerDecorations=F1;Le.atomicRanges=_h;Le.bidiIsolatedRanges=kz;Le.cursorScrollMargin=Ne.define({combine:t=>{let e=5,n=5;for(let i of t)typeof i=="number"?e=n=i:{x:e,y:n}=i;return{x:e,y:n}}});Le.scrollMargins=Cz;Le.darkTheme=Rx;Le.cspNonce=Ne.define({combine:t=>t.length?t[0]:""});Le.contentAttributes=Y1;Le.editorAttributes=xz;Le.lineWrapping=Le.contentAttributes.of({class:"cm-lineWrapping"});Le.announce=Jt.define();const Sre=4096,QR={};class Zm{constructor(e,n,i,r,s,o){this.from=e,this.to=n,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:bn.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=i[r],o=typeof s=="function"?s(t):s;o&&X1(o,n)}return n}const xre=Te.mac?"mac":Te.windows?"win":Te.linux?"linux":"key";function wre(t,e){const n=t.split(/-(?!$)/);let i=n[n.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let u=0;ui.concat(r),[]))),n}let pa=null;const _re=4e3;function $re(t,e=xre){let n=Object.create(null),i=Object.create(null),r=(o,l)=>{let u=i[o];if(u==null)i[o]=l;else if(u!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,u,f,h)=>{var p,O;let y=n[o]||(n[o]=Object.create(null)),v=l.split(/ (?!$)/).map(C=>wre(C,e));for(let C=1;C{let Q=pa={view:T,prefix:$,scope:o};return setTimeout(()=>{pa==Q&&(pa=null)},_re),!0}]})}let S=v.join(" ");r(S,!1);let k=y[S]||(y[S]={preventDefault:!1,stopPropagation:!1,run:((O=(p=y._any)===null||p===void 0?void 0:p.run)===null||O===void 0?void 0:O.slice())||[]});u&&k.run.push(u),f&&(k.preventDefault=!0),h&&(k.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let f of l){let h=n[f]||(n[f]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:p}=o;for(let O in h)h[O].run.push(y=>p(y,Px))}let u=o[e]||o.key;if(u)for(let f of l)s(f,u,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(f,"Shift-"+u,o.shift,o.preventDefault,o.stopPropagation)}return n}let Px=null;function Tre(t,e,n,i){Px=e;let r=Lne(e),s=Sne(r,0),o=xne(s)==r.length&&r!=" ",l="",u=!1,f=!1,h=!1;pa&&pa.view==n&&pa.scope==i&&(l=pa.prefix+" ",jz.indexOf(e.keyCode)<0&&(f=!0,pa=null));let p=new Set,O=k=>{if(k){for(let C of k.run)if(!p.has(C)&&(p.add(C),C(n)))return k.stopPropagation&&(h=!0),!0;k.preventDefault&&(k.stopPropagation&&(h=!0),f=!0)}return!1},y=t[i],v,S;return y&&(O(y[l+Eg(r,e,!o)])?u=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Te.windows&&e.ctrlKey&&e.altKey)&&!(Te.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(v=Ea[e.keyCode])&&v!=r?(O(y[l+Eg(v,e,!0)])||e.shiftKey&&(S=Zf[e.keyCode])!=r&&S!=v&&O(y[l+Eg(S,e,!1)]))&&(u=!0):o&&e.shiftKey&&O(y[l+Eg(r,e,!0)])&&(u=!0),!u&&O(y._any)&&(u=!0)),f&&(u=!0),u&&h&&e.stopPropagation(),Px=null,u}function Ere(){return Qre}const Rre=Tt.line({class:"cm-activeLine"}),Qre=Dr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let i of t.state.selection.ranges){let r=t.lineBlockAt(i.head);r.from>e&&(n.push(Rre.range(r.from)),e=r.from)}return Tt.set(n)}},{decorations:t=>t.decorations});class Zl extends $a{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Zl.prototype.elementClass="";Zl.prototype.toDOM=void 0;Zl.prototype.mapMode=ki.TrackBefore;Zl.prototype.startSide=Zl.prototype.endSide=-1;Zl.prototype.point=!0;const Rb=Ne.define(),Are=Ne.define(),Jg=Ne.define(),jR=Ne.define({combine:t=>t.some(e=>e)});function Pre(t){return[jre]}const jre=Dr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Jg).map(e=>new DR(t,e)),this.fixed=!t.state.facet(jR);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,i=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jR)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(Rb),this.view.viewport.from),i=[],r=this.gutters.map(s=>new Mre(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Ui.Text&&o){jx(n,i,l.from);for(let u of r)u.line(this.view,l,i);o=!1}else if(l.widget)for(let u of r)u.widget(this.view,l)}else if(s.type==Ui.Text){jx(n,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Jg),n=t.state.facet(Jg),i=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(Rb),t.state.facet(Rb),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let r of this.gutters)r.update(t)&&(i=!0);else{i=!0;let r=[];for(let s of n){let o=e.indexOf(s);o<0?r.push(new DR(this.view,s)):(this.gutters[o].update(t),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Le.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let i=n.dom.offsetWidth*e.scaleX,r=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==bn.LTR?{left:i,right:r}:{right:i,left:r}})});function MR(t){return Array.isArray(t)?t:[t]}function jx(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Mre{constructor(e,n,i){this.gutter=e,this.height=i,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,i){let{gutter:r}=this,s=(n.top-this.height)/e.scaleY,o=n.height/e.scaleY;if(this.i==r.elements.length){let l=new Uz(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=n.bottom,this.i++}line(e,n,i){let r=[];jx(this.cursor,r,n.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,n,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,n,r)}widget(e,n){let i=this.gutter.config.widgetMarker(e,n.widget,n),r=i?[i]:null;for(let s of e.state.facet(Are)){let o=s(e,n.widget,n);o&&(r||(r=[])).push(o)}r&&this.addElement(e,n,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class DR{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in n.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let u=s.getBoundingClientRect();o=(u.top+u.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);n.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=MR(n.markers(e)),n.initialSpacer&&(this.spacer=new Uz(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=MR(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!mt.eq(this.markers,n,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Uz{constructor(e,n,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,i,r)}update(e,n,i,r){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Dre(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,n){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,u=ss(l,u,f)||o(l,u,f):o}return i}})}});class Qb extends Zl{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ab(t,e){return t.state.facet(Kc).formatNumber(e,t.state)}const Lre=Jg.compute([Kc],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Nre)},lineMarker(e,n,i){return i.some(r=>r.toDOM)?null:new Qb(Ab(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,i)=>{for(let r of e.state.facet(zre)){let s=r(e,n,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Kc)!=e.state.facet(Kc),initialSpacer(e){return new Qb(Ab(e,NR(e.state.doc.lines)))},updateSpacer(e,n){let i=Ab(n.view,NR(n.view.state.doc.lines));return i==e.number?e:new Qb(i)},domEventHandlers:t.facet(Kc).domEventHandlers,side:"before"}));function Zre(t={}){return[Kc.of(t),Pre(),Lre]}function NR(t){let e=9;for(;e{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Dn.match(e)),n=>{let i=e(n);return i===void 0?null:[this,i]}}}We.closedBy=new We({deserialize:t=>t.split(" ")});We.openedBy=new We({deserialize:t=>t.split(" ")});We.group=new We({deserialize:t=>t.split(" ")});We.isolate=new We({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});We.contextHash=new We({perNode:!0});We.lookAhead=new We({perNode:!0});We.mounted=new We({perNode:!0});class uu{constructor(e,n,i,r=!1){this.tree=e,this.overlay=n,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[We.mounted.id]}}const Xre=Object.create(null);class Dn{constructor(e,n,i,r=0){this.name=e,this.props=n,this.id=i,this.flags=r}static define(e){let n=e.props&&e.props.length?Object.create(null):Xre,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Dn(e.name||"",n,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(We.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let i in e)for(let r of i.split(" "))n[r]=e[i];return i=>{for(let r=i.prop(We.group),s=-1;s<(r?r.length:0);s++){let o=n[s<0?i.name:r[s]];if(o)return o}}}}Dn.none=new Dn("",Object.create(null),0,8);class $h{constructor(e){this.types=e;for(let n=0;n0;for(let u=this.cursor(o|$t.IncludeAnonymous);;){let f=!1;if(u.from<=s&&u.to>=r&&(!l&&u.type.isAnonymous||n(u)!==!1)){if(u.firstChild())continue;f=!0}for(;f&&i&&(l||!u.type.isAnonymous)&&i(u),!u.nextSibling();){if(!u.parent())return;f=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:ek(Dn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,i,r)=>new wt(this.type,n,i,r,this.propValues),e.makeTree||((n,i,r)=>new wt(Dn.none,n,i,r)))}static build(e){return qre(e)}}wt.empty=new wt(Dn.none,[],[],0);class K1{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new K1(this.buffer,this.index)}}class Qa{constructor(e,n,i){this.buffer=e,this.length=n,this.set=i}get type(){return Dn.none}toString(){let e=[];for(let n=0;n0));u=o[u+3]);return l}slice(e,n,i){let r=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,u=0;l=e&&ne;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function Bf(t,e,n,i){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=f;e+=n){let h=l[e],p=u[e]+o.from,O;if(!(!(s&$t.EnterBracketed&&h instanceof wt&&(O=uu.get(h))&&!O.overlay&&O.bracketed&&i>=p&&i<=p+h.length)&&!Yz(r,i,p,p+h.length))){if(h instanceof Qa){if(s&$t.ExcludeBuffers)continue;let y=h.findChild(0,h.buffer.length,n,i-p,r);if(y>-1)return new Es(new Vre(o,h,e,p),null,y)}else if(s&$t.IncludeAnonymous||!h.type.isAnonymous||J1(h)){let y;if(!(s&$t.IgnoreMounts)&&(y=uu.get(h))&&!y.overlay)return new pi(y.tree,p,e,o);let v=new pi(h,p,e,o);return s&$t.IncludeAnonymous||!v.type.isAnonymous?v:v.nextChild(n<0?h.children.length-1:0,n,i,r,s)}}}if(s&$t.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,i=0){let r;if(!(i&$t.IgnoreOverlays)&&(r=uu.get(this._tree))&&r.overlay){let s=e-this.from,o=i&$t.EnterBracketed&&r.bracketed;for(let{from:l,to:u}of r.overlay)if((n>0||o?l<=s:l=s:u>s))return new pi(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function LR(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=r.type.is(n),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function Mx(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class Vre{constructor(e,n,i,r){this.parent=e,this.buffer=n,this.index=i,this.start=r}}class Es extends Fz{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,i){super(),this.context=e,this._parent=n,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,n,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,i);return s<0?null:new Es(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,i=0){if(i&$t.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new Es(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Es(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Es(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),n.push(0)}return new wt(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Gz(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new pi(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Bf(l,e,n,!1))}}return r?Gz(r):i}class Im{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~$t.EnterBracketed,e instanceof pi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof pi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,i=this.mode){return this.buffer?i&$t.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&$t.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&$t.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(i<0?n.buffer.length:n.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,i,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&$t.IncludeAnonymous||l instanceof Qa||!l.type.isAnonymous||J1(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;n=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r=0;s--){if(s<0)return Mx(this._tree,e,r);let o=i[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function J1(t){return t.children.some(e=>e instanceof Qa||!e.type.isAnonymous||J1(e))}function qre(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=qz,reused:s=[],minRepeatType:o=i.types.length}=t,l=Array.isArray(n)?new K1(n,n.length):n,u=i.types,f=0,h=0;function p(A,R,j,L,ne,G){let{id:H,start:Y,end:re,size:K}=l,ye=h,N=f;if(K<0)if(l.next(),K==-1){let D=s[H];j.push(D),L.push(Y-A);return}else if(K==-3){f=H;return}else if(K==-4){h=H;return}else throw new RangeError(`Unrecognized record size: ${K}`);let W=u[H],ce,oe,le=Y-A;if(re-Y<=r&&(oe=k(l.pos-R,ne))){let D=new Uint16Array(oe.size-oe.skip),P=l.pos-oe.size,I=D.length;for(;l.pos>P;)I=C(oe.start,D,I);ce=new Qa(D,re-oe.start,i),le=oe.start-A}else{let D=l.pos-K;l.next();let P=[],I=[],X=H>=o?H:-1,V=0,J=re;for(;l.pos>D;)X>=0&&l.id==X&&l.size>=0?(l.end<=J-r&&(v(P,I,Y,V,l.end,J,X,ye,N),V=P.length,J=l.end),l.next()):G>2500?O(Y,D,P,I):p(Y,D,P,I,X,G+1);if(X>=0&&V>0&&V-1&&V>0){let se=y(W,N);ce=ek(W,P,I,0,P.length,0,re-Y,se,se)}else ce=S(W,P,I,re-Y,ye-re,N)}j.push(ce),L.push(le)}function O(A,R,j,L){let ne=[],G=0,H=-1;for(;l.pos>R;){let{id:Y,start:re,end:K,size:ye}=l;if(ye>4)l.next();else{if(H>-1&&re=0;K-=3)Y[ye++]=ne[K],Y[ye++]=ne[K+1]-re,Y[ye++]=ne[K+2]-re,Y[ye++]=ye;j.push(new Qa(Y,ne[2]-re,i)),L.push(re-A)}}function y(A,R){return(j,L,ne)=>{let G=0,H=j.length-1,Y,re;if(H>=0&&(Y=j[H])instanceof wt){if(!H&&Y.type==A&&Y.length==ne)return Y;(re=Y.prop(We.lookAhead))&&(G=L[H]+Y.length+re)}return S(A,j,L,ne,G,R)}}function v(A,R,j,L,ne,G,H,Y,re){let K=[],ye=[];for(;A.length>L;)K.push(A.pop()),ye.push(R.pop()+j-ne);A.push(S(i.types[H],K,ye,G-ne,Y-G,re)),R.push(ne-j)}function S(A,R,j,L,ne,G,H){if(G){let Y=[We.contextHash,G];H=H?[Y].concat(H):[Y]}if(ne>25){let Y=[We.lookAhead,ne];H=H?[Y].concat(H):[Y]}return new wt(A,R,j,L,H)}function k(A,R){let j=l.fork(),L=0,ne=0,G=0,H=j.end-r,Y={size:0,start:0,skip:0};e:for(let re=j.pos-A;j.pos>re;){let K=j.size;if(j.id==R&&K>=0){Y.size=L,Y.start=ne,Y.skip=G,G+=4,L+=4,j.next();continue}let ye=j.pos-K;if(K<0||ye=o?4:0,W=j.start;for(j.next();j.pos>ye;){if(j.size<0)if(j.size==-3||j.size==-4)N+=4;else break e;else j.id>=o&&(N+=4);j.next()}ne=W,L+=K,G+=N}return(R<0||L==A)&&(Y.size=L,Y.start=ne,Y.skip=G),Y.size>4?Y:void 0}function C(A,R,j){let{id:L,start:ne,end:G,size:H}=l;if(l.next(),H>=0&&L4){let re=l.pos-(H-4);for(;l.pos>re;)j=C(A,R,j)}R[--j]=Y,R[--j]=G-A,R[--j]=ne-A,R[--j]=L}else H==-3?f=L:H==-4&&(h=L);return j}let $=[],T=[];for(;l.pos>0;)p(t.start||0,t.bufferStart||0,$,T,-1,0);let Q=(e=t.length)!==null&&e!==void 0?e:$.length?T[0]+$[0].length:0;return new wt(u[t.topID],$.reverse(),T.reverse(),Q)}const ZR=new WeakMap;function em(t,e){if(!t.isAnonymous||e instanceof Qa||e.type!=t)return 1;let n=ZR.get(e);if(n==null){n=1;for(let i of e.children){if(i.type!=t||!(i instanceof wt)){n=1;break}n+=em(t,i)}ZR.set(e,n)}return n}function ek(t,e,n,i,r,s,o,l,u){let f=0;for(let v=i;v=h)break;R+=j}if(T==Q+1){if(R>h){let j=v[Q];y(j.children,j.positions,0,j.children.length,S[Q]+$);continue}p.push(v[Q])}else{let j=S[T-1]+v[T-1].length-A;p.push(ek(t,v,S,Q,T,A,j,null,u))}O.push(A+$-s)}}return y(e,n,i,r,0),(l||u)(p,O,o)}class Hz{constructor(){this.map=new WeakMap}setBuffer(e,n,i){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(n,i)}getBuffer(e,n){let i=this.map.get(e);return i&&i.get(n)}set(e,n){e instanceof Es?this.setBuffer(e.context.buffer,e.index,n):e instanceof pi&&this.map.set(e.tree,n)}get(e){return e instanceof Es?this.getBuffer(e.context.buffer,e.index):e instanceof pi?this.map.get(e.tree):void 0}cursorSet(e,n){e.buffer?this.setBuffer(e.buffer.buffer,e.index,n):this.map.set(e.tree,n)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Co{constructor(e,n,i,r,s=!1,o=!1){this.from=e,this.to=n,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],i=!1){let r=[new Co(0,e.length,e,0,!1,i)];for(let s of n)s.to>e.length&&r.push(s);return r}static applyChanges(e,n,i=128){if(!n.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,u=0,f=0;;l++){let h=l=i)for(;o&&o.from=O.from||p<=O.to||f){let y=Math.max(O.from,u)-f,v=Math.min(O.to,p)-f;O=y>=v?null:new Co(y,v,O.tree,O.offset+f,l>0,!!h)}if(O&&r.push(O),o.to>p)break;o=snew Qr(r.from,r.to)):[new Qr(0,0)]:[new Qr(0,e.length)],this.createParse(e,n||[],i)}parse(e,n,i){let r=this.startParse(e,n,i);for(;;){let s=r.advance();if(s)return s}}}class Yre{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}function Wz(t){return(e,n,i,r)=>new Gre(e,t,n,i,r)}class IR{constructor(e,n,i,r,s,o){this.parser=e,this.parse=n,this.overlay=i,this.bracketed=r,this.target=s,this.from=o}}function XR(t){if(!t.length||t.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}class Fre{constructor(e,n,i,r,s,o,l,u){this.parser=e,this.predicate=n,this.mounts=i,this.index=r,this.start=s,this.bracketed=o,this.target=l,this.prev=u,this.depth=0,this.ranges=[]}}const Dx=new We({perNode:!0});class Gre{constructor(e,n,i,r,s){this.nest=n,this.input=i,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new wt(i.type,i.children,i.positions,i.length,i.propValues.concat([[Dx,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],n=e.parse.advance();if(n){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[We.mounted.id]=new uu(n,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let n=this.innerDone;n=this.stoppedAt)l=!1;else if(e.hasNode(r)){if(n){let f=n.mounts.find(h=>h.frag.from<=r.from&&h.frag.to>=r.to&&h.mount.overlay);if(f)for(let h of f.mount.overlay){let p=h.from+f.pos,O=h.to+f.pos;p>=r.from&&O<=r.to&&!n.ranges.some(y=>y.fromp)&&n.ranges.push({from:p,to:O})}}l=!1}else if(i&&(o=Hre(i.ranges,r.from,r.to)))l=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.fromnew Qr(p.from-r.from,p.to-r.from)):null,!!s.bracketed,r.tree,h.length?h[0].from:r.from)),s.overlay?h.length&&(i={ranges:h,depth:0,prev:i}):l=!1}}else if(n&&(u=n.predicate(r))&&(u===!0&&(u=new Qr(r.from,r.to)),u.from=0&&n.ranges[f].to==u.from?n.ranges[f]={from:n.ranges[f].from,to:u.to}:n.ranges.push(u)}if(l&&r.firstChild())n&&n.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(n&&!--n.depth){let f=UR(this.ranges,n.ranges);f.length&&(XR(f),this.inner.splice(n.index,0,new IR(n.parser,n.parser.startParse(this.input,qR(n.mounts,f),f),n.ranges.map(h=>new Qr(h.from-n.start,h.to-n.start)),n.bracketed,n.target,f[0].from))),n=n.prev}i&&!--i.depth&&(i=i.prev)}}}}function Hre(t,e,n){for(let i of t){if(i.from>=n)break;if(i.to>e)return i.from<=e&&i.to>=n?2:1}return 0}function VR(t,e,n,i,r,s){if(e=e&&n.enter(i,1,$t.IgnoreOverlays|$t.ExcludeBuffers)))if(n.to<=e)n.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==e.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof wt)n=n.children[0];else break}return!1}}let Kre=class{constructor(e){var n;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(n=i.tree.prop(Dx))!==null&&n!==void 0?n:i.to,this.inner=new BR(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(e=n.tree.prop(Dx))!==null&&e!==void 0?e:n.to,this.inner=new BR(n.tree,-n.offset)}}findMounts(e,n){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(i=s.tree)===null||i===void 0?void 0:i.prop(We.mounted);if(o&&o.parser==n)for(let l=this.fragI;l=s.to)break;u.tree==this.curFrag.tree&&r.push({frag:u,pos:s.from-u.offset,mount:o})}}}return r}};function UR(t,e){let n=null,i=e;for(let r=1,s=0;r=l)break;u.to<=o||(n||(i=n=e.slice()),u.froml&&n.splice(s+1,0,new Qr(l,u.to))):u.to>l?n[s--]=new Qr(l,u.to):n.splice(s--,1))}}return i}function Jre(t,e,n,i){let r=0,s=0,o=!1,l=!1,u=-1e9,f=[];for(;;){let h=r==t.length?1e9:o?t[r].to:t[r].from,p=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let O=Math.max(u,n),y=Math.min(h,p,i);Onew Qr(O.from+i,O.to+i)),p=Jre(e,h,u,f);for(let O=0,y=u;;O++){let v=O==p.length,S=v?f:p[O].from;if(S>y&&n.push(new Co(y,S,r.tree,-o,s.from>=y||s.openStart,s.to<=S||s.openEnd)),v)break;y=p[O].to}}else n.push(new Co(u,f,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return n}let ese=0;class lr{constructor(e,n,i,r){this.name=e,this.set=n,this.base=i,this.modified=r,this.id=ese++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let i=typeof e=="string"?e:"?";if(e instanceof lr&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let r=new lr(i,[],null,[]);if(r.set.push(r),n)for(let s of n.set)r.set.push(s);return r}static defineModifier(e){let n=new Xm(e);return i=>i.modified.indexOf(n)>-1?i:Xm.get(i.base||i,i.modified.concat(n).sort((r,s)=>r.id-s.id))}}let tse=0;class Xm{constructor(e){this.name=e,this.instances=[],this.id=tse++}static get(e,n){if(!n.length)return e;let i=n[0].instances.find(l=>l.base==e&&nse(n,l.modified));if(i)return i;let r=[],s=new lr(e.name,r,e,n);for(let l of n)l.instances.push(s);let o=ise(n);for(let l of e.set)if(!l.modified.length)for(let u of o)r.push(Xm.get(l,u));return s}}function nse(t,e){return t.length==e.length&&t.every((n,i)=>n==e[i])}function ise(t){let e=[[]];for(let n=0;ni.length-n.length)}function Fu(t){let e=Object.create(null);for(let n in t){let i=t[n];Array.isArray(i)||(i=[i]);for(let r of n.split(" "))if(r){let s=[],o=2,l=r;for(let p=0;;){if(l=="..."&&p>0&&p+3==r.length){o=1;break}let O=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!O)throw new RangeError("Invalid path: "+r);if(s.push(O[0]=="*"?"":O[0][0]=='"'?JSON.parse(O[0]):O[0]),p+=O[0].length,p==r.length)break;let y=r[p++];if(p==r.length&&y=="!"){o=0;break}if(y!="/")throw new RangeError("Invalid path: "+r);l=r.slice(p)}let u=s.length-1,f=s[u];if(!f)throw new RangeError("Invalid path: "+r);let h=new Uf(i,o,u>0?s.slice(0,u):null);e[f]=h.sort(e[f])}}return Kz.add(e)}const Kz=new We({combine(t,e){let n,i,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let s=new Uf(r.tags,r.mode,r.context);n?n.next=s:i=s,n=s}return i}});class Uf{constructor(e,n,i,r){this.tags=e,this.mode=n,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let l of s)for(let u of l.set){let f=n[u.id];if(f){o=o?o+" "+f:f;break}}return o},scope:i}}function rse(t,e){let n=null;for(let i of t){let r=i.style(e);r&&(n=n?n+" "+r:r)}return n}function sse(t,e,n,i=0,r=t.length){let s=new ose(i,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),i,r,"",s.highlighters),s.flush(r)}class ose{constructor(e,n,i){this.at=e,this.highlighters=n,this.span=i,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,i,r,s){let{type:o,from:l,to:u}=e;if(l>=i||u<=n)return;o.isTop&&(s=this.highlighters.filter(y=>!y.scope||y.scope(o)));let f=r,h=ase(e)||Uf.empty,p=rse(s,h.tags);if(p&&(f&&(f+=" "),f+=p,h.mode==1&&(r+=(r?" ":"")+p)),this.startSpan(Math.max(n,l),f),h.opaque)return;let O=e.tree&&e.tree.prop(We.mounted);if(O&&O.overlay){let y=e.node.enter(O.overlay[0].from+l,1),v=this.highlighters.filter(k=>!k.scope||k.scope(O.tree.type)),S=e.firstChild();for(let k=0,C=l;;k++){let $=k=T||!e.nextSibling())););if(!$||T>i)break;C=$.to+l,C>n&&(this.highlightRange(y.cursor(),Math.max(n,$.from+l),Math.min(i,C),"",v),this.startSpan(Math.min(i,C),f))}S&&e.parent()}else if(e.firstChild()){O&&(r="");do if(!(e.to<=n)){if(e.from>=i)break;this.highlightRange(e,n,i,r,s),this.startSpan(Math.min(i,e.to),f)}while(e.nextSibling());e.parent()}}}function ase(t){let e=t.type.prop(Kz);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Ce=lr.define,Qg=Ce(),da=Ce(),YR=Ce(da),FR=Ce(da),fa=Ce(),Ag=Ce(fa),Pb=Ce(fa),vs=Ce(),fl=Ce(vs),ms=Ce(),Os=Ce(),Nx=Ce(),tf=Ce(Nx),Pg=Ce(),Z={comment:Qg,lineComment:Ce(Qg),blockComment:Ce(Qg),docComment:Ce(Qg),name:da,variableName:Ce(da),typeName:YR,tagName:Ce(YR),propertyName:FR,attributeName:Ce(FR),className:Ce(da),labelName:Ce(da),namespace:Ce(da),macroName:Ce(da),literal:fa,string:Ag,docString:Ce(Ag),character:Ce(Ag),attributeValue:Ce(Ag),number:Pb,integer:Ce(Pb),float:Ce(Pb),bool:Ce(fa),regexp:Ce(fa),escape:Ce(fa),color:Ce(fa),url:Ce(fa),keyword:ms,self:Ce(ms),null:Ce(ms),atom:Ce(ms),unit:Ce(ms),modifier:Ce(ms),operatorKeyword:Ce(ms),controlKeyword:Ce(ms),definitionKeyword:Ce(ms),moduleKeyword:Ce(ms),operator:Os,derefOperator:Ce(Os),arithmeticOperator:Ce(Os),logicOperator:Ce(Os),bitwiseOperator:Ce(Os),compareOperator:Ce(Os),updateOperator:Ce(Os),definitionOperator:Ce(Os),typeOperator:Ce(Os),controlOperator:Ce(Os),punctuation:Nx,separator:Ce(Nx),bracket:tf,angleBracket:Ce(tf),squareBracket:Ce(tf),paren:Ce(tf),brace:Ce(tf),content:vs,heading:fl,heading1:Ce(fl),heading2:Ce(fl),heading3:Ce(fl),heading4:Ce(fl),heading5:Ce(fl),heading6:Ce(fl),contentSeparator:Ce(vs),list:Ce(vs),quote:Ce(vs),emphasis:Ce(vs),strong:Ce(vs),link:Ce(vs),monospace:Ce(vs),strikethrough:Ce(vs),inserted:Ce(),deleted:Ce(),changed:Ce(),invalid:Ce(),meta:Pg,documentMeta:Ce(Pg),annotation:Ce(Pg),processingInstruction:Ce(Pg),definition:lr.defineModifier("definition"),constant:lr.defineModifier("constant"),function:lr.defineModifier("function"),standard:lr.defineModifier("standard"),local:lr.defineModifier("local"),special:lr.defineModifier("special")};for(let t in Z){let e=Z[t];e instanceof lr&&(e.name=t)}Jz([{tag:Z.link,class:"tok-link"},{tag:Z.heading,class:"tok-heading"},{tag:Z.emphasis,class:"tok-emphasis"},{tag:Z.strong,class:"tok-strong"},{tag:Z.keyword,class:"tok-keyword"},{tag:Z.atom,class:"tok-atom"},{tag:Z.bool,class:"tok-bool"},{tag:Z.url,class:"tok-url"},{tag:Z.labelName,class:"tok-labelName"},{tag:Z.inserted,class:"tok-inserted"},{tag:Z.deleted,class:"tok-deleted"},{tag:Z.literal,class:"tok-literal"},{tag:Z.string,class:"tok-string"},{tag:Z.number,class:"tok-number"},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],class:"tok-string2"},{tag:Z.variableName,class:"tok-variableName"},{tag:Z.local(Z.variableName),class:"tok-variableName tok-local"},{tag:Z.definition(Z.variableName),class:"tok-variableName tok-definition"},{tag:Z.special(Z.variableName),class:"tok-variableName2"},{tag:Z.definition(Z.propertyName),class:"tok-propertyName tok-definition"},{tag:Z.typeName,class:"tok-typeName"},{tag:Z.namespace,class:"tok-namespace"},{tag:Z.className,class:"tok-className"},{tag:Z.macroName,class:"tok-macroName"},{tag:Z.propertyName,class:"tok-propertyName"},{tag:Z.operator,class:"tok-operator"},{tag:Z.comment,class:"tok-comment"},{tag:Z.meta,class:"tok-meta"},{tag:Z.invalid,class:"tok-invalid"},{tag:Z.punctuation,class:"tok-punctuation"}]);var jb;const xl=new We;function nk(t){return Ne.define({combine:t?e=>e.concat(t):void 0})}const ik=new We;class Ar{constructor(e,n,i=[],r=""){this.data=e,this.name=r,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return hn(this)}}),this.parser=n,this.extension=[Ru.of(this),St.languageData.of((s,o,l)=>{let u=GR(s,o,l),f=u.type.prop(xl);if(!f)return[];let h=s.facet(f),p=u.type.prop(ik);if(p){let O=u.resolve(o-u.from,l);for(let y of p)if(y.test(O,s)){let v=s.facet(y.facet);return y.type=="replace"?v:v.concat(h)}}return h})].concat(i)}isActiveAt(e,n,i=-1){return GR(e,n,i).type.prop(xl)==this.data}findRegions(e){let n=e.facet(Ru);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(xl)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(We.mounted);if(l){if(l.tree.prop(xl)==this.data){if(l.overlay)for(let u of l.overlay)i.push({from:u.from+o,to:u.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let u=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>u)return}}for(let u=0;ui.isTop?n:void 0)]}),e.name)}configure(e,n){return new Tu(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function hn(t){let e=t.field(Ar.state,!1);return e?e.tree:wt.empty}class lse{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-i,n-i)}}let nf=null;class qf{constructor(e,n,i=[],r,s,o,l,u){this.parser=e,this.state=n,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=u,this.parse=null,this.tempSkipped=[]}static create(e,n,i){return new qf(e,n,[],wt.empty,0,i,[],null)}startParse(){return this.parser.startParse(new lse(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=wt.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Co.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=nf;nf=this;try{return e()}finally{nf=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=HR(e,n.from,n.to);return e}changes(e,n){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let u=[];if(e.iterChangedRanges((f,h,p,O)=>u.push({fromA:f,toA:h,fromB:p,toB:O})),i=Co.applyChanges(i,u),r=wt.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let f of this.skipped){let h=e.mapPos(f.from,1),p=e.mapPos(f.to,-1);he.from&&(this.fragments=HR(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends tk{createParse(n,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let u=nf;if(u){for(let f of r)u.tempSkipped.push(f);e&&(u.scheduleOn=u.scheduleOn?Promise.all([u.scheduleOn,e]):e)}return this.parsedPos=o,new wt(Dn.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return nf}}function HR(t,e,n){return Co.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Eu{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,i)||n.takeTree(),new Eu(n)}static init(e){let n=Math.min(3e3,e.doc.length),i=qf.create(e.facet(Ru).parser,e,{from:0,to:n});return i.work(20,n)||i.takeTree(),new Eu(i)}}Ar.state=Ao.define({create:Eu.init,update(t,e){for(let n of e.effects)if(n.is(Ar.setState))return n.value;return e.startState.facet(Ru)!=e.state.facet(Ru)?Eu.init(e.state):t.apply(e)}});let e5=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(e5=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Mb=typeof navigator<"u"&&(!((jb=navigator.scheduling)===null||jb===void 0)&&jb.isInputPending)?()=>navigator.scheduling.isInputPending():null,cse=Dr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Ar.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Ar.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=e5(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndr+1e3,u=s.context.work(()=>Mb&&Mb()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-n,(u||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ar.setState.of(new Eu(s.context))})),this.chunkBudget>0&&!(u&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Ts(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ru=Ne.define({combine(t){return t.length?t[0]:null},enables:t=>[Ar.state,cse,Le.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class Yf{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}class Vm{constructor(e,n,i,r,s,o=void 0){this.name=e,this.alias=n,this.extensions=i,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:n,support:i}=e;if(!n){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(i)}return new Vm(e.name,(e.alias||[]).concat(e.name).map(r=>r.toLowerCase()),e.extensions||[],e.filename,n,i)}static matchFilename(e,n){for(let r of e)if(r.filename&&r.filename.test(n))return r;let i=/\.([^.]+)$/.exec(n);if(i){for(let r of e)if(r.extensions.indexOf(i[1])>-1)return r}return null}static matchLanguageName(e,n,i=!0){n=n.toLowerCase();for(let r of e)if(r.alias.some(s=>s==n))return r;if(i)for(let r of e)for(let s of r.alias){let o=n.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(n[o-1])&&!/\w/.test(n[o+s.length])))return r}return null}}const use=Ne.define(),Th=Ne.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Bm(t){let e=t.facet(Th);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Um(t,e){let n="",i=t.tabSize,r=t.facet(Th)[0];if(r==" "){for(;e>=i;)n+=" ",e-=i;r=" "}for(let s=0;s=e?dse(t,n,e):null}class ry{constructor(e,n={}){this.state=e,this.options=n,this.unit=Bm(e)}lineAt(e,n=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(n<0?r-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,n=e.length){return To(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Eh=new We;function dse(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let s=[];for(let o=r;o&&!(o.fromi.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return n5(i,t,n)}function n5(t,e,n){for(let i=t;i;i=i.next){let r=hse(i.node);if(r)return r(rk.create(e,n,i))}return 0}function fse(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function hse(t){let e=t.type.prop(Eh);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(We.closedBy))){let r=t.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>i5(o,!0,1,void 0,s&&!fse(o)?r.from:void 0)}return t.parent==null?pse:null}function pse(){return 0}class rk extends ry{constructor(e,n,i){super(e.state,e.options),this.base=e,this.pos=n,this.context=i}get node(){return this.context.node}static create(e,n,i){return new rk(e,n,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(n.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(gse(i,e))break;n=this.state.doc.lineAt(i.from)}return this.lineIndent(n.from)}continue(){return n5(this.context.next,this.base,this.pos)}}function gse(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function mse(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=n.to;;){let u=e.childAfter(l);if(!u||u==i)return null;if(!u.type.isSkipped){if(u.from>=o)return null;let f=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+f}}l=u.to}}function Ose({closing:t,align:e=!0,units:n=1}){return i=>i5(i,e,n,t)}function i5(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==t.pos+o,u=e?mse(t):null;return u?l?t.column(u.from):t.column(u.to):t.baseIndent+(l?0:t.unit*n)}const yse=t=>t.baseIndent;function tm({except:t,units:e=1}={}){return n=>{let i=t&&t.test(n.textAfter);return n.baseIndent+(i?0:e*n.unit)}}const vse=Ne.define(),Rh=new We;function r5(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(xl)==o.data:o?l=>l==o:void 0,this.style=Jz(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Ta(i):null,this.themeType=n.themeType}static define(e,n){return new sy(e,n||{})}}const zx=Ne.define(),s5=Ne.define({combine(t){return t.length?[t[0]]:null}});function Db(t){let e=t.facet(zx);return e.length?e:t.facet(s5)}function bse(t,e){let n=[xse],i;return t instanceof sy&&(t.module&&n.push(Le.styleModule.of(t.module)),i=t.themeType),e?.fallback?n.push(s5.of(t)):i?n.push(zx.computeN([Le.darkTheme],r=>r.facet(Le.darkTheme)==(i=="dark")?[t]:[])):n.push(zx.of(t)),n}class Sse{constructor(e){this.markCache=Object.create(null),this.tree=hn(e.state),this.decorations=this.buildDeco(e,Db(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=hn(e.state),i=Db(e.state),r=i!=Db(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Tt.none;let i=new ou;for(let{from:r,to:s}of e.visibleRanges)sse(this.tree,n,(o,l,u)=>{i.add(o,l,this.markCache[u]||(this.markCache[u]=Tt.mark({class:u})))},r,s);return i.finish()}}const xse=wh.high(Dr.fromClass(Sse,{decorations:t=>t.decorations})),wse=sy.define([{tag:Z.meta,color:"#404740"},{tag:Z.link,textDecoration:"underline"},{tag:Z.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Z.emphasis,fontStyle:"italic"},{tag:Z.strong,fontWeight:"bold"},{tag:Z.strikethrough,textDecoration:"line-through"},{tag:Z.keyword,color:"#708"},{tag:[Z.atom,Z.bool,Z.url,Z.contentSeparator,Z.labelName],color:"#219"},{tag:[Z.literal,Z.inserted],color:"#164"},{tag:[Z.string,Z.deleted],color:"#a11"},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],color:"#e40"},{tag:Z.definition(Z.variableName),color:"#00f"},{tag:Z.local(Z.variableName),color:"#30a"},{tag:[Z.typeName,Z.namespace],color:"#085"},{tag:Z.className,color:"#167"},{tag:[Z.special(Z.variableName),Z.macroName],color:"#256"},{tag:Z.definition(Z.propertyName),color:"#00c"},{tag:Z.comment,color:"#940"},{tag:Z.invalid,color:"#f00"}]),kse=1e4,Cse="()[]{}",o5=new We;function Lx(t,e,n){let i=t.prop(e<0?We.openedBy:We.closedBy);if(i)return i;if(t.name.length==1){let r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function Zx(t){let e=t.type.prop(o5);return e?e(t.node):t}function Jc(t,e,n,i={}){let r=i.maxScanDistance||kse,s=i.brackets||Cse,o=hn(t),l=o.resolveInner(e,n);for(let u=l;u;u=u.parent){let f=Lx(u.type,n,s);if(f&&u.from0?e>=h.from&&eh.from&&e<=h.to))return _se(t,e,n,u,h,f,s)}}return $se(t,e,n,o,l.type,r,s)}function _se(t,e,n,i,r,s,o){let l=i.parent,u={from:r.from,to:r.to},f=0,h=l?.cursor();if(h&&(n<0?h.childBefore(i.from):h.childAfter(i.to)))do if(n<0?h.to<=i.from:h.from>=i.to){if(f==0&&s.indexOf(h.type.name)>-1&&h.from0)return null;let f={from:n<0?e-1:e,to:n>0?e+1:e},h=t.doc.iterRange(e,n>0?t.doc.length:0),p=0;for(let O=0;!h.next().done&&O<=s;){let y=h.value;n<0&&(O+=y.length);let v=e+O*n;for(let S=n>0?0:y.length-1,k=n>0?y.length:-1;S!=k;S+=n){let C=o.indexOf(y[S]);if(!(C<0||i.resolveInner(v+S,1).type!=r))if(C%2==0==n>0)p++;else{if(p==1)return{start:f,end:{from:v+S,to:v+S+1},matched:C>>1==u>>1};p--}}n>0&&(O+=y.length)}return h.done?{start:f,matched:!1}:null}const Tse=Object.create(null),WR=[Dn.none],KR=[],JR=Object.create(null),Ese=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Ese[t]=Rse(Tse,e);function Nb(t,e){KR.indexOf(t)>-1||(KR.push(t),console.warn(e))}function Rse(t,e){let n=[];for(let l of e.split(" ")){let u=[];for(let f of l.split(".")){let h=t[f]||Z[f];h?typeof h=="function"?u.length?u=u.map(h):Nb(f,`Modifier ${f} used at start of tag`):u.length?Nb(f,`Tag ${f} used as modifier`):u=Array.isArray(h)?h:[h]:Nb(f,`Unknown highlighting tag ${f}`)}for(let f of u)n.push(f)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+n.map(l=>l.id),s=JR[r];if(s)return s.id;let o=JR[r]=Dn.define({id:WR.length,name:i,props:[Fu({[i]:n})]});return WR.push(o),o.id}bn.RTL,bn.LTR;const Qse=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=ok(t.state,n.from);return i.line?Ase(t):i.block?jse(t):!1};function sk(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return r?(i(n.update(r)),!0):!1}}const Ase=sk(Nse,0),Pse=sk(a5,0),jse=sk((t,e)=>a5(t,e,Dse(e)),0);function ok(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const rf=50;function Mse(t,{open:e,close:n},i,r){let s=t.sliceDoc(i-rf,i),o=t.sliceDoc(r,r+rf),l=/\s*$/.exec(s)[0].length,u=/^\s*/.exec(o)[0].length,f=s.length-l;if(s.slice(f-e.length,f)==e&&o.slice(u,u+n.length)==n)return{open:{pos:i-l,margin:l&&1},close:{pos:r+u,margin:u&&1}};let h,p;r-i<=2*rf?h=p=t.sliceDoc(i,r):(h=t.sliceDoc(i,i+rf),p=t.sliceDoc(r-rf,r));let O=/^\s*/.exec(h)[0].length,y=/\s*$/.exec(p)[0].length,v=p.length-y-n.length;return h.slice(O,O+e.length)==e&&p.slice(v,v+n.length)==n?{open:{pos:i+O+e.length,margin:/\s/.test(h.charAt(O+e.length))?1:0},close:{pos:r-y-n.length,margin:/\s/.test(p.charAt(v-1))?1:0}}:null}function Dse(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function a5(t,e,n=e.selection.ranges){let i=n.map(s=>ok(e,s.from).block);if(!i.every(s=>s))return null;let r=n.map((s,o)=>Mse(e,i[o],s.from,s.to));if(t!=2&&!r.every(s=>s))return{changes:e.changes(n.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(t!=1&&r.some(s=>s)){let s=[];for(let o=0,l;or&&(s==o||o>p.from)){r=p.from;let O=/^\s*/.exec(p.text)[0].length,y=O==p.length,v=p.text.slice(O,O+f.length)==f?O:-1;Os.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:u,indent:f,empty:h,single:p}of i)(p||!h)&&s.push({from:l.from+f,insert:u+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:u}of i)if(l>=0){let f=o.from+l,h=f+u.length;o.text[h-o.from]==" "&&h++,s.push({from:f,to:h})}return{changes:s}}return null}const Ix=ss.define(),zse=ss.define(),Lse=Ne.define(),l5=Ne.define({combine(t){return GN(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(i,r)=>e(i,r)||n(i,r)})}}),c5=Ao.define({create(){return Rs.empty},update(t,e){let n=e.state.facet(l5),i=e.annotation(Ix);if(i){let u=Vi.fromTransaction(e,i.selection),f=i.side,h=f==0?t.undone:t.done;return u?h=qm(h,h.length,n.minDepth,u):h=f5(h,e.startState.selection),new Rs(f==0?i.rest:h,f==0?h:i.rest)}let r=e.annotation(zse);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(Ci.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Vi.fromTransaction(e),o=e.annotation(Ci.time),l=e.annotation(Ci.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Rs(t.done.map(Vi.fromJSON),t.undone.map(Vi.fromJSON))}});function Zse(t={}){return[c5,l5.of(t),Le.domEventHandlers({beforeinput(e,n){let i=e.inputType=="historyUndo"?u5:e.inputType=="historyRedo"?Xx:null;return i?(e.preventDefault(),i(n)):!1}})]}function oy(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(c5,!1);if(!r)return!1;let s=r.pop(t,n,e);return s?(i(s),!0):!1}}const u5=oy(0,!1),Xx=oy(1,!1),Ise=oy(0,!0),Xse=oy(1,!0);class Vi{constructor(e,n,i,r,s){this.changes=e,this.effects=n,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new Vi(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new Vi(e.changes&&jn.fromJSON(e.changes),[],e.mapped&&js.fromJSON(e.mapped),e.startSelection&&Oe.fromJSON(e.startSelection),e.selectionsAfter.map(Oe.fromJSON))}static fromTransaction(e,n){let i=Pr;for(let r of e.startState.facet(Lse)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new Vi(e.changes.invert(e.startState.doc),i,void 0,n||e.startState.selection,Pr)}static selection(e){return new Vi(void 0,Pr,void 0,void 0,e)}}function qm(t,e,n,i){let r=e+1>n+20?e-n-1:0,s=t.slice(r,e);return s.push(i),s}function Vse(t,e){let n=[],i=!1;return t.iterChangedRanges((r,s)=>n.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let u=0;u=f&&o<=h&&(i=!0)}}),i}function Bse(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,i)=>n.empty!=e.ranges[i].empty).length===0}function d5(t,e){return t.length?e.length?t.concat(e):t:e}const Pr=[],Use=200;function f5(t,e){if(t.length){let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Use));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),qm(t,t.length-1,1e9,n.setSelAfter(i)))}else return[Vi.selection([e])]}function qse(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function zb(t,e){if(!t.length)return t;let n=t.length,i=Pr;for(;n;){let r=Yse(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=t.slice(0,n);return s[n-1]=r,s}else e=r.mapped,n--,i=r.selectionsAfter}return i.length?[Vi.selection(i)]:Pr}function Yse(t,e,n){let i=d5(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):Pr,n);if(!t.changes)return Vi.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Vi(r,Jt.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}const Fse=/^(input\.type|delete)($|\.)/;class Rs{constructor(e,n,i=0,r=void 0){this.done=e,this.undone=n,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new Rs(this.done,this.undone):this}addChanges(e,n,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||Fse.test(i))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):ay(n,e))}function mi(t){return t.textDirectionAt(t.state.selection.main.head)==bn.LTR}const p5=t=>h5(t,!mi(t)),g5=t=>h5(t,mi(t));function m5(t,e){return as(t,n=>n.empty?t.moveByGroup(n,e):ay(n,e))}const Hse=t=>m5(t,!mi(t)),Wse=t=>m5(t,mi(t));function Kse(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function ly(t,e,n){let i=hn(t).resolveInner(e.head),r=n?We.closedBy:We.openedBy;for(let u=e.head;;){let f=n?i.childAfter(u):i.childBefore(u);if(!f)break;Kse(t,f,r)?i=f:u=n?f.to:f.from}let s=i.type.prop(r),o,l;return s&&(o=n?Jc(t,i.from,1):Jc(t,i.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?i.to:i.from,Oe.cursor(l,n?-1:1)}const Jse=t=>as(t,e=>ly(t.state,e,!mi(t))),eoe=t=>as(t,e=>ly(t.state,e,mi(t)));function O5(t,e){return as(t,n=>{if(!n.empty)return ay(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)})}const y5=t=>O5(t,!1),v5=t=>O5(t,!0);function b5(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):ay(o,e));if(r.eq(i.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(i.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),u=l.top+n.marginTop,f=l.bottom-n.marginBottom;o&&o.top>u&&o.bottomS5(t,!1),Vx=t=>S5(t,!0);function Va(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let s=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=Oe.cursor(i.from+s))}return r}const toe=t=>as(t,e=>Va(t,e,!0)),noe=t=>as(t,e=>Va(t,e,!1)),ioe=t=>as(t,e=>Va(t,e,!mi(t))),roe=t=>as(t,e=>Va(t,e,mi(t))),soe=t=>as(t,e=>Oe.cursor(t.lineBlockAt(e.head).from,1)),ooe=t=>as(t,e=>Oe.cursor(t.lineBlockAt(e.head).to,-1));function aoe(t,e,n){let i=!1,r=Gu(t.selection,s=>{let o=Jc(t,s.head,-1)||Jc(t,s.head,1)||s.head>0&&Jc(t,s.head-1,1)||s.headaoe(t,e);function zr(t,e,n){let i=Gu(t.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=Oe.range(r.head,r.anchor));let s=n(r);return Oe.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(t.state.selection)?!1:(t.dispatch(os(t.state,i)),!0)}function x5(t,e){return zr(t,e,n=>t.moveByChar(n,e))}const w5=t=>x5(t,!mi(t)),k5=t=>x5(t,mi(t));function C5(t,e){return zr(t,e,n=>t.moveByGroup(n,e))}const coe=t=>C5(t,!mi(t)),uoe=t=>C5(t,mi(t)),doe=t=>{let e=!mi(t);return zr(t,e,n=>ly(t.state,n,e))},foe=t=>{let e=mi(t);return zr(t,e,n=>ly(t.state,n,e))};function _5(t,e){return zr(t,e,n=>t.moveVertically(n,e))}const $5=t=>_5(t,!1),T5=t=>_5(t,!0);function E5(t,e){return zr(t,e,n=>t.moveVertically(n,e,b5(t).height))}const tQ=t=>E5(t,!1),nQ=t=>E5(t,!0),hoe=t=>zr(t,!0,e=>Va(t,e,!0)),poe=t=>zr(t,!1,e=>Va(t,e,!1)),goe=t=>{let e=!mi(t);return zr(t,e,n=>Va(t,n,e))},moe=t=>{let e=mi(t);return zr(t,e,n=>Va(t,n,e))},Ooe=t=>zr(t,!1,e=>Oe.cursor(t.lineBlockAt(e.head).from)),yoe=t=>zr(t,!0,e=>Oe.cursor(t.lineBlockAt(e.head).to)),iQ=({state:t,dispatch:e})=>(e(os(t,{anchor:0})),!0),rQ=({state:t,dispatch:e})=>(e(os(t,{anchor:t.doc.length})),!0),sQ=({state:t,dispatch:e})=>(e(os(t,{anchor:t.selection.main.anchor,head:0})),!0),oQ=({state:t,dispatch:e})=>(e(os(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),voe=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),boe=({state:t,dispatch:e})=>{let n=cy(t).map(({from:i,to:r})=>Oe.undirectionalRange(i,Math.min(r+1,t.doc.length)));return e(t.update({selection:Oe.create(n),userEvent:"select"})),!0},Soe=({state:t,dispatch:e})=>{let n=Gu(t.selection,i=>{let r=hn(t),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return Oe.undirectionalRange(l.from,l.to)}return i});return n.eq(t.selection)?!1:(e(os(t,n)),!0)};function R5(t,e){let{state:n}=t,i=n.selection,r=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let u=t.moveVertically(l,e);if(u.heado.to){r.some(f=>f.head==u.head)||r.push(u);break}else{if(u.head==l.head)break;l=u}}}return r.length==i.ranges.length?!1:(t.dispatch(os(n,Oe.create(r,r.length-1))),!0)}const xoe=t=>R5(t,!1),woe=t=>R5(t,!0),koe=({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=Oe.create([n.main]):n.main.empty||(i=Oe.create([Oe.cursor(n.main.head)])),i?(e(os(t,i)),!0):!1};function Qh(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:i}=t,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let u=e(s);uo&&(n="delete.forward",u=jg(t,u,!0)),o=Math.min(o,u),l=Math.max(l,u)}else o=jg(t,o,!1),l=jg(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:Oe.cursor(o,or(t)))i.between(e,e,(r,s)=>{re&&(e=n?s:r)});return e}const Q5=(t,e,n)=>Qh(t,i=>{let r=i.from,{state:s}=t,o=s.doc.lineAt(r),l,u;if(n&&!e&&r>o.from&&rQ5(t,!1,!0),A5=t=>Q5(t,!0,!1),P5=(t,e)=>Qh(t,n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let u=fi(s.text,i-s.from,e)+s.from,f=s.text.slice(Math.min(i,u)-s.from,Math.max(i,u)-s.from),h=o(f);if(l!=null&&h!=l)break;(f!=" "||i!=n.head)&&(l=h),i=u}return i}),j5=t=>P5(t,!1),Coe=t=>P5(t,!0),_oe=t=>Qh(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headQh(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),Toe=t=>Qh(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Ot.of(["",""])},range:Oe.cursor(i.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Roe=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{if(!i.empty||i.from==0||i.from==t.doc.length)return{range:i};let r=i.from,s=t.doc.lineAt(r),o=r==s.from?r-1:fi(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:fi(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(r,l).append(t.doc.slice(o,r))},range:Oe.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function cy(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=t.doc.lineAt(i.to-1)),n>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function M5(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let s of cy(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let u of s.ranges)r.push(Oe.range(Math.min(t.doc.length,u.anchor+l),Math.min(t.doc.length,u.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let u of s.ranges)r.push(Oe.range(u.anchor-l,u.head-l))}}return i.length?(e(t.update({changes:i,scrollIntoView:!0,selection:Oe.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Qoe=({state:t,dispatch:e})=>M5(t,e,!1),Aoe=({state:t,dispatch:e})=>M5(t,e,!0);function D5(t,e,n){if(t.readOnly)return!1;let i=[];for(let s of cy(t))n?i.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):i.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let r=t.changes(i);return e(t.update({changes:r,selection:t.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Poe=({state:t,dispatch:e})=>D5(t,e,!1),joe=({state:t,dispatch:e})=>D5(t,e,!0),Moe=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(cy(e).map(({from:r,to:s})=>(r>0?r--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(r.head),l=t.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,s)}).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Doe(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=hn(t).resolveInner(e),i=n.childBefore(e),r=n.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(We.closedBy))&&s.indexOf(r.name)>-1&&t.doc.lineAt(i.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const aQ=N5(!1),Noe=N5(!0);function N5(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),u=!t&&s==o&&Doe(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let f=new ry(e,{simulateBreak:s,simulateDoubleBreak:!!u}),h=t5(f,s);for(h==null&&(h=To(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let r=[];for(let o=i.from;o<=i.to;){let l=t.doc.lineAt(o);l.number>n&&(i.empty||i.to>l.from)&&(e(l,r,i),n=l.number),o=l.to+1}let s=t.changes(r);return{changes:r,range:Oe.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const zoe=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new ry(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),r=ak(t,(s,o,l)=>{let u=t5(i,s.from);if(u==null)return;/\S/.test(s.text)||(u=0);let f=/^\s*/.exec(s.text)[0],h=Um(t,u);(f!=h||l.fromt.readOnly?!1:(e(t.update(ak(t,(n,i)=>{i.push({from:n.from,insert:t.facet(Th)})}),{userEvent:"input.indent"})),!0),L5=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(ak(t,(n,i)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let s=To(r,t.tabSize),o=0,l=Um(t,Math.max(0,s-Bm(t)));for(;o(t.setTabFocusMode(),!0),Zoe=[{key:"Ctrl-b",run:p5,shift:w5,preventDefault:!0},{key:"Ctrl-f",run:g5,shift:k5},{key:"Ctrl-p",run:y5,shift:$5},{key:"Ctrl-n",run:v5,shift:T5},{key:"Ctrl-a",run:soe,shift:Ooe},{key:"Ctrl-e",run:ooe,shift:yoe},{key:"Ctrl-d",run:A5},{key:"Ctrl-h",run:Bx},{key:"Ctrl-k",run:_oe},{key:"Ctrl-Alt-h",run:j5},{key:"Ctrl-o",run:Eoe},{key:"Ctrl-t",run:Roe},{key:"Ctrl-v",run:Vx}],Ioe=[{key:"ArrowLeft",run:p5,shift:w5,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Hse,shift:coe,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:ioe,shift:goe,preventDefault:!0},{key:"ArrowRight",run:g5,shift:k5,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Wse,shift:uoe,preventDefault:!0},{mac:"Cmd-ArrowRight",run:roe,shift:moe,preventDefault:!0},{key:"ArrowUp",run:y5,shift:$5,preventDefault:!0},{mac:"Cmd-ArrowUp",run:iQ,shift:sQ},{mac:"Ctrl-ArrowUp",run:eQ,shift:tQ},{key:"ArrowDown",run:v5,shift:T5,preventDefault:!0},{mac:"Cmd-ArrowDown",run:rQ,shift:oQ},{mac:"Ctrl-ArrowDown",run:Vx,shift:nQ},{key:"PageUp",run:eQ,shift:tQ},{key:"PageDown",run:Vx,shift:nQ},{key:"Home",run:noe,shift:poe,preventDefault:!0},{key:"Mod-Home",run:iQ,shift:sQ},{key:"End",run:toe,shift:hoe,preventDefault:!0},{key:"Mod-End",run:rQ,shift:oQ},{key:"Enter",run:aQ,shift:aQ},{key:"Mod-a",run:voe},{key:"Backspace",run:Bx,shift:Bx,preventDefault:!0},{key:"Delete",run:A5,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:j5,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Coe,preventDefault:!0},{mac:"Mod-Backspace",run:$oe,preventDefault:!0},{mac:"Mod-Delete",run:Toe,preventDefault:!0}].concat(Zoe.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Xoe=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Jse,shift:doe},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eoe,shift:foe},{key:"Alt-ArrowUp",run:Qoe},{key:"Shift-Alt-ArrowUp",run:Poe},{key:"Alt-ArrowDown",run:Aoe},{key:"Shift-Alt-ArrowDown",run:joe},{key:"Mod-Alt-ArrowUp",run:xoe},{key:"Mod-Alt-ArrowDown",run:woe},{key:"Escape",run:koe},{key:"Mod-Enter",run:Noe},{key:"Alt-l",mac:"Ctrl-l",run:boe},{key:"Mod-i",run:Soe,preventDefault:!0},{key:"Mod-[",run:L5},{key:"Mod-]",run:z5},{key:"Mod-Alt-\\",run:zoe},{key:"Shift-Mod-k",run:Moe},{key:"Shift-Mod-\\",run:loe},{key:"Mod-/",run:Qse},{key:"Alt-A",mac:"Ctrl-A",run:Pse},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Loe}].concat(Ioe),Voe={key:"Tab",run:z5,shift:L5};class Boe{constructor(e,n,i,r){this.state=e,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=hn(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(Foe(e));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function lQ(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Uoe(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[n,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Uoe(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:n}:null}}function Yoe(t,e){return n=>{for(let i=hn(n.state).resolveInner(n.pos,-1);i;i=i.parent){if(t.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(n)}}function Foe(t,e){var n;let{source:i}=t,r=i[i.length-1]!="$";return r?new RegExp(`(?:${i})${r?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":""):t}const Goe=ss.define(),Hoe=Le.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Woe{constructor(e,n,i,r){this.field=e,this.line=n,this.from=i,this.to=r}}class lk{constructor(e,n,i){this.field=e,this.from=n,this.to=i}map(e){let n=e.mapPos(this.from,-1,ki.TrackDel),i=e.mapPos(this.to,1,ki.TrackDel);return n==null||i==null?null:new lk(this.field,n,i)}}class ck{constructor(e,n){this.lines=e,this.fieldPositions=n}instantiate(e,n){let i=[],r=[n],s=e.doc.lineAt(n),o=/^\s*/.exec(s.text)[0];for(let u of this.lines){if(i.length){let f=o,h=/^\t*/.exec(u)[0].length;for(let p=0;pnew lk(u.field,r[u.line]+u.from,r[u.line]+u.to));return{text:i,ranges:l}}static parse(e){let n=[],i=[],r=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=s[1]?+s[1]:null,u=s[2]||s[3]||"",f=-1;l===0&&(l=1e9);let h=u.replace(/\\[{}]/g,p=>p[1]);for(let p=0;p=f&&O.field++}for(let p of r)if(p.line==i.length&&p.from>s.index){let O=s[2]?3+(s[1]||"").length:2;p.from-=O,p.to-=O}r.push(new Woe(f,i.length,s.index,s.index+h.length)),o=o.slice(0,s.index)+u+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(l,u,f)=>{for(let h of r)h.line==i.length&&h.from>f&&(h.from--,h.to--);return u}),i.push(o)}return new ck(i,r)}}let Koe=Tt.widget({widget:new class extends Yu{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),Joe=Tt.mark({class:"cm-snippetField"});class Hu{constructor(e,n){this.ranges=e,this.active=n,this.deco=Tt.set(e.map(i=>(i.from==i.to?Koe:Joe).range(i.from,i.to)),!0)}map(e){let n=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;n.push(r)}return new Hu(n,this.active)}selectionInsideField(e){return e.ranges.every(n=>this.ranges.some(i=>i.field==this.active&&i.from<=n.from&&i.to>=n.to))}}const Ah=Jt.define({map(t,e){return t&&t.map(e)}}),eae=Jt.define(),Ff=Ao.define({create(){return null},update(t,e){for(let n of e.effects){if(n.is(Ah))return n.value;if(n.is(eae)&&t)return new Hu(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>Le.decorations.from(t,e=>e?e.deco:Tt.none)});function uk(t,e){return Oe.create(t.filter(n=>n.field==e).map(n=>Oe.range(n.from,n.to)))}function tae(t){let e=ck.parse(t);return(n,i,r,s)=>{let{text:o,ranges:l}=e.instantiate(n.state,r),{main:u}=n.state.selection,f={changes:{from:r,to:s==u.from?u.to:s,insert:Ot.of(o)},scrollIntoView:!0,annotations:i?[Goe.of(i),Ci.userEvent.of("input.complete")]:void 0};if(l.length&&(f.selection=uk(l,0)),l.some(h=>h.field>0)){let h=new Hu(l,0),p=f.effects=[Ah.of(h)];n.state.field(Ff,!1)===void 0&&p.push(Jt.appendConfig.of([Ff,oae,aae,Hoe]))}n.dispatch(n.state.update(f))}}function Z5(t){return({state:e,dispatch:n})=>{let i=e.field(Ff,!1);if(!i||t<0&&i.active==0)return!1;let r=i.active+t,s=t>0&&!i.ranges.some(o=>o.field==r+t);return n(e.update({selection:uk(i.ranges,r),effects:Ah.of(s?null:new Hu(i.ranges,r)),scrollIntoView:!0})),!0}}const nae=({state:t,dispatch:e})=>t.field(Ff,!1)?(e(t.update({effects:Ah.of(null)})),!0):!1,iae=Z5(1),rae=Z5(-1),sae=[{key:"Tab",run:iae,shift:rae},{key:"Escape",run:nae}],cQ=Ne.define({combine(t){return t.length?t[0]:sae}}),oae=wh.highest(iy.compute([cQ],t=>t.facet(cQ)));function zi(t,e){return{...e,apply:tae(t)}}const aae=Le.domEventHandlers({mousedown(t,e){let n=e.state.field(Ff,!1),i;if(!n||(i=e.posAtCoords({x:t.clientX,y:t.clientY}))==null)return!1;let r=n.ranges.find(s=>s.from<=i&&s.to>=i);return!r||r.field==n.active?!1:(e.dispatch({selection:uk(n.ranges,r.field),effects:Ah.of(n.ranges.some(s=>s.field>r.field)?new Hu(n.ranges,r.field):null),scrollIntoView:!0}),!0)}}),I5=new class extends $a{};I5.startSide=1;I5.endSide=-1;class Ym{static create(e,n,i,r,s){let o=r+(r<<8)+e+(n<<4)|0;return new Ym(e,n,i,o,s,[],[])}constructor(e,n,i,r,s,o,l){this.type=e,this.value=n,this.from=i,this.hash=r,this.end=s,this.children=o,this.positions=l,this.hashProp=[[We.contextHash,r]]}addChild(e,n){e.prop(We.contextHash)!=this.hash&&(e=new wt(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(n)}toTree(e,n=this.end){let i=this.children.length-1;return i>=0&&(n=Math.max(n,this.positions[i]+this.children[i].length+this.from)),new wt(e.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(r,s,o)=>new wt(Dn.none,r,s,o,this.hashProp)})}}var we;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(we||(we={}));class lae{constructor(e,n){this.start=e,this.content=n,this.marks=[],this.parsers=[]}}class cae{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return Cf(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,n=0,i=0){for(let r=n;r=e.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let i=(t.type==we.OrderedList?hk:fk)(n,e,!1);return i>0&&(t.type!=we.BulletList||dk(n,e,!1)<0)&&n.text.charCodeAt(n.pos+i-1)==t.value}const X5={[we.Blockquote](t,e,n){return n.next!=62?!1:(n.markers.push(gt(we.QuoteMark,e.lineStart+n.pos,e.lineStart+n.pos+1)),n.moveBase(n.pos+(Lr(n.text.charCodeAt(n.pos+1))?2:1)),t.end=e.lineStart+n.text.length,!0)},[we.ListItem](t,e,n){return n.indent-1?!1:(n.moveBaseColumn(n.baseIndent+t.value),!0)},[we.OrderedList]:uQ,[we.BulletList]:uQ,[we.Document](){return!0}};function Lr(t){return t==32||t==9||t==10||t==13}function Cf(t,e=0){for(;en&&Lr(t.charCodeAt(e-1));)e--;return e}function V5(t){if(t.next!=96&&t.next!=126)return-1;let e=t.pos+1;for(;e-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(W5.SetextHeading)>-1||i<3?-1:1}function U5(t,e){for(let n=t.stack.length-1;n>=0;n--)if(t.stack[n].type==e)return!0;return!1}function fk(t,e,n){return(t.next==45||t.next==43||t.next==42)&&(t.pos==t.text.length-1||Lr(t.text.charCodeAt(t.pos+1)))&&(!n||U5(e,we.BulletList)||t.skipSpace(t.pos+2)=48&&r<=57;){i++;if(i==t.text.length)return-1;r=t.text.charCodeAt(i)}return i==t.pos||i>t.pos+9||r!=46&&r!=41||it.pos+1||t.next!=49)?-1:i+1-t.pos}function q5(t){if(t.next!=35)return-1;let e=t.pos+1;for(;e6?-1:n}function Y5(t){if(t.next!=45&&t.next!=61||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e/,G5=/\?>/,qx=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/i.exec(i);if(s)return t.append(gt(we.Comment,n,n+1+s[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return t.append(gt(we.ProcessingInstruction,n,n+1+o[0].length));let l=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return l?t.append(gt(we.HTMLTag,n,n+1+l[0].length)):-1},Emphasis(t,e,n){if(e!=95&&e!=42)return-1;let i=n+1;for(;t.char(i)==e;)i++;let r=t.slice(n-1,n),s=t.slice(i,i+1),o=Hf.test(r),l=Hf.test(s),u=/\s|^$/.test(r),f=/\s|^$/.test(s),h=!f&&(!l||u||o),p=!u&&(!o||f||l),O=h&&(e==42||!p||o),y=p&&(e==42||!h||l);return t.append(new or(e==95?nL:iL,n,i,(O?1:0)|(y?2:0)))},HardBreak(t,e,n){if(e==92&&t.char(n+1)==10)return t.append(gt(we.HardBreak,n,n+2));if(e==32){let i=n+1;for(;t.char(i)==32;)i++;if(t.char(i)==10&&i>=n+2)return t.append(gt(we.HardBreak,n,i+1))}return-1},Link(t,e,n){return e==91?t.append(new or(Ol,n,n+1,1)):-1},Image(t,e,n){return e==33&&t.char(n+1)==91?t.append(new or(Fm,n,n+2,1)):-1},LinkEnd(t,e,n){if(e!=93)return-1;for(let i=t.parts.length-1;i>=0;i--){let r=t.parts[i];if(r instanceof or&&(r.type==Ol||r.type==Fm)){if(!r.side||t.skipSpace(r.to)==n&&!/[(\[]/.test(t.slice(n+1,n+2)))return t.parts[i]=null,-1;let s=t.takeContent(i),o=t.parts[i]=gae(t,s,r.type==Ol?we.Link:we.Image,r.from,n+1);if(r.type==Ol)for(let l=0;le?gt(we.URL,e+n,s+n):s==t.length?null:!1}}function sL(t,e,n){let i=t.charCodeAt(e);if(i!=39&&i!=34&&i!=40)return!1;let r=i==40?41:i;for(let s=e+1,o=!1;s=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,n){return this.text.slice(e-this.offset,n-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,n,i,r,s){return this.append(new or(e,n,i,(r?1:0)|(s?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let n=this.parts[e];if(n instanceof or&&(n.type==Ol||n.type==Fm))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let i=e;i=e;u--){let S=this.parts[u];if(S instanceof or&&S.side&1&&S.type==r.type&&!(s&&(r.side&1||S.side&2)&&(S.to-S.from+o)%3==0&&((S.to-S.from)%3||o%3))){l=S;break}}if(!l)continue;let f=r.type.resolve,h=[],p=l.from,O=r.to;if(s){let S=Math.min(2,l.to-l.from,o);p=l.to-S,O=r.from+S,f=S==1?"Emphasis":"StrongEmphasis"}l.type.mark&&h.push(this.elt(l.type.mark,p,l.to));for(let S=u+1;S=0;n--){let i=this.parts[n];if(i instanceof or&&i.type==e&&i.side&1)return n}return null}takeContent(e){let n=this.resolveMarkers(e);return this.parts.length=e,n}getDelimiterAt(e){let n=this.parts[e];return n instanceof or?n:null}skipSpace(e){return Cf(this.text,e-this.offset)+this.offset}elt(e,n,i,r){return typeof e=="string"?gt(this.parser.getNodeType(e),n,i,r):new tL(e,n)}}pk.linkStart=Ol;pk.imageStart=Fm;function Fx(t,e){if(!e.length)return t;if(!t.length)return e;let n=t.slice(),i=0;for(let r of e){for(;i(e?e-1:0))return!1;if(this.fragmentEnd<0){let s=this.fragment.to;for(;s>0&&this.input.read(s-1,s)!=` -`;)s--;this.fragmentEnd=s?s-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let r=e+this.fragment.offset;for(;i.to<=r;)if(!i.parent())return!1;for(;;){if(i.from>=r)return this.fragment.from<=n;if(!i.childAfter(r))return!1}}matches(e){let n=this.cursor.tree;return n&&n.prop(We.contextHash)==e}takeNodes(e){let n=this.cursor,i=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=e.absoluteLineStart,o=s,l=e.block.children.length,u=o,f=l;for(;;){if(n.to-i>r){if(n.type.isAnonymous&&n.firstChild())continue;break}let h=aL(n.from-i,e.ranges);if(n.to-i<=e.ranges[e.rangeI].to)e.addNode(n.tree,h);else{let p=new wt(e.parser.nodeSet.types[we.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(p,n.tree),e.addNode(p,h)}if(n.type.is("Block")&&(mae.indexOf(n.type.id)<0?(o=n.to-i,l=e.block.children.length):(o=u,l=f),u=n.to-i,f=e.block.children.length),!n.nextSibling())break}for(;e.block.children.length>l;)e.block.children.pop(),e.block.positions.pop();return o-s}};function aL(t,e){let n=t;for(let i=1;iMg[t]),Object.keys(Mg).map(t=>W5[t]),Object.keys(Mg),fae,X5,Object.keys(Zb).map(t=>Zb[t]),Object.keys(Zb),[]);function bae(t,e,n){let i=[];for(let r=t.firstChild,s=e;;r=r.nextSibling){let o=r?r.from:n;if(o>s&&i.push({from:s,to:o}),!r)break;s=r.to}return i}function Sae(t){let{codeParser:e,htmlParser:n}=t;return{wrap:Wz((r,s)=>{let o=r.type.id;if(e&&(o==we.CodeBlock||o==we.FencedCode)){let l="";if(o==we.FencedCode){let f=r.node.getChild(we.CodeInfo);f&&(l=s.read(f.from,f.to))}let u=e(l);if(u)return{parser:u,overlay:f=>f.type.id==we.CodeText,bracketed:o==we.FencedCode}}else if(n&&(o==we.HTMLBlock||o==we.HTMLTag||o==we.CommentBlock))return{parser:n,overlay:bae(r.node,r.from,r.to)};return null})}}const xae={resolve:"Strikethrough",mark:"StrikethroughMark"},wae={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":Z.strikethrough}},{name:"StrikethroughMark",style:Z.processingInstruction}],parseInline:[{name:"Strikethrough",parse(t,e,n){if(e!=126||t.char(n+1)!=126||t.char(n+2)==126)return-1;let i=t.slice(n-1,n),r=t.slice(n+2,n+3),s=/\s|^$/.test(i),o=/\s|^$/.test(r),l=Hf.test(i),u=Hf.test(r);return t.addDelimiter(xae,n,n+2,!o&&(!u||s||l),!s&&(!l||o||u))},after:"Emphasis"}]};function _f(t,e,n=0,i,r=0){let s=0,o=!0,l=-1,u=-1,f=!1,h=()=>{i.push(t.elt("TableCell",r+l,r+u,t.parser.parseInline(e.slice(l,u),r+l)))};for(let p=n;p-1)&&s++,o=!1,i&&(l>-1&&h(),i.push(t.elt("TableDelimiter",p+r,p+r+1))),l=u=-1):(f||O!=32&&O!=9)&&(l<0&&(l=p),u=p+1),f=!f&&O==92}return l>-1&&(s++,i&&h()),s}function pQ(t,e){for(let n=e;n\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class gQ{constructor(){this.rows=null}nextLine(e,n,i){if(this.rows==null){this.rows=!1;let r;if((n.next==45||n.next==58||n.next==124)&&lL.test(r=n.text.slice(n.pos))){let s=[];_f(e,i.content,0,s,i.start)==_f(e,r,0)&&(this.rows=[e.elt("TableHeader",i.start,i.start+i.content.length,s),e.elt("TableDelimiter",e.lineStart+n.pos,e.lineStart+n.text.length)])}}else if(this.rows){let r=[];_f(e,n.text,n.pos,r,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+n.pos,e.lineStart+n.text.length,r))}return!1}finish(e,n){return this.rows?(e.addLeafElement(n,e.elt("Table",n.start,n.start+n.content.length,this.rows)),!0):!1}}const kae={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":Z.heading}},"TableRow",{name:"TableCell",style:Z.content},{name:"TableDelimiter",style:Z.processingInstruction}],parseBlock:[{name:"Table",leaf(t,e){return pQ(e.content,0)?new gQ:null},endLeaf(t,e,n){if(n.parsers.some(r=>r instanceof gQ)||!pQ(e.text,e.basePos))return!1;let i=t.peekLine();return lL.test(i)&&_f(t,e.text,e.basePos)==_f(t,i,e.basePos)},before:"SetextHeading"}]};class Cae{nextLine(){return!1}finish(e,n){return e.addLeafElement(n,e.elt("Task",n.start,n.start+n.content.length,[e.elt("TaskMarker",n.start,n.start+3),...e.parser.parseInline(n.content.slice(3),n.start+3)])),!0}}const _ae={defineNodes:[{name:"Task",block:!0,style:Z.list},{name:"TaskMarker",style:Z.atom}],parseBlock:[{name:"TaskList",leaf(t,e){return/^\[[ xX]\][ \t]/.test(e.content)&&t.parentType().name=="ListItem"?new Cae:null},after:"SetextHeading"}]},mQ=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,OQ=/[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy,$ae=/[\w-]+\.[\w-]+($|[/:])/,yQ=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,vQ=/\/[a-zA-Z\d@.]+/gy;function bQ(t,e,n,i){let r=0;for(let s=e;s-1)return-1;let i=e+n[0].length;for(;;){let r=t[i-1],s;if(/[?!.,:*_~]/.test(r)||r==")"&&bQ(t,e,i,")")>bQ(t,e,i,"("))i--;else if(r==";"&&(s=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(t.slice(e,i))))i=e+s.index;else break}return i}function SQ(t,e){yQ.lastIndex=e;let n=yQ.exec(t);if(!n)return-1;let i=n[0][n[0].length-1];return i=="_"||i=="-"?-1:e+n[0].length-(i=="."?1:0)}const Eae={parseInline:[{name:"Autolink",parse(t,e,n){let i=n-t.offset;if(i&&/\w/.test(t.text[i-1]))return-1;mQ.lastIndex=i;let r=mQ.exec(t.text),s=-1;if(!r)return-1;if(r[1]||r[2]){if(s=Tae(t.text,i+r[0].length),s>-1&&t.hasOpenLink){let o=/([^\[\]]|\[[^\]]*\])*/.exec(t.text.slice(i,s));s=i+o[0].length}}else r[3]?s=SQ(t.text,i):(s=SQ(t.text,i+r[0].length),s>-1&&r[0]=="xmpp:"&&(vQ.lastIndex=s,r=vQ.exec(t.text),r&&(s=r.index+r[0].length)));return s<0?-1:(t.addElement(t.elt("URL",n,s+t.offset)),s+t.offset)}}]},Rae=[kae,_ae,wae,Eae];function cL(t,e,n){return(i,r,s)=>{if(r!=t||i.char(s+1)==t)return-1;let o=[i.elt(n,s,s+1)];for(let l=s+1;ln%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,i=0){let r=e.parser.context;return new Gm(e,[],n,i,i,0,[],0,r?new wQ(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(f==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizeu;)this.stack.pop();this.reduceContext(r,f)}storeNode(e,n,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==i)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,n,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let u=o;u>0&&this.buffer[u-2]>i;u-=4)if(this.buffer[u-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,n,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let l=o.stateFlag(s,1);!l&&(r>i||n<=o.maxNode)&&(this.reducePos=r),this.pushState(s,l?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=o.maxNode&&this.buffer.push(n,i,r,4)}else this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4)}apply(e,n,i,r){e&65536?this.reduce(e):this.shift(e,n,i,r)}useNode(e,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let i=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new Gm(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new jae(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(i==0)return!1;if((i&65536)==0)return!0;n.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,o;su&1&&l==o)||r.push(n[s],o)}n=r}let i=[];for(let r=0;r>19,r=n&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let u=o&65535,f=this.stack.length-l*3;if(f>=0&&e.getGoto(this.stack[f],u,!1)>=0)return l<<19|65536|u}}else{let l=i(o,s+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class wQ{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class jae{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class Hm{constructor(e,n,i){this.stack=e,this.pos=n,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Hm(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Hm(this.stack,this.pos,this.index)}}function Of(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let i=0,r=0;i=92&&o--,o>=34&&o--;let u=o-32;if(u>=46&&(u-=46,l=!0),s+=u,l)break;s*=46}n?n[r++]=s:n=new e(s)}return n}class nm{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const kQ=new nm;class Mae{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=kQ,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;si.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,i,r;if(n>=0&&n=this.chunk2Pos&&il.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=kQ,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return i}}class du{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:i}=n.p;uL(this.data,e,n,this.id,i.data,i.tokenPrecTable)}}du.prototype.contextual=du.prototype.fallback=du.prototype.extend=!1;class Wm{constructor(e,n,i){this.precTable=n,this.elseToken=i,this.data=typeof e=="string"?Of(e):e}token(e,n){let i=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(uL(this.data,e,n,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}}Wm.prototype.contextual=du.prototype.fallback=du.prototype.extend=!1;class hr{constructor(e,n={}){this.token=e,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function uL(t,e,n,i,r,s){let o=0,l=1<0){let v=t[y];if(u.allows(v)&&(e.token.value==-1||e.token.value==v||Dae(v,e.token.value,r,s))){e.acceptToken(v);break}}let h=e.next,p=0,O=t[o+2];if(e.next<0&&O>p&&t[f+O*3-3]==65535){o=t[f+O*3-1];continue e}for(;p>1,v=f+y+(y<<1),S=t[v],k=t[v+1]||65536;if(h=k)p=y+1;else{o=t[v+2],e.advance();continue e}}break}}function CQ(t,e,n){for(let i=e,r;(r=t[i])!=65535;i++)if(r==n)return i-e;return-1}function Dae(t,e,n,i){let r=CQ(n,i,e);return r<0||CQ(n,i,t)e)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:t.length}}class Nae{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?_Q(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?_Q(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof wt){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class zae{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new nm)}getActions(e){let n=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,u=0;for(let f=0;fp.end+25&&(u=Math.max(p.lookAhead,u)),p.value!=0)){let O=n;if(p.extended>-1&&(n=this.addActions(e,p.extended,p.end,n)),n=this.addActions(e,p.value,p.end,n),!h.extend&&(i=p,n>O))break}}for(;this.actions.length>n;)this.actions.pop();return u&&e.setLookAhead(u),!i&&e.pos==this.stream.end&&(i=new nm,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,n=this.addActions(e,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new nm,{pos:i,p:r}=e;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,i,r){for(let s=0;se.bufferLength*4?new Nae(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;on)i.push(l);else{if(this.advanceStack(l,i,e))continue;{r||(r=[],s=[]),r.push(l);let u=this.tokens.getMainToken(l);s.push(u.value,u.end)}}break}}if(!i.length){let o=r&&Iae(r);if(o)return nr&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw nr&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return nr&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,u)=>u.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&f.buffer.length>500)if((l.score-f.score||l.buffer.length-f.buffer.length)>0)i.splice(u--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let f=e.curContext&&e.curContext.tracker.strict,h=f?e.curContext.hash:0;for(let p=this.fragments.nodeAt(r);p;){let O=this.parser.nodeSet.types[p.type.id]==p.type?s.getGoto(e.state,p.type.id):-1;if(O>-1&&p.length&&(!f||(p.prop(We.contextHash)||0)==h))return e.useNode(p,O),nr&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(p.type.id)})`),!0;if(!(p instanceof wt)||p.children.length==0||p.positions[0]>0)break;let y=p.children[0];if(y instanceof wt&&p.positions[0]==0)p=y;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),nr&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let f=0;fr?n.push(v):i.push(v)}return!1}advanceFully(e,n){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return $Q(e,n),!0}}runRecovery(e,n,i){let r=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),nr&&console.log(h+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let p=l.split(),O=h;for(let y=0;y<10&&p.forceReduce()&&(nr&&console.log(O+this.stackID(p)+" (via force-reduce)"),!this.advanceFully(p,i));y++)nr&&(O=this.stackID(p)+" -> ");for(let y of l.recoverByInsert(u))nr&&console.log(h+this.stackID(y)+" (via recover-insert)"),this.advanceFully(y,i);this.stream.end>l.pos?(f==l.pos&&(f++,u=0),l.recoverByDelete(u,f),nr&&console.log(h+this.stackID(l)+` (via recover-delete ${this.parser.getName(u)})`),$Q(l,i)):(!r||r.scoret;class dL{constructor(e){this.start=e.start,this.shift=e.shift||Xb,this.reduce=e.reduce||Xb,this.reuse=e.reuse||Xb,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Au extends tk{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let l=0;le.topRules[l][1]),r=[];for(let l=0;l=0)s(h,u,l[f++]);else{let p=l[f+-h];for(let O=-h;O>0;O--)s(l[f++],u,p);f++}}}this.nodeSet=new $h(n.map((l,u)=>Dn.define({name:u>=this.minRepeatTerm?void 0:l,id:u,props:r[u],top:i.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=qz;let o=Of(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new du(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,i){let r=new Lae(this,e,n,i);for(let s of this.wrappers)r=s(r,e,n,i);return r}getGoto(e,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let o=r[s++],l=o&1,u=r[s++];if(l&&i)return u;for(let f=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,i=>i==n?!0:null)}allActions(e,n){let i=this.stateSlot(e,4),r=i?n(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=mo(this.data,s+2);else break;r=n(mo(this.data,s+1))}return r}nextStates(e){let n=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=mo(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];n.some((s,o)=>o&1&&s==r)||n.push(this.data[i],r)}}return n}configure(e){let n=Object.assign(Object.create(Au.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=i}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(l=>l.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=TQ(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;si)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,i)<<1|e}return t.get}const Xae=55,Vae=1,Bae=56,Uae=2,qae=57,Yae=3,EQ=4,Fae=5,gk=6,fL=7,hL=8,pL=9,gL=10,Gae=11,Hae=12,Wae=13,Vb=58,Kae=14,Jae=15,RQ=59,mL=21,ele=23,OL=24,tle=25,Gx=27,yL=28,nle=29,ile=32,rle=35,sle=37,ole=38,ale=0,lle=1,cle={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},ule={dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},QQ={dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}};function dle(t){return t==45||t==46||t==58||t>=65&&t<=90||t==95||t>=97&&t<=122||t>=161}let AQ=null,PQ=null,jQ=0;function Hx(t,e){let n=t.pos+e;if(jQ==n&&PQ==t)return AQ;let i=t.peek(e),r="";for(;dle(i);)r+=String.fromCharCode(i),i=t.peek(++e);return PQ=t,jQ=n,AQ=r?r.toLowerCase():i==fle||i==hle?void 0:null}const vL=60,Km=62,mk=47,fle=63,hle=33,ple=45;function MQ(t,e){this.name=t,this.parent=e}const gle=[gk,gL,fL,hL,pL],mle=new dL({start:null,shift(t,e,n,i){return gle.indexOf(e)>-1?new MQ(Hx(i,1)||"",t):t},reduce(t,e){return e==mL&&t?t.parent:t},reuse(t,e,n,i){let r=e.type.id;return r==gk||r==sle?new MQ(Hx(i,1)||"",t):t},strict:!1}),Ole=new hr((t,e)=>{if(t.next!=vL){t.next<0&&e.context&&t.acceptToken(Vb);return}t.advance();let n=t.next==mk;n&&t.advance();let i=Hx(t,0);if(i===void 0)return;if(!i)return t.acceptToken(n?Jae:Kae);let r=e.context?e.context.name:null;if(n){if(i==r)return t.acceptToken(Gae);if(r&&ule[r])return t.acceptToken(Vb,-2);if(e.dialectEnabled(ale))return t.acceptToken(Hae);for(let s=e.context;s;s=s.parent)if(s.name==i)return;t.acceptToken(Wae)}else{if(i=="script")return t.acceptToken(fL);if(i=="style")return t.acceptToken(hL);if(i=="textarea")return t.acceptToken(pL);if(cle.hasOwnProperty(i))return t.acceptToken(gL);r&&QQ[r]&&QQ[r][i]?t.acceptToken(Vb,-1):t.acceptToken(gk)}},{contextual:!0}),yle=new hr(t=>{for(let e=0,n=0;;n++){if(t.next<0){n&&t.acceptToken(RQ);break}if(t.next==ple)e++;else if(t.next==Km&&e>=2){n>=3&&t.acceptToken(RQ,-2);break}else e=0;t.advance()}});function vle(t){for(;t;t=t.parent)if(t.name=="svg"||t.name=="math")return!0;return!1}const ble=new hr((t,e)=>{if(t.next==mk&&t.peek(1)==Km){let n=e.dialectEnabled(lle)||vle(e.context);t.acceptToken(n?Fae:EQ,2)}else t.next==Km&&t.acceptToken(EQ,1)});function Ok(t,e,n){let i=2+t.length;return new hr(r=>{for(let s=0,o=0,l=0;;l++){if(r.next<0){l&&r.acceptToken(e);break}if(s==0&&r.next==vL||s==1&&r.next==mk||s>=2&&so?r.acceptToken(e,-o):r.acceptToken(n,-(o-2));break}else if((r.next==10||r.next==13)&&l){r.acceptToken(e,1);break}else s=o=0;r.advance()}})}const Sle=Ok("script",Xae,Vae),xle=Ok("style",Bae,Uae),wle=Ok("textarea",qae,Yae),kle=Fu({"Text RawText IncompleteTag IncompleteCloseTag":Z.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":Z.angleBracket,TagName:Z.tagName,"MismatchedCloseTag/TagName":[Z.tagName,Z.invalid],AttributeName:Z.attributeName,"AttributeValue UnquotedAttributeValue":Z.attributeValue,Is:Z.definitionOperator,"EntityReference CharacterReference":Z.character,Comment:Z.blockComment,ProcessingInst:Z.processingInstruction,DoctypeDecl:Z.documentMeta}),Cle=Au.deserialize({version:14,states:",xOVO!rOOO!ZQ#tO'#CrO!`Q#tO'#C{O!eQ#tO'#DOO!jQ#tO'#DRO!oQ#tO'#DTO!tOaO'#CqO#PObO'#CqO#[OdO'#CqO$kO!rO'#CqOOO`'#Cq'#CqO$rO$fO'#DUO$zQ#tO'#DWO%PQ#tO'#DXOOO`'#Dl'#DlOOO`'#DZ'#DZQVO!rOOO%UQ&rO,59^O%aQ&rO,59gO%lQ&rO,59jO%wQ&rO,59mO&SQ&rO,59oOOOa'#D_'#D_O&_OaO'#CyO&jOaO,59]OOOb'#D`'#D`O&rObO'#C|O&}ObO,59]OOOd'#Da'#DaO'VOdO'#DPO'bOdO,59]OOO`'#Db'#DbO'jO!rO,59]O'qQ#tO'#DSOOO`,59],59]OOOp'#Dc'#DcO'vO$fO,59pOOO`,59p,59pO(OQ#|O,59rO(TQ#|O,59sOOO`-E7X-E7XO(YQ&rO'#CtOOQW'#D['#D[O(hQ&rO1G.xOOOa1G.x1G.xOOO`1G/Z1G/ZO(sQ&rO1G/ROOOb1G/R1G/RO)OQ&rO1G/UOOOd1G/U1G/UO)ZQ&rO1G/XOOO`1G/X1G/XO)fQ&rO1G/ZOOOa-E7]-E7]O)qQ#tO'#CzOOO`1G.w1G.wOOOb-E7^-E7^O)vQ#tO'#C}OOOd-E7_-E7_O){Q#tO'#DQOOO`-E7`-E7`O*QQ#|O,59nOOOp-E7a-E7aOOO`1G/[1G/[OOO`1G/^1G/^OOO`1G/_1G/_O*VQ,UO,59`OOQW-E7Y-E7YOOOa7+$d7+$dOOO`7+$u7+$uOOOb7+$m7+$mOOOd7+$p7+$pOOO`7+$s7+$sO*bQ#|O,59fO*gQ#|O,59iO*lQ#|O,59lOOO`1G/Y1G/YO*qO7[O'#CwO+SOMhO'#CwOOQW1G.z1G.zOOO`1G/Q1G/QOOO`1G/T1G/TOOO`1G/W1G/WOOOO'#D]'#D]O+eO7[O,59cOOQW,59c,59cOOOO'#D^'#D^O+vOMhO,59cOOOO-E7Z-E7ZOOQW1G.}1G.}OOOO-E7[-E7[",stateData:",c~O!_OS~OUSOVPOWQOXROYTO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O|_O!eZO~OgaO~OgbO~OgcO~OgdO~OgeO~O!XfOPmP![mP~O!YiOQpP![pP~O!ZlORsP![sP~OUSOVPOWQOXROYTOZqO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O!eZO~O![rO~P#gO!]sO!fuO~OgvO~OgwO~OS|OT}OiyO~OS!POT}OiyO~OS!ROT}OiyO~OS!TOT}OiyO~OS}OT}OiyO~O!XfOPmX![mX~OP!WO![!XO~O!YiOQpX![pX~OQ!ZO![!XO~O!ZlORsX![sX~OR!]O![!XO~O![!XO~P#gOg!_O~O!]sO!f!aO~OS!bO~OS!cO~Oj!dOShXThXihX~OS!fOT!gOiyO~OS!hOT!gOiyO~OS!iOT!gOiyO~OS!jOT!gOiyO~OS!gOT!gOiyO~Og!kO~Og!lO~Og!mO~OS!nO~Ol!qO!a!oO!c!pO~OS!rO~OS!sO~OS!tO~Ob!uOc!uOd!uO!a!wO!b!uO~Ob!xOc!xOd!xO!c!wO!d!xO~Ob!uOc!uOd!uO!a!{O!b!uO~Ob!xOc!xOd!xO!c!{O!d!xO~OT~cbd!ey|!e~",goto:"%q!aPPPPPPPPPPPPPPPPPPPPP!b!hP!nPP!zP!}#Q#T#Z#^#a#g#j#m#s#y!bP!b!bP$P$V$m$s$y%P%V%]%cPPPPPPPP%iX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:68,context:mle,nodeProps:[["closedBy",-10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,22,31,34,37,"CloseTag"],["openedBy",4,"StartTag StartCloseTag",5,"StartTag",-4,30,33,36,38,"OpenTag"],["group",-10,14,15,18,19,20,21,40,41,42,43,"Entity",17,"Entity TextContent",-3,29,32,35,"TextContent Entity"],["isolate",-11,22,30,31,33,34,36,37,38,39,42,43,"ltr",-3,27,28,40,""]],propSources:[kle],skippedNodes:[0],repeatNodeCount:9,tokenData:"!]tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^/^!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!Z5zblWOX5uXZ7SZ[5u[^7S^p5uqr5urs7Sst+Ptw5uwx7Sx!]5u!]!^7w!^!a7S!a#S5u#S#T7S#T;'S5u;'S;=`8n<%lO5u!R7VVOp7Sqs7St!]7S!]!^7l!^;'S7S;'S;=`7q<%lO7S!R7qOb!R!R7tP;=`<%l7S!Z8OYlWb!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z8qP;=`<%l5u!_8{iiSlWOX5uXZ7SZ[5u[^7S^p5uqr8trs7Sst/^tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^:j!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!_:sbiSlWb!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VP<%l?Ah;{?Ah?BY7S?BY?Mn;{?MnO7S!V=dXiSb!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!V>SP;=`<%l;{!_>YP;=`<%l8t!_>dhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^/^!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!Z@TalWOX@OXZAYZ[@O[^AY^p@Oqr@OrsAYsw@OwxAYx!]@O!]!^Az!^!aAY!a#S@O#S#TAY#T;'S@O;'S;=`Bq<%lO@O!RA]UOpAYq!]AY!]!^Ao!^;'SAY;'S;=`At<%lOAY!RAtOc!R!RAwP;=`<%lAY!ZBRYlWc!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!ZBtP;=`<%l@O!_COhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^Dj!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!_DsbiSlWc!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VFQbiSOpAYqrE{rsAYswE{wxAYx!PE{!P!QAY!Q!]E{!]!^GY!^!aAY!a#sE{#s$fAY$f;'SE{;'S;=`G|<%l?AhE{?Ah?BYAY?BY?MnE{?MnOAY!VGaXiSc!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!VHPP;=`<%lE{!_HVP;=`<%lBw!ZHcW!cxaP!b`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t!aIYliSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OKQ!O!P-_!P!Q$q!Q!^-_!^!_*V!_!a&X!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!aK_kiSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_*V!_!`&X!`!aMS!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!TM_XaP!b`!dp!fQOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!aNZ!ZiSgQaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OMz!O!PMz!P!Q$q!Q![Mz![!]Mz!]!^-_!^!_*V!_!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f$}-_$}%OMz%O%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4UMz4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Je-_$Je$JgMz$Jg$Kh-_$Kh%#tMz%#t&/x-_&/x&EtMz&Et&FV-_&FV;'SMz;'S;:j!#|;:j;=`3X<%l?&r-_?&r?AhMz?Ah?BY$q?BY?MnMz?MnO$q!a!$PP;=`<%lMz!R!$ZY!b`!dpOq*Vqr!$yrs(Vsv*Vwx)ex!a*V!a!b!4t!b;'S*V;'S;=`*s<%lO*V!R!%Q]!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!%y!O!f*V!f!g!']!g#W*V#W#X!0`#X;'S*V;'S;=`*s<%lO*V!R!&QX!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!&m!O;'S*V;'S;=`*s<%lO*V!R!&vV!b`!dp!ePOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!'dX!b`!dpOr*Vrs(Vsv*Vwx)ex!q*V!q!r!(P!r;'S*V;'S;=`*s<%lO*V!R!(WX!b`!dpOr*Vrs(Vsv*Vwx)ex!e*V!e!f!(s!f;'S*V;'S;=`*s<%lO*V!R!(zX!b`!dpOr*Vrs(Vsv*Vwx)ex!v*V!v!w!)g!w;'S*V;'S;=`*s<%lO*V!R!)nX!b`!dpOr*Vrs(Vsv*Vwx)ex!{*V!{!|!*Z!|;'S*V;'S;=`*s<%lO*V!R!*bX!b`!dpOr*Vrs(Vsv*Vwx)ex!r*V!r!s!*}!s;'S*V;'S;=`*s<%lO*V!R!+UX!b`!dpOr*Vrs(Vsv*Vwx)ex!g*V!g!h!+q!h;'S*V;'S;=`*s<%lO*V!R!+xY!b`!dpOr!+qrs!,hsv!+qvw!-Swx!.[x!`!+q!`!a!/j!a;'S!+q;'S;=`!0Y<%lO!+qq!,mV!dpOv!,hvx!-Sx!`!,h!`!a!-q!a;'S!,h;'S;=`!.U<%lO!,hP!-VTO!`!-S!`!a!-f!a;'S!-S;'S;=`!-k<%lO!-SP!-kO|PP!-nP;=`<%l!-Sq!-xS!dp|POv(Vx;'S(V;'S;=`(h<%lO(Vq!.XP;=`<%l!,ha!.aX!b`Or!.[rs!-Ssv!.[vw!-Sw!`!.[!`!a!.|!a;'S!.[;'S;=`!/d<%lO!.[a!/TT!b`|POr)esv)ew;'S)e;'S;=`)y<%lO)ea!/gP;=`<%l!.[!R!/sV!b`!dp|POr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!0]P;=`<%l!+q!R!0gX!b`!dpOr*Vrs(Vsv*Vwx)ex#c*V#c#d!1S#d;'S*V;'S;=`*s<%lO*V!R!1ZX!b`!dpOr*Vrs(Vsv*Vwx)ex#V*V#V#W!1v#W;'S*V;'S;=`*s<%lO*V!R!1}X!b`!dpOr*Vrs(Vsv*Vwx)ex#h*V#h#i!2j#i;'S*V;'S;=`*s<%lO*V!R!2qX!b`!dpOr*Vrs(Vsv*Vwx)ex#m*V#m#n!3^#n;'S*V;'S;=`*s<%lO*V!R!3eX!b`!dpOr*Vrs(Vsv*Vwx)ex#d*V#d#e!4Q#e;'S*V;'S;=`*s<%lO*V!R!4XX!b`!dpOr*Vrs(Vsv*Vwx)ex#X*V#X#Y!+q#Y;'S*V;'S;=`*s<%lO*V!R!4{Y!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!a!4t!a!b!:]!b;'S!4t;'S;=`!;r<%lO!4tq!5pV!dpOv!5kvx!6Vx!a!5k!a!b!7W!b;'S!5k;'S;=`!8V<%lO!5kP!6YTO!a!6V!a!b!6i!b;'S!6V;'S;=`!7Q<%lO!6VP!6lTO!`!6V!`!a!6{!a;'S!6V;'S;=`!7Q<%lO!6VP!7QOyPP!7TP;=`<%l!6Vq!7]V!dpOv!5kvx!6Vx!`!5k!`!a!7r!a;'S!5k;'S;=`!8V<%lO!5kq!7yS!dpyPOv(Vx;'S(V;'S;=`(h<%lO(Vq!8YP;=`<%l!5ka!8bX!b`Or!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!b`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!b`yPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!b`!dpyPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!{let f=l.type.id;if(f==nle)return Bb(l,u,n);if(f==ile)return Bb(l,u,i);if(f==rle)return Bb(l,u,r);if(f==mL&&s.length){let h=l.node,p=h.firstChild,O=p&&DQ(p,u),y;if(O){for(let v of s)if(v.tag==O&&(!v.attrs||v.attrs(y||(y=bL(p,u))))){let S=h.lastChild,k=S.type.id==ole?S.from:h.to;if(k>p.to)return{parser:v.parser,overlay:[{from:p.to,to:k}]}}}}if(o&&f==OL){let h=l.node,p;if(p=h.firstChild){let O=o[u.read(p.from,p.to)];if(O)for(let y of O){if(y.tagName&&y.tagName!=DQ(h.parent,u))continue;let v=h.lastChild;if(v.type.id==Gx){let S=v.from+1,k=v.lastChild,C=v.to-(k&&k.isError?0:1);if(C>S)return{parser:y.parser,overlay:[{from:S,to:C}],bracketed:!0}}else if(v.type.id==yL)return{parser:y.parser,overlay:[{from:v.from,to:v.to}]}}}}return null})}const _le=148,NQ=1,$le=149,Tle=150,xL=2,Ele=151,Rle=3,Qle=4,wL=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],Ale=58,Ple=40,kL=95,jle=91,im=45,Mle=46,Dle=35,Nle=37,zle=38,Lle=92,Zle=10,Ile=42;function Wf(t){return t>=65&&t<=90||t>=97&&t<=122||t>=161}function yk(t){return t>=48&&t<=57}function zQ(t){return yk(t)||t>=97&&t<=102||t>=65&&t<=70}const CL=(t,e,n)=>(i,r)=>{for(let s=!1,o=0,l=0;;l++){let{next:u}=i;if(Wf(u)||u==im||u==kL||s&&yk(u))!s&&(u!=im||l>0)&&(s=!0),o===l&&u==im&&o++,i.advance();else if(u==Lle&&i.peek(1)!=Zle){if(i.advance(),zQ(i.next)){do i.advance();while(zQ(i.next));i.next==32&&i.advance()}else i.next>-1&&i.advance();s=!0}else{s&&i.acceptToken(o==2&&r.canShift(xL)?e:u==Ple?n:t);break}}},Xle=new hr(CL($le,xL,Tle),{contextual:!0}),Vle=new hr(CL(Ele,Rle,Qle),{contextual:!0}),Ble=new hr(t=>{if(wL.includes(t.peek(-1))){let{next:e}=t;(Wf(e)||e==kL||e==Dle||e==Mle||e==Ile||e==jle||e==Ale&&Wf(t.peek(1))||e==im||e==zle)&&t.acceptToken(_le)}}),Ule=new hr(t=>{if(!wL.includes(t.peek(-1))){let{next:e}=t;if(e==Nle&&(t.advance(),t.acceptToken(NQ)),Wf(e)){do t.advance();while(Wf(t.next)||yk(t.next));t.acceptToken(NQ)}}}),qle=Fu({"AtKeyword import charset namespace keyframes media supports font-feature-values":Z.definitionKeyword,"from to selector scope MatchFlag":Z.keyword,NamespaceName:Z.namespace,KeyframeName:Z.labelName,KeyframeRangeName:Z.operatorKeyword,TagName:Z.tagName,ClassName:Z.className,PseudoClassName:Z.constant(Z.className),IdName:Z.labelName,"FeatureName PropertyName":Z.propertyName,AttributeName:Z.attributeName,NumberLiteral:Z.number,KeywordQuery:Z.keyword,UnaryQueryOp:Z.operatorKeyword,"CallTag ValueName FontName":Z.atom,VariableName:Z.variableName,Callee:Z.operatorKeyword,Unit:Z.unit,"UniversalSelector NestingSelector":Z.definitionOperator,"MatchOp CompareOp":Z.compareOperator,"ChildOp SiblingOp, LogicOp":Z.logicOperator,BinOp:Z.arithmeticOperator,Important:Z.modifier,Comment:Z.blockComment,ColorLiteral:Z.color,"ParenthesizedContent StringLiteral":Z.string,":":Z.punctuation,"PseudoOp #":Z.derefOperator,"; , |":Z.separator,"( )":Z.paren,"[ ]":Z.squareBracket,"{ }":Z.brace}),Yle={__proto__:null,lang:44,"nth-child":44,"nth-last-child":44,"nth-of-type":44,"nth-last-of-type":44,dir:44,"host-context":44,if:90,url:158,"url-prefix":158,domain:158,regexp:158},Fle={__proto__:null,or:104,and:104,not:112,only:112,layer:212},Gle={__proto__:null,selector:118,style:124,layer:208},Hle={__proto__:null,"@import":204,"@media":216,"@charset":220,"@namespace":224,"@keyframes":230,"@supports":242,"@scope":246,"@font-feature-values":252},Wle={__proto__:null,to:249},Kle=Au.deserialize({version:14,states:"MrQYQdOOO#}QdOOP$UO`OOO%OQaO'#CfOOQP'#Ce'#CeO%VQdO'#CgO%[Q`O'#CgO%aQaO'#FqO&XQdO'#CkO&xQaO'#CcO'SQdO'#CnO'_QdO'#ERO'dQdO'#ETO'oQdO'#E[O'oQdO'#E_OOQP'#Fq'#FqO)RQhO'#FQOOQS'#Fp'#FpOOQS'#FT'#FTQYQdOOO)YQdO'#EeO*iQhO'#EkO)YQdO'#EmO*pQdO'#EoO*{QdO'#ErO)}QhO'#ExO+TQdO'#EzO+`QdO'#E}O+eQaO'#CfO+lQ`O'#EbO+qQ`O'#F}O+|QdO'#F}QOQ`OOP,WO&jO'#CaPOOO)CA`)CA`OOQP'#Ci'#CiOOQP,59R,59RO%VQdO,59ROOQP'#Cm'#CmOOQP,59V,59VO&XQdO,59VO,cQdO,59YO'_QdO,5:mO'dQdO,5:oO'oQdO,5:vO'oQdO,5:xO'oQdO,5:yO'oQdO'#F[O,nQ`O,58}O,vQdO'#EaOOQS,58},58}OOQP'#Cq'#CqOOQO'#EP'#EPOOQP,59Y,59YO,}Q`O,59YO-SQ`O,59YOOQP'#ES'#ESOOQP,5:m,5:mO-XQpO'#EUO-dQdO'#EVO-iQ`O'#EVO-nQpO,5:oO.XQaO,5:vO.oQaO,5:yOOQW'#D^'#D^O/nQhO'#DgO0RQhO,5;lO)}QhO'#DeO0`Q`O'#DnO0eQhO'#D{OOQW'#Fw'#FwOOQS,5;l,5;lO0jQ`O'#DhO0oQ`O'#DkOOQS-E9R-E9ROOQ['#Cv'#CvO0tQdO'#CwO1[QdO'#C}O1rQdO'#DQO2YQ!pO'#DSO4fQ!jO,5;POOQO'#DX'#DXO-SQ`O'#DWO4vQ!nO'#FtO6|Q`O'#DYO7RQ`O'#D|OOQ['#Ft'#FtO7WQhO'#GQO7fQ`O,5;VO7kQ!bO,5;XOOQS'#Eq'#EqO7sQ`O,5;ZO7xQdO,5;ZOOQO'#Et'#EtO8QQ`O,5;^O8VQhO,5;dO'oQdO'#DjOOQS,5;f,5;fO0jQ`O,5;fO8_QdO,5;fOOQS'#Fc'#FcO8gQdO'#FPO7fQ`O,5;iO8oQdO,5:|O9PQdO'#F^O9^Q`O,5lQhO'#DoOOQW,5:Y,5:YOOQW,5:g,5:gOOQW,5:S,5:SO>vQhO,5:VO?bQ!fO'#FuOOQS'#Fu'#FuOOQS'#FV'#FVO@rQdO,59cOOQ[,59c,59cOAYQdO,59iOOQ[,59i,59iOApQdO,59lOOQ[,59l,59lOOQ[,59n,59nO)YQdO,59pOBWQhO'#EgOOQW'#Eg'#EgOBuQ`O1G0kO4oQhO1G0kOOQ[,59r,59rO)}QhO'#D[OOQ[,59t,59tOBzQ#tO,5:hOCVQhO'#F`OCdQ`O,5vQhO'#DmOI_QhO'#DsOIgQhO'#DuOIlQ!jO'#FzOOQO'#Fz'#FzOIwQ`O'#DxOJPQ!bO'#DzOOQO'#Fy'#FyOJUQ`O1G/qOOQS-E9T-E9TOOQ[1G.}1G.}OOQ[1G/T1G/TOOQ[1G/W1G/WOOQ[1G/[1G/[OJZQdO,5;ROOQS7+&V7+&VOJ`Q`O7+&VOJeQhO'#D]OJmQ`O,59vO)}QhO,59vOOQ[1G0S1G0SOJuQ`O1G0SOJzQhO,5;zOOQO-E9^-E9^OOQS7+&a7+&aOKYQbO'#DSOOQO'#Ew'#EwOKhQ`O'#EvOOQO'#Ev'#EvOKsQ`O'#FaOK{QdO,5;aOOQS,5;a,5;aOOQ[1G/p1G/pOOQS7+&l7+&lO7fQ`O7+&lOLWQ!fO'#F]O)YQdO'#F]OM_QdO7+&SOOQO7+&S7+&SOOQO,5;O,5;OOOQO1G1d1G1dOMrQ!bO<vQhO'#DtOOQO,5:_,5:_O! sQhO,5:aO! {QhO,5:fO)YQdO,5:dOOQW7+%]7+%]OOQO'#Ei'#EiO!!SQ`O1G0mOOQS<{AN>{O!$^Q`OAN>{O!$cQaO,5;uOOQO-E9X-E9XO!$mQdO,5;tOOQO-E9W-E9WOOQW<vQhO'#DwOOQO1G/{1G/{O!&aQ!bO1G0QO!&iQdO1G0OOJZQdO'#F_O!&pQ`O7+&XOOQW7+&X7+&XO!&xQ!bO1G/cOOQ[7+$|7+$|O!'TQhO7+$|P!'[Q`O'#FWOOQO,5;|,5;|OOQO-E9`-E9`OOQS1G1g1G1gOOQPG24gG24gO!'aQ`OAN>ZO)YQdO1G1_O!'fQ`O7+'mOOQO1G/z1G/zO!'nQ`O,5:cO!'sQhO7+%lOOQO,5;y,5;yOOQO-E9]-E9]OOQW<Q!]!^>|!^!_?_!_!`@Z!`!a@n!a!b%Z!b!cAo!c!k%Z!k!lC|!l!u%Z!u!vC|!v!}%Z!}#OD_#O#P%Z#P#QDp#Q#R2X#R#]%Z#]#^ER#^#g%Z#g#hC|#h#o%Z#o#pIf#p#qIw#q#rJ`#r#sJq#s#y%Z#y#z&R#z$f%Z$f$g&R$g#BY%Z#BY#BZ&R#BZ$IS%Z$IS$I_&R$I_$I|%Z$I|$JO&R$JO$JT%Z$JT$JU&R$JU$KV%Z$KV$KW&R$KW&FU%Z&FU&FV&R&FV;'S%Z;'S;=`KY<%lO%Z`%^SOy%jz;'S%j;'S;=`%{<%lO%j`%oS!r`Oy%jz;'S%j;'S;=`%{<%lO%j`&OP;=`<%l%j~&Wh$_~OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%j~'yh$_~!r`OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%jj)jS$sYOy%jz;'S%j;'S;=`%{<%lO%j~)yWOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d<%lO)v~*hOw~~*kRO;'S)v;'S;=`*t;=`O)v~*wXOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d;=`<%l)v<%lO)v~+gP;=`<%l)vj+oYmYOy%jz!Q%j!Q![,_![!c%j!c!i,_!i#T%j#T#Z,_#Z;'S%j;'S;=`%{<%lO%jj,dY!r`Oy%jz!Q%j!Q![-S![!c%j!c!i-S!i#T%j#T#Z-S#Z;'S%j;'S;=`%{<%lO%jj-XY!r`Oy%jz!Q%j!Q![-w![!c%j!c!i-w!i#T%j#T#Z-w#Z;'S%j;'S;=`%{<%lO%jj.OYuY!r`Oy%jz!Q%j!Q![.n![!c%j!c!i.n!i#T%j#T#Z.n#Z;'S%j;'S;=`%{<%lO%jj.uYuY!r`Oy%jz!Q%j!Q![/e![!c%j!c!i/e!i#T%j#T#Z/e#Z;'S%j;'S;=`%{<%lO%jj/jY!r`Oy%jz!Q%j!Q![0Y![!c%j!c!i0Y!i#T%j#T#Z0Y#Z;'S%j;'S;=`%{<%lO%jj0aYuY!r`Oy%jz!Q%j!Q![1P![!c%j!c!i1P!i#T%j#T#Z1P#Z;'S%j;'S;=`%{<%lO%jj1UY!r`Oy%jz!Q%j!Q![1t![!c%j!c!i1t!i#T%j#T#Z1t#Z;'S%j;'S;=`%{<%lO%jj1{SuY!r`Oy%jz;'S%j;'S;=`%{<%lO%jd2[UOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jd2uS!|S!r`Oy%jz;'S%j;'S;=`%{<%lO%jb3WS^QOy%jz;'S%j;'S;=`%{<%lO%j~3gWOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{<%lO3d~4SRO;'S3d;'S;=`4];=`O3d~4`XOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{;=`<%l3d<%lO3d~5OP;=`<%l3dj5WShYOy%jz;'S%j;'S;=`%{<%lO%j~5iOg~n5pUWQyWOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jj6ZWyW#SQOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj6xU!r`Oy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%jj7cY!r`$jYOy%jz!Q%j!Q![7[![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj8WY!r`Oy%jz{%j{|8v|}%j}!O8v!O!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj8{U!r`Oy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj9fU!r`$jYOy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj:P[!r`$jYOy%jz!O%j!O!P7[!P!Q%j!Q![9x![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj:zS!eYOy%jz;'S%j;'S;=`%{<%lO%jj;]WyWOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj;zU`YOy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%j~VUcYOy%jz![%j![!]>i!];'S%j;'S;=`%{<%lO%jj>pSdY!r`Oy%jz;'S%j;'S;=`%{<%lO%jj?RSnYOy%jz;'S%j;'S;=`%{<%lO%jh?dU!WWOy%jz!_%j!_!`?v!`;'S%j;'S;=`%{<%lO%jh?}S!WW!r`Oy%jz;'S%j;'S;=`%{<%lO%jl@bS!WW!|SOy%jz;'S%j;'S;=`%{<%lO%jj@uV#PQ!WWOy%jz!_%j!_!`?v!`!aA[!a;'S%j;'S;=`%{<%lO%jbAcS#PQ!r`Oy%jz;'S%j;'S;=`%{<%lO%jjArYOy%jz}%j}!OBb!O!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjBgW!r`Oy%jz!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjCW[lY!r`Oy%jz}%j}!OCP!O!Q%j!Q![CP![!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jhDRS!}WOy%jz;'S%j;'S;=`%{<%lO%jjDdSpYOy%jz;'S%j;'S;=`%{<%lO%jnDuSo^Oy%jz;'S%j;'S;=`%{<%lO%jjEWU!}WOy%jz#a%j#a#bEj#b;'S%j;'S;=`%{<%lO%jbEoU!r`Oy%jz#d%j#d#eFR#e;'S%j;'S;=`%{<%lO%jbFWU!r`Oy%jz#c%j#c#dFj#d;'S%j;'S;=`%{<%lO%jbFoU!r`Oy%jz#f%j#f#gGR#g;'S%j;'S;=`%{<%lO%jbGWU!r`Oy%jz#h%j#h#iGj#i;'S%j;'S;=`%{<%lO%jbGoU!r`Oy%jz#T%j#T#UHR#U;'S%j;'S;=`%{<%lO%jbHWU!r`Oy%jz#b%j#b#cHj#c;'S%j;'S;=`%{<%lO%jbHoU!r`Oy%jz#h%j#h#iIR#i;'S%j;'S;=`%{<%lO%jbIYS$rQ!r`Oy%jz;'S%j;'S;=`%{<%lO%jjIkSsYOy%jz;'S%j;'S;=`%{<%lO%jfI|U$fUOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jjJeSrYOy%jz;'S%j;'S;=`%{<%lO%jfJvU#SQOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%j`K]P;=`<%l%Z",tokenizers:[Ble,Ule,Xle,Vle,1,2,3,4,new Wm("m~RRYZ[z{a~~g~aO$b~~dP!P!Qg~lO$c~~",28,155)],topRules:{StyleSheet:[0,6],Styles:[1,129]},dynamicPrecedences:{97:1},specialized:[{term:150,get:t=>Yle[t]||-1},{term:151,get:t=>Fle[t]||-1},{term:4,get:t=>Gle[t]||-1},{term:28,get:t=>Hle[t]||-1},{term:149,get:t=>Wle[t]||-1}],tokenPrec:2444});let Ub=null;function qb(){if(!Ub&&typeof document=="object"&&document.body){let{style:t}=document.body,e=[],n=new Set;for(let i in t)i!="cssText"&&i!="cssFloat"&&typeof t[i]=="string"&&(/[A-Z]/.test(i)&&(i=i.replace(/[A-Z]/g,r=>"-"+r.toLowerCase())),n.has(i)||(e.push(i),n.add(i)));Ub=e.sort().map(i=>({type:"property",label:i,apply:i+": "}))}return Ub||[]}const LQ=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(t=>({type:"class",label:t})),ZQ=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(t=>({type:"keyword",label:t})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(t=>({type:"constant",label:t}))),Jle=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(t=>({type:"type",label:t})),ece=["@charset","@color-profile","@container","@counter-style","@font-face","@font-feature-values","@font-palette-values","@import","@keyframes","@layer","@media","@namespace","@page","@position-try","@property","@scope","@starting-style","@supports","@view-transition"].map(t=>({type:"keyword",label:t})),po=/^(\w[\w-]*|-\w[\w-]*|)$/,tce=/^-(-[\w-]*)?$/;function nce(t,e){var n;if((t.name=="("||t.type.isError)&&(t=t.parent||t),t.name!="ArgList")return!1;let i=(n=t.parent)===null||n===void 0?void 0:n.firstChild;return i?.name!="Callee"?!1:e.sliceString(i.from,i.to)=="var"}const IQ=new Hz,ice=["Declaration"];function rce(t){for(let e=t;;){if(e.type.isTop)return e;if(!(e=e.parent))return t}}function _L(t,e,n){if(e.to-e.from>4096){let i=IQ.get(e);if(i)return i;let r=[],s=new Set,o=e.cursor($t.IncludeAnonymous);if(o.firstChild())do for(let l of _L(t,o.node,n))s.has(l.label)||(s.add(l.label),r.push(l));while(o.nextSibling());return IQ.set(e,r),r}else{let i=[],r=new Set;return e.cursor().iterate(s=>{var o;if(n(s)&&s.matchContext(ice)&&((o=s.node.nextSibling)===null||o===void 0?void 0:o.name)==":"){let l=t.sliceString(s.from,s.to);r.has(l)||(r.add(l),i.push({label:l,type:"variable"}))}}),i}}const sce=t=>e=>{let{state:n,pos:i}=e,r=hn(n).resolveInner(i,-1),s=r.type.isError&&r.from==r.to-1&&n.doc.sliceString(r.from,r.to)=="-";if(r.name=="PropertyName"||(s||r.name=="TagName")&&/^(Block|Styles)$/.test(r.resolve(r.to).name))return{from:r.from,options:qb(),validFor:po};if(r.name=="ValueName")return{from:r.from,options:ZQ,validFor:po};if(r.name=="PseudoClassName")return{from:r.from,options:LQ,validFor:po};if(t(r)||(e.explicit||s)&&nce(r,n.doc))return{from:t(r)||s?r.from:i,options:_L(n.doc,rce(r),t),validFor:tce};if(r.name=="TagName"){for(let{parent:u}=r;u;u=u.parent)if(u.name=="Block")return{from:r.from,options:qb(),validFor:po};return{from:r.from,options:Jle,validFor:po}}if(r.name=="AtKeyword")return{from:r.from,options:ece,validFor:po};if(!e.explicit)return null;let o=r.resolve(i),l=o.childBefore(i);return l&&l.name==":"&&o.name=="PseudoClassSelector"?{from:i,options:LQ,validFor:po}:l&&l.name==":"&&o.name=="Declaration"||o.name=="ArgList"?{from:i,options:ZQ,validFor:po}:o.name=="Block"||o.name=="Styles"?{from:i,options:qb(),validFor:po}:null},oce=sce(t=>t.name=="VariableName"),Jm=Tu.define({name:"css",parser:Kle.configure({props:[Eh.add({Declaration:tm()}),Rh.add({"Block KeyframeList":r5})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function ace(){return new Yf(Jm,Jm.data.of({autocomplete:oce}))}const lce=316,cce=317,XQ=1,uce=2,dce=3,fce=4,hce=318,pce=320,gce=321,mce=5,Oce=6,yce=0,Wx=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],$L=125,vce=59,Kx=47,bce=42,Sce=43,xce=45,wce=60,kce=44,Cce=63,_ce=46,$ce=91,Tce=new dL({start:!1,shift(t,e){return e==mce||e==Oce||e==pce?t:e==gce},strict:!1}),Ece=new hr((t,e)=>{let{next:n}=t;(n==$L||n==-1||e.context)&&t.acceptToken(hce)},{contextual:!0,fallback:!0}),Rce=new hr((t,e)=>{let{next:n}=t,i;Wx.indexOf(n)>-1||n==Kx&&((i=t.peek(1))==Kx||i==bce)||n!=$L&&n!=vce&&n!=-1&&!e.context&&t.acceptToken(lce)},{contextual:!0}),Qce=new hr((t,e)=>{t.next==$ce&&!e.context&&t.acceptToken(cce)},{contextual:!0}),Ace=new hr((t,e)=>{let{next:n}=t;if(n==Sce||n==xce){if(t.advance(),n==t.next){t.advance();let i=!e.context&&e.canShift(XQ);t.acceptToken(i?XQ:uce)}}else n==Cce&&t.peek(1)==_ce&&(t.advance(),t.advance(),(t.next<48||t.next>57)&&t.acceptToken(dce))},{contextual:!0});function Yb(t,e){return t>=65&&t<=90||t>=97&&t<=122||t==95||t>=192||!e&&t>=48&&t<=57}const Pce=new hr((t,e)=>{if(t.next!=wce||!e.dialectEnabled(yce)||(t.advance(),t.next==Kx))return;let n=0;for(;Wx.indexOf(t.next)>-1;)t.advance(),n++;if(Yb(t.next,!0)){for(t.advance(),n++;Yb(t.next,!1);)t.advance(),n++;for(;Wx.indexOf(t.next)>-1;)t.advance(),n++;if(t.next==kce)return;for(let i=0;;i++){if(i==7){if(!Yb(t.next,!0))return;break}if(t.next!="extends".charCodeAt(i))break;t.advance(),n++}}t.acceptToken(fce,-n)}),jce=Fu({"get set async static":Z.modifier,"for while do if else switch try catch finally return throw break continue default case defer":Z.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":Z.operatorKeyword,"let var const using function class extends":Z.definitionKeyword,"import export from":Z.moduleKeyword,"with debugger new":Z.keyword,TemplateString:Z.special(Z.string),super:Z.atom,BooleanLiteral:Z.bool,this:Z.self,null:Z.null,Star:Z.modifier,VariableName:Z.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":Z.function(Z.variableName),VariableDefinition:Z.definition(Z.variableName),Label:Z.labelName,PropertyName:Z.propertyName,PrivatePropertyName:Z.special(Z.propertyName),"CallExpression/MemberExpression/PropertyName":Z.function(Z.propertyName),"FunctionDeclaration/VariableDefinition":Z.function(Z.definition(Z.variableName)),"ClassDeclaration/VariableDefinition":Z.definition(Z.className),"NewExpression/VariableName":Z.className,PropertyDefinition:Z.definition(Z.propertyName),PrivatePropertyDefinition:Z.definition(Z.special(Z.propertyName)),UpdateOp:Z.updateOperator,"LineComment Hashbang":Z.lineComment,BlockComment:Z.blockComment,Number:Z.number,String:Z.string,Escape:Z.escape,ArithOp:Z.arithmeticOperator,LogicOp:Z.logicOperator,BitOp:Z.bitwiseOperator,CompareOp:Z.compareOperator,RegExp:Z.regexp,Equals:Z.definitionOperator,Arrow:Z.function(Z.punctuation),": Spread":Z.punctuation,"( )":Z.paren,"[ ]":Z.squareBracket,"{ }":Z.brace,"InterpolationStart InterpolationEnd":Z.special(Z.brace),".":Z.derefOperator,", ;":Z.separator,"@":Z.meta,TypeName:Z.typeName,TypeDefinition:Z.definition(Z.typeName),"type enum interface implements namespace module declare":Z.definitionKeyword,"abstract global Privacy readonly override":Z.modifier,"is keyof unique infer asserts":Z.operatorKeyword,JSXAttributeValue:Z.attributeValue,JSXText:Z.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":Z.angleBracket,"JSXIdentifier JSXNameSpacedName":Z.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":Z.attributeName,"JSXBuiltin/JSXIdentifier":Z.standard(Z.tagName)}),Mce={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},Dce={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},Nce={__proto__:null,"<":193},zce=Au.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-EtOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-EPO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-ERQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<VO!l$xO#jROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!OVO!l$xO#jVO!l$xO#jROe!iOpkOrPO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]VO!l$xO#j^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOrROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]WO!l$xO#jgPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{SU+P%]S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mR>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o>UPS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^T)z$u){V+P%]S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SS#q]SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uSSR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:mSR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:oS)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mSS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:mS#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^Q+T%aQ/c*Oo4OP>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^n=rTQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o4OP>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f]>^nZ>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f]>^nZ>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:Tce,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[jce],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[Rce,Qce,Ace,Pce,2,3,4,5,6,7,8,9,10,11,12,13,14,Ece,new Wm("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new Wm("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:t=>Mce[t]||-1},{term:343,get:t=>Dce[t]||-1},{term:95,get:t=>Nce[t]||-1}],tokenPrec:15201}),TL=[zi("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),zi("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),zi("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),zi("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),zi("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),zi(`try { - \${} -} catch (\${error}) { - \${} -}`,{label:"try",detail:"/ catch block",type:"keyword"}),zi("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),zi(`if (\${}) { - \${} -} else { - \${} -}`,{label:"if",detail:"/ else block",type:"keyword"}),zi(`class \${name} { - constructor(\${params}) { - \${} - } -}`,{label:"class",detail:"definition",type:"keyword"}),zi('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),zi('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],Lce=TL.concat([zi("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),zi("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),zi("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),VQ=new Hz,EL=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function of(t){return(e,n)=>{let i=e.node.getChild("VariableDefinition");return i&&n(i,t),!0}}const Zce=["FunctionDeclaration"],Ice={FunctionDeclaration:of("function"),ClassDeclaration:of("class"),ClassExpression:()=>!0,EnumDeclaration:of("constant"),TypeAliasDeclaration:of("type"),NamespaceDeclaration:of("namespace"),VariableDefinition(t,e){t.matchContext(Zce)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function RL(t,e){let n=VQ.get(e);if(n)return n;let i=[],r=!0;function s(o,l){let u=t.sliceString(o.from,o.to);i.push({label:u,type:l})}return e.cursor($t.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=Ice[o.name];if(l&&l(o,s)||EL.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of RL(t,o.node))i.push(l);return!1}}),VQ.set(e,i),i}const BQ=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,QL=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function Xce(t){let e=hn(t.state).resolveInner(t.pos,-1);if(QL.indexOf(e.name)>-1)return null;let n=e.name=="VariableName"||e.to-e.from<20&&BQ.test(t.state.sliceDoc(e.from,e.to));if(!n&&!t.explicit)return null;let i=[];for(let r=e;r;r=r.parent)EL.has(r.name)&&(i=i.concat(RL(t.state.doc,r)));return{options:i,from:n?e.from:t.pos,validFor:BQ}}const Ms=Tu.define({name:"javascript",parser:zce.configure({props:[Eh.add({IfStatement:tm({except:/^\s*({|else\b)/}),TryStatement:tm({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:yse,SwitchBody:t=>{let e=t.textAfter,n=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return t.baseIndent+(n?0:i?1:2)*t.unit},Block:Ose({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":tm({except:/^\s*{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag"(t){return t.column(t.node.from)+t.unit}}),Rh.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":r5,BlockComment(t){return{from:t.from+2,to:t.to-2}},JSXElement(t){let e=t.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let n=t.lastChild;return{from:e.to,to:n.type.isError?t.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(t){var e;let n=(e=t.firstChild)===null||e===void 0?void 0:e.nextSibling,i=t.lastChild;return!n||n.type.isError?null:{from:n.to,to:i.type.isError?t.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),AL={test:t=>/^JSX/.test(t.name),facet:nk({commentTokens:{block:{open:"{/*",close:"*/}"}}})},PL=Ms.configure({dialect:"ts"},"typescript"),jL=Ms.configure({dialect:"jsx",props:[ik.add(t=>t.isTop?[AL]:void 0)]}),ML=Ms.configure({dialect:"jsx ts",props:[ik.add(t=>t.isTop?[AL]:void 0)]},"typescript");let DL=t=>({label:t,type:"keyword"});const NL="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(DL),Vce=NL.concat(["declare","implements","private","protected","public"].map(DL));function Bce(t={}){let e=t.jsx?t.typescript?ML:jL:t.typescript?PL:Ms,n=t.typescript?Lce.concat(Vce):TL.concat(NL);return new Yf(e,[Ms.data.of({autocomplete:Yoe(QL,qoe(n))}),Ms.data.of({autocomplete:Xce}),t.jsx?Yce:[]])}function Uce(t){for(;;){if(t.name=="JSXOpenTag"||t.name=="JSXSelfClosingTag"||t.name=="JSXFragmentTag")return t;if(t.name=="JSXEscape"||!t.parent)return null;t=t.parent}}function UQ(t,e,n=t.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return t.sliceString(i.from,Math.min(i.to,n));return""}const qce=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Yce=Le.inputHandler.of((t,e,n,i,r)=>{if((qce?t.composing:t.compositionStarted)||t.state.readOnly||e!=n||i!=">"&&i!="/"||!Ms.isActiveAt(t.state,e,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(u=>{var f;let{head:h}=u,p=hn(o).resolveInner(h-1,-1),O;if(p.name=="JSXStartTag"&&(p=p.parent),!(o.doc.sliceString(h-1,h)!=i||p.name=="JSXAttributeValue"&&p.to>h)){if(i==">"&&p.name=="JSXFragmentTag")return{range:u,changes:{from:h,insert:""}};if(i=="/"&&p.name=="JSXStartCloseTag"){let y=p.parent,v=y.parent;if(v&&y.from==h-2&&((O=UQ(o.doc,v.firstChild,h))||((f=v.firstChild)===null||f===void 0?void 0:f.name)=="JSXFragmentTag")){let S=`${O}>`;return{range:Oe.cursor(h+S.length,-1),changes:{from:h,insert:S}}}}else if(i==">"){let y=Uce(p);if(y&&y.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(O=UQ(o.doc,y,h)))return{range:u,changes:{from:h,insert:``}}}}return{range:u}});return l.changes.empty?!1:(t.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),af=["_blank","_self","_top","_parent"],Fb=["ascii","utf-8","utf-16","latin1","latin1"],Gb=["get","post","put","delete"],Hb=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],ir=["true","false"],ze={},Fce={a:{attrs:{href:null,ping:null,type:null,media:null,target:af,hreflang:null}},abbr:ze,address:ze,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:ze,aside:ze,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:ze,base:{attrs:{href:null,target:af}},bdi:ze,bdo:ze,blockquote:{attrs:{cite:null}},body:ze,br:ze,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:Hb,formmethod:Gb,formnovalidate:["novalidate"],formtarget:af,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:ze,center:ze,cite:ze,code:ze,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:ze,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:ze,div:ze,dl:ze,dt:ze,em:ze,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:ze,figure:ze,footer:ze,form:{attrs:{action:null,name:null,"accept-charset":Fb,autocomplete:["on","off"],enctype:Hb,method:Gb,novalidate:["novalidate"],target:af}},h1:ze,h2:ze,h3:ze,h4:ze,h5:ze,h6:ze,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:ze,hgroup:ze,hr:ze,html:{attrs:{manifest:null}},i:ze,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:Hb,formmethod:Gb,formnovalidate:["novalidate"],formtarget:af,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:ze,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:ze,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:ze,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Fb,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:ze,noscript:ze,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:ze,param:{attrs:{name:null,value:null}},pre:ze,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:ze,rt:ze,ruby:ze,samp:ze,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Fb}},section:ze,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:ze,source:{attrs:{src:null,type:null,media:null}},span:ze,strong:ze,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:ze,summary:ze,sup:ze,table:ze,tbody:ze,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:ze,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:ze,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:ze,time:{attrs:{datetime:null}},title:ze,tr:ze,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:ze,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:ze},zL={accesskey:null,class:null,contenteditable:ir,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:ir,autocorrect:ir,autocapitalize:ir,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":ir,"aria-autocomplete":["inline","list","both","none"],"aria-busy":ir,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":ir,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":ir,"aria-hidden":ir,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":ir,"aria-multiselectable":ir,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":ir,"aria-relevant":null,"aria-required":ir,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},LL="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(t=>"on"+t);for(let t of LL)zL[t]=null;let Kf=class{constructor(e,n){this.tags={...Fce,...e},this.globalAttrs={...zL,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};Kf.default=new Kf;function Il(t,e,n=t.length){if(!e)return"";let i=e.firstChild,r=i&&i.getChild("TagName");return r?t.sliceString(r.from,Math.min(r.to,n)):""}function Pu(t,e=!1){for(;t;t=t.parent)if(t.name=="Element")if(e)e=!1;else return t;return null}function ZL(t,e,n){let i=n.tags[Il(t,Pu(e))];return i?.children||n.allTags}function vk(t,e){let n=[];for(let i=Pu(e);i&&!i.type.isTop;i=Pu(i.parent)){let r=Il(t,i);if(r&&i.lastChild.name=="CloseTag")break;r&&n.indexOf(r)<0&&(e.name=="EndTag"||e.from>=i.firstChild.to)&&n.push(r)}return n}const IL=/^[:\-\.\w\u00b7-\uffff]*$/;function qQ(t,e,n,i,r){let s=/\s*>/.test(t.sliceDoc(r,r+5))?"":">",o=Pu(n,n.name=="StartTag"||n.name=="TagName");return{from:i,to:r,options:ZL(t.doc,o,e).map(l=>({label:l,type:"type"})).concat(vk(t.doc,n).map((l,u)=>({label:"/"+l,apply:"/"+l+s,type:"type",boost:99-u}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function YQ(t,e,n,i){let r=/\s*>/.test(t.sliceDoc(i,i+5))?"":">";return{from:n,to:i,options:vk(t.doc,e).map((s,o)=>({label:s,apply:s+r,type:"type",boost:99-o})),validFor:IL}}function Gce(t,e,n,i){let r=[],s=0;for(let o of ZL(t.doc,n,e))r.push({label:"<"+o,type:"type"});for(let o of vk(t.doc,n))r.push({label:"",type:"type",boost:99-s++});return{from:i,to:i,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function Hce(t,e,n,i,r){let s=Pu(n),o=s?e.tags[Il(t.doc,s)]:null,l=o&&o.attrs?Object.keys(o.attrs):[],u=o&&o.globalAttrs===!1?l:l.length?l.concat(e.globalAttrNames):e.globalAttrNames;return{from:i,to:r,options:u.map(f=>({label:f,type:"property"})),validFor:IL}}function Wce(t,e,n,i,r){var s;let o=(s=n.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),l=[],u;if(o){let f=t.sliceDoc(o.from,o.to),h=e.globalAttrs[f];if(!h){let p=Pu(n),O=p?e.tags[Il(t.doc,p)]:null;h=O?.attrs&&O.attrs[f]}if(h){let p=t.sliceDoc(i,r).toLowerCase(),O='"',y='"';/^['"]/.test(p)?(u=p[0]=='"'?/^[^"]*$/:/^[^']*$/,O="",y=t.sliceDoc(r,r+1)==p[0]?"":p[0],p=p.slice(1),i++):u=/^[^\s<>='"]*$/;for(let v of h)l.push({label:v,apply:O+v+y,type:"constant"})}}return{from:i,to:r,options:l,validFor:u}}function XL(t,e){let{state:n,pos:i}=e,r=hn(n).resolveInner(i,-1),s=r.resolve(i);for(let o=i,l;s==r&&(l=r.childBefore(o));){let u=l.lastChild;if(!u||!u.type.isError||u.fromXL(i,r)}const eue=Ms.parser.configure({top:"SingleExpression"}),VL=[{tag:"script",attrs:t=>t.type=="text/typescript"||t.lang=="ts",parser:PL.parser},{tag:"script",attrs:t=>t.type=="text/babel"||t.type=="text/jsx",parser:jL.parser},{tag:"script",attrs:t=>t.type=="text/typescript-jsx",parser:ML.parser},{tag:"script",attrs(t){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(t.type)},parser:eue},{tag:"script",attrs(t){return!t.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(t.type)},parser:Ms.parser},{tag:"style",attrs(t){return(!t.lang||t.lang=="css")&&(!t.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(t.type))},parser:Jm.parser}],BL=[{name:"style",parser:Jm.parser.configure({top:"Styles"})}].concat(LL.map(t=>({name:t,parser:Ms.parser}))),UL=Tu.define({name:"html",parser:Cle.configure({props:[Eh.add({Element(t){let e=/^(\s*)(<\/)?/.exec(t.textAfter);return t.node.to<=t.pos+e[0].length?t.continue():t.lineIndent(t.node.from)+(e[2]?0:t.unit)},"OpenTag CloseTag SelfClosingTag"(t){return t.column(t.node.from)+t.unit},Document(t){if(t.pos+/\s*/.exec(t.textAfter)[0].lengtht.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:""}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),rm=UL.configure({wrap:SL(VL,BL)});function tue(t={}){let e="",n;t.matchClosingTags===!1&&(e="noMatch"),t.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(t.nestedLanguages&&t.nestedLanguages.length||t.nestedAttributes&&t.nestedAttributes.length)&&(n=SL((t.nestedLanguages||[]).concat(VL),(t.nestedAttributes||[]).concat(BL)));let i=n?UL.configure({wrap:n,dialect:e}):e?rm.configure({dialect:e}):rm;return new Yf(i,[rm.data.of({autocomplete:Jce(t)}),t.autoCloseTags!==!1?iue:[],Bce().support,ace().support])}const FQ=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" "));function nue(t,e,n){for(var i;;){if(((i=e.lastChild)===null||i===void 0?void 0:i.name)!="CloseTag")return!1;let r=e.parent;if(!r||Il(t,r)!=n)return!0;e=r}}const iue=Le.inputHandler.of((t,e,n,i,r)=>{if(t.composing||t.state.readOnly||e!=n||i!=">"&&i!="/"||!rm.isActiveAt(t.state,e,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(u=>{var f;let h=o.doc.sliceString(u.from-1,u.to)==i,{head:p}=u,O=hn(o).resolveInner(p,-1),y;if(h&&i==">"&&O.name=="EndTag"){let v=O.parent;if((y=Il(o.doc,v.parent,p))&&!FQ.has(y)&&!nue(o.doc,v.parent,y)){let S=p+(o.doc.sliceString(p,p+1)===">"?1:0),k=``;return{range:u,changes:{from:p,to:S,insert:k}}}}else if(h&&i=="/"&&O.name=="IncompleteCloseTag"){let v=O.parent;if(O.from==p-2&&((f=v.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(y=Il(o.doc,v,p))&&!FQ.has(y)){let S=p+(o.doc.sliceString(p,p+1)===">"?1:0),k=`${y}>`;return{range:Oe.cursor(p+k.length,-1),changes:{from:p,to:S,insert:k}}}}return{range:u}});return l.changes.empty?!1:(t.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),qL=nk({commentTokens:{block:{open:""}}}),YL=new We,FL=vae.configure({props:[Rh.add(t=>!t.is("Block")||t.is("Document")||Jx(t)!=null||rue(t)?void 0:(e,n)=>({from:n.doc.lineAt(e.from).to,to:e.to})),YL.add(Jx),Eh.add({Document:()=>null}),xl.add({Document:qL})]});function Jx(t){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(t.name);return e?+e[1]:void 0}function rue(t){return t.name=="OrderedList"||t.name=="BulletList"}function sue(t,e){let n=t;for(;;){let i=n.nextSibling,r;if(!i||(r=Jx(i.type))!=null&&r<=e)break;n=i}return n.to}const oue=vse.of((t,e,n)=>{for(let i=hn(t).resolveInner(n,-1);i&&!(i.fromn)return{from:n,to:s}}return null});function bk(t){return new Ar(qL,t,[],"markdown")}const aue=bk(FL),lue=FL.configure([Rae,Aae,Qae,Pae,{props:[Rh.add({Table:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}]),eO=bk(lue);function cue(t,e){return n=>{if(n&&t){let i=null;if(n=/\S*/.exec(n)[0],typeof t=="function"?i=t(n):i=Vm.matchLanguageName(t,n,!0),i instanceof Vm)return i.support?i.support.language.parser:qf.getSkippingParser(i.load());if(i)return i.parser}return e?e.parser:null}}class Wb{constructor(e,n,i,r,s,o,l){this.node=e,this.from=n,this.to=i,this.spaceBefore=r,this.spaceAfter=s,this.type=o,this.item=l}blank(e,n=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;i.length0;r--)i+=" ";return i+(n?this.spaceAfter:"")}}marker(e,n){let i=this.node.name=="OrderedList"?String(+HL(this.item,e)[2]+n):"";return this.spaceBefore+i+this.type+this.spaceAfter}}function GL(t,e){let n=[],i=[];for(let r=t;r;r=r.parent){if(r.name=="FencedCode")return i;(r.name=="ListItem"||r.name=="Blockquote")&&n.push(r)}for(let r=n.length-1;r>=0;r--){let s=n[r],o,l=e.lineAt(s.from),u=s.from-l.from;if(s.name=="Blockquote"&&(o=/^ *>( ?)/.exec(l.text.slice(u))))i.push(new Wb(s,u,u+o[0].length,"",o[1],">",null));else if(s.name=="ListItem"&&s.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(l.text.slice(u)))){let f=o[3],h=o[0].length;f.length>=4&&(f=f.slice(0,f.length-4),h-=4),i.push(new Wb(s.parent,u,u+h,o[1],f,o[2],s))}else if(s.name=="ListItem"&&s.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(u)))){let f=o[4],h=o[0].length;f.length>4&&(f=f.slice(0,f.length-4),h-=4);let p=o[2];o[3]&&(p+=o[3].replace(/[xX]/," ")),i.push(new Wb(s.parent,u,u+h,o[1],f,p,s))}}return i}function HL(t,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(t.from,t.from+10))}function Kb(t,e,n,i=0){for(let r=-1,s=t;;){if(s.name=="ListItem"){let l=HL(s,e),u=+l[2];if(r>=0){if(u!=r+1)return;n.push({from:s.from+l[1].length,to:s.from+l[0].length,insert:String(r+2+i)})}r=u}let o=s.nextSibling;if(!o)break;s=o}}function Sk(t,e){let n=/^[ \t]*/.exec(t)[0].length;if(!n||e.facet(Th)!=" ")return t;let i=To(t,4,n),r="";for(let s=i;s>0;)s>=4?(r+=" ",s-=4):(r+=" ",s--);return r+t.slice(n)}const uue=(t={})=>({state:e,dispatch:n})=>{let i=hn(e),{doc:r}=e,s=null,o=e.changeByRange(l=>{if(!l.empty||!eO.isActiveAt(e,l.from,-1)&&!eO.isActiveAt(e,l.from,1))return s={range:l};let u=l.from,f=r.lineAt(u),h=GL(i.resolveInner(u,-1),r);for(;h.length&&h[h.length-1].from>u-f.from;)h.pop();if(!h.length)return s={range:l};let p=h[h.length-1];if(p.to-p.spaceAfter.length>u-f.from)return s={range:l};let O=u>=p.to-p.spaceAfter.length&&!/\S/.test(f.text.slice(p.to));if(p.item&&O){if(p.item.from]*$/.test(f.text.slice(0,p.to)))return s={range:l};let C=p.node.firstChild,$=p.node.getChild("ListItem","ListItem");if(C.to>=u||$&&$.to0&&!/[^\s>]/.test(r.lineAt(f.from-1).text)||t.nonTightLists===!1){let T=h.length>1?h[h.length-2]:null,Q,A="";T&&T.item?(Q=f.from+T.from,A=T.marker(r,1)):Q=f.from+(T?T.to:0);let R=[{from:Q,to:u,insert:A}];return p.node.name=="OrderedList"&&Kb(p.item,r,R,-2),T&&T.node.name=="OrderedList"&&Kb(T.item,r,R),{range:Oe.cursor(Q+A.length),changes:R}}else{let T=HQ(h,e,f);return{range:Oe.cursor(u+T.length+1),changes:{from:f.from,insert:T+e.lineBreak}}}}if(p.node.name=="Blockquote"&&O&&f.from){let C=r.lineAt(f.from-1),$=/>\s*$/.exec(C.text);if($&&$.index==p.from){let T=e.changes([{from:C.from+$.index,to:C.to},{from:f.from+p.from,to:f.to}]);return{range:l.map(T),changes:T}}}let y=[];p.node.name=="OrderedList"&&Kb(p.item,r,y);let v=p.item&&p.item.from]*/.exec(f.text)[0].length>=p.to)for(let C=0,$=h.length-1;C<=$;C++)S+=C==$&&!v?h[C].marker(r,1):h[C].blank(C<$?To(f.text,4,h[C+1].from)-S.length:null);let k=u;for(;k>f.from&&/\s/.test(f.text.charAt(k-f.from-1));)k--;return S=Sk(S,e),fue(p.node,e.doc)&&(S=HQ(h,e,f)+e.lineBreak+S),y.push({from:k,to:u,insert:e.lineBreak+S}),{range:Oe.cursor(k+S.length+1),changes:y}});return s?!1:(n(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},due=uue();function GQ(t){return t.name=="QuoteMark"||t.name=="ListMark"}function fue(t,e){if(t.name!="OrderedList"&&t.name!="BulletList")return!1;let n=t.firstChild,i=t.getChild("ListItem","ListItem");if(!i)return!1;let r=e.lineAt(n.to),s=e.lineAt(i.from),o=/^[\s>]*$/.test(r.text);return r.number+(o?0:1){let n=hn(t),i=null,r=t.changeByRange(s=>{let o=s.from,{doc:l}=t;if(s.empty&&eO.isActiveAt(t,s.from)){let u=l.lineAt(o),f=GL(hue(n,o),l);if(f.length){let h=f[f.length-1],p=h.to-h.spaceAfter.length+(h.spaceAfter?1:0);if(o-u.from>p&&!/\S/.test(u.text.slice(p,o-u.from)))return{range:Oe.cursor(u.from+p),changes:{from:u.from+p,to:o}};if(o-u.from==p&&(h.item&&u.from<=h.item.from||/^[\s>]*$/.test(u.text.slice(0,h.to)))){let O=u.from+h.from;if(h.item&&h.node.from{var n;let{main:i}=e.state.selection;if(i.empty)return!1;let r=(n=t.clipboardData)===null||n===void 0?void 0:n.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!eO.isActiveAt(e.state,i.from,1)))return!1;let s=hn(e.state),o=!1;return s.iterate({from:i.from,to:i.to,enter:l=>{(l.from>i.from||vue.test(l.name))&&(o=!0)},leave:l=>{l.tonew Map,ew=t=>{const e=qi();return t.forEach((n,i)=>{e.set(i,n)}),e},Vs=(t,e,n)=>{let i=t.get(e);return i===void 0&&t.set(e,i=n()),i},Sue=(t,e)=>{const n=[];for(const[i,r]of t)n.push(e(r,i));return n},xue=(t,e)=>{for(const[n,i]of t)if(e(i,n))return!0;return!1},Aa=()=>new Set,eS=t=>t[t.length-1],wue=(t,e)=>{for(let n=0;n{for(let n=0;n{for(let n=0;n{const n=new Array(t);for(let i=0;i{this.off(e,i),n(...r)};this.on(e,i)}off(e,n){const i=this._observers.get(e);i!==void 0&&(i.delete(n),i.size===0&&this._observers.delete(e))}emit(e,n){return Ro((this._observers.get(e)||qi()).values()).forEach(i=>i(...n))}destroy(){this._observers=qi()}}class Cue{constructor(){this._observers=qi()}on(e,n){Vs(this._observers,e,Aa).add(n)}once(e,n){const i=(...r)=>{this.off(e,i),n(...r)};this.on(e,i)}off(e,n){const i=this._observers.get(e);i!==void 0&&(i.delete(n),i.size===0&&this._observers.delete(e))}emit(e,n){return Ro((this._observers.get(e)||qi()).values()).forEach(i=>i(...n))}destroy(){this._observers=qi()}}const ns=Math.floor,sm=Math.abs,dy=(t,e)=>tt>e?t:e,_ue=Math.pow,KL=t=>t!==0?t<0:1/t<0,WQ=1,KQ=2,tS=4,nS=8,Jf=32,_o=64,cr=128,fy=31,tw=63,$l=127,$ue=2147483647,tO=Number.MAX_SAFE_INTEGER,JQ=Number.MIN_SAFE_INTEGER,Tue=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&ns(t)===t),JL=String.fromCharCode,Eue=t=>t.toLowerCase(),Rue=/^\s*/g,Que=t=>t.replace(Rue,""),Aue=/([A-Z])/g,eA=(t,e)=>Que(t.replace(Aue,n=>`${e}${Eue(n)}`)),Pue=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,i=new Uint8Array(n);for(let r=0;reh.encode(t),Mue=eh?jue:Pue;let $f=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});$f&&$f.decode(new Uint8Array).length===1&&($f=null);const Due=(t,e)=>kue(e,()=>t).join("");class Ph{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const ci=()=>new Ph,Ck=t=>{let e=t.cpos;for(let n=0;n{const e=new Uint8Array(Ck(t));let n=0;for(let i=0;i{const n=t.cbuf.length;n-t.cpos{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},nw=In,Ue=(t,e)=>{for(;e>$l;)In(t,cr|$l&e),e=ns(e/128);In(t,$l&e)},_k=(t,e)=>{const n=KL(e);for(n&&(e=-e),In(t,(e>tw?cr:0)|(n?_o:0)|tw&e),e=ns(e/64);e>0;)In(t,(e>$l?cr:0)|$l&e),e=ns(e/128)},iw=new Uint8Array(3e4),zue=iw.length/3,Lue=(t,e)=>{if(e.length{const n=unescape(encodeURIComponent(e)),i=n.length;Ue(t,i);for(let r=0;r{const n=t.cbuf.length,i=t.cpos,r=dy(n-i,e.length),s=e.length-r;t.cbuf.set(e.subarray(0,r),i),t.cpos+=r,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Ba(n*2,s)),t.cbuf.set(e.subarray(r)),t.cpos=s)},yn=(t,e)=>{Ue(t,e.byteLength),hy(t,e)},$k=(t,e)=>{Nue(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Iue=(t,e)=>$k(t,4).setFloat32(0,e,!1),Xue=(t,e)=>$k(t,8).setFloat64(0,e,!1),Vue=(t,e)=>$k(t,8).setBigInt64(0,e,!1),tA=new DataView(new ArrayBuffer(4)),Bue=t=>(tA.setFloat32(0,t),tA.getFloat32(0)===t),th=(t,e)=>{switch(typeof e){case"string":In(t,119),Tl(t,e);break;case"number":Tue(e)&&sm(e)<=$ue?(In(t,125),_k(t,e)):Bue(e)?(In(t,124),Iue(t,e)):(In(t,123),Xue(t,e));break;case"bigint":In(t,122),Vue(t,e);break;case"object":if(e===null)In(t,126);else if(ju(e)){In(t,117),Ue(t,e.length);for(let n=0;n0&&Ue(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const iA=t=>{t.count>0&&(_k(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Ue(t.encoder,t.count-2))};class om{constructor(){this.encoder=new Ph,this.s=0,this.count=0}write(e){this.s===e?this.count++:(iA(this),this.count=1,this.s=e)}toUint8Array(){return iA(this),tn(this.encoder)}}const rA=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);_k(t.encoder,e),t.count>1&&Ue(t.encoder,t.count-2)}};class iS{constructor(){this.encoder=new Ph,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(rA(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return rA(this),tn(this.encoder)}}class Uue{constructor(){this.sarr=[],this.s="",this.lensE=new om}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Ph;return this.sarr.push(this.s),this.s="",Tl(e,this.sarr.join("")),hy(e,this.lensE.toUint8Array()),tn(e)}}const Ls=t=>new Error(t),es=()=>{throw Ls("Method unimplemented")},dr=()=>{throw Ls("Unexpected case")},e3=Ls("Unexpected end of array"),t3=Ls("Integer out of Range");class py{constructor(e){this.arr=e,this.pos=0}}const Ua=t=>new py(t),que=t=>t.pos!==t.arr.length,Yue=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},li=t=>Yue(t,et(t)),Mu=t=>t.arr[t.pos++],et=t=>{let e=0,n=1;const i=t.arr.length;for(;t.postO)throw t3}throw e3},Tk=t=>{let e=t.arr[t.pos++],n=e&tw,i=64;const r=(e&_o)>0?-1:1;if((e&cr)===0)return r*n;const s=t.arr.length;for(;t.postO)throw t3}throw e3},Fue=t=>{let e=et(t);if(e===0)return"";{let n=String.fromCodePoint(Mu(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Mu(t));else for(;e>0;){const i=e<1e4?e:1e4,r=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,n+=String.fromCodePoint.apply(null,r),e-=i}return decodeURIComponent(escape(n))}},Gue=t=>$f.decode(li(t)),xa=$f?Gue:Fue,Ek=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Hue=t=>Ek(t,4).getFloat32(0,!1),Wue=t=>Ek(t,8).getFloat64(0,!1),Kue=t=>Ek(t,8).getBigInt64(0,!1),Jue=[t=>{},t=>null,Tk,Hue,Wue,Kue,t=>!1,t=>!0,xa,t=>{const e=et(t),n={};for(let i=0;i{const e=et(t),n=[];for(let i=0;iJue[127-Mu(t)](t);class sA extends py{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),que(this)?this.count=et(this)+1:this.count=-1),this.count--,this.s}}class am extends py{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Tk(this);const e=KL(this.s);this.count=1,e&&(this.s=-this.s,this.count=et(this)+2)}return this.count--,this.s}}class rS extends py{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Tk(this),n=e&1;this.diff=ns(e/2),this.count=1,n&&(this.count=et(this)+2)}return this.s+=this.diff,this.count--,this.s}}class ede{constructor(e){this.decoder=new am(e),this.str=xa(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const tde=crypto.getRandomValues.bind(crypto),n3=()=>tde(new Uint32Array(1))[0],nde="10000000-1000-4000-8000"+-1e11,ide=()=>nde.replace(/[018]/g,t=>(t^n3()&15>>t/4).toString(16)),Pa=Date.now,oA=t=>new Promise(t);Promise.all.bind(Promise);const aA=t=>t===void 0?null:t;class rde{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let i3=new rde,Rk=!0;try{typeof localStorage<"u"&&localStorage&&(i3=localStorage,Rk=!1)}catch{}const r3=i3,sde=t=>Rk||addEventListener("storage",t),ode=t=>Rk||removeEventListener("storage",t),ih=Symbol("Equality"),s3=(t,e)=>t===e||!!t?.[ih]?.(e)||!1,ade=t=>typeof t=="object",lde=Object.assign,cde=Object.keys,ude=(t,e)=>{for(const n in t)e(t[n],n)},dde=(t,e)=>{const n=[];for(const i in t)n.push(e(t[i],i));return n},nO=t=>cde(t).length,fde=t=>{for(const e in t)return!1;return!0},jh=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Qk=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),hde=(t,e)=>t===e||nO(t)===nO(e)&&jh(t,(n,i)=>(n!==void 0||Qk(e,i))&&s3(e[i],n)),pde=Object.freeze,o3=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&o3(t[e])}return pde(t)},Ak=(t,e,n=0)=>{try{for(;nt,fu=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[ih]!=null)return t[ih](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;ne.includes(t);var a3={};const ja=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",l3=typeof window<"u"&&typeof document<"u"&&!ja;let ys;const Ode=()=>{if(ys===void 0)if(ja){ys=qi();const t=process.argv;let e=null;for(let n=0;n{if(t.length!==0){const[e,n]=t.split("=");ys.set(`--${eA(e,"-")}`,n),ys.set(`-${eA(e,"-")}`,n)}})):ys=qi();return ys},rw=t=>Ode().has(t),iO=t=>aA(ja?a3[t.toUpperCase().replaceAll("-","_")]:r3.getItem(t)),c3=t=>rw("--"+t)||iO(t)!==null,yde=c3("production"),vde=ja&&mde(a3.FORCE_COLOR,["true","1","2"]),bde=vde||!rw("--no-colors")&&!c3("no-color")&&(!ja||process.stdout.isTTY)&&(!ja||rw("--color")||iO("COLORTERM")!==null||(iO("TERM")||"").includes("color")),u3=t=>new Uint8Array(t),Sde=(t,e,n)=>new Uint8Array(t,e,n),xde=t=>new Uint8Array(t),wde=t=>{let e="";for(let n=0;nBuffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Cde=t=>{const e=atob(t),n=u3(e.length);for(let i=0;i{const e=Buffer.from(t,"base64");return Sde(e.buffer,e.byteOffset,e.byteLength)},$de=l3?wde:kde,Tde=l3?Cde:_de,Ede=t=>{const e=u3(t.byteLength);return e.set(t),e};class Rde{constructor(e,n){this.left=e,this.right=n}}const rr=(t,e)=>new Rde(t,e),Qde=(t,e)=>t.forEach(n=>e(n.left,n.right)),lA=t=>t.next()>=.5,sS=(t,e,n)=>ns(t.next()*(n+1-e)+e),d3=(t,e,n)=>ns(t.next()*(n+1-e)+e),Pk=(t,e,n)=>d3(t,e,n),Ade=t=>JL(Pk(t,97,122)),Pde=(t,e=0,n=20)=>{const i=Pk(t,e,n);let r="";for(let s=0;se[Pk(t,0,e.length-1)],jde=Symbol("0schema");class Mde{constructor(){this._rerrs=[]}extend(e,n,i,r=null){this._rerrs.push({path:e,expected:n,has:i,message:r})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const i=this._rerrs[n];e.push(Due(" ",(this._rerrs.length-n)*2)+`${i.path!=null?`[${i.path}] `:""}${i.has} doesn't match ${i.expected}. ${i.message}`)}return e.join(` -`)}}const sw=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[ih]?s3(t,e):ju(t)?xk(t,n=>wk(e,i=>sw(n,i))):ade(t)?jh(t,(n,i)=>sw(n,e[i])):!1;class Ei{static _dilutes=!1;extends(e){let[n,i]=[this.shape,e.shape];return this.constructor._dilutes&&([i,n]=[n,i]),sw(n,i)}equals(e){return this.constructor===e.constructor&&fu(this.shape,e.shape)}[jde](){return!0}[ih](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){es()}get nullable(){return Wu(this,vy)}get optional(){return new p3(this)}cast(e){return cA(e,this),e}expect(e){return cA(e,this),e}}class jk extends Ei{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const i=e?.constructor===this.shape&&(this._c==null||this._c(e));return!i&&n?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),i}}const En=(t,e=null)=>new jk(t,e);En(jk);class Mk extends Ei{constructor(e){super(),this.shape=e}check(e,n){const i=this.shape(e);return!i&&n?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),i}}const Bn=t=>new Mk(t);En(Mk);class gy extends Ei{constructor(e){super(),this.shape=e}check(e,n){const i=this.shape.some(r=>r===e);return!i&&n?.extend(null,this.shape.join(" | "),e.toString()),i}}const my=(...t)=>new gy(t),f3=En(gy),Dde=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),h3=t=>{if(Du.check(t))return[Dde(t)];if(f3.check(t))return t.shape.map(e=>e+"");if(w3.check(t))return["[+-]?\\d+.?\\d*"];if(k3.check(t))return[".*"];if(rO.check(t))return t.shape.map(h3).flat(1);dr()};class Nde extends Ei{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(h3).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const i=this._r.exec(e)!=null;return!i&&n?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),i}}En(Nde);const zde=Symbol("optional");class p3 extends Ei{constructor(e){super(),this.shape=e}check(e,n){const i=e===void 0||this.shape.check(e);return!i&&n?.extend(null,"undefined (optional)","()"),i}get[zde](){return!0}}const Lde=En(p3);class Zde extends Ei{check(e,n){return n?.extend(null,"never",typeof e),!1}}En(Zde);class Oy extends Ei{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}static _dilutes=!0;get partial(){return new Oy(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):jh(this.shape,(i,r)=>{const s=this._isPartial&&!Qk(e,r)||i.check(e[r],n);return!s&&n?.extend(r.toString(),i.toString(),typeof e[r],"Object property does not match"),s})}}const Ide=t=>new Oy(t),Xde=En(Oy),Vde=Bn(t=>t!=null&&(t.constructor===Object||t.constructor==null));class g3 extends Ei{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&jh(e,(i,r)=>{const s=this.shape.keys.check(r,n);return!s&&n?.extend(r+"","Record",typeof e,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(i,n)})}}const m3=(t,e)=>new g3(t,e),Bde=En(g3);class O3 extends Ei{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&jh(this.shape,(i,r)=>{const s=i.check(e[r],n);return!s&&n?.extend(r.toString(),"Tuple",typeof i),s})}}const Ude=(...t)=>new O3(t);En(O3);class y3 extends Ei{constructor(e){super(),this.shape=e.length===1?e[0]:new Dk(e)}check(e,n){const i=ju(e)&&xk(e,r=>this.shape.check(r));return!i&&n?.extend(null,"Array",""),i}}const v3=(...t)=>new y3(t),qde=En(y3),Yde=Bn(t=>ju(t));class b3 extends Ei{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const i=e instanceof this.shape&&(this._c==null||this._c(e));return!i&&n?.extend(null,this.shape.name,e?.constructor.name),i}}const Fde=(t,e=null)=>new b3(t,e);En(b3);const Gde=Fde(Ei);class Hde extends Ei{constructor(e){super(),this.len=e.length-1,this.args=Ude(...e.slice(-1)),this.res=e[this.len]}check(e,n){const i=e.constructor===Function&&e.length<=this.len;return!i&&n?.extend(null,"function",typeof e),i}}const Wde=En(Hde),Kde=Bn(t=>typeof t=="function");class Jde extends Ei{constructor(e){super(),this.shape=e}check(e,n){const i=xk(this.shape,r=>r.check(e,n));return!i&&n?.extend(null,"Intersectinon",typeof e),i}}En(Jde,t=>t.shape.length>0);class Dk extends Ei{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,n){const i=wk(this.shape,r=>r.check(e,n));return n?.extend(null,"Union",typeof e),i}}const Wu=(...t)=>t.findIndex(e=>rO.check(e))>=0?Wu(...t.map(e=>rh(e)).map(e=>rO.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Dk(t),rO=En(Dk),S3=()=>!0,sO=Bn(S3),efe=En(Mk,t=>t.shape===S3),Nk=Bn(t=>typeof t=="bigint"),tfe=Bn(t=>t===Nk),x3=Bn(t=>typeof t=="symbol");Bn(t=>t===x3);const hu=Bn(t=>typeof t=="number"),w3=Bn(t=>t===hu),Du=Bn(t=>typeof t=="string"),k3=Bn(t=>t===Du),yy=Bn(t=>typeof t=="boolean"),nfe=Bn(t=>t===yy),C3=my(void 0);En(gy,t=>t.shape.length===1&&t.shape[0]===void 0);my(void 0);const vy=my(null),ife=En(gy,t=>t.shape.length===1&&t.shape[0]===null);En(Uint8Array);En(jk,t=>t.shape===Uint8Array);const rfe=Wu(hu,Du,vy,C3,Nk,yy,x3);(()=>{const t=v3(sO),e=m3(Du,sO),n=Wu(hu,Du,vy,yy,t,e);return t.shape=n,e.shape.values=n,n})();const rh=t=>{if(Gde.check(t))return t;if(Vde.check(t)){const e={};for(const n in t)e[n]=rh(t[n]);return Ide(e)}else{if(Yde.check(t))return Wu(...t.map(rh));if(rfe.check(t))return my(t);if(Kde.check(t))return En(t)}dr()},cA=yde?()=>{}:(t,e)=>{const n=new Mde;if(!e.check(t,n))throw Ls(`Expected value to be of type ${e.constructor.name}. -${n.toString()}`)};class sfe{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:rh(e),h:n}),this}else(e){return this.if(sO,e)}done(){return(e,n)=>{for(let i=0;inew sfe(t),_3=ofe(sO).if(w3,(t,e)=>sS(e,JQ,tO)).if(k3,(t,e)=>Pde(e)).if(nfe,(t,e)=>lA(e)).if(tfe,(t,e)=>BigInt(sS(e,JQ,tO))).if(rO,(t,e)=>Zc(e,oS(e,t.shape))).if(Xde,(t,e)=>{const n={};for(const i in t.shape){let r=t.shape[i];if(Lde.check(r)){if(lA(e))continue;r=r.shape}n[i]=_3(r,e)}return n}).if(qde,(t,e)=>{const n=[],i=d3(e,0,42);for(let r=0;roS(e,t.shape)).if(ife,(t,e)=>null).if(Wde,(t,e)=>{const n=Zc(e,t.res);return()=>n}).if(efe,(t,e)=>Zc(e,oS(e,[hu,Du,vy,C3,Nk,yy,v3(hu),m3(Wu("a","b","c"),hu)]))).if(Bde,(t,e)=>{const n={},i=sS(e,0,3);for(let r=0;r_3(rh(e),t),Bs=typeof document<"u"?document:{},afe=t=>Bs.createElement(t),lfe=()=>Bs.createDocumentFragment();Bn(t=>t.nodeType===Ofe);const cfe=t=>Bs.createTextNode(t);typeof DOMParser<"u"&&new DOMParser;const ufe=(t,e)=>(Qde(e,(n,i)=>{i===!1?t.removeAttribute(n):i===!0?t.setAttribute(n,""):t.setAttribute(n,i)}),t),dfe=t=>{const e=lfe();for(let n=0;n($3(t,dfe(e)),t),aS=(t,e=[],n=[])=>ffe(ufe(afe(t),e),n);Bn(t=>t.nodeType===pfe);const Ng=cfe;Bn(t=>t.nodeType===gfe);const hfe=t=>Sue(t,(e,n)=>`${n}:${e};`).join(""),$3=(t,e)=>t.appendChild(e),pfe=Bs.ELEMENT_NODE,gfe=Bs.TEXT_NODE;Bs.CDATA_SECTION_NODE;Bs.COMMENT_NODE;const mfe=Bs.DOCUMENT_NODE;Bs.DOCUMENT_TYPE_NODE;const Ofe=Bs.DOCUMENT_FRAGMENT_NODE;Bn(t=>t.nodeType===mfe);const Po=Symbol,T3=Po(),E3=Po(),yfe=Po(),vfe=Po(),bfe=Po(),R3=Po(),Sfe=Po(),zk=Po(),xfe=Po(),wfe=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let i=0;for(;i0&&n.push(e.join(""));i{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],i=qi();let r=[],s=0;for(;s0||u.length>0?(e.push("%c"+o),n.push(u)):e.push(o)}else break}}for(s>0&&(r=n,r.unshift(e.join("")));s{console.log(...Q3(t)),P3.forEach(e=>e.print(t))},A3=(...t)=>{console.warn(...Q3(t)),t.unshift(zk),P3.forEach(e=>e.print(t))},P3=Aa(),j3=t=>({[Symbol.iterator](){return this},next:t}),$fe=(t,e)=>j3(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),lS=(t,e)=>j3(()=>{const{done:n,value:i}=t.next();return{done:n,value:n?void 0:e(i)}});class by{constructor(e,n){this.clock=e,this.len=n}}class Ku{constructor(){this.clients=new Map}}const Nu=(t,e,n)=>e.clients.forEach((i,r)=>{const s=t.doc.store.clients.get(r);if(s!=null){const o=s[s.length-1],l=o.id.clock+o.length;for(let u=0,f=i[u];u{let n=0,i=t.length-1;for(;n<=i;){const r=ns((n+i)/2),s=t[r],o=s.clock;if(o<=e){if(e{const n=t.clients.get(e.client);return n!==void 0&&Tfe(n,e.clock)!==null},Lk=t=>{t.clients.forEach(e=>{e.sort((r,s)=>r.clock-s.clock);let n,i;for(n=1,i=1;n=s.clock?e[i-1]=new by(r.clock,Ba(r.len,s.clock+s.len-r.clock)):(i{const e=new Ku;for(let n=0;n{if(!e.clients.has(r)){const s=i.slice();for(let o=n+1;o{Vs(t.clients,e,()=>[]).push(new by(n,i))},Efe=()=>new Ku,Rfe=t=>{const e=Efe();return t.clients.forEach((n,i)=>{const r=[];for(let s=0;s0&&e.clients.set(i,r)}),e},Ju=(t,e)=>{Ue(t.restEncoder,e.clients.size),Ro(e.clients.entries()).sort((n,i)=>i[0]-n[0]).forEach(([n,i])=>{t.resetDsCurVal(),Ue(t.restEncoder,n);const r=i.length;Ue(t.restEncoder,r);for(let s=0;s{const e=new Ku,n=et(t.restDecoder);for(let i=0;i0){const o=Vs(e.clients,r,()=>[]);for(let l=0;l{const i=new Ku,r=et(t.restDecoder);for(let s=0;s0){const s=new Xl;return Ue(s.restEncoder,0),Ju(s,i),s.toUint8Array()}return null},M3=n3;class Kl extends kk{constructor({guid:e=ide(),collectionid:n=null,gc:i=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=i,this.gcFilter=r,this.clientID=M3(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new q3,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=oA(f=>{this.on("load",()=>{this.isLoaded=!0,f(this)})});const u=()=>oA(f=>{const h=p=>{(p===void 0||p===!0)&&(this.off("sync",h),f())};this.on("sync",h)});this.on("sync",f=>{f===!1&&this.isSynced&&(this.whenSynced=u()),this.isSynced=f===void 0||f===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=u()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Bt(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ro(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Bt(this,e,n)}get(e,n=Vn){const i=Vs(this.share,e,()=>{const s=new n;return s._integrate(this,null),s}),r=i.constructor;if(n!==Vn&&r!==n)if(r===Vn){const s=new n;s._map=i._map,i._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s}),s._start=i._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=i._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return i}getArray(e=""){return this.get(e,mu)}getText(e=""){return this.get(e,Zu)}getMap(e=""){return this.get(e,Lu)}getXmlElement(e=""){return this.get(e,Iu)}getXmlFragment(e=""){return this.get(e,Vl)}toJSON(){const e={};return this.share.forEach((n,i)=>{e[i]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Ro(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Kl({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Bt(e.parent.doc,i=>{const r=n.doc;e.deleted||i.subdocsAdded.add(r),i.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class D3{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return et(this.restDecoder)}readDsLen(){return et(this.restDecoder)}}class N3 extends D3{readLeftID(){return nt(et(this.restDecoder),et(this.restDecoder))}readRightID(){return nt(et(this.restDecoder),et(this.restDecoder))}readClient(){return et(this.restDecoder)}readInfo(){return Mu(this.restDecoder)}readString(){return xa(this.restDecoder)}readParentInfo(){return et(this.restDecoder)===1}readTypeRef(){return et(this.restDecoder)}readLen(){return et(this.restDecoder)}readAny(){return nh(this.restDecoder)}readBuf(){return Ede(li(this.restDecoder))}readJSON(){return JSON.parse(xa(this.restDecoder))}readKey(){return xa(this.restDecoder)}}class Qfe{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=et(this.restDecoder),this.dsCurrVal}readDsLen(){const e=et(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class zu extends Qfe{constructor(e){super(e),this.keys=[],et(e),this.keyClockDecoder=new rS(li(e)),this.clientDecoder=new am(li(e)),this.leftClockDecoder=new rS(li(e)),this.rightClockDecoder=new rS(li(e)),this.infoDecoder=new sA(li(e),Mu),this.stringDecoder=new ede(li(e)),this.parentInfoDecoder=new sA(li(e),Mu),this.typeRefDecoder=new am(li(e)),this.lenDecoder=new am(li(e))}readLeftID(){return new pu(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new pu(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return nh(this.restDecoder)}readBuf(){return li(this.restDecoder)}readJSON(){return nh(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e{i=Ba(i,e[0].id.clock);const r=Zs(e,i);Ue(t.restEncoder,e.length-r),t.writeClient(n),Ue(t.restEncoder,i);const s=e[r];s.write(t,i-s.id.clock);for(let o=r+1;o{const i=new Map;n.forEach((r,s)=>{Sn(e,s)>r&&i.set(s,r)}),Sy(e).forEach((r,s)=>{n.has(s)||i.set(s,0)}),Ue(t.restEncoder,i.size),Ro(i.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{Afe(t,e.clients.get(r),r,s)})},Pfe=(t,e)=>{const n=qi(),i=et(t.restDecoder);for(let r=0;r{const i=[];let r=Ro(n.keys()).sort((y,v)=>y-v);if(r.length===0)return null;const s=()=>{if(r.length===0)return null;let y=n.get(r[r.length-1]);for(;y.refs.length===y.i;)if(r.pop(),r.length>0)y=n.get(r[r.length-1]);else return null;return y};let o=s();if(o===null)return null;const l=new q3,u=new Map,f=(y,v)=>{const S=u.get(y);(S==null||S>v)&&u.set(y,v)};let h=o.refs[o.i++];const p=new Map,O=()=>{for(const y of i){const v=y.id.client,S=n.get(v);S?(S.i--,l.clients.set(v,S.refs.slice(S.i)),n.delete(v),S.i=0,S.refs=[]):l.clients.set(v,[y]),r=r.filter(k=>k!==v)}i.length=0};for(;;){if(h.constructor!==Er){const v=Vs(p,h.id.client,()=>Sn(e,h.id.client))-h.id.clock;if(v<0)i.push(h),f(h.id.client,h.id.clock-1),O();else{const S=h.getMissing(t,e);if(S!==null){i.push(h);const k=n.get(S)||{refs:[],i:0};if(k.refs.length===k.i)f(S,Sn(e,S)),O();else{h=k.refs[k.i++];continue}}else(v===0||v0)h=i.pop();else if(o!==null&&o.i0){const y=new Xl;return Ik(y,l,new Map),Ue(y.restEncoder,0),{missing:u,update:y.toUint8Array()}}return null},Mfe=(t,e)=>Ik(t,e.doc.store,e.beforeState),Dfe=(t,e,n,i=new zu(t))=>Bt(e,r=>{r.local=!1;let s=!1;const o=r.doc,l=o.store,u=Pfe(i,o),f=jfe(r,l,u),h=l.pendingStructs;if(h){for(const[O,y]of h.missing)if(yy)&&h.missing.set(O,y)}h.update=aO([h.update,f.update])}}else l.pendingStructs=f;const p=uA(i,r,l);if(l.pendingDs){const O=new zu(Ua(l.pendingDs));et(O.restDecoder);const y=uA(O,r,l);p&&y?l.pendingDs=aO([p,y]):l.pendingDs=p||y}else l.pendingDs=p;if(s){const O=l.pendingStructs.update;l.pendingStructs=null,Z3(r.doc,O)}},n,!1),Z3=(t,e,n,i=zu)=>{const r=Ua(e);Dfe(r,t,n,new i(r))},aw=(t,e,n)=>Z3(t,e,n,N3),Nfe=(t,e,n=new Map)=>{Ik(t,e.store,n),Ju(t,Rfe(e.store))},zfe=(t,e=new Uint8Array([0]),n=new Xl)=>{const i=I3(e);Nfe(n,t,i);const r=[n.toUint8Array()];if(t.store.pendingDs&&r.push(t.store.pendingDs),t.store.pendingStructs&&r.push(ihe(t.store.pendingStructs.update,e)),r.length>1){if(n.constructor===Dh)return H3(r.map((s,o)=>o===0?s:she(s)));if(n.constructor===Xl)return aO(r)}return r[0]},Lfe=(t,e)=>zfe(t,e,new Dh),Zfe=t=>{const e=new Map,n=et(t.restDecoder);for(let i=0;iZfe(new D3(Ua(t))),X3=(t,e)=>(Ue(t.restEncoder,e.size),Ro(e.entries()).sort((n,i)=>i[0]-n[0]).forEach(([n,i])=>{Ue(t.restEncoder,n),Ue(t.restEncoder,i)}),t),Ife=(t,e)=>X3(t,Sy(e.store)),Xfe=(t,e=new L3)=>(t instanceof Map?X3(e,t):Ife(e,t),e.toUint8Array()),Vfe=t=>Xfe(t,new z3);class Bfe{constructor(){this.l=[]}}const dA=()=>new Bfe,fA=(t,e)=>t.l.push(e),hA=(t,e)=>{const n=t.l,i=n.length;t.l=n.filter(r=>e!==r),i===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},V3=(t,e,n)=>Ak(t.l,[e,n]);class pu{constructor(e,n){this.client=e,this.clock=n}}const eu=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,nt=(t,e)=>new pu(t,e),B3=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw dr()},oO=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class U3{constructor(e,n,i,r=0){this.type=e,this.tname=n,this.item=i,this.assoc=r}}const pA=t=>{const e={};return t.type&&(e.type=t.type),t.tname&&(e.tname=t.tname),t.item&&(e.item=t.item),t.assoc!=null&&(e.assoc=t.assoc),e},oh=t=>new U3(t.type==null?null:nt(t.type.client,t.type.clock),t.tname??null,t.item==null?null:nt(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class Ufe{constructor(e,n,i=0){this.type=e,this.index=n,this.assoc=i}}const qfe=(t,e,n=0)=>new Ufe(t,e,n),zg=(t,e,n)=>{let i=null,r=null;return t._item===null?r=B3(t):i=nt(t._item.id.client,t._item.id.clock),new U3(i,r,e,n)},ah=(t,e,n=0)=>{let i=t._start;if(n<0){if(e===0)return zg(t,null,n);e--}for(;i!==null;){if(!i.deleted&&i.countable){if(i.length>e)return zg(t,nt(i.id.client,i.id.clock+e),n);e-=i.length}if(i.right===null&&n<0)return zg(t,i.lastId,n);i=i.right}return zg(t,null,n)},Yfe=(t,e)=>{const n=gu(t,e),i=e.clock-n.id.clock;return{item:n,diff:i}},lh=(t,e,n=!0)=>{const i=e.store,r=t.item,s=t.type,o=t.tname,l=t.assoc;let u=null,f=0;if(r!==null){if(Sn(i,r.client)<=r.clock)return null;const h=n?dw(i,r):Yfe(i,r),p=h.item;if(!(p instanceof Ut))return null;if(u=p.parent,u._item===null||!u._item.deleted){f=p.deleted||!p.countable?0:h.diff+(l>=0?0:1);let O=p.left;for(;O!==null;)!O.deleted&&O.countable&&(f+=O.length),O=O.left}}else{if(o!==null)u=e.get(o);else if(s!==null){if(Sn(i,s.client)<=s.clock)return null;const{item:h}=n?dw(i,s):{item:gu(i,s)};if(h instanceof Ut&&h.content instanceof Us)u=h.content.type;else return null}else throw dr();l>=0?f=u._length:f=0}return qfe(u,f,t.assoc)},gA=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&eu(t.item,e.item)&&eu(t.type,e.type)&&t.assoc===e.assoc,Bc=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Mh(e.ds,t.id),lw=(t,e)=>{const n=Vs(t.meta,lw,Aa),i=t.doc.store;n.has(e)||(e.sv.forEach((r,s)=>{r{}),n.add(e))};class q3{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Sy=t=>{const e=new Map;return t.clients.forEach((n,i)=>{const r=n[n.length-1];e.set(i,r.id.clock+r.length)}),e},Sn=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const i=n[n.length-1];return i.id.clock+i.length},Y3=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const i=n[n.length-1];if(i.id.clock+i.length!==e.id.clock)throw dr()}n.push(e)},Zs=(t,e)=>{let n=0,i=t.length-1,r=t[i],s=r.id.clock;if(s===e)return i;let o=ns(e/(s+r.length-1)*i);for(;n<=i;){if(r=t[o],s=r.id.clock,s<=e){if(e{const n=t.clients.get(e.client);return n[Zs(n,e.clock)]},gu=Ffe,cw=(t,e,n)=>{const i=Zs(e,n),r=e[i];return r.id.clock{const n=t.doc.store.clients.get(e.client);return n[cw(t,n,e.clock)]},mA=(t,e,n)=>{const i=e.clients.get(n.client),r=Zs(i,n.clock),s=i[r];return n.clock!==s.id.clock+s.length-1&&s.constructor!==Tr&&i.splice(r+1,0,hO(t,s,n.clock-s.id.clock+1)),s},Gfe=(t,e,n)=>{const i=t.clients.get(e.id.client);i[Zs(i,e.id.clock)]=n},F3=(t,e,n,i,r)=>{if(i===0)return;const s=n+i;let o=cw(t,e,n),l;do l=e[o++],se.deleteSet.clients.size===0&&!xue(e.afterState,(n,i)=>e.beforeState.get(i)!==n)?!1:(Lk(e.deleteSet),Mfe(t,e),Ju(t,e.deleteSet),!0),yA=(t,e,n)=>{const i=e._item;(i===null||i.id.clock<(t.beforeState.get(i.id.client)||0)&&!i.deleted)&&Vs(t.changed,e,Aa).add(n)},lm=(t,e)=>{let n=t[e],i=t[e-1],r=e;for(;r>0;n=i,i=t[--r-1]){if(i.deleted===n.deleted&&i.constructor===n.constructor&&i.mergeWith(n)){n instanceof Ut&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,i);continue}break}const s=e-r;return s&&t.splice(e+1-s,s),s},Wfe=(t,e,n)=>{for(const[i,r]of t.clients.entries()){const s=e.clients.get(i);for(let o=r.length-1;o>=0;o--){const l=r[o],u=l.clock+l.len;for(let f=Zs(s,l.clock),h=s[f];f{t.clients.forEach((n,i)=>{const r=e.clients.get(i);for(let s=n.length-1;s>=0;s--){const o=n[s],l=dy(r.length-1,1+Zs(r,o.clock+o.len-1));for(let u=l,f=r[u];u>0&&f.id.clock>=o.clock;f=r[u])u-=1+lm(r,u)}})},G3=(t,e)=>{if(el.push(()=>{(f._item===null||!f._item.deleted)&&f._callObserver(n,u)})),l.push(()=>{n.changedParentTypes.forEach((u,f)=>{f._dEH.l.length>0&&(f._item===null||!f._item.deleted)&&(u=u.filter(h=>h.target._item===null||!h.target._item.deleted),u.forEach(h=>{h.currentTarget=f,h._path=null}),u.sort((h,p)=>h.path.length-p.path.length),l.push(()=>{V3(f._dEH,u,n)}))}),l.push(()=>i.emit("afterTransaction",[n,i])),l.push(()=>{n._needFormattingCleanup&&vhe(n)})}),Ak(l,[])}finally{i.gc&&Wfe(s,r,i.gcFilter),Kfe(s,r),n.afterState.forEach((h,p)=>{const O=n.beforeState.get(p)||0;if(O!==h){const y=r.clients.get(p),v=Ba(Zs(y,O),1);for(let S=y.length-1;S>=v;)S-=1+lm(y,S)}});for(let h=o.length-1;h>=0;h--){const{client:p,clock:O}=o[h].id,y=r.clients.get(p),v=Zs(y,O);v+11||v>0&&lm(y,v)}if(!n.local&&n.afterState.get(i.clientID)!==n.beforeState.get(i.clientID)&&(_fe(zk,T3,"[yjs] ",E3,R3,"Changed the client-id because another client seems to be using it."),i.clientID=M3()),i.emit("afterTransactionCleanup",[n,i]),i._observers.has("update")){const h=new Dh;OA(h,n)&&i.emit("update",[h.toUint8Array(),n.origin,i,n])}if(i._observers.has("updateV2")){const h=new Xl;OA(h,n)&&i.emit("updateV2",[h.toUint8Array(),n.origin,i,n])}const{subdocsAdded:l,subdocsLoaded:u,subdocsRemoved:f}=n;(l.size>0||f.size>0||u.size>0)&&(l.forEach(h=>{h.clientID=i.clientID,h.collectionid==null&&(h.collectionid=i.collectionid),i.subdocs.add(h)}),f.forEach(h=>i.subdocs.delete(h)),i.emit("subdocs",[{loaded:u,added:l,removed:f},i,n]),f.forEach(h=>h.destroy())),t.length<=e+1?(i._transactionCleanups=[],i.emit("afterAllTransactions",[i,t])):G3(t,e+1)}}},Bt=(t,e,n=null,i=!0)=>{const r=t._transactionCleanups;let s=!1,o=null;t._transaction===null&&(s=!0,t._transaction=new Hfe(t,n,i),r.push(t._transaction),r.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(s){const l=t._transaction===r[0];t._transaction=null,l&&G3(r,0)}}return o};class Jfe{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const vA=(t,e,n)=>{Nu(t,n.deletions,i=>{i instanceof Ut&&e.scope.some(r=>r===t.doc||oO(r,i))&&Gk(i,!1)})},bA=(t,e,n)=>{let i=null;const r=t.doc,s=t.scope;Bt(r,l=>{for(;e.length>0&&t.currStackItem===null;){const u=r.store,f=e.pop(),h=new Set,p=[];let O=!1;Nu(l,f.insertions,y=>{if(y instanceof Ut){if(y.redone!==null){let{item:v,diff:S}=dw(u,y.id);S>0&&(v=Xi(l,nt(v.id.client,v.id.clock+S))),y=v}!y.deleted&&s.some(v=>v===l.doc||oO(v,y))&&p.push(y)}}),Nu(l,f.deletions,y=>{y instanceof Ut&&s.some(v=>v===l.doc||oO(v,y))&&!Mh(f.insertions,y.id)&&h.add(y)}),h.forEach(y=>{O=pZ(l,y,h,f.insertions,t.ignoreRemoteMapChanges,t)!==null||O});for(let y=p.length-1;y>=0;y--){const v=p[y];t.deleteFilter(v)&&(v.delete(l),O=!0)}t.currStackItem=O?f:null}l.changed.forEach((u,f)=>{u.has(null)&&f._searchMarker&&(f._searchMarker.length=0)}),i=l},t);const o=t.currStackItem;if(o!=null){const l=i.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class ehe extends kk{constructor(e,{captureTimeout:n=500,captureTransaction:i=u=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=ju(e)?e[0].doc:e instanceof Kl?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=i,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=u=>{if(!this.captureTransaction(u)||!this.scope.some(k=>u.changedParentTypes.has(k)||k===this.doc)||!this.trackedOrigins.has(u.origin)&&(!u.origin||!this.trackedOrigins.has(u.origin.constructor)))return;const f=this.undoing,h=this.redoing,p=f?this.redoStack:this.undoStack;f?this.stopCapturing():h||this.clear(!1,!0);const O=new Ku;u.afterState.forEach((k,C)=>{const $=u.beforeState.get(C)||0,T=k-$;T>0&&sh(O,C,$,T)});const y=Pa();let v=!1;if(this.lastChange>0&&y-this.lastChange0&&!f&&!h){const k=p[p.length-1];k.deletions=ow([k.deletions,u.deleteSet]),k.insertions=ow([k.insertions,O])}else p.push(new Jfe(u.deleteSet,O)),v=!0;!f&&!h&&(this.lastChange=y),Nu(u,u.deleteSet,k=>{k instanceof Ut&&this.scope.some(C=>C===u.doc||oO(C,k))&&Gk(k,!0)});const S=[{stackItem:p[p.length-1],origin:u.origin,type:f?"redo":"undo",changedParentTypes:u.changedParentTypes},this];v?this.emit("stack-item-added",S):this.emit("stack-item-updated",S)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(e){const n=new Set(this.scope);e=ju(e)?e:[e],e.forEach(i=>{n.has(i)||(n.add(i),(i instanceof Vn?i.doc!==this.doc:i!==this.doc)&&A3("[yjs#509] Not same Y.Doc"),this.scope.push(i))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(i=>{e&&(this.undoStack.forEach(r=>vA(i,this,r)),this.undoStack=[]),n&&(this.redoStack.forEach(r=>vA(i,this,r)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=bA(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=bA(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*the(t){const e=et(t.restDecoder);for(let n=0;naO(t,N3,Dh),nhe=(t,e)=>{if(t.constructor===Tr){const{client:n,clock:i}=t.id;return new Tr(nt(n,i+e),t.length-e)}else if(t.constructor===Er){const{client:n,clock:i}=t.id;return new Er(nt(n,i+e),t.length-e)}else{const n=t,{client:i,clock:r}=n.id;return new Ut(nt(i,r+e),null,nt(i,r+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},aO=(t,e=zu,n=Xl)=>{if(t.length===1)return t[0];const i=t.map(h=>new e(Ua(h)));let r=i.map(h=>new Xk(h,!0)),s=null;const o=new n,l=new Vk(o);for(;r=r.filter(O=>O.curr!==null),r.sort((O,y)=>{if(O.curr.id.client===y.curr.id.client){const v=O.curr.id.clock-y.curr.id.clock;return v===0?O.curr.constructor===y.curr.constructor?0:O.curr.constructor===Er?1:-1:v}else return y.curr.id.client-O.curr.id.client}),r.length!==0;){const h=r[0],p=h.curr.id.client;if(s!==null){let O=h.curr,y=!1;for(;O!==null&&O.id.clock+O.length<=s.struct.id.clock+s.struct.length&&O.id.client>=s.struct.id.client;)O=h.next(),y=!0;if(O===null||O.id.client!==p||y&&O.id.clock>s.struct.id.clock+s.struct.length)continue;if(p!==s.struct.id.client)ga(l,s.struct,s.offset),s={struct:O,offset:0},h.next();else if(s.struct.id.clock+s.struct.length0&&(s.struct.constructor===Er?s.struct.length-=v:O=nhe(O,v)),s.struct.mergeWith(O)||(ga(l,s.struct,s.offset),s={struct:O,offset:0},h.next())}}else s={struct:h.curr,offset:0},h.next();for(let O=h.curr;O!==null&&O.id.client===p&&O.id.clock===s.struct.id.clock+s.struct.length&&O.constructor!==Er;O=h.next())ga(l,s.struct,s.offset),s={struct:O,offset:0}}s!==null&&(ga(l,s.struct,s.offset),s=null),Bk(l);const u=i.map(h=>Zk(h)),f=ow(u);return Ju(o,f),o.toUint8Array()},ihe=(t,e,n=zu,i=Xl)=>{const r=I3(e),s=new i,o=new Vk(s),l=new n(Ua(t)),u=new Xk(l,!1);for(;u.curr;){const h=u.curr,p=h.id.client,O=r.get(p)||0;if(u.curr.constructor===Er){u.next();continue}if(h.id.clock+h.length>O)for(ga(o,h,Ba(O-h.id.clock,0)),u.next();u.curr&&u.curr.id.client===p;)ga(o,u.curr,0),u.next();else for(;u.curr&&u.curr.id.client===p&&u.curr.id.clock+u.curr.length<=O;)u.next()}Bk(o);const f=Zk(l);return Ju(s,f),s.toUint8Array()},W3=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:tn(t.encoder.restEncoder)}),t.encoder.restEncoder=ci(),t.written=0)},ga=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&W3(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Ue(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},Bk=t=>{W3(t);const e=t.encoder.restEncoder;Ue(e,t.clientStructs.length);for(let n=0;n{const r=new n(Ua(t)),s=new Xk(r,!1),o=new i,l=new Vk(o);for(let f=s.curr;f!==null;f=s.next())ga(l,e(f),0);Bk(l);const u=Zk(r);return Ju(o,u),o.toUint8Array()},she=t=>rhe(t,gde,zu,Dh),SA="You must not compute changes after the event-handler fired.";class xy{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=ohe(this.currentTarget,this.target))}deletes(e){return Mh(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ls(SA);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(r=>{if(r!==null){const s=n._map.get(r);let o,l;if(this.adds(s)){let u=s.left;for(;u!==null&&this.adds(u);)u=u.left;if(this.deletes(s))if(u!==null&&this.deletes(u))o="delete",l=eS(u.content.getContent());else return;else u!==null&&this.deletes(u)?(o="update",l=eS(u.content.getContent())):(o="add",l=void 0)}else if(this.deletes(s))o="delete",l=eS(s.content.getContent());else return;e.set(r,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ls(SA);const n=this.target,i=Aa(),r=Aa(),s=[];if(e={added:i,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const u=()=>{l&&s.push(l)};for(let f=n._start;f!==null;f=f.right)f.deleted?this.deletes(f)&&!this.adds(f)&&((l===null||l.delete===void 0)&&(u(),l={delete:0}),l.delete+=f.length,r.add(f)):this.adds(f)?((l===null||l.insert===void 0)&&(u(),l={insert:[]}),l.insert=l.insert.concat(f.content.getContent()),i.add(f)):((l===null||l.retain===void 0)&&(u(),l={retain:0}),l.retain+=f.length);l!==null&&l.retain===void 0&&u()}this._changes=e}return e}}const ohe=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let i=0,r=e._item.parent._start;for(;r!==e._item&&r!==null;)!r.deleted&&r.countable&&(i+=r.length),r=r.right;n.unshift(i)}e=e._item.parent}return n},gi=()=>{A3("Invalid access: Add Yjs type to a document before reading data.")},K3=80;let Uk=0;class ahe{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Uk++}}const lhe=t=>{t.timestamp=Uk++},J3=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Uk++},che=(t,e,n)=>{if(t.length>=K3){const i=t.reduce((r,s)=>r.timestamp{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((s,o)=>sm(e-s.index)e;)i=i.left,!i.deleted&&i.countable&&(r-=i.length);for(;i.left!==null&&i.left.id.client===i.id.client&&i.left.id.clock+i.left.length===i.id.clock;)i=i.left,!i.deleted&&i.countable&&(r-=i.length);return n!==null&&sm(n.index-r){for(let i=t.length-1;i>=0;i--){const r=t[i];if(n>0){let s=r.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(r.index-=s.length);if(s===null||s.marker===!0){t.splice(i,1);continue}r.p=s,s.marker=!0}(e0&&e===r.index)&&(r.index=Ba(e,r.index+n))}},ky=(t,e,n)=>{const i=t,r=e.changedParentTypes;for(;Vs(r,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;V3(i._eH,n,e)};class Vn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=dA(),this._dEH=dA(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw es()}clone(){throw es()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){fA(this._eH,e)}observeDeep(e){fA(this._dEH,e)}unobserve(e){hA(this._eH,e)}unobserveDeep(e){hA(this._dEH,e)}toJSON(){}}const eZ=(t,e,n)=>{t.doc??gi(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let i=n-e;const r=[];let s=t._start;for(;s!==null&&i>0;){if(s.countable&&!s.deleted){const o=s.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l0;l++)r.push(o[l]),i--;e=0}}s=s.right}return r},tZ=t=>{t.doc??gi();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const i=n.content.getContent();for(let r=0;r{let n=0,i=t._start;for(t.doc??gi();i!==null;){if(i.countable&&!i.deleted){const r=i.content.getContent();for(let s=0;s{const n=[];return uh(t,(i,r)=>{n.push(e(i,r,t))}),n},uhe=t=>{let e=t._start,n=null,i=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),i=0,e=e.right}const r=n[i++];return n.length<=i&&(n=null),{done:!1,value:r}}}},iZ=(t,e)=>{t.doc??gi();const n=wy(t,e);let i=t._start;for(n!==null&&(i=n.p,e-=n.index);i!==null;i=i.right)if(!i.deleted&&i.countable){if(e{let r=n;const s=t.doc,o=s.clientID,l=s.store,u=n===null?e._start:n.right;let f=[];const h=()=>{f.length>0&&(r=new Ut(nt(o,Sn(l,o)),r,r&&r.lastId,u,u&&u.id,e,null,new Bl(f)),r.integrate(t,0),f=[])};i.forEach(p=>{if(p===null)f.push(p);else switch(p.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(p);break;default:switch(h(),p.constructor){case Uint8Array:case ArrayBuffer:r=new Ut(nt(o,Sn(l,o)),r,r&&r.lastId,u,u&&u.id,e,null,new Nh(new Uint8Array(p))),r.integrate(t,0);break;case Kl:r=new Ut(nt(o,Sn(l,o)),r,r&&r.lastId,u,u&&u.id,e,null,new zh(p)),r.integrate(t,0);break;default:if(p instanceof Vn)r=new Ut(nt(o,Sn(l,o)),r,r&&r.lastId,u,u&&u.id,e,null,new Us(p)),r.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},rZ=()=>Ls("Length exceeded!"),sZ=(t,e,n,i)=>{if(n>e._length)throw rZ();if(n===0)return e._searchMarker&&ch(e._searchMarker,n,i.length),lO(t,e,null,i);const r=n,s=wy(e,n);let o=e._start;for(s!==null&&(o=s.p,n-=s.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n{let r=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(r)for(;r.right;)r=r.right;return lO(t,e,r,n)},oZ=(t,e,n,i)=>{if(i===0)return;const r=n,s=i,o=wy(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n0&&l!==null;)l.deleted||(i0)throw rZ();e._searchMarker&&ch(e._searchMarker,r,-s+i)},cO=(t,e,n)=>{const i=e._map.get(n);i!==void 0&&i.delete(t)},qk=(t,e,n,i)=>{const r=e._map.get(n)||null,s=t.doc,o=s.clientID;let l;if(i==null)l=new Bl([i]);else switch(i.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Bl([i]);break;case Uint8Array:l=new Nh(i);break;case Kl:l=new zh(i);break;default:if(i instanceof Vn)l=new Us(i);else throw new Error("Unexpected content type")}new Ut(nt(o,Sn(s.store,o)),r,r&&r.lastId,null,null,e,n,l).integrate(t,0)},Yk=(t,e)=>{t.doc??gi();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},aZ=t=>{const e={};return t.doc??gi(),t._map.forEach((n,i)=>{n.deleted||(e[i]=n.content.getContent()[n.length-1])}),e},lZ=(t,e)=>{t.doc??gi();const n=t._map.get(e);return n!==void 0&&!n.deleted},fhe=(t,e)=>{const n={};return t._map.forEach((i,r)=>{let s=i;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&Bc(s,e)&&(n[r]=s.content.getContent()[s.length-1])}),n},Lg=t=>(t.doc??gi(),$fe(t._map.entries(),e=>!e[1].deleted));class hhe extends xy{}class mu extends Vn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new mu;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mu}clone(){const e=new mu;return e.insert(0,this.toArray().map(n=>n instanceof Vn?n.clone():n)),e}get length(){return this.doc??gi(),this._length}_callObserver(e,n){super._callObserver(e,n),ky(this,e,new hhe(this,e))}insert(e,n){this.doc!==null?Bt(this.doc,i=>{sZ(i,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Bt(this.doc,n=>{dhe(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Bt(this.doc,i=>{oZ(i,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return iZ(this,e)}toArray(){return tZ(this)}slice(e=0,n=this.length){return eZ(this,e,n)}toJSON(){return this.map(e=>e instanceof Vn?e.toJSON():e)}map(e){return nZ(this,e)}forEach(e){uh(this,e)}[Symbol.iterator](){return uhe(this)}_write(e){e.writeTypeRef(zhe)}}const phe=t=>new mu;class ghe extends xy{constructor(e,n,i){super(e,n),this.keysChanged=i}}class Lu extends Vn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((i,r)=>{this.set(r,i)}),this._prelimContent=null}_copy(){return new Lu}clone(){const e=new Lu;return this.forEach((n,i)=>{e.set(i,n instanceof Vn?n.clone():n)}),e}_callObserver(e,n){ky(this,e,new ghe(this,e,n))}toJSON(){this.doc??gi();const e={};return this._map.forEach((n,i)=>{if(!n.deleted){const r=n.content.getContent()[n.length-1];e[i]=r instanceof Vn?r.toJSON():r}}),e}get size(){return[...Lg(this)].length}keys(){return lS(Lg(this),e=>e[0])}values(){return lS(Lg(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return lS(Lg(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??gi(),this._map.forEach((n,i)=>{n.deleted||e(n.content.getContent()[n.length-1],i,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Bt(this.doc,n=>{cO(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Bt(this.doc,i=>{qk(i,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return Yk(this,e)}has(e){return lZ(this,e)}clear(){this.doc!==null?Bt(this.doc,e=>{this.forEach(function(n,i,r){cO(e,r,i)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Lhe)}}const mhe=t=>new Lu,va=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&hde(t,e);class uw{constructor(e,n,i,r){this.left=e,this.right=n,this.index=i,this.currentAttributes=r}forward(){this.right===null&&dr(),this.right.content.constructor===Nn?this.right.deleted||ed(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const xA=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===Nn?e.right.deleted||ed(e.currentAttributes,e.right.content):e.right.deleted||(n{const r=new Map,s=i?wy(e,n):null;if(s){const o=new uw(s.p.left,s.p,s.index,r);return xA(t,o,n-s.index)}else{const o=new uw(null,e._start,0,r);return xA(t,o,n)}},cZ=(t,e,n,i)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Nn&&va(i.get(n.right.content.key),n.right.content.value));)n.right.deleted||i.delete(n.right.content.key),n.forward();const r=t.doc,s=r.clientID;i.forEach((o,l)=>{const u=n.left,f=n.right,h=new Ut(nt(s,Sn(r.store,s)),u,u&&u.lastId,f,f&&f.id,e,null,new Nn(l,o));h.integrate(t,0),n.right=h,n.forward()})},ed=(t,e)=>{const{key:n,value:i}=e;i===null?t.delete(n):t.set(n,i)},uZ=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Nn&&va(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},dZ=(t,e,n,i)=>{const r=t.doc,s=r.clientID,o=new Map;for(const l in i){const u=i[l],f=n.currentAttributes.get(l)??null;if(!va(f,u)){o.set(l,f);const{left:h,right:p}=n;n.right=new Ut(nt(s,Sn(r.store,s)),h,h&&h.lastId,p,p&&p.id,e,null,new Nn(l,u)),n.right.integrate(t,0),n.forward()}}return o},cS=(t,e,n,i,r)=>{n.currentAttributes.forEach((O,y)=>{r[y]===void 0&&(r[y]=null)});const s=t.doc,o=s.clientID;uZ(n,r);const l=dZ(t,e,n,r),u=i.constructor===String?new Is(i):i instanceof Vn?new Us(i):new Jl(i);let{left:f,right:h,index:p}=n;e._searchMarker&&ch(e._searchMarker,n.index,u.getLength()),h=new Ut(nt(o,Sn(s.store,o)),f,f&&f.lastId,h,h&&h.id,e,null,u),h.integrate(t,0),n.right=h,n.index=p,n.forward(),cZ(t,e,n,l)},wA=(t,e,n,i,r)=>{const s=t.doc,o=s.clientID;uZ(n,r);const l=dZ(t,e,n,r);e:for(;n.right!==null&&(i>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Nn));){if(!n.right.deleted)switch(n.right.content.constructor){case Nn:{const{key:u,value:f}=n.right.content,h=r[u];if(h!==void 0){if(va(h,f))l.delete(u);else{if(i===0)break e;l.set(u,f)}n.right.delete(t)}else n.currentAttributes.set(u,f);break}default:i0){let u="";for(;i>0;i--)u+=` -`;n.right=new Ut(nt(o,Sn(s.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Is(u)),n.right.integrate(t,0),n.forward()}cZ(t,e,n,l)},fZ=(t,e,n,i,r)=>{let s=e;const o=qi();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===Nn){const f=s.content;o.set(f.key,f)}s=s.right}let l=0,u=!1;for(;e!==s;){if(n===e&&(u=!0),!e.deleted){const f=e.content;if(f.constructor===Nn){const{key:h,value:p}=f,O=i.get(h)??null;(o.get(h)!==f||O===p)&&(e.delete(t),l++,!u&&(r.get(h)??null)===p&&O!==p&&(O===null?r.delete(h):r.set(h,O))),!u&&!e.deleted&&ed(r,f)}}e=e.right}return l},Ohe=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Nn){const i=e.content.key;n.has(i)?e.delete(t):n.add(i)}e=e.left}},yhe=t=>{let e=0;return Bt(t.doc,n=>{let i=t._start,r=t._start,s=qi();const o=ew(s);for(;r;)r.deleted===!1&&(r.content.constructor===Nn?ed(o,r.content):(e+=fZ(n,i,r,s,o),s=ew(o),i=r)),r=r.right}),e},vhe=t=>{const e=new Set,n=t.doc;for(const[i,r]of t.afterState.entries()){const s=t.beforeState.get(i)||0;r!==s&&F3(t,n.store.clients.get(i),s,r,o=>{!o.deleted&&o.content.constructor===Nn&&o.constructor!==Tr&&e.add(o.parent)})}Bt(n,i=>{Nu(t,t.deleteSet,r=>{if(r instanceof Tr||!r.parent._hasFormatting||e.has(r.parent))return;const s=r.parent;r.content.constructor===Nn?e.add(s):Ohe(i,r)});for(const r of e)yhe(r)})},kA=(t,e,n)=>{const i=n,r=ew(e.currentAttributes),s=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Us:case Jl:case Is:n{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];Bt(e,i=>{const r=new Map,s=new Map;let o=this.target._start,l=null;const u={};let f="",h=0,p=0;const O=()=>{if(l!==null){let y=null;switch(l){case"delete":p>0&&(y={delete:p}),p=0;break;case"insert":(typeof f=="object"||f.length>0)&&(y={insert:f},r.size>0&&(y.attributes={},r.forEach((v,S)=>{v!==null&&(y.attributes[S]=v)}))),f="";break;case"retain":h>0&&(y={retain:h},fde(u)||(y.attributes=lde({},u))),h=0;break}y&&n.push(y),l=null}};for(;o!==null;){switch(o.content.constructor){case Us:case Jl:this.adds(o)?this.deletes(o)||(O(),l="insert",f=o.content.getContent()[0],O()):this.deletes(o)?(l!=="delete"&&(O(),l="delete"),p+=1):o.deleted||(l!=="retain"&&(O(),l="retain"),h+=1);break;case Is:this.adds(o)?this.deletes(o)||(l!=="insert"&&(O(),l="insert"),f+=o.content.str):this.deletes(o)?(l!=="delete"&&(O(),l="delete"),p+=o.length):o.deleted||(l!=="retain"&&(O(),l="retain"),h+=o.length);break;case Nn:{const{key:y,value:v}=o.content;if(this.adds(o)){if(!this.deletes(o)){const S=r.get(y)??null;va(S,v)?v!==null&&o.delete(i):(l==="retain"&&O(),va(v,s.get(y)??null)?delete u[y]:u[y]=v)}}else if(this.deletes(o)){s.set(y,v);const S=r.get(y)??null;va(S,v)||(l==="retain"&&O(),u[y]=S)}else if(!o.deleted){s.set(y,v);const S=u[y];S!==void 0&&(va(S,v)?S!==null&&o.delete(i):(l==="retain"&&O(),v===null?delete u[y]:u[y]=v))}o.deleted||(l==="insert"&&O(),ed(r,o.content));break}}o=o.right}for(O();n.length>0;){const y=n[n.length-1];if(y.retain!==void 0&&y.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class Zu extends Vn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??gi(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(i=>i())}catch(i){console.error(i)}this._pending=null}_copy(){return new Zu}clone(){const e=new Zu;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const i=new bhe(this,e,n);ky(this,e,i),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??gi();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Is&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Bt(this.doc,i=>{const r=new uw(null,this._start,0,new Map);for(let s=0;s0)&&cS(i,this,r,l,o.attributes||{})}else o.retain!==void 0?wA(i,this,r,o.retain,o.attributes||{}):o.delete!==void 0&&kA(i,r,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,i){this.doc??gi();const r=[],s=new Map,o=this.doc;let l="",u=this._start;function f(){if(l.length>0){const p={};let O=!1;s.forEach((v,S)=>{O=!0,p[S]=v});const y={insert:l};O&&(y.attributes=p),r.push(y),l=""}}const h=()=>{for(;u!==null;){if(Bc(u,e)||n!==void 0&&Bc(u,n))switch(u.content.constructor){case Is:{const p=s.get("ychange");e!==void 0&&!Bc(u,e)?(p===void 0||p.user!==u.id.client||p.type!=="removed")&&(f(),s.set("ychange",i?i("removed",u.id):{type:"removed"})):n!==void 0&&!Bc(u,n)?(p===void 0||p.user!==u.id.client||p.type!=="added")&&(f(),s.set("ychange",i?i("added",u.id):{type:"added"})):p!==void 0&&(f(),s.delete("ychange")),l+=u.content.str;break}case Us:case Jl:{f();const p={insert:u.content.getContent()[0]};if(s.size>0){const O={};p.attributes=O,s.forEach((y,v)=>{O[v]=y})}r.push(p);break}case Nn:Bc(u,e)&&(f(),ed(s,u.content));break}u=u.right}f()};return e||n?Bt(o,p=>{e&&lw(p,e),n&&lw(p,n),h()},"cleanup"):h(),r}insert(e,n,i){if(n.length<=0)return;const r=this.doc;r!==null?Bt(r,s=>{const o=Zg(s,this,e,!i);i||(i={},o.currentAttributes.forEach((l,u)=>{i[u]=l})),cS(s,this,o,n,i)}):this._pending.push(()=>this.insert(e,n,i))}insertEmbed(e,n,i){const r=this.doc;r!==null?Bt(r,s=>{const o=Zg(s,this,e,!i);cS(s,this,o,n,i||{})}):this._pending.push(()=>this.insertEmbed(e,n,i||{}))}delete(e,n){if(n===0)return;const i=this.doc;i!==null?Bt(i,r=>{kA(r,Zg(r,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,i){if(n===0)return;const r=this.doc;r!==null?Bt(r,s=>{const o=Zg(s,this,e,!1);o.right!==null&&wA(s,this,o,n,i)}):this._pending.push(()=>this.format(e,n,i))}removeAttribute(e){this.doc!==null?Bt(this.doc,n=>{cO(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Bt(this.doc,i=>{qk(i,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return Yk(this,e)}getAttributes(){return aZ(this)}_write(e){e.writeTypeRef(Zhe)}}const She=t=>new Zu;class uS{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??gi()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===Iu||n.constructor===Vl)&&n._start!==null)e=n._start;else for(;e!==null;){const i=e.next;if(i!==null){e=i;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Vl extends Vn{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Vl}clone(){const e=new Vl;return e.insert(0,this.toArray().map(n=>n instanceof Vn?n.clone():n)),e}get length(){return this.doc??gi(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new uS(this,e)}querySelector(e){e=e.toUpperCase();const i=new uS(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e).next();return i.done?null:i.value}querySelectorAll(e){return e=e.toUpperCase(),Ro(new uS(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){ky(this,e,new khe(this,n,e))}toString(){return nZ(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},i){const r=e.createDocumentFragment();return i!==void 0&&i._createAssociation(r,this),uh(this,s=>{r.insertBefore(s.toDOM(e,n,i),null)}),r}insert(e,n){this.doc!==null?Bt(this.doc,i=>{sZ(i,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Bt(this.doc,i=>{const r=e&&e instanceof Vn?e._item:e;lO(i,this,r,n)});else{const i=this._prelimContent,r=e===null?0:i.findIndex(s=>s===e)+1;if(r===0&&e!==null)throw Ls("Reference item not found");i.splice(r,0,...n)}}delete(e,n=1){this.doc!==null?Bt(this.doc,i=>{oZ(i,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return tZ(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return iZ(this,e)}slice(e=0,n=this.length){return eZ(this,e,n)}forEach(e){uh(this,e)}_write(e){e.writeTypeRef(Xhe)}}const xhe=t=>new Vl;class Iu extends Vl{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((i,r)=>{this.setAttribute(r,i)}),this._prelimAttrs=null}_copy(){return new Iu(this.nodeName)}clone(){const e=new Iu(this.nodeName),n=this.getAttributes();return ude(n,(i,r)=>{e.setAttribute(r,i)}),e.insert(0,this.toArray().map(i=>i instanceof Vn?i.clone():i)),e}toString(){const e=this.getAttributes(),n=[],i=[];for(const l in e)i.push(l);i.sort();const r=i.length;for(let l=0;l0?" "+n.join(" "):"";return`<${s}${o}>${super.toString()}`}removeAttribute(e){this.doc!==null?Bt(this.doc,n=>{cO(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Bt(this.doc,i=>{qk(i,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return Yk(this,e)}hasAttribute(e){return lZ(this,e)}getAttributes(e){return e?fhe(this,e):aZ(this)}toDOM(e=document,n={},i){const r=e.createElement(this.nodeName),s=this.getAttributes();for(const o in s){const l=s[o];typeof l=="string"&&r.setAttribute(o,l)}return uh(this,o=>{r.appendChild(o.toDOM(e,n,i))}),i!==void 0&&i._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ihe),e.writeKey(this.nodeName)}}const whe=t=>new Iu(t.readKey());class khe extends xy{constructor(e,n,i){super(e,i),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}}class uO extends Lu{constructor(e){super(),this.hookName=e}_copy(){return new uO(this.hookName)}clone(){const e=new uO(this.hookName);return this.forEach((n,i)=>{e.set(i,n)}),e}toDOM(e=document,n={},i){const r=n[this.hookName];let s;return r!==void 0?s=r.createDom(this):s=document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),i!==void 0&&i._createAssociation(s,this),s}_write(e){e.writeTypeRef(Vhe),e.writeKey(this.hookName)}}const Che=t=>new uO(t.readKey());class dO extends Zu{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new dO}clone(){const e=new dO;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,i){const r=e.createTextNode(this.toString());return i!==void 0&&i._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{const n=[];for(const r in e.attributes){const s=[];for(const o in e.attributes[r])s.push({key:o,value:e.attributes[r][o]});s.sort((o,l)=>o.keyr.nodeName=0;r--)i+=``;return i}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Bhe)}}const _he=t=>new dO;class Fk{constructor(e,n){this.id=e,this.length=n}get deleted(){throw es()}mergeWith(e){return!1}write(e,n,i){throw es()}integrate(e,n){throw es()}}const $he=0;class Tr extends Fk{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),Y3(e.doc.store,this)}write(e,n){e.writeInfo($he),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Nh{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Nh(this.content)}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const The=t=>new Nh(t.readBuf());class dh{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new dh(this.len)}splice(e){const n=new dh(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){sh(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const Ehe=t=>new dh(t.readLen()),hZ=(t,e)=>new Kl({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class zh{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new zh(hZ(this.doc.guid,this.opts))}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const Rhe=t=>new zh(hZ(t.readString(),t.readAny()));class Jl{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Jl(this.embed)}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const Qhe=t=>new Jl(t.readJSON());class Nn{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Nn(this.key,this.value)}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){const i=n.parent;i._searchMarker=null,i._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const Ahe=t=>new Nn(t.readKey(),t.readJSON());class fO{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new fO(this.arr)}splice(e){const n=new fO(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const i=this.arr.length;e.writeLen(i-n);for(let r=n;r{const e=t.readLen(),n=[];for(let i=0;i{const e=t.readLen(),n=[];for(let i=0;i=55296&&i<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const Dhe=t=>new Is(t.readString()),Nhe=[phe,mhe,She,whe,xhe,Che,_he],zhe=0,Lhe=1,Zhe=2,Ihe=3,Xhe=4,Vhe=5,Bhe=6;class Us{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Us(this.type._copy())}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(i=>{i.deleted?i.id.clock<(e.beforeState.get(i.id.client)||0)&&e._mergeStructs.push(i):i.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(i=>{for(;i!==null;)i.gc(e,!0),i=i.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const Uhe=t=>new Us(Nhe[t.readTypeRef()](t)),dw=(t,e)=>{let n=e,i=0,r;do i>0&&(n=nt(n.client,n.clock+i)),r=gu(t,n),i=n.clock-r.id.clock,n=r.redone;while(n!==null&&r instanceof Ut);return{item:r,diff:i}},Gk=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},hO=(t,e,n)=>{const{client:i,clock:r}=e.id,s=new Ut(nt(i,r+n),e,nt(i,r+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=nt(e.redone.client,e.redone.clock+n)),e.right=s,s.right!==null&&(s.right.left=s),t._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=n,s},CA=(t,e)=>wk(t,n=>Mh(n.deletions,e)),pZ=(t,e,n,i,r,s)=>{const o=t.doc,l=o.store,u=o.clientID,f=e.redone;if(f!==null)return Xi(t,f);let h=e.parent._item,p=null,O;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||pZ(t,h,n,i,r,s)===null))return null;for(;h.redone!==null;)h=Xi(t,h.redone)}const y=h===null?e.parent:h.content.type;if(e.parentSub===null){for(p=e.left,O=e;p!==null;){let C=p;for(;C!==null&&C.parent._item!==h;)C=C.redone===null?null:Xi(t,C.redone);if(C!==null&&C.parent._item===h){p=C;break}p=p.left}for(;O!==null;){let C=O;for(;C!==null&&C.parent._item!==h;)C=C.redone===null?null:Xi(t,C.redone);if(C!==null&&C.parent._item===h){O=C;break}O=O.right}}else{if(O=null,e.right&&!r){for(p=e;p!==null&&p.right!==null&&(p.right.redone||Mh(i,p.right.id)||CA(s.undoStack,p.right.id)||CA(s.redoStack,p.right.id));)for(p=p.right;p.redone;)p=Xi(t,p.redone);if(p&&p.right!==null)return null}else p=y._map.get(e.parentSub)||null;p!==null&&p.parent._item!==h&&(p=y._map.get(e.parentSub)||null)}const v=Sn(l,u),S=nt(u,v),k=new Ut(S,p,p&&p.lastId,O,O&&O.id,y,e.parentSub,e.content.copy());return e.redone=S,Gk(k,!0),k.integrate(t,0),k};class Ut extends Fk{constructor(e,n,i,r,s,o,l,u){super(e,u.getLength()),this.origin=i,this.left=n,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=l,this.redone=null,this.content=u,this.info=this.content.isCountable()?KQ:0}set marker(e){(this.info&nS)>0!==e&&(this.info^=nS)}get marker(){return(this.info&nS)>0}get keep(){return(this.info&WQ)>0}set keep(e){this.keep!==e&&(this.info^=WQ)}get countable(){return(this.info&KQ)>0}get deleted(){return(this.info&tS)>0}set deleted(e){this.deleted!==e&&(this.info^=tS)}markDeleted(){this.info|=tS}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Sn(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Sn(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===pu&&this.id.client!==this.parent.client&&this.parent.clock>=Sn(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=mA(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Xi(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Tr||this.right&&this.right.constructor===Tr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Ut?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Ut&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===pu){const i=gu(n,this.parent);i.constructor===Tr?this.parent=null:this.parent=i.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=mA(e,e.doc.store,nt(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let i=this.left,r;if(i!==null)r=i.right;else if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start;const s=new Set,o=new Set;for(;r!==null&&r!==this.right;){if(o.add(r),s.add(r),eu(this.origin,r.origin)){if(r.id.client{i.p===e&&(i.p=this,!this.deleted&&this.countable&&(i.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),sh(e.deleteSet,this.id.client,this.id.clock,this.length),yA(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw dr();this.content.gc(e),n?Gfe(e,this,new Tr(this.id,this.length)):this.content=new dh(this.length)}write(e,n){const i=n>0?nt(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&fy|(i===null?0:cr)|(r===null?0:_o)|(s===null?0:Jf);if(e.writeInfo(o),i!==null&&e.writeLeftID(i),r!==null&&e.writeRightID(r),i===null&&r===null){const l=this.parent;if(l._item!==void 0){const u=l._item;if(u===null){const f=B3(l);e.writeParentInfo(!0),e.writeString(f)}else e.writeParentInfo(!1),e.writeLeftID(u.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===pu?(e.writeParentInfo(!1),e.writeLeftID(l)):dr();s!==null&&e.writeString(s)}this.content.write(e,n)}}const gZ=(t,e)=>qhe[e&fy](t),qhe=[()=>{dr()},Ehe,Phe,The,Dhe,Qhe,Ahe,Uhe,Mhe,Rhe,()=>{dr()}],Yhe=10;class Er extends Fk{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){dr()}write(e,n){e.writeInfo(Yhe),Ue(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const mZ=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},OZ="__ $YJS$ __";mZ[OZ]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");mZ[OZ]=!0;class Hk{constructor(e,n){this.yanchor=e,this.yhead=n}toJSON(){return{yanchor:pA(this.yanchor),yhead:pA(this.yhead)}}static fromJSON(e){return new Hk(oh(e.yanchor),oh(e.yhead))}}class Fhe{constructor(e,n){this.ytext=e,this.awareness=n}toYPos(e,n=0){return ah(this.ytext,e,n)}fromYPos(e){const n=lh(oh(e),this.ytext.doc);if(n==null||n.type!==this.ytext)throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");return{pos:n.index,assoc:n.assoc}}toYRange(e){const n=e.assoc,i=this.toYPos(e.anchor,n),r=this.toYPos(e.head,n);return new Hk(i,r)}fromYRange(e){const n=this.fromYPos(e.yanchor),i=this.fromYPos(e.yhead);return n.pos===i.pos?Oe.cursor(i.pos,i.assoc):Oe.range(n.pos,i.pos)}}const Cy=Ne.define({combine(t){return t[t.length-1]}}),fw=ss.define();class Ghe{constructor(e){this.view=e,this.conf=e.state.facet(Cy),this._observer=(n,i)=>{if(i.origin!==this.conf){const r=n.delta,s=[];let o=0;for(let l=0;l0&&e.transactions[0].annotation(fw)===this.conf)return;const n=this.conf.ytext;n.doc.transact(()=>{let i=0;e.changes.iterChanges((r,s,o,l,u)=>{const f=u.sliceString(0,u.length,` -`);r!==s&&n.delete(r+i,s-r),f.length>0&&n.insert(r+i,f),i+=f.length-(s-r)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}}const Hhe=Dr.fromClass(Ghe),Whe=Le.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:"0px 2px 0px 4px"},".cm-ySelectionCaret":{position:"relative",borderLeft:"1px solid black",borderRight:"1px solid black",marginLeft:"-1px",marginRight:"-1px",boxSizing:"border-box",display:"inline"},".cm-ySelectionCaretDot":{borderRadius:"50%",position:"absolute",width:".4em",height:".4em",top:"-.2em",left:"-.2em",backgroundColor:"inherit",transition:"transform .3s ease-in-out",boxSizing:"border-box"},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:"bottom center",transform:"scale(0)"},".cm-ySelectionInfo":{position:"absolute",top:"-1.05em",left:"-1px",fontSize:".75em",fontFamily:"serif",fontStyle:"normal",fontWeight:"normal",lineHeight:"normal",userSelect:"none",color:"white",paddingLeft:"2px",paddingRight:"2px",zIndex:101,transition:"opacity .3s ease-in-out",backgroundColor:"inherit",opacity:0,transitionDelay:"0s",whiteSpace:"nowrap"},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:"0s"}}),Khe=ss.define();class Jhe extends Yu{constructor(e,n){super(),this.color=e,this.name=n}toDOM(){return aS("span",[rr("class","cm-ySelectionCaret"),rr("style",`background-color: ${this.color}; border-color: ${this.color}`)],[Ng("⁠"),aS("div",[rr("class","cm-ySelectionCaretDot")]),Ng("⁠"),aS("div",[rr("class","cm-ySelectionInfo")],[Ng(this.name)]),Ng("⁠")])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}}class epe{constructor(e){this.conf=e.state.facet(Cy),this._listener=({added:n,updated:i,removed:r},s,o)=>{n.concat(i).concat(r).findIndex(u=>u!==this.conf.awareness.doc.clientID)>=0&&e.dispatch({annotations:[Khe.of([])]})},this._awareness=this.conf.awareness,this._awareness.on("change",this._listener),this.decorations=mt.of([])}destroy(){this._awareness.off("change",this._listener)}update(e){const n=this.conf.ytext,i=n.doc,r=this.conf.awareness,s=[],o=this.conf.awareness.getLocalState();if(o!=null){const l=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),u=l?e.state.selection.main:null,f=o.cursor==null?null:oh(o.cursor.anchor),h=o.cursor==null?null:oh(o.cursor.head);if(u!=null){const p=ah(n,u.anchor),O=ah(n,u.head);(o.cursor==null||!gA(f,p)||!gA(h,O))&&r.setLocalStateField("cursor",{anchor:p,head:O})}else o.cursor!=null&&l&&r.setLocalStateField("cursor",null)}r.getStates().forEach((l,u)=>{if(u===r.doc.clientID)return;const f=l.cursor;if(f==null||f.anchor==null||f.head==null)return;const h=lh(f.anchor,i),p=lh(f.head,i);if(h==null||p==null||h.type!==n||p.type!==n)return;const{color:O="#30bced",name:y="Anonymous"}=l.user||{},v=l.user&&l.user.colorLight||O+"33",S=dy(h.index,p.index),k=Ba(h.index,p.index),C=e.view.state.doc.lineAt(S),$=e.view.state.doc.lineAt(k);if(C.number===$.number)s.push({from:S,to:k,value:Tt.mark({attributes:{style:`background-color: ${v}`},class:"cm-ySelection"})});else{s.push({from:S,to:C.from+C.length,value:Tt.mark({attributes:{style:`background-color: ${v}`},class:"cm-ySelection"})}),s.push({from:$.from,to:k,value:Tt.mark({attributes:{style:`background-color: ${v}`},class:"cm-ySelection"})});for(let T=C.number+1;T<$.number;T++){const Q=e.view.state.doc.line(T).from;s.push({from:Q,to:Q,value:Tt.line({attributes:{style:`background-color: ${v}`,class:"cm-yLineSelection"}})})}}s.push({from:p.index,to:p.index,value:Tt.widget({side:p.index-h.index>0?-1:1,block:!1,widget:new Jhe(O,y)})})}),this.decorations=Tt.set(s,!0)}}const tpe=Dr.fromClass(epe,{decorations:t=>t.decorations});class npe{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}}const _y=Ne.define({combine(t){return t[t.length-1]}});class ipe{constructor(e){this.view=e,this.conf=e.state.facet(_y),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(Cy),this._beforeChangeSelection=null,this._onStackItemAdded=({stackItem:n,changedParentTypes:i})=>{i.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!n.meta.has(this)&&n.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:n})=>{const i=n.meta.get(this);if(i){const r=this.syncConf.fromYRange(i);e.dispatch(e.state.update({selection:r,effects:[Le.scrollIntoView(r)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on("stack-item-added",this._onStackItemAdded),this._undoManager.on("stack-item-popped",this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){e.selectionSet&&(e.transactions.length===0||e.transactions[0].annotation(fw)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off("stack-item-added",this._onStackItemAdded),this._undoManager.off("stack-item-popped",this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}}const rpe=Dr.fromClass(ipe),spe=({state:t,dispatch:e})=>t.facet(_y).undo()||!0,ope=({state:t,dispatch:e})=>t.facet(_y).redo()||!0,ape=(t,e,{undoManager:n=new ehe(t)}={})=>{const i=new Fhe(t,e),r=[Cy.of(i),Hhe];return e&&r.push(Whe,tpe),n!==!1&&r.push(_y.of(new npe(n)),rpe,Le.domEventHandlers({beforeinput(s,o){return s.inputType==="historyUndo"?spe(o):s.inputType==="historyRedo"?ope(o):!1}})),r},yZ=new Map;class lpe{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:Tde(n.newValue||"")}),sde(this._onChange)}postMessage(e){r3.setItem(this.room,$de(xde(e)))}close(){ode(this._onChange)}}const cpe=typeof BroadcastChannel>"u"?lpe:BroadcastChannel,Wk=t=>Vs(yZ,t,()=>{const e=Aa(),n=new cpe(t);return n.onmessage=i=>e.forEach(r=>r(i.data,"broadcastchannel")),{bc:n,subs:e}}),upe=(t,e)=>(Wk(t).subs.add(e),e),dpe=(t,e)=>{const n=Wk(t),i=n.subs.delete(e);return i&&n.subs.size===0&&(n.bc.close(),yZ.delete(t)),i},Uc=(t,e,n=null)=>{const i=Wk(t);i.bc.postMessage(e),i.subs.forEach(r=>r(e,n))},vZ=0,Kk=1,bZ=2,hw=(t,e)=>{Ue(t,vZ);const n=Vfe(e);yn(t,n)},SZ=(t,e,n)=>{Ue(t,Kk),yn(t,Lfe(e,n))},fpe=(t,e,n)=>SZ(e,n,li(t)),xZ=(t,e,n,i)=>{try{aw(e,li(t),n)}catch(r){i?.(r),console.error("Caught error while handling a Yjs update",r)}},hpe=(t,e)=>{Ue(t,bZ),yn(t,e)},ppe=xZ,gpe=(t,e,n,i,r)=>{const s=et(t);switch(s){case vZ:fpe(t,e,n);break;case Kk:xZ(t,n,i,r);break;case bZ:ppe(t,n,i,r);break;default:throw new Error("Unknown message type")}return s},mpe=0,Ope=(t,e,n)=>{et(t)===mpe&&n(e,xa(t))},dS=3e4;class wZ extends Cue{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=Pa();this.getLocalState()!==null&&dS/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const i=[];this.meta.forEach((r,s)=>{s!==this.clientID&&dS<=n-r.lastUpdated&&this.states.has(s)&&i.push(s)}),i.length>0&&Jk(this,i,"timeout")},ns(dS/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const n=this.clientID,i=this.meta.get(n),r=i===void 0?0:i.clock+1,s=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:r,lastUpdated:Pa()});const o=[],l=[],u=[],f=[];e===null?f.push(n):s==null?e!=null&&o.push(n):(l.push(n),fu(s,e)||u.push(n)),(o.length>0||u.length>0||f.length>0)&&this.emit("change",[{added:o,updated:u,removed:f},"local"]),this.emit("update",[{added:o,updated:l,removed:f},"local"])}setLocalStateField(e,n){const i=this.getLocalState();i!==null&&this.setLocalState({...i,[e]:n})}getStates(){return this.states}}const Jk=(t,e,n)=>{const i=[];for(let r=0;r0&&(t.emit("change",[{added:[],updated:[],removed:i},n]),t.emit("update",[{added:[],updated:[],removed:i},n]))},Ou=(t,e,n=t.states)=>{const i=e.length,r=ci();Ue(r,i);for(let s=0;s{const i=Ua(e),r=Pa(),s=[],o=[],l=[],u=[],f=et(i);for(let h=0;h0||l.length>0||u.length>0)&&t.emit("change",[{added:s,updated:l,removed:u},n]),(s.length>0||o.length>0||u.length>0)&&t.emit("update",[{added:s,updated:o,removed:u},n])},ype=t=>dde(t,(e,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(e)}`).join("&"),wl=0,CZ=3,yu=1,vpe=2,Lh=[];Lh[wl]=(t,e,n,i,r)=>{Ue(t,wl);const s=gpe(e,t,n.doc,n);i&&s===Kk&&!n.synced&&(n.synced=!0)};Lh[CZ]=(t,e,n,i,r)=>{Ue(t,yu),yn(t,Ou(n.awareness,Array.from(n.awareness.getStates().keys())))};Lh[yu]=(t,e,n,i,r)=>{kZ(n.awareness,li(e),n)};Lh[vpe]=(t,e,n,i,r)=>{Ope(e,n.doc,(s,o)=>bpe(n,o))};const _A=3e4,bpe=(t,e)=>console.warn(`Permission denied to access ${t.url}. -${e}`),_Z=(t,e,n)=>{const i=Ua(e),r=ci(),s=et(i),o=t.messageHandlers[s];return o?o(r,i,t,n,s):console.error("Unable to compute message"),r},Spe=t=>!(t.code>=4400&&t.code<4500),pw=(t,e,n)=>{if(e!==null&&e===t.ws){t.emit("connection-close",[n,t]),t.ws=null,e.onmessage=null,e.onopen=null,e.onclose=null,e.onerror=()=>{},e.close(),t.wsconnecting=!1,t.wsconnected&&(t.wsconnected=!1,t.synced=!1,Jk(t.awareness,Array.from(t.awareness.getStates().keys()).filter(r=>r!==t.doc.clientID),t),t.emit("status",[{status:"disconnected"}])),t.wsUnsuccessfulReconnects++;let i=null;n!=null&&!t.shouldReconnect(n,t)&&(t.shouldConnect=!1,i={code:n.code,reason:n.reason}),setTimeout($Z,dy(_ue(2,t.wsUnsuccessfulReconnects)*100,t.maxBackoffTime),t),i!==null&&t.emit("closed",[i,t])}},$Z=t=>{if(t.shouldConnect&&t.ws===null){const e=new t._WS(t.url,t.protocols);e.binaryType="arraybuffer",t.ws=e,t.wsconnecting=!0,t.wsconnected=!1,t.synced=!1,e.onmessage=n=>{if(t.ws!==e)return;t.wsLastMessageReceived=Pa();const i=_Z(t,new Uint8Array(n.data),!0);Ck(i)>1&&e.send(tn(i))},e.onerror=n=>{t.ws===e&&t.emit("connection-error",[n,t])},e.onclose=n=>{pw(t,e,n)},e.onopen=()=>{if(t.ws!==e)return;t.wsLastMessageReceived=Pa(),t.wsconnecting=!1,t.wsconnected=!0,t.emit("status",[{status:"connected"}]);const n=ci();if(Ue(n,wl),hw(n,t.doc),e.send(tn(n)),t.awareness.getLocalState()!==null){const i=ci();Ue(i,yu),yn(i,Ou(t.awareness,[t.doc.clientID])),e.send(tn(i))}},t.emit("status",[{status:"connecting"}])}},fS=(t,e)=>{const n=t.ws;t.wsconnected&&n&&n.readyState===n.OPEN&&n.send(e),t.bcconnected&&Uc(t.bcChannel,e,t)};class xpe extends kk{constructor(e,n,i,{connect:r=!0,awareness:s=new wZ(i),params:o={},protocols:l=[],WebSocketPolyfill:u=WebSocket,resyncInterval:f=-1,maxBackoffTime:h=2500,disableBc:p=!1,shouldReconnect:O=Spe}={}){for(super();e[e.length-1]==="/";)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+n,this.maxBackoffTime=h,this.shouldReconnect=O,this.params=o,this.protocols=l,this.roomname=n,this.doc=i,this._WS=u,this.awareness=s,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=p,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Lh.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,f>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const y=ci();Ue(y,wl),hw(y,i),this.ws.send(tn(y))}},f)),this._bcSubscriber=(y,v)=>{if(v!==this){const S=_Z(this,new Uint8Array(y),!1);Ck(S)>1&&Uc(this.bcChannel,tn(S),this)}},this._updateHandler=(y,v)=>{if(v!==this){const S=ci();Ue(S,wl),hpe(S,y),fS(this,tn(S))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:y,updated:v,removed:S},k)=>{const C=y.concat(v).concat(S),$=ci();Ue($,yu),yn($,Ou(s,C)),fS(this,tn($))},this._exitHandler=()=>{Jk(this.awareness,[i.clientID],"app closed")},ja&&typeof process<"u"&&process.on("exit",this._exitHandler),s.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&_A{this.held||this.applying||(this.pending.push(u),this.timer||(this.timer=setTimeout(()=>this.flush(),$A)))})}url;seedText;onStatus;onSeeded;onUnavailable;me;held;doc=new Kl;text;awareness;es=null;pending=[];timer=null;closed=!1;cursorTimer=null;sending=!1;announced=!1;everConnected=!1;applying=!1;cid=globalThis.crypto?.randomUUID?.()??String(Math.random()).slice(2);ws=null;onAwareness=({added:e,updated:n,removed:i})=>{const r=e.concat(n,i);!r.length||this.closed||r.includes(this.doc.clientID)&&(this.cursorTimer||(this.cursorTimer=setTimeout(()=>{this.cursorTimer=null,this.publishAwareness()},wpe)))};publishAwareness(e=!1){if(this.closed||this.held||!e&&this.announced&&this.awareness.getStates().size<=1)return;this.announced=!0;const n=Ou(this.awareness,[this.doc.clientID]);fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({awareness:TA(n),cid:this.cid})}).catch(()=>{})}connectHeld(){const e=new URL(this.url,location.href),n=e.searchParams.get("path")??"",i=(e.protocol==="https:"?"wss://":"ws://")+e.host+e.pathname,r=new xpe(i,"held",this.doc,{params:{path:n},awareness:this.awareness,connect:!0});this.ws=r,r.on("status",s=>{this.onStatus(s.status==="connected"?"live":"offline")}),r.on("sync",s=>{s&&this.onSeeded()})}connect(){if(this.onStatus("connecting"),this.held)return this.connectHeld();const e=new EventSource(this.url+(this.url.includes("?")?"&":"?")+"cid="+this.cid);this.es=e,e.onmessage=n=>{let i;try{i=JSON.parse(n.data)}catch{return}if(i.type==="hello"){this.everConnected=!0,this.applying=!0;try{for(const r of i.log??[])aw(this.doc,hS(r))}finally{this.applying=!1}i.seed&&this.text.length===0&&this.seedText&&this.text.insert(0,this.seedText),this.onSeeded(),this.onStatus("live");return}if(i.type==="update"&&i.update){this.applying=!0;try{aw(this.doc,hS(i.update))}finally{this.applying=!1}return}if(i.type==="awareness"&&i.awareness){const r=this.awareness.getStates().size;kZ(this.awareness,hS(i.awareness),this),this.awareness.getStates().size>r&&this.publishAwareness(!0);return}i.type==="resync"&&this.reconnect()},e.onerror=()=>{this.onStatus("offline"),this.everConnected||this.onUnavailable()}}reconnect(){this.es?.close(),!this.closed&&this.connect()}async flush(){if(this.timer=null,this.sending||!this.pending.length||this.closed)return;this.sending=!0;const e=H3(this.pending);this.pending=[];let n=!1;try{const i=await fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({update:TA(e),cid:this.cid})});i.ok&&(await i.json().catch(()=>({}))).full&&this.reconnect()}catch{this.pending.unshift(e),this.onStatus("offline"),n=!0}finally{this.sending=!1,!this.closed&&!this.timer&&this.pending.length&&!n&&(this.timer=setTimeout(()=>this.flush(),$A))}}peerCount(){return Math.max(0,this.awareness.getStates().size-1)}destroy(){this.closed=!0,this.ws?.destroy(),this.ws=null,this.awareness.off("update",this.onAwareness),this.timer&&clearTimeout(this.timer),this.cursorTimer&&clearTimeout(this.cursorTimer),this.es?.close(),this.awareness.destroy(),this.doc.destroy()}}function hS(t){const e=atob(t),n=new Uint8Array(e.length);for(let i=0;it.onState?.(v),o=v=>t.apiBase+"upload/content?path="+encodeURIComponent(v),l=async v=>{if(!i.has(v)){if(v===e){s("clean");return}s("saving"),t.onWriting?.(),i.add(v);try{const S=await l2(o(t.path),v,n);e=v,S.sha&&(n=S.sha),s("clean"),t.onSaved?.(v)}catch(S){if(S instanceof kw&&S.status===409){i.delete(v),await u(v,S);return}s("error")}finally{i.delete(v)}}},u=async(v,S)=>{let k="";try{k=JSON.parse(S.body).sha??""}catch{}const C=Kte(t.path,t.who||"browser",new Date);try{await l2(o(C),v),e=v,n=k,s("clean"),t.onConflictCopy?.(C)}catch{s("error")}},f=new kpe(t.apiBase+(t.held?"ycollab":"collab")+"?path="+encodeURIComponent(t.path),t.seed,v=>t.onCollab?.(v),()=>t.onReady(f),()=>t.onSolo(),t.me,t.held),h=()=>{s("dirty"),r&&clearTimeout(r),r=setTimeout(()=>l(f.text.toString()),TZ)};f.text.observe(h);const p=()=>t.onPeers?.(f.peerCount());f.awareness.on("change",p),f.connect();const O=()=>f.text.length?f.text.toString():t.soloText?.()??"";return{collab:f,current:O,merge:v=>{if(v===e||i.has(v))return"same";const S=O();if(v===S)return e=v,"same";if(S!==e||f.peerCount()>0)return"blocked";const k=nne(S,v);return k?!f.text.length&&!t.soloApply?"blocked":(e=v,f.text.length?f.doc.transact(()=>{f.text.delete(k.from,k.to-k.from),f.text.insert(k.from,k.insert)}):t.soloApply(k),"merged"):"same"},saveNow:()=>l(O()),destroy(){r&&clearTimeout(r);const v=O();v&&v!==e&&l(v),f.awareness.off("change",p),f.text.unobserve(h),f.destroy()}}}function Cpe({apiBase:t,path:e,initial:n,onSaved:i,onWriting:r,onStateChange:s,onCollab:o,onPeers:l,onExternal:u,onConflictCopy:f,baseSha:h,me:p}){const{data:O}=Cw(),y=w.useRef(null),v=w.useRef(null),S=w.useRef({onSaved:i,onWriting:r,onStateChange:s,onCollab:o,onPeers:l,onExternal:u,onConflictCopy:f});S.current={onSaved:i,onWriting:r,onStateChange:s,onCollab:o,onPeers:l,onExternal:u,onConflictCopy:f};const k=w.useRef(n),C=w.useRef(n),$=w.useRef(null),T=w.useRef(null);w.useEffect(()=>{if(n===C.current)return;k.current=n;const R=$.current;S.current.onExternal?.(R&&T.current?R.merge(n):"blocked")},[n]);const Q=w.useRef(p);Q.current=p;const A=w.useRef(h);return A.current=h,w.useEffect(()=>{if(!y.current)return;let R=null;const j=[Zre(),Ere(),Zse(),mue(),bse(wse,{fallback:!0}),iy.of([...Xoe,...Gse,Voe]),Le.lineWrapping],L=Le.updateListener.of(Y=>{Y.docChanged&&(S.current.onStateChange?.("dirty"),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{H.saveNow()},TZ))}),ne=()=>{R||!y.current||(R=new Le({parent:y.current,state:St.create({doc:k.current,extensions:[...j,L]})}),T.current=R,R.focus())},G=()=>{R||!y.current||(R=new Le({parent:y.current,state:St.create({doc:H.collab.text.toString(),extensions:[...j,ape(H.collab.text,H.collab.awareness)]})}),T.current=R,R.focus())},H=EZ({apiBase:t,path:e,seed:k.current,held:!!O?.collab?.held,baseSha:A.current,who:Q.current?.name,me:Q.current,onConflictCopy:Y=>S.current.onConflictCopy?.(Y),onReady:()=>G(),onSolo:()=>ne(),onState:Y=>S.current.onStateChange?.(Y),onCollab:Y=>S.current.onCollab?.(Y),onPeers:Y=>S.current.onPeers?.(Y),onSaved:Y=>S.current.onSaved?.(Y),onWriting:()=>S.current.onWriting?.(),soloText:()=>R?.state.doc.toString()??"",soloApply:Y=>R?.dispatch({changes:Y})});return $.current=H,()=>{v.current&&clearTimeout(v.current),$.current=null,T.current=null,H.destroy(),R?.destroy()}},[t,e]),m.jsx("div",{ref:y,id:"editor",className:"cm-host"})}async function _pe(t){if(!globalThis.crypto?.subtle)return null;try{const e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return[...new Uint8Array(e)].map(n=>n.toString(16).padStart(2,"0")).join("")}catch{return null}}function $pe({apiBase:t,fileURL:e,path:n,initial:i,me:r,onStateChange:s,onCollab:o,onPeers:l,onConflictCopy:u,baseSha:f,onSaved:h,onWriting:p,onRendered:O}){const{data:y}=Cw(),v=w.useRef(null),[S,k]=w.useState(null),[C,$]=w.useState(!1),[T,Q]=w.useState(!1),A=w.useRef(0),[R,j]=w.useState(0),L=w.useRef({onStateChange:s,onCollab:o,onPeers:l,onSaved:h,onWriting:p,onRendered:O,onConflictCopy:u});L.current={onStateChange:s,onCollab:o,onPeers:l,onSaved:h,onWriting:p,onRendered:O,onConflictCopy:u};const ne=w.useRef(i),G=w.useRef(r);G.current=r;const H=w.useRef(f);return H.current=f,w.useEffect(()=>{let Y=null,re=!1;$(!1),Q(!1);const K=setTimeout(()=>{!P&&A.current<1&&(A.current++,j(V=>V+1))},11e3),ye=setTimeout(()=>Q(!0),24e3),N=EZ({apiBase:t,path:n,seed:ne.current,held:!!y?.collab?.held,baseSha:H.current,who:G.current?.name,me:G.current,onConflictCopy:V=>L.current.onConflictCopy?.(V),onReady:()=>{re=!0,oe()},onSolo:()=>{N.collab.text.length||N.collab.text.insert(0,ne.current),re=!0,oe()},onState:V=>L.current.onStateChange?.(V),onCollab:V=>L.current.onCollab?.(V),onPeers:V=>L.current.onPeers?.(V),onSaved:V=>L.current.onSaved?.(V),onWriting:()=>L.current.onWriting?.(),soloText:()=>ne.current}),W=new Map,ce=V=>V.start+","+V.end,oe=async()=>{if(P||!Y||!re)return;const V=N.collab.text.toString();if(!V)return;if(Y.some(pe=>pe.end>V.length||pe.start>pe.end)){Y=null,j(pe=>pe+1);return}const J=await _pe(V);if(J!==null?J!==le:D>=0&&V.length!==D){Y=null,j(pe=>pe+1);return}W.clear();for(const pe of Y)W.set(ce(pe),{from:ah(N.collab.text,pe.start),to:ah(N.collab.text,pe.end),span:pe.end-pe.start});P=!0,$(!0),L.current.onRendered?.()};let le="",D=-1,P=!1;const I=async V=>{if(!v.current||V.source!==v.current.contentWindow)return;const J=V.data;if(!J||typeof J!="object")return;if(J.type==="bd-edit:clobbered"){k("This page rewrites itself as it runs, and it replaced the part you were editing. That edit was not saved.");return}if(J.type==="bd-edit:ready"){Y=J.ranges,le=J.hash,D=J.len,await oe();return}if(J.type!=="bd-edit:patch")return;const se=W.get(ce(J));if(!se)return;const pe=N.collab.doc,xe=lh(se.from,pe),Ze=lh(se.to,pe);if(!xe||!Ze||xe.index>Ze.index)return;const Xe=N.collab.text,Ge=Ze.index-xe.index;if(xe.index===0&&Ze.index===Xe.length&&se.spanse.span*4+256){console.warn("bdrive: refusing an implausible patch range",{span:Ge,stamped:se.span,docLength:Xe.length}),W.clear(),P=!1,j(lt=>lt+1);return}Xe.toString().slice(xe.index,Ze.index)!==J.html&&pe.transact(()=>{Xe.delete(xe.index,Ge),Xe.insert(xe.index,J.html)})},X=()=>{oe()};return N.collab.text.observe(X),window.addEventListener("message",I),()=>{clearTimeout(K),clearTimeout(ye),N.collab.text.unobserve(X),setTimeout(()=>{window.removeEventListener("message",I),N.destroy()},300)}},[t,n,R]),m.jsxs(m.Fragment,{children:[S&&m.jsx("div",{id:"edit-clobbered",className:"banner",children:S}),T&&!C&&m.jsxs("div",{id:"edit-not-ready",className:"banner",children:["This file could not be opened for editing — the shared document never loaded. Reload the page to try again, or use ",m.jsx("b",{children:"Edit source"}),"."]}),m.jsx("iframe",{ref:v,className:"htmlview",sandbox:"allow-scripts",src:e+(e.includes("?")?"&":"?")+"edit=1",title:n},R)]})}function Tpe(t){const{apiBase:e,path:n,version:i,onMeta:r}=t,s=Nf(e,n,i);return w.useEffect(()=>()=>r(""),[n,r]),t.editing?m.jsx(Ape,{...t}):zM.test(n)?m.jsx(Ppe,{...t}):Fc.test(n)?m.jsx(Epe,{...t,fileURL:s}):Bg.test(n)?m.jsx("iframe",{className:"pdfview",src:s,title:n,onLoad:t.onRendered}):LM.test(n)?m.jsx(zpe,{src:s,alt:n,version:i,onRendered:t.onRendered}):Sq.test(n)?m.jsx(EA,{...t,fileURL:s,delim:/\.tsv$/i.test(n)?" ":","}):xq.test(n)?m.jsx(EA,{...t,fileURL:s}):m.jsx(Rpe,{...t,fileURL:s})}function Epe(t){const{path:e,fileURL:n,onRendered:i}=t,[r,s]=w.useState(0);return w.useEffect(()=>{const o=l=>{l.detail?.includes(e)&&s(u=>u+1)};return window.addEventListener("bdrive:changed",o),()=>window.removeEventListener("bdrive:changed",o)},[e]),m.jsx("iframe",{className:"htmlview",sandbox:"allow-scripts",src:n,title:e,onLoad:i},r)}function Rpe(t){const{apiBase:e,path:n,version:i,fileURL:r,onRendered:s}=t,{data:o,error:l}=D1(r,["text",r],!0,!!i);return w.useEffect(()=>{o&&s?.()},[o,s]),l?m.jsx($y,{version:i,err:l}):o?o.kind==="text"?m.jsx("pre",{className:"plain",children:o.text},n):m.jsx(Qpe,{apiBase:e,path:n,version:i,fileURL:r,children:o.kind==="too-large"?`Too large to preview (${l1(o.size)}).`:"No preview for this file type."}):null}function Qpe(t){const{apiBase:e,path:n,version:i,fileURL:r}=t;return m.jsxs("div",{className:"filecard",children:[m.jsx("div",{className:"name",children:n.split("/").pop()}),m.jsx("p",{children:t.children}),m.jsx("a",{className:"btn",download:!0,href:i?r+"&download=1":e+"download?path="+encodeURIComponent(n),children:"Download"})]})}function Ape(t){const{apiBase:e,path:n,onMeta:i}=t,r=Fc.test(n)&&!t.editSource,s=Nf(e,n),{data:o,error:l}=D1(s,["text",s],!0,!1),[u,f]=w.useState("clean"),[h,p]=w.useState("connecting"),[O,y]=w.useState(!1),v=w.useRef(0),S=w.useRef(0),k=C=>{Be("Someone else saved this file first. Your version is beside it as "+(C.split("/").pop()??C))};return w.useEffect(()=>{const C=$=>{if($.detail?.includes(n)&&r){if(v.current>0){v.current--;return}S.current>0||y(!0)}};return window.addEventListener("bdrive:changed",C),()=>window.removeEventListener("bdrive:changed",C)},[n,r]),w.useEffect(()=>{i(m.jsx("span",{id:"editor-state","data-state":u,"data-collab":h,children:u==="saving"?"saving…":u==="dirty"?"unsaved":u==="error"?"save failed — still trying":"saved"}))},[u,h,i]),l&&!o?m.jsxs("div",{className:"empty",children:["Could not open ",n," for editing."]}):o?o.kind!=="text"?m.jsx("div",{className:"empty",children:"This file is not text, so it cannot be edited here."}):m.jsxs(m.Fragment,{children:[l&&m.jsx("div",{id:"read-stale",className:"banner",children:"Could not check this file for changes just now — your work is untouched and still saving. Retrying."}),O&&m.jsx("div",{id:"peer-wrote",className:"banner",children:"Someone else changed this file while you were editing. Your buffer is unchanged — saving keeps your version and theirs stays in history."}),r?m.jsx($pe,{apiBase:e,fileURL:s,path:n,initial:o.text,baseSha:o.sha,onConflictCopy:k,onWriting:()=>{v.current++},onStateChange:f,onCollab:p,onPeers:C=>{S.current=C},me:t.me,onRendered:t.onRendered}):m.jsx(Cpe,{apiBase:e,path:n,initial:o.text,baseSha:o.sha,onConflictCopy:k,onExternal:C=>{y(C==="blocked"),C==="merged"&&Be("Folded in a change from outside this editor.")},onWriting:()=>{v.current++},onStateChange:f,onCollab:p,onPeers:C=>{S.current=C},me:t.me})]}):m.jsx("div",{className:"empty",children:"Loading…"})}function Ppe(t){const{apiBase:e,path:n,version:i,heatMap:r,flatFiles:s,projectId:o,onOpenFile:l,onMeta:u,onRendered:f}=t,{data:h,error:p}=nn({queryKey:["render",e,n,i||""],queryFn:()=>Wt(e+"render?path="+encodeURIComponent(n)+(i?"&sha="+i:"")),retry:i?!1:void 0}),O=w.useMemo(()=>h?Npe(h.html,n,e,s,o):"",[h,n,e,s,o]),[y,v]=w.useState(null);return w.useEffect(()=>{if(v(null),!WI(O))return;let S=!1;return KI(O).then(k=>{S||v(k)}),()=>{S=!0}},[O]),w.useEffect(()=>{if(!h)return;const S=[],k=i?null:r&&r[h.path],C=wN(k||null,h.time);(h.user_name||h.user||h.author)&&S.push(MO(h)+(h.device?" on "+h.device:"")),h.time&&S.push(new Date(h.time).toLocaleString());const $=k&&vo(k)?ff(k)+" / 30d":"",T=C?m.jsxs("span",{className:"meta-stale",title:C,children:[m.jsx("span",{"aria-hidden":"true",children:"⚠ "}),C]}):null;u($?m.jsxs(m.Fragment,{children:[T,T?" · ":"",S.length?S.join(" · ")+" · ":"",m.jsxs("span",{title:_l,children:[$,m.jsxs("span",{className:"sr-only",children:[" — ",_l]})]})]}):T?m.jsxs(m.Fragment,{children:[T,S.length?" · "+S.join(" · "):""]}):S.join(" · "))},[h,i,r,u]),w.useEffect(()=>{O&&f?.()},[O,y,f]),p?m.jsx($y,{version:i,err:p}):h?m.jsxs(m.Fragment,{children:[m.jsx(Mpe,{findings:h.findings}),h.frontmatter?.length?m.jsx(jpe,{pairs:h.frontmatter}):null,m.jsx("div",{dangerouslySetInnerHTML:{__html:y??O},onClick:S=>Dpe(S,n,l)})]}):null}function jpe({pairs:t}){const[e,n]=w.useState(Tq);return m.jsxs("details",{className:"fmpanel",open:e,children:[m.jsx("summary",{onClick:i=>{i.preventDefault(),n(!e),Eq(!e)},children:"Properties"}),m.jsx("dl",{children:t.map(i=>m.jsxs("div",{children:[m.jsx("dt",{children:i.key}),m.jsx("dd",{children:i.code?m.jsx("code",{children:i.value}):i.value})]},i.key))})]})}function Mpe({findings:t}){return t?.length?m.jsxs("div",{className:"sbadge",role:"status",children:[m.jsx("span",{className:"sb-icon",children:m.jsx(st,{name:"shield"})}),m.jsxs("div",{className:"sb-text",children:[m.jsx("b",{children:hne(t)}),m.jsx("span",{children:"Checked when this page loaded. Sharing the file asks you to confirm first."})]})]}):null}function Dpe(t,e,n){const i=t.target.closest("a");if(!i||!t.currentTarget.contains(i)||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.button!==0)return;const r=i.getAttribute("href")||"",s=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",o=i.getAttribute("data-wiki");o!==null?(t.preventDefault(),n(o)):/^([a-z]+:|\/|#)/i.test(r)||(t.preventDefault(),n(ZM(s,decodeURIComponent(r))))}function Npe(t,e,n,i,r){const s=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",o=u=>n+"file?path="+encodeURIComponent(u),l=new DOMParser().parseFromString(t,"text/html");for(const u of l.querySelectorAll("img")){const f=u.getAttribute("src")||"";/^\s*data:image\/svg/i.test(f)?u.removeAttribute("src"):/^([a-z]+:|\/)/i.test(f)||u.setAttribute("src",o(ZM(s,f)))}for(const u of l.querySelectorAll("a")){const f=u.getAttribute("href")||"";if(f.startsWith("wiki:")){const h=kq(decodeURIComponent(f.slice(5)),i);h?(u.setAttribute("href",Yr(h.path,r)),u.setAttribute("data-wiki",h.path)):(u.removeAttribute("href"),u.classList.add("wiki-missing"),u.setAttribute("title","No file matches this wikilink"));continue}/^\s*data:/i.test(f)?u.removeAttribute("href"):/^https?:/i.test(f)&&(u.setAttribute("target","_blank"),u.setAttribute("rel","noopener"))}return l.body.innerHTML}function zpe(t){const[e,n]=w.useState(!1);return e?m.jsx($y,{version:t.version,err:new Error("could not be loaded")}):m.jsx("img",{src:t.src,alt:t.alt,onLoad:t.onRendered,onError:()=>n(!0)})}function $y({version:t,err:e}){return m.jsx("div",{className:"empty",children:t?"That version isn't available.":"Could not load file: "+e.message})}function EA(t){const{path:e,version:n,fileURL:i,delim:r,onRendered:s}=t,{data:o,error:l}=nn({queryKey:["text",i],queryFn:async()=>{const f=await fetch(i);if(!f.ok)throw new Error(await f.text());return f.text()},retry:n?!1:void 0});w.useEffect(()=>{o!=null&&s?.()},[o,s]);const u=w.useMemo(()=>r&&o!=null?cne(o,r,RN):null,[o,r]);return l?m.jsx($y,{version:n,err:l}):o==null?null:u?m.jsx(Lpe,{csv:u},e):m.jsx("pre",{className:"plain",children:o},e)}function Lpe({csv:t}){const[e,...n]=t.rows,i=t.rows.reduce((s,o)=>Math.max(s,o.length),0),r=Array.from({length:i},(s,o)=>o);return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"csvbox",children:m.jsxs("table",{className:"csvview",children:[m.jsx("thead",{children:m.jsx("tr",{children:r.map(s=>m.jsx("th",{children:e[s]??""},s))})}),m.jsx("tbody",{children:n.map((s,o)=>m.jsx("tr",{children:r.map(l=>m.jsx("td",{children:s[l]??""},l))},o))})]})}),t.truncated>0&&m.jsxs("p",{className:"csvnote",children:["showing ",t.rows.length.toLocaleString()," of"," ",(t.rows.length+t.truncated).toLocaleString()," rows — Download for the rest"]})]})}const Zpe=[{value:"",label:"Never"},{value:"24h",label:"In 24 hours"},{value:"168h",label:"In 7 days"},{value:"720h",label:"In 30 days"}],RZ=[{value:"",label:"Same as the project"},{value:"write",label:"Write"},{value:"read",label:"Read"},{value:"none",label:"No access"}],RA=RZ.filter(t=>t.value!=="");function Ipe({project:t,path:e,isDir:n,shares:i,onChanged:r,onOpenFolder:s,onClose:o}){const l=fr(),{data:u}=aD(t.id),{data:f}=f1(t.id),{data:h}=oD(!!t.org),p=h?.find(X=>X.id===t.org)?.name||"this workspace",O=_s(t.perm,"admin"),y=_s(t.perm,"write"),v=n?e+"/":e,S=w.useMemo(()=>u?.folders||[],[u]),k=n?S.find(X=>X.prefix===v):void 0,C=_N(S,v),[$,T]=w.useState(null),Q=i.find(X=>X.path===e)||$||void 0,[A,R]=w.useState(!1),[j,L]=w.useState(""),[ne,G]=w.useState("read"),[H,Y]=w.useState(null),[re,K]=w.useState(""),ye=w.useRef(null),N=()=>{l.invalidateQueries({queryKey:["folders",t.id]}),r()},W=async(X,V)=>{R(!0);try{await X(),Be(V)}catch(J){Be(J.message,!0)}finally{R(!1),N()}},ce=X=>{const V=X.perms??Object.fromEntries((k?.grants||[]).map(se=>[se.email,se.level])),J=X.level??k?.default??"";return J===""&&Object.keys(V).length===0?di("DELETE",`/api/p/${t.id}/folders?prefix=${encodeURIComponent(v)}`):di("PUT",`/api/p/${t.id}/folders`,{prefix:v,default:J,perms:V})};async function oe(X){R(!0);try{const V=await fetch(`/api/p/${t.id}/shares`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(X?{path:e,confirm:!0}:{path:e})});if(V.status===409){const{findings:pe}=await V.json();Y(pe||[]);return}if(!V.ok)throw new Error(await V.text());const J=await V.json();T({token:J.token,url:J.url,path:e,project:t.id}),Y(null),iP("share_created");const se=await zs(J.url);Be(se?"Link created and copied.":"Link created."),r()}catch(V){Be("Share failed: "+V.message,!0)}finally{R(!1)}}async function le(X){if(X==="public")return oe(!1);Y(null),T(null),Q&&await W(()=>di("DELETE",`/api/shares/${Q.token}`),"Link revoked — the URL no longer works.")}async function D(X){if(!Q)return;const V=re;K(X);try{await di("PATCH",`/api/shares/${Q.token}`,{expires_in:X}),r()}catch(J){Be(J.message,!0),K(V)}}const P=S.filter(X=>X.prefix!==v&&X.prefix.startsWith(v)),I=`Share "${e.split("/").pop()||t.name}"`;return m.jsx(NO,{open:!0,onOpenChange:X=>!X&&o(),children:m.jsxs(zO,{className:"modal modal-wide",showCloseButton:!1,onOpenAutoFocus:X=>{X.preventDefault(),ye.current?.focus()},children:[m.jsx(vh,{asChild:!0,children:m.jsx("h3",{children:I})}),m.jsx("h4",{className:"sd-head",children:"Who can open this"}),n?m.jsxs(m.Fragment,{children:[m.jsxs("p",{className:"ps-row",children:[m.jsxs("span",{children:["Everyone in ",p," can"]}),m.jsx("select",{"aria-label":"Access for everyone in the workspace",disabled:!O||A,value:k?.default??"",onChange:X=>W(()=>ce({level:X.target.value}),"Folder access updated."),children:RZ.map(X=>m.jsx("option",{value:X.value,children:X.label},X.value))}),!k?.default&&f&&m.jsxs("span",{className:"ai-tag",children:["the project default is ",f.default]})]}),k?.default==="none"&&m.jsxs("p",{className:"ps-note",children:["A folder set to ",m.jsx("b",{children:"no access"})," is not synced to anyone outside the list below, and disappears from their file tree, history and search. Older share links into it stop working. Its ",m.jsx("i",{children:"name"})," stays visible to project members — their devices have to know not to write there. If the name has to be secret too, use a separate project."]}),P.length>0&&m.jsx("p",{className:"ps-note",children:P.length===1?`${P[0].prefix} has its own rule and keeps it — this does not reach inside it.`:`${P.length} folders inside have their own rules and keep them — this does not reach inside them.`}),(k?.grants.length||O)&&m.jsxs("div",{className:"admin-list sd-people",children:[(k?.grants||[]).map(X=>m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"avatar sd-avatar",style:{background:wu(X.email)},"aria-hidden":"true",children:(X.email.trim()[0]||"?").toUpperCase()}),m.jsx("span",{className:"ai-main",title:X.email,children:X.email}),m.jsx("span",{className:"role-cell",children:m.jsx("select",{"aria-label":`Access to this folder for ${X.email}`,disabled:!O||A,value:X.level,onChange:V=>{const J=Object.fromEntries((k?.grants||[]).map(se=>[se.email,se.level]));J[X.email]=V.target.value,W(()=>ce({perms:J}),`${X.email} updated.`)},children:RA.map(V=>m.jsx("option",{value:V.value,children:V.label},V.value))})})]},X.email)),O&&m.jsxs("div",{className:"admin-item sd-add",children:[m.jsx("input",{className:"sd-add-input",placeholder:"Email of a workspace member","aria-label":"Add someone to this folder",value:j,disabled:A,onChange:X=>L(X.target.value)}),m.jsxs("span",{className:"role-cell",children:[m.jsx("select",{"aria-label":"Access for the person being added",value:ne,disabled:A,onChange:X=>G(X.target.value),children:RA.map(X=>m.jsx("option",{value:X.value,children:X.label},X.value))}),m.jsx(at,{variant:"subtle",disabled:!j.trim()||A,onClick:()=>{const X=Object.fromEntries((k?.grants||[]).map(J=>[J.email,J.level]));X[j.trim().toLowerCase()]=ne;const V=j.trim();L(""),W(()=>ce({perms:X}),`${V} added.`)},children:"Add"})]})]})]})]}):m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"ps-row",children:C?m.jsxs("span",{children:["Access comes from the rule on ",m.jsx("b",{children:C.prefix})," — you can"," ",m.jsx("b",{children:C.me})," here."]}):m.jsxs("span",{children:["Everyone in ",p," with access to this project can open it",f&&m.jsxs(m.Fragment,{children:[" — the project default is ",m.jsx("b",{children:f.default})]}),"."]})}),C&&m.jsx("p",{className:"ps-row",children:m.jsxs(at,{variant:"subtle",onClick:()=>s(C.prefix.replace(/\/$/,"")),children:["Open sharing for ",C.prefix]})})]}),m.jsx("h4",{className:"sd-head",children:"Public link"}),n?m.jsx("p",{className:"ps-note",children:"Public links are per file — open a file inside this folder to share it with someone who has no account."}):m.jsxs(m.Fragment,{children:[m.jsxs("p",{className:"ps-row",children:[m.jsx("span",{children:m.jsx(st,{name:Q?"globe":"lock"})}),m.jsxs("select",{"aria-label":"Public link",id:"share-public",disabled:!y||A,value:Q?"public":"restricted",onChange:X=>le(X.target.value),children:[m.jsx("option",{value:"restricted",children:"Restricted — only people with access"}),m.jsx("option",{value:"public",children:"Anyone with the link can view"})]})]}),H&&m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"sd-warn",children:m.jsx("b",{children:"This file may contain credentials"})}),m.jsx("p",{className:"ps-note",children:fne(H)}),m.jsxs("p",{className:"ps-row",children:[m.jsx(at,{variant:"primary",disabled:A,onClick:()=>oe(!0),children:"Share anyway"}),m.jsx(at,{variant:"subtle",disabled:A,onClick:()=>Y(null),children:"Cancel"})]})]}),Q&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"modal-url",children:Q.url}),m.jsxs("div",{className:"modal-expiry",children:[m.jsx("label",{htmlFor:"share-expiry",children:"Expires"}),m.jsx("select",{id:"share-expiry",value:re,disabled:!y||A,onChange:X=>D(X.target.value),children:Zpe.map(X=>m.jsx("option",{value:X.value,children:X.label},X.value))}),m.jsx("span",{className:"modal-expiry-note",children:dN(Q.expires)})]})]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx(at,{ref:ye,variant:"primary",onClick:()=>zs(Q?Q.url:window.location.href).then(X=>Be(X?"Copied.":"Select and copy the link above.")),children:"Copy link"}),m.jsx(at,{variant:"subtle",onClick:o,children:"Done"})]})]})})}function Xpe({shares:t,canRevoke:e,onChanged:n}){return t.length===0?null:m.jsxs("div",{className:"share-banner",role:"status",children:[m.jsxs("div",{className:"sb-head",children:[m.jsx(st,{name:"share"}),m.jsx("b",{children:"Publicly shared"}),m.jsxs("span",{className:"sb-count",children:[t.length," active link",t.length>1?"s":""]})]}),m.jsxs("p",{className:"sb-note",children:[m.jsx("b",{children:"Anyone with this link can view this file"})," — no account needed. It always shows the latest version until you revoke it.",t.some(i=>i.opens!==void 0)&&m.jsxs(m.Fragment,{children:[" ",hN]})]}),t.map(i=>m.jsxs("div",{className:"sb-link",children:[m.jsx("span",{className:"sb-url mono",title:i.url,children:i.url}),m.jsx("span",{className:"sb-meta",children:fN(i,!1)}),m.jsxs("span",{className:"sb-actions",children:[m.jsx(at,{variant:"subtle",onClick:()=>zs(i.url).then(r=>Be(r?"Copied.":"Select and copy the link.")),children:"Copy link"}),m.jsx(at,{variant:"subtle",onClick:()=>window.open(i.url,"_blank"),children:"Open"}),e&&m.jsx("button",{className:"ai-del","aria-label":`Revoke the share of ${i.path}`,onClick:()=>gN(i,n),children:"Revoke"})]})]},i.token))]})}var QA=1,Vpe=.9,Bpe=.8,Upe=.17,pS=.1,gS=.999,qpe=.9999,Ype=.99,Fpe=/[\\\/_+.#"@\[\(\{&]/,Gpe=/[\\\/_+.#"@\[\(\{&]/g,Hpe=/[\s-]/,QZ=/[\s-]/g;function gw(t,e,n,i,r,s,o){if(s===e.length)return r===t.length?QA:Ype;var l=`${r},${s}`;if(o[l]!==void 0)return o[l];for(var u=i.charAt(s),f=n.indexOf(u,r),h=0,p,O,y,v;f>=0;)p=gw(t,e,n,i,f+1,s+1,o),p>h&&(f===r?p*=QA:Fpe.test(t.charAt(f-1))?(p*=Bpe,y=t.slice(r,f-1).match(Gpe),y&&r>0&&(p*=Math.pow(gS,y.length))):Hpe.test(t.charAt(f-1))?(p*=Vpe,v=t.slice(r,f-1).match(QZ),v&&r>0&&(p*=Math.pow(gS,v.length))):(p*=Upe,r>0&&(p*=Math.pow(gS,f-r))),t.charAt(f)!==e.charAt(s)&&(p*=qpe)),(pp&&(p=O*pS)),p>h&&(h=p),f=n.indexOf(u,f+1);return o[l]=h,h}function AA(t){return t.toLowerCase().replace(QZ," ")}function Wpe(t,e,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,gw(t,e,AA(t),AA(e),0,0,{})}var lf='[cmdk-group=""]',mS='[cmdk-group-items=""]',Kpe='[cmdk-group-heading=""]',AZ='[cmdk-item=""]',PA=`${AZ}:not([aria-disabled="true"])`,mw="cmdk-item-select",qc="data-value",Jpe=(t,e,n)=>Wpe(t,e,n),PZ=w.createContext(void 0),Zh=()=>w.useContext(PZ),jZ=w.createContext(void 0),eC=()=>w.useContext(jZ),MZ=w.createContext(void 0),DZ=w.forwardRef((t,e)=>{let n=Yc(()=>{var P,I;return{search:"",value:(I=(P=t.value)!=null?P:t.defaultValue)!=null?I:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=Yc(()=>new Set),r=Yc(()=>new Map),s=Yc(()=>new Map),o=Yc(()=>new Set),l=NZ(t),{label:u,children:f,value:h,onValueChange:p,filter:O,shouldFilter:y,loop:v,disablePointerSelection:S=!1,vimBindings:k=!0,...C}=t,$=hi(),T=hi(),Q=hi(),A=w.useRef(null),R=uge();Ul(()=>{if(h!==void 0){let P=h.trim();n.current.value=P,j.emit()}},[h]),Ul(()=>{R(6,re)},[]);let j=w.useMemo(()=>({subscribe:P=>(o.current.add(P),()=>o.current.delete(P)),snapshot:()=>n.current,setState:(P,I,X)=>{var V,J,se,pe;if(!Object.is(n.current[P],I)){if(n.current[P]=I,P==="search")Y(),G(),R(1,H);else if(P==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let xe=document.getElementById(Q);xe?xe.focus():(V=document.getElementById($))==null||V.focus()}if(R(7,()=>{var xe;n.current.selectedItemId=(xe=K())==null?void 0:xe.id,j.emit()}),X||R(5,re),((J=l.current)==null?void 0:J.value)!==void 0){let xe=I??"";(pe=(se=l.current).onValueChange)==null||pe.call(se,xe);return}}j.emit()}},emit:()=>{o.current.forEach(P=>P())}}),[]),L=w.useMemo(()=>({value:(P,I,X)=>{var V;I!==((V=s.current.get(P))==null?void 0:V.value)&&(s.current.set(P,{value:I,keywords:X}),n.current.filtered.items.set(P,ne(I,X)),R(2,()=>{G(),j.emit()}))},item:(P,I)=>(i.current.add(P),I&&(r.current.has(I)?r.current.get(I).add(P):r.current.set(I,new Set([P]))),R(3,()=>{Y(),G(),n.current.value||H(),j.emit()}),()=>{s.current.delete(P),i.current.delete(P),n.current.filtered.items.delete(P);let X=K();R(4,()=>{Y(),X?.getAttribute("id")===P&&H(),j.emit()})}),group:P=>(r.current.has(P)||r.current.set(P,new Set),()=>{s.current.delete(P),r.current.delete(P)}),filter:()=>l.current.shouldFilter,label:u||t["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:$,inputId:Q,labelId:T,listInnerRef:A}),[]);function ne(P,I){var X,V;let J=(V=(X=l.current)==null?void 0:X.filter)!=null?V:Jpe;return P?J(P,n.current.search,I):0}function G(){if(!n.current.search||l.current.shouldFilter===!1)return;let P=n.current.filtered.items,I=[];n.current.filtered.groups.forEach(V=>{let J=r.current.get(V),se=0;J.forEach(pe=>{let xe=P.get(pe);se=Math.max(xe,se)}),I.push([V,se])});let X=A.current;ye().sort((V,J)=>{var se,pe;let xe=V.getAttribute("id"),Ze=J.getAttribute("id");return((se=P.get(Ze))!=null?se:0)-((pe=P.get(xe))!=null?pe:0)}).forEach(V=>{let J=V.closest(mS);J?J.appendChild(V.parentElement===J?V:V.closest(`${mS} > *`)):X.appendChild(V.parentElement===X?V:V.closest(`${mS} > *`))}),I.sort((V,J)=>J[1]-V[1]).forEach(V=>{var J;let se=(J=A.current)==null?void 0:J.querySelector(`${lf}[${qc}="${encodeURIComponent(V[0])}"]`);se?.parentElement.appendChild(se)})}function H(){let P=ye().find(X=>X.getAttribute("aria-disabled")!=="true"),I=P?.getAttribute(qc);j.setState("value",I||void 0)}function Y(){var P,I,X,V;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=i.current.size;return}n.current.filtered.groups=new Set;let J=0;for(let se of i.current){let pe=(I=(P=s.current.get(se))==null?void 0:P.value)!=null?I:"",xe=(V=(X=s.current.get(se))==null?void 0:X.keywords)!=null?V:[],Ze=ne(pe,xe);n.current.filtered.items.set(se,Ze),Ze>0&&J++}for(let[se,pe]of r.current)for(let xe of pe)if(n.current.filtered.items.get(xe)>0){n.current.filtered.groups.add(se);break}n.current.filtered.count=J}function re(){var P,I,X;let V=K();V&&(((P=V.parentElement)==null?void 0:P.firstChild)===V&&((X=(I=V.closest(lf))==null?void 0:I.querySelector(Kpe))==null||X.scrollIntoView({block:"nearest"})),V.scrollIntoView({block:"nearest"}))}function K(){var P;return(P=A.current)==null?void 0:P.querySelector(`${AZ}[aria-selected="true"]`)}function ye(){var P;return Array.from(((P=A.current)==null?void 0:P.querySelectorAll(PA))||[])}function N(P){let I=ye()[P];I&&j.setState("value",I.getAttribute(qc))}function W(P){var I;let X=K(),V=ye(),J=V.findIndex(pe=>pe===X),se=V[J+P];(I=l.current)!=null&&I.loop&&(se=J+P<0?V[V.length-1]:J+P===V.length?V[0]:V[J+P]),se&&j.setState("value",se.getAttribute(qc))}function ce(P){let I=K(),X=I?.closest(lf),V;for(;X&&!V;)X=P>0?lge(X,lf):cge(X,lf),V=X?.querySelector(PA);V?j.setState("value",V.getAttribute(qc)):W(P)}let oe=()=>N(ye().length-1),le=P=>{P.preventDefault(),P.metaKey?oe():P.altKey?ce(1):W(1)},D=P=>{P.preventDefault(),P.metaKey?N(0):P.altKey?ce(-1):W(-1)};return w.createElement(Ke.div,{ref:e,tabIndex:-1,...C,"cmdk-root":"",onKeyDown:P=>{var I;(I=C.onKeyDown)==null||I.call(C,P);let X=P.nativeEvent.isComposing||P.keyCode===229;if(!(P.defaultPrevented||X))switch(P.key){case"n":case"j":{k&&P.ctrlKey&&le(P);break}case"ArrowDown":{le(P);break}case"p":case"k":{k&&P.ctrlKey&&D(P);break}case"ArrowUp":{D(P);break}case"Home":{P.preventDefault(),N(0);break}case"End":{P.preventDefault(),oe();break}case"Enter":{P.preventDefault();let V=K();if(V){let J=new Event(mw);V.dispatchEvent(J)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:L.inputId,id:L.labelId,style:fge},u),Ey(t,P=>w.createElement(jZ.Provider,{value:j},w.createElement(PZ.Provider,{value:L},P))))}),ege=w.forwardRef((t,e)=>{var n,i;let r=hi(),s=w.useRef(null),o=w.useContext(MZ),l=Zh(),u=NZ(t),f=(i=(n=u.current)==null?void 0:n.forceMount)!=null?i:o?.forceMount;Ul(()=>{if(!f)return l.item(r,o?.id)},[f]);let h=zZ(r,s,[t.value,t.children,s],t.keywords),p=eC(),O=Ma(R=>R.value&&R.value===h.current),y=Ma(R=>f||l.filter()===!1?!0:R.search?R.filtered.items.get(r)>0:!0);w.useEffect(()=>{let R=s.current;if(!(!R||t.disabled))return R.addEventListener(mw,v),()=>R.removeEventListener(mw,v)},[y,t.onSelect,t.disabled]);function v(){var R,j;S(),(j=(R=u.current).onSelect)==null||j.call(R,h.current)}function S(){p.setState("value",h.current,!0)}if(!y)return null;let{disabled:k,value:C,onSelect:$,forceMount:T,keywords:Q,...A}=t;return w.createElement(Ke.div,{ref:vu(s,e),...A,id:r,"cmdk-item":"",role:"option","aria-disabled":!!k,"aria-selected":!!O,"data-disabled":!!k,"data-selected":!!O,onPointerMove:k||l.getDisablePointerSelection()?void 0:S,onClick:k?void 0:v},t.children)}),tge=w.forwardRef((t,e)=>{let{heading:n,children:i,forceMount:r,...s}=t,o=hi(),l=w.useRef(null),u=w.useRef(null),f=hi(),h=Zh(),p=Ma(y=>r||h.filter()===!1?!0:y.search?y.filtered.groups.has(o):!0);Ul(()=>h.group(o),[]),zZ(o,l,[t.value,t.heading,u]);let O=w.useMemo(()=>({id:o,forceMount:r}),[r]);return w.createElement(Ke.div,{ref:vu(l,e),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&w.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),Ey(t,y=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},w.createElement(MZ.Provider,{value:O},y))))}),nge=w.forwardRef((t,e)=>{let{alwaysRender:n,...i}=t,r=w.useRef(null),s=Ma(o=>!o.search);return!n&&!s?null:w.createElement(Ke.div,{ref:vu(r,e),...i,"cmdk-separator":"",role:"separator"})}),ige=w.forwardRef((t,e)=>{let{onValueChange:n,...i}=t,r=t.value!=null,s=eC(),o=Ma(f=>f.search),l=Ma(f=>f.selectedItemId),u=Zh();return w.useEffect(()=>{t.value!=null&&s.setState("search",t.value)},[t.value]),w.createElement(Ke.input,{ref:e,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":l,id:u.inputId,type:"text",value:r?t.value:o,onChange:f=>{r||s.setState("search",f.target.value),n?.(f.target.value)}})}),rge=w.forwardRef((t,e)=>{let{children:n,label:i="Suggestions",...r}=t,s=w.useRef(null),o=w.useRef(null),l=Ma(f=>f.selectedItemId),u=Zh();return w.useEffect(()=>{if(o.current&&s.current){let f=o.current,h=s.current,p,O=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let y=f.offsetHeight;h.style.setProperty("--cmdk-list-height",y.toFixed(1)+"px")})});return O.observe(f),()=>{cancelAnimationFrame(p),O.unobserve(f)}}},[]),w.createElement(Ke.div,{ref:vu(s,e),...r,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":i,id:u.listId},Ey(t,f=>w.createElement("div",{ref:vu(o,u.listInnerRef),"cmdk-list-sizer":""},f)))}),sge=w.forwardRef((t,e)=>{let{open:n,onOpenChange:i,overlayClassName:r,contentClassName:s,container:o,...l}=t;return w.createElement(Qw,{open:n,onOpenChange:i},w.createElement(Pw,{container:o},w.createElement(jw,{"cmdk-overlay":"",className:r}),w.createElement(Mw,{"aria-label":t.label,"cmdk-dialog":"",className:s},w.createElement(DZ,{ref:e,...l}))))}),oge=w.forwardRef((t,e)=>Ma(n=>n.filtered.count===0)?w.createElement(Ke.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),age=w.forwardRef((t,e)=>{let{progress:n,children:i,label:r="Loading...",...s}=t;return w.createElement(Ke.div,{ref:e,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r},Ey(t,o=>w.createElement("div",{"aria-hidden":!0},o)))}),Ty=Object.assign(DZ,{List:rge,Item:ege,Input:ige,Group:tge,Separator:nge,Dialog:sge,Empty:oge,Loading:age});function lge(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function cge(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}function NZ(t){let e=w.useRef(t);return Ul(()=>{e.current=t}),e}var Ul=typeof window>"u"?w.useEffect:w.useLayoutEffect;function Yc(t){let e=w.useRef();return e.current===void 0&&(e.current=t()),e}function Ma(t){let e=eC(),n=()=>t(e.snapshot());return w.useSyncExternalStore(e.subscribe,n,n)}function zZ(t,e,n,i=[]){let r=w.useRef(),s=Zh();return Ul(()=>{var o;let l=(()=>{var f;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(f=h.current.textContent)==null?void 0:f.trim():r.current}})(),u=i.map(f=>f.trim());s.value(t,l,u),(o=e.current)==null||o.setAttribute(qc,l),r.current=l}),r}var uge=()=>{let[t,e]=w.useState(),n=Yc(()=>new Map);return Ul(()=>{n.current.forEach(i=>i()),n.current=new Map},[t]),(i,r)=>{n.current.set(i,r),e({})}};function dge(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function Ey({asChild:t,children:e},n){return t&&w.isValidElement(e)?w.cloneElement(dge(e),{ref:e.ref},n(e.props.children)):n(e)}var fge={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function hge({className:t,...e}){return m.jsx(Ty,{"data-slot":"command",className:yt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e})}function pge({className:t,...e}){return m.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[m.jsx(GM,{className:"size-4 shrink-0 opacity-50"}),m.jsx(Ty.Input,{"data-slot":"command-input",className:yt("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...e})]})}function gge({className:t,...e}){return m.jsx(Ty.List,{"data-slot":"command-list",className:yt("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...e})}function mge({className:t,...e}){return m.jsx(Ty.Item,{"data-slot":"command-item",className:yt("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...e})}function jA(t,e){if(!t)return{score:0,hits:[]};const n=t.toLowerCase(),i=e.toLowerCase();let r=0,s=0,o=0;const l=[];for(let u=0;u3&&i.endsWith("ies")?r=i.slice(0,-3)+"y":i.length>3&&i.endsWith("es")?r=i.slice(0,-2):i.length>2&&i.endsWith("s")&&(r=i.slice(0,-1)),r?jA(r,e):null}const Oge=1e3,yge=12,vge=4;function DA(t,e,n){if(!t.trim())return{score:0,hits:[]};const i=e.lastIndexOf("/")+1;let r=0;const s=[];for(const o of t.trim().split(/\s+/)){let l=MA(o,e),u=!1;if(!l&&n?.allowError&&o.length>=vge)for(let f=0;f0&&l.hits[0]>=i&&(r+=yge),s.push(...l.hits)}return{score:r,hits:[...new Set(s)].sort((o,l)=>o-l)}}function bge({text:t,hits:e}){const n=[];let i=0;return e.forEach((r,s)=>{r>i&&n.push(t.slice(i,r)),n.push(m.jsx("b",{children:t[r]},s)),i=r+1}),n.push(t.slice(i)),m.jsx("span",{className:"plabel",children:n})}function Sge({open:t,onClose:e,candidates:n}){const[i,r]=w.useState(""),s=w.useMemo(()=>{if(!t)return[];const l=[],u=[];for(const f of n()){const h=DA(i,f.label);h?l.push({...f,score:h.score,hits:h.hits}):u.push(f)}if(i.trim()&&l.length<40)for(const f of u){const h=DA(i,f.label,{allowError:!0});h&&l.push({...f,score:h.score,hits:h.hits})}return l.sort((f,h)=>h.score-f.score),l.slice(0,40)},[t,i,n]);w.useEffect(()=>{t&&r("")},[t]);const o=l=>{e(),l.run()};return m.jsx(NO,{open:t,onOpenChange:l=>!l&&e(),children:m.jsxs(zO,{id:"palette",className:"palette",showCloseButton:!1,"aria-describedby":void 0,children:[m.jsx(vh,{className:"sr-only",children:"Search and quick actions"}),m.jsxs(hge,{shouldFilter:!1,loop:!0,children:[m.jsxs("div",{id:"palette-inputwrap",children:[m.jsx(st,{name:"search"}),m.jsx(pge,{placeholder:"Search file names, projects, actions…",autoComplete:"off",spellCheck:!1,value:i,onValueChange:r})]}),m.jsx(gge,{children:s.length===0?m.jsx("div",{className:"pempty",children:"No matches — search covers file names, projects, and actions"}):s.map(l=>m.jsxs(mge,{value:l.kind+":"+l.label,onSelect:()=>o(l),children:[m.jsx("span",{className:"picon",children:m.jsx(st,{name:l.icon})}),m.jsx(bge,{text:l.label,hits:l.hits}),m.jsx("span",{className:"pkind",children:l.kind})]},l.kind+":"+l.label))}),m.jsx("footer",{id:"palette-hint",children:"↑↓ navigate · ⏎ select · esc close"})]})]})})}function xge(t,e){return nn({queryKey:["heatDevices",t],queryFn:()=>Wt(t+"heat?by=device&days=30"),enabled:e,retry:!1,staleTime:6e4}).data?.devices??null}const wge=["all","human","agent","share"],kge={all:"All reads",human:"Human reads",agent:"Agent reads",share:"Shared reads"},Cge={agent:{agent:1,human:0,share:0},human:{agent:0,human:1,share:0},share:{agent:0,human:0,share:1}};function NA(t){const[e,n]=w.useState("all"),{flatFiles:i,heatMap:r,devices:s,scope:o}=t,l=v=>!o||v===o||v.startsWith(o+"/"),u=o?i.filter(v=>l(v.path)):i;if(!t.loading&&!u.length)return m.jsxs("div",{className:"insights",children:[m.jsxs("h1",{className:"in-title",children:["Knowledge insights",o?m.jsxs("span",{className:"in-scope",children:[" · ",o]}):null]}),m.jsxs("div",{className:"dl-empty in-blank",children:[m.jsx("p",{children:o?`Nothing in ${o} to chart yet.`:"Nothing to chart yet."}),m.jsx("p",{children:o?`No files under ${o} are syncing here yet.`:"This project has no files. Once a device syncs files here, the map, the reads × freshness plot and the hot path fill in on their own."}),t.installHref&&m.jsx("a",{className:"pbtn",...Cl(t.installHref),children:"Set up a device →"})]})]});const f=s&&o?s.map(v=>{const S=Object.create(null);for(const[k,C]of Object.entries(v.folders||{}))l(k)&&(S[k]=C);return{...v,folders:S}}).filter(v=>Object.keys(v.folders).length>0):s,h=Date.now(),p=u.map(v=>{const S=r&&r[v.path]||{},k=v.time?Math.max(0,(h-new Date(v.time).getTime())/864e5):0,C=e==="all"?vo(S):S[e]||0;return{path:v.path,reads:C,agent:S.agent||0,human:S.human||0,share:S.share||0,total:vo(S),days:k,danger:xN(C,k)}}),O=cte(r,new Set(i.map(v=>v.path))).filter(l).map(v=>{const S=r[v];return{path:v,reads:e==="all"?vo(S):S[e]||0,agent:S.agent||0,human:S.human||0,share:S.share||0,total:vo(S),days:0,danger:!1,orphan:!0}}).filter(v=>v.reads>0),y=O.length>0?m.jsxs("p",{className:"in-legend in-orphan-note",children:[Ow(O.length,"file")," with reads ",O.length===1?"is":"are"," no longer in the project — see Hot path."]}):null;return m.jsxs("div",{className:"insights",children:[m.jsxs("h1",{className:"in-title",children:["Knowledge insights",o?m.jsxs("span",{className:"in-scope",children:[" · ",o]}):null]}),m.jsx("p",{className:"dl-sub",children:o?`Reads over the last 30 days × freshness, for ${o} and everything in it. ${_l}`:"Reads over the last 30 days × how long since each file changed. Hot but stale knowledge — read a lot, maintained by nobody — is the danger zone. "+_l}),m.jsx("div",{className:"in-lens",children:wge.map(v=>m.jsx("button",{className:"in-lens-btn"+(v===e?" active":""),onClick:()=>n(v),children:kge[v]},v))}),m.jsx("h3",{className:"dl-h3",children:"Map — cell size = reads, color = freshness (scale below)"}),m.jsx($ge,{pts:p,onOpenFile:t.onOpenFile,onOpenFolder:t.onOpenFolder,isFolder:t.isFolder}),y,m.jsxs("h3",{className:"dl-h3 in-h3-row",children:["Reads × freshness",m.jsx("span",{className:"in-cap",children:"dot size = agent share of reads"})]}),m.jsx(Ege,{pts:p,onOpenFile:t.onOpenFile}),y,m.jsx("h3",{className:"dl-h3",children:"Hot path — top files by reads"}),m.jsx(Rge,{pts:[...p,...O],lens:e,onOpenFile:t.onOpenFile,onOpenHistory:t.onOpenHistory}),f&&f.length>0&&m.jsxs(m.Fragment,{children:[m.jsx("h3",{className:"dl-h3",children:"Agent coverage — which agents read which areas"}),m.jsx(Qge,{devices:f})]})]})}const _ge="rgb(150,156,164)";function LZ(t){const e=[[76,195,138],[232,196,84],[224,93,93]],n=Math.min(1,Math.max(0,t/300))*(e.length-1),i=Math.min(e.length-2,Math.floor(n)),r=n-i,s=e[i].map((o,l)=>Math.round(o+(e[i+1][l]-o)*r));return`rgb(${s[0]},${s[1]},${s[2]})`}function zA(t,e,n,i,r){const s=t.reduce((f,h)=>f+h.value,0);if(!s||i<=0||r<=0)return[];const o=t.slice().sort((f,h)=>h.value-f.value).map(f=>({it:f,a:f.value/s*i*r})),l=(f,h)=>{const O=f.reduce((v,S)=>v+S.a,0)/h;let y=0;for(const v of f){const S=v.a/O;y=Math.max(y,S/O,O/S)}return y},u=[];for(;o.length;){const f=i>=r,h=f?r:i,p=[o.shift()];for(;o.length&&l(p.concat(o[0]),h)<=l(p,h);)p.push(o.shift());const O=p.reduce((v,S)=>v+S.a,0)/h;let y=0;for(const v of p){const S=v.a/O;f?u.push({item:v.it,x:e,y:n+y,w:O,h:S}):u.push({item:v.it,x:e+y,y:n,w:S,h:O}),y+=S}f?(e+=O,i-=O):(n+=O,r-=O)}return u}const OS=15;function LA(t,e,n){const i=Math.floor((n-8)/6),r=`${t} · ${e}`;return r.length<=i?{label:r,fit:i}:{label:t.length>i?t.slice(0,Math.max(1,i-1))+"…":t,fit:i}}const Ow=(t,e)=>`${t} ${e}${t===1?"":"s"}`;function $ge({pts:t,onOpenFile:e,onOpenFolder:n,isFolder:i}){const o=dte(t.map(h=>h.days)),l=!!o&&fte(o.min,o.max),u=new Map;for(const h of t){const p=h.path.includes("/")?h.path.split("/")[0]:"/";let O=u.get(p);O||u.set(p,O={name:p,files:[],value:0,reads:0}),O.files.push(h),O.value+=h.reads+1,O.reads+=h.reads}const f=[];for(const h of zA([...u.values()],0,0,720,480)){const p=h.item,O=p.name==="/"?"":p.name,y=p.name==="/"?"(root)":p.name;if(f.push(m.jsx("rect",{x:h.x+1,y:h.y+1,width:Math.max(0,h.w-2),height:Math.max(0,h.h-2),rx:3,className:"in-tm-group","data-dir":O,children:m.jsx("title",{children:`${p.name==="/"?"(root)":p.name+"/"} — ${Ow(p.reads,"read")}/30d · ${Ow(p.files.length,"file")}`})},"g"+p.name)),h.w>46&&h.h>OS+10){const{label:S}=LA(y,p.reads,h.w);f.push(m.jsx("text",{x:h.x+5,y:h.y+12,className:"in-tm-glabel","data-dir":O,children:S},"gl"+p.name))}const v=zA(p.files.map(S=>({...S,name:S.path.split("/").pop(),value:S.reads+1})),h.x+2,h.y+OS,Math.max(0,h.w-4),Math.max(0,h.h-OS-2));for(const S of v)if(f.push(m.jsx("rect",{x:S.x+.6,y:S.y+.6,width:Math.max(.4,S.w-1.2),height:Math.max(.4,S.h-1.2),rx:1.5,fill:l?_ge:LZ(S.item.days),className:"in-tm-cell","data-path":S.item.path,children:m.jsx("title",{children:`${S.item.path} — ${S.item.reads} read${S.item.reads===1?"":"s"}/30d · changed ${Math.round(S.item.days)}d ago`})},S.item.path)),S.w>54&&S.h>16){const{label:k,fit:C}=LA((S.item.danger?"⚠ ":"")+S.item.name,S.item.reads,S.w);C>=5&&f.push(m.jsx("text",{x:S.x+4.5,y:S.y+12.5,className:"in-tm-label","data-path":S.item.path,children:k},"l"+S.item.path))}}return m.jsxs(m.Fragment,{children:[m.jsx("svg",{viewBox:"0 0 720 480",className:"in-chart in-treemap",onClick:h=>{const p=h.target.closest("[data-path], [data-dir]");if(!p)return;const O=p.getAttribute("data-path");if(O)return e(O);const y=p.getAttribute("data-dir");y&&i(y)&&n(y)},children:f}),m.jsx(Tge,{range:o,flat:l})]})}function Tge({range:t,flat:e}){if(!t)return null;const n=hte(t.min,t.max);return m.jsxs("p",{className:"in-legend in-tm-legend",children:["freshness 0d",m.jsx("span",{className:"in-sw in-sw-age"+(e?" in-sw-flat":""),style:{background:`linear-gradient(to right, ${[0,60,150,300].map(LZ).join(", ")})`}}),"300d+",m.jsx("span",{className:"in-tm-range",children:e?`all files here: ${n} old — colour off, not enough range to rank`:`observed: ${n} old`})]})}function Ege({pts:t,onOpenFile:e}){const r={l:44,r:16,t:20,b:34},s=Math.max(Ic*2,...t.map(v=>v.days)),o=Math.max(hf*2,...t.map(v=>v.reads)),l=v=>Math.log10(v+1)/Math.log10(s+1),u=v=>Math.log10(v+1)/Math.log10(o+1),f=v=>3+4*v,h=f(1),p=v=>r.l+h+l(v)*(720-r.l-r.r-2*h),O=v=>360-r.b-h-u(v)*(360-r.t-r.b-2*h),y=mte(t.filter(v=>v.danger).map(v=>({path:v.path,reads:v.reads,cx:p(v.days),cy:O(v.reads),r:f(v.total?(v.agent||0)/v.total:0)})),{right:720-r.r,top:r.t+8,bottom:360-r.b-4});return m.jsxs("svg",{viewBox:"0 0 720 360",className:"in-chart",children:[m.jsx("rect",{x:p(Ic),y:r.t,width:720-r.r-p(Ic),height:O(hf)-r.t,className:"in-danger-zone"}),m.jsx("line",{x1:p(Ic),y1:r.t,x2:p(Ic),y2:360-r.b,className:"in-threshold"}),m.jsx("line",{x1:r.l,y1:O(hf),x2:720-r.r,y2:O(hf),className:"in-threshold"}),m.jsx("line",{x1:r.l,y1:360-r.b,x2:720-r.r,y2:360-r.b,className:"in-axis"}),m.jsx("line",{x1:r.l,y1:r.t,x2:r.l,y2:360-r.b,className:"in-axis"}),m.jsx("text",{x:(r.l+720-r.r)/2,y:352,className:"in-label",children:"days since last change →"}),m.jsx("text",{x:12,y:(r.t+360-r.b)/2,className:"in-label",transform:`rotate(-90 12 ${(r.t+360-r.b)/2})`,children:"reads / 30d →"}),m.jsx("text",{x:720-r.r-6,y:r.t+14,className:"in-quad in-quad-danger",textAnchor:"end",children:"hot + stale"}),m.jsx("text",{x:r.l+6,y:r.t+14,className:"in-quad",children:"hot + fresh"}),m.jsx("text",{x:720-r.r-6,y:360-r.b-8,className:"in-quad",textAnchor:"end",children:"cold + stale"}),m.jsx("text",{x:r.l+6,y:360-r.b-8,className:"in-quad",children:"cold + fresh"}),t.map(v=>{const S=v.total?(v.agent||0)/v.total:0;return m.jsx("circle",{cx:Number(p(v.days).toFixed(1)),cy:Number(O(v.reads).toFixed(1)),r:Number(f(S).toFixed(1)),className:"in-pt"+(v.danger?" danger":v.reads?"":" cold"),onClick:()=>e(v.path),children:m.jsx("title",{children:`${v.path} — ${v.reads} read${v.reads===1?"":"s"} / 30d · changed ${Math.round(v.days)}d ago`})},v.path)}),y.map(v=>m.jsx("text",{x:Number(v.x.toFixed(1)),y:Number(v.y.toFixed(1)),textAnchor:v.anchor,className:"in-pt-label",children:v.name},v.path))]})}function Rge({pts:t,lens:e,onOpenFile:n,onOpenHistory:i}){const r=t.filter(l=>l.reads>0).sort((l,u)=>u.reads-l.reads||u.days-l.days).slice(0,20);if(!r.length)return m.jsx("div",{className:"dl-empty",children:"No reads in the window yet."});const s=r[0].reads,o=r.some(l=>l.share>0);return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"in-hotpath",children:r.map(l=>{const u=Cge[e]??lte(l),f=l.reads/s*100,h=()=>l.orphan?i(l.path):n(l.path);return m.jsxs("div",{className:"in-hp-row",tabIndex:0,role:"button",title:l.orphan?`${l.reads} read${l.reads===1?"":"s"}/30d · no longer in the project — open its history`:l.danger?`${l.reads} read${l.reads===1?"":"s"}/30d · unchanged ${Math.round(l.days)}d — review this file`:l.path,onClick:h,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),h())},children:[m.jsx("span",{className:"in-hp-name"+(l.danger?" danger":""),children:l.path+(l.danger?" ⚠":"")}),l.orphan&&m.jsx("span",{className:"in-hp-gone",children:"· no longer in the project"}),m.jsxs("span",{className:"in-hp-bar",children:[m.jsx("span",{className:"in-hp-agent",style:{width:(f*u.agent).toFixed(1)+"%"}}),m.jsx("span",{className:"in-hp-human",style:{width:(f*u.human).toFixed(1)+"%"}}),m.jsx("span",{className:"in-hp-share",style:{width:(f*u.share).toFixed(1)+"%"}})]}),m.jsx("span",{className:"in-hp-count",children:l.reads})]},l.path)})}),m.jsxs("p",{className:"in-legend",children:[m.jsx("span",{className:"in-sw agent"})," agent reads ",m.jsx("span",{className:"in-sw human"})," human reads",o&&m.jsxs(m.Fragment,{children:[" ",m.jsx("span",{className:"in-sw share"})," shared reads"]})]})]})}function Qge({devices:t}){const e=new Map;for(const O of t)for(const[y,v]of Object.entries(O.folders||{}))e.set(y,(e.get(y)||0)+v);const n=[...e.entries()].sort((O,y)=>y[1]-O[1]).slice(0,12).map(O=>O[0]),i=t.slice(0,12),r=140,s=6,o=Math.min(76,Math.max(34,(720-r-8)/n.length)),l=26,u=720,f=s+i.length*l+58,h=Math.max(1,...i.flatMap(O=>n.map(y=>(O.folders||{})[y]||0))),p=O=>{const y=[23,25,31],v=[245,166,35],S=y.map((k,C)=>Math.round(k+(v[C]-k)*O));return`rgb(${S[0]},${S[1]},${S[2]})`};return m.jsxs("svg",{viewBox:`0 0 ${u} ${f}`,className:"in-chart in-matrix",children:[i.map((O,y)=>{let v=O.name||O.id||"";return v.length>20&&(v=v.slice(0,19)+"…"),m.jsxs("g",{children:[m.jsx("text",{x:r-8,y:s+y*l+17,textAnchor:"end",className:"in-label",children:v}),n.map((S,k)=>{const C=(O.folders||{})[S]||0;return m.jsx("rect",{x:r+k*o,y:s+y*l,width:o-4,height:l-4,rx:3,fill:p(Math.sqrt(C/h)),children:m.jsx("title",{children:`${O.name||O.id} × ${S||"(root)"}: ${C} read${C===1?"":"s"}/30d`})},S)})]},O.id||y)}),n.map((O,y)=>{const v=r+y*o+(o-4)/2,S=s+i.length*l+14;return m.jsx("text",{x:v,y:S,className:"in-label",textAnchor:"end",transform:`rotate(-28 ${v} ${S})`,children:O||"(root)"},O)})]})}function ZZ(t){return new Set(t.entries.map(e=>e.path)).size}function Age(t){const e=s=>(s.session?"s\0"+s.session:"n\0"+s.note)+"\0"+(s.device?.id??""),n=new Map;t.forEach((s,o)=>{if(!s.note&&!s.session)return;const l=n.get(e(s));if(l){l.entries.push(s),l.idx.push(o);return}n.set(e(s),{note:s.note??"",session:s.session,entries:[s],idx:[o]})});const i=[],r=new Set;return t.forEach((s,o)=>{const l=s.note||s.session?n.get(e(s)):void 0;if(!l||ZZ(l)<2){i.push({i:o});return}r.has(l)||(r.add(l),i.push({run:l,i:o}))}),i}function Pge(t){const{filters:e,authors:n,onChange:i}=t,r=(h,p)=>i({...e,[h]:p||void 0}),[s,o]=w.useState(e?.q??""),l=w.useRef(!1);w.useEffect(()=>{l.current||o(e?.q??"")},[e?.q]),w.useEffect(()=>{if(!l.current)return;const h=setTimeout(()=>{l.current=!1,s!==(e?.q??"")&&r("q",s)},250);return()=>clearTimeout(h)},[s]);const u=e?.user&&!n.includes(e.user)?[e.user,...n]:n,f=p1(e);return m.jsxs("div",{className:"hfilters",children:[m.jsxs("label",{className:"hf-search",children:[m.jsx(st,{name:"search"}),m.jsx(Fg,{type:"search",value:s,placeholder:"path contains…","aria-label":"Filter by path",onChange:h=>{l.current=!0,o(h.target.value)}})]}),m.jsxs("select",{className:"hf-user",value:e?.user??"","aria-label":"Filter by author",onChange:h=>r("user",h.target.value),children:[m.jsx("option",{value:"",children:"Anyone"}),u.map(h=>m.jsx("option",{value:h,children:h},h))]}),m.jsxs("span",{className:"hf-dates",children:[m.jsx("span",{className:"hf-lbl",children:"UTC"}),m.jsx(Fg,{type:"date",className:"hf-date",value:e?.since??"","aria-label":"From date (UTC)",onChange:h=>r("since",h.target.value)}),m.jsx("span",{className:"hf-dash",children:"–"}),m.jsx(Fg,{type:"date",className:"hf-date",value:e?.until??"","aria-label":"To date (UTC)",onChange:h=>r("until",h.target.value)})]}),f&&m.jsx("button",{type:"button",className:"hf-clear",onClick:()=>i({}),children:"Clear"})]})}function jge(t){const e=new Set;for(const n of t)n.user&&e.add(n.user);return[...e].sort()}function Mge(t){const{apiBase:e,target:n,isFolder:i,onMeta:r,onRendered:s,restore:o,remove:l,undoRun:u,filters:f}=t,h=w.useMemo(()=>new Set(t.flatFiles.map(G=>G.path)),[t.flatFiles]),p=n?i(n)?{prefix:n+"/"}:{path:n}:{prefix:""},O=("path"in p&&p.path!==void 0?"path="+encodeURIComponent(p.path):"prefix="+encodeURIComponent(p.prefix??""))+fD(f).replace("?","&"),{data:y,error:v,isPending:S,fetchNextPage:k,hasNextPage:C,isFetchingNextPage:$}=FX({queryKey:["history",e,O],queryFn:({pageParam:G})=>Wt(e+"history?"+O+"&n=100"+(G?"&cursor="+encodeURIComponent(G):"")),initialPageParam:"",getNextPageParam:G=>G.next_cursor,staleTime:15e3}),T=w.useRef(new Set);w.useEffect(()=>{v&&r("History unavailable: "+v.message)},[v,r]),w.useEffect(()=>{y&&s?.()},[y,s]);const Q=y?y.pages.flatMap(G=>G.entries||[]):[];for(const G of jge(Q))T.current.add(G);const A=t.onFilters&&m.jsx(Pge,{filters:f,authors:[...T.current].sort(),onChange:t.onFilters});if(!y)return m.jsxs("div",{className:"history",children:[A,S&&!v&&m.jsx("div",{className:"empty",children:"Loading…"})]});const R=G=>{for(let H=G+1;H{const H=Q[G].kind==="delete"?R(G):Q[G].blob;return H&&H===j.get(Q[G].path)?void 0:H},ne=G=>j.get(Q[G].path)==="";return m.jsxs("div",{className:"history",children:[A,Q.length===0&&(p1(f)?m.jsxs("div",{className:"empty",children:["No changes match these filters.",m.jsx("br",{}),m.jsx("button",{type:"button",className:"btn hf-clear-empty",onClick:()=>t.onFilters?.({}),children:"Clear filters"})]}):m.jsx("div",{className:"empty",children:"No history yet."})),Age(Q).map((G,H)=>G.run?m.jsx(Dge,{run:G.run,known:h,onOpen:t.onOpen,apiBase:e,prevBlob:R,restoreSha:L,recreates:ne,restore:o,remove:l,undoRun:u},"g"+H):m.jsx(N1,{entry:Q[G.i],apiBase:e,onOpen:t.onOpen,diff:{apiBase:e,prev:R(G.i)},restore:o,restoreSha:L(G.i),recreates:ne(G.i)},"r"+G.i)),C&&m.jsx("button",{type:"button",className:"btn hmore",onClick:()=>k(),disabled:$,children:$?"Loading…":"Load more"})]})}function Dge({run:t,known:e,onOpen:n,apiBase:i,prevBlob:r,restoreSha:s,recreates:o,restore:l,remove:u,undoRun:f}){const[h,p]=w.useState(!0),O=t.entries[0],y=MO(O),v=[O.device.name||O.device.id,O.device.os].filter(Boolean).join(" · "),S=O.session,k=O.device?.id,{data:C}=nn({queryKey:["session-reads",i,S,k],queryFn:()=>Wt(i+"heat?session="+encodeURIComponent(S)+"&device="+encodeURIComponent(k)),enabled:!!S&&!!k,staleTime:3e4}),$=new Set(C?.paths??[]),T=new Set(t.entries.map(ne=>ne.path)),Q=[...$].filter(ne=>!T.has(ne)).sort(),A=t.entries.map(ne=>new Date(ne.time).getTime()),R=Nge(Math.min(...A),Math.max(...A)),j=ZZ(t),L=!!f?.busy&&f.busy===(t.session||t.note);return m.jsxs("div",{className:"hrun"+(h?" open":""),children:[m.jsxs("div",{className:"hrun-head",children:[m.jsx("button",{type:"button",className:"hrun-toggle","aria-expanded":h,title:h?"Collapse this run":"Expand this run",onClick:()=>p(!h),children:m.jsx(st,{name:h?"chevd":"chev"})}),m.jsx("span",{className:"hrun-note",children:m.jsx(EN,{text:t.note})}),m.jsxs("span",{className:"hrun-meta",children:[$.size>0?`read ${$.size} · changed ${j}`:`${j} file${j===1?"":"s"}`," ·"," ",y,v?" · "+v:""]}),m.jsx("span",{className:"hrun-time",children:R}),f&&m.jsxs("button",{type:"button",className:"hrun-undo",disabled:L,title:"Put every file this run touched back the way it was",onClick:()=>f.onUndoRun(t),children:[m.jsx(st,{name:"hist"}),L?"undoing…":"undo this run"]})]}),h&&m.jsxs("div",{className:"hrun-body",children:[t.entries.map((ne,G)=>m.jsx(N1,{entry:ne,apiBase:i,onOpen:n,diff:{apiBase:i,prev:r(t.idx[G])},restore:l,remove:u,restoreSha:s(t.idx[G]),recreates:o(t.idx[G]),inRun:!0,read:$.has(ne.path)},G)),Q.length>0&&m.jsxs("div",{className:"hrun-reads",children:[m.jsx("div",{className:"hrun-reads-head",children:"Read, not changed"}),Q.map(ne=>m.jsxs("button",{type:"button",className:"hrun-read",onClick:()=>n(ne),children:[m.jsx("span",{className:"hkind",children:"read"}),m.jsx("span",{className:"hpath",children:ne}),!e.has(ne)&&m.jsx("span",{className:"in-hp-gone",children:"· no longer in the project"})]},ne))]}),S&&m.jsx("div",{className:"hrun-foot",children:"Reads shown are what this device reported for this session — a narrower set than the project's read totals."})]})]})}function Nge(t,e){const n=new Date(t),i=new Date(e),r=o=>o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(n.toDateString()!==i.toDateString())return n.toLocaleString()+" – "+i.toLocaleString();const s=i.toLocaleDateString();return t===e?s+" "+r(i):s+" "+r(n)+" – "+r(i)}function zge(t,e){return t?e(t)?t+"/ (folder)":t:"all changes"}const Lge=3,ZA=2;function IA(t,e){return{key:t,want:e,attempts:0}}function Zge(t,e){return t.key!==e||t.attempts>=Lge?null:(t.attempts++,t.want)}function Ige(t,e,n,i){t.key===e&&(Math.abs(n-t.want)<=ZA||t.attempts===0||n>=i-ZA&&nWt(e+"history?"+r+"&n=200"),staleTime:15e3}),o=s?.entries?.find(h=>h.blob===i),l=o?MO(o):"",u=o?.time?new Date(o.time).toLocaleString():"",f=e+"blob?sha="+i+"&name="+encodeURIComponent(n.split("/").pop()||n)+"&download=1";return m.jsxs("div",{className:"vbanner",role:"status",children:[m.jsx("span",{className:"vb-icon",children:m.jsx(st,{name:"clock"})}),m.jsxs("div",{className:"vb-text",children:[m.jsx("b",{children:[u&&"Version from "+u,l&&"by "+l].filter(Boolean).join(" ")||"Earlier version"}),m.jsx("span",{children:"This is not the current file."})]}),m.jsxs("div",{className:"vb-actions",children:[m.jsx("button",{className:"ai-btn",onClick:t.onViewCurrent,children:"View current"}),m.jsx("a",{className:"ai-btn",download:!0,href:f,children:"Download this version"})]})]})}function Vge(t){const{conflict:e,originalHref:n}=t,i=e.device||"another device";return m.jsxs("div",{className:"vbanner",role:"status",children:[m.jsx("span",{className:"vb-icon",children:m.jsx(st,{name:"alert"})}),m.jsxs("div",{className:"vb-text",children:[m.jsx("b",{children:"Conflict copy — a concurrent edit, preserved"}),m.jsxs("span",{children:[i," edited this file at the same time as someone else on"," ",e.when.toLocaleString(),". Rather than drop either version, beardrive kept that one here."," ",n?m.jsxs(m.Fragment,{children:["The other version lives at ",m.jsx("code",{children:e.original})]}):m.jsx(m.Fragment,{children:"The other version kept the original name."})]})]}),n&&m.jsx("div",{className:"vb-actions",children:m.jsx("button",{className:"ai-btn",onClick:n,children:"Open the other version"})})]})}function IZ(t){const{config:e,apiBase:n,route:i,hub:r,project:s}=t,o=PF(m1()),l=fr(),{tree:u,flatFiles:f,dirIndex:h,loaded:p}=vte(n,!r||!!s),O=!r||!!s,{people:y,setPeople:v}=$te(n,i.path??"",O);Cte(n,O,v);const S=bte(n,r&&!!s&&!!e.reads?.enabled),{data:k}=aD(r&&s?s?.id:void 0),C=w.useMemo(()=>k?.folders||[],[k]),$=w.useMemo(()=>new Set(C.map(ve=>ve.prefix.replace(/\/$/,""))),[C]),T=r&&!!s&&!i.path&&!i.view,Q=i.view==="dashboard"||T,A=xge(n,Q);w.useEffect(()=>{Q&&l.invalidateQueries({queryKey:["heat",n]})},[Q,n,l]);const R=i.path,j=i.view?void 0:i.version,L=R||(i.view==="dashboard"||i.view==="history")&&i.viewTarget||"",ne=!!R&&h.has(R),G=!!R&&p&&!ne&&f.some(ve=>ve.path===R),H=!!R&&p&&!ne&&!G,Y=ne&&!i.view,{data:re}=nn({queryKey:["resolve",n,R],queryFn:()=>Wt(n+"resolve?path="+encodeURIComponent(R)),enabled:H,retry:!1,staleTime:6e4}),[K,ye]=w.useState(null);w.useEffect(()=>{!H||!re?.to||(ye({from:R,to:re.to}),zt(Yr(re.to,s?.id,void 0,i.full,i.editing),{replace:!0}))},[H,re,R,s?.id,i.full,i.editing]);const[N,W]=w.useState(()=>new Set),ce=w.useRef(!0);w.useEffect(()=>{if(!u||!ce.current)return;ce.current=!1;const ve=(u.children||[]).filter(Pe=>Pe.dir);ve.length===1&&W(Pe=>new Set(Pe).add(ve[0].path))},[u]),w.useEffect(()=>{!L||!p||W(ve=>{const Pe=new Set(ve);for(const rt of Gte(L))Pe.add(rt);return h.has(L)&&Pe.add(L),Pe})},[L,p,h]);const oe=w.useCallback(ve=>{W(Pe=>{const rt=new Set(Pe);return rt.has(ve)?rt.delete(ve):rt.add(ve),rt})},[]),le=w.useRef(null),D=w.useRef(new Map),P=w.useRef(IA("",0)),I=w.useCallback(()=>{const ve=le.current;if(!ve)return;const Pe=Zge(P.current,o);Pe!==null&&ve.scrollTo({top:Pe,behavior:"instant"})},[o]);w.useEffect(()=>{P.current=IA(o,MF()==="POP"?D.current.get(o)??0:0),I()},[o,I]);const X=w.useCallback(()=>{const ve=le.current;ve&&(D.current.set(o,ve.scrollTop),Ige(P.current,o,ve.scrollTop,ve.scrollHeight-ve.clientHeight))},[o]),V=w.useCallback((ve,Pe)=>{zt(Yr(ve,s?.id,Pe)),Fr()},[s?.id]),J=w.useCallback(ve=>zt(Zi("history",s?.id,ve)),[s?.id]),[se,pe]=w.useState(""),[xe,Ze]=w.useState(!1),[Xe,Ge]=w.useState(!1),[Qt,lt]=w.useState(!1);w.useEffect(()=>vq(()=>lt(!0)),[]);const ti=w.useRef(null),Oi=w.useRef(null),At=t.panel??null,pr=!At&&r&&!!s&&(G||ne)&&_s(s.perm,"write"),gr=!At&&G&&!j&&(!r||!!s&&_s((ve=>_N(C,ve)?.me)(R)??s.perm,"write")),Ri=!!i.editing&&gr,[sn,Yi]=w.useState(!1);w.useEffect(()=>{Yi(!1)},[R,j]);const xn=w.useMemo(()=>{const ve=e.me?.name||e.me?.email||"Someone";let Pe=0;for(let rt=0;rt{Fi.current=!1},[R]);const jo=w.useCallback(()=>{Fi.current=!0,zt(Yr(R,s?.id,j,!0,i.editing))},[R,s?.id,j,i.editing]),ii=w.useCallback(()=>{Fi.current?(Fi.current=!1,history.back()):zt(Yr(R,s?.id,j,!1,i.editing),{replace:!0})},[R,s?.id,j,i.editing]);w.useLayoutEffect(()=>{if(ni)return document.body.classList.add("full-view"),document.body.classList.remove("sb-open"),jl(),()=>{document.body.classList.remove("full-view"),jl()}},[ni]),w.useEffect(()=>{if(!ni)return;const ve=Pe=>{Pe.key==="Escape"&&!Qt&&ii()};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[ni,Qt,ii]);const M=w.useRef(!1);w.useEffect(()=>{ni?qs.current?.focus():M.current&&mr.current?.focus(),M.current=ni},[ni]);const{data:U}=lD(s?.id,r&&!!s),q=w.useCallback(()=>{l.invalidateQueries({queryKey:["shares",s?.id]})},[l,s?.id]),he=G?(U||[]).filter(ve=>ve.path===R):[],{data:me}=nn({queryKey:["desktop-status"],queryFn:()=>Wt("/api/desktop/status"),enabled:!!e.desktop,staleTime:6e4}),Se=e.desktop&&s?me?.mounts.find(ve=>ve.project===s.id)?.server:void 0,ke=w.useCallback(async()=>{if(!Se)return;const ve=Se+window.location.pathname,Pe=await zs(ve);Be(Pe?"Web link copied":ve,!Pe)},[Se]),_e=!At&&r&&!!s,Ae=!At&&G&&!i.view,dt=!At&&G,Zt=dt&&!LM.test(R)&&!Bg.test(R)&&!Fc.test(R),on=dt&&!Bg.test(R)&&!Ri,an=!At&&(G||r&&!!s&&ne),Ve=j?n+"blob?sha="+j+"&name="+encodeURIComponent(R)+"&download=1":n+"download?path="+encodeURIComponent(R),Ct=!Fc.test(R),qt=Nf(n,R,j)+"&print=1",ln=w.useCallback(()=>{Ge(!1),Ct?window.print():Oi.current?.click()},[Ct]),yi=w.useCallback(async()=>{try{const ve=await CN(Nf(n,R,j));if(ve.kind!=="text")return Be(ve.kind==="too-large"?"Too large to copy — use Download.":"That file isn't text — use Download.",!0);const Pe=await zs(ve.text);Be(Pe?"Copied "+R:"Copy failed — the clipboard needs a secure (https) origin.",!Pe)}catch(ve){Be("Copy failed: "+ve.message,!0)}},[n,R,j]),It=w.useCallback(()=>Ze(!0),[]),[ri,ls]=w.useState(""),Ln=r&&!!s&&_s(s?.perm,"write"),si=w.useCallback(async(ve,Pe,rt)=>{if(await kl("Restore this version of "+ve+"?","It syncs to every device as a new change. "+(rt?"The file comes back on every device. Removing it again isn't available from History yet.":"You can restore any other version afterwards."),"Restore")){ls(ve+Pe);try{await Wr(n+"restore",{path:ve,sha:Pe}),l.invalidateQueries({queryKey:["history",n]}),l.invalidateQueries({queryKey:["tree",n]}),l.invalidateQueries({queryKey:["render",n,ve]}),l.invalidateQueries({queryKey:["text"]}),Be("Restored "+ve+" — it syncs to every device like any other change.")}catch(_t){Be("Restore failed: "+_t.message,!0)}finally{ls("")}}},[n,l]),[Mo,Qi]=w.useState(""),td=w.useCallback(async ve=>{if(await kl("Remove "+ve+"?","It disappears from every synced device. History keeps it — you can restore it from the DELETED row afterwards.","Remove file",!0)){Qi(ve);try{await Wr(n+"remove",{path:ve}),l.invalidateQueries({queryKey:["history",n]}),l.invalidateQueries({queryKey:["tree",n]}),l.invalidateQueries({queryKey:["render",n,ve]}),l.invalidateQueries({queryKey:["text"]}),Be("Removed "+ve+" — it syncs to every device like any other change.")}catch(Pe){Be("Remove failed: "+Pe.message,!0)}finally{Qi("")}}},[n,l]),[Ih,Zr]=w.useState(""),Rn=w.useCallback(async ve=>{const Pe=ve.session||ve.note,rt=ve.session?{session:ve.session,device:ve.entries[0]?.device?.id}:{note:ve.note,device:ve.entries[0]?.device?.id};Zr(Pe);try{const _t=await Wr(n+"undo-run",{...rt,preview:!0}),Pt=new Set(_t.changed_after);if(!_t.undone.length){Be("Nothing to undo — every file this run touched already holds its pre-run content.");return}if(!await kl("Undo this run?",m.jsxs(m.Fragment,{children:[m.jsxs("div",{children:[ve.note||Pe," — ",_t.undone.length," file",_t.undone.length===1?"":"s"]}),m.jsx("div",{className:"undo-list",children:_t.undone.map(Ir=>m.jsxs("div",{className:"undo-row",children:[m.jsx("span",{className:"undo-path",children:Ir.path}),Pt.has(Ir.path)&&m.jsx("span",{className:"undo-after",children:"changed after this run"}),m.jsx("span",{className:"undo-what",children:Ir.action==="remove"?"remove (the run created it)":"restore to pre-run version"})]},Ir.path))}),Pt.size>0&&m.jsxs("div",{className:"undo-warn",children:[Pt.size," file",Pt.size===1?" was":"s were"," changed by someone else after this run. Undoing overwrites ",Pt.size===1?"that change":"those changes"," too."]}),_t.skipped.length>0&&m.jsxs("div",{children:[_t.skipped.length," already hold",_t.skipped.length===1?"s":""," its pre-run content and will be left alone."]}),_t.refused.length>0&&m.jsxs("div",{children:[_t.refused.length," path",_t.refused.length===1?"":"s"," can't be written by the hub and will be left alone: ",_t.refused.join(", "),"."]})]}),"Undo run",!0))return;const Ya=await Wr(n+"undo-run",rt);l.invalidateQueries({queryKey:["history",n]}),l.invalidateQueries({queryKey:["tree",n]}),l.invalidateQueries({queryKey:["render",n]}),l.invalidateQueries({queryKey:["text"]});const Ys=Ya.skipped.length?`, skipped ${Ya.skipped.length} (already current)`:"";Be(`Undid ${Ya.undone.length} file${Ya.undone.length===1?"":"s"}${Ys}.`)}catch(_t){Be("Undo failed: "+_t.message,!0)}finally{Zr("")}},[n,l]),Qn=w.useCallback(()=>{if(!R)return J("");J(ne?R+"/":R)},[R,ne,J]);w.useEffect(()=>{const ve=Pe=>{(Pe.metaKey||Pe.ctrlKey)&&Pe.key.toLowerCase()==="k"&&(Pe.preventDefault(),lt(rt=>!rt))};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[]);const Do=w.useCallback(()=>{const ve=[],Pe=(rt,_t,Pt,rd)=>ve.push({icon:rt,label:_t,kind:Pt,run:rd});if(r&&s){const rt=s.id,_t=Pt=>()=>{t.onClosePanel?.(),zt(Pt)};Pe("folder",s.name+" — project root","project",_t("/"+rt)),Pe("dashboard","Dashboard","action",_t(Zi("dashboard",rt))),Pe("terminal","Installation","action",_t(Zi("install",rt))),Pe("gear","Settings","action",_t(Zi("settings",rt)))}if(r&&s&&R&&(pr&&Pe("share","Share: "+R,"action",It),Pe("hist","History: "+R,"action",Qn),G&&Pe("download","Download: "+R,"action",()=>ti.current?.click()),on&&Pe("printer","Print: "+R,"action",ln),Zt&&Pe("copy","Copy: "+R,"action",yi)),r&&s&&Pe("hist","History: whole project","action",()=>J("")),r)for(const rt of t.projects||[])(!s||rt.id!==s.id)&&Pe("folder","Switch to project: "+rt.name,"project",()=>zt("/"+rt.id));e.auth?.enabled&&Pe("power","Sign out","action",()=>window.location.href="/auth/logout");for(const rt of h.keys())Pe("folder",rt,"folder",()=>V(rt));for(const rt of f)Pe("doc",rt.path,"file",()=>V(rt.path));return ve},[r,s,R,G,pr,Zt,on,e.auth?.enabled,h,f,t.projects,t.onClosePanel,It,yi,ln,Qn,J,V]);w.useEffect(()=>{if(!Xe)return;const ve=()=>Ge(!1);return document.addEventListener("click",ve),()=>document.removeEventListener("click",ve)},[Xe]);const No=w.useCallback(ve=>h.has(ve),[h]);let Xh="app",nd,vi;if(At)vi=At.body;else if(i.view==="dashboard")vi=m.jsx(NA,{flatFiles:f,heatMap:S,devices:A,scope:i.viewTarget||"",loading:!p,installHref:s?Zi("install",s.id):void 0,onOpenFile:V,onOpenFolder:V,onOpenHistory:J,isFolder:No});else if(i.view==="history")vi=m.jsx(Mge,{apiBase:n,target:i.viewTarget||"",isFolder:No,flatFiles:f,onOpen:V,onMeta:pe,onRendered:I,restore:Ln?{onRestore:si,busy:ri}:void 0,remove:Ln?{onRemove:td,busy:Mo}:void 0,undoRun:Ln?{onUndoRun:Rn,busy:Ih}:void 0,filters:i.filters,onFilters:ve=>zt(Zi("history",s?.id,i.viewTarget||"",ve))});else if(R)if(!p)vi=m.jsx("div",{className:"empty",children:"Loading…"});else if(H)vi=m.jsxs("div",{className:"notfound",children:[m.jsx("h1",{children:"Couldn't find that"}),m.jsxs("p",{children:[m.jsx("code",{children:R})," isn't in this project right now."]}),m.jsx("p",{className:"nf-sub",children:"If it was just created, it may still be uploading or syncing from a teammate's device — this page checks again automatically every few seconds, so refresh or come back in a moment."}),m.jsx("button",{className:"pbtn",onClick:()=>l.invalidateQueries({queryKey:["tree",n]}),children:"Check again"})]});else if(ne)vi=m.jsx(ane,{node:h.get(R),heatMap:S,folders:C,hub:r&&!!s,apiBase:n,onOpen:V,onFullHistory:J,onRendered:I});else{Xh=Fc.test(R)||Bg.test(R)?"wide":"read",nd="markdown",ni&&!zM.test(R)&&(nd+=" bleed");const ve=TN(R);vi=m.jsxs(m.Fragment,{children:[j&&m.jsx(Xge,{apiBase:n,path:R,version:j,onViewCurrent:()=>V(R)}),ve&&m.jsx(Vge,{conflict:ve,originalHref:f.some(Pe=>Pe.path===ve.original)?()=>V(ve.original):void 0}),m.jsx(Tpe,{apiBase:n,path:R,version:j,heatMap:S,flatFiles:f,projectId:s?.id,onOpenFile:V,onMeta:pe,onRendered:I,editing:Ri,editSource:sn,me:xn})]})}else T?vi=m.jsxs(m.Fragment,{children:[m.jsx(bN,{project:s,existing:i.connect==="existing"}),m.jsx("div",{className:"home-insights",children:m.jsx(NA,{flatFiles:f,heatMap:S,devices:A,loading:!p,onOpenFile:V,onOpenFolder:V,onOpenHistory:J,isFolder:No})})]}):vi=m.jsx("div",{className:"empty",children:"Select a file to read it."});K&&K.to===R&&(vi=m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"vbanner",role:"status",children:[m.jsx("span",{className:"vb-icon",children:m.jsx(st,{name:"link"})}),m.jsxs("div",{className:"vb-text",children:[m.jsxs("b",{children:["Moved from ",K.from]}),m.jsx("span",{children:"The URL has been updated."})]})]}),vi]}));const qa=At?At.crumb:R?m.jsx(Hte,{path:R,onOpenFolder:V}):i.view==="dashboard"?"Dashboard — "+(i.viewTarget||s?.name||""):i.view==="history"?"History — "+zge(i.viewTarget||"",No):T?s.name:null,id=m.jsx(bl,{nav:e.desktop?m.jsxs("span",{id:"nav-btns",children:[m.jsx("button",{className:"nav-btn",title:"Back (⌘[)","aria-label":"Back",onClick:()=>history.back(),children:m.jsx(st,{name:"chevl"})}),m.jsx("button",{className:"nav-btn",title:"Forward (⌘])","aria-label":"Forward",onClick:()=>history.forward(),children:m.jsx(st,{name:"chev"})})]}):void 0,crumb:qa,meta:se,actions:m.jsxs(m.Fragment,{children:[m.jsx(Ete,{people:y,path:R}),gr&&m.jsx(at,{id:"edit-btn",variant:"toolbar",title:Ri?"Stop editing":"Edit this file",onClick:()=>zt(Yr(R,s?.id,j,i.full,!Ri)),children:Ri?"Done":"Edit"}),Ri&&Fc.test(R)&&m.jsx(at,{id:"edit-source-btn",variant:"toolbar",title:sn?"Back to editing the page":"Edit this file's HTML markup",onClick:()=>Yi(ve=>!ve),children:sn?"Edit page":"Edit source"}),pr&&m.jsx(at,{id:"share-btn",variant:"toolbar",className:"icon-only",title:"Share","aria-label":"Share",onClick:It,children:m.jsx(st,{name:"share"})}),Ae&&m.jsx(at,{id:"full-btn",ref:mr,variant:"toolbar",className:"icon-only",title:"Fullscreen","aria-label":"Fullscreen",onClick:jo,children:m.jsx(st,{name:"expand"})}),_e&&!R&&!i.view&&m.jsxs(at,{id:"history-btn",variant:"toolbar",onClick:Qn,children:[m.jsx(st,{name:"hist"})," ",m.jsx("span",{className:"lbl",children:"History"})]}),dt&&m.jsx("a",{id:"download",hidden:!0,download:!0,href:Ve,ref:ti,children:"Download"}),on&&!Ct&&m.jsx("a",{id:"print",hidden:!0,target:"_blank",rel:"noopener",href:qt,ref:Oi,children:"Print"}),an&&m.jsx(at,{id:"more-btn",variant:"toolbar",className:"icon-only",title:"More actions","aria-label":"More actions",onClick:ve=>{ve.stopPropagation(),Ge(!Xe)},children:m.jsx(st,{name:"dots"})}),Xe&&m.jsxs("div",{id:"more-menu",role:"menu",children:[_e&&m.jsx("button",{className:"more-item",onClick:Qn,children:"History"}),dt&&m.jsx("button",{className:"more-item",onClick:()=>ti.current?.click(),children:"Download"}),on&&m.jsx("button",{id:"print-item",className:"more-item",onClick:ln,children:"Print"}),Se&&m.jsx("button",{className:"more-item",onClick:ke,children:"Copy web link"}),Zt&&m.jsx("button",{className:"more-item",onClick:yi,children:"Copy"}),r&&!!s&&m.jsx("button",{className:"more-item",onClick:()=>{t.onClosePanel?.(),zt(Zi("dashboard",s?.id,R))},children:"Dashboard"})]})]})});return m.jsxs(m.Fragment,{children:[m.jsx(vl,{vault:t.sidebar.vault,projectsNav:t.sidebar.projectsNav,orgBar:t.sidebar.orgBar,tree:m.jsx(Fte,{root:u,expanded:N,onToggle:oe,currentPath:L,listingShowing:Y,restricted:$,onOpen:V}),topbar:id,exit:ni?m.jsxs("button",{id:"exit-full",ref:qs,onClick:ii,"aria-label":"Exit fullscreen",children:[m.jsx(st,{name:"shrink"}),m.jsx("span",{className:"lbl",children:"Exit"}),m.jsx("kbd",{children:"esc"})]}):void 0,contentRef:le,onContentScroll:X,children:m.jsxs(Gc,{width:Xh,className:nd,children:[!At&&G&&m.jsx(Xpe,{shares:he,canRevoke:!!s&&_s(s.perm,"write"),onChanged:q}),vi]})}),xe&&s&&m.jsx(Ipe,{project:s,path:R,isDir:ne,shares:U||[],onChanged:q,onOpenFolder:ve=>zt(Yr(ve,s.id)),onClose:()=>{Ze(!1),q()}}),m.jsx(Sge,{open:Qt,onClose:()=>lt(!1),candidates:Do})]})}function Bge({config:t}){const e=m1(),n=uD(),[i,r]=w.useState(null),[s,o]=w.useState(null);w.useEffect(()=>o(null),[e]);const l=w.useMemo(()=>{if(!t.desktop)return null;const I=e.split("?")[0].match(/^\/setup(?:\/(connect|syncing|done))?\/?$/);return I?I[1]??"welcome":null},[e,t.desktop]),u=w.useMemo(()=>{const I=e.split("?")[0].match(/^\/join\/([0-9a-f]+)\/?$/);return I?I[1]:null},[e]),f=w.useMemo(()=>new URLSearchParams(e.split("?")[1]||"").get("p")||"",[e]),h=$F(),{data:p}=_F(!u),{data:O}=oD(!u),y=!!t.auth.admin,{data:v}=cD(y),S=w.useMemo(()=>pD(e,"hub"),[e]),[k,C]=w.useState(!1),$=()=>t.desktop?zt("/setup/connect"):C(!0),T=t.upload.enabled,Q=async(I,X)=>{const V=X===SN;try{const J=await Wr("/api/projects",{name:I,template:V?"":X});C(!1),await n(),zt("/"+J.project.id+(V?"?connect=existing":"")),Be(`Created “${J.project.name}”.`)}catch(J){Be("Could not create the project: "+J.message,!0)}},A=k&&!t.desktop?m.jsx(ote,{templates:t.templates??[],onCreate:Q,onClose:()=>C(!1)}):null,R=w.useMemo(()=>p&&(p.find(I=>I.id===S.project)||i&&p.find(I=>I.org===i)||p.find(I=>I.id===Cq())||p[0])||null,[p,S.project,i]),j=f1(t.desktop?R?.id:void 0),L=w.useMemo(()=>!R||!t.desktop?R:{...R,perm:j.data?.me??R.perm},[R,t.desktop,j.data]);if(w.useEffect(()=>{document.title=R?hD(S,R.name):t.brand||"BearDrive"},[R,S,t.brand]),w.useEffect(()=>{R&&_q(R.id)},[R]),u)return m.jsx(Uge,{token:u,onDone:async I=>{r(I),await n();const V=!!(f?await h().catch(()=>null):null)?.projects?.some(J=>J.id===f);zt(V?"/"+f+"/install":"/",{replace:!0})}});const ne=t.brand||"BearDrive",G=R&&O?.find(I=>I.id===R.org)||null,H=m.jsx(DO,{name:ne,onHome:()=>zt("/"),search:!!R,beta:ne==="BearDrive"}),Y=fr(),re=(I,X)=>{X&&Be(X),dm(I).catch(()=>{}).finally(()=>Y.invalidateQueries({queryKey:["config"]}))},K=t.me?m.jsx(Vee,{me:t.me,org:G,orgActive:!!S.org,billing:t.billing,mcp:t.mcp,signOut:t.desktop?()=>re("/api/desktop/logout"):void 0,admin:y?{pending:v?.length||0,onClick:()=>{o({kind:"hub"}),Fr()}}:void 0}):t.desktop?m.jsx(Bee,{onSignIn:()=>re("/api/desktop/login","Finish signing in in your browser…")}):void 0;if(l)return m.jsx(vl,{vault:H,topbar:m.jsx(bl,{}),children:m.jsx(Gc,{children:m.jsx(ste,{step:l,signedIn:!!t.me,onSignIn:()=>re("/api/desktop/login","Finish signing in in your browser…")})})});if(!p||!O)return m.jsx(vl,{vault:H,topbar:m.jsx(bl,{}),children:m.jsx(Gc,{children:m.jsx("div",{className:"empty",children:"Loading…"})})});if(t.desktop&&p.length===0)return m.jsx(hl,{to:"/setup"});if(!R)return m.jsxs(vl,{vault:H,projectsNav:m.jsx(fb,{projects:p,onNew:$}),orgBar:K,topbar:m.jsx(bl,{}),children:[m.jsx(Gc,{children:m.jsx(Jee,{onNew:$,canCreate:T})}),A]});const ye=s?.kind==="hub"?{crumb:"Signup & access",body:m.jsx(Aee,{})}:null,N=S.org?O.find(I=>I.id===S.org):null,ce=S.org&&!N?{crumb:"Organization",body:m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"Organization not found"}),m.jsx("p",{children:"This organization doesn't exist, or you're no longer a member."}),m.jsx("p",{children:m.jsxs("a",{...Cl("/"+R.id),children:["Back to ",R.name]})})]})}:N?{crumb:"Organization",body:m.jsx(Eee,{org:N,projects:p,myEmail:t.me?.email||""})}:null;if(!!S.project&&!p.some(I=>I.id===S.project)){const I=jF(p,S.project);return I?m.jsx(hl,{to:S.view?Zi(S.view,I,S.viewTarget,S.filters):Yr(S.path,I,S.version,S.full,S.editing)}):m.jsxs(vl,{vault:H,projectsNav:m.jsx(fb,{projects:p,onNew:$}),orgBar:K,topbar:m.jsx(bl,{}),children:[m.jsx(Gc,{children:m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"Project not found"}),m.jsxs("p",{children:["There's no project called “",LO(S.project),"” in your account. It may have been renamed or deleted, or the link may be wrong."]}),m.jsx("p",{children:m.jsxs("a",{...Cl("/"+R.id),children:["Back to ",R.name]})})]})}),A]})}const le=S.connections?{crumb:"Connected agents",body:t.mcp?m.jsx(Pee,{projects:p}):m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"No agent access on this hub"}),m.jsx("p",{children:"This BearDrive hub doesn't serve an MCP endpoint."})]})}:null,D=S.billing?{crumb:"Billing",body:t.billing?m.jsx(Uee,{url:t.billing.url}):m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"No billing on this hub"}),m.jsx("p",{children:"This BearDrive hub doesn't have a billing surface."})]})}:null,P=S.view==="settings"?{crumb:"Project settings",body:m.jsx(Fee,{project:L??R,org:G,onDeleted:async()=>{await n(),zt("/")}})}:S.view==="install"?{crumb:"Installation",body:m.jsx(bN,{project:R,existing:S.connect==="existing"})}:null;return!S.org&&!S.billing&&!S.connections&&S.project!==R.id?m.jsx(hl,{to:"/"+R.id}):S.legacyView&&S.view?m.jsx(hl,{to:Zi(S.view,R.id,S.viewTarget,S.filters)}):S.queryTarget&&S.view?m.jsx(hl,{to:Zi(S.view,R.id,S.viewTarget,S.filters)}):S.trailingSlash&&S.path?m.jsx(hl,{to:Yr(S.path,R.id,S.version,S.full,S.editing)}):m.jsxs(m.Fragment,{children:[m.jsx(IZ,{config:t,apiBase:"/api/p/"+R.id+"/",route:S,hub:!0,project:L??R,projects:p,sidebar:{vault:H,projectsNav:m.jsx(fb,{projects:p,currentId:R.id,onNew:$,menu:{active:s?null:S.view==="dashboard"&&!S.viewTarget?"dashboard":S.view==="install"?"install":S.view==="history"&&!S.viewTarget?"history":S.view==="settings"?"settings":null,onDashboard:()=>{o(null),zt(Zi("dashboard",R.id)),Fr()},onInstall:()=>{o(null),zt(Zi("install",R.id)),Fr()},onHistory:()=>{o(null),zt(Zi("history",R.id)),Fr()},onSettings:()=>{o(null),zt(Zi("settings",R.id)),Fr()}}}),orgBar:K},panel:ye||ce||D||le||P,onClosePanel:()=>o(null)},R.id),A]})}function Uge({token:t,onDone:e}){return w.useEffect(()=>{let n=!1;return Wr("/api/invites/"+t).then(i=>{n||(Be(`Welcome — you joined the “${i.org.name}” team. Opening its projects…`),e(i.org.id))}).catch(i=>{n||String(i.message).includes("signing in")||(Be("Could not accept the invite: "+i.message,!0),e(null))}),()=>{n=!0}},[t]),m.jsx(vl,{vault:m.jsx(DO,{name:"BearDrive",beta:!0}),topbar:m.jsx(bl,{}),children:m.jsx(Gc,{children:m.jsx("div",{className:"empty",children:"Joining…"})})})}function qge({config:t}){const e=m1(),n=t.volume||"BearDrive",i=w.useMemo(()=>pD(e,"volume"),[e]),r=t.brand||t.volume;return w.useEffect(()=>{document.title=r?hD(i,r):"BearDrive"},[i,r]),i.trailingSlash&&i.path?m.jsx(hl,{to:Yr(i.path,void 0,i.version,i.full,i.editing)}):m.jsx(IZ,{config:t,apiBase:"/api/",route:i,hub:!1,sidebar:{vault:m.jsx(DO,{name:n,showSignout:t.auth.enabled,search:!0})}})}function Yge(){const{data:t}=Cw();return m.jsxs(yq,{delayDuration:150,children:[t?t.mode==="hub"?m.jsx(Bge,{config:t}):m.jsx(qge,{config:t}):m.jsx(vl,{vault:m.jsx(DO,{name:"…",showSignout:!1}),topbar:m.jsx(bl,{}),children:m.jsx("div",{className:"empty",children:"Loading…"})}),m.jsx(yF,{}),m.jsx(wF,{})]})}class Fge extends w.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,n){console.error("BearDrive: unhandled render error",e,n.componentStack)}render(){return this.state.error?m.jsxs("div",{className:"mx-auto max-w-lg p-8 text-sm",children:[m.jsx("h1",{className:"mb-2 text-lg font-semibold",children:"This page didn’t load"}),m.jsx("p",{className:"mb-4 opacity-80",children:"Something went wrong rendering this view. The rest of BearDrive is fine."}),m.jsx("p",{className:"mb-4",children:m.jsx("a",{className:"underline",href:"/",children:"Go to the project list"})}),m.jsx("pre",{className:"overflow-x-auto rounded bg-black/5 p-3 text-xs dark:bg-white/10",children:String(this.state.error)})]}):this.props.children}}const Gge=new MX({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1,staleTime:3e4}}});lX.createRoot(document.getElementById("root")).render(m.jsx(w.StrictMode,{children:m.jsx(Fge,{children:m.jsx(DX,{client:Gge,children:m.jsx(Yge,{})})})})); diff --git a/internal/webapp/static/assets/index-CLl9iapu.js b/internal/webapp/static/assets/index-CLl9iapu.js new file mode 100644 index 0000000..d15dec9 --- /dev/null +++ b/internal/webapp/static/assets/index-CLl9iapu.js @@ -0,0 +1,152 @@ +import{g as NA}from"./_commonjsHelpers-CqkleIqs.js";import{h as BI,r as UI}from"./mermaid-DQuCJ8Gi.js";function qI(t,e){for(var n=0;ni[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=n(r);fetch(r.href,s)}})();var Nv={exports:{}},Ud={};var LT;function YI(){if(LT)return Ud;LT=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(i,r,s){var o=null;if(s!==void 0&&(o=""+s),r.key!==void 0&&(o=""+r.key),"key"in r){s={};for(var l in r)l!=="key"&&(s[l]=r[l])}else s=r;return r=s.ref,{$$typeof:t,type:i,key:o,ref:r!==void 0?r:null,props:s}}return Ud.Fragment=e,Ud.jsx=n,Ud.jsxs=n,Ud}var ZT;function FI(){return ZT||(ZT=1,Nv.exports=YI()),Nv.exports}var m=FI(),zv={exports:{}},Je={};var IT;function GI(){if(IT)return Je;IT=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),O=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=O&&D[O]||D["@@iterator"],typeof D=="function"?D:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,k={};function C(D,j,I){this.props=D,this.context=j,this.refs=k,this.updater=I||v}C.prototype.isReactComponent={},C.prototype.setState=function(D,j){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,j,"setState")},C.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function $(){}$.prototype=C.prototype;function T(D,j,I){this.props=D,this.context=j,this.refs=k,this.updater=I||v}var Q=T.prototype=new $;Q.constructor=T,S(Q,C.prototype),Q.isPureReactComponent=!0;var A=Array.isArray;function R(){}var P={H:null,A:null,T:null,S:null},X=Object.prototype.hasOwnProperty;function te(D,j,I){var N=I.ref;return{$$typeof:t,type:D,key:j,ref:N!==void 0?N:null,props:I}}function G(D,j){return te(D.type,j,D.props)}function Y(D){return typeof D=="object"&&D!==null&&D.$$typeof===t}function K(D){var j={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(I){return j[I]})}var se=/\/+/g;function H(D,j){return typeof D=="object"&&D!==null&&D.key!=null?K(""+D.key):j.toString(36)}function pe(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(R,R):(D.status="pending",D.then(function(j){D.status==="pending"&&(D.status="fulfilled",D.value=j)},function(j){D.status==="pending"&&(D.status="rejected",D.reason=j)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function z(D,j,I,N,V){var ne=typeof D;(ne==="undefined"||ne==="boolean")&&(D=null);var ie=!1;if(D===null)ie=!0;else switch(ne){case"bigint":case"string":case"number":ie=!0;break;case"object":switch(D.$$typeof){case t:case e:ie=!0;break;case h:return ie=D._init,z(ie(D._payload),j,I,N,V)}}if(ie)return V=V(D),ie=N===""?"."+H(D,0):N,A(V)?(I="",ie!=null&&(I=ie.replace(se,"$&/")+"/"),z(V,j,I,"",function(Le){return Le})):V!=null&&(Y(V)&&(V=G(V,I+(V.key==null||D&&D.key===V.key?"":(""+V.key).replace(se,"$&/")+"/")+ie)),j.push(V)),1;ie=0;var ye=N===""?".":N+":";if(A(D))for(var xe=0;xe>>1,ae=z[oe];if(0>>1;oer(I,ce))Nr(V,I)?(z[oe]=V,z[N]=ce,oe=N):(z[oe]=I,z[j]=ce,oe=j);else if(Nr(V,ce))z[oe]=V,z[N]=ce,oe=N;else break e}}return W}function r(z,W){var ce=z.sortIndex-W.sortIndex;return ce!==0?ce:z.id-W.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var u=[],f=[],h=1,p=null,O=3,y=!1,v=!1,S=!1,k=!1,C=typeof setTimeout=="function"?setTimeout:null,$=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function Q(z){for(var W=n(f);W!==null;){if(W.callback===null)i(f);else if(W.startTime<=z)i(f),W.sortIndex=W.expirationTime,e(u,W);else break;W=n(f)}}function A(z){if(S=!1,Q(z),!v)if(n(u)!==null)v=!0,R||(R=!0,K());else{var W=n(f);W!==null&&pe(A,W.startTime-z)}}var R=!1,P=-1,X=5,te=-1;function G(){return k?!0:!(t.unstable_now()-tez&&G());){var oe=p.callback;if(typeof oe=="function"){p.callback=null,O=p.priorityLevel;var ae=oe(p.expirationTime<=z);if(z=t.unstable_now(),typeof ae=="function"){p.callback=ae,Q(z),W=!0;break t}p===n(u)&&i(u),Q(z)}else i(u);p=n(u)}if(p!==null)W=!0;else{var D=n(f);D!==null&&pe(A,D.startTime-z),W=!1}}break e}finally{p=null,O=ce,y=!1}W=void 0}}finally{W?K():R=!1}}}var K;if(typeof T=="function")K=function(){T(Y)};else if(typeof MessageChannel<"u"){var se=new MessageChannel,H=se.port2;se.port1.onmessage=Y,K=function(){H.postMessage(null)}}else K=function(){C(Y,0)};function pe(z,W){P=C(function(){z(t.unstable_now())},W)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(z){z.callback=null},t.unstable_forceFrameRate=function(z){0>z||125oe?(z.sortIndex=ce,e(f,z),n(u)===null&&z===n(f)&&(S?($(P),P=-1):S=!0,pe(A,ce-oe))):(z.sortIndex=ae,e(u,z),v||y||(v=!0,R||(R=!0,K()))),z},t.unstable_shouldYield=G,t.unstable_wrapCallback=function(z){var W=O;return function(){var ce=O;O=W;try{return z.apply(this,arguments)}finally{O=ce}}}})(Iv)),Iv}var BT;function WI(){return BT||(BT=1,Zv.exports=HI()),Zv.exports}var Xv={exports:{}},oi={};var UT;function KI(){if(UT)return oi;UT=1;var t=mw();function e(u){var f="https://react.dev/errors/"+u;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Xv.exports=KI(),Xv.exports}var YT;function JI(){if(YT)return qd;YT=1;var t=WI(),e=mw(),n=zA();function i(a){var c="https://react.dev/errors/"+a;if(1ae||(a.current=oe[ae],oe[ae]=null,ae--)}function I(a,c){ae++,oe[ae]=a.current,a.current=c}var N=D(null),V=D(null),ne=D(null),ie=D(null);function ye(a,c){switch(I(ne,c),I(V,a),I(N,null),c.nodeType){case 9:case 11:a=(a=c.documentElement)&&(a=a.namespaceURI)?lT(a):0;break;default:if(a=c.tagName,c=c.namespaceURI)c=lT(c),a=cT(c,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}j(N),I(N,a)}function xe(){j(N),j(V),j(ne)}function Le(a){a.memoizedState!==null&&I(ie,a);var c=N.current,d=cT(c,a.type);c!==d&&(I(V,a),I(N,d))}function Ue(a){V.current===a&&(j(N),j(V)),ie.current===a&&(j(ie),Id._currentValue=ce)}var Ke,Et;function ht(a){if(Ke===void 0)try{throw Error()}catch(d){var c=d.stack.trim().match(/\n( *(at )?)/);Ke=c&&c[1]||"",Et=-1)":-1b||L[g]!==ee[b]){var ue=` +`+L[g].replace(" at new "," at ");return a.displayName&&ue.includes("")&&(ue=ue.replace("",a.displayName)),ue}while(1<=g&&0<=b);break}}}finally{ti=!1,Error.prepareStackTrace=d}return(d=a?a.displayName||a.name:"")?ht(d):""}function At(a,c){switch(a.tag){case 26:case 27:case 5:return ht(a.type);case 16:return ht("Lazy");case 13:return a.child!==c&&c!==null?ht("Suspense Fallback"):ht("Suspense");case 19:return ht("SuspenseList");case 0:case 15:return Oi(a.type,!1);case 11:return Oi(a.type.render,!1);case 1:return Oi(a.type,!0);case 31:return ht("Activity");default:return""}}function pr(a){try{var c="",d=null;do c+=At(a,d),d=a,a=a.return;while(a);return c}catch(g){return` +Error generating stack: `+g.message+` +`+g.stack}}var zn=Object.prototype.hasOwnProperty,gr=t.unstable_scheduleCallback,Ri=t.unstable_cancelCallback,sn=t.unstable_shouldYield,Yi=t.unstable_requestPaint,xn=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,mr=t.unstable_ImmediatePriority,qs=t.unstable_UserBlockingPriority,Fi=t.unstable_NormalPriority,jo=t.unstable_LowPriority,ii=t.unstable_IdlePriority,M=t.log,U=t.unstable_setDisableYieldValue,q=null,he=null;function me(a){if(typeof M=="function"&&U(a),he&&typeof he.setStrictMode=="function")try{he.setStrictMode(q,a)}catch{}}var Se=Math.clz32?Math.clz32:Ae,ke=Math.log,_e=Math.LN2;function Ae(a){return a>>>=0,a===0?32:31-(ke(a)/_e|0)|0}var ut=256,Zt=262144,on=4194304;function an(a){var c=a&42;if(c!==0)return c;switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function Xe(a,c,d){var g=a.pendingLanes;if(g===0)return 0;var b=0,x=a.suspendedLanes,_=a.pingedLanes;a=a.warmLanes;var E=g&134217727;return E!==0?(g=E&~x,g!==0?b=an(g):(_&=E,_!==0?b=an(_):d||(d=E&~a,d!==0&&(b=an(d))))):(E=g&~x,E!==0?b=an(E):_!==0?b=an(_):d||(d=g&~a,d!==0&&(b=an(d)))),b===0?0:c!==0&&c!==b&&(c&x)===0&&(x=b&-b,d=c&-c,x>=d||x===32&&(d&4194048)!==0)?c:b}function Ct(a,c){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&c)===0}function qt(a,c){switch(a){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32: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 c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ln(){var a=on;return on<<=1,(on&62914560)===0&&(on=4194304),a}function yi(a){for(var c=[],d=0;31>d;d++)c.push(a);return c}function It(a,c){a.pendingLanes|=c,c!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function ri(a,c,d,g,b,x){var _=a.pendingLanes;a.pendingLanes=d,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=d,a.entangledLanes&=d,a.errorRecoveryDisabledLanes&=d,a.shellSuspendCounter=0;var E=a.entanglements,L=a.expirationTimes,ee=a.hiddenUpdates;for(d=_&~d;0"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var zZ=/[\n"\\]/g;function yr(a){return a.replace(zZ,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function Qy(a,c,d,g,b,x,_,E){a.name="",_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?a.type=_:a.removeAttribute("type"),c!=null?_==="number"?(c===0&&a.value===""||a.value!=c)&&(a.value=""+Or(c)):a.value!==""+Or(c)&&(a.value=""+Or(c)):_!=="submit"&&_!=="reset"||a.removeAttribute("value"),c!=null?Ay(a,_,Or(c)):d!=null?Ay(a,_,Or(d)):g!=null&&a.removeAttribute("value"),b==null&&x!=null&&(a.defaultChecked=!!x),b!=null&&(a.checked=b&&typeof b!="function"&&typeof b!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?a.name=""+Or(E):a.removeAttribute("name")}function nC(a,c,d,g,b,x,_,E){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(a.type=x),c!=null||d!=null){if(!(x!=="submit"&&x!=="reset"||c!=null)){Ry(a);return}d=d!=null?""+Or(d):"",c=c!=null?""+Or(c):d,E||c===a.value||(a.value=c),a.defaultValue=c}g=g??b,g=typeof g!="function"&&typeof g!="symbol"&&!!g,a.checked=E?a.checked:!!g,a.defaultChecked=!!g,_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"&&(a.name=_),Ry(a)}function Ay(a,c,d){c==="number"&&Uh(a.ownerDocument)===a||a.defaultValue===""+d||(a.defaultValue=""+d)}function ec(a,c,d,g){if(a=a.options,c){c={};for(var b=0;b"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ny=!1;if(Hs)try{var sd={};Object.defineProperty(sd,"passive",{get:function(){Ny=!0}}),window.addEventListener("test",sd,sd),window.removeEventListener("test",sd,sd)}catch{Ny=!1}var zo=null,zy=null,Yh=null;function cC(){if(Yh)return Yh;var a,c=zy,d=c.length,g,b="value"in zo?zo.value:zo.textContent,x=b.length;for(a=0;a=ld),gC=" ",mC=!1;function OC(a,c){switch(a){case"keyup":return f4.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yC(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var rc=!1;function p4(a,c){switch(a){case"compositionend":return yC(c);case"keypress":return c.which!==32?null:(mC=!0,gC);case"textInput":return a=c.data,a===gC&&mC?null:a;default:return null}}function g4(a,c){if(rc)return a==="compositionend"||!Vy&&OC(a,c)?(a=cC(),Yh=zy=zo=null,rc=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1=c)return{node:d,offset:c-a};a=g}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=_C(d)}}function TC(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?TC(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function EC(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var c=Uh(a.document);c instanceof a.HTMLIFrameElement;){try{var d=typeof c.contentWindow.location.href=="string"}catch{d=!1}if(d)a=c.contentWindow;else break;c=Uh(a.document)}return c}function qy(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c&&(c==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||c==="textarea"||a.contentEditable==="true")}var w4=Hs&&"documentMode"in document&&11>=document.documentMode,sc=null,Yy=null,fd=null,Fy=!1;function RC(a,c,d){var g=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Fy||sc==null||sc!==Uh(g)||(g=sc,"selectionStart"in g&&qy(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),fd&&dd(fd,g)||(fd=g,g=Zp(Yy,"onSelect"),0>=_,b-=_,cs=1<<32-Se(c)+b|d<it?(ft=Me,Me=null):ft=Me.sibling;var bt=re(F,Me,J[it],de);if(bt===null){Me===null&&(Me=ft);break}a&&Me&&bt.alternate===null&&c(F,Me),B=x(bt,B,it),vt===null?Ie=bt:vt.sibling=bt,vt=bt,Me=ft}if(it===J.length)return d(F,Me),pt&&Ks(F,it),Ie;if(Me===null){for(;itit?(ft=Me,Me=null):ft=Me.sibling;var oa=re(F,Me,bt.value,de);if(oa===null){Me===null&&(Me=ft);break}a&&Me&&oa.alternate===null&&c(F,Me),B=x(oa,B,it),vt===null?Ie=oa:vt.sibling=oa,vt=oa,Me=ft}if(bt.done)return d(F,Me),pt&&Ks(F,it),Ie;if(Me===null){for(;!bt.done;it++,bt=J.next())bt=fe(F,bt.value,de),bt!==null&&(B=x(bt,B,it),vt===null?Ie=bt:vt.sibling=bt,vt=bt);return pt&&Ks(F,it),Ie}for(Me=g(Me);!bt.done;it++,bt=J.next())bt=le(Me,F,it,bt.value,de),bt!==null&&(a&&bt.alternate!==null&&Me.delete(bt.key===null?it:bt.key),B=x(bt,B,it),vt===null?Ie=bt:vt.sibling=bt,vt=bt);return a&&Me.forEach(function(VI){return c(F,VI)}),pt&&Ks(F,it),Ie}function Dt(F,B,J,de){if(typeof J=="object"&&J!==null&&J.type===S&&J.key===null&&(J=J.props.children),typeof J=="object"&&J!==null){switch(J.$$typeof){case y:e:{for(var Ie=J.key;B!==null;){if(B.key===Ie){if(Ie=J.type,Ie===S){if(B.tag===7){d(F,B.sibling),de=b(B,J.props.children),de.return=F,F=de;break e}}else if(B.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===X&&il(Ie)===B.type){d(F,B.sibling),de=b(B,J.props),yd(de,J),de.return=F,F=de;break e}d(F,B);break}else c(F,B);B=B.sibling}J.type===S?(de=Ka(J.props.children,F.mode,de,J.key),de.return=F,F=de):(de=ip(J.type,J.key,J.props,null,F.mode,de),yd(de,J),de.return=F,F=de)}return _(F);case v:e:{for(Ie=J.key;B!==null;){if(B.key===Ie)if(B.tag===4&&B.stateNode.containerInfo===J.containerInfo&&B.stateNode.implementation===J.implementation){d(F,B.sibling),de=b(B,J.children||[]),de.return=F,F=de;break e}else{d(F,B);break}else c(F,B);B=B.sibling}de=t0(J,F.mode,de),de.return=F,F=de}return _(F);case X:return J=il(J),Dt(F,B,J,de)}if(pe(J))return Qe(F,B,J,de);if(K(J)){if(Ie=K(J),typeof Ie!="function")throw Error(i(150));return J=Ie.call(J),qe(F,B,J,de)}if(typeof J.then=="function")return Dt(F,B,up(J),de);if(J.$$typeof===T)return Dt(F,B,op(F,J),de);dp(F,J)}return typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint"?(J=""+J,B!==null&&B.tag===6?(d(F,B.sibling),de=b(B,J),de.return=F,F=de):(d(F,B),de=e0(J,F.mode,de),de.return=F,F=de),_(F)):d(F,B)}return function(F,B,J,de){try{Od=0;var Ie=Dt(F,B,J,de);return mc=null,Ie}catch(Me){if(Me===gc||Me===lp)throw Me;var vt=Hi(29,Me,null,F.mode);return vt.lanes=de,vt.return=F,vt}}}var sl=JC(!0),e_=JC(!1),Vo=!1;function h0(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function p0(a,c){a=a.updateQueue,c.updateQueue===a&&(c.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function Bo(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function Uo(a,c,d){var g=a.updateQueue;if(g===null)return null;if(g=g.shared,(xt&2)!==0){var b=g.pending;return b===null?c.next=c:(c.next=b.next,b.next=c),g.pending=c,c=np(a),NC(a,null,d),c}return tp(a,g,c,d),np(a)}function vd(a,c,d){if(c=c.updateQueue,c!==null&&(c=c.shared,(d&4194048)!==0)){var g=c.lanes;g&=a.pendingLanes,d|=g,c.lanes=d,Ln(a,d)}}function g0(a,c){var d=a.updateQueue,g=a.alternate;if(g!==null&&(g=g.updateQueue,d===g)){var b=null,x=null;if(d=d.firstBaseUpdate,d!==null){do{var _={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};x===null?b=x=_:x=x.next=_,d=d.next}while(d!==null);x===null?b=x=c:x=x.next=c}else b=x=c;d={baseState:g.baseState,firstBaseUpdate:b,lastBaseUpdate:x,shared:g.shared,callbacks:g.callbacks},a.updateQueue=d;return}a=d.lastBaseUpdate,a===null?d.firstBaseUpdate=c:a.next=c,d.lastBaseUpdate=c}var m0=!1;function bd(){if(m0){var a=pc;if(a!==null)throw a}}function Sd(a,c,d,g){m0=!1;var b=a.updateQueue;Vo=!1;var x=b.firstBaseUpdate,_=b.lastBaseUpdate,E=b.shared.pending;if(E!==null){b.shared.pending=null;var L=E,ee=L.next;L.next=null,_===null?x=ee:_.next=ee,_=L;var ue=a.alternate;ue!==null&&(ue=ue.updateQueue,E=ue.lastBaseUpdate,E!==_&&(E===null?ue.firstBaseUpdate=ee:E.next=ee,ue.lastBaseUpdate=L))}if(x!==null){var fe=b.baseState;_=0,ue=ee=L=null,E=x;do{var re=E.lane&-536870913,le=re!==E.lane;if(le?(dt&re)===re:(g&re)===re){re!==0&&re===hc&&(m0=!0),ue!==null&&(ue=ue.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Qe=a,qe=E;re=c;var Dt=d;switch(qe.tag){case 1:if(Qe=qe.payload,typeof Qe=="function"){fe=Qe.call(Dt,fe,re);break e}fe=Qe;break e;case 3:Qe.flags=Qe.flags&-65537|128;case 0:if(Qe=qe.payload,re=typeof Qe=="function"?Qe.call(Dt,fe,re):Qe,re==null)break e;fe=p({},fe,re);break e;case 2:Vo=!0}}re=E.callback,re!==null&&(a.flags|=64,le&&(a.flags|=8192),le=b.callbacks,le===null?b.callbacks=[re]:le.push(re))}else le={lane:re,tag:E.tag,payload:E.payload,callback:E.callback,next:null},ue===null?(ee=ue=le,L=fe):ue=ue.next=le,_|=re;if(E=E.next,E===null){if(E=b.shared.pending,E===null)break;le=E,E=le.next,le.next=null,b.lastBaseUpdate=le,b.shared.pending=null}}while(!0);ue===null&&(L=fe),b.baseState=L,b.firstBaseUpdate=ee,b.lastBaseUpdate=ue,x===null&&(b.shared.lanes=0),Ho|=_,a.lanes=_,a.memoizedState=fe}}function t_(a,c){if(typeof a!="function")throw Error(i(191,a));a.call(c)}function n_(a,c){var d=a.callbacks;if(d!==null)for(a.callbacks=null,a=0;ax?x:8;var _=z.T,E={};z.T=E,M0(a,!1,c,d);try{var L=b(),ee=z.S;if(ee!==null&&ee(E,L),L!==null&&typeof L=="object"&&typeof L.then=="function"){var ue=A4(L,g);kd(a,c,ue,tr(a))}else kd(a,c,g,tr(a))}catch(fe){kd(a,c,{then:function(){},status:"rejected",reason:fe},tr())}finally{W.p=x,_!==null&&E.types!==null&&(_.types=E.types),z.T=_}}function z4(){}function P0(a,c,d,g){if(a.tag!==5)throw Error(i(476));var b=j_(a).queue;P_(a,b,c,ce,d===null?z4:function(){return M_(a),d(g)})}function j_(a){var c=a.memoizedState;if(c!==null)return c;c={memoizedState:ce,baseState:ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:no,lastRenderedState:ce},next:null};var d={};return c.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:no,lastRenderedState:d},next:null},a.memoizedState=c,a=a.alternate,a!==null&&(a.memoizedState=c),c}function M_(a){var c=j_(a);c.next===null&&(c=a.alternate.memoizedState),kd(a,c.next.queue,{},tr())}function j0(){return qn(Id)}function D_(){return gn().memoizedState}function N_(){return gn().memoizedState}function L4(a){for(var c=a.return;c!==null;){switch(c.tag){case 24:case 3:var d=tr();a=Bo(d);var g=Uo(c,a,d);g!==null&&(Ni(g,c,d),vd(g,c,d)),c={cache:c0()},a.payload=c;return}c=c.return}}function Z4(a,c,d){var g=tr();d={lane:g,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Sp(a)?L_(c,d):(d=Ky(a,c,d,g),d!==null&&(Ni(d,a,g),Z_(d,c,g)))}function z_(a,c,d){var g=tr();kd(a,c,d,g)}function kd(a,c,d,g){var b={lane:g,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(Sp(a))L_(c,b);else{var x=a.alternate;if(a.lanes===0&&(x===null||x.lanes===0)&&(x=c.lastRenderedReducer,x!==null))try{var _=c.lastRenderedState,E=x(_,d);if(b.hasEagerState=!0,b.eagerState=E,Gi(E,_))return tp(a,c,b,0),Xt===null&&ep(),!1}catch{}if(d=Ky(a,c,b,g),d!==null)return Ni(d,a,g),Z_(d,c,g),!0}return!1}function M0(a,c,d,g){if(g={lane:2,revertLane:hv(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},Sp(a)){if(c)throw Error(i(479))}else c=Ky(a,d,g,2),c!==null&&Ni(c,a,2)}function Sp(a){var c=a.alternate;return a===tt||c!==null&&c===tt}function L_(a,c){yc=pp=!0;var d=a.pending;d===null?c.next=c:(c.next=d.next,d.next=c),a.pending=c}function Z_(a,c,d){if((d&4194048)!==0){var g=c.lanes;g&=a.pendingLanes,d|=g,c.lanes=d,Ln(a,d)}}var Cd={readContext:qn,use:Op,useCallback:cn,useContext:cn,useEffect:cn,useImperativeHandle:cn,useLayoutEffect:cn,useInsertionEffect:cn,useMemo:cn,useReducer:cn,useRef:cn,useState:cn,useDebugValue:cn,useDeferredValue:cn,useTransition:cn,useSyncExternalStore:cn,useId:cn,useHostTransitionStatus:cn,useFormState:cn,useActionState:cn,useOptimistic:cn,useMemoCache:cn,useCacheRefresh:cn};Cd.useEffectEvent=cn;var I_={readContext:qn,use:Op,useCallback:function(a,c){return bi().memoizedState=[a,c===void 0?null:c],a},useContext:qn,useEffect:k_,useImperativeHandle:function(a,c,d){d=d!=null?d.concat([a]):null,vp(4194308,4,T_.bind(null,c,a),d)},useLayoutEffect:function(a,c){return vp(4194308,4,a,c)},useInsertionEffect:function(a,c){vp(4,2,a,c)},useMemo:function(a,c){var d=bi();c=c===void 0?null:c;var g=a();if(ol){me(!0);try{a()}finally{me(!1)}}return d.memoizedState=[g,c],g},useReducer:function(a,c,d){var g=bi();if(d!==void 0){var b=d(c);if(ol){me(!0);try{d(c)}finally{me(!1)}}}else b=c;return g.memoizedState=g.baseState=b,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:b},g.queue=a,a=a.dispatch=Z4.bind(null,tt,a),[g.memoizedState,a]},useRef:function(a){var c=bi();return a={current:a},c.memoizedState=a},useState:function(a){a=T0(a);var c=a.queue,d=z_.bind(null,tt,c);return c.dispatch=d,[a.memoizedState,d]},useDebugValue:Q0,useDeferredValue:function(a,c){var d=bi();return A0(d,a,c)},useTransition:function(){var a=T0(!1);return a=P_.bind(null,tt,a.queue,!0,!1),bi().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,c,d){var g=tt,b=bi();if(pt){if(d===void 0)throw Error(i(407));d=d()}else{if(d=c(),Xt===null)throw Error(i(349));(dt&127)!==0||l_(g,c,d)}b.memoizedState=d;var x={value:d,getSnapshot:c};return b.queue=x,k_(u_.bind(null,g,x,a),[a]),g.flags|=2048,bc(9,{destroy:void 0},c_.bind(null,g,x,d,c),null),d},useId:function(){var a=bi(),c=Xt.identifierPrefix;if(pt){var d=us,g=cs;d=(g&~(1<<32-Se(g)-1)).toString(32)+d,c="_"+c+"R_"+d,d=gp++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof g.is=="string"?_.createElement("select",{is:g.is}):_.createElement("select"),g.multiple?x.multiple=!0:g.size&&(x.size=g.size);break;default:x=typeof g.is=="string"?_.createElement(b,{is:g.is}):_.createElement(b)}}x[Rn]=c,x[Qn]=g;e:for(_=c.child;_!==null;){if(_.tag===5||_.tag===6)x.appendChild(_.stateNode);else if(_.tag!==4&&_.tag!==27&&_.child!==null){_.child.return=_,_=_.child;continue}if(_===c)break e;for(;_.sibling===null;){if(_.return===null||_.return===c)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}c.stateNode=x;e:switch(Fn(x,b,g),b){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&ro(c)}}return Gt(c),G0(c,c.type,a===null?null:a.memoizedProps,c.pendingProps,d),null;case 6:if(a&&c.stateNode!=null)a.memoizedProps!==g&&ro(c);else{if(typeof g!="string"&&c.stateNode===null)throw Error(i(166));if(a=ne.current,dc(c)){if(a=c.stateNode,d=c.memoizedProps,g=null,b=Un,b!==null)switch(b.tag){case 27:case 5:g=b.memoizedProps}a[Rn]=c,a=!!(a.nodeValue===d||g!==null&&g.suppressHydrationWarning===!0||oT(a.nodeValue,d)),a||Io(c,!0)}else a=Ip(a).createTextNode(g),a[Rn]=c,c.stateNode=a}return Gt(c),null;case 31:if(d=c.memoizedState,a===null||a.memoizedState!==null){if(g=dc(c),d!==null){if(a===null){if(!g)throw Error(i(318));if(a=c.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(i(557));a[Rn]=c}else Ja(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Gt(c),a=!1}else d=s0(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=d),a=!0;if(!a)return c.flags&256?(Ki(c),c):(Ki(c),null);if((c.flags&128)!==0)throw Error(i(558))}return Gt(c),null;case 13:if(g=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(b=dc(c),g!==null&&g.dehydrated!==null){if(a===null){if(!b)throw Error(i(318));if(b=c.memoizedState,b=b!==null?b.dehydrated:null,!b)throw Error(i(317));b[Rn]=c}else Ja(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Gt(c),b=!1}else b=s0(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=b),b=!0;if(!b)return c.flags&256?(Ki(c),c):(Ki(c),null)}return Ki(c),(c.flags&128)!==0?(c.lanes=d,c):(d=g!==null,a=a!==null&&a.memoizedState!==null,d&&(g=c.child,b=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(b=g.alternate.memoizedState.cachePool.pool),x=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(x=g.memoizedState.cachePool.pool),x!==b&&(g.flags|=2048)),d!==a&&d&&(c.child.flags|=8192),_p(c,c.updateQueue),Gt(c),null);case 4:return xe(),a===null&&Ov(c.stateNode.containerInfo),Gt(c),null;case 10:return eo(c.type),Gt(c),null;case 19:if(j(pn),g=c.memoizedState,g===null)return Gt(c),null;if(b=(c.flags&128)!==0,x=g.rendering,x===null)if(b)$d(g,!1);else{if(un!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(x=hp(a),x!==null){for(c.flags|=128,$d(g,!1),a=x.updateQueue,c.updateQueue=a,_p(c,a),c.subtreeFlags=0,a=d,d=c.child;d!==null;)zC(d,a),d=d.sibling;return I(pn,pn.current&1|2),pt&&Ks(c,g.treeForkCount),c.child}a=a.sibling}g.tail!==null&&xn()>Qp&&(c.flags|=128,b=!0,$d(g,!1),c.lanes=4194304)}else{if(!b)if(a=hp(x),a!==null){if(c.flags|=128,b=!0,a=a.updateQueue,c.updateQueue=a,_p(c,a),$d(g,!0),g.tail===null&&g.tailMode==="hidden"&&!x.alternate&&!pt)return Gt(c),null}else 2*xn()-g.renderingStartTime>Qp&&d!==536870912&&(c.flags|=128,b=!0,$d(g,!1),c.lanes=4194304);g.isBackwards?(x.sibling=c.child,c.child=x):(a=g.last,a!==null?a.sibling=x:c.child=x,g.last=x)}return g.tail!==null?(a=g.tail,g.rendering=a,g.tail=a.sibling,g.renderingStartTime=xn(),a.sibling=null,d=pn.current,I(pn,b?d&1|2:d&1),pt&&Ks(c,g.treeForkCount),a):(Gt(c),null);case 22:case 23:return Ki(c),y0(),g=c.memoizedState!==null,a!==null?a.memoizedState!==null!==g&&(c.flags|=8192):g&&(c.flags|=8192),g?(d&536870912)!==0&&(c.flags&128)===0&&(Gt(c),c.subtreeFlags&6&&(c.flags|=8192)):Gt(c),d=c.updateQueue,d!==null&&_p(c,d.retryQueue),d=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),g=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(g=c.memoizedState.cachePool.pool),g!==d&&(c.flags|=2048),a!==null&&j(nl),null;case 24:return d=null,a!==null&&(d=a.memoizedState.cache),c.memoizedState.cache!==d&&(c.flags|=2048),eo(wn),Gt(c),null;case 25:return null;case 30:return null}throw Error(i(156,c.tag))}function U4(a,c){switch(i0(c),c.tag){case 1:return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return eo(wn),xe(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 26:case 27:case 5:return Ue(c),null;case 31:if(c.memoizedState!==null){if(Ki(c),c.alternate===null)throw Error(i(340));Ja()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 13:if(Ki(c),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(i(340));Ja()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return j(pn),null;case 4:return xe(),null;case 10:return eo(c.type),null;case 22:case 23:return Ki(c),y0(),a!==null&&j(nl),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 24:return eo(wn),null;case 25:return null;default:return null}}function d$(a,c){switch(i0(c),c.tag){case 3:eo(wn),xe();break;case 26:case 27:case 5:Ue(c);break;case 4:xe();break;case 31:c.memoizedState!==null&&Ki(c);break;case 13:Ki(c);break;case 19:j(pn);break;case 10:eo(c.type);break;case 22:case 23:Ki(c),y0(),a!==null&&j(nl);break;case 24:eo(wn)}}function Td(a,c){try{var d=c.updateQueue,g=d!==null?d.lastEffect:null;if(g!==null){var b=g.next;d=b;do{if((d.tag&a)===a){g=void 0;var x=d.create,_=d.inst;g=x(),_.destroy=g}d=d.next}while(d!==b)}}catch(E){Qt(c,c.return,E)}}function Fo(a,c,d){try{var g=c.updateQueue,b=g!==null?g.lastEffect:null;if(b!==null){var x=b.next;g=x;do{if((g.tag&a)===a){var _=g.inst,E=_.destroy;if(E!==void 0){_.destroy=void 0,b=c;var L=d,ee=E;try{ee()}catch(ue){Qt(b,L,ue)}}}g=g.next}while(g!==x)}}catch(ue){Qt(c,c.return,ue)}}function f$(a){var c=a.updateQueue;if(c!==null){var d=a.stateNode;try{n_(c,d)}catch(g){Qt(a,a.return,g)}}}function h$(a,c,d){d.props=al(a.type,a.memoizedProps),d.state=a.memoizedState;try{d.componentWillUnmount()}catch(g){Qt(a,c,g)}}function Ed(a,c){try{var d=a.ref;if(d!==null){switch(a.tag){case 26:case 27:case 5:var g=a.stateNode;break;case 30:g=a.stateNode;break;default:g=a.stateNode}typeof d=="function"?a.refCleanup=d(g):d.current=g}}catch(b){Qt(a,c,b)}}function ds(a,c){var d=a.ref,g=a.refCleanup;if(d!==null)if(typeof g=="function")try{g()}catch(b){Qt(a,c,b)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(b){Qt(a,c,b)}else d.current=null}function p$(a){var c=a.type,d=a.memoizedProps,g=a.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":d.autoFocus&&g.focus();break e;case"img":d.src?g.src=d.src:d.srcSet&&(g.srcset=d.srcSet)}}catch(b){Qt(a,a.return,b)}}function H0(a,c,d){try{var g=a.stateNode;hI(g,a.type,d,c),g[Qn]=c}catch(b){Qt(a,a.return,b)}}function g$(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&ta(a.type)||a.tag===4}function W0(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||g$(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&ta(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function K0(a,c,d){var g=a.tag;if(g===5||g===6)a=a.stateNode,c?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(a,c):(c=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,c.appendChild(a),d=d._reactRootContainer,d!=null||c.onclick!==null||(c.onclick=Gs));else if(g!==4&&(g===27&&ta(a.type)&&(d=a.stateNode,c=null),a=a.child,a!==null))for(K0(a,c,d),a=a.sibling;a!==null;)K0(a,c,d),a=a.sibling}function $p(a,c,d){var g=a.tag;if(g===5||g===6)a=a.stateNode,c?d.insertBefore(a,c):d.appendChild(a);else if(g!==4&&(g===27&&ta(a.type)&&(d=a.stateNode),a=a.child,a!==null))for($p(a,c,d),a=a.sibling;a!==null;)$p(a,c,d),a=a.sibling}function m$(a){var c=a.stateNode,d=a.memoizedProps;try{for(var g=a.type,b=c.attributes;b.length;)c.removeAttributeNode(b[0]);Fn(c,g,d),c[Rn]=a,c[Qn]=d}catch(x){Qt(a,a.return,x)}}var so=!1,_n=!1,J0=!1,O$=typeof WeakSet=="function"?WeakSet:Set,Zn=null;function q4(a,c){if(a=a.containerInfo,bv=Fp,a=EC(a),qy(a)){if("selectionStart"in a)var d={start:a.selectionStart,end:a.selectionEnd};else e:{d=(d=a.ownerDocument)&&d.defaultView||window;var g=d.getSelection&&d.getSelection();if(g&&g.rangeCount!==0){d=g.anchorNode;var b=g.anchorOffset,x=g.focusNode;g=g.focusOffset;try{d.nodeType,x.nodeType}catch{d=null;break e}var _=0,E=-1,L=-1,ee=0,ue=0,fe=a,re=null;t:for(;;){for(var le;fe!==d||b!==0&&fe.nodeType!==3||(E=_+b),fe!==x||g!==0&&fe.nodeType!==3||(L=_+g),fe.nodeType===3&&(_+=fe.nodeValue.length),(le=fe.firstChild)!==null;)re=fe,fe=le;for(;;){if(fe===a)break t;if(re===d&&++ee===b&&(E=_),re===x&&++ue===g&&(L=_),(le=fe.nextSibling)!==null)break;fe=re,re=fe.parentNode}fe=le}d=E===-1||L===-1?null:{start:E,end:L}}else d=null}d=d||{start:0,end:0}}else d=null;for(Sv={focusedElem:a,selectionRange:d},Fp=!1,Zn=c;Zn!==null;)if(c=Zn,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,Zn=a;else for(;Zn!==null;){switch(c=Zn,x=c.alternate,a=c.flags,c.tag){case 0:if((a&4)!==0&&(a=c.updateQueue,a=a!==null?a.events:null,a!==null))for(d=0;d title"))),Fn(x,g,d),x[Rn]=a,Pt(x),g=x;break e;case"link":var _=wT("link","href",b).get(g+(d.href||""));if(_){for(var E=0;E<_.length;E++)if(x=_[E],x.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&x.getAttribute("rel")===(d.rel==null?null:d.rel)&&x.getAttribute("title")===(d.title==null?null:d.title)&&x.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){_.splice(E,1);break t}}x=b.createElement(g),Fn(x,g,d),b.head.appendChild(x);break;case"meta":if(_=wT("meta","content",b).get(g+(d.content||""))){for(E=0;E<_.length;E++)if(x=_[E],x.getAttribute("content")===(d.content==null?null:""+d.content)&&x.getAttribute("name")===(d.name==null?null:d.name)&&x.getAttribute("property")===(d.property==null?null:d.property)&&x.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&x.getAttribute("charset")===(d.charSet==null?null:d.charSet)){_.splice(E,1);break t}}x=b.createElement(g),Fn(x,g,d),b.head.appendChild(x);break;default:throw Error(i(468,g))}x[Rn]=a,Pt(x),g=x}a.stateNode=g}else kT(b,a.type,a.stateNode);else a.stateNode=xT(b,g,a.memoizedProps);else x!==g?(x===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):x.count--,g===null?kT(b,a.type,a.stateNode):xT(b,g,a.memoizedProps)):g===null&&a.stateNode!==null&&H0(a,a.memoizedProps,d.memoizedProps)}break;case 27:ji(c,a),Mi(a),g&512&&(_n||d===null||ds(d,d.return)),d!==null&&g&4&&H0(a,a.memoizedProps,d.memoizedProps);break;case 5:if(ji(c,a),Mi(a),g&512&&(_n||d===null||ds(d,d.return)),a.flags&32){b=a.stateNode;try{tc(b,"")}catch(Qe){Qt(a,a.return,Qe)}}g&4&&a.stateNode!=null&&(b=a.memoizedProps,H0(a,b,d!==null?d.memoizedProps:b)),g&1024&&(J0=!0);break;case 6:if(ji(c,a),Mi(a),g&4){if(a.stateNode===null)throw Error(i(162));g=a.memoizedProps,d=a.stateNode;try{d.nodeValue=g}catch(Qe){Qt(a,a.return,Qe)}}break;case 3:if(Bp=null,b=Vr,Vr=Xp(c.containerInfo),ji(c,a),Vr=b,Mi(a),g&4&&d!==null&&d.memoizedState.isDehydrated)try{Ac(c.containerInfo)}catch(Qe){Qt(a,a.return,Qe)}J0&&(J0=!1,k$(a));break;case 4:g=Vr,Vr=Xp(a.stateNode.containerInfo),ji(c,a),Mi(a),Vr=g;break;case 12:ji(c,a),Mi(a);break;case 31:ji(c,a),Mi(a),g&4&&(g=a.updateQueue,g!==null&&(a.updateQueue=null,Tp(a,g)));break;case 13:ji(c,a),Mi(a),a.child.flags&8192&&a.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&(Rp=xn()),g&4&&(g=a.updateQueue,g!==null&&(a.updateQueue=null,Tp(a,g)));break;case 22:b=a.memoizedState!==null;var L=d!==null&&d.memoizedState!==null,ee=so,ue=_n;if(so=ee||b,_n=ue||L,ji(c,a),_n=ue,so=ee,Mi(a),g&8192)e:for(c=a.stateNode,c._visibility=b?c._visibility&-2:c._visibility|1,b&&(d===null||L||so||_n||ll(a)),d=null,c=a;;){if(c.tag===5||c.tag===26){if(d===null){L=d=c;try{if(x=L.stateNode,b)_=x.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none";else{E=L.stateNode;var fe=L.memoizedProps.style,re=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;E.style.display=re==null||typeof re=="boolean"?"":(""+re).trim()}}catch(Qe){Qt(L,L.return,Qe)}}}else if(c.tag===6){if(d===null){L=c;try{L.stateNode.nodeValue=b?"":L.memoizedProps}catch(Qe){Qt(L,L.return,Qe)}}}else if(c.tag===18){if(d===null){L=c;try{var le=L.stateNode;b?hT(le,!0):hT(L.stateNode,!1)}catch(Qe){Qt(L,L.return,Qe)}}}else if((c.tag!==22&&c.tag!==23||c.memoizedState===null||c===a)&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===a)break e;for(;c.sibling===null;){if(c.return===null||c.return===a)break e;d===c&&(d=null),c=c.return}d===c&&(d=null),c.sibling.return=c.return,c=c.sibling}g&4&&(g=a.updateQueue,g!==null&&(d=g.retryQueue,d!==null&&(g.retryQueue=null,Tp(a,d))));break;case 19:ji(c,a),Mi(a),g&4&&(g=a.updateQueue,g!==null&&(a.updateQueue=null,Tp(a,g)));break;case 30:break;case 21:break;default:ji(c,a),Mi(a)}}function Mi(a){var c=a.flags;if(c&2){try{for(var d,g=a.return;g!==null;){if(g$(g)){d=g;break}g=g.return}if(d==null)throw Error(i(160));switch(d.tag){case 27:var b=d.stateNode,x=W0(a);$p(a,x,b);break;case 5:var _=d.stateNode;d.flags&32&&(tc(_,""),d.flags&=-33);var E=W0(a);$p(a,E,_);break;case 3:case 4:var L=d.stateNode.containerInfo,ee=W0(a);K0(a,ee,L);break;default:throw Error(i(161))}}catch(ue){Qt(a,a.return,ue)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function k$(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var c=a;k$(c),c.tag===5&&c.flags&1024&&c.stateNode.reset(),a=a.sibling}}function ao(a,c){if(c.subtreeFlags&8772)for(c=c.child;c!==null;)y$(a,c.alternate,c),c=c.sibling}function ll(a){for(a=a.child;a!==null;){var c=a;switch(c.tag){case 0:case 11:case 14:case 15:Fo(4,c,c.return),ll(c);break;case 1:ds(c,c.return);var d=c.stateNode;typeof d.componentWillUnmount=="function"&&h$(c,c.return,d),ll(c);break;case 27:zd(c.stateNode);case 26:case 5:ds(c,c.return),ll(c);break;case 22:c.memoizedState===null&&ll(c);break;case 30:ll(c);break;default:ll(c)}a=a.sibling}}function lo(a,c,d){for(d=d&&(c.subtreeFlags&8772)!==0,c=c.child;c!==null;){var g=c.alternate,b=a,x=c,_=x.flags;switch(x.tag){case 0:case 11:case 15:lo(b,x,d),Td(4,x);break;case 1:if(lo(b,x,d),g=x,b=g.stateNode,typeof b.componentDidMount=="function")try{b.componentDidMount()}catch(ee){Qt(g,g.return,ee)}if(g=x,b=g.updateQueue,b!==null){var E=g.stateNode;try{var L=b.shared.hiddenCallbacks;if(L!==null)for(b.shared.hiddenCallbacks=null,b=0;bDt&&(_=Dt,Dt=qe,qe=_);var F=$C(E,qe),B=$C(E,Dt);if(F&&B&&(le.rangeCount!==1||le.anchorNode!==F.node||le.anchorOffset!==F.offset||le.focusNode!==B.node||le.focusOffset!==B.offset)){var J=fe.createRange();J.setStart(F.node,F.offset),le.removeAllRanges(),qe>Dt?(le.addRange(J),le.extend(B.node,B.offset)):(J.setEnd(B.node,B.offset),le.addRange(J))}}}}for(fe=[],le=E;le=le.parentNode;)le.nodeType===1&&fe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;Ed?32:d,z.T=null,d=ov,ov=null;var x=Ko,_=uo;if(An=0,Cc=Ko=null,uo=0,(xt&6)!==0)throw Error(i(331));var E=xt;if(xt|=4,T$(x.current),C$(x,x.current,_,d),xt=E,Md(0,!1),he&&typeof he.onPostCommitFiberRoot=="function")try{he.onPostCommitFiberRoot(q,x)}catch{}return!0}finally{W.p=b,z.T=g,q$(a,c)}}function F$(a,c,d){c=br(d,c),c=L0(a.stateNode,c,2),a=Uo(a,c,2),a!==null&&(It(a,2),fs(a))}function Qt(a,c,d){if(a.tag===3)F$(a,a,d);else for(;c!==null;){if(c.tag===3){F$(c,a,d);break}else if(c.tag===1){var g=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Wo===null||!Wo.has(g))){a=br(d,a),d=G_(2),g=Uo(c,d,2),g!==null&&(H_(d,g,c,a),It(g,2),fs(g));break}}c=c.return}}function uv(a,c,d){var g=a.pingCache;if(g===null){g=a.pingCache=new G4;var b=new Set;g.set(c,b)}else b=g.get(c),b===void 0&&(b=new Set,g.set(c,b));b.has(d)||(nv=!0,b.add(d),a=eI.bind(null,a,c,d),c.then(a,a))}function eI(a,c,d){var g=a.pingCache;g!==null&&g.delete(c),a.pingedLanes|=a.suspendedLanes&d,a.warmLanes&=~d,Xt===a&&(dt&d)===d&&(un===4||un===3&&(dt&62914560)===dt&&300>xn()-Rp?(xt&2)===0&&_c(a,0):iv|=d,kc===dt&&(kc=0)),fs(a)}function G$(a,c){c===0&&(c=ln()),a=Wa(a,c),a!==null&&(It(a,c),fs(a))}function tI(a){var c=a.memoizedState,d=0;c!==null&&(d=c.retryLane),G$(a,d)}function nI(a,c){var d=0;switch(a.tag){case 31:case 13:var g=a.stateNode,b=a.memoizedState;b!==null&&(d=b.retryLane);break;case 19:g=a.stateNode;break;case 22:g=a.stateNode._retryCache;break;default:throw Error(i(314))}g!==null&&g.delete(c),G$(a,d)}function iI(a,c){return gr(a,c)}var Np=null,Tc=null,dv=!1,zp=!1,fv=!1,ea=0;function fs(a){a!==Tc&&a.next===null&&(Tc===null?Np=Tc=a:Tc=Tc.next=a),zp=!0,dv||(dv=!0,sI())}function Md(a,c){if(!fv&&zp){fv=!0;do for(var d=!1,g=Np;g!==null;){if(a!==0){var b=g.pendingLanes;if(b===0)var x=0;else{var _=g.suspendedLanes,E=g.pingedLanes;x=(1<<31-Se(42|a)+1)-1,x&=b&~(_&~E),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(d=!0,J$(g,x))}else x=dt,x=Xe(g,g===Xt?x:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(x&3)===0||Ct(g,x)||(d=!0,J$(g,x));g=g.next}while(d);fv=!1}}function rI(){H$()}function H$(){zp=dv=!1;var a=0;ea!==0&&gI()&&(a=ea);for(var c=xn(),d=null,g=Np;g!==null;){var b=g.next,x=W$(g,c);x===0?(g.next=null,d===null?Np=b:d.next=b,b===null&&(Tc=d)):(d=g,(a!==0||(x&3)!==0)&&(zp=!0)),g=b}An!==0&&An!==5||Md(a),ea!==0&&(ea=0)}function W$(a,c){for(var d=a.suspendedLanes,g=a.pingedLanes,b=a.expirationTimes,x=a.pendingLanes&-62914561;0E)break;var ue=L.transferSize,fe=L.initiatorType;ue&&aT(fe)&&(L=L.responseEnd,_+=ue*(L"u"?null:document;function vT(a,c,d){var g=Ec;if(g&&typeof c=="string"&&c){var b=yr(c);b='link[rel="'+a+'"][href="'+b+'"]',typeof d=="string"&&(b+='[crossorigin="'+d+'"]'),yT.has(b)||(yT.add(b),a={rel:a,crossOrigin:d,href:c},g.querySelector(b)===null&&(c=g.createElement("link"),Fn(c,"link",a),Pt(c),g.head.appendChild(c)))}}function kI(a){fo.D(a),vT("dns-prefetch",a,null)}function CI(a,c){fo.C(a,c),vT("preconnect",a,c)}function _I(a,c,d){fo.L(a,c,d);var g=Ec;if(g&&a&&c){var b='link[rel="preload"][as="'+yr(c)+'"]';c==="image"&&d&&d.imageSrcSet?(b+='[imagesrcset="'+yr(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(b+='[imagesizes="'+yr(d.imageSizes)+'"]')):b+='[href="'+yr(a)+'"]';var x=b;switch(c){case"style":x=Rc(a);break;case"script":x=Qc(a)}_r.has(x)||(a=p({rel:"preload",href:c==="image"&&d&&d.imageSrcSet?void 0:a,as:c},d),_r.set(x,a),g.querySelector(b)!==null||c==="style"&&g.querySelector(Ld(x))||c==="script"&&g.querySelector(Zd(x))||(c=g.createElement("link"),Fn(c,"link",a),Pt(c),g.head.appendChild(c)))}}function $I(a,c){fo.m(a,c);var d=Ec;if(d&&a){var g=c&&typeof c.as=="string"?c.as:"script",b='link[rel="modulepreload"][as="'+yr(g)+'"][href="'+yr(a)+'"]',x=b;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Qc(a)}if(!_r.has(x)&&(a=p({rel:"modulepreload",href:a},c),_r.set(x,a),d.querySelector(b)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(Zd(x)))return}g=d.createElement("link"),Fn(g,"link",a),Pt(g),d.head.appendChild(g)}}}function TI(a,c,d){fo.S(a,c,d);var g=Ec;if(g&&a){var b=_t(g).hoistableStyles,x=Rc(a);c=c||"default";var _=b.get(x);if(!_){var E={loading:0,preload:null};if(_=g.querySelector(Ld(x)))E.loading=5;else{a=p({rel:"stylesheet",href:a,"data-precedence":c},d),(d=_r.get(x))&&Tv(a,d);var L=_=g.createElement("link");Pt(L),Fn(L,"link",a),L._p=new Promise(function(ee,ue){L.onload=ee,L.onerror=ue}),L.addEventListener("load",function(){E.loading|=1}),L.addEventListener("error",function(){E.loading|=2}),E.loading|=4,Vp(_,c,g)}_={type:"stylesheet",instance:_,count:1,state:E},b.set(x,_)}}}function EI(a,c){fo.X(a,c);var d=Ec;if(d&&a){var g=_t(d).hoistableScripts,b=Qc(a),x=g.get(b);x||(x=d.querySelector(Zd(b)),x||(a=p({src:a,async:!0},c),(c=_r.get(b))&&Ev(a,c),x=d.createElement("script"),Pt(x),Fn(x,"link",a),d.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},g.set(b,x))}}function RI(a,c){fo.M(a,c);var d=Ec;if(d&&a){var g=_t(d).hoistableScripts,b=Qc(a),x=g.get(b);x||(x=d.querySelector(Zd(b)),x||(a=p({src:a,async:!0,type:"module"},c),(c=_r.get(b))&&Ev(a,c),x=d.createElement("script"),Pt(x),Fn(x,"link",a),d.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},g.set(b,x))}}function bT(a,c,d,g){var b=(b=ne.current)?Xp(b):null;if(!b)throw Error(i(446));switch(a){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(c=Rc(d.href),d=_t(b).hoistableStyles,g=d.get(c),g||(g={type:"style",instance:null,count:0,state:null},d.set(c,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){a=Rc(d.href);var x=_t(b).hoistableStyles,_=x.get(a);if(_||(b=b.ownerDocument||b,_={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(a,_),(x=b.querySelector(Ld(a)))&&!x._p&&(_.instance=x,_.state.loading=5),_r.has(a)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},_r.set(a,d),x||QI(b,a,d,_.state))),c&&g===null)throw Error(i(528,""));return _}if(c&&g!==null)throw Error(i(529,""));return null;case"script":return c=d.async,d=d.src,typeof d=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=Qc(d),d=_t(b).hoistableScripts,g=d.get(c),g||(g={type:"script",instance:null,count:0,state:null},d.set(c,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,a))}}function Rc(a){return'href="'+yr(a)+'"'}function Ld(a){return'link[rel="stylesheet"]['+a+"]"}function ST(a){return p({},a,{"data-precedence":a.precedence,precedence:null})}function QI(a,c,d,g){a.querySelector('link[rel="preload"][as="style"]['+c+"]")?g.loading=1:(c=a.createElement("link"),g.preload=c,c.addEventListener("load",function(){return g.loading|=1}),c.addEventListener("error",function(){return g.loading|=2}),Fn(c,"link",d),Pt(c),a.head.appendChild(c))}function Qc(a){return'[src="'+yr(a)+'"]'}function Zd(a){return"script[async]"+a}function xT(a,c,d){if(c.count++,c.instance===null)switch(c.type){case"style":var g=a.querySelector('style[data-href~="'+yr(d.href)+'"]');if(g)return c.instance=g,Pt(g),g;var b=p({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return g=(a.ownerDocument||a).createElement("style"),Pt(g),Fn(g,"style",b),Vp(g,d.precedence,a),c.instance=g;case"stylesheet":b=Rc(d.href);var x=a.querySelector(Ld(b));if(x)return c.state.loading|=4,c.instance=x,Pt(x),x;g=ST(d),(b=_r.get(b))&&Tv(g,b),x=(a.ownerDocument||a).createElement("link"),Pt(x);var _=x;return _._p=new Promise(function(E,L){_.onload=E,_.onerror=L}),Fn(x,"link",g),c.state.loading|=4,Vp(x,d.precedence,a),c.instance=x;case"script":return x=Qc(d.src),(b=a.querySelector(Zd(x)))?(c.instance=b,Pt(b),b):(g=d,(b=_r.get(x))&&(g=p({},d),Ev(g,b)),a=a.ownerDocument||a,b=a.createElement("script"),Pt(b),Fn(b,"link",g),a.head.appendChild(b),c.instance=b);case"void":return null;default:throw Error(i(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(g=c.instance,c.state.loading|=4,Vp(g,d.precedence,a));return c.instance}function Vp(a,c,d){for(var g=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),b=g.length?g[g.length-1]:null,x=b,_=0;_ title"):null)}function AI(a,c,d){if(d===1||c.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;return c.rel==="stylesheet"?(a=c.disabled,typeof c.precedence=="string"&&a==null):!0;case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function CT(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function PI(a,c,d,g){if(d.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var b=Rc(g.href),x=c.querySelector(Ld(b));if(x){c=x._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(a.count++,a=Up.bind(a),c.then(a,a)),d.state.loading|=4,d.instance=x,Pt(x);return}x=c.ownerDocument||c,g=ST(g),(b=_r.get(b))&&Tv(g,b),x=x.createElement("link"),Pt(x);var _=x;_._p=new Promise(function(E,L){_.onload=E,_.onerror=L}),Fn(x,"link",g),d.instance=x}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(d,c),(c=d.state.preload)&&(d.state.loading&3)===0&&(a.count++,d=Up.bind(a),c.addEventListener("load",d),c.addEventListener("error",d))}}var Rv=0;function jI(a,c){return a.stylesheets&&a.count===0&&Yp(a,a.stylesheets),0Rv?50:800)+c);return a.unsuspend=d,function(){a.unsuspend=null,clearTimeout(g),clearTimeout(b)}}:null}function Up(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Yp(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var qp=null;function Yp(a,c){a.stylesheets=null,a.unsuspend!==null&&(a.count++,qp=new Map,c.forEach(MI,a),qp=null,Up.call(a))}function MI(a,c){if(!(c.state.loading&4)){var d=qp.get(a);if(d)var g=d.get(null);else{d=new Map,qp.set(a,d);for(var b=a.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Lv.exports=JI(),Lv.exports}var tX=eX(),Iu=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},nX=class extends Iu{#e;#t;#n;constructor(){super(),this.#n=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Ow=new nX,iX={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},rX=class{#e=iX;#t=!1;setTimeoutProvider(t){this.#e=t}setTimeout(t,e){return this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},yl=new rX;function sX(t){setTimeout(t,0)}var oX=typeof window>"u"||"Deno"in globalThis;function xi(){}function aX(t,e){return typeof t=="function"?t(e):t}function OS(t){return typeof t=="number"&&t>=0&&t!==1/0}function LA(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ba(t,e){return typeof t=="function"?t(e):t}function ar(t,e){return typeof t=="function"?t(e):t}function GT(t,e){const{type:n="all",exact:i,fetchStatus:r,predicate:s,queryKey:o,stale:l}=t;if(o){if(i){if(e.queryHash!==yw(o,e.options))return!1}else if(!Tf(e.queryKey,o))return!1}if(n!=="all"){const u=e.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof l=="boolean"&&e.isStale()!==l||r&&r!==e.state.fetchStatus||s&&!s(e))}function HT(t,e){const{exact:n,status:i,predicate:r,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(El(e.options.mutationKey)!==El(s))return!1}else if(!Tf(e.options.mutationKey,s))return!1}return!(i&&e.state.status!==i||r&&!r(e))}function yw(t,e){return(e?.queryKeyHashFn||El)(t)}function El(t){return JSON.stringify(t,(e,n)=>yS(n)?Object.keys(n).sort().reduce((i,r)=>(i[r]=n[r],i),{}):n)}function Tf(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>Tf(t[n],e[n])):!1}var lX=Object.prototype.hasOwnProperty;function ZA(t,e,n=0){if(t===e)return t;if(n>500)return e;const i=WT(t)&&WT(e);if(!i&&!(yS(t)&&yS(e)))return e;const s=(i?t:Object.keys(t)).length,o=i?e:Object.keys(e),l=o.length,u=i?new Array(l):{};let f=0;for(let h=0;h{yl.setTimeout(e,t)})}function vS(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?ZA(t,e):e}function uX(t,e,n=0){const i=[...t,e];return n&&i.length>n?i.slice(1):i}function dX(t,e,n=0){const i=[e,...t];return n&&i.length>n?i.slice(0,-1):i}var vw=Symbol();function IA(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===vw?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function bw(t,e){return typeof t=="function"?t(...e):!!t}function fX(t,e,n){let i=!1,r;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(r??=e(),i||(i=!0,r.aborted?n():r.addEventListener("abort",n,{once:!0})),r)}),t}var Ef=(()=>{let t=()=>oX;return{isServer(){return t()},setIsServer(e){t=e}}})();function bS(){let t,e;const n=new Promise((r,s)=>{t=r,e=s});n.status="pending",n.catch(()=>{});function i(r){Object.assign(n,r),delete n.resolve,delete n.reject}return n.resolve=r=>{i({status:"fulfilled",value:r}),t(r)},n.reject=r=>{i({status:"rejected",reason:r}),e(r)},n}var hX=sX;function pX(){let t=[],e=0,n=l=>{l()},i=l=>{l()},r=hX;const s=l=>{e?t.push(l):r(()=>{n(l)})},o=()=>{const l=t;t=[],l.length&&r(()=>{i(()=>{l.forEach(u=>{n(u)})})})};return{batch:l=>{let u;e++;try{u=l()}finally{e--,e||o()}return u},batchCalls:l=>(...u)=>{s(()=>{l(...u)})},schedule:s,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{i=l},setScheduler:l=>{r=l}}}var Mn=pX(),gX=class extends Iu{#e=!0;#t;#n;constructor(){super(),this.#n=t=>{if(typeof window<"u"&&window.addEventListener){const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#n=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(n=>{n(t)}))}isOnline(){return this.#e}},um=new gX;function mX(t){return Math.min(1e3*2**t,3e4)}function XA(t){return(t??"online")==="online"?um.isOnline():!0}var SS=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function VA(t){let e=!1,n=0,i;const r=bS(),s=()=>r.status!=="pending",o=S=>{if(!s()){const k=new SS(S);O(k),t.onCancel?.(k)}},l=()=>{e=!0},u=()=>{e=!1},f=()=>Ow.isFocused()&&(t.networkMode==="always"||um.isOnline())&&t.canRun(),h=()=>XA(t.networkMode)&&t.canRun(),p=S=>{s()||(i?.(),r.resolve(S))},O=S=>{s()||(i?.(),r.reject(S))},y=()=>new Promise(S=>{i=k=>{(s()||f())&&S(k)},t.onPause?.()}).then(()=>{i=void 0,s()||t.onContinue?.()}),v=()=>{if(s())return;let S;const k=n===0?t.initialPromise:void 0;try{S=k??t.fn()}catch(C){S=Promise.reject(C)}Promise.resolve(S).then(p).catch(C=>{if(s())return;const $=t.retry??(Ef.isServer()?0:3),T=t.retryDelay??mX,Q=typeof T=="function"?T(n,C):T,A=$===!0||typeof $=="number"&&n<$||typeof $=="function"&&$(n,C);if(e||!A){O(C);return}n++,t.onFail?.(n,C),cX(Q).then(()=>f()?void 0:y()).then(()=>{e?O(C):v()})})};return{promise:r,status:()=>r.status,cancel:o,continue:()=>(i?.(),r),cancelRetry:l,continueRetry:u,canStart:h,start:()=>(h()?v():y().then(v),r)}}var BA=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),OS(this.gcTime)&&(this.#e=yl.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Ef.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(yl.clearTimeout(this.#e),this.#e=void 0)}};function OX(t){return{onFetch:(e,n)=>{const i=e.options,r=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},u=0;const f=async()=>{let h=!1;const p=v=>{fX(v,()=>e.signal,()=>h=!0)},O=IA(e.options,e.fetchOptions),y=async(v,S,k)=>{if(h)return Promise.reject(e.signal.reason);if(S==null&&v.pages.length)return Promise.resolve(v);const $=(()=>{const R={client:e.client,queryKey:e.queryKey,pageParam:S,direction:k?"backward":"forward",meta:e.options.meta};return p(R),R})(),T=await O($),{maxPages:Q}=e.options,A=k?dX:uX;return{pages:A(v.pages,T,Q),pageParams:A(v.pageParams,S,Q)}};if(r&&s.length){const v=r==="backward",S=v?UA:xS,k={pages:s,pageParams:o},C=S(i,k);l=await y(k,C,v)}else{const v=t??s.length;do{const S=u===0?o[0]??i.initialPageParam:xS(i,l);if(u>0&&S==null)break;l=await y(l,S),u++}while(ue.options.persister?.(f,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},n):e.fetchFn=f}}}function xS(t,{pages:e,pageParams:n}){const i=e.length-1;return e.length>0?t.getNextPageParam(e[i],e,n[i],n):void 0}function UA(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}function yX(t,e){return e?xS(t,e)!=null:!1}function vX(t,e){return!e||!t.getPreviousPageParam?!1:UA(t,e)!=null}var bX=class extends BA{#e;#t;#n;#i;#s;#r;#a;#o;constructor(t){super(),this.#o=!1,this.#a=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.#s=t.client,this.#i=this.#s.getQueryCache(),this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.#t=e2(this.options),this.state=t.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#r?.promise}setOptions(t){if(this.options={...this.#a,...t},t?._type&&(this.#e=t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const e=e2(this.options);e.data!==void 0&&(this.setState(JT(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#i.remove(this)}setData(t,e){const n=vS(this.state.data,t,this.options);return this.#l({data:n,type:"success",dataUpdatedAt:e?.updatedAt,manual:e?.manual}),n}setState(t){this.#l({type:"setState",state:t})}cancel(t){const e=this.#r?.promise;return this.#r?.cancel(t),e?e.then(xi).catch(xi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>ar(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===vw||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>ba(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!LA(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),this.#i.notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(e=>e!==t),this.observers.length||(this.#r&&(this.#o||this.#u()?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#i.notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}#u(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#l({type:"invalidate"})}async fetch(t,e){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&e?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(t&&this.setOptions(t),!this.options.queryFn){const u=this.observers.find(f=>f.options.queryFn);u&&this.setOptions(u.options)}const n=new AbortController,i=u=>{Object.defineProperty(u,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},r=()=>{const u=IA(this.options,e),h=(()=>{const p={client:this.#s,queryKey:this.queryKey,meta:this.meta};return i(p),p})();return this.#o=!1,this.options.persister?this.options.persister(u,h,this):u(h)},o=(()=>{const u={fetchOptions:e,options:this.options,queryKey:this.queryKey,client:this.#s,state:this.state,fetchFn:r};return i(u),u})();(this.#e==="infinite"?OX(this.options.pages):this.options.behavior)?.onFetch(o,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#l({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=VA({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:u=>{u instanceof SS&&u.revert&&this.setState({...this.#n,fetchStatus:"idle"}),n.abort()},onFail:(u,f)=>{this.#l({type:"failed",failureCount:u,error:f})},onPause:()=>{this.#l({type:"pause"})},onContinue:()=>{this.#l({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const u=await this.#r.start();if(u===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(u),this.#i.config.onSuccess?.(u,this),this.#i.config.onSettled?.(u,this.state.error,this),u}catch(u){if(u instanceof SS){if(u.silent)return this.#r.promise;if(u.revert){if(this.state.data===void 0)throw u;return this.state.data}}throw this.#l({type:"error",error:u}),this.#i.config.onError?.(u,this),this.#i.config.onSettled?.(this.state.data,u,this),u}finally{this.scheduleGc()}}#l(t){const e=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...qA(n.data,this.options),fetchMeta:t.meta??null};case"success":const i={...n,...JT(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=t.manual?i:void 0,i;case"error":const r=t.error;return{...n,error:r,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=e(this.state),Mn.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#i.notify({query:this,type:"updated",action:t})})}};function qA(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:XA(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function JT(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function e2(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,n=e!==void 0,i=n?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:n?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var YA=class extends Iu{constructor(t,e){super(),this.options=e,this.#e=t,this.#o=null,this.#a=bS(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#n=void 0;#i=void 0;#s;#r;#a;#o;#u;#l;#p;#d;#f;#c;#g=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),t2(this.#t,this.options)?this.#h():this.updateResult(),this.#v())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return wS(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return wS(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#S(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ar(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#t.setOptions(this.options),e._defaulted&&!cm(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const i=this.hasListeners();i&&n2(this.#t,n,this.options,e)&&this.#h(),this.updateResult(),i&&(this.#t!==n||ar(this.options.enabled,this.#t)!==ar(e.enabled,this.#t)||ba(this.options.staleTime,this.#t)!==ba(e.staleTime,this.#t))&&this.#m();const r=this.#O();i&&(this.#t!==n||ar(this.options.enabled,this.#t)!==ar(e.enabled,this.#t)||r!==this.#c)&&this.#y(r)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),n=this.createResult(e,t);return xX(this,n)&&(this.#i=n,this.#r=this.options,this.#s=this.#t.state),n}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(n,i)=>(this.trackProp(i),e?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,i))})}trackProp(t){this.#g.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),n=this.#e.getQueryCache().build(this.#e,e);return n.fetch().then(()=>this.createResult(n,e))}fetch(t){return this.#h({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#h(t){this.#x();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(xi)),e}#m(){this.#b();const t=ba(this.options.staleTime,this.#t);if(Ef.isServer()||this.#i.isStale||!OS(t))return;const n=LA(this.#i.dataUpdatedAt,t)+1;this.#d=yl.setTimeout(()=>{this.#i.isStale||this.updateResult()},n)}#O(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(t){this.#S(),this.#c=t,!(Ef.isServer()||ar(this.options.enabled,this.#t)===!1||!OS(this.#c)||this.#c===0)&&(this.#f=yl.setInterval(()=>{(this.options.refetchIntervalInBackground||Ow.isFocused())&&this.#h()},this.#c))}#v(){this.#m(),this.#y(this.#O())}#b(){this.#d!==void 0&&(yl.clearTimeout(this.#d),this.#d=void 0)}#S(){this.#f!==void 0&&(yl.clearInterval(this.#f),this.#f=void 0)}createResult(t,e){const n=this.#t,i=this.options,r=this.#i,s=this.#s,o=this.#r,u=t!==n?t.state:this.#n,{state:f}=t;let h={...f},p=!1,O;if(e._optimisticResults){const X=this.hasListeners(),te=!X&&t2(t,e),G=X&&n2(t,n,e,i);(te||G)&&(h={...h,...qA(f.data,t.options)}),e._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:y,errorUpdatedAt:v,status:S}=h;O=h.data;let k=!1;if(e.placeholderData!==void 0&&O===void 0&&S==="pending"){let X;r?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(X=r.data,k=!0):X=typeof e.placeholderData=="function"?e.placeholderData(this.#p?.state.data,this.#p):e.placeholderData,X!==void 0&&(S="success",O=vS(r?.data,X,e),p=!0)}if(e.select&&O!==void 0&&!k)if(r&&O===s?.data&&e.select===this.#u)O=this.#l;else try{this.#u=e.select,O=e.select(O),O=vS(r?.data,O,e),this.#l=O,this.#o=null}catch(X){this.#o=X}this.#o&&(y=this.#o,O=this.#l,v=Date.now(),S="error");const C=h.fetchStatus==="fetching",$=S==="pending",T=S==="error",Q=$&&C,A=O!==void 0,P={status:S,fetchStatus:h.fetchStatus,isPending:$,isSuccess:S==="success",isError:T,isInitialLoading:Q,isLoading:Q,data:O,dataUpdatedAt:h.dataUpdatedAt,error:y,errorUpdatedAt:v,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>u.dataUpdateCount||h.errorUpdateCount>u.errorUpdateCount,isFetching:C,isRefetching:C&&!$,isLoadingError:T&&!A,isPaused:h.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:T&&A,isStale:Sw(t,e),refetch:this.refetch,promise:this.#a,isEnabled:ar(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const X=P.data!==void 0,te=P.status==="error"&&!X,G=se=>{te?se.reject(P.error):X&&se.resolve(P.data)},Y=()=>{const se=this.#a=P.promise=bS();G(se)},K=this.#a;switch(K.status){case"pending":t.queryHash===n.queryHash&&G(K);break;case"fulfilled":(te||P.data!==K.value)&&Y();break;case"rejected":(!te||P.error!==K.reason)&&Y();break}}return P}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#s=this.#t.state,this.#r=this.options,this.#s.data!==void 0&&(this.#p=this.#t),cm(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,r=typeof i=="function"?i():i;if(r==="all"||!r&&!this.#g.size)return!0;const s=new Set(r??this.#g);return this.options.throwOnError&&s.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&s.has(l)})};this.#w({listeners:n()})}#x(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#n=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#v()}#w(t){Mn.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function SX(t,e){return ar(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&ar(e.retryOnMount,t)===!1)}function t2(t,e){return SX(t,e)||t.state.data!==void 0&&wS(t,e,e.refetchOnMount)}function wS(t,e,n){if(ar(e.enabled,t)!==!1&&ba(e.staleTime,t)!=="static"){const i=typeof n=="function"?n(t):n;return i==="always"||i!==!1&&Sw(t,e)}return!1}function n2(t,e,n,i){return(t!==e||ar(i.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&Sw(t,n)}function Sw(t,e){return ar(e.enabled,t)!==!1&&t.isStaleByTime(ba(e.staleTime,t))}function xX(t,e){return!cm(t.getCurrentResult(),e)}var wX=class extends YA{constructor(t,e){super(t,e)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(t){t._type="infinite",super.setOptions(t)}getOptimisticResult(t){return t._type="infinite",super.getOptimisticResult(t)}fetchNextPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(t){return this.fetch({...t,meta:{fetchMore:{direction:"backward"}}})}createResult(t,e){const{state:n}=t,i=super.createResult(t,e),{isFetching:r,isRefetching:s,isError:o,isRefetchError:l}=i,u=n.fetchMeta?.fetchMore?.direction,f=o&&u==="forward",h=r&&u==="forward",p=o&&u==="backward",O=r&&u==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:yX(e,n.data),hasPreviousPage:vX(e,n.data),isFetchNextPageError:f,isFetchingNextPage:h,isFetchPreviousPageError:p,isFetchingPreviousPage:O,isRefetchError:l&&!f&&!p,isRefetching:s&&!h&&!O}}},kX=class extends BA{#e;#t;#n;#i;constructor(t){super(),this.#e=t.client,this.mutationId=t.mutationId,this.#n=t.mutationCache,this.#t=[],this.state=t.state||FA(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#s({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=VA({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(s,o)=>{this.#s({type:"failed",failureCount:s,error:o})},onPause:()=>{this.#s({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const i=this.state.status==="pending",r=!this.#i.canStart();try{if(i)e();else{this.#s({type:"pending",variables:t,isPaused:r}),this.#n.config.onMutate&&await this.#n.config.onMutate(t,this,n);const o=await this.options.onMutate?.(t,n);o!==this.state.context&&this.#s({type:"pending",context:o,variables:t,isPaused:r})}const s=await this.#i.start();return await this.#n.config.onSuccess?.(s,t,this.state.context,this,n),await this.options.onSuccess?.(s,t,this.state.context,n),await this.#n.config.onSettled?.(s,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(s,null,t,this.state.context,n),this.#s({type:"success",data:s}),s}catch(s){try{await this.#n.config.onError?.(s,t,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onError?.(s,t,this.state.context,n)}catch(o){Promise.reject(o)}try{await this.#n.config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,n)}catch(o){Promise.reject(o)}try{await this.options.onSettled?.(void 0,s,t,this.state.context,n)}catch(o){Promise.reject(o)}throw this.#s({type:"error",error:s}),s}finally{this.#n.runNext(this)}}#s(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),Mn.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function FA(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var CX=class extends Iu{constructor(t={}){super(),this.config=t,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(t,e,n){const i=new kX({client:t,mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:n});return this.add(i),i}add(t){this.#e.add(t);const e=tg(t);if(typeof e=="string"){const n=this.#t.get(e);n?n.push(t):this.#t.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#e.delete(t)){const e=tg(t);if(typeof e=="string"){const n=this.#t.get(e);if(n)if(n.length>1){const i=n.indexOf(t);i!==-1&&n.splice(i,1)}else n[0]===t&&this.#t.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=tg(t);if(typeof e=="string"){const i=this.#t.get(e)?.find(r=>r.state.status==="pending");return!i||i===t}else return!0}runNext(t){const e=tg(t);return typeof e=="string"?this.#t.get(e)?.find(i=>i!==t&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Mn.batch(()=>{this.#e.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(t){const e={exact:!0,...t};return this.getAll().find(n=>HT(e,n))}findAll(t={}){return this.getAll().filter(e=>HT(t,e))}notify(t){Mn.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return Mn.batch(()=>Promise.all(t.map(e=>e.continue().catch(xi))))}};function tg(t){return t.options.scope?.id}var _X=class extends Iu{#e;#t=void 0;#n;#i;constructor(e,n){super(),this.#e=e,this.setOptions(n),this.bindMethods(),this.#s()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const n=this.options;this.options=this.#e.defaultMutationOptions(e),cm(this.options,n)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&El(n.mutationKey)!==El(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#s(),this.#r(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#s(),this.#r()}mutate(e,n){return this.#i=n,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#s(){const e=this.#n?.state??FA();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#r(e){Mn.batch(()=>{if(this.#i&&this.hasListeners()){const n=this.#t.variables,i=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#i.onSuccess?.(e.data,n,i,r)}catch(s){Promise.reject(s)}try{this.#i.onSettled?.(e.data,null,n,i,r)}catch(s){Promise.reject(s)}}else if(e?.type==="error"){try{this.#i.onError?.(e.error,n,i,r)}catch(s){Promise.reject(s)}try{this.#i.onSettled?.(void 0,e.error,n,i,r)}catch(s){Promise.reject(s)}}}this.listeners.forEach(n=>{n(this.#t)})})}},$X=class extends Iu{constructor(t={}){super(),this.config=t,this.#e=new Map}#e;build(t,e,n){const i=e.queryKey,r=e.queryHash??yw(i,e);let s=this.get(r);return s||(s=new bX({client:t,queryKey:i,queryHash:r,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(i)}),this.add(s)),s}add(t){this.#e.has(t.queryHash)||(this.#e.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#e.get(t.queryHash);e&&(t.destroy(),e===t&&this.#e.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Mn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#e.get(t)}getAll(){return[...this.#e.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(n=>GT(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>GT(t,n)):e}notify(t){Mn.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){Mn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Mn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},TX=class{#e;#t;#n;#i;#s;#r;#a;#o;constructor(t={}){this.#e=t.queryCache||new $X,this.#t=t.mutationCache||new CX,this.#n=t.defaultOptions||{},this.#i=new Map,this.#s=new Map,this.#r=0}mount(){this.#r++,this.#r===1&&(this.#a=Ow.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#o=um.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#r--,this.#r===0&&(this.#a?.(),this.#a=void 0,this.#o?.(),this.#o=void 0)}isFetching(t){return this.#e.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#t.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),n=this.#e.build(this,e),i=n.state.data;return i===void 0?this.fetchQuery(t):(t.revalidateIfStale&&n.isStaleByTime(ba(e.staleTime,n))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(t){return this.#e.findAll(t).map(({queryKey:e,state:n})=>{const i=n.data;return[e,i]})}setQueryData(t,e,n){const i=this.defaultQueryOptions({queryKey:t}),s=this.#e.get(i.queryHash)?.state.data,o=aX(e,s);if(o!==void 0)return this.#e.build(this,i).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return Mn.batch(()=>this.#e.findAll(t).map(({queryKey:i})=>[i,this.setQueryData(i,e,n)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#e.get(e.queryHash)?.state}removeQueries(t){const e=this.#e;Mn.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#e;return Mn.batch(()=>(n.findAll(t).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},i=Mn.batch(()=>this.#e.findAll(t).map(r=>r.cancel(n)));return Promise.all(i).then(xi).catch(xi)}invalidateQueries(t,e={}){return Mn.batch(()=>(this.#e.findAll(t).forEach(n=>{n.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const n={...e,cancelRefetch:e.cancelRefetch??!0},i=Mn.batch(()=>this.#e.findAll(t).filter(r=>!r.isDisabled()&&!r.isStatic()).map(r=>{let s=r.fetch(void 0,n);return n.throwOnError||(s=s.catch(xi)),r.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(i).then(xi)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#e.build(this,e);return n.isStaleByTime(ba(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(xi).catch(xi)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(xi).catch(xi)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return um.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(t){this.#n=t}setQueryDefaults(t,e){this.#i.set(El(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(i=>{Tf(t,i.queryKey)&&Object.assign(n,i.defaultOptions)}),n}setMutationDefaults(t,e){this.#s.set(El(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#s.values()],n={};return e.forEach(i=>{Tf(t,i.mutationKey)&&Object.assign(n,i.defaultOptions)}),n}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#n.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=yw(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===vw&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#n.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},GA=w.createContext(void 0),fr=t=>{const e=w.useContext(GA);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},EX=({client:t,children:e})=>(w.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),m.jsx(GA.Provider,{value:t,children:e})),HA=w.createContext(!1),RX=()=>w.useContext(HA);HA.Provider;function QX(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var AX=w.createContext(QX()),PX=()=>w.useContext(AX),jX=(t,e,n)=>{const i=n?.state.error&&typeof t.throwOnError=="function"?bw(t.throwOnError,[n.state.error,n]):t.throwOnError;(t.suspense||t.experimental_prefetchInRender||i)&&(e.isReset()||(t.retryOnMount=!1))},MX=t=>{w.useEffect(()=>{t.clearReset()},[t])},DX=({result:t,errorResetBoundary:e,throwOnError:n,query:i,suspense:r})=>t.isError&&!e.isReset()&&!t.isFetching&&i&&(r&&t.data===void 0||bw(n,[t.error,i])),NX=t=>{if(t.suspense){const n=r=>r==="static"?r:Math.max(r??1e3,1e3),i=t.staleTime;t.staleTime=typeof i=="function"?(...r)=>n(i(...r)):n(i),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},zX=(t,e)=>t.isLoading&&t.isFetching&&!e,LX=(t,e)=>t?.suspense&&e.isPending,i2=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function WA(t,e,n){const i=RX(),r=PX(),s=fr(),o=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(o);const l=s.getQueryCache().get(o.queryHash),u=t.subscribed!==!1;o._optimisticResults=i?"isRestoring":u?"optimistic":void 0,NX(o),jX(o,r,l),MX(r);const f=!s.getQueryCache().get(o.queryHash),[h]=w.useState(()=>new e(s,o)),p=h.getOptimisticResult(o),O=!i&&u;if(w.useSyncExternalStore(w.useCallback(y=>{const v=O?h.subscribe(Mn.batchCalls(y)):xi;return h.updateResult(),v},[h,O]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),w.useEffect(()=>{h.setOptions(o)},[o,h]),LX(o,p))throw i2(o,h,r);if(DX({result:p,errorResetBoundary:r,throwOnError:o.throwOnError,query:l,suspense:o.suspense}))throw p.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(o,p),o.experimental_prefetchInRender&&!Ef.isServer()&&zX(p,i)&&(f?i2(o,h,r):l?.promise)?.catch(xi).finally(()=>{h.updateResult()}),o.notifyOnChangeProps?p:h.trackResult(p)}function nn(t,e){return WA(t,YA)}function ZX(t,e){const n=fr(),[i]=w.useState(()=>new _X(n,t));w.useEffect(()=>{i.setOptions(t)},[i,t]);const r=w.useSyncExternalStore(w.useCallback(o=>i.subscribe(Mn.batchCalls(o)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),s=w.useCallback((o,l)=>{i.mutate(o,l).catch(xi)},[i]);if(r.error&&bw(i.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:s,mutateAsync:r.mutate}}function IX(t,e){return WA(t,wX)}let r2=!1;function XX(t){const e=t.analytics;if(!e?.key||r2)return;r2=!0;const n=document.createElement("script");n.src=e.host.replace(".i.posthog.com","-assets.i.posthog.com")+"/static/array.js",n.async=!0,n.onload=()=>{const i=window.posthog;i&&(i.init(e.key,{api_host:e.host,defaults:"2026-05-30",capture_pageview:"history_change",session_recording:{maskAllInputs:!0,maskTextSelector:"*"}}),t.me&&i.identify(t.me.email,{email:t.me.email,name:t.me.name,...t.billing?{plan:t.billing.plan}:{}}))},document.head.appendChild(n)}function KA(t,e){window.posthog?.capture(t,e)}const VX=[[/^POST \/api\/projects$/,"project_created"],[/^DELETE \/api\/projects\//,"project_deleted"],[/^POST \/api\/p\/[^/]+\/restore$/,"file_restored"],[/^DELETE \/api\/shares\//,"share_revoked"],[/^PATCH \/api\/shares\//,"share_expiry_changed"],[/^POST \/api\/orgs\/[^/]+\/invites$/,"invite_created"],[/^DELETE \/api\/orgs\/[^/]+\/invites\//,"invite_revoked"],[/^POST \/api\/invites\//,"invite_accepted"],[/^PUT \/api\/p\/[^/]+\/permissions\/./,"project_access_granted"],[/^DELETE \/api\/p\/[^/]+\/permissions\/./,"project_access_revoked"]];function gO(t,e){const n=t+" "+e.split("?")[0],i=VX.find(([r])=>r.test(n));i&&KA(i[1])}function mO(){throw location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),new Error("signing in…")}function BX(t,e){const n=e.trim();switch(t){case 403:return n.includes("seat")?"This plan is out of seats. Upgrade to add more people.":n.includes("owner")?"Only owners can do that.":"You don't have access to that.";case 409:return n?n[0].toUpperCase()+n.slice(1):"That is managed outside this hub.";case 404:return"That is gone — it may have been removed already.";case 413:return"This project is over its plan limit.";case 429:return"Too many requests. Give it a moment.";default:return t>=500?"The server had a problem. Try again.":n?n[0].toUpperCase()+n.slice(1):"Something went wrong."}}class xw extends Error{constructor(e,n,i=""){super(n),this.status=e,this.body=i,this.name="HttpError"}status;body}async function fh(t){const e=await t.text();throw new xw(t.status,BX(t.status,e),e)}async function Wt(t){const e=await fetch(t,{headers:{Accept:"application/json"}});return e.status===401&&mO(),e.ok||await fh(e),e.json()}async function UX(t){const e=await fetch(t);return e.status===401&&mO(),e.ok||await fh(e),e}async function di(t,e,n){const i={method:t};n!==void 0&&(i.headers={"Content-Type":"application/json"},i.body=JSON.stringify(n));const r=await fetch(e,i);return r.ok||await fh(r),gO(t,e),r.status===204?{}:r.json()}async function dm(t,e){const n=await fetch(t,{method:"POST",headers:{"X-Bdrive-Desktop":"1","Content-Type":"application/json"},body:e===void 0?void 0:JSON.stringify(e)});return n.ok&&gO("POST",t),n}async function Wr(t,e){const n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e||{})});return n.status===401&&mO(),n.ok||await fh(n),gO("POST",t),n.json()}async function s2(t,e,n){const i=await fetch(t,{method:"PUT",headers:{"Content-Type":"text/plain; charset=utf-8",...n?{"If-Match":n}:{}},body:e});return i.status===401&&mO(),i.ok||await fh(i),gO("PUT",t),await i.json().catch(()=>({}))}function qX(){return nn({queryKey:["config"],queryFn:async()=>{const t=await Wt("/api/config");return t.auth.enabled&&!t.me&&(location.href="/auth/login?next="+encodeURIComponent(location.pathname+location.search),await new Promise(()=>{})),XX(t),t},staleTime:1/0})}var ql=zA();const YX=NA(ql);function o2(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function yu(...t){return e=>{let n=!1;const i=t.map(r=>{const s=o2(r,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r{let{children:r,...s}=n,o=null,l=!1;const u=[];a2(r)&&typeof ng=="function"&&(r=ng(r._payload)),w.Children.forEach(r,O=>{if(JX(O)){l=!0;const y=O;let v="child"in y.props?y.props.child:y.props.children;a2(v)&&typeof ng=="function"&&(v=ng(v._payload)),o=HX(y,v),u.push(o?.props?.children)}else u.push(O)}),o?o=w.cloneElement(o,void 0,u):!l&&w.Children.count(r)===1&&w.isValidElement(r)&&(o=r);const f=o?KX(o):void 0,h=kt(i,f);if(!o){if(r||r===0)throw new Error(l?iV(t):nV(t));return r}const p=WX(s,o.props??{});return o.type!==w.Fragment&&(p.ref=i?h:f),w.cloneElement(o,p)});return e.displayName=`${t}.Slot`,e}var FX=Rl("Slot"),JA=Symbol.for("radix.slottable");function GX(t){const e=n=>"child"in n?n.children(n.child):n.children;return e.displayName=`${t}.Slottable`,e.__radixId=JA,e}var HX=(t,e)=>{if("child"in t.props){const n=t.props.child;return w.isValidElement(n)?w.cloneElement(n,void 0,t.props.children(n.props.children)):null}return w.isValidElement(e)?e:null};function WX(t,e){const n={...e};for(const i in e){const r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...l)=>{const u=s(...l);return r(...l),u}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function KX(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function JX(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===JA}var eV=Symbol.for("react.lazy");function a2(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===eV&&"_payload"in t&&tV(t._payload)}function tV(t){return typeof t=="object"&&t!==null&&"then"in t}var nV=t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,iV=t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,ng=pO[" use ".trim().toString()],rV=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],We=rV.reduce((t,e)=>{const n=Rl(`Primitive.${e}`),i=w.forwardRef((r,s)=>{const{asChild:o,...l}=r,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(u,{...l,ref:s})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{});function eP(t,e){t&&ql.flushSync(()=>t.dispatchEvent(e))}var tP=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),sV="VisuallyHidden",nP=w.forwardRef((t,e)=>m.jsx(We.span,{...t,ref:e,style:{...tP,...t.style}}));nP.displayName=sV;var oV=nP;function Da(t,e=[]){let n=[];function i(s,o){const l=w.createContext(o);l.displayName=s+"Context";const u=n.length;n=[...n,o];const f=p=>{const{scope:O,children:y,...v}=p,S=O?.[t]?.[u]||l,k=w.useMemo(()=>v,Object.values(v));return m.jsx(S.Provider,{value:k,children:y})};f.displayName=s+"Provider";function h(p,O,y={}){const{optional:v=!1}=y,S=O?.[t]?.[u]||l,k=w.useContext(S);if(k)return k;if(o!==void 0)return o;if(!v)throw new Error(`\`${p}\` must be used within \`${s}\``)}return[f,h]}const r=()=>{const s=n.map(o=>w.createContext(o));return function(l){const u=l?.[t]||s;return w.useMemo(()=>({[`__scope${t}`]:{...l,[t]:u}}),[l,u])}};return r.scopeName=t,[i,aV(r,...e)]}function aV(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const i=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(s){const o=i.reduce((l,{useScope:u,scopeName:f})=>{const p=u(s)[`__scope${f}`];return{...l,...p}},{});return w.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}function ww(t){const e=t+"CollectionProvider",[n,i]=Da(e),[r,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=S=>{const{scope:k,children:C}=S,$=w.useRef(null),T=w.useRef(new Map).current;return m.jsx(r,{scope:k,itemMap:T,collectionRef:$,children:C})};o.displayName=e;const l=t+"CollectionSlot",u=Rl(l),f=w.forwardRef((S,k)=>{const{scope:C,children:$}=S,T=s(l,C),Q=kt(k,T.collectionRef);return m.jsx(u,{ref:Q,children:$})});f.displayName=l;const h=t+"CollectionItemSlot",p="data-radix-collection-item",O=Rl(h),y=w.forwardRef((S,k)=>{const{scope:C,children:$,...T}=S,Q=w.useRef(null),A=kt(k,Q),R=s(h,C);return w.useEffect(()=>(R.itemMap.set(Q,{ref:Q,...T}),()=>{R.itemMap.delete(Q)})),m.jsx(O,{[p]:"",ref:A,children:$})});y.displayName=h;function v(S){const k=s(t+"CollectionConsumer",S);return w.useCallback(()=>{const $=k.collectionRef.current;if(!$)return[];const T=Array.from($.querySelectorAll(`[${p}]`));return Array.from(k.itemMap.values()).sort((R,P)=>T.indexOf(R.ref.current)-T.indexOf(P.ref.current))},[k.collectionRef,k.itemMap])}return[{Provider:o,Slot:f,ItemSlot:y},v,i]}function je(t,e,{checkForDefaultPrevented:n=!0}={}){return function(r){if(t?.(r),n===!1||!r||!r.defaultPrevented)return e?.(r)}}var Xn=globalThis?.document?w.useLayoutEffect:()=>{},lV=pO[" useInsertionEffect ".trim().toString()]||Xn;function vu({prop:t,defaultProp:e,onChange:n=()=>{},caller:i}){const[r,s,o]=cV({defaultProp:e,onChange:n}),l=t!==void 0,u=l?t:r;{const h=w.useRef(t!==void 0);w.useEffect(()=>{const p=h.current;p!==l&&console.warn(`${i} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=l},[l,i])}const f=w.useCallback(h=>{if(l){const p=uV(h)?h(t):h;p!==t&&o.current?.(p)}else s(h)},[l,t,s,o]);return[u,f]}function cV({defaultProp:t,onChange:e}){const[n,i]=w.useState(t),r=w.useRef(n),s=w.useRef(e);return lV(()=>{s.current=e},[e]),w.useEffect(()=>{r.current!==n&&(s.current?.(n),r.current=n)},[n,r]),[n,i,s]}function uV(t){return typeof t=="function"}function dV(t,e){return w.useReducer((n,i)=>e[n][i]??n,t)}var is=t=>{const{present:e,children:n}=t,i=fV(e),r=typeof n=="function"?n({present:i.isPresent}):w.Children.only(n),s=hV(i.ref,pV(r));return typeof n=="function"||i.isPresent?w.cloneElement(r,{ref:s}):null};is.displayName="Presence";function fV(t){const[e,n]=w.useState(),i=w.useRef(null),r=w.useRef(t),s=w.useRef("none"),o=w.useRef(void 0),l=t?"mounted":"unmounted",[u,f]=dV(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return w.useEffect(()=>{u==="mounted"?(s.current=o.current??Yd(i.current),o.current=void 0):s.current="none"},[u]),Xn(()=>{const h=i.current,p=r.current;if(p!==t){const y=s.current,v=Yd(h);t?(o.current=v,f("MOUNT")):v==="none"||h?.display==="none"?f("UNMOUNT"):f(p&&y!==v?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,f]),Xn(()=>{if(e){let h;const p=e.ownerDocument.defaultView??window,O=v=>{const k=Yd(i.current).includes(CSS.escape(v.animationName));if(v.target===e&&k&&(f("ANIMATION_END"),!r.current)){const C=e.style.animationFillMode;e.style.animationFillMode="forwards",h=p.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=C)})}},y=v=>{v.target===e&&(s.current=Yd(i.current))};return e.addEventListener("animationstart",y),e.addEventListener("animationcancel",O),e.addEventListener("animationend",O),()=>{p.clearTimeout(h),e.removeEventListener("animationstart",y),e.removeEventListener("animationcancel",O),e.removeEventListener("animationend",O)}}else f("ANIMATION_END")},[e,f]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:w.useCallback(h=>{if(h){const p=getComputedStyle(h);i.current=p,o.current=Yd(p)}else i.current=null;n(h)},[])}}function l2(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function hV(...t){const e=w.useRef(t);return e.current=t,w.useCallback(n=>{const i=e.current;let r=!1;const s=i.map(o=>{const l=l2(o,n);return!r&&typeof l=="function"&&(r=!0),l});if(r)return()=>{for(let o=0;o{}),mV=0;function hi(t){const[e,n]=w.useState(gV());return Xn(()=>{n(i=>i??String(mV++))},[t]),e?`radix-${e}`:""}var OV=w.createContext(void 0);function kw(t){const e=w.useContext(OV);return t||e||"ltr"}function Mr(t){const e=w.useRef(t);return w.useEffect(()=>{e.current=t}),w.useMemo(()=>((...n)=>e.current?.(...n)),[])}var yV="DismissableLayer",kS="dismissableLayer.update",vV="dismissableLayer.pointerDownOutside",bV="dismissableLayer.focusOutside",c2,Cw=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),hh=w.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:r,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:l,onDismiss:u,...f}=t,h=w.useContext(Cw),[p,O]=w.useState(null),y=p?.ownerDocument??globalThis?.document,[,v]=w.useState({}),S=kt(e,O),k=Array.from(h.layers),[C]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),$=C?k.indexOf(C):-1,T=p?k.indexOf(p):-1,Q=h.layersWithOutsidePointerEventsDisabled.size>0,A=T>=$,R=w.useRef(!1),P=CV(Y=>{s?.(Y),l?.(Y),Y.defaultPrevented||u?.()},{ownerDocument:y,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:R,dismissableSurfaces:h.dismissableSurfaces,shouldHandlePointerDownOutside:w.useCallback(Y=>{if(!(Y instanceof Node))return!1;const K=[...h.branches].some(se=>se.contains(Y));return A&&!K},[h.branches,A])}),X=_V(Y=>{if(i&&R.current)return;const K=Y.target;[...h.branches].some(H=>H.contains(K))||(o?.(Y),l?.(Y),Y.defaultPrevented||u?.())},y),te=p?T===k.length-1:!1,G=Mr(Y=>{Y.key==="Escape"&&(r?.(Y),!Y.defaultPrevented&&u&&(Y.preventDefault(),u()))});return w.useEffect(()=>{if(te)return y.addEventListener("keydown",G,{capture:!0}),()=>y.removeEventListener("keydown",G,{capture:!0})},[y,te,G]),w.useEffect(()=>{if(p)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(c2=y.body.style.pointerEvents,y.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(p)),h.layers.add(p),u2(),()=>{n&&(h.layersWithOutsidePointerEventsDisabled.delete(p),h.layersWithOutsidePointerEventsDisabled.size===0&&(y.body.style.pointerEvents=c2))}},[p,y,n,h]),w.useEffect(()=>()=>{p&&(h.layers.delete(p),h.layersWithOutsidePointerEventsDisabled.delete(p),u2())},[p,h]),w.useEffect(()=>{const Y=()=>v({});return document.addEventListener(kS,Y),()=>document.removeEventListener(kS,Y)},[]),m.jsx(We.div,{...f,ref:S,style:{pointerEvents:Q?A?"auto":"none":void 0,...t.style},onFocusCapture:je(t.onFocusCapture,X.onFocusCapture),onBlurCapture:je(t.onBlurCapture,X.onBlurCapture),onPointerDownCapture:je(t.onPointerDownCapture,P.onPointerDownCapture)})});hh.displayName=yV;var SV="DismissableLayerBranch",xV=w.forwardRef((t,e)=>{const n=w.useContext(Cw),i=w.useRef(null),r=kt(e,i);return w.useEffect(()=>{const s=i.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),m.jsx(We.div,{...t,ref:r})});xV.displayName=SV;function wV(){const t=w.useContext(Cw),[e,n]=w.useState(null);return w.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}var kV=()=>!0;function CV(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:i=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:s,shouldHandlePointerDownOutside:o=kV}=e,l=Mr(t),u=w.useRef(!1),f=w.useRef(!1),h=w.useRef(new Map),p=w.useRef(()=>{});return w.useEffect(()=>{function O(){f.current=!1,r.current=!1,h.current.clear()}function y(){return Array.from(h.current.values()).some(Boolean)}function v(T){if(!f.current)return;const Q=T.target;Q instanceof Node&&[...s].some(R=>R.contains(Q))||h.current.set(T.type,!0),T.type==="click"&&window.setTimeout(()=>{f.current&&p.current()},0)}function S(T){f.current&&h.current.set(T.type,!1)}const k=T=>{if(T.target&&!u.current){let Q=function(){n.removeEventListener("click",p.current);const R=y();O(),R||iP(vV,l,A,{discrete:!0})};if(!o(T.target)){n.removeEventListener("click",p.current),O(),u.current=!1;return}const A={originalEvent:T};f.current=!0,r.current=i&&T.button===0,h.current.clear(),!i||T.button!==0?Q():(n.removeEventListener("click",p.current),p.current=Q,n.addEventListener("click",p.current,{once:!0}))}else n.removeEventListener("click",p.current),O();u.current=!1},C=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const T of C)n.addEventListener(T,v,!0),n.addEventListener(T,S);const $=window.setTimeout(()=>{n.addEventListener("pointerdown",k)},0);return()=>{window.clearTimeout($),n.removeEventListener("pointerdown",k),n.removeEventListener("click",p.current);for(const T of C)n.removeEventListener(T,v,!0),n.removeEventListener(T,S)}},[n,l,i,r,s,o]),{onPointerDownCapture:()=>u.current=!0}}function _V(t,e=globalThis?.document){const n=Mr(t),i=w.useRef(!1);return w.useEffect(()=>{const r=s=>{s.target&&!i.current&&iP(bV,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",r),()=>e.removeEventListener("focusin",r)},[e,n]),{onFocusCapture:()=>i.current=!0,onBlurCapture:()=>i.current=!1}}function u2(){const t=new CustomEvent(kS);document.dispatchEvent(t)}function iP(t,e,n,{discrete:i}){const r=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&r.addEventListener(t,e,{once:!0}),i?eP(r,s):r.dispatchEvent(s)}var Vv="focusScope.autoFocusOnMount",Bv="focusScope.autoFocusOnUnmount",d2={bubbles:!1,cancelable:!0},$V="FocusScope",OO=w.forwardRef((t,e)=>{const{loop:n=!1,trapped:i=!1,onMountAutoFocus:r,onUnmountAutoFocus:s,...o}=t,[l,u]=w.useState(null),f=Mr(r),h=Mr(s),p=w.useRef(null),O=kt(e,u),y=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(i){let S=function(T){if(y.paused||!l)return;const Q=T.target;l.contains(Q)?p.current=Q:ca(p.current,{select:!0})},k=function(T){if(y.paused||!l)return;const Q=T.relatedTarget;Q!==null&&(l.contains(Q)||ca(p.current,{select:!0}))},C=function(T){if(document.activeElement===document.body)for(const A of T)A.removedNodes.length>0&&ca(l)};document.addEventListener("focusin",S),document.addEventListener("focusout",k);const $=new MutationObserver(C);return l&&$.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",S),document.removeEventListener("focusout",k),$.disconnect()}}},[i,l,y.paused]),w.useEffect(()=>{if(l){h2.add(y);const S=document.activeElement;if(!l.contains(S)){const C=new CustomEvent(Vv,d2);l.addEventListener(Vv,f),l.dispatchEvent(C),C.defaultPrevented||(TV(PV(rP(l)),{select:!0}),document.activeElement===S&&ca(l))}return()=>{l.removeEventListener(Vv,f),setTimeout(()=>{const C=new CustomEvent(Bv,d2);l.addEventListener(Bv,h),l.dispatchEvent(C),C.defaultPrevented||ca(S??document.body,{select:!0}),l.removeEventListener(Bv,h),h2.remove(y)},0)}}},[l,f,h,y]);const v=w.useCallback(S=>{if(!n&&!i||y.paused)return;const k=S.key==="Tab"&&!S.altKey&&!S.ctrlKey&&!S.metaKey,C=document.activeElement;if(k&&C){const $=S.currentTarget,[T,Q]=EV($);T&&Q?!S.shiftKey&&C===Q?(S.preventDefault(),n&&ca(T,{select:!0})):S.shiftKey&&C===T&&(S.preventDefault(),n&&ca(Q,{select:!0})):C===$&&S.preventDefault()}},[n,i,y.paused]);return m.jsx(We.div,{tabIndex:-1,...o,ref:O,onKeyDown:v})});OO.displayName=$V;function TV(t,{select:e=!1}={}){const n=document.activeElement;for(const i of t)if(ca(i,{select:e}),document.activeElement!==n)return}function EV(t){const e=rP(t),n=f2(e,t),i=f2(e.reverse(),t);return[n,i]}function rP(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const r=i.tagName==="INPUT"&&i.type==="hidden";return i.disabled||i.hidden||r?NodeFilter.FILTER_SKIP:i.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function f2(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const i of t)if(!(n?!i.checkVisibility({checkVisibilityCSS:!0}):RV(i,{upTo:e})))return i}function RV(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function QV(t){return t instanceof HTMLInputElement&&"select"in t}function ca(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&QV(t)&&e&&t.select()}}var h2=AV();function AV(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=p2(t,e),t.unshift(e)},remove(e){t=p2(t,e),t[0]?.resume()}}}function p2(t,e){const n=[...t],i=n.indexOf(e);return i!==-1&&n.splice(i,1),n}function PV(t){return t.filter(e=>e.tagName!=="A")}var jV="Portal",ph=w.forwardRef((t,e)=>{const{container:n,...i}=t,[r,s]=w.useState(!1);Xn(()=>s(!0),[]);const o=n||r&&globalThis?.document?.body;return o?ql.createPortal(m.jsx(We.div,{...i,ref:e}),o):null});ph.displayName=jV;var ig=0,Pc=null;function _w(){w.useEffect(()=>{Pc||(Pc={start:g2(),end:g2()});const{start:t,end:e}=Pc;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),ig++,()=>{ig===1&&(Pc?.start.remove(),Pc?.end.remove(),Pc=null),ig=Math.max(0,ig-1)}},[])}function g2(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var xs=function(){return xs=Object.assign||function(e){for(var n,i=1,r=arguments.length;i"u")return WV;var e=KV(t),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,i-n+e[2]-e[0])}},eB=lP(),tu="data-scroll-locked",tB=function(t,e,n,i){var r=t.left,s=t.top,o=t.right,l=t.gap;return n===void 0&&(n="margin"),` + .`.concat(DV,` { + overflow: hidden `).concat(i,`; + padding-right: `).concat(l,"px ").concat(i,`; + } + body[`).concat(tu,`] { + overflow: hidden `).concat(i,`; + overscroll-behavior: contain; + `).concat([e&&"position: relative ".concat(i,";"),n==="margin"&&` + padding-left: `.concat(r,`px; + padding-top: `).concat(s,`px; + padding-right: `).concat(o,`px; + margin-left:0; + margin-top:0; + margin-right: `).concat(l,"px ").concat(i,`; + `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(i,";")].filter(Boolean).join(""),` + } + + .`).concat(Ig,` { + right: `).concat(l,"px ").concat(i,`; + } + + .`).concat(Xg,` { + margin-right: `).concat(l,"px ").concat(i,`; + } + + .`).concat(Ig," .").concat(Ig,` { + right: 0 `).concat(i,`; + } + + .`).concat(Xg," .").concat(Xg,` { + margin-right: 0 `).concat(i,`; + } + + body[`).concat(tu,`] { + `).concat(NV,": ").concat(l,`px; + } +`)},O2=function(){var t=parseInt(document.body.getAttribute(tu)||"0",10);return isFinite(t)?t:0},nB=function(){w.useEffect(function(){return document.body.setAttribute(tu,(O2()+1).toString()),function(){var t=O2()-1;t<=0?document.body.removeAttribute(tu):document.body.setAttribute(tu,t.toString())}},[])},iB=function(t){var e=t.noRelative,n=t.noImportant,i=t.gapMode,r=i===void 0?"margin":i;nB();var s=w.useMemo(function(){return JV(r)},[r]);return w.createElement(eB,{styles:tB(s,!e,r,n?"":"!important")})},CS=!1;if(typeof window<"u")try{var rg=Object.defineProperty({},"passive",{get:function(){return CS=!0,!0}});window.addEventListener("test",rg,rg),window.removeEventListener("test",rg,rg)}catch{CS=!1}var jc=CS?{passive:!1}:!1,rB=function(t){return t.tagName==="TEXTAREA"},cP=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!rB(t)&&n[e]==="visible")},sB=function(t){return cP(t,"overflowY")},oB=function(t){return cP(t,"overflowX")},y2=function(t,e){var n=e.ownerDocument,i=e;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var r=uP(t,i);if(r){var s=dP(t,i),o=s[1],l=s[2];if(o>l)return!0}i=i.parentNode}while(i&&i!==n.body);return!1},aB=function(t){var e=t.scrollTop,n=t.scrollHeight,i=t.clientHeight;return[e,n,i]},lB=function(t){var e=t.scrollLeft,n=t.scrollWidth,i=t.clientWidth;return[e,n,i]},uP=function(t,e){return t==="v"?sB(e):oB(e)},dP=function(t,e){return t==="v"?aB(e):lB(e)},cB=function(t,e){return t==="h"&&e==="rtl"?-1:1},uB=function(t,e,n,i,r){var s=cB(t,window.getComputedStyle(e).direction),o=s*i,l=n.target,u=e.contains(l),f=!1,h=o>0,p=0,O=0;do{if(!l)break;var y=dP(t,l),v=y[0],S=y[1],k=y[2],C=S-k-s*v;(v||C)&&uP(t,l)&&(p+=C,O+=v);var $=l.parentNode;l=$&&$.nodeType===Node.DOCUMENT_FRAGMENT_NODE?$.host:$}while(!u&&l!==document.body||u&&(e.contains(l)||e===l));return(h&&Math.abs(p)<1||!h&&Math.abs(O)<1)&&(f=!0),f},sg=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},v2=function(t){return[t.deltaX,t.deltaY]},b2=function(t){return t&&"current"in t?t.current:t},dB=function(t,e){return t[0]===e[0]&&t[1]===e[1]},fB=function(t){return` + .block-interactivity-`.concat(t,` {pointer-events: none;} + .allow-interactivity-`).concat(t,` {pointer-events: all;} +`)},hB=0,Mc=[];function pB(t){var e=w.useRef([]),n=w.useRef([0,0]),i=w.useRef(),r=w.useState(hB++)[0],s=w.useState(lP)[0],o=w.useRef(t);w.useEffect(function(){o.current=t},[t]),w.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(r));var S=MV([t.lockRef.current],(t.shards||[]).map(b2),!0).filter(Boolean);return S.forEach(function(k){return k.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),S.forEach(function(k){return k.classList.remove("allow-interactivity-".concat(r))})}}},[t.inert,t.lockRef.current,t.shards]);var l=w.useCallback(function(S,k){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!o.current.allowPinchZoom;var C=sg(S),$=n.current,T="deltaX"in S?S.deltaX:$[0]-C[0],Q="deltaY"in S?S.deltaY:$[1]-C[1],A,R=S.target,P=Math.abs(T)>Math.abs(Q)?"h":"v";if("touches"in S&&P==="h"&&R.type==="range")return!1;var X=window.getSelection(),te=X&&X.anchorNode,G=te?te===R||te.contains(R):!1;if(G)return!1;var Y=y2(P,R);if(!Y)return!0;if(Y?A=P:(A=P==="v"?"h":"v",Y=y2(P,R)),!Y)return!1;if(!i.current&&"changedTouches"in S&&(T||Q)&&(i.current=A),!A)return!0;var K=i.current||A;return uB(K,k,S,K==="h"?T:Q)},[]),u=w.useCallback(function(S){var k=S;if(!(!Mc.length||Mc[Mc.length-1]!==s)){var C="deltaY"in k?v2(k):sg(k),$=e.current.filter(function(A){return A.name===k.type&&(A.target===k.target||k.target===A.shadowParent)&&dB(A.delta,C)})[0];if($&&$.should){k.cancelable&&k.preventDefault();return}if(!$){var T=(o.current.shards||[]).map(b2).filter(Boolean).filter(function(A){return A.contains(k.target)}),Q=T.length>0?l(k,T[0]):!o.current.noIsolation;Q&&k.cancelable&&k.preventDefault()}}},[]),f=w.useCallback(function(S,k,C,$){var T={name:S,delta:k,target:C,should:$,shadowParent:gB(C)};e.current.push(T),setTimeout(function(){e.current=e.current.filter(function(Q){return Q!==T})},1)},[]),h=w.useCallback(function(S){n.current=sg(S),i.current=void 0},[]),p=w.useCallback(function(S){f(S.type,v2(S),S.target,l(S,t.lockRef.current))},[]),O=w.useCallback(function(S){f(S.type,sg(S),S.target,l(S,t.lockRef.current))},[]);w.useEffect(function(){return Mc.push(s),t.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:O}),document.addEventListener("wheel",u,jc),document.addEventListener("touchmove",u,jc),document.addEventListener("touchstart",h,jc),function(){Mc=Mc.filter(function(S){return S!==s}),document.removeEventListener("wheel",u,jc),document.removeEventListener("touchmove",u,jc),document.removeEventListener("touchstart",h,jc)}},[]);var y=t.removeScrollBar,v=t.inert;return w.createElement(w.Fragment,null,v?w.createElement(s,{styles:fB(r)}):null,y?w.createElement(iB,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function gB(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const mB=BV(aP,pB);var vO=w.forwardRef(function(t,e){return w.createElement(yO,xs({},t,{ref:e,sideCar:mB}))});vO.classNames=yO.classNames;var OB=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Dc=new WeakMap,og=new WeakMap,ag={},Fv=0,fP=function(t){return t&&(t.host||fP(t.parentNode))},yB=function(t,e){return e.map(function(n){if(t.contains(n))return n;var i=fP(n);return i&&t.contains(i)?i:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},vB=function(t,e,n,i){var r=yB(e,Array.isArray(t)?t:[t]);ag[n]||(ag[n]=new WeakMap);var s=ag[n],o=[],l=new Set,u=new Set(r),f=function(p){!p||l.has(p)||(l.add(p),f(p.parentNode))};r.forEach(f);var h=function(p){!p||u.has(p)||Array.prototype.forEach.call(p.children,function(O){if(l.has(O))h(O);else try{var y=O.getAttribute(i),v=y!==null&&y!=="false",S=(Dc.get(O)||0)+1,k=(s.get(O)||0)+1;Dc.set(O,S),s.set(O,k),o.push(O),S===1&&v&&og.set(O,!0),k===1&&O.setAttribute(n,"true"),v||O.setAttribute(i,"true")}catch(C){console.error("aria-hidden: cannot operate on ",O,C)}})};return h(e),l.clear(),Fv++,function(){o.forEach(function(p){var O=Dc.get(p)-1,y=s.get(p)-1;Dc.set(p,O),s.set(p,y),O||(og.has(p)||p.removeAttribute(i),og.delete(p)),y||p.removeAttribute(n)}),Fv--,Fv||(Dc=new WeakMap,Dc=new WeakMap,og=new WeakMap,ag={})}},$w=function(t,e,n){n===void 0&&(n="data-aria-hidden");var i=Array.from(Array.isArray(t)?t:[t]),r=OB(t);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),vB(i,r,n,"aria-hidden")):function(){return null}},bO="Dialog",[hP]=Da(bO),[bB,rs]=hP(bO),Tw=t=>{const{__scopeDialog:e,children:n,open:i,defaultOpen:r,onOpenChange:s,modal:o=!0}=t,l=w.useRef(null),u=w.useRef(null),[f,h]=vu({prop:i,defaultProp:r??!1,onChange:s,caller:bO});return m.jsx(bB,{scope:e,triggerRef:l,contentRef:u,contentId:hi(),titleId:hi(),descriptionId:hi(),open:f,onOpenChange:h,onOpenToggle:w.useCallback(()=>h(p=>!p),[h]),modal:o,children:n})};Tw.displayName=bO;var pP="DialogTrigger",SB=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(pP,n),s=kt(e,r.triggerRef);return m.jsx(We.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":Pw(r.open),...i,ref:s,onClick:je(t.onClick,r.onOpenToggle)})});SB.displayName=pP;var Ew="DialogPortal",[xB,gP]=hP(Ew,{forceMount:void 0}),Rw=t=>{const{__scopeDialog:e,forceMount:n,children:i,container:r}=t,s=rs(Ew,e);return m.jsx(xB,{scope:e,forceMount:n,children:w.Children.map(i,o=>m.jsx(is,{present:n||s.open,children:m.jsx(ph,{asChild:!0,container:r,children:o})}))})};Rw.displayName=Ew;var fm="DialogOverlay",Qw=w.forwardRef((t,e)=>{const n=gP(fm,t.__scopeDialog),{forceMount:i=n.forceMount,...r}=t,s=rs(fm,t.__scopeDialog);return s.modal?m.jsx(is,{present:i||s.open,children:m.jsx(kB,{...r,ref:e})}):null});Qw.displayName=fm;var wB=Rl("DialogOverlay.RemoveScroll"),kB=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(fm,n),s=wV(),o=kt(e,s);return m.jsx(vO,{as:wB,allowPinchZoom:!0,shards:[r.contentRef],children:m.jsx(We.div,{"data-state":Pw(r.open),...i,ref:o,style:{pointerEvents:"auto",...i.style}})})}),bu="DialogContent",Aw=w.forwardRef((t,e)=>{const n=gP(bu,t.__scopeDialog),{forceMount:i=n.forceMount,...r}=t,s=rs(bu,t.__scopeDialog);return m.jsx(is,{present:i||s.open,children:s.modal?m.jsx(CB,{...r,ref:e}):m.jsx(_B,{...r,ref:e})})});Aw.displayName=bu;var CB=w.forwardRef((t,e)=>{const n=rs(bu,t.__scopeDialog),i=w.useRef(null),r=kt(e,n.contentRef,i);return w.useEffect(()=>{const s=i.current;if(s)return $w(s)},[]),m.jsx(mP,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:je(t.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:je(t.onPointerDownOutside,s=>{const o=s.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&s.preventDefault()}),onFocusOutside:je(t.onFocusOutside,s=>s.preventDefault())})}),_B=w.forwardRef((t,e)=>{const n=rs(bu,t.__scopeDialog),i=w.useRef(!1),r=w.useRef(!1);return m.jsx(mP,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{t.onCloseAutoFocus?.(s),s.defaultPrevented||(i.current||n.triggerRef.current?.focus(),s.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:s=>{t.onInteractOutside?.(s),s.defaultPrevented||(i.current=!0,s.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const o=s.target;n.triggerRef.current?.contains(o)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&r.current&&s.preventDefault()}})}),mP=w.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:s,...o}=t,l=rs(bu,n);return _w(),m.jsx(m.Fragment,{children:m.jsx(OO,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:s,children:m.jsx(hh,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Pw(l.open),...o,ref:e,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),OP="DialogTitle",yP=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(OP,n);return m.jsx(We.h2,{id:r.titleId,...i,ref:e})});yP.displayName=OP;var vP="DialogDescription",$B=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(vP,n);return m.jsx(We.p,{id:r.descriptionId,...i,ref:e})});$B.displayName=vP;var bP="DialogClose",SP=w.forwardRef((t,e)=>{const{__scopeDialog:n,...i}=t,r=rs(bP,n);return m.jsx(We.button,{type:"button",...i,ref:e,onClick:je(t.onClick,()=>r.onOpenChange(!1))})});SP.displayName=bP;function Pw(t){return t?"open":"closed"}function TB(t){const e=w.useRef({value:t,previous:t});return w.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function EB(t){const[e,n]=w.useState(void 0);return Xn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const s=r[0];let o,l;if("borderBoxSize"in s){const u=s.borderBoxSize,f=Array.isArray(u)?u[0]:u;o=f.inlineSize,l=f.blockSize}else o=t.offsetWidth,l=t.offsetHeight;n({width:o,height:l})});return i.observe(t,{box:"border-box"}),()=>i.unobserve(t)}else n(void 0)},[t]),e}const RB=["top","right","bottom","left"],wa=Math.min,So=Math.max,hm=Math.round,lg=Math.floor,xo=t=>({x:t,y:t}),QB={left:"right",right:"left",bottom:"top",top:"bottom"};function xP(t,e,n){return So(t,wa(e,n))}function $o(t,e){return typeof t=="function"?t(e):t}function ka(t){return t.split("-")[0]}function Xu(t){return t.split("-")[1]}function jw(t){return t==="x"?"y":"x"}function Mw(t){return t==="y"?"height":"width"}function Cs(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function Dw(t){return jw(Cs(t))}function AB(t,e,n){n===void 0&&(n=!1);const i=Xu(t),r=Dw(t),s=Mw(r);let o=r==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=pm(o)),[o,pm(o)]}function PB(t){const e=pm(t);return[_S(t),e,_S(e)]}function _S(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const S2=["left","right"],x2=["right","left"],jB=["top","bottom"],MB=["bottom","top"];function DB(t,e,n){switch(t){case"top":case"bottom":return n?e?x2:S2:e?S2:x2;case"left":case"right":return e?jB:MB;default:return[]}}function NB(t,e,n,i){const r=Xu(t);let s=DB(ka(t),n==="start",i);return r&&(s=s.map(o=>o+"-"+r),e&&(s=s.concat(s.map(_S)))),s}function pm(t){const e=ka(t);return QB[e]+t.slice(e.length)}function zB(t){var e,n,i,r;return{top:(e=t.top)!=null?e:0,right:(n=t.right)!=null?n:0,bottom:(i=t.bottom)!=null?i:0,left:(r=t.left)!=null?r:0}}function wP(t){return typeof t!="number"?zB(t):{top:t,right:t,bottom:t,left:t}}function gm(t){const{x:e,y:n,width:i,height:r}=t;return{width:i,height:r,top:n,left:e,right:e+i,bottom:n+r,x:e,y:n}}function w2(t,e,n){let{reference:i,floating:r}=t;const s=Cs(e),o=Dw(e),l=Mw(o),u=ka(e),f=s==="y",h=i.x+i.width/2-r.width/2,p=i.y+i.height/2-r.height/2,O=i[l]/2-r[l]/2;let y;switch(u){case"top":y={x:h,y:i.y-r.height};break;case"bottom":y={x:h,y:i.y+i.height};break;case"right":y={x:i.x+i.width,y:p};break;case"left":y={x:i.x-r.width,y:p};break;default:y={x:i.x,y:i.y}}const v=Xu(e);return v&&(y[o]+=O*(v==="end"?1:-1)*(n&&f?-1:1)),y}async function LB(t,e){var n;e===void 0&&(e={});const{x:i,y:r,platform:s,rects:o,elements:l,strategy:u}=t,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:p="floating",altBoundary:O=!1,padding:y=0}=$o(e,t),v=wP(y),k=l[O?p==="floating"?"reference":"floating":p],C=gm(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(k)))==null||n?k:k.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:f,rootBoundary:h,strategy:u})),$=p==="floating"?{x:i,y:r,width:o.floating.width,height:o.floating.height}:o.reference,T=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),Q=await(s.isElement==null?void 0:s.isElement(T))&&await(s.getScale==null?void 0:s.getScale(T))||{x:1,y:1},A=gm(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:$,offsetParent:T,strategy:u}):$);return{top:(C.top-A.top+v.top)/Q.y,bottom:(A.bottom-C.bottom+v.bottom)/Q.y,left:(C.left-A.left+v.left)/Q.x,right:(A.right-C.right+v.right)/Q.x}}const ZB=50,IB=async(t,e,n)=>{const{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:LB},u=await(o.isRTL==null?void 0:o.isRTL(e));let f=await o.getElementRects({reference:t,floating:e,strategy:r}),{x:h,y:p}=w2(f,i,u),O=i,y=0;const v={};for(let S=0;S({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:s,platform:o,elements:l,middlewareData:u}=e,{element:f,padding:h=0}=$o(t,e)||{};if(f==null)return{};const p=wP(h),O={x:n,y:i},y=Dw(r),v=Mw(y),S=await o.getDimensions(f),k=y==="y",C=k?"top":"left",$=k?"bottom":"right",T=k?"clientHeight":"clientWidth",Q=s.reference[v]+s.reference[y]-O[y]-s.floating[v],A=O[y]-s.reference[y],R=await(o.getOffsetParent==null?void 0:o.getOffsetParent(f));let P=R?R[T]:0;(!P||!await(o.isElement==null?void 0:o.isElement(R)))&&(P=l.floating[T]||s.floating[v]);const X=Q/2-A/2,te=P/2-S[v]/2-1,G=wa(p[C],te),Y=wa(p[$],te),K=P-S[v]-Y,se=P/2-S[v]/2+X,H=xP(G,se,K),pe=!u.arrow&&Xu(r)!=null&&se!==H&&s.reference[v]/2-(seH<=0)){var Y,K;const H=(((Y=s.flip)==null?void 0:Y.index)||0)+1,pe=P[H];if(pe&&(!(p==="alignment"?$!==Cs(pe):!1)||G.every(ce=>Cs(ce.placement)===$?ce.overflows[0]>0:!0)))return{data:{index:H,overflows:G},reset:{placement:pe}};let z=(K=G.filter(W=>W.overflows[0]<=0).sort((W,ce)=>W.overflows[1]-ce.overflows[1])[0])==null?void 0:K.placement;if(!z)switch(y){case"bestFit":{var se;const W=(se=G.filter(ce=>{if(R){const oe=Cs(ce.placement);return oe===$||oe==="y"}return!0}).map(ce=>[ce.placement,ce.overflows.filter(oe=>oe>0).reduce((oe,ae)=>oe+ae,0)]).sort((ce,oe)=>ce[1]-oe[1])[0])==null?void 0:se[0];W&&(z=W);break}case"initialPlacement":z=l;break}if(r!==z)return{reset:{placement:z}}}return{}}}};function k2(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function C2(t){return RB.some(e=>t[e]>=0)}const BB=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:i}=e,{strategy:r="referenceHidden",...s}=$o(t,e);switch(r){case"referenceHidden":{const o=await i.detectOverflow(e,{...s,elementContext:"reference"}),l=k2(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:C2(l)}}}case"escaped":{const o=await i.detectOverflow(e,{...s,altBoundary:!0}),l=k2(o,n.floating);return{data:{escapedOffsets:l,escaped:C2(l)}}}default:return{}}}}},kP=new Set(["left","top"]);async function UB(t,e){const{placement:n,platform:i,elements:r}=t,s=await(i.isRTL==null?void 0:i.isRTL(r.floating)),o=ka(n),l=Xu(n),u=Cs(n)==="y",f=kP.has(o)?-1:1,h=s&&u?-1:1,p=$o(e,t);let{mainAxis:O,crossAxis:y,alignmentAxis:v}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof v=="number"&&(y=l==="end"?v*-1:v),u?{x:y*h,y:O*f}:{x:O*f,y:y*h}}const qB=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,i;const{x:r,y:s,placement:o,middlewareData:l}=e,u=await UB(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(i=l.arrow)!=null&&i.alignmentOffset?{}:{x:r+u.x,y:s+u.y,data:{...u,placement:o}}}}},YB=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:i,placement:r,platform:s}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:u={fn:$=>{let{x:T,y:Q}=$;return{x:T,y:Q}}},...f}=$o(t,e),h={x:n,y:i},p=await s.detectOverflow(e,f),O=Cs(r),y=jw(O);let v=h[y],S=h[O];const k=($,T)=>xP(T+p[$==="y"?"top":"left"],T,T-p[$==="y"?"bottom":"right"]);o&&(v=k(y,v)),l&&(S=k(O,S));const C=u.fn({...e,[y]:v,[O]:S});return{...C,data:{x:C.x-n,y:C.y-i,enabled:{[y]:o,[O]:l}}}}}},FB=function(t){return t===void 0&&(t={}),{options:t,fn(e){var n,i;const{x:r,y:s,placement:o,rects:l,middlewareData:u}=e,{offset:f=0,mainAxis:h=!0,crossAxis:p=!0}=$o(t,e),O={x:r,y:s},y=Cs(o),v=jw(y);let S=O[v],k=O[y];const C=$o(f,e),$=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:(n=C.mainAxis)!=null?n:0,crossAxis:(i=C.crossAxis)!=null?i:0};if(h){const A=v==="y"?"height":"width",R=l.reference[v]-l.floating[A]+$.mainAxis,P=l.reference[v]+l.reference[A]-$.mainAxis;SP&&(S=P)}if(p){var T,Q;const A=v==="y"?"width":"height",R=kP.has(ka(o)),P=l.reference[y]-l.floating[A]+(R&&((T=u.offset)==null?void 0:T[y])||0)+(R?0:$.crossAxis),X=l.reference[y]+l.reference[A]+(R?0:((Q=u.offset)==null?void 0:Q[y])||0)-(R?$.crossAxis:0);kX&&(k=X)}return{[v]:S,[y]:k}}}},GB=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:i,platform:r,elements:s}=e,{apply:o=()=>{},...l}=$o(t,e),u=await r.detectOverflow(e,l),f=ka(n),h=Xu(n),p=Cs(n)==="y",{width:O,height:y}=i.floating;let v,S;f==="top"||f==="bottom"?(v=f,S=h===(await(r.isRTL==null?void 0:r.isRTL(s.floating))?"start":"end")?"left":"right"):(S=f,v=h==="end"?"top":"bottom");const k=y-u.top-u.bottom,C=O-u.left-u.right,$=wa(y-u[v],k),T=wa(O-u[S],C),Q=e.middlewareData.shift,A=!Q;let R=$,P=T;Q!=null&&Q.enabled.x&&(P=C),Q!=null&&Q.enabled.y&&(R=k),A&&!h&&(p?P=O-2*So(u.left,u.right):R=y-2*So(u.top,u.bottom)),await o({...e,availableWidth:P,availableHeight:R});const X=await r.getDimensions(s.floating);return O!==X.width||y!==X.height?{reset:{rects:!0}}:{}}}};function SO(){return typeof window<"u"}function Vu(t){return CP(t)?(t.nodeName||"").toLowerCase():"#document"}function Bi(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Qo(t){var e;return(e=(CP(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function CP(t){return SO()?t instanceof Node||t instanceof Bi(t).Node:!1}function Ds(t){return SO()?t instanceof Element||t instanceof Bi(t).Element:!1}function Na(t){return SO()?t instanceof HTMLElement||t instanceof Bi(t).HTMLElement:!1}function _2(t){return!SO()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Bi(t).ShadowRoot}function xO(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=Ns(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&r!=="inline"&&r!=="contents"}function HB(t){return/^(table|td|th)$/.test(Vu(t))}function wO(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const WB=/transform|translate|scale|rotate|perspective|filter/,KB=/paint|layout|strict|content/,ul=t=>!!t&&t!=="none";let Gv;function Nw(t){const e=Ds(t)?Ns(t):t;return ul(e.transform)||ul(e.translate)||ul(e.scale)||ul(e.rotate)||ul(e.perspective)||!zw()&&(ul(e.backdropFilter)||ul(e.filter))||WB.test(e.willChange||"")||KB.test(e.contain||"")}function JB(t){let e=Ql(t);for(;Na(e)&&!Rf(e);){if(Nw(e))return e;if(wO(e))return null;e=Ql(e)}return null}function zw(){return Gv==null&&(Gv=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Gv}function Rf(t){return/^(html|body|#document)$/.test(Vu(t))}function Ns(t){return Bi(t).getComputedStyle(t)}function kO(t){return Ds(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Ql(t){if(Vu(t)==="html")return t;const e=t.assignedSlot||t.parentNode||_2(t)&&t.host||Qo(t);return _2(e)?e.host:e}function _P(t){const e=Ql(t);return Rf(e)?(t.ownerDocument||t).body:Na(e)&&xO(e)?e:_P(e)}function Qf(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=_P(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),o=Bi(r);if(s){const l=$S(o);return e.concat(o,o.visualViewport||[],xO(r)?r:[],l&&n?Qf(l):[])}else return e.concat(r,Qf(r,[],n))}function $S(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function $P(t){const e=Ns(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=Na(t),s=r?t.offsetWidth:n,o=r?t.offsetHeight:i,l=hm(n)!==s||hm(i)!==o;return l&&(n=s,i=o),{width:n,height:i,$:l}}function Lw(t){return Ds(t)?t:t.contextElement}function nu(t){const e=Lw(t);if(!Na(e))return xo(1);const n=e.getBoundingClientRect(),{width:i,height:r,$:s}=$P(e);let o=(s?hm(n.width):n.width)/i,l=(s?hm(n.height):n.height)/r;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const e6=xo(0);function TP(t){const e=Bi(t);return!zw()||!e.visualViewport?e6:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function t6(t,e,n){return e===void 0&&(e=!1),!!n&&e&&n===Bi(t)}function Al(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),s=Lw(t);let o=xo(1);e&&(i?Ds(i)&&(o=nu(i)):o=nu(t));const l=t6(s,n,i)?TP(s):xo(0);let u=(r.left+l.x)/o.x,f=(r.top+l.y)/o.y,h=r.width/o.x,p=r.height/o.y;if(s&&i){const O=Bi(s),y=Ds(i)?Bi(i):i;let v=O,S=$S(v);for(;S&&y!==v;){const k=nu(S),C=S.getBoundingClientRect(),$=Ns(S),T=C.left+(S.clientLeft+parseFloat($.paddingLeft))*k.x,Q=C.top+(S.clientTop+parseFloat($.paddingTop))*k.y;u*=k.x,f*=k.y,h*=k.x,p*=k.y,u+=T,f+=Q,v=Bi(S),S=$S(v)}}return gm({width:h,height:p,x:u,y:f})}function CO(t,e){const n=kO(t).scrollLeft;return e?e.left+n:Al(Qo(t)).left+n}function EP(t,e){const n=t.getBoundingClientRect(),i=n.left+e.scrollLeft-CO(t,n),r=n.top+e.scrollTop;return{x:i,y:r}}function n6(t){let{elements:e,rect:n,offsetParent:i,strategy:r}=t;const s=r==="fixed",o=Qo(i),l=e?wO(e.floating):!1;if(i===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},f=xo(1);const h=xo(0),p=Na(i);if((p||!s)&&((Vu(i)!=="body"||xO(o))&&(u=kO(i)),p)){const y=Al(i);f=nu(i),h.x=y.x+i.clientLeft,h.y=y.y+i.clientTop}const O=o&&!p&&!s?EP(o,u):xo(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+h.x+O.x,y:n.y*f.y-u.scrollTop*f.y+h.y+O.y}}function i6(t){return t.getClientRects?Array.from(t.getClientRects()):[]}function r6(t){const e=kO(t),n=t.ownerDocument.body,i=So(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),r=So(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-e.scrollLeft+CO(t);const o=-e.scrollTop;return Ns(n).direction==="rtl"&&(s+=So(t.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:o}}const s6=25;function o6(t,e,n){n===void 0&&(n="viewport");const i=n==="layoutViewport",r=Bi(t),s=Qo(t),o=r.visualViewport;let l=s.clientWidth,u=s.clientHeight,f=0,h=0;if(o){const O=!zw()||e==="fixed";i?O||(f=-o.offsetLeft,h=-o.offsetTop):(l=o.width,u=o.height,O&&(f=o.offsetLeft,h=o.offsetTop))}if(CO(s)<=0){const O=s.ownerDocument,y=O.body,v=getComputedStyle(y),S=O.compatMode==="CSS1Compat"&&parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0,k=Math.abs(s.clientWidth-y.clientWidth-S),C=getComputedStyle(s).scrollbarGutter==="stable both-edges"?k/2:k;C<=s6&&(l-=C)}return{width:l,height:u,x:f,y:h}}function a6(t,e){const n=Al(t,!0,e==="fixed"),i=n.top+t.clientTop,r=n.left+t.clientLeft,s=nu(t),o=t.clientWidth*s.x,l=t.clientHeight*s.y,u=r*s.x,f=i*s.y;return{width:o,height:l,x:u,y:f}}function $2(t,e,n){let i;if(e==="viewport"||e==="layoutViewport")i=o6(t,n,e);else if(e==="document")i=r6(Qo(t));else if(Ds(e))i=a6(e,n);else{const r=TP(t);i={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return gm(i)}function l6(t,e){const n=e.get(t);if(n)return n;let i=Qf(t,[],!1).filter(l=>Ds(l)&&Vu(l)!=="body"),r=null;const s=Ns(t).position==="fixed";let o=s?Ql(t):t;for(;Ds(o)&&!Rf(o);){const l=Ns(o),u=Nw(o),f=r?r.position:s?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&l.position==="static")?i=i.filter(p=>p!==o):r=l,o=Ql(o)}return e.set(t,i),i}function c6(t){let{element:e,boundary:n,rootBoundary:i,strategy:r}=t;const o=[...n==="clippingAncestors"?wO(e)?[]:l6(e,this._c):[].concat(n),i],l=$2(e,o[0],r);let u=l.top,f=l.right,h=l.bottom,p=l.left;for(let O=1;O{l(!1,1e-7)},1e3)}P=!1}try{i=new IntersectionObserver(X,{...R,root:s.ownerDocument})}catch{i=new IntersectionObserver(X,R)}i.observe(t)}const u=Bi(t),f=()=>l(n);return u.addEventListener("resize",f),l(!0),()=>{u.removeEventListener("resize",f),o()}}function m6(t,e,n,i){i===void 0&&(i={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=i,f=Lw(t),h=r||s?[...f?Qf(f):[],...e?Qf(e):[]]:[];h.forEach(C=>{r&&C.addEventListener("scroll",n),s&&C.addEventListener("resize",n)});const p=f&&l?g6(f,n,s):null;let O=-1,y=null;o&&(y=new ResizeObserver(C=>{let[$]=C;$&&$.target===f&&y&&e&&(y.unobserve(e),cancelAnimationFrame(O),O=requestAnimationFrame(()=>{var T;(T=y)==null||T.observe(e)})),n()}),f&&!u&&y.observe(f),e&&y.observe(e));let v,S=u?Al(t):null;u&&k();function k(){const C=Al(t);S&&!QP(S,C)&&n(),S=C,v=requestAnimationFrame(k)}return n(),()=>{var C;h.forEach($=>{r&&$.removeEventListener("scroll",n),s&&$.removeEventListener("resize",n)}),p?.(),(C=y)==null||C.disconnect(),y=null,u&&cancelAnimationFrame(v)}}const O6=qB,y6=YB,v6=VB,b6=GB,S6=BB,E2=XB,x6=FB,w6=(t,e,n)=>{const i=new Map,r=n??{},s={...p6,...r.platform,_c:i};return IB(t,e,{...r,platform:s})};var k6=typeof document<"u",C6=function(){},Vg=k6?w.useLayoutEffect:C6;function mm(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,i,r;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(i=n;i--!==0;)if(!mm(t[i],e[i]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(e).length)return!1;for(i=n;i--!==0;)if(!{}.hasOwnProperty.call(e,r[i]))return!1;for(i=n;i--!==0;){const s=r[i];if(!(s==="_owner"&&t.$$typeof)&&!mm(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function AP(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function R2(t,e){const n=AP(t);return Math.round(e*n)/n}function Wv(t){const e=w.useRef(t);return Vg(()=>{e.current=t}),e}function _6(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:i=[],platform:r,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:u,open:f}=t,[h,p]=w.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[O,y]=w.useState(i);mm(O,i)||y(i);const[v,S]=w.useState(null),[k,C]=w.useState(null),$=w.useCallback(ce=>{ce!==R.current&&(R.current=ce,S(ce))},[]),T=w.useCallback(ce=>{ce!==P.current&&(P.current=ce,C(ce))},[]),Q=s||v,A=o||k,R=w.useRef(null),P=w.useRef(null),X=w.useRef(h),te=u!=null,G=Wv(u),Y=Wv(r),K=Wv(f),se=w.useCallback(()=>{if(!R.current||!P.current)return;const ce={placement:e,strategy:n,middleware:O};Y.current&&(ce.platform=Y.current),w6(R.current,P.current,ce).then(oe=>{const ae={...oe,isPositioned:K.current!==!1};H.current&&!mm(X.current,ae)&&(X.current=ae,ql.flushSync(()=>{p(ae)}))})},[O,e,n,Y,K]);Vg(()=>{f===!1&&X.current.isPositioned&&(X.current.isPositioned=!1,p(ce=>({...ce,isPositioned:!1})))},[f]);const H=w.useRef(!1);Vg(()=>(H.current=!0,()=>{H.current=!1}),[]),Vg(()=>{if(Q&&(R.current=Q),A&&(P.current=A),Q&&A){if(G.current)return G.current(Q,A,se);se()}},[Q,A,se,G,te]);const pe=w.useMemo(()=>({reference:R,floating:P,setReference:$,setFloating:T}),[$,T]),z=w.useMemo(()=>({reference:Q,floating:A}),[Q,A]),W=w.useMemo(()=>{const ce={position:n,left:0,top:0};if(!z.floating)return ce;const oe=R2(z.floating,h.x),ae=R2(z.floating,h.y);return l?{...ce,transform:"translate("+oe+"px, "+ae+"px)",...AP(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:oe,top:ae}},[n,l,z.floating,h.x,h.y]);return w.useMemo(()=>({...h,update:se,refs:pe,elements:z,floatingStyles:W}),[h,se,pe,z,W])}const $6=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:i,padding:r}=typeof t=="function"?t(n):t;return i&&e(i)?i.current!=null?E2({element:i.current,padding:r}).fn(n):{}:i?E2({element:i,padding:r}).fn(n):{}}}},T6=(t,e)=>{const n=O6(t);return{name:n.name,fn:n.fn,options:[t,e]}},E6=(t,e)=>{const n=y6(t);return{name:n.name,fn:n.fn,options:[t,e]}},R6=(t,e)=>({fn:x6(t).fn,options:[t,e]}),Q6=(t,e)=>{const n=v6(t);return{name:n.name,fn:n.fn,options:[t,e]}},A6=(t,e)=>{const n=b6(t);return{name:n.name,fn:n.fn,options:[t,e]}},P6=(t,e)=>{const n=S6(t);return{name:n.name,fn:n.fn,options:[t,e]}},j6=(t,e)=>{const n=$6(t);return{name:n.name,fn:n.fn,options:[t,e]}};var M6="Arrow",PP=w.forwardRef((t,e)=>{const{children:n,width:i=10,height:r=5,...s}=t;return m.jsx(We.svg,{...s,ref:e,width:i,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});PP.displayName=M6;var D6=PP,Zw="Popper",[jP,Bu]=Da(Zw),[N6,MP]=jP(Zw),DP=t=>{const{__scopePopper:e,children:n}=t,[i,r]=w.useState(null),[s,o]=w.useState(void 0);return m.jsx(N6,{scope:e,anchor:i,onAnchorChange:r,placementState:s,setPlacementState:o,children:n})};DP.displayName=Zw;var NP="PopperAnchor",zP=w.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:i,...r}=t,s=MP(NP,n),o=w.useRef(null),l=s.onAnchorChange,u=w.useCallback(v=>{o.current=v,v&&l(v)},[l]),f=kt(e,u),h=w.useRef(null);w.useEffect(()=>{if(!i)return;const v=h.current;h.current=i.current,v!==h.current&&l(h.current)});const p=s.placementState&&Xw(s.placementState),O=p?.[0],y=p?.[1];return i?null:m.jsx(We.div,{"data-radix-popper-side":O,"data-radix-popper-align":y,...r,ref:f})});zP.displayName=NP;var Iw="PopperContent",[z6,L6]=jP(Iw),LP=w.forwardRef((t,e)=>{const{__scopePopper:n,side:i="bottom",sideOffset:r=0,align:s="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:h=0,sticky:p="partial",hideWhenDetached:O=!1,updatePositionStrategy:y="optimized",onPlaced:v,...S}=t,k=MP(Iw,n),[C,$]=w.useState(null),T=kt(e,$),[Q,A]=w.useState(null),R=EB(Q),P=R?.width??0,X=R?.height??0,te=i+(s!=="center"?"-"+s:""),G=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},Y=Array.isArray(f)?f:[f],K=Y.length>0,se={padding:G,boundary:Y.filter(I6),altBoundary:K},{refs:H,floatingStyles:pe,placement:z,isPositioned:W,middlewareData:ce}=_6({strategy:"fixed",placement:te,whileElementsMounted:(...ye)=>m6(...ye,{animationFrame:y==="always"}),elements:{reference:k.anchor},middleware:[T6({mainAxis:r+X,alignmentAxis:o}),u&&E6({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?R6():void 0,...se}),u&&Q6({...se}),A6({...se,apply:({elements:ye,rects:xe,availableWidth:Le,availableHeight:Ue})=>{const{width:Ke,height:Et}=xe.reference,ht=ye.floating.style;ht.setProperty("--radix-popper-available-width",`${Le}px`),ht.setProperty("--radix-popper-available-height",`${Ue}px`),ht.setProperty("--radix-popper-anchor-width",`${Ke}px`),ht.setProperty("--radix-popper-anchor-height",`${Et}px`)}}),Q&&j6({element:Q,padding:l}),X6({arrowWidth:P,arrowHeight:X}),O&&P6({strategy:"referenceHidden",...se,boundary:K?se.boundary:void 0})]}),oe=k.setPlacementState;Xn(()=>(oe(z),()=>{oe(void 0)}),[z,oe]);const[ae,D]=Xw(z),j=Mr(v);Xn(()=>{W&&j?.()},[W,j]);const I=ce.arrow?.x,N=ce.arrow?.y,V=ce.arrow?.centerOffset!==0,[ne,ie]=w.useState();return Xn(()=>{C&&ie(window.getComputedStyle(C).zIndex)},[C]),m.jsx("div",{ref:H.setFloating,"data-radix-popper-content-wrapper":"",style:{...pe,transform:W?pe.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ne,"--radix-popper-transform-origin":[ce.transformOrigin?.x,ce.transformOrigin?.y].join(" "),...ce.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:m.jsx(z6,{scope:n,placedSide:ae,placedAlign:D,onArrowChange:A,arrowX:I,arrowY:N,shouldHideArrow:V,children:m.jsx(We.div,{"data-side":ae,"data-align":D,...S,ref:T,style:{...S.style,animation:W?void 0:"none"}})})})});LP.displayName=Iw;var ZP="PopperArrow",Z6={top:"bottom",right:"left",bottom:"top",left:"right"},IP=w.forwardRef(function(e,n){const{__scopePopper:i,...r}=e,s=L6(ZP,i),o=Z6[s.placedSide];return m.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:m.jsx(D6,{...r,ref:n,style:{...r.style,display:"block"}})})});IP.displayName=ZP;function I6(t){return t!==null}var X6=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:i,middlewareData:r}=e,o=r.arrow?.centerOffset!==0,l=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[f,h]=Xw(n),p={start:"0%",center:"50%",end:"100%"}[h],O=(r.arrow?.x??0)+l/2,y=(r.arrow?.y??0)+u/2;let v="",S="";return f==="bottom"?(v=o?p:`${O}px`,S=`${-u}px`):f==="top"?(v=o?p:`${O}px`,S=`${i.floating.height+u}px`):f==="right"?(v=`${-u}px`,S=o?p:`${y}px`):f==="left"&&(v=`${i.floating.width+u}px`,S=o?p:`${y}px`),{data:{x:v,y:S}}}});function Xw(t){const[e,n="center"]=t.split("-");return[e,n]}var Vw=DP,Bw=zP,Uw=LP,qw=IP,Kv=!1;function V6(){const[t,e]=w.useState(Kv);return w.useEffect(()=>{Kv||(Kv=!0,e(!0))},[]),t}var XP=pO[" useSyncExternalStore ".trim().toString()];function B6(){return()=>{}}function U6(){return XP(B6,()=>!0,()=>!1)}var q6=typeof XP=="function"?U6:V6,Jv="rovingFocusGroup.onEntryFocus",Y6={bubbles:!1,cancelable:!0},gh="RovingFocusGroup",[TS,VP,F6]=ww(gh),[G6,BP]=Da(gh,[F6]),[H6,W6]=G6(gh),UP=w.forwardRef((t,e)=>m.jsx(TS.Provider,{scope:t.__scopeRovingFocusGroup,children:m.jsx(TS.Slot,{scope:t.__scopeRovingFocusGroup,children:m.jsx(K6,{...t,ref:e})})}));UP.displayName=gh;var K6=w.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:i,loop:r=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:h=!1,...p}=t,O=w.useRef(null),y=kt(e,O),v=kw(s),[S,k]=vu({prop:o,defaultProp:l??null,onChange:u,caller:gh}),[C,$]=w.useState(!1),T=Mr(f),Q=VP(n),A=w.useRef(!1),[R,P]=w.useState(0);return w.useEffect(()=>{const X=O.current;if(X)return X.addEventListener(Jv,T),()=>X.removeEventListener(Jv,T)},[T]),m.jsx(H6,{scope:n,orientation:i,dir:v,loop:r,currentTabStopId:S,onItemFocus:w.useCallback(X=>k(X),[k]),onItemShiftTab:w.useCallback(()=>$(!0),[]),onFocusableItemAdd:w.useCallback(()=>P(X=>X+1),[]),onFocusableItemRemove:w.useCallback(()=>P(X=>X-1),[]),children:m.jsx(We.div,{tabIndex:C||R===0?-1:0,"data-orientation":i,...p,ref:y,style:{outline:"none",...t.style},onMouseDown:je(t.onMouseDown,()=>{A.current=!0}),onFocus:je(t.onFocus,X=>{const te=!A.current;if(X.target===X.currentTarget&&te&&!C){const G=new CustomEvent(Jv,Y6);if(X.currentTarget.dispatchEvent(G),!G.defaultPrevented){const Y=Q().filter(z=>z.focusable),K=Y.find(z=>z.active),se=Y.find(z=>z.id===S),pe=[K,se,...Y].filter(Boolean).map(z=>z.ref.current);FP(pe,h)}}A.current=!1}),onBlur:je(t.onBlur,()=>$(!1))})})}),qP="RovingFocusGroupItem",YP=w.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:i=!0,active:r=!1,tabStopId:s,children:o,...l}=t,u=hi(),f=s||u,h=W6(qP,n),p=h.currentTabStopId===f,O=VP(n),{onFocusableItemAdd:y,onFocusableItemRemove:v,currentTabStopId:S}=h,k=q6();return Xn(()=>{if(!(!k||!i))return y(),()=>v()},[k,i,y,v]),w.useEffect(()=>{if(!(k||!i))return y(),()=>v()},[k,i,y,v]),m.jsx(TS.ItemSlot,{scope:n,id:f,focusable:i,active:r,children:m.jsx(We.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...l,ref:e,onMouseDown:je(t.onMouseDown,C=>{i?h.onItemFocus(f):C.preventDefault()}),onFocus:je(t.onFocus,()=>h.onItemFocus(f)),onKeyDown:je(t.onKeyDown,C=>{if(C.key==="Tab"&&C.shiftKey){h.onItemShiftTab();return}if(C.target!==C.currentTarget)return;const $=t8(C,h.orientation,h.dir);if($!==void 0){if(C.metaKey||C.ctrlKey||C.altKey||C.shiftKey)return;C.preventDefault();let Q=O().filter(A=>A.focusable).map(A=>A.ref.current);if($==="last")Q.reverse();else if($==="prev"||$==="next"){$==="prev"&&Q.reverse();const A=Q.indexOf(C.currentTarget);Q=h.loop?n8(Q,A+1):Q.slice(A+1)}setTimeout(()=>FP(Q))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:S!=null}):o})})});YP.displayName=qP;var J6={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function e8(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function t8(t,e,n){const i=e8(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return J6[i]}function FP(t,e=!1){const n=document.activeElement;for(const i of t)if(i===n||(i.focus({preventScroll:e}),document.activeElement!==n))return}function n8(t,e){return t.map((n,i)=>t[(e+i)%t.length])}var i8=UP,r8=YP,ES=["Enter"," "],s8=["ArrowDown","PageUp","Home"],GP=["ArrowUp","PageDown","End"],o8=[...s8,...GP],a8={ltr:[...ES,"ArrowRight"],rtl:[...ES,"ArrowLeft"]},l8={ltr:["ArrowLeft"],rtl:["ArrowRight"]},mh="Menu",[Af,c8,u8]=ww(mh),[Yl,HP]=Da(mh,[u8,Bu,BP]),_O=Bu(),WP=BP(),[d8,Fl]=Yl(mh),[f8,Oh]=Yl(mh),KP=t=>{const{__scopeMenu:e,open:n=!1,children:i,dir:r,onOpenChange:s,modal:o=!0}=t,l=_O(e),[u,f]=w.useState(null),h=w.useRef(!1),p=Mr(s),O=kw(r);return w.useEffect(()=>{const y=()=>{h.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>h.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),w.useEffect(()=>{if(!n)return;const y=()=>p(!1);return window.addEventListener("blur",y),()=>window.removeEventListener("blur",y)},[n,p]),m.jsx(Vw,{...l,children:m.jsx(d8,{scope:e,open:n,onOpenChange:p,content:u,onContentChange:f,children:m.jsx(f8,{scope:e,onClose:w.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:h,dir:O,modal:o,children:i})})})};KP.displayName=mh;var h8="MenuAnchor",Yw=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t,r=_O(n);return m.jsx(Bw,{...r,...i,ref:e})});Yw.displayName=h8;var Fw="MenuPortal",[p8,JP]=Yl(Fw,{forceMount:void 0}),ej=t=>{const{__scopeMenu:e,forceMount:n,children:i,container:r}=t,s=Fl(Fw,e);return m.jsx(p8,{scope:e,forceMount:n,children:m.jsx(is,{present:n||s.open,children:m.jsx(ph,{asChild:!0,container:r,children:i})})})};ej.displayName=Fw;var jr="MenuContent",[g8,Gw]=Yl(jr),tj=w.forwardRef((t,e)=>{const n=JP(jr,t.__scopeMenu),{forceMount:i=n.forceMount,...r}=t,s=Fl(jr,t.__scopeMenu),o=Oh(jr,t.__scopeMenu);return m.jsx(Af.Provider,{scope:t.__scopeMenu,children:m.jsx(is,{present:i||s.open,children:m.jsx(Af.Slot,{scope:t.__scopeMenu,children:o.modal?m.jsx(m8,{...r,ref:e}):m.jsx(O8,{...r,ref:e})})})})}),m8=w.forwardRef((t,e)=>{const n=Fl(jr,t.__scopeMenu),i=w.useRef(null),r=kt(e,i);return w.useEffect(()=>{const s=i.current;if(s)return $w(s)},[]),m.jsx(Hw,{...t,ref:r,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:je(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),O8=w.forwardRef((t,e)=>{const n=Fl(jr,t.__scopeMenu);return m.jsx(Hw,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),y8=Rl("MenuContent.ScrollLock"),Hw=w.forwardRef((t,e)=>{const{__scopeMenu:n,loop:i=!1,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:O,onDismiss:y,disableOutsideScroll:v,...S}=t,k=Fl(jr,n),C=Oh(jr,n),$=_O(n),T=WP(n),Q=c8(n),[A,R]=w.useState(null),P=w.useRef(null),X=kt(e,P,k.onContentChange),te=w.useRef(0),G=w.useRef(""),Y=w.useRef(0),K=w.useRef(null),se=w.useRef("right"),H=w.useRef(0),pe=v?vO:w.Fragment,z=v?{as:y8,allowPinchZoom:!0}:void 0,W=oe=>{const ae=G.current+oe,D=Q().filter(ie=>!ie.disabled),j=document.activeElement,I=D.find(ie=>ie.ref.current===j)?.textValue,N=D.map(ie=>ie.textValue),V=R8(N,ae,I),ne=D.find(ie=>ie.textValue===V)?.ref.current;(function ie(ye){G.current=ye,window.clearTimeout(te.current),ye!==""&&(te.current=window.setTimeout(()=>ie(""),1e3))})(ae),ne&&setTimeout(()=>ne.focus())};w.useEffect(()=>()=>window.clearTimeout(te.current),[]),_w();const ce=w.useCallback(oe=>se.current===K.current?.side&&A8(oe,K.current?.area),[]);return m.jsx(g8,{scope:n,searchRef:G,onItemEnter:w.useCallback(oe=>{ce(oe)&&oe.preventDefault()},[ce]),onItemLeave:w.useCallback(oe=>{ce(oe)||(P.current?.focus(),R(null))},[ce]),onTriggerLeave:w.useCallback(oe=>{ce(oe)&&oe.preventDefault()},[ce]),pointerGraceTimerRef:Y,onPointerGraceIntentChange:w.useCallback(oe=>{K.current=oe},[]),children:m.jsx(pe,{...z,children:m.jsx(OO,{asChild:!0,trapped:r,onMountAutoFocus:je(s,oe=>{oe.preventDefault(),P.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:m.jsx(hh,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:O,onDismiss:y,children:m.jsx(i8,{asChild:!0,...T,dir:C.dir,orientation:"vertical",loop:i,currentTabStopId:A,onCurrentTabStopIdChange:R,onEntryFocus:je(u,oe=>{C.isUsingKeyboardRef.current||oe.preventDefault()}),preventScrollOnEntryFocus:!0,children:m.jsx(Uw,{role:"menu","aria-orientation":"vertical","data-state":Oj(k.open),"data-radix-menu-content":"",dir:C.dir,...$,...S,ref:X,style:{outline:"none",...S.style},onKeyDown:je(S.onKeyDown,oe=>{const D=oe.target.closest("[data-radix-menu-content]")===oe.currentTarget,j=oe.ctrlKey||oe.altKey||oe.metaKey,I=oe.key.length===1;D&&(oe.key==="Tab"&&oe.preventDefault(),!j&&I&&W(oe.key));const N=P.current;if(oe.target!==N||!o8.includes(oe.key))return;oe.preventDefault();const ne=Q().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);GP.includes(oe.key)&&ne.reverse(),T8(ne)}),onBlur:je(t.onBlur,oe=>{oe.currentTarget.contains(oe.target)||(window.clearTimeout(te.current),G.current="")}),onPointerMove:je(t.onPointerMove,Pf(oe=>{const ae=oe.target,D=H.current!==oe.clientX;if(oe.currentTarget.contains(ae)&&D){const j=oe.clientX>H.current?"right":"left";se.current=j,H.current=oe.clientX}}))})})})})})})});tj.displayName=jr;var v8="MenuGroup",Ww=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t;return m.jsx(We.div,{role:"group",...i,ref:e})});Ww.displayName=v8;var b8="MenuLabel",nj=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t;return m.jsx(We.div,{...i,ref:e})});nj.displayName=b8;var Om="MenuItem",Q2="menu.itemSelect",$O=w.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:i,...r}=t,s=w.useRef(null),o=Oh(Om,t.__scopeMenu),l=Gw(Om,t.__scopeMenu),u=kt(e,s),f=w.useRef(!1),h=()=>{const p=s.current;if(!n&&p){const O=new CustomEvent(Q2,{bubbles:!0,cancelable:!0});p.addEventListener(Q2,y=>i?.(y),{once:!0}),eP(p,O),O.defaultPrevented?f.current=!1:o.onClose()}};return m.jsx(ij,{...r,ref:u,disabled:n,onClick:je(t.onClick,h),onPointerDown:p=>{t.onPointerDown?.(p),f.current=!0},onPointerUp:je(t.onPointerUp,p=>{f.current||p.currentTarget?.click()}),onKeyDown:je(t.onKeyDown,p=>{n||p.target!==p.currentTarget||l.searchRef.current!==""&&p.key===" "||ES.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});$O.displayName=Om;var ij=w.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:i=!1,textValue:r,...s}=t,o=Gw(Om,n),l=WP(n),u=w.useRef(null),f=kt(e,u),[h,p]=w.useState(!1),[O,y]=w.useState("");return w.useEffect(()=>{const v=u.current;v&&y((v.textContent??"").trim())},[s.children]),m.jsx(Af.ItemSlot,{scope:n,disabled:i,textValue:r??O,children:m.jsx(r8,{asChild:!0,...l,focusable:!i,children:m.jsx(We.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...s,ref:f,onPointerMove:je(t.onPointerMove,Pf(v=>{i?o.onItemLeave(v):(o.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:je(t.onPointerLeave,Pf(v=>o.onItemLeave(v))),onFocus:je(t.onFocus,()=>p(!0)),onBlur:je(t.onBlur,()=>p(!1))})})})}),S8="MenuCheckboxItem",rj=w.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:i,...r}=t;return m.jsx(cj,{scope:t.__scopeMenu,checked:n,children:m.jsx($O,{role:"menuitemcheckbox","aria-checked":ym(n)?"mixed":n,...r,ref:e,"data-state":Jw(n),onSelect:je(r.onSelect,()=>i?.(ym(n)?!0:!n),{checkForDefaultPrevented:!1})})})});rj.displayName=S8;var sj="MenuRadioGroup",[x8,w8]=Yl(sj,{value:void 0,onValueChange:()=>{}}),oj=w.forwardRef((t,e)=>{const{value:n,onValueChange:i,...r}=t,s=Mr(i);return m.jsx(x8,{scope:t.__scopeMenu,value:n,onValueChange:s,children:m.jsx(Ww,{...r,ref:e})})});oj.displayName=sj;var aj="MenuRadioItem",lj=w.forwardRef((t,e)=>{const{value:n,...i}=t,r=w8(aj,t.__scopeMenu),s=n===r.value;return m.jsx(cj,{scope:t.__scopeMenu,checked:s,children:m.jsx($O,{role:"menuitemradio","aria-checked":s,...i,ref:e,"data-state":Jw(s),onSelect:je(i.onSelect,()=>r.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});lj.displayName=aj;var Kw="MenuItemIndicator",[cj,k8]=Yl(Kw,{checked:!1}),uj=w.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:i,...r}=t,s=k8(Kw,n);return m.jsx(is,{present:i||ym(s.checked)||s.checked===!0,children:m.jsx(We.span,{...r,ref:e,"data-state":Jw(s.checked)})})});uj.displayName=Kw;var C8="MenuSeparator",dj=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t;return m.jsx(We.div,{role:"separator","aria-orientation":"horizontal",...i,ref:e})});dj.displayName=C8;var _8="MenuArrow",fj=w.forwardRef((t,e)=>{const{__scopeMenu:n,...i}=t,r=_O(n);return m.jsx(qw,{...r,...i,ref:e})});fj.displayName=_8;var $8="MenuSub",[Hge,hj]=Yl($8),lf="MenuSubTrigger",pj=w.forwardRef((t,e)=>{const n=Fl(lf,t.__scopeMenu),i=Oh(lf,t.__scopeMenu),r=hj(lf,t.__scopeMenu),s=Gw(lf,t.__scopeMenu),o=w.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=s,f={__scopeMenu:t.__scopeMenu},h=w.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);w.useEffect(()=>h,[h]),w.useEffect(()=>{const O=l.current;return()=>{window.clearTimeout(O),u(null)}},[l,u]);const p=kt(e,r.onTriggerChange);return m.jsx(Yw,{asChild:!0,...f,children:m.jsx(ij,{id:r.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":n.open?r.contentId:void 0,"data-state":Oj(n.open),...t,ref:p,onClick:O=>{t.onClick?.(O),!(t.disabled||O.defaultPrevented)&&(O.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:je(t.onPointerMove,Pf(O=>{s.onItemEnter(O),!O.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:je(t.onPointerLeave,Pf(O=>{h();const y=n.content?.getBoundingClientRect();if(y){const v=n.content?.dataset.side,S=v==="right",k=S?-5:5,C=y[S?"left":"right"],$=y[S?"right":"left"];s.onPointerGraceIntentChange({area:[{x:O.clientX+k,y:O.clientY},{x:C,y:y.top},{x:$,y:y.top},{x:$,y:y.bottom},{x:C,y:y.bottom}],side:v}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(O),O.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:je(t.onKeyDown,O=>{t.disabled||O.target!==O.currentTarget||s.searchRef.current!==""&&O.key===" "||a8[i.dir].includes(O.key)&&(n.onOpenChange(!0),n.content?.focus(),O.preventDefault())})})})});pj.displayName=lf;var gj="MenuSubContent",mj=w.forwardRef((t,e)=>{const n=JP(jr,t.__scopeMenu),{forceMount:i=n.forceMount,align:r="start",...s}=t,o=Fl(jr,t.__scopeMenu),l=Oh(jr,t.__scopeMenu),u=hj(gj,t.__scopeMenu),f=w.useRef(null),h=kt(e,f);return m.jsx(Af.Provider,{scope:t.__scopeMenu,children:m.jsx(is,{present:i||o.open,children:m.jsx(Af.Slot,{scope:t.__scopeMenu,children:m.jsx(Hw,{id:u.contentId,"aria-labelledby":u.triggerId,...s,ref:h,align:r,side:l.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:p=>{l.isUsingKeyboardRef.current&&f.current?.focus(),p.preventDefault()},onCloseAutoFocus:p=>p.preventDefault(),onFocusOutside:je(t.onFocusOutside,p=>{p.target!==u.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:je(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:je(t.onKeyDown,p=>{const O=p.currentTarget.contains(p.target),y=l8[l.dir].includes(p.key);O&&y&&(o.onOpenChange(!1),u.trigger?.focus(),p.preventDefault())})})})})})});mj.displayName=gj;function Oj(t){return t?"open":"closed"}function ym(t){return t==="indeterminate"}function Jw(t){return ym(t)?"indeterminate":t?"checked":"unchecked"}function T8(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function E8(t,e){return t.map((n,i)=>t[(e+i)%t.length])}function R8(t,e,n){const r=e.length>1&&Array.from(e).every(f=>f===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=E8(t,Math.max(s,0));r.length===1&&(o=o.filter(f=>f!==n));const u=o.find(f=>f.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function Q8(t,e){const{x:n,y:i}=t;let r=!1;for(let s=0,o=e.length-1;si!=O>i&&n<(p-f)*(i-h)/(O-h)+f&&(r=!r)}return r}function A8(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return Q8(n,e)}function Pf(t){return e=>e.pointerType==="mouse"?t(e):void 0}var P8=KP,j8=Yw,M8=ej,D8=tj,N8=Ww,z8=nj,L8=$O,Z8=rj,I8=oj,X8=lj,V8=uj,B8=dj,U8=fj,q8=pj,Y8=mj,TO="DropdownMenu",[F8]=Da(TO,[HP]),Ti=HP(),[G8,yj]=F8(TO),vj=t=>{const{__scopeDropdownMenu:e,children:n,dir:i,open:r,defaultOpen:s,onOpenChange:o,modal:l=!0}=t,u=Ti(e),f=w.useRef(null),[h,p]=vu({prop:r,defaultProp:s??!1,onChange:o,caller:TO});return m.jsx(G8,{scope:e,triggerId:hi(),triggerRef:f,contentId:hi(),open:h,onOpenChange:p,onOpenToggle:w.useCallback(()=>p(O=>!O),[p]),modal:l,children:m.jsx(P8,{...u,open:h,onOpenChange:p,dir:i,modal:l,children:n})})};vj.displayName=TO;var bj="DropdownMenuTrigger",Sj=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:i=!1,...r}=t,s=yj(bj,n),o=Ti(n),l=kt(e,s.triggerRef);return m.jsx(j8,{asChild:!0,...o,children:m.jsx(We.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...r,ref:l,onPointerDown:je(t.onPointerDown,u=>{!i&&u.button===0&&u.ctrlKey===!1&&(s.onOpenToggle(),s.open||u.preventDefault())}),onKeyDown:je(t.onKeyDown,u=>{i||(["Enter"," "].includes(u.key)&&s.onOpenToggle(),u.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(u.key)&&u.preventDefault())})})})});Sj.displayName=bj;var H8="DropdownMenuPortal",xj=t=>{const{__scopeDropdownMenu:e,...n}=t,i=Ti(e);return m.jsx(M8,{...i,...n})};xj.displayName=H8;var wj="DropdownMenuContent",kj=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=yj(wj,n),s=Ti(n),o=w.useRef(!1);return m.jsx(D8,{id:r.contentId,"aria-labelledby":r.triggerId,...s,...i,ref:e,onCloseAutoFocus:je(t.onCloseAutoFocus,l=>{o.current||r.triggerRef.current?.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:je(t.onInteractOutside,l=>{const u=l.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,h=u.button===2||f;(!r.modal||h)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});kj.displayName=wj;var W8="DropdownMenuGroup",K8=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(N8,{...r,...i,ref:e})});K8.displayName=W8;var J8="DropdownMenuLabel",Cj=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(z8,{...r,...i,ref:e})});Cj.displayName=J8;var eU="DropdownMenuItem",_j=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(L8,{...r,...i,ref:e})});_j.displayName=eU;var tU="DropdownMenuCheckboxItem",nU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(Z8,{...r,...i,ref:e})});nU.displayName=tU;var iU="DropdownMenuRadioGroup",rU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(I8,{...r,...i,ref:e})});rU.displayName=iU;var sU="DropdownMenuRadioItem",oU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(X8,{...r,...i,ref:e})});oU.displayName=sU;var aU="DropdownMenuItemIndicator",lU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(V8,{...r,...i,ref:e})});lU.displayName=aU;var cU="DropdownMenuSeparator",uU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(B8,{...r,...i,ref:e})});uU.displayName=cU;var dU="DropdownMenuArrow",fU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(U8,{...r,...i,ref:e})});fU.displayName=dU;var hU="DropdownMenuSubTrigger",pU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(q8,{...r,...i,ref:e})});pU.displayName=hU;var gU="DropdownMenuSubContent",mU=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...i}=t,r=Ti(n);return m.jsx(Y8,{...r,...i,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});mU.displayName=gU;var OU=vj,yU=Sj,vU=xj,bU=kj,SU=Cj,xU=_j,wU="Label",$j=w.forwardRef((t,e)=>m.jsx(We.label,{...t,ref:e,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));$j.displayName=wU;var kU=$j;function A2(t,[e,n]){return Math.min(n,Math.max(e,t))}var CU=[" ","Enter","ArrowUp","ArrowDown"],_U=[" ","Enter"],Pl="Select",[EO,RO,$U]=ww(Pl),[Gl]=Da(Pl,[$U,Bu]),QO=Bu(),[TU,za]=Gl(Pl),[EU,RU]=Gl(Pl),QU="SelectProvider";function Tj(t){const{__scopeSelect:e,children:n,open:i,defaultOpen:r,onOpenChange:s,value:o,defaultValue:l,onValueChange:u,dir:f,name:h,autoComplete:p,disabled:O,required:y,form:v,internal_do_not_use_render:S}=t,k=QO(e),[C,$]=w.useState(null),[T,Q]=w.useState(null),[A,R]=w.useState(!1),P=kw(f),[X,te]=vu({prop:i,defaultProp:r??!1,onChange:s,caller:Pl}),[G,Y]=vu({prop:o,defaultProp:l,onChange:u,caller:Pl}),K=w.useRef(null),se=w.useRef(G);w.useEffect(()=>{const j=v?C?.ownerDocument.getElementById(v):C?.form;if(j instanceof HTMLFormElement){const I=()=>Y(se.current);return j.addEventListener("reset",I),()=>j.removeEventListener("reset",I)}},[v,C,Y]);const H=C?!!v||!!C.closest("form"):!0,[pe,z]=w.useState(new Set),W=hi(),ce=Array.from(pe).map(j=>j.props.value).join(";"),oe=w.useCallback(j=>{z(I=>new Set(I).add(j))},[]),ae=w.useCallback(j=>{z(I=>{const N=new Set(I);return N.delete(j),N})},[]),D={required:y,trigger:C,onTriggerChange:$,valueNode:T,onValueNodeChange:Q,valueNodeHasChildren:A,onValueNodeHasChildrenChange:R,contentId:W,value:G,onValueChange:Y,open:X,onOpenChange:te,dir:P,triggerPointerDownPosRef:K,disabled:O,name:h,autoComplete:p,form:v,nativeOptions:pe,nativeSelectKey:ce,isFormControl:H};return m.jsx(Vw,{...k,children:m.jsx(TU,{scope:e,...D,children:m.jsx(EO.Provider,{scope:e,children:m.jsx(EU,{scope:e,onNativeOptionAdd:oe,onNativeOptionRemove:ae,children:FU(S)?S(D):n})})})})}Tj.displayName=QU;var Ej=t=>{const{__scopeSelect:e,children:n,...i}=t;return m.jsx(Tj,{__scopeSelect:e,...i,internal_do_not_use_render:({isFormControl:r})=>m.jsxs(m.Fragment,{children:[n,r?m.jsx(tM,{__scopeSelect:e}):null]})})};Ej.displayName=Pl;var Rj="SelectTrigger",Qj=w.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:i=!1,...r}=t,s=QO(n),o=za(Rj,n),l=o.disabled||i,u=kt(e,o.onTriggerChange),f=RO(n),h=w.useRef("touch"),[p,O,y]=nM(S=>{const k=f().filter(T=>!T.disabled),C=k.find(T=>T.value===o.value),$=iM(k,S,C);$!==void 0&&o.onValueChange($.value)}),v=S=>{l||(o.onOpenChange(!0),y()),S&&(o.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return m.jsx(Bw,{asChild:!0,...s,children:m.jsx(We.button,{type:"button",role:"combobox","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":AO(o.value)?"":void 0,...r,ref:u,onClick:je(r.onClick,S=>{S.currentTarget.focus(),h.current!=="mouse"&&v(S)}),onPointerDown:je(r.onPointerDown,S=>{h.current=S.pointerType;const k=S.target;k.hasPointerCapture(S.pointerId)&&k.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(v(S),S.preventDefault())}),onKeyDown:je(r.onKeyDown,S=>{const k=p.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&O(S.key),!(k&&S.key===" ")&&CU.includes(S.key)&&(v(),S.preventDefault())})})})});Qj.displayName=Rj;var Aj="SelectValue",Pj=w.forwardRef((t,e)=>{const{__scopeSelect:n,className:i,style:r,children:s,placeholder:o="",...l}=t,u=za(Aj,n),{onValueNodeHasChildrenChange:f}=u,h=s!==void 0,p=kt(e,u.onValueNodeChange);Xn(()=>{f(h)},[f,h]);const O=AO(u.value);return m.jsx(We.span,{...l,asChild:O?!1:l.asChild,ref:p,style:{pointerEvents:"none"},children:m.jsx(w.Fragment,{children:O?o:s},O?"placeholder":"value")})});Pj.displayName=Aj;var AU="SelectIcon",jj=w.forwardRef((t,e)=>{const{__scopeSelect:n,children:i,...r}=t;return m.jsx(We.span,{"aria-hidden":!0,...r,ref:e,children:i||"▼"})});jj.displayName=AU;var Mj="SelectPortal",[PU,jU]=Gl(Mj,{forceMount:void 0}),Dj=t=>{const{__scopeSelect:e,forceMount:n,...i}=t;return m.jsx(PU,{scope:t.__scopeSelect,forceMount:n,children:m.jsx(ph,{asChild:!0,...i})})};Dj.displayName=Mj;var Ca="SelectContent",Nj=w.forwardRef((t,e)=>{const n=jU(Ca,t.__scopeSelect),{forceMount:i=n.forceMount,...r}=t,s=za(Ca,t.__scopeSelect),[o,l]=w.useState();return Xn(()=>{l(new DocumentFragment)},[]),m.jsx(is,{present:i||s.open,children:({present:u})=>u?m.jsx(Zj,{...r,ref:e}):m.jsx(zj,{...r,fragment:o})})});Nj.displayName=Ca;var zj=w.forwardRef((t,e)=>{const{__scopeSelect:n,children:i,fragment:r}=t;return r?ql.createPortal(m.jsx(Lj,{scope:n,children:m.jsx(EO.Slot,{scope:n,children:m.jsx("div",{ref:e,children:i})})}),r):null});zj.displayName="SelectContentFragment";var Ur=10,[Lj,La]=Gl(Ca),MU="SelectContentImpl",DU=Rl("SelectContent.RemoveScroll"),Zj=w.forwardRef((t,e)=>{const{__scopeSelect:n}=t,{position:i="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:s,onPointerDownOutside:o,side:l,sideOffset:u,align:f,alignOffset:h,arrowPadding:p,collisionBoundary:O,collisionPadding:y,sticky:v,hideWhenDetached:S,avoidCollisions:k,...C}=t,$=za(Ca,n),[T,Q]=w.useState(null),[A,R]=w.useState(null),P=kt(e,Q),[X,te]=w.useState(null),[G,Y]=w.useState(null),K=RO(n),[se,H]=w.useState(!1),pe=w.useRef(!1);w.useEffect(()=>{if(T)return $w(T)},[T]),_w();const z=w.useCallback(ie=>{const[ye,...xe]=K().map(Ke=>Ke.ref.current),[Le]=xe.slice(-1),Ue=document.activeElement;for(const Ke of ie)if(Ke===Ue||(Ke?.scrollIntoView({block:"nearest"}),Ke===ye&&A&&(A.scrollTop=0),Ke===Le&&A&&(A.scrollTop=A.scrollHeight),Ke?.focus(),document.activeElement!==Ue))return},[K,A]),W=w.useCallback(()=>z([X,T]),[z,X,T]);w.useEffect(()=>{se&&W()},[se,W]);const{onOpenChange:ce,triggerPointerDownPosRef:oe}=$;w.useEffect(()=>{if(T){let ie={x:0,y:0};const ye=Le=>{ie={x:Math.abs(Math.round(Le.pageX)-(oe.current?.x??0)),y:Math.abs(Math.round(Le.pageY)-(oe.current?.y??0))}},xe=Le=>{ie.x<=10&&ie.y<=10?Le.preventDefault():Le.composedPath().includes(T)||ce(!1),document.removeEventListener("pointermove",ye),oe.current=null};return oe.current!==null&&(document.addEventListener("pointermove",ye),document.addEventListener("pointerup",xe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",xe,{capture:!0})}}},[T,ce,oe]),w.useEffect(()=>{const ie=()=>ce(!1);return window.addEventListener("blur",ie),window.addEventListener("resize",ie),()=>{window.removeEventListener("blur",ie),window.removeEventListener("resize",ie)}},[ce]);const[ae,D]=nM(ie=>{const ye=K().filter(Ue=>!Ue.disabled),xe=ye.find(Ue=>Ue.ref.current===document.activeElement),Le=iM(ye,ie,xe);Le&&setTimeout(()=>Le.ref.current?.focus())}),j=w.useCallback((ie,ye,xe)=>{const Le=!pe.current&&!xe;($.value!==void 0&&$.value===ye||Le)&&(te(ie),Le&&(pe.current=!0))},[$.value]),I=w.useCallback(()=>T?.focus(),[T]),N=w.useCallback((ie,ye,xe)=>{const Le=!pe.current&&!xe;($.value!==void 0&&$.value===ye||Le)&&Y(ie)},[$.value]),V=i==="popper"?RS:Ij,ne=V===RS?{side:l,sideOffset:u,align:f,alignOffset:h,arrowPadding:p,collisionBoundary:O,collisionPadding:y,sticky:v,hideWhenDetached:S,avoidCollisions:k}:{};return m.jsx(Lj,{scope:n,content:T,viewport:A,onViewportChange:R,itemRefCallback:j,selectedItem:X,onItemLeave:I,itemTextRefCallback:N,focusSelectedItem:W,selectedItemText:G,position:i,isPositioned:se,searchRef:ae,children:m.jsx(vO,{as:DU,allowPinchZoom:!0,children:m.jsx(OO,{asChild:!0,trapped:$.open,onMountAutoFocus:ie=>{ie.preventDefault()},onUnmountAutoFocus:je(r,ie=>{$.trigger?.focus({preventScroll:!0}),ie.preventDefault()}),children:m.jsx(hh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:ie=>ie.preventDefault(),onDismiss:()=>$.onOpenChange(!1),children:m.jsx(V,{role:"listbox",id:$.contentId,"data-state":$.open?"open":"closed",dir:$.dir,onContextMenu:ie=>ie.preventDefault(),...C,...ne,onPlaced:()=>H(!0),ref:P,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:je(C.onKeyDown,ie=>{const ye=ie.ctrlKey||ie.altKey||ie.metaKey;if(ie.key==="Tab"&&ie.preventDefault(),!ye&&ie.key.length===1&&D(ie.key),["ArrowUp","ArrowDown","Home","End"].includes(ie.key)){let Le=K().filter(Ue=>!Ue.disabled).map(Ue=>Ue.ref.current);if(["ArrowUp","End"].includes(ie.key)&&(Le=Le.slice().reverse()),["ArrowUp","ArrowDown"].includes(ie.key)){const Ue=ie.target,Ke=Le.indexOf(Ue);Le=Le.slice(Ke+1)}setTimeout(()=>z(Le)),ie.preventDefault()}})})})})})})});Zj.displayName=MU;var NU="SelectItemAlignedPosition",Ij=w.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:i,...r}=t,s=za(Ca,n),o=La(Ca,n),[l,u]=w.useState(null),[f,h]=w.useState(null),p=kt(e,h),O=RO(n),y=w.useRef(!1),v=w.useRef(!0),{viewport:S,selectedItem:k,selectedItemText:C,focusSelectedItem:$}=o,T=w.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&f&&S&&k&&C){const P=s.trigger.getBoundingClientRect(),X=f.getBoundingClientRect(),te=s.valueNode.getBoundingClientRect(),G=C.getBoundingClientRect();if(s.dir!=="rtl"){const Ue=G.left-X.left,Ke=te.left-Ue,Et=P.left-Ke,ht=P.width+Et,ti=Math.max(ht,X.width),Oi=window.innerWidth-Ur,At=A2(Ke,[Ur,Math.max(Ur,Oi-ti)]);l.style.minWidth=ht+"px",l.style.left=At+"px"}else{const Ue=X.right-G.right,Ke=window.innerWidth-te.right-Ue,Et=window.innerWidth-P.right-Ke,ht=P.width+Et,ti=Math.max(ht,X.width),Oi=window.innerWidth-Ur,At=A2(Ke,[Ur,Math.max(Ur,Oi-ti)]);l.style.minWidth=ht+"px",l.style.right=At+"px"}const Y=O(),K=window.innerHeight-Ur*2,se=S.scrollHeight,H=window.getComputedStyle(f),pe=parseInt(H.borderTopWidth,10),z=parseInt(H.paddingTop,10),W=parseInt(H.borderBottomWidth,10),ce=parseInt(H.paddingBottom,10),oe=pe+z+se+ce+W,ae=Math.min(k.offsetHeight*5,oe),D=window.getComputedStyle(S),j=parseInt(D.paddingTop,10),I=parseInt(D.paddingBottom,10),N=P.top+P.height/2-Ur,V=K-N,ne=k.offsetHeight/2,ie=k.offsetTop+ne,ye=pe+z+ie,xe=oe-ye;if(ye<=N){const Ue=Y.length>0&&k===Y[Y.length-1].ref.current;l.style.bottom="0px";const Ke=f.clientHeight-S.offsetTop-S.offsetHeight,Et=Math.max(V,ne+(Ue?I:0)+Ke+W),ht=ye+Et;l.style.height=ht+"px"}else{const Ue=Y.length>0&&k===Y[0].ref.current;l.style.top="0px";const Et=Math.max(N,pe+S.offsetTop+(Ue?j:0)+ne)+xe;l.style.height=Et+"px",S.scrollTop=ye-N+S.offsetTop}l.style.margin=`${Ur}px 0`,l.style.minHeight=ae+"px",l.style.maxHeight=K+"px",i?.(),requestAnimationFrame(()=>y.current=!0)}},[O,s.trigger,s.valueNode,l,f,S,k,C,s.dir,i]);Xn(()=>T(),[T]);const[Q,A]=w.useState();Xn(()=>{f&&A(window.getComputedStyle(f).zIndex)},[f]);const R=w.useCallback(P=>{P&&v.current===!0&&(T(),$?.(),v.current=!1)},[T,$]);return m.jsx(LU,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:y,onScrollButtonChange:R,children:m.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:Q},children:m.jsx(We.div,{...r,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});Ij.displayName=NU;var zU="SelectPopperPosition",RS=w.forwardRef((t,e)=>{const{__scopeSelect:n,align:i="start",collisionPadding:r=Ur,...s}=t,o=QO(n);return m.jsx(Uw,{...o,...s,ref:e,align:i,collisionPadding:r,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});RS.displayName=zU;var[LU,e1]=Gl(Ca,{}),QS="SelectViewport",Xj=w.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:i,...r}=t,s=La(QS,n),o=e1(QS,n),l=kt(e,s.onViewportChange),u=w.useRef(0);return m.jsxs(m.Fragment,{children:[m.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),m.jsx(EO.Slot,{scope:n,children:m.jsx(We.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:je(r.onScroll,f=>{const h=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:O}=o;if(O?.current&&p){const y=Math.abs(u.current-h.scrollTop);if(y>0){const v=window.innerHeight-Ur*2,S=parseFloat(p.style.minHeight),k=parseFloat(p.style.height),C=Math.max(S,k);if(C0?Q:0,p.style.justifyContent="flex-end")}}}u.current=h.scrollTop})})})]})});Xj.displayName=QS;var Vj="SelectGroup",[ZU,IU]=Gl(Vj),XU=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t,r=hi();return m.jsx(ZU,{scope:n,id:r,children:m.jsx(We.div,{role:"group","aria-labelledby":r,...i,ref:e})})});XU.displayName=Vj;var Bj="SelectLabel",VU=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t,r=IU(Bj,n);return m.jsx(We.div,{id:r.id,...i,ref:e})});VU.displayName=Bj;var vm="SelectItem",[BU,Uj]=Gl(vm),qj=w.forwardRef((t,e)=>{const{__scopeSelect:n,value:i,disabled:r=!1,textValue:s,...o}=t,l=za(vm,n),u=La(vm,n),f=l.value===i,[h,p]=w.useState(s??""),[O,y]=w.useState(!1),v=Mr(T=>u.itemRefCallback?.(T,i,r)),S=kt(e,v),k=hi(),C=w.useRef("touch"),$=()=>{r||(l.onValueChange(i),l.onOpenChange(!1))};return m.jsx(BU,{scope:n,value:i,disabled:r,textId:k,isSelected:f,onItemTextChange:w.useCallback(T=>{p(Q=>Q||(T?.textContent??"").trim())},[]),children:m.jsx(EO.ItemSlot,{scope:n,value:i,disabled:r,textValue:h,children:m.jsx(We.div,{role:"option","aria-labelledby":k,"data-highlighted":O?"":void 0,"aria-selected":f&&O,"data-state":f?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...o,ref:S,onFocus:je(o.onFocus,()=>y(!0)),onBlur:je(o.onBlur,()=>y(!1)),onClick:je(o.onClick,()=>{C.current!=="mouse"&&$()}),onPointerUp:je(o.onPointerUp,()=>{C.current==="mouse"&&$()}),onPointerDown:je(o.onPointerDown,T=>{C.current=T.pointerType}),onPointerMove:je(o.onPointerMove,T=>{C.current=T.pointerType,r?u.onItemLeave?.():C.current==="mouse"&&T.currentTarget.focus({preventScroll:!0})}),onPointerLeave:je(o.onPointerLeave,T=>{T.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:je(o.onKeyDown,T=>{r||T.target!==T.currentTarget||u.searchRef?.current!==""&&T.key===" "||(_U.includes(T.key)&&$(),T.key===" "&&T.preventDefault())})})})})});qj.displayName=vm;var cf="SelectItemText",Yj=w.forwardRef((t,e)=>{const{__scopeSelect:n,className:i,style:r,...s}=t,o=za(cf,n),l=La(cf,n),u=Uj(cf,n),f=RU(cf,n),[h,p]=w.useState(null),O=Mr($=>l.itemTextRefCallback?.($,u.value,u.disabled)),y=kt(e,p,u.onItemTextChange,O),v=h?.textContent,S=w.useMemo(()=>m.jsx("option",{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:k,onNativeOptionRemove:C}=f;return Xn(()=>(k(S),()=>C(S)),[k,C,S]),m.jsxs(m.Fragment,{children:[m.jsx(We.span,{id:u.textId,...s,ref:y}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!AO(o.value)?ql.createPortal(s.children,o.valueNode):null]})});Yj.displayName=cf;var Fj="SelectItemIndicator",Gj=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t;return Uj(Fj,n).isSelected?m.jsx(We.span,{"aria-hidden":!0,...i,ref:e}):null});Gj.displayName=Fj;var AS="SelectScrollUpButton",Hj=w.forwardRef((t,e)=>{const n=La(AS,t.__scopeSelect),i=e1(AS,t.__scopeSelect),[r,s]=w.useState(!1),o=kt(e,i.onScrollButtonChange);return Xn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=u.scrollTop>0;s(f)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),r?m.jsx(Kj,{...t,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});Hj.displayName=AS;var PS="SelectScrollDownButton",Wj=w.forwardRef((t,e)=>{const n=La(PS,t.__scopeSelect),i=e1(PS,t.__scopeSelect),[r,s]=w.useState(!1),o=kt(e,i.onScrollButtonChange);return Xn(()=>{if(n.viewport&&n.isPositioned){let l=function(){const f=u.scrollHeight-u.clientHeight,h=Math.ceil(u.scrollTop)u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),r?m.jsx(Kj,{...t,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});Wj.displayName=PS;var Kj=w.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:i,...r}=t,s=La("SelectScrollButton",n),o=w.useRef(null),l=RO(n),u=w.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return w.useEffect(()=>()=>u(),[u]),Xn(()=>{l().find(h=>h.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),m.jsx(We.div,{"aria-hidden":!0,...r,ref:e,style:{flexShrink:0,...r.style},onPointerDown:je(r.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(i,50))}),onPointerMove:je(r.onPointerMove,()=>{s.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(i,50))}),onPointerLeave:je(r.onPointerLeave,()=>{u()})})}),UU="SelectSeparator",qU=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t;return m.jsx(We.div,{"aria-hidden":!0,...i,ref:e})});qU.displayName=UU;var Jj="SelectArrow",YU=w.forwardRef((t,e)=>{const{__scopeSelect:n,...i}=t,r=QO(n);return La(Jj,n).position==="popper"?m.jsx(qw,{...r,...i,ref:e}):null});YU.displayName=Jj;var eM="SelectBubbleInput",tM=w.forwardRef(({__scopeSelect:t,...e},n)=>{const i=za(eM,t),{value:r,onValueChange:s,required:o,disabled:l,name:u,autoComplete:f,form:h}=i,{nativeOptions:p,nativeSelectKey:O}=i,y=w.useRef(null),v=kt(n,y),S=r??"",k=TB(S),C=Array.from(p).some($=>($.props.value??"")==="");return w.useEffect(()=>{const $=y.current;if(!$)return;const T=window.HTMLSelectElement.prototype,A=Object.getOwnPropertyDescriptor(T,"value").set;if(k!==S&&A){const R=new Event("change",{bubbles:!0});A.call($,S),$.dispatchEvent(R)}},[k,S]),m.jsxs(We.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:u,autoComplete:f,disabled:l,form:h,onChange:$=>s($.target.value),...e,style:{...tP,...e.style},ref:v,defaultValue:S,children:[AO(r)&&!C?m.jsx("option",{value:""}):null,Array.from(p)]},O)});tM.displayName=eM;function FU(t){return typeof t=="function"}function AO(t){return t===""||t===void 0}function nM(t){const e=Mr(t),n=w.useRef(""),i=w.useRef(0),r=w.useCallback(o=>{const l=n.current+o;e(l),(function u(f){n.current=f,window.clearTimeout(i.current),f!==""&&(i.current=window.setTimeout(()=>u(""),1e3))})(l)},[e]),s=w.useCallback(()=>{n.current="",window.clearTimeout(i.current)},[]);return w.useEffect(()=>()=>window.clearTimeout(i.current),[]),[n,r,s]}function iM(t,e,n){const r=e.length>1&&Array.from(e).every(f=>f===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=GU(t,Math.max(s,0));r.length===1&&(o=o.filter(f=>f!==n));const u=o.find(f=>f.textValue.toLowerCase().startsWith(r.toLowerCase()));return u!==n?u:void 0}function GU(t,e){return t.map((n,i)=>t[(e+i)%t.length])}var HU="Separator",P2="horizontal",WU=["horizontal","vertical"],rM=w.forwardRef((t,e)=>{const{decorative:n,orientation:i=P2,...r}=t,s=KU(i)?i:P2,l=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return m.jsx(We.div,{"data-orientation":s,...l,...r,ref:e})});rM.displayName=HU;function KU(t){return WU.includes(t)}var JU=rM,[PO]=Da("Tooltip",[Bu]),jO=Bu(),sM="TooltipProvider",e9=700,jS="tooltip.open",[t9,t1]=PO(sM),oM=t=>{const{__scopeTooltip:e,delayDuration:n=e9,skipDelayDuration:i=300,disableHoverableContent:r=!1,children:s}=t,o=w.useRef(!0),l=w.useRef(!1),u=w.useRef(0);return w.useEffect(()=>{const f=u.current;return()=>window.clearTimeout(f)},[]),m.jsx(t9,{scope:e,isOpenDelayedRef:o,delayDuration:n,onOpen:w.useCallback(()=>{i<=0||(window.clearTimeout(u.current),o.current=!1)},[i]),onClose:w.useCallback(()=>{i<=0||(window.clearTimeout(u.current),u.current=window.setTimeout(()=>o.current=!0,i))},[i]),isPointerInTransitRef:l,onPointerInTransitChange:w.useCallback(f=>{l.current=f},[]),disableHoverableContent:r,children:s})};oM.displayName=sM;var jf="Tooltip",[n9,yh]=PO(jf),aM=t=>{const{__scopeTooltip:e,children:n,open:i,defaultOpen:r,onOpenChange:s,disableHoverableContent:o,delayDuration:l}=t,u=t1(jf,t.__scopeTooltip),f=jO(e),[h,p]=w.useState(null),O=hi(),y=w.useRef(0),v=o??u.disableHoverableContent,S=l??u.delayDuration,k=w.useRef(!1),[C,$]=vu({prop:i,defaultProp:r??!1,onChange:P=>{P?(u.onOpen(),document.dispatchEvent(new CustomEvent(jS))):u.onClose(),s?.(P)},caller:jf}),T=w.useMemo(()=>C?k.current?"delayed-open":"instant-open":"closed",[C]),Q=w.useCallback(()=>{window.clearTimeout(y.current),y.current=0,k.current=!1,$(!0)},[$]),A=w.useCallback(()=>{window.clearTimeout(y.current),y.current=0,$(!1)},[$]),R=w.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{k.current=!0,$(!0),y.current=0},S)},[S,$]);return w.useEffect(()=>()=>{y.current&&(window.clearTimeout(y.current),y.current=0)},[]),m.jsx(Vw,{...f,children:m.jsx(n9,{scope:e,contentId:O,open:C,stateAttribute:T,trigger:h,onTriggerChange:p,onTriggerEnter:w.useCallback(()=>{u.isOpenDelayedRef.current?R():Q()},[u.isOpenDelayedRef,R,Q]),onTriggerLeave:w.useCallback(()=>{v?A():(window.clearTimeout(y.current),y.current=0)},[A,v]),onOpen:Q,onClose:A,disableHoverableContent:v,children:n})})};aM.displayName=jf;var MS="TooltipTrigger",lM=w.forwardRef((t,e)=>{const{__scopeTooltip:n,...i}=t,r=yh(MS,n),s=t1(MS,n),o=jO(n),l=w.useRef(null),u=kt(e,l,r.onTriggerChange),f=w.useRef(!1),h=w.useRef(!1),p=w.useCallback(()=>f.current=!1,[]);return w.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),m.jsx(Bw,{asChild:!0,...o,children:m.jsx(We.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...i,ref:u,onPointerMove:je(t.onPointerMove,O=>{O.pointerType!=="touch"&&!h.current&&!s.isPointerInTransitRef.current&&(r.onTriggerEnter(),h.current=!0)}),onPointerLeave:je(t.onPointerLeave,()=>{r.onTriggerLeave(),h.current=!1}),onPointerDown:je(t.onPointerDown,()=>{r.open&&r.onClose(),f.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:je(t.onFocus,()=>{f.current||r.onOpen()}),onBlur:je(t.onBlur,r.onClose),onClick:je(t.onClick,r.onClose)})})});lM.displayName=MS;var n1="TooltipPortal",[i9,r9]=PO(n1,{forceMount:void 0}),cM=t=>{const{__scopeTooltip:e,forceMount:n,children:i,container:r}=t,s=yh(n1,e);return m.jsx(i9,{scope:e,forceMount:n,children:m.jsx(is,{present:n||s.open,children:m.jsx(ph,{asChild:!0,container:r,children:i})})})};cM.displayName=n1;var Su="TooltipContent",uM=w.forwardRef((t,e)=>{const n=r9(Su,t.__scopeTooltip),{forceMount:i=n.forceMount,side:r="top",...s}=t,o=yh(Su,t.__scopeTooltip);return m.jsx(is,{present:i||o.open,children:o.disableHoverableContent?m.jsx(dM,{side:r,...s,ref:e}):m.jsx(s9,{side:r,...s,ref:e})})}),s9=w.forwardRef((t,e)=>{const n=yh(Su,t.__scopeTooltip),i=t1(Su,t.__scopeTooltip),r=w.useRef(null),s=kt(e,r),[o,l]=w.useState(null),{trigger:u,onClose:f}=n,h=r.current,{onPointerInTransitChange:p}=i,O=w.useCallback(()=>{l(null),p(!1)},[p]),y=w.useCallback((v,S)=>{const k=v.currentTarget,C={x:v.clientX,y:v.clientY},$=c9(C,k.getBoundingClientRect()),T=u9(C,$),Q=d9(S.getBoundingClientRect()),A=h9([...T,...Q]);l(A),p(!0)},[p]);return w.useEffect(()=>()=>O(),[O]),w.useEffect(()=>{if(u&&h){const v=k=>y(k,h),S=k=>y(k,u);return u.addEventListener("pointerleave",v),h.addEventListener("pointerleave",S),()=>{u.removeEventListener("pointerleave",v),h.removeEventListener("pointerleave",S)}}},[u,h,y,O]),w.useEffect(()=>{if(o){const v=S=>{const k=S.target,C={x:S.clientX,y:S.clientY},$=u?.contains(k)||h?.contains(k),T=!f9(C,o);$?O():T&&(O(),f())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[u,h,o,f,O]),m.jsx(dM,{...t,ref:s})}),[o9,a9]=PO(jf,{isInside:!1}),l9=GX("TooltipContent"),dM=w.forwardRef((t,e)=>{const{__scopeTooltip:n,children:i,"aria-label":r,onEscapeKeyDown:s,onPointerDownOutside:o,...l}=t,u=yh(Su,n),f=jO(n),{onClose:h}=u;return w.useEffect(()=>(document.addEventListener(jS,h),()=>document.removeEventListener(jS,h)),[h]),w.useEffect(()=>{if(u.trigger){const p=O=>{O.target instanceof Node&&O.target.contains(u.trigger)&&h()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[u.trigger,h]),m.jsx(hh,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:p=>p.preventDefault(),onDismiss:h,children:m.jsxs(Uw,{"data-state":u.stateAttribute,...f,...l,ref:e,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(l9,{children:i}),m.jsx(o9,{scope:n,isInside:!0,children:m.jsx(oV,{id:u.contentId,role:"tooltip",children:r||i})})]})})});uM.displayName=Su;var fM="TooltipArrow",hM=w.forwardRef((t,e)=>{const{__scopeTooltip:n,...i}=t,r=jO(n);return a9(fM,n).isInside?null:m.jsx(qw,{...r,...i,ref:e})});hM.displayName=fM;function c9(t,e){const n=Math.abs(e.top-t.y),i=Math.abs(e.bottom-t.y),r=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,i,r,s)){case s:return"left";case r:return"right";case n:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function u9(t,e,n=5){const i=[];switch(e){case"top":i.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":i.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":i.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":i.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return i}function d9(t){const{top:e,right:n,bottom:i,left:r}=t;return[{x:r,y:e},{x:n,y:e},{x:n,y:i},{x:r,y:i}]}function f9(t,e){const{x:n,y:i}=t;let r=!1;for(let s=0,o=e.length-1;si!=O>i&&n<(p-f)*(i-h)/(O-h)+f&&(r=!r)}return r}function h9(t){const e=t.slice();return e.sort((n,i)=>n.xi.x?1:n.yi.y?1:0),p9(e)}function p9(t){if(t.length<=1)return t.slice();const e=[];for(let i=0;i=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(r.y-o.y)>=(s.y-o.y)*(r.x-o.x))e.pop();else break}e.push(r)}e.pop();const n=[];for(let i=t.length-1;i>=0;i--){const r=t[i];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(r.y-o.y)>=(s.y-o.y)*(r.x-o.x))n.pop();else break}n.push(r)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var g9=oM,m9=aM,O9=lM,y9=cM,v9=uM,b9=hM;function pM(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e{const n=new Array(t.length+e.length);for(let i=0;i({classGroupId:t,validator:e}),mM=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),bm="-",j2=[],w9="arbitrary..",k9=t=>{const e=_9(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return C9(o);const l=o.split(bm),u=l[0]===""&&l.length>1?1:0;return OM(l,u,e)},getConflictingClassGroupIds:(o,l)=>{if(l){const u=i[o],f=n[o];return u?f?S9(f,u):u:f||j2}return n[o]||j2}}},OM=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const r=t[e],s=n.nextPart.get(r);if(s){const f=OM(t,e+1,s);if(f)return f}const o=n.validators;if(o===null)return;const l=e===0?t.join(bm):t.slice(e).join(bm),u=o.length;for(let f=0;ft.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),i=e.slice(0,n);return i?w9+i:void 0})(),_9=t=>{const{theme:e,classGroups:n}=t;return $9(n,e)},$9=(t,e)=>{const n=mM();for(const i in t){const r=t[i];i1(r,n,i,e)}return n},i1=(t,e,n,i)=>{const r=t.length;for(let s=0;s{if(typeof t=="string"){E9(t,e,n);return}if(typeof t=="function"){R9(t,e,n,i);return}Q9(t,e,n,i)},E9=(t,e,n)=>{const i=t===""?e:yM(e,t);i.classGroupId=n},R9=(t,e,n,i)=>{if(A9(t)){i1(t(i),e,n,i);return}e.validators===null&&(e.validators=[]),e.validators.push(x9(n,t))},Q9=(t,e,n,i)=>{const r=Object.entries(t),s=r.length;for(let o=0;o{let n=t;const i=e.split(bm),r=i.length;for(let s=0;s"isThemeGetter"in t&&t.isThemeGetter===!0,P9=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),i=Object.create(null);const r=(s,o)=>{n[s]=o,e++,e>t&&(e=0,i=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=i[s])!==void 0)return r(s,o),o},set(s,o){s in n?n[s]=o:r(s,o)}}},DS="!",M2=":",j9=[],D2=(t,e,n,i,r)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:i,isExternal:r}),M9=t=>{const{prefix:e,experimentalParseClassName:n}=t;let i=r=>{const s=[];let o=0,l=0,u=0,f;const h=r.length;for(let S=0;Su?f-u:void 0;return D2(s,y,O,v)};if(e){const r=e+M2,s=i;i=o=>o.startsWith(r)?s(o.slice(r.length)):D2(j9,!1,o,void 0,!0)}if(n){const r=i;i=s=>n({className:s,parseClassName:r})}return i},D9=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,i)=>{e.set(n,1e6+i)}),n=>{const i=[];let r=[];for(let s=0;s0&&(r.sort(),i.push(...r),r=[]),i.push(o)):r.push(o)}return r.length>0&&(r.sort(),i.push(...r)),i}},N9=t=>({cache:P9(t.cacheSize),parseClassName:M9(t),sortModifiers:D9(t),postfixLookupClassGroupIds:z9(t),...k9(t)}),z9=t=>{const e=Object.create(null),n=t.postfixLookupClassGroups;if(n)for(let i=0;i{const{parseClassName:n,getClassGroupId:i,getConflictingClassGroupIds:r,sortModifiers:s,postfixLookupClassGroupIds:o}=e,l=[],u=t.trim().split(L9);let f="";for(let h=u.length-1;h>=0;h-=1){const p=u[h],{isExternal:O,modifiers:y,hasImportantModifier:v,baseClassName:S,maybePostfixModifierPosition:k}=n(p);if(O){f=p+(f.length>0?" "+f:f);continue}let C=!!k,$;if(C){const P=S.substring(0,k);$=i(P);const X=$&&o[$]?i(S):void 0;X&&X!==$&&($=X,C=!1)}else $=i(S);if(!$){if(!C){f=p+(f.length>0?" "+f:f);continue}if($=i(S),!$){f=p+(f.length>0?" "+f:f);continue}C=!1}const T=y.length===0?"":y.length===1?y[0]:s(y).join(":"),Q=v?T+DS:T,A=Q+$;if(l.indexOf(A)>-1)continue;l.push(A);const R=r($,C);for(let P=0;P0?" "+f:f)}return f},I9=(...t)=>{let e=0,n,i,r="";for(;e{if(typeof t=="string")return t;let e,n="";for(let i=0;i{let n,i,r,s;const o=u=>{const f=e.reduce((h,p)=>p(h),t());return n=N9(f),i=n.cache.get,r=n.cache.set,s=l,l(u)},l=u=>{const f=i(u);if(f)return f;const h=Z9(u,n);return r(u,h),h};return s=o,(...u)=>s(I9(...u))},V9=[],Pn=t=>{const e=n=>n[t]||V9;return e.isThemeGetter=!0,e},bM=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,SM=/^\((?:(\w[\w-]*):)?(.+)\)$/i,B9=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,U9=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,q9=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Y9=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,F9=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,G9=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,aa=t=>B9.test(t),ot=t=>!!t&&!Number.isNaN(Number(t)),hs=t=>!!t&&Number.isInteger(Number(t)),eb=t=>t.endsWith("%")&&ot(t.slice(0,-1)),ho=t=>U9.test(t),xM=()=>!0,H9=t=>q9.test(t)&&!Y9.test(t),r1=()=>!1,W9=t=>F9.test(t),K9=t=>G9.test(t),J9=t=>!Ee(t)&&!Re(t),eq=t=>t.startsWith("@container")&&(t[10]==="/"&&t[11]!==void 0||t[11]==="s"&&t[16]!==void 0&&t.startsWith("-size/",10)||t[11]==="n"&&t[18]!==void 0&&t.startsWith("-normal/",10)),tq=t=>Za(t,CM,r1),Ee=t=>bM.test(t),dl=t=>Za(t,_M,H9),N2=t=>Za(t,cq,ot),nq=t=>Za(t,TM,xM),iq=t=>Za(t,$M,r1),z2=t=>Za(t,wM,r1),rq=t=>Za(t,kM,K9),cg=t=>Za(t,EM,W9),Re=t=>SM.test(t),Fd=t=>Hl(t,_M),sq=t=>Hl(t,$M),L2=t=>Hl(t,wM),oq=t=>Hl(t,CM),aq=t=>Hl(t,kM),ug=t=>Hl(t,EM,!0),lq=t=>Hl(t,TM,!0),Za=(t,e,n)=>{const i=bM.exec(t);return i?i[1]?e(i[1]):n(i[2]):!1},Hl=(t,e,n=!1)=>{const i=SM.exec(t);return i?i[1]?e(i[1]):n:!1},wM=t=>t==="position"||t==="percentage",kM=t=>t==="image"||t==="url",CM=t=>t==="length"||t==="size"||t==="bg-size",_M=t=>t==="length",cq=t=>t==="number",$M=t=>t==="family-name",TM=t=>t==="number"||t==="weight",EM=t=>t==="shadow",uq=()=>{const t=Pn("color"),e=Pn("font"),n=Pn("text"),i=Pn("font-weight"),r=Pn("tracking"),s=Pn("leading"),o=Pn("breakpoint"),l=Pn("container"),u=Pn("spacing"),f=Pn("radius"),h=Pn("shadow"),p=Pn("inset-shadow"),O=Pn("text-shadow"),y=Pn("drop-shadow"),v=Pn("blur"),S=Pn("perspective"),k=Pn("aspect"),C=Pn("ease"),$=Pn("animate"),T=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Q=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...Q(),Re,Ee],R=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto","contain","none"],X=()=>[Re,Ee,u],te=()=>[aa,"full","auto",...X()],G=()=>[hs,"none","subgrid",Re,Ee],Y=()=>["auto",{span:["full",hs,Re,Ee]},hs,Re,Ee],K=()=>[hs,"auto",Re,Ee],se=()=>["auto","min","max","fr",Re,Ee],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],pe=()=>["start","end","center","stretch","center-safe","end-safe"],z=()=>["auto",...X()],W=()=>[aa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...X()],ce=()=>[aa,"screen","full","dvw","lvw","svw","min","max","fit",...X()],oe=()=>[aa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...X()],ae=()=>[t,Re,Ee],D=()=>[...Q(),L2,z2,{position:[Re,Ee]}],j=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",oq,tq,{size:[Re,Ee]}],N=()=>[eb,Fd,dl],V=()=>["","none","full",f,Re,Ee],ne=()=>["",ot,Fd,dl],ie=()=>["solid","dashed","dotted","double"],ye=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],xe=()=>[ot,eb,L2,z2],Le=()=>["","none",v,Re,Ee],Ue=()=>["none",ot,Re,Ee],Ke=()=>["none",ot,Re,Ee],Et=()=>[ot,Re,Ee],ht=()=>[aa,"full",...X()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ho],breakpoint:[ho],color:[xM],container:[ho],"drop-shadow":[ho],ease:["in","out","in-out"],font:[J9],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ho],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ho],shadow:[ho],spacing:["px",ot],text:[ho],"text-shadow":[ho],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",aa,Ee,Re,k]}],container:["container"],"container-type":[{"@container":["","normal","size",Re,Ee]}],"container-named":[eq],columns:[{columns:[ot,Ee,Re,l]}],"break-after":[{"break-after":T()}],"break-before":[{"break-before":T()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:R()}],"overflow-x":[{"overflow-x":R()}],"overflow-y":[{"overflow-y":R()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:te()}],"inset-x":[{"inset-x":te()}],"inset-y":[{"inset-y":te()}],start:[{"inset-s":te(),start:te()}],end:[{"inset-e":te(),end:te()}],"inset-bs":[{"inset-bs":te()}],"inset-be":[{"inset-be":te()}],top:[{top:te()}],right:[{right:te()}],bottom:[{bottom:te()}],left:[{left:te()}],visibility:["visible","invisible","collapse"],z:[{z:[hs,"auto",Re,Ee]}],basis:[{basis:[aa,"full","auto",l,...X()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ot,aa,"auto","initial","none",Ee]}],grow:[{grow:["",ot,Re,Ee]}],shrink:[{shrink:["",ot,Re,Ee]}],order:[{order:[hs,"first","last","none",Re,Ee]}],"grid-cols":[{"grid-cols":G()}],"col-start-end":[{col:Y()}],"col-start":[{"col-start":K()}],"col-end":[{"col-end":K()}],"grid-rows":[{"grid-rows":G()}],"row-start-end":[{row:Y()}],"row-start":[{"row-start":K()}],"row-end":[{"row-end":K()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":se()}],"auto-rows":[{"auto-rows":se()}],gap:[{gap:X()}],"gap-x":[{"gap-x":X()}],"gap-y":[{"gap-y":X()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[...pe(),"normal"]}],"justify-self":[{"justify-self":["auto",...pe()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[...pe(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...pe(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[...pe(),"baseline"]}],"place-self":[{"place-self":["auto",...pe()]}],p:[{p:X()}],px:[{px:X()}],py:[{py:X()}],ps:[{ps:X()}],pe:[{pe:X()}],pbs:[{pbs:X()}],pbe:[{pbe:X()}],pt:[{pt:X()}],pr:[{pr:X()}],pb:[{pb:X()}],pl:[{pl:X()}],m:[{m:z()}],mx:[{mx:z()}],my:[{my:z()}],ms:[{ms:z()}],me:[{me:z()}],mbs:[{mbs:z()}],mbe:[{mbe:z()}],mt:[{mt:z()}],mr:[{mr:z()}],mb:[{mb:z()}],ml:[{ml:z()}],"space-x":[{"space-x":X()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":X()}],"space-y-reverse":["space-y-reverse"],size:[{size:W()}],"inline-size":[{inline:["auto",...ce()]}],"min-inline-size":[{"min-inline":["auto",...ce()]}],"max-inline-size":[{"max-inline":["none",...ce()]}],"block-size":[{block:["auto",...oe()]}],"min-block-size":[{"min-block":["auto",...oe()]}],"max-block-size":[{"max-block":["none",...oe()]}],w:[{w:[l,"screen",...W()]}],"min-w":[{"min-w":[l,"screen","none",...W()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...W()]}],h:[{h:["screen","lh",...W()]}],"min-h":[{"min-h":["screen","lh","none",...W()]}],"max-h":[{"max-h":["screen","lh",...W()]}],"font-size":[{text:["base",n,Fd,dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,lq,nq]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",eb,Ee]}],"font-family":[{font:[sq,iq,e]}],"font-features":[{"font-features":[Ee]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,Re,Ee]}],"line-clamp":[{"line-clamp":[ot,"none",Re,N2]}],leading:[{leading:[s,...X()]}],"list-image":[{"list-image":["none",Re,Ee]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Re,Ee]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:ae()}],"text-color":[{text:ae()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:[ot,"from-font","auto",Re,dl]}],"text-decoration-color":[{decoration:ae()}],"underline-offset":[{"underline-offset":[ot,"auto",Re,Ee]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:X()}],"tab-size":[{tab:[hs,Re,Ee]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Re,Ee]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Re,Ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:j()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},hs,Re,Ee],radial:["",Re,Ee],conic:[hs,Re,Ee]},aq,rq]}],"bg-color":[{bg:ae()}],"gradient-from-pos":[{from:N()}],"gradient-via-pos":[{via:N()}],"gradient-to-pos":[{to:N()}],"gradient-from":[{from:ae()}],"gradient-via":[{via:ae()}],"gradient-to":[{to:ae()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:ne()}],"border-w-x":[{"border-x":ne()}],"border-w-y":[{"border-y":ne()}],"border-w-s":[{"border-s":ne()}],"border-w-e":[{"border-e":ne()}],"border-w-bs":[{"border-bs":ne()}],"border-w-be":[{"border-be":ne()}],"border-w-t":[{"border-t":ne()}],"border-w-r":[{"border-r":ne()}],"border-w-b":[{"border-b":ne()}],"border-w-l":[{"border-l":ne()}],"divide-x":[{"divide-x":ne()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ne()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ie(),"hidden","none"]}],"divide-style":[{divide:[...ie(),"hidden","none"]}],"border-color":[{border:ae()}],"border-color-x":[{"border-x":ae()}],"border-color-y":[{"border-y":ae()}],"border-color-s":[{"border-s":ae()}],"border-color-e":[{"border-e":ae()}],"border-color-bs":[{"border-bs":ae()}],"border-color-be":[{"border-be":ae()}],"border-color-t":[{"border-t":ae()}],"border-color-r":[{"border-r":ae()}],"border-color-b":[{"border-b":ae()}],"border-color-l":[{"border-l":ae()}],"divide-color":[{divide:ae()}],"outline-style":[{outline:[...ie(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ot,Re,Ee]}],"outline-w":[{outline:["",ot,Fd,dl]}],"outline-color":[{outline:ae()}],shadow:[{shadow:["","none",h,ug,cg]}],"shadow-color":[{shadow:ae()}],"inset-shadow":[{"inset-shadow":["none",p,ug,cg]}],"inset-shadow-color":[{"inset-shadow":ae()}],"ring-w":[{ring:ne()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:ae()}],"ring-offset-w":[{"ring-offset":[ot,dl]}],"ring-offset-color":[{"ring-offset":ae()}],"inset-ring-w":[{"inset-ring":ne()}],"inset-ring-color":[{"inset-ring":ae()}],"text-shadow":[{"text-shadow":["none",O,ug,cg]}],"text-shadow-color":[{"text-shadow":ae()}],opacity:[{opacity:[ot,Re,Ee]}],"mix-blend":[{"mix-blend":[...ye(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ye()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[ot]}],"mask-image-linear-from-pos":[{"mask-linear-from":xe()}],"mask-image-linear-to-pos":[{"mask-linear-to":xe()}],"mask-image-linear-from-color":[{"mask-linear-from":ae()}],"mask-image-linear-to-color":[{"mask-linear-to":ae()}],"mask-image-t-from-pos":[{"mask-t-from":xe()}],"mask-image-t-to-pos":[{"mask-t-to":xe()}],"mask-image-t-from-color":[{"mask-t-from":ae()}],"mask-image-t-to-color":[{"mask-t-to":ae()}],"mask-image-r-from-pos":[{"mask-r-from":xe()}],"mask-image-r-to-pos":[{"mask-r-to":xe()}],"mask-image-r-from-color":[{"mask-r-from":ae()}],"mask-image-r-to-color":[{"mask-r-to":ae()}],"mask-image-b-from-pos":[{"mask-b-from":xe()}],"mask-image-b-to-pos":[{"mask-b-to":xe()}],"mask-image-b-from-color":[{"mask-b-from":ae()}],"mask-image-b-to-color":[{"mask-b-to":ae()}],"mask-image-l-from-pos":[{"mask-l-from":xe()}],"mask-image-l-to-pos":[{"mask-l-to":xe()}],"mask-image-l-from-color":[{"mask-l-from":ae()}],"mask-image-l-to-color":[{"mask-l-to":ae()}],"mask-image-x-from-pos":[{"mask-x-from":xe()}],"mask-image-x-to-pos":[{"mask-x-to":xe()}],"mask-image-x-from-color":[{"mask-x-from":ae()}],"mask-image-x-to-color":[{"mask-x-to":ae()}],"mask-image-y-from-pos":[{"mask-y-from":xe()}],"mask-image-y-to-pos":[{"mask-y-to":xe()}],"mask-image-y-from-color":[{"mask-y-from":ae()}],"mask-image-y-to-color":[{"mask-y-to":ae()}],"mask-image-radial":[{"mask-radial":[Re,Ee]}],"mask-image-radial-from-pos":[{"mask-radial-from":xe()}],"mask-image-radial-to-pos":[{"mask-radial-to":xe()}],"mask-image-radial-from-color":[{"mask-radial-from":ae()}],"mask-image-radial-to-color":[{"mask-radial-to":ae()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":Q()}],"mask-image-conic-pos":[{"mask-conic":[ot]}],"mask-image-conic-from-pos":[{"mask-conic-from":xe()}],"mask-image-conic-to-pos":[{"mask-conic-to":xe()}],"mask-image-conic-from-color":[{"mask-conic-from":ae()}],"mask-image-conic-to-color":[{"mask-conic-to":ae()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:j()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Re,Ee]}],filter:[{filter:["","none",Re,Ee]}],blur:[{blur:Le()}],brightness:[{brightness:[ot,Re,Ee]}],contrast:[{contrast:[ot,Re,Ee]}],"drop-shadow":[{"drop-shadow":["","none",y,ug,cg]}],"drop-shadow-color":[{"drop-shadow":ae()}],grayscale:[{grayscale:["",ot,Re,Ee]}],"hue-rotate":[{"hue-rotate":[ot,Re,Ee]}],invert:[{invert:["",ot,Re,Ee]}],saturate:[{saturate:[ot,Re,Ee]}],sepia:[{sepia:["",ot,Re,Ee]}],"backdrop-filter":[{"backdrop-filter":["","none",Re,Ee]}],"backdrop-blur":[{"backdrop-blur":Le()}],"backdrop-brightness":[{"backdrop-brightness":[ot,Re,Ee]}],"backdrop-contrast":[{"backdrop-contrast":[ot,Re,Ee]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ot,Re,Ee]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ot,Re,Ee]}],"backdrop-invert":[{"backdrop-invert":["",ot,Re,Ee]}],"backdrop-opacity":[{"backdrop-opacity":[ot,Re,Ee]}],"backdrop-saturate":[{"backdrop-saturate":[ot,Re,Ee]}],"backdrop-sepia":[{"backdrop-sepia":["",ot,Re,Ee]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":X()}],"border-spacing-x":[{"border-spacing-x":X()}],"border-spacing-y":[{"border-spacing-y":X()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Re,Ee]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ot,"initial",Re,Ee]}],ease:[{ease:["linear","initial",C,Re,Ee]}],delay:[{delay:[ot,Re,Ee]}],animate:[{animate:["none",$,Re,Ee]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[S,Re,Ee]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:Ue()}],"rotate-x":[{"rotate-x":Ue()}],"rotate-y":[{"rotate-y":Ue()}],"rotate-z":[{"rotate-z":Ue()}],scale:[{scale:Ke()}],"scale-x":[{"scale-x":Ke()}],"scale-y":[{"scale-y":Ke()}],"scale-z":[{"scale-z":Ke()}],"scale-3d":["scale-3d"],skew:[{skew:Et()}],"skew-x":[{"skew-x":Et()}],"skew-y":[{"skew-y":Et()}],transform:[{transform:[Re,Ee,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ht()}],"translate-x":[{"translate-x":ht()}],"translate-y":[{"translate-y":ht()}],"translate-z":[{"translate-z":ht()}],"translate-none":["translate-none"],zoom:[{zoom:[hs,Re,Ee]}],accent:[{accent:ae()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:ae()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Re,Ee]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":ae()}],"scrollbar-track-color":[{"scrollbar-track":ae()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":X()}],"scroll-mx":[{"scroll-mx":X()}],"scroll-my":[{"scroll-my":X()}],"scroll-ms":[{"scroll-ms":X()}],"scroll-me":[{"scroll-me":X()}],"scroll-mbs":[{"scroll-mbs":X()}],"scroll-mbe":[{"scroll-mbe":X()}],"scroll-mt":[{"scroll-mt":X()}],"scroll-mr":[{"scroll-mr":X()}],"scroll-mb":[{"scroll-mb":X()}],"scroll-ml":[{"scroll-ml":X()}],"scroll-p":[{"scroll-p":X()}],"scroll-px":[{"scroll-px":X()}],"scroll-py":[{"scroll-py":X()}],"scroll-ps":[{"scroll-ps":X()}],"scroll-pe":[{"scroll-pe":X()}],"scroll-pbs":[{"scroll-pbs":X()}],"scroll-pbe":[{"scroll-pbe":X()}],"scroll-pt":[{"scroll-pt":X()}],"scroll-pr":[{"scroll-pr":X()}],"scroll-pb":[{"scroll-pb":X()}],"scroll-pl":[{"scroll-pl":X()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Re,Ee]}],fill:[{fill:["none",...ae()]}],"stroke-w":[{stroke:[ot,Fd,dl,N2]}],stroke:[{stroke:["none",...ae()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},dq=X9(uq);function yt(...t){return dq(gM(t))}function fq({delayDuration:t=0,...e}){return m.jsx(g9,{"data-slot":"tooltip-provider",delayDuration:t,...e})}function RM({...t}){return m.jsx(m9,{"data-slot":"tooltip",...t})}function QM({...t}){return m.jsx(O9,{"data-slot":"tooltip-trigger",...t})}function AM({className:t,sideOffset:e=0,children:n,...i}){return m.jsx(y9,{children:m.jsxs(v9,{"data-slot":"tooltip-content",sideOffset:e,className:yt("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",t),...i,children:[n,m.jsx(b9,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}const NS=new Set;function hq(t){return NS.add(t),()=>NS.delete(t)}function pq(){for(const t of NS)t()}const PM=/\.(md|markdown)$/i,jM=/\.(png|jpe?g|gif|svg|webp|ico|bmp|avif)$/i,Fc=/\.html?$/i,Bg=/\.pdf$/i,gq=/\.(csv|tsv)$/i,mq=/\.(txt|log|json|ya?ml|toml|csv|go|py|js|ts|jsx|tsx|sh|bash|zsh|rb|rs|c|h|cpp|java|kt|swift|sql|css|xml|ini|conf|env|mod|sum|jsonl)$/i,Oq=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/i.test(navigator.platform||navigator.userAgent||"");function s1(t){if(t<1024)return t+" B";const e=["KB","MB","GB","TB"];let n=-1;do t/=1024,n++;while(t>=1024&&ni.path.toLowerCase()===n||i.path.toLowerCase()===n+".md")||e.find(i=>{const r=i.name.toLowerCase();return r===n||r===n+".md"})}async function zs(t){try{if(navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}return!1}const DM="bdrive.lastProject";function vq(){try{return localStorage.getItem(DM)||""}catch{return""}}function bq(t){try{localStorage.setItem(DM,t)}catch{}}const NM="bdrive.fmPanel",Sq="(min-width: 1400px)";function xq(){try{const t=localStorage.getItem(NM);if(t!==null)return t==="1"}catch{}return window.matchMedia(Sq).matches}function wq(t){try{localStorage.setItem(NM,t?"1":"0")}catch{}}function MO(t){return t.user_name?`${t.user_name} <${t.user}>`:t.user||t.author||"unknown"}const zM=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim();const kq=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Cq=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase());const Z2=t=>{const e=Cq(t);return e.charAt(0).toUpperCase()+e.slice(1)};var tb={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const _q=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},$q=w.createContext({}),Tq=()=>w.useContext($q),Eq=w.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:i,className:r="",children:s,iconNode:o,...l},u)=>{const{size:f=24,strokeWidth:h=2,absoluteStrokeWidth:p=!1,color:O="currentColor",className:y=""}=Tq()??{},v=i??p?Number(n??h)*24/Number(e??f):n??h;return w.createElement("svg",{ref:u,...tb,width:e??f??tb.width,height:e??f??tb.height,stroke:t??O,strokeWidth:v,className:zM("lucide",y,r),...!s&&!_q(l)&&{"aria-hidden":"true"},...l},[...o.map(([S,k])=>w.createElement(S,k)),...Array.isArray(s)?s:[s]])});const De=(t,e)=>{const n=w.forwardRef(({className:i,...r},s)=>w.createElement(Eq,{ref:s,iconNode:e,className:zM(`lucide-${kq(Z2(t))}`,`lucide-${t}`,i),...r}));return n.displayName=Z2(t),n};const Rq=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],Qq=De("beaker",Rq);const Aq=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Pq=De("book-open",Aq);const jq=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],Mq=De("briefcase",jq);const Dq=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],Nq=De("bug",Dq);const zq=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Lq=De("calendar",zq);const Zq=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],LM=De("check",Zq);const Iq=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],o1=De("chevron-down",Iq);const Xq=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Vq=De("chevron-left",Xq);const Bq=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Uq=De("chevron-right",Bq);const qq=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Yq=De("chevron-up",qq);const Fq=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Gq=De("circle-check",Fq);const Hq=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],ZM=De("clock",Hq);const Wq=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Kq=De("code",Wq);const Jq=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],e7=De("compass",Jq);const t7=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],n7=De("copy",t7);const i7=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],r7=De("credit-card",i7);const s7=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],o7=De("database",s7);const a7=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],l7=De("download",a7);const c7=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],u7=De("ellipsis",c7);const d7=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],IM=De("file-text",d7);const f7=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],h7=De("flag",f7);const p7=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],a1=De("folder",p7);const g7=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],m7=De("gauge",g7);const O7=[["path",{d:"m14 13-8.381 8.38a1 1 0 0 1-3.001-3l8.384-8.381",key:"pgg06f"}],["path",{d:"m16 16 6-6",key:"vzrcl6"}],["path",{d:"m21.5 10.5-8-8",key:"a17d9x"}],["path",{d:"m8 8 6-6",key:"18bi4p"}],["path",{d:"m8.5 7.5 8 8",key:"1oyaui"}]],y7=De("gavel",O7);const v7=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],XM=De("globe",v7);const b7=[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]],S7=De("graduation-cap",b7);const x7=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],w7=De("heart",x7);const k7=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],C7=De("history",k7);const _7=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],$7=De("image",_7);const T7=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],E7=De("info",T7);const R7=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Q7=De("layout-dashboard",R7);const A7=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],P7=De("lightbulb",A7);const j7=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],M7=De("link",j7);const D7=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],N7=De("loader-circle",D7);const z7=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],VM=De("lock",z7);const L7=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Z7=De("log-out",L7);const I7=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],X7=De("maximize-2",I7);const V7=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],B7=De("megaphone",V7);const U7=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],q7=De("menu",U7);const Y7=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],F7=De("minimize-2",Y7);const G7=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],H7=De("music",G7);const W7=[["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z",key:"2d38gg"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],K7=De("octagon-x",W7);const J7=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],eY=De("package",J7);const tY=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],nY=De("panel-left",tY);const iY=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],rY=De("pen-line",iY);const sY=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],oY=De("plug",sY);const aY=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],lY=De("plus",aY);const cY=[["path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2",key:"143wyd"}],["path",{d:"M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6",key:"1itne7"}],["rect",{x:"6",y:"14",width:"12",height:"8",rx:"1",key:"1ue0tg"}]],uY=De("printer",cY);const dY=[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]],fY=De("rocket",dY);const hY=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],BM=De("search",hY);const pY=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],gY=De("settings",pY);const mY=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],OY=De("share-2",mY);const yY=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],UM=De("shield",yY);const vY=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],qM=De("square-terminal",vY);const bY=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],SY=De("star",bY);const xY=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],wY=De("trash-2",xY);const kY=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],YM=De("triangle-alert",kY);const CY=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],_Y=De("upload",CY);const $Y=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],FM=De("users",$Y);const TY=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],EY=De("wrench",TY);const RY=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],GM=De("x",RY),HM="bdrive.sbCollapsed";function WM(){window.innerWidth<=l1?QY():AY(!document.body.classList.contains("sb-collapsed"))}function QY(){const t=!document.body.classList.contains("sb-open");document.body.classList.toggle("sb-open"),jl(),t?document.getElementById("sidebar")?.querySelector(PY)?.focus():document.getElementById("menu-btn")?.focus()}function AY(t){document.body.classList.toggle("sb-collapsed",t);try{localStorage.setItem(HM,t?"1":"0")}catch{}jl()}const PY='a[href], button:not(:disabled), select, input, [tabindex]:not([tabindex="-1"])';function Fr(){const t=document.body.classList.contains("sb-open");document.body.classList.remove("sb-open"),jl(),t&&window.innerWidth<=l1&&document.getElementById("menu-btn")?.focus()}function jY(t){const e=t;if(!e||typeof e.tagName!="string")return!1;const n=e.tagName;return n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||e.isContentEditable?!0:!!e.closest?.(".cm-editor")}const l1=900;function jl(){const t=document.getElementById("sidebar");if(!t)return;const e=window.innerWidth<=l1,n=document.body.classList.contains("sb-open"),i=document.body.classList.contains("sb-collapsed"),r=e?!n:i;r?t.setAttribute("inert",""):t.removeAttribute("inert");const s=document.getElementById("main");s&&(n&&e?s.setAttribute("inert",""):s.removeAttribute("inert")),t.setAttribute("aria-modal",String(n&&e)),document.getElementById("menu-btn")?.setAttribute("aria-expanded",String(!r))}if(typeof window<"u"){try{document.body&&localStorage.getItem(HM)==="1"&&document.body.classList.add("sb-collapsed")}catch{}window.addEventListener("resize",jl),window.addEventListener("keydown",t=>{if(t.key==="Escape"&&document.body.classList.contains("sb-open")){Fr();return}if((t.metaKey||t.ctrlKey)&&!t.altKey&&!t.shiftKey&&t.key.toLowerCase()==="b"){if(jY(t.target))return;t.preventDefault(),WM()}})}const MY={alert:YM,card:r7,check:LM,chev:Uq,chevd:o1,chevl:Vq,clock:ZM,copy:n7,doc:IM,dots:u7,download:l7,expand:X7,folder:a1,dashboard:Q7,gear:gY,globe:XM,hist:C7,link:M7,lock:VM,menu:q7,plug:oY,plus:lY,power:Z7,printer:uY,search:BM,share:OY,sidebar:nY,shield:UM,shrink:F7,terminal:qM,trash:wY,upload:_Y,users:FM,x:GM};function st({name:t}){const e=MY[t];return e?m.jsx(e,{className:"ico","aria-hidden":"true"}):null}const zS={folder:a1,"book-open":Pq,"file-text":IM,"pen-line":rY,users:FM,briefcase:Mq,megaphone:B7,rocket:fY,lightbulb:P7,flag:h7,star:SY,heart:w7,code:Kq,"square-terminal":qM,bug:Nq,wrench:EY,database:o7,package:eY,beaker:Qq,gauge:m7,shield:UM,lock:VM,gavel:y7,globe:XM,compass:e7,calendar:Lq,clock:ZM,"graduation-cap":S7,image:$7,music:H7};function iu({name:t,className:e}){const n=t??"",i=Object.hasOwn(zS,n)?zS[n]:a1;return m.jsx(i,{className:e,"aria-hidden":"true"})}function DY({size:t=22}){return m.jsxs("svg",{width:t,height:t,viewBox:"0 0 32 32",fill:"currentColor",role:"img","aria-label":"BearDrive",children:[m.jsx("rect",{x:"4",y:"4",width:"5.6",height:"24"}),m.jsx("rect",{x:"11.2",y:"4",width:"14.4",height:"11.2"}),m.jsx("rect",{x:"11.2",y:"16.8",width:"16.8",height:"11.2"})]})}function Gc(t){const e=["page",t.width??"app",t.className].filter(Boolean).join(" ");return m.jsx("div",{className:e,children:t.children})}function NY(t){t&&jl()}function vl(t){return m.jsxs(m.Fragment,{children:[m.jsx("div",{id:"sb-backdrop",onClick:Fr}),m.jsxs("aside",{id:"sidebar",ref:NY,children:[t.vault,t.projectsNav,t.tree??m.jsx("nav",{id:"tree","aria-label":"Files"}),t.orgBar]}),m.jsxs("main",{id:"main",children:[t.topbar,t.exit,m.jsx("article",{id:"content",ref:t.contentRef,onScroll:t.onContentScroll,children:t.children})]})]})}function DO(t){const{name:e,onHome:n,showSignout:i,search:r,beta:s}=t;return m.jsxs("header",{id:"vault",children:[m.jsx("span",{id:"vault-badge",children:m.jsx(DY,{size:22})}),m.jsx("span",{id:"vault-name",className:n?"vault-link":void 0,onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,onKeyDown:o=>{n&&(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n())},children:e}),s&&m.jsx("span",{id:"vault-beta",children:"Beta"}),m.jsxs("div",{className:"vault-actions",children:[r&&m.jsxs(RM,{delayDuration:150,children:[m.jsx(QM,{asChild:!0,children:m.jsx("button",{id:"search-btn",className:"icon-btn2","aria-label":"Search",onClick:()=>{pq(),Fr()},children:m.jsx(st,{name:"search"})})}),m.jsxs(AM,{className:"tipcard",sideOffset:6,children:["Search ",m.jsx("kbd",{children:"⌘K"})]})]}),i&&m.jsx("a",{id:"signout",href:"/auth/logout",title:"Sign out","aria-label":"Sign out",children:m.jsx(st,{name:"power"})})]})]})}function bl(t){return m.jsxs("header",{id:"topbar",children:[m.jsxs(RM,{delayDuration:150,children:[m.jsx(QM,{asChild:!0,children:m.jsx("button",{id:"menu-btn",className:"icon-btn","aria-label":"Toggle sidebar","aria-controls":"sidebar","aria-expanded":"false",onClick:WM,children:m.jsx(st,{name:"sidebar"})})}),m.jsxs(AM,{className:"tipcard",sideOffset:6,children:["Toggle sidebar ",m.jsx("kbd",{children:Oq?"⌘B":"Ctrl+B"})]})]}),t.nav,m.jsx("span",{id:"crumb",children:t.crumb}),m.jsx("span",{id:"meta",children:t.meta}),t.actions]})}function zY(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}const LY=t=>{switch(t){case"success":return XY;case"info":return BY;case"warning":return VY;case"error":return UY;default:return null}},ZY=Array(12).fill(0),IY=({visible:t,className:e})=>be.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},be.createElement("div",{className:"sonner-spinner"},ZY.map((n,i)=>be.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${i}`})))),XY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},be.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),VY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},be.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),BY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},be.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),UY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},be.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),qY=be.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},be.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),be.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),YY=()=>{const[t,e]=be.useState(document.hidden);return be.useEffect(()=>{const n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t};let LS=1;class FY{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const n=this.subscribers.indexOf(e);this.subscribers.splice(n,1)}),this.publish=e=>{this.subscribers.forEach(n=>n(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var n;const{message:i,...r}=e,s=typeof e?.id=="number"||((n=e.id)==null?void 0:n.length)>0?e.id:LS++,o=this.toasts.find(u=>u.id===s),l=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),o?this.toasts=this.toasts.map(u=>u.id===s?(this.publish({...u,...e,id:s,title:i}),{...u,...e,id:s,dismissible:l,title:i}):u):this.addToast({title:i,...r,dismissible:l,id:s}),s},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:e,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(i=>i({id:n.id,dismiss:!0}))}),e),this.message=(e,n)=>this.create({...n,message:e}),this.error=(e,n)=>this.create({...n,message:e,type:"error"}),this.success=(e,n)=>this.create({...n,type:"success",message:e}),this.info=(e,n)=>this.create({...n,type:"info",message:e}),this.warning=(e,n)=>this.create({...n,type:"warning",message:e}),this.loading=(e,n)=>this.create({...n,type:"loading",message:e}),this.promise=(e,n)=>{if(!n)return;let i;n.loading!==void 0&&(i=this.create({...n,promise:e,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let s=i!==void 0,o;const l=r.then(async f=>{if(o=["resolve",f],be.isValidElement(f))s=!1,this.create({id:i,type:"default",message:f});else if(HY(f)&&!f.ok){s=!1;const p=typeof n.error=="function"?await n.error(`HTTP error! status: ${f.status}`):n.error,O=typeof n.description=="function"?await n.description(`HTTP error! status: ${f.status}`):n.description,v=typeof p=="object"&&!be.isValidElement(p)?p:{message:p};this.create({id:i,type:"error",description:O,...v})}else if(f instanceof Error){s=!1;const p=typeof n.error=="function"?await n.error(f):n.error,O=typeof n.description=="function"?await n.description(f):n.description,v=typeof p=="object"&&!be.isValidElement(p)?p:{message:p};this.create({id:i,type:"error",description:O,...v})}else if(n.success!==void 0){s=!1;const p=typeof n.success=="function"?await n.success(f):n.success,O=typeof n.description=="function"?await n.description(f):n.description,v=typeof p=="object"&&!be.isValidElement(p)?p:{message:p};this.create({id:i,type:"success",description:O,...v})}}).catch(async f=>{if(o=["reject",f],n.error!==void 0){s=!1;const h=typeof n.error=="function"?await n.error(f):n.error,p=typeof n.description=="function"?await n.description(f):n.description,y=typeof h=="object"&&!be.isValidElement(h)?h:{message:h};this.create({id:i,type:"error",description:p,...y})}}).finally(()=>{s&&(this.dismiss(i),i=void 0),n.finally==null||n.finally.call(n)}),u=()=>new Promise((f,h)=>l.then(()=>o[0]==="reject"?h(o[1]):f(o[1])).catch(h));return typeof i!="string"&&typeof i!="number"?{unwrap:u}:Object.assign(i,{unwrap:u})},this.custom=(e,n)=>{const i=n?.id||LS++;return this.create({jsx:e(i),id:i,...n}),i},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Li=new FY,GY=(t,e)=>{const n=e?.id||LS++;return Li.addToast({title:t,...e,id:n}),n},HY=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",WY=GY,KY=()=>Li.toasts,JY=()=>Li.getActiveToasts(),I2=Object.assign(WY,{success:Li.success,info:Li.info,warning:Li.warning,error:Li.error,custom:Li.custom,message:Li.message,promise:Li.promise,dismiss:Li.dismiss,loading:Li.loading},{getHistory:KY,getToasts:JY});zY("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function dg(t){return t.label!==void 0}const eF=3,tF="24px",nF="16px",X2=4e3,iF=356,rF=14,sF=45,oF=200;function ps(...t){return t.filter(Boolean).join(" ")}function aF(t){const[e,n]=t.split("-"),i=[];return e&&i.push(e),n&&i.push(n),i}const lF=t=>{var e,n,i,r,s,o,l,u,f;const{invert:h,toast:p,unstyled:O,interacting:y,setHeights:v,visibleToasts:S,heights:k,index:C,toasts:$,expanded:T,removeToast:Q,defaultRichColors:A,closeButton:R,style:P,cancelButtonStyle:X,actionButtonStyle:te,className:G="",descriptionClassName:Y="",duration:K,position:se,gap:H,expandByDefault:pe,classNames:z,icons:W,closeButtonAriaLabel:ce="Close toast"}=t,[oe,ae]=be.useState(null),[D,j]=be.useState(null),[I,N]=be.useState(!1),[V,ne]=be.useState(!1),[ie,ye]=be.useState(!1),[xe,Le]=be.useState(!1),[Ue,Ke]=be.useState(!1),[Et,ht]=be.useState(0),[ti,Oi]=be.useState(0),At=be.useRef(p.duration||K||X2),pr=be.useRef(null),zn=be.useRef(null),gr=C===0,Ri=C+1<=S,sn=p.type,Yi=p.dismissible!==!1,xn=p.className||"",ni=p.descriptionClassName||"",mr=be.useMemo(()=>k.findIndex(Xe=>Xe.toastId===p.id)||0,[k,p.id]),qs=be.useMemo(()=>{var Xe;return(Xe=p.closeButton)!=null?Xe:R},[p.closeButton,R]),Fi=be.useMemo(()=>p.duration||K||X2,[p.duration,K]),jo=be.useRef(0),ii=be.useRef(0),M=be.useRef(0),U=be.useRef(null),[q,he]=se.split("-"),me=be.useMemo(()=>k.reduce((Xe,Ct,qt)=>qt>=mr?Xe:Xe+Ct.height,0),[k,mr]),Se=YY(),ke=p.invert||h,_e=sn==="loading";ii.current=be.useMemo(()=>mr*H+me,[mr,me]),be.useEffect(()=>{At.current=Fi},[Fi]),be.useEffect(()=>{N(!0)},[]),be.useEffect(()=>{const Xe=zn.current;if(Xe){const Ct=Xe.getBoundingClientRect().height;return Oi(Ct),v(qt=>[{toastId:p.id,height:Ct,position:p.position},...qt]),()=>v(qt=>qt.filter(ln=>ln.toastId!==p.id))}},[v,p.id]),be.useLayoutEffect(()=>{if(!I)return;const Xe=zn.current,Ct=Xe.style.height;Xe.style.height="auto";const qt=Xe.getBoundingClientRect().height;Xe.style.height=Ct,Oi(qt),v(ln=>ln.find(It=>It.toastId===p.id)?ln.map(It=>It.toastId===p.id?{...It,height:qt}:It):[{toastId:p.id,height:qt,position:p.position},...ln])},[I,p.title,p.description,v,p.id,p.jsx,p.action,p.cancel]);const Ae=be.useCallback(()=>{ne(!0),ht(ii.current),v(Xe=>Xe.filter(Ct=>Ct.toastId!==p.id)),setTimeout(()=>{Q(p)},oF)},[p,Q,v,ii]);be.useEffect(()=>{if(p.promise&&sn==="loading"||p.duration===1/0||p.type==="loading")return;let Xe;return T||y||Se?(()=>{if(M.current{p.onAutoClose==null||p.onAutoClose.call(p,p),Ae()},At.current)),()=>clearTimeout(Xe)},[T,y,p,sn,Se,Ae]),be.useEffect(()=>{p.delete&&(Ae(),p.onDismiss==null||p.onDismiss.call(p,p))},[Ae,p.delete]);function ut(){var Xe;if(W?.loading){var Ct;return be.createElement("div",{className:ps(z?.loader,p==null||(Ct=p.classNames)==null?void 0:Ct.loader,"sonner-loader"),"data-visible":sn==="loading"},W.loading)}return be.createElement(IY,{className:ps(z?.loader,p==null||(Xe=p.classNames)==null?void 0:Xe.loader),visible:sn==="loading"})}const Zt=p.icon||W?.[sn]||LY(sn);var on,an;return be.createElement("li",{tabIndex:0,ref:zn,className:ps(G,xn,z?.toast,p==null||(e=p.classNames)==null?void 0:e.toast,z?.default,z?.[sn],p==null||(n=p.classNames)==null?void 0:n[sn]),"data-sonner-toast":"","data-rich-colors":(on=p.richColors)!=null?on:A,"data-styled":!(p.jsx||p.unstyled||O),"data-mounted":I,"data-promise":!!p.promise,"data-swiped":Ue,"data-removed":V,"data-visible":Ri,"data-y-position":q,"data-x-position":he,"data-index":C,"data-front":gr,"data-swiping":ie,"data-dismissible":Yi,"data-type":sn,"data-invert":ke,"data-swipe-out":xe,"data-swipe-direction":D,"data-expanded":!!(T||pe&&I),"data-testid":p.testId,style:{"--index":C,"--toasts-before":C,"--z-index":$.length-C,"--offset":`${V?Et:ii.current}px`,"--initial-height":pe?"auto":`${ti}px`,...P,...p.style},onDragEnd:()=>{ye(!1),ae(null),U.current=null},onPointerDown:Xe=>{Xe.button!==2&&(_e||!Yi||(pr.current=new Date,ht(ii.current),Xe.target.setPointerCapture(Xe.pointerId),Xe.target.tagName!=="BUTTON"&&(ye(!0),U.current={x:Xe.clientX,y:Xe.clientY})))},onPointerUp:()=>{var Xe,Ct,qt;if(xe||!Yi)return;U.current=null;const ln=Number(((Xe=zn.current)==null?void 0:Xe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),yi=Number(((Ct=zn.current)==null?void 0:Ct.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),It=new Date().getTime()-((qt=pr.current)==null?void 0:qt.getTime()),ri=oe==="x"?ln:yi,ls=Math.abs(ri)/It;if(Math.abs(ri)>=sF||ls>.11){ht(ii.current),p.onDismiss==null||p.onDismiss.call(p,p),j(oe==="x"?ln>0?"right":"left":yi>0?"down":"up"),Ae(),Le(!0);return}else{var Ln,si;(Ln=zn.current)==null||Ln.style.setProperty("--swipe-amount-x","0px"),(si=zn.current)==null||si.style.setProperty("--swipe-amount-y","0px")}Ke(!1),ye(!1),ae(null)},onPointerMove:Xe=>{var Ct,qt,ln;if(!U.current||!Yi||((Ct=window.getSelection())==null?void 0:Ct.toString().length)>0)return;const It=Xe.clientY-U.current.y,ri=Xe.clientX-U.current.x;var ls;const Ln=(ls=t.swipeDirections)!=null?ls:aF(se);!oe&&(Math.abs(ri)>1||Math.abs(It)>1)&&ae(Math.abs(ri)>Math.abs(It)?"x":"y");let si={x:0,y:0};const Mo=Qi=>1/(1.5+Math.abs(Qi)/20);if(oe==="y"){if(Ln.includes("top")||Ln.includes("bottom"))if(Ln.includes("top")&&It<0||Ln.includes("bottom")&&It>0)si.y=It;else{const Qi=It*Mo(It);si.y=Math.abs(Qi)0)si.x=ri;else{const Qi=ri*Mo(ri);si.x=Math.abs(Qi)0||Math.abs(si.y)>0)&&Ke(!0),(qt=zn.current)==null||qt.style.setProperty("--swipe-amount-x",`${si.x}px`),(ln=zn.current)==null||ln.style.setProperty("--swipe-amount-y",`${si.y}px`)}},qs&&!p.jsx&&sn!=="loading"?be.createElement("button",{"aria-label":ce,"data-disabled":_e,"data-close-button":!0,onClick:_e||!Yi?()=>{}:()=>{Ae(),p.onDismiss==null||p.onDismiss.call(p,p)},className:ps(z?.closeButton,p==null||(i=p.classNames)==null?void 0:i.closeButton)},(an=W?.close)!=null?an:qY):null,(sn||p.icon||p.promise)&&p.icon!==null&&(W?.[sn]!==null||p.icon)?be.createElement("div",{"data-icon":"",className:ps(z?.icon,p==null||(r=p.classNames)==null?void 0:r.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||ut():null,p.type!=="loading"?Zt:null):null,be.createElement("div",{"data-content":"",className:ps(z?.content,p==null||(s=p.classNames)==null?void 0:s.content)},be.createElement("div",{"data-title":"",className:ps(z?.title,p==null||(o=p.classNames)==null?void 0:o.title)},p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title),p.description?be.createElement("div",{"data-description":"",className:ps(Y,ni,z?.description,p==null||(l=p.classNames)==null?void 0:l.description)},typeof p.description=="function"?p.description():p.description):null),be.isValidElement(p.cancel)?p.cancel:p.cancel&&dg(p.cancel)?be.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||X,onClick:Xe=>{dg(p.cancel)&&Yi&&(p.cancel.onClick==null||p.cancel.onClick.call(p.cancel,Xe),Ae())},className:ps(z?.cancelButton,p==null||(u=p.classNames)==null?void 0:u.cancelButton)},p.cancel.label):null,be.isValidElement(p.action)?p.action:p.action&&dg(p.action)?be.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||te,onClick:Xe=>{dg(p.action)&&(p.action.onClick==null||p.action.onClick.call(p.action,Xe),!Xe.defaultPrevented&&Ae())},className:ps(z?.actionButton,p==null||(f=p.classNames)==null?void 0:f.actionButton)},p.action.label):null)};function V2(){if(typeof window>"u"||typeof document>"u")return"ltr";const t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function cF(t,e){const n={};return[t,e].forEach((i,r)=>{const s=r===1,o=s?"--mobile-offset":"--offset",l=s?nF:tF;function u(f){["top","right","bottom","left"].forEach(h=>{n[`${o}-${h}`]=typeof f=="number"?`${f}px`:f})}typeof i=="number"||typeof i=="string"?u(i):typeof i=="object"?["top","right","bottom","left"].forEach(f=>{i[f]===void 0?n[`${o}-${f}`]=l:n[`${o}-${f}`]=typeof i[f]=="number"?`${i[f]}px`:i[f]}):u(l)}),n}const uF=be.forwardRef(function(e,n){const{id:i,invert:r,position:s="bottom-right",hotkey:o=["altKey","KeyT"],expand:l,closeButton:u,className:f,offset:h,mobileOffset:p,theme:O="light",richColors:y,duration:v,style:S,visibleToasts:k=eF,toastOptions:C,dir:$=V2(),gap:T=rF,icons:Q,containerAriaLabel:A="Notifications"}=e,[R,P]=be.useState([]),X=be.useMemo(()=>i?R.filter(I=>I.toasterId===i):R.filter(I=>!I.toasterId),[R,i]),te=be.useMemo(()=>Array.from(new Set([s].concat(X.filter(I=>I.position).map(I=>I.position)))),[X,s]),[G,Y]=be.useState([]),[K,se]=be.useState(!1),[H,pe]=be.useState(!1),[z,W]=be.useState(O!=="system"?O:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),ce=be.useRef(null),oe=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),ae=be.useRef(null),D=be.useRef(!1),j=be.useCallback(I=>{P(N=>{var V;return(V=N.find(ne=>ne.id===I.id))!=null&&V.delete||Li.dismiss(I.id),N.filter(({id:ne})=>ne!==I.id)})},[]);return be.useEffect(()=>Li.subscribe(I=>{if(I.dismiss){requestAnimationFrame(()=>{P(N=>N.map(V=>V.id===I.id?{...V,delete:!0}:V))});return}setTimeout(()=>{YX.flushSync(()=>{P(N=>{const V=N.findIndex(ne=>ne.id===I.id);return V!==-1?[...N.slice(0,V),{...N[V],...I},...N.slice(V+1)]:[I,...N]})})})}),[R]),be.useEffect(()=>{if(O!=="system"){W(O);return}if(O==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?W("dark"):W("light")),typeof window>"u")return;const I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:N})=>{W(N?"dark":"light")})}catch{I.addListener(({matches:V})=>{try{W(V?"dark":"light")}catch(ne){console.error(ne)}})}},[O]),be.useEffect(()=>{R.length<=1&&se(!1)},[R]),be.useEffect(()=>{const I=N=>{var V;if(o.every(ye=>N[ye]||N.code===ye)){var ie;se(!0),(ie=ce.current)==null||ie.focus()}N.code==="Escape"&&(document.activeElement===ce.current||(V=ce.current)!=null&&V.contains(document.activeElement))&&se(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[o]),be.useEffect(()=>{if(ce.current)return()=>{ae.current&&(ae.current.focus({preventScroll:!0}),ae.current=null,D.current=!1)}},[ce.current]),be.createElement("section",{ref:n,"aria-label":`${A} ${oe}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},te.map((I,N)=>{var V;const[ne,ie]=I.split("-");return X.length?be.createElement("ol",{key:I,dir:$==="auto"?V2():$,tabIndex:-1,ref:ce,className:f,"data-sonner-toaster":!0,"data-sonner-theme":z,"data-y-position":ne,"data-x-position":ie,style:{"--front-toast-height":`${((V=G[0])==null?void 0:V.height)||0}px`,"--width":`${iF}px`,"--gap":`${T}px`,...S,...cF(h,p)},onBlur:ye=>{D.current&&!ye.currentTarget.contains(ye.relatedTarget)&&(D.current=!1,ae.current&&(ae.current.focus({preventScroll:!0}),ae.current=null))},onFocus:ye=>{ye.target instanceof HTMLElement&&ye.target.dataset.dismissible==="false"||D.current||(D.current=!0,ae.current=ye.relatedTarget)},onMouseEnter:()=>se(!0),onMouseMove:()=>se(!0),onMouseLeave:()=>{H||se(!1)},onDragEnd:()=>se(!1),onPointerDown:ye=>{ye.target instanceof HTMLElement&&ye.target.dataset.dismissible==="false"||pe(!0)},onPointerUp:()=>pe(!1)},X.filter(ye=>!ye.position&&N===0||ye.position===I).map((ye,xe)=>{var Le,Ue;return be.createElement(lF,{key:ye.id,icons:Q,index:xe,toast:ye,defaultRichColors:y,duration:(Le=C?.duration)!=null?Le:v,className:C?.className,descriptionClassName:C?.descriptionClassName,invert:r,visibleToasts:k,closeButton:(Ue=C?.closeButton)!=null?Ue:u,interacting:H,position:I,style:C?.style,unstyled:C?.unstyled,classNames:C?.classNames,cancelButtonStyle:C?.cancelButtonStyle,actionButtonStyle:C?.actionButtonStyle,closeButtonAriaLabel:C?.closeButtonAriaLabel,removeToast:j,toasts:X.filter(Ke=>Ke.position==ye.position),heights:G.filter(Ke=>Ke.position==ye.position),setHeights:Y,expandByDefault:l,gap:T,expanded:K,swipeDirections:e.swipeDirections})})):null}))}),dF=({...t})=>m.jsx(uF,{theme:"dark",className:"toaster group",icons:{success:m.jsx(Gq,{className:"size-4"}),info:m.jsx(E7,{className:"size-4"}),warning:m.jsx(YM,{className:"size-4"}),error:m.jsx(K7,{className:"size-4"}),loading:m.jsx(N7,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius-ctl)"},...t});function Ve(t,e=!1){e?I2.error(t,{duration:1/0,closeButton:!0}):I2(t)}function fF(){return m.jsx(dF,{position:"bottom-center"})}const B2=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,U2=gM,hF=(t,e)=>n=>{var i;if(e?.variants==null)return U2(t,n?.class,n?.className);const{variants:r,defaultVariants:s}=e,o=Object.keys(r).map(f=>{const h=n?.[f],p=s?.[f];if(h===null)return null;const O=B2(h)||B2(p);return r[f][O]}),l=n&&Object.entries(n).reduce((f,h)=>{let[p,O]=h;return O===void 0||(f[p]=O),f},{}),u=e==null||(i=e.compoundVariants)===null||i===void 0?void 0:i.reduce((f,h)=>{let{class:p,className:O,...y}=h;return Object.entries(y).every(v=>{let[S,k]=v;return Array.isArray(k)?k.includes({...s,...l}[S]):{...s,...l}[S]===k})?[...f,p,O]:f},[]);return U2(t,o,u,n?.class,n?.className)},pF=hF("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[background-color,border-color,color] disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",primary:"pbtn",danger:"danger-btn",subtle:"ai-btn",toolbar:"btn",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function at({className:t,variant:e="default",size:n="default",asChild:i=!1,...r}){const s=i?FX:"button";return m.jsx(s,{"data-slot":"button","data-variant":e,"data-size":n,className:yt(pF({variant:e,size:n,className:t})),...r})}function NO({...t}){return m.jsx(Tw,{"data-slot":"dialog",...t})}function gF({...t}){return m.jsx(Rw,{"data-slot":"dialog-portal",...t})}function mF({className:t,...e}){return m.jsx(Qw,{"data-slot":"dialog-overlay",className:yt("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",t),...e})}function zO({className:t,children:e,showCloseButton:n=!0,...i}){return m.jsxs(gF,{"data-slot":"dialog-portal",children:[m.jsx(mF,{}),m.jsxs(Aw,{"data-slot":"dialog-content",className:yt("fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",t),...i,children:[e,n&&m.jsxs(SP,{"data-slot":"dialog-close",className:"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[m.jsx(GM,{}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function vh({className:t,...e}){return m.jsx(yP,{"data-slot":"dialog-title",className:yt("text-lg leading-none font-semibold",t),...e})}let KM=null,Ug=[];function bh(t){KM=t,Ug.forEach(e=>e())}function JM(t,e,n="",i="OK",r={}){return new Promise(s=>bh({kind:"prompt",title:t,label:e,value:n,okLabel:i,...r,resolve:s}))}function kl(t,e,n="Confirm",i=!1){return new Promise(r=>bh({kind:"confirm",title:t,message:e,confirmLabel:n,danger:i,resolve:r}))}function OF(){const t=w.useSyncExternalStore(n=>(Ug.push(n),()=>{Ug=Ug.filter(i=>i!==n)}),()=>KM);if(!t)return null;const e=()=>{bh(null),t.kind==="prompt"?t.resolve(null):t.resolve(!1)};return m.jsx(NO,{open:!0,onOpenChange:n=>!n&&e(),children:m.jsx(zO,{className:"modal",showCloseButton:!1,children:t.kind==="prompt"?m.jsx(yF,{m:t}):m.jsx(vF,{m:t})})})}function yF({m:t}){const e=w.useRef(null),n=f=>{bh(null),t.resolve(f)},[i,r]=w.useState(""),[s,o]=w.useState(t.value),l=t.match===void 0||s.trim()===t.match,u=()=>{const f=s;if(l){if(!f.trim()){r("Give it a name."),e.current.focus();return}n(f)}};return m.jsxs(m.Fragment,{children:[m.jsx(vh,{asChild:!0,children:m.jsx("h3",{children:t.title})}),m.jsx("label",{className:"modal-label",htmlFor:"modal-input",children:t.label}),m.jsx("input",{className:"modal-input",type:"text",autoComplete:"off",value:s,ref:e,id:"modal-input",autoFocus:!0,onFocus:f=>f.currentTarget.select(),"aria-invalid":!!i,"aria-describedby":i?"modal-input-err":void 0,onChange:f=>{o(f.currentTarget.value),i&&r("")},onKeyDown:f=>f.key==="Enter"&&u()}),i&&m.jsx("span",{id:"modal-input-err",role:"alert",className:"field-err",children:i}),m.jsxs("div",{className:"modal-actions",children:[m.jsx(at,{variant:"subtle",onClick:()=>n(null),children:"Cancel"}),m.jsx(at,{variant:t.danger?"danger":"primary",onClick:u,disabled:!l,children:t.okLabel})]})]})}function vF({m:t}){const e=n=>{bh(null),t.resolve(n)};return m.jsxs(m.Fragment,{children:[m.jsx(vh,{asChild:!0,children:m.jsx("h3",{children:t.title})}),m.jsx("div",{className:"modal-msg",children:t.message}),m.jsxs("div",{className:"modal-actions",children:[m.jsx(at,{variant:"subtle",onClick:()=>e(!1),autoFocus:t.danger,children:"Cancel"}),m.jsx(at,{variant:t.danger?"danger":"primary",onClick:()=>e(!0),autoFocus:!t.danger,children:t.confirmLabel})]})]})}const eD={queryKey:["projects"],queryFn:()=>Wt("/api/projects")};function bF(t){return nn({...eD,enabled:t,select:e=>e.projects||[]})}function SF(){const t=fr();return()=>t.fetchQuery(eD)}function tD(t){return nn({queryKey:["orgs"],queryFn:()=>Wt("/api/orgs"),enabled:t,select:e=>e.orgs||[]})}function c1(t){return nn({queryKey:["permissions",t],queryFn:()=>Wt(`/api/p/${t}/permissions`),enabled:!!t})}function nD(t){return nn({queryKey:["folders",t],queryFn:()=>Wt(`/api/p/${t}/folders`),enabled:!!t})}function iD(t,e=!0){return nn({queryKey:["shares",t],queryFn:()=>Wt(`/api/p/${t}/shares`),enabled:!!t&&e,select:n=>n.shares||[]})}function rD(t){return nn({queryKey:["admin","pending"],queryFn:()=>Wt("/api/admin/pending"),enabled:t,select:e=>e.pending||[]})}function sD(){const t=fr();return()=>Promise.all([t.invalidateQueries({queryKey:["projects"]}),t.invalidateQueries({queryKey:["orgs"]})]).then(()=>{})}function oD(t){return t.split("/").map(encodeURIComponent).join("/")}function xF(t){try{return decodeURIComponent(t)}catch{return t}}function LO(t){return t.split("/").map(xF).join("/")}const wF=new Set(["dashboard","history","install","settings"]),q2={insights:"dashboard"};function kF(t){return Object.hasOwn(q2,t)?q2[t]:void 0}const u1=["q","user","since","until"];function d1(t){return!!t&&u1.some(e=>!!t[e])}function aD(t){const e=new URLSearchParams;for(const i of u1)t?.[i]&&e.set(i,t[i]);const n=e.toString();return n?"?"+n:""}const CF={dashboard:"Dashboard",history:"History",install:"Install",settings:"Settings"};function lD(t,e){let n="";return t.view?(n=CF[t.view],t.viewTarget&&(n=`${t.viewTarget} · ${n}`)):t.path&&(n=t.path+(t.editing?" · Editing":t.version?" · Version":"")),n?`${n} — ${e}`:e}function cD(t,e){const n=t.indexOf("?"),i=n===-1?null:new URLSearchParams(t.slice(n)),r=i?.get("v")||"",s=i?.get("connect")||"",o=_F(n===-1?t:t.slice(0,n),e);r&&(o.version=r),s&&(o.connect=s),i?.has("full")&&(o.full=!0);const l={};for(const u of u1){const f=i?.get(u);f&&(l[u]=f)}if(d1(l)&&(o.filters=l),o.view==="history"&&!o.viewTarget){const u=(i?.get("path")||i?.get("prefix")||"").replace(/^\/+|\/+$/g,"");u&&(o.viewTarget=LO(u),o.queryTarget=!0)}return o}function Y2(t,e){const n=e.replace(/\/+$/,"");return n!==e&&(t.trailingSlash=!0),t.path=n?LO(n):"",t}function F2(t){return t.path.split("/")[0]!=="edit"||(t.editing=!0,t.path=t.path.slice(5).replace(/\/+$/,"")),t}function _F(t,e){const n=t.replace(/^\/+/,"");if(e!=="hub")return F2(Y2({path:""},n));if(n==="orgs"||n.startsWith("orgs/"))return{org:n.slice(5).replace(/\/+$/,""),path:""};if(n==="billing"||n.startsWith("billing/"))return{billing:!0,path:""};if(n==="connections"||n.startsWith("connections/"))return{connections:!0,path:""};const i=n.indexOf("/");if(i===-1)return{project:n,path:""};const r=Y2({project:n.slice(0,i),path:""},n.slice(i+1)),s=r.path.indexOf("/"),o=s===-1?r.path:r.path.slice(0,s);if(o==="edit")return F2(r);const l=kF(o);return(wF.has(o)||l)&&(r.view=l||o,l&&(r.legacyView=!0),r.viewTarget=s===-1?"":r.path.slice(s+1).replace(/\/+$/,""),r.path=""),r}function Yr(t,e,n,i,r){const s=oD(t),o=s&&r?"edit/"+s:s,l=(n?"?v="+n:"")+(i?(n?"&":"?")+"full=1":"");return e?"/"+e+(o?"/"+o:"")+l:"/"+o+l}function $F(t){const e=t.indexOf("?");if(e===-1)return t;const n=new URLSearchParams(t.slice(e+1));if(!n.has("full"))return t;n.delete("full");const i=n.toString();return t.slice(0,e)+(i?"?"+i:"")}function Zi(t,e,n,i){let r=(e?"/"+e:"")+"/"+t;return n&&(r+="/"+oD(n.replace(/\/+$/,""))),r+(t==="history"?aD(i):"")}function TF(t,e){const n=LO(e).toLowerCase(),i=t.filter(r=>r.name.toLowerCase()===n);return i.length===1?i[0].id:void 0}let f1="POP";const ZS=new Set;function uD(){for(const t of ZS)t()}window.addEventListener("popstate",()=>{f1="POP",uD()});function zt(t,e){const n=location.pathname+location.search;!e?.replace&&n===t||(history[e?.replace?"replaceState":"pushState"](null,"",t),f1=e?.replace?"REPLACE":"PUSH",uD())}function h1(){return w.useSyncExternalStore(t=>(ZS.add(t),()=>{ZS.delete(t)}),()=>location.pathname+location.search)}function EF(){return f1}function Cl(t){return t.startsWith("/")&&!t.startsWith("//")?{href:t,onClick:n=>{n.defaultPrevented||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0||(n.preventDefault(),zt(t),document.body.classList.remove("sb-open"))}}:{href:t,target:"_blank",rel:"noopener noreferrer"}}function hl({to:t}){return w.useEffect(()=>{zt(t,{replace:!0})},[t]),null}function dD(){return{accessor:(t,e)=>typeof t=="function"?{...e,accessorFn:t}:{...e,accessorKey:t},display:t=>t,group:t=>t}}function ma(t,e){return typeof t=="function"?t(e):t}function ur(t,e){return n=>{e.setState(i=>({...i,[t]:ma(n,i[t])}))}}function ZO(t){return t instanceof Function}function RF(t){return Array.isArray(t)&&t.every(e=>typeof e=="number")}function QF(t,e){const n=[],i=r=>{r.forEach(s=>{n.push(s);const o=e(s);o!=null&&o.length&&i(o)})};return i(t),n}function Ye(t,e,n){let i=[],r;return s=>{let o;n.key&&n.debug&&(o=Date.now());const l=t(s);if(!(l.length!==i.length||l.some((h,p)=>i[p]!==h)))return r;i=l;let f;if(n.key&&n.debug&&(f=Date.now()),r=e(...l),n==null||n.onChange==null||n.onChange(r),n.key&&n.debug&&n!=null&&n.debug()){const h=Math.round((Date.now()-o)*100)/100,p=Math.round((Date.now()-f)*100)/100,O=p/16,y=(v,S)=>{for(v=String(v);v.length{var r;return(r=t?.debugAll)!=null?r:t[e]},key:!1,onChange:i}}function AF(t,e,n,i){const r=()=>{var o;return(o=s.getValue())!=null?o:t.options.renderFallbackValue},s={id:`${e.id}_${n.id}`,row:e,column:n,getValue:()=>e.getValue(i),renderValue:r,getContext:Ye(()=>[t,n,e,s],(o,l,u,f)=>({table:o,column:l,row:u,cell:f,getValue:f.getValue,renderValue:f.renderValue}),Fe(t.options,"debugCells"))};return t._features.forEach(o=>{o.createCell==null||o.createCell(s,n,e,t)},{}),s}function PF(t,e,n,i){var r,s;const l={...t._getDefaultColumnDef(),...e},u=l.accessorKey;let f=(r=(s=l.id)!=null?s:u?typeof String.prototype.replaceAll=="function"?u.replaceAll(".","_"):u.replace(/\./g,"_"):void 0)!=null?r:typeof l.header=="string"?l.header:void 0,h;if(l.accessorFn?h=l.accessorFn:u&&(u.includes(".")?h=O=>{let y=O;for(const S of u.split(".")){var v;y=(v=y)==null?void 0:v[S]}return y}:h=O=>O[l.accessorKey]),!f)throw new Error;let p={id:`${String(f)}`,accessorFn:h,parent:i,depth:n,columnDef:l,columns:[],getFlatColumns:Ye(()=>[!0],()=>{var O;return[p,...(O=p.columns)==null?void 0:O.flatMap(y=>y.getFlatColumns())]},Fe(t.options,"debugColumns")),getLeafColumns:Ye(()=>[t._getOrderColumnsFn()],O=>{var y;if((y=p.columns)!=null&&y.length){let v=p.columns.flatMap(S=>S.getLeafColumns());return O(v)}return[p]},Fe(t.options,"debugColumns"))};for(const O of t._features)O.createColumn==null||O.createColumn(p,t);return p}const ai="debugHeaders";function G2(t,e,n){var i;let s={id:(i=n.id)!=null?i:e.id,column:e,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const o=[],l=u=>{u.subHeaders&&u.subHeaders.length&&u.subHeaders.map(l),o.push(u)};return l(s),o},getContext:()=>({table:t,header:s,column:e})};return t._features.forEach(o=>{o.createHeader==null||o.createHeader(s,t)}),s}const jF={createTable:t=>{t.getHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,i,r)=>{var s,o;const l=(s=i?.map(p=>n.find(O=>O.id===p)).filter(Boolean))!=null?s:[],u=(o=r?.map(p=>n.find(O=>O.id===p)).filter(Boolean))!=null?o:[],f=n.filter(p=>!(i!=null&&i.includes(p.id))&&!(r!=null&&r.includes(p.id)));return fg(e,[...l,...f,...u],t)},Fe(t.options,ai)),t.getCenterHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,i,r)=>(n=n.filter(s=>!(i!=null&&i.includes(s.id))&&!(r!=null&&r.includes(s.id))),fg(e,n,t,"center")),Fe(t.options,ai)),t.getLeftHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left],(e,n,i)=>{var r;const s=(r=i?.map(o=>n.find(l=>l.id===o)).filter(Boolean))!=null?r:[];return fg(e,s,t,"left")},Fe(t.options,ai)),t.getRightHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.right],(e,n,i)=>{var r;const s=(r=i?.map(o=>n.find(l=>l.id===o)).filter(Boolean))!=null?r:[];return fg(e,s,t,"right")},Fe(t.options,ai)),t.getFooterGroups=Ye(()=>[t.getHeaderGroups()],e=>[...e].reverse(),Fe(t.options,ai)),t.getLeftFooterGroups=Ye(()=>[t.getLeftHeaderGroups()],e=>[...e].reverse(),Fe(t.options,ai)),t.getCenterFooterGroups=Ye(()=>[t.getCenterHeaderGroups()],e=>[...e].reverse(),Fe(t.options,ai)),t.getRightFooterGroups=Ye(()=>[t.getRightHeaderGroups()],e=>[...e].reverse(),Fe(t.options,ai)),t.getFlatHeaders=Ye(()=>[t.getHeaderGroups()],e=>e.map(n=>n.headers).flat(),Fe(t.options,ai)),t.getLeftFlatHeaders=Ye(()=>[t.getLeftHeaderGroups()],e=>e.map(n=>n.headers).flat(),Fe(t.options,ai)),t.getCenterFlatHeaders=Ye(()=>[t.getCenterHeaderGroups()],e=>e.map(n=>n.headers).flat(),Fe(t.options,ai)),t.getRightFlatHeaders=Ye(()=>[t.getRightHeaderGroups()],e=>e.map(n=>n.headers).flat(),Fe(t.options,ai)),t.getCenterLeafHeaders=Ye(()=>[t.getCenterFlatHeaders()],e=>e.filter(n=>{var i;return!((i=n.subHeaders)!=null&&i.length)}),Fe(t.options,ai)),t.getLeftLeafHeaders=Ye(()=>[t.getLeftFlatHeaders()],e=>e.filter(n=>{var i;return!((i=n.subHeaders)!=null&&i.length)}),Fe(t.options,ai)),t.getRightLeafHeaders=Ye(()=>[t.getRightFlatHeaders()],e=>e.filter(n=>{var i;return!((i=n.subHeaders)!=null&&i.length)}),Fe(t.options,ai)),t.getLeafHeaders=Ye(()=>[t.getLeftHeaderGroups(),t.getCenterHeaderGroups(),t.getRightHeaderGroups()],(e,n,i)=>{var r,s,o,l,u,f;return[...(r=(s=e[0])==null?void 0:s.headers)!=null?r:[],...(o=(l=n[0])==null?void 0:l.headers)!=null?o:[],...(u=(f=i[0])==null?void 0:f.headers)!=null?u:[]].map(h=>h.getLeafHeaders()).flat()},Fe(t.options,ai))}};function fg(t,e,n,i){var r,s;let o=0;const l=function(O,y){y===void 0&&(y=1),o=Math.max(o,y),O.filter(v=>v.getIsVisible()).forEach(v=>{var S;(S=v.columns)!=null&&S.length&&l(v.columns,y+1)},0)};l(t);let u=[];const f=(O,y)=>{const v={depth:y,id:[i,`${y}`].filter(Boolean).join("_"),headers:[]},S=[];O.forEach(k=>{const C=[...S].reverse()[0],$=k.column.depth===v.depth;let T,Q=!1;if($&&k.column.parent?T=k.column.parent:(T=k.column,Q=!0),C&&C?.column===T)C.subHeaders.push(k);else{const A=G2(n,T,{id:[i,y,T.id,k?.id].filter(Boolean).join("_"),isPlaceholder:Q,placeholderId:Q?`${S.filter(R=>R.column===T).length}`:void 0,depth:y,index:S.length});A.subHeaders.push(k),S.push(A)}v.headers.push(k),k.headerGroup=v}),u.push(v),y>0&&f(S,y-1)},h=e.map((O,y)=>G2(n,O,{depth:o,index:y}));f(h,o-1),u.reverse();const p=O=>O.filter(v=>v.column.getIsVisible()).map(v=>{let S=0,k=0,C=[0];v.subHeaders&&v.subHeaders.length?(C=[],p(v.subHeaders).forEach(T=>{let{colSpan:Q,rowSpan:A}=T;S+=Q,C.push(A)})):S=1;const $=Math.min(...C);return k=k+$,v.colSpan=S,v.rowSpan=k,{colSpan:S,rowSpan:k}});return p((r=(s=u[0])==null?void 0:s.headers)!=null?r:[]),u}const MF=(t,e,n,i,r,s,o)=>{let l={id:e,index:i,original:n,depth:r,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:u=>{if(l._valuesCache.hasOwnProperty(u))return l._valuesCache[u];const f=t.getColumn(u);if(f!=null&&f.accessorFn)return l._valuesCache[u]=f.accessorFn(l.original,i),l._valuesCache[u]},getUniqueValues:u=>{if(l._uniqueValuesCache.hasOwnProperty(u))return l._uniqueValuesCache[u];const f=t.getColumn(u);if(f!=null&&f.accessorFn)return f.columnDef.getUniqueValues?(l._uniqueValuesCache[u]=f.columnDef.getUniqueValues(l.original,i),l._uniqueValuesCache[u]):(l._uniqueValuesCache[u]=[l.getValue(u)],l._uniqueValuesCache[u])},renderValue:u=>{var f;return(f=l.getValue(u))!=null?f:t.options.renderFallbackValue},subRows:[],getLeafRows:()=>QF(l.subRows,u=>u.subRows),getParentRow:()=>l.parentId?t.getRow(l.parentId,!0):void 0,getParentRows:()=>{let u=[],f=l;for(;;){const h=f.getParentRow();if(!h)break;u.push(h),f=h}return u.reverse()},getAllCells:Ye(()=>[t.getAllLeafColumns()],u=>u.map(f=>AF(t,l,f,f.id)),Fe(t.options,"debugRows")),_getAllCellsByColumnId:Ye(()=>[l.getAllCells()],u=>u.reduce((f,h)=>(f[h.column.id]=h,f),{}),Fe(t.options,"debugRows"))};for(let u=0;u{t._getFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,t.id),t.getFacetedRowModel=()=>t._getFacetedRowModel?t._getFacetedRowModel():e.getPreFilteredRowModel(),t._getFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,t.id),t.getFacetedUniqueValues=()=>t._getFacetedUniqueValues?t._getFacetedUniqueValues():new Map,t._getFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,t.id),t.getFacetedMinMaxValues=()=>{if(t._getFacetedMinMaxValues)return t._getFacetedMinMaxValues()}}},fD=(t,e,n)=>{var i,r;const s=n==null||(i=n.toString())==null?void 0:i.toLowerCase();return!!(!((r=t.getValue(e))==null||(r=r.toString())==null||(r=r.toLowerCase())==null)&&r.includes(s))};fD.autoRemove=t=>Jr(t);const hD=(t,e,n)=>{var i;return!!(!((i=t.getValue(e))==null||(i=i.toString())==null)&&i.includes(n))};hD.autoRemove=t=>Jr(t);const pD=(t,e,n)=>{var i;return((i=t.getValue(e))==null||(i=i.toString())==null?void 0:i.toLowerCase())===n?.toLowerCase()};pD.autoRemove=t=>Jr(t);const gD=(t,e,n)=>{var i;return(i=t.getValue(e))==null?void 0:i.includes(n)};gD.autoRemove=t=>Jr(t);const mD=(t,e,n)=>!n.some(i=>{var r;return!((r=t.getValue(e))!=null&&r.includes(i))});mD.autoRemove=t=>Jr(t)||!(t!=null&&t.length);const OD=(t,e,n)=>n.some(i=>{var r;return(r=t.getValue(e))==null?void 0:r.includes(i)});OD.autoRemove=t=>Jr(t)||!(t!=null&&t.length);const yD=(t,e,n)=>t.getValue(e)===n;yD.autoRemove=t=>Jr(t);const vD=(t,e,n)=>t.getValue(e)==n;vD.autoRemove=t=>Jr(t);const p1=(t,e,n)=>{let[i,r]=n;const s=t.getValue(e);return s>=i&&s<=r};p1.resolveFilterValue=t=>{let[e,n]=t,i=typeof e!="number"?parseFloat(e):e,r=typeof n!="number"?parseFloat(n):n,s=e===null||Number.isNaN(i)?-1/0:i,o=n===null||Number.isNaN(r)?1/0:r;if(s>o){const l=s;s=o,o=l}return[s,o]};p1.autoRemove=t=>Jr(t)||Jr(t[0])&&Jr(t[1]);const go={includesString:fD,includesStringSensitive:hD,equalsString:pD,arrIncludes:gD,arrIncludesAll:mD,arrIncludesSome:OD,equals:yD,weakEquals:vD,inNumberRange:p1};function Jr(t){return t==null||t===""}const NF={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:t=>({columnFilters:[],...t}),getDefaultOptions:t=>({onColumnFiltersChange:ur("columnFilters",t),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(t,e)=>{t.getAutoFilterFn=()=>{const n=e.getCoreRowModel().flatRows[0],i=n?.getValue(t.id);return typeof i=="string"?go.includesString:typeof i=="number"?go.inNumberRange:typeof i=="boolean"||i!==null&&typeof i=="object"?go.equals:Array.isArray(i)?go.arrIncludes:go.weakEquals},t.getFilterFn=()=>{var n,i;return ZO(t.columnDef.filterFn)?t.columnDef.filterFn:t.columnDef.filterFn==="auto"?t.getAutoFilterFn():(n=(i=e.options.filterFns)==null?void 0:i[t.columnDef.filterFn])!=null?n:go[t.columnDef.filterFn]},t.getCanFilter=()=>{var n,i,r;return((n=t.columnDef.enableColumnFilter)!=null?n:!0)&&((i=e.options.enableColumnFilters)!=null?i:!0)&&((r=e.options.enableFilters)!=null?r:!0)&&!!t.accessorFn},t.getIsFiltered=()=>t.getFilterIndex()>-1,t.getFilterValue=()=>{var n;return(n=e.getState().columnFilters)==null||(n=n.find(i=>i.id===t.id))==null?void 0:n.value},t.getFilterIndex=()=>{var n,i;return(n=(i=e.getState().columnFilters)==null?void 0:i.findIndex(r=>r.id===t.id))!=null?n:-1},t.setFilterValue=n=>{e.setColumnFilters(i=>{const r=t.getFilterFn(),s=i?.find(h=>h.id===t.id),o=ma(n,s?s.value:void 0);if(H2(r,o,t)){var l;return(l=i?.filter(h=>h.id!==t.id))!=null?l:[]}const u={id:t.id,value:o};if(s){var f;return(f=i?.map(h=>h.id===t.id?u:h))!=null?f:[]}return i!=null&&i.length?[...i,u]:[u]})}},createRow:(t,e)=>{t.columnFilters={},t.columnFiltersMeta={}},createTable:t=>{t.setColumnFilters=e=>{const n=t.getAllLeafColumns(),i=r=>{var s;return(s=ma(e,r))==null?void 0:s.filter(o=>{const l=n.find(u=>u.id===o.id);if(l){const u=l.getFilterFn();if(H2(u,o.value,l))return!1}return!0})};t.options.onColumnFiltersChange==null||t.options.onColumnFiltersChange(i)},t.resetColumnFilters=e=>{var n,i;t.setColumnFilters(e?[]:(n=(i=t.initialState)==null?void 0:i.columnFilters)!=null?n:[])},t.getPreFilteredRowModel=()=>t.getCoreRowModel(),t.getFilteredRowModel=()=>(!t._getFilteredRowModel&&t.options.getFilteredRowModel&&(t._getFilteredRowModel=t.options.getFilteredRowModel(t)),t.options.manualFiltering||!t._getFilteredRowModel?t.getPreFilteredRowModel():t._getFilteredRowModel())}};function H2(t,e,n){return(t&&t.autoRemove?t.autoRemove(e,n):!1)||typeof e>"u"||typeof e=="string"&&!e}const zF=(t,e,n)=>n.reduce((i,r)=>{const s=r.getValue(t);return i+(typeof s=="number"?s:0)},0),LF=(t,e,n)=>{let i;return n.forEach(r=>{const s=r.getValue(t);s!=null&&(i>s||i===void 0&&s>=s)&&(i=s)}),i},ZF=(t,e,n)=>{let i;return n.forEach(r=>{const s=r.getValue(t);s!=null&&(i=s)&&(i=s)}),i},IF=(t,e,n)=>{let i,r;return n.forEach(s=>{const o=s.getValue(t);o!=null&&(i===void 0?o>=o&&(i=r=o):(i>o&&(i=o),r{let n=0,i=0;if(e.forEach(r=>{let s=r.getValue(t);s!=null&&(s=+s)>=s&&(++n,i+=s)}),n)return i/n},VF=(t,e)=>{if(!e.length)return;const n=e.map(s=>s.getValue(t));if(!RF(n))return;if(n.length===1)return n[0];const i=Math.floor(n.length/2),r=n.sort((s,o)=>s-o);return n.length%2!==0?r[i]:(r[i-1]+r[i])/2},BF=(t,e)=>Array.from(new Set(e.map(n=>n.getValue(t))).values()),UF=(t,e)=>new Set(e.map(n=>n.getValue(t))).size,qF=(t,e)=>e.length,nb={sum:zF,min:LF,max:ZF,extent:IF,mean:XF,median:VF,unique:BF,uniqueCount:UF,count:qF},YF={getDefaultColumnDef:()=>({aggregatedCell:t=>{var e,n;return(e=(n=t.getValue())==null||n.toString==null?void 0:n.toString())!=null?e:null},aggregationFn:"auto"}),getInitialState:t=>({grouping:[],...t}),getDefaultOptions:t=>({onGroupingChange:ur("grouping",t),groupedColumnMode:"reorder"}),createColumn:(t,e)=>{t.toggleGrouping=()=>{e.setGrouping(n=>n!=null&&n.includes(t.id)?n.filter(i=>i!==t.id):[...n??[],t.id])},t.getCanGroup=()=>{var n,i;return((n=t.columnDef.enableGrouping)!=null?n:!0)&&((i=e.options.enableGrouping)!=null?i:!0)&&(!!t.accessorFn||!!t.columnDef.getGroupingValue)},t.getIsGrouped=()=>{var n;return(n=e.getState().grouping)==null?void 0:n.includes(t.id)},t.getGroupedIndex=()=>{var n;return(n=e.getState().grouping)==null?void 0:n.indexOf(t.id)},t.getToggleGroupingHandler=()=>{const n=t.getCanGroup();return()=>{n&&t.toggleGrouping()}},t.getAutoAggregationFn=()=>{const n=e.getCoreRowModel().flatRows[0],i=n?.getValue(t.id);if(typeof i=="number")return nb.sum;if(Object.prototype.toString.call(i)==="[object Date]")return nb.extent},t.getAggregationFn=()=>{var n,i;if(!t)throw new Error;return ZO(t.columnDef.aggregationFn)?t.columnDef.aggregationFn:t.columnDef.aggregationFn==="auto"?t.getAutoAggregationFn():(n=(i=e.options.aggregationFns)==null?void 0:i[t.columnDef.aggregationFn])!=null?n:nb[t.columnDef.aggregationFn]}},createTable:t=>{t.setGrouping=e=>t.options.onGroupingChange==null?void 0:t.options.onGroupingChange(e),t.resetGrouping=e=>{var n,i;t.setGrouping(e?[]:(n=(i=t.initialState)==null?void 0:i.grouping)!=null?n:[])},t.getPreGroupedRowModel=()=>t.getFilteredRowModel(),t.getGroupedRowModel=()=>(!t._getGroupedRowModel&&t.options.getGroupedRowModel&&(t._getGroupedRowModel=t.options.getGroupedRowModel(t)),t.options.manualGrouping||!t._getGroupedRowModel?t.getPreGroupedRowModel():t._getGroupedRowModel())},createRow:(t,e)=>{t.getIsGrouped=()=>!!t.groupingColumnId,t.getGroupingValue=n=>{if(t._groupingValuesCache.hasOwnProperty(n))return t._groupingValuesCache[n];const i=e.getColumn(n);return i!=null&&i.columnDef.getGroupingValue?(t._groupingValuesCache[n]=i.columnDef.getGroupingValue(t.original),t._groupingValuesCache[n]):t.getValue(n)},t._groupingValuesCache={}},createCell:(t,e,n,i)=>{t.getIsGrouped=()=>e.getIsGrouped()&&e.id===n.groupingColumnId,t.getIsPlaceholder=()=>!t.getIsGrouped()&&e.getIsGrouped(),t.getIsAggregated=()=>{var r;return!t.getIsGrouped()&&!t.getIsPlaceholder()&&!!((r=n.subRows)!=null&&r.length)}}};function FF(t,e,n){if(!(e!=null&&e.length)||!n)return t;const i=t.filter(s=>!e.includes(s.id));return n==="remove"?i:[...e.map(s=>t.find(o=>o.id===s)).filter(Boolean),...i]}const GF={getInitialState:t=>({columnOrder:[],...t}),getDefaultOptions:t=>({onColumnOrderChange:ur("columnOrder",t)}),createColumn:(t,e)=>{t.getIndex=Ye(n=>[Of(e,n)],n=>n.findIndex(i=>i.id===t.id),Fe(e.options,"debugColumns")),t.getIsFirstColumn=n=>{var i;return((i=Of(e,n)[0])==null?void 0:i.id)===t.id},t.getIsLastColumn=n=>{var i;const r=Of(e,n);return((i=r[r.length-1])==null?void 0:i.id)===t.id}},createTable:t=>{t.setColumnOrder=e=>t.options.onColumnOrderChange==null?void 0:t.options.onColumnOrderChange(e),t.resetColumnOrder=e=>{var n;t.setColumnOrder(e?[]:(n=t.initialState.columnOrder)!=null?n:[])},t._getOrderColumnsFn=Ye(()=>[t.getState().columnOrder,t.getState().grouping,t.options.groupedColumnMode],(e,n,i)=>r=>{let s=[];if(!(e!=null&&e.length))s=r;else{const o=[...e],l=[...r];for(;l.length&&o.length;){const u=o.shift(),f=l.findIndex(h=>h.id===u);f>-1&&s.push(l.splice(f,1)[0])}s=[...s,...l]}return FF(s,n,i)},Fe(t.options,"debugTable"))}},ib=()=>({left:[],right:[]}),HF={getInitialState:t=>({columnPinning:ib(),...t}),getDefaultOptions:t=>({onColumnPinningChange:ur("columnPinning",t)}),createColumn:(t,e)=>{t.pin=n=>{const i=t.getLeafColumns().map(r=>r.id).filter(Boolean);e.setColumnPinning(r=>{var s,o;if(n==="right"){var l,u;return{left:((l=r?.left)!=null?l:[]).filter(p=>!(i!=null&&i.includes(p))),right:[...((u=r?.right)!=null?u:[]).filter(p=>!(i!=null&&i.includes(p))),...i]}}if(n==="left"){var f,h;return{left:[...((f=r?.left)!=null?f:[]).filter(p=>!(i!=null&&i.includes(p))),...i],right:((h=r?.right)!=null?h:[]).filter(p=>!(i!=null&&i.includes(p)))}}return{left:((s=r?.left)!=null?s:[]).filter(p=>!(i!=null&&i.includes(p))),right:((o=r?.right)!=null?o:[]).filter(p=>!(i!=null&&i.includes(p)))}})},t.getCanPin=()=>t.getLeafColumns().some(i=>{var r,s,o;return((r=i.columnDef.enablePinning)!=null?r:!0)&&((s=(o=e.options.enableColumnPinning)!=null?o:e.options.enablePinning)!=null?s:!0)}),t.getIsPinned=()=>{const n=t.getLeafColumns().map(l=>l.id),{left:i,right:r}=e.getState().columnPinning,s=n.some(l=>i?.includes(l)),o=n.some(l=>r?.includes(l));return s?"left":o?"right":!1},t.getPinnedIndex=()=>{var n,i;const r=t.getIsPinned();return r?(n=(i=e.getState().columnPinning)==null||(i=i[r])==null?void 0:i.indexOf(t.id))!=null?n:-1:0}},createRow:(t,e)=>{t.getCenterVisibleCells=Ye(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,i,r)=>{const s=[...i??[],...r??[]];return n.filter(o=>!s.includes(o.column.id))},Fe(e.options,"debugRows")),t.getLeftVisibleCells=Ye(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left],(n,i)=>(i??[]).map(s=>n.find(o=>o.column.id===s)).filter(Boolean).map(s=>({...s,position:"left"})),Fe(e.options,"debugRows")),t.getRightVisibleCells=Ye(()=>[t._getAllVisibleCells(),e.getState().columnPinning.right],(n,i)=>(i??[]).map(s=>n.find(o=>o.column.id===s)).filter(Boolean).map(s=>({...s,position:"right"})),Fe(e.options,"debugRows"))},createTable:t=>{t.setColumnPinning=e=>t.options.onColumnPinningChange==null?void 0:t.options.onColumnPinningChange(e),t.resetColumnPinning=e=>{var n,i;return t.setColumnPinning(e?ib():(n=(i=t.initialState)==null?void 0:i.columnPinning)!=null?n:ib())},t.getIsSomeColumnsPinned=e=>{var n;const i=t.getState().columnPinning;if(!e){var r,s;return!!((r=i.left)!=null&&r.length||(s=i.right)!=null&&s.length)}return!!((n=i[e])!=null&&n.length)},t.getLeftLeafColumns=Ye(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left],(e,n)=>(n??[]).map(i=>e.find(r=>r.id===i)).filter(Boolean),Fe(t.options,"debugColumns")),t.getRightLeafColumns=Ye(()=>[t.getAllLeafColumns(),t.getState().columnPinning.right],(e,n)=>(n??[]).map(i=>e.find(r=>r.id===i)).filter(Boolean),Fe(t.options,"debugColumns")),t.getCenterLeafColumns=Ye(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,i)=>{const r=[...n??[],...i??[]];return e.filter(s=>!r.includes(s.id))},Fe(t.options,"debugColumns"))}};function WF(t){return t||(typeof document<"u"?document:null)}const hg={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},rb=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),KF={getDefaultColumnDef:()=>hg,getInitialState:t=>({columnSizing:{},columnSizingInfo:rb(),...t}),getDefaultOptions:t=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:ur("columnSizing",t),onColumnSizingInfoChange:ur("columnSizingInfo",t)}),createColumn:(t,e)=>{t.getSize=()=>{var n,i,r;const s=e.getState().columnSizing[t.id];return Math.min(Math.max((n=t.columnDef.minSize)!=null?n:hg.minSize,(i=s??t.columnDef.size)!=null?i:hg.size),(r=t.columnDef.maxSize)!=null?r:hg.maxSize)},t.getStart=Ye(n=>[n,Of(e,n),e.getState().columnSizing],(n,i)=>i.slice(0,t.getIndex(n)).reduce((r,s)=>r+s.getSize(),0),Fe(e.options,"debugColumns")),t.getAfter=Ye(n=>[n,Of(e,n),e.getState().columnSizing],(n,i)=>i.slice(t.getIndex(n)+1).reduce((r,s)=>r+s.getSize(),0),Fe(e.options,"debugColumns")),t.resetSize=()=>{e.setColumnSizing(n=>{let{[t.id]:i,...r}=n;return r})},t.getCanResize=()=>{var n,i;return((n=t.columnDef.enableResizing)!=null?n:!0)&&((i=e.options.enableColumnResizing)!=null?i:!0)},t.getIsResizing=()=>e.getState().columnSizingInfo.isResizingColumn===t.id},createHeader:(t,e)=>{t.getSize=()=>{let n=0;const i=r=>{if(r.subHeaders.length)r.subHeaders.forEach(i);else{var s;n+=(s=r.column.getSize())!=null?s:0}};return i(t),n},t.getStart=()=>{if(t.index>0){const n=t.headerGroup.headers[t.index-1];return n.getStart()+n.getSize()}return 0},t.getResizeHandler=n=>{const i=e.getColumn(t.column.id),r=i?.getCanResize();return s=>{if(!i||!r||(s.persist==null||s.persist(),sb(s)&&s.touches&&s.touches.length>1))return;const o=t.getSize(),l=t?t.getLeafHeaders().map(C=>[C.column.id,C.column.getSize()]):[[i.id,i.getSize()]],u=sb(s)?Math.round(s.touches[0].clientX):s.clientX,f={},h=(C,$)=>{typeof $=="number"&&(e.setColumnSizingInfo(T=>{var Q,A;const R=e.options.columnResizeDirection==="rtl"?-1:1,P=($-((Q=T?.startOffset)!=null?Q:0))*R,X=Math.max(P/((A=T?.startSize)!=null?A:0),-.999999);return T.columnSizingStart.forEach(te=>{let[G,Y]=te;f[G]=Math.round(Math.max(Y+Y*X,0)*100)/100}),{...T,deltaOffset:P,deltaPercentage:X}}),(e.options.columnResizeMode==="onChange"||C==="end")&&e.setColumnSizing(T=>({...T,...f})))},p=C=>h("move",C),O=C=>{h("end",C),e.setColumnSizingInfo($=>({...$,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},y=WF(n),v={moveHandler:C=>p(C.clientX),upHandler:C=>{y?.removeEventListener("mousemove",v.moveHandler),y?.removeEventListener("mouseup",v.upHandler),O(C.clientX)}},S={moveHandler:C=>(C.cancelable&&(C.preventDefault(),C.stopPropagation()),p(C.touches[0].clientX),!1),upHandler:C=>{var $;y?.removeEventListener("touchmove",S.moveHandler),y?.removeEventListener("touchend",S.upHandler),C.cancelable&&(C.preventDefault(),C.stopPropagation()),O(($=C.touches[0])==null?void 0:$.clientX)}},k=JF()?{passive:!1}:!1;sb(s)?(y?.addEventListener("touchmove",S.moveHandler,k),y?.addEventListener("touchend",S.upHandler,k)):(y?.addEventListener("mousemove",v.moveHandler,k),y?.addEventListener("mouseup",v.upHandler,k)),e.setColumnSizingInfo(C=>({...C,startOffset:u,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:i.id}))}}},createTable:t=>{t.setColumnSizing=e=>t.options.onColumnSizingChange==null?void 0:t.options.onColumnSizingChange(e),t.setColumnSizingInfo=e=>t.options.onColumnSizingInfoChange==null?void 0:t.options.onColumnSizingInfoChange(e),t.resetColumnSizing=e=>{var n;t.setColumnSizing(e?{}:(n=t.initialState.columnSizing)!=null?n:{})},t.resetHeaderSizeInfo=e=>{var n;t.setColumnSizingInfo(e?rb():(n=t.initialState.columnSizingInfo)!=null?n:rb())},t.getTotalSize=()=>{var e,n;return(e=(n=t.getHeaderGroups()[0])==null?void 0:n.headers.reduce((i,r)=>i+r.getSize(),0))!=null?e:0},t.getLeftTotalSize=()=>{var e,n;return(e=(n=t.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((i,r)=>i+r.getSize(),0))!=null?e:0},t.getCenterTotalSize=()=>{var e,n;return(e=(n=t.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((i,r)=>i+r.getSize(),0))!=null?e:0},t.getRightTotalSize=()=>{var e,n;return(e=(n=t.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((i,r)=>i+r.getSize(),0))!=null?e:0}}};let pg=null;function JF(){if(typeof pg=="boolean")return pg;let t=!1;try{const e={get passive(){return t=!0,!1}},n=()=>{};window.addEventListener("test",n,e),window.removeEventListener("test",n)}catch{t=!1}return pg=t,pg}function sb(t){return t.type==="touchstart"}const eG={getInitialState:t=>({columnVisibility:{},...t}),getDefaultOptions:t=>({onColumnVisibilityChange:ur("columnVisibility",t)}),createColumn:(t,e)=>{t.toggleVisibility=n=>{t.getCanHide()&&e.setColumnVisibility(i=>({...i,[t.id]:n??!t.getIsVisible()}))},t.getIsVisible=()=>{var n,i;const r=t.columns;return(n=r.length?r.some(s=>s.getIsVisible()):(i=e.getState().columnVisibility)==null?void 0:i[t.id])!=null?n:!0},t.getCanHide=()=>{var n,i;return((n=t.columnDef.enableHiding)!=null?n:!0)&&((i=e.options.enableHiding)!=null?i:!0)},t.getToggleVisibilityHandler=()=>n=>{t.toggleVisibility==null||t.toggleVisibility(n.target.checked)}},createRow:(t,e)=>{t._getAllVisibleCells=Ye(()=>[t.getAllCells(),e.getState().columnVisibility],n=>n.filter(i=>i.column.getIsVisible()),Fe(e.options,"debugRows")),t.getVisibleCells=Ye(()=>[t.getLeftVisibleCells(),t.getCenterVisibleCells(),t.getRightVisibleCells()],(n,i,r)=>[...n,...i,...r],Fe(e.options,"debugRows"))},createTable:t=>{const e=(n,i)=>Ye(()=>[i(),i().filter(r=>r.getIsVisible()).map(r=>r.id).join("_")],r=>r.filter(s=>s.getIsVisible==null?void 0:s.getIsVisible()),Fe(t.options,"debugColumns"));t.getVisibleFlatColumns=e("getVisibleFlatColumns",()=>t.getAllFlatColumns()),t.getVisibleLeafColumns=e("getVisibleLeafColumns",()=>t.getAllLeafColumns()),t.getLeftVisibleLeafColumns=e("getLeftVisibleLeafColumns",()=>t.getLeftLeafColumns()),t.getRightVisibleLeafColumns=e("getRightVisibleLeafColumns",()=>t.getRightLeafColumns()),t.getCenterVisibleLeafColumns=e("getCenterVisibleLeafColumns",()=>t.getCenterLeafColumns()),t.setColumnVisibility=n=>t.options.onColumnVisibilityChange==null?void 0:t.options.onColumnVisibilityChange(n),t.resetColumnVisibility=n=>{var i;t.setColumnVisibility(n?{}:(i=t.initialState.columnVisibility)!=null?i:{})},t.toggleAllColumnsVisible=n=>{var i;n=(i=n)!=null?i:!t.getIsAllColumnsVisible(),t.setColumnVisibility(t.getAllLeafColumns().reduce((r,s)=>({...r,[s.id]:n||!(s.getCanHide!=null&&s.getCanHide())}),{}))},t.getIsAllColumnsVisible=()=>!t.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),t.getIsSomeColumnsVisible=()=>t.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),t.getToggleAllColumnsVisibilityHandler=()=>n=>{var i;t.toggleAllColumnsVisible((i=n.target)==null?void 0:i.checked)}}};function Of(t,e){return e?e==="center"?t.getCenterVisibleLeafColumns():e==="left"?t.getLeftVisibleLeafColumns():t.getRightVisibleLeafColumns():t.getVisibleLeafColumns()}const tG={createTable:t=>{t._getGlobalFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,"__global__"),t.getGlobalFacetedRowModel=()=>t.options.manualFiltering||!t._getGlobalFacetedRowModel?t.getPreFilteredRowModel():t._getGlobalFacetedRowModel(),t._getGlobalFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,"__global__"),t.getGlobalFacetedUniqueValues=()=>t._getGlobalFacetedUniqueValues?t._getGlobalFacetedUniqueValues():new Map,t._getGlobalFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,"__global__"),t.getGlobalFacetedMinMaxValues=()=>{if(t._getGlobalFacetedMinMaxValues)return t._getGlobalFacetedMinMaxValues()}}},nG={getInitialState:t=>({globalFilter:void 0,...t}),getDefaultOptions:t=>({onGlobalFilterChange:ur("globalFilter",t),globalFilterFn:"auto",getColumnCanGlobalFilter:e=>{var n;const i=(n=t.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[e.id])==null?void 0:n.getValue();return typeof i=="string"||typeof i=="number"}}),createColumn:(t,e)=>{t.getCanGlobalFilter=()=>{var n,i,r,s;return((n=t.columnDef.enableGlobalFilter)!=null?n:!0)&&((i=e.options.enableGlobalFilter)!=null?i:!0)&&((r=e.options.enableFilters)!=null?r:!0)&&((s=e.options.getColumnCanGlobalFilter==null?void 0:e.options.getColumnCanGlobalFilter(t))!=null?s:!0)&&!!t.accessorFn}},createTable:t=>{t.getGlobalAutoFilterFn=()=>go.includesString,t.getGlobalFilterFn=()=>{var e,n;const{globalFilterFn:i}=t.options;return ZO(i)?i:i==="auto"?t.getGlobalAutoFilterFn():(e=(n=t.options.filterFns)==null?void 0:n[i])!=null?e:go[i]},t.setGlobalFilter=e=>{t.options.onGlobalFilterChange==null||t.options.onGlobalFilterChange(e)},t.resetGlobalFilter=e=>{t.setGlobalFilter(e?void 0:t.initialState.globalFilter)}}},iG={getInitialState:t=>({expanded:{},...t}),getDefaultOptions:t=>({onExpandedChange:ur("expanded",t),paginateExpandedRows:!0}),createTable:t=>{let e=!1,n=!1;t._autoResetExpanded=()=>{var i,r;if(!e){t._queue(()=>{e=!0});return}if((i=(r=t.options.autoResetAll)!=null?r:t.options.autoResetExpanded)!=null?i:!t.options.manualExpanding){if(n)return;n=!0,t._queue(()=>{t.resetExpanded(),n=!1})}},t.setExpanded=i=>t.options.onExpandedChange==null?void 0:t.options.onExpandedChange(i),t.toggleAllRowsExpanded=i=>{i??!t.getIsAllRowsExpanded()?t.setExpanded(!0):t.setExpanded({})},t.resetExpanded=i=>{var r,s;t.setExpanded(i?{}:(r=(s=t.initialState)==null?void 0:s.expanded)!=null?r:{})},t.getCanSomeRowsExpand=()=>t.getPrePaginationRowModel().flatRows.some(i=>i.getCanExpand()),t.getToggleAllRowsExpandedHandler=()=>i=>{i.persist==null||i.persist(),t.toggleAllRowsExpanded()},t.getIsSomeRowsExpanded=()=>{const i=t.getState().expanded;return i===!0||Object.values(i).some(Boolean)},t.getIsAllRowsExpanded=()=>{const i=t.getState().expanded;return typeof i=="boolean"?i===!0:!(!Object.keys(i).length||t.getRowModel().flatRows.some(r=>!r.getIsExpanded()))},t.getExpandedDepth=()=>{let i=0;return(t.getState().expanded===!0?Object.keys(t.getRowModel().rowsById):Object.keys(t.getState().expanded)).forEach(s=>{const o=s.split(".");i=Math.max(i,o.length)}),i},t.getPreExpandedRowModel=()=>t.getSortedRowModel(),t.getExpandedRowModel=()=>(!t._getExpandedRowModel&&t.options.getExpandedRowModel&&(t._getExpandedRowModel=t.options.getExpandedRowModel(t)),t.options.manualExpanding||!t._getExpandedRowModel?t.getPreExpandedRowModel():t._getExpandedRowModel())},createRow:(t,e)=>{t.toggleExpanded=n=>{e.setExpanded(i=>{var r;const s=i===!0?!0:!!(i!=null&&i[t.id]);let o={};if(i===!0?Object.keys(e.getRowModel().rowsById).forEach(l=>{o[l]=!0}):o=i,n=(r=n)!=null?r:!s,!s&&n)return{...o,[t.id]:!0};if(s&&!n){const{[t.id]:l,...u}=o;return u}return i})},t.getIsExpanded=()=>{var n;const i=e.getState().expanded;return!!((n=e.options.getIsRowExpanded==null?void 0:e.options.getIsRowExpanded(t))!=null?n:i===!0||i?.[t.id])},t.getCanExpand=()=>{var n,i,r;return(n=e.options.getRowCanExpand==null?void 0:e.options.getRowCanExpand(t))!=null?n:((i=e.options.enableExpanding)!=null?i:!0)&&!!((r=t.subRows)!=null&&r.length)},t.getIsAllParentsExpanded=()=>{let n=!0,i=t;for(;n&&i.parentId;)i=e.getRow(i.parentId,!0),n=i.getIsExpanded();return n},t.getToggleExpandedHandler=()=>{const n=t.getCanExpand();return()=>{n&&t.toggleExpanded()}}}},IS=0,XS=10,ob=()=>({pageIndex:IS,pageSize:XS}),rG={getInitialState:t=>({...t,pagination:{...ob(),...t?.pagination}}),getDefaultOptions:t=>({onPaginationChange:ur("pagination",t)}),createTable:t=>{let e=!1,n=!1;t._autoResetPageIndex=()=>{var i,r;if(!e){t._queue(()=>{e=!0});return}if((i=(r=t.options.autoResetAll)!=null?r:t.options.autoResetPageIndex)!=null?i:!t.options.manualPagination){if(n)return;n=!0,t._queue(()=>{t.resetPageIndex(),n=!1})}},t.setPagination=i=>{const r=s=>ma(i,s);return t.options.onPaginationChange==null?void 0:t.options.onPaginationChange(r)},t.resetPagination=i=>{var r;t.setPagination(i?ob():(r=t.initialState.pagination)!=null?r:ob())},t.setPageIndex=i=>{t.setPagination(r=>{let s=ma(i,r.pageIndex);const o=typeof t.options.pageCount>"u"||t.options.pageCount===-1?Number.MAX_SAFE_INTEGER:t.options.pageCount-1;return s=Math.max(0,Math.min(s,o)),{...r,pageIndex:s}})},t.resetPageIndex=i=>{var r,s;t.setPageIndex(i?IS:(r=(s=t.initialState)==null||(s=s.pagination)==null?void 0:s.pageIndex)!=null?r:IS)},t.resetPageSize=i=>{var r,s;t.setPageSize(i?XS:(r=(s=t.initialState)==null||(s=s.pagination)==null?void 0:s.pageSize)!=null?r:XS)},t.setPageSize=i=>{t.setPagination(r=>{const s=Math.max(1,ma(i,r.pageSize)),o=r.pageSize*r.pageIndex,l=Math.floor(o/s);return{...r,pageIndex:l,pageSize:s}})},t.setPageCount=i=>t.setPagination(r=>{var s;let o=ma(i,(s=t.options.pageCount)!=null?s:-1);return typeof o=="number"&&(o=Math.max(-1,o)),{...r,pageCount:o}}),t.getPageOptions=Ye(()=>[t.getPageCount()],i=>{let r=[];return i&&i>0&&(r=[...new Array(i)].fill(null).map((s,o)=>o)),r},Fe(t.options,"debugTable")),t.getCanPreviousPage=()=>t.getState().pagination.pageIndex>0,t.getCanNextPage=()=>{const{pageIndex:i}=t.getState().pagination,r=t.getPageCount();return r===-1?!0:r===0?!1:it.setPageIndex(i=>i-1),t.nextPage=()=>t.setPageIndex(i=>i+1),t.firstPage=()=>t.setPageIndex(0),t.lastPage=()=>t.setPageIndex(t.getPageCount()-1),t.getPrePaginationRowModel=()=>t.getExpandedRowModel(),t.getPaginationRowModel=()=>(!t._getPaginationRowModel&&t.options.getPaginationRowModel&&(t._getPaginationRowModel=t.options.getPaginationRowModel(t)),t.options.manualPagination||!t._getPaginationRowModel?t.getPrePaginationRowModel():t._getPaginationRowModel()),t.getPageCount=()=>{var i;return(i=t.options.pageCount)!=null?i:Math.ceil(t.getRowCount()/t.getState().pagination.pageSize)},t.getRowCount=()=>{var i;return(i=t.options.rowCount)!=null?i:t.getPrePaginationRowModel().rows.length}}},ab=()=>({top:[],bottom:[]}),sG={getInitialState:t=>({rowPinning:ab(),...t}),getDefaultOptions:t=>({onRowPinningChange:ur("rowPinning",t)}),createRow:(t,e)=>{t.pin=(n,i,r)=>{const s=i?t.getLeafRows().map(u=>{let{id:f}=u;return f}):[],o=r?t.getParentRows().map(u=>{let{id:f}=u;return f}):[],l=new Set([...o,t.id,...s]);e.setRowPinning(u=>{var f,h;if(n==="bottom"){var p,O;return{top:((p=u?.top)!=null?p:[]).filter(S=>!(l!=null&&l.has(S))),bottom:[...((O=u?.bottom)!=null?O:[]).filter(S=>!(l!=null&&l.has(S))),...Array.from(l)]}}if(n==="top"){var y,v;return{top:[...((y=u?.top)!=null?y:[]).filter(S=>!(l!=null&&l.has(S))),...Array.from(l)],bottom:((v=u?.bottom)!=null?v:[]).filter(S=>!(l!=null&&l.has(S)))}}return{top:((f=u?.top)!=null?f:[]).filter(S=>!(l!=null&&l.has(S))),bottom:((h=u?.bottom)!=null?h:[]).filter(S=>!(l!=null&&l.has(S)))}})},t.getCanPin=()=>{var n;const{enableRowPinning:i,enablePinning:r}=e.options;return typeof i=="function"?i(t):(n=i??r)!=null?n:!0},t.getIsPinned=()=>{const n=[t.id],{top:i,bottom:r}=e.getState().rowPinning,s=n.some(l=>i?.includes(l)),o=n.some(l=>r?.includes(l));return s?"top":o?"bottom":!1},t.getPinnedIndex=()=>{var n,i;const r=t.getIsPinned();if(!r)return-1;const s=(n=r==="top"?e.getTopRows():e.getBottomRows())==null?void 0:n.map(o=>{let{id:l}=o;return l});return(i=s?.indexOf(t.id))!=null?i:-1}},createTable:t=>{t.setRowPinning=e=>t.options.onRowPinningChange==null?void 0:t.options.onRowPinningChange(e),t.resetRowPinning=e=>{var n,i;return t.setRowPinning(e?ab():(n=(i=t.initialState)==null?void 0:i.rowPinning)!=null?n:ab())},t.getIsSomeRowsPinned=e=>{var n;const i=t.getState().rowPinning;if(!e){var r,s;return!!((r=i.top)!=null&&r.length||(s=i.bottom)!=null&&s.length)}return!!((n=i[e])!=null&&n.length)},t._getPinnedRows=(e,n,i)=>{var r;return((r=t.options.keepPinnedRows)==null||r?(n??[]).map(o=>{const l=t.getRow(o,!0);return l.getIsAllParentsExpanded()?l:null}):(n??[]).map(o=>e.find(l=>l.id===o))).filter(Boolean).map(o=>({...o,position:i}))},t.getTopRows=Ye(()=>[t.getRowModel().rows,t.getState().rowPinning.top],(e,n)=>t._getPinnedRows(e,n,"top"),Fe(t.options,"debugRows")),t.getBottomRows=Ye(()=>[t.getRowModel().rows,t.getState().rowPinning.bottom],(e,n)=>t._getPinnedRows(e,n,"bottom"),Fe(t.options,"debugRows")),t.getCenterRows=Ye(()=>[t.getRowModel().rows,t.getState().rowPinning.top,t.getState().rowPinning.bottom],(e,n,i)=>{const r=new Set([...n??[],...i??[]]);return e.filter(s=>!r.has(s.id))},Fe(t.options,"debugRows"))}},oG={getInitialState:t=>({rowSelection:{},...t}),getDefaultOptions:t=>({onRowSelectionChange:ur("rowSelection",t),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:t=>{t.setRowSelection=e=>t.options.onRowSelectionChange==null?void 0:t.options.onRowSelectionChange(e),t.resetRowSelection=e=>{var n;return t.setRowSelection(e?{}:(n=t.initialState.rowSelection)!=null?n:{})},t.toggleAllRowsSelected=e=>{t.setRowSelection(n=>{e=typeof e<"u"?e:!t.getIsAllRowsSelected();const i={...n},r=t.getPreGroupedRowModel().flatRows;return e?r.forEach(s=>{s.getCanSelect()&&(i[s.id]=!0)}):r.forEach(s=>{delete i[s.id]}),i})},t.toggleAllPageRowsSelected=e=>t.setRowSelection(n=>{const i=typeof e<"u"?e:!t.getIsAllPageRowsSelected(),r={...n};return t.getRowModel().rows.forEach(s=>{VS(r,s.id,i,!0,t)}),r}),t.getPreSelectedRowModel=()=>t.getCoreRowModel(),t.getSelectedRowModel=Ye(()=>[t.getState().rowSelection,t.getCoreRowModel()],(e,n)=>Object.keys(e).length?lb(t,n):{rows:[],flatRows:[],rowsById:{}},Fe(t.options,"debugTable")),t.getFilteredSelectedRowModel=Ye(()=>[t.getState().rowSelection,t.getFilteredRowModel()],(e,n)=>Object.keys(e).length?lb(t,n):{rows:[],flatRows:[],rowsById:{}},Fe(t.options,"debugTable")),t.getGroupedSelectedRowModel=Ye(()=>[t.getState().rowSelection,t.getSortedRowModel()],(e,n)=>Object.keys(e).length?lb(t,n):{rows:[],flatRows:[],rowsById:{}},Fe(t.options,"debugTable")),t.getIsAllRowsSelected=()=>{const e=t.getFilteredRowModel().flatRows,{rowSelection:n}=t.getState();let i=!!(e.length&&Object.keys(n).length);return i&&e.some(r=>r.getCanSelect()&&!n[r.id])&&(i=!1),i},t.getIsAllPageRowsSelected=()=>{const e=t.getPaginationRowModel().flatRows.filter(r=>r.getCanSelect()),{rowSelection:n}=t.getState();let i=!!e.length;return i&&e.some(r=>!n[r.id])&&(i=!1),i},t.getIsSomeRowsSelected=()=>{var e;const n=Object.keys((e=t.getState().rowSelection)!=null?e:{}).length;return n>0&&n{const e=t.getPaginationRowModel().flatRows;return t.getIsAllPageRowsSelected()?!1:e.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},t.getToggleAllRowsSelectedHandler=()=>e=>{t.toggleAllRowsSelected(e.target.checked)},t.getToggleAllPageRowsSelectedHandler=()=>e=>{t.toggleAllPageRowsSelected(e.target.checked)}},createRow:(t,e)=>{t.toggleSelected=(n,i)=>{const r=t.getIsSelected();e.setRowSelection(s=>{var o;if(n=typeof n<"u"?n:!r,t.getCanSelect()&&r===n)return s;const l={...s};return VS(l,t.id,n,(o=i?.selectChildren)!=null?o:!0,e),l})},t.getIsSelected=()=>{const{rowSelection:n}=e.getState();return g1(t,n)},t.getIsSomeSelected=()=>{const{rowSelection:n}=e.getState();return BS(t,n)==="some"},t.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=e.getState();return BS(t,n)==="all"},t.getCanSelect=()=>{var n;return typeof e.options.enableRowSelection=="function"?e.options.enableRowSelection(t):(n=e.options.enableRowSelection)!=null?n:!0},t.getCanSelectSubRows=()=>{var n;return typeof e.options.enableSubRowSelection=="function"?e.options.enableSubRowSelection(t):(n=e.options.enableSubRowSelection)!=null?n:!0},t.getCanMultiSelect=()=>{var n;return typeof e.options.enableMultiRowSelection=="function"?e.options.enableMultiRowSelection(t):(n=e.options.enableMultiRowSelection)!=null?n:!0},t.getToggleSelectedHandler=()=>{const n=t.getCanSelect();return i=>{var r;n&&t.toggleSelected((r=i.target)==null?void 0:r.checked)}}}},VS=(t,e,n,i,r)=>{var s;const o=r.getRow(e,!0);n?(o.getCanMultiSelect()||Object.keys(t).forEach(l=>delete t[l]),o.getCanSelect()&&(t[e]=!0)):delete t[e],i&&(s=o.subRows)!=null&&s.length&&o.getCanSelectSubRows()&&o.subRows.forEach(l=>VS(t,l.id,n,i,r))};function lb(t,e){const n=t.getState().rowSelection,i=[],r={},s=function(o,l){return o.map(u=>{var f;const h=g1(u,n);if(h&&(i.push(u),r[u.id]=u),(f=u.subRows)!=null&&f.length&&(u={...u,subRows:s(u.subRows)}),h)return u}).filter(Boolean)};return{rows:s(e.rows),flatRows:i,rowsById:r}}function g1(t,e){var n;return(n=e[t.id])!=null?n:!1}function BS(t,e,n){var i;if(!((i=t.subRows)!=null&&i.length))return!1;let r=!0,s=!1;return t.subRows.forEach(o=>{if(!(s&&!r)&&(o.getCanSelect()&&(g1(o,e)?s=!0:r=!1),o.subRows&&o.subRows.length)){const l=BS(o,e);l==="all"?s=!0:(l==="some"&&(s=!0),r=!1)}}),r?"all":s?"some":!1}const US=/([0-9]+)/gm,aG=(t,e,n)=>bD(_a(t.getValue(n)).toLowerCase(),_a(e.getValue(n)).toLowerCase()),lG=(t,e,n)=>bD(_a(t.getValue(n)),_a(e.getValue(n))),cG=(t,e,n)=>m1(_a(t.getValue(n)).toLowerCase(),_a(e.getValue(n)).toLowerCase()),uG=(t,e,n)=>m1(_a(t.getValue(n)),_a(e.getValue(n))),dG=(t,e,n)=>{const i=t.getValue(n),r=e.getValue(n);return i>r?1:im1(t.getValue(n),e.getValue(n));function m1(t,e){return t===e?0:t>e?1:-1}function _a(t){return typeof t=="number"?isNaN(t)||t===1/0||t===-1/0?"":String(t):typeof t=="string"?t:""}function bD(t,e){const n=t.split(US).filter(Boolean),i=e.split(US).filter(Boolean);for(;n.length&&i.length;){const r=n.shift(),s=i.shift(),o=parseInt(r,10),l=parseInt(s,10),u=[o,l].sort();if(isNaN(u[0])){if(r>s)return 1;if(s>r)return-1;continue}if(isNaN(u[1]))return isNaN(o)?-1:1;if(o>l)return 1;if(l>o)return-1}return n.length-i.length}const Gd={alphanumeric:aG,alphanumericCaseSensitive:lG,text:cG,textCaseSensitive:uG,datetime:dG,basic:fG},hG={getInitialState:t=>({sorting:[],...t}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:t=>({onSortingChange:ur("sorting",t),isMultiSortEvent:e=>e.shiftKey}),createColumn:(t,e)=>{t.getAutoSortingFn=()=>{const n=e.getFilteredRowModel().flatRows.slice(10);let i=!1;for(const r of n){const s=r?.getValue(t.id);if(Object.prototype.toString.call(s)==="[object Date]")return Gd.datetime;if(typeof s=="string"&&(i=!0,s.split(US).length>1))return Gd.alphanumeric}return i?Gd.text:Gd.basic},t.getAutoSortDir=()=>{const n=e.getFilteredRowModel().flatRows[0];return typeof n?.getValue(t.id)=="string"?"asc":"desc"},t.getSortingFn=()=>{var n,i;if(!t)throw new Error;return ZO(t.columnDef.sortingFn)?t.columnDef.sortingFn:t.columnDef.sortingFn==="auto"?t.getAutoSortingFn():(n=(i=e.options.sortingFns)==null?void 0:i[t.columnDef.sortingFn])!=null?n:Gd[t.columnDef.sortingFn]},t.toggleSorting=(n,i)=>{const r=t.getNextSortingOrder(),s=typeof n<"u"&&n!==null;e.setSorting(o=>{const l=o?.find(y=>y.id===t.id),u=o?.findIndex(y=>y.id===t.id);let f=[],h,p=s?n:r==="desc";if(o!=null&&o.length&&t.getCanMultiSort()&&i?l?h="toggle":h="add":o!=null&&o.length&&u!==o.length-1?h="replace":l?h="toggle":h="replace",h==="toggle"&&(s||r||(h="remove")),h==="add"){var O;f=[...o,{id:t.id,desc:p}],f.splice(0,f.length-((O=e.options.maxMultiSortColCount)!=null?O:Number.MAX_SAFE_INTEGER))}else h==="toggle"?f=o.map(y=>y.id===t.id?{...y,desc:p}:y):h==="remove"?f=o.filter(y=>y.id!==t.id):f=[{id:t.id,desc:p}];return f})},t.getFirstSortDir=()=>{var n,i;return((n=(i=t.columnDef.sortDescFirst)!=null?i:e.options.sortDescFirst)!=null?n:t.getAutoSortDir()==="desc")?"desc":"asc"},t.getNextSortingOrder=n=>{var i,r;const s=t.getFirstSortDir(),o=t.getIsSorted();return o?o!==s&&((i=e.options.enableSortingRemoval)==null||i)&&(!(n&&(r=e.options.enableMultiRemove)!=null)||r)?!1:o==="desc"?"asc":"desc":s},t.getCanSort=()=>{var n,i;return((n=t.columnDef.enableSorting)!=null?n:!0)&&((i=e.options.enableSorting)!=null?i:!0)&&!!t.accessorFn},t.getCanMultiSort=()=>{var n,i;return(n=(i=t.columnDef.enableMultiSort)!=null?i:e.options.enableMultiSort)!=null?n:!!t.accessorFn},t.getIsSorted=()=>{var n;const i=(n=e.getState().sorting)==null?void 0:n.find(r=>r.id===t.id);return i?i.desc?"desc":"asc":!1},t.getSortIndex=()=>{var n,i;return(n=(i=e.getState().sorting)==null?void 0:i.findIndex(r=>r.id===t.id))!=null?n:-1},t.clearSorting=()=>{e.setSorting(n=>n!=null&&n.length?n.filter(i=>i.id!==t.id):[])},t.getToggleSortingHandler=()=>{const n=t.getCanSort();return i=>{n&&(i.persist==null||i.persist(),t.toggleSorting==null||t.toggleSorting(void 0,t.getCanMultiSort()?e.options.isMultiSortEvent==null?void 0:e.options.isMultiSortEvent(i):!1))}}},createTable:t=>{t.setSorting=e=>t.options.onSortingChange==null?void 0:t.options.onSortingChange(e),t.resetSorting=e=>{var n,i;t.setSorting(e?[]:(n=(i=t.initialState)==null?void 0:i.sorting)!=null?n:[])},t.getPreSortedRowModel=()=>t.getGroupedRowModel(),t.getSortedRowModel=()=>(!t._getSortedRowModel&&t.options.getSortedRowModel&&(t._getSortedRowModel=t.options.getSortedRowModel(t)),t.options.manualSorting||!t._getSortedRowModel?t.getPreSortedRowModel():t._getSortedRowModel())}},pG=[jF,eG,GF,HF,DF,NF,tG,nG,hG,YF,iG,rG,sG,oG,KF];function gG(t){var e,n;const i=[...pG,...(e=t._features)!=null?e:[]];let r={_features:i};const s=r._features.reduce((O,y)=>Object.assign(O,y.getDefaultOptions==null?void 0:y.getDefaultOptions(r)),{}),o=O=>r.options.mergeOptions?r.options.mergeOptions(s,O):{...s,...O};let u={...{},...(n=t.initialState)!=null?n:{}};r._features.forEach(O=>{var y;u=(y=O.getInitialState==null?void 0:O.getInitialState(u))!=null?y:u});const f=[];let h=!1;const p={_features:i,options:{...s,...t},initialState:u,_queue:O=>{f.push(O),h||(h=!0,Promise.resolve().then(()=>{for(;f.length;)f.shift()();h=!1}).catch(y=>setTimeout(()=>{throw y})))},reset:()=>{r.setState(r.initialState)},setOptions:O=>{const y=ma(O,r.options);r.options=o(y)},getState:()=>r.options.state,setState:O=>{r.options.onStateChange==null||r.options.onStateChange(O)},_getRowId:(O,y,v)=>{var S;return(S=r.options.getRowId==null?void 0:r.options.getRowId(O,y,v))!=null?S:`${v?[v.id,y].join("."):y}`},getCoreRowModel:()=>(r._getCoreRowModel||(r._getCoreRowModel=r.options.getCoreRowModel(r)),r._getCoreRowModel()),getRowModel:()=>r.getPaginationRowModel(),getRow:(O,y)=>{let v=(y?r.getPrePaginationRowModel():r.getRowModel()).rowsById[O];if(!v&&(v=r.getCoreRowModel().rowsById[O],!v))throw new Error;return v},_getDefaultColumnDef:Ye(()=>[r.options.defaultColumn],O=>{var y;return O=(y=O)!=null?y:{},{header:v=>{const S=v.header.column.columnDef;return S.accessorKey?S.accessorKey:S.accessorFn?S.id:null},cell:v=>{var S,k;return(S=(k=v.renderValue())==null||k.toString==null?void 0:k.toString())!=null?S:null},...r._features.reduce((v,S)=>Object.assign(v,S.getDefaultColumnDef==null?void 0:S.getDefaultColumnDef()),{}),...O}},Fe(t,"debugColumns")),_getColumnDefs:()=>r.options.columns,getAllColumns:Ye(()=>[r._getColumnDefs()],O=>{const y=function(v,S,k){return k===void 0&&(k=0),v.map(C=>{const $=PF(r,C,k,S),T=C;return $.columns=T.columns?y(T.columns,$,k+1):[],$})};return y(O)},Fe(t,"debugColumns")),getAllFlatColumns:Ye(()=>[r.getAllColumns()],O=>O.flatMap(y=>y.getFlatColumns()),Fe(t,"debugColumns")),_getAllFlatColumnsById:Ye(()=>[r.getAllFlatColumns()],O=>O.reduce((y,v)=>(y[v.id]=v,y),{}),Fe(t,"debugColumns")),getAllLeafColumns:Ye(()=>[r.getAllColumns(),r._getOrderColumnsFn()],(O,y)=>{let v=O.flatMap(S=>S.getLeafColumns());return y(v)},Fe(t,"debugColumns")),getColumn:O=>r._getAllFlatColumnsById()[O]};Object.assign(r,p);for(let O=0;OYe(()=>[t.options.data],e=>{const n={rows:[],flatRows:[],rowsById:{}},i=function(r,s,o){s===void 0&&(s=0);const l=[];for(let f=0;ft._autoResetPageIndex()))}function xD(){return t=>Ye(()=>[t.getState().sorting,t.getPreSortedRowModel()],(e,n)=>{if(!n.rows.length||!(e!=null&&e.length))return n;const i=t.getState().sorting,r=[],s=i.filter(u=>{var f;return(f=t.getColumn(u.id))==null?void 0:f.getCanSort()}),o={};s.forEach(u=>{const f=t.getColumn(u.id);f&&(o[u.id]={sortUndefined:f.columnDef.sortUndefined,invertSorting:f.columnDef.invertSorting,sortingFn:f.getSortingFn()})});const l=u=>{const f=u.map(h=>({...h}));return f.sort((h,p)=>{for(let y=0;y{var p;r.push(h),(p=h.subRows)!=null&&p.length&&(h.subRows=l(h.subRows))}),f};return{rows:l(n.rows),flatRows:r,rowsById:n.rowsById}},Fe(t.options,"debugTable","getSortedRowModel",()=>t._autoResetPageIndex()))}function qS(t,e){return t?mG(t)?w.createElement(t,e):t:null}function mG(t){return OG(t)||typeof t=="function"||yG(t)}function OG(t){return typeof t=="function"&&(()=>{const e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}function yG(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}function wD(t){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[n]=w.useState(()=>({current:gG(e)})),[i,r]=w.useState(()=>n.current.initialState);return n.current.setOptions(s=>({...s,...t,state:{...i,...t.state},onStateChange:o=>{r(o),t.onStateChange==null||t.onStateChange(o)}})),n.current}var Sh=t=>t.type==="checkbox",Oa=t=>t instanceof Date,Wn=t=>t==null;const O1=t=>typeof t=="object";var dn=t=>!Wn(t)&&!Array.isArray(t)&&O1(t)&&!Oa(t),vG=t=>dn(t)&&t.target?Sh(t.target)?t.target.checked:t.target.value:t,bG=(t,e)=>e.split(".").some((n,i,r)=>!isNaN(Number(n))&&t.has(r.slice(0,i).join("."))),kD=t=>{const e=t.constructor&&t.constructor.prototype;return dn(e)&&e.hasOwnProperty("isPrototypeOf")},IO=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function mn(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(IO&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(dn(t)&&kD(t)))return t;const i=n?[]:Object.create(Object.getPrototypeOf(t));for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=mn(t[r]));return i}const Nc={BLUR:"blur",FOCUS_OUT:"focusout",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},Gr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},qr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},CD="root",y1=["__proto__","constructor","prototype"],SG=/^\w*$/;var xh=t=>SG.test(t),Ht=t=>t===void 0;const xG=/[.[\]'"]/;var XO=t=>t.split(xG).filter(Boolean),$e=(t,e,n)=>{if(!e||!dn(t))return n;const i=xh(e)?[e]:XO(e);if(i.some(s=>y1.includes(s)))return n;const r=i.reduce((s,o)=>Wn(s)?void 0:s[o],t);return Ht(r)||r===t?Ht(t[e])?n:t[e]:r},bs=t=>typeof t=="boolean",$r=t=>typeof t=="function",Nt=(t,e,n)=>{let i=-1;const r=xh(e)?[e]:XO(e),s=r.length,o=s-1;for(;++i{const r={};for(const s in t)Object.defineProperty(r,s,{get:()=>{const o=s;return e._proxyFormState[o]!==Gr.all&&(e._proxyFormState[o]=!i||Gr.all),t[o]}});return r};const CG=IO?be.useLayoutEffect:be.useEffect;var Kn=t=>typeof t=="string",_G=(t,e,n,i,r)=>Kn(t)?(i&&e.watch.add(t),$e(n,t,r)):Array.isArray(t)?t.map(s=>(i&&e.watch.add(s),$e(n,s))):(i&&(e.watchAll=!0),n),YS=t=>Wn(t)||!O1(t);const W2=(t,e)=>e.length===0&&!Array.isArray(t)&&!kD(t);function Ss(t,e,n=new WeakMap){if(t===e)return!0;if(YS(t)||YS(e))return Object.is(t,e);if(Oa(t)&&Oa(e))return Object.is(t.getTime(),e.getTime());const i=Object.keys(t),r=Object.keys(e);if(i.length!==r.length)return!1;if(W2(t,i)||W2(e,r))return Object.is(t,e);if(!i.length&&Array.isArray(t)!==Array.isArray(e))return!1;const s=n.get(t);if(s&&s.has(e))return!0;if(s)s.add(e);else{const o=new WeakSet;o.add(e),n.set(t,o)}for(const o of i){const l=t[o];if(!(o in e))return!1;if(o!=="ref"){const u=e[o];if(Oa(l)&&Oa(u)||(dn(l)||Array.isArray(l))&&(dn(u)||Array.isArray(u))?!Ss(l,u,n):!Object.is(l,u))return!1}}return!0}var gg=t=>({isOnSubmit:!t||t===Gr.onSubmit,isOnBlur:t===Gr.onBlur,isOnChange:t===Gr.onChange,isOnAll:t===Gr.all,isOnTouch:t===Gr.onTouched}),cb=(t,e,n)=>{if(n)return!1;if(e.watchAll||e.watch.has(t))return!0;for(const i of e.watch)if(t.startsWith(i)&&t.charAt(i.length)===".")return!0;return!1};const yf=(t,e,n,i)=>{for(const r of n||Object.keys(t)){const s=$e(t,r);if(s){const{_f:o,...l}=s;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],r)&&!i)return!0;if(o.ref&&e(o.ref,o.name)&&!i)return!0;if(yf(l,e))break}else if(dn(l)&&yf(l,e))break}}};var K2=(t,e,n)=>{const i=$e(t,n),r=Array.isArray(i)?i:[];return Nt(r,CD,e[n]),Nt(t,n,r),t},Gn=t=>dn(t)&&!Object.keys(t).length,v1=t=>t.type==="file",Sm=t=>{if(!IO)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},b1=t=>t.type==="radio",xm=t=>t instanceof RegExp,S1=(t,e,n,i,r)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[i]:r||!0}}:{};const J2={value:!1,isValid:!1},eE={value:!0,isValid:!0};var _D=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!Ht(t[0].attributes.value)?Ht(t[0].value)||t[0].value===""?eE:{value:t[0].value,isValid:!0}:eE:J2}return J2};const tE={isValid:!1,value:null};var $D=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,tE):tE;function nE(t,e,n="validate"){if(Kn(t)||Array.isArray(t)&&t.every(Kn)||bs(t)&&!t)return{type:n,message:Kn(t)?t:"",ref:e}}var zc=t=>dn(t)&&!xm(t)?t:{value:t,message:""},iE=async(t,e,n,i,r,s)=>{const{ref:o,refs:l,required:u,maxLength:f,minLength:h,min:p,max:O,pattern:y,validate:v,name:S,valueAsNumber:k,mount:C}=t._f,$=$e(n,S);if(!C||e.has(S))return{};const T=l?l[0]:o,Q=K=>{if(r&&T.reportValidity){const se=bs(K)?"":K||"";l?l.forEach(H=>H.setCustomValidity(se)):T.setCustomValidity(se),T.reportValidity()}},A={},R=b1(o),P=Sh(o),X=R||P,te=(k||v1(o))&&Ht(o.value)&&Ht($)||Sm(o)&&o.value===""||$===""||Array.isArray($)&&!$.length,G=S1.bind(null,S,i,A),Y=(K,se,H,pe=qr.maxLength,z=qr.minLength)=>{const W=K?se:H;A[S]={type:K?pe:z,message:W,ref:o,...G(K?pe:z,W)}};if(s?!Array.isArray($)||!$.length:u&&(!X&&(te||Wn($))||bs($)&&!$||P&&!_D(l).isValid||R&&!$D(l).isValid)){const{value:K,message:se}=Kn(u)?{value:!!u,message:u}:zc(u);if(K&&(A[S]={type:qr.required,message:se,ref:T,...G(qr.required,se)},!i))return Q(se),A}if(!te&&(!Wn(p)||!Wn(O))){let K,se;const H=zc(O),pe=zc(p);if(!Wn($)&&!isNaN($)){const z=o.valueAsNumber||$&&+$;Wn(H.value)||(K=z>H.value),Wn(pe.value)||(se=znew Date(new Date().toDateString()+" "+ae),ce=o.type=="time",oe=o.type=="week";Kn(H.value)&&$&&(K=ce?W($)>W(H.value):oe?$>H.value:z>new Date(H.value)),Kn(pe.value)&&$&&(se=ce?W($)+K.value,pe=!Wn(se.value)&&$.length<+se.value;if((H||pe)&&(Y(H,K.message,se.message),!i))return Q(A[S].message),A}if(y&&!te&&Kn($)){const{value:K,message:se}=zc(y);if(xm(K)&&!$.match(K)&&(A[S]={type:qr.pattern,message:se,ref:o,...G(qr.pattern,se)},!i))return Q(se),A}if(v){if($r(v)){const K=await v($,n),se=nE(K,T);if(se&&(A[S]={...se,...G(qr.validate,se.message)},!i))return Q(se.message),A}else if(dn(v)){let K={};for(const se in v){if(!Gn(K)&&!i)break;const H=nE(await v[se]($,n),T,se);H&&(K={...H,...G(se,H.message)},Q(H.message),i&&(A[S]=K))}if(!Gn(K)&&(A[S]={ref:T,...K},!i))return A}}return Q(!0),A},qg=t=>Array.isArray(t)?t:[t],TD=t=>Array.isArray(t)?t.filter(Boolean):[];function $G(t,e){const n=e.slice(0,-1).length;let i=0;for(;iy1.includes(String(o))))return t;const i=n.length===1?t:$G(t,n),r=n.length-1,s=n[r];return i&&delete i[s],r!==0&&(dn(i)&&Gn(i)||Array.isArray(i)&&TG(i))&&On(t,n.slice(0,-1)),t}const ED=t=>{const e={};for(const n of Object.keys(t))if(O1(t[n])&&t[n]!==null&&!Oa(t[n])){const i=ED(t[n]);for(const r of Object.keys(i))e[`${n}.${r}`]=i[r]}else e[n]=t[n];return e},EG=be.createContext(null);EG.displayName="HookFormContext";var rE=()=>{let t=[];return{get observers(){return t},next:r=>{for(const s of t)s.next&&s.next(r)},subscribe:r=>(t.push(r),{unsubscribe:()=>{t=t.filter(s=>s!==r)}}),unsubscribe:()=>{t=[]}}};function RD(t,e){const n={};for(const i in t)if(t.hasOwnProperty(i)){const r=t[i],s=e[i];if(r&&dn(r)&&s){const o=RD(r,s);dn(o)&&(n[i]=o)}else t[i]&&(n[i]=s)}return n}var QD=t=>t.type==="select-multiple",RG=t=>b1(t)||Sh(t),ub=t=>Sm(t)&&t.isConnected,QG=t=>{for(const e in t)if($r(t[e]))return!0;return!1};function AD(t){return Array.isArray(t)||dn(t)&&!QG(t)}function PD(t){return!!(t&&"_f"in t)}function jD(t){return Array.isArray(t)?!t.some(e=>!Ht(e)):!Object.keys(t).length}function FS(t,e){Array.isArray(t)?t[e]=void 0:delete t[e]}function GS(t,e={},n){for(const i in t){const r=t[i],s=n&&n[i];AD(r)&&(!Array.isArray(r)||!PD(s))?(e[i]=Array.isArray(r)?[]:{},GS(r,e[i],s),jD(e[i])&&FS(e,i)):Ht(r)||(e[i]=!0)}return e}function pl(t,e,n,i){n||(n=GS(e,{},i));for(const r in t){const s=t[r],o=i&&i[r];AD(s)&&(!Array.isArray(s)||!PD(o))?(Ht(e)||YS(n[r])?n[r]=GS(s,Array.isArray(s)?[]:{},o):pl(s,Wn(e)?{}:e[r],n[r],o),jD(n[r])&&FS(n,r)):Ss(s,e[r])?FS(n,r):n[r]=!0}return n}var MD=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:i})=>Ht(t)?t:e?t===""?NaN:t&&+t:n&&Kn(t)?new Date(t):i?i(t):t;function sE(t){const e=t.ref;return v1(e)?e.files:b1(e)?$D(t.refs).value:QD(e)?[...e.selectedOptions].map(({value:n})=>n):Sh(e)?_D(t.refs).value:MD(Ht(e.value)?t.ref.value:e.value,t)}var AG=(t,e,n,i)=>{const r={};for(const s of t){const o=$e(e,s);o&&Nt(r,s,o._f)}return{criteriaMode:n,names:[...t],fields:r,shouldUseNativeValidation:i}},Hd=t=>Ht(t)?t:xm(t)?t.source:dn(t)?xm(t.value)?t.value.source:t.value:t;const oE="AsyncFunction";var PG=t=>{if(!t||!t.validate)return!1;if($r(t.validate))return t.validate.constructor.name===oE;if(dn(t.validate)){for(const e in t.validate)if(t.validate[e].constructor.name===oE)return!0}return!1},jG=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate);function aE(t,e,n){const i=$e(t,n);if(i||xh(n))return{error:i,name:n};const r=n.split(".");for(;r.length;){const s=r.join("."),o=$e(e,s),l=$e(t,s);if(o&&!Array.isArray(o)&&n!==s)return{name:n};if(l&&l.type)return{name:s,error:l};if(l&&l.root&&l.root.type)return{name:`${s}.root`,error:l.root};r.pop()}return{name:n}}var MG=(t,e,n,i)=>{n(t);const{name:r,...s}=t,o=Object.keys(s);return!o.length||i&&o.length>=Object.keys(e).length||o.find(l=>e[l]===(!i||Gr.all))},DG=(t,e,n)=>!t||!e||t===e||qg(t).some(i=>i&&(n?i===e||i.startsWith(e+"."):i.startsWith(e)||e.startsWith(i))),NG=(t,e,n,i,r)=>r.isOnAll?!1:!n&&r.isOnTouch?!(e||t):(n?i.isOnBlur:r.isOnBlur)?!t:(n?i.isOnChange:r.isOnChange)?t:!0,zG=(t,e)=>!TD($e(t,e)).length&&On(t,e);const LG={mode:Gr.onSubmit,reValidateMode:Gr.onChange,shouldFocusError:!0},db="form",DD={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function ZG(t={}){let e={...LG,...t},n={...mn(DD),isLoading:$r(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1},i={},r=dn(e.defaultValues)||dn(e.values)?mn(e.defaultValues||e.values)||{}:{},s=e.shouldUnregister?{}:mn(r),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const u={},f={};let h=0,p=gg(e.mode),O=gg(e.reValidateMode);const y={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},v={...y};let S={...v};const k={array:rE(),state:rE()};let C=0;const $=e.criteriaMode===Gr.all,T=(M,U)=>q=>{clearTimeout(f[M]),f[M]=setTimeout(U,q)},Q=async M=>{if(!o.keepIsValid&&!e.disabled&&(v.isValid||S.isValid||M)){const U=++C;let q;e.resolver?(q=Gn((await H()).errors),U===C&&A()):q=await W({fields:i,onlyCheckValid:!0,eventType:Nc.VALID}),U===C&&q!==n.isValid&&k.state.next({isValid:q})}},A=(M,U)=>{!e.disabled&&(v.isValidating||v.validatingFields||S.isValidating||S.validatingFields)&&((M||Array.from(l.mount)).forEach(q=>{q&&(U?Nt(n.validatingFields,q,U):On(n.validatingFields,q))}),k.state.next({validatingFields:n.validatingFields,isValidating:!Gn(n.validatingFields)}))},R=()=>{n.dirtyFields=pl(r,s,void 0,i)},P=(M,U=[],q,he,me=!0,Se=!0)=>{if(he&&q&&!e.disabled){if(o.action=!0,Se&&Array.isArray($e(i,M))){const ke=q($e(i,M),he.argA,he.argB);me&&Nt(i,M,ke)}if(Se&&Array.isArray($e(n.errors,M))){const ke=q($e(n.errors,M),he.argA,he.argB);me&&Nt(n.errors,M,ke),zG(n.errors,M)}if((v.touchedFields||S.touchedFields)&&Se&&Array.isArray($e(n.touchedFields,M))){const ke=q($e(n.touchedFields,M),he.argA,he.argB);me&&Nt(n.touchedFields,M,ke)}(v.dirtyFields||S.dirtyFields)&&R(),k.state.next({name:M,isDirty:oe(M,U),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else Nt(s,M,U)},X=(M,U)=>{Nt(n.errors,M,U),n.errors={...n.errors},k.state.next({errors:n.errors})},te=M=>{n.errors=M,k.state.next({errors:n.errors,isValid:!1})},G=M=>{const U=xh(M)?[M]:XO(M);let q=s,he=r;for(let me=0;me{const me=$e(i,M);if(me){if(G(M))return;const Se=Ht($e(s,M)),ke=$e(s,M,Ht(q)?$e(r,M):q);Ht(ke)||he&&he.defaultChecked||U?Nt(s,M,U?ke:sE(me._f)):j(M,ke),o.mount&&!o.action&&(Q(),Se&&n.isDirty&&(v.isDirty||S.isDirty)&&(oe()||(n.isDirty=!1,k.state.next({...n}))),t.shouldUnregister&&Se&&!Ht($e(s,M))&&cb(M,l)&&(o.watch=!0))}},K=(M,U,q,he,me)=>{let Se=!1,ke=!1;const _e={name:M};if(!e.disabled||he===!0){if(!q||he){const Ae=Ss($e(r,M),U);(v.isDirty||S.isDirty)&&(ke=n.isDirty,n.isDirty=_e.isDirty=!Ae||oe(),Se=ke!==_e.isDirty),ke=!!$e(n.dirtyFields,M),Ae!==n.isDirty?n.dirtyFields=pl(r,s,void 0,i):Ae?On(n.dirtyFields,M):Nt(n.dirtyFields,M,!0),_e.dirtyFields=n.dirtyFields,Se=Se||(v.dirtyFields||S.dirtyFields)&&ke!==!Ae}if(q){const Ae=$e(n.touchedFields,M);Ae||(Nt(n.touchedFields,M,q),_e.touchedFields=n.touchedFields,Se=Se||(v.touchedFields||S.touchedFields)&&Ae!==q)}Se&&me&&k.state.next(_e)}return Se?_e:{}},se=(M,U,q,he)=>{const me=$e(n.errors,M),Se=(v.isValid||S.isValid)&&bs(U)&&n.isValid!==U;if(e.delayError&&q?(u[M]=T(M,()=>X(M,q)),u[M](e.delayError)):(clearTimeout(f[M]),delete u[M],q?Nt(n.errors,M,q):On(n.errors,M),n.errors={...n.errors}),(q?!Ss(me,q):me)||!Gn(he)||Se){const ke={...he,...Se&&bs(U)?{isValid:U}:{},errors:n.errors,name:M};n={...n,...ke},k.state.next(ke)}},H=async M=>(A(M,!0),await e.resolver(s,e.context,AG(M||l.mount,i,e.criteriaMode,e.shouldUseNativeValidation))),pe=async M=>{const{errors:U}=await H(M);if(A(M),M){for(const q of M){const he=$e(U,q);he?l.array.has(q)&&dn(he)&&!Object.keys(he).some(me=>!Number.isNaN(Number(me)))?K2(n.errors,{[q]:he},q):Nt(n.errors,q,he):On(n.errors,q)}n.errors={...n.errors}}else n.errors=U;return U},z=async({name:M,eventType:U})=>{if(t.validate){const q=await t.validate({formValues:s,formState:n,name:M,eventType:U});if(dn(q))for(const he in q){const me=q[he];me&&Et(`${db}.${he}`,{message:Kn(me.message)?me.message:"",type:me.type||qr.validate})}else Kn(q)||!q?Et(db,{message:q||"",type:qr.validate}):Ke(db);return q}return!0},W=async({fields:M,onlyCheckValid:U,name:q,eventType:he,context:me={valid:!0,runRootValidation:!1}})=>{if(t.validate&&(me.runRootValidation=!0,!await z({name:q,eventType:he})&&(me.valid=!1,U)))return me.valid;for(const Se in M){const ke=M[Se];if(ke){const{_f:_e,...Ae}=ke;if(_e){const ut=l.array.has(_e.name),Zt=ke._f&&PG(ke._f),on=v.validatingFields||v.isValidating||S.validatingFields||S.isValidating;Zt&&on&&A([_e.name],!0);const an=await iE(ke,l.disabled,s,$,e.shouldUseNativeValidation&&!U,ut);if(Zt&&on&&A([_e.name]),an[_e.name]&&(me.valid=!1,U)||(!U&&($e(an,_e.name)?ut?K2(n.errors,an,_e.name):Nt(n.errors,_e.name,an[_e.name]):On(n.errors,_e.name)),t.shouldUseNativeValidation&&an[_e.name]))break}!Gn(Ae)&&await W({context:me,onlyCheckValid:U,fields:Ae,name:Se,eventType:he})}}return me.valid},ce=()=>{for(const M of l.unMount){const U=$e(i,M);U&&(U._f.refs?U._f.refs.every(q=>!ub(q)):!ub(U._f.ref))&&At(M)}l.unMount=new Set},oe=(M,U)=>(M&&U&&Nt(s,M,U),!Ss(o.mount?s:r,r)),ae=(M,U,q)=>_G(M,l,{...o.mount?s:Ht(U)?r:Kn(M)?{[M]:U}:U},q,U),D=M=>TD($e(o.mount?s:r,M,e.shouldUnregister?$e(r,M,[]):[])),j=(M,U,q={},he=!1,me=!1)=>{const Se=$e(i,M);let ke=U;if(Se){const _e=Se._f;_e&&(!_e.disabled&&Nt(s,M,MD(U,_e)),ke=Sm(_e.ref)&&Wn(U)?"":U,QD(_e.ref)?[..._e.ref.options].forEach(Ae=>Ae.selected=ke.includes(Ae.value)):_e.refs?Sh(_e.ref)?_e.refs.forEach(Ae=>{(!Ae.defaultChecked||!Ae.disabled)&&(Array.isArray(ke)?Ae.checked=!!ke.find(ut=>ut===Ae.value):Ae.checked=ke===Ae.value||!!ke)}):_e.refs.forEach(Ae=>Ae.checked=Ae.value===ke):v1(_e.ref)?_e.ref.value="":(_e.ref.value=ke,!_e.ref.type&&!me&&k.state.next({name:M,values:he?s:mn(s)})))}(q.shouldDirty||q.shouldTouch)&&K(M,ke,q.shouldTouch,q.shouldDirty,!me),q.shouldValidate&&xe(M,{delayError:q.delayError})},I=(M,U,q,he=!1,me=!1)=>{for(const Se in U){if(!U.hasOwnProperty(Se))return;const ke=U[Se],_e=M+"."+Se,Ae=$e(i,_e);(l.array.has(M)||dn(ke)||Ae&&!Ae._f)&&!Oa(ke)?I(_e,ke,q,he,me):j(_e,ke,q,he,me)}},N=(M,U,q,he,me=!1)=>{const Se=$e(i,M),ke=l.array.has(M),_e=he?U:mn(U),Ae=$e(s,M),ut=Ss(Ae,_e);if(ut||Nt(s,M,_e),ke)k.array.next({name:M,values:he?s:mn(s)}),(v.isDirty||v.dirtyFields||S.isDirty||S.dirtyFields)&&q.shouldDirty&&(R(),me||k.state.next({name:M,dirtyFields:n.dirtyFields,isDirty:oe(M,_e)}));else{const Zt=Array.isArray(_e)&&!_e.length||Gn(_e);!Se||Se._f||Wn(_e)||Zt?j(M,_e,q,he,me):I(M,_e,q,he,me)}if(!ut&&!me){const Zt=cb(M,l),on=he?s:mn(s);k.state.next({...Zt&&n,name:o.mount||Zt?M:void 0,values:on})}},V=(M,U,q={})=>N(M,U,q,!1),ne=(M,U={})=>{const q=$r(M)?M(s):M;if(!Ss(s,q)){s={...s,...q};const he=ED(q);for(const me of l.mount)me in he&&N(me,he[me],U,!0,!0);k.state.next({...n,name:void 0,type:void 0,...h?{values:s}:{}}),U.shouldValidate&&Q()}},ie=async M=>{o.mount=!0;const U=M.target;let q=U.name,he=!0;const me=$e(i,q),Se=ke=>{he=Number.isNaN(ke)||Oa(ke)&&isNaN(ke.getTime())||Ss(ke,$e(s,q,ke))};if(me){let ke,_e;const Ae=U.type?sE(me._f):vG(M),ut=M.type===Nc.BLUR||M.type===Nc.FOCUS_OUT,Zt=!jG(me._f)&&!t.validate&&!e.resolver&&!$e(n.errors,q)&&!me._f.deps,on=Zt||NG(ut,$e(n.touchedFields,q),n.isSubmitted,O,p),an=cb(q,l,ut);if(Nt(s,q,Ae),ut){if(!U||!U.readOnly){me._f.onBlur&&me._f.onBlur(M);const qt=u[q];qt&&qt(0)}}else me._f.onChange&&me._f.onChange(M);const Xe=K(q,Ae,ut),Ct=!Gn(Xe)||an;if(!ut&&k.state.next({name:q,type:M.type,...h?{values:mn(s)}:{}}),on)return(!Zt||!n.isValid)&&(v.isValid||S.isValid)&&(e.mode==="onBlur"?ut&&Q():ut||Q()),Ct&&k.state.next({name:q,...an?{}:Xe});if(!e.resolver&&t.validate&&await z({name:q,eventType:M.type}),!ut&&an&&k.state.next({...n}),e.resolver){const{errors:qt}=await H([q]);if(A([q]),Se(Ae),!he){!Gn(Xe)&&k.state.next(Xe);return}const ln=aE(n.errors,i,q),yi=aE(qt,i,ln.name||q);ke=yi.error,q=yi.name,_e=Gn(qt)}else A([q],!0),ke=(await iE(me,l.disabled,s,$,e.shouldUseNativeValidation))[q],A([q]),Se(Ae),he&&(ke?_e=!1:(v.isValid||S.isValid)&&(_e=await W({fields:i,onlyCheckValid:!0,name:q,eventType:M.type})));he&&(me._f.deps&&(!Array.isArray(me._f.deps)||me._f.deps.length>0)&&xe(me._f.deps),se(q,_e,ke,Xe))}},ye=(M,U)=>{if($e(n.errors,U)&&M.focus)return M.focus(),1},xe=async(M,U={})=>{let q,he;const me=qg(M);if(e.resolver){const Se=await pe(Ht(M)?M:me);q=Gn(Se),he=M?!me.some(ke=>$e(Se,ke)):q}else M?(he=(await Promise.all(me.map(async Se=>{const ke=$e(i,Se);return await W({fields:ke&&ke._f?{[Se]:ke}:ke,eventType:Nc.TRIGGER})}))).every(Boolean),!(!he&&!n.isValid)&&Q()):he=q=await W({fields:i,name:M,eventType:Nc.TRIGGER});if(U.delayError&&e.delayError&&Kn(M)){const Se=$e(n.errors,M);Se?(On(n.errors,M),u[M]=T(M,()=>X(M,Se)),u[M](e.delayError)):(clearTimeout(f[M]),delete u[M])}return k.state.next({...!Kn(M)||(v.isValid||S.isValid)&&q!==n.isValid?{}:{name:M},...e.resolver||!M?{isValid:q}:{},errors:n.errors}),U.shouldFocus&&!he&&yf(i,ye,M?me:l.mount),he},Le=(M,U)=>{let q={...o.mount?s:r};return U&&(q=RD(U.dirtyFields?n.dirtyFields:n.touchedFields,q)),Ht(M)?q:Kn(M)?$e(q,M):M.map(he=>$e(q,he))},Ue=(M,U)=>({invalid:!!$e((U||n).errors,M),isDirty:!!$e((U||n).dirtyFields,M),error:$e((U||n).errors,M),isValidating:!!$e(n.validatingFields,M),isTouched:!!$e((U||n).touchedFields,M)}),Ke=M=>{const U=M?qg(M):void 0;U?.forEach(q=>On(n.errors,q)),U?U.forEach(q=>{k.state.next({name:q,errors:n.errors})}):k.state.next({errors:{}})},Et=(M,U,q)=>{const he=($e(i,M,{_f:{}})._f||{}).ref,me=$e(n.errors,M)||{},{ref:Se,message:ke,type:_e,...Ae}=me;Nt(n.errors,M,{...Ae,...U,ref:he}),k.state.next({name:M,errors:n.errors,isValid:!1}),q&&q.shouldFocus&&he&&he.focus&&he.focus()},ht=(M,U)=>{if($r(M)){h++;const{unsubscribe:q}=k.state.subscribe({next:me=>"values"in me&&M(me.values||ae(void 0,U),me)});let he=!1;return{unsubscribe:()=>{he||(he=!0,h--,q())}}}return ae(M,U,!0)},ti=M=>{var U;const q=!!(!((U=M.formState)===null||U===void 0)&&U.values);q&&h++;const{unsubscribe:he}=k.state.subscribe({next:Se=>{if(DG(M.name,Se.name,M.exact)&&MG(Se,M.formState||v,qs,M.reRenderRoot)){const ke={...s};M.callback({values:ke,...n,...Se,defaultValues:r})}}});if(!q)return he;let me=!1;return()=>{me||(me=!0,h--,he())}},Oi=M=>(o.mount=!0,S={...S,...M.formState},ti({...M,formState:{...y,...M.formState}})),At=(M,U={})=>{for(const q of M?qg(M):l.mount)l.mount.delete(q),l.array.delete(q),U.keepValue||(On(i,q),On(s,q)),!U.keepError&&On(n.errors,q),!U.keepDirty&&On(n.dirtyFields,q),!U.keepTouched&&On(n.touchedFields,q),!U.keepIsValidating&&On(n.validatingFields,q),!e.shouldUnregister&&!U.keepDefaultValue&&On(r,q);k.state.next({values:mn(s)}),k.state.next({...n,...U.keepDirty?{isDirty:oe()}:{}}),!U.keepIsValid&&Q()},pr=({disabled:M,name:U})=>{if(bs(M)&&o.mount||M||l.disabled.has(U)){const me=l.disabled.has(U)!==!!M;M?l.disabled.add(U):l.disabled.delete(U),me&&o.mount&&!o.action&&Q()}},zn=(M,U={})=>{let q=$e(i,M);const he=bs(U.disabled)||bs(e.disabled),me=!l.registerName.has(M)&&q&&q._f&&!q._f.mount;return Nt(i,M,{...q||{},_f:{...q&&q._f?q._f:{ref:{name:M}},name:M,mount:!0,...U}}),l.mount.add(M),q&&!me?pr({disabled:bs(U.disabled)?U.disabled:e.disabled,name:M}):Y(M,!0,U.value),{...he?{disabled:U.disabled||e.disabled}:{},...e.progressive?{required:!!U.required,min:Hd(U.min),max:Hd(U.max),minLength:Hd(U.minLength),maxLength:Hd(U.maxLength),pattern:Hd(U.pattern)}:{},name:M,onChange:ie,onBlur:ie,ref:Se=>{if(Se){l.registerName.add(M),zn(M,U),l.registerName.delete(M),q=$e(i,M);const ke=Ht(Se.value)&&Se.querySelectorAll&&Se.querySelectorAll("input,select,textarea")[0]||Se,_e=RG(ke),Ae=q._f.refs||[];if(_e?Ae.find(ut=>ut===ke):ke===q._f.ref)return;Nt(i,M,{_f:{...q._f,..._e?{refs:[...Ae.filter(ub),ke,...Array.isArray($e(r,M))?[{}]:[]],ref:{type:ke.type,name:M}}:{ref:ke}}}),Y(M,!1,void 0,ke)}else q=$e(i,M,{}),q._f&&(q._f.mount=!1),(e.shouldUnregister||U.shouldUnregister)&&!(bG(l.array,M)&&o.action)&&l.unMount.add(M)}}},gr=()=>e.shouldFocusError&&!e.shouldUseNativeValidation&&yf(i,ye,l.mount),Ri=M=>{bs(M)&&(k.state.next({disabled:M}),yf(i,(U,q)=>{const he=$e(i,q);he&&(U.disabled=he._f.disabled||M,Array.isArray(he._f.refs)&&he._f.refs.forEach(me=>{me.disabled=he._f.disabled||M}))},0,!1))},sn=(M,U)=>async q=>{let he;q&&(q.preventDefault&&q.preventDefault(),q.persist&&q.persist());let me=mn(s);if(k.state.next({isSubmitting:!0}),e.resolver){const{errors:Se,values:ke}=await H();A(),n.errors=Se,me=mn(ke)}else await W({fields:i,eventType:Nc.SUBMIT});if(l.disabled.size)for(const Se of l.disabled)On(me,Se);if(On(n.errors,CD),Gn(n.errors)){k.state.next({errors:{}});try{await M(me,q)}catch(Se){he=Se}}else U&&await U({...n.errors},q),gr(),setTimeout(gr);if(k.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Gn(n.errors)&&!he,submitCount:n.submitCount+1,errors:n.errors}),he)throw he},Yi=(M,U={})=>{$e(i,M)&&(Ht(U.defaultValue)?V(M,mn($e(r,M))):(V(M,U.defaultValue),Nt(r,M,mn(U.defaultValue))),U.keepTouched||On(n.touchedFields,M),U.keepDirty||(On(n.dirtyFields,M),n.isDirty=U.defaultValue?oe(M,mn($e(r,M))):oe()),U.keepError||(On(n.errors,M),v.isValid&&Q()),k.state.next({...n}))},xn=(M,U={})=>{const q=M?mn(M):r,he=mn(q),me=Gn(M),Se=he,ke=i;if(U.keepDefaultValues||(r=q),!U.keepValues){if(U.keepDirtyValues){const _e=new Set([...l.mount,...Object.keys(pl(r,s,void 0,ke))]);for(const Ae of Array.from(_e)){const ut=$e(n.dirtyFields,Ae),Zt=$e(s,Ae),on=$e(Se,Ae);ut&&!Ht(Zt)?Nt(Se,Ae,Zt):!ut&&!Ht(on)&&V(Ae,on)}}else{if(IO&&Ht(M))for(const _e of l.mount){const Ae=$e(i,_e);if(Ae&&Ae._f){const ut=Array.isArray(Ae._f.refs)?Ae._f.refs[0]:Ae._f.ref;if(Sm(ut)){const Zt=ut.closest("form");if(Zt){Zt.reset();break}}}}if(U.keepFieldsRef)for(const _e of l.mount)V(_e,$e(Se,_e));else i={}}if(e.shouldUnregister){if(s=U.keepDefaultValues?mn(r):{},U.keepFieldsRef)for(const _e of l.mount)Nt(s,_e,$e(Se,_e))}else s=mn(Se);k.array.next({values:{...Se}}),k.state.next({name:void 0,type:void 0,values:{...Se}})}l={mount:U.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!v.isValid||!!U.keepIsValid||!!U.keepDirtyValues||!e.shouldUnregister&&!Gn(Se),o.watch=!!e.shouldUnregister,o.keepIsValid=!!U.keepIsValid,o.action=!1,U.keepErrors||(n.errors={}),k.state.next({submitCount:U.keepSubmitCount?n.submitCount:0,isDirty:me?!1:U.keepDirty?n.isDirty:U.keepValues?oe():!!(U.keepDefaultValues&&!Ss(M,r)),isSubmitted:U.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:me?{}:U.keepDirtyValues?U.keepDefaultValues&&s?pl(r,s,void 0,ke):n.dirtyFields:U.keepDefaultValues&&M?pl(r,M,void 0,ke):U.keepDirty?n.dirtyFields:{},touchedFields:U.keepTouched?n.touchedFields:{},errors:U.keepErrors?n.errors:{},isSubmitSuccessful:U.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:r})},ni=(M,U)=>xn($r(M)?M(s):M,{...e.resetOptions,...U}),mr=(M,U={})=>{const q=$e(i,M),he=q&&q._f;if(he){const me=he.refs?he.refs[0]:he.ref;me.focus&&setTimeout(()=>{me.focus(),U.shouldSelect&&$r(me.select)&&me.select()})}},qs=M=>{const{name:U,type:q,values:he,...me}=M;n={...n,...me}},ii={control:{register:zn,unregister:At,getFieldState:Ue,handleSubmit:sn,setError:Et,_subscribe:ti,_runSchema:H,_updateIsValidating:A,_focusError:gr,_getWatch:ae,_getDirty:oe,_setValid:Q,_setFieldArray:P,_setDisabledField:pr,_setErrors:te,_getFieldArray:D,_reset:xn,_resetDefaultValues:()=>$r(e.defaultValues)&&e.defaultValues().then(M=>{ni(M,e.resetOptions),k.state.next({isLoading:!1})}),_removeUnmounted:ce,_disableForm:Ri,_subjects:k,_proxyFormState:v,get _fields(){return i},get _formValues(){return s},get _state(){return o},set _state(M){o=M},get _defaultValues(){return r},get _names(){return l},set _names(M){l=M},get _formState(){return n},get _options(){return e},set _options(M){e={...e,...M},p=gg(e.mode),O=gg(e.reValidateMode)}},subscribe:Oi,trigger:xe,register:zn,handleSubmit:sn,watch:ht,setValue:V,setValues:ne,getValues:Le,reset:ni,resetField:Yi,resetDefaultValues:(M,U={})=>{if(r=mn(M),!U.keepDirty){const q=pl(r,s,void 0,i);n.dirtyFields=q,n.isDirty=!Gn(q)}U.keepIsValid||Q(),k.state.next({...n,defaultValues:r})},clearErrors:Ke,unregister:At,setError:Et,setFocus:mr,getFieldState:Ue};return{...ii,formControl:ii}}function x1(t={}){const e=be.useRef(void 0),n=be.useRef(void 0),i=be.useRef(t.formControl),[r,s]=be.useState(()=>({...mn(DD),isLoading:$r(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1,defaultValues:$r(t.defaultValues)?void 0:t.defaultValues}));if(!e.current||t.formControl&&i.current!==t.formControl)if(i.current=t.formControl,t.formControl)e.current={...t.formControl,formState:r},t.defaultValues&&!$r(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...u}=ZG(t);e.current={...u,formState:r}}const o=e.current.control;return o._options=t,CG(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>s({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return s(u=>({...u,isReady:!0})),o._formState.isReady=!0,l},[o]),be.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),be.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),be.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),be.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),be.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==r.isDirty&&o._subjects.state.next({isDirty:l})}},[o,r.isDirty]),be.useEffect(()=>{var l;t.values&&!Ss(t.values,n.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=t.values,s(u=>({...u}))):o._resetDefaultValues()},[o,t.values]),be.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),e.current.formState=be.useMemo(()=>kG(r,o),[o,r]),e.current}const lE=(t,e,n)=>{if(t&&"reportValidity"in t){const i=$e(n,e);t.setCustomValidity(i&&i.message||""),t.reportValidity()}},HS=(t,e)=>{for(const n in e.fields){const i=e.fields[n];i&&i.ref&&"reportValidity"in i.ref?lE(i.ref,n,t):i&&i.refs&&i.refs.forEach(r=>lE(r,n,t))}},cE=(t,e)=>{e.shouldUseNativeValidation&&HS(t,e);const n={};for(const i in t){const r=$e(e.fields,i),s=Object.assign(t[i]||{},{ref:r&&r.ref});if(IG(e.names||Object.keys(t),i)){const o=Object.assign({},$e(n,i));Nt(o,"root",s),Nt(n,i,o)}else Nt(n,i,s)}return n},IG=(t,e)=>{const n=uE(e).replace(/[.*+?^${}()|\\]/g,"\\$&");return t.some(i=>uE(i).match(`^${n}\\.\\d+`))};function uE(t){return t.replace(/[\[\]]/g,"")}var dE;function ge(t,e,n){function i(l,u){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:u,constr:o,traits:new Set},enumerable:!1}),l._zod.traits.has(t))return;l._zod.traits.add(t),e(l,u);const f=o.prototype,h=Object.keys(f);for(let p=0;pn?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}class ru extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ND extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(dE=globalThis).__zod_globalConfig??(dE.__zod_globalConfig={});const w1=globalThis.__zod_globalConfig;function Ml(t){return w1}function zD(t){const e=Object.values(t).filter(i=>typeof i=="number");return Object.entries(t).filter(([i,r])=>e.indexOf(+i)===-1).map(([i,r])=>r)}function WS(t,e){return typeof e=="bigint"?e.toString():e}function k1(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function C1(t){return t==null}function _1(t){const e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}const fE=Symbol("evaluating");function Lt(t,e,n){let i;Object.defineProperty(t,e,{get(){if(i!==fE)return i===void 0&&(i=fE,i=n()),i},set(r){Object.defineProperty(t,e,{value:r})},configurable:!0})}function Wl(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ia(...t){const e={};for(const n of t){const i=Object.getOwnPropertyDescriptors(n);Object.assign(e,i)}return Object.defineProperties({},e)}function hE(t){return JSON.stringify(t)}function XG(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const LD="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function wm(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const VG=k1(()=>{if(w1.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Mf(t){if(wm(t)===!1)return!1;const e=t.constructor;if(e===void 0||typeof e!="function")return!0;const n=e.prototype;return!(wm(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ZD(t){return Mf(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}const BG=new Set(["string","number","symbol"]);function VO(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xa(t,e,n){const i=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(i._zod.parent=t),i}function Ge(t){const e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function UG(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function qG(t,e){const n=t._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=Ia(t._zod.def,{get shape(){const o={};for(const l in e){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);e[l]&&(o[l]=n.shape[l])}return Wl(this,"shape",o),o},checks:[]});return Xa(t,s)}function YG(t,e){const n=t._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=Ia(t._zod.def,{get shape(){const o={...t._zod.def.shape};for(const l in e){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);e[l]&&delete o[l]}return Wl(this,"shape",o),o},checks:[]});return Xa(t,s)}function FG(t,e){if(!Mf(e))throw new Error("Invalid input to extend: expected a plain object");const n=t._zod.def.checks;if(n&&n.length>0){const s=t._zod.def.shape;for(const o in e)if(Object.getOwnPropertyDescriptor(s,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=Ia(t._zod.def,{get shape(){const s={...t._zod.def.shape,...e};return Wl(this,"shape",s),s}});return Xa(t,r)}function GG(t,e){if(!Mf(e))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ia(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e};return Wl(this,"shape",i),i}});return Xa(t,n)}function HG(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Ia(t._zod.def,{get shape(){const i={...t._zod.def.shape,...e._zod.def.shape};return Wl(this,"shape",i),i},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Xa(t,n)}function WG(t,e,n){const r=e._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=Ia(e._zod.def,{get shape(){const l=e._zod.def.shape,u={...l};if(n)for(const f in n){if(!(f in l))throw new Error(`Unrecognized key: "${f}"`);n[f]&&(u[f]=t?new t({type:"optional",innerType:l[f]}):l[f])}else for(const f in l)u[f]=t?new t({type:"optional",innerType:l[f]}):l[f];return Wl(this,"shape",u),u},checks:[]});return Xa(e,o)}function KG(t,e,n){const i=Ia(e._zod.def,{get shape(){const r=e._zod.def.shape,s={...r};if(n)for(const o in n){if(!(o in s))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=new t({type:"nonoptional",innerType:r[o]}))}else for(const o in r)s[o]=new t({type:"nonoptional",innerType:r[o]});return Wl(this,"shape",s),s}});return Xa(e,i)}function Hc(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n{var i;return(i=n).path??(i.path=[]),n.path.unshift(t),n})}function mg(t){return typeof t=="string"?t:t?.message}function Dl(t,e,n){const i=t.message?t.message:mg(t.inst?._zod.def?.error?.(t))??mg(e?.error?.(t))??mg(n.customError?.(t))??mg(n.localeError?.(t))??"Invalid input",{inst:r,continue:s,input:o,...l}=t;return l.path??(l.path=[]),l.message=i,e?.reportInput&&(l.input=o),l}function $1(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Df(...t){const[e,n,i]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:i}:{...e}}const XD=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,WS,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},T1=ge("$ZodError",XD),BO=ge("$ZodError",XD,{Parent:Error});function eH(t,e=n=>n.message){const n={},i=[];for(const r of t.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):i.push(e(r));return{formErrors:i,fieldErrors:n}}function tH(t,e=n=>n.message){const n={_errors:[]},i=(r,s=[])=>{for(const o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(l=>i({issues:l},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{const l=[...s,...o.path];if(l.length===0)n._errors.push(e(o));else{let u=n,f=0;for(;f(e,n,i,r)=>{const s=i?{...i,async:!1}:{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new ru;if(o.issues.length){const l=new(r?.Err??t)(o.issues.map(u=>Dl(u,s,Ml())));throw LD(l,r?.callee),l}return o.value},nH=UO(BO),qO=t=>async(e,n,i,r)=>{const s=i?{...i,async:!0}:{async:!0};let o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){const l=new(r?.Err??t)(o.issues.map(u=>Dl(u,s,Ml())));throw LD(l,r?.callee),l}return o.value},iH=qO(BO),YO=t=>(e,n,i)=>{const r=i?{...i,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new ru;return s.issues.length?{success:!1,error:new(t??T1)(s.issues.map(o=>Dl(o,r,Ml())))}:{success:!0,data:s.value}},rH=YO(BO),FO=t=>async(e,n,i)=>{const r=i?{...i,async:!0}:{async:!0};let s=e._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>Dl(o,r,Ml())))}:{success:!0,data:s.value}},sH=FO(BO),oH=t=>(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return UO(t)(e,n,r)},aH=t=>(e,n,i)=>UO(t)(e,n,i),lH=t=>async(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return qO(t)(e,n,r)},cH=t=>async(e,n,i)=>qO(t)(e,n,i),uH=t=>(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return YO(t)(e,n,r)},dH=t=>(e,n,i)=>YO(t)(e,n,i),fH=t=>async(e,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return FO(t)(e,n,r)},hH=t=>async(e,n,i)=>FO(t)(e,n,i),pH=/^[cC][0-9a-z]{6,}$/,gH=/^[0-9a-z]+$/,mH=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,OH=/^[0-9a-vA-V]{20}$/,yH=/^[A-Za-z0-9]{27}$/,vH=/^[a-zA-Z0-9_-]{21}$/,bH=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,SH=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pE=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,xH=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,wH="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function kH(){return new RegExp(wH,"u")}const CH=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,_H=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,$H=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,TH=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,EH=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,VD=/^[A-Za-z0-9_-]*$/,RH=/^https?$/,QH=/^\+[1-9]\d{6,14}$/,BD="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",AH=new RegExp(`^${BD}$`);function UD(t){const e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function PH(t){return new RegExp(`^${UD(t)}$`)}function jH(t){const e=UD({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${e}(?:${n.join("|")})`;return new RegExp(`^${BD}T(?:${i})$`)}const MH=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},DH=/^(?:true|false)$/i,NH=/^[^A-Z]*$/,zH=/^[^a-z]*$/,Xs=ge("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),LH=ge("$ZodCheckMaxLength",(t,e)=>{var n;Xs.init(t,e),(n=t._zod.def).when??(n.when=i=>{const r=i.value;return!C1(r)&&r.length!==void 0}),t._zod.onattach.push(i=>{const r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum{const r=i.value;if(r.length<=e.maximum)return;const o=$1(r);i.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:r,inst:t,continue:!e.abort})}}),ZH=ge("$ZodCheckMinLength",(t,e)=>{var n;Xs.init(t,e),(n=t._zod.def).when??(n.when=i=>{const r=i.value;return!C1(r)&&r.length!==void 0}),t._zod.onattach.push(i=>{const r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>r&&(i._zod.bag.minimum=e.minimum)}),t._zod.check=i=>{const r=i.value;if(r.length>=e.minimum)return;const o=$1(r);i.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:r,inst:t,continue:!e.abort})}}),IH=ge("$ZodCheckLengthEquals",(t,e)=>{var n;Xs.init(t,e),(n=t._zod.def).when??(n.when=i=>{const r=i.value;return!C1(r)&&r.length!==void 0}),t._zod.onattach.push(i=>{const r=i._zod.bag;r.minimum=e.length,r.maximum=e.length,r.length=e.length}),t._zod.check=i=>{const r=i.value,s=r.length;if(s===e.length)return;const o=$1(r),l=s>e.length;i.issues.push({origin:o,...l?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:i.value,inst:t,continue:!e.abort})}}),GO=ge("$ZodCheckStringFormat",(t,e)=>{var n,i;Xs.init(t,e),t._zod.onattach.push(r=>{const s=r._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:e.format,input:r.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(i=t._zod).check??(i.check=()=>{})}),XH=ge("$ZodCheckRegex",(t,e)=>{GO.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),VH=ge("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=NH),GO.init(t,e)}),BH=ge("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=zH),GO.init(t,e)}),UH=ge("$ZodCheckIncludes",(t,e)=>{Xs.init(t,e);const n=VO(e.includes),i=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=i,t._zod.onattach.push(r=>{const s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(i)}),t._zod.check=r=>{r.value.includes(e.includes,e.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:r.value,inst:t,continue:!e.abort})}}),qH=ge("$ZodCheckStartsWith",(t,e)=>{Xs.init(t,e);const n=new RegExp(`^${VO(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),t._zod.check=i=>{i.value.startsWith(e.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:i.value,inst:t,continue:!e.abort})}}),YH=ge("$ZodCheckEndsWith",(t,e)=>{Xs.init(t,e);const n=new RegExp(`.*${VO(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),t._zod.check=i=>{i.value.endsWith(e.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:i.value,inst:t,continue:!e.abort})}}),FH=ge("$ZodCheckOverwrite",(t,e)=>{Xs.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}});let GH=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}const i=e.split(` +`).filter(o=>o),r=Math.min(...i.map(o=>o.length-o.trimStart().length)),s=i.map(o=>o.slice(r)).map(o=>" ".repeat(this.indent*2)+o);for(const o of s)this.content.push(o)}compile(){const e=Function,n=this?.args,r=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...n,r.join(` +`))}};const HH={major:4,minor:4,patch:3},$n=ge("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=HH;const i=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&i.unshift(t);for(const r of i)for(const s of r._zod.onattach)s(t);if(i.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const r=(o,l,u)=>{let f=Hc(o),h;for(const p of l){if(p._zod.def.when){if(JG(o)||!p._zod.def.when(o))continue}else if(f)continue;const O=o.issues.length,y=p._zod.check(o);if(y instanceof Promise&&u?.async===!1)throw new ru;if(h||y instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await y,o.issues.length!==O&&(f||(f=Hc(o,O)))});else{if(o.issues.length===O)continue;f||(f=Hc(o,O))}}return h?h.then(()=>o):o},s=(o,l,u)=>{if(Hc(o))return o.aborted=!0,o;const f=r(l,i,u);if(f instanceof Promise){if(u.async===!1)throw new ru;return f.then(h=>t._zod.parse(h,u))}return t._zod.parse(f,u)};t._zod.run=(o,l)=>{if(l.skipChecks)return t._zod.parse(o,l);if(l.direction==="backward"){const f=t._zod.parse({value:o.value,issues:[]},{...l,skipChecks:!0});return f instanceof Promise?f.then(h=>s(h,o,l)):s(f,o,l)}const u=t._zod.parse(o,l);if(u instanceof Promise){if(l.async===!1)throw new ru;return u.then(f=>r(f,i,l))}return r(u,i,l)}}Lt(t,"~standard",()=>({validate:r=>{try{const s=rH(t,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return sH(t,r).then(o=>o.success?{value:o.data}:{issues:o.error?.issues})}},vendor:"zod",version:1}))}),E1=ge("$ZodString",(t,e)=>{$n.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??MH(t._zod.bag),t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),en=ge("$ZodStringFormat",(t,e)=>{GO.init(t,e),E1.init(t,e)}),WH=ge("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=SH),en.init(t,e)}),KH=ge("$ZodUUID",(t,e)=>{if(e.version){const i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(i===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=pE(i))}else e.pattern??(e.pattern=pE());en.init(t,e)}),JH=ge("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=xH),en.init(t,e)}),eW=ge("$ZodURL",(t,e)=>{en.init(t,e),t._zod.check=n=>{try{const i=n.value.trim();if(!e.normalize&&e.protocol?.source===RH.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:t,continue:!e.abort});return}const r=new URL(i);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=r.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),tW=ge("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=kH()),en.init(t,e)}),nW=ge("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=vH),en.init(t,e)}),iW=ge("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=pH),en.init(t,e)}),rW=ge("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=gH),en.init(t,e)}),sW=ge("$ZodULID",(t,e)=>{e.pattern??(e.pattern=mH),en.init(t,e)}),oW=ge("$ZodXID",(t,e)=>{e.pattern??(e.pattern=OH),en.init(t,e)}),aW=ge("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=yH),en.init(t,e)}),lW=ge("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=jH(e)),en.init(t,e)}),cW=ge("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=AH),en.init(t,e)}),uW=ge("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=PH(e)),en.init(t,e)}),dW=ge("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=bH),en.init(t,e)}),fW=ge("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=CH),en.init(t,e),t._zod.bag.format="ipv4"}),hW=ge("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=_H),en.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),pW=ge("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=$H),en.init(t,e)}),gW=ge("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=TH),en.init(t,e),t._zod.check=n=>{const i=n.value.split("/");try{if(i.length!==2)throw new Error;const[r,s]=i;if(!s)throw new Error;const o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function qD(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const mW=ge("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=EH),en.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{qD(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function OW(t){if(!VD.test(t))return!1;const e=t.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return qD(n)}const yW=ge("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=VD),en.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{OW(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),vW=ge("$ZodE164",(t,e)=>{e.pattern??(e.pattern=QH),en.init(t,e)});function bW(t,e=null){try{const n=t.split(".");if(n.length!==3)return!1;const[i]=n;if(!i)return!1;const r=JSON.parse(atob(i));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||e&&(!("alg"in r)||r.alg!==e))}catch{return!1}}const SW=ge("$ZodJWT",(t,e)=>{en.init(t,e),t._zod.check=n=>{bW(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),xW=ge("$ZodBoolean",(t,e)=>{$n.init(t,e),t._zod.pattern=DH,t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:t}),n}}),wW=ge("$ZodUnknown",(t,e)=>{$n.init(t,e),t._zod.parse=n=>n}),kW=ge("$ZodNever",(t,e)=>{$n.init(t,e),t._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function gE(t,e,n){t.issues.length&&e.issues.push(...ID(n,t.issues)),e.value[n]=t.value}const CW=ge("$ZodArray",(t,e)=>{$n.init(t,e),t._zod.parse=(n,i)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:t}),n;n.value=Array(r.length);const s=[];for(let o=0;ogE(f,n,o))):gE(u,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function km(t,e,n,i,r,s){const o=n in i;if(t.issues.length){if(r&&s&&!o)return;e.issues.push(...ID(n,t.issues))}if(!o&&!r){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}t.value===void 0?o&&(e.value[n]=void 0):e.value[n]=t.value}function YD(t){const e=Object.keys(t.shape);for(const i of e)if(!t.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const n=UG(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function FD(t,e,n,i,r,s){const o=[],l=r.keySet,u=r.catchall._zod,f=u.def.type,h=u.optin==="optional",p=u.optout==="optional";for(const O in e){if(O==="__proto__"||l.has(O))continue;if(f==="never"){o.push(O);continue}const y=u.run({value:e[O],issues:[]},i);y instanceof Promise?t.push(y.then(v=>km(v,n,O,e,h,p))):km(y,n,O,e,h,p)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}const _W=ge("$ZodObject",(t,e)=>{if($n.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){const l=e.shape;Object.defineProperty(e,"shape",{get:()=>{const u={...l};return Object.defineProperty(e,"shape",{value:u}),u}})}const i=k1(()=>YD(e));Lt(t._zod,"propValues",()=>{const l=e.shape,u={};for(const f in l){const h=l[f]._zod;if(h.values){u[f]??(u[f]=new Set);for(const p of h.values)u[f].add(p)}}return u});const r=wm,s=e.catchall;let o;t._zod.parse=(l,u)=>{o??(o=i.value);const f=l.value;if(!r(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:t}),l;l.value={};const h=[],p=o.shape;for(const O of o.keys){const y=p[O],v=y._zod.optin==="optional",S=y._zod.optout==="optional",k=y._zod.run({value:f[O],issues:[]},u);k instanceof Promise?h.push(k.then(C=>km(C,l,O,f,v,S))):km(k,l,O,f,v,S)}return s?FD(h,f,l,u,i.value,t):h.length?Promise.all(h).then(()=>l):l}}),$W=ge("$ZodObjectJIT",(t,e)=>{_W.init(t,e);const n=t._zod.parse,i=k1(()=>YD(e)),r=O=>{const y=new GH(["shape","payload","ctx"]),v=i.value,S=T=>{const Q=hE(T);return`shape[${Q}]._zod.run({ value: input[${Q}], issues: [] }, ctx)`};y.write("const input = payload.value;");const k=Object.create(null);let C=0;for(const T of v.keys)k[T]=`key_${C++}`;y.write("const newResult = {};");for(const T of v.keys){const Q=k[T],A=hE(T),R=O[T],P=R?._zod?.optin==="optional",X=R?._zod?.optout==="optional";y.write(`const ${Q} = ${S(T)};`),P&&X?y.write(` + if (${Q}.issues.length) { + if (${A} in input) { + payload.issues = payload.issues.concat(${Q}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${A}, ...iss.path] : [${A}] + }))); + } + } + + if (${Q}.value === undefined) { + if (${A} in input) { + newResult[${A}] = undefined; + } + } else { + newResult[${A}] = ${Q}.value; + } + + `):P?y.write(` + if (${Q}.issues.length) { + payload.issues = payload.issues.concat(${Q}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${A}, ...iss.path] : [${A}] + }))); + } + + if (${Q}.value === undefined) { + if (${A} in input) { + newResult[${A}] = undefined; + } + } else { + newResult[${A}] = ${Q}.value; + } + + `):y.write(` + const ${Q}_present = ${A} in input; + if (${Q}.issues.length) { + payload.issues = payload.issues.concat(${Q}.issues.map(iss => ({ + ...iss, + path: iss.path ? [${A}, ...iss.path] : [${A}] + }))); + } + if (!${Q}_present && !${Q}.issues.length) { + payload.issues.push({ + code: "invalid_type", + expected: "nonoptional", + input: undefined, + path: [${A}] + }); + } + + if (${Q}_present) { + if (${Q}.value === undefined) { + newResult[${A}] = undefined; + } else { + newResult[${A}] = ${Q}.value; + } + } + + `)}y.write("payload.value = newResult;"),y.write("return payload;");const $=y.compile();return(T,Q)=>$(O,T,Q)};let s;const o=wm,l=!w1.jitless,f=l&&VG.value,h=e.catchall;let p;t._zod.parse=(O,y)=>{p??(p=i.value);const v=O.value;return o(v)?l&&f&&y?.async===!1&&y.jitless!==!0?(s||(s=r(e.shape)),O=s(O,y),h?FD([],v,O,y,p,t):O):n(O,y):(O.issues.push({expected:"object",code:"invalid_type",input:v,inst:t}),O)}});function mE(t,e,n,i){for(const s of t)if(s.issues.length===0)return e.value=s.value,e;const r=t.filter(s=>!Hc(s));return r.length===1?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>Dl(o,i,Ml())))}),e)}const TW=ge("$ZodUnion",(t,e)=>{$n.init(t,e),Lt(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Lt(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Lt(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),Lt(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(r=>r._zod.pattern);return new RegExp(`^(${i.map(r=>_1(r.source)).join("|")})$`)}});const n=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1;const o=[];for(const l of e.options){const u=l._zod.run({value:i.value,issues:[]},r);if(u instanceof Promise)o.push(u),s=!0;else{if(u.issues.length===0)return u;o.push(u)}}return s?Promise.all(o).then(l=>mE(l,i,t,r)):mE(o,i,t,r)}}),EW=ge("$ZodIntersection",(t,e)=>{$n.init(t,e),t._zod.parse=(n,i)=>{const r=n.value,s=e.left._zod.run({value:r,issues:[]},i),o=e.right._zod.run({value:r,issues:[]},i);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([u,f])=>OE(n,u,f)):OE(n,s,o)}});function KS(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Mf(t)&&Mf(e)){const n=Object.keys(e),i=Object.keys(t).filter(s=>n.indexOf(s)!==-1),r={...t,...e};for(const s of i){const o=KS(t[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;il.l&&l.r).map(([l])=>l);if(s.length&&r&&t.issues.push({...r,keys:s}),Hc(t))return t;const o=KS(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}const RW=ge("$ZodEnum",(t,e)=>{$n.init(t,e);const n=zD(e.entries),i=new Set(n);t._zod.values=i,t._zod.pattern=new RegExp(`^(${n.filter(r=>BG.has(typeof r)).map(r=>typeof r=="string"?VO(r):r.toString()).join("|")})$`),t._zod.parse=(r,s)=>{const o=r.value;return i.has(o)||r.issues.push({code:"invalid_value",values:n,input:o,inst:t}),r}}),QW=ge("$ZodTransform",(t,e)=>{$n.init(t,e),t._zod.optin="optional",t._zod.parse=(n,i)=>{if(i.direction==="backward")throw new ND(t.constructor.name);const r=e.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(o=>(n.value=o,n.fallback=!0,n));if(r instanceof Promise)throw new ru;return n.value=r,n.fallback=!0,n}});function yE(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}const GD=ge("$ZodOptional",(t,e)=>{$n.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Lt(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Lt(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${_1(n.source)})?$`):void 0}),t._zod.parse=(n,i)=>{if(e.innerType._zod.optin==="optional"){const r=n.value,s=e.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>yE(o,r)):yE(s,r)}return n.value===void 0?n:e.innerType._zod.run(n,i)}}),AW=ge("$ZodExactOptional",(t,e)=>{GD.init(t,e),Lt(t._zod,"values",()=>e.innerType._zod.values),Lt(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,i)=>e.innerType._zod.run(n,i)}),PW=ge("$ZodNullable",(t,e)=>{$n.init(t,e),Lt(t._zod,"optin",()=>e.innerType._zod.optin),Lt(t._zod,"optout",()=>e.innerType._zod.optout),Lt(t._zod,"pattern",()=>{const n=e.innerType._zod.pattern;return n?new RegExp(`^(${_1(n.source)}|null)$`):void 0}),Lt(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,i)=>n.value===null?n:e.innerType._zod.run(n,i)}),jW=ge("$ZodDefault",(t,e)=>{$n.init(t,e),t._zod.optin="optional",Lt(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,i)=>{if(i.direction==="backward")return e.innerType._zod.run(n,i);if(n.value===void 0)return n.value=e.defaultValue,n;const r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>vE(s,e)):vE(r,e)}});function vE(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const MW=ge("$ZodPrefault",(t,e)=>{$n.init(t,e),t._zod.optin="optional",Lt(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,i))}),DW=ge("$ZodNonOptional",(t,e)=>{$n.init(t,e),Lt(t._zod,"values",()=>{const n=e.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),t._zod.parse=(n,i)=>{const r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>bE(s,t)):bE(r,t)}});function bE(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}const NW=ge("$ZodCatch",(t,e)=>{$n.init(t,e),t._zod.optin="optional",Lt(t._zod,"optout",()=>e.innerType._zod.optout),Lt(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,i)=>{if(i.direction==="backward")return e.innerType._zod.run(n,i);const r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(o=>Dl(o,i,Ml()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=r.value,r.issues.length&&(n.value=e.catchValue({...n,error:{issues:r.issues.map(s=>Dl(s,i,Ml()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),zW=ge("$ZodPipe",(t,e)=>{$n.init(t,e),Lt(t._zod,"values",()=>e.in._zod.values),Lt(t._zod,"optin",()=>e.in._zod.optin),Lt(t._zod,"optout",()=>e.out._zod.optout),Lt(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,i)=>{if(i.direction==="backward"){const s=e.out._zod.run(n,i);return s instanceof Promise?s.then(o=>Og(o,e.in,i)):Og(s,e.in,i)}const r=e.in._zod.run(n,i);return r instanceof Promise?r.then(s=>Og(s,e.out,i)):Og(r,e.out,i)}});function Og(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},n)}const LW=ge("$ZodReadonly",(t,e)=>{$n.init(t,e),Lt(t._zod,"propValues",()=>e.innerType._zod.propValues),Lt(t._zod,"values",()=>e.innerType._zod.values),Lt(t._zod,"optin",()=>e.innerType?._zod?.optin),Lt(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(n,i)=>{if(i.direction==="backward")return e.innerType._zod.run(n,i);const r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(SE):SE(r)}});function SE(t){return t.value=Object.freeze(t.value),t}const ZW=ge("$ZodCustom",(t,e)=>{Xs.init(t,e),$n.init(t,e),t._zod.parse=(n,i)=>n,t._zod.check=n=>{const i=n.value,r=e.fn(i);if(r instanceof Promise)return r.then(s=>xE(s,n,i,t));xE(r,n,i,t)}});function xE(t,e,n,i){if(!t){const r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),e.issues.push(Df(r))}}var wE;class IW{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){const i=n[0];return this._map.set(e,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const n=this._map.get(e);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(e),this}get(e){const n=e._zod.parent;if(n){const i={...this.get(n)??{}};delete i.id;const r={...i,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function XW(){return new IW}(wE=globalThis).__zod_globalRegistry??(wE.__zod_globalRegistry=XW());const uf=globalThis.__zod_globalRegistry;function VW(t,e){return new t({type:"string",...Ge(e)})}function BW(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Ge(e)})}function kE(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Ge(e)})}function UW(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Ge(e)})}function qW(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ge(e)})}function YW(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ge(e)})}function FW(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ge(e)})}function GW(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Ge(e)})}function HW(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Ge(e)})}function WW(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ge(e)})}function KW(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Ge(e)})}function JW(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ge(e)})}function eK(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Ge(e)})}function tK(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Ge(e)})}function nK(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ge(e)})}function iK(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ge(e)})}function rK(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ge(e)})}function sK(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ge(e)})}function oK(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ge(e)})}function aK(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Ge(e)})}function lK(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Ge(e)})}function cK(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Ge(e)})}function uK(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Ge(e)})}function dK(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ge(e)})}function fK(t,e){return new t({type:"string",format:"date",check:"string_format",...Ge(e)})}function hK(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Ge(e)})}function pK(t,e){return new t({type:"string",format:"duration",check:"string_format",...Ge(e)})}function gK(t,e){return new t({type:"boolean",...Ge(e)})}function mK(t){return new t({type:"unknown"})}function OK(t,e){return new t({type:"never",...Ge(e)})}function HD(t,e){return new LH({check:"max_length",...Ge(e),maximum:t})}function Cm(t,e){return new ZH({check:"min_length",...Ge(e),minimum:t})}function WD(t,e){return new IH({check:"length_equals",...Ge(e),length:t})}function yK(t,e){return new XH({check:"string_format",format:"regex",...Ge(e),pattern:t})}function vK(t){return new VH({check:"string_format",format:"lowercase",...Ge(t)})}function bK(t){return new BH({check:"string_format",format:"uppercase",...Ge(t)})}function SK(t,e){return new UH({check:"string_format",format:"includes",...Ge(e),includes:t})}function xK(t,e){return new qH({check:"string_format",format:"starts_with",...Ge(e),prefix:t})}function wK(t,e){return new YH({check:"string_format",format:"ends_with",...Ge(e),suffix:t})}function Uu(t){return new FH({check:"overwrite",tx:t})}function kK(t){return Uu(e=>e.normalize(t))}function CK(){return Uu(t=>t.trim())}function _K(){return Uu(t=>t.toLowerCase())}function $K(){return Uu(t=>t.toUpperCase())}function TK(){return Uu(t=>XG(t))}function EK(t,e,n){return new t({type:"array",element:e,...Ge(n)})}function RK(t,e,n){return new t({type:"custom",check:"custom",fn:e,...Ge(n)})}function QK(t,e){const n=AK(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(Df(r,i.value,n._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=i.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Df(s))}},t(i.value,i)),e);return n}function AK(t,e){const n=new Xs({check:"custom",...Ge(e)});return n._zod.check=t,n}function KD(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??uf,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function ei(t,e,n={path:[],schemaPath:[]}){var i;const r=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;const o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);const l=t._zod.toJSONSchema?.();if(l)o.schema=l;else{const h={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,h);else{const O=o.schema,y=e.processors[r.type];if(!y)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);y(t,e,O,h)}const p=t._zod.parent;p&&(o.ref||(o.ref=p),ei(p,e,h),e.seen.get(p).isParent=!0)}const u=e.metadataRegistry.get(t);return u&&Object.assign(o.schema,u),e.io==="input"&&Si(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function JD(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const o of t.seen.entries()){const l=t.metadataRegistry.get(o[0])?.id;if(l){const u=i.get(l);if(u&&u!==o[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(l,o[0])}}const r=o=>{const l=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){const p=t.external.registry.get(o[0])?.id,O=t.external.uri??(v=>v);if(p)return{ref:O(p)};const y=o[1].defId??o[1].schema.id??`schema${t.counter++}`;return o[1].defId=y,{defId:y,ref:`${O("__shared")}#/${l}/${y}`}}if(o[1]===n)return{ref:"#"};const f=`#/${l}/`,h=o[1].schema.id??`__schema${t.counter++}`;return{defId:h,ref:f+h}},s=o=>{if(o[1].schema.$ref)return;const l=o[1],{ref:u,defId:f}=r(o);l.def={...l.schema},f&&(l.defId=f);const h=l.schema;for(const p in h)delete h[p];h.$ref=u};if(t.cycles==="throw")for(const o of t.seen.entries()){const l=o[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/ + +Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const o of t.seen.entries()){const l=o[1];if(e===o[0]){s(o);continue}if(t.external){const f=t.external.registry.get(o[0])?.id;if(e!==o[0]&&f){s(o);continue}}if(t.metadataRegistry.get(o[0])?.id){s(o);continue}if(l.cycle){s(o);continue}if(l.count>1&&t.reused==="ref"){s(o);continue}}}function eN(t,e){const n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=l=>{const u=t.seen.get(l);if(u.ref===null)return;const f=u.def??u.schema,h={...f},p=u.ref;if(u.ref=null,p){i(p);const y=t.seen.get(p),v=y.schema;if(v.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(v)):Object.assign(f,v),Object.assign(f,h),l._zod.parent===p)for(const k in f)k==="$ref"||k==="allOf"||k in h||delete f[k];if(v.$ref&&y.def)for(const k in f)k==="$ref"||k==="allOf"||k in y.def&&JSON.stringify(f[k])===JSON.stringify(y.def[k])&&delete f[k]}const O=l._zod.parent;if(O&&O!==p){i(O);const y=t.seen.get(O);if(y?.schema.$ref&&(f.$ref=y.schema.$ref,y.def))for(const v in f)v==="$ref"||v==="allOf"||v in y.def&&JSON.stringify(f[v])===JSON.stringify(y.def[v])&&delete f[v]}t.override({zodSchema:l,jsonSchema:f,path:u.path??[]})};for(const l of[...t.seen.entries()].reverse())i(l[0]);const r={};if(t.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){const l=t.external.registry.get(e)?.id;if(!l)throw new Error("Schema is missing an `id` property");r.$id=t.external.uri(l)}Object.assign(r,n.def??n.schema);const s=t.metadataRegistry.get(e)?.id;s!==void 0&&r.id===s&&delete r.id;const o=t.external?.defs??{};for(const l of t.seen.entries()){const u=l[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,o[u.defId]=u.def)}t.external||Object.keys(o).length>0&&(t.target==="draft-2020-12"?r.$defs=o:r.definitions=o);try{const l=JSON.parse(JSON.stringify(r));return Object.defineProperty(l,"~standard",{value:{...e["~standard"],jsonSchema:{input:_m(e,"input",t.processors),output:_m(e,"output",t.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function Si(t,e){const n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);const i=t._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Si(i.element,n);if(i.type==="set")return Si(i.valueType,n);if(i.type==="lazy")return Si(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Si(i.innerType,n);if(i.type==="intersection")return Si(i.left,n)||Si(i.right,n);if(i.type==="record"||i.type==="map")return Si(i.keyType,n)||Si(i.valueType,n);if(i.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:Si(i.in,n)||Si(i.out,n);if(i.type==="object"){for(const r in i.shape)if(Si(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(const r of i.options)if(Si(r,n))return!0;return!1}if(i.type==="tuple"){for(const r of i.items)if(Si(r,n))return!0;return!!(i.rest&&Si(i.rest,n))}return!1}const PK=(t,e={})=>n=>{const i=KD({...n,processors:e});return ei(t,i),JD(i,t),eN(i,t)},_m=(t,e,n={})=>i=>{const{libraryOptions:r,target:s}=i??{},o=KD({...r??{},target:s,io:e,processors:n});return ei(t,o),JD(o,t),eN(o,t)},jK={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},MK=(t,e,n,i)=>{const r=n;r.type="string";const{minimum:s,maximum:o,format:l,patterns:u,contentEncoding:f}=t._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof o=="number"&&(r.maxLength=o),l&&(r.format=jK[l]??l,r.format===""&&delete r.format,l==="time"&&delete r.format),f&&(r.contentEncoding=f),u&&u.size>0){const h=[...u];h.length===1?r.pattern=h[0].source:h.length>1&&(r.allOf=[...h.map(p=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},DK=(t,e,n,i)=>{n.type="boolean"},NK=(t,e,n,i)=>{n.not={}},zK=(t,e,n,i)=>{},LK=(t,e,n,i)=>{const r=t._zod.def,s=zD(r.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},ZK=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},IK=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},XK=(t,e,n,i)=>{const r=n,s=t._zod.def,{minimum:o,maximum:l}=t._zod.bag;typeof o=="number"&&(r.minItems=o),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=ei(s.element,e,{...i,path:[...i.path,"items"]})},VK=(t,e,n,i)=>{const r=n,s=t._zod.def;r.type="object",r.properties={};const o=s.shape;for(const f in o)r.properties[f]=ei(o[f],e,{...i,path:[...i.path,"properties",f]});const l=new Set(Object.keys(o)),u=new Set([...l].filter(f=>{const h=s.shape[f]._zod;return e.io==="input"?h.optin===void 0:h.optout===void 0}));u.size>0&&(r.required=Array.from(u)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=ei(s.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},BK=(t,e,n,i)=>{const r=t._zod.def,s=r.inclusive===!1,o=r.options.map((l,u)=>ei(l,e,{...i,path:[...i.path,s?"oneOf":"anyOf",u]}));s?n.oneOf=o:n.anyOf=o},UK=(t,e,n,i)=>{const r=t._zod.def,s=ei(r.left,e,{...i,path:[...i.path,"allOf",0]}),o=ei(r.right,e,{...i,path:[...i.path,"allOf",1]}),l=f=>"allOf"in f&&Object.keys(f).length===1,u=[...l(s)?s.allOf:[s],...l(o)?o.allOf:[o]];n.allOf=u},qK=(t,e,n,i)=>{const r=t._zod.def,s=ei(r.innerType,e,i),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},YK=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType},FK=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},GK=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},HK=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},WK=(t,e,n,i)=>{const r=t._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=e.io==="input"?s?r.out:r.in:r.out;ei(o,e,i);const l=e.seen.get(t);l.ref=o},KK=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType,n.readOnly=!0},tN=(t,e,n,i)=>{const r=t._zod.def;ei(r.innerType,e,i);const s=e.seen.get(t);s.ref=r.innerType};function JS(){return JS=Object.assign?Object.assign.bind():function(t){for(var e=1;e0){var u=r.errors[0][0];n[l]={message:u.message,type:u.code}}else n[l]={message:o,type:s};if(r.code==="invalid_union"&&r.errors.forEach(function(p){return p.forEach(function(O){return t.push(JS({},O,{path:[].concat(r.path,O.path)}))})}),e){var f=n[l].types,h=f&&f[r.code];n[l]=S1(l,e,n,s,h?[].concat(h,r.message):r.message)}t.shift()};t.length;)i();return n}function R1(t,e,n){if(n===void 0&&(n={}),(function(i){return"_def"in i&&typeof i._def=="object"&&"typeName"in i._def})(t))return function(i,r,s){try{return Promise.resolve(CE(function(){return Promise.resolve(t[n.mode==="sync"?"parse":"parseAsync"](i,e)).then(function(o){return s.shouldUseNativeValidation&&HS({},s),{errors:{},values:n.raw?Object.assign({},i):o}})},function(o){if((function(l){return Array.isArray(l?.issues)})(o))return{values:{},errors:cE(JK(o.errors,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw o}))}catch(o){return Promise.reject(o)}};if((function(i){return"_zod"in i&&typeof i._zod=="object"})(t))return function(i,r,s){try{return Promise.resolve(CE(function(){return Promise.resolve((n.mode==="sync"?nH:iH)(t,i,e)).then(function(o){return s.shouldUseNativeValidation&&HS({},s),{errors:{},values:n.raw?Object.assign({},i):o}})},function(o){if((function(l){return l instanceof T1})(o))return{values:{},errors:cE(eJ(o.issues,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}const tJ=ge("ZodISODateTime",(t,e)=>{lW.init(t,e),rn.init(t,e)});function nJ(t){return dK(tJ,t)}const iJ=ge("ZodISODate",(t,e)=>{cW.init(t,e),rn.init(t,e)});function rJ(t){return fK(iJ,t)}const sJ=ge("ZodISOTime",(t,e)=>{uW.init(t,e),rn.init(t,e)});function oJ(t){return hK(sJ,t)}const aJ=ge("ZodISODuration",(t,e)=>{dW.init(t,e),rn.init(t,e)});function lJ(t){return pK(aJ,t)}const cJ=(t,e)=>{T1.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>tH(t,n)},flatten:{value:n=>eH(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,WS,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,WS,2)}},isEmpty:{get(){return t.issues.length===0}}})},Nr=ge("ZodError",cJ,{Parent:Error}),uJ=UO(Nr),dJ=qO(Nr),fJ=YO(Nr),hJ=FO(Nr),pJ=oH(Nr),gJ=aH(Nr),mJ=lH(Nr),OJ=cH(Nr),yJ=uH(Nr),vJ=dH(Nr),bJ=fH(Nr),SJ=hH(Nr),_E=new WeakMap;function HO(t,e,n){const i=Object.getPrototypeOf(t);let r=_E.get(i);if(r||(r=new Set,_E.set(i,r)),!r.has(e)){r.add(e);for(const s in n){const o=n[s];Object.defineProperty(i,s,{configurable:!0,enumerable:!1,get(){const l=o.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const Tn=ge("ZodType",(t,e)=>($n.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:_m(t,"input"),output:_m(t,"output")}}),t.toJSONSchema=PK(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(n,i)=>uJ(t,n,i,{callee:t.parse}),t.safeParse=(n,i)=>fJ(t,n,i),t.parseAsync=async(n,i)=>dJ(t,n,i,{callee:t.parseAsync}),t.safeParseAsync=async(n,i)=>hJ(t,n,i),t.spa=t.safeParseAsync,t.encode=(n,i)=>pJ(t,n,i),t.decode=(n,i)=>gJ(t,n,i),t.encodeAsync=async(n,i)=>mJ(t,n,i),t.decodeAsync=async(n,i)=>OJ(t,n,i),t.safeEncode=(n,i)=>yJ(t,n,i),t.safeDecode=(n,i)=>vJ(t,n,i),t.safeEncodeAsync=async(n,i)=>bJ(t,n,i),t.safeDecodeAsync=async(n,i)=>SJ(t,n,i),HO(t,"ZodType",{check(...n){const i=this.def;return this.clone(Ia(i,{checks:[...i.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,i){return Xa(this,n,i)},brand(){return this},register(n,i){return n.add(this,i),this},refine(n,i){return this.check(pee(n,i))},superRefine(n,i){return this.check(gee(n,i))},overwrite(n){return this.check(Uu(n))},optional(){return RE(this)},exactOptional(){return tee(this)},nullable(){return QE(this)},nullish(){return RE(QE(this))},nonoptional(n){return aee(this,n)},array(){return UJ(this)},or(n){return FJ([this,n])},and(n){return HJ(this,n)},transform(n){return AE(this,JJ(n))},default(n){return ree(this,n)},prefault(n){return oee(this,n)},catch(n){return cee(this,n)},pipe(n){return AE(this,n)},readonly(){return fee(this)},describe(n){const i=this.clone();return uf.add(i,{description:n}),i},meta(...n){if(n.length===0)return uf.get(this);const i=this.clone();return uf.add(i,n[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(t,"description",{get(){return uf.get(t)?.description},configurable:!0}),t)),nN=ge("_ZodString",(t,e)=>{E1.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(i,r,s)=>MK(t,i,r);const n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,HO(t,"_ZodString",{regex(...i){return this.check(yK(...i))},includes(...i){return this.check(SK(...i))},startsWith(...i){return this.check(xK(...i))},endsWith(...i){return this.check(wK(...i))},min(...i){return this.check(Cm(...i))},max(...i){return this.check(HD(...i))},length(...i){return this.check(WD(...i))},nonempty(...i){return this.check(Cm(1,...i))},lowercase(i){return this.check(vK(i))},uppercase(i){return this.check(bK(i))},trim(){return this.check(CK())},normalize(...i){return this.check(kK(...i))},toLowerCase(){return this.check(_K())},toUpperCase(){return this.check($K())},slugify(){return this.check(TK())}})}),xJ=ge("ZodString",(t,e)=>{E1.init(t,e),nN.init(t,e),t.email=n=>t.check(BW(wJ,n)),t.url=n=>t.check(GW(kJ,n)),t.jwt=n=>t.check(uK(LJ,n)),t.emoji=n=>t.check(HW(CJ,n)),t.guid=n=>t.check(kE($E,n)),t.uuid=n=>t.check(UW(yg,n)),t.uuidv4=n=>t.check(qW(yg,n)),t.uuidv6=n=>t.check(YW(yg,n)),t.uuidv7=n=>t.check(FW(yg,n)),t.nanoid=n=>t.check(WW(_J,n)),t.guid=n=>t.check(kE($E,n)),t.cuid=n=>t.check(KW($J,n)),t.cuid2=n=>t.check(JW(TJ,n)),t.ulid=n=>t.check(eK(EJ,n)),t.base64=n=>t.check(aK(DJ,n)),t.base64url=n=>t.check(lK(NJ,n)),t.xid=n=>t.check(tK(RJ,n)),t.ksuid=n=>t.check(nK(QJ,n)),t.ipv4=n=>t.check(iK(AJ,n)),t.ipv6=n=>t.check(rK(PJ,n)),t.cidrv4=n=>t.check(sK(jJ,n)),t.cidrv6=n=>t.check(oK(MJ,n)),t.e164=n=>t.check(cK(zJ,n)),t.datetime=n=>t.check(nJ(n)),t.date=n=>t.check(rJ(n)),t.time=n=>t.check(oJ(n)),t.duration=n=>t.check(lJ(n))});function Yg(t){return VW(xJ,t)}const rn=ge("ZodStringFormat",(t,e)=>{en.init(t,e),nN.init(t,e)}),wJ=ge("ZodEmail",(t,e)=>{JH.init(t,e),rn.init(t,e)}),$E=ge("ZodGUID",(t,e)=>{WH.init(t,e),rn.init(t,e)}),yg=ge("ZodUUID",(t,e)=>{KH.init(t,e),rn.init(t,e)}),kJ=ge("ZodURL",(t,e)=>{eW.init(t,e),rn.init(t,e)}),CJ=ge("ZodEmoji",(t,e)=>{tW.init(t,e),rn.init(t,e)}),_J=ge("ZodNanoID",(t,e)=>{nW.init(t,e),rn.init(t,e)}),$J=ge("ZodCUID",(t,e)=>{iW.init(t,e),rn.init(t,e)}),TJ=ge("ZodCUID2",(t,e)=>{rW.init(t,e),rn.init(t,e)}),EJ=ge("ZodULID",(t,e)=>{sW.init(t,e),rn.init(t,e)}),RJ=ge("ZodXID",(t,e)=>{oW.init(t,e),rn.init(t,e)}),QJ=ge("ZodKSUID",(t,e)=>{aW.init(t,e),rn.init(t,e)}),AJ=ge("ZodIPv4",(t,e)=>{fW.init(t,e),rn.init(t,e)}),PJ=ge("ZodIPv6",(t,e)=>{hW.init(t,e),rn.init(t,e)}),jJ=ge("ZodCIDRv4",(t,e)=>{pW.init(t,e),rn.init(t,e)}),MJ=ge("ZodCIDRv6",(t,e)=>{gW.init(t,e),rn.init(t,e)}),DJ=ge("ZodBase64",(t,e)=>{mW.init(t,e),rn.init(t,e)}),NJ=ge("ZodBase64URL",(t,e)=>{yW.init(t,e),rn.init(t,e)}),zJ=ge("ZodE164",(t,e)=>{vW.init(t,e),rn.init(t,e)}),LJ=ge("ZodJWT",(t,e)=>{SW.init(t,e),rn.init(t,e)}),ZJ=ge("ZodBoolean",(t,e)=>{xW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>DK(t,n,i)});function TE(t){return gK(ZJ,t)}const IJ=ge("ZodUnknown",(t,e)=>{wW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>zK()});function EE(){return mK(IJ)}const XJ=ge("ZodNever",(t,e)=>{kW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>NK(t,n,i)});function VJ(t){return OK(XJ,t)}const BJ=ge("ZodArray",(t,e)=>{CW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>XK(t,n,i,r),t.element=e.element,HO(t,"ZodArray",{min(n,i){return this.check(Cm(n,i))},nonempty(n){return this.check(Cm(1,n))},max(n,i){return this.check(HD(n,i))},length(n,i){return this.check(WD(n,i))},unwrap(){return this.element}})});function UJ(t,e){return EK(BJ,t,e)}const qJ=ge("ZodObject",(t,e)=>{$W.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>VK(t,n,i,r),Lt(t,"shape",()=>e.shape),HO(t,"ZodObject",{keyof(){return WJ(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:EE()})},loose(){return this.clone({...this._zod.def,catchall:EE()})},strict(){return this.clone({...this._zod.def,catchall:VJ()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return FG(this,n)},safeExtend(n){return GG(this,n)},merge(n){return HG(this,n)},pick(n){return qG(this,n)},omit(n){return YG(this,n)},partial(...n){return WG(iN,this,n[0])},required(...n){return KG(rN,this,n[0])}})});function Q1(t,e){const n={type:"object",shape:t??{},...Ge(e)};return new qJ(n)}const YJ=ge("ZodUnion",(t,e)=>{TW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>BK(t,n,i,r),t.options=e.options});function FJ(t,e){return new YJ({type:"union",options:t,...Ge(e)})}const GJ=ge("ZodIntersection",(t,e)=>{EW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>UK(t,n,i,r)});function HJ(t,e){return new GJ({type:"intersection",left:t,right:e})}const ex=ge("ZodEnum",(t,e)=>{RW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(i,r,s)=>LK(t,i,r),t.enum=e.entries,t.options=Object.values(e.entries);const n=new Set(Object.keys(e.entries));t.extract=(i,r)=>{const s={};for(const o of i)if(n.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new ex({...e,checks:[],...Ge(r),entries:s})},t.exclude=(i,r)=>{const s={...e.entries};for(const o of i)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new ex({...e,checks:[],...Ge(r),entries:s})}});function WJ(t,e){const n=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new ex({type:"enum",entries:n,...Ge(e)})}const KJ=ge("ZodTransform",(t,e)=>{QW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>IK(t,n),t._zod.parse=(n,i)=>{if(i.direction==="backward")throw new ND(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Df(s,n.value,e));else{const o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(Df(o))}};const r=e.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=r,n.fallback=!0,n)}});function JJ(t){return new KJ({type:"transform",transform:t})}const iN=ge("ZodOptional",(t,e)=>{GD.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>tN(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function RE(t){return new iN({type:"optional",innerType:t})}const eee=ge("ZodExactOptional",(t,e)=>{AW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>tN(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function tee(t){return new eee({type:"optional",innerType:t})}const nee=ge("ZodNullable",(t,e)=>{PW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>qK(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function QE(t){return new nee({type:"nullable",innerType:t})}const iee=ge("ZodDefault",(t,e)=>{jW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>FK(t,n,i,r),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function ree(t,e){return new iee({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():ZD(e)}})}const see=ge("ZodPrefault",(t,e)=>{MW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>GK(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function oee(t,e){return new see({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():ZD(e)}})}const rN=ge("ZodNonOptional",(t,e)=>{DW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>YK(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function aee(t,e){return new rN({type:"nonoptional",innerType:t,...Ge(e)})}const lee=ge("ZodCatch",(t,e)=>{NW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>HK(t,n,i,r),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function cee(t,e){return new lee({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const uee=ge("ZodPipe",(t,e)=>{zW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>WK(t,n,i,r),t.in=e.in,t.out=e.out});function AE(t,e){return new uee({type:"pipe",in:t,out:e})}const dee=ge("ZodReadonly",(t,e)=>{LW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>KK(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function fee(t){return new dee({type:"readonly",innerType:t})}const hee=ge("ZodCustom",(t,e)=>{ZW.init(t,e),Tn.init(t,e),t._zod.processJSONSchema=(n,i,r)=>ZK(t,n)});function pee(t,e={}){return RK(hee,t,e)}function gee(t,e){return QK(t,e)}function mee({className:t,...e}){return m.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:m.jsx("table",{"data-slot":"table",className:yt("w-full caption-bottom text-sm",t),...e})})}function Oee({className:t,...e}){return m.jsx("thead",{"data-slot":"table-header",className:yt("[&_tr]:border-b",t),...e})}function yee({className:t,...e}){return m.jsx("tbody",{"data-slot":"table-body",className:yt("[&_tr:last-child]:border-0",t),...e})}function PE({className:t,...e}){return m.jsx("tr",{"data-slot":"table-row",className:yt("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),...e})}function jE({className:t,...e}){return m.jsx("th",{"data-slot":"table-head",className:yt("h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}function vee({className:t,...e}){return m.jsx("td",{"data-slot":"table-cell",className:yt("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",t),...e})}function bee({header:t}){const e=t.column.getIsSorted();return t.column.getCanSort()?m.jsx(jE,{"data-sort":e||void 0,"aria-sort":e==="asc"?"ascending":e==="desc"?"descending":"none",children:m.jsxs("button",{type:"button",className:"th-sort",onClick:t.column.getToggleSortingHandler(),children:[qS(t.column.columnDef.header,t.getContext()),e==="asc"?" ↑":e==="desc"?" ↓":""]})}):m.jsx(jE,{children:qS(t.column.columnDef.header,t.getContext())})}function sN({table:t,className:e}){return m.jsx("div",{className:"admin-list admin-card-table"+(e?" "+e:""),children:m.jsxs(mee,{className:"admin-table",children:[m.jsx(Oee,{children:t.getHeaderGroups().map(n=>m.jsx(PE,{children:n.headers.map(i=>m.jsx(bee,{header:i},i.id))},n.id))}),m.jsx(yee,{children:t.getRowModel().rows.map(n=>m.jsx(PE,{className:"admin-item",children:n.getVisibleCells().map(i=>m.jsx(vee,{children:qS(i.column.columnDef.cell,i.getContext())},i.id))},n.id))})]})})}function oN(t){return t?"expires "+new Date(t).toLocaleDateString():"no expiry"}function See(t){if(t.opens===void 0)return null;if(t.opens===0)return"not opened yet";const e=`${t.opens} open${t.opens===1?"":"s"}`;return t.last_opened?`${e} · last opened ${new Date(t.last_opened).toLocaleDateString()}`:e}function aN(t,e){const n=[];e&&t.project_name&&n.push(t.project_name),t.creator&&n.push("by "+t.creator),t.created&&n.push(new Date(t.created).toLocaleDateString()),n.push(oN(t.expires));const i=See(t);return i&&n.push(i),n.join(" · ")}const lN="Opens count how many times a file has been read through a public link. Repeat opens from the same browser and network within 10 minutes count once — two people on one network using the same browser still count as one.";function cN({shares:t,onChanged:e,showProject:n=!1,canRevoke:i=!0,empty:r="No public shares.",loading:s=!1}){const[o,l]=w.useState([]),u=w.useMemo(()=>dD(),[]),f=w.useMemo(()=>[u.accessor("path",{header:"Path",cell:p=>m.jsx("a",{className:"ai-main mono",title:p.getValue(),...Cl(Yr(p.getValue(),p.row.original.project)),children:p.getValue()})}),u.accessor(p=>aN(p,n),{id:"detail",header:n?"Project":"Shared",cell:p=>m.jsx("span",{className:"ai-tag",children:p.getValue()})}),u.display({id:"actions",header:"",cell:p=>m.jsxs("span",{className:"share-acts",children:[m.jsx("button",{className:"ai-btn","aria-label":`Copy the public link to ${p.row.original.path}`,title:"Copy link",onClick:()=>zs(p.row.original.url).then(O=>Ve(O?"Copied.":"Select and copy the link.")),children:m.jsx(st,{name:"copy"})}),i&&m.jsx("button",{className:"ai-del","aria-label":`Revoke the share of ${p.row.original.path}`,onClick:()=>uN(p.row.original,e),children:"Revoke"})]})})],[u,e,n,i]),h=wD({data:t,columns:f,state:{sorting:o},onSortingChange:l,getCoreRowModel:SD(),getSortedRowModel:xD()});return s?m.jsx("div",{className:"admin-list",children:m.jsx("div",{className:"admin-empty",children:"Loading…"})}):t.length===0?m.jsx("div",{className:"admin-list",children:m.jsx("div",{className:"admin-empty",children:r})}):m.jsx(sN,{table:h,className:"shares-table"})}async function uN(t,e){if(await kl("Revoke share link",`Revoke the public link to “${t.path}”? Anyone with the URL will lose access.`,"Revoke",!0))try{await di("DELETE","/api/shares/"+t.token),Ve("Share revoked."),e()}catch(n){Ve(n.message,!0)}}const xee=Q1({name:Yg().trim().min(1,"Give the organization a name.").max(60,"Keep it under 60 characters.")});function wee({org:t,projects:e,myEmail:n}){const i=fr(),r=t.role==="owner",s=()=>i.invalidateQueries({queryKey:["orgs"]}),o=()=>i.invalidateQueries({queryKey:["invites",t.id]}),l=()=>i.invalidateQueries({queryKey:["orgShares",t.id]}),u=x1({resolver:R1(xee),values:{name:t.name}}),{data:f}=nn({queryKey:["invites",t.id],queryFn:()=>Wt(`/api/orgs/${t.id}/invites`),enabled:r,select:y=>y.invites||[]}),{data:h,isLoading:p}=nn({queryKey:["orgShares",t.id],queryFn:()=>Wt(`/api/orgs/${t.id}/shares`),enabled:r,select:y=>y.shares||[]}),O=e.filter(y=>y.org===t.id);return m.jsxs("div",{className:"admin",children:[m.jsx("h1",{id:"org-title",children:t.name}),!r&&m.jsx("p",{className:"role-chip-row",children:m.jsx("span",{className:"ai-tag role-chip",children:"Member"})}),!r&&m.jsx("p",{className:"admin-sub",children:"Only owners can rename this organization, manage members, or issue invite links."}),r&&m.jsxs("form",{className:"admin-row",onSubmit:u.handleSubmit(async({name:y})=>{try{await di("PATCH","/api/orgs/"+t.id,{name:y}),Ve("Renamed."),s()}catch(v){Ve(v.message,!0)}}),children:[m.jsx("label",{className:"admin-lbl",htmlFor:"org-rename",children:"Organization name"}),m.jsx("input",{id:"org-rename",type:"text","aria-invalid":!!u.formState.errors.name,"aria-describedby":u.formState.errors.name?"org-rename-err":void 0,...u.register("name")}),m.jsx(at,{variant:"subtle",id:"org-rename-btn",type:"submit",disabled:!u.formState.isDirty,children:"Rename org"}),u.formState.errors.name&&m.jsx("span",{id:"org-rename-err",role:"alert",className:"field-err",children:u.formState.errors.name.message})]}),m.jsx("h3",{children:"Members"}),m.jsx(kee,{org:t,owner:r,myEmail:n,onChanged:s}),m.jsx("h3",{children:"Projects"}),m.jsxs("div",{className:"admin-list",children:[O.length===0&&m.jsx("div",{className:"admin-empty",children:"No projects yet."}),O.map(y=>m.jsx("div",{className:"admin-item",children:m.jsx("span",{className:"ai-main",title:y.name,children:y.name})},y.id))]}),r&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"admin-h",children:[m.jsx("h3",{children:"Invite links"}),m.jsx(at,{variant:"primary",onClick:async()=>{try{const y=await Wr(`/api/orgs/${t.id}/invites`),v=await zs(y.url);Ve(v?"Invite link copied to clipboard.":"Invite created — copy it from the list below."),o()}catch(y){Ve(y.message,!0)}},children:"New invite"})]}),m.jsxs("div",{className:"admin-list",children:[f&&f.length===0&&m.jsx("div",{className:"admin-empty",children:"No active invite links."}),(f||[]).map(y=>m.jsxs("div",{className:"admin-item",children:[m.jsx("button",{type:"button",className:"ai-main mono ai-copy","aria-label":`Copy invite link ${y.url}`,title:y.url,onClick:()=>zs(y.url).then(v=>Ve(v?"Copied.":"Select and copy the link.")),children:y.url}),m.jsx("span",{className:"ai-tag",children:(y.creator?"by "+y.creator+" · ":"")+(y.uses?y.uses+" joined · ":"unused · ")+"expires "+new Date(y.expires).toLocaleDateString()}),m.jsx("button",{className:"ai-del","aria-label":`Revoke invite ${y.token.slice(0,8)}`,onClick:async()=>{if(await kl("Revoke invite",`Revoke the link starting ${y.token.slice(0,8)}…? Anyone still holding it won't be able to join.`,"Revoke",!0))try{await di("DELETE",`/api/orgs/${t.id}/invites/${y.token}`),Ve("Revoked."),o()}catch(v){Ve(v.message,!0)}},children:"Revoke"})]},y.token))]}),m.jsx("h3",{children:"Public share links"}),m.jsx("p",{className:"admin-sub",children:"Every live link across this organization's projects. A project's own links are on its Settings page, and on the file itself."}),m.jsx(cN,{shares:h||[],loading:p,onChanged:l,showProject:!0})]})]})}function kee({org:t,owner:e,myEmail:n,onChanged:i}){const[r,s]=w.useState([{id:"email",desc:!1}]),o=w.useMemo(()=>dD(),[]),l=w.useMemo(()=>[o.accessor("email",{id:"email",header:"Member",cell:f=>{const h=!!n&&f.getValue().toLowerCase()===n.toLowerCase();return m.jsx("span",{className:"ai-main",title:f.getValue(),children:f.getValue()+(h?" (you)":"")})}}),o.accessor("role",{id:"role",header:"Role",cell:f=>{const h=f.row.original,p=!!n&&h.email.toLowerCase()===n.toLowerCase();return!e||p?m.jsx("span",{className:"ai-tag role-static",children:h.role}):m.jsxs("span",{className:"role-cell",children:[m.jsxs("select",{"aria-label":`Role for ${h.email}`,value:h.role,onChange:async O=>{try{await di("PATCH",`/api/orgs/${t.id}/members/${encodeURIComponent(h.email)}`,{role:O.target.value}),Ve("Role updated.")}catch(y){Ve(y.message,!0)}i()},children:[m.jsx("option",{value:"owner",children:"owner"}),m.jsx("option",{value:"member",children:"member"})]}),m.jsx("button",{className:"ai-del","aria-label":`Remove ${h.email}`,onClick:async()=>{if(await kl("Remove member",`Remove ${h.email} from ${t.name}?`,"Remove",!0))try{await di("DELETE",`/api/orgs/${t.id}/members/${encodeURIComponent(h.email)}`),Ve("Removed."),i()}catch(O){Ve(O.message,!0)}},children:"Remove"})]})}})],[o,t.id,t.name,e,n]),u=wD({data:t.members,columns:l,state:{sorting:r},onSortingChange:s,getCoreRowModel:SD(),getSortedRowModel:xD()});return m.jsx(sN,{table:u})}const Cee=Q1({require_verification:TE(),require_approval:TE()});function _ee(){const t=fr(),{data:e,error:n}=nn({queryKey:["admin","policy"],queryFn:()=>Wt("/api/admin/policy")}),{data:i}=rD(!0),r=x1({resolver:R1(Cee),values:e?{require_verification:e.require_verification&&e.mailer,require_approval:e.require_approval}:{require_verification:!1,require_approval:!1}});if(w.useEffect(()=>{n&&Ve(n.message,!0)},[n]),!e)return null;const s=async(o,l,u)=>{try{await Wr(`/api/admin/pending/${o}/${l}`),Ve((l==="approve"?"Approved ":"Denied ")+u),t.invalidateQueries({queryKey:["admin","pending"]})}catch(f){Ve(f.message,!0)}};return m.jsxs("div",{className:"admin",children:[m.jsx("h1",{children:"Signup & access"}),m.jsx("p",{className:"admin-sub",children:"Who can create an account on this hub, and how new accounts are vetted."}),m.jsx("h3",{children:"New-account vetting"}),m.jsxs("form",{onSubmit:r.handleSubmit(async o=>{try{await Wr("/api/admin/policy",o),Ve("Signup policy saved."),t.invalidateQueries({queryKey:["admin","policy"]})}catch(l){Ve(l.message,!0)}}),children:[m.jsxs("div",{className:"admin-list",children:[m.jsx(ME,{label:"Require email verification",desc:e.mailer?"New accounts must click an emailed link before they can sign in — proves they control the address.":"Configure SMTP on the server (auth.smtp) to enable email verification.",disabled:!e.mailer,inputProps:r.register("require_verification")}),m.jsx(ME,{label:"Require admin approval",desc:"New accounts wait for a hub admin to approve them before they gain access.",inputProps:r.register("require_approval")})]}),m.jsx(at,{variant:"primary",type:"submit",style:{marginTop:14},disabled:!r.formState.isDirty,children:"Save policy"})]}),m.jsx("h3",{children:"Who can sign up"}),m.jsxs("div",{className:"admin-list",children:[m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"ai-main",children:"Allowed email domains"}),m.jsx("span",{className:"ai-tag",children:e.allowed_domains&&e.allowed_domains.length?e.allowed_domains.map(o=>"@"+o).join(", "):"any"})]}),m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"ai-main",children:"Self-signup"}),m.jsx("span",{className:"ai-tag",children:e.allow_signup?"open":"invite-only"})]}),m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"ai-main",children:"Hub admins"}),m.jsx("span",{className:"ai-tag",children:e.admins&&e.admins.length?e.admins.join(", "):"none"})]})]}),m.jsx("p",{className:"admin-sub",children:"Domains and admins are set in the server config file (they can't be widened from the browser)."}),m.jsx("h3",{children:"Pending signups"}),m.jsxs("div",{className:"admin-list",children:[(!i||i.length===0)&&m.jsx("div",{className:"admin-empty",children:"No one is waiting for approval."}),(i||[]).map(o=>m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"ai-main",children:(o.name?o.name+" · ":"")+o.email}),m.jsx(at,{variant:"primary",onClick:()=>s(o.id,"approve",o.email),children:"Approve"}),m.jsx("button",{className:"ai-del",onClick:()=>s(o.id,"deny",o.email),children:"Deny"})]},o.id))]})]})}function ME({label:t,desc:e,disabled:n,inputProps:i}){return m.jsxs("label",{className:"admin-item toggle",style:n?{opacity:.55}:void 0,children:[m.jsxs("span",{className:"ai-main",children:[m.jsx("div",{className:"tg-label",children:t}),m.jsx("div",{className:"tg-desc",children:e})]}),m.jsx("input",{type:"checkbox",disabled:n,...i})]})}function Qs({className:t,...e}){return m.jsx("div",{"data-slot":"card",className:yt("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...e})}function As({className:t,...e}){return m.jsx("div",{"data-slot":"card-header",className:yt("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...e})}function Ps({className:t,...e}){return m.jsx("div",{"data-slot":"card-title",className:yt("leading-none font-semibold",t),...e})}function Sa({className:t,...e}){return m.jsx("div",{"data-slot":"card-description",className:yt("text-muted-foreground text-sm",t),...e})}function wo({className:t,...e}){return m.jsx("div",{"data-slot":"card-content",className:yt("px-6",t),...e})}function DE(t){if(!t||t.startsWith("0001-"))return"never";const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function $ee({projects:t}){const e=fr(),n=nn({queryKey:["mcp","grants"],queryFn:()=>Wt("/api/mcp/grants")}),i=ZX({mutationFn:o=>di("DELETE",`/api/mcp/grants/${encodeURIComponent(o)}`),onSuccess:()=>{Ve("Disconnected. The agent's access stopped immediately."),e.invalidateQueries({queryKey:["mcp","grants"]})},onError:o=>Ve(o.message,!0)}),r=o=>t.find(l=>l.id===o)?.name||o;if(n.isLoading)return m.jsx("div",{className:"empty",children:"Loading…"});if(n.error)return m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"Connections are unavailable"}),m.jsx("p",{children:n.error.message})]});const s=n.data?.grants??[];return m.jsxs("div",{className:"project-settings",id:"mcp-connections",children:[m.jsx("h2",{children:"Connected agents"}),m.jsxs("p",{className:"admin-sub",children:["Agents you have connected to this hub over"," ",m.jsx("a",{href:"https://modelcontextprotocol.io",target:"_blank",rel:"noreferrer",children:"MCP"}),". Each one reads and changes files in the projects you chose, acting as you — so its changes appear in History under your name, and it can never do more than you can."]}),s.length===0?m.jsx(Qs,{children:m.jsxs(As,{children:[m.jsx(Ps,{children:"No agents connected"}),m.jsxs(Sa,{children:["Point an MCP client (Claude, ChatGPT, Cursor, …) at"," ",m.jsxs("code",{children:[window.location.origin,"/mcp"]}),". It will send you back here to pick which projects it may use."]})]})}):s.map(o=>m.jsxs(Qs,{className:"mcp-grant",children:[m.jsxs(As,{children:[m.jsx(Ps,{children:o.client_name||"Unnamed client"}),m.jsxs(Sa,{children:["Connected ",DE(o.created)," · last used ",DE(o.last_used)]})]}),m.jsxs(wo,{children:[m.jsx("div",{className:"mcp-projects",children:o.projects.map(l=>m.jsx("span",{className:"ps-chip",children:r(l)},l))}),m.jsx(at,{variant:"destructive",disabled:i.isPending,onClick:()=>{i.mutate(o.id)},children:"Disconnect"})]})]},o.id))]})}function Tee({...t}){return m.jsx(Ej,{"data-slot":"select",...t})}function Eee({...t}){return m.jsx(Pj,{"data-slot":"select-value",...t})}function Ree({className:t,size:e="default",children:n,...i}){return m.jsxs(Qj,{"data-slot":"select-trigger","data-size":e,className:yt("flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...i,children:[n,m.jsx(jj,{asChild:!0,children:m.jsx(o1,{className:"size-4 opacity-50"})})]})}function Qee({className:t,children:e,position:n="item-aligned",align:i="center",...r}){return m.jsx(Dj,{children:m.jsxs(Nj,{"data-slot":"select-content",className:yt("relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,align:i,...r,children:[m.jsx(Pee,{}),m.jsx(Xj,{className:yt("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),m.jsx(jee,{})]})})}function Aee({className:t,children:e,...n}){return m.jsxs(qj,{"data-slot":"select-item",className:yt("relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[m.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:m.jsx(Gj,{children:m.jsx(LM,{className:"size-4"})})}),m.jsx(Yj,{children:e})]})}function Pee({className:t,...e}){return m.jsx(Hj,{"data-slot":"select-scroll-up-button",className:yt("flex cursor-default items-center justify-center py-1",t),...e,children:m.jsx(Yq,{className:"size-4"})})}function jee({className:t,...e}){return m.jsx(Wj,{"data-slot":"select-scroll-down-button",className:yt("flex cursor-default items-center justify-center py-1",t),...e,children:m.jsx(o1,{className:"size-4"})})}const NE=["#5b8def","#f5a623","#4cc38a","#e0679b","#8b7bf0","#3ec8c8","#e6934a"];function xu(t){let e=0;for(const n of t)e=e*31+n.charCodeAt(0)>>>0;return NE[e%NE.length]}function fb({projects:t,currentId:e,menu:n,onNew:i}){const r=t.find(s=>s.id===e);return m.jsxs("nav",{id:"projects","aria-label":"Projects",children:[m.jsxs("div",{className:"nav-head",children:[m.jsx("span",{children:"Projects"}),m.jsx("button",{className:"nav-add",title:"New project","aria-label":"New project",onClick:i,children:"+"})]}),m.jsx("div",{className:"proj-row",children:m.jsxs(Tee,{value:e||"",onValueChange:s=>{s&&s!==e&&(zt("/"+s),Fr())},children:[m.jsxs(Ree,{id:"project-select","aria-label":`Switch project — current: ${r?.name??"none"}`,title:r?.name,className:"proj-trigger",children:[r&&m.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:xu(r.name)},children:m.jsx(iu,{name:r.icon})}),r?m.jsx("span",{"data-slot":"select-value",children:r.name}):m.jsx(Eee,{placeholder:"Select a project"})]}),m.jsx(Qee,{className:"proj-menu",position:"popper",sideOffset:4,children:t.map(s=>m.jsxs(Aee,{value:s.id,children:[m.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:xu(s.name)},children:m.jsx(iu,{name:s.icon})}),s.name]},s.id))})]})}),n&&m.jsx("ul",{className:"nav-menu","aria-label":"Project pages",children:[["dashboard","Dashboard","dashboard",n.onDashboard],["install","Installation","terminal",n.onInstall],["history","History","hist",n.onHistory],["settings","Settings","gear",n.onSettings]].map(([s,o,l,u])=>m.jsx("li",{children:m.jsxs("div",{id:"nav-"+s,className:"row"+(n.active===s?" active":""),role:"button",tabIndex:0,onClick:u,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),u())},children:[m.jsx(st,{name:l}),m.jsx("span",{className:"label",children:o})]})},s))})]})}function dN({...t}){return m.jsx(OU,{"data-slot":"dropdown-menu",...t})}function fN({...t}){return m.jsx(yU,{"data-slot":"dropdown-menu-trigger",...t})}function hN({className:t,sideOffset:e=4,...n}){return m.jsx(vU,{children:m.jsx(bU,{"data-slot":"dropdown-menu-content",sideOffset:e,className:yt("z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",t),...n})})}function ua({className:t,inset:e,variant:n="default",...i}){return m.jsx(xU,{"data-slot":"dropdown-menu-item","data-inset":e,"data-variant":n,className:yt("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",t),...i})}function hb({className:t,inset:e,...n}){return m.jsx(SU,{"data-slot":"dropdown-menu-label","data-inset":e,className:yt("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})}const Mee="https://github.com/runbear-io/beardrive";function Dee(){return m.jsx("svg",{viewBox:"0 0 16 16",className:"gh-mark",fill:"currentColor","aria-hidden":"true",children:m.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})}function pN(){return m.jsxs("a",{className:"gh-star",href:Mee,target:"_blank",rel:"noreferrer",children:[m.jsx(Dee,{}),m.jsx("span",{children:"Star on GitHub"}),m.jsx("span",{className:"ext","aria-hidden":"true",children:"↗"}),m.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})}function Nee({me:t,org:e,admin:n,orgActive:i,billing:r,mcp:s,signOut:o}){const l=t.name||t.email,[u,f]=w.useState(!1),h=e?Cl(e.manage_url):null,p=r?Cl(r.url):null,O=Cl("/connections");return m.jsxs("footer",{id:"accountbar",children:[m.jsx(pN,{}),m.jsxs(dN,{modal:!1,open:u,onOpenChange:f,children:[m.jsx(fN,{asChild:!0,children:m.jsxs("button",{id:"account-btn",className:i?"active":void 0,"aria-label":"Account menu",children:[m.jsx("span",{className:"avatar",style:{background:xu(t.email)},"aria-hidden":"true",children:(l.trim()[0]||"?").toUpperCase()}),m.jsxs("span",{className:"acct",children:[m.jsx("b",{children:l}),t.name&&m.jsx("small",{children:t.email})]}),m.jsx(st,{name:"chev"})]})}),m.jsxs(hN,{id:"account-menu",side:"top",align:"start",sideOffset:6,className:"acct-menu",children:[e&&m.jsxs(m.Fragment,{children:[m.jsx(hb,{className:"menu-sec",children:"Organization"}),m.jsx(ua,{asChild:!0,children:m.jsxs("a",{id:"menu-org-settings","aria-current":i?"page":void 0,...h,onClick:y=>{h?.onClick?.(y),f(!1)},children:[m.jsx(st,{name:"gear"}),m.jsxs("span",{children:[m.jsx("b",{children:e.name})," Settings"]}),!e.manage_url.startsWith("/")&&m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"ext","aria-hidden":"true",children:"↗"}),m.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]})]})}),r&&m.jsx(ua,{asChild:!0,children:m.jsxs("a",{id:"menu-billing",...p,onClick:y=>{p?.onClick?.(y),f(!1)},children:[m.jsx(st,{name:"card"}),m.jsx("span",{children:"Billing"}),m.jsx("span",{className:"ps-chip plan-chip",children:r.plan})]})})]}),n&&m.jsxs(m.Fragment,{children:[m.jsx(hb,{className:"menu-sec",children:"Hub"}),m.jsxs(ua,{id:"menu-hub-admin",onSelect:n.onClick,children:[m.jsx(st,{name:"shield"}),m.jsxs("span",{children:["Signup & access",n.pending?` · ${n.pending}`:""]})]})]}),m.jsx(hb,{className:"menu-sec",children:"Account"}),s&&m.jsx(ua,{asChild:!0,children:m.jsxs("a",{id:"menu-connections",...O,onClick:y=>{O.onClick?.(y),f(!1)},children:[m.jsx(st,{name:"plug"}),m.jsx("span",{children:"Connected agents"})]})}),o?m.jsxs(ua,{id:"signout",onSelect:o,children:[m.jsx(st,{name:"power"}),m.jsx("span",{children:"Sign out"})]}):m.jsx(ua,{asChild:!0,children:m.jsxs("a",{id:"signout",href:"/auth/logout",children:[m.jsx(st,{name:"power"}),m.jsx("span",{children:"Log out"})]})})]})]})]})}function zee({onSignIn:t}){return m.jsxs("footer",{id:"accountbar",children:[m.jsx(pN,{}),m.jsxs("button",{id:"account-btn",onClick:t,"aria-label":"Sign in",children:[m.jsx("span",{className:"avatar",style:{background:"var(--hover)"},"aria-hidden":"true",children:"?"}),m.jsxs("span",{className:"acct",children:[m.jsx("b",{children:"Sign in…"}),m.jsx("small",{children:"connect to your hub"})]})]})]})}function yo({className:t,orientation:e="horizontal",decorative:n=!0,...i}){return m.jsx(JU,{"data-slot":"separator",decorative:n,orientation:e,className:yt("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...i})}function Lee({url:t}){const e=nn({queryKey:["billing"],queryFn:()=>Wt(t)});if(e.isLoading)return m.jsx("div",{className:"empty",children:"Loading…"});if(e.error||!e.data)return m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"Billing is unavailable"}),m.jsx("p",{children:e.error?.message||"Try again shortly."})]});const n=e.data;return m.jsxs("div",{className:"project-settings",id:"billing-view",children:[m.jsxs("h2",{children:["Billing",m.jsx("span",{className:"ps-chip plan-chip",children:n.plan.name})]}),m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsxs(Ps,{children:[n.plan.name," plan",n.plan.status?` (${n.plan.status})`:""]}),m.jsxs(Sa,{children:["Organization ",n.org," · ",n.usage.used," of ",n.usage.cap," used · ",n.seats.used," of ",n.seats.cap," ",n.seats.cap===1?"seat":"seats"]})]}),m.jsx(yo,{}),m.jsx(wo,{children:m.jsx("div",{className:"usage-bar",children:m.jsx("div",{style:{width:`${n.usage.pct}%`}})})})]}),n.owner?m.jsx("div",{className:"plan-grid",children:n.plans.map(i=>m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsx(Ps,{children:i.name}),m.jsx(Sa,{children:i.blurb})]}),m.jsx(yo,{}),m.jsxs(wo,{children:[m.jsxs("p",{className:"plan-price",children:[i.price,m.jsx("small",{children:" / user / month"})]}),m.jsxs("form",{method:"post",action:n.checkout_url,children:[m.jsx("input",{type:"hidden",name:"plan",value:i.id}),m.jsx(at,{type:"submit",disabled:i.current,variant:i.current?"subtle":"default",children:i.current?"Current plan":`Upgrade to ${i.name}`})]})]})]},i.id))}):m.jsx("p",{className:"muted-note",children:"Only an organization owner can change the plan."}),n.owner&&n.has_customer&&m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsx(Ps,{children:"Manage subscription"}),m.jsx(Sa,{children:"Change seats, update the card, download invoices, or cancel."})]}),m.jsx(yo,{}),m.jsx(wo,{children:m.jsx("form",{method:"post",action:n.portal_url,children:m.jsx(at,{type:"submit",variant:"subtle",children:"Open the billing portal"})})})]})]})}function Fg({className:t,type:e,...n}){return m.jsx("input",{type:e,"data-slot":"input",className:yt("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30","focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",t),...n})}function pb({className:t,...e}){return m.jsx(kU,{"data-slot":"label",className:yt("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}function Zee({className:t,...e}){return m.jsx("textarea",{"data-slot":"textarea",className:yt("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...e})}const zE={read:1,write:2,admin:3};function _s(t,e){return(zE[t||""]||0)>=(zE[e]||0)}const tx=280,Iee=Q1({name:Yg().trim().min(1,"Give the project a name.").max(120,"Keep the name under 120 characters."),description:Yg().max(tx,`Keep the description under ${tx} characters.`),icon:Yg()});function Xee({project:t,org:e,onDeleted:n}){const i=sD(),r=_s(t.perm,"admin"),s=x1({resolver:R1(Iee),defaultValues:{name:t.name,description:t.description??"",icon:t.icon??""}});w.useEffect(()=>{s.reset({name:t.name,description:t.description??"",icon:t.icon??""})},[t.id,t.name,t.description,t.icon]);const o=s.watch("icon"),l=s.watch("description"),u=s.handleSubmit(async f=>{const h=s.formState.dirtyFields,p={};if(h.name&&(p.name=f.name.trim()),h.description&&(p.description=f.description),h.icon&&(p.icon=f.icon),Object.keys(p).length!==0)try{await di("PATCH","/api/projects/"+t.id,p),Ve("Saved."),s.reset({...f,name:f.name.trim()}),await i()}catch(O){Ve(O.message,!0)}});return m.jsxs("div",{className:"project-settings",children:[m.jsxs("h2",{children:[t.name,!_s(t.perm,"write")&&m.jsx("span",{className:"ps-chip",children:"Read-only"})]}),m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsx(Ps,{children:"General"}),m.jsx(Sa,{children:"Name, description and icon for this project."})]}),m.jsx(yo,{}),m.jsx(wo,{children:m.jsxs("form",{className:"ps-form",onSubmit:u,children:[m.jsxs("div",{className:"ps-field",children:[m.jsx(pb,{htmlFor:"ps-icon-btn",children:"Icon"}),m.jsxs("div",{className:"ps-icon-row",children:[m.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:xu(t.name)},children:m.jsx(iu,{name:o})}),m.jsxs(dN,{children:[m.jsx(fN,{asChild:!0,children:m.jsx(at,{id:"ps-icon-btn",type:"button",variant:"subtle",disabled:!r,children:"Change"})}),m.jsxs(hN,{align:"start",className:"ps-icon-grid",children:[m.jsx(ua,{className:"ps-icon-cell"+(o===""?" active":""),title:"Default","aria-label":"Default icon",onSelect:()=>s.setValue("icon","",{shouldDirty:!0}),children:m.jsx(iu,{})}),Object.keys(zS).map(f=>m.jsx(ua,{className:"ps-icon-cell"+(o===f?" active":""),title:f,"aria-label":f,onSelect:()=>s.setValue("icon",f,{shouldDirty:!0}),children:m.jsx(iu,{name:f})},f))]})]})]})]}),m.jsxs("div",{className:"ps-field",children:[m.jsx(pb,{htmlFor:"ps-name",children:"Name"}),m.jsx(Fg,{id:"ps-name",disabled:!r,"aria-invalid":!!s.formState.errors.name,"aria-describedby":s.formState.errors.name?"ps-name-err":void 0,...s.register("name")}),s.formState.errors.name&&m.jsx("span",{id:"ps-name-err",role:"alert",className:"field-err",children:s.formState.errors.name.message})]}),m.jsxs("div",{className:"ps-field",children:[m.jsxs(pb,{htmlFor:"ps-desc",children:["Description ",m.jsx("span",{className:"ps-opt",children:"(optional)"})]}),m.jsx(Zee,{id:"ps-desc",rows:2,disabled:!r,placeholder:"What this project is for.","aria-invalid":!!s.formState.errors.description,"aria-describedby":s.formState.errors.description?"ps-desc-err":void 0,...s.register("description")}),m.jsxs("div",{className:"ps-meta",children:[s.formState.errors.description?m.jsx("span",{id:"ps-desc-err",role:"alert",className:"field-err",children:s.formState.errors.description.message}):m.jsx("span",{}),m.jsxs("span",{className:"ps-count",children:[l.length," / ",tx]})]})]}),r&&m.jsxs(m.Fragment,{children:[m.jsx(yo,{}),m.jsx("div",{className:"ps-actions",children:m.jsx(at,{id:"ps-save",type:"submit",variant:"primary",disabled:!s.formState.isDirty||s.formState.isSubmitting,children:"Save changes"})})]})]})})]}),m.jsx(Vee,{project:t}),m.jsx(Uee,{project:t,org:e}),m.jsxs(Qs,{children:[m.jsx(As,{children:m.jsx(Ps,{children:"About"})}),m.jsx(yo,{}),m.jsxs(wo,{children:[m.jsxs("dl",{className:"ps-facts",children:[m.jsx("dt",{children:"Project id"}),m.jsx("dd",{children:m.jsx("code",{children:t.id})}),e&&m.jsxs(m.Fragment,{children:[m.jsx("dt",{children:"Workspace"}),m.jsx("dd",{children:e.name})]}),t.created&&m.jsxs(m.Fragment,{children:[m.jsx("dt",{children:"Created"}),m.jsx("dd",{children:new Date(t.created).toLocaleDateString()})]})]}),m.jsxs("p",{className:"ps-note ps-export",children:[m.jsx("strong",{children:"Take your files elsewhere."})," Run ",m.jsx("code",{children:"bdrive export"})," in the synced folder to write the whole project — every device's journal and every content blob, so full history and authorship — into a single archive. ",m.jsx("code",{children:"bdrive import"})," restores it into any other BearDrive hub, self-hosted or cloud. Export warns first if this device still has changes it hasn't pushed."," ",m.jsx("a",{href:"https://docs.beardrive.ai/reference/migration/",target:"_blank",rel:"noreferrer",children:"How migration works →"})]})]})]}),r&&m.jsxs(Qs,{className:"ps-danger",children:[m.jsx(As,{children:m.jsx(Ps,{children:"Danger zone"})}),m.jsx(yo,{}),m.jsxs(wo,{children:[m.jsx("p",{children:"Deleting removes the project from this hub. Its files stay in storage. This can't be undone."}),m.jsx(at,{variant:"danger",onClick:async()=>{if(await JM(`Delete “${t.name}”?`,"This can't be undone. Type the project name to confirm:","","Delete project",{match:t.name,danger:!0})!==null)try{await di("DELETE","/api/projects/"+t.id),Ve(`Deleted “${t.name}”.`),await n()}catch(h){Ve(h.message,!0)}},children:"Delete project"})]})]})]})}function Vee({project:t}){const e=fr(),{data:n,error:i,isLoading:r}=iD(t.id);return i?null:m.jsxs(Qs,{children:[m.jsxs(As,{children:[m.jsx(Ps,{children:"Public links"}),m.jsxs(Sa,{children:["Files in this project that anyone with the URL can read — no account needed.",(n||[]).some(s=>s.opens!==void 0)&&m.jsxs(m.Fragment,{children:[" ",lN]})]})]}),m.jsx(yo,{}),m.jsx(wo,{children:m.jsx(cN,{shares:n||[],loading:r,canRevoke:_s(t.perm,"write"),onChanged:()=>e.invalidateQueries({queryKey:["shares",t.id]}),empty:"No public links."})})]})}const nx=[{value:"admin",label:"Admin"},{value:"write",label:"Write"},{value:"read",label:"Read"},{value:"none",label:"No access"}],Bee=Object.fromEntries(nx.map(t=>[t.value,t.label]));function Uee({project:t,org:e}){const n=fr(),{data:i,error:r}=c1(t.id),s=_s(t.perm,"admin"),o=()=>{n.invalidateQueries({queryKey:["permissions",t.id]}),n.invalidateQueries({queryKey:["projects"]})},l=async(y,v)=>{try{await y(),Ve(v)}catch(S){Ve(S.message,!0)}o()};if(r||!i)return null;const u=i,f=`/api/p/${t.id}/permissions`,h=new Set((e?.members||[]).filter(y=>y.role==="owner").map(y=>y.email.toLowerCase())),p=[...u.grants.filter(y=>!h.has(y.email.toLowerCase())),...[...h].sort().map(y=>({email:y,level:"admin",owner:!0}))],O=async()=>{const y=await JM("Add an exception","Email of a workspace member. They get Read access; change it in the table.","","Add");y===null||!y.trim()||await l(()=>di("PUT",`${f}/${encodeURIComponent(y.trim())}`,{level:"read"}),"Added.")};return m.jsxs(Qs,{className:"ps-people",children:[m.jsxs(As,{children:[m.jsx(Ps,{children:"People"}),m.jsx(Sa,{children:"Who can see and change this project."})]}),m.jsx(yo,{}),m.jsxs(wo,{children:[e?.role==="owner"&&m.jsxs("p",{className:"ps-row",children:[m.jsxs("span",{children:["Not in ",e.name," yet?"]}),m.jsx(at,{id:"ps-invite",type:"button",variant:"subtle",onClick:async()=>{try{const y=await Wr(`/api/orgs/${e.id}/invites`),v=await zs(y.url+"?p="+t.id);Ve(v?"Invite link copied — it opens this project.":"Invite created — copy it from Organization settings.")}catch(y){Ve(y.message,!0)}},children:"Invite a teammate"})]}),m.jsxs("p",{className:"ps-row",children:[m.jsxs("span",{children:["Everyone in ",e?.name||"this workspace"," can"]}),m.jsx("select",{"aria-label":"Default access for workspace members",disabled:!s,value:u.default,onChange:async y=>{const v=y.target.value;if(v==="none"&&!await kl("Make this project invite-only?","Only people listed below (and workspace owners) will see this project.","Make invite-only")){o();return}await l(()=>di("PUT",f,{default:v}),"Default access updated.")},children:nx.filter(y=>y.value!=="admin").map(y=>m.jsx("option",{value:y.value,children:y.label},y.value))})]}),u.default==="none"&&m.jsx("p",{className:"ps-note",children:"This project is invite-only: only the people below and workspace owners can see it."}),m.jsxs("div",{className:"ps-people-head",children:[m.jsx("h4",{children:"Exceptions"}),s&&m.jsx(at,{type:"button",variant:"subtle",onClick:O,children:"+ Add"})]}),p.length===0?m.jsx("p",{className:"ps-note",children:"No exceptions — everyone gets the access above."}):m.jsx("div",{className:"admin-list",children:p.map(y=>{const v="owner"in y;return m.jsxs("div",{className:"admin-item",children:[m.jsxs("span",{className:"ai-main",title:y.email,children:[y.email,u.creator&&y.email.toLowerCase()===u.creator.toLowerCase()&&m.jsx("span",{className:"ai-tag",children:" (creator)"})]}),v?m.jsx("span",{className:"ai-tag",children:"Workspace owner — always admin"}):m.jsxs("span",{className:"role-cell",children:[m.jsx("select",{"aria-label":`Access for ${y.email}`,disabled:!s,value:y.level,onChange:S=>l(()=>di("PUT",`${f}/${encodeURIComponent(y.email)}`,{level:S.target.value}),`${y.email} is now ${Bee[S.target.value]||S.target.value}.`),children:nx.map(S=>m.jsx("option",{value:S.value,children:S.label},S.value))}),s&&m.jsx("button",{className:"ai-del","aria-label":`Remove exception for ${y.email}`,onClick:()=>l(()=>di("DELETE",`${f}/${encodeURIComponent(y.email)}`),"Reverted to the default access."),children:"Remove"})]})]},y.email)})})]})]})}const qee="https://raw.githubusercontent.com/runbear-io/beardrive/main/INSTALL_FOR_AGENTS.md";function A1(t,e={}){const{project:n,folder:i,existing:r}=e,s=n?"BearDrive project "+n.id:i?`the shared ${i}/ folder in my project`:"a new BearDrive project",o=r?"I already have a folder of notes — ask me which one to sync":"Ask me which folder to sync",l=n?` (the project is named "${n.name}")`:"";return`Follow ${qee} +to set up ${s} on ${t}. ${o}${l}.`}function gN({project:t,existing:e}){const n=window.location.origin,i=A1(n,{project:t,existing:e}),r=`brew install runbear-io/tap/beardrive +bdrive init --server `+n+" --project "+t.id;return m.jsxs("div",{className:"guide",children:[m.jsxs("h1",{className:"in-title gd-head",children:[m.jsx("span",{className:"proj-mark","aria-hidden":"true",style:{background:xu(t.name)},children:m.jsx(iu,{name:t.icon})}),t.name]}),t.description&&m.jsx("p",{className:"in-desc",children:t.description}),m.jsxs("div",{className:"gd-body",children:[m.jsx("p",{className:"gd-desc",children:e?"Paste into your coding agent — Claude Code, Cowork, Codex, Gemini CLI, Hermes — in the folder you already have:":"Paste into your coding agent — Claude Code, Cowork, Codex, Gemini CLI, Hermes — in the folder where you want the files:"}),e&&m.jsx("p",{className:"gd-note",children:"Your files stay exactly where they are. Connecting a folder never moves, renames or overwrites anything in it — it uploads what is there and keeps it in sync."}),m.jsx($m,{code:i}),m.jsx("p",{className:"gd-desc",children:"The agent installs the CLI, signs this machine in, and registers the sync hooks — asking before anything it changes."}),m.jsx("p",{className:"gd-desc",children:"Runs on macOS and Linux. Windows is not supported yet."}),m.jsxs("details",{className:"gd-manual",children:[m.jsx("summary",{children:"What exactly happens"}),m.jsxs("ul",{className:"gd-desc gd-list",children:[m.jsx("li",{children:"Sign-in uses a device code you approve in this browser — the folder itself never holds credentials."}),m.jsx("li",{children:"Sync hooks pull the latest before every agent turn, push edits seconds after they happen, and stamp each change with the session that made it; agent reads feed Insights. They register once per machine in your agent's own config, so every session is covered and nothing is written into the synced folder."}),m.jsx("li",{children:"Codex hooks are off by default: set [features] codex_hooks = true in ~/.codex/config.toml."})]})]}),m.jsxs("details",{className:"gd-manual",children:[m.jsx("summary",{children:"Or run it yourself"}),m.jsx("p",{className:"gd-desc",children:"Same result, in the folder you want the files. Install the CLI, point it at this hub, then bdrive init registers the sync hooks and starts syncing."}),m.jsx($m,{code:r}),m.jsx("p",{className:"gd-desc",children:m.jsx("a",{href:"https://docs.beardrive.ai/manual/install/",target:"_blank",rel:"noreferrer",children:"Full manual setup guide →"})})]})]})]})}function $m({code:t}){const[e,n]=w.useState("Copy");return m.jsxs("pre",{className:"gd-code",children:[m.jsx("code",{children:t}),m.jsx("button",{className:"gd-copy",onClick:async()=>{n(await zs(t)?"Copied":"Copy failed"),setTimeout(()=>n("Copy"),1400)},children:e})]})}function Yee({onNew:t,canCreate:e}){return m.jsxs("div",{className:"onboard",children:[m.jsx("h1",{children:"Welcome to BearDrive"}),m.jsx("p",{children:"You're signed in, but you're not part of any project yet."}),e&&m.jsxs("div",{className:"ob-card ob-start",children:[m.jsx("h3",{children:"Start a project"}),m.jsx("p",{children:"Name it and pick what it starts from — a structure, or nothing at all. Then connect a folder on any machine and it stays in sync."}),m.jsx(at,{variant:"primary",id:"ob-new",onClick:t,children:"New project"})]}),m.jsxs("div",{className:"ob-card ob-agent",children:[m.jsx("h3",{children:e?"Or let your agent do it":"Connect a new drive to your project"}),m.jsx("p",{children:"Paste into your coding agent — Claude Code, Cowork, Codex, Gemini CLI, Hermes — in the folder where you want the files. It creates the project and starts syncing:"}),m.jsx($m,{code:A1(window.location.origin)}),m.jsx("p",{className:"ob-alt",children:m.jsx("a",{href:"https://docs.beardrive.ai/manual/setup-by-hand/",target:"_blank",rel:"noreferrer",children:"Or start a project manually →"})})]})]})}function Fee({onStart:t}){return m.jsxs("div",{className:"onboard setup-welcome",children:[m.jsx("h1",{children:"Welcome to BearDrive"}),m.jsx("p",{children:"One shared drive for your team and your AI agents — every folder you connect stays in sync, with full history."}),m.jsx(at,{variant:"primary",id:"setup-start",onClick:t,children:"Get started"}),m.jsx("p",{className:"setup-foot",children:"Takes about two minutes · works offline afterwards"})]})}function Gee({data:t,name:e}){const n=t?.entries??[],i=t?.root_name||"your project";return m.jsxs("div",{className:"setup-tree","aria-label":"How it will look",children:[m.jsx("div",{className:"setup-tree-head",children:"HOW IT WILL LOOK"}),m.jsxs("div",{className:"setup-tree-root",children:[i,"/ ",m.jsx("span",{className:"setup-dim",children:"· private"})]}),n.map(r=>m.jsxs("div",{className:"setup-dim",children:["├── ",r]},r)),t?.entries_truncated&&m.jsx("div",{className:"setup-dim",children:"├── …"}),m.jsxs("div",{className:"setup-tree-shared",children:["└── ",e||"team","/ ",m.jsx("span",{className:"setup-shared-tag",children:"shared"})]}),m.jsxs("p",{className:"setup-tree-foot",children:["Only ",e||"team","/ syncs. Everything else never leaves this Mac. Teammates get the same"," ",e||"team","/ inside their own projects."]})]})}function Hee({onStarted:t}){const[e,n]=w.useState(""),[i,r]=w.useState("team"),[s,o]=w.useState(!0),[l,u]=w.useState(null),[f,h]=w.useState(!1),[p,O]=w.useState(""),[y,v]=w.useState(!1),S=w.useCallback(async Q=>{const A=window.__TAURI__?.core?.invoke;if(!(!A||!Q))try{await A("prime_folder_access",{path:Q})}catch{}},[]);w.useEffect(()=>{if(!e){u(null);return}const Q=setTimeout(async()=>{await S(e),Wt(`/api/desktop/inspect?path=${encodeURIComponent(e)}&name=${encodeURIComponent(i)}`).then(u).catch(()=>u(null))},200);return()=>clearTimeout(Q)},[e,i,S]);const k=w.useCallback(async()=>{const Q=await dm("/api/desktop/choose-folder");if(!Q.ok)return;const A=await Q.json();A.path&&(await S(A.path),n(A.path))},[S]),C=w.useCallback(async()=>{h(!0),O("");const Q=await dm("/api/desktop/init",{root:e,name:i,hooks:s});if(h(!1),!Q.ok){O((await Q.text()).trim()||"could not connect that folder");return}t(i)},[e,i,s,t]),$=!!l?.join,T=!e||!!l?.error||!!l?.conflict||f;return m.jsxs("div",{className:"setup-connect",children:[m.jsxs("header",{children:[m.jsxs("h2",{children:["Add a shared folder to your project",!$&&m.jsx("span",{className:"setup-badge",children:"RECOMMENDED"})]}),m.jsxs("p",{children:["Your project stays yours. One folder inside it is shared — your agent reads it in every session."," ",m.jsx("a",{href:"#why",onClick:Q=>(Q.preventDefault(),v(!y)),children:"Why this layout?"})]}),y&&m.jsxs("ul",{className:"setup-why",children:[m.jsx("li",{children:"Claude sessions here read and write it automatically — shared memory, no setup."}),m.jsx("li",{children:"Everything outside it stays on this Mac. Your code never syncs."}),m.jsx("li",{children:"Teammates get the same folder inside their own projects — one shared space."})]})]}),m.jsxs("div",{className:"setup-body",children:[m.jsxs("div",{className:"setup-form",children:[m.jsxs("label",{className:"setup-field",children:[m.jsx("span",{children:"Your project folder"}),m.jsxs("div",{className:"setup-root",children:[m.jsx("input",{id:"setup-root",value:e,spellCheck:!1,placeholder:"/Users/you/work/your-project",onChange:Q=>n(Q.target.value)}),m.jsx("button",{type:"button",id:"setup-choose",onClick:k,children:"Choose…"})]})]}),m.jsxs("label",{className:"setup-field",children:[m.jsx("span",{children:"Shared folder name"}),m.jsx("input",{id:"setup-name",value:i,spellCheck:!1,onChange:Q=>r(Q.target.value)})]}),m.jsxs("label",{className:"setup-toggle",children:[m.jsx("input",{type:"checkbox",id:"setup-hooks",checked:s,onChange:Q=>o(Q.target.checked)}),m.jsx("span",{children:"Claude Code integration"})]}),l?.is_claude_project&&!l?.error&&m.jsxs("p",{className:"setup-ok",children:["Claude Code project detected — ",(l.markers??[]).join(", ")]}),$&&m.jsxs("p",{className:"setup-ok",children:["Your team already shares a “",l.join.name,"” space — you'll join it."]}),(l?.error||l?.conflict||p)&&m.jsx("p",{className:"setup-err",children:p||l?.conflict||l?.error}),l?.warning&&!l?.error&&!l?.conflict&&m.jsxs("div",{className:"setup-warn",children:[m.jsx("p",{children:l.warning}),l.helper&&m.jsxs("p",{className:"setup-helper",children:["Full Disk Access wants this binary:"," ",m.jsx("code",{children:l.helper})," ",m.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(l.helper),children:"Copy path"})]})]}),m.jsx(at,{variant:"primary",id:"setup-go",disabled:T,onClick:C,children:$?`Join ${i}/ and start syncing`:`Create ${i}/ and start syncing`}),m.jsxs("p",{className:"setup-foot",children:["Prefer to share the whole folder?"," ",m.jsx("a",{href:"https://docs.beardrive.ai/manual/setup-by-hand/",target:"_blank",rel:"noreferrer",children:"Advanced"})]})]}),m.jsx(Gee,{data:l,name:i})]})]})}function Wee({onDone:t}){const e=new URLSearchParams(window.location.search).get("name")||"",[n,i]=w.useState({phase:"creating",name:e}),r=w.useRef(!1);w.useEffect(()=>{const l=setInterval(async()=>{try{const u=await Wt("/api/desktop/init/status");i({...u,name:u.name||e}),!r.current&&(u.phase==="done"||u.phase==="error")&&(r.current=!0,clearInterval(l),u.phase==="done"&&t(u))}catch{}},400);return()=>clearInterval(l)},[t]);const s=["creating","connecting","syncing","done"],o=Math.max(0,s.indexOf(n.phase));return m.jsxs("div",{className:"setup-syncing",children:[m.jsxs("h2",{children:["Syncing ",n.name?n.name+"/":"your folder"]}),m.jsx("div",{className:"setup-bar",children:m.jsx("div",{style:{width:`${(o+1)/s.length*100}%`}})}),m.jsxs("ul",{className:"setup-log",children:[m.jsx("li",{className:o>0?"ok":"",children:"created the shared folder"}),m.jsx("li",{className:o>1?"ok":"",children:n.joined?"joined the project":"created the project"}),m.jsx("li",{className:o>2?"ok":"",children:"first sync"})]}),n.phase==="error"?m.jsx("p",{className:"setup-err",id:"setup-error",children:n.error}):m.jsx("p",{className:"setup-foot",children:"You can close this window — syncing continues from the menu bar."})]})}function Kee({st:t}){const[e,n]=w.useState(""),[i,r]=w.useState(!1),[s,o]=w.useState(""),l=t.name||"team",u=A1(window.location.origin,{folder:l}),f=async(p,O)=>{try{await navigator.clipboard.writeText(O),n(p)}catch{n("")}},h=async()=>{r(!0),o("");try{const O=(await Wt("/api/orgs")).orgs[0]?.id;if(!O)throw new Error("no organization on this hub");const y=await dm(`/api/orgs/${O}/invites`,{});if(!y.ok)throw new Error((await y.text()).trim());const v=await y.json();await navigator.clipboard.writeText(v.url),n("invite")}catch(p){o(p.message||"could not create an invite link")}finally{r(!1)}};return m.jsxs("div",{className:"setup-done",children:[m.jsxs("h2",{children:[l,"/ is live"]}),m.jsxs("p",{className:"setup-foot",children:["shared inside ",t.root?t.root.split("/").pop():"your project"," · history from here on"]}),t.error&&m.jsx("p",{className:"setup-err",children:t.error}),m.jsxs("div",{className:"setup-cards",children:[m.jsxs("div",{className:"setup-card",children:[m.jsx("h3",{children:"Open the dashboard"}),m.jsx("p",{children:"Browse files, history, and who reads what."}),m.jsx(at,{id:"setup-open",onClick:()=>zt(t.project?"/"+t.project:"/"),children:"Open"})]}),m.jsxs("div",{className:"setup-card setup-card-lead",children:[m.jsx("h3",{children:"Tell your agent"}),m.jsx("p",{children:"Claude sessions in this folder now share context with your team."}),m.jsx($m,{code:u}),m.jsx(at,{id:"setup-copy-prompt",onClick:()=>f("prompt",u),children:e==="prompt"?"Copied":"Copy prompt"})]}),m.jsxs("div",{className:"setup-card",children:[m.jsx("h3",{children:"Invite teammates"}),m.jsx("p",{children:"A link that signs them up straight into this project."}),m.jsx(at,{id:"setup-invite",disabled:i,onClick:h,children:e==="invite"?"Copied":i?"…":"Copy invite link"}),s&&m.jsx("p",{className:"setup-err",id:"setup-invite-err",children:s})]})]})]})}function Jee({step:t,signedIn:e,onSignIn:n}){const[i,r]=w.useState(null);return w.useEffect(()=>{t==="welcome"&&e&&zt("/setup/connect"),t!=="welcome"&&!e&&zt("/setup")},[t,e]),m.jsxs("div",{className:"setup",children:[t==="welcome"&&m.jsx(Fee,{onStart:n}),t==="connect"&&m.jsx(Hee,{onStarted:s=>zt("/setup/syncing?name="+encodeURIComponent(s))}),t==="syncing"&&m.jsx(Wee,{onDone:s=>{r(s),zt("/setup/done")}}),t==="done"&&m.jsx(Kee,{st:i??{}})]})}const mN="__existing__";function ete({templates:t,onCreate:e,onClose:n}){const i=[...t.map(y=>({value:y.name,title:y.title,blurb:y.blurb,rule:!1})),{value:mN,title:"I already have a folder",blurb:"nothing is seeded — connect it and your files stay as they are",rule:!0},{value:"",title:"Empty project",blurb:"just the folder",rule:!1}],[r,s]=w.useState(""),[o,l]=w.useState(i[0].value),[u,f]=w.useState(""),[h,p]=w.useState(!1),O=async()=>{if(!h){if(!r.trim()){f("Give it a name.");return}p(!0);try{await e(r.trim(),o)}finally{p(!1)}}};return m.jsx(NO,{open:!0,onOpenChange:y=>!y&&n(),children:m.jsxs(zO,{className:"modal",showCloseButton:!1,children:[m.jsx(vh,{asChild:!0,children:m.jsx("h3",{children:"New project"})}),m.jsx("label",{className:"modal-label",htmlFor:"modal-input",children:"Name"}),m.jsx("input",{className:"modal-input",type:"text",autoComplete:"off",id:"modal-input",autoFocus:!0,value:r,"aria-invalid":!!u,"aria-describedby":u?"modal-input-err":void 0,onChange:y=>{s(y.currentTarget.value),u&&f("")},onKeyDown:y=>y.key==="Enter"&&O()}),u&&m.jsx("span",{id:"modal-input-err",role:"alert",className:"field-err",children:u}),i.length>1&&m.jsxs("fieldset",{className:"start-points",children:[m.jsx("legend",{className:"modal-label",children:"Starting point"}),i.map((y,v)=>m.jsxs("label",{className:"start-point"+(o===y.value?" on":"")+(y.rule?" sp-rule":""),children:[m.jsx("input",{type:"radio",name:"template",value:y.value,checked:o===y.value,onChange:()=>l(y.value)}),m.jsxs("span",{className:"sp-text",children:[m.jsxs("span",{className:"sp-title",children:[y.title,v===0&&m.jsx("span",{className:"sp-rec",children:"Recommended"})]}),m.jsx("span",{className:"sp-blurb",children:y.blurb})]})]},y.value))]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx(at,{variant:"subtle",onClick:n,children:"Cancel"}),m.jsx(at,{variant:"primary",onClick:O,disabled:h,children:"Create"})]})]})})}function gb(t,e,n){if(!t)return null;if(!n)return t[e]||null;const i={human:0,agent:0,share:0};for(const[r,s]of Object.entries(t))r.startsWith(e+"/")&&(i.human+=s.human||0,i.agent+=s.agent||0,i.share+=s.share||0);return i.human||i.agent||i.share?i:null}function vo(t){return(t.human||0)+(t.agent||0)+(t.share||0)}function df(t){const e=vo(t);if(!e)return"";const n=e+(e===1?" read":" reads");if(!t.agent&&!t.share)return n;const i=[];return t.human&&i.push(t.human+" human"),t.agent&&i.push(t.agent+" agent"),t.share&&i.push(t.share+" shared"),n+" ("+i.join(", ")+")"}const _l="Includes your own views. Repeat opens by the same reader inside 10 minutes count once.";function tte(t){const e=vo(t);return e?e<3?1:e<10?2:e<30?3:4:0}function nte(t){const e=vo(t);return e?{agent:(t.agent||0)/e,human:(t.human||0)/e,share:(t.share||0)/e}:{agent:0,human:0,share:0}}function ite(t,e){return t?Object.keys(t).filter(n=>!e.has(n)).sort():[]}const rte=7;function ste(t){if(!t.length)return null;let e=t[0],n=t[0];for(const i of t)in&&(n=i);return{min:e,max:n}}const ote=(t,e)=>e-ts.reads-r.reads).slice(0,lte)){const r=i.path.split("/").pop();let s=i.cx+i.r+4,o="start";s+r.length*cte>e.right&&(s=i.cx-i.r-4,o="end");const l=f=>n.every(h=>Math.abs(h.y-f)>=mb);let u=i.cy;for(;u<=e.bottom&&!l(u);)u+=mb;if(u>e.bottom)for(u=i.cy;u>=e.top&&!l(u);)u-=mb;n.push({path:i.path,name:r,x:s,y:Math.min(e.bottom,Math.max(e.top,u)),anchor:o})}return n}const ff=3,Ic=30,ON=(t,e)=>t>=ff&&e>=Ic;function dte(t,e=Date.now()){if(!t)return null;const n=new Date(t).getTime();return Number.isFinite(n)?Math.max(0,(e-n)/864e5):null}function fte(t){const e=new Intl.RelativeTimeFormat("en",{numeric:"always"});return t<30?e.format(-Math.round(t),"day"):t<365?e.format(-Math.round(t/30),"month"):e.format(-Math.round(t/365),"year")}function yN(t,e){const n=dte(e);return!t||n===null||!ON(vo(t),n)?"":`stale · last changed ${fte(n)}`}function hte(t,e=!0){const n=nn({queryKey:["tree",t],queryFn:()=>Wt(t+"tree?slim=1"),enabled:e,refetchInterval:3e5}),i=w.useMemo(()=>{const r=[],s=new Map,o=(l,u)=>{for(const f of l.children||[])f.path=u?u+"/"+f.name:f.name,f.dir?(s.set(f.path,f),o(f,f.path)):r.push(f)};return n.data&&o(n.data,""),{flatFiles:r,dirIndex:s}},[n.data]);return{tree:n.data,...i,loaded:!!n.data}}function pte(t,e){return nn({queryKey:["heat",t],queryFn:()=>Wt(t+"heat?days=30"),enabled:e,staleTime:6e4}).data?.entries??null}function gte(t,e,n){return nn({queryKey:["history",t,"prefix",e,20],queryFn:()=>Wt(t+"history?prefix="+encodeURIComponent(e)+"&n=20"),enabled:n,staleTime:15e3}).data?.entries??null}const vN=1<<20,mte=8192;function Ote(t){if(t.byteLength>vN)return{kind:"too-large",size:t.byteLength};if(t.subarray(0,mte).includes(0))return{kind:"binary"};try{return{kind:"text",text:new TextDecoder("utf-8",{fatal:!0}).decode(t)}}catch{return{kind:"binary"}}}function Tm(t,e,n,i){let r=t+"blob?sha="+encodeURIComponent(e);return n&&(r+="&name="+encodeURIComponent(n)),i&&(r+="&download=1"),r}async function bN(t){const e=await UX(t),n=Number(e.headers.get("Content-Length")??e.headers.get("X-Uncompressed-Length"));if(n>vN)return{kind:"too-large",size:n};const i=Ote(new Uint8Array(await e.arrayBuffer())),r=e.headers.get("ETag")?.replace(/^W\/|"/g,"");return i.kind==="text"&&r?{...i,sha:r}:i}function Nf(t,e,n){return n?Tm(t,n,e):t+"file?path="+encodeURIComponent(e)}function yte(t){return!(t instanceof xw)||t.status===429||t.status>=500}function P1(t,e,n,i){return nn({queryKey:e,queryFn:()=>bN(t),enabled:n,...i?{staleTime:1/0,gcTime:1/0}:{},retry:i?!1:(r,s)=>r<3&&yte(s),retryDelay:r=>Math.min(1e3*2**r,8e3)})}function LE(t,e,n){return P1(e?Tm(t,e):"",["blob",t,e],!!e,!0)}function vte(t,e=!0,n){const i=fr(),r=w.useRef(n);r.current=n,w.useEffect(()=>{if(!e||typeof EventSource>"u")return;const s=2e3;let o=null;const l=()=>{o||(o=setTimeout(()=>{o=null,i.invalidateQueries({queryKey:["tree",t]}),i.invalidateQueries({queryKey:["history",t]})},s))},u=k=>{let C;try{C=JSON.parse(k)}catch{return}if(C.type==="presence"){r.current?.(C.people??[]);return}if(window.dispatchEvent(new CustomEvent("bdrive:changed",{detail:C.paths??[]})),l(),C.type==="resync"||C.more||!C.paths?.length){i.invalidateQueries({queryKey:["render",t]}),i.invalidateQueries({queryKey:["text"]});return}for(const $ of C.paths)i.invalidateQueries({queryKey:["render",t,$]}),i.invalidateQueries({queryKey:["text",Nf(t,$)]})},f=`bdrive:events:${t}`;let h=null,p=null,O=null;const y=new AbortController;let v=!1;const S=()=>{h=new EventSource(t+"events"),h.onmessage=k=>{p?.postMessage(k.data),u(k.data)},h.onerror=()=>{}};return typeof BroadcastChannel>"u"||!navigator.locks?S():(p=new BroadcastChannel(f),p.onmessage=k=>u(k.data),navigator.locks.request(`${f}:leader`,{signal:y.signal},()=>new Promise(k=>{if(v)return k();O=k,S()})).catch(()=>{})),()=>{v=!0,y.abort(),O?.(),h?.close(),p?.close()}},[t,e,i])}const bte=1e4;function Ste(t,e,n=!0){const[i,r]=w.useState([]),s=w.useRef(e);return s.current=e,w.useEffect(()=>{if(!n)return;let o=!0;const l=async(f=!1)=>{try{const h=await Wr(t+"presence",{path:s.current,...f?{leave:!0}:{}});o&&!f&&r(h.people??[])}catch{}};l();const u=setInterval(l,bte);return()=>{o=!1,clearInterval(u),l(!0)}},[t,n]),{people:i,setPeople:r}}function xte(t){const e=t.trim().split(/[\s@._-]+/).filter(Boolean);return e.length?(e[0][0]+(e[1]?.[0]??"")).toUpperCase():"?"}function ZE(t){let e=0;for(let n=0;n{const l=e&&s.path===e?0:1,u=e&&o.path===e?0:1;return l-u}),i=n.slice(0,5),r=n.length-i.length;return m.jsxs("div",{id:"presence",className:"flex items-center gap-1","aria-label":"People viewing this project",children:[i.map((s,o)=>m.jsx("span",{title:s.path?`${s.name} — ${s.path}`:s.name,className:"inline-flex h-6 w-6 items-center justify-center rounded-full text-[10px] font-medium ring-1 ring-black/10",style:{backgroundColor:`hsl(${ZE(s.name)} 70% 88%)`,color:`hsl(${ZE(s.name)} 60% 28%)`,outline:e&&s.path===e?"2px solid hsl(var(--ring))":void 0,outlineOffset:"1px"},children:xte(s.name)},s.name+o)),r>0&&m.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",r]})]})}function SN(t,e){let n;for(const i of t)e.startsWith(i.prefix)&&(!n||i.prefix.length>n.prefix.length)&&(n=i);return n}function kte(t,e,n){const i=new Array(t);return new Proxy(i,{get(r,s,o){if(typeof s=="string"){const l=s.charCodeAt(0);if(l>=48&&l<=57){const u=+s;if(Number.isInteger(u)&&u>=0&&ui[h]!==f))&&(i=l,r=e(...l),n?.onChange&&!(s&&n.skipInitialOnChange)&&n.onChange(r),s=!1),r}return o.updateDeps=l=>{i=l},o}function IE(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const Cte=(t,e)=>Math.abs(t-e)<1.01,_te=(t,e,n)=>{let i;return function(...r){t.clearTimeout(i),i=t.setTimeout(()=>e.apply(this,r),n)}};let Wd;const Ob=()=>{if(Wd!==void 0)return Wd;if(typeof navigator>"u")return Wd=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Wd=!0;const t=navigator.maxTouchPoints;return Wd=navigator.platform==="MacIntel"&&t!==void 0&&t>0},XE=t=>{const{offsetWidth:e,offsetHeight:n}=t;return{width:e,height:n}},$te=t=>t,Tte=t=>{const e=Math.max(t.startIndex-t.overscan,0),i=Math.min(t.endIndex+t.overscan,t.count-1)-e+1,r=new Array(i);for(let s=0;s{const n=t.scrollElement;if(!n)return;const i=t.targetWindow;if(!i)return;const r=o=>{const{width:l,height:u}=o;e({width:Math.round(l),height:Math.round(u)})};if(r(XE(n)),!i.ResizeObserver)return()=>{};const s=new i.ResizeObserver(o=>{const l=()=>{const u=o[0];if(u?.borderBoxSize){const f=u.borderBoxSize[0];if(f){r({width:f.inlineSize,height:f.blockSize});return}}r(XE(n))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},Em={passive:!0},Rte=typeof window>"u"?!0:"onscrollend"in window,Qte=(t,e,n)=>{const i=t.scrollElement;if(!i)return;const r=t.targetWindow;if(!r)return;const s=t.options.useScrollendEvent&&Rte;let o=0;const l=s?null:_te(r,()=>e(o,!1),t.options.isScrollingResetDelay),u=p=>()=>{o=n(i),l?.(),e(o,p)},f=u(!0),h=u(!1);return i.addEventListener("scroll",f,Em),s&&i.addEventListener("scrollend",h,Em),()=>{i.removeEventListener("scroll",f),s&&i.removeEventListener("scrollend",h)}},Ate=(t,e)=>Qte(t,e,n=>{const{horizontal:i,isRtl:r}=t.options;return i?n.scrollLeft*(r&&-1||1):n.scrollTop}),Pte=(t,e,n)=>{if(n.options.useCachedMeasurements){const i=n.indexFromElement(t),r=n.options.getItemKey(i);return n.itemSizeCache.get(r)??n.options.estimateSize(i)}if(e?.borderBoxSize){const i=e.borderBoxSize[0];if(i)return Math.round(i[n.options.horizontal?"inlineSize":"blockSize"])}if(!e){const i=n.indexFromElement(t),r=n.options.getItemKey(i),s=n.itemSizeCache.get(r);if(s!==void 0)return s}return t[n.options.horizontal?"offsetWidth":"offsetHeight"]},jte=(t,{adjustments:e=0,behavior:n},i)=>{var r,s;(s=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||s.call(r,{[i.options.horizontal?"left":"top"]:t+e,behavior:n})},Mte=jte;class Dte{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,i,r;return((r=(i=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let n=null;const i=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(s=>{const o=()=>{const l=s.target,u=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[f,h]of this.elementsCache)if(h===l){this.elementsCache.delete(f);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(l,s,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),n=null},observe:r=>{var s;return(s=i())==null?void 0:s.observe(r,{box:"border-box"})},unobserve:r=>{var s;return(s=i())==null?void 0:s.unobserve(r)}}})(),this.range=null,this.setOptions=n=>{var i,r;const s={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:$te,rangeExtractor:Tte,onChange:()=>{},measureElement:Pte,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const O in n){const y=n[O];y!==void 0&&(s[O]=y)}const o=this.options;let l=null,u=null,f=!1;if(o!==void 0&&o.enabled&&s.enabled&&s.anchorTo==="end"&&this.scrollElement!==null){const O=o.count,y=s.count,v=this.getMeasurements(),S=O>0?((i=v[0])==null?void 0:i.key)??o.getItemKey(0):null,k=O>0?((r=v[O-1])==null?void 0:r.key)??o.getItemKey(O-1):null;if(y!==O||O>0&&y>0&&(s.getItemKey(0)!==S||s.getItemKey(y-1)!==k)){f=!0;const T=O>0?this.getVirtualItemForOffset(this.getScrollOffset())??v[0]:null;T&&(l=[T.key,this.getScrollOffset()-T.start]);const Q=s.followOnAppend===!0?"auto":s.followOnAppend||null;Q&&y>O&&this.isAtEnd(o.scrollEndThreshold)&&(O===0||s.getItemKey(y-1)!==k)&&(u=Q)}}this.options=s,f&&(this.pendingMin=0,this.itemSizeCacheVersion++);let h=!1,p=0;if(l&&this.scrollOffset!==null){const[O,y]=l,v=this.getMeasurements(),{count:S,getItemKey:k}=this.options;let C=0;for(;C{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,n)},this.maybeNotify=Lc(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}if(this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{if(o&&this._intendedScrollOffset===null&&s===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(s-this._intendedScrollOffset)<1.5&&(s=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const l=this.getScrollOffset();this.scrollDirection=o?l===s?this.scrollDirection:l{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},l=()=>{this._iosTouching=!1,!(!Ob()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};s.addEventListener("touchstart",o,Em),s.addEventListener("touchend",l,Em),this.unsubs.push(()=>{s.removeEventListener("touchstart",o),s.removeEventListener("touchend",l),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[s,o,l,u]=r;s!==null&&!l&&(Ob()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),i=this.getMaxScrollOffset();if(n<0||n>i)return;const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Lc(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,i,r,s,o,l,u,f)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:i,scrollMargin:r,getItemKey:s,enabled:o,lanes:l,laneAssignmentMode:u,gap:f}),{key:!1}),this.getMeasurements=Lc(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:i,scrollMargin:r,getItemKey:s,enabled:o,lanes:l,laneAssignmentMode:u,gap:f},h)=>{const p=this.itemSizeCache;if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const C of this.laneAssignments.keys())C>=n&&this.laneAssignments.delete(C);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(C=>{this.itemSizeCache.set(C.key,C.size)}));const O=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),l===1){const C=n*2;let $=this._flatMeasurements;if(!$||$.length0&&A.set($.subarray(0,O*2)),$=A,this._flatMeasurements=$}let T;if(O===0)T=i+r;else{const A=O-1;T=$[A*2]+$[A*2+1]+f}for(let A=O;A1){Q=T;const G=v[Q],Y=G!==void 0?y[G]:void 0;A=Y?Y.end+f:i+r}else if(k===l){let G=0,Y=S[0],K=v[0];for(let se=1;sethis.options.debug}),this.calculateRange=Lc(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,i,r,s)=>n.length===0||i===0?(this.range=null,null):(this.range=zte(n,i,r,s,s===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Lc(()=>{let n=null,i=null;const r=this.calculateRange();return r&&(n=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,i]},(n,i,r,s,o)=>s===null||o===null?[]:n({startIndex:s,endIndex:o,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const i=this.options.indexAttribute,r=n.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const s=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,r-s),l=Math.min(this.options.count-1,r+s);return n>=o&&n<=l}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,l)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(l))});return}const i=this.indexFromElement(n),r=this.options.getItemKey(i),s=this.elementsCache.get(r);s!==n&&(s&&this.observer.unobserve(s),this.observer.observe(n),this.elementsCache.set(r,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,i)=>{var r,s;if(n<0||n>=this.options.count)return;let o,l,u;const f=this._flatMeasurements;if(this.options.lanes===1&&f!==null)u=this.options.getItemKey(n),l=f[n*2],o=f[n*2+1];else{const O=this.measurementsCache[n];if(!O)return;u=O.key,l=O.start,o=O.size}const h=this.itemSizeCache.get(u)??o,p=i-h;if(p!==0){const O=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,y=O?this.getTotalSize():0,v=((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:u,start:l,size:o,end:l+o,lane:0},p,this):l[this.getVirtualIndexes(),this.getMeasurements()],(n,i)=>{const r=[];for(let s=0,o=n.length;sthis.options.debug}),this.getVirtualItemForOffset=n=>{const i=this.getMeasurements();if(i.length===0)return;const r=this._flatMeasurements,s=this.options.lanes===1&&r!=null,o=xN(0,i.length-1,s?l=>r[l*2]:l=>IE(i[l]).start,n);return IE(i[o])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,i,r=0)=>{if(!this.scrollElement)return 0;const s=this.getSize(),o=this.getScrollOffset();i==="auto"&&(i=n>=o+s?"end":"start"),i==="center"?n+=(r-s)/2:i==="end"&&(n-=s);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,i="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getSize(),s=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(i==="auto")if(o.end>=s+r-this.options.scrollPaddingEnd)i="end";else if(o.start<=s+this.options.scrollPaddingStart)i="start";else return[s,i];if(i==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),i];const l=i==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,i,o.size),i]},this.scrollToOffset=(n,{align:i="start",behavior:r="auto"}={})=>{const s=this.getOffsetForAlignment(n,i),o=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:o,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:i="auto",behavior:r="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.getOffsetForIndex(n,i);if(!s)return;const[o,l]=s,u=this.now();this.scrollState={index:n,align:l,behavior:r,startedAt:u,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+n,s=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:s,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const i=this.getMeasurements();let r;if(i.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const s=i.length-1,o=this._flatMeasurements;o!=null?r=o[s*2]+o[s*2+1]:r=((n=i[s])==null?void 0:n.end)??0}else{const s=Array(this.options.lanes).fill(null);let o=i.length-1;for(;o>=0&&s.some(l=>l===null);){const l=i[o];s[l.lane]===null&&(s[l.lane]=l.end),o--}r=Math.max(...s.filter(l=>l!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const i=this.getMeasurements();for(const r of i)r&&this.itemSizeCache.has(r.key)&&n.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return n},this._scrollToOffset=(n,{adjustments:i,behavior:r})=>{this._intendedScrollOffset=n+(i??0),this.options.scrollToFn(n,{behavior:r,adjustments:i},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,n){e!==0&&(Ob()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,s=1,o=r!==this.scrollState.lastTargetOffset;if(!o&&Cte(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=s){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,o){const l=this.getSize()||600,u=Math.abs(r-this.getScrollOffset()),f=this.scrollState.behavior==="smooth"&&u>l;this.scrollState.lastTargetOffset=r,f||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:f?"smooth":"auto"})}this.scheduleScrollReconcile()}}const xN=(t,e,n,i)=>{for(;t<=e;){const r=(t+e)/2|0,s=n(r);if(si)e=r-1;else return r}return t>0?t-1:0};function Nte(t,e,n){let i=0;for(;i<=e;){const r=(i+e)/2|0,s=t[r*2];if(sn)e=r-1;else return r}return i>0?i-1:0}function zte(t,e,n,i,r){const s=t.length-1;if(t.length<=i)return{startIndex:0,endIndex:s};if(i===1&&r!==null){const f=Nte(r,s,n);let h=f;const p=n+e;for(;ht[f].start,n),u=l;if(i===1)for(;u1){const f=Array(i).fill(0);for(;up=0&&h.some(p=>p>=n);){const p=t[l];h[p.lane]=p.start,l--}l=Math.max(0,l-l%i),u=Math.min(s,u+(i-1-u%i))}return{startIndex:l,endIndex:u}}const yb=typeof document<"u"?w.useLayoutEffect:w.useEffect;function Lte({useFlushSync:t=!0,directDomUpdates:e=!1,directDomUpdatesMode:n="transform",...i}){const r=w.useReducer(f=>f+1,0)[1],s=w.useRef({enabled:e,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});s.current.enabled=e,s.current.mode=n;const o=f=>{const h=s.current;if(!h.enabled||!h.container)return;const p=f.getTotalSize();if(p!==h.lastSize){h.lastSize=p;const C=f.options.horizontal?"width":"height";h.container.style[C]=`${p}px`}const O=!!f.options.horizontal,y=h.mode==="transform",v=O?"left":"top",S=f.options.scrollMargin,k=f.getVirtualItems();for(const C of k){const $=C.start-S,T=f.elementsCache.get(C.key);T&&h.lastPositions.get(T)!==$&&(h.lastPositions.set(T,$),y?T.style.transform=O?`translate3d(${$}px, 0, 0)`:`translate3d(0, ${$}px, 0)`:T.style[v]=`${$}px`)}},l={...i,onChange:(f,h)=>{var p;const O=s.current;let y=!0;if(O.enabled){o(f);const v=f.range,S=O.prevRange;y=!S||S.isScrolling!==f.isScrolling||S.startIndex!==v?.startIndex||S.endIndex!==v?.endIndex,y&&(O.prevRange=v?{startIndex:v.startIndex,endIndex:v.endIndex,isScrolling:f.isScrolling}:null)}y&&(t&&h?ql.flushSync(r):r()),(p=i.onChange)==null||p.call(i,f,h)}},[u]=w.useState(()=>{const f=new Dte(l);return Object.assign(f,{containerRef:h=>{const p=s.current;if(p.container=h,p.lastSize=null,h&&p.enabled){const O=f.getTotalSize();p.lastSize=O;const y=f.options.horizontal?"width":"height";h.style[y]=`${O}px`}}})});return u.setOptions(l),yb(()=>u._didMount(),[]),yb(()=>u._willUpdate()),yb(()=>{o(u)}),u}function Zte(t){return Lte({observeElementRect:Ete,observeElementOffset:Ate,scrollToFn:Mte,...t})}function Ite(t,e){const n=[],i=(r,s)=>{for(const o of r)n.push({node:o,depth:s}),o.dir&&e.has(o.path)&&i(o.children||[],s+1)};return i(t?.children||[],0),n}function Xte(t){const{root:e,expanded:n,onToggle:i,currentPath:r,listingShowing:s,restricted:o,onOpen:l}=t,u=w.useRef(null),f=w.useMemo(()=>Ite(e,n),[e,n]),h=Zte({count:f.length,getScrollElement:()=>u.current,estimateSize:()=>window.matchMedia("(max-width: 768px)").matches?44:28,overscan:12,getItemKey:p=>f[p].node.path});return w.useEffect(()=>{if(!r)return;const p=f.findIndex(O=>O.node.path===r);p>=0&&h.scrollToIndex(p,{align:"auto"})},[r,f]),m.jsx("nav",{id:"tree","aria-label":"Files",ref:u,children:m.jsx("div",{style:{height:h.getTotalSize(),position:"relative"},children:h.getVirtualItems().map(p=>{const{node:O,depth:y}=f[p.index],v=O.dir?n.has(O.path):!1,S=()=>{if(O.dir&&r===O.path&&s){i(O.path);return}l(O.path),O.dir||Fr()};return m.jsxs("div",{className:"row "+(O.dir?"dir":"file")+(r===O.path?" active":"")+(O.dir&&!v?" collapsed":""),"data-path":O.path,tabIndex:0,role:"button",title:O.name,"aria-expanded":O.dir?v:void 0,style:{position:"absolute",top:0,left:0,right:0,transform:`translateY(${p.start}px)`,paddingLeft:8+y*13},onClick:S,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),S())},children:[Array.from({length:y},(k,C)=>m.jsx("span",{className:"tguide",style:{left:8+C*13+5},"aria-hidden":"true"},C)),m.jsx("span",{className:"chev",onClick:k=>{O.dir&&(k.stopPropagation(),i(O.path))},children:m.jsx(st,{name:"chevd"})}),m.jsx("span",{className:"ticon",children:m.jsx(st,{name:O.dir?"folder":"doc"})}),m.jsx("span",{className:"label",children:O.name}),O.dir&&o.has(O.path)&&m.jsx("span",{className:"trestricted",role:"img","aria-label":O.name+" is a restricted folder",title:"Restricted — not everyone in the workspace has the same access here",children:m.jsx(st,{name:"lock"})})]},p.key)})})})}function Vte(t){const e=t.split("/"),n=[];let i="";for(let r=0;r{i=i?i+"/"+r:r;const o=i,l=s===n.length-1;return m.jsxs("span",{children:[s>0&&m.jsx("span",{className:"crumb-sep",children:"/"}),l?m.jsx("span",{children:r}):m.jsx("span",{className:"crumb-seg",title:o,onClick:()=>e(o),children:r})]},o)})})}const Ute=/\.bdrive-conflict-([A-Za-z0-9_-]{0,32})-(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z$/;function wN(t){const e=Ute.exec(t);if(!e)return null;const[,n,i,r,s,o,l,u]=e,f=new Date(Date.UTC(+i,+r-1,+s,+o,+l,+u));return f.getUTCFullYear()!==+i||f.getUTCMonth()!==+r-1||f.getUTCDate()!==+s||f.getUTCHours()!==+o||f.getUTCMinutes()!==+l||f.getUTCSeconds()!==+u?null:{original:t.slice(0,e.index),device:n,when:f}}function qte(t,e,n){const i=f=>String(f).padStart(2,"0"),r=String(n.getUTCFullYear())+i(n.getUTCMonth()+1)+i(n.getUTCDate())+"T"+i(n.getUTCHours())+i(n.getUTCMinutes())+i(n.getUTCSeconds())+"Z",s=".bdrive-conflict-"+e.replace(/[^A-Za-z0-9_-]/g,"-").slice(0,32)+"-"+r,o=t.lastIndexOf("/"),l=o<0?"":t.slice(0,o+1),u=o<0?t:t.slice(o+1);return l+u.slice(0,Math.max(0,255-s.length))+s}function VE(t){if(t==="")return[];const e=t.split(` +`);return e[e.length-1]===""&&e.pop(),e}const Yte=4e6;function Fte(t,e){let n=0;for(;nr.push({op:"-",line:s[p],an:n+p+1}),h=p=>r.push({op:"+",line:o[p],bn:n+p+1});if(l*u>Yte){for(let p=0;p=0;v--)for(let S=u-1;S>=0;S--)p[v][S]=s[v]===o[S]?p[v+1][S+1]+1:Math.max(p[v+1][S],p[v][S+1]);let O=0,y=0;for(;O=p[O][y+1]?f(O++):h(y++);for(;Oi.op==="+").length,del:n.filter(i=>i.op==="-").length}}function Hte(t,e){if(t===e)return null;const n=Math.min(t.length,e.length);let i=0;for(;ir.data?.kind==="text"&&s.data?.kind==="text"?Gte(r.data.text,s.data.text):null,[r.data,s.data]);if(r.error||s.error)return m.jsx("div",{className:"dv dv-msg",children:"Could not load one of the versions."});if(!r.data||!s.data)return m.jsx("div",{className:"dv dv-msg",children:"Loading changes…"});if(!o){const p=r.data.kind==="too-large"||s.data.kind==="too-large";return m.jsxs("div",{className:"dv dv-msg",children:[p?"Too large to diff — download to compare.":"Binary file — no diff available.",m.jsx(Kte,{apiBase:t,path:e,prev:n,cur:i})]})}const{lines:u,add:f,del:h}=l;return m.jsxs("div",{className:"dv",children:[m.jsxs("div",{className:"dv-head",children:[m.jsxs("span",{className:"dv-stat",children:[m.jsxs("span",{className:"dv-add",children:["+",f]})," ",m.jsxs("span",{className:"dv-del",children:["−",h]})]}),f===0&&h===0&&m.jsx("span",{className:"dv-same",children:"No line changes"})]}),m.jsx("div",{className:"dv-body",children:u.map((p,O)=>m.jsxs("div",{className:"dv-line dv-"+(p.op==="="?"ctx":p.op==="+"?"ins":"rm"),children:[m.jsx("span",{className:"dv-n",children:p.an??""}),m.jsx("span",{className:"dv-n",children:p.bn??""}),m.jsx("span",{className:"dv-mark",children:p.op==="="?" ":p.op}),m.jsx("span",{className:"dv-text",children:p.line||" "})]},O))})]})}const ene={add:"added",edit:"edited",delete:"deleted"};function kN({text:t}){return m.jsx(m.Fragment,{children:t.split(/(https?:\/\/\S+)/).map((e,n)=>/^https?:\/\//.test(e)?m.jsx("a",{href:e,target:"_blank",rel:"noopener",children:e},n):e)})}function j1({entry:t,apiBase:e,onOpen:n,diff:i,restore:r,remove:s,restoreSha:o,recreates:l,inRun:u,read:f}){const[h,p]=w.useState(!1),[O,y]=w.useState(!1),v=t.kind==="put"?"edit":t.kind,S=MO(t),k=[t.device.name||t.device.id,t.device.os].filter(Boolean).join(" · "),C=v!=="delete",$=!!i&&v!=="delete"&&!!t.blob,T=!!u&&v==="add",Q=!!r&&!!o&&!T,A=!!s&&T,R=!!r?.busy&&r.busy===t.path+o,P=!!s?.busy&&s.busy===t.path,X=C&&!!t.blob,te=t.path.split("/").pop()||t.path,G=new Date(t.time).toLocaleString(),Y=e+"blob?sha="+t.blob+"&name="+encodeURIComponent(te)+"&download=1",K=()=>y(!O),se=H=>{H.target.tagName!=="A"&&C&&n(t.path,t.blob)};return m.jsxs("div",{className:"hentry "+v+(C?" clickable":""),tabIndex:C?0:void 0,role:C?"button":void 0,onClick:se,onKeyDown:H=>{C&&(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),n(t.path,t.blob))},children:[m.jsxs("div",{className:"hline",children:[m.jsx("span",{className:"hkind",children:ene[v]||v}),f&&m.jsx("span",{className:"hread",title:"This run read this file before changing it",children:"read"}),m.jsx("span",{className:"hpath",children:t.path}),m.jsx("span",{className:"htime",children:G})]}),m.jsxs("div",{className:"hmeta",children:[m.jsx("span",{className:"hwho",children:S}),m.jsx("span",{className:"hdev",children:k}),m.jsx("span",{className:"hsize",children:t.size?s1(t.size):""}),Q&&m.jsxs("button",{type:"button",className:"hrestore-btn",disabled:R,title:"Put this version of "+t.path+" back as a new change",onClick:H=>{H.stopPropagation(),r.onRestore(t.path,o,!!l)},onKeyDown:H=>H.stopPropagation(),children:[m.jsx(st,{name:"hist"}),R?"restoring…":"restore"]}),A&&m.jsxs("button",{type:"button",className:"hremove-btn",disabled:P,title:"Remove "+t.path+" — this run created it",onClick:H=>{H.stopPropagation(),s.onRemove(t.path)},onKeyDown:H=>H.stopPropagation(),children:[m.jsx(st,{name:"trash"}),P?"removing…":"undo — remove file"]})]}),t.note&&!u&&m.jsx("div",{className:"hnote"+(h?" open":""),tabIndex:0,role:"button",title:h?"Collapse note":"Show full note","aria-expanded":h,onClick:H=>{H.stopPropagation(),H.target.tagName!=="A"&&p(!h)},onKeyDown:H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),H.stopPropagation(),p(!h))},children:m.jsx(kN,{text:t.note})}),($||X)&&m.jsxs("div",{className:"hactions",children:[$&&(i.prev?m.jsxs("button",{type:"button",className:"hdiff-btn"+(O?" open":""),"aria-expanded":O,onClick:H=>{H.stopPropagation(),K()},onKeyDown:H=>H.stopPropagation(),children:[m.jsx(st,{name:O?"chevd":"chev"}),O?"hide changes":"show changes"]}):m.jsx("div",{className:"hdiff-none",children:"First version — nothing to compare against"})),X&&m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",className:"hver-btn","aria-label":`Open ${te} as of ${G}`,onClick:H=>{H.stopPropagation(),n(t.path,t.blob)},onKeyDown:H=>H.stopPropagation(),children:[m.jsx(st,{name:"clock"}),"Open this version"]}),m.jsxs("a",{className:"hver-btn",download:!0,href:Y,"aria-label":`Download ${te} as of ${G}`,onClick:H=>H.stopPropagation(),onKeyDown:H=>{H.stopPropagation(),H.key===" "&&(H.preventDefault(),H.currentTarget.click())},children:[m.jsx(st,{name:"download"}),"Download"]})]})]}),$&&i.prev&&O&&m.jsx("div",{onClick:H=>H.stopPropagation(),children:m.jsx(Jte,{apiBase:i.apiBase,path:t.path,prev:i.prev,cur:t.blob})})]})}function tne(t){const{node:e,heatMap:n,folders:i,onOpen:r}=t,s=(e.children||[]).slice().sort((p,O)=>Number(O.dir||!1)-Number(p.dir||!1)||p.name.localeCompare(O.name)),o=s.filter(p=>p.dir).length,l=s.length-o,u=[];o&&u.push(o+(o===1?" folder":" folders")),l&&u.push(l+(l===1?" file":" files"));const f=gb(n,e.path,!0);f&&u.push(df(f)+" in 30 days");const h=!!f||s.some(p=>gb(n,p.path,!!p.dir));return m.jsxs("div",{className:"dirlist",children:[m.jsxs("h1",{className:"dl-title",children:[m.jsx("span",{className:"dl-title-icon",children:m.jsx(st,{name:"folder"})}),m.jsx("span",{children:e.name})]}),m.jsx("p",{className:"dl-sub",children:u.join(" · ")||"Empty folder"}),h&&m.jsx("p",{className:"dl-heatnote",children:_l}),s.length===0?m.jsx("div",{className:"dl-empty",children:"Nothing in this folder yet."}):m.jsx("div",{className:"dl-items",children:s.map(p=>{let O="";if(p.dir){const C=(p.children||[]).length;O=C+(C===1?" item":" items")}else O=[p.size?s1(p.size):"",p.time?new Date(p.time).toLocaleDateString():""].filter(Boolean).join(" · ");const y=gb(n,p.path,!!p.dir);y&&(O=df(y)+(O?" · "+O:""));const v=p.dir?null:wN(p.path),S=p.dir?i.find(C=>C.prefix===p.path+"/"):void 0,k=p.dir?"":yN(y,p.time);return m.jsxs("div",{className:"dl-row",tabIndex:0,role:"button",title:p.path,onClick:()=>r(p.path),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),r(p.path))},children:[m.jsx("span",{className:"ticon",children:m.jsx(st,{name:p.dir?"folder":"doc"})}),m.jsx("span",{className:"dl-name",children:p.name}),S&&m.jsx("span",{className:"dl-restricted","aria-label":S.default==="none"?"Restricted folder: not shared with everyone in this workspace.":"Restricted folder: everyone in this workspace can "+(S.default||"read")+" here.",title:S.default==="none"?"Not shared with everyone — only the people on its list.":"Everyone in this workspace can "+(S.default||"read")+" here.",children:S.default==="none"?"restricted":S.default||"shared"}),v&&m.jsx("span",{className:"dl-conflict","aria-label":"Conflict copy: a concurrent edit from "+(v.device||"another device")+" that beardrive preserved instead of dropping.",title:"A concurrent edit from "+(v.device||"another device")+" that beardrive preserved instead of dropping.",children:"conflict copy"}),k&&m.jsx("span",{className:"stalemark",role:"img","aria-label":"Warning: "+k,title:"Read often, but "+k,children:"⚠"}),y&&m.jsx("span",{className:"heatdot lvl"+tte(y),role:"img","aria-label":df(y)+" in 30 days. "+_l,title:df(y)+" in 30 days. "+_l}),m.jsx("span",{className:"dl-meta",children:O})]},p.path)})}),t.hub&&m.jsx(nne,{apiBase:t.apiBase,prefix:e.path+"/",onOpen:r,onFullHistory:()=>t.onFullHistory(e.path+"/"),onRendered:t.onRendered})]})}function nne(t){const e=gte(t.apiBase,t.prefix,!0),{onRendered:n}=t;return w.useEffect(()=>{e&&e.length&&n&&n()},[e,n]),!e||e.length===0?null:m.jsxs("div",{className:"dl-history",children:[m.jsx("h3",{className:"dl-h3",children:"Recent changes"}),m.jsx("div",{className:"history dl-hlist",children:e.map((i,r)=>m.jsx(j1,{entry:i,apiBase:t.apiBase,onOpen:t.onOpen},r))}),m.jsx("button",{className:"ai-btn dl-more",onClick:t.onFullHistory,children:"Full history"})]})}const CN=5e3;function ine(t,e,n=CN){const i=[];let r=[],s="",o=!1,l=0;const u=()=>{r.push(s),s="",i.length1?e.slice(0,-1).join(", ")+" and "+e[e.length-1]:e[0]||"something credential-shaped"}function one(t=[]){return`BearDrive found ${_N(t)} in this file. The check covers the file at the moment you share it — a link always serves the file's latest content, so later changes are never checked. Share anyway?`}function ane(t=[]){return`This file contains ${_N(t)}.`}let ix=[],$N=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=$N[i])e=i+1;else return!0;if(e==n)return!1}}function BE(t){return t>=127462&&t<=127487}const UE=8205;function cne(t,e,n=!0,i=!0){return(n?TN:une)(t,e,i)}function TN(t,e,n){if(e==t.length)return e;e&&EN(t.charCodeAt(e))&&RN(t.charCodeAt(e-1))&&e--;let i=vb(t,e);for(e+=qE(i);e=0&&BE(vb(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function une(t,e,n){for(;e>1;){let i=TN(t,e-2,n);if(i=56320&&t<57344}function RN(t){return t>=55296&&t<56320}function qE(t){return t<65536?1:2}class Ot{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,i){[e,n]=wu(this,e,n);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),ws.from(r,this.length-(n-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=wu(this,e,n);let i=[];return this.decompose(e,n,i,0),ws.from(i,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new vf(this),s=new vf(e);for(let o=n,l=n;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(l+=r.value.length,r.done||l>=i)return!0}}iter(e=1){return new vf(this,e)}iterRange(e,n=this.length){return new QN(this,e,n)}iterLines(e,n){let i;if(e==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new AN(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Ot.empty:e.length<=32?new vn(e):ws.from(vn.split(e,[]))}}class vn extends Ot{constructor(e,n=dne(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.text[s],l=r+o.length;if((n?i:l)>=e)return new fne(r,l,i,o);r=l+1,i++}}decompose(e,n,i,r){let s=e<=0&&n>=this.length?this:new vn(YE(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),l=Gg(s.text,o.text.slice(),0,s.length);if(l.length<=32)i.push(new vn(l,o.length+s.length));else{let u=l.length>>1;i.push(new vn(l.slice(0,u)),new vn(l.slice(u)))}}else i.push(s)}replace(e,n,i){if(!(i instanceof vn))return super.replace(e,n,i);[e,n]=wu(this,e,n);let r=Gg(this.text,Gg(i.text,YE(this.text,0,e)),n),s=this.length+i.length-(n-e);return r.length<=32?new vn(r,s):ws.from(vn.split(r,[]),s)}sliceString(e,n=this.length,i=` +`){[e,n]=wu(this,e,n);let r="";for(let s=0,o=0;s<=n&&oe&&o&&(r+=i),es&&(r+=l.slice(Math.max(0,e-s),n-s)),s=u+1}return r}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(n.push(new vn(i,r)),i=[],r=-1);return r>-1&&n.push(new vn(i,r)),n}}class ws extends Ot{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.children[s],l=r+o.length,u=i+o.lines-1;if((n?u:l)>=e)return o.lineInner(e,n,i,r);r=l+1,i=u+1}}decompose(e,n,i,r){for(let s=0,o=0;o<=n&&s=o){let f=r&((o<=e?1:0)|(u>=n?2:0));o>=e&&u<=n&&!f?i.push(l):l.decompose(e-o,n-o,i,f)}o=u+1}}replace(e,n,i){if([e,n]=wu(this,e,n),i.lines=s&&n<=l){let u=o.replace(e-s,n-s,i),f=this.lines-o.lines+u.lines;if(u.lines>4&&u.lines>f>>6){let h=this.children.slice();return h[r]=u,new ws(h,this.length-(n-e)+i.length)}return super.replace(s,l,u)}s=l+1}return super.replace(e,n,i)}sliceString(e,n=this.length,i=` +`){[e,n]=wu(this,e,n);let r="";for(let s=0,o=0;se&&s&&(r+=i),eo&&(r+=l.sliceString(e-o,n-o,i)),o=u+1}return r}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof ws))return 0;let i=0,[r,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=n,s+=n){if(r==o||s==l)return i;let u=this.children[r],f=e.children[s];if(u!=f)return i+u.scanIdentical(f,n);i+=u.length+1}}static from(e,n=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let y of e)i+=y.lines;if(i<32){let y=[];for(let v of e)v.flatten(y);return new vn(y,n)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,l=[],u=0,f=-1,h=[];function p(y){let v;if(y.lines>s&&y instanceof ws)for(let S of y.children)p(S);else y.lines>o&&(u>o||!u)?(O(),l.push(y)):y instanceof vn&&u&&(v=h[h.length-1])instanceof vn&&y.lines+v.lines<=32?(u+=y.lines,f+=y.length+1,h[h.length-1]=new vn(v.text.concat(y.text),v.length+1+y.length)):(u+y.lines>r&&O(),u+=y.lines,f+=y.length+1,h.push(y))}function O(){u!=0&&(l.push(h.length==1?h[0]:ws.from(h,f)),f=-1,u=h.length=0)}for(let y of e)p(y);return O(),l.length==1?l[0]:new ws(l,n)}}Ot.empty=new vn([""],0);function dne(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Gg(t,e,n=0,i=1e9){for(let r=0,s=0,o=!0;s=n&&(u>i&&(l=l.slice(0,i-r)),r0?1:(e instanceof vn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,l=r instanceof vn?r.text.length:r.children.length;if(o==(n>0?l:0)){if(i==0)return this.done=!0,this.value="",this;n>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[i]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(r instanceof vn){let u=r.text[o+(n<0?-1:0)];if(this.offsets[i]+=n,u.length>Math.max(0,e))return this.value=e==0?u:n>0?u.slice(e):u.slice(0,u.length-e),this;e-=u.length}else{let u=r.children[o+(n<0?-1:0)];e>u.length?(e-=u.length,this.offsets[i]+=n):(n<0&&this.offsets[i]--,this.nodes.push(u),this.offsets.push(n>0?1:(u instanceof vn?u.text.length:u.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class QN{constructor(e,n,i){this.value="",this.done=!1,this.cursor=new vf(e,n>i?-1:1),this.pos=n>i?e.length:0,this.from=Math.min(n,i),this.to=Math.max(n,i)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let i=n<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*n,this.value=r.length<=i?r:n<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class AN{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:i,value:r}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Ot.prototype[Symbol.iterator]=function(){return this.iter()},vf.prototype[Symbol.iterator]=QN.prototype[Symbol.iterator]=AN.prototype[Symbol.iterator]=function(){return this});let fne=class{constructor(e,n,i,r){this.from=e,this.to=n,this.number=i,this.text=r}get length(){return this.to-this.from}};function wu(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function fi(t,e,n=!0,i=!0){return cne(t,e,n,i)}function hne(t){return t>=56320&&t<57344}function pne(t){return t>=55296&&t<56320}function gne(t,e){let n=t.charCodeAt(e);if(!pne(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return hne(i)?(n-55296<<10)+(i-56320)+65536:n}function mne(t){return t<65536?1:2}const rx=/\r\n?|\n/;var ki=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(ki||(ki={}));class js{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-r);s+=l}else{if(i!=ki.Simple&&f>=e&&(i==ki.TrackDel&&re||i==ki.TrackBefore&&re))return null;if(f>e||f==e&&n<0&&!l)return e==r||n<0?s:s+u;s+=u}r=f}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,n=e){for(let i=0,r=0;i=0&&r<=n&&l>=e)return rn?"cover":!0;r=l}return!1}toString(){let e="";for(let n=0;n=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new js(e)}static create(e){return new js(e)}}class jn extends js{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return sx(this,(n,i,r,s,o)=>e=e.replace(r,r+(i-n),o),!1),e}mapDesc(e,n=!1){return ox(this,e,n,!0)}invert(e){let n=this.sections.slice(),i=[];for(let r=0,s=0;r=0){n[r]=l,n[r+1]=o;let u=r>>1;for(;i.length0&&ya(i,n,s.text),s.forward(h),l+=h}let f=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,i){let r=[],s=[],o=0,l=null;function u(h=!1){if(!h&&!r.length)return;oO||p<0||O>n)throw new RangeError(`Invalid change range ${p} to ${O} (in doc of length ${n})`);let v=y?typeof y=="string"?Ot.of(y.split(i||rx)):y:Ot.empty,S=v.length;if(p==O&&S==0)return;po&&ui(r,p-o,-1),ui(r,O-p,S),ya(s,r,v),o=O}}return f(e),u(!l),l}static empty(e){return new jn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],i=[];for(let r=0;rl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;i.length=0&&n<=0&&n==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=n:i?(t[r]+=e,t[r+1]+=n):t.push(e,n)}function ya(t,e,n){if(n.length==0)return;let i=e.length-2>>1;if(i>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],u=t.sections[o++];e(r,f,s,h,p),r=f,s=h}}}function ox(t,e,n,i=!1){let r=[],s=i?[]:null,o=new zf(t),l=new zf(e);for(let u=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let f=Math.min(o.len,l.len);ui(r,f,-1),o.forward(f),l.forward(f)}else if(l.ins>=0&&(o.ins<0||u==o.i||o.off==0&&(l.len=0&&u=0){let f=0,h=o.len;for(;h;)if(l.ins==-1){let p=Math.min(h,l.len);f+=p,h-=p,l.forward(p)}else if(l.ins==0&&l.lenu||o.ins>=0&&o.len>u)&&(l||i.length>f),s.forward2(u),o.forward(u)}}}}class zf{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?Ot.empty:e[n]}textBit(e){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!e?Ot.empty:n[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ha{constructor(e,n,i,r){this.from=e,this.to=n,this.flags=i,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,n):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new ha(i,r,this.flags,this.goalColumn)}extend(e,n=e,i=0){if(e<=this.anchor&&n>=this.anchor)return Oe.range(e,n,void 0,void 0,i);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Oe.range(this.anchor,r,void 0,void 0,i)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Oe.range(e.anchor,e.head)}static create(e,n,i,r){return new ha(e,n,i,r)}}class Oe{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Oe.create(this.ranges.map(i=>i.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Oe(e.ranges.map(n=>ha.fromJSON(n)),e.main)}static single(e,n=e){return new Oe([Oe.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;rr.from-s.from),n=e.indexOf(i);for(let r=1;rs.head?Oe.range(u,l):Oe.range(l,u))}}return new Oe(e,n)}}function jN(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let M1=0;class Ne{constructor(e,n,i,r,s){this.combine=e,this.compareInput=n,this.compare=i,this.isStatic=r,this.id=M1++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new Ne(e.combine||(n=>n),e.compareInput||((n,i)=>n===i),e.compare||(e.combine?(n,i)=>n===i:D1),!!e.static,e.enables)}of(e){return new Hg([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Hg(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Hg(e,this,2,n)}from(e,n){return n||(n=i=>i),this.compute([e],i=>n(i.field(e)))}}function D1(t,e){return t==e||t.length==e.length&&t.every((n,i)=>n===e[i])}class Hg{constructor(e,n,i,r){this.dependencies=e,this.facet=n,this.type=i,this.value=r,this.id=M1++}dynamicSlot(e){var n;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,u=!1,f=!1,h=[];for(let p of this.dependencies)p=="doc"?u=!0:p=="selection"?f=!0:(((n=e[p.id])!==null&&n!==void 0?n:1)&1)==0&&h.push(e[p.id]);return{create(p){return p.values[o]=i(p),1},update(p,O){if(u&&O.docChanged||f&&(O.docChanged||O.selection)||ax(p,h)){let y=i(p);if(l?!FE(y,p.values[o],r):!r(y,p.values[o]))return p.values[o]=y,1}return 0},reconfigure:(p,O)=>{let y,v=O.config.address[s];if(v!=null){let S=Qm(O,v);if(this.dependencies.every(k=>k instanceof Ne?O.facet(k)===p.facet(k):k instanceof Ao?O.field(k,!1)==p.field(k,!1):!0)||(l?FE(y=i(p),S,r):r(y=i(p),S)))return p.values[o]=S,0}else y=i(p);return p.values[o]=y,1}}}get extension(){return this}}function FE(t,e,n){if(t.length!=e.length)return!1;for(let i=0;it[u.id]),r=n.map(u=>u.type),s=i.filter(u=>!(u&1)),o=t[e.id]>>1;function l(u){let f=[];for(let h=0;hi===r),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(vg).find(i=>i.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:i=>(i.values[n]=this.create(i),1),update:(i,r)=>{let s=i.values[n],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[n]=o,1)},reconfigure:(i,r)=>{let s=i.facet(vg),o=r.facet(vg),l;return(l=s.find(u=>u.field==this))&&l!=o.find(u=>u.field==this)?(i.values[n]=l.create(i),1):r.config.address[this.id]!=null?(i.values[n]=r.field(this),0):(i.values[n]=this.create(i),1)}}}init(e){return[this,vg.of({field:this,create:e})]}get extension(){return this}}const ml={lowest:4,low:3,default:2,high:1,highest:0};function Kd(t){return e=>new MN(e,t)}const wh={highest:Kd(ml.highest),high:Kd(ml.high),default:Kd(ml.default),low:Kd(ml.low),lowest:Kd(ml.lowest)};class MN{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class WO{of(e){return new lx(this,e)}reconfigure(e){return WO.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class lx{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Rm{constructor(e,n,i,r,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,i){let r=[],s=Object.create(null),o=new Map;for(let O of yne(e,n,o))O instanceof Ao?r.push(O):(s[O.facet.id]||(s[O.facet.id]=[])).push(O);let l=Object.create(null),u=[],f=[];for(let O of r)l[O.id]=f.length<<1,f.push(y=>O.slot(y));let h=i?.config.facets;for(let O in s){let y=s[O],v=y[0].facet,S=h&&h[O]||[];if(y.every(k=>k.type==0))if(l[v.id]=u.length<<1|1,D1(S,y))u.push(i.facet(v));else{let k=v.combine(y.map(C=>C.value));u.push(i&&v.compare(k,i.facet(v))?i.facet(v):k)}else{for(let k of y)k.type==0?(l[k.id]=u.length<<1|1,u.push(k.value)):(l[k.id]=f.length<<1,f.push(C=>k.dynamicSlot(C)));l[v.id]=f.length<<1,f.push(k=>One(k,v,y))}}let p=f.map(O=>O(l));return new Rm(e,o,p,l,u,s)}}function yne(t,e,n){let i=[[],[],[],[],[]],r=new Map;function s(o,l){let u=r.get(o);if(u!=null){if(u<=l)return;let f=i[u].indexOf(o);f>-1&&i[u].splice(f,1),o instanceof lx&&n.delete(o.compartment)}if(r.set(o,l),Array.isArray(o))for(let f of o)s(f,l);else if(o instanceof lx){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let f=e.get(o.compartment)||o.inner;n.set(o.compartment,f),s(f,l)}else if(o instanceof MN)s(o.inner,o.prec);else if(o instanceof Ao)i[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Hg)i[l].push(o),o.facet.extensions&&s(o.facet.extensions,ml.default);else{let f=o.extension;if(!f)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(f==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(f,l)}}return s(t,ml.default),i.reduce((o,l)=>o.concat(l))}function bf(t,e){if(e&1)return 2;let n=e>>1,i=t.status[n];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;t.status[n]=4;let r=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|r}function Qm(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const DN=Ne.define(),cx=Ne.define({combine:t=>t.some(e=>e),static:!0}),NN=Ne.define({combine:t=>t.length?t[0]:void 0,static:!0}),zN=Ne.define(),LN=Ne.define(),ZN=Ne.define(),IN=Ne.define({combine:t=>t.length?t[0]:!1});class ss{constructor(e,n){this.type=e,this.value=n}static define(){return new vne}}class vne{of(e){return new ss(this,e)}}class bne{constructor(e){this.map=e}of(e){return new Jt(this,e)}}class Jt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Jt(this.type,n)}is(e){return this.type==e}static define(e={}){return new bne(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(n);s&&i.push(s)}return i}}Jt.reconfigure=Jt.define();Jt.appendConfig=Jt.define();let Ci=class hf{constructor(e,n,i,r,s,o){this.startState=e,this.changes=n,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&jN(i,n.newLength),s.some(l=>l.type==hf.time)||(this.annotations=s.concat(hf.time.of(Date.now())))}static create(e,n,i,r,s,o){return new hf(e,n,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(hf.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}};Ci.time=ss.define();Ci.userEvent=ss.define();Ci.addToHistory=ss.define();Ci.remote=ss.define();function Sne(t,e){let n=[];for(let i=0,r=0;;){let s,o;if(i=t[i]))s=t[i++],o=t[i++];else if(r=0;r--){let s=i[r](t);s instanceof Ci?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Ci?t=s[0]:t=VN(e,su(s),!1)}return t}function wne(t){let e=t.startState,n=e.facet(ZN),i=t;for(let r=n.length-1;r>=0;r--){let s=n[r](t);s&&Object.keys(s).length&&(i=XN(i,ux(e,s,t.changes.newLength),!0))}return i==t?t:Ci.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}const kne=[];function su(t){return t==null?kne:Array.isArray(t)?t:[t]}var bo=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(bo||(bo={}));const Cne=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let dx;try{dx=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function _ne(t){if(dx)return dx.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||Cne.test(n)))return!0}return!1}function $ne(t){return e=>{if(!/\S/.test(e))return bo.Space;if(_ne(e))return bo.Word;for(let n=0;n-1)return bo.Word;return bo.Other}}class St{constructor(e,n,i,r,s,o){this.config=e,this.doc=n,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;lr.set(f,u)),n=null),r.set(l.value.compartment,l.value.extension)):l.is(Jt.reconfigure)?(n=null,i=l.value):l.is(Jt.appendConfig)&&(n=null,i=su(i).concat(l.value));let s;n?s=e.startState.values.slice():(n=Rm.resolve(i,r,this),s=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(u,f)=>f.reconfigure(u,this),null).values);let o=e.startState.facet(cx)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,o,s,(l,u)=>u.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Oe.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,i=e(n.ranges[0]),r=this.changes(i.changes),s=[i.range],o=su(i.effects);for(let l=1;lo.spec.fromJSON(l,u)))}}return St.create({doc:e.doc,selection:Oe.fromJSON(e.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(e={}){let n=Rm.resolve(e.extensions||[],new Map),i=e.doc instanceof Ot?e.doc:Ot.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||rx)),r=e.selection?e.selection instanceof Oe?e.selection:Oe.single(e.selection.anchor,e.selection.head):Oe.single(0);return jN(r,i.length),n.staticFacet(cx)||(r=r.asSingle()),new St(n,i,r,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(IN)}phrase(e,...n){for(let i of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(i,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>n.length?i:n[s-1]})),e}languageDataAt(e,n,i=-1){let r=[];for(let s of this.facet(DN))for(let o of s(this,n,i))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return $ne(n.length?n[0]:"")}wordAt(e){let{text:n,from:i,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let u=fi(n,o,!1);if(s(n.slice(u,o))!=bo.Word)break;o=u}for(;lt.length?t[0]:4});St.lineSeparator=NN;St.readOnly=IN;St.phrases=Ne.define({compare(t,e){let n=Object.keys(t),i=Object.keys(e);return n.length==i.length&&n.every(r=>t[r]==e[r])}});St.languageData=DN;St.changeFilter=zN;St.transactionFilter=LN;St.transactionExtender=ZN;WO.reconfigure=Jt.define();function BN(t,e,n={}){let i={};for(let r of t)for(let s of Object.keys(r)){let o=r[s],l=i[s];if(l===void 0)i[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))i[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)i[r]===void 0&&(i[r]=e[r]);return i}class $a{eq(e){return this==e}range(e,n=e){return fx.create(e,n,this)}}$a.prototype.startSide=$a.prototype.endSide=0;$a.prototype.point=!1;$a.prototype.mapMode=ki.TrackDel;function N1(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let fx=class UN{constructor(e,n,i){this.from=e,this.to=n,this.value=i}static create(e,n,i){return new UN(e,n,i)}};function hx(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class z1{constructor(e,n,i,r){this.from=e,this.to=n,this.value=i,this.maxPoint=r}get length(){return Xc(this.to)}findIndex(e,n,i,r=0){let s=i?this.to:this.from;for(let o=r,l=s.length;;){if(o==l)return o;let u=o+l>>1,f=s[u]-e||(i?this.value[u].endSide:this.value[u].startSide)-n;if(u==o)return f>=0?o:l;f>=0?l=u:o=u+1}}between(e,n,i,r){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(i,1e9,!1,s);sk||S==k&&O.startSide>0&&O.endSide<=0)continue;if(!((k-S||O.endSide-O.startSide)<0))if(f<0&&(f=S),O.point&&(h=Math.max(h,k-S)),(S-i||O.startSide-r)>=0)o.push(O),l.push(S-f),u.push(k-f),i=k,r=O.endSide;else{if(S==k)for(let C=o.length;C>0;C--){if((S-(u[C-1]+f)||O.startSide-o[C-1].endSide)>=0){o.splice(C,0,O),l.splice(C,0,S-f),u.splice(C,0,k-f);continue e}if((S-(l[C-1]+f)||O.endSide-o[C-1].startSide)>0)break}s(S,k,O)}}return{mapped:o.length?new z1(l,u,o,h):null,pos:f}}}class mt{constructor(e,n,i,r){this.chunkPos=e,this.chunk=n,this.nextLayer=i,this.maxPoint=r}static create(e,n,i,r){return new mt(e,n,i,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:i=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(i&&(n=n.slice().sort(hx)),this.isEmpty)return n.length?mt.of(n):this;let l=new qN(this,null,-1).goto(0),u=0,f=[],h=new ou;for(;l.value||u=0){let p=n[u++];h.addInner(p.from,p.to,p.value,!1)||f.push(p)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s{s||(s=new ou),s.addRange(u,f,h,!1)};for(let u=0;u=s&&e<=s+o.length&&o.between(s,e-s,n-s,i)===!1)return}this.nextLayer.between(e,n,i)}}iter(e=0){return Lf.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Lf.from(e).goto(n)}static compare(e,n,i,r,s=-1){let o=e.filter(p=>p.maxPoint>0||!p.isEmpty&&p.maxPoint>=s),l=n.filter(p=>p.maxPoint>0||!p.isEmpty&&p.maxPoint>=s),u=GE(o,l,i),f=new Jd(o,u,s),h=new Jd(l,u,s);i.iterGaps((p,O,y)=>HE(f,p,h,O,y,r)),i.empty&&i.length==0&&HE(f,0,h,0,0,r)}static eq(e,n,i=0,r){r==null&&(r=999999999);let s=e.filter(h=>!h.isEmpty&&n.indexOf(h)<0),o=n.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=GE(s,o),u=new Jd(s,l,0).goto(i),f=new Jd(o,l,0).goto(i);for(;;){if(u.to!=f.to||!px(u.active,f.active)||u.point&&(!f.point||!N1(u.point,f.point)))return!1;if(u.to>r)return!0;u.next(),f.next()}}static spans(e,n,i,r,s=-1){let o=new Jd(e,null,s).goto(n),l=n,u=o.openStart;for(;;){let f=Math.min(o.to,i);if(o.point){let h=o.activeForPoint(o.to),p=o.pointFroml&&(r.span(l,f,o.active,u),u=o.openEnd(f));if(o.to>i)return u+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,n=!1){let i=new ou;for(let r of e instanceof fx?[e]:n?Tne(e):e)i.add(r.from,r.to,r.value);return i.finish()}static join(e){if(!e.length)return mt.empty;let n=Xc(e);for(let i=e.length-2;i>=0;i--)for(let r=e[i];r!=mt.empty;r=r.nextLayer)n=new mt(r.chunkPos,r.chunk,n,Math.max(r.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function Xc(t){return t[t.length-1]}function Tne(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(hx);e=i}return t}mt.empty.nextLayer=mt.empty;class ou{finishChunk(e){this.chunks.push(new z1(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,i){this.addRange(e,n,i,!0)}addRange(e,n,i,r){this.addInner(e,n,i,r)||(this.nextLayer||(this.nextLayer=new ou)).addRange(e,n,i,r)}addInner(e,n,i,r){let s=e-this.lastTo||i.startSide-this.last.endSide;if(r&&s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=n,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let i=n.value.length-1;return this.last=n.value[i],this.lastFrom=n.from[i]+e,this.lastTo=n.to[i]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function GE(t,e,n){let i=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&r.push(new qN(o,n,i,s));return r.length==1?r[0]:new Lf(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let i of this.heap)i.goto(e,n);for(let i=this.heap.length>>1;i>=0;i--)bb(this.heap,i);return this.next(),this}forward(e,n){for(let i of this.heap)i.forward(e,n);for(let i=this.heap.length>>1;i>=0;i--)bb(this.heap,i);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),bb(this.heap,0)}}}function bb(t,e){for(let n=t[e];;){let i=(e<<1)+1;if(i>=t.length)break;let r=t[i];if(i+1=0&&(r=t[i+1],i++),n.compare(r)<0)break;t[i]=n,t[e]=r,e=i}}class Jd{constructor(e,n,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Lf.from(e,n,i)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){bg(this.active,e),bg(this.activeTo,e),bg(this.activeRank,e),this.minActive=WE(this.active,this.activeTo)}addActive(e){let n=0,{value:i,to:r,rank:s}=this.cursor;for(;n0;)n++;Sg(this.active,n,i),Sg(this.activeTo,n,r),Sg(this.activeRank,n,s),e&&Sg(e,n,this.cursor.from),this.minActive=WE(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&bg(i,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(i),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&i[r]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&n.push(this.active[i]);return n.reverse()}openEnd(e){let n=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)n++;return n}}function HE(t,e,n,i,r,s){t.goto(e),n.goto(i);let o=i+r,l=i,u=i-e,f=!!s.boundChange;for(let h=!1;;){let p=t.to+u-n.to,O=p||t.endSide-n.endSide,y=O<0?t.to+u:n.to,v=Math.min(y,o);if(t.point||n.point?(t.point&&n.point&&N1(t.point,n.point)&&px(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,v,t.point,n.point),h=!1):(h&&s.boundChange(l),v>l&&!px(t.active,n.active)&&s.compareRange(l,v,t.active,n.active),f&&vo)break;l=y,O<=0&&t.next(),O>=0&&n.next()}}function px(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;i--)t[i+1]=t[i];t[e]=n}function WE(t,e){let n=-1,i=1e9;for(let r=0;r=e)return r;if(r==t.length)break;s+=t.charCodeAt(r)==9?n-s%n:1,r=fi(t,r)}return t.length}const gx="ͼ",KE=typeof Symbol>"u"?"__"+gx:Symbol.for(gx),mx=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),JE=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Ta{constructor(e,n){this.rules=[];let{finish:i}=n||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,u,f){let h=[],p=/^@(\w+)\b/.exec(o[0]),O=p&&p[1]=="keyframes";if(p&&l==null)return u.push(o[0]+";");for(let y in l){let v=l[y];if(/&/.test(y))s(y.split(/,\s*/).map(S=>o.map(k=>S.replace(/&/,k))).reduce((S,k)=>S.concat(k)),v,u);else if(v&&typeof v=="object"){if(!p)throw new RangeError("The value of a property ("+y+") should be a primitive value.");s(r(y),v,h,O)}else v!=null&&h.push(y.replace(/_.*/,"").replace(/[A-Z]/g,S=>"-"+S.toLowerCase())+": "+v+";")}(h.length||O)&&u.push((i&&!p&&!f?o.map(i):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=JE[KE]||1;return JE[KE]=e+1,gx+e.toString(36)}static mount(e,n,i){let r=e[mx],s=i&&i.nonce;r?s&&r.setNonce(s):r=new Rne(e,s),r.mount(Array.isArray(n)?n:[n],e)}}let eR=new Map;class Rne{constructor(e,n){let i=e.ownerDocument||e,r=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let s=eR.get(i);if(s)return e[mx]=s;this.sheet=new r.CSSStyleSheet,eR.set(i,this)}else this.styleTag=i.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[mx]=this}mount(e,n){let i=this.sheet,r=0,s=0;for(let o=0;o-1&&(this.modules.splice(u,1),s--,u=-1),u==-1){if(this.modules.splice(s++,0,l),i)for(let f=0;f",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Qne=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ane=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Jn=0;Jn<10;Jn++)Ea[48+Jn]=Ea[96+Jn]=String(Jn);for(var Jn=1;Jn<=24;Jn++)Ea[Jn+111]="F"+Jn;for(var Jn=65;Jn<=90;Jn++)Ea[Jn]=String.fromCharCode(Jn+32),Zf[Jn]=String.fromCharCode(Jn);for(var Sb in Ea)Zf.hasOwnProperty(Sb)||(Zf[Sb]=Ea[Sb]);function Pne(t){var e=Qne&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ane&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Zf:Ea)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let wi=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ox=typeof document<"u"?document:{documentElement:{style:{}}};const yx=/Edge\/(\d+)/.exec(wi.userAgent),YN=/MSIE \d/.test(wi.userAgent),vx=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(wi.userAgent),KO=!!(YN||vx||yx),tR=!KO&&/gecko\/(\d+)/i.test(wi.userAgent),xb=!KO&&/Chrome\/(\d+)/.exec(wi.userAgent),nR="webkitFontSmoothing"in Ox.documentElement.style,bx=!KO&&/Apple Computer/.test(wi.vendor),iR=bx&&(/Mobile\/\w+/.test(wi.userAgent)||wi.maxTouchPoints>2);var Te={mac:iR||/Mac/.test(wi.platform),windows:/Win/.test(wi.platform),linux:/Linux|X11/.test(wi.platform),ie:KO,ie_version:YN?Ox.documentMode||6:vx?+vx[1]:yx?+yx[1]:0,gecko:tR,gecko_version:tR?+(/Firefox\/(\d+)/.exec(wi.userAgent)||[0,0])[1]:0,chrome:!!xb,chrome_version:xb?+xb[1]:0,ios:iR,android:/Android\b/.test(wi.userAgent),webkit:nR,webkit_version:nR?+(/\bAppleWebKit\/(\d+)/.exec(wi.userAgent)||[0,0])[1]:0,safari:bx,safari_version:bx?+(/\bVersion\/(\d+(\.\d+)?)/.exec(wi.userAgent)||[0,0])[1]:0,tabSize:Ox.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function L1(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const Am=Object.create(null);function Z1(t,e,n){if(t==e)return!0;t||(t=Am),e||(e=Am);let i=Object.keys(t),r=Object.keys(e);if(i.length-0!=r.length-0)return!1;for(let s of i)if(s!=n&&(r.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function jne(t,e){for(let n=t.attributes.length-1;n>=0;n--){let i=t.attributes[n].name;e[i]==null&&t.removeAttribute(i)}for(let n in e){let i=e[n];n=="style"?t.style.cssText=i:t.getAttribute(n)!=i&&t.setAttribute(n,i)}}function rR(t,e,n){let i=!1;if(e)for(let r in e)n&&r in n||(i=!0,r=="style"?t.style.cssText="":t.removeAttribute(r));if(n)for(let r in n)e&&e[r]==n[r]||(i=!0,r=="style"?t.style.cssText=n[r]:t.setAttribute(r,n[r]));return i}function Mne(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new Nl(e,n,n,i,e.widget||null,!1)}static replace(e){let n=!!e.block,i,r;if(e.isBlockGap)i=-5e8,r=4e8;else{let{start:s,end:o}=FN(e,n);i=(s?n?-3e8:-1:5e8)-1,r=(o?n?2e8:1:-6e8)+1}return new Nl(e,i,r,n,e.widget||null,!0)}static line(e){return new Ch(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Tt.none=mt.empty;class kh extends Tt{constructor(e){let{start:n,end:i}=FN(e);super(n?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?L1(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Am}eq(e){return this==e||e instanceof kh&&this.tagName==e.tagName&&Z1(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}kh.prototype.point=!1;class Ch extends Tt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ch&&this.spec.class==e.spec.class&&Z1(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}Ch.prototype.mapMode=ki.TrackBefore;Ch.prototype.point=!0;class Nl extends Tt{constructor(e,n,i,r,s,o){super(n,i,s,e),this.block=r,this.isReplace=o,this.mapMode=r?n<=0?ki.TrackBefore:ki.TrackAfter:ki.TrackDel}get type(){return this.startSide!=this.endSide?Ui.WidgetRange:this.startSide<=0?Ui.WidgetBefore:Ui.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Nl&&Dne(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}Nl.prototype.point=!0;function FN(t,e=!1){let{inclusiveStart:n,inclusiveEnd:i}=t;return n==null&&(n=t.inclusive),i==null&&(i=t.inclusive),{start:n??e,end:i??e}}function Dne(t,e){return t==e||!!(t&&e&&t.compare(e))}function au(t,e,n,i=0){let r=n.length-1;r>=0&&n[r]+i>=t?n[r]=Math.max(n[r],e):n.push(t,e)}class If extends $a{constructor(e,n,i){super(),this.tagName=e,this.attributes=n,this.rank=i}eq(e){return e==this||e instanceof If&&this.tagName==e.tagName&&Z1(this.attributes,e.attributes)}static create(e){return new If(e.tagName,e.attributes||Am,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}If.prototype.startSide=If.prototype.endSide=-1;function Xf(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Sx(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Sf(t,e){if(!e.anchorNode)return!1;try{return Sx(t,e.anchorNode)}catch{return!1}}function Wg(t){return t.nodeType==3?Vf(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function xf(t,e,n,i){return n?sR(t,e,n,i,-1)||sR(t,e,n,i,1):!1}function Ra(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Pm(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function sR(t,e,n,i,r){for(;;){if(t==n&&e==i)return!0;if(e==(r<0?0:Eo(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Ra(t)+(r<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(r<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=r<0?Eo(t):0}else return!1}}function Eo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function jm(t,e){let{left:n,right:i}=t;if(n==i)return t;let r=e?n:i;return{left:r,right:r,top:t.top,bottom:t.bottom}}function Nne(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function GN(t,e){let n=e.width/t.offsetWidth,i=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-t.offsetHeight)<1)&&(i=1),{scaleX:n,scaleY:i}}function zne(t,e,n,i,r,s,o,l){let u=t.ownerDocument,f=u.defaultView||window;for(let h=t,p=!1;h&&!p;)if(h.nodeType==1){let O,y=h==u.body,v=1,S=1;if(y)O=Nne(f);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(p=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let $=h.getBoundingClientRect();({scaleX:v,scaleY:S}=GN(h,$)),O={left:$.left,right:$.left+h.clientWidth*v,top:$.top,bottom:$.top+h.clientHeight*S}}let k=0,C=0;if(r=="nearest")e.top0&&e.bottom>O.bottom+C&&(C=e.bottom-O.bottom+o)):e.bottom>O.bottom-o&&(C=e.bottom-O.bottom+o,n<0&&e.top-C0&&e.right>O.right+k&&(k=e.right-O.right+s)):e.right>O.right-s&&(k=e.right-O.right+s,n<0&&e.leftO.bottom||e.leftO.right)&&(e={left:Math.max(e.left,O.left),right:Math.min(e.right,O.right),top:Math.max(e.top,O.top),bottom:Math.min(e.bottom,O.bottom)}),h=h.assignedSlot||h.parentNode}else if(h.nodeType==11)h=h.host;else break}function HN(t,e=!0){let n=t.ownerDocument,i=null,r=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||i)&&r);)if(s.nodeType==1)!r&&s.scrollHeight>s.clientHeight&&(r=s),e&&!i&&s.scrollWidth>s.clientWidth&&(i=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:i,y:r}}class Lne{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:i}=e;this.set(n,Math.min(e.anchorOffset,n?Eo(n):0),i,Math.min(e.focusOffset,i?Eo(i):0))}set(e,n,i,r){this.anchorNode=e,this.anchorOffset=n,this.focusNode=i,this.focusOffset=r}}function WN(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function KN(t,e=!0){for(let{node:n,left:i,top:r}of t)e&&n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}let gl=null;Te.safari&&Te.safari_version>=26&&(gl=!1);function JN(t){if(t.setActive)return t.setActive();if(gl)return t.focus(gl);let e=WN(t);t.focus(gl==null?{get preventScroll(){return gl={preventScroll:!0},!0}}:void 0),gl||(gl=!1,KN(e))}let oR;function Vf(t,e,n=e){let i=oR||(oR=document.createRange());return i.setEnd(t,n),i.setStart(t,e),i}function lu(t,e,n,i){let r={key:e,code:e,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function Zne(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function Ine(t,e){let n=e.focusNode,i=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=i)return!1;for(i=Math.min(i,Eo(n));;)if(i){if(n.nodeType!=1)return!1;let r=n.childNodes[i-1];r.contentEditable=="false"?i--:(n=r,i=Eo(n))}else{if(n==t)return!0;i=Ra(n),n=n.parentNode}}function ez(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function tz(t,e){for(let n=t,i=e;;){if(n.nodeType==3&&i>0)return{node:n,offset:i};if(n.nodeType==1&&i>0){if(n.contentEditable=="false")return null;n=n.childNodes[i-1],i=Eo(n)}else if(n.parentNode&&!Pm(n))i=Ra(n),n=n.parentNode;else return null}}function nz(t,e){for(let n=t,i=e;;){if(n.nodeType==3&&i=n){if(l.level==i)return o;(s<0||(r!=0?r<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function sz(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;S-=3)if(gs[S+1]==-y){let k=gs[S+2],C=k&2?r:k&4?k&1?s:r:0;C&&(Vt[p]=Vt[gs[S]]=C),l=S;break}}else{if(gs.length==189)break;gs[l++]=p,gs[l++]=O,gs[l++]=u}else if((v=Vt[p])==2||v==1){let S=v==r;u=S?0:1;for(let k=l-3;k>=0;k-=3){let C=gs[k+2];if(C&2)break;if(S)gs[k+2]|=2;else{if(C&4)break;gs[k+2]|=4}}}}}function Yne(t,e,n,i){for(let r=0,s=i;r<=n.length;r++){let o=r?n[r-1].to:t,l=ru;)v==k&&(v=n[--S].from,k=S?n[S-1].to:t),Vt[--v]=y;u=h}else s=f,u++}}}function wx(t,e,n,i,r,s,o){let l=i%2?2:1;if(i%2==r%2)for(let u=e,f=0;uu&&o.push(new $s(u,S.from,y));let k=S.direction==zl!=!(y%2);kx(t,k?i+1:i,r,S.inner,S.from,S.to,o),u=S.to}v=S.to}else{if(v==n||(h?Vt[v]!=l:Vt[v]==l))break;v++}O?wx(t,u,v,i+1,r,O,o):ue;){let h=!0,p=!1;if(!f||u>s[f-1].to){let S=Vt[u-1];S!=l&&(h=!1,p=S==16)}let O=!h&&l==1?[]:null,y=h?i:i+1,v=u;e:for(;;)if(f&&v==s[f-1].to){if(p)break e;let S=s[--f];if(!h)for(let k=S.from,C=f;;){if(k==e)break e;if(C&&s[C-1].to==k)k=s[--C].from;else{if(Vt[k-1]==l)break e;break}}if(O)O.push(S);else{S.toVt.length;)Vt[Vt.length]=256;let i=[],r=e==zl?0:1;return kx(t,r,r,n,0,t.length,i),i}function oz(t){return[new $s(0,t,0)]}let az="";function Gne(t,e,n,i,r){var s;let o=i.head-t.from,l=$s.find(e,o,(s=i.bidiLevel)!==null&&s!==void 0?s:-1,i.assoc),u=e[l],f=u.side(r,n);if(o==f){let O=l+=r?1:-1;if(O<0||O>=e.length)return null;u=e[l=O],o=u.side(!r,n),f=u.side(r,n)}let h=fi(t.text,o,u.forward(r,n));(hu.to)&&(h=f),az=t.text.slice(Math.min(o,h),Math.max(o,h));let p=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return p&&h==f&&p.level+(r?0:1)t.some(e=>e)}),Wne=Ne.define({combine:t=>t.some(e=>e)}),gz=Ne.define();class cu{constructor(e,n,i,r,s,o=!1){this.range=e,this.y=n,this.x=i,this.yMargin=r,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new cu(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new cu(Oe.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const xg=Jt.define({map:(t,e)=>t.map(e)}),mz=Jt.define();function Ts(t,e,n){let i=t.facet(dz);i.length?i[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Oo=Ne.define({combine:t=>t.length?t[0]:!0});let Kne=0;const Wc=Ne.define({combine(t){return t.filter((e,n)=>{for(let i=0;i{let u=[];return o&&u.push(JO.of(f=>{let h=f.plugin(l);return h?o(h):Tt.none})),s&&u.push(s(l)),u})}static fromClass(e,n){return Dr.define((i,r)=>new e(i,r),n)}}class wb{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(i){if(Ts(n.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Ts(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(i){Ts(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Oz=Ne.define(),B1=Ne.define(),JO=Ne.define(),yz=Ne.define(),U1=Ne.define(),_h=Ne.define(),vz=Ne.define();function aR(t,e){let n=t.state.facet(vz);if(!n.length)return n;let i=n.map(s=>s instanceof Function?s(t):s),r=[];return mt.spans(i,e.from,e.to,{point(){},span(s,o,l,u){let f=s-e.from,h=o-e.from,p=r;for(let O=l.length-1;O>=0;O--,u--){let y=l[O].spec.bidiIsolate,v;if(y==null&&(y=Hne(e.text,f,h)),u>0&&p.length&&(v=p[p.length-1]).to==f&&v.direction==y)v.to=h,p=v.inner;else{let S={from:f,to:h,direction:y,inner:[]};p.push(S),p=S.inner}}}}),r}const bz=Ne.define();function Sz(t){let e=0,n=0,i=0,r=0;for(let s of t.state.facet(bz)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:n,top:i,bottom:r}}const pf=Ne.define();class Rr{constructor(e,n,i,r){this.fromA=e,this.toA=n,this.fromB=i,this.toB=r}join(e){return new Rr(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,i=this;for(;n>0;n--){let r=e[n-1];if(!(r.fromA>i.toA)){if(r.toAr.push(new Rr(s,o,l,u))),this.changedRanges=r}static create(e,n,i){return new Mm(e,n,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const Jne=[];class fn{constructor(e,n,i=0){this.dom=e,this.length=n,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Jne}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&jne(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let i=n;for(let r of this.children){if(r==e)return i;i+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,i){return null}domPosFor(e,n){let i=Ra(this.dom),r=this.length?e>0:n>0;return new Kr(this.parent.dom,i+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof ty)return e;return null}static get(e){return e.cmTile}}class ey extends fn{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,i=null,r,s=e?.node==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,r=i?i.nextSibling:n.firstChild,s&&r!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;r&&r!=l.dom;)r=lR(r);else n.insertBefore(l.dom,r);i=l.dom}for(r=i?i.nextSibling:n.firstChild,s&&r&&(s.written=!0);r;)r=lR(r);this.length=o}}function lR(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class ty extends ey{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=fn.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],i=this,r=0,s=0;;)if(r==i.children.length){if(!n.length)return;i=i.parent,i.breakAfter&&s++,r=n.pop()}else{let o=i.children[r++];if(o instanceof ko)n.push(r),i=o,r=0;else{let l=s+o.length,u=e(o,s);if(u!==void 0)return u;s=l+o.breakAfter}}}resolveBlock(e,n){let i,r=-1,s,o=-1;if(this.blockTiles((l,u)=>{let f=u+l.length;if(e>=u&&e<=f){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(ue||e==u&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-u)}}),!i&&!s)throw new Error("No tile at position "+e);return i&&n<0||!s?{tile:i,offset:r}:{tile:s,offset:o}}}class ko extends ey{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let i=new ko(n||document.createElement(e.tagName),e);return n||(i.flags|=4),i}}class ku extends ey{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,i){let r=new ku(n||document.createElement("div"),e);return(!n||!i)&&(r.flags|=4),r}get domAttrs(){return this.attrs}resolveInline(e,n,i){let r=null,s=-1,o=null,l=-1;function u(h,p){for(let O=0,y=0;O=p&&(v.isComposite()?u(v,p-y):(!o||o.isHidden&&(n>0&&!(o.flags&32)||i&&tie(o,v)))&&(S>p||v.flags&32&&n<=1)?(o=v,l=p-y):(y=-1)&&(r=v,s=p-y)),y=S}}u(this,e);let f=(n<0?r:o)||r||o;return f?{tile:f,offset:f==r?s:l}:null}coordsIn(e,n,i){let r=this.resolveInline(e,n,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),n,i):eie(this)}domIn(e,n){let i=this.resolveInline(e,n);if(i){let{tile:r,offset:s}=i;if(this.dom.contains(r.dom))return r.isText()?new Kr(r.dom,Math.min(r.dom.nodeValue.length,s)):r.domPosFor(s,r.flags&16?1:r.flags&32?-1:n);let o=i.tile.parent,l=!1;for(let u of o.children){if(l)return new Kr(u.dom,0);u==i.tile&&(l=!0)}}return new Kr(this.dom,0)}}function eie(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=Wg(e);return n[n.length-1]||null}function tie(t,e){let n=t.coordsIn(0,1),i=e.coordsIn(0,1);return n&&i&&i.topr&&(e=r);let s=e,o=e,l=0;e==0&&n<0||e==r&&n>=0?Te.chrome||Te.gecko||(e?(s--,l=1):o=0)?0:u.length-1];return Te.safari&&!l&&f.width==0&&(f=Array.prototype.find.call(u,h=>h.width)||f),i==null?f:jm(f,(l?l>0:n<0)==i)}static of(e,n){let i=new Sl(n||document.createTextNode(e),e);return n||(i.flags|=2),i}}class Ll extends fn{constructor(e,n,i,r){super(e,n,r),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,i){let r=this.widget.coordsAt(this.dom,e,n);if(r)return r;if(i)return jm(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let u=l?s.length-1:0;o=s[u],!(e>0?u==0:u==s.length-1||o.top0==i)}}class nie{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,i){let{tile:r,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(r.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(s==r.children.length){if(!e&&!l.length)break;i&&i.leave(r),o=!!r.breakAfter,{tile:r,index:s}=l.pop(),s++}else{let u=r.children[s],f=u.breakAfter;(n>0?u.length<=e:u.length=0;l--){let u=n.marks[l],f=r.lastChild;if(f instanceof Ii&&f.mark.eq(u.mark))f.dom!=u.dom&&f.setDOM(kb(u.dom)),r=f;else{if(this.cache.reused.get(u)){let p=fn.get(u.dom);p&&p.setDOM(kb(u.dom))}let h=Ii.of(u.mark,u.dom);r.append(h),r=h}this.cache.reused.set(u,2)}let s=fn.get(e.text);s&&this.cache.reused.set(s,2);let o=new Sl(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,r.append(o)}addInlineWidget(e,n,i){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let s=this.ensureMarks(n,i);!r&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,i){this.flushBuffer(),this.ensureMarks(n,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var i;e||(e=xz);let r=ku.start(e,n||((i=this.cache.find(ku))===null||i===void 0?void 0:i.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var i;let r=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=r.lastChild)&&l instanceof Ii&&l.mark.eq(o))r=l,n--;else{let u=Ii.of(o,(i=this.cache.find(Ii,f=>f.mark.eq(o)))===null||i===void 0?void 0:i.dom);r.append(u),r=u,n=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!cR(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Te.ios&&cR(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Cb,0,32)||new Ll(Cb.toDOM(),0,Cb,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,i=new iie(e.from,e.to,e.value,n),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-i.rank||this.wrappers[r-1].to-i.to)<0;)r--;this.wrappers.splice(r,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let i of this.wrappers){let r=n.lastChild;if(i.fromo.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),i=this.cache.find(Dm,void 0,1);return i&&(i.flags=n),i||new Dm(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class sie{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let l=this.textOff=Math.min(e,r.length);return s?null:r.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,n);return this.textOff=n,i}}const Nm=[Ll,ku,Sl,Ii,Dm,ko,ty];for(let t=0;t[]),this.index=Nm.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,i=this.buckets[n];i.length<6?i.push(e):i[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,i=2){let r=e.bucket,s=this.buckets[r],o=this.index[r];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let i=n&&this.getCompositionContext(n.text);for(let r=0,s=0,o=0;;){let l=or){let f=u-r;this.preserve(f,!o,!l),r=u,s+=f}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(u-l);else{let f=u>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Ii&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=s=0):o instanceof Ii&&(r.shift(),s=Math.min(s,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let i=null,r=this.builder,s=-1,o=mt.spans(this.decorations,e,n,{point:(l,u,f,h,p,O)=>{if(f instanceof Nl){if(this.disallowBlockEffectsFor[O]){if(f.block)throw new RangeError("Block decorations may not be specified via plugins");if(u>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=h.length,p>h.length)r.continueWidget(u-l);else{let y=f.widget||(f.block?Cu.block:Cu.inline),v=lie(f),S=this.cache.findWidget(y,u-l,v)||Ll.of(y,this.view,u-l,v);f.block?(f.startSide>0&&r.addLineStartIfNotCovered(i),r.addBlockWidget(S)):(r.ensureLine(i),r.addInlineWidget(S,h,p))}i=null}else i=cie(i,f);u>l&&this.text.skip(u-l)},span:(l,u,f,h)=>{for(let p=l;p-1&&(this.openWidget=o>s),this.openWidget||r.addLineStartIfNotCovered(i),this.openMarks=o}forward(e,n,i=1){n-e<=10?this.old.advance(n-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let n=[],i=null;for(let r=e.parentNode;;r=r.parentNode){let s=fn.get(r);if(r==this.view.contentDOM)break;s instanceof Ii?n.push(s):s?.isLine()?i=s:s instanceof ko||(r.nodeName=="DIV"&&!i&&r!=this.view.contentDOM?i=new ku(r,xz):i||n.push(Ii.of(new kh({tagName:r.nodeName.toLowerCase(),attributes:Mne(r)}),r)))}return{line:i,marks:n}}}function cR(t,e){let n=i=>{for(let r of i.children)if((e?r.isText():r.length)||n(r))return!0;return!1};return n(t)}function lie(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const xz={class:"cm-line"};function cie(t,e){let n=e.spec.attributes,i=e.spec.class;return!n&&!i||(t||(t={class:"cm-line"}),n&&L1(n,t),i&&(t.class+=" "+i)),t}function uie(t){let e=[];for(let n=t.parents.length;n>1;n--){let i=n==t.parents.length?t.tile:t.parents[n].tile;i instanceof Ii&&e.push(i.mark)}return e}function kb(t){let e=fn.get(t);return e&&e.setDOM(t.cloneNode()),t}class Cu extends qu{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Cu.inline=new Cu("span");Cu.block=new Cu("div");const Cb=new class extends qu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class uR{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Tt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new ty(e,e.contentDOM),this.updateInner([new Rr(0,0,0,e.state.doc.length)],null)}update(e){var n;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:h,toA:p})=>pthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?r=this.domChanged.newSel.head:!vie(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let s=r>-1?fie(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:h,to:p}=this.hasComposition;i=new Rr(h,p,e.changes.mapPos(h,-1),e.changes.mapPos(p,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Te.ie||Te.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let u=gie(o,this.decorations,e.changes);u.length&&(i=Rr.extendWithRanges(i,u));let f=Oie(l,this.blockWrappers,e.changes);return f.length&&(i=Rr.extendWithRanges(i,f)),s&&!i.some(h=>h.fromA<=s.range.fromA&&h.toA>=s.range.toA)&&(i=s.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(n||e.length){let o=this.tile,l=new aie(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&fn.get(n.text)&&l.cache.reused.set(fn.get(n.text),2),this.tile=l.run(e,n),_x(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Te.chrome||Te.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||i.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Sf(i,this.view.observer.selectionRange)&&!(r&&i.contains(r));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let u=this.view.state.selection.main,f,h;if(u.empty?h=f=this.inlineDOMNearPos(u.anchor,u.assoc||1):(h=this.inlineDOMNearPos(u.head,u.head==u.from?1:-1),f=this.inlineDOMNearPos(u.anchor,u.anchor==u.from?1:-1)),Te.gecko&&u.empty&&!this.hasComposition&&die(f)){let O=document.createTextNode("");this.view.observer.ignore(()=>f.node.insertBefore(O,f.node.childNodes[f.offset]||null)),f=h=new Kr(O,0),l=!0}let p=this.view.observer.selectionRange;(l||!p.focusNode||(!xf(f.node,f.offset,p.anchorNode,p.anchorOffset)||!xf(h.node,h.offset,p.focusNode,p.focusOffset))&&!this.suppressWidgetCursorChange(p,u))&&(this.view.observer.ignore(()=>{Te.android&&Te.chrome&&i.contains(p.focusNode)&&yie(p.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let O=Xf(this.view.root);if(O)if(u.empty){if(Te.gecko){let y=hie(f.node,f.offset);if(y&&y!=3){let v=(y==1?tz:nz)(f.node,f.offset);v&&(f=new Kr(v.node,v.offset))}}O.collapse(f.node,f.offset),u.bidiLevel!=null&&O.caretBidiLevel!==void 0&&(O.caretBidiLevel=u.bidiLevel)}else if(O.extend){O.collapse(f.node,f.offset);try{O.extend(h.node,h.offset)}catch{}}else{let y=document.createRange();u.anchor>u.head&&([f,h]=[h,f]),y.setEnd(h.node,h.offset),y.setStart(f.node,f.offset),O.removeAllRanges(),O.addRange(y)}o&&this.view.root.activeElement==i&&(i.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(f,h)),this.impreciseAnchor=f.precise?null:new Kr(p.anchorNode,p.anchorOffset),this.impreciseHead=h.precise?null:new Kr(p.focusNode,p.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&xf(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,i=Xf(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!i||!n.empty||!n.assoc||!i.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let u=this.coordsAt(n.head,-1),f=this.coordsAt(n.head,1);if(!u||!f||u.bottom>f.top)return;let h=this.domAtPos(n.head+n.assoc,n.assoc);i.collapse(h.node,h.offset),i.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let p=e.observer.selectionRange;e.docView.posFromDOM(p.anchorNode,p.anchorOffset)!=n.from&&i.collapse(r,s)}posFromDOM(e,n){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=i.posAtStart;if(i.isComposite()){let s;if(e==i.dom)s=i.dom.childNodes[n];else{let o=Eo(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==i.dom.firstChild)return r;for(;s&&!fn.get(s);)s=s.nextSibling;if(!s)return r+i.length;for(let o=0,l=r;;o++){let u=i.children[o];if(u.dom==s)return l;l+=u.length+u.breakAfter}}else return i.isText()?e==i.dom?r+n:r+(n?i.length:0):r}domAtPos(e,n){let{tile:i,offset:r}=this.tile.resolveBlock(e,n);return i.isWidget()?i.domPosFor(r,n):i.domIn(r,n)}inlineDOMNearPos(e,n){let i,r=-1,s=!1,o,l=-1,u=!1;return this.tile.blockTiles((f,h)=>{if(f.isWidget()){if(f.flags&32&&h>=e)return!0;f.flags&16&&(s=!0)}else{let p=h+f.length;if(h<=e&&(i=f,r=e-h,s=p=e&&!o&&(o=f,l=e-h,u=h>e),h>e&&o)return!0}}),!i&&!o?this.domAtPos(e,n):(s&&o?i=null:u&&i&&(o=null),i&&n<0||!o?i.domIn(r,n):o.domIn(l,n))}coordsAt(e,n,i){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.widget instanceof _b?null:r.coordsInWidget(s,n,!0):r.coordsIn(s,n,i)}lineAt(e,n){let{tile:i}=this.tile.resolveBlock(e,n);return i.isLine()?i:null}coordsForChar(e){let{tile:n,offset:i}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function r(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let u=r(l,o);if(u)return u}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,u=this.view.textDirection==bn.LTR,f=0,h=(p,O,y)=>{for(let v=0;vr);v++){let S=p.children[v],k=O+S.length,C=S.dom.getBoundingClientRect(),{height:$}=C;if(y&&!v&&(f+=C.top-y.top),S instanceof ko)k>i&&h(S,O,C);else if(O>=i&&(f>0&&n.push(-f),n.push($+f),f=0,o)){let T=S.dom.lastChild,Q=T?Wg(T):[];if(Q.length){let A=Q[Q.length-1],R=u?A.right-C.left:C.right-A.left;R>l&&(l=R,this.minWidth=s,this.minWidthFrom=O,this.minWidthTo=k)}}y&&v==p.children.length-1&&(f+=y.bottom-C.bottom),O=k+S.breakAfter}};return h(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?bn.RTL:bn.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,u;for(let f of o.children){if(!f.isText()||/[^ -~]/.test(f.text))return;let h=Wg(f.dom);if(h.length!=1)return;l+=h[0].width,u=h[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:u}}});if(e)return e;let n=document.createElement("div"),i,r,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=Wg(n.firstChild)[0];i=n.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,s=o&&o.height?o.height:i,n.remove()}),{lineHeight:i,charWidth:r,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let i=0,r=0;;r++){let s=r==n.viewports.length?null:n.viewports[r],o=s?s.from-1:this.view.state.doc.length;if(o>i){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(i).top)/this.view.scaleY;e.push(Tt.replace({widget:new _b(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return Tt.set(e)}updateDeco(){let e=1,n=this.view.state.facet(JO).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),i=!1,r=this.view.state.facet(U1).map((s,o)=>{let l=typeof s=="function";return l&&(i=!0),l?s(this.view):s});for(r.length&&(this.dynamicDecorationMap[e++]=i,n.push(mt.join(r))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let f=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=f.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let f of this.view.state.facet(gz))try{if(f(this.view,e.range,e))return!0}catch(h){Ts(this.view.state,h,"scroll handler")}let{range:n}=e,i=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),r;if(!i)return;!n.empty&&(r=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(i={left:Math.min(i.left,r.left),top:Math.min(i.top,r.top),right:Math.max(i.right,r.right),bottom:Math.max(i.bottom,r.bottom)});let s=Sz(this.view),o={left:i.left-s.left,top:i.top-s.top,right:i.right+s.right,bottom:i.bottom+s.bottom},{offsetWidth:l,offsetHeight:u}=this.view.scrollDOM;if(zne(this.view.scrollDOM,o,n.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){_x(this.tile)}}function _x(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let i of t.children)_x(i,e)}}function die(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function wz(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let i=tz(n.focusNode,n.focusOffset),r=nz(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let l=fn.get(r.node);if(!l||l.isText()&&l.text!=r.node.nodeValue)s=r;else if(t.docView.lastCompositionAfterCursor){let u=fn.get(i.node);!u||u.isText()&&u.text!=i.node.nodeValue||(s=r)}}if(t.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function fie(t,e,n){let i=wz(t,n);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(i.from,i.to)!=l)return null;let u=e.invertedDesc;return{range:new Rr(u.mapPos(s),u.mapPos(o),s,o),text:r}}function hie(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(n=!0)}),n}class _b extends qu{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function bie(t,e,n=1){let i=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(r.length==0)return Oe.cursor(e);s==0?n=1:s==r.length&&(n=-1);let o=s,l=s;n<0?o=fi(r.text,s,!1):l=fi(r.text,s);let u=i(r.text.slice(o,l));for(;o>0;){let f=fi(r.text,o,!1);if(i(r.text.slice(f,o))!=u)break;o=f}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,u=Math.floor((r-n.top-(t.defaultLineHeight-l)*.5)/l);s+=u*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+Ene(o,s,t.state.tabSize)}function xie(t,e,n){let i=t.lineBlockAt(e);if(Array.isArray(i.type)){let r;for(let s of i.type){if(s.from>e)break;if(!(s.toe)return s;(!r||s.type==Ui.Text&&(r.type!=s.type||(n<0?s.frome)))&&(r=s)}}return r||i}return i}function wie(t,e,n,i){let r=xie(t,e.head,e.assoc||-1),s=!i||r.type!=Ui.Text||!(t.lineWrapping||r.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(r.from),u=t.posAtCoords({x:n==(l==bn.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(u!=null)return Oe.cursor(u,n?-1:1)}return Oe.cursor(n?r.to:r.from,n?-1:1)}function dR(t,e,n,i){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let l=e,u=null;;){let f=Gne(r,s,o,l,n),h=az;if(!f){if(r.number==(n?t.state.doc.lines:1))return l;h=` +`,r=t.state.doc.line(r.number+(n?1:-1)),s=t.bidiSpans(r),f=t.visualLineSide(r,!n)}if(u){if(!u(h))return l}else{if(!i)return f;u=i(h)}l=f}}function kie(t,e,n){let i=t.state.charCategorizer(e),r=i(n);return s=>{let o=i(s);return r==bo.Space&&(r=o),r==o}}function Cie(t,e,n,i){let r=e.head,s=n?1:-1;if(r==(n?t.state.doc.length:0))return Oe.cursor(r,e.assoc);let o=e.goalColumn,l,u=t.contentDOM.getBoundingClientRect(),f=t.coordsAtPos(r,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),h=t.documentTop;if(f)o==null&&(o=f.left-u.left),l=s<0?f.top:f.bottom;else{let v=t.viewState.lineBlockAt(r);o==null&&(o=Math.min(u.right-u.left,t.defaultCharacterWidth*(r-v.from))),l=(s<0?v.top:v.bottom)+h}let p=u.left+o,O=t.viewState.heightOracle.textHeight>>1,y=i??O;for(let v=0;;v+=O){let S=l+(y+v)*s,k=$x(t,{x:p,y:S},!1,s);if(n?S>u.bottom:Sl:${if(e>s&&er(t)),n.from,e.head>n.from?-1:1);return i==n.from?n:Oe.cursor(i,it.viewState.docHeight)return new ks(t.state.doc.length,-1);if(f=t.elementAtHeight(u),i==null)break;if(f.type==Ui.Text){if(i<0?f.tot.viewport.to)break;let O=t.docView.coordsAt(i<0?f.from:f.to,i>0?-1:1);if(O&&(i<0?O.top<=u+s:O.bottom>=u+s))break}let p=t.viewState.heightOracle.textHeight/2;u=i>0?f.bottom+p:f.top-p}if(t.viewport.from>=f.to||t.viewport.to<=f.from){if(n)return null;if(f.type==Ui.Text){let p=Sie(t,r,f,o,l);return new ks(p,p==f.from?1:-1)}}if(f.type!=Ui.Text)return u<(f.top+f.bottom)/2?new ks(f.from,1):new ks(f.to,-1);let h=t.docView.lineAt(f.from,2);return(!h||h.length!=f.length)&&(h=t.docView.lineAt(f.from,-2)),new _ie(t,o,l,t.textDirectionAt(f.from)).scanTile(h,f.from)}class _ie{constructor(e,n,i,r){this.view=e,this.x=n,this.y=i,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+r.from>1;t:if(o.has(S)){for(let $=1;$=s&&(T-=v),!o.has(T)){S=T;break t}}break e}o.add(S);let k=n(S),C=0;if(k)for(let $=0;$1))if(T.bottomthis.y)(!f||f.top>T.top)&&(f=T),C=-1;else{let Q=T.left>this.x?this.x-T.left:T.right(v+v+S)/3)return this.y=u.bottom-1,this.scan(e,n,!0);if(f&&f.top<(v+S+S)/3)return this.y=f.top+1,this.scan(e,n,!0)}let y=(l?this.dirAt(e[h],1):this.baseDir)==bn.LTR;return{i:h,after:this.x>(O.left+O.right)/2==y}}scanText(e,n){let i=[];for(let s=0;s{let o=i[s]-n,l=i[s+1]-n;return Vf(e.dom,o,l).getClientRects()});return r.after?new ks(i[r.i+1],-1):new ks(i[r.i],1)}scanTile(e,n){if(!e.length)return new ks(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let i=[n];for(let l=0,u=n;l{let u=e.children[l];return u.flags&48?null:(u.dom.nodeType==1?u.dom:Vf(u.dom,0,u.length)).getClientRects()}),s=e.children[r.i],o=i[r.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):r.after?new ks(i[r.i+1],-1):new ks(o,1)}}const Vc="￿";class $ie{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Vc}readRange(e,n){if(!e)return this;let i=e.parentNode;for(let r=e;;){this.findPointBefore(i,r);let s=this.text.length;this.readNode(r);let o=fn.get(r),l=r.nextSibling;if(l==n){o?.breakAfter&&!l&&i!=this.view.contentDOM&&this.lineBreak();break}let u=fn.get(l);(o&&u?o.breakAfter:(o?o.breakAfter:Pm(r))||Pm(l)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>s)&&!Eie(l,n)&&this.lineBreak(),r=l}return this.findPointBefore(i,n),this}readTextNode(e){let n=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,n.length));for(let i=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=r.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(i,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let u of this.points)u.node==e&&u.pos>this.text.length&&(u.pos-=o-1);i=s+o}}readNode(e){let n=fn.get(e),i=n&&n.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let r=i.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==n&&(i.pos=this.text.length)}findPointInside(e,n){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(Tie(e,i.node,i.offset)?n:0))}}function Tie(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Cz(e.docView.tile,n,i,0))){let u=s||o?[]:Aie(e),f=new $ie(u,e);f.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=f.text,this.newSel=Pie(u,this.bounds.from)}else{let u=e.observer.selectionRange,f=s&&s.node==u.focusNode&&s.offset==u.focusOffset||!Sx(e.contentDOM,u.focusNode)?l.main.head:e.docView.posFromDOM(u.focusNode,u.focusOffset),h=o&&o.node==u.anchorNode&&o.offset==u.anchorOffset||!Sx(e.contentDOM,u.anchorNode)?l.main.anchor:e.docView.posFromDOM(u.anchorNode,u.anchorOffset),p=e.viewport;if((Te.ios||Te.chrome)&&f!=h&&Math.min(f,h)<=l.main.from&&Math.max(f,h)>=l.main.to&&(p.from>0||p.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(Oe.range(h,f));else if(e.lineWrapping&&h==f&&!(l.main.empty&&l.main.head==f)&&e.inputState.lastTouchTime>Date.now()-100){let O=e.coordsAtPos(f,-1),y=0;O&&(y=e.inputState.lastTouchY<=O.bottom?-1:1),this.newSel=Oe.create([Oe.cursor(f,y)])}else this.newSel=Oe.single(h,f)}}}function Cz(t,e,n,i){if(t.isComposite()){let r=-1,s=-1,o=-1,l=-1;for(let u=0,f=i,h=i;un)return Cz(p,e,n,f);if(O>=e&&r==-1&&(r=u,s=f),f>n&&p.dom.parentNode==t.dom){o=u,l=h;break}h=O,f=O+p.breakAfter}return{from:s,to:l<0?i+t.length:l,startDOM:(r?t.children[r-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:i,to:i+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function _z(t,e){let n,{newSel:i}=e,{state:r}=t,s=r.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:u}=e.bounds,f=s.from,h=null;(o===8||Te.android&&e.text.length=l&&s.to<=u&&(e.typeOver||p!=e.text)&&p.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&p.slice(s.to-l)==e.text.slice(O=e.text.length-(p.length-(s.to-l)))?n={from:s.from,to:s.to,insert:Ot.of(e.text.slice(s.from-l,O).split(Vc))}:(y=$z(p,e.text,f-l,h))&&(Te.chrome&&o==13&&y.toB==y.from+2&&e.text.slice(y.from,y.toB)==Vc+Vc&&y.toB--,n={from:l+y.from,to:l+y.toA,insert:Ot.of(e.text.slice(y.from,y.toB).split(Vc))})}else i&&(!t.hasFocus&&r.facet(Oo)||zm(i,s))&&(i=null);if(!n&&!i)return!1;if((Te.mac||Te.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(i&&n.insert.length==2&&(i=Oe.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:Ot.of([n.insert.toString().replace("."," ")])}):r.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:r.toText(t.inputState.insertingText)}:Te.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` + `&&t.lineWrapping&&(i&&(i=Oe.single(i.main.anchor-1,i.main.head-1)),n={from:s.from,to:s.to,insert:Ot.of([" "])}),n)return q1(t,n,i,o);if(i&&!zm(i,s)){let l=!1,u="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),u=t.inputState.lastSelectionOrigin,u=="select.pointer"&&(i=kz(r.facet(_h).map(f=>f(t)),i))),t.dispatch({selection:i,scrollIntoView:l,userEvent:u}),!0}else return!1}function q1(t,e,n,i=-1){if(Te.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(Te.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&lu(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.lengthr.head)&&lu(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&lu(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=Qie(t,e,n));return t.state.facet(fz).some(u=>u(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function Qie(t,e,n){let i,r=t.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let u=e.fromp(t)),f,u);e.from==h&&(o=h)}if(o>-1)i={changes:e,selection:Oe.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let u=s.frome.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(t.state.toText(u+e.insert.sliceString(0,void 0,t.state.lineBreak)+f))}else{let u=r.changes(e),f=n&&n.main.to<=u.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let h=t.state.sliceDoc(e.from,e.to),p,O=n&&wz(t,n.main.head);if(O){let v=e.insert.length-(e.to-e.from);p={from:O.from,to:O.to-v}}else p=t.state.doc.lineAt(s.head);let y=s.to-e.to;i=r.changeByRange(v=>{if(v.from==s.from&&v.to==s.to)return{changes:u,range:f||v.map(u)};let S=v.to-y,k=S-h.length;if(t.state.sliceDoc(k,S)!=h||S>=p.from&&k<=p.to)return{range:v};let C=r.changes({from:k,to:S,insert:e.insert}),$=v.to-s.to;return{changes:C,range:f?Oe.range(Math.max(0,f.anchor+$),Math.max(0,f.head+$)):v.map(C)}})}else i={changes:u,selection:f&&r.selection.replaceRange(f)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}function $z(t,e,n,i){let r=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let u=Math.max(0,s-Math.min(o,l));n-=o+u-s}if(o=o?s-n:0;s-=u,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=u,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function Aie(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new fR(n,i)),(r!=n||s!=i)&&e.push(new fR(r,s))),e}function Pie(t,e){if(t.length==0)return null;let n=t[0].pos,i=t.length==2?t[1].pos:n;return n>-1&&i>-1?Oe.single(n+e,i+e):null}function zm(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class jie{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Te.safari&&e.contentDOM.addEventListener("input",()=>null),Te.gecko&&Hie(e.contentDOM.ownerDocument)}handleEvent(e){!Vie(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,n);for(let r of i.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=Die(e),i=this.handlers,r=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=i[s];l&&o!=!l.handlers.length&&(r.removeEventListener(s,this.handleEvent),l=null),l||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!n[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Ez.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Te.android&&Te.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Te.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Tz.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||Nie.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Te.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&Mie(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Te.safari&&!Te.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function Mie(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function hR(t,e){return(n,i)=>{try{return e.call(t,i,n)}catch(r){Ts(n.state,r)}}}function Die(t){let e=Object.create(null);function n(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of t){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let l in s){let u=s[l];u&&n(l).handlers.push(hR(i.value,u))}if(o)for(let l in o){let u=o[l];u&&n(l).observers.push(hR(i.value,u))}}for(let i in ts)n(i).handlers.push(ts[i]);for(let i in $i)n(i).observers.push($i[i]);return e}const Tz=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],Nie="dthko",Ez=[16,17,18,20,91,92,224,225],wg=6;function kg(t){return Math.max(0,t)*.7+8}function zie(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class Lie{constructor(e,n,i,r){this.view=e,this.startEvent=n,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=HN(e.contentDOM),this.atoms=e.state.facet(_h).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&Zie(e,n),this.dragging=Xie(e,n)&&Az(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&zie(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let u=Sz(this.view);e.clientX-u.left<=r+wg?n=-kg(r-e.clientX):e.clientX+u.right>=o-wg&&(n=kg(e.clientX-o)),e.clientY-u.top<=s+wg?i=-kg(s-e.clientY):e.clientY+u.bottom>=l-wg&&(i=kg(e.clientY-l)),this.setScrollSpeed(n,i)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,i=kz(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Zie(t,e){let n=t.state.facet(lz);return n.length?n[0](e):Te.mac?e.metaKey:e.ctrlKey}function Iie(t,e){let n=t.state.facet(cz);return n.length?n[0](e):Te.mac?!e.altKey:!e.ctrlKey}function Xie(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let i=Xf(t.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Vie(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,i;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(i=fn.get(n))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const ts=Object.create(null),$i=Object.create(null),Rz=Te.ie&&Te.ie_version<15||Te.ios&&Te.webkit_version<604;function Bie(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Qz(t,n.value)},50)}function ny(t,e,n){for(let i of t.facet(e))n=i(n,t);return n}function Qz(t,e){e=ny(t.state,X1,e);let{state:n}=t,i,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(Tx!=null&&n.selection.ranges.every(u=>u.empty)&&Tx==s.toString()){let u=-1;i=n.changeByRange(f=>{let h=n.doc.lineAt(f.from);if(h.from==u)return{range:f};u=h.from;let p=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:h.from,insert:p},range:Oe.cursor(f.from+p.length)}})}else o?i=n.changeByRange(u=>{let f=s.line(r++);return{changes:{from:u.from,to:u.to,insert:f.text},range:Oe.cursor(u.from+f.length)}}):i=n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}$i.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Te.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};$i.wheel=$i.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};ts.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);$i.touchstart=(t,e)=>{let n=t.inputState,i=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),i&&(n.lastTouchX=i.clientX,n.lastTouchY=i.clientY),n.setSelectionOrigin("select.pointer")};$i.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};$i.touchend=(t,e)=>{t.inputState.touchActive=!1};ts.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of t.state.facet(uz))if(n=i(t,e),n)break;if(!n&&e.button==0&&(n=qie(t,e)),n){let i=!t.hasFocus;t.inputState.startMouseSelection(new Lie(t,e,n,i)),i&&t.observer.ignore(()=>{JN(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function pR(t,e,n,i){if(i==1)return Oe.cursor(e,n);if(i==2)return bie(t.state,e,n);{let r=t.docView.lineAt(e,n),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(mR+1)%3:1}function qie(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=Az(e),r=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),r=r.map(s.changes))},get(s,o,l){let u=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),f,h=pR(t,u.pos,u.assoc,i);if(n.pos!=u.pos&&!o){let p=pR(t,n.pos,n.assoc,i),O=Math.min(p.from,h.from),y=Math.max(p.to,h.to);h=O1&&(f=Yie(r,u.pos))?f:l?r.addRange(h):Oe.create([h])}}}function Yie(t,e){for(let n=0;n=e)return Oe.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}ts.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let r=t.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=n.to||o<=n.from)&&(n=Oe.undirectionalRange(s,o))}}let{inputState:i}=t;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",ny(t.state,V1,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};ts.dragend=t=>(t.inputState.draggedContent=null,!1);function yR(t,e,n,i){if(n=ny(t.state,X1,n),!n)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=i&&s&&Iie(t,e)?{from:s.from,to:s.to}:null,l={from:r,insert:n},u=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:u,selection:{anchor:u.mapPos(r,-1),head:u.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}ts.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&yR(t,e,i.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return yR(t,e,i,!0),!0}return!1};ts.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Rz?null:e.clipboardData;return n?(Qz(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(Bie(t),!1)};function Fie(t,e){let n=t.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),t.focus()},50)}function Gie(t){let e=[],n=[],i=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),n.push(r));if(!e.length){let r=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>r&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),r=o.number}i=!0}return{text:ny(t,V1,e.join(t.lineBreak)),ranges:n,linewise:i}}let Tx=null;ts.copy=ts.cut=(t,e)=>{if(!Sf(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=Gie(t.state);if(!n&&!r)return!1;Tx=r?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=Rz?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(Fie(t,n),!1)};const Pz=ss.define();function jz(t,e){let n=[];for(let i of t.facet(hz)){let r=i(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:Pz.of(!0)}):null}function Mz(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=jz(t.state,e);n?t.dispatch(n):t.update([])}},10)}$i.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),Mz(t)};$i.blur=t=>{t.observer.clearSelectionRange(),Mz(t)};$i.compositionstart=$i.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};$i.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Te.chrome&&Te.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};$i.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};ts.beforeinput=(t,e)=>{var n,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],u=t.posAtDOM(l.startContainer,l.startOffset),f=t.posAtDOM(l.endContainer,l.endOffset);return q1(t,{from:u,to:f,insert:t.state.toText(s)},null),!0}}let r;if(Te.chrome&&Te.android&&(r=Tz.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Te.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Te.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>$i.compositionend(t,e),20),!1};const vR=new Set;function Hie(t){vR.has(t)||(vR.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const bR=["pre-wrap","normal","pre-line","break-spaces"];let _u=!1;function SR(){_u=!1}class Wie{constructor(e){this.lineWrapping=e,this.doc=Ot.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let i=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((n-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return bR.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let i=0;i-1,u=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=i,this.textHeight=r,this.lineLength=s,u){this.heightSamples={};for(let f=0;f0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>Kg&&(_u=!0),this.height=e)}replace(e,n,i){return _i.of(i)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,i,r){let s=this,o=i.doc;for(let l=r.length-1;l>=0;l--){let{fromA:u,toA:f,fromB:h,toB:p}=r[l],O=s.lineAt(u,Yt.ByPosNoHeight,i.setDoc(n),0,0),y=O.to>=f?O:s.lineAt(f,Yt.ByPosNoHeight,i,0,0);for(p+=y.to-f,f=y.to;l>0&&O.from<=r[l-1].toA;)u=r[l-1].fromA,h=r[l-1].fromB,l--,us*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),i+=1+l.break,r-=l.size}else if(s>r*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,s-=l.size}else break;else if(r=s&&o(this.lineAt(0,Yt.ByPos,i,r,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class sr extends Dz{constructor(e,n,i){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,n){return new Hr(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,i){let r=i[0];return i.length==1&&(r instanceof sr||r instanceof Hn&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof Hn?r=new sr(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):_i.of(i)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(i||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Hn extends _i{constructor(e){super(e,0)}heightMetrics(e,n){let i=e.doc.lineAt(n).number,r=e.doc.lineAt(n+this.length).number,s=r-i+1,o,l=0;if(e.lineWrapping){let u=Math.min(this.height,e.lineHeight*s);o=u/s,this.length>s+1&&(l=(this.height-u)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:l}}blockAt(e,n,i,r){let{firstLine:s,lastLine:o,perLine:l,perChar:u}=this.heightMetrics(n,r);if(n.lineWrapping){let f=r+(e0){let s=i[i.length-1];s instanceof Hn?i[i.length-1]=new Hn(s.length+r):i.push(null,new Hn(r-1))}if(e>0){let s=i[0];s instanceof Hn?i[0]=new Hn(e+s.length):i.unshift(new Hn(e-1),null)}return _i.of(i)}decomposeLeft(e,n){n.push(new Hn(e-1),null)}decomposeRight(e,n){n.push(null,new Hn(this.length-e-1))}updateHeight(e,n=0,i=!1,r){let s=n+this.length;if(r&&r.from<=n+this.length&&r.more){let o=[],l=Math.max(n,r.from),u=-1;for(r.from>n&&o.push(new Hn(r.from-n-1).updateHeight(e,n));l<=s&&r.more;){let h=e.doc.lineAt(l).length;o.length&&o.push(null);let p=r.heights[r.index++],O=0;p<0&&(O=-p,p=r.heights[r.index++]),u==-1?u=p:Math.abs(p-u)>=Kg&&(u=-2);let y=new sr(h,p,O);y.outdated=!1,o.push(y),l+=h+1}l<=s&&o.push(null,new Hn(s-l).updateHeight(e,l));let f=_i.of(o);return(u<0||Math.abs(f.height-this.height)>=Kg||Math.abs(u-this.heightMetrics(e,n).perLine)>=Kg)&&(_u=!0),Lm(this,f)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class ere extends _i{constructor(e,n,i){super(e.length+n+i.length,e.height+i.height,n|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,n,i,r){let s=i+this.left.height;return el))return f;let h=n==Yt.ByPosNoHeight?Yt.ByPosNoHeight:Yt.ByPos;return u?f.join(this.right.lineAt(l,h,i,o,l)):this.left.lineAt(l,h,i,r,s).join(f)}forEachLine(e,n,i,r,s,o){let l=r+this.left.height,u=s+this.left.length+this.break;if(this.break)e=u&&this.right.forEachLine(e,n,i,l,u,o);else{let f=this.lineAt(u,Yt.ByPos,i,r,s);e=e&&f.from<=n&&o(f),n>f.to&&this.right.forEachLine(f.to+1,n,i,l,u,o)}}replace(e,n,i){let r=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-r,n-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of i)s.push(l);if(e>0&&xR(s,o-1),n=i&&n.push(null)),e>i&&this.right.decomposeLeft(e-i,n)}decomposeRight(e,n){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,n);e2*n.size||n.size>2*e.size?_i.of(this.break?[e,null,n]:[e,n]):(this.left=Lm(this.left,e),this.right=Lm(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,i=!1,r){let{left:s,right:o}=this,l=n+s.length+this.break,u=null;return r&&r.from<=n+s.length&&r.more?u=s=s.updateHeight(e,n,i,r):s.updateHeight(e,n,i),r&&r.from<=l+o.length&&r.more?u=o=o.updateHeight(e,l,i,r):o.updateHeight(e,l,i),u?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function xR(t,e){let n,i;t[e]==null&&(n=t[e-1])instanceof Hn&&(i=t[e+1])instanceof Hn&&t.splice(e-1,3,new Hn(n.length+1+i.length))}const tre=5;class Y1{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let i=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof sr?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new sr(i-this.pos,-1,0)),this.writtenTo=i,n>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,i){if(e=tre)&&this.addLineDeco(r,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new sr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let i=new Hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof sr)return e;let n=new sr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=n,this.writtenTo=this.pos=this.pos+i}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof sr)&&!this.isCovered?this.nodes.push(new sr(0,-1,0)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&p.overflow!="visible"){let O=h.getBoundingClientRect();s=Math.max(s,O.left),o=Math.min(o,O.right),l=Math.max(l,O.top),u=Math.min(f==t.parentNode?r.innerHeight:u,O.bottom)}f=p.position=="absolute"||p.position=="fixed"?h.offsetParent:h.parentNode}else if(f.nodeType==11)f=f.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,u)-(n.top+e)}}function sre(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function ore(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class Tb{constructor(e,n,i,r){this.from=e,this.to=n,this.size=i,this.displaySize=r}static same(e,n){if(e.length!=n.length)return!1;for(let i=0;itypeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new Wie(i),this.stateDeco=CR(n),this.heightMap=_i.empty().applyChanges(this.stateDeco,Ot.empty,this.heightOracle.setDoc(n.doc),[new Rr(0,0,0,n.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Tt.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let i=0;i<=1;i++){let r=i?n.head:n.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new Cg(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?kR:new F1(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(gf(e,this.scaler))})}update(e,n=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=CR(this.state);let r=e.changedRanges,s=Rr.extendWithRanges(r,nre(i,this.stateDeco,e?e.changes:jn.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);SR(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||_u)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let u=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headu.to)||!this.viewportIsAppropriate(u))&&(u=this.getViewport(0,n));let f=u.from!=this.viewport.from||u.to!=this.viewport.to;this.viewport=u,e.flags|=this.updateForViewport(),(f||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Wne)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,i=window.getComputedStyle(n),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?bn.RTL:bn.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),u=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let f=0,h=0;if(l.width&&l.height){let{scaleX:A,scaleY:R}=GN(n,l);(A>.005&&Math.abs(this.scaleX-A)>.005||R>.005&&Math.abs(this.scaleY-R)>.005)&&(this.scaleX=A,this.scaleY=R,f|=16,o=u=!0)}let p=(parseInt(i.paddingTop)||0)*this.scaleY,O=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=p||this.paddingBottom!=O)&&(this.paddingTop=p,this.paddingBottom=O,f|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(u=!0),this.editorWidth=e.scrollDOM.clientWidth,f|=16);let y=HN(this.view.contentDOM,!1).y;y!=this.scrollParent&&(this.scrollParent=y,this.scrollAnchorHeight=-1,this.scrollOffset=0);let v=this.getScrollOffset();this.scrollOffset!=v&&(this.scrollAnchorHeight=-1,this.scrollOffset=v),this.scrolledToBottom=ez(this.scrollParent||e.win);let S=(this.printing?ore:rre)(n,this.paddingTop),k=S.top-this.pixelViewport.top,C=S.bottom-this.pixelViewport.bottom;this.pixelViewport=S;let $=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if($!=this.inView&&(this.inView=$,$&&(u=!0)),!this.inView&&!this.scrollTarget&&!sre(e.dom))return 0;let T=l.width;if((this.contentDOMWidth!=T||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,f|=16),u){let A=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(A)&&(o=!0),o||r.lineWrapping&&Math.abs(T-this.contentDOMWidth)>r.charWidth){let{lineHeight:R,charWidth:P,textHeight:X}=e.docView.measureTextSize();o=R>0&&r.refresh(s,R,P,X,Math.max(5,T/P),A),o&&(e.docView.minWidth=0,f|=16)}k>0&&C>0?h=Math.max(k,C):k<0&&C<0&&(h=Math.min(k,C)),SR();for(let R of this.viewports){let P=R.from==this.viewport.from?A:e.docView.measureVisibleLineHeights(R);this.heightMap=(o?_i.empty().applyChanges(this.stateDeco,Ot.empty,this.heightOracle,[new Rr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new Kie(R.from,P))}_u&&(f|=2)}let Q=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return Q&&(f&2&&(f|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),f|=this.updateForViewport()),(f&2||Q)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),f|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),f}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,u=new Cg(r.lineAt(o-i*1e3,Yt.ByHeight,s,0,0).from,r.lineAt(l+(1-i)*1e3,Yt.ByHeight,s,0,0).to);if(n){let{head:f}=n.range;if(fu.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),p=r.lineAt(f,Yt.ByPos,s,0,0),O;n.y=="center"?O=(p.top+p.bottom)/2-h/2:n.y=="start"||n.y=="nearest"&&f=l+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=bn.LTR&&!i)return[];let l=[],u=(h,p,O,y)=>{if(p-hh&&CC.from>=O.from&&C.to<=O.to&&Math.abs(C.from-h)C.from<$&&C.to>$));if(!k){if(pT.from<=p&&T.to>=p)){let T=n.moveToLineBoundary(Oe.cursor(p),!1,!0).head;T>h&&(p=T)}let C=this.gapSize(O,h,p,y),$=i||C<2e6?C:2e6;k=new Tb(h,p,C,$)}l.push(k)},f=h=>{if(h.length2e6)for(let R of e)R.from>=h.from&&R.fromh.from&&u(h.from,y,h,p),vn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let i=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||gf(this.heightMap.lineAt(e,Yt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||gf(this.heightMap.lineAt(this.scaler.fromDOM(e),Yt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return gf(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Cg{constructor(e,n){this.from=e,this.to=n}}function lre(t,e,n){let i=[],r=t,s=0;return mt.spans(n,t,e,{span(){},point(o,l){o>r&&(i.push({from:r,to:o}),s+=o-r),r=l}},20),r=1)return e[e.length-1].to;let i=Math.floor(t*n);for(let r=0;;r++){let{from:s,to:o}=e[r],l=o-s;if(i<=l)return s+i;i-=l}}function $g(t,e){let n=0;for(let{from:i,to:r}of t.ranges){if(e<=r){n+=e-i;break}n+=r-i}return n/t.total}function cre(t,e){for(let n of t)if(e(n))return n}const kR={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function CR(t){let e=t.facet(JO).filter(i=>typeof i!="function"),n=t.facet(U1).filter(i=>typeof i!="function");return n.length&&e.push(mt.join(n)),e}class F1{constructor(e,n,i){let r=0,s=0,o=0;this.viewports=i.map(({from:l,to:u})=>{let f=n.lineAt(l,Yt.ByPos,e,0,0).top,h=n.lineAt(u,Yt.ByPos,e,0,0).bottom;return r+=h-f,{from:l,to:u,top:f,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,i=0,r=0;;n++){let s=nn.from==e.viewports[i].from&&n.to==e.viewports[i].to):!1}}function gf(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),i=e.toDOM(t.bottom);return new Hr(t.from,t.length,n,i-n,Array.isArray(t._content)?t._content.map(r=>gf(r,e)):t._content)}const Tg=Ne.define({combine:t=>t.join(" ")}),Ex=Ne.define({combine:t=>t.indexOf(!0)>-1}),Rx=Ta.newName(),Nz=Ta.newName(),zz=Ta.newName(),Lz={"&light":"."+Nz,"&dark":"."+zz};function Qx(t,e,n){return new Ta(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return t;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):t+" "+i}})}const ure=Qx("."+Rx,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Lz),dre={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Eb=Te.ie&&Te.ie_version<=11;class fre{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Lne,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let i of n)this.queue.push(i);(Te.ie&&Te.ie_version<=11||Te.ios&&e.composing)&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Te.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Te.chrome&&Te.chrome_version<126)&&(this.editContext=new pre(e),e.state.facet(Oo)&&(e.contentDOM.editContext=this.editContext.editContext)),Eb&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,i)=>n!=e[i]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Oo)?i.root.activeElement!=this.dom:!Sf(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Te.ie&&Te.ie_version<=11||Te.android&&Te.chrome)&&!i.state.selection.main.empty&&r.focusNode&&xf(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Xf(e.root);if(!n)return!1;let i=Te.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&hre(this.view,n)||n;if(!i||this.selectionRange.eq(i))return!1;let r=Sf(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&lu(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),n==-1?{from:n,to:i}=o:(n=Math.min(o.from,n),i=Math.max(o.to,i)))}return{from:n,to:i,typeOver:r}}readChange(){let{from:e,to:n,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Sf(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Rie(this.view,e,n,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let i=this.view.state,r=_z(this.view,n);return this.view.state==i&&(n.domChanged||n.newSel&&!zm(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let i=_R(n,e.previousSibling||e.target.previousSibling,-1),r=_R(n,e.nextSibling||e.target.nextSibling,1);return{from:i?n.posAfter(i):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Oo)!=e.state.facet(Oo)&&(e.view.contentDOM.editContext=e.state.facet(Oo)?this.editContext.editContext:null))}destroy(){var e,n,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function _R(t,e,n){for(;e;){let i=fn.get(e);if(i&&i.parent==t)return i;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function $R(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return xf(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}function hre(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return $R(t,r)}let n=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),n?$R(t,n):null}class pre{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,l=this.toEditorPos(i.updateRangeStart),u=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:l,drifted:!1});let f=u-l>i.text.length;l==this.from&&sthis.to&&(u=s);let h=$z(e.state.sliceDoc(l,u),i.text,(f?r.from:r.to)-l,f?"end":null);if(!h){let O=Oe.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));zm(O,r)||e.dispatch({selection:O,userEvent:"select"});return}let p={from:h.from+l,to:h.toA+l,insert:Ot.of(i.text.slice(h.from,h.toB).split(` +`))};if((Te.mac||Te.android)&&p.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(p={from:l,to:u,insert:Ot.of([i.text.replace("."," ")])}),this.pendingContextChange=p,!e.state.readOnly){let O=this.to-this.from+(p.to-p.from+p.insert.length);q1(e,p,Oe.single(this.toEditorPos(i.selectionStart,O),this.toEditorPos(i.selectionEnd,O)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),p.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(n.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);o{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let u=this.toEditorPos(s.rangeStart),f=this.toEditorPos(s.rangeEnd);if(u{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)n.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let r=Xf(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,l,u,f)=>{if(i)return;let h=f.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(f)){r=this.pendingContextChange=null,n+=h,this.to+=h;return}else r=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=h,this.to+=h;else if(sthis.to||this.to-this.from+f.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),f.toString()),this.to+=h}n+=h}),r&&!i&&this.revertPending(e.state),!i}update(e){let n=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Ze{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Zne(e.parent)||document,this.viewState=new wR(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(xg)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Wc).map(r=>new wb(r));for(let r of this.plugins)r.update(this);this.observer=new fre(this),this.inputState=new jie(this),this.inputState.ensureHandlers(this.plugins),this.docView=new uR(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Ci?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,i=!1,r,s=this.state;for(let O of e){if(O.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=O.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,u=null;e.some(O=>O.annotation(Pz))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,u=jz(s,o),u||(l=1));let f=this.observer.delayedAndroidKey,h=null;if(f?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(s);r=Mm.create(this,s,e),r.flags|=l;let p=this.viewState.scrollTarget;try{this.updateState=2;for(let O of e){if(p&&(p=p.map(O.changes)),O.scrollIntoView){let{main:y}=O.state.selection,{x:v,y:S}=this.state.facet(Ze.cursorScrollMargin);p=new cu(y.empty?y:Oe.cursor(y.head,y.head>y.anchor?-1:1),"nearest","nearest",S,v)}for(let y of O.effects)y.is(xg)&&(p=y.value.clip(this.state))}this.viewState.update(r,p),this.bidiCache=Zm.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(pf)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(O=>O.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Tg)!=r.state.facet(Tg)&&(this.viewState.mustMeasureContent=!0),(n||i||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let O of this.state.facet(Cx))try{O(r)}catch(y){Ts(this.state,y,"update listener")}(u||h)&&Promise.resolve().then(()=>{u&&this.state==u.startState&&this.dispatch(u),h&&!_z(this,h)&&f.force&&lu(this.contentDOM,f.key,f.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new wR(this,e),this.plugins=e.facet(Wc).map(i=>new wb(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new uR(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(Wc),i=e.state.facet(Wc);if(n!=i){let r=[];for(let s of i){let o=n.indexOf(s);if(o<0)r.push(new wb(s));else{let l=this.plugins[o];l.mustUpdate=e,r.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o,scaleY:l}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let u=0;;u++){if(o<0){if(ez(i||this.win))s=-1,o=this.viewState.heightMap.height/this.viewState.scaleY;else{let v=this.viewState.scrollAnchorAt(r);s=v.from,o=v.top}l=this.viewState.scaleY}this.updateState=1;let f=this.viewState.measure();if(!f&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(u>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];f&4||([this.measureRequests,h]=[h,this.measureRequests]);let p=h.map(v=>{try{return v.read(this)}catch(S){return Ts(this.state,S),TR}}),O=Mm.create(this,this.state,[]),y=!1;O.flags|=f,n?n.flags|=f:n=O,this.updateState=2,O.empty||(this.updatePlugins(O),this.inputState.update(O),this.updateAttrs(),y=this.docView.update(O),y&&this.docViewUpdate());for(let v=0;v1||S<-1)&&!(Te.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+S,i?s<0?i.scrollTop=i.scrollHeight:i.scrollTop+=S:this.win.scrollBy(0,S),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let u of this.state.facet(Cx))u(n)}get themeClasses(){return Rx+" "+(this.state.facet(Ex)?zz:Nz)+" "+this.state.facet(Tg)}updateAttrs(){let e=ER(this,Oz,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Oo)?"true":"false",class:"cm-content",style:`${Te.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),ER(this,B1,n);let i=this.observer.ignore(()=>{let r=rR(this.contentDOM,this.contentAttrs,n),s=rR(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=n,i}showAnnouncements(e){let n=!0;for(let i of e)for(let r of i.effects)if(r.is(Ze.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(pf);let e=this.state.facet(Ze.cspNonce);Ta.mount(this.root,this.styleModules.concat(ure).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;ni.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,i){return $b(this,e,dR(this,e,n,i))}moveByGroup(e,n){return $b(this,e,dR(this,e,n,i=>kie(this,e.head,i)))}visualLineSide(e,n){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[n?i.length-1:0];return Oe.cursor(s.side(n,r)+e.from,s.forward(!n,r)?1:-1)}moveToLineBoundary(e,n,i=!0){return wie(this,e,n,i)}moveVertically(e,n,i){return $b(this,e,Cie(this,e,n,i))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let i=$x(this,e,n);return i&&i.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),$x(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let i=this.state.doc.lineAt(e),r=this.bidiSpans(i),s=r[$s.find(r,e-i.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==bn.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(pz)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>gre)return oz(e.length);let n=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||sz(s.isolates,i=aR(this,e))))return s.order;i||(i=aR(this,e));let r=Fne(e.text,n,i);return this.bidiCache.push(new Zm(e.from,e.to,n,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Te.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{JN(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var i,r,s,o;return xg.of(new cu(typeof e=="number"?Oe.cursor(e):e,(i=n.y)!==null&&i!==void 0?i:"nearest",(r=n.x)!==null&&r!==void 0?r:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return xg.of(new cu(Oe.cursor(i.from),"start","start",i.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Dr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Dr.define(()=>({}),{eventObservers:e})}static theme(e,n){let i=Ta.newName(),r=[Tg.of(i),pf.of(Qx(`.${i}`,e))];return n&&n.dark&&r.push(Ex.of(!0)),r}static baseTheme(e){return wh.lowest(pf.of(Qx("."+Rx,e,Lz)))}static findFromDOM(e){var n;let i=e.querySelector(".cm-content"),r=i&&fn.get(i)||fn.get(e);return((n=r?.root)===null||n===void 0?void 0:n.view)||null}}Ze.styleModule=pf;Ze.inputHandler=fz;Ze.clipboardInputFilter=X1;Ze.clipboardOutputFilter=V1;Ze.scrollHandler=gz;Ze.focusChangeEffect=hz;Ze.perLineTextDirection=pz;Ze.exceptionSink=dz;Ze.updateListener=Cx;Ze.editable=Oo;Ze.mouseSelectionStyle=uz;Ze.dragMovesSelection=cz;Ze.clickAddsSelectionRange=lz;Ze.decorations=JO;Ze.blockWrappers=yz;Ze.outerDecorations=U1;Ze.atomicRanges=_h;Ze.bidiIsolatedRanges=vz;Ze.cursorScrollMargin=Ne.define({combine:t=>{let e=5,n=5;for(let i of t)typeof i=="number"?e=n=i:{x:e,y:n}=i;return{x:e,y:n}}});Ze.scrollMargins=bz;Ze.darkTheme=Ex;Ze.cspNonce=Ne.define({combine:t=>t.length?t[0]:""});Ze.contentAttributes=B1;Ze.editorAttributes=Oz;Ze.lineWrapping=Ze.contentAttributes.of({class:"cm-lineWrapping"});Ze.announce=Jt.define();const gre=4096,TR={};class Zm{constructor(e,n,i,r,s,o){this.from=e,this.to=n,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:bn.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=i[r],o=typeof s=="function"?s(t):s;o&&L1(o,n)}return n}const mre=Te.mac?"mac":Te.windows?"win":Te.linux?"linux":"key";function Ore(t,e){const n=t.split(/-(?!$)/);let i=n[n.length-1];i=="Space"&&(i=" ");let r,s,o,l;for(let u=0;ui.concat(r),[]))),n}let pa=null;const bre=4e3;function Sre(t,e=mre){let n=Object.create(null),i=Object.create(null),r=(o,l)=>{let u=i[o];if(u==null)i[o]=l;else if(u!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,u,f,h)=>{var p,O;let y=n[o]||(n[o]=Object.create(null)),v=l.split(/ (?!$)/).map(C=>Ore(C,e));for(let C=1;C{let Q=pa={view:T,prefix:$,scope:o};return setTimeout(()=>{pa==Q&&(pa=null)},bre),!0}]})}let S=v.join(" ");r(S,!1);let k=y[S]||(y[S]={preventDefault:!1,stopPropagation:!1,run:((O=(p=y._any)===null||p===void 0?void 0:p.run)===null||O===void 0?void 0:O.slice())||[]});u&&k.run.push(u),f&&(k.preventDefault=!0),h&&(k.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let f of l){let h=n[f]||(n[f]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:p}=o;for(let O in h)h[O].run.push(y=>p(y,Ax))}let u=o[e]||o.key;if(u)for(let f of l)s(f,u,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(f,"Shift-"+u,o.shift,o.preventDefault,o.stopPropagation)}return n}let Ax=null;function xre(t,e,n,i){Ax=e;let r=Pne(e),s=gne(r,0),o=mne(s)==r.length&&r!=" ",l="",u=!1,f=!1,h=!1;pa&&pa.view==n&&pa.scope==i&&(l=pa.prefix+" ",Ez.indexOf(e.keyCode)<0&&(f=!0,pa=null));let p=new Set,O=k=>{if(k){for(let C of k.run)if(!p.has(C)&&(p.add(C),C(n)))return k.stopPropagation&&(h=!0),!0;k.preventDefault&&(k.stopPropagation&&(h=!0),f=!0)}return!1},y=t[i],v,S;return y&&(O(y[l+Eg(r,e,!o)])?u=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Te.windows&&e.ctrlKey&&e.altKey)&&!(Te.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(v=Ea[e.keyCode])&&v!=r?(O(y[l+Eg(v,e,!0)])||e.shiftKey&&(S=Zf[e.keyCode])!=r&&S!=v&&O(y[l+Eg(S,e,!1)]))&&(u=!0):o&&e.shiftKey&&O(y[l+Eg(r,e,!0)])&&(u=!0),!u&&O(y._any)&&(u=!0)),f&&(u=!0),u&&h&&e.stopPropagation(),Ax=null,u}function wre(){return Cre}const kre=Tt.line({class:"cm-activeLine"}),Cre=Dr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let i of t.state.selection.ranges){let r=t.lineBlockAt(i.head);r.from>e&&(n.push(kre.range(r.from)),e=r.from)}return Tt.set(n)}},{decorations:t=>t.decorations});class Zl extends $a{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Zl.prototype.elementClass="";Zl.prototype.toDOM=void 0;Zl.prototype.mapMode=ki.TrackBefore;Zl.prototype.startSide=Zl.prototype.endSide=-1;Zl.prototype.point=!0;const Rb=Ne.define(),_re=Ne.define(),Jg=Ne.define(),QR=Ne.define({combine:t=>t.some(e=>e)});function $re(t){return[Tre]}const Tre=Dr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Jg).map(e=>new PR(t,e)),this.fixed=!t.state.facet(QR);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,i=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(QR)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(Rb),this.view.viewport.from),i=[],r=this.gutters.map(s=>new Ere(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let l of s.type)if(l.type==Ui.Text&&o){Px(n,i,l.from);for(let u of r)u.line(this.view,l,i);o=!1}else if(l.widget)for(let u of r)u.widget(this.view,l)}else if(s.type==Ui.Text){Px(n,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Jg),n=t.state.facet(Jg),i=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(Rb),t.state.facet(Rb),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let r of this.gutters)r.update(t)&&(i=!0);else{i=!0;let r=[];for(let s of n){let o=e.indexOf(s);o<0?r.push(new PR(this.view,s)):(this.gutters[o].update(t),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Ze.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let i=n.dom.offsetWidth*e.scaleX,r=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==bn.LTR?{left:i,right:r}:{right:i,left:r}})});function AR(t){return Array.isArray(t)?t:[t]}function Px(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Ere{constructor(e,n,i){this.gutter=e,this.height=i,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,i){let{gutter:r}=this,s=(n.top-this.height)/e.scaleY,o=n.height/e.scaleY;if(this.i==r.elements.length){let l=new Zz(e,o,s,i);r.elements.push(l),r.dom.appendChild(l.dom)}else r.elements[this.i].update(e,o,s,i);this.height=n.bottom,this.i++}line(e,n,i){let r=[];Px(this.cursor,r,n.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,n,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,n,r)}widget(e,n){let i=this.gutter.config.widgetMarker(e,n.widget,n),r=i?[i]:null;for(let s of e.state.facet(_re)){let o=s(e,n.widget,n);o&&(r||(r=[])).push(o)}r&&this.addElement(e,n,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class PR{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in n.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let u=s.getBoundingClientRect();o=(u.top+u.bottom)/2}else o=r.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);n.domEventHandlers[i](e,l,r)&&r.preventDefault()});this.markers=AR(n.markers(e)),n.initialSpacer&&(this.spacer=new Zz(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=AR(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!mt.eq(this.markers,n,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Zz{constructor(e,n,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,i,r)}update(e,n,i,r){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Rre(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,n){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let l=o,u=ss(l,u,f)||o(l,u,f):o}return i}})}});class Qb extends Zl{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Ab(t,e){return t.state.facet(Kc).formatNumber(e,t.state)}const Pre=Jg.compute([Kc],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Qre)},lineMarker(e,n,i){return i.some(r=>r.toDOM)?null:new Qb(Ab(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,i)=>{for(let r of e.state.facet(Are)){let s=r(e,n,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Kc)!=e.state.facet(Kc),initialSpacer(e){return new Qb(Ab(e,jR(e.state.doc.lines)))},updateSpacer(e,n){let i=Ab(n.view,jR(n.view.state.doc.lines));return i==e.number?e:new Qb(i)},domEventHandlers:t.facet(Kc).domEventHandlers,side:"before"}));function jre(t={}){return[Kc.of(t),$re(),Pre]}function jR(t){let e=9;for(;e{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Dn.match(e)),n=>{let i=e(n);return i===void 0?null:[this,i]}}}He.closedBy=new He({deserialize:t=>t.split(" ")});He.openedBy=new He({deserialize:t=>t.split(" ")});He.group=new He({deserialize:t=>t.split(" ")});He.isolate=new He({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});He.contextHash=new He({perNode:!0});He.lookAhead=new He({perNode:!0});He.mounted=new He({perNode:!0});class uu{constructor(e,n,i,r=!1){this.tree=e,this.overlay=n,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[He.mounted.id]}}const Dre=Object.create(null);class Dn{constructor(e,n,i,r=0){this.name=e,this.props=n,this.id=i,this.flags=r}static define(e){let n=e.props&&e.props.length?Object.create(null):Dre,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Dn(e.name||"",n,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(He.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let i in e)for(let r of i.split(" "))n[r]=e[i];return i=>{for(let r=i.prop(He.group),s=-1;s<(r?r.length:0);s++){let o=n[s<0?i.name:r[s]];if(o)return o}}}}Dn.none=new Dn("",Object.create(null),0,8);class $h{constructor(e){this.types=e;for(let n=0;n0;for(let u=this.cursor(o|$t.IncludeAnonymous);;){let f=!1;if(u.from<=s&&u.to>=r&&(!l&&u.type.isAnonymous||n(u)!==!1)){if(u.firstChild())continue;f=!0}for(;f&&i&&(l||!u.type.isAnonymous)&&i(u),!u.nextSibling();){if(!u.parent())return;f=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:W1(Dn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,i,r)=>new wt(this.type,n,i,r,this.propValues),e.makeTree||((n,i,r)=>new wt(Dn.none,n,i,r)))}static build(e){return Zre(e)}}wt.empty=new wt(Dn.none,[],[],0);class G1{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new G1(this.buffer,this.index)}}class Qa{constructor(e,n,i){this.buffer=e,this.length=n,this.set=i}get type(){return Dn.none}toString(){let e=[];for(let n=0;n0));u=o[u+3]);return l}slice(e,n,i){let r=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,u=0;l=e&&ne;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function Bf(t,e,n,i){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=f;e+=n){let h=l[e],p=u[e]+o.from,O;if(!(!(s&$t.EnterBracketed&&h instanceof wt&&(O=uu.get(h))&&!O.overlay&&O.bracketed&&i>=p&&i<=p+h.length)&&!Xz(r,i,p,p+h.length))){if(h instanceof Qa){if(s&$t.ExcludeBuffers)continue;let y=h.findChild(0,h.buffer.length,n,i-p,r);if(y>-1)return new Es(new Nre(o,h,e,p),null,y)}else if(s&$t.IncludeAnonymous||!h.type.isAnonymous||H1(h)){let y;if(!(s&$t.IgnoreMounts)&&(y=uu.get(h))&&!y.overlay)return new pi(y.tree,p,e,o);let v=new pi(h,p,e,o);return s&$t.IncludeAnonymous||!v.type.isAnonymous?v:v.nextChild(n<0?h.children.length-1:0,n,i,r,s)}}}if(s&$t.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,i=0){let r;if(!(i&$t.IgnoreOverlays)&&(r=uu.get(this._tree))&&r.overlay){let s=e-this.from,o=i&$t.EnterBracketed&&r.bracketed;for(let{from:l,to:u}of r.overlay)if((n>0||o?l<=s:l=s:u>s))return new pi(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function DR(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=r.type.is(n),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function jx(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class Nre{constructor(e,n,i,r){this.parent=e,this.buffer=n,this.index=i,this.start=r}}class Es extends Vz{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,i){super(),this.context=e,this._parent=n,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,n,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,i);return s<0?null:new Es(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,i=0){if(i&$t.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new Es(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Es(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Es(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),n.push(0)}return new wt(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Bz(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new pi(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(Bf(l,e,n,!1))}}return r?Bz(r):i}class Im{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~$t.EnterBracketed,e instanceof pi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof pi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,i=this.mode){return this.buffer?i&$t.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&$t.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&$t.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(i<0?n.buffer.length:n.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,i,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let l=i._tree.children[s];if(this.mode&$t.IncludeAnonymous||l instanceof Qa||!l.type.isAnonymous||H1(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;n=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r=0;s--){if(s<0)return jx(this._tree,e,r);let o=i[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function H1(t){return t.children.some(e=>e instanceof Qa||!e.type.isAnonymous||H1(e))}function Zre(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=Iz,reused:s=[],minRepeatType:o=i.types.length}=t,l=Array.isArray(n)?new G1(n,n.length):n,u=i.types,f=0,h=0;function p(A,R,P,X,te,G){let{id:Y,start:K,end:se,size:H}=l,pe=h,z=f;if(H<0)if(l.next(),H==-1){let D=s[Y];P.push(D),X.push(K-A);return}else if(H==-3){f=Y;return}else if(H==-4){h=Y;return}else throw new RangeError(`Unrecognized record size: ${H}`);let W=u[Y],ce,oe,ae=K-A;if(se-K<=r&&(oe=k(l.pos-R,te))){let D=new Uint16Array(oe.size-oe.skip),j=l.pos-oe.size,I=D.length;for(;l.pos>j;)I=C(oe.start,D,I);ce=new Qa(D,se-oe.start,i),ae=oe.start-A}else{let D=l.pos-H;l.next();let j=[],I=[],N=Y>=o?Y:-1,V=0,ne=se;for(;l.pos>D;)N>=0&&l.id==N&&l.size>=0?(l.end<=ne-r&&(v(j,I,K,V,l.end,ne,N,pe,z),V=j.length,ne=l.end),l.next()):G>2500?O(K,D,j,I):p(K,D,j,I,N,G+1);if(N>=0&&V>0&&V-1&&V>0){let ie=y(W,z);ce=W1(W,j,I,0,j.length,0,se-K,ie,ie)}else ce=S(W,j,I,se-K,pe-se,z)}P.push(ce),X.push(ae)}function O(A,R,P,X){let te=[],G=0,Y=-1;for(;l.pos>R;){let{id:K,start:se,end:H,size:pe}=l;if(pe>4)l.next();else{if(Y>-1&&se=0;H-=3)K[pe++]=te[H],K[pe++]=te[H+1]-se,K[pe++]=te[H+2]-se,K[pe++]=pe;P.push(new Qa(K,te[2]-se,i)),X.push(se-A)}}function y(A,R){return(P,X,te)=>{let G=0,Y=P.length-1,K,se;if(Y>=0&&(K=P[Y])instanceof wt){if(!Y&&K.type==A&&K.length==te)return K;(se=K.prop(He.lookAhead))&&(G=X[Y]+K.length+se)}return S(A,P,X,te,G,R)}}function v(A,R,P,X,te,G,Y,K,se){let H=[],pe=[];for(;A.length>X;)H.push(A.pop()),pe.push(R.pop()+P-te);A.push(S(i.types[Y],H,pe,G-te,K-G,se)),R.push(te-P)}function S(A,R,P,X,te,G,Y){if(G){let K=[He.contextHash,G];Y=Y?[K].concat(Y):[K]}if(te>25){let K=[He.lookAhead,te];Y=Y?[K].concat(Y):[K]}return new wt(A,R,P,X,Y)}function k(A,R){let P=l.fork(),X=0,te=0,G=0,Y=P.end-r,K={size:0,start:0,skip:0};e:for(let se=P.pos-A;P.pos>se;){let H=P.size;if(P.id==R&&H>=0){K.size=X,K.start=te,K.skip=G,G+=4,X+=4,P.next();continue}let pe=P.pos-H;if(H<0||pe=o?4:0,W=P.start;for(P.next();P.pos>pe;){if(P.size<0)if(P.size==-3||P.size==-4)z+=4;else break e;else P.id>=o&&(z+=4);P.next()}te=W,X+=H,G+=z}return(R<0||X==A)&&(K.size=X,K.start=te,K.skip=G),K.size>4?K:void 0}function C(A,R,P){let{id:X,start:te,end:G,size:Y}=l;if(l.next(),Y>=0&&X4){let se=l.pos-(Y-4);for(;l.pos>se;)P=C(A,R,P)}R[--P]=K,R[--P]=G-A,R[--P]=te-A,R[--P]=X}else Y==-3?f=X:Y==-4&&(h=X);return P}let $=[],T=[];for(;l.pos>0;)p(t.start||0,t.bufferStart||0,$,T,-1,0);let Q=(e=t.length)!==null&&e!==void 0?e:$.length?T[0]+$[0].length:0;return new wt(u[t.topID],$.reverse(),T.reverse(),Q)}const NR=new WeakMap;function em(t,e){if(!t.isAnonymous||e instanceof Qa||e.type!=t)return 1;let n=NR.get(e);if(n==null){n=1;for(let i of e.children){if(i.type!=t||!(i instanceof wt)){n=1;break}n+=em(t,i)}NR.set(e,n)}return n}function W1(t,e,n,i,r,s,o,l,u){let f=0;for(let v=i;v=h)break;R+=P}if(T==Q+1){if(R>h){let P=v[Q];y(P.children,P.positions,0,P.children.length,S[Q]+$);continue}p.push(v[Q])}else{let P=S[T-1]+v[T-1].length-A;p.push(W1(t,v,S,Q,T,A,P,null,u))}O.push(A+$-s)}}return y(e,n,i,r,0),(l||u)(p,O,o)}class Uz{constructor(){this.map=new WeakMap}setBuffer(e,n,i){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(n,i)}getBuffer(e,n){let i=this.map.get(e);return i&&i.get(n)}set(e,n){e instanceof Es?this.setBuffer(e.context.buffer,e.index,n):e instanceof pi&&this.map.set(e.tree,n)}get(e){return e instanceof Es?this.getBuffer(e.context.buffer,e.index):e instanceof pi?this.map.get(e.tree):void 0}cursorSet(e,n){e.buffer?this.setBuffer(e.buffer.buffer,e.index,n):this.map.set(e.tree,n)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}}class Co{constructor(e,n,i,r,s=!1,o=!1){this.from=e,this.to=n,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],i=!1){let r=[new Co(0,e.length,e,0,!1,i)];for(let s of n)s.to>e.length&&r.push(s);return r}static applyChanges(e,n,i=128){if(!n.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let l=0,u=0,f=0;;l++){let h=l=i)for(;o&&o.from=O.from||p<=O.to||f){let y=Math.max(O.from,u)-f,v=Math.min(O.to,p)-f;O=y>=v?null:new Co(y,v,O.tree,O.offset+f,l>0,!!h)}if(O&&r.push(O),o.to>p)break;o=snew Qr(r.from,r.to)):[new Qr(0,0)]:[new Qr(0,e.length)],this.createParse(e,n||[],i)}parse(e,n,i){let r=this.startParse(e,n,i);for(;;){let s=r.advance();if(s)return s}}}class Ire{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}function qz(t){return(e,n,i,r)=>new Vre(e,t,n,i,r)}class zR{constructor(e,n,i,r,s,o){this.parser=e,this.parse=n,this.overlay=i,this.bracketed=r,this.target=s,this.from=o}}function LR(t){if(!t.length||t.some(e=>e.from>=e.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}class Xre{constructor(e,n,i,r,s,o,l,u){this.parser=e,this.predicate=n,this.mounts=i,this.index=r,this.start=s,this.bracketed=o,this.target=l,this.prev=u,this.depth=0,this.ranges=[]}}const Mx=new He({perNode:!0});class Vre{constructor(e,n,i,r,s){this.nest=n,this.input=i,this.fragments=r,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let i=this.baseParse.advance();if(!i)return null;if(this.baseParse=null,this.baseTree=i,this.startInner(),this.stoppedAt!=null)for(let r of this.inner)r.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let i=this.baseTree;return this.stoppedAt!=null&&(i=new wt(i.type,i.children,i.positions,i.length,i.propValues.concat([[Mx,this.stoppedAt]]))),i}let e=this.inner[this.innerDone],n=e.parse.advance();if(n){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[He.mounted.id]=new uu(n,e.overlay,e.parser,e.bracketed),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let n=this.innerDone;n=this.stoppedAt)l=!1;else if(e.hasNode(r)){if(n){let f=n.mounts.find(h=>h.frag.from<=r.from&&h.frag.to>=r.to&&h.mount.overlay);if(f)for(let h of f.mount.overlay){let p=h.from+f.pos,O=h.to+f.pos;p>=r.from&&O<=r.to&&!n.ranges.some(y=>y.fromp)&&n.ranges.push({from:p,to:O})}}l=!1}else if(i&&(o=Bre(i.ranges,r.from,r.to)))l=o!=2;else if(!r.type.isAnonymous&&(s=this.nest(r,this.input))&&(r.fromnew Qr(p.from-r.from,p.to-r.from)):null,!!s.bracketed,r.tree,h.length?h[0].from:r.from)),s.overlay?h.length&&(i={ranges:h,depth:0,prev:i}):l=!1}}else if(n&&(u=n.predicate(r))&&(u===!0&&(u=new Qr(r.from,r.to)),u.from=0&&n.ranges[f].to==u.from?n.ranges[f]={from:n.ranges[f].from,to:u.to}:n.ranges.push(u)}if(l&&r.firstChild())n&&n.depth++,i&&i.depth++;else for(;!r.nextSibling();){if(!r.parent())break e;if(n&&!--n.depth){let f=XR(this.ranges,n.ranges);f.length&&(LR(f),this.inner.splice(n.index,0,new zR(n.parser,n.parser.startParse(this.input,VR(n.mounts,f),f),n.ranges.map(h=>new Qr(h.from-n.start,h.to-n.start)),n.bracketed,n.target,f[0].from))),n=n.prev}i&&!--i.depth&&(i=i.prev)}}}}function Bre(t,e,n){for(let i of t){if(i.from>=n)break;if(i.to>e)return i.from<=e&&i.to>=n?2:1}return 0}function ZR(t,e,n,i,r,s){if(e=e&&n.enter(i,1,$t.IgnoreOverlays|$t.ExcludeBuffers)))if(n.to<=e)n.next(!1)||(this.done=!0);else break}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==e.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof wt)n=n.children[0];else break}return!1}}let qre=class{constructor(e){var n;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=(n=i.tree.prop(Mx))!==null&&n!==void 0?n:i.to,this.inner=new IR(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(e=n.tree.prop(Mx))!==null&&e!==void 0?e:n.to,this.inner=new IR(n.tree,-n.offset)}}findMounts(e,n){var i;let r=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let s=this.inner.cursor.node;s;s=s.parent){let o=(i=s.tree)===null||i===void 0?void 0:i.prop(He.mounted);if(o&&o.parser==n)for(let l=this.fragI;l=s.to)break;u.tree==this.curFrag.tree&&r.push({frag:u,pos:s.from-u.offset,mount:o})}}}return r}};function XR(t,e){let n=null,i=e;for(let r=1,s=0;r=l)break;u.to<=o||(n||(i=n=e.slice()),u.froml&&n.splice(s+1,0,new Qr(l,u.to))):u.to>l?n[s--]=new Qr(l,u.to):n.splice(s--,1))}}return i}function Yre(t,e,n,i){let r=0,s=0,o=!1,l=!1,u=-1e9,f=[];for(;;){let h=r==t.length?1e9:o?t[r].to:t[r].from,p=s==e.length?1e9:l?e[s].to:e[s].from;if(o!=l){let O=Math.max(u,n),y=Math.min(h,p,i);Onew Qr(O.from+i,O.to+i)),p=Yre(e,h,u,f);for(let O=0,y=u;;O++){let v=O==p.length,S=v?f:p[O].from;if(S>y&&n.push(new Co(y,S,r.tree,-o,s.from>=y||s.openStart,s.to<=S||s.openEnd)),v)break;y=p[O].to}}else n.push(new Co(u,f,r.tree,-o,s.from>=o||s.openStart,s.to<=l||s.openEnd))}return n}let Fre=0;class lr{constructor(e,n,i,r){this.name=e,this.set=n,this.base=i,this.modified=r,this.id=Fre++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let i=typeof e=="string"?e:"?";if(e instanceof lr&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let r=new lr(i,[],null,[]);if(r.set.push(r),n)for(let s of n.set)r.set.push(s);return r}static defineModifier(e){let n=new Xm(e);return i=>i.modified.indexOf(n)>-1?i:Xm.get(i.base||i,i.modified.concat(n).sort((r,s)=>r.id-s.id))}}let Gre=0;class Xm{constructor(e){this.name=e,this.instances=[],this.id=Gre++}static get(e,n){if(!n.length)return e;let i=n[0].instances.find(l=>l.base==e&&Hre(n,l.modified));if(i)return i;let r=[],s=new lr(e.name,r,e,n);for(let l of n)l.instances.push(s);let o=Wre(n);for(let l of e.set)if(!l.modified.length)for(let u of o)r.push(Xm.get(l,u));return s}}function Hre(t,e){return t.length==e.length&&t.every((n,i)=>n==e[i])}function Wre(t){let e=[[]];for(let n=0;ni.length-n.length)}function Yu(t){let e=Object.create(null);for(let n in t){let i=t[n];Array.isArray(i)||(i=[i]);for(let r of n.split(" "))if(r){let s=[],o=2,l=r;for(let p=0;;){if(l=="..."&&p>0&&p+3==r.length){o=1;break}let O=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!O)throw new RangeError("Invalid path: "+r);if(s.push(O[0]=="*"?"":O[0][0]=='"'?JSON.parse(O[0]):O[0]),p+=O[0].length,p==r.length)break;let y=r[p++];if(p==r.length&&y=="!"){o=0;break}if(y!="/")throw new RangeError("Invalid path: "+r);l=r.slice(p)}let u=s.length-1,f=s[u];if(!f)throw new RangeError("Invalid path: "+r);let h=new Uf(i,o,u>0?s.slice(0,u):null);e[f]=h.sort(e[f])}}return Yz.add(e)}const Yz=new He({combine(t,e){let n,i,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let s=new Uf(r.tags,r.mode,r.context);n?n.next=s:i=s,n=s}return i}});class Uf{constructor(e,n,i,r){this.tags=e,this.mode=n,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=r;for(let l of s)for(let u of l.set){let f=n[u.id];if(f){o=o?o+" "+f:f;break}}return o},scope:i}}function Kre(t,e){let n=null;for(let i of t){let r=i.style(e);r&&(n=n?n+" "+r:r)}return n}function Jre(t,e,n,i=0,r=t.length){let s=new ese(i,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),i,r,"",s.highlighters),s.flush(r)}class ese{constructor(e,n,i){this.at=e,this.highlighters=n,this.span=i,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,i,r,s){let{type:o,from:l,to:u}=e;if(l>=i||u<=n)return;o.isTop&&(s=this.highlighters.filter(y=>!y.scope||y.scope(o)));let f=r,h=tse(e)||Uf.empty,p=Kre(s,h.tags);if(p&&(f&&(f+=" "),f+=p,h.mode==1&&(r+=(r?" ":"")+p)),this.startSpan(Math.max(n,l),f),h.opaque)return;let O=e.tree&&e.tree.prop(He.mounted);if(O&&O.overlay){let y=e.node.enter(O.overlay[0].from+l,1),v=this.highlighters.filter(k=>!k.scope||k.scope(O.tree.type)),S=e.firstChild();for(let k=0,C=l;;k++){let $=k=T||!e.nextSibling())););if(!$||T>i)break;C=$.to+l,C>n&&(this.highlightRange(y.cursor(),Math.max(n,$.from+l),Math.min(i,C),"",v),this.startSpan(Math.min(i,C),f))}S&&e.parent()}else if(e.firstChild()){O&&(r="");do if(!(e.to<=n)){if(e.from>=i)break;this.highlightRange(e,n,i,r,s),this.startSpan(Math.min(i,e.to),f)}while(e.nextSibling());e.parent()}}}function tse(t){let e=t.type.prop(Yz);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const Ce=lr.define,Qg=Ce(),da=Ce(),BR=Ce(da),UR=Ce(da),fa=Ce(),Ag=Ce(fa),Pb=Ce(fa),vs=Ce(),fl=Ce(vs),ms=Ce(),Os=Ce(),Dx=Ce(),ef=Ce(Dx),Pg=Ce(),Z={comment:Qg,lineComment:Ce(Qg),blockComment:Ce(Qg),docComment:Ce(Qg),name:da,variableName:Ce(da),typeName:BR,tagName:Ce(BR),propertyName:UR,attributeName:Ce(UR),className:Ce(da),labelName:Ce(da),namespace:Ce(da),macroName:Ce(da),literal:fa,string:Ag,docString:Ce(Ag),character:Ce(Ag),attributeValue:Ce(Ag),number:Pb,integer:Ce(Pb),float:Ce(Pb),bool:Ce(fa),regexp:Ce(fa),escape:Ce(fa),color:Ce(fa),url:Ce(fa),keyword:ms,self:Ce(ms),null:Ce(ms),atom:Ce(ms),unit:Ce(ms),modifier:Ce(ms),operatorKeyword:Ce(ms),controlKeyword:Ce(ms),definitionKeyword:Ce(ms),moduleKeyword:Ce(ms),operator:Os,derefOperator:Ce(Os),arithmeticOperator:Ce(Os),logicOperator:Ce(Os),bitwiseOperator:Ce(Os),compareOperator:Ce(Os),updateOperator:Ce(Os),definitionOperator:Ce(Os),typeOperator:Ce(Os),controlOperator:Ce(Os),punctuation:Dx,separator:Ce(Dx),bracket:ef,angleBracket:Ce(ef),squareBracket:Ce(ef),paren:Ce(ef),brace:Ce(ef),content:vs,heading:fl,heading1:Ce(fl),heading2:Ce(fl),heading3:Ce(fl),heading4:Ce(fl),heading5:Ce(fl),heading6:Ce(fl),contentSeparator:Ce(vs),list:Ce(vs),quote:Ce(vs),emphasis:Ce(vs),strong:Ce(vs),link:Ce(vs),monospace:Ce(vs),strikethrough:Ce(vs),inserted:Ce(),deleted:Ce(),changed:Ce(),invalid:Ce(),meta:Pg,documentMeta:Ce(Pg),annotation:Ce(Pg),processingInstruction:Ce(Pg),definition:lr.defineModifier("definition"),constant:lr.defineModifier("constant"),function:lr.defineModifier("function"),standard:lr.defineModifier("standard"),local:lr.defineModifier("local"),special:lr.defineModifier("special")};for(let t in Z){let e=Z[t];e instanceof lr&&(e.name=t)}Fz([{tag:Z.link,class:"tok-link"},{tag:Z.heading,class:"tok-heading"},{tag:Z.emphasis,class:"tok-emphasis"},{tag:Z.strong,class:"tok-strong"},{tag:Z.keyword,class:"tok-keyword"},{tag:Z.atom,class:"tok-atom"},{tag:Z.bool,class:"tok-bool"},{tag:Z.url,class:"tok-url"},{tag:Z.labelName,class:"tok-labelName"},{tag:Z.inserted,class:"tok-inserted"},{tag:Z.deleted,class:"tok-deleted"},{tag:Z.literal,class:"tok-literal"},{tag:Z.string,class:"tok-string"},{tag:Z.number,class:"tok-number"},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],class:"tok-string2"},{tag:Z.variableName,class:"tok-variableName"},{tag:Z.local(Z.variableName),class:"tok-variableName tok-local"},{tag:Z.definition(Z.variableName),class:"tok-variableName tok-definition"},{tag:Z.special(Z.variableName),class:"tok-variableName2"},{tag:Z.definition(Z.propertyName),class:"tok-propertyName tok-definition"},{tag:Z.typeName,class:"tok-typeName"},{tag:Z.namespace,class:"tok-namespace"},{tag:Z.className,class:"tok-className"},{tag:Z.macroName,class:"tok-macroName"},{tag:Z.propertyName,class:"tok-propertyName"},{tag:Z.operator,class:"tok-operator"},{tag:Z.comment,class:"tok-comment"},{tag:Z.meta,class:"tok-meta"},{tag:Z.invalid,class:"tok-invalid"},{tag:Z.punctuation,class:"tok-punctuation"}]);var jb;const xl=new He;function J1(t){return Ne.define({combine:t?e=>e.concat(t):void 0})}const ek=new He;class Ar{constructor(e,n,i=[],r=""){this.data=e,this.name=r,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return hn(this)}}),this.parser=n,this.extension=[Eu.of(this),St.languageData.of((s,o,l)=>{let u=qR(s,o,l),f=u.type.prop(xl);if(!f)return[];let h=s.facet(f),p=u.type.prop(ek);if(p){let O=u.resolve(o-u.from,l);for(let y of p)if(y.test(O,s)){let v=s.facet(y.facet);return y.type=="replace"?v:v.concat(h)}}return h})].concat(i)}isActiveAt(e,n,i=-1){return qR(e,n,i).type.prop(xl)==this.data}findRegions(e){let n=e.facet(Eu);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(xl)==this.data){i.push({from:o,to:o+s.length});return}let l=s.prop(He.mounted);if(l){if(l.tree.prop(xl)==this.data){if(l.overlay)for(let u of l.overlay)i.push({from:u.from+o,to:u.to+o});else i.push({from:o,to:o+s.length});return}else if(l.overlay){let u=i.length;if(r(l.tree,l.overlay[0].from+o),i.length>u)return}}for(let u=0;ui.isTop?n:void 0)]}),e.name)}configure(e,n){return new $u(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function hn(t){let e=t.field(Ar.state,!1);return e?e.tree:wt.empty}class nse{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-i,n-i)}}let tf=null;class qf{constructor(e,n,i=[],r,s,o,l,u){this.parser=e,this.state=n,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=u,this.parse=null,this.tempSkipped=[]}static create(e,n,i){return new qf(e,n,[],wt.empty,0,i,[],null)}startParse(){return this.parser.startParse(new nse(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=wt.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(Co.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=tf;tf=this;try{return e()}finally{tf=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=YR(e,n.from,n.to);return e}changes(e,n){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let u=[];if(e.iterChangedRanges((f,h,p,O)=>u.push({fromA:f,toA:h,fromB:p,toB:O})),i=Co.applyChanges(i,u),r=wt.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let f of this.skipped){let h=e.mapPos(f.from,1),p=e.mapPos(f.to,-1);he.from&&(this.fragments=YR(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends K1{createParse(n,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let u=tf;if(u){for(let f of r)u.tempSkipped.push(f);e&&(u.scheduleOn=u.scheduleOn?Promise.all([u.scheduleOn,e]):e)}return this.parsedPos=o,new wt(Dn.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return tf}}function YR(t,e,n){return Co.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Tu{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,i)||n.takeTree(),new Tu(n)}static init(e){let n=Math.min(3e3,e.doc.length),i=qf.create(e.facet(Eu).parser,e,{from:0,to:n});return i.work(20,n)||i.takeTree(),new Tu(i)}}Ar.state=Ao.define({create:Tu.init,update(t,e){for(let n of e.effects)if(n.is(Ar.setState))return n.value;return e.startState.facet(Eu)!=e.state.facet(Eu)?Tu.init(e.state):t.apply(e)}});let Gz=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Gz=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Mb=typeof navigator<"u"&&(!((jb=navigator.scheduling)===null||jb===void 0)&&jb.isInputPending)?()=>navigator.scheduling.isInputPending():null,ise=Dr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Ar.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Ar.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Gz(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndr+1e3,u=s.context.work(()=>Mb&&Mb()||Date.now()>o,r+(l?0:1e5));this.chunkBudget-=Date.now()-n,(u||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ar.setState.of(new Tu(s.context))})),this.chunkBudget>0&&!(u&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Ts(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Eu=Ne.define({combine(t){return t.length?t[0]:null},enables:t=>[Ar.state,ise,Ze.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class Yf{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}class Vm{constructor(e,n,i,r,s,o=void 0){this.name=e,this.alias=n,this.extensions=i,this.filename=r,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e}))}static of(e){let{load:n,support:i}=e;if(!n){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");n=()=>Promise.resolve(i)}return new Vm(e.name,(e.alias||[]).concat(e.name).map(r=>r.toLowerCase()),e.extensions||[],e.filename,n,i)}static matchFilename(e,n){for(let r of e)if(r.filename&&r.filename.test(n))return r;let i=/\.([^.]+)$/.exec(n);if(i){for(let r of e)if(r.extensions.indexOf(i[1])>-1)return r}return null}static matchLanguageName(e,n,i=!0){n=n.toLowerCase();for(let r of e)if(r.alias.some(s=>s==n))return r;if(i)for(let r of e)for(let s of r.alias){let o=n.indexOf(s);if(o>-1&&(s.length>2||!/\w/.test(n[o-1])&&!/\w/.test(n[o+s.length])))return r}return null}}const rse=Ne.define(),Th=Ne.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Bm(t){let e=t.facet(Th);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Um(t,e){let n="",i=t.tabSize,r=t.facet(Th)[0];if(r==" "){for(;e>=i;)n+=" ",e-=i;r=" "}for(let s=0;s=e?sse(t,n,e):null}class ry{constructor(e,n={}){this.state=e,this.options=n,this.unit=Bm(e)}lineAt(e,n=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(n<0?r-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,n=e.length){return To(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Eh=new He;function sse(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let s=[];for(let o=r;o&&!(o.fromi.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return Wz(i,t,n)}function Wz(t,e,n){for(let i=t;i;i=i.next){let r=ase(i.node);if(r)return r(tk.create(e,n,i))}return 0}function ose(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function ase(t){let e=t.type.prop(Eh);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(He.closedBy))){let r=t.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>Kz(o,!0,1,void 0,s&&!ose(o)?r.from:void 0)}return t.parent==null?lse:null}function lse(){return 0}class tk extends ry{constructor(e,n,i){super(e.state,e.options),this.base=e,this.pos=n,this.context=i}get node(){return this.context.node}static create(e,n,i){return new tk(e,n,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(n.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(cse(i,e))break;n=this.state.doc.lineAt(i.from)}return this.lineIndent(n.from)}continue(){return Wz(this.context.next,this.base,this.pos)}}function cse(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function use(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let l=n.to;;){let u=e.childAfter(l);if(!u||u==i)return null;if(!u.type.isSkipped){if(u.from>=o)return null;let f=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+f}}l=u.to}}function dse({closing:t,align:e=!0,units:n=1}){return i=>Kz(i,e,n,t)}function Kz(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==t.pos+o,u=e?use(t):null;return u?l?t.column(u.from):t.column(u.to):t.baseIndent+(l?0:t.unit*n)}const fse=t=>t.baseIndent;function tm({except:t,units:e=1}={}){return n=>{let i=t&&t.test(n.textAfter);return n.baseIndent+(i?0:e*n.unit)}}const hse=Ne.define(),Rh=new He;function Jz(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(xl)==o.data:o?l=>l==o:void 0,this.style=Fz(e.map(l=>({tag:l.tag,class:l.class||r(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=i?new Ta(i):null,this.themeType=n.themeType}static define(e,n){return new sy(e,n||{})}}const Nx=Ne.define(),e5=Ne.define({combine(t){return t.length?[t[0]]:null}});function Db(t){let e=t.facet(Nx);return e.length?e:t.facet(e5)}function pse(t,e){let n=[mse],i;return t instanceof sy&&(t.module&&n.push(Ze.styleModule.of(t.module)),i=t.themeType),e?.fallback?n.push(e5.of(t)):i?n.push(Nx.computeN([Ze.darkTheme],r=>r.facet(Ze.darkTheme)==(i=="dark")?[t]:[])):n.push(Nx.of(t)),n}class gse{constructor(e){this.markCache=Object.create(null),this.tree=hn(e.state),this.decorations=this.buildDeco(e,Db(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=hn(e.state),i=Db(e.state),r=i!=Db(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Tt.none;let i=new ou;for(let{from:r,to:s}of e.visibleRanges)Jre(this.tree,n,(o,l,u)=>{i.add(o,l,this.markCache[u]||(this.markCache[u]=Tt.mark({class:u})))},r,s);return i.finish()}}const mse=wh.high(Dr.fromClass(gse,{decorations:t=>t.decorations})),Ose=sy.define([{tag:Z.meta,color:"#404740"},{tag:Z.link,textDecoration:"underline"},{tag:Z.heading,textDecoration:"underline",fontWeight:"bold"},{tag:Z.emphasis,fontStyle:"italic"},{tag:Z.strong,fontWeight:"bold"},{tag:Z.strikethrough,textDecoration:"line-through"},{tag:Z.keyword,color:"#708"},{tag:[Z.atom,Z.bool,Z.url,Z.contentSeparator,Z.labelName],color:"#219"},{tag:[Z.literal,Z.inserted],color:"#164"},{tag:[Z.string,Z.deleted],color:"#a11"},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],color:"#e40"},{tag:Z.definition(Z.variableName),color:"#00f"},{tag:Z.local(Z.variableName),color:"#30a"},{tag:[Z.typeName,Z.namespace],color:"#085"},{tag:Z.className,color:"#167"},{tag:[Z.special(Z.variableName),Z.macroName],color:"#256"},{tag:Z.definition(Z.propertyName),color:"#00c"},{tag:Z.comment,color:"#940"},{tag:Z.invalid,color:"#f00"}]),yse=1e4,vse="()[]{}",t5=new He;function zx(t,e,n){let i=t.prop(e<0?He.openedBy:He.closedBy);if(i)return i;if(t.name.length==1){let r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function Lx(t){let e=t.type.prop(t5);return e?e(t.node):t}function Jc(t,e,n,i={}){let r=i.maxScanDistance||yse,s=i.brackets||vse,o=hn(t),l=o.resolveInner(e,n);for(let u=l;u;u=u.parent){let f=zx(u.type,n,s);if(f&&u.from0?e>=h.from&&eh.from&&e<=h.to))return bse(t,e,n,u,h,f,s)}}return Sse(t,e,n,o,l.type,r,s)}function bse(t,e,n,i,r,s,o){let l=i.parent,u={from:r.from,to:r.to},f=0,h=l?.cursor();if(h&&(n<0?h.childBefore(i.from):h.childAfter(i.to)))do if(n<0?h.to<=i.from:h.from>=i.to){if(f==0&&s.indexOf(h.type.name)>-1&&h.from0)return null;let f={from:n<0?e-1:e,to:n>0?e+1:e},h=t.doc.iterRange(e,n>0?t.doc.length:0),p=0;for(let O=0;!h.next().done&&O<=s;){let y=h.value;n<0&&(O+=y.length);let v=e+O*n;for(let S=n>0?0:y.length-1,k=n>0?y.length:-1;S!=k;S+=n){let C=o.indexOf(y[S]);if(!(C<0||i.resolveInner(v+S,1).type!=r))if(C%2==0==n>0)p++;else{if(p==1)return{start:f,end:{from:v+S,to:v+S+1},matched:C>>1==u>>1};p--}}n>0&&(O+=y.length)}return h.done?{start:f,matched:!1}:null}const xse=Object.create(null),FR=[Dn.none],GR=[],HR=Object.create(null),wse=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])wse[t]=kse(xse,e);function Nb(t,e){GR.indexOf(t)>-1||(GR.push(t),console.warn(e))}function kse(t,e){let n=[];for(let l of e.split(" ")){let u=[];for(let f of l.split(".")){let h=t[f]||Z[f];h?typeof h=="function"?u.length?u=u.map(h):Nb(f,`Modifier ${f} used at start of tag`):u.length?Nb(f,`Tag ${f} used as modifier`):u=Array.isArray(h)?h:[h]:Nb(f,`Unknown highlighting tag ${f}`)}for(let f of u)n.push(f)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+n.map(l=>l.id),s=HR[r];if(s)return s.id;let o=HR[r]=Dn.define({id:FR.length,name:i,props:[Yu({[i]:n})]});return FR.push(o),o.id}bn.RTL,bn.LTR;const Cse=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=ik(t.state,n.from);return i.line?_se(t):i.block?Tse(t):!1};function nk(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return r?(i(n.update(r)),!0):!1}}const _se=nk(Qse,0),$se=nk(n5,0),Tse=nk((t,e)=>n5(t,e,Rse(e)),0);function ik(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const nf=50;function Ese(t,{open:e,close:n},i,r){let s=t.sliceDoc(i-nf,i),o=t.sliceDoc(r,r+nf),l=/\s*$/.exec(s)[0].length,u=/^\s*/.exec(o)[0].length,f=s.length-l;if(s.slice(f-e.length,f)==e&&o.slice(u,u+n.length)==n)return{open:{pos:i-l,margin:l&&1},close:{pos:r+u,margin:u&&1}};let h,p;r-i<=2*nf?h=p=t.sliceDoc(i,r):(h=t.sliceDoc(i,i+nf),p=t.sliceDoc(r-nf,r));let O=/^\s*/.exec(h)[0].length,y=/\s*$/.exec(p)[0].length,v=p.length-y-n.length;return h.slice(O,O+e.length)==e&&p.slice(v,v+n.length)==n?{open:{pos:i+O+e.length,margin:/\s/.test(h.charAt(O+e.length))?1:0},close:{pos:r-y-n.length,margin:/\s/.test(p.charAt(v-1))?1:0}}:null}function Rse(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function n5(t,e,n=e.selection.ranges){let i=n.map(s=>ik(e,s.from).block);if(!i.every(s=>s))return null;let r=n.map((s,o)=>Ese(e,i[o],s.from,s.to));if(t!=2&&!r.every(s=>s))return{changes:e.changes(n.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(t!=1&&r.some(s=>s)){let s=[];for(let o=0,l;or&&(s==o||o>p.from)){r=p.from;let O=/^\s*/.exec(p.text)[0].length,y=O==p.length,v=p.text.slice(O,O+f.length)==f?O:-1;Os.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:u,indent:f,empty:h,single:p}of i)(p||!h)&&s.push({from:l.from+f,insert:u+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:u}of i)if(l>=0){let f=o.from+l,h=f+u.length;o.text[h-o.from]==" "&&h++,s.push({from:f,to:h})}return{changes:s}}return null}const Zx=ss.define(),Ase=ss.define(),Pse=Ne.define(),i5=Ne.define({combine(t){return BN(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(i,r)=>e(i,r)||n(i,r)})}}),r5=Ao.define({create(){return Rs.empty},update(t,e){let n=e.state.facet(i5),i=e.annotation(Zx);if(i){let u=Vi.fromTransaction(e,i.selection),f=i.side,h=f==0?t.undone:t.done;return u?h=qm(h,h.length,n.minDepth,u):h=a5(h,e.startState.selection),new Rs(f==0?i.rest:h,f==0?h:i.rest)}let r=e.annotation(Ase);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(Ci.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Vi.fromTransaction(e),o=e.annotation(Ci.time),l=e.annotation(Ci.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Rs(t.done.map(Vi.fromJSON),t.undone.map(Vi.fromJSON))}});function jse(t={}){return[r5,i5.of(t),Ze.domEventHandlers({beforeinput(e,n){let i=e.inputType=="historyUndo"?s5:e.inputType=="historyRedo"?Ix:null;return i?(e.preventDefault(),i(n)):!1}})]}function oy(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(r5,!1);if(!r)return!1;let s=r.pop(t,n,e);return s?(i(s),!0):!1}}const s5=oy(0,!1),Ix=oy(1,!1),Mse=oy(0,!0),Dse=oy(1,!0);class Vi{constructor(e,n,i,r,s){this.changes=e,this.effects=n,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new Vi(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new Vi(e.changes&&jn.fromJSON(e.changes),[],e.mapped&&js.fromJSON(e.mapped),e.startSelection&&Oe.fromJSON(e.startSelection),e.selectionsAfter.map(Oe.fromJSON))}static fromTransaction(e,n){let i=Pr;for(let r of e.startState.facet(Pse)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new Vi(e.changes.invert(e.startState.doc),i,void 0,n||e.startState.selection,Pr)}static selection(e){return new Vi(void 0,Pr,void 0,void 0,e)}}function qm(t,e,n,i){let r=e+1>n+20?e-n-1:0,s=t.slice(r,e);return s.push(i),s}function Nse(t,e){let n=[],i=!1;return t.iterChangedRanges((r,s)=>n.push(r,s)),e.iterChangedRanges((r,s,o,l)=>{for(let u=0;u=f&&o<=h&&(i=!0)}}),i}function zse(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,i)=>n.empty!=e.ranges[i].empty).length===0}function o5(t,e){return t.length?e.length?t.concat(e):t:e}const Pr=[],Lse=200;function a5(t,e){if(t.length){let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Lse));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),qm(t,t.length-1,1e9,n.setSelAfter(i)))}else return[Vi.selection([e])]}function Zse(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function zb(t,e){if(!t.length)return t;let n=t.length,i=Pr;for(;n;){let r=Ise(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=t.slice(0,n);return s[n-1]=r,s}else e=r.mapped,n--,i=r.selectionsAfter}return i.length?[Vi.selection(i)]:Pr}function Ise(t,e,n){let i=o5(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):Pr,n);if(!t.changes)return Vi.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Vi(r,Jt.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}const Xse=/^(input\.type|delete)($|\.)/;class Rs{constructor(e,n,i=0,r=void 0){this.done=e,this.undone=n,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new Rs(this.done,this.undone):this}addChanges(e,n,i,r,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||Xse.test(i))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):ay(n,e))}function mi(t){return t.textDirectionAt(t.state.selection.main.head)==bn.LTR}const c5=t=>l5(t,!mi(t)),u5=t=>l5(t,mi(t));function d5(t,e){return as(t,n=>n.empty?t.moveByGroup(n,e):ay(n,e))}const Bse=t=>d5(t,!mi(t)),Use=t=>d5(t,mi(t));function qse(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function ly(t,e,n){let i=hn(t).resolveInner(e.head),r=n?He.closedBy:He.openedBy;for(let u=e.head;;){let f=n?i.childAfter(u):i.childBefore(u);if(!f)break;qse(t,f,r)?i=f:u=n?f.to:f.from}let s=i.type.prop(r),o,l;return s&&(o=n?Jc(t,i.from,1):Jc(t,i.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?i.to:i.from,Oe.cursor(l,n?-1:1)}const Yse=t=>as(t,e=>ly(t.state,e,!mi(t))),Fse=t=>as(t,e=>ly(t.state,e,mi(t)));function f5(t,e){return as(t,n=>{if(!n.empty)return ay(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)})}const h5=t=>f5(t,!1),p5=t=>f5(t,!0);function g5(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):ay(o,e));if(r.eq(i.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(i.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),u=l.top+n.marginTop,f=l.bottom-n.marginBottom;o&&o.top>u&&o.bottomm5(t,!1),Xx=t=>m5(t,!0);function Va(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let s=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=Oe.cursor(i.from+s))}return r}const Gse=t=>as(t,e=>Va(t,e,!0)),Hse=t=>as(t,e=>Va(t,e,!1)),Wse=t=>as(t,e=>Va(t,e,!mi(t))),Kse=t=>as(t,e=>Va(t,e,mi(t))),Jse=t=>as(t,e=>Oe.cursor(t.lineBlockAt(e.head).from,1)),eoe=t=>as(t,e=>Oe.cursor(t.lineBlockAt(e.head).to,-1));function toe(t,e,n){let i=!1,r=Fu(t.selection,s=>{let o=Jc(t,s.head,-1)||Jc(t,s.head,1)||s.head>0&&Jc(t,s.head-1,1)||s.headtoe(t,e);function zr(t,e,n){let i=Fu(t.state.selection,r=>{r.undirectional&&r.head>=r.anchor!=e&&(r=Oe.range(r.head,r.anchor));let s=n(r);return Oe.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return i.eq(t.state.selection)?!1:(t.dispatch(os(t.state,i)),!0)}function O5(t,e){return zr(t,e,n=>t.moveByChar(n,e))}const y5=t=>O5(t,!mi(t)),v5=t=>O5(t,mi(t));function b5(t,e){return zr(t,e,n=>t.moveByGroup(n,e))}const ioe=t=>b5(t,!mi(t)),roe=t=>b5(t,mi(t)),soe=t=>{let e=!mi(t);return zr(t,e,n=>ly(t.state,n,e))},ooe=t=>{let e=mi(t);return zr(t,e,n=>ly(t.state,n,e))};function S5(t,e){return zr(t,e,n=>t.moveVertically(n,e))}const x5=t=>S5(t,!1),w5=t=>S5(t,!0);function k5(t,e){return zr(t,e,n=>t.moveVertically(n,e,g5(t).height))}const KR=t=>k5(t,!1),JR=t=>k5(t,!0),aoe=t=>zr(t,!0,e=>Va(t,e,!0)),loe=t=>zr(t,!1,e=>Va(t,e,!1)),coe=t=>{let e=!mi(t);return zr(t,e,n=>Va(t,n,e))},uoe=t=>{let e=mi(t);return zr(t,e,n=>Va(t,n,e))},doe=t=>zr(t,!1,e=>Oe.cursor(t.lineBlockAt(e.head).from)),foe=t=>zr(t,!0,e=>Oe.cursor(t.lineBlockAt(e.head).to)),eQ=({state:t,dispatch:e})=>(e(os(t,{anchor:0})),!0),tQ=({state:t,dispatch:e})=>(e(os(t,{anchor:t.doc.length})),!0),nQ=({state:t,dispatch:e})=>(e(os(t,{anchor:t.selection.main.anchor,head:0})),!0),iQ=({state:t,dispatch:e})=>(e(os(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),hoe=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),poe=({state:t,dispatch:e})=>{let n=cy(t).map(({from:i,to:r})=>Oe.undirectionalRange(i,Math.min(r+1,t.doc.length)));return e(t.update({selection:Oe.create(n),userEvent:"select"})),!0},goe=({state:t,dispatch:e})=>{let n=Fu(t.selection,i=>{let r=hn(t),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=i.to||l.to>i.to&&l.from<=i.from)&&o.next)return Oe.undirectionalRange(l.from,l.to)}return i});return n.eq(t.selection)?!1:(e(os(t,n)),!0)};function C5(t,e){let{state:n}=t,i=n.selection,r=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let u=t.moveVertically(l,e);if(u.heado.to){r.some(f=>f.head==u.head)||r.push(u);break}else{if(u.head==l.head)break;l=u}}}return r.length==i.ranges.length?!1:(t.dispatch(os(n,Oe.create(r,r.length-1))),!0)}const moe=t=>C5(t,!1),Ooe=t=>C5(t,!0),yoe=({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=Oe.create([n.main]):n.main.empty||(i=Oe.create([Oe.cursor(n.main.head)])),i?(e(os(t,i)),!0):!1};function Qh(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:i}=t,r=i.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let u=e(s);uo&&(n="delete.forward",u=jg(t,u,!0)),o=Math.min(o,u),l=Math.max(l,u)}else o=jg(t,o,!1),l=jg(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:Oe.cursor(o,or(t)))i.between(e,e,(r,s)=>{re&&(e=n?s:r)});return e}const _5=(t,e,n)=>Qh(t,i=>{let r=i.from,{state:s}=t,o=s.doc.lineAt(r),l,u;if(n&&!e&&r>o.from&&r_5(t,!1,!0),$5=t=>_5(t,!0,!1),T5=(t,e)=>Qh(t,n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let l=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let u=fi(s.text,i-s.from,e)+s.from,f=s.text.slice(Math.min(i,u)-s.from,Math.max(i,u)-s.from),h=o(f);if(l!=null&&h!=l)break;(f!=" "||i!=n.head)&&(l=h),i=u}return i}),E5=t=>T5(t,!1),voe=t=>T5(t,!0),boe=t=>Qh(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headQh(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),xoe=t=>Qh(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:Ot.of(["",""])},range:Oe.cursor(i.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},koe=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{if(!i.empty||i.from==0||i.from==t.doc.length)return{range:i};let r=i.from,s=t.doc.lineAt(r),o=r==s.from?r-1:fi(s.text,r-s.from,!1)+s.from,l=r==s.to?r+1:fi(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(r,l).append(t.doc.slice(o,r))},range:Oe.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function cy(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=t.doc.lineAt(i.to-1)),n>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function R5(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let s of cy(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let u of s.ranges)r.push(Oe.range(Math.min(t.doc.length,u.anchor+l),Math.min(t.doc.length,u.head+l)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let u of s.ranges)r.push(Oe.range(u.anchor-l,u.head-l))}}return i.length?(e(t.update({changes:i,scrollIntoView:!0,selection:Oe.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Coe=({state:t,dispatch:e})=>R5(t,e,!1),_oe=({state:t,dispatch:e})=>R5(t,e,!0);function Q5(t,e,n){if(t.readOnly)return!1;let i=[];for(let s of cy(t))n?i.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):i.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let r=t.changes(i);return e(t.update({changes:r,selection:t.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const $oe=({state:t,dispatch:e})=>Q5(t,e,!1),Toe=({state:t,dispatch:e})=>Q5(t,e,!0),Eoe=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(cy(e).map(({from:r,to:s})=>(r>0?r--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(r.head),l=t.coordsAtPos(r.head,r.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,s)}).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function Roe(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=hn(t).resolveInner(e),i=n.childBefore(e),r=n.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(He.closedBy))&&s.indexOf(r.name)>-1&&t.doc.lineAt(i.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const rQ=A5(!1),Qoe=A5(!0);function A5(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,l=e.doc.lineAt(s),u=!t&&s==o&&Roe(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let f=new ry(e,{simulateBreak:s,simulateDoubleBreak:!!u}),h=Hz(f,s);for(h==null&&(h=To(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let r=[];for(let o=i.from;o<=i.to;){let l=t.doc.lineAt(o);l.number>n&&(i.empty||i.to>l.from)&&(e(l,r,i),n=l.number),o=l.to+1}let s=t.changes(r);return{changes:r,range:Oe.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const Aoe=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new ry(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),r=rk(t,(s,o,l)=>{let u=Hz(i,s.from);if(u==null)return;/\S/.test(s.text)||(u=0);let f=/^\s*/.exec(s.text)[0],h=Um(t,u);(f!=h||l.fromt.readOnly?!1:(e(t.update(rk(t,(n,i)=>{i.push({from:n.from,insert:t.facet(Th)})}),{userEvent:"input.indent"})),!0),j5=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(rk(t,(n,i)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let s=To(r,t.tabSize),o=0,l=Um(t,Math.max(0,s-Bm(t)));for(;o(t.setTabFocusMode(),!0),joe=[{key:"Ctrl-b",run:c5,shift:y5,preventDefault:!0},{key:"Ctrl-f",run:u5,shift:v5},{key:"Ctrl-p",run:h5,shift:x5},{key:"Ctrl-n",run:p5,shift:w5},{key:"Ctrl-a",run:Jse,shift:doe},{key:"Ctrl-e",run:eoe,shift:foe},{key:"Ctrl-d",run:$5},{key:"Ctrl-h",run:Vx},{key:"Ctrl-k",run:boe},{key:"Ctrl-Alt-h",run:E5},{key:"Ctrl-o",run:woe},{key:"Ctrl-t",run:koe},{key:"Ctrl-v",run:Xx}],Moe=[{key:"ArrowLeft",run:c5,shift:y5,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Bse,shift:ioe,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Wse,shift:coe,preventDefault:!0},{key:"ArrowRight",run:u5,shift:v5,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Use,shift:roe,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Kse,shift:uoe,preventDefault:!0},{key:"ArrowUp",run:h5,shift:x5,preventDefault:!0},{mac:"Cmd-ArrowUp",run:eQ,shift:nQ},{mac:"Ctrl-ArrowUp",run:WR,shift:KR},{key:"ArrowDown",run:p5,shift:w5,preventDefault:!0},{mac:"Cmd-ArrowDown",run:tQ,shift:iQ},{mac:"Ctrl-ArrowDown",run:Xx,shift:JR},{key:"PageUp",run:WR,shift:KR},{key:"PageDown",run:Xx,shift:JR},{key:"Home",run:Hse,shift:loe,preventDefault:!0},{key:"Mod-Home",run:eQ,shift:nQ},{key:"End",run:Gse,shift:aoe,preventDefault:!0},{key:"Mod-End",run:tQ,shift:iQ},{key:"Enter",run:rQ,shift:rQ},{key:"Mod-a",run:hoe},{key:"Backspace",run:Vx,shift:Vx,preventDefault:!0},{key:"Delete",run:$5,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:E5,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:voe,preventDefault:!0},{mac:"Mod-Backspace",run:Soe,preventDefault:!0},{mac:"Mod-Delete",run:xoe,preventDefault:!0}].concat(joe.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Doe=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Yse,shift:soe},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Fse,shift:ooe},{key:"Alt-ArrowUp",run:Coe},{key:"Shift-Alt-ArrowUp",run:$oe},{key:"Alt-ArrowDown",run:_oe},{key:"Shift-Alt-ArrowDown",run:Toe},{key:"Mod-Alt-ArrowUp",run:moe},{key:"Mod-Alt-ArrowDown",run:Ooe},{key:"Escape",run:yoe},{key:"Mod-Enter",run:Qoe},{key:"Alt-l",mac:"Ctrl-l",run:poe},{key:"Mod-i",run:goe,preventDefault:!0},{key:"Mod-[",run:j5},{key:"Mod-]",run:P5},{key:"Mod-Alt-\\",run:Aoe},{key:"Shift-Mod-k",run:Eoe},{key:"Shift-Mod-\\",run:noe},{key:"Mod-/",run:Cse},{key:"Alt-A",mac:"Ctrl-A",run:$se},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Poe}].concat(Moe),Noe={key:"Tab",run:P5,shift:j5};class zoe{constructor(e,n,i,r){this.state=e,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=hn(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(Xoe(e));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function sQ(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Loe(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let s=1;stypeof r=="string"?{label:r}:r),[n,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:Loe(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:n}:null}}function Ioe(t,e){return n=>{for(let i=hn(n.state).resolveInner(n.pos,-1);i;i=i.parent){if(t.indexOf(i.name)>-1)return null;if(i.type.isTop)break}return e(n)}}function Xoe(t,e){var n;let{source:i}=t,r=i[i.length-1]!="$";return r?new RegExp(`(?:${i})${r?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":""):t}const Voe=ss.define(),Boe=Ze.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class Uoe{constructor(e,n,i,r){this.field=e,this.line=n,this.from=i,this.to=r}}class sk{constructor(e,n,i){this.field=e,this.from=n,this.to=i}map(e){let n=e.mapPos(this.from,-1,ki.TrackDel),i=e.mapPos(this.to,1,ki.TrackDel);return n==null||i==null?null:new sk(this.field,n,i)}}class ok{constructor(e,n){this.lines=e,this.fieldPositions=n}instantiate(e,n){let i=[],r=[n],s=e.doc.lineAt(n),o=/^\s*/.exec(s.text)[0];for(let u of this.lines){if(i.length){let f=o,h=/^\t*/.exec(u)[0].length;for(let p=0;pnew sk(u.field,r[u.line]+u.from,r[u.line]+u.to));return{text:i,ranges:l}}static parse(e){let n=[],i=[],r=[],s;for(let o of e.split(/\r\n?|\n/)){for(;s=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(o);){let l=s[1]?+s[1]:null,u=s[2]||s[3]||"",f=-1;l===0&&(l=1e9);let h=u.replace(/\\[{}]/g,p=>p[1]);for(let p=0;p=f&&O.field++}for(let p of r)if(p.line==i.length&&p.from>s.index){let O=s[2]?3+(s[1]||"").length:2;p.from-=O,p.to-=O}r.push(new Uoe(f,i.length,s.index,s.index+h.length)),o=o.slice(0,s.index)+u+o.slice(s.index+s[0].length)}o=o.replace(/\\([{}])/g,(l,u,f)=>{for(let h of r)h.line==i.length&&h.from>f&&(h.from--,h.to--);return u}),i.push(o)}return new ok(i,r)}}let qoe=Tt.widget({widget:new class extends qu{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),Yoe=Tt.mark({class:"cm-snippetField"});class Gu{constructor(e,n){this.ranges=e,this.active=n,this.deco=Tt.set(e.map(i=>(i.from==i.to?qoe:Yoe).range(i.from,i.to)),!0)}map(e){let n=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;n.push(r)}return new Gu(n,this.active)}selectionInsideField(e){return e.ranges.every(n=>this.ranges.some(i=>i.field==this.active&&i.from<=n.from&&i.to>=n.to))}}const Ah=Jt.define({map(t,e){return t&&t.map(e)}}),Foe=Jt.define(),Ff=Ao.define({create(){return null},update(t,e){for(let n of e.effects){if(n.is(Ah))return n.value;if(n.is(Foe)&&t)return new Gu(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>Ze.decorations.from(t,e=>e?e.deco:Tt.none)});function ak(t,e){return Oe.create(t.filter(n=>n.field==e).map(n=>Oe.range(n.from,n.to)))}function Goe(t){let e=ok.parse(t);return(n,i,r,s)=>{let{text:o,ranges:l}=e.instantiate(n.state,r),{main:u}=n.state.selection,f={changes:{from:r,to:s==u.from?u.to:s,insert:Ot.of(o)},scrollIntoView:!0,annotations:i?[Voe.of(i),Ci.userEvent.of("input.complete")]:void 0};if(l.length&&(f.selection=ak(l,0)),l.some(h=>h.field>0)){let h=new Gu(l,0),p=f.effects=[Ah.of(h)];n.state.field(Ff,!1)===void 0&&p.push(Jt.appendConfig.of([Ff,eae,tae,Boe]))}n.dispatch(n.state.update(f))}}function M5(t){return({state:e,dispatch:n})=>{let i=e.field(Ff,!1);if(!i||t<0&&i.active==0)return!1;let r=i.active+t,s=t>0&&!i.ranges.some(o=>o.field==r+t);return n(e.update({selection:ak(i.ranges,r),effects:Ah.of(s?null:new Gu(i.ranges,r)),scrollIntoView:!0})),!0}}const Hoe=({state:t,dispatch:e})=>t.field(Ff,!1)?(e(t.update({effects:Ah.of(null)})),!0):!1,Woe=M5(1),Koe=M5(-1),Joe=[{key:"Tab",run:Woe,shift:Koe},{key:"Escape",run:Hoe}],oQ=Ne.define({combine(t){return t.length?t[0]:Joe}}),eae=wh.highest(iy.compute([oQ],t=>t.facet(oQ)));function zi(t,e){return{...e,apply:Goe(t)}}const tae=Ze.domEventHandlers({mousedown(t,e){let n=e.state.field(Ff,!1),i;if(!n||(i=e.posAtCoords({x:t.clientX,y:t.clientY}))==null)return!1;let r=n.ranges.find(s=>s.from<=i&&s.to>=i);return!r||r.field==n.active?!1:(e.dispatch({selection:ak(n.ranges,r.field),effects:Ah.of(n.ranges.some(s=>s.field>r.field)?new Gu(n.ranges,r.field):null),scrollIntoView:!0}),!0)}}),D5=new class extends $a{};D5.startSide=1;D5.endSide=-1;class Ym{static create(e,n,i,r,s){let o=r+(r<<8)+e+(n<<4)|0;return new Ym(e,n,i,o,s,[],[])}constructor(e,n,i,r,s,o,l){this.type=e,this.value=n,this.from=i,this.hash=r,this.end=s,this.children=o,this.positions=l,this.hashProp=[[He.contextHash,r]]}addChild(e,n){e.prop(He.contextHash)!=this.hash&&(e=new wt(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(n)}toTree(e,n=this.end){let i=this.children.length-1;return i>=0&&(n=Math.max(n,this.positions[i]+this.children[i].length+this.from)),new wt(e.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(r,s,o)=>new wt(Dn.none,r,s,o,this.hashProp)})}}var we;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(we||(we={}));class nae{constructor(e,n){this.start=e,this.content=n,this.marks=[],this.parsers=[]}}class iae{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return kf(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,n=0,i=0){for(let r=n;r=e.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let i=(t.type==we.OrderedList?uk:ck)(n,e,!1);return i>0&&(t.type!=we.BulletList||lk(n,e,!1)<0)&&n.text.charCodeAt(n.pos+i-1)==t.value}const N5={[we.Blockquote](t,e,n){return n.next!=62?!1:(n.markers.push(gt(we.QuoteMark,e.lineStart+n.pos,e.lineStart+n.pos+1)),n.moveBase(n.pos+(Lr(n.text.charCodeAt(n.pos+1))?2:1)),t.end=e.lineStart+n.text.length,!0)},[we.ListItem](t,e,n){return n.indent-1?!1:(n.moveBaseColumn(n.baseIndent+t.value),!0)},[we.OrderedList]:aQ,[we.BulletList]:aQ,[we.Document](){return!0}};function Lr(t){return t==32||t==9||t==10||t==13}function kf(t,e=0){for(;en&&Lr(t.charCodeAt(e-1));)e--;return e}function z5(t){if(t.next!=96&&t.next!=126)return-1;let e=t.pos+1;for(;e-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(q5.SetextHeading)>-1||i<3?-1:1}function Z5(t,e){for(let n=t.stack.length-1;n>=0;n--)if(t.stack[n].type==e)return!0;return!1}function ck(t,e,n){return(t.next==45||t.next==43||t.next==42)&&(t.pos==t.text.length-1||Lr(t.text.charCodeAt(t.pos+1)))&&(!n||Z5(e,we.BulletList)||t.skipSpace(t.pos+2)=48&&r<=57;){i++;if(i==t.text.length)return-1;r=t.text.charCodeAt(i)}return i==t.pos||i>t.pos+9||r!=46&&r!=41||it.pos+1||t.next!=49)?-1:i+1-t.pos}function I5(t){if(t.next!=35)return-1;let e=t.pos+1;for(;e6?-1:n}function X5(t){if(t.next!=45&&t.next!=61||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e/,B5=/\?>/,Ux=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*/i.exec(i);if(s)return t.append(gt(we.Comment,n,n+1+s[0].length));let o=/^\?[^]*?\?>/.exec(i);if(o)return t.append(gt(we.ProcessingInstruction,n,n+1+o[0].length));let l=/^(?:![A-Z][^]*?>|!\[CDATA\[[^]*?\]\]>|\/\s*[a-zA-Z][\w-]*\s*>|\s*[a-zA-Z][\w-]*(\s+[a-zA-Z:_][\w-.:]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*(\/\s*)?>)/.exec(i);return l?t.append(gt(we.HTMLTag,n,n+1+l[0].length)):-1},Emphasis(t,e,n){if(e!=95&&e!=42)return-1;let i=n+1;for(;t.char(i)==e;)i++;let r=t.slice(n-1,n),s=t.slice(i,i+1),o=Hf.test(r),l=Hf.test(s),u=/\s|^$/.test(r),f=/\s|^$/.test(s),h=!f&&(!l||u||o),p=!u&&(!o||f||l),O=h&&(e==42||!p||o),y=p&&(e==42||!h||l);return t.append(new or(e==95?W5:K5,n,i,(O?1:0)|(y?2:0)))},HardBreak(t,e,n){if(e==92&&t.char(n+1)==10)return t.append(gt(we.HardBreak,n,n+2));if(e==32){let i=n+1;for(;t.char(i)==32;)i++;if(t.char(i)==10&&i>=n+2)return t.append(gt(we.HardBreak,n,i+1))}return-1},Link(t,e,n){return e==91?t.append(new or(Ol,n,n+1,1)):-1},Image(t,e,n){return e==33&&t.char(n+1)==91?t.append(new or(Fm,n,n+2,1)):-1},LinkEnd(t,e,n){if(e!=93)return-1;for(let i=t.parts.length-1;i>=0;i--){let r=t.parts[i];if(r instanceof or&&(r.type==Ol||r.type==Fm)){if(!r.side||t.skipSpace(r.to)==n&&!/[(\[]/.test(t.slice(n+1,n+2)))return t.parts[i]=null,-1;let s=t.takeContent(i),o=t.parts[i]=cae(t,s,r.type==Ol?we.Link:we.Image,r.from,n+1);if(r.type==Ol)for(let l=0;le?gt(we.URL,e+n,s+n):s==t.length?null:!1}}function eL(t,e,n){let i=t.charCodeAt(e);if(i!=39&&i!=34&&i!=40)return!1;let r=i==40?41:i;for(let s=e+1,o=!1;s=this.end?-1:this.text.charCodeAt(e-this.offset)}get end(){return this.offset+this.text.length}slice(e,n){return this.text.slice(e-this.offset,n-this.offset)}append(e){return this.parts.push(e),e.to}addDelimiter(e,n,i,r,s){return this.append(new or(e,n,i,(r?1:0)|(s?2:0)))}get hasOpenLink(){for(let e=this.parts.length-1;e>=0;e--){let n=this.parts[e];if(n instanceof or&&(n.type==Ol||n.type==Fm))return!0}return!1}addElement(e){return this.append(e)}resolveMarkers(e){for(let i=e;i=e;u--){let S=this.parts[u];if(S instanceof or&&S.side&1&&S.type==r.type&&!(s&&(r.side&1||S.side&2)&&(S.to-S.from+o)%3==0&&((S.to-S.from)%3||o%3))){l=S;break}}if(!l)continue;let f=r.type.resolve,h=[],p=l.from,O=r.to;if(s){let S=Math.min(2,l.to-l.from,o);p=l.to-S,O=r.from+S,f=S==1?"Emphasis":"StrongEmphasis"}l.type.mark&&h.push(this.elt(l.type.mark,p,l.to));for(let S=u+1;S=0;n--){let i=this.parts[n];if(i instanceof or&&i.type==e&&i.side&1)return n}return null}takeContent(e){let n=this.resolveMarkers(e);return this.parts.length=e,n}getDelimiterAt(e){let n=this.parts[e];return n instanceof or?n:null}skipSpace(e){return kf(this.text,e-this.offset)+this.offset}elt(e,n,i,r){return typeof e=="string"?gt(this.parser.getNodeType(e),n,i,r):new H5(e,n)}}dk.linkStart=Ol;dk.imageStart=Fm;function Yx(t,e){if(!e.length)return t;if(!t.length)return e;let n=t.slice(),i=0;for(let r of e){for(;i(e?e-1:0))return!1;if(this.fragmentEnd<0){let s=this.fragment.to;for(;s>0&&this.input.read(s-1,s)!=` +`;)s--;this.fragmentEnd=s?s-1:0}let i=this.cursor;i||(i=this.cursor=this.fragment.tree.cursor(),i.firstChild());let r=e+this.fragment.offset;for(;i.to<=r;)if(!i.parent())return!1;for(;;){if(i.from>=r)return this.fragment.from<=n;if(!i.childAfter(r))return!1}}matches(e){let n=this.cursor.tree;return n&&n.prop(He.contextHash)==e}takeNodes(e){let n=this.cursor,i=this.fragment.offset,r=this.fragmentEnd-(this.fragment.openEnd?1:0),s=e.absoluteLineStart,o=s,l=e.block.children.length,u=o,f=l;for(;;){if(n.to-i>r){if(n.type.isAnonymous&&n.firstChild())continue;break}let h=nL(n.from-i,e.ranges);if(n.to-i<=e.ranges[e.rangeI].to)e.addNode(n.tree,h);else{let p=new wt(e.parser.nodeSet.types[we.Paragraph],[],[],0,e.block.hashProp);e.reusePlaceholders.set(p,n.tree),e.addNode(p,h)}if(n.type.is("Block")&&(uae.indexOf(n.type.id)<0?(o=n.to-i,l=e.block.children.length):(o=u,l=f),u=n.to-i,f=e.block.children.length),!n.nextSibling())break}for(;e.block.children.length>l;)e.block.children.pop(),e.block.positions.pop();return o-s}};function nL(t,e){let n=t;for(let i=1;iMg[t]),Object.keys(Mg).map(t=>q5[t]),Object.keys(Mg),oae,N5,Object.keys(Zb).map(t=>Zb[t]),Object.keys(Zb),[]);function pae(t,e,n){let i=[];for(let r=t.firstChild,s=e;;r=r.nextSibling){let o=r?r.from:n;if(o>s&&i.push({from:s,to:o}),!r)break;s=r.to}return i}function gae(t){let{codeParser:e,htmlParser:n}=t;return{wrap:qz((r,s)=>{let o=r.type.id;if(e&&(o==we.CodeBlock||o==we.FencedCode)){let l="";if(o==we.FencedCode){let f=r.node.getChild(we.CodeInfo);f&&(l=s.read(f.from,f.to))}let u=e(l);if(u)return{parser:u,overlay:f=>f.type.id==we.CodeText,bracketed:o==we.FencedCode}}else if(n&&(o==we.HTMLBlock||o==we.HTMLTag||o==we.CommentBlock))return{parser:n,overlay:pae(r.node,r.from,r.to)};return null})}}const mae={resolve:"Strikethrough",mark:"StrikethroughMark"},Oae={defineNodes:[{name:"Strikethrough",style:{"Strikethrough/...":Z.strikethrough}},{name:"StrikethroughMark",style:Z.processingInstruction}],parseInline:[{name:"Strikethrough",parse(t,e,n){if(e!=126||t.char(n+1)!=126||t.char(n+2)==126)return-1;let i=t.slice(n-1,n),r=t.slice(n+2,n+3),s=/\s|^$/.test(i),o=/\s|^$/.test(r),l=Hf.test(i),u=Hf.test(r);return t.addDelimiter(mae,n,n+2,!o&&(!u||s||l),!s&&(!l||o||u))},after:"Emphasis"}]};function Cf(t,e,n=0,i,r=0){let s=0,o=!0,l=-1,u=-1,f=!1,h=()=>{i.push(t.elt("TableCell",r+l,r+u,t.parser.parseInline(e.slice(l,u),r+l)))};for(let p=n;p-1)&&s++,o=!1,i&&(l>-1&&h(),i.push(t.elt("TableDelimiter",p+r,p+r+1))),l=u=-1):(f||O!=32&&O!=9)&&(l<0&&(l=p),u=p+1),f=!f&&O==92}return l>-1&&(s++,i&&h()),s}function dQ(t,e){for(let n=e;n\s]*\|?(\s*:?-+:?\s*\|)+(\s*:?-+:?\s*)?$/;class fQ{constructor(){this.rows=null}nextLine(e,n,i){if(this.rows==null){this.rows=!1;let r;if((n.next==45||n.next==58||n.next==124)&&iL.test(r=n.text.slice(n.pos))){let s=[];Cf(e,i.content,0,s,i.start)==Cf(e,r,0)&&(this.rows=[e.elt("TableHeader",i.start,i.start+i.content.length,s),e.elt("TableDelimiter",e.lineStart+n.pos,e.lineStart+n.text.length)])}}else if(this.rows){let r=[];Cf(e,n.text,n.pos,r,e.lineStart),this.rows.push(e.elt("TableRow",e.lineStart+n.pos,e.lineStart+n.text.length,r))}return!1}finish(e,n){return this.rows?(e.addLeafElement(n,e.elt("Table",n.start,n.start+n.content.length,this.rows)),!0):!1}}const yae={defineNodes:[{name:"Table",block:!0},{name:"TableHeader",style:{"TableHeader/...":Z.heading}},"TableRow",{name:"TableCell",style:Z.content},{name:"TableDelimiter",style:Z.processingInstruction}],parseBlock:[{name:"Table",leaf(t,e){return dQ(e.content,0)?new fQ:null},endLeaf(t,e,n){if(n.parsers.some(r=>r instanceof fQ)||!dQ(e.text,e.basePos))return!1;let i=t.peekLine();return iL.test(i)&&Cf(t,e.text,e.basePos)==Cf(t,i,e.basePos)},before:"SetextHeading"}]};class vae{nextLine(){return!1}finish(e,n){return e.addLeafElement(n,e.elt("Task",n.start,n.start+n.content.length,[e.elt("TaskMarker",n.start,n.start+3),...e.parser.parseInline(n.content.slice(3),n.start+3)])),!0}}const bae={defineNodes:[{name:"Task",block:!0,style:Z.list},{name:"TaskMarker",style:Z.atom}],parseBlock:[{name:"TaskList",leaf(t,e){return/^\[[ xX]\][ \t]/.test(e.content)&&t.parentType().name=="ListItem"?new vae:null},after:"SetextHeading"}]},hQ=/(www\.)|(https?:\/\/)|([\w.+-]{1,100}@)|(mailto:|xmpp:)/gy,pQ=/[\w-]+(\.[\w-]+)+(:\d+)?(\/[^\s<]*)?/gy,Sae=/[\w-]+\.[\w-]+($|[/:])/,gQ=/[\w.+-]+@[\w-]+(\.[\w.-]+)+/gy,mQ=/\/[a-zA-Z\d@.]+/gy;function OQ(t,e,n,i){let r=0;for(let s=e;s-1)return-1;let i=e+n[0].length;for(;;){let r=t[i-1],s;if(/[?!.,:*_~]/.test(r)||r==")"&&OQ(t,e,i,")")>OQ(t,e,i,"("))i--;else if(r==";"&&(s=/&(?:#\d+|#x[a-f\d]+|\w+);$/.exec(t.slice(e,i))))i=e+s.index;else break}return i}function yQ(t,e){gQ.lastIndex=e;let n=gQ.exec(t);if(!n)return-1;let i=n[0][n[0].length-1];return i=="_"||i=="-"?-1:e+n[0].length-(i=="."?1:0)}const wae={parseInline:[{name:"Autolink",parse(t,e,n){let i=n-t.offset;if(i&&/\w/.test(t.text[i-1]))return-1;hQ.lastIndex=i;let r=hQ.exec(t.text),s=-1;if(!r)return-1;if(r[1]||r[2]){if(s=xae(t.text,i+r[0].length),s>-1&&t.hasOpenLink){let o=/([^\[\]]|\[[^\]]*\])*/.exec(t.text.slice(i,s));s=i+o[0].length}}else r[3]?s=yQ(t.text,i):(s=yQ(t.text,i+r[0].length),s>-1&&r[0]=="xmpp:"&&(mQ.lastIndex=s,r=mQ.exec(t.text),r&&(s=r.index+r[0].length)));return s<0?-1:(t.addElement(t.elt("URL",n,s+t.offset)),s+t.offset)}}]},kae=[yae,bae,Oae,wae];function rL(t,e,n){return(i,r,s)=>{if(r!=t||i.char(s+1)==t)return-1;let o=[i.elt(n,s,s+1)];for(let l=s+1;ln%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,i=0){let r=e.parser.context;return new Gm(e,[],n,i,i,0,[],0,r?new bQ(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(f==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizeu;)this.stack.pop();this.reduceContext(r,f)}storeNode(e,n,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==i)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,n,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let u=o;u>0&&this.buffer[u-2]>i;u-=4)if(this.buffer[u-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,n,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let l=o.stateFlag(s,1);!l&&(r>i||n<=o.maxNode)&&(this.reducePos=r),this.pushState(s,l?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=o.maxNode&&this.buffer.push(n,i,r,4)}else this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4)}apply(e,n,i,r){e&65536?this.reduce(e):this.shift(e,n,i,r)}useNode(e,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let i=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new Gm(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new Tae(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(i==0)return!1;if((i&65536)==0)return!0;n.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,o;su&1&&l==o)||r.push(n[s],o)}n=r}let i=[];for(let r=0;r>19,r=n&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let u=o&65535,f=this.stack.length-l*3;if(f>=0&&e.getGoto(this.stack[f],u,!1)>=0)return l<<19|65536|u}}else{let l=i(o,s+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class bQ{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class Tae{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class Hm{constructor(e,n,i){this.stack=e,this.pos=n,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Hm(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Hm(this.stack,this.pos,this.index)}}function mf(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let i=0,r=0;i=92&&o--,o>=34&&o--;let u=o-32;if(u>=46&&(u-=46,l=!0),s+=u,l)break;s*=46}n?n[r++]=s:n=new e(s)}return n}class nm{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const SQ=new nm;class Eae{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=SQ,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;si.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,i,r;if(n>=0&&n=this.chunk2Pos&&il.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=SQ,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return i}}class du{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:i}=n.p;sL(this.data,e,n,this.id,i.data,i.tokenPrecTable)}}du.prototype.contextual=du.prototype.fallback=du.prototype.extend=!1;class Wm{constructor(e,n,i){this.precTable=n,this.elseToken=i,this.data=typeof e=="string"?mf(e):e}token(e,n){let i=e.pos,r=0;for(;;){let s=e.next<0,o=e.resolveOffset(1,1);if(sL(this.data,e,n,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(s||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}}Wm.prototype.contextual=du.prototype.fallback=du.prototype.extend=!1;class hr{constructor(e,n={}){this.token=e,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function sL(t,e,n,i,r,s){let o=0,l=1<0){let v=t[y];if(u.allows(v)&&(e.token.value==-1||e.token.value==v||Rae(v,e.token.value,r,s))){e.acceptToken(v);break}}let h=e.next,p=0,O=t[o+2];if(e.next<0&&O>p&&t[f+O*3-3]==65535){o=t[f+O*3-1];continue e}for(;p>1,v=f+y+(y<<1),S=t[v],k=t[v+1]||65536;if(h=k)p=y+1;else{o=t[v+2],e.advance();continue e}}break}}function xQ(t,e,n){for(let i=e,r;(r=t[i])!=65535;i++)if(r==n)return i-e;return-1}function Rae(t,e,n,i){let r=xQ(n,i,e);return r<0||xQ(n,i,t)e)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:t.length}}class Qae{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?wQ(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?wQ(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof wt){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class Aae{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new nm)}getActions(e){let n=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,u=0;for(let f=0;fp.end+25&&(u=Math.max(p.lookAhead,u)),p.value!=0)){let O=n;if(p.extended>-1&&(n=this.addActions(e,p.extended,p.end,n)),n=this.addActions(e,p.value,p.end,n),!h.extend&&(i=p,n>O))break}}for(;this.actions.length>n;)this.actions.pop();return u&&e.setLookAhead(u),!i&&e.pos==this.stream.end&&(i=new nm,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,n=this.addActions(e,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new nm,{pos:i,p:r}=e;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,i,r){for(let s=0;se.bufferLength*4?new Qae(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;on)i.push(l);else{if(this.advanceStack(l,i,e))continue;{r||(r=[],s=[]),r.push(l);let u=this.tokens.getMainToken(l);s.push(u.value,u.end)}}break}}if(!i.length){let o=r&&Mae(r);if(o)return nr&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw nr&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return nr&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,u)=>u.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&f.buffer.length>500)if((l.score-f.score||l.buffer.length-f.buffer.length)>0)i.splice(u--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,l)=>l.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let f=e.curContext&&e.curContext.tracker.strict,h=f?e.curContext.hash:0;for(let p=this.fragments.nodeAt(r);p;){let O=this.parser.nodeSet.types[p.type.id]==p.type?s.getGoto(e.state,p.type.id):-1;if(O>-1&&p.length&&(!f||(p.prop(He.contextHash)||0)==h))return e.useNode(p,O),nr&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(p.type.id)})`),!0;if(!(p instanceof wt)||p.children.length==0||p.positions[0]>0)break;let y=p.children[0];if(y instanceof wt&&p.positions[0]==0)p=y;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),nr&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let f=0;fr?n.push(v):i.push(v)}return!1}advanceFully(e,n){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return kQ(e,n),!0}}runRecovery(e,n,i){let r=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),nr&&console.log(h+this.stackID(l)+" (restarted)"),this.advanceFully(l,i))))continue;let p=l.split(),O=h;for(let y=0;y<10&&p.forceReduce()&&(nr&&console.log(O+this.stackID(p)+" (via force-reduce)"),!this.advanceFully(p,i));y++)nr&&(O=this.stackID(p)+" -> ");for(let y of l.recoverByInsert(u))nr&&console.log(h+this.stackID(y)+" (via recover-insert)"),this.advanceFully(y,i);this.stream.end>l.pos?(f==l.pos&&(f++,u=0),l.recoverByDelete(u,f),nr&&console.log(h+this.stackID(l)+` (via recover-delete ${this.parser.getName(u)})`),kQ(l,i)):(!r||r.scoret;class oL{constructor(e){this.start=e.start,this.shift=e.shift||Xb,this.reduce=e.reduce||Xb,this.reuse=e.reuse||Xb,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class Qu extends K1{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let l=0;le.topRules[l][1]),r=[];for(let l=0;l=0)s(h,u,l[f++]);else{let p=l[f+-h];for(let O=-h;O>0;O--)s(l[f++],u,p);f++}}}this.nodeSet=new $h(n.map((l,u)=>Dn.define({name:u>=this.minRepeatTerm?void 0:l,id:u,props:r[u],top:i.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Iz;let o=mf(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new du(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,i){let r=new Pae(this,e,n,i);for(let s of this.wrappers)r=s(r,e,n,i);return r}getGoto(e,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let o=r[s++],l=o&1,u=r[s++];if(l&&i)return u;for(let f=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,i=>i==n?!0:null)}allActions(e,n){let i=this.stateSlot(e,4),r=i?n(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=mo(this.data,s+2);else break;r=n(mo(this.data,s+1))}return r}nextStates(e){let n=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=mo(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];n.some((s,o)=>o&1&&s==r)||n.push(this.data[i],r)}}return n}configure(e){let n=Object.assign(Object.create(Qu.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=i}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(l=>l.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=CQ(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;si)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,i)<<1|e}return t.get}const Dae=55,Nae=1,zae=56,Lae=2,Zae=57,Iae=3,_Q=4,Xae=5,fk=6,aL=7,lL=8,cL=9,uL=10,Vae=11,Bae=12,Uae=13,Vb=58,qae=14,Yae=15,$Q=59,dL=21,Fae=23,fL=24,Gae=25,Fx=27,hL=28,Hae=29,Wae=32,Kae=35,Jae=37,ele=38,tle=0,nle=1,ile={area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},rle={dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},TQ={dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}};function sle(t){return t==45||t==46||t==58||t>=65&&t<=90||t==95||t>=97&&t<=122||t>=161}let EQ=null,RQ=null,QQ=0;function Gx(t,e){let n=t.pos+e;if(QQ==n&&RQ==t)return EQ;let i=t.peek(e),r="";for(;sle(i);)r+=String.fromCharCode(i),i=t.peek(++e);return RQ=t,QQ=n,EQ=r?r.toLowerCase():i==ole||i==ale?void 0:null}const pL=60,Km=62,hk=47,ole=63,ale=33,lle=45;function AQ(t,e){this.name=t,this.parent=e}const cle=[fk,uL,aL,lL,cL],ule=new oL({start:null,shift(t,e,n,i){return cle.indexOf(e)>-1?new AQ(Gx(i,1)||"",t):t},reduce(t,e){return e==dL&&t?t.parent:t},reuse(t,e,n,i){let r=e.type.id;return r==fk||r==Jae?new AQ(Gx(i,1)||"",t):t},strict:!1}),dle=new hr((t,e)=>{if(t.next!=pL){t.next<0&&e.context&&t.acceptToken(Vb);return}t.advance();let n=t.next==hk;n&&t.advance();let i=Gx(t,0);if(i===void 0)return;if(!i)return t.acceptToken(n?Yae:qae);let r=e.context?e.context.name:null;if(n){if(i==r)return t.acceptToken(Vae);if(r&&rle[r])return t.acceptToken(Vb,-2);if(e.dialectEnabled(tle))return t.acceptToken(Bae);for(let s=e.context;s;s=s.parent)if(s.name==i)return;t.acceptToken(Uae)}else{if(i=="script")return t.acceptToken(aL);if(i=="style")return t.acceptToken(lL);if(i=="textarea")return t.acceptToken(cL);if(ile.hasOwnProperty(i))return t.acceptToken(uL);r&&TQ[r]&&TQ[r][i]?t.acceptToken(Vb,-1):t.acceptToken(fk)}},{contextual:!0}),fle=new hr(t=>{for(let e=0,n=0;;n++){if(t.next<0){n&&t.acceptToken($Q);break}if(t.next==lle)e++;else if(t.next==Km&&e>=2){n>=3&&t.acceptToken($Q,-2);break}else e=0;t.advance()}});function hle(t){for(;t;t=t.parent)if(t.name=="svg"||t.name=="math")return!0;return!1}const ple=new hr((t,e)=>{if(t.next==hk&&t.peek(1)==Km){let n=e.dialectEnabled(nle)||hle(e.context);t.acceptToken(n?Xae:_Q,2)}else t.next==Km&&t.acceptToken(_Q,1)});function pk(t,e,n){let i=2+t.length;return new hr(r=>{for(let s=0,o=0,l=0;;l++){if(r.next<0){l&&r.acceptToken(e);break}if(s==0&&r.next==pL||s==1&&r.next==hk||s>=2&&so?r.acceptToken(e,-o):r.acceptToken(n,-(o-2));break}else if((r.next==10||r.next==13)&&l){r.acceptToken(e,1);break}else s=o=0;r.advance()}})}const gle=pk("script",Dae,Nae),mle=pk("style",zae,Lae),Ole=pk("textarea",Zae,Iae),yle=Yu({"Text RawText IncompleteTag IncompleteCloseTag":Z.content,"StartTag StartCloseTag SelfClosingEndTag EndTag":Z.angleBracket,TagName:Z.tagName,"MismatchedCloseTag/TagName":[Z.tagName,Z.invalid],AttributeName:Z.attributeName,"AttributeValue UnquotedAttributeValue":Z.attributeValue,Is:Z.definitionOperator,"EntityReference CharacterReference":Z.character,Comment:Z.blockComment,ProcessingInst:Z.processingInstruction,DoctypeDecl:Z.documentMeta}),vle=Qu.deserialize({version:14,states:",xOVO!rOOO!ZQ#tO'#CrO!`Q#tO'#C{O!eQ#tO'#DOO!jQ#tO'#DRO!oQ#tO'#DTO!tOaO'#CqO#PObO'#CqO#[OdO'#CqO$kO!rO'#CqOOO`'#Cq'#CqO$rO$fO'#DUO$zQ#tO'#DWO%PQ#tO'#DXOOO`'#Dl'#DlOOO`'#DZ'#DZQVO!rOOO%UQ&rO,59^O%aQ&rO,59gO%lQ&rO,59jO%wQ&rO,59mO&SQ&rO,59oOOOa'#D_'#D_O&_OaO'#CyO&jOaO,59]OOOb'#D`'#D`O&rObO'#C|O&}ObO,59]OOOd'#Da'#DaO'VOdO'#DPO'bOdO,59]OOO`'#Db'#DbO'jO!rO,59]O'qQ#tO'#DSOOO`,59],59]OOOp'#Dc'#DcO'vO$fO,59pOOO`,59p,59pO(OQ#|O,59rO(TQ#|O,59sOOO`-E7X-E7XO(YQ&rO'#CtOOQW'#D['#D[O(hQ&rO1G.xOOOa1G.x1G.xOOO`1G/Z1G/ZO(sQ&rO1G/ROOOb1G/R1G/RO)OQ&rO1G/UOOOd1G/U1G/UO)ZQ&rO1G/XOOO`1G/X1G/XO)fQ&rO1G/ZOOOa-E7]-E7]O)qQ#tO'#CzOOO`1G.w1G.wOOOb-E7^-E7^O)vQ#tO'#C}OOOd-E7_-E7_O){Q#tO'#DQOOO`-E7`-E7`O*QQ#|O,59nOOOp-E7a-E7aOOO`1G/[1G/[OOO`1G/^1G/^OOO`1G/_1G/_O*VQ,UO,59`OOQW-E7Y-E7YOOOa7+$d7+$dOOO`7+$u7+$uOOOb7+$m7+$mOOOd7+$p7+$pOOO`7+$s7+$sO*bQ#|O,59fO*gQ#|O,59iO*lQ#|O,59lOOO`1G/Y1G/YO*qO7[O'#CwO+SOMhO'#CwOOQW1G.z1G.zOOO`1G/Q1G/QOOO`1G/T1G/TOOO`1G/W1G/WOOOO'#D]'#D]O+eO7[O,59cOOQW,59c,59cOOOO'#D^'#D^O+vOMhO,59cOOOO-E7Z-E7ZOOQW1G.}1G.}OOOO-E7[-E7[",stateData:",c~O!_OS~OUSOVPOWQOXROYTO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O|_O!eZO~OgaO~OgbO~OgcO~OgdO~OgeO~O!XfOPmP![mP~O!YiOQpP![pP~O!ZlORsP![sP~OUSOVPOWQOXROYTOZqO[]O][O^^O_^Oa^Ob^Oc^Od^Oy^O!eZO~O![rO~P#gO!]sO!fuO~OgvO~OgwO~OS|OT}OiyO~OS!POT}OiyO~OS!ROT}OiyO~OS!TOT}OiyO~OS}OT}OiyO~O!XfOPmX![mX~OP!WO![!XO~O!YiOQpX![pX~OQ!ZO![!XO~O!ZlORsX![sX~OR!]O![!XO~O![!XO~P#gOg!_O~O!]sO!f!aO~OS!bO~OS!cO~Oj!dOShXThXihX~OS!fOT!gOiyO~OS!hOT!gOiyO~OS!iOT!gOiyO~OS!jOT!gOiyO~OS!gOT!gOiyO~Og!kO~Og!lO~Og!mO~OS!nO~Ol!qO!a!oO!c!pO~OS!rO~OS!sO~OS!tO~Ob!uOc!uOd!uO!a!wO!b!uO~Ob!xOc!xOd!xO!c!wO!d!xO~Ob!uOc!uOd!uO!a!{O!b!uO~Ob!xOc!xOd!xO!c!{O!d!xO~OT~cbd!ey|!e~",goto:"%q!aPPPPPPPPPPPPPPPPPPPPP!b!hP!nPP!zP!}#Q#T#Z#^#a#g#j#m#s#y!bP!b!bP$P$V$m$s$y%P%V%]%cPPPPPPPP%iX^OX`pXUOX`pezabcde{!O!Q!S!UR!q!dRhUR!XhXVOX`pRkVR!XkXWOX`pRnWR!XnXXOX`pQrXR!XpXYOX`pQ`ORx`Q{aQ!ObQ!QcQ!SdQ!UeZ!e{!O!Q!S!UQ!v!oR!z!vQ!y!pR!|!yQgUR!VgQjVR!YjQmWR![mQpXR!^pQtZR!`tS_O`ToXp",nodeNames:"⚠ StartCloseTag StartCloseTag StartCloseTag EndTag SelfClosingEndTag StartTag StartTag StartTag StartTag StartTag StartCloseTag StartCloseTag StartCloseTag IncompleteTag IncompleteCloseTag Document Text EntityReference CharacterReference InvalidEntity Element OpenTag TagName Attribute AttributeName Is AttributeValue UnquotedAttributeValue ScriptText CloseTag OpenTag StyleText CloseTag OpenTag TextareaText CloseTag OpenTag CloseTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag CloseTag DoctypeDecl",maxTerm:68,context:ule,nodeProps:[["closedBy",-10,1,2,3,7,8,9,10,11,12,13,"EndTag",6,"EndTag SelfClosingEndTag",-4,22,31,34,37,"CloseTag"],["openedBy",4,"StartTag StartCloseTag",5,"StartTag",-4,30,33,36,38,"OpenTag"],["group",-10,14,15,18,19,20,21,40,41,42,43,"Entity",17,"Entity TextContent",-3,29,32,35,"TextContent Entity"],["isolate",-11,22,30,31,33,34,36,37,38,39,42,43,"ltr",-3,27,28,40,""]],propSources:[yle],skippedNodes:[0],repeatNodeCount:9,tokenData:"!]tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^/^!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!Z5zblWOX5uXZ7SZ[5u[^7S^p5uqr5urs7Sst+Ptw5uwx7Sx!]5u!]!^7w!^!a7S!a#S5u#S#T7S#T;'S5u;'S;=`8n<%lO5u!R7VVOp7Sqs7St!]7S!]!^7l!^;'S7S;'S;=`7q<%lO7S!R7qOb!R!R7tP;=`<%l7S!Z8OYlWb!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!Z8qP;=`<%l5u!_8{iiSlWOX5uXZ7SZ[5u[^7S^p5uqr8trs7Sst/^tw8twx7Sx!P8t!P!Q5u!Q!]8t!]!^:j!^!a7S!a#S8t#S#T;{#T#s8t#s$f5u$f;'S8t;'S;=`>V<%l?Ah8t?Ah?BY5u?BY?Mn8t?MnO5u!_:sbiSlWb!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VP<%l?Ah;{?Ah?BY7S?BY?Mn;{?MnO7S!V=dXiSb!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!V>SP;=`<%l;{!_>YP;=`<%l8t!_>dhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^/^!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!Z@TalWOX@OXZAYZ[@O[^AY^p@Oqr@OrsAYsw@OwxAYx!]@O!]!^Az!^!aAY!a#S@O#S#TAY#T;'S@O;'S;=`Bq<%lO@O!RA]UOpAYq!]AY!]!^Ao!^;'SAY;'S;=`At<%lOAY!RAtOc!R!RAwP;=`<%lAY!ZBRYlWc!ROX+PZ[+P^p+Pqr+Psw+Px!^+P!a#S+P#T;'S+P;'S;=`+t<%lO+P!ZBtP;=`<%l@O!_COhiSlWOX@OXZAYZ[@O[^AY^p@OqrBwrsAYswBwwxAYx!PBw!P!Q@O!Q!]Bw!]!^Dj!^!aAY!a#SBw#S#TE{#T#sBw#s$f@O$f;'SBw;'S;=`HS<%l?AhBw?Ah?BY@O?BY?MnBw?MnO@O!_DsbiSlWc!ROX+PZ[+P^p+Pqr/^sw/^x!P/^!P!Q+P!Q!^/^!a#S/^#S#T0m#T#s/^#s$f+P$f;'S/^;'S;=`1e<%l?Ah/^?Ah?BY+P?BY?Mn/^?MnO+P!VFQbiSOpAYqrE{rsAYswE{wxAYx!PE{!P!QAY!Q!]E{!]!^GY!^!aAY!a#sE{#s$fAY$f;'SE{;'S;=`G|<%l?AhE{?Ah?BYAY?BY?MnE{?MnOAY!VGaXiSc!Rqr0msw0mx!P0m!Q!^0m!a#s0m$f;'S0m;'S;=`1_<%l?Ah0m?BY?Mn0m!VHPP;=`<%lE{!_HVP;=`<%lBw!ZHcW!cxaP!b`Or(trs'ksv(tw!^(t!^!_)e!_;'S(t;'S;=`*P<%lO(t!aIYliSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OKQ!O!P-_!P!Q$q!Q!^-_!^!_*V!_!a&X!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!aK_kiSaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx!P-_!P!Q$q!Q!^-_!^!_*V!_!`&X!`!aMS!a#S-_#S#T1k#T#s-_#s$f$q$f;'S-_;'S;=`3X<%l?Ah-_?Ah?BY$q?BY?Mn-_?MnO$q!TM_XaP!b`!dp!fQOr&Xrs&}sv&Xwx(tx!^&X!^!_*V!_;'S&X;'S;=`*y<%lO&X!aNZ!ZiSgQaPlW!b`!dpOX$qXZ&XZ[$q[^&X^p$qpq&Xqr-_rs&}sv-_vw/^wx(tx}-_}!OMz!O!PMz!P!Q$q!Q![Mz![!]Mz!]!^-_!^!_*V!_!a&X!a!c-_!c!}Mz!}#R-_#R#SMz#S#T1k#T#oMz#o#s-_#s$f$q$f$}-_$}%OMz%O%W-_%W%oMz%o%p-_%p&aMz&a&b-_&b1pMz1p4UMz4U4dMz4d4e-_4e$ISMz$IS$I`-_$I`$IbMz$Ib$Je-_$Je$JgMz$Jg$Kh-_$Kh%#tMz%#t&/x-_&/x&EtMz&Et&FV-_&FV;'SMz;'S;:j!#|;:j;=`3X<%l?&r-_?&r?AhMz?Ah?BY$q?BY?MnMz?MnO$q!a!$PP;=`<%lMz!R!$ZY!b`!dpOq*Vqr!$yrs(Vsv*Vwx)ex!a*V!a!b!4t!b;'S*V;'S;=`*s<%lO*V!R!%Q]!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!%y!O!f*V!f!g!']!g#W*V#W#X!0`#X;'S*V;'S;=`*s<%lO*V!R!&QX!b`!dpOr*Vrs(Vsv*Vwx)ex}*V}!O!&m!O;'S*V;'S;=`*s<%lO*V!R!&vV!b`!dp!ePOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!'dX!b`!dpOr*Vrs(Vsv*Vwx)ex!q*V!q!r!(P!r;'S*V;'S;=`*s<%lO*V!R!(WX!b`!dpOr*Vrs(Vsv*Vwx)ex!e*V!e!f!(s!f;'S*V;'S;=`*s<%lO*V!R!(zX!b`!dpOr*Vrs(Vsv*Vwx)ex!v*V!v!w!)g!w;'S*V;'S;=`*s<%lO*V!R!)nX!b`!dpOr*Vrs(Vsv*Vwx)ex!{*V!{!|!*Z!|;'S*V;'S;=`*s<%lO*V!R!*bX!b`!dpOr*Vrs(Vsv*Vwx)ex!r*V!r!s!*}!s;'S*V;'S;=`*s<%lO*V!R!+UX!b`!dpOr*Vrs(Vsv*Vwx)ex!g*V!g!h!+q!h;'S*V;'S;=`*s<%lO*V!R!+xY!b`!dpOr!+qrs!,hsv!+qvw!-Swx!.[x!`!+q!`!a!/j!a;'S!+q;'S;=`!0Y<%lO!+qq!,mV!dpOv!,hvx!-Sx!`!,h!`!a!-q!a;'S!,h;'S;=`!.U<%lO!,hP!-VTO!`!-S!`!a!-f!a;'S!-S;'S;=`!-k<%lO!-SP!-kO|PP!-nP;=`<%l!-Sq!-xS!dp|POv(Vx;'S(V;'S;=`(h<%lO(Vq!.XP;=`<%l!,ha!.aX!b`Or!.[rs!-Ssv!.[vw!-Sw!`!.[!`!a!.|!a;'S!.[;'S;=`!/d<%lO!.[a!/TT!b`|POr)esv)ew;'S)e;'S;=`)y<%lO)ea!/gP;=`<%l!.[!R!/sV!b`!dp|POr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!0]P;=`<%l!+q!R!0gX!b`!dpOr*Vrs(Vsv*Vwx)ex#c*V#c#d!1S#d;'S*V;'S;=`*s<%lO*V!R!1ZX!b`!dpOr*Vrs(Vsv*Vwx)ex#V*V#V#W!1v#W;'S*V;'S;=`*s<%lO*V!R!1}X!b`!dpOr*Vrs(Vsv*Vwx)ex#h*V#h#i!2j#i;'S*V;'S;=`*s<%lO*V!R!2qX!b`!dpOr*Vrs(Vsv*Vwx)ex#m*V#m#n!3^#n;'S*V;'S;=`*s<%lO*V!R!3eX!b`!dpOr*Vrs(Vsv*Vwx)ex#d*V#d#e!4Q#e;'S*V;'S;=`*s<%lO*V!R!4XX!b`!dpOr*Vrs(Vsv*Vwx)ex#X*V#X#Y!+q#Y;'S*V;'S;=`*s<%lO*V!R!4{Y!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!a!4t!a!b!:]!b;'S!4t;'S;=`!;r<%lO!4tq!5pV!dpOv!5kvx!6Vx!a!5k!a!b!7W!b;'S!5k;'S;=`!8V<%lO!5kP!6YTO!a!6V!a!b!6i!b;'S!6V;'S;=`!7Q<%lO!6VP!6lTO!`!6V!`!a!6{!a;'S!6V;'S;=`!7Q<%lO!6VP!7QOyPP!7TP;=`<%l!6Vq!7]V!dpOv!5kvx!6Vx!`!5k!`!a!7r!a;'S!5k;'S;=`!8V<%lO!5kq!7yS!dpyPOv(Vx;'S(V;'S;=`(h<%lO(Vq!8YP;=`<%l!5ka!8bX!b`Or!8]rs!6Vsv!8]vw!6Vw!a!8]!a!b!8}!b;'S!8];'S;=`!:V<%lO!8]a!9SX!b`Or!8]rs!6Vsv!8]vw!6Vw!`!8]!`!a!9o!a;'S!8];'S;=`!:V<%lO!8]a!9vT!b`yPOr)esv)ew;'S)e;'S;=`)y<%lO)ea!:YP;=`<%l!8]!R!:dY!b`!dpOr!4trs!5ksv!4tvw!6Vwx!8]x!`!4t!`!a!;S!a;'S!4t;'S;=`!;r<%lO!4t!R!;]V!b`!dpyPOr*Vrs(Vsv*Vwx)ex;'S*V;'S;=`*s<%lO*V!R!;uP;=`<%l!4t!V!{let f=l.type.id;if(f==Hae)return Bb(l,u,n);if(f==Wae)return Bb(l,u,i);if(f==Kae)return Bb(l,u,r);if(f==dL&&s.length){let h=l.node,p=h.firstChild,O=p&&PQ(p,u),y;if(O){for(let v of s)if(v.tag==O&&(!v.attrs||v.attrs(y||(y=gL(p,u))))){let S=h.lastChild,k=S.type.id==ele?S.from:h.to;if(k>p.to)return{parser:v.parser,overlay:[{from:p.to,to:k}]}}}}if(o&&f==fL){let h=l.node,p;if(p=h.firstChild){let O=o[u.read(p.from,p.to)];if(O)for(let y of O){if(y.tagName&&y.tagName!=PQ(h.parent,u))continue;let v=h.lastChild;if(v.type.id==Fx){let S=v.from+1,k=v.lastChild,C=v.to-(k&&k.isError?0:1);if(C>S)return{parser:y.parser,overlay:[{from:S,to:C}],bracketed:!0}}else if(v.type.id==hL)return{parser:y.parser,overlay:[{from:v.from,to:v.to}]}}}}return null})}const ble=148,jQ=1,Sle=149,xle=150,OL=2,wle=151,kle=3,Cle=4,yL=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],_le=58,$le=40,vL=95,Tle=91,im=45,Ele=46,Rle=35,Qle=37,Ale=38,Ple=92,jle=10,Mle=42;function Wf(t){return t>=65&&t<=90||t>=97&&t<=122||t>=161}function gk(t){return t>=48&&t<=57}function MQ(t){return gk(t)||t>=97&&t<=102||t>=65&&t<=70}const bL=(t,e,n)=>(i,r)=>{for(let s=!1,o=0,l=0;;l++){let{next:u}=i;if(Wf(u)||u==im||u==vL||s&&gk(u))!s&&(u!=im||l>0)&&(s=!0),o===l&&u==im&&o++,i.advance();else if(u==Ple&&i.peek(1)!=jle){if(i.advance(),MQ(i.next)){do i.advance();while(MQ(i.next));i.next==32&&i.advance()}else i.next>-1&&i.advance();s=!0}else{s&&i.acceptToken(o==2&&r.canShift(OL)?e:u==$le?n:t);break}}},Dle=new hr(bL(Sle,OL,xle),{contextual:!0}),Nle=new hr(bL(wle,kle,Cle),{contextual:!0}),zle=new hr(t=>{if(yL.includes(t.peek(-1))){let{next:e}=t;(Wf(e)||e==vL||e==Rle||e==Ele||e==Mle||e==Tle||e==_le&&Wf(t.peek(1))||e==im||e==Ale)&&t.acceptToken(ble)}}),Lle=new hr(t=>{if(!yL.includes(t.peek(-1))){let{next:e}=t;if(e==Qle&&(t.advance(),t.acceptToken(jQ)),Wf(e)){do t.advance();while(Wf(t.next)||gk(t.next));t.acceptToken(jQ)}}}),Zle=Yu({"AtKeyword import charset namespace keyframes media supports font-feature-values":Z.definitionKeyword,"from to selector scope MatchFlag":Z.keyword,NamespaceName:Z.namespace,KeyframeName:Z.labelName,KeyframeRangeName:Z.operatorKeyword,TagName:Z.tagName,ClassName:Z.className,PseudoClassName:Z.constant(Z.className),IdName:Z.labelName,"FeatureName PropertyName":Z.propertyName,AttributeName:Z.attributeName,NumberLiteral:Z.number,KeywordQuery:Z.keyword,UnaryQueryOp:Z.operatorKeyword,"CallTag ValueName FontName":Z.atom,VariableName:Z.variableName,Callee:Z.operatorKeyword,Unit:Z.unit,"UniversalSelector NestingSelector":Z.definitionOperator,"MatchOp CompareOp":Z.compareOperator,"ChildOp SiblingOp, LogicOp":Z.logicOperator,BinOp:Z.arithmeticOperator,Important:Z.modifier,Comment:Z.blockComment,ColorLiteral:Z.color,"ParenthesizedContent StringLiteral":Z.string,":":Z.punctuation,"PseudoOp #":Z.derefOperator,"; , |":Z.separator,"( )":Z.paren,"[ ]":Z.squareBracket,"{ }":Z.brace}),Ile={__proto__:null,lang:44,"nth-child":44,"nth-last-child":44,"nth-of-type":44,"nth-last-of-type":44,dir:44,"host-context":44,if:90,url:158,"url-prefix":158,domain:158,regexp:158},Xle={__proto__:null,or:104,and:104,not:112,only:112,layer:212},Vle={__proto__:null,selector:118,style:124,layer:208},Ble={__proto__:null,"@import":204,"@media":216,"@charset":220,"@namespace":224,"@keyframes":230,"@supports":242,"@scope":246,"@font-feature-values":252},Ule={__proto__:null,to:249},qle=Qu.deserialize({version:14,states:"MrQYQdOOO#}QdOOP$UO`OOO%OQaO'#CfOOQP'#Ce'#CeO%VQdO'#CgO%[Q`O'#CgO%aQaO'#FqO&XQdO'#CkO&xQaO'#CcO'SQdO'#CnO'_QdO'#ERO'dQdO'#ETO'oQdO'#E[O'oQdO'#E_OOQP'#Fq'#FqO)RQhO'#FQOOQS'#Fp'#FpOOQS'#FT'#FTQYQdOOO)YQdO'#EeO*iQhO'#EkO)YQdO'#EmO*pQdO'#EoO*{QdO'#ErO)}QhO'#ExO+TQdO'#EzO+`QdO'#E}O+eQaO'#CfO+lQ`O'#EbO+qQ`O'#F}O+|QdO'#F}QOQ`OOP,WO&jO'#CaPOOO)CA`)CA`OOQP'#Ci'#CiOOQP,59R,59RO%VQdO,59ROOQP'#Cm'#CmOOQP,59V,59VO&XQdO,59VO,cQdO,59YO'_QdO,5:mO'dQdO,5:oO'oQdO,5:vO'oQdO,5:xO'oQdO,5:yO'oQdO'#F[O,nQ`O,58}O,vQdO'#EaOOQS,58},58}OOQP'#Cq'#CqOOQO'#EP'#EPOOQP,59Y,59YO,}Q`O,59YO-SQ`O,59YOOQP'#ES'#ESOOQP,5:m,5:mO-XQpO'#EUO-dQdO'#EVO-iQ`O'#EVO-nQpO,5:oO.XQaO,5:vO.oQaO,5:yOOQW'#D^'#D^O/nQhO'#DgO0RQhO,5;lO)}QhO'#DeO0`Q`O'#DnO0eQhO'#D{OOQW'#Fw'#FwOOQS,5;l,5;lO0jQ`O'#DhO0oQ`O'#DkOOQS-E9R-E9ROOQ['#Cv'#CvO0tQdO'#CwO1[QdO'#C}O1rQdO'#DQO2YQ!pO'#DSO4fQ!jO,5;POOQO'#DX'#DXO-SQ`O'#DWO4vQ!nO'#FtO6|Q`O'#DYO7RQ`O'#D|OOQ['#Ft'#FtO7WQhO'#GQO7fQ`O,5;VO7kQ!bO,5;XOOQS'#Eq'#EqO7sQ`O,5;ZO7xQdO,5;ZOOQO'#Et'#EtO8QQ`O,5;^O8VQhO,5;dO'oQdO'#DjOOQS,5;f,5;fO0jQ`O,5;fO8_QdO,5;fOOQS'#Fc'#FcO8gQdO'#FPO7fQ`O,5;iO8oQdO,5:|O9PQdO'#F^O9^Q`O,5lQhO'#DoOOQW,5:Y,5:YOOQW,5:g,5:gOOQW,5:S,5:SO>vQhO,5:VO?bQ!fO'#FuOOQS'#Fu'#FuOOQS'#FV'#FVO@rQdO,59cOOQ[,59c,59cOAYQdO,59iOOQ[,59i,59iOApQdO,59lOOQ[,59l,59lOOQ[,59n,59nO)YQdO,59pOBWQhO'#EgOOQW'#Eg'#EgOBuQ`O1G0kO4oQhO1G0kOOQ[,59r,59rO)}QhO'#D[OOQ[,59t,59tOBzQ#tO,5:hOCVQhO'#F`OCdQ`O,5vQhO'#DmOI_QhO'#DsOIgQhO'#DuOIlQ!jO'#FzOOQO'#Fz'#FzOIwQ`O'#DxOJPQ!bO'#DzOOQO'#Fy'#FyOJUQ`O1G/qOOQS-E9T-E9TOOQ[1G.}1G.}OOQ[1G/T1G/TOOQ[1G/W1G/WOOQ[1G/[1G/[OJZQdO,5;ROOQS7+&V7+&VOJ`Q`O7+&VOJeQhO'#D]OJmQ`O,59vO)}QhO,59vOOQ[1G0S1G0SOJuQ`O1G0SOJzQhO,5;zOOQO-E9^-E9^OOQS7+&a7+&aOKYQbO'#DSOOQO'#Ew'#EwOKhQ`O'#EvOOQO'#Ev'#EvOKsQ`O'#FaOK{QdO,5;aOOQS,5;a,5;aOOQ[1G/p1G/pOOQS7+&l7+&lO7fQ`O7+&lOLWQ!fO'#F]O)YQdO'#F]OM_QdO7+&SOOQO7+&S7+&SOOQO,5;O,5;OOOQO1G1d1G1dOMrQ!bO<vQhO'#DtOOQO,5:_,5:_O! sQhO,5:aO! {QhO,5:fO)YQdO,5:dOOQW7+%]7+%]OOQO'#Ei'#EiO!!SQ`O1G0mOOQS<{AN>{O!$^Q`OAN>{O!$cQaO,5;uOOQO-E9X-E9XO!$mQdO,5;tOOQO-E9W-E9WOOQW<vQhO'#DwOOQO1G/{1G/{O!&aQ!bO1G0QO!&iQdO1G0OOJZQdO'#F_O!&pQ`O7+&XOOQW7+&X7+&XO!&xQ!bO1G/cOOQ[7+$|7+$|O!'TQhO7+$|P!'[Q`O'#FWOOQO,5;|,5;|OOQO-E9`-E9`OOQS1G1g1G1gOOQPG24gG24gO!'aQ`OAN>ZO)YQdO1G1_O!'fQ`O7+'mOOQO1G/z1G/zO!'nQ`O,5:cO!'sQhO7+%lOOQO,5;y,5;yOOQO-E9]-E9]OOQW<Q!]!^>|!^!_?_!_!`@Z!`!a@n!a!b%Z!b!cAo!c!k%Z!k!lC|!l!u%Z!u!vC|!v!}%Z!}#OD_#O#P%Z#P#QDp#Q#R2X#R#]%Z#]#^ER#^#g%Z#g#hC|#h#o%Z#o#pIf#p#qIw#q#rJ`#r#sJq#s#y%Z#y#z&R#z$f%Z$f$g&R$g#BY%Z#BY#BZ&R#BZ$IS%Z$IS$I_&R$I_$I|%Z$I|$JO&R$JO$JT%Z$JT$JU&R$JU$KV%Z$KV$KW&R$KW&FU%Z&FU&FV&R&FV;'S%Z;'S;=`KY<%lO%Z`%^SOy%jz;'S%j;'S;=`%{<%lO%j`%oS!r`Oy%jz;'S%j;'S;=`%{<%lO%j`&OP;=`<%l%j~&Wh$_~OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%j~'yh$_~!r`OX%jX^'r^p%jpq'rqy%jz#y%j#y#z'r#z$f%j$f$g'r$g#BY%j#BY#BZ'r#BZ$IS%j$IS$I_'r$I_$I|%j$I|$JO'r$JO$JT%j$JT$JU'r$JU$KV%j$KV$KW'r$KW&FU%j&FU&FV'r&FV;'S%j;'S;=`%{<%lO%jj)jS$sYOy%jz;'S%j;'S;=`%{<%lO%j~)yWOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d<%lO)v~*hOw~~*kRO;'S)v;'S;=`*t;=`O)v~*wXOY)vZr)vrs*cs#O)v#O#P*h#P;'S)v;'S;=`+d;=`<%l)v<%lO)v~+gP;=`<%l)vj+oYmYOy%jz!Q%j!Q![,_![!c%j!c!i,_!i#T%j#T#Z,_#Z;'S%j;'S;=`%{<%lO%jj,dY!r`Oy%jz!Q%j!Q![-S![!c%j!c!i-S!i#T%j#T#Z-S#Z;'S%j;'S;=`%{<%lO%jj-XY!r`Oy%jz!Q%j!Q![-w![!c%j!c!i-w!i#T%j#T#Z-w#Z;'S%j;'S;=`%{<%lO%jj.OYuY!r`Oy%jz!Q%j!Q![.n![!c%j!c!i.n!i#T%j#T#Z.n#Z;'S%j;'S;=`%{<%lO%jj.uYuY!r`Oy%jz!Q%j!Q![/e![!c%j!c!i/e!i#T%j#T#Z/e#Z;'S%j;'S;=`%{<%lO%jj/jY!r`Oy%jz!Q%j!Q![0Y![!c%j!c!i0Y!i#T%j#T#Z0Y#Z;'S%j;'S;=`%{<%lO%jj0aYuY!r`Oy%jz!Q%j!Q![1P![!c%j!c!i1P!i#T%j#T#Z1P#Z;'S%j;'S;=`%{<%lO%jj1UY!r`Oy%jz!Q%j!Q![1t![!c%j!c!i1t!i#T%j#T#Z1t#Z;'S%j;'S;=`%{<%lO%jj1{SuY!r`Oy%jz;'S%j;'S;=`%{<%lO%jd2[UOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jd2uS!|S!r`Oy%jz;'S%j;'S;=`%{<%lO%jb3WS^QOy%jz;'S%j;'S;=`%{<%lO%j~3gWOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{<%lO3d~4SRO;'S3d;'S;=`4];=`O3d~4`XOY3dZw3dwx*cx#O3d#O#P4P#P;'S3d;'S;=`4{;=`<%l3d<%lO3d~5OP;=`<%l3dj5WShYOy%jz;'S%j;'S;=`%{<%lO%j~5iOg~n5pUWQyWOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jj6ZWyW#SQOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj6xU!r`Oy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%jj7cY!r`$jYOy%jz!Q%j!Q![7[![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj8WY!r`Oy%jz{%j{|8v|}%j}!O8v!O!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj8{U!r`Oy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj9fU!r`$jYOy%jz!Q%j!Q![9_![;'S%j;'S;=`%{<%lO%jj:P[!r`$jYOy%jz!O%j!O!P7[!P!Q%j!Q![9x![!g%j!g!h8R!h#X%j#X#Y8R#Y;'S%j;'S;=`%{<%lO%jj:zS!eYOy%jz;'S%j;'S;=`%{<%lO%jj;]WyWOy%jz!O%j!O!P6s!P!Q%j!Q![9x![;'S%j;'S;=`%{<%lO%jj;zU`YOy%jz!Q%j!Q![7[![;'S%j;'S;=`%{<%lO%j~VUcYOy%jz![%j![!]>i!];'S%j;'S;=`%{<%lO%jj>pSdY!r`Oy%jz;'S%j;'S;=`%{<%lO%jj?RSnYOy%jz;'S%j;'S;=`%{<%lO%jh?dU!WWOy%jz!_%j!_!`?v!`;'S%j;'S;=`%{<%lO%jh?}S!WW!r`Oy%jz;'S%j;'S;=`%{<%lO%jl@bS!WW!|SOy%jz;'S%j;'S;=`%{<%lO%jj@uV#PQ!WWOy%jz!_%j!_!`?v!`!aA[!a;'S%j;'S;=`%{<%lO%jbAcS#PQ!r`Oy%jz;'S%j;'S;=`%{<%lO%jjArYOy%jz}%j}!OBb!O!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjBgW!r`Oy%jz!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jjCW[lY!r`Oy%jz}%j}!OCP!O!Q%j!Q![CP![!c%j!c!}CP!}#T%j#T#oCP#o;'S%j;'S;=`%{<%lO%jhDRS!}WOy%jz;'S%j;'S;=`%{<%lO%jjDdSpYOy%jz;'S%j;'S;=`%{<%lO%jnDuSo^Oy%jz;'S%j;'S;=`%{<%lO%jjEWU!}WOy%jz#a%j#a#bEj#b;'S%j;'S;=`%{<%lO%jbEoU!r`Oy%jz#d%j#d#eFR#e;'S%j;'S;=`%{<%lO%jbFWU!r`Oy%jz#c%j#c#dFj#d;'S%j;'S;=`%{<%lO%jbFoU!r`Oy%jz#f%j#f#gGR#g;'S%j;'S;=`%{<%lO%jbGWU!r`Oy%jz#h%j#h#iGj#i;'S%j;'S;=`%{<%lO%jbGoU!r`Oy%jz#T%j#T#UHR#U;'S%j;'S;=`%{<%lO%jbHWU!r`Oy%jz#b%j#b#cHj#c;'S%j;'S;=`%{<%lO%jbHoU!r`Oy%jz#h%j#h#iIR#i;'S%j;'S;=`%{<%lO%jbIYS$rQ!r`Oy%jz;'S%j;'S;=`%{<%lO%jjIkSsYOy%jz;'S%j;'S;=`%{<%lO%jfI|U$fUOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%jjJeSrYOy%jz;'S%j;'S;=`%{<%lO%jfJvU#SQOy%jz!_%j!_!`2n!`;'S%j;'S;=`%{<%lO%j`K]P;=`<%l%Z",tokenizers:[zle,Lle,Dle,Nle,1,2,3,4,new Wm("m~RRYZ[z{a~~g~aO$b~~dP!P!Qg~lO$c~~",28,155)],topRules:{StyleSheet:[0,6],Styles:[1,129]},dynamicPrecedences:{97:1},specialized:[{term:150,get:t=>Ile[t]||-1},{term:151,get:t=>Xle[t]||-1},{term:4,get:t=>Vle[t]||-1},{term:28,get:t=>Ble[t]||-1},{term:149,get:t=>Ule[t]||-1}],tokenPrec:2444});let Ub=null;function qb(){if(!Ub&&typeof document=="object"&&document.body){let{style:t}=document.body,e=[],n=new Set;for(let i in t)i!="cssText"&&i!="cssFloat"&&typeof t[i]=="string"&&(/[A-Z]/.test(i)&&(i=i.replace(/[A-Z]/g,r=>"-"+r.toLowerCase())),n.has(i)||(e.push(i),n.add(i)));Ub=e.sort().map(i=>({type:"property",label:i,apply:i+": "}))}return Ub||[]}const DQ=["active","after","any-link","autofill","backdrop","before","checked","cue","default","defined","disabled","empty","enabled","file-selector-button","first","first-child","first-letter","first-line","first-of-type","focus","focus-visible","focus-within","fullscreen","has","host","host-context","hover","in-range","indeterminate","invalid","is","lang","last-child","last-of-type","left","link","marker","modal","not","nth-child","nth-last-child","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","part","placeholder","placeholder-shown","read-only","read-write","required","right","root","scope","selection","slotted","target","target-text","valid","visited","where"].map(t=>({type:"class",label:t})),NQ=["above","absolute","activeborder","additive","activecaption","after-white-space","ahead","alias","all","all-scroll","alphabetic","alternate","always","antialiased","appworkspace","asterisks","attr","auto","auto-flow","avoid","avoid-column","avoid-page","avoid-region","axis-pan","background","backwards","baseline","below","bidi-override","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","bullets","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","calc","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-decimal","clear","clip","close-quote","col-resize","collapse","color","color-burn","color-dodge","column","column-reverse","compact","condensed","contain","content","contents","content-box","context-menu","continuous","copy","counter","counters","cover","crop","cross","crosshair","currentcolor","cursive","cyclic","darken","dashed","decimal","decimal-leading-zero","default","default-button","dense","destination-atop","destination-in","destination-out","destination-over","difference","disc","discard","disclosure-closed","disclosure-open","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic-abegede-gez","ethiopic-halehame-aa-er","ethiopic-halehame-gez","ew-resize","exclusion","expanded","extends","extra-condensed","extra-expanded","fantasy","fast","fill","fill-box","fixed","flat","flex","flex-end","flex-start","footnotes","forwards","from","geometricPrecision","graytext","grid","groove","hand","hard-light","help","hidden","hide","higher","highlight","highlighttext","horizontal","hsl","hsla","hue","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-flex","inline-grid","inline-table","inset","inside","intrinsic","invert","italic","justify","keep-all","landscape","large","larger","left","level","lighter","lighten","line-through","linear","linear-gradient","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-hexadecimal","lower-latin","lower-norwegian","lowercase","ltr","luminosity","manipulation","match","matrix","matrix3d","medium","menu","menutext","message-box","middle","min-intrinsic","mix","monospace","move","multiple","multiple_mask_images","multiply","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","numbers","numeric","nw-resize","nwse-resize","oblique","opacity","open-quote","optimizeLegibility","optimizeSpeed","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","perspective","pinch-zoom","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radial-gradient","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeating-linear-gradient","repeating-radial-gradient","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","rotate","rotate3d","rotateX","rotateY","rotateZ","round","row","row-resize","row-reverse","rtl","run-in","running","s-resize","sans-serif","saturation","scale","scale3d","scaleX","scaleY","scaleZ","screen","scroll","scrollbar","scroll-position","se-resize","self-start","self-end","semi-condensed","semi-expanded","separate","serif","show","single","skew","skewX","skewY","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","soft-light","solid","source-atop","source-in","source-out","source-over","space","space-around","space-between","space-evenly","spell-out","square","start","static","status-bar","stretch","stroke","stroke-box","sub","subpixel-antialiased","svg_masks","super","sw-resize","symbolic","symbols","system-ui","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","text","text-bottom","text-top","textarea","textfield","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","to","top","transform","translate","translate3d","translateX","translateY","translateZ","transparent","ultra-condensed","ultra-expanded","underline","unidirectional-pan","unset","up","upper-latin","uppercase","url","var","vertical","vertical-text","view-box","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","words","wrap","wrap-reverse","x-large","x-small","xor","xx-large","xx-small"].map(t=>({type:"keyword",label:t})).concat(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"].map(t=>({type:"constant",label:t}))),Yle=["a","abbr","address","article","aside","b","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","dd","del","details","dfn","dialog","div","dl","dt","em","figcaption","figure","footer","form","header","hgroup","h1","h2","h3","h4","h5","h6","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","main","meter","nav","ol","output","p","pre","ruby","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","tr","u","ul"].map(t=>({type:"type",label:t})),Fle=["@charset","@color-profile","@container","@counter-style","@font-face","@font-feature-values","@font-palette-values","@import","@keyframes","@layer","@media","@namespace","@page","@position-try","@property","@scope","@starting-style","@supports","@view-transition"].map(t=>({type:"keyword",label:t})),po=/^(\w[\w-]*|-\w[\w-]*|)$/,Gle=/^-(-[\w-]*)?$/;function Hle(t,e){var n;if((t.name=="("||t.type.isError)&&(t=t.parent||t),t.name!="ArgList")return!1;let i=(n=t.parent)===null||n===void 0?void 0:n.firstChild;return i?.name!="Callee"?!1:e.sliceString(i.from,i.to)=="var"}const zQ=new Uz,Wle=["Declaration"];function Kle(t){for(let e=t;;){if(e.type.isTop)return e;if(!(e=e.parent))return t}}function SL(t,e,n){if(e.to-e.from>4096){let i=zQ.get(e);if(i)return i;let r=[],s=new Set,o=e.cursor($t.IncludeAnonymous);if(o.firstChild())do for(let l of SL(t,o.node,n))s.has(l.label)||(s.add(l.label),r.push(l));while(o.nextSibling());return zQ.set(e,r),r}else{let i=[],r=new Set;return e.cursor().iterate(s=>{var o;if(n(s)&&s.matchContext(Wle)&&((o=s.node.nextSibling)===null||o===void 0?void 0:o.name)==":"){let l=t.sliceString(s.from,s.to);r.has(l)||(r.add(l),i.push({label:l,type:"variable"}))}}),i}}const Jle=t=>e=>{let{state:n,pos:i}=e,r=hn(n).resolveInner(i,-1),s=r.type.isError&&r.from==r.to-1&&n.doc.sliceString(r.from,r.to)=="-";if(r.name=="PropertyName"||(s||r.name=="TagName")&&/^(Block|Styles)$/.test(r.resolve(r.to).name))return{from:r.from,options:qb(),validFor:po};if(r.name=="ValueName")return{from:r.from,options:NQ,validFor:po};if(r.name=="PseudoClassName")return{from:r.from,options:DQ,validFor:po};if(t(r)||(e.explicit||s)&&Hle(r,n.doc))return{from:t(r)||s?r.from:i,options:SL(n.doc,Kle(r),t),validFor:Gle};if(r.name=="TagName"){for(let{parent:u}=r;u;u=u.parent)if(u.name=="Block")return{from:r.from,options:qb(),validFor:po};return{from:r.from,options:Yle,validFor:po}}if(r.name=="AtKeyword")return{from:r.from,options:Fle,validFor:po};if(!e.explicit)return null;let o=r.resolve(i),l=o.childBefore(i);return l&&l.name==":"&&o.name=="PseudoClassSelector"?{from:i,options:DQ,validFor:po}:l&&l.name==":"&&o.name=="Declaration"||o.name=="ArgList"?{from:i,options:NQ,validFor:po}:o.name=="Block"||o.name=="Styles"?{from:i,options:qb(),validFor:po}:null},ece=Jle(t=>t.name=="VariableName"),Jm=$u.define({name:"css",parser:qle.configure({props:[Eh.add({Declaration:tm()}),Rh.add({"Block KeyframeList":Jz})]}),languageData:{commentTokens:{block:{open:"/*",close:"*/"}},indentOnInput:/^\s*\}$/,wordChars:"-"}});function tce(){return new Yf(Jm,Jm.data.of({autocomplete:ece}))}const nce=316,ice=317,LQ=1,rce=2,sce=3,oce=4,ace=318,lce=320,cce=321,uce=5,dce=6,fce=0,Hx=[9,10,11,12,13,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],xL=125,hce=59,Wx=47,pce=42,gce=43,mce=45,Oce=60,yce=44,vce=63,bce=46,Sce=91,xce=new oL({start:!1,shift(t,e){return e==uce||e==dce||e==lce?t:e==cce},strict:!1}),wce=new hr((t,e)=>{let{next:n}=t;(n==xL||n==-1||e.context)&&t.acceptToken(ace)},{contextual:!0,fallback:!0}),kce=new hr((t,e)=>{let{next:n}=t,i;Hx.indexOf(n)>-1||n==Wx&&((i=t.peek(1))==Wx||i==pce)||n!=xL&&n!=hce&&n!=-1&&!e.context&&t.acceptToken(nce)},{contextual:!0}),Cce=new hr((t,e)=>{t.next==Sce&&!e.context&&t.acceptToken(ice)},{contextual:!0}),_ce=new hr((t,e)=>{let{next:n}=t;if(n==gce||n==mce){if(t.advance(),n==t.next){t.advance();let i=!e.context&&e.canShift(LQ);t.acceptToken(i?LQ:rce)}}else n==vce&&t.peek(1)==bce&&(t.advance(),t.advance(),(t.next<48||t.next>57)&&t.acceptToken(sce))},{contextual:!0});function Yb(t,e){return t>=65&&t<=90||t>=97&&t<=122||t==95||t>=192||!e&&t>=48&&t<=57}const $ce=new hr((t,e)=>{if(t.next!=Oce||!e.dialectEnabled(fce)||(t.advance(),t.next==Wx))return;let n=0;for(;Hx.indexOf(t.next)>-1;)t.advance(),n++;if(Yb(t.next,!0)){for(t.advance(),n++;Yb(t.next,!1);)t.advance(),n++;for(;Hx.indexOf(t.next)>-1;)t.advance(),n++;if(t.next==yce)return;for(let i=0;;i++){if(i==7){if(!Yb(t.next,!0))return;break}if(t.next!="extends".charCodeAt(i))break;t.advance(),n++}}t.acceptToken(oce,-n)}),Tce=Yu({"get set async static":Z.modifier,"for while do if else switch try catch finally return throw break continue default case defer":Z.controlKeyword,"in of await yield void typeof delete instanceof as satisfies":Z.operatorKeyword,"let var const using function class extends":Z.definitionKeyword,"import export from":Z.moduleKeyword,"with debugger new":Z.keyword,TemplateString:Z.special(Z.string),super:Z.atom,BooleanLiteral:Z.bool,this:Z.self,null:Z.null,Star:Z.modifier,VariableName:Z.variableName,"CallExpression/VariableName TaggedTemplateExpression/VariableName":Z.function(Z.variableName),VariableDefinition:Z.definition(Z.variableName),Label:Z.labelName,PropertyName:Z.propertyName,PrivatePropertyName:Z.special(Z.propertyName),"CallExpression/MemberExpression/PropertyName":Z.function(Z.propertyName),"FunctionDeclaration/VariableDefinition":Z.function(Z.definition(Z.variableName)),"ClassDeclaration/VariableDefinition":Z.definition(Z.className),"NewExpression/VariableName":Z.className,PropertyDefinition:Z.definition(Z.propertyName),PrivatePropertyDefinition:Z.definition(Z.special(Z.propertyName)),UpdateOp:Z.updateOperator,"LineComment Hashbang":Z.lineComment,BlockComment:Z.blockComment,Number:Z.number,String:Z.string,Escape:Z.escape,ArithOp:Z.arithmeticOperator,LogicOp:Z.logicOperator,BitOp:Z.bitwiseOperator,CompareOp:Z.compareOperator,RegExp:Z.regexp,Equals:Z.definitionOperator,Arrow:Z.function(Z.punctuation),": Spread":Z.punctuation,"( )":Z.paren,"[ ]":Z.squareBracket,"{ }":Z.brace,"InterpolationStart InterpolationEnd":Z.special(Z.brace),".":Z.derefOperator,", ;":Z.separator,"@":Z.meta,TypeName:Z.typeName,TypeDefinition:Z.definition(Z.typeName),"type enum interface implements namespace module declare":Z.definitionKeyword,"abstract global Privacy readonly override":Z.modifier,"is keyof unique infer asserts":Z.operatorKeyword,JSXAttributeValue:Z.attributeValue,JSXText:Z.content,"JSXStartTag JSXStartCloseTag JSXSelfCloseEndTag JSXEndTag":Z.angleBracket,"JSXIdentifier JSXNameSpacedName":Z.tagName,"JSXAttribute/JSXIdentifier JSXAttribute/JSXNameSpacedName":Z.attributeName,"JSXBuiltin/JSXIdentifier":Z.standard(Z.tagName)}),Ece={__proto__:null,export:20,as:25,from:33,default:36,async:41,function:42,in:52,out:55,const:56,extends:60,this:64,true:72,false:72,null:84,void:88,typeof:92,super:108,new:142,delete:154,yield:163,await:167,class:172,public:235,private:235,protected:235,readonly:237,instanceof:256,satisfies:259,import:292,keyof:349,unique:353,infer:359,asserts:395,is:397,abstract:417,implements:419,type:421,let:424,var:426,using:429,interface:435,enum:439,namespace:445,module:447,declare:451,global:455,defer:471,for:476,of:485,while:488,with:492,do:496,if:500,else:502,switch:506,case:512,try:518,catch:522,finally:526,return:530,throw:534,break:538,continue:542,debugger:546},Rce={__proto__:null,async:129,get:131,set:133,declare:195,public:197,private:197,protected:197,static:199,abstract:201,override:203,readonly:209,accessor:211,new:401},Qce={__proto__:null,"<":193},Ace=Qu.deserialize({version:14,states:"$F|Q%TQlOOO%[QlOOO'_QpOOP(lO`OOO*zQ!0MxO'#CiO+RO#tO'#CjO+aO&jO'#CjO+oO#@ItO'#DaO.QQlO'#DgO.bQlO'#DrO%[QlO'#DzO0fQlO'#ESOOQ!0Lf'#E['#E[O1PQ`O'#EXOOQO'#Ep'#EpOOQO'#Il'#IlO1XQ`O'#GsO1dQ`O'#EoO1iQ`O'#EoO3hQ!0MxO'#JrO6[Q!0MxO'#JsO6uQ`O'#F]O6zQ,UO'#FtOOQ!0Lf'#Ff'#FfO7VO7dO'#FfO9XQMhO'#F|O9`Q`O'#F{OOQ!0Lf'#Js'#JsOOQ!0Lb'#Jr'#JrO9eQ`O'#GwOOQ['#K_'#K_O9pQ`O'#IYO9uQ!0LrO'#IZOOQ['#J`'#J`OOQ['#I_'#I_Q`QlOOQ`QlOOO9}Q!L^O'#DvO:UQlO'#EOO:]QlO'#EQO9kQ`O'#GsO:dQMhO'#CoO:rQ`O'#EnO:}Q`O'#EyO;hQMhO'#FeO;xQ`O'#GsOOQO'#K`'#K`O;}Q`O'#K`O<]Q`O'#G{O<]Q`O'#G|O<]Q`O'#HOO9kQ`O'#HRO=SQ`O'#HUO>kQ`O'#CeO>{Q`O'#HcO?TQ`O'#HiO?TQ`O'#HkO`QlO'#HmO?TQ`O'#HoO?TQ`O'#HrO?YQ`O'#HxO?_Q!0LsO'#IOO%[QlO'#IQO?jQ!0LsO'#ISO?uQ!0LsO'#IUO9uQ!0LrO'#IWO@QQ!0MxO'#CiOASQpO'#DlQOQ`OOO%[QlO'#EQOAjQ`O'#ETO:dQMhO'#EnOAuQ`O'#EnOBQQ!bO'#FeOOQ['#Cg'#CgOOQ!0Lb'#Dq'#DqOOQ!0Lb'#Jv'#JvO%[QlO'#JvOOQO'#Jy'#JyOOQO'#Ih'#IhOCQQpO'#EgOOQ!0Lb'#Ef'#EfOOQ!0Lb'#J}'#J}OC|Q!0MSO'#EgODWQpO'#EWOOQO'#Jx'#JxODlQpO'#JyOEyQpO'#EWODWQpO'#EgPFWO&2DjO'#CbPOOO)CD})CD}OOOO'#I`'#I`OFcO#tO,59UOOQ!0Lh,59U,59UOOOO'#Ia'#IaOFqO&jO,59UOGPQ!L^O'#DcOOOO'#Ic'#IcOGWO#@ItO,59{OOQ!0Lf,59{,59{OGfQlO'#IdOGyQ`O'#JtOIxQ!fO'#JtO+}QlO'#JtOJPQ`O,5:ROJgQ`O'#EpOJtQ`O'#KTOKPQ`O'#KSOKPQ`O'#KSOKXQ`O,5;^OK^Q`O'#KROOQ!0Ln,5:^,5:^OKeQlO,5:^OMcQ!0MxO,5:fONSQ`O,5:nONmQ!0LrO'#KQONtQ`O'#KPO9eQ`O'#KPO! YQ`O'#KPO! bQ`O,5;]O! gQ`O'#KPO!#lQ!fO'#JsOOQ!0Lh'#Ci'#CiO%[QlO'#ESO!$[Q!fO,5:sOOQS'#Jz'#JzOOQO-EtOOQ['#Jh'#JhOOQ[,5>u,5>uOOQ[-E<]-E<]O!TO`QlO,5>VO!LOQ`O,5>XO`QlO,5>ZO!LTQ`O,5>^O!LYQlO,5>dOOQ[,5>j,5>jO%[QlO,5>jO9uQ!0LrO,5>lOOQ[,5>n,5>nO#!dQ`O,5>nOOQ[,5>p,5>pO#!dQ`O,5>pOOQ[,5>r,5>rO##QQpO'#D_O%[QlO'#JvO##sQpO'#JvO##}QpO'#DmO#$`QpO'#DmO#&qQlO'#DmO#&xQ`O'#JuO#'QQ`O,5:WO#'VQ`O'#EtO#'eQ`O'#KUO#'mQ`O,5;_O#'rQpO'#DmO#(PQpO'#EVOOQ!0Lf,5:o,5:oO%[QlO,5:oO#(WQ`O,5:oO?YQ`O,5;YO!CUQpO,5;YO!C^QMhO,5;YO:dQMhO,5;YO#(`Q`O,5@bO#(eQ07dO,5:sOOQO-EPO$6^Q`O,5>POOQ[1G3i1G3iO`QlO1G3iOOQ[1G3o1G3oOOQ[1G3q1G3qO?TQ`O1G3sO$6cQlO1G3uO$:gQlO'#HtOOQ[1G3x1G3xO$:tQ`O'#HzO?YQ`O'#H|OOQ[1G4O1G4OO$:|QlO1G4OO9uQ!0LrO1G4UOOQ[1G4W1G4WOOQ!0Lb'#G_'#G_O9uQ!0LrO1G4YO9uQ!0LrO1G4[O$?TQ`O,5@bO!)[QlO,5;`O9eQ`O,5;`O?YQ`O,5:XO!)[QlO,5:XO!CUQpO,5:XO$?YQ?MtO,5:XOOQO,5;`,5;`O$?dQpO'#IeO$?zQ`O,5@aOOQ!0Lf1G/r1G/rO$@SQpO'#IkO$@^Q`O,5@pOOQ!0Lb1G0y1G0yO#$`QpO,5:XOOQO'#Ig'#IgO$@fQpO,5:qOOQ!0Ln,5:q,5:qO#(ZQ`O1G0ZOOQ!0Lf1G0Z1G0ZO%[QlO1G0ZOOQ!0Lf1G0t1G0tO?YQ`O1G0tO!CUQpO1G0tO!C^QMhO1G0tOOQ!0Lb1G5|1G5|O!ByQ!0LrO1G0^OOQO1G0m1G0mO%[QlO1G0mO$@mQ!0LrO1G0mO$@xQ!0LrO1G0mO!CUQpO1G0^ODWQpO1G0^O$AWQ!0LrO1G0mOOQO1G0^1G0^O$AlQ!0MxO1G0mPOOO-E<[-E<[POOO1G.h1G.hOOOO1G/i1G/iO$AvQ!bO,5QQpO,5@}OOQ!0Lb1G3c1G3cOOQ[7+$V7+$VO@zQ`O7+$VO9uQ!0LrO7+$VO%>]Q`O7+$VO%[QlO1G6lO%[QlO1G6mO%>bQ!0LrO1G6lO%>lQlO1G3kO%>sQ`O1G3kO%>xQlO1G3kOOQ[7+)T7+)TO9uQ!0LrO7+)_O`QlO7+)aOOQ['#Kh'#KhOOQ['#JS'#JSO%?PQlO,5>`OOQ[,5>`,5>`O%[QlO'#HuO%?^Q`O'#HwOOQ[,5>f,5>fO9eQ`O,5>fOOQ[,5>h,5>hOOQ[7+)j7+)jOOQ[7+)p7+)pOOQ[7+)t7+)tOOQ[7+)v7+)vO%?cQpO1G5|O%?}Q?MtO1G0zO%@XQ`O1G0zOOQO1G/s1G/sO%@dQ?MtO1G/sO?YQ`O1G/sO!)[QlO'#DmOOQO,5?P,5?POOQO-ERQ`O7+,WO&>WQ`O7+,XO%[QlO7+,WO%[QlO7+,XOOQ[7+)V7+)VO&>]Q`O7+)VO&>bQlO7+)VO&>iQ`O7+)VOOQ[<nQ`O,5>aOOQ[,5>c,5>cO&>sQ`O1G4QO9eQ`O7+&fO!)[QlO7+&fOOQO7+%_7+%_O&>xQ?MtO1G6ZO?YQ`O7+%_OOQ!0Lf<yQ?MvO,5?aO'@|Q?MvO,5?cO'CPQ?MvO7+'|O'DuQMjOG27TOOQO<VO!l$xO#jROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]$_Oa$qa'z$qa'w$qa!k$qa!Y$qa!_$qa%i$qa!g$qa~Ol)dO~P!&zOh%VOp%WOr%XOs$tOt$tOz%YO|%ZO!O%]O!S${O!_$|O!i%bO!l$xO#j%cO$W%`O$t%^O$v%_O$y%aO(T(vO(VTO(YUO(a$uO(y$}O(z%PO~Og(pP~P!,TO!Q)iO!g)hO!_$^X$Z$^X$]$^X$_$^X$f$^X~O!g)hO!_({X$Z({X$]({X$_({X$f({X~O!Q)iO~P!.^O!Q)iO!_({X$Z({X$]({X$_({X$f({X~O!_)kO$Z)oO$])jO$_)jO$f)pO~O![)sO~P!)[O$]$hO$_$gO$f)wO~On$zX!Q$zX#S$zX'y$zX(y$zX(z$zX~OgmXg$zXnmX!]mX#`mX~P!0SOx)yO(b)zO(c)|O~On*VO!Q*OO'y*PO(y$}O(z%PO~Og)}O~P!1WOg*WO~Oh%VOr%XOs$tOt$tOz%YO|%ZO!OVO!l$xO#jVO!l$xO#jROe!iOpkOrPO(VTO(YUO(aVO(o[O~O(T=QO~P#$qO!]-]O!^(iX~O!^-_O~O!g-VO#`-UO!]#hX!^#hX~O!]-`O!^(xX~O!^-bO~O!c-cO!d-cO(U!lO~P#$`O!^-fO~P'_On-iO!_'`O~O!Y-nO~Os!{a!b!{a!c!{a!d!{a#T!{a#U!{a#V!{a#W!{a#X!{a#[!{a#]!{a(U!{a(V!{a(Y!{a(e!{a(o!{a~P!#vO!p-sO#`-qO~PChO!c-uO!d-uO(U!lO~PDWOa%nO#`-qO'z%nO~Oa%nO!g#vO#`-qO'z%nO~Oa%nO!g#vO!p-sO#`-qO'z%nO(r'pO~O(P'xO(Q'xO(R-zO~Ov-{O~O!Y'Wa!]'Wa~P!:tO![.PO!Y'WX!]'WX~P%[O!](VO!Y(ha~O!Y(ha~PHRO!](^O!Y(va~O!S%hO![.TO!_%iO(T%gO!Y'^X!]'^X~O#`.VO!](ta!k(taa(ta'z(ta~O!g#vO~P#,wO!](jO!k(sa~O!S%hO!_%iO#j.ZO(T%gO~Op.`O!S%hO![.]O!_%iO!|]O#i._O#j.]O(T%gO!]'aX!k'aX~OR.dO!l#xO~Oh%VOn.gO!_'`O%i.fO~Oa#ci!]#ci'z#ci'w#ci!Y#ci!k#civ#ci!_#ci%i#ci!g#ci~P!:tOn>]O!Q*OO'y*PO(y$}O(z%PO~O#k#_aa#_a#`#_a'z#_a!]#_a!k#_a!_#_a!Y#_a~P#/sO#k(`XP(`XR(`X[(`Xa(`Xj(`Xr(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X'z(`X(a(`X(r(`X!k(`X!Y(`X'w(`Xv(`X!_(`X%i(`X!g(`X~P!6kO!].tO!k(kX~P!:tO!k.wO~O!Y.yO~OP$[OR#zO!Q#yO!S#{O!l#xO!p$[O(aVO[#mia#mij#mir#mi!]#mi#R#mi#o#mi#p#mi#q#mi#r#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#n#mi~P#3cO#n$OO~P#3cOP$[OR#zOr$aO!Q#yO!S#{O!l#xO!p$[O#n$OO#o$PO#p$PO#q$PO(aVO[#mia#mij#mi!]#mi#R#mi#s#mi#t#mi#u#mi#v#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#r#mi~P#6QO#r$QO~P#6QOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO(aVOa#mi!]#mi#x#mi#z#mi#{#mi'z#mi(r#mi(y#mi(z#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#v#mi~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO(aVO(z#}Oa#mi!]#mi#z#mi#{#mi'z#mi(r#mi(y#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#x$UO~P#;VO#x#mi~P#;VO#v$SO~P#8oOP$[OR#zO[$cOj$ROr$aO!Q#yO!S#{O!l#xO!p$[O#R$RO#n$OO#o$PO#p$PO#q$PO#r$QO#s$RO#t$RO#u$bO#v$SO#x$UO(aVO(y#|O(z#}Oa#mi!]#mi#{#mi'z#mi(r#mi'w#mi!Y#mi!k#miv#mi!_#mi%i#mi!g#mi~O#z#mi~P#={O#z$WO~P#={OP]XR]X[]Xj]Xr]X!Q]X!S]X!l]X!p]X#R]X#S]X#`]X#kfX#n]X#o]X#p]X#q]X#r]X#s]X#t]X#u]X#v]X#x]X#z]X#{]X$Q]X(a]X(r]X(y]X(z]X!]]X!^]X~O$O]X~P#@jOP$[OR#zO[]O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P#EyO!]/POg(pX~P!1WOg/RO~Oa$Pi!]$Pi'z$Pi'w$Pi!Y$Pi!k$Piv$Pi!_$Pi%i$Pi!g$Pi~P!:tO$]/SO$_/SO~O$]/TO$_/TO~O!g)hO#`/UO!_$cX$Z$cX$]$cX$_$cX$f$cX~O![/VO~O!_)kO$Z/XO$])jO$_)jO$f/YO~O!]VO!l$xO#j^O!Q*OO'y*PO(y$}O(z%POP#miR#mi!S#mi!l#mi!p#mi#n#mi#o#mi#p#mi#q#mi(a#mi~P&,QO#S$dOP(`XR(`X[(`Xj(`Xn(`Xr(`X!Q(`X!S(`X!l(`X!p(`X#R(`X#n(`X#o(`X#p(`X#q(`X#r(`X#s(`X#t(`X#u(`X#v(`X#x(`X#z(`X#{(`X$O(`X'y(`X(a(`X(r(`X(y(`X(z(`X!](`X!^(`X~O$O$Pi!]$Pi!^$Pi~P#BwO$O!ri!^!ri~P$+oOg']a!]']a~P!1WO!^7nO~O!]'da!^'da~P#BwO!Y7oO~P#/sO!g#vO(r'pO!]'ea!k'ea~O!]/pO!k)Oi~O!]/pO!g#vO!k)Oi~Og$|q!]$|q#`$|q$O$|q~P!1WO!Y'ga!]'ga~P#/sO!g7vO~O!]/yO!Y)Pi~P#/sO!]/yO!Y)Pi~O!Y7yO~Oh%VOr8OO!l%eO(r'pO~Oj8QO!g#vO~Or8TO!g#vO(r'pO~O!Q*OO'y*PO(z%POn'ja(y'ja!]'ja#`'ja~Og'ja$O'ja~P&5RO!Q*OO'y*POn'la(y'la(z'la!]'la#`'la~Og'la$O'la~P&5tOg(_q!](_q~P!1WO#`8VOg(_q!](_q~P!1WO!Y8WO~Og%Oq!]%Oq#`%Oq$O%Oq~P!1WOa$oy!]$oy'z$oy'w$oy!Y$oy!k$oyv$oy!_$oy%i$oy!g$oy~P!:tO!g6rO~O!]5[O!_)Qa~O!_'`OP$TaR$Ta[$Taj$Tar$Ta!Q$Ta!S$Ta!]$Ta!l$Ta!p$Ta#R$Ta#n$Ta#o$Ta#p$Ta#q$Ta#r$Ta#s$Ta#t$Ta#u$Ta#v$Ta#x$Ta#z$Ta#{$Ta(a$Ta(r$Ta(y$Ta(z$Ta~O%i7WO~P&8fO%^8[Oa%[i!_%[i'z%[i!]%[i~Oa#cy!]#cy'z#cy'w#cy!Y#cy!k#cyv#cy!_#cy%i#cy!g#cy~P!:tO[8^O~Ob8`O(T+qO(VTO(YUO~O!]1TO!^)Xi~O`8dO~O(e(|O!]'pX!^'pX~O!]5uO!^)Ua~O!^8nO~P%;eO(o!sO~P$&YO#[8oO~O!_1oO~O!_1oO%i8qO~On8tO!_1oO%i8qO~O[8yO!]'sa!^'sa~O!]1zO!^)Vi~O!k8}O~O!k9OO~O!k9RO~O!k9RO~P%[Oa9TO~O!g9UO~O!k9VO~O!](wi!^(wi~P#BwOa%nO#`9_O'z%nO~O!](ty!k(tya(ty'z(ty~P!:tO!](jO!k(sy~O%i9bO~P&8fO!_'`O%i9bO~O#k$|qP$|qR$|q[$|qa$|qj$|qr$|q!S$|q!]$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q'z$|q(a$|q(r$|q!k$|q!Y$|q'w$|q#`$|qv$|q!_$|q%i$|q!g$|q~P#/sO#k'jaP'jaR'ja['jaa'jaj'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja'z'ja(a'ja(r'ja!k'ja!Y'ja'w'jav'ja!_'ja%i'ja!g'ja~P&5RO#k'laP'laR'la['laa'laj'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la'z'la(a'la(r'la!k'la!Y'la'w'lav'la!_'la%i'la!g'la~P&5tO#k%OqP%OqR%Oq[%Oqa%Oqj%Oqr%Oq!S%Oq!]%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq'z%Oq(a%Oq(r%Oq!k%Oq!Y%Oq'w%Oq#`%Oqv%Oq!_%Oq%i%Oq!g%Oq~P#/sO!]'Yi!k'Yi~P!:tO$O#cq!]#cq!^#cq~P#BwO(y$}OP%aaR%aa[%aaj%aar%aa!S%aa!l%aa!p%aa#R%aa#n%aa#o%aa#p%aa#q%aa#r%aa#s%aa#t%aa#u%aa#v%aa#x%aa#z%aa#{%aa$O%aa(a%aa(r%aa!]%aa!^%aa~On%aa!Q%aa'y%aa(z%aa~P&IyO(z%POP%caR%ca[%caj%car%ca!S%ca!l%ca!p%ca#R%ca#n%ca#o%ca#p%ca#q%ca#r%ca#s%ca#t%ca#u%ca#v%ca#x%ca#z%ca#{%ca$O%ca(a%ca(r%ca!]%ca!^%ca~On%ca!Q%ca'y%ca(y%ca~P&LQOn>^O!Q*OO'y*PO(z%PO~P&IyOn>^O!Q*OO'y*PO(y$}O~P&LQOR0kO!Q0kO!S0lO#S$dOP}a[}aj}an}ar}a!l}a!p}a#R}a#n}a#o}a#p}a#q}a#r}a#s}a#t}a#u}a#v}a#x}a#z}a#{}a$O}a'y}a(a}a(r}a(y}a(z}a!]}a!^}a~O!Q*OO'y*POP$saR$sa[$saj$san$sar$sa!S$sa!l$sa!p$sa#R$sa#n$sa#o$sa#p$sa#q$sa#r$sa#s$sa#t$sa#u$sa#v$sa#x$sa#z$sa#{$sa$O$sa(a$sa(r$sa(y$sa(z$sa!]$sa!^$sa~O!Q*OO'y*POP$uaR$ua[$uaj$uan$uar$ua!S$ua!l$ua!p$ua#R$ua#n$ua#o$ua#p$ua#q$ua#r$ua#s$ua#t$ua#u$ua#v$ua#x$ua#z$ua#{$ua$O$ua(a$ua(r$ua(y$ua(z$ua!]$ua!^$ua~On>^O!Q*OO'y*PO(y$}O(z%PO~OP%TaR%Ta[%Taj%Tar%Ta!S%Ta!l%Ta!p%Ta#R%Ta#n%Ta#o%Ta#p%Ta#q%Ta#r%Ta#s%Ta#t%Ta#u%Ta#v%Ta#x%Ta#z%Ta#{%Ta$O%Ta(a%Ta(r%Ta!]%Ta!^%Ta~P''VO$O$mq!]$mq!^$mq~P#BwO$O$oq!]$oq!^$oq~P#BwO!^9oO~O$O9pO~P!1WO!g#vO!]'ei!k'ei~O!g#vO(r'pO!]'ei!k'ei~O!]/pO!k)Oq~O!Y'gi!]'gi~P#/sO!]/yO!Y)Pq~Or9wO!g#vO(r'pO~O[9yO!Y9xO~P#/sO!Y9xO~Oj:PO!g#vO~Og(_y!](_y~P!1WO!]'na!_'na~P#/sOa%[q!_%[q'z%[q!]%[q~P#/sO[:UO~O!]1TO!^)Xq~O`:YO~O#`:ZO!]'pa!^'pa~O!]5uO!^)Ui~P#BwO!S:]O~O!_1oO%i:`O~O(VTO(YUO(e:eO~O!]1zO!^)Vq~O!k:hO~O!k:iO~O!k:jO~O!k:jO~P%[O#`:mO!]#hy!^#hy~O!]#hy!^#hy~P#BwO%i:rO~P&8fO!_'`O%i:rO~O$O#|y!]#|y!^#|y~P#BwOP$|iR$|i[$|ij$|ir$|i!S$|i!l$|i!p$|i#R$|i#n$|i#o$|i#p$|i#q$|i#r$|i#s$|i#t$|i#u$|i#v$|i#x$|i#z$|i#{$|i$O$|i(a$|i(r$|i!]$|i!^$|i~P''VO!Q*OO'y*PO(z%POP'iaR'ia['iaj'ian'iar'ia!S'ia!l'ia!p'ia#R'ia#n'ia#o'ia#p'ia#q'ia#r'ia#s'ia#t'ia#u'ia#v'ia#x'ia#z'ia#{'ia$O'ia(a'ia(r'ia(y'ia!]'ia!^'ia~O!Q*OO'y*POP'kaR'ka['kaj'kan'kar'ka!S'ka!l'ka!p'ka#R'ka#n'ka#o'ka#p'ka#q'ka#r'ka#s'ka#t'ka#u'ka#v'ka#x'ka#z'ka#{'ka$O'ka(a'ka(r'ka(y'ka(z'ka!]'ka!^'ka~O(y$}OP%aiR%ai[%aij%ain%air%ai!Q%ai!S%ai!l%ai!p%ai#R%ai#n%ai#o%ai#p%ai#q%ai#r%ai#s%ai#t%ai#u%ai#v%ai#x%ai#z%ai#{%ai$O%ai'y%ai(a%ai(r%ai(z%ai!]%ai!^%ai~O(z%POP%ciR%ci[%cij%cin%cir%ci!Q%ci!S%ci!l%ci!p%ci#R%ci#n%ci#o%ci#p%ci#q%ci#r%ci#s%ci#t%ci#u%ci#v%ci#x%ci#z%ci#{%ci$O%ci'y%ci(a%ci(r%ci(y%ci!]%ci!^%ci~O$O$oy!]$oy!^$oy~P#BwO$O#cy!]#cy!^#cy~P#BwO!g#vO!]'eq!k'eq~O!]/pO!k)Oy~O!Y'gq!]'gq~P#/sOr:|O!g#vO(r'pO~O[;QO!Y;PO~P#/sO!Y;PO~Og(_!R!](_!R~P!1WOa%[y!_%[y'z%[y!]%[y~P#/sO!]1TO!^)Xy~O!]5uO!^)Uq~O(T;XO~O!_1oO%i;[O~O!k;_O~O%i;dO~P&8fOP$|qR$|q[$|qj$|qr$|q!S$|q!l$|q!p$|q#R$|q#n$|q#o$|q#p$|q#q$|q#r$|q#s$|q#t$|q#u$|q#v$|q#x$|q#z$|q#{$|q$O$|q(a$|q(r$|q!]$|q!^$|q~P''VO!Q*OO'y*PO(z%POP'jaR'ja['jaj'jan'jar'ja!S'ja!l'ja!p'ja#R'ja#n'ja#o'ja#p'ja#q'ja#r'ja#s'ja#t'ja#u'ja#v'ja#x'ja#z'ja#{'ja$O'ja(a'ja(r'ja(y'ja!]'ja!^'ja~O!Q*OO'y*POP'laR'la['laj'lan'lar'la!S'la!l'la!p'la#R'la#n'la#o'la#p'la#q'la#r'la#s'la#t'la#u'la#v'la#x'la#z'la#{'la$O'la(a'la(r'la(y'la(z'la!]'la!^'la~OP%OqR%Oq[%Oqj%Oqr%Oq!S%Oq!l%Oq!p%Oq#R%Oq#n%Oq#o%Oq#p%Oq#q%Oq#r%Oq#s%Oq#t%Oq#u%Oq#v%Oq#x%Oq#z%Oq#{%Oq$O%Oq(a%Oq(r%Oq!]%Oq!^%Oq~P''VOg%e!Z!]%e!Z#`%e!Z$O%e!Z~P!1WO!Y;hO~P#/sOr;iO!g#vO(r'pO~O[;kO!Y;hO~P#/sO!]'pq!^'pq~P#BwO!]#h!Z!^#h!Z~P#BwO#k%e!ZP%e!ZR%e!Z[%e!Za%e!Zj%e!Zr%e!Z!S%e!Z!]%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z'z%e!Z(a%e!Z(r%e!Z!k%e!Z!Y%e!Z'w%e!Z#`%e!Zv%e!Z!_%e!Z%i%e!Z!g%e!Z~P#/sOr;tO!g#vO(r'pO~O!Y;uO~P#/sOr;|O!g#vO(r'pO~O!Y;}O~P#/sOP%e!ZR%e!Z[%e!Zj%e!Zr%e!Z!S%e!Z!l%e!Z!p%e!Z#R%e!Z#n%e!Z#o%e!Z#p%e!Z#q%e!Z#r%e!Z#s%e!Z#t%e!Z#u%e!Z#v%e!Z#x%e!Z#z%e!Z#{%e!Z$O%e!Z(a%e!Z(r%e!Z!]%e!Z!^%e!Z~P''VOrROe!iOpkOrPO(T)]O(VTO(YUO(aVO(o[O~O!]WO!l$xO#jgPPP!>oI[PPPPPPPPP!BOP!C]PPI[!DnPI[PI[I[I[I[I[PI[!FQP!I[P!LbP!Lf!Lp!Lt!LtP!IXP!Lx!LxP#!OP#!SI[PI[#!Y#%_CjA^PA^PA^A^P#&lA^A^#)OA^#+vA^#.SA^A^#.r#1W#1W#1]#1f#1W#1qPP#1WPA^#2ZA^#6YA^A^6mPPP#:_PPP#:x#:xP#:xP#;`#:xPP#;fP#;]P#;]#;y#;]#P#>V#>]#>k#>q#>{#?R#?]#?c#?s#?y#@k#@}#AT#AZ#Ai#BO#Cs#DR#DY#Et#FS#Gt#HS#HY#H`#Hf#Hp#Hv#H|#IW#Ij#IpPPPPPPPPPPP#IvPPPPPPP#Jk#Mx$ b$ i$ qPPP$']P$'f$*_$0x$0{$1O$1}$2Q$2X$2aP$2g$2jP$3W$3[$4S$5b$5g$5}PP$6S$6Y$6^$6a$6e$6i$7e$7|$8e$8i$8l$8o$8y$8|$9Q$9UR!|RoqOXst!Z#d%m&r&t&u&w,s,x2[2_Y!vQ'`-e1o5{Q%tvQ%|yQ&T|Q&j!VS'W!e-]Q'f!iS'l!r!yU*k$|*Z*oQ+o%}S+|&V&WQ,d&dQ-c'_Q-m'gQ-u'mQ0[*qQ1b,OQ1y,eR<{SU+P%]S!S!nQ!r!v!y!z$|'W'_'`'l'm'n*k*o*q*r-]-c-e-u0[0_1o5{5}%[$ti#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^Q&X|Q'U!eS'[%i-`Q+t&PQ,P&WQ,f&gQ0n+SQ1Y+uQ1_+{Q2Q,jQ2R,kQ5f1TQ5o1aQ6[1zQ6_1|Q6`2PQ8`5gQ8c5lQ8|6bQ:X8dQ:f8yQ;V:YR<}*ZrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R,h&k&z^OPXYstuvwz!Z!`!g!j!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'b'r(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mR>S[#]WZ#W#Z'X(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ%wxQ%{yW&Q|&V&W,OQ&_!TQ'c!hQ'e!iQ(q#sS+n%|%}Q+r&PQ,_&bQ,c&dS-l'f'gQ.i(rQ1R+oQ1X+uQ1Z+vQ1^+zQ1t,`S1x,d,eQ2|-mQ5e1TQ5i1WQ5n1`Q6Z1yQ8_5gQ8b5kQ8f5pQ:T8^R;T:U!U$zi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y!^%yy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{Q+h%wQ,T&[Q,W&]Q,b&dQ.h(qQ1s,_U1w,c,d,eQ3e.iQ6U1tS6Y1x1yQ8x6Z#f>T#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o>UPS&[!Q&iQ&]!RQ&^!SU*}%[%d=sR,R&Y%]%Si#v$b$c$d$x${%O%Q%^%_%c)y*R*T*V*Y*a*g*w*x+f+i,S,V.f/P/d/m/x/y/{0`0b0i0j0o1f1i1q3c4^4_4j4o5Q5[5_6S7W7v8Q8V8[8q9b9p9y:P:`:r;Q;[;d;kP>X>Y>]>^T)z$u){V+P%]S$i$^c#Y#e%q%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.|.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SQ'Y!eR2q-]!W!nQ!e!r!v!y!z$|'W'_'`'l'm'n*Z*k*o*q*r-]-c-e-u0[0_1o5{5}R1l,ZnqOXst!Z#d%m&r&t&u&w,s,x2[2_Q&y!^Q'v!xS(s#u<^Q+l%zQ,]&_Q,^&aQ-j'dQ-w'oS.r(x=PS0q+X=ZQ1P+mQ1n,[Q2c,zQ2e,{Q2m-WQ2z-kQ2}-oS5Y0r=eQ5a1QS5d1S=fQ6t2oQ6x2{Q6}3SQ8]5bQ9Y6vQ9Z6yQ9^7OR:l9V$d$]c#Y#e%s%u(S(Y(t(y)R)S)T)U)V)W)X)Y)Z)[)^)`)b)g)q+d+x-Z-x-}.S.U.s.v.z.}/O/b0p2k2n3O3V3k3p3q3r3s3t3u3v3w3x3y3z3{3|4P4Q4X5X5c6u6{7Q7a7b7k7l8k9X9]9g9m9n:o;W;`SS#q]SU$fd)_,mS(p#p'iU*v%R(w4OU0m+O.n7gQ5^0xQ7V3`Q9d7YR:s9em!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}Q't!uS(f#g2US-s'k'wQ/s*]Q0R*jQ3U-vQ4f/tQ4r0TQ4s0UQ4x0^Q7r4`S7}4t4vS8R4y4{Q9r7sQ9v7yQ9{8OQ:Q8TS:{9w9xS;g:|;PS;s;h;iS;{;t;uSSR=o>R%^bOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Q%fj!^%xy!i!u%{%|%}'V'e'f'g'k'u*j+n+o-Y-l-m-t0R0U1R2u2|3T4r4s4v7}9{S&Oz!jQ+k%yQ,a&dW1v,b,c,d,eU6X1w1x1yS8w6Y6ZQ:d8x!r=j$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ=t>QR=u>R%QeOPXYstuvw!Z!`!g!o#S#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_Y#bWZ#W#Z(T!b%jm#h#i#l$x%e%h(^(h(i(j*Y*^*b+Z+[+^,o-V.T.Z.[.]._/m/p2d3[3]4a6r7TQ,n&o!p=k$Z$n)s-U-X/V2p4T5w6s:Z:mSR=n'XU']!e%i*ZR2s-`%SdOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+],p,s,x-i-q.P.V.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3l4z6T6e6f6i6|8t9T9_!r)_$Z$n'X)s-U-X/V2p4T5w6s:Z:mSQ,m&oQ0x+gQ3`.gQ7Y3dR9e7[!b$Tc#Y%q(S(Y(t(y)Z)[)`)g+x-x-}.S.U.s.v/b0p3O3V3k3{5X5c6{7Q7a9]:oS)^)q-Z.|2k2n3p4P4X6u7b7k7l8k9X9g9m9n;W;`=vQ>X>ZR>Y>['QkOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mSS$oh$pR4U/U'XgOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$kf$qQ$ifS)j$l)nR)v$qT$jf$qT)l$l)n'XhOPWXYZhstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$Z$_$a$e$n$p%m%t&R&k&n&o&r&t&u&w&{'T'X'b'r(T(V(](d(x(z)O)s)}*i+X+]+g,p,s,x-U-X-i-q.P.V.g.t.{/U/V/n0]0l0r1S1r2S2T2V2X2[2_2a2p3Q3W3d3l4T4z5w6T6e6f6i6s6|7[8t9T9_:Z:mST$oh$pQ$rhR)u$p%^jOPWXYZstuvw!Z!`!g!o#S#W#Z#d#o#u#x#{$O$P$Q$R$S$T$U$V$W$X$_$a$e%m%t&R&k&n&o&r&t&u&w&{'T'b'r(T(V(](d(x(z)O)}*i+X+]+g,p,s,x-i-q.P.V.g.t.{/n0]0l0r1S1r2S2T2V2X2[2_2a3Q3W3d3l4z6T6e6f6i6|7[8t9T9_!s>Q$Z$n'X)s-U-X/V2p4T5w6s:Z:mS#glOPXZst!Z!`!o#S#d#o#{$n%m&k&n&o&r&t&u&w&{'T'b)O)s*i+]+g,p,s,x-i.g/V/n0]0l1r2S2T2V2X2[2_2a3d4T4z6T6e6f6i7[8t9T!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^Q+T%aQ/c*Oo4OP>X>YQ*c$zU*l$|*Z*oQ+U%bQ0W*m#f=q#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^n=rTQ=x>UQ=y>VR=z>W!U%Ri$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y#f(w#v$b$c$x${)y*V*Y*g+f+i,S,V.f/d/m/y/{1f1i1q3c4^4j4o5[5_6S7W7v8Q8[8q9b9y:P:`:r;Q;[;d;k]>^o4OP>X>Y>]>^Q,U&]Q1h,WQ5s1gR8h5tV*n$|*Z*oU*n$|*Z*oT5z1o5{S0P*i/nQ4w0]T8S4z:]Q+j%xQ0V*lQ1O+kQ1u,aQ6W1vQ8v6XQ:c8wR;^:d!U%Oi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Yx*R$v)e*S*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>OS0`*t0a#f]>^nZ>[`=T3}7c7f7j9h:t:w;yS=_.l3iT=`7e9k!U%Qi$d%O%Q%^%_%c*R*T*a*w*x/P/x0`0b0i0j0o4_5Q8V9p>P>X>Y|*T$v)e*U*t+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>OS0b*u0c#f]>^nZ>[d=V3}7d7e7j9h9i:t:u:w;yS=a.m3jT=b7f9lrnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q&f!UR,p&ornOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_R&f!UQ,Y&^R1d,RsnOXst!V!Z#d%m&i&r&t&u&w,s,x2[2_Q1p,_S6R1s1tU8p6P6Q6US:_8r8sS;Y:^:aQ;m;ZR;w;nQ&m!VR,i&iR6_1|R:f8yW&Q|&V&W,OR1Z+vQ&r!WR,s&sR,y&xT2],x2_R,}&yQ,|&yR2f,}Q'y!{R-y'ySsOtQ#dXT%ps#dQ#OTR'{#OQ#RUR'}#RQ){$uR/`){Q#UVR(Q#UQ#XWU(W#X(X.QQ(X#YR.Q(YQ-^'YR2r-^Q.u(yS3m.u3nR3n.vQ-e'`R2v-eY!rQ'`-e1o5{R'j!rQ/Q)eR4S/QU#_W%h*YU(_#_(`.RQ(`#`R.R(ZQ-a']R2t-at`OXst!V!Z#d%m&i&k&r&t&u&w,s,x2[2_S#hZ%eU#r`#h.[R.[(jQ(k#jQ.X(gW.a(k.X3X7RQ3X.YR7R3YQ)n$lR/W)nQ$phR)t$pQ$`cU)a$`-|O>Z>[Q/z*eU4k/z4m7xQ4m/|R7x4lS*o$|*ZR0Y*ox*S$v)e*t*u+V/v0d0e4R4g5R5S5W7p8U:R:x=p=}>O!d.j(u)c*[*e.l.m.q/_/k/|0v1e3h4[4h4l5r7]7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/h*S.j7ca7c3}7e7f7j9h:t:w;yQ0a*tQ3i.lU4}0a3i9kR9k7e|*U$v)e*t*u+V/g/v0d0e4R4g4|5R5S5W7p8U:R:x=p=}>O!h.k(u)c*[*e.l.m.q/_/k/|0v1e3f3h4[4h4l5r7]7^7`7w7z8X8Z9t9|:S:};R;e;j;v>Z>[U/j*U.k7de7d3}7e7f7j9h9i:t:u:w;yQ0c*uQ3j.mU5P0c3j9lR9l7fQ*z%UR0g*zQ5]0vR8Y5]Q+_%kR0u+_Q5v1jS8j5v:[R:[8kQ,[&_R1m,[Q5{1oR8m5{Q1{,fS6]1{8zR8z6_Q1U+rW5h1U5j8a:VQ5j1XQ8a5iR:V8bQ+w&QR1[+wQ2_,xR6m2_YrOXst#dQ&v!ZQ+a%mQ,r&rQ,t&tQ,u&uQ,w&wQ2Y,sS2],x2_R6l2[Q%opQ&z!_Q&}!aQ'P!bQ'R!cQ'q!uQ+`%lQ+l%zQ,Q&XQ,h&mQ-P&|W-p'k's't'wQ-w'oQ0X*nQ1P+mQ1c,PS2O,i,lQ2g-OQ2h-RQ2i-SQ2}-oW3P-r-s-v-xQ5a1QQ5m1_Q5q1eQ6V1uQ6a2QQ6k2ZU6z3O3R3UQ6}3SQ8]5bQ8e5oQ8g5rQ8l5zQ8u6WQ8{6`S9[6{7PQ9^7OQ:W8cQ:b8vQ:g8|Q:n9]Q;U:XQ;]:cQ;a:oQ;l;VR;o;^Q%zyQ'd!iQ'o!uU+m%{%|%}Q-W'VU-k'e'f'gS-o'k'uQ0Q*jS1Q+n+oQ2o-YS2{-l-mQ3S-tS4p0R0UQ5b1RQ6v2uQ6y2|Q7O3TU7{4r4s4vQ9z7}R;O9{S$wi>PR*{%VU%Ui%V>PR0f*yQ$viS(u#v+iS)c$b$cQ)e$dQ*[$xS*e${*YQ*t%OQ*u%QQ+Q%^Q+R%_Q+V%cQ.lPQ=}>XQ>O>YQ>Z>]R>[>^Q+O%]Q.nSR#[WR'Z!el!tQ!r!v!y!z'`'l'm'n-e-u1o5{5}S'V!e-]U*j$|*Z*oS-Y'W'_S0U*k*qQ0^*rQ2u-cQ4v0[R4{0_R({#xQ!fQT-d'`-e]!qQ!r'`-e1o5{Q#p]R'i < TypeParamList in out const TypeDefinition extends ThisType this LiteralType ArithOp Number BooleanLiteral TemplateType InterpolationEnd Interpolation InterpolationStart NullType null VoidType void TypeofType typeof MemberExpression . PropertyName [ TemplateString Escape Interpolation super RegExp ] ArrayExpression Spread , } { ObjectExpression Property async get set PropertyDefinition Block : NewTarget new NewExpression ) ( ArgList UnaryExpression delete LogicOp BitOp YieldExpression yield AwaitExpression await ParenthesizedExpression ClassExpression class ClassBody MethodDeclaration Decorator @ MemberExpression PrivatePropertyName CallExpression TypeArgList CompareOp < declare Privacy static abstract override PrivatePropertyDefinition PropertyDeclaration readonly accessor Optional TypeAnnotation Equals StaticBlock FunctionExpression ArrowFunction ParamList ParamList ArrayPattern ObjectPattern PatternProperty Privacy readonly Arrow MemberExpression BinaryExpression ArithOp ArithOp ArithOp ArithOp BitOp CompareOp instanceof satisfies CompareOp BitOp BitOp BitOp LogicOp LogicOp ConditionalExpression LogicOp LogicOp AssignmentExpression UpdateOp PostfixExpression CallExpression InstantiationExpression TaggedTemplateExpression DynamicImport import ImportMeta JSXElement JSXSelfCloseEndTag JSXSelfClosingTag JSXIdentifier JSXBuiltin JSXIdentifier JSXNamespacedName JSXMemberExpression JSXSpreadAttribute JSXAttribute JSXAttributeValue JSXEscape JSXEndTag JSXOpenTag JSXFragmentTag JSXText JSXEscape JSXStartCloseTag JSXCloseTag PrefixCast < ArrowFunction TypeParamList SequenceExpression InstantiationExpression KeyofType keyof UniqueType unique ImportType InferredType infer TypeName ParenthesizedType FunctionSignature ParamList NewSignature IndexedType TupleType Label ArrayType ReadonlyType ObjectType MethodType PropertyType IndexSignature PropertyDefinition CallSignature TypePredicate asserts is NewSignature new UnionType LogicOp IntersectionType LogicOp ConditionalType ParameterizedType ClassDeclaration abstract implements type VariableDeclaration let var using TypeAliasDeclaration InterfaceDeclaration interface EnumDeclaration enum EnumBody NamespaceDeclaration namespace module AmbientDeclaration declare GlobalDeclaration global ClassDeclaration ClassBody AmbientFunctionDeclaration ExportGroup VariableName VariableName ImportDeclaration defer ImportGroup ForStatement for ForSpec ForInSpec ForOfSpec of WhileStatement while WithStatement with DoStatement do IfStatement if else SwitchStatement switch SwitchBody CaseLabel case DefaultLabel TryStatement try CatchClause catch FinallyClause finally ReturnStatement return ThrowStatement throw BreakStatement break ContinueStatement continue DebuggerStatement debugger LabeledStatement ExpressionStatement SingleExpression SingleClassItem",maxTerm:380,context:xce,nodeProps:[["isolate",-8,5,6,14,37,39,51,53,55,""],["group",-26,9,17,19,68,207,211,215,216,218,221,224,234,237,243,245,247,249,252,258,264,266,268,270,272,274,275,"Statement",-34,13,14,32,35,36,42,51,54,55,57,62,70,72,76,80,82,84,85,110,111,120,121,136,139,141,142,143,144,145,147,148,167,169,171,"Expression",-23,31,33,37,41,43,45,173,175,177,178,180,181,182,184,185,186,188,189,190,201,203,205,206,"Type",-3,88,103,109,"ClassItem"],["openedBy",23,"<",38,"InterpolationStart",56,"[",60,"{",73,"(",160,"JSXStartCloseTag"],["closedBy",-2,24,168,">",40,"InterpolationEnd",50,"]",61,"}",74,")",165,"JSXEndTag"]],propSources:[Tce],skippedNodes:[0,5,6,278],repeatNodeCount:37,tokenData:"$Fq07[R!bOX%ZXY+gYZ-yZ[+g[]%Z]^.c^p%Zpq+gqr/mrs3cst:_tuEruvJSvwLkwx! Yxy!'iyz!(sz{!)}{|!,q|}!.O}!O!,q!O!P!/Y!P!Q!9j!Q!R#:O!R![#<_![!]#I_!]!^#Jk!^!_#Ku!_!`$![!`!a$$v!a!b$*T!b!c$,r!c!}Er!}#O$-|#O#P$/W#P#Q$4o#Q#R$5y#R#SEr#S#T$7W#T#o$8b#o#p$x#r#s$@U#s$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$I|Er$I|$I}$Dk$I}$JO$Dk$JO$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr(n%d_$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z&j&hT$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c&j&zP;=`<%l&c'|'U]$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!b(SU(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!b(iP;=`<%l'}'|(oP;=`<%l&}'[(y]$i&j(WpOY(rYZ&cZr(rrs&cs!^(r!^!_)r!_#O(r#O#P&c#P#o(r#o#p)r#p;'S(r;'S;=`*a<%lO(rp)wU(WpOY)rZr)rs#O)r#P;'S)r;'S;=`*Z<%lO)rp*^P;=`<%l)r'[*dP;=`<%l(r#S*nX(Wp(Z!bOY*gZr*grs'}sw*gwx)rx#O*g#P;'S*g;'S;=`+Z<%lO*g#S+^P;=`<%l*g(n+dP;=`<%l%Z07[+rq$i&j(Wp(Z!b'|0/lOX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p$f%Z$f$g+g$g#BY%Z#BY#BZ+g#BZ$IS%Z$IS$I_+g$I_$JT%Z$JT$JU+g$JU$KV%Z$KV$KW+g$KW&FU%Z&FU&FV+g&FV;'S%Z;'S;=`+a<%l?HT%Z?HT?HU+g?HUO%Z07[.ST(X#S$i&j'}0/lO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c07[.n_$i&j(Wp(Z!b'}0/lOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)3p/x`$i&j!p),Q(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`0z!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW1V`#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_!`2X!`#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z(KW2d_#v(Ch$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'At3l_(V':f$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k(^4r_$i&j(Z!bOY4kYZ5qZr4krs7nsw4kwx5qx!^4k!^!_8p!_#O4k#O#P5q#P#o4k#o#p8p#p;'S4k;'S;=`:X<%lO4k&z5vX$i&jOr5qrs6cs!^5q!^!_6y!_#o5q#o#p6y#p;'S5q;'S;=`7h<%lO5q&z6jT$d`$i&jO!^&c!_#o&c#p;'S&c;'S;=`&w<%lO&c`6|TOr6yrs7]s;'S6y;'S;=`7b<%lO6y`7bO$d``7eP;=`<%l6y&z7kP;=`<%l5q(^7w]$d`$i&j(Z!bOY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}!r8uZ(Z!bOY8pYZ6yZr8prs9hsw8pwx6yx#O8p#O#P6y#P;'S8p;'S;=`:R<%lO8p!r9oU$d`(Z!bOY'}Zw'}x#O'}#P;'S'};'S;=`(f<%lO'}!r:UP;=`<%l8p(^:[P;=`<%l4k%9[:hh$i&j(Wp(Z!bOY%ZYZ&cZq%Zqr`#P#o`x!^=^!^!_?q!_#O=^#O#P>`#P#o=^#o#p?q#p;'S=^;'S;=`@h<%lO=^&n>gXWS$i&jOY>`YZ&cZ!^>`!^!_?S!_#o>`#o#p?S#p;'S>`;'S;=`?k<%lO>`S?XSWSOY?SZ;'S?S;'S;=`?e<%lO?SS?hP;=`<%l?S&n?nP;=`<%l>`!f?xWWS(Z!bOY?qZw?qwx?Sx#O?q#O#P?S#P;'S?q;'S;=`@b<%lO?q!f@eP;=`<%l?q(Q@kP;=`<%l=^'`@w]WS$i&j(WpOY@nYZ&cZr@nrs>`s!^@n!^!_Ap!_#O@n#O#P>`#P#o@n#o#pAp#p;'S@n;'S;=`Bg<%lO@ntAwWWS(WpOYApZrAprs?Ss#OAp#O#P?S#P;'SAp;'S;=`Ba<%lOAptBdP;=`<%lAp'`BjP;=`<%l@n#WBvYWS(Wp(Z!bOYBmZrBmrs?qswBmwxApx#OBm#O#P?S#P;'SBm;'S;=`Cf<%lOBm#WCiP;=`<%lBm(rCoP;=`<%l^!Q^$i&j!X7`OY!=yYZ&cZ!P!=y!P!Q!>|!Q!^!=y!^!_!@c!_!}!=y!}#O!CW#O#P!Dy#P#o!=y#o#p!@c#p;'S!=y;'S;=`!Ek<%lO!=y|#X#Z&c#Z#[!>|#[#]&c#]#^!>|#^#a&c#a#b!>|#b#g&c#g#h!>|#h#i&c#i#j!>|#j#k!>|#k#m&c#m#n!>|#n#o&c#p;'S&c;'S;=`&w<%lO&c7`!@hX!X7`OY!@cZ!P!@c!P!Q!AT!Q!}!@c!}#O!Ar#O#P!Bq#P;'S!@c;'S;=`!CQ<%lO!@c7`!AYW!X7`#W#X!AT#Z#[!AT#]#^!AT#a#b!AT#g#h!AT#i#j!AT#j#k!AT#m#n!AT7`!AuVOY!ArZ#O!Ar#O#P!B[#P#Q!@c#Q;'S!Ar;'S;=`!Bk<%lO!Ar7`!B_SOY!ArZ;'S!Ar;'S;=`!Bk<%lO!Ar7`!BnP;=`<%l!Ar7`!BtSOY!@cZ;'S!@c;'S;=`!CQ<%lO!@c7`!CTP;=`<%l!@c^!Ezl$i&j(Z!b!X7`OY&}YZ&cZw&}wx&cx!^&}!^!_'}!_#O&}#O#P&c#P#W&}#W#X!Eq#X#Z&}#Z#[!Eq#[#]&}#]#^!Eq#^#a&}#a#b!Eq#b#g&}#g#h!Eq#h#i&}#i#j!Eq#j#k!Eq#k#m&}#m#n!Eq#n#o&}#o#p'}#p;'S&};'S;=`(l<%lO&}8r!GyZ(Z!b!X7`OY!GrZw!Grwx!@cx!P!Gr!P!Q!Hl!Q!}!Gr!}#O!JU#O#P!Bq#P;'S!Gr;'S;=`!J|<%lO!Gr8r!Hse(Z!b!X7`OY'}Zw'}x#O'}#P#W'}#W#X!Hl#X#Z'}#Z#[!Hl#[#]'}#]#^!Hl#^#a'}#a#b!Hl#b#g'}#g#h!Hl#h#i'}#i#j!Hl#j#k!Hl#k#m'}#m#n!Hl#n;'S'};'S;=`(f<%lO'}8r!JZX(Z!bOY!JUZw!JUwx!Arx#O!JU#O#P!B[#P#Q!Gr#Q;'S!JU;'S;=`!Jv<%lO!JU8r!JyP;=`<%l!JU8r!KPP;=`<%l!Gr>^!KZ^$i&j(Z!bOY!KSYZ&cZw!KSwx!CWx!^!KS!^!_!JU!_#O!KS#O#P!DR#P#Q!^!LYP;=`<%l!KS>^!L`P;=`<%l!_#c#d#Bq#d#l%Z#l#m#Es#m#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#>j_$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#?rd$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#A]f$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!R#AQ!R!S#AQ!S!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#AQ#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Bzc$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Dbe$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q!Y#DV!Y!^%Z!^!_*g!_#O%Z#O#P&c#P#R%Z#R#S#DV#S#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#E|g$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z'Ad#Gpi$i&j(Wp(Z!bs'9tOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!Q%Z!Q![#Ge![!^%Z!^!_*g!_!c%Z!c!i#Ge!i#O%Z#O#P&c#P#R%Z#R#S#Ge#S#T%Z#T#Z#Ge#Z#b%Z#b#c#>_#c#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z*)x#Il_!g$b$i&j$O)Lv(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z)[#Jv_al$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z04f#LS^h#)`#R-v$?V_!^(CdvBr$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z?O$@a_!q7`$i&j(Wp(Z!bOY%ZYZ&cZr%Zrs&}sw%Zwx(rx!^%Z!^!_*g!_#O%Z#O#P&c#P#o%Z#o#p*g#p;'S%Z;'S;=`+a<%lO%Z07[$Aq|$i&j(Wp(Z!b'|0/l$]#t(T,2j(e$I[OX%ZXY+gYZ&cZ[+g[p%Zpq+gqr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$f%Z$f$g+g$g#BYEr#BY#BZ$A`#BZ$ISEr$IS$I_$A`$I_$JTEr$JT$JU$A`$JU$KVEr$KV$KW$A`$KW&FUEr&FU&FV$A`&FV;'SEr;'S;=`I|<%l?HTEr?HT?HU$A`?HUOEr07[$D|k$i&j(Wp(Z!b'}0/l$]#t(T,2j(e$I[OY%ZYZ&cZr%Zrs&}st%ZtuEruw%Zwx(rx}%Z}!OGv!O!Q%Z!Q![Er![!^%Z!^!_*g!_!c%Z!c!}Er!}#O%Z#O#P&c#P#R%Z#R#SEr#S#T%Z#T#oEr#o#p*g#p$g%Z$g;'SEr;'S;=`I|<%lOEr",tokenizers:[kce,Cce,_ce,$ce,2,3,4,5,6,7,8,9,10,11,12,13,14,wce,new Wm("$S~RRtu[#O#Pg#S#T#|~_P#o#pb~gOx~~jVO#i!P#i#j!U#j#l!P#l#m!q#m;'S!P;'S;=`#v<%lO!P~!UO!U~~!XS!Q![!e!c!i!e#T#Z!e#o#p#Z~!hR!Q![!q!c!i!q#T#Z!q~!tR!Q![!}!c!i!}#T#Z!}~#QR!Q![!P!c!i!P#T#Z!P~#^R!Q![#g!c!i#g#T#Z#g~#jS!Q![#g!c!i#g#T#Z#g#q#r!P~#yP;=`<%l!P~$RO(c~~",141,340),new Wm("j~RQYZXz{^~^O(Q~~aP!P!Qd~iO(R~~",25,323)],topRules:{Script:[0,7],SingleExpression:[1,276],SingleClassItem:[2,277]},dialects:{jsx:0,ts:15175},dynamicPrecedences:{80:1,82:1,94:1,169:1,199:1},specialized:[{term:327,get:t=>Ece[t]||-1},{term:343,get:t=>Rce[t]||-1},{term:95,get:t=>Qce[t]||-1}],tokenPrec:15201}),wL=[zi("function ${name}(${params}) {\n ${}\n}",{label:"function",detail:"definition",type:"keyword"}),zi("for (let ${index} = 0; ${index} < ${bound}; ${index}++) {\n ${}\n}",{label:"for",detail:"loop",type:"keyword"}),zi("for (let ${name} of ${collection}) {\n ${}\n}",{label:"for",detail:"of loop",type:"keyword"}),zi("do {\n ${}\n} while (${})",{label:"do",detail:"loop",type:"keyword"}),zi("while (${}) {\n ${}\n}",{label:"while",detail:"loop",type:"keyword"}),zi(`try { + \${} +} catch (\${error}) { + \${} +}`,{label:"try",detail:"/ catch block",type:"keyword"}),zi("if (${}) {\n ${}\n}",{label:"if",detail:"block",type:"keyword"}),zi(`if (\${}) { + \${} +} else { + \${} +}`,{label:"if",detail:"/ else block",type:"keyword"}),zi(`class \${name} { + constructor(\${params}) { + \${} + } +}`,{label:"class",detail:"definition",type:"keyword"}),zi('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),zi('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],Pce=wL.concat([zi("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),zi("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),zi("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),ZQ=new Uz,kL=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function sf(t){return(e,n)=>{let i=e.node.getChild("VariableDefinition");return i&&n(i,t),!0}}const jce=["FunctionDeclaration"],Mce={FunctionDeclaration:sf("function"),ClassDeclaration:sf("class"),ClassExpression:()=>!0,EnumDeclaration:sf("constant"),TypeAliasDeclaration:sf("type"),NamespaceDeclaration:sf("namespace"),VariableDefinition(t,e){t.matchContext(jce)||e(t,"variable")},TypeDefinition(t,e){e(t,"type")},__proto__:null};function CL(t,e){let n=ZQ.get(e);if(n)return n;let i=[],r=!0;function s(o,l){let u=t.sliceString(o.from,o.to);i.push({label:u,type:l})}return e.cursor($t.IncludeAnonymous).iterate(o=>{if(r)r=!1;else if(o.name){let l=Mce[o.name];if(l&&l(o,s)||kL.has(o.name))return!1}else if(o.to-o.from>8192){for(let l of CL(t,o.node))i.push(l);return!1}}),ZQ.set(e,i),i}const IQ=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,_L=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function Dce(t){let e=hn(t.state).resolveInner(t.pos,-1);if(_L.indexOf(e.name)>-1)return null;let n=e.name=="VariableName"||e.to-e.from<20&&IQ.test(t.state.sliceDoc(e.from,e.to));if(!n&&!t.explicit)return null;let i=[];for(let r=e;r;r=r.parent)kL.has(r.name)&&(i=i.concat(CL(t.state.doc,r)));return{options:i,from:n?e.from:t.pos,validFor:IQ}}const Ms=$u.define({name:"javascript",parser:Ace.configure({props:[Eh.add({IfStatement:tm({except:/^\s*({|else\b)/}),TryStatement:tm({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:fse,SwitchBody:t=>{let e=t.textAfter,n=/^\s*\}/.test(e),i=/^\s*(case|default)\b/.test(e);return t.baseIndent+(n?0:i?1:2)*t.unit},Block:dse({closing:"}"}),ArrowFunction:t=>t.baseIndent+t.unit,"TemplateString BlockComment":()=>null,"Statement Property":tm({except:/^\s*{/}),JSXElement(t){let e=/^\s*<\//.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},JSXEscape(t){let e=/\s*\}/.test(t.textAfter);return t.lineIndent(t.node.from)+(e?0:t.unit)},"JSXOpenTag JSXSelfClosingTag"(t){return t.column(t.node.from)+t.unit}}),Rh.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":Jz,BlockComment(t){return{from:t.from+2,to:t.to-2}},JSXElement(t){let e=t.firstChild;if(!e||e.name=="JSXSelfClosingTag")return null;let n=t.lastChild;return{from:e.to,to:n.type.isError?t.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(t){var e;let n=(e=t.firstChild)===null||e===void 0?void 0:e.nextSibling,i=t.lastChild;return!n||n.type.isError?null:{from:n.to,to:i.type.isError?t.to:i.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),$L={test:t=>/^JSX/.test(t.name),facet:J1({commentTokens:{block:{open:"{/*",close:"*/}"}}})},TL=Ms.configure({dialect:"ts"},"typescript"),EL=Ms.configure({dialect:"jsx",props:[ek.add(t=>t.isTop?[$L]:void 0)]}),RL=Ms.configure({dialect:"jsx ts",props:[ek.add(t=>t.isTop?[$L]:void 0)]},"typescript");let QL=t=>({label:t,type:"keyword"});const AL="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(QL),Nce=AL.concat(["declare","implements","private","protected","public"].map(QL));function zce(t={}){let e=t.jsx?t.typescript?RL:EL:t.typescript?TL:Ms,n=t.typescript?Pce.concat(Nce):wL.concat(AL);return new Yf(e,[Ms.data.of({autocomplete:Ioe(_L,Zoe(n))}),Ms.data.of({autocomplete:Dce}),t.jsx?Ice:[]])}function Lce(t){for(;;){if(t.name=="JSXOpenTag"||t.name=="JSXSelfClosingTag"||t.name=="JSXFragmentTag")return t;if(t.name=="JSXEscape"||!t.parent)return null;t=t.parent}}function XQ(t,e,n=t.length){for(let i=e?.firstChild;i;i=i.nextSibling)if(i.name=="JSXIdentifier"||i.name=="JSXBuiltin"||i.name=="JSXNamespacedName"||i.name=="JSXMemberExpression")return t.sliceString(i.from,Math.min(i.to,n));return""}const Zce=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Ice=Ze.inputHandler.of((t,e,n,i,r)=>{if((Zce?t.composing:t.compositionStarted)||t.state.readOnly||e!=n||i!=">"&&i!="/"||!Ms.isActiveAt(t.state,e,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(u=>{var f;let{head:h}=u,p=hn(o).resolveInner(h-1,-1),O;if(p.name=="JSXStartTag"&&(p=p.parent),!(o.doc.sliceString(h-1,h)!=i||p.name=="JSXAttributeValue"&&p.to>h)){if(i==">"&&p.name=="JSXFragmentTag")return{range:u,changes:{from:h,insert:""}};if(i=="/"&&p.name=="JSXStartCloseTag"){let y=p.parent,v=y.parent;if(v&&y.from==h-2&&((O=XQ(o.doc,v.firstChild,h))||((f=v.firstChild)===null||f===void 0?void 0:f.name)=="JSXFragmentTag")){let S=`${O}>`;return{range:Oe.cursor(h+S.length,-1),changes:{from:h,insert:S}}}}else if(i==">"){let y=Lce(p);if(y&&y.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(o.doc.sliceString(h,h+2))&&(O=XQ(o.doc,y,h)))return{range:u,changes:{from:h,insert:``}}}}return{range:u}});return l.changes.empty?!1:(t.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),of=["_blank","_self","_top","_parent"],Fb=["ascii","utf-8","utf-16","latin1","latin1"],Gb=["get","post","put","delete"],Hb=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],ir=["true","false"],ze={},Xce={a:{attrs:{href:null,ping:null,type:null,media:null,target:of,hreflang:null}},abbr:ze,address:ze,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:ze,aside:ze,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:ze,base:{attrs:{href:null,target:of}},bdi:ze,bdo:ze,blockquote:{attrs:{cite:null}},body:ze,br:ze,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:Hb,formmethod:Gb,formnovalidate:["novalidate"],formtarget:of,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:ze,center:ze,cite:ze,code:ze,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:ze,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:ze,div:ze,dl:ze,dt:ze,em:ze,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:ze,figure:ze,footer:ze,form:{attrs:{action:null,name:null,"accept-charset":Fb,autocomplete:["on","off"],enctype:Hb,method:Gb,novalidate:["novalidate"],target:of}},h1:ze,h2:ze,h3:ze,h4:ze,h5:ze,h6:ze,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:ze,hgroup:ze,hr:ze,html:{attrs:{manifest:null}},i:ze,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:Hb,formmethod:Gb,formnovalidate:["novalidate"],formtarget:of,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:ze,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:ze,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:ze,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:Fb,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:ze,noscript:ze,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:ze,param:{attrs:{name:null,value:null}},pre:ze,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:ze,rt:ze,ruby:ze,samp:ze,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:Fb}},section:ze,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:ze,source:{attrs:{src:null,type:null,media:null}},span:ze,strong:ze,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:ze,summary:ze,sup:ze,table:ze,tbody:ze,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:ze,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:ze,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:ze,time:{attrs:{datetime:null}},title:ze,tr:ze,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:ze,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:ze},PL={accesskey:null,class:null,contenteditable:ir,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:ir,autocorrect:ir,autocapitalize:ir,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":ir,"aria-autocomplete":["inline","list","both","none"],"aria-busy":ir,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":ir,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":ir,"aria-hidden":ir,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":ir,"aria-multiselectable":ir,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":ir,"aria-relevant":null,"aria-required":ir,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},jL="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(t=>"on"+t);for(let t of jL)PL[t]=null;let Kf=class{constructor(e,n){this.tags={...Xce,...e},this.globalAttrs={...PL,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};Kf.default=new Kf;function Il(t,e,n=t.length){if(!e)return"";let i=e.firstChild,r=i&&i.getChild("TagName");return r?t.sliceString(r.from,Math.min(r.to,n)):""}function Au(t,e=!1){for(;t;t=t.parent)if(t.name=="Element")if(e)e=!1;else return t;return null}function ML(t,e,n){let i=n.tags[Il(t,Au(e))];return i?.children||n.allTags}function mk(t,e){let n=[];for(let i=Au(e);i&&!i.type.isTop;i=Au(i.parent)){let r=Il(t,i);if(r&&i.lastChild.name=="CloseTag")break;r&&n.indexOf(r)<0&&(e.name=="EndTag"||e.from>=i.firstChild.to)&&n.push(r)}return n}const DL=/^[:\-\.\w\u00b7-\uffff]*$/;function VQ(t,e,n,i,r){let s=/\s*>/.test(t.sliceDoc(r,r+5))?"":">",o=Au(n,n.name=="StartTag"||n.name=="TagName");return{from:i,to:r,options:ML(t.doc,o,e).map(l=>({label:l,type:"type"})).concat(mk(t.doc,n).map((l,u)=>({label:"/"+l,apply:"/"+l+s,type:"type",boost:99-u}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function BQ(t,e,n,i){let r=/\s*>/.test(t.sliceDoc(i,i+5))?"":">";return{from:n,to:i,options:mk(t.doc,e).map((s,o)=>({label:s,apply:s+r,type:"type",boost:99-o})),validFor:DL}}function Vce(t,e,n,i){let r=[],s=0;for(let o of ML(t.doc,n,e))r.push({label:"<"+o,type:"type"});for(let o of mk(t.doc,n))r.push({label:"",type:"type",boost:99-s++});return{from:i,to:i,options:r,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function Bce(t,e,n,i,r){let s=Au(n),o=s?e.tags[Il(t.doc,s)]:null,l=o&&o.attrs?Object.keys(o.attrs):[],u=o&&o.globalAttrs===!1?l:l.length?l.concat(e.globalAttrNames):e.globalAttrNames;return{from:i,to:r,options:u.map(f=>({label:f,type:"property"})),validFor:DL}}function Uce(t,e,n,i,r){var s;let o=(s=n.parent)===null||s===void 0?void 0:s.getChild("AttributeName"),l=[],u;if(o){let f=t.sliceDoc(o.from,o.to),h=e.globalAttrs[f];if(!h){let p=Au(n),O=p?e.tags[Il(t.doc,p)]:null;h=O?.attrs&&O.attrs[f]}if(h){let p=t.sliceDoc(i,r).toLowerCase(),O='"',y='"';/^['"]/.test(p)?(u=p[0]=='"'?/^[^"]*$/:/^[^']*$/,O="",y=t.sliceDoc(r,r+1)==p[0]?"":p[0],p=p.slice(1),i++):u=/^[^\s<>='"]*$/;for(let v of h)l.push({label:v,apply:O+v+y,type:"constant"})}}return{from:i,to:r,options:l,validFor:u}}function NL(t,e){let{state:n,pos:i}=e,r=hn(n).resolveInner(i,-1),s=r.resolve(i);for(let o=i,l;s==r&&(l=r.childBefore(o));){let u=l.lastChild;if(!u||!u.type.isError||u.fromNL(i,r)}const Fce=Ms.parser.configure({top:"SingleExpression"}),zL=[{tag:"script",attrs:t=>t.type=="text/typescript"||t.lang=="ts",parser:TL.parser},{tag:"script",attrs:t=>t.type=="text/babel"||t.type=="text/jsx",parser:EL.parser},{tag:"script",attrs:t=>t.type=="text/typescript-jsx",parser:RL.parser},{tag:"script",attrs(t){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(t.type)},parser:Fce},{tag:"script",attrs(t){return!t.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(t.type)},parser:Ms.parser},{tag:"style",attrs(t){return(!t.lang||t.lang=="css")&&(!t.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(t.type))},parser:Jm.parser}],LL=[{name:"style",parser:Jm.parser.configure({top:"Styles"})}].concat(jL.map(t=>({name:t,parser:Ms.parser}))),ZL=$u.define({name:"html",parser:vle.configure({props:[Eh.add({Element(t){let e=/^(\s*)(<\/)?/.exec(t.textAfter);return t.node.to<=t.pos+e[0].length?t.continue():t.lineIndent(t.node.from)+(e[2]?0:t.unit)},"OpenTag CloseTag SelfClosingTag"(t){return t.column(t.node.from)+t.unit},Document(t){if(t.pos+/\s*/.exec(t.textAfter)[0].lengtht.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:""}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),rm=ZL.configure({wrap:mL(zL,LL)});function Gce(t={}){let e="",n;t.matchClosingTags===!1&&(e="noMatch"),t.selfClosingTags===!0&&(e=(e?e+" ":"")+"selfClosing"),(t.nestedLanguages&&t.nestedLanguages.length||t.nestedAttributes&&t.nestedAttributes.length)&&(n=mL((t.nestedLanguages||[]).concat(zL),(t.nestedAttributes||[]).concat(LL)));let i=n?ZL.configure({wrap:n,dialect:e}):e?rm.configure({dialect:e}):rm;return new Yf(i,[rm.data.of({autocomplete:Yce(t)}),t.autoCloseTags!==!1?Wce:[],zce().support,tce().support])}const UQ=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" "));function Hce(t,e,n){for(var i;;){if(((i=e.lastChild)===null||i===void 0?void 0:i.name)!="CloseTag")return!1;let r=e.parent;if(!r||Il(t,r)!=n)return!0;e=r}}const Wce=Ze.inputHandler.of((t,e,n,i,r)=>{if(t.composing||t.state.readOnly||e!=n||i!=">"&&i!="/"||!rm.isActiveAt(t.state,e,-1))return!1;let s=r(),{state:o}=s,l=o.changeByRange(u=>{var f;let h=o.doc.sliceString(u.from-1,u.to)==i,{head:p}=u,O=hn(o).resolveInner(p,-1),y;if(h&&i==">"&&O.name=="EndTag"){let v=O.parent;if((y=Il(o.doc,v.parent,p))&&!UQ.has(y)&&!Hce(o.doc,v.parent,y)){let S=p+(o.doc.sliceString(p,p+1)===">"?1:0),k=``;return{range:u,changes:{from:p,to:S,insert:k}}}}else if(h&&i=="/"&&O.name=="IncompleteCloseTag"){let v=O.parent;if(O.from==p-2&&((f=v.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(y=Il(o.doc,v,p))&&!UQ.has(y)){let S=p+(o.doc.sliceString(p,p+1)===">"?1:0),k=`${y}>`;return{range:Oe.cursor(p+k.length,-1),changes:{from:p,to:S,insert:k}}}}return{range:u}});return l.changes.empty?!1:(t.dispatch([s,o.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),IL=J1({commentTokens:{block:{open:""}}}),XL=new He,VL=hae.configure({props:[Rh.add(t=>!t.is("Block")||t.is("Document")||Kx(t)!=null||Kce(t)?void 0:(e,n)=>({from:n.doc.lineAt(e.from).to,to:e.to})),XL.add(Kx),Eh.add({Document:()=>null}),xl.add({Document:IL})]});function Kx(t){let e=/^(?:ATX|Setext)Heading(\d)$/.exec(t.name);return e?+e[1]:void 0}function Kce(t){return t.name=="OrderedList"||t.name=="BulletList"}function Jce(t,e){let n=t;for(;;){let i=n.nextSibling,r;if(!i||(r=Kx(i.type))!=null&&r<=e)break;n=i}return n.to}const eue=hse.of((t,e,n)=>{for(let i=hn(t).resolveInner(n,-1);i&&!(i.fromn)return{from:n,to:s}}return null});function Ok(t){return new Ar(IL,t,[],"markdown")}const tue=Ok(VL),nue=VL.configure([kae,_ae,Cae,$ae,{props:[Rh.add({Table:(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}]),eO=Ok(nue);function iue(t,e){return n=>{if(n&&t){let i=null;if(n=/\S*/.exec(n)[0],typeof t=="function"?i=t(n):i=Vm.matchLanguageName(t,n,!0),i instanceof Vm)return i.support?i.support.language.parser:qf.getSkippingParser(i.load());if(i)return i.parser}return e?e.parser:null}}class Wb{constructor(e,n,i,r,s,o,l){this.node=e,this.from=n,this.to=i,this.spaceBefore=r,this.spaceAfter=s,this.type=o,this.item=l}blank(e,n=!0){let i=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(e!=null){for(;i.length0;r--)i+=" ";return i+(n?this.spaceAfter:"")}}marker(e,n){let i=this.node.name=="OrderedList"?String(+UL(this.item,e)[2]+n):"";return this.spaceBefore+i+this.type+this.spaceAfter}}function BL(t,e){let n=[],i=[];for(let r=t;r;r=r.parent){if(r.name=="FencedCode")return i;(r.name=="ListItem"||r.name=="Blockquote")&&n.push(r)}for(let r=n.length-1;r>=0;r--){let s=n[r],o,l=e.lineAt(s.from),u=s.from-l.from;if(s.name=="Blockquote"&&(o=/^ *>( ?)/.exec(l.text.slice(u))))i.push(new Wb(s,u,u+o[0].length,"",o[1],">",null));else if(s.name=="ListItem"&&s.parent.name=="OrderedList"&&(o=/^( *)\d+([.)])( *)/.exec(l.text.slice(u)))){let f=o[3],h=o[0].length;f.length>=4&&(f=f.slice(0,f.length-4),h-=4),i.push(new Wb(s.parent,u,u+h,o[1],f,o[2],s))}else if(s.name=="ListItem"&&s.parent.name=="BulletList"&&(o=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(u)))){let f=o[4],h=o[0].length;f.length>4&&(f=f.slice(0,f.length-4),h-=4);let p=o[2];o[3]&&(p+=o[3].replace(/[xX]/," ")),i.push(new Wb(s.parent,u,u+h,o[1],f,p,s))}}return i}function UL(t,e){return/^(\s*)(\d+)(?=[.)])/.exec(e.sliceString(t.from,t.from+10))}function Kb(t,e,n,i=0){for(let r=-1,s=t;;){if(s.name=="ListItem"){let l=UL(s,e),u=+l[2];if(r>=0){if(u!=r+1)return;n.push({from:s.from+l[1].length,to:s.from+l[0].length,insert:String(r+2+i)})}r=u}let o=s.nextSibling;if(!o)break;s=o}}function yk(t,e){let n=/^[ \t]*/.exec(t)[0].length;if(!n||e.facet(Th)!=" ")return t;let i=To(t,4,n),r="";for(let s=i;s>0;)s>=4?(r+=" ",s-=4):(r+=" ",s--);return r+t.slice(n)}const rue=(t={})=>({state:e,dispatch:n})=>{let i=hn(e),{doc:r}=e,s=null,o=e.changeByRange(l=>{if(!l.empty||!eO.isActiveAt(e,l.from,-1)&&!eO.isActiveAt(e,l.from,1))return s={range:l};let u=l.from,f=r.lineAt(u),h=BL(i.resolveInner(u,-1),r);for(;h.length&&h[h.length-1].from>u-f.from;)h.pop();if(!h.length)return s={range:l};let p=h[h.length-1];if(p.to-p.spaceAfter.length>u-f.from)return s={range:l};let O=u>=p.to-p.spaceAfter.length&&!/\S/.test(f.text.slice(p.to));if(p.item&&O){if(p.item.from]*$/.test(f.text.slice(0,p.to)))return s={range:l};let C=p.node.firstChild,$=p.node.getChild("ListItem","ListItem");if(C.to>=u||$&&$.to0&&!/[^\s>]/.test(r.lineAt(f.from-1).text)||t.nonTightLists===!1){let T=h.length>1?h[h.length-2]:null,Q,A="";T&&T.item?(Q=f.from+T.from,A=T.marker(r,1)):Q=f.from+(T?T.to:0);let R=[{from:Q,to:u,insert:A}];return p.node.name=="OrderedList"&&Kb(p.item,r,R,-2),T&&T.node.name=="OrderedList"&&Kb(T.item,r,R),{range:Oe.cursor(Q+A.length),changes:R}}else{let T=YQ(h,e,f);return{range:Oe.cursor(u+T.length+1),changes:{from:f.from,insert:T+e.lineBreak}}}}if(p.node.name=="Blockquote"&&O&&f.from){let C=r.lineAt(f.from-1),$=/>\s*$/.exec(C.text);if($&&$.index==p.from){let T=e.changes([{from:C.from+$.index,to:C.to},{from:f.from+p.from,to:f.to}]);return{range:l.map(T),changes:T}}}let y=[];p.node.name=="OrderedList"&&Kb(p.item,r,y);let v=p.item&&p.item.from]*/.exec(f.text)[0].length>=p.to)for(let C=0,$=h.length-1;C<=$;C++)S+=C==$&&!v?h[C].marker(r,1):h[C].blank(C<$?To(f.text,4,h[C+1].from)-S.length:null);let k=u;for(;k>f.from&&/\s/.test(f.text.charAt(k-f.from-1));)k--;return S=yk(S,e),oue(p.node,e.doc)&&(S=YQ(h,e,f)+e.lineBreak+S),y.push({from:k,to:u,insert:e.lineBreak+S}),{range:Oe.cursor(k+S.length+1),changes:y}});return s?!1:(n(e.update(o,{scrollIntoView:!0,userEvent:"input"})),!0)},sue=rue();function qQ(t){return t.name=="QuoteMark"||t.name=="ListMark"}function oue(t,e){if(t.name!="OrderedList"&&t.name!="BulletList")return!1;let n=t.firstChild,i=t.getChild("ListItem","ListItem");if(!i)return!1;let r=e.lineAt(n.to),s=e.lineAt(i.from),o=/^[\s>]*$/.test(r.text);return r.number+(o?0:1){let n=hn(t),i=null,r=t.changeByRange(s=>{let o=s.from,{doc:l}=t;if(s.empty&&eO.isActiveAt(t,s.from)){let u=l.lineAt(o),f=BL(aue(n,o),l);if(f.length){let h=f[f.length-1],p=h.to-h.spaceAfter.length+(h.spaceAfter?1:0);if(o-u.from>p&&!/\S/.test(u.text.slice(p,o-u.from)))return{range:Oe.cursor(u.from+p),changes:{from:u.from+p,to:o}};if(o-u.from==p&&(h.item&&u.from<=h.item.from||/^[\s>]*$/.test(u.text.slice(0,h.to)))){let O=u.from+h.from;if(h.item&&h.node.from{var n;let{main:i}=e.state.selection;if(i.empty)return!1;let r=(n=t.clipboardData)===null||n===void 0?void 0:n.getData("text/plain");if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r="https://"+r),!eO.isActiveAt(e.state,i.from,1)))return!1;let s=hn(e.state),o=!1;return s.iterate({from:i.from,to:i.to,enter:l=>{(l.from>i.from||hue.test(l.name))&&(o=!0)},leave:l=>{l.tonew Map,Jx=t=>{const e=qi();return t.forEach((n,i)=>{e.set(i,n)}),e},Vs=(t,e,n)=>{let i=t.get(e);return i===void 0&&t.set(e,i=n()),i},gue=(t,e)=>{const n=[];for(const[i,r]of t)n.push(e(r,i));return n},mue=(t,e)=>{for(const[n,i]of t)if(e(i,n))return!0;return!1},Aa=()=>new Set,eS=t=>t[t.length-1],Oue=(t,e)=>{for(let n=0;n{for(let n=0;n{for(let n=0;n{const n=new Array(t);for(let i=0;i{this.off(e,i),n(...r)};this.on(e,i)}off(e,n){const i=this._observers.get(e);i!==void 0&&(i.delete(n),i.size===0&&this._observers.delete(e))}emit(e,n){return Ro((this._observers.get(e)||qi()).values()).forEach(i=>i(...n))}destroy(){this._observers=qi()}}class vue{constructor(){this._observers=qi()}on(e,n){Vs(this._observers,e,Aa).add(n)}once(e,n){const i=(...r)=>{this.off(e,i),n(...r)};this.on(e,i)}off(e,n){const i=this._observers.get(e);i!==void 0&&(i.delete(n),i.size===0&&this._observers.delete(e))}emit(e,n){return Ro((this._observers.get(e)||qi()).values()).forEach(i=>i(...n))}destroy(){this._observers=qi()}}const ns=Math.floor,sm=Math.abs,dy=(t,e)=>tt>e?t:e,bue=Math.pow,YL=t=>t!==0?t<0:1/t<0,FQ=1,GQ=2,tS=4,nS=8,Jf=32,_o=64,cr=128,fy=31,ew=63,$l=127,Sue=2147483647,tO=Number.MAX_SAFE_INTEGER,HQ=Number.MIN_SAFE_INTEGER,xue=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&ns(t)===t),FL=String.fromCharCode,wue=t=>t.toLowerCase(),kue=/^\s*/g,Cue=t=>t.replace(kue,""),_ue=/([A-Z])/g,WQ=(t,e)=>Cue(t.replace(_ue,n=>`${e}${wue(n)}`)),$ue=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,i=new Uint8Array(n);for(let r=0;reh.encode(t),Eue=eh?Tue:$ue;let _f=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});_f&&_f.decode(new Uint8Array).length===1&&(_f=null);const Rue=(t,e)=>yue(e,()=>t).join("");class Ph{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const ci=()=>new Ph,xk=t=>{let e=t.cpos;for(let n=0;n{const e=new Uint8Array(xk(t));let n=0;for(let i=0;i{const n=t.cbuf.length;n-t.cpos{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},tw=In,Be=(t,e)=>{for(;e>$l;)In(t,cr|$l&e),e=ns(e/128);In(t,$l&e)},wk=(t,e)=>{const n=YL(e);for(n&&(e=-e),In(t,(e>ew?cr:0)|(n?_o:0)|ew&e),e=ns(e/64);e>0;)In(t,(e>$l?cr:0)|$l&e),e=ns(e/128)},nw=new Uint8Array(3e4),Aue=nw.length/3,Pue=(t,e)=>{if(e.length{const n=unescape(encodeURIComponent(e)),i=n.length;Be(t,i);for(let r=0;r{const n=t.cbuf.length,i=t.cpos,r=dy(n-i,e.length),s=e.length-r;t.cbuf.set(e.subarray(0,r),i),t.cpos+=r,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Ba(n*2,s)),t.cbuf.set(e.subarray(r)),t.cpos=s)},yn=(t,e)=>{Be(t,e.byteLength),hy(t,e)},kk=(t,e)=>{Que(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},Mue=(t,e)=>kk(t,4).setFloat32(0,e,!1),Due=(t,e)=>kk(t,8).setFloat64(0,e,!1),Nue=(t,e)=>kk(t,8).setBigInt64(0,e,!1),KQ=new DataView(new ArrayBuffer(4)),zue=t=>(KQ.setFloat32(0,t),KQ.getFloat32(0)===t),th=(t,e)=>{switch(typeof e){case"string":In(t,119),Tl(t,e);break;case"number":xue(e)&&sm(e)<=Sue?(In(t,125),wk(t,e)):zue(e)?(In(t,124),Mue(t,e)):(In(t,123),Due(t,e));break;case"bigint":In(t,122),Nue(t,e);break;case"object":if(e===null)In(t,126);else if(Pu(e)){In(t,117),Be(t,e.length);for(let n=0;n0&&Be(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const eA=t=>{t.count>0&&(wk(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Be(t.encoder,t.count-2))};class om{constructor(){this.encoder=new Ph,this.s=0,this.count=0}write(e){this.s===e?this.count++:(eA(this),this.count=1,this.s=e)}toUint8Array(){return eA(this),tn(this.encoder)}}const tA=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);wk(t.encoder,e),t.count>1&&Be(t.encoder,t.count-2)}};class iS{constructor(){this.encoder=new Ph,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(tA(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return tA(this),tn(this.encoder)}}class Lue{constructor(){this.sarr=[],this.s="",this.lensE=new om}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Ph;return this.sarr.push(this.s),this.s="",Tl(e,this.sarr.join("")),hy(e,this.lensE.toUint8Array()),tn(e)}}const Ls=t=>new Error(t),es=()=>{throw Ls("Method unimplemented")},dr=()=>{throw Ls("Unexpected case")},GL=Ls("Unexpected end of array"),HL=Ls("Integer out of Range");class py{constructor(e){this.arr=e,this.pos=0}}const Ua=t=>new py(t),Zue=t=>t.pos!==t.arr.length,Iue=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},li=t=>Iue(t,et(t)),ju=t=>t.arr[t.pos++],et=t=>{let e=0,n=1;const i=t.arr.length;for(;t.postO)throw HL}throw GL},Ck=t=>{let e=t.arr[t.pos++],n=e&ew,i=64;const r=(e&_o)>0?-1:1;if((e&cr)===0)return r*n;const s=t.arr.length;for(;t.postO)throw HL}throw GL},Xue=t=>{let e=et(t);if(e===0)return"";{let n=String.fromCodePoint(ju(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(ju(t));else for(;e>0;){const i=e<1e4?e:1e4,r=t.arr.subarray(t.pos,t.pos+i);t.pos+=i,n+=String.fromCodePoint.apply(null,r),e-=i}return decodeURIComponent(escape(n))}},Vue=t=>_f.decode(li(t)),xa=_f?Vue:Xue,_k=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Bue=t=>_k(t,4).getFloat32(0,!1),Uue=t=>_k(t,8).getFloat64(0,!1),que=t=>_k(t,8).getBigInt64(0,!1),Yue=[t=>{},t=>null,Ck,Bue,Uue,que,t=>!1,t=>!0,xa,t=>{const e=et(t),n={};for(let i=0;i{const e=et(t),n=[];for(let i=0;iYue[127-ju(t)](t);class nA extends py{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Zue(this)?this.count=et(this)+1:this.count=-1),this.count--,this.s}}class am extends py{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ck(this);const e=YL(this.s);this.count=1,e&&(this.s=-this.s,this.count=et(this)+2)}return this.count--,this.s}}class rS extends py{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Ck(this),n=e&1;this.diff=ns(e/2),this.count=1,n&&(this.count=et(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Fue{constructor(e){this.decoder=new am(e),this.str=xa(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const Gue=crypto.getRandomValues.bind(crypto),WL=()=>Gue(new Uint32Array(1))[0],Hue="10000000-1000-4000-8000"+-1e11,Wue=()=>Hue.replace(/[018]/g,t=>(t^WL()&15>>t/4).toString(16)),Pa=Date.now,iA=t=>new Promise(t);Promise.all.bind(Promise);const rA=t=>t===void 0?null:t;class Kue{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let KL=new Kue,$k=!0;try{typeof localStorage<"u"&&localStorage&&(KL=localStorage,$k=!1)}catch{}const JL=KL,Jue=t=>$k||addEventListener("storage",t),ede=t=>$k||removeEventListener("storage",t),ih=Symbol("Equality"),e3=(t,e)=>t===e||!!t?.[ih]?.(e)||!1,tde=t=>typeof t=="object",nde=Object.assign,ide=Object.keys,rde=(t,e)=>{for(const n in t)e(t[n],n)},sde=(t,e)=>{const n=[];for(const i in t)n.push(e(t[i],i));return n},nO=t=>ide(t).length,ode=t=>{for(const e in t)return!1;return!0},jh=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Tk=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),ade=(t,e)=>t===e||nO(t)===nO(e)&&jh(t,(n,i)=>(n!==void 0||Tk(e,i))&&e3(e[i],n)),lde=Object.freeze,t3=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&t3(t[e])}return lde(t)},Ek=(t,e,n=0)=>{try{for(;nt,fu=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[ih]!=null)return t[ih](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;ne.includes(t);var n3={};const ja=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",i3=typeof window<"u"&&typeof document<"u"&&!ja;let ys;const dde=()=>{if(ys===void 0)if(ja){ys=qi();const t=process.argv;let e=null;for(let n=0;n{if(t.length!==0){const[e,n]=t.split("=");ys.set(`--${WQ(e,"-")}`,n),ys.set(`-${WQ(e,"-")}`,n)}})):ys=qi();return ys},iw=t=>dde().has(t),iO=t=>rA(ja?n3[t.toUpperCase().replaceAll("-","_")]:JL.getItem(t)),r3=t=>iw("--"+t)||iO(t)!==null,fde=r3("production"),hde=ja&&ude(n3.FORCE_COLOR,["true","1","2"]),pde=hde||!iw("--no-colors")&&!r3("no-color")&&(!ja||process.stdout.isTTY)&&(!ja||iw("--color")||iO("COLORTERM")!==null||(iO("TERM")||"").includes("color")),s3=t=>new Uint8Array(t),gde=(t,e,n)=>new Uint8Array(t,e,n),mde=t=>new Uint8Array(t),Ode=t=>{let e="";for(let n=0;nBuffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),vde=t=>{const e=atob(t),n=s3(e.length);for(let i=0;i{const e=Buffer.from(t,"base64");return gde(e.buffer,e.byteOffset,e.byteLength)},Sde=i3?Ode:yde,xde=i3?vde:bde,wde=t=>{const e=s3(t.byteLength);return e.set(t),e};class kde{constructor(e,n){this.left=e,this.right=n}}const rr=(t,e)=>new kde(t,e),Cde=(t,e)=>t.forEach(n=>e(n.left,n.right)),sA=t=>t.next()>=.5,sS=(t,e,n)=>ns(t.next()*(n+1-e)+e),o3=(t,e,n)=>ns(t.next()*(n+1-e)+e),Rk=(t,e,n)=>o3(t,e,n),_de=t=>FL(Rk(t,97,122)),$de=(t,e=0,n=20)=>{const i=Rk(t,e,n);let r="";for(let s=0;se[Rk(t,0,e.length-1)],Tde=Symbol("0schema");class Ede{constructor(){this._rerrs=[]}extend(e,n,i,r=null){this._rerrs.push({path:e,expected:n,has:i,message:r})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const i=this._rerrs[n];e.push(Rue(" ",(this._rerrs.length-n)*2)+`${i.path!=null?`[${i.path}] `:""}${i.has} doesn't match ${i.expected}. ${i.message}`)}return e.join(` +`)}}const rw=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[ih]?e3(t,e):Pu(t)?vk(t,n=>bk(e,i=>rw(n,i))):tde(t)?jh(t,(n,i)=>rw(n,e[i])):!1;class Ei{static _dilutes=!1;extends(e){let[n,i]=[this.shape,e.shape];return this.constructor._dilutes&&([i,n]=[n,i]),rw(n,i)}equals(e){return this.constructor===e.constructor&&fu(this.shape,e.shape)}[Tde](){return!0}[ih](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){es()}get nullable(){return Hu(this,vy)}get optional(){return new c3(this)}cast(e){return oA(e,this),e}expect(e){return oA(e,this),e}}class Qk extends Ei{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const i=e?.constructor===this.shape&&(this._c==null||this._c(e));return!i&&n?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),i}}const En=(t,e=null)=>new Qk(t,e);En(Qk);class Ak extends Ei{constructor(e){super(),this.shape=e}check(e,n){const i=this.shape(e);return!i&&n?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),i}}const Bn=t=>new Ak(t);En(Ak);class gy extends Ei{constructor(e){super(),this.shape=e}check(e,n){const i=this.shape.some(r=>r===e);return!i&&n?.extend(null,this.shape.join(" | "),e.toString()),i}}const my=(...t)=>new gy(t),a3=En(gy),Rde=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),l3=t=>{if(Mu.check(t))return[Rde(t)];if(a3.check(t))return t.shape.map(e=>e+"");if(y3.check(t))return["[+-]?\\d+.?\\d*"];if(v3.check(t))return[".*"];if(rO.check(t))return t.shape.map(l3).flat(1);dr()};class Qde extends Ei{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(l3).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const i=this._r.exec(e)!=null;return!i&&n?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),i}}En(Qde);const Ade=Symbol("optional");class c3 extends Ei{constructor(e){super(),this.shape=e}check(e,n){const i=e===void 0||this.shape.check(e);return!i&&n?.extend(null,"undefined (optional)","()"),i}get[Ade](){return!0}}const Pde=En(c3);class jde extends Ei{check(e,n){return n?.extend(null,"never",typeof e),!1}}En(jde);class Oy extends Ei{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}static _dilutes=!0;get partial(){return new Oy(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):jh(this.shape,(i,r)=>{const s=this._isPartial&&!Tk(e,r)||i.check(e[r],n);return!s&&n?.extend(r.toString(),i.toString(),typeof e[r],"Object property does not match"),s})}}const Mde=t=>new Oy(t),Dde=En(Oy),Nde=Bn(t=>t!=null&&(t.constructor===Object||t.constructor==null));class u3 extends Ei{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&jh(e,(i,r)=>{const s=this.shape.keys.check(r,n);return!s&&n?.extend(r+"","Record",typeof e,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(i,n)})}}const d3=(t,e)=>new u3(t,e),zde=En(u3);class f3 extends Ei{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&jh(this.shape,(i,r)=>{const s=i.check(e[r],n);return!s&&n?.extend(r.toString(),"Tuple",typeof i),s})}}const Lde=(...t)=>new f3(t);En(f3);class h3 extends Ei{constructor(e){super(),this.shape=e.length===1?e[0]:new Pk(e)}check(e,n){const i=Pu(e)&&vk(e,r=>this.shape.check(r));return!i&&n?.extend(null,"Array",""),i}}const p3=(...t)=>new h3(t),Zde=En(h3),Ide=Bn(t=>Pu(t));class g3 extends Ei{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const i=e instanceof this.shape&&(this._c==null||this._c(e));return!i&&n?.extend(null,this.shape.name,e?.constructor.name),i}}const Xde=(t,e=null)=>new g3(t,e);En(g3);const Vde=Xde(Ei);class Bde extends Ei{constructor(e){super(),this.len=e.length-1,this.args=Lde(...e.slice(-1)),this.res=e[this.len]}check(e,n){const i=e.constructor===Function&&e.length<=this.len;return!i&&n?.extend(null,"function",typeof e),i}}const Ude=En(Bde),qde=Bn(t=>typeof t=="function");class Yde extends Ei{constructor(e){super(),this.shape=e}check(e,n){const i=vk(this.shape,r=>r.check(e,n));return!i&&n?.extend(null,"Intersectinon",typeof e),i}}En(Yde,t=>t.shape.length>0);class Pk extends Ei{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,n){const i=bk(this.shape,r=>r.check(e,n));return n?.extend(null,"Union",typeof e),i}}const Hu=(...t)=>t.findIndex(e=>rO.check(e))>=0?Hu(...t.map(e=>rh(e)).map(e=>rO.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Pk(t),rO=En(Pk),m3=()=>!0,sO=Bn(m3),Fde=En(Ak,t=>t.shape===m3),jk=Bn(t=>typeof t=="bigint"),Gde=Bn(t=>t===jk),O3=Bn(t=>typeof t=="symbol");Bn(t=>t===O3);const hu=Bn(t=>typeof t=="number"),y3=Bn(t=>t===hu),Mu=Bn(t=>typeof t=="string"),v3=Bn(t=>t===Mu),yy=Bn(t=>typeof t=="boolean"),Hde=Bn(t=>t===yy),b3=my(void 0);En(gy,t=>t.shape.length===1&&t.shape[0]===void 0);my(void 0);const vy=my(null),Wde=En(gy,t=>t.shape.length===1&&t.shape[0]===null);En(Uint8Array);En(Qk,t=>t.shape===Uint8Array);const Kde=Hu(hu,Mu,vy,b3,jk,yy,O3);(()=>{const t=p3(sO),e=d3(Mu,sO),n=Hu(hu,Mu,vy,yy,t,e);return t.shape=n,e.shape.values=n,n})();const rh=t=>{if(Vde.check(t))return t;if(Nde.check(t)){const e={};for(const n in t)e[n]=rh(t[n]);return Mde(e)}else{if(Ide.check(t))return Hu(...t.map(rh));if(Kde.check(t))return my(t);if(qde.check(t))return En(t)}dr()},oA=fde?()=>{}:(t,e)=>{const n=new Ede;if(!e.check(t,n))throw Ls(`Expected value to be of type ${e.constructor.name}. +${n.toString()}`)};class Jde{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:rh(e),h:n}),this}else(e){return this.if(sO,e)}done(){return(e,n)=>{for(let i=0;inew Jde(t),S3=efe(sO).if(y3,(t,e)=>sS(e,HQ,tO)).if(v3,(t,e)=>$de(e)).if(Hde,(t,e)=>sA(e)).if(Gde,(t,e)=>BigInt(sS(e,HQ,tO))).if(rO,(t,e)=>Zc(e,oS(e,t.shape))).if(Dde,(t,e)=>{const n={};for(const i in t.shape){let r=t.shape[i];if(Pde.check(r)){if(sA(e))continue;r=r.shape}n[i]=S3(r,e)}return n}).if(Zde,(t,e)=>{const n=[],i=o3(e,0,42);for(let r=0;roS(e,t.shape)).if(Wde,(t,e)=>null).if(Ude,(t,e)=>{const n=Zc(e,t.res);return()=>n}).if(Fde,(t,e)=>Zc(e,oS(e,[hu,Mu,vy,b3,jk,yy,p3(hu),d3(Hu("a","b","c"),hu)]))).if(zde,(t,e)=>{const n={},i=sS(e,0,3);for(let r=0;rS3(rh(e),t),Bs=typeof document<"u"?document:{},tfe=t=>Bs.createElement(t),nfe=()=>Bs.createDocumentFragment();Bn(t=>t.nodeType===dfe);const ife=t=>Bs.createTextNode(t);typeof DOMParser<"u"&&new DOMParser;const rfe=(t,e)=>(Cde(e,(n,i)=>{i===!1?t.removeAttribute(n):i===!0?t.setAttribute(n,""):t.setAttribute(n,i)}),t),sfe=t=>{const e=nfe();for(let n=0;n(x3(t,sfe(e)),t),aS=(t,e=[],n=[])=>ofe(rfe(tfe(t),e),n);Bn(t=>t.nodeType===lfe);const Ng=ife;Bn(t=>t.nodeType===cfe);const afe=t=>gue(t,(e,n)=>`${n}:${e};`).join(""),x3=(t,e)=>t.appendChild(e),lfe=Bs.ELEMENT_NODE,cfe=Bs.TEXT_NODE;Bs.CDATA_SECTION_NODE;Bs.COMMENT_NODE;const ufe=Bs.DOCUMENT_NODE;Bs.DOCUMENT_TYPE_NODE;const dfe=Bs.DOCUMENT_FRAGMENT_NODE;Bn(t=>t.nodeType===ufe);const Po=Symbol,w3=Po(),k3=Po(),ffe=Po(),hfe=Po(),pfe=Po(),C3=Po(),gfe=Po(),Mk=Po(),mfe=Po(),Ofe=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let i=0;for(;i0&&n.push(e.join(""));i{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],i=qi();let r=[],s=0;for(;s0||u.length>0?(e.push("%c"+o),n.push(u)):e.push(o)}else break}}for(s>0&&(r=n,r.unshift(e.join("")));s{console.log(..._3(t)),T3.forEach(e=>e.print(t))},$3=(...t)=>{console.warn(..._3(t)),t.unshift(Mk),T3.forEach(e=>e.print(t))},T3=Aa(),E3=t=>({[Symbol.iterator](){return this},next:t}),Sfe=(t,e)=>E3(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),lS=(t,e)=>E3(()=>{const{done:n,value:i}=t.next();return{done:n,value:n?void 0:e(i)}});class by{constructor(e,n){this.clock=e,this.len=n}}class Wu{constructor(){this.clients=new Map}}const Du=(t,e,n)=>e.clients.forEach((i,r)=>{const s=t.doc.store.clients.get(r);if(s!=null){const o=s[s.length-1],l=o.id.clock+o.length;for(let u=0,f=i[u];u{let n=0,i=t.length-1;for(;n<=i;){const r=ns((n+i)/2),s=t[r],o=s.clock;if(o<=e){if(e{const n=t.clients.get(e.client);return n!==void 0&&xfe(n,e.clock)!==null},Dk=t=>{t.clients.forEach(e=>{e.sort((r,s)=>r.clock-s.clock);let n,i;for(n=1,i=1;n=s.clock?e[i-1]=new by(r.clock,Ba(r.len,s.clock+s.len-r.clock)):(i{const e=new Wu;for(let n=0;n{if(!e.clients.has(r)){const s=i.slice();for(let o=n+1;o{Vs(t.clients,e,()=>[]).push(new by(n,i))},wfe=()=>new Wu,kfe=t=>{const e=wfe();return t.clients.forEach((n,i)=>{const r=[];for(let s=0;s0&&e.clients.set(i,r)}),e},Ku=(t,e)=>{Be(t.restEncoder,e.clients.size),Ro(e.clients.entries()).sort((n,i)=>i[0]-n[0]).forEach(([n,i])=>{t.resetDsCurVal(),Be(t.restEncoder,n);const r=i.length;Be(t.restEncoder,r);for(let s=0;s{const e=new Wu,n=et(t.restDecoder);for(let i=0;i0){const o=Vs(e.clients,r,()=>[]);for(let l=0;l{const i=new Wu,r=et(t.restDecoder);for(let s=0;s0){const s=new Xl;return Be(s.restEncoder,0),Ku(s,i),s.toUint8Array()}return null},R3=WL;class Kl extends Sk{constructor({guid:e=Wue(),collectionid:n=null,gc:i=!0,gcFilter:r=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=i,this.gcFilter=r,this.clientID=R3(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new I3,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=iA(f=>{this.on("load",()=>{this.isLoaded=!0,f(this)})});const u=()=>iA(f=>{const h=p=>{(p===void 0||p===!0)&&(this.off("sync",h),f())};this.on("sync",h)});this.on("sync",f=>{f===!1&&this.isSynced&&(this.whenSynced=u()),this.isSynced=f===void 0||f===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=u()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Bt(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Ro(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Bt(this,e,n)}get(e,n=Vn){const i=Vs(this.share,e,()=>{const s=new n;return s._integrate(this,null),s}),r=i.constructor;if(n!==Vn&&r!==n)if(r===Vn){const s=new n;s._map=i._map,i._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s}),s._start=i._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=i._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return i}getArray(e=""){return this.get(e,mu)}getText(e=""){return this.get(e,Lu)}getMap(e=""){return this.get(e,zu)}getXmlElement(e=""){return this.get(e,Zu)}getXmlFragment(e=""){return this.get(e,Vl)}toJSON(){const e={};return this.share.forEach((n,i)=>{e[i]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Ro(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Kl({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Bt(e.parent.doc,i=>{const r=n.doc;e.deleted||i.subdocsAdded.add(r),i.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Q3{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return et(this.restDecoder)}readDsLen(){return et(this.restDecoder)}}class A3 extends Q3{readLeftID(){return nt(et(this.restDecoder),et(this.restDecoder))}readRightID(){return nt(et(this.restDecoder),et(this.restDecoder))}readClient(){return et(this.restDecoder)}readInfo(){return ju(this.restDecoder)}readString(){return xa(this.restDecoder)}readParentInfo(){return et(this.restDecoder)===1}readTypeRef(){return et(this.restDecoder)}readLen(){return et(this.restDecoder)}readAny(){return nh(this.restDecoder)}readBuf(){return wde(li(this.restDecoder))}readJSON(){return JSON.parse(xa(this.restDecoder))}readKey(){return xa(this.restDecoder)}}class Cfe{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=et(this.restDecoder),this.dsCurrVal}readDsLen(){const e=et(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Nu extends Cfe{constructor(e){super(e),this.keys=[],et(e),this.keyClockDecoder=new rS(li(e)),this.clientDecoder=new am(li(e)),this.leftClockDecoder=new rS(li(e)),this.rightClockDecoder=new rS(li(e)),this.infoDecoder=new nA(li(e),ju),this.stringDecoder=new Fue(li(e)),this.parentInfoDecoder=new nA(li(e),ju),this.typeRefDecoder=new am(li(e)),this.lenDecoder=new am(li(e))}readLeftID(){return new pu(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new pu(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return nh(this.restDecoder)}readBuf(){return li(this.restDecoder)}readJSON(){return nh(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e{i=Ba(i,e[0].id.clock);const r=Zs(e,i);Be(t.restEncoder,e.length-r),t.writeClient(n),Be(t.restEncoder,i);const s=e[r];s.write(t,i-s.id.clock);for(let o=r+1;o{const i=new Map;n.forEach((r,s)=>{Sn(e,s)>r&&i.set(s,r)}),Sy(e).forEach((r,s)=>{n.has(s)||i.set(s,0)}),Be(t.restEncoder,i.size),Ro(i.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{_fe(t,e.clients.get(r),r,s)})},$fe=(t,e)=>{const n=qi(),i=et(t.restDecoder);for(let r=0;r{const i=[];let r=Ro(n.keys()).sort((y,v)=>y-v);if(r.length===0)return null;const s=()=>{if(r.length===0)return null;let y=n.get(r[r.length-1]);for(;y.refs.length===y.i;)if(r.pop(),r.length>0)y=n.get(r[r.length-1]);else return null;return y};let o=s();if(o===null)return null;const l=new I3,u=new Map,f=(y,v)=>{const S=u.get(y);(S==null||S>v)&&u.set(y,v)};let h=o.refs[o.i++];const p=new Map,O=()=>{for(const y of i){const v=y.id.client,S=n.get(v);S?(S.i--,l.clients.set(v,S.refs.slice(S.i)),n.delete(v),S.i=0,S.refs=[]):l.clients.set(v,[y]),r=r.filter(k=>k!==v)}i.length=0};for(;;){if(h.constructor!==Er){const v=Vs(p,h.id.client,()=>Sn(e,h.id.client))-h.id.clock;if(v<0)i.push(h),f(h.id.client,h.id.clock-1),O();else{const S=h.getMissing(t,e);if(S!==null){i.push(h);const k=n.get(S)||{refs:[],i:0};if(k.refs.length===k.i)f(S,Sn(e,S)),O();else{h=k.refs[k.i++];continue}}else(v===0||v0)h=i.pop();else if(o!==null&&o.i0){const y=new Xl;return zk(y,l,new Map),Be(y.restEncoder,0),{missing:u,update:y.toUint8Array()}}return null},Efe=(t,e)=>zk(t,e.doc.store,e.beforeState),Rfe=(t,e,n,i=new Nu(t))=>Bt(e,r=>{r.local=!1;let s=!1;const o=r.doc,l=o.store,u=$fe(i,o),f=Tfe(r,l,u),h=l.pendingStructs;if(h){for(const[O,y]of h.missing)if(yy)&&h.missing.set(O,y)}h.update=aO([h.update,f.update])}}else l.pendingStructs=f;const p=aA(i,r,l);if(l.pendingDs){const O=new Nu(Ua(l.pendingDs));et(O.restDecoder);const y=aA(O,r,l);p&&y?l.pendingDs=aO([p,y]):l.pendingDs=p||y}else l.pendingDs=p;if(s){const O=l.pendingStructs.update;l.pendingStructs=null,M3(r.doc,O)}},n,!1),M3=(t,e,n,i=Nu)=>{const r=Ua(e);Rfe(r,t,n,new i(r))},Qfe=(t,e,n)=>M3(t,e,n,A3),Afe=(t,e,n=new Map)=>{zk(t,e.store,n),Ku(t,kfe(e.store))},Pfe=(t,e=new Uint8Array([0]),n=new Xl)=>{const i=D3(e);Afe(n,t,i);const r=[n.toUint8Array()];if(t.store.pendingDs&&r.push(t.store.pendingDs),t.store.pendingStructs&&r.push(Jfe(t.store.pendingStructs.update,e)),r.length>1){if(n.constructor===Dh)return Wfe(r.map((s,o)=>o===0?s:the(s)));if(n.constructor===Xl)return aO(r)}return r[0]},jfe=(t,e)=>Pfe(t,e,new Dh),Mfe=t=>{const e=new Map,n=et(t.restDecoder);for(let i=0;iMfe(new Q3(Ua(t))),N3=(t,e)=>(Be(t.restEncoder,e.size),Ro(e.entries()).sort((n,i)=>i[0]-n[0]).forEach(([n,i])=>{Be(t.restEncoder,n),Be(t.restEncoder,i)}),t),Dfe=(t,e)=>N3(t,Sy(e.store)),Nfe=(t,e=new j3)=>(t instanceof Map?N3(e,t):Dfe(e,t),e.toUint8Array()),zfe=t=>Nfe(t,new P3);class Lfe{constructor(){this.l=[]}}const lA=()=>new Lfe,cA=(t,e)=>t.l.push(e),uA=(t,e)=>{const n=t.l,i=n.length;t.l=n.filter(r=>e!==r),i===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},z3=(t,e,n)=>Ek(t.l,[e,n]);class pu{constructor(e,n){this.client=e,this.clock=n}}const eu=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,nt=(t,e)=>new pu(t,e),L3=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw dr()},oO=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Z3{constructor(e,n,i,r=0){this.type=e,this.tname=n,this.item=i,this.assoc=r}}const dA=t=>{const e={};return t.type&&(e.type=t.type),t.tname&&(e.tname=t.tname),t.item&&(e.item=t.item),t.assoc!=null&&(e.assoc=t.assoc),e},oh=t=>new Z3(t.type==null?null:nt(t.type.client,t.type.clock),t.tname??null,t.item==null?null:nt(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class Zfe{constructor(e,n,i=0){this.type=e,this.index=n,this.assoc=i}}const Ife=(t,e,n=0)=>new Zfe(t,e,n),zg=(t,e,n)=>{let i=null,r=null;return t._item===null?r=L3(t):i=nt(t._item.id.client,t._item.id.clock),new Z3(i,r,e,n)},ah=(t,e,n=0)=>{let i=t._start;if(n<0){if(e===0)return zg(t,null,n);e--}for(;i!==null;){if(!i.deleted&&i.countable){if(i.length>e)return zg(t,nt(i.id.client,i.id.clock+e),n);e-=i.length}if(i.right===null&&n<0)return zg(t,i.lastId,n);i=i.right}return zg(t,null,n)},Xfe=(t,e)=>{const n=gu(t,e),i=e.clock-n.id.clock;return{item:n,diff:i}},lh=(t,e,n=!0)=>{const i=e.store,r=t.item,s=t.type,o=t.tname,l=t.assoc;let u=null,f=0;if(r!==null){if(Sn(i,r.client)<=r.clock)return null;const h=n?cw(i,r):Xfe(i,r),p=h.item;if(!(p instanceof Ut))return null;if(u=p.parent,u._item===null||!u._item.deleted){f=p.deleted||!p.countable?0:h.diff+(l>=0?0:1);let O=p.left;for(;O!==null;)!O.deleted&&O.countable&&(f+=O.length),O=O.left}}else{if(o!==null)u=e.get(o);else if(s!==null){if(Sn(i,s.client)<=s.clock)return null;const{item:h}=n?cw(i,s):{item:gu(i,s)};if(h instanceof Ut&&h.content instanceof Us)u=h.content.type;else return null}else throw dr();l>=0?f=u._length:f=0}return Ife(u,f,t.assoc)},fA=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&eu(t.item,e.item)&&eu(t.type,e.type)&&t.assoc===e.assoc,Bc=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Mh(e.ds,t.id),ow=(t,e)=>{const n=Vs(t.meta,ow,Aa),i=t.doc.store;n.has(e)||(e.sv.forEach((r,s)=>{r{}),n.add(e))};class I3{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Sy=t=>{const e=new Map;return t.clients.forEach((n,i)=>{const r=n[n.length-1];e.set(i,r.id.clock+r.length)}),e},Sn=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const i=n[n.length-1];return i.id.clock+i.length},X3=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const i=n[n.length-1];if(i.id.clock+i.length!==e.id.clock)throw dr()}n.push(e)},Zs=(t,e)=>{let n=0,i=t.length-1,r=t[i],s=r.id.clock;if(s===e)return i;let o=ns(e/(s+r.length-1)*i);for(;n<=i;){if(r=t[o],s=r.id.clock,s<=e){if(e{const n=t.clients.get(e.client);return n[Zs(n,e.clock)]},gu=Vfe,aw=(t,e,n)=>{const i=Zs(e,n),r=e[i];return r.id.clock{const n=t.doc.store.clients.get(e.client);return n[aw(t,n,e.clock)]},hA=(t,e,n)=>{const i=e.clients.get(n.client),r=Zs(i,n.clock),s=i[r];return n.clock!==s.id.clock+s.length-1&&s.constructor!==Tr&&i.splice(r+1,0,hO(t,s,n.clock-s.id.clock+1)),s},Bfe=(t,e,n)=>{const i=t.clients.get(e.id.client);i[Zs(i,e.id.clock)]=n},V3=(t,e,n,i,r)=>{if(i===0)return;const s=n+i;let o=aw(t,e,n),l;do l=e[o++],se.deleteSet.clients.size===0&&!mue(e.afterState,(n,i)=>e.beforeState.get(i)!==n)?!1:(Dk(e.deleteSet),Efe(t,e),Ku(t,e.deleteSet),!0),gA=(t,e,n)=>{const i=e._item;(i===null||i.id.clock<(t.beforeState.get(i.id.client)||0)&&!i.deleted)&&Vs(t.changed,e,Aa).add(n)},lm=(t,e)=>{let n=t[e],i=t[e-1],r=e;for(;r>0;n=i,i=t[--r-1]){if(i.deleted===n.deleted&&i.constructor===n.constructor&&i.mergeWith(n)){n instanceof Ut&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,i);continue}break}const s=e-r;return s&&t.splice(e+1-s,s),s},qfe=(t,e,n)=>{for(const[i,r]of t.clients.entries()){const s=e.clients.get(i);for(let o=r.length-1;o>=0;o--){const l=r[o],u=l.clock+l.len;for(let f=Zs(s,l.clock),h=s[f];f{t.clients.forEach((n,i)=>{const r=e.clients.get(i);for(let s=n.length-1;s>=0;s--){const o=n[s],l=dy(r.length-1,1+Zs(r,o.clock+o.len-1));for(let u=l,f=r[u];u>0&&f.id.clock>=o.clock;f=r[u])u-=1+lm(r,u)}})},B3=(t,e)=>{if(el.push(()=>{(f._item===null||!f._item.deleted)&&f._callObserver(n,u)})),l.push(()=>{n.changedParentTypes.forEach((u,f)=>{f._dEH.l.length>0&&(f._item===null||!f._item.deleted)&&(u=u.filter(h=>h.target._item===null||!h.target._item.deleted),u.forEach(h=>{h.currentTarget=f,h._path=null}),u.sort((h,p)=>h.path.length-p.path.length),l.push(()=>{z3(f._dEH,u,n)}))}),l.push(()=>i.emit("afterTransaction",[n,i])),l.push(()=>{n._needFormattingCleanup&&ghe(n)})}),Ek(l,[])}finally{i.gc&&qfe(s,r,i.gcFilter),Yfe(s,r),n.afterState.forEach((h,p)=>{const O=n.beforeState.get(p)||0;if(O!==h){const y=r.clients.get(p),v=Ba(Zs(y,O),1);for(let S=y.length-1;S>=v;)S-=1+lm(y,S)}});for(let h=o.length-1;h>=0;h--){const{client:p,clock:O}=o[h].id,y=r.clients.get(p),v=Zs(y,O);v+11||v>0&&lm(y,v)}if(!n.local&&n.afterState.get(i.clientID)!==n.beforeState.get(i.clientID)&&(bfe(Mk,w3,"[yjs] ",k3,C3,"Changed the client-id because another client seems to be using it."),i.clientID=R3()),i.emit("afterTransactionCleanup",[n,i]),i._observers.has("update")){const h=new Dh;pA(h,n)&&i.emit("update",[h.toUint8Array(),n.origin,i,n])}if(i._observers.has("updateV2")){const h=new Xl;pA(h,n)&&i.emit("updateV2",[h.toUint8Array(),n.origin,i,n])}const{subdocsAdded:l,subdocsLoaded:u,subdocsRemoved:f}=n;(l.size>0||f.size>0||u.size>0)&&(l.forEach(h=>{h.clientID=i.clientID,h.collectionid==null&&(h.collectionid=i.collectionid),i.subdocs.add(h)}),f.forEach(h=>i.subdocs.delete(h)),i.emit("subdocs",[{loaded:u,added:l,removed:f},i,n]),f.forEach(h=>h.destroy())),t.length<=e+1?(i._transactionCleanups=[],i.emit("afterAllTransactions",[i,t])):B3(t,e+1)}}},Bt=(t,e,n=null,i=!0)=>{const r=t._transactionCleanups;let s=!1,o=null;t._transaction===null&&(s=!0,t._transaction=new Ufe(t,n,i),r.push(t._transaction),r.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(s){const l=t._transaction===r[0];t._transaction=null,l&&B3(r,0)}}return o};class Ffe{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const mA=(t,e,n)=>{Du(t,n.deletions,i=>{i instanceof Ut&&e.scope.some(r=>r===t.doc||oO(r,i))&&qk(i,!1)})},OA=(t,e,n)=>{let i=null;const r=t.doc,s=t.scope;Bt(r,l=>{for(;e.length>0&&t.currStackItem===null;){const u=r.store,f=e.pop(),h=new Set,p=[];let O=!1;Du(l,f.insertions,y=>{if(y instanceof Ut){if(y.redone!==null){let{item:v,diff:S}=cw(u,y.id);S>0&&(v=Xi(l,nt(v.id.client,v.id.clock+S))),y=v}!y.deleted&&s.some(v=>v===l.doc||oO(v,y))&&p.push(y)}}),Du(l,f.deletions,y=>{y instanceof Ut&&s.some(v=>v===l.doc||oO(v,y))&&!Mh(f.insertions,y.id)&&h.add(y)}),h.forEach(y=>{O=lZ(l,y,h,f.insertions,t.ignoreRemoteMapChanges,t)!==null||O});for(let y=p.length-1;y>=0;y--){const v=p[y];t.deleteFilter(v)&&(v.delete(l),O=!0)}t.currStackItem=O?f:null}l.changed.forEach((u,f)=>{u.has(null)&&f._searchMarker&&(f._searchMarker.length=0)}),i=l},t);const o=t.currStackItem;if(o!=null){const l=i.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class Gfe extends Sk{constructor(e,{captureTimeout:n=500,captureTransaction:i=u=>!0,deleteFilter:r=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Pu(e)?e[0].doc:e instanceof Kl?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=r,s.add(this),this.trackedOrigins=s,this.captureTransaction=i,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=u=>{if(!this.captureTransaction(u)||!this.scope.some(k=>u.changedParentTypes.has(k)||k===this.doc)||!this.trackedOrigins.has(u.origin)&&(!u.origin||!this.trackedOrigins.has(u.origin.constructor)))return;const f=this.undoing,h=this.redoing,p=f?this.redoStack:this.undoStack;f?this.stopCapturing():h||this.clear(!1,!0);const O=new Wu;u.afterState.forEach((k,C)=>{const $=u.beforeState.get(C)||0,T=k-$;T>0&&sh(O,C,$,T)});const y=Pa();let v=!1;if(this.lastChange>0&&y-this.lastChange0&&!f&&!h){const k=p[p.length-1];k.deletions=sw([k.deletions,u.deleteSet]),k.insertions=sw([k.insertions,O])}else p.push(new Ffe(u.deleteSet,O)),v=!0;!f&&!h&&(this.lastChange=y),Du(u,u.deleteSet,k=>{k instanceof Ut&&this.scope.some(C=>C===u.doc||oO(C,k))&&qk(k,!0)});const S=[{stackItem:p[p.length-1],origin:u.origin,type:f?"redo":"undo",changedParentTypes:u.changedParentTypes},this];v?this.emit("stack-item-added",S):this.emit("stack-item-updated",S)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(e){const n=new Set(this.scope);e=Pu(e)?e:[e],e.forEach(i=>{n.has(i)||(n.add(i),(i instanceof Vn?i.doc!==this.doc:i!==this.doc)&&$3("[yjs#509] Not same Y.Doc"),this.scope.push(i))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(i=>{e&&(this.undoStack.forEach(r=>mA(i,this,r)),this.undoStack=[]),n&&(this.redoStack.forEach(r=>mA(i,this,r)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=OA(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=OA(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*Hfe(t){const e=et(t.restDecoder);for(let n=0;naO(t,A3,Dh),Kfe=(t,e)=>{if(t.constructor===Tr){const{client:n,clock:i}=t.id;return new Tr(nt(n,i+e),t.length-e)}else if(t.constructor===Er){const{client:n,clock:i}=t.id;return new Er(nt(n,i+e),t.length-e)}else{const n=t,{client:i,clock:r}=n.id;return new Ut(nt(i,r+e),null,nt(i,r+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},aO=(t,e=Nu,n=Xl)=>{if(t.length===1)return t[0];const i=t.map(h=>new e(Ua(h)));let r=i.map(h=>new Lk(h,!0)),s=null;const o=new n,l=new Zk(o);for(;r=r.filter(O=>O.curr!==null),r.sort((O,y)=>{if(O.curr.id.client===y.curr.id.client){const v=O.curr.id.clock-y.curr.id.clock;return v===0?O.curr.constructor===y.curr.constructor?0:O.curr.constructor===Er?1:-1:v}else return y.curr.id.client-O.curr.id.client}),r.length!==0;){const h=r[0],p=h.curr.id.client;if(s!==null){let O=h.curr,y=!1;for(;O!==null&&O.id.clock+O.length<=s.struct.id.clock+s.struct.length&&O.id.client>=s.struct.id.client;)O=h.next(),y=!0;if(O===null||O.id.client!==p||y&&O.id.clock>s.struct.id.clock+s.struct.length)continue;if(p!==s.struct.id.client)ga(l,s.struct,s.offset),s={struct:O,offset:0},h.next();else if(s.struct.id.clock+s.struct.length0&&(s.struct.constructor===Er?s.struct.length-=v:O=Kfe(O,v)),s.struct.mergeWith(O)||(ga(l,s.struct,s.offset),s={struct:O,offset:0},h.next())}}else s={struct:h.curr,offset:0},h.next();for(let O=h.curr;O!==null&&O.id.client===p&&O.id.clock===s.struct.id.clock+s.struct.length&&O.constructor!==Er;O=h.next())ga(l,s.struct,s.offset),s={struct:O,offset:0}}s!==null&&(ga(l,s.struct,s.offset),s=null),Ik(l);const u=i.map(h=>Nk(h)),f=sw(u);return Ku(o,f),o.toUint8Array()},Jfe=(t,e,n=Nu,i=Xl)=>{const r=D3(e),s=new i,o=new Zk(s),l=new n(Ua(t)),u=new Lk(l,!1);for(;u.curr;){const h=u.curr,p=h.id.client,O=r.get(p)||0;if(u.curr.constructor===Er){u.next();continue}if(h.id.clock+h.length>O)for(ga(o,h,Ba(O-h.id.clock,0)),u.next();u.curr&&u.curr.id.client===p;)ga(o,u.curr,0),u.next();else for(;u.curr&&u.curr.id.client===p&&u.curr.id.clock+u.curr.length<=O;)u.next()}Ik(o);const f=Nk(l);return Ku(s,f),s.toUint8Array()},U3=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:tn(t.encoder.restEncoder)}),t.encoder.restEncoder=ci(),t.written=0)},ga=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&U3(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Be(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},Ik=t=>{U3(t);const e=t.encoder.restEncoder;Be(e,t.clientStructs.length);for(let n=0;n{const r=new n(Ua(t)),s=new Lk(r,!1),o=new i,l=new Zk(o);for(let f=s.curr;f!==null;f=s.next())ga(l,e(f),0);Ik(l);const u=Nk(r);return Ku(o,u),o.toUint8Array()},the=t=>ehe(t,cde,Nu,Dh),yA="You must not compute changes after the event-handler fired.";class xy{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=nhe(this.currentTarget,this.target))}deletes(e){return Mh(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ls(yA);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(r=>{if(r!==null){const s=n._map.get(r);let o,l;if(this.adds(s)){let u=s.left;for(;u!==null&&this.adds(u);)u=u.left;if(this.deletes(s))if(u!==null&&this.deletes(u))o="delete",l=eS(u.content.getContent());else return;else u!==null&&this.deletes(u)?(o="update",l=eS(u.content.getContent())):(o="add",l=void 0)}else if(this.deletes(s))o="delete",l=eS(s.content.getContent());else return;e.set(r,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Ls(yA);const n=this.target,i=Aa(),r=Aa(),s=[];if(e={added:i,deleted:r,delta:s,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const u=()=>{l&&s.push(l)};for(let f=n._start;f!==null;f=f.right)f.deleted?this.deletes(f)&&!this.adds(f)&&((l===null||l.delete===void 0)&&(u(),l={delete:0}),l.delete+=f.length,r.add(f)):this.adds(f)?((l===null||l.insert===void 0)&&(u(),l={insert:[]}),l.insert=l.insert.concat(f.content.getContent()),i.add(f)):((l===null||l.retain===void 0)&&(u(),l={retain:0}),l.retain+=f.length);l!==null&&l.retain===void 0&&u()}this._changes=e}return e}}const nhe=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let i=0,r=e._item.parent._start;for(;r!==e._item&&r!==null;)!r.deleted&&r.countable&&(i+=r.length),r=r.right;n.unshift(i)}e=e._item.parent}return n},gi=()=>{$3("Invalid access: Add Yjs type to a document before reading data.")},q3=80;let Xk=0;class ihe{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Xk++}}const rhe=t=>{t.timestamp=Xk++},Y3=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Xk++},she=(t,e,n)=>{if(t.length>=q3){const i=t.reduce((r,s)=>r.timestamp{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((s,o)=>sm(e-s.index)e;)i=i.left,!i.deleted&&i.countable&&(r-=i.length);for(;i.left!==null&&i.left.id.client===i.id.client&&i.left.id.clock+i.left.length===i.id.clock;)i=i.left,!i.deleted&&i.countable&&(r-=i.length);return n!==null&&sm(n.index-r){for(let i=t.length-1;i>=0;i--){const r=t[i];if(n>0){let s=r.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(r.index-=s.length);if(s===null||s.marker===!0){t.splice(i,1);continue}r.p=s,s.marker=!0}(e0&&e===r.index)&&(r.index=Ba(e,r.index+n))}},ky=(t,e,n)=>{const i=t,r=e.changedParentTypes;for(;Vs(r,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;z3(i._eH,n,e)};class Vn{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=lA(),this._dEH=lA(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw es()}clone(){throw es()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){cA(this._eH,e)}observeDeep(e){cA(this._dEH,e)}unobserve(e){uA(this._eH,e)}unobserveDeep(e){uA(this._dEH,e)}toJSON(){}}const F3=(t,e,n)=>{t.doc??gi(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let i=n-e;const r=[];let s=t._start;for(;s!==null&&i>0;){if(s.countable&&!s.deleted){const o=s.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l0;l++)r.push(o[l]),i--;e=0}}s=s.right}return r},G3=t=>{t.doc??gi();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const i=n.content.getContent();for(let r=0;r{let n=0,i=t._start;for(t.doc??gi();i!==null;){if(i.countable&&!i.deleted){const r=i.content.getContent();for(let s=0;s{const n=[];return uh(t,(i,r)=>{n.push(e(i,r,t))}),n},ohe=t=>{let e=t._start,n=null,i=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),i=0,e=e.right}const r=n[i++];return n.length<=i&&(n=null),{done:!1,value:r}}}},W3=(t,e)=>{t.doc??gi();const n=wy(t,e);let i=t._start;for(n!==null&&(i=n.p,e-=n.index);i!==null;i=i.right)if(!i.deleted&&i.countable){if(e{let r=n;const s=t.doc,o=s.clientID,l=s.store,u=n===null?e._start:n.right;let f=[];const h=()=>{f.length>0&&(r=new Ut(nt(o,Sn(l,o)),r,r&&r.lastId,u,u&&u.id,e,null,new Bl(f)),r.integrate(t,0),f=[])};i.forEach(p=>{if(p===null)f.push(p);else switch(p.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(p);break;default:switch(h(),p.constructor){case Uint8Array:case ArrayBuffer:r=new Ut(nt(o,Sn(l,o)),r,r&&r.lastId,u,u&&u.id,e,null,new Nh(new Uint8Array(p))),r.integrate(t,0);break;case Kl:r=new Ut(nt(o,Sn(l,o)),r,r&&r.lastId,u,u&&u.id,e,null,new zh(p)),r.integrate(t,0);break;default:if(p instanceof Vn)r=new Ut(nt(o,Sn(l,o)),r,r&&r.lastId,u,u&&u.id,e,null,new Us(p)),r.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},K3=()=>Ls("Length exceeded!"),J3=(t,e,n,i)=>{if(n>e._length)throw K3();if(n===0)return e._searchMarker&&ch(e._searchMarker,n,i.length),lO(t,e,null,i);const r=n,s=wy(e,n);let o=e._start;for(s!==null&&(o=s.p,n-=s.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n{let r=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(r)for(;r.right;)r=r.right;return lO(t,e,r,n)},eZ=(t,e,n,i)=>{if(i===0)return;const r=n,s=i,o=wy(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n0&&l!==null;)l.deleted||(i0)throw K3();e._searchMarker&&ch(e._searchMarker,r,-s+i)},cO=(t,e,n)=>{const i=e._map.get(n);i!==void 0&&i.delete(t)},Vk=(t,e,n,i)=>{const r=e._map.get(n)||null,s=t.doc,o=s.clientID;let l;if(i==null)l=new Bl([i]);else switch(i.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Bl([i]);break;case Uint8Array:l=new Nh(i);break;case Kl:l=new zh(i);break;default:if(i instanceof Vn)l=new Us(i);else throw new Error("Unexpected content type")}new Ut(nt(o,Sn(s.store,o)),r,r&&r.lastId,null,null,e,n,l).integrate(t,0)},Bk=(t,e)=>{t.doc??gi();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},tZ=t=>{const e={};return t.doc??gi(),t._map.forEach((n,i)=>{n.deleted||(e[i]=n.content.getContent()[n.length-1])}),e},nZ=(t,e)=>{t.doc??gi();const n=t._map.get(e);return n!==void 0&&!n.deleted},lhe=(t,e)=>{const n={};return t._map.forEach((i,r)=>{let s=i;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&Bc(s,e)&&(n[r]=s.content.getContent()[s.length-1])}),n},Lg=t=>(t.doc??gi(),Sfe(t._map.entries(),e=>!e[1].deleted));class che extends xy{}class mu extends Vn{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new mu;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new mu}clone(){const e=new mu;return e.insert(0,this.toArray().map(n=>n instanceof Vn?n.clone():n)),e}get length(){return this.doc??gi(),this._length}_callObserver(e,n){super._callObserver(e,n),ky(this,e,new che(this,e))}insert(e,n){this.doc!==null?Bt(this.doc,i=>{J3(i,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Bt(this.doc,n=>{ahe(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Bt(this.doc,i=>{eZ(i,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return W3(this,e)}toArray(){return G3(this)}slice(e=0,n=this.length){return F3(this,e,n)}toJSON(){return this.map(e=>e instanceof Vn?e.toJSON():e)}map(e){return H3(this,e)}forEach(e){uh(this,e)}[Symbol.iterator](){return ohe(this)}_write(e){e.writeTypeRef(jhe)}}const uhe=t=>new mu;class dhe extends xy{constructor(e,n,i){super(e,n),this.keysChanged=i}}class zu extends Vn{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((i,r)=>{this.set(r,i)}),this._prelimContent=null}_copy(){return new zu}clone(){const e=new zu;return this.forEach((n,i)=>{e.set(i,n instanceof Vn?n.clone():n)}),e}_callObserver(e,n){ky(this,e,new dhe(this,e,n))}toJSON(){this.doc??gi();const e={};return this._map.forEach((n,i)=>{if(!n.deleted){const r=n.content.getContent()[n.length-1];e[i]=r instanceof Vn?r.toJSON():r}}),e}get size(){return[...Lg(this)].length}keys(){return lS(Lg(this),e=>e[0])}values(){return lS(Lg(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return lS(Lg(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??gi(),this._map.forEach((n,i)=>{n.deleted||e(n.content.getContent()[n.length-1],i,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Bt(this.doc,n=>{cO(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Bt(this.doc,i=>{Vk(i,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return Bk(this,e)}has(e){return nZ(this,e)}clear(){this.doc!==null?Bt(this.doc,e=>{this.forEach(function(n,i,r){cO(e,r,i)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Mhe)}}const fhe=t=>new zu,va=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&ade(t,e);class lw{constructor(e,n,i,r){this.left=e,this.right=n,this.index=i,this.currentAttributes=r}forward(){this.right===null&&dr(),this.right.content.constructor===Nn?this.right.deleted||Ju(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const vA=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===Nn?e.right.deleted||Ju(e.currentAttributes,e.right.content):e.right.deleted||(n{const r=new Map,s=i?wy(e,n):null;if(s){const o=new lw(s.p.left,s.p,s.index,r);return vA(t,o,n-s.index)}else{const o=new lw(null,e._start,0,r);return vA(t,o,n)}},iZ=(t,e,n,i)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Nn&&va(i.get(n.right.content.key),n.right.content.value));)n.right.deleted||i.delete(n.right.content.key),n.forward();const r=t.doc,s=r.clientID;i.forEach((o,l)=>{const u=n.left,f=n.right,h=new Ut(nt(s,Sn(r.store,s)),u,u&&u.lastId,f,f&&f.id,e,null,new Nn(l,o));h.integrate(t,0),n.right=h,n.forward()})},Ju=(t,e)=>{const{key:n,value:i}=e;i===null?t.delete(n):t.set(n,i)},rZ=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Nn&&va(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},sZ=(t,e,n,i)=>{const r=t.doc,s=r.clientID,o=new Map;for(const l in i){const u=i[l],f=n.currentAttributes.get(l)??null;if(!va(f,u)){o.set(l,f);const{left:h,right:p}=n;n.right=new Ut(nt(s,Sn(r.store,s)),h,h&&h.lastId,p,p&&p.id,e,null,new Nn(l,u)),n.right.integrate(t,0),n.forward()}}return o},cS=(t,e,n,i,r)=>{n.currentAttributes.forEach((O,y)=>{r[y]===void 0&&(r[y]=null)});const s=t.doc,o=s.clientID;rZ(n,r);const l=sZ(t,e,n,r),u=i.constructor===String?new Is(i):i instanceof Vn?new Us(i):new Jl(i);let{left:f,right:h,index:p}=n;e._searchMarker&&ch(e._searchMarker,n.index,u.getLength()),h=new Ut(nt(o,Sn(s.store,o)),f,f&&f.lastId,h,h&&h.id,e,null,u),h.integrate(t,0),n.right=h,n.index=p,n.forward(),iZ(t,e,n,l)},bA=(t,e,n,i,r)=>{const s=t.doc,o=s.clientID;rZ(n,r);const l=sZ(t,e,n,r);e:for(;n.right!==null&&(i>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Nn));){if(!n.right.deleted)switch(n.right.content.constructor){case Nn:{const{key:u,value:f}=n.right.content,h=r[u];if(h!==void 0){if(va(h,f))l.delete(u);else{if(i===0)break e;l.set(u,f)}n.right.delete(t)}else n.currentAttributes.set(u,f);break}default:i0){let u="";for(;i>0;i--)u+=` +`;n.right=new Ut(nt(o,Sn(s.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Is(u)),n.right.integrate(t,0),n.forward()}iZ(t,e,n,l)},oZ=(t,e,n,i,r)=>{let s=e;const o=qi();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===Nn){const f=s.content;o.set(f.key,f)}s=s.right}let l=0,u=!1;for(;e!==s;){if(n===e&&(u=!0),!e.deleted){const f=e.content;if(f.constructor===Nn){const{key:h,value:p}=f,O=i.get(h)??null;(o.get(h)!==f||O===p)&&(e.delete(t),l++,!u&&(r.get(h)??null)===p&&O!==p&&(O===null?r.delete(h):r.set(h,O))),!u&&!e.deleted&&Ju(r,f)}}e=e.right}return l},hhe=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Nn){const i=e.content.key;n.has(i)?e.delete(t):n.add(i)}e=e.left}},phe=t=>{let e=0;return Bt(t.doc,n=>{let i=t._start,r=t._start,s=qi();const o=Jx(s);for(;r;)r.deleted===!1&&(r.content.constructor===Nn?Ju(o,r.content):(e+=oZ(n,i,r,s,o),s=Jx(o),i=r)),r=r.right}),e},ghe=t=>{const e=new Set,n=t.doc;for(const[i,r]of t.afterState.entries()){const s=t.beforeState.get(i)||0;r!==s&&V3(t,n.store.clients.get(i),s,r,o=>{!o.deleted&&o.content.constructor===Nn&&o.constructor!==Tr&&e.add(o.parent)})}Bt(n,i=>{Du(t,t.deleteSet,r=>{if(r instanceof Tr||!r.parent._hasFormatting||e.has(r.parent))return;const s=r.parent;r.content.constructor===Nn?e.add(s):hhe(i,r)});for(const r of e)phe(r)})},SA=(t,e,n)=>{const i=n,r=Jx(e.currentAttributes),s=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Us:case Jl:case Is:n{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];Bt(e,i=>{const r=new Map,s=new Map;let o=this.target._start,l=null;const u={};let f="",h=0,p=0;const O=()=>{if(l!==null){let y=null;switch(l){case"delete":p>0&&(y={delete:p}),p=0;break;case"insert":(typeof f=="object"||f.length>0)&&(y={insert:f},r.size>0&&(y.attributes={},r.forEach((v,S)=>{v!==null&&(y.attributes[S]=v)}))),f="";break;case"retain":h>0&&(y={retain:h},ode(u)||(y.attributes=nde({},u))),h=0;break}y&&n.push(y),l=null}};for(;o!==null;){switch(o.content.constructor){case Us:case Jl:this.adds(o)?this.deletes(o)||(O(),l="insert",f=o.content.getContent()[0],O()):this.deletes(o)?(l!=="delete"&&(O(),l="delete"),p+=1):o.deleted||(l!=="retain"&&(O(),l="retain"),h+=1);break;case Is:this.adds(o)?this.deletes(o)||(l!=="insert"&&(O(),l="insert"),f+=o.content.str):this.deletes(o)?(l!=="delete"&&(O(),l="delete"),p+=o.length):o.deleted||(l!=="retain"&&(O(),l="retain"),h+=o.length);break;case Nn:{const{key:y,value:v}=o.content;if(this.adds(o)){if(!this.deletes(o)){const S=r.get(y)??null;va(S,v)?v!==null&&o.delete(i):(l==="retain"&&O(),va(v,s.get(y)??null)?delete u[y]:u[y]=v)}}else if(this.deletes(o)){s.set(y,v);const S=r.get(y)??null;va(S,v)||(l==="retain"&&O(),u[y]=S)}else if(!o.deleted){s.set(y,v);const S=u[y];S!==void 0&&(va(S,v)?S!==null&&o.delete(i):(l==="retain"&&O(),v===null?delete u[y]:u[y]=v))}o.deleted||(l==="insert"&&O(),Ju(r,o.content));break}}o=o.right}for(O();n.length>0;){const y=n[n.length-1];if(y.retain!==void 0&&y.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class Lu extends Vn{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??gi(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(i=>i())}catch(i){console.error(i)}this._pending=null}_copy(){return new Lu}clone(){const e=new Lu;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const i=new mhe(this,e,n);ky(this,e,i),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??gi();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Is&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Bt(this.doc,i=>{const r=new lw(null,this._start,0,new Map);for(let s=0;s0)&&cS(i,this,r,l,o.attributes||{})}else o.retain!==void 0?bA(i,this,r,o.retain,o.attributes||{}):o.delete!==void 0&&SA(i,r,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,i){this.doc??gi();const r=[],s=new Map,o=this.doc;let l="",u=this._start;function f(){if(l.length>0){const p={};let O=!1;s.forEach((v,S)=>{O=!0,p[S]=v});const y={insert:l};O&&(y.attributes=p),r.push(y),l=""}}const h=()=>{for(;u!==null;){if(Bc(u,e)||n!==void 0&&Bc(u,n))switch(u.content.constructor){case Is:{const p=s.get("ychange");e!==void 0&&!Bc(u,e)?(p===void 0||p.user!==u.id.client||p.type!=="removed")&&(f(),s.set("ychange",i?i("removed",u.id):{type:"removed"})):n!==void 0&&!Bc(u,n)?(p===void 0||p.user!==u.id.client||p.type!=="added")&&(f(),s.set("ychange",i?i("added",u.id):{type:"added"})):p!==void 0&&(f(),s.delete("ychange")),l+=u.content.str;break}case Us:case Jl:{f();const p={insert:u.content.getContent()[0]};if(s.size>0){const O={};p.attributes=O,s.forEach((y,v)=>{O[v]=y})}r.push(p);break}case Nn:Bc(u,e)&&(f(),Ju(s,u.content));break}u=u.right}f()};return e||n?Bt(o,p=>{e&&ow(p,e),n&&ow(p,n),h()},"cleanup"):h(),r}insert(e,n,i){if(n.length<=0)return;const r=this.doc;r!==null?Bt(r,s=>{const o=Zg(s,this,e,!i);i||(i={},o.currentAttributes.forEach((l,u)=>{i[u]=l})),cS(s,this,o,n,i)}):this._pending.push(()=>this.insert(e,n,i))}insertEmbed(e,n,i){const r=this.doc;r!==null?Bt(r,s=>{const o=Zg(s,this,e,!i);cS(s,this,o,n,i||{})}):this._pending.push(()=>this.insertEmbed(e,n,i||{}))}delete(e,n){if(n===0)return;const i=this.doc;i!==null?Bt(i,r=>{SA(r,Zg(r,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,i){if(n===0)return;const r=this.doc;r!==null?Bt(r,s=>{const o=Zg(s,this,e,!1);o.right!==null&&bA(s,this,o,n,i)}):this._pending.push(()=>this.format(e,n,i))}removeAttribute(e){this.doc!==null?Bt(this.doc,n=>{cO(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Bt(this.doc,i=>{Vk(i,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return Bk(this,e)}getAttributes(){return tZ(this)}_write(e){e.writeTypeRef(Dhe)}}const Ohe=t=>new Lu;class uS{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??gi()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===Zu||n.constructor===Vl)&&n._start!==null)e=n._start;else for(;e!==null;){const i=e.next;if(i!==null){e=i;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Vl extends Vn{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Vl}clone(){const e=new Vl;return e.insert(0,this.toArray().map(n=>n instanceof Vn?n.clone():n)),e}get length(){return this.doc??gi(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new uS(this,e)}querySelector(e){e=e.toUpperCase();const i=new uS(this,r=>r.nodeName&&r.nodeName.toUpperCase()===e).next();return i.done?null:i.value}querySelectorAll(e){return e=e.toUpperCase(),Ro(new uS(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){ky(this,e,new bhe(this,n,e))}toString(){return H3(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},i){const r=e.createDocumentFragment();return i!==void 0&&i._createAssociation(r,this),uh(this,s=>{r.insertBefore(s.toDOM(e,n,i),null)}),r}insert(e,n){this.doc!==null?Bt(this.doc,i=>{J3(i,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Bt(this.doc,i=>{const r=e&&e instanceof Vn?e._item:e;lO(i,this,r,n)});else{const i=this._prelimContent,r=e===null?0:i.findIndex(s=>s===e)+1;if(r===0&&e!==null)throw Ls("Reference item not found");i.splice(r,0,...n)}}delete(e,n=1){this.doc!==null?Bt(this.doc,i=>{eZ(i,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return G3(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return W3(this,e)}slice(e=0,n=this.length){return F3(this,e,n)}forEach(e){uh(this,e)}_write(e){e.writeTypeRef(zhe)}}const yhe=t=>new Vl;class Zu extends Vl{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((i,r)=>{this.setAttribute(r,i)}),this._prelimAttrs=null}_copy(){return new Zu(this.nodeName)}clone(){const e=new Zu(this.nodeName),n=this.getAttributes();return rde(n,(i,r)=>{e.setAttribute(r,i)}),e.insert(0,this.toArray().map(i=>i instanceof Vn?i.clone():i)),e}toString(){const e=this.getAttributes(),n=[],i=[];for(const l in e)i.push(l);i.sort();const r=i.length;for(let l=0;l0?" "+n.join(" "):"";return`<${s}${o}>${super.toString()}`}removeAttribute(e){this.doc!==null?Bt(this.doc,n=>{cO(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Bt(this.doc,i=>{Vk(i,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return Bk(this,e)}hasAttribute(e){return nZ(this,e)}getAttributes(e){return e?lhe(this,e):tZ(this)}toDOM(e=document,n={},i){const r=e.createElement(this.nodeName),s=this.getAttributes();for(const o in s){const l=s[o];typeof l=="string"&&r.setAttribute(o,l)}return uh(this,o=>{r.appendChild(o.toDOM(e,n,i))}),i!==void 0&&i._createAssociation(r,this),r}_write(e){e.writeTypeRef(Nhe),e.writeKey(this.nodeName)}}const vhe=t=>new Zu(t.readKey());class bhe extends xy{constructor(e,n,i){super(e,i),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}}class uO extends zu{constructor(e){super(),this.hookName=e}_copy(){return new uO(this.hookName)}clone(){const e=new uO(this.hookName);return this.forEach((n,i)=>{e.set(i,n)}),e}toDOM(e=document,n={},i){const r=n[this.hookName];let s;return r!==void 0?s=r.createDom(this):s=document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),i!==void 0&&i._createAssociation(s,this),s}_write(e){e.writeTypeRef(Lhe),e.writeKey(this.hookName)}}const She=t=>new uO(t.readKey());class dO extends Lu{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new dO}clone(){const e=new dO;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,i){const r=e.createTextNode(this.toString());return i!==void 0&&i._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{const n=[];for(const r in e.attributes){const s=[];for(const o in e.attributes[r])s.push({key:o,value:e.attributes[r][o]});s.sort((o,l)=>o.keyr.nodeName=0;r--)i+=``;return i}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Zhe)}}const xhe=t=>new dO;class Uk{constructor(e,n){this.id=e,this.length=n}get deleted(){throw es()}mergeWith(e){return!1}write(e,n,i){throw es()}integrate(e,n){throw es()}}const whe=0;class Tr extends Uk{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),X3(e.doc.store,this)}write(e,n){e.writeInfo(whe),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Nh{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Nh(this.content)}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const khe=t=>new Nh(t.readBuf());class dh{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new dh(this.len)}splice(e){const n=new dh(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){sh(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const Che=t=>new dh(t.readLen()),aZ=(t,e)=>new Kl({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class zh{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new zh(aZ(this.doc.guid,this.opts))}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const _he=t=>new zh(aZ(t.readString(),t.readAny()));class Jl{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Jl(this.embed)}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const $he=t=>new Jl(t.readJSON());class Nn{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Nn(this.key,this.value)}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){const i=n.parent;i._searchMarker=null,i._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const The=t=>new Nn(t.readKey(),t.readJSON());class fO{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new fO(this.arr)}splice(e){const n=new fO(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const i=this.arr.length;e.writeLen(i-n);for(let r=n;r{const e=t.readLen(),n=[];for(let i=0;i{const e=t.readLen(),n=[];for(let i=0;i=55296&&i<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const Ahe=t=>new Is(t.readString()),Phe=[uhe,fhe,Ohe,vhe,yhe,She,xhe],jhe=0,Mhe=1,Dhe=2,Nhe=3,zhe=4,Lhe=5,Zhe=6;class Us{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Us(this.type._copy())}splice(e){throw es()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(i=>{i.deleted?i.id.clock<(e.beforeState.get(i.id.client)||0)&&e._mergeStructs.push(i):i.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(i=>{for(;i!==null;)i.gc(e,!0),i=i.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const Ihe=t=>new Us(Phe[t.readTypeRef()](t)),cw=(t,e)=>{let n=e,i=0,r;do i>0&&(n=nt(n.client,n.clock+i)),r=gu(t,n),i=n.clock-r.id.clock,n=r.redone;while(n!==null&&r instanceof Ut);return{item:r,diff:i}},qk=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},hO=(t,e,n)=>{const{client:i,clock:r}=e.id,s=new Ut(nt(i,r+n),e,nt(i,r+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=nt(e.redone.client,e.redone.clock+n)),e.right=s,s.right!==null&&(s.right.left=s),t._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=n,s},xA=(t,e)=>bk(t,n=>Mh(n.deletions,e)),lZ=(t,e,n,i,r,s)=>{const o=t.doc,l=o.store,u=o.clientID,f=e.redone;if(f!==null)return Xi(t,f);let h=e.parent._item,p=null,O;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||lZ(t,h,n,i,r,s)===null))return null;for(;h.redone!==null;)h=Xi(t,h.redone)}const y=h===null?e.parent:h.content.type;if(e.parentSub===null){for(p=e.left,O=e;p!==null;){let C=p;for(;C!==null&&C.parent._item!==h;)C=C.redone===null?null:Xi(t,C.redone);if(C!==null&&C.parent._item===h){p=C;break}p=p.left}for(;O!==null;){let C=O;for(;C!==null&&C.parent._item!==h;)C=C.redone===null?null:Xi(t,C.redone);if(C!==null&&C.parent._item===h){O=C;break}O=O.right}}else{if(O=null,e.right&&!r){for(p=e;p!==null&&p.right!==null&&(p.right.redone||Mh(i,p.right.id)||xA(s.undoStack,p.right.id)||xA(s.redoStack,p.right.id));)for(p=p.right;p.redone;)p=Xi(t,p.redone);if(p&&p.right!==null)return null}else p=y._map.get(e.parentSub)||null;p!==null&&p.parent._item!==h&&(p=y._map.get(e.parentSub)||null)}const v=Sn(l,u),S=nt(u,v),k=new Ut(S,p,p&&p.lastId,O,O&&O.id,y,e.parentSub,e.content.copy());return e.redone=S,qk(k,!0),k.integrate(t,0),k};class Ut extends Uk{constructor(e,n,i,r,s,o,l,u){super(e,u.getLength()),this.origin=i,this.left=n,this.right=r,this.rightOrigin=s,this.parent=o,this.parentSub=l,this.redone=null,this.content=u,this.info=this.content.isCountable()?GQ:0}set marker(e){(this.info&nS)>0!==e&&(this.info^=nS)}get marker(){return(this.info&nS)>0}get keep(){return(this.info&FQ)>0}set keep(e){this.keep!==e&&(this.info^=FQ)}get countable(){return(this.info&GQ)>0}get deleted(){return(this.info&tS)>0}set deleted(e){this.deleted!==e&&(this.info^=tS)}markDeleted(){this.info|=tS}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Sn(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Sn(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===pu&&this.id.client!==this.parent.client&&this.parent.clock>=Sn(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=hA(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Xi(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Tr||this.right&&this.right.constructor===Tr)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Ut?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Ut&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===pu){const i=gu(n,this.parent);i.constructor===Tr?this.parent=null:this.parent=i.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=hA(e,e.doc.store,nt(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let i=this.left,r;if(i!==null)r=i.right;else if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start;const s=new Set,o=new Set;for(;r!==null&&r!==this.right;){if(o.add(r),s.add(r),eu(this.origin,r.origin)){if(r.id.client{i.p===e&&(i.p=this,!this.deleted&&this.countable&&(i.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),sh(e.deleteSet,this.id.client,this.id.clock,this.length),gA(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw dr();this.content.gc(e),n?Bfe(e,this,new Tr(this.id,this.length)):this.content=new dh(this.length)}write(e,n){const i=n>0?nt(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&fy|(i===null?0:cr)|(r===null?0:_o)|(s===null?0:Jf);if(e.writeInfo(o),i!==null&&e.writeLeftID(i),r!==null&&e.writeRightID(r),i===null&&r===null){const l=this.parent;if(l._item!==void 0){const u=l._item;if(u===null){const f=L3(l);e.writeParentInfo(!0),e.writeString(f)}else e.writeParentInfo(!1),e.writeLeftID(u.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===pu?(e.writeParentInfo(!1),e.writeLeftID(l)):dr();s!==null&&e.writeString(s)}this.content.write(e,n)}}const cZ=(t,e)=>Xhe[e&fy](t),Xhe=[()=>{dr()},Che,Ehe,khe,Ahe,$he,The,Ihe,Qhe,_he,()=>{dr()}],Vhe=10;class Er extends Uk{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){dr()}write(e,n){e.writeInfo(Vhe),Be(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const uZ=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},dZ="__ $YJS$ __";uZ[dZ]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");uZ[dZ]=!0;class Yk{constructor(e,n){this.yanchor=e,this.yhead=n}toJSON(){return{yanchor:dA(this.yanchor),yhead:dA(this.yhead)}}static fromJSON(e){return new Yk(oh(e.yanchor),oh(e.yhead))}}class Bhe{constructor(e,n){this.ytext=e,this.awareness=n}toYPos(e,n=0){return ah(this.ytext,e,n)}fromYPos(e){const n=lh(oh(e),this.ytext.doc);if(n==null||n.type!==this.ytext)throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");return{pos:n.index,assoc:n.assoc}}toYRange(e){const n=e.assoc,i=this.toYPos(e.anchor,n),r=this.toYPos(e.head,n);return new Yk(i,r)}fromYRange(e){const n=this.fromYPos(e.yanchor),i=this.fromYPos(e.yhead);return n.pos===i.pos?Oe.cursor(i.pos,i.assoc):Oe.range(n.pos,i.pos)}}const Cy=Ne.define({combine(t){return t[t.length-1]}}),uw=ss.define();class Uhe{constructor(e){this.view=e,this.conf=e.state.facet(Cy),this._observer=(n,i)=>{if(i.origin!==this.conf){const r=n.delta,s=[];let o=0;for(let l=0;l0&&e.transactions[0].annotation(uw)===this.conf)return;const n=this.conf.ytext;n.doc.transact(()=>{let i=0;e.changes.iterChanges((r,s,o,l,u)=>{const f=u.sliceString(0,u.length,` +`);r!==s&&n.delete(r+i,s-r),f.length>0&&n.insert(r+i,f),i+=f.length-(s-r)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}}const qhe=Dr.fromClass(Uhe),Yhe=Ze.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:"0px 2px 0px 4px"},".cm-ySelectionCaret":{position:"relative",borderLeft:"1px solid black",borderRight:"1px solid black",marginLeft:"-1px",marginRight:"-1px",boxSizing:"border-box",display:"inline"},".cm-ySelectionCaretDot":{borderRadius:"50%",position:"absolute",width:".4em",height:".4em",top:"-.2em",left:"-.2em",backgroundColor:"inherit",transition:"transform .3s ease-in-out",boxSizing:"border-box"},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:"bottom center",transform:"scale(0)"},".cm-ySelectionInfo":{position:"absolute",top:"-1.05em",left:"-1px",fontSize:".75em",fontFamily:"serif",fontStyle:"normal",fontWeight:"normal",lineHeight:"normal",userSelect:"none",color:"white",paddingLeft:"2px",paddingRight:"2px",zIndex:101,transition:"opacity .3s ease-in-out",backgroundColor:"inherit",opacity:0,transitionDelay:"0s",whiteSpace:"nowrap"},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:"0s"}}),Fhe=ss.define();class Ghe extends qu{constructor(e,n){super(),this.color=e,this.name=n}toDOM(){return aS("span",[rr("class","cm-ySelectionCaret"),rr("style",`background-color: ${this.color}; border-color: ${this.color}`)],[Ng("⁠"),aS("div",[rr("class","cm-ySelectionCaretDot")]),Ng("⁠"),aS("div",[rr("class","cm-ySelectionInfo")],[Ng(this.name)]),Ng("⁠")])}eq(e){return e.color===this.color}compare(e){return e.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}}class Hhe{constructor(e){this.conf=e.state.facet(Cy),this._listener=({added:n,updated:i,removed:r},s,o)=>{n.concat(i).concat(r).findIndex(u=>u!==this.conf.awareness.doc.clientID)>=0&&e.dispatch({annotations:[Fhe.of([])]})},this._awareness=this.conf.awareness,this._awareness.on("change",this._listener),this.decorations=mt.of([])}destroy(){this._awareness.off("change",this._listener)}update(e){const n=this.conf.ytext,i=n.doc,r=this.conf.awareness,s=[],o=this.conf.awareness.getLocalState();if(o!=null){const l=e.view.hasFocus&&e.view.dom.ownerDocument.hasFocus(),u=l?e.state.selection.main:null,f=o.cursor==null?null:oh(o.cursor.anchor),h=o.cursor==null?null:oh(o.cursor.head);if(u!=null){const p=ah(n,u.anchor),O=ah(n,u.head);(o.cursor==null||!fA(f,p)||!fA(h,O))&&r.setLocalStateField("cursor",{anchor:p,head:O})}else o.cursor!=null&&l&&r.setLocalStateField("cursor",null)}r.getStates().forEach((l,u)=>{if(u===r.doc.clientID)return;const f=l.cursor;if(f==null||f.anchor==null||f.head==null)return;const h=lh(f.anchor,i),p=lh(f.head,i);if(h==null||p==null||h.type!==n||p.type!==n)return;const{color:O="#30bced",name:y="Anonymous"}=l.user||{},v=l.user&&l.user.colorLight||O+"33",S=dy(h.index,p.index),k=Ba(h.index,p.index),C=e.view.state.doc.lineAt(S),$=e.view.state.doc.lineAt(k);if(C.number===$.number)s.push({from:S,to:k,value:Tt.mark({attributes:{style:`background-color: ${v}`},class:"cm-ySelection"})});else{s.push({from:S,to:C.from+C.length,value:Tt.mark({attributes:{style:`background-color: ${v}`},class:"cm-ySelection"})}),s.push({from:$.from,to:k,value:Tt.mark({attributes:{style:`background-color: ${v}`},class:"cm-ySelection"})});for(let T=C.number+1;T<$.number;T++){const Q=e.view.state.doc.line(T).from;s.push({from:Q,to:Q,value:Tt.line({attributes:{style:`background-color: ${v}`,class:"cm-yLineSelection"}})})}}s.push({from:p.index,to:p.index,value:Tt.widget({side:p.index-h.index>0?-1:1,block:!1,widget:new Ghe(O,y)})})}),this.decorations=Tt.set(s,!0)}}const Whe=Dr.fromClass(Hhe,{decorations:t=>t.decorations});class Khe{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}}const _y=Ne.define({combine(t){return t[t.length-1]}});class Jhe{constructor(e){this.view=e,this.conf=e.state.facet(_y),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(Cy),this._beforeChangeSelection=null,this._onStackItemAdded=({stackItem:n,changedParentTypes:i})=>{i.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!n.meta.has(this)&&n.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:n})=>{const i=n.meta.get(this);if(i){const r=this.syncConf.fromYRange(i);e.dispatch(e.state.update({selection:r,effects:[Ze.scrollIntoView(r)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on("stack-item-added",this._onStackItemAdded),this._undoManager.on("stack-item-popped",this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){e.selectionSet&&(e.transactions.length===0||e.transactions[0].annotation(uw)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off("stack-item-added",this._onStackItemAdded),this._undoManager.off("stack-item-popped",this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}}const epe=Dr.fromClass(Jhe),tpe=({state:t,dispatch:e})=>t.facet(_y).undo()||!0,npe=({state:t,dispatch:e})=>t.facet(_y).redo()||!0,ipe=(t,e,{undoManager:n=new Gfe(t)}={})=>{const i=new Bhe(t,e),r=[Cy.of(i),qhe];return e&&r.push(Yhe,Whe),n!==!1&&r.push(_y.of(new Khe(n)),epe,Ze.domEventHandlers({beforeinput(s,o){return s.inputType==="historyUndo"?tpe(o):s.inputType==="historyRedo"?npe(o):!1}})),r},fZ=new Map;class rpe{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:xde(n.newValue||"")}),Jue(this._onChange)}postMessage(e){JL.setItem(this.room,Sde(mde(e)))}close(){ede(this._onChange)}}const spe=typeof BroadcastChannel>"u"?rpe:BroadcastChannel,Fk=t=>Vs(fZ,t,()=>{const e=Aa(),n=new spe(t);return n.onmessage=i=>e.forEach(r=>r(i.data,"broadcastchannel")),{bc:n,subs:e}}),ope=(t,e)=>(Fk(t).subs.add(e),e),ape=(t,e)=>{const n=Fk(t),i=n.subs.delete(e);return i&&n.subs.size===0&&(n.bc.close(),fZ.delete(t)),i},Uc=(t,e,n=null)=>{const i=Fk(t);i.bc.postMessage(e),i.subs.forEach(r=>r(e,n))},hZ=0,Gk=1,pZ=2,dw=(t,e)=>{Be(t,hZ);const n=zfe(e);yn(t,n)},gZ=(t,e,n)=>{Be(t,Gk),yn(t,jfe(e,n))},lpe=(t,e,n)=>gZ(e,n,li(t)),mZ=(t,e,n,i)=>{try{Qfe(e,li(t),n)}catch(r){i?.(r),console.error("Caught error while handling a Yjs update",r)}},cpe=(t,e)=>{Be(t,pZ),yn(t,e)},upe=mZ,dpe=(t,e,n,i,r)=>{const s=et(t);switch(s){case hZ:lpe(t,e,n);break;case Gk:mZ(t,n,i,r);break;case pZ:upe(t,n,i,r);break;default:throw new Error("Unknown message type")}return s},fpe=0,hpe=(t,e,n)=>{et(t)===fpe&&n(e,xa(t))},dS=3e4;class OZ extends vue{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=Pa();this.getLocalState()!==null&&dS/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const i=[];this.meta.forEach((r,s)=>{s!==this.clientID&&dS<=n-r.lastUpdated&&this.states.has(s)&&i.push(s)}),i.length>0&&Hk(this,i,"timeout")},ns(dS/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const n=this.clientID,i=this.meta.get(n),r=i===void 0?0:i.clock+1,s=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:r,lastUpdated:Pa()});const o=[],l=[],u=[],f=[];e===null?f.push(n):s==null?e!=null&&o.push(n):(l.push(n),fu(s,e)||u.push(n)),(o.length>0||u.length>0||f.length>0)&&this.emit("change",[{added:o,updated:u,removed:f},"local"]),this.emit("update",[{added:o,updated:l,removed:f},"local"])}setLocalStateField(e,n){const i=this.getLocalState();i!==null&&this.setLocalState({...i,[e]:n})}getStates(){return this.states}}const Hk=(t,e,n)=>{const i=[];for(let r=0;r0&&(t.emit("change",[{added:[],updated:[],removed:i},n]),t.emit("update",[{added:[],updated:[],removed:i},n]))},$f=(t,e,n=t.states)=>{const i=e.length,r=ci();Be(r,i);for(let s=0;s{const i=Ua(e),r=Pa(),s=[],o=[],l=[],u=[],f=et(i);for(let h=0;h0||l.length>0||u.length>0)&&t.emit("change",[{added:s,updated:l,removed:u},n]),(s.length>0||o.length>0||u.length>0)&&t.emit("update",[{added:s,updated:o,removed:u},n])},gpe=t=>sde(t,(e,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(e)}`).join("&"),wl=0,yZ=3,Ou=1,mpe=2,Lh=[];Lh[wl]=(t,e,n,i,r)=>{Be(t,wl);const s=dpe(e,t,n.doc,n);i&&s===Gk&&!n.synced&&(n.synced=!0)};Lh[yZ]=(t,e,n,i,r)=>{Be(t,Ou),yn(t,$f(n.awareness,Array.from(n.awareness.getStates().keys())))};Lh[Ou]=(t,e,n,i,r)=>{ppe(n.awareness,li(e),n)};Lh[mpe]=(t,e,n,i,r)=>{hpe(e,n.doc,(s,o)=>Ope(n,o))};const wA=3e4,Ope=(t,e)=>console.warn(`Permission denied to access ${t.url}. +${e}`),vZ=(t,e,n)=>{const i=Ua(e),r=ci(),s=et(i),o=t.messageHandlers[s];return o?o(r,i,t,n,s):console.error("Unable to compute message"),r},ype=t=>!(t.code>=4400&&t.code<4500),fw=(t,e,n)=>{if(e!==null&&e===t.ws){t.emit("connection-close",[n,t]),t.ws=null,e.onmessage=null,e.onopen=null,e.onclose=null,e.onerror=()=>{},e.close(),t.wsconnecting=!1,t.wsconnected&&(t.wsconnected=!1,t.synced=!1,Hk(t.awareness,Array.from(t.awareness.getStates().keys()).filter(r=>r!==t.doc.clientID),t),t.emit("status",[{status:"disconnected"}])),t.wsUnsuccessfulReconnects++;let i=null;n!=null&&!t.shouldReconnect(n,t)&&(t.shouldConnect=!1,i={code:n.code,reason:n.reason}),setTimeout(bZ,dy(bue(2,t.wsUnsuccessfulReconnects)*100,t.maxBackoffTime),t),i!==null&&t.emit("closed",[i,t])}},bZ=t=>{if(t.shouldConnect&&t.ws===null){const e=new t._WS(t.url,t.protocols);e.binaryType="arraybuffer",t.ws=e,t.wsconnecting=!0,t.wsconnected=!1,t.synced=!1,e.onmessage=n=>{if(t.ws!==e)return;t.wsLastMessageReceived=Pa();const i=vZ(t,new Uint8Array(n.data),!0);xk(i)>1&&e.send(tn(i))},e.onerror=n=>{t.ws===e&&t.emit("connection-error",[n,t])},e.onclose=n=>{fw(t,e,n)},e.onopen=()=>{if(t.ws!==e)return;t.wsLastMessageReceived=Pa(),t.wsconnecting=!1,t.wsconnected=!0,t.emit("status",[{status:"connected"}]);const n=ci();if(Be(n,wl),dw(n,t.doc),e.send(tn(n)),t.awareness.getLocalState()!==null){const i=ci();Be(i,Ou),yn(i,$f(t.awareness,[t.doc.clientID])),e.send(tn(i))}},t.emit("status",[{status:"connecting"}])}},fS=(t,e)=>{const n=t.ws;t.wsconnected&&n&&n.readyState===n.OPEN&&n.send(e),t.bcconnected&&Uc(t.bcChannel,e,t)};class vpe extends Sk{constructor(e,n,i,{connect:r=!0,awareness:s=new OZ(i),params:o={},protocols:l=[],WebSocketPolyfill:u=WebSocket,resyncInterval:f=-1,maxBackoffTime:h=2500,disableBc:p=!1,shouldReconnect:O=ype}={}){for(super();e[e.length-1]==="/";)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+n,this.maxBackoffTime=h,this.shouldReconnect=O,this.params=o,this.protocols=l,this.roomname=n,this.doc=i,this._WS=u,this.awareness=s,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=p,this.wsUnsuccessfulReconnects=0,this.messageHandlers=Lh.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,f>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const y=ci();Be(y,wl),dw(y,i),this.ws.send(tn(y))}},f)),this._bcSubscriber=(y,v)=>{if(v!==this){const S=vZ(this,new Uint8Array(y),!1);xk(S)>1&&Uc(this.bcChannel,tn(S),this)}},this._updateHandler=(y,v)=>{if(v!==this){const S=ci();Be(S,wl),cpe(S,y),fS(this,tn(S))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:y,updated:v,removed:S},k)=>{const C=y.concat(v).concat(S),$=ci();Be($,Ou),yn($,$f(s,C)),fS(this,tn($))},this._exitHandler=()=>{Hk(this.awareness,[i.clientID],"app closed")},ja&&typeof process<"u"&&process.on("exit",this._exitHandler),s.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&wA{this.closed||this.onStatus(s.status==="connected"?"live":"offline")}),r.on("sync",s=>{s&&!this.closed&&this.onReady()}),setTimeout(()=>{!this.closed&&!r.synced&&this.onUnavailable()},Spe)}peerCount(){return Math.max(0,this.awareness.getStates().size-1)}destroy(){this.closed=!0,this.ws?.destroy(),this.ws=null,this.awareness.destroy(),this.doc.destroy()}}const Spe=8e3,SZ=700;function xZ(t){let e=t.seed,n=t.baseSha;const i=new Set;let r=null;const s=v=>t.onState?.(v),o=v=>t.apiBase+"upload/content?path="+encodeURIComponent(v),l=async v=>{if(!i.has(v)){if(v===e){s("clean");return}s("saving"),t.onWriting?.(),i.add(v);try{const S=await s2(o(t.path),v,n);e=v,S.sha&&(n=S.sha),s("clean"),t.onSaved?.(v)}catch(S){if(S instanceof xw&&S.status===409){i.delete(v),await u(v,S);return}s("error")}finally{i.delete(v)}}},u=async(v,S)=>{let k="";try{k=JSON.parse(S.body).sha??""}catch{}const C=qte(t.path,t.who||"browser",new Date);try{await s2(o(C),v),e=v,n=k,s("clean"),t.onConflictCopy?.(C)}catch{s("error")}},f=new bpe(t.apiBase+"ycollab?path="+encodeURIComponent(t.path),v=>t.onCollab?.(v),()=>t.onReady(f),()=>t.onSolo(),t.me),h=()=>{s("dirty"),r&&clearTimeout(r),r=setTimeout(()=>l(f.text.toString()),SZ)};f.text.observe(h);const p=()=>t.onPeers?.(f.peerCount());f.awareness.on("change",p),f.connect();const O=()=>f.text.length?f.text.toString():t.soloText?.()??"";return{collab:f,current:O,merge:v=>{if(v===e||i.has(v))return"same";const S=O();if(v===S)return e=v,"same";if(S!==e||f.peerCount()>0)return"blocked";const k=Hte(S,v);return k?!f.text.length&&!t.soloApply?"blocked":(e=v,f.text.length?f.doc.transact(()=>{f.text.delete(k.from,k.to-k.from),f.text.insert(k.from,k.insert)}):t.soloApply(k),"merged"):"same"},saveNow:()=>l(O()),destroy(){r&&clearTimeout(r);const v=O();v&&v!==e&&l(v),f.awareness.off("change",p),f.text.unobserve(h),f.destroy()}}}function xpe({apiBase:t,path:e,initial:n,onSaved:i,onWriting:r,onStateChange:s,onCollab:o,onPeers:l,onExternal:u,onConflictCopy:f,baseSha:h,me:p}){const O=w.useRef(null),y=w.useRef(null),v=w.useRef({onSaved:i,onWriting:r,onStateChange:s,onCollab:o,onPeers:l,onExternal:u,onConflictCopy:f});v.current={onSaved:i,onWriting:r,onStateChange:s,onCollab:o,onPeers:l,onExternal:u,onConflictCopy:f};const S=w.useRef(n),k=w.useRef(n),C=w.useRef(null),$=w.useRef(null);w.useEffect(()=>{if(n===k.current)return;S.current=n;const A=C.current;v.current.onExternal?.(A&&$.current?A.merge(n):"blocked")},[n]);const T=w.useRef(p);T.current=p;const Q=w.useRef(h);return Q.current=h,w.useEffect(()=>{if(!O.current)return;let A=null;const R=[jre(),wre(),jse(),uue(),pse(Ose,{fallback:!0}),iy.of([...Doe,...Vse,Noe]),Ze.lineWrapping],P=Ze.updateListener.of(Y=>{Y.docChanged&&(v.current.onStateChange?.("dirty"),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{G.saveNow()},SZ))}),X=()=>{A||!O.current||(A=new Ze({parent:O.current,state:St.create({doc:S.current,extensions:[...R,P]})}),$.current=A,A.focus())},te=()=>{A||!O.current||(A=new Ze({parent:O.current,state:St.create({doc:G.collab.text.toString(),extensions:[...R,ipe(G.collab.text,G.collab.awareness)]})}),$.current=A,A.focus())},G=xZ({apiBase:t,path:e,seed:S.current,baseSha:Q.current,who:T.current?.name,me:T.current,onConflictCopy:Y=>v.current.onConflictCopy?.(Y),onReady:()=>te(),onSolo:()=>X(),onState:Y=>v.current.onStateChange?.(Y),onCollab:Y=>v.current.onCollab?.(Y),onPeers:Y=>v.current.onPeers?.(Y),onSaved:Y=>v.current.onSaved?.(Y),onWriting:()=>v.current.onWriting?.(),soloText:()=>A?.state.doc.toString()??"",soloApply:Y=>A?.dispatch({changes:Y})});return C.current=G,()=>{y.current&&clearTimeout(y.current),C.current=null,$.current=null,G.destroy(),A?.destroy()}},[t,e]),m.jsx("div",{ref:O,id:"editor",className:"cm-host"})}async function wpe(t){if(!globalThis.crypto?.subtle)return null;try{const e=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return[...new Uint8Array(e)].map(n=>n.toString(16).padStart(2,"0")).join("")}catch{return null}}function kpe({apiBase:t,fileURL:e,path:n,initial:i,me:r,onStateChange:s,onCollab:o,onPeers:l,onConflictCopy:u,baseSha:f,onSaved:h,onWriting:p,onRendered:O}){const y=w.useRef(null),[v,S]=w.useState(null),[k,C]=w.useState(!1),[$,T]=w.useState(!1),Q=w.useRef(0),[A,R]=w.useState(0),P=w.useRef({onStateChange:s,onCollab:o,onPeers:l,onSaved:h,onWriting:p,onRendered:O,onConflictCopy:u});P.current={onStateChange:s,onCollab:o,onPeers:l,onSaved:h,onWriting:p,onRendered:O,onConflictCopy:u};const X=w.useRef(i),te=w.useRef(r);te.current=r;const G=w.useRef(f);return G.current=f,w.useEffect(()=>{let Y=null,K=!1;C(!1),T(!1);const se=setTimeout(()=>{!D&&Q.current<1&&(Q.current++,R(N=>N+1))},11e3),H=setTimeout(()=>T(!0),24e3),pe=xZ({apiBase:t,path:n,seed:X.current,baseSha:G.current,who:te.current?.name,me:te.current,onConflictCopy:N=>P.current.onConflictCopy?.(N),onReady:()=>{K=!0,ce()},onSolo:()=>{pe.collab.text.length||pe.collab.text.insert(0,X.current),K=!0,ce()},onState:N=>P.current.onStateChange?.(N),onCollab:N=>P.current.onCollab?.(N),onPeers:N=>P.current.onPeers?.(N),onSaved:N=>P.current.onSaved?.(N),onWriting:()=>P.current.onWriting?.(),soloText:()=>X.current}),z=new Map,W=N=>N.start+","+N.end,ce=async()=>{if(D||!Y||!K)return;const N=pe.collab.text.toString();if(!N)return;if(Y.some(ie=>ie.end>N.length||ie.start>ie.end)){Y=null,R(ie=>ie+1);return}const V=await wpe(N);if(V!==null?V!==oe:ae>=0&&N.length!==ae){Y=null,R(ie=>ie+1);return}z.clear();for(const ie of Y)z.set(W(ie),{from:ah(pe.collab.text,ie.start),to:ah(pe.collab.text,ie.end),span:ie.end-ie.start});D=!0,C(!0),P.current.onRendered?.()};let oe="",ae=-1,D=!1;const j=async N=>{if(!y.current||N.source!==y.current.contentWindow)return;const V=N.data;if(!V||typeof V!="object")return;if(V.type==="bd-edit:clobbered"){S("This page rewrites itself as it runs, and it replaced the part you were editing. That edit was not saved.");return}if(V.type==="bd-edit:ready"){Y=V.ranges,oe=V.hash,ae=V.len,await ce();return}if(V.type!=="bd-edit:patch")return;const ne=z.get(W(V));if(!ne)return;const ie=pe.collab.doc,ye=lh(ne.from,ie),xe=lh(ne.to,ie);if(!ye||!xe||ye.index>xe.index)return;const Le=pe.collab.text,Ue=xe.index-ye.index;if(ye.index===0&&xe.index===Le.length&&ne.spanne.span*4+256){console.warn("bdrive: refusing an implausible patch range",{span:Ue,stamped:ne.span,docLength:Le.length}),z.clear(),D=!1,R(Et=>Et+1);return}Le.toString().slice(ye.index,xe.index)!==V.html&&ie.transact(()=>{Le.delete(ye.index,Ue),Le.insert(ye.index,V.html)})},I=()=>{ce()};return pe.collab.text.observe(I),window.addEventListener("message",j),()=>{clearTimeout(se),clearTimeout(H),pe.collab.text.unobserve(I),setTimeout(()=>{window.removeEventListener("message",j),pe.destroy()},300)}},[t,n,A]),m.jsxs(m.Fragment,{children:[v&&m.jsx("div",{id:"edit-clobbered",className:"banner",children:v}),$&&!k&&m.jsxs("div",{id:"edit-not-ready",className:"banner",children:["This file could not be opened for editing — the shared document never loaded. Reload the page to try again, or use ",m.jsx("b",{children:"Edit source"}),"."]}),m.jsx("iframe",{ref:y,className:"htmlview",sandbox:"allow-scripts",src:e+(e.includes("?")?"&":"?")+"edit=1",title:n},A)]})}function Cpe(t){const{apiBase:e,path:n,version:i,onMeta:r}=t,s=Nf(e,n,i);return w.useEffect(()=>()=>r(""),[n,r]),t.editing?m.jsx(Epe,{...t}):PM.test(n)?m.jsx(Rpe,{...t}):Fc.test(n)?m.jsx(_pe,{...t,fileURL:s}):Bg.test(n)?m.jsx("iframe",{className:"pdfview",src:s,title:n,onLoad:t.onRendered}):jM.test(n)?m.jsx(Mpe,{src:s,alt:n,version:i,onRendered:t.onRendered}):gq.test(n)?m.jsx(kA,{...t,fileURL:s,delim:/\.tsv$/i.test(n)?" ":","}):mq.test(n)?m.jsx(kA,{...t,fileURL:s}):m.jsx($pe,{...t,fileURL:s})}function _pe(t){const{path:e,fileURL:n,onRendered:i}=t,[r,s]=w.useState(0);return w.useEffect(()=>{const o=l=>{l.detail?.includes(e)&&s(u=>u+1)};return window.addEventListener("bdrive:changed",o),()=>window.removeEventListener("bdrive:changed",o)},[e]),m.jsx("iframe",{className:"htmlview",sandbox:"allow-scripts",src:n,title:e,onLoad:i},r)}function $pe(t){const{apiBase:e,path:n,version:i,fileURL:r,onRendered:s}=t,{data:o,error:l}=P1(r,["text",r],!0,!!i);return w.useEffect(()=>{o&&s?.()},[o,s]),l?m.jsx($y,{version:i,err:l}):o?o.kind==="text"?m.jsx("pre",{className:"plain",children:o.text},n):m.jsx(Tpe,{apiBase:e,path:n,version:i,fileURL:r,children:o.kind==="too-large"?`Too large to preview (${s1(o.size)}).`:"No preview for this file type."}):null}function Tpe(t){const{apiBase:e,path:n,version:i,fileURL:r}=t;return m.jsxs("div",{className:"filecard",children:[m.jsx("div",{className:"name",children:n.split("/").pop()}),m.jsx("p",{children:t.children}),m.jsx("a",{className:"btn",download:!0,href:i?r+"&download=1":e+"download?path="+encodeURIComponent(n),children:"Download"})]})}function Epe(t){const{apiBase:e,path:n,onMeta:i}=t,r=Fc.test(n)&&!t.editSource,s=Nf(e,n),{data:o,error:l}=P1(s,["text",s],!0,!1),[u,f]=w.useState("clean"),[h,p]=w.useState("connecting"),[O,y]=w.useState(!1),v=w.useRef(0),S=w.useRef(0),k=C=>{Ve("Someone else saved this file first. Your version is beside it as "+(C.split("/").pop()??C))};return w.useEffect(()=>{const C=$=>{if($.detail?.includes(n)&&r){if(v.current>0){v.current--;return}S.current>0||y(!0)}};return window.addEventListener("bdrive:changed",C),()=>window.removeEventListener("bdrive:changed",C)},[n,r]),w.useEffect(()=>{i(m.jsx("span",{id:"editor-state","data-state":u,"data-collab":h,children:u==="saving"?"saving…":u==="dirty"?"unsaved":u==="error"?"save failed — still trying":"saved"}))},[u,h,i]),l&&!o?m.jsxs("div",{className:"empty",children:["Could not open ",n," for editing."]}):o?o.kind!=="text"?m.jsx("div",{className:"empty",children:"This file is not text, so it cannot be edited here."}):m.jsxs(m.Fragment,{children:[l&&m.jsx("div",{id:"read-stale",className:"banner",children:"Could not check this file for changes just now — your work is untouched and still saving. Retrying."}),O&&m.jsx("div",{id:"peer-wrote",className:"banner",children:"Someone else changed this file while you were editing. Your buffer is unchanged — saving keeps your version and theirs stays in history."}),r?m.jsx(kpe,{apiBase:e,fileURL:s,path:n,initial:o.text,baseSha:o.sha,onConflictCopy:k,onWriting:()=>{v.current++},onStateChange:f,onCollab:p,onPeers:C=>{S.current=C},me:t.me,onRendered:t.onRendered}):m.jsx(xpe,{apiBase:e,path:n,initial:o.text,baseSha:o.sha,onConflictCopy:k,onExternal:C=>{y(C==="blocked"),C==="merged"&&Ve("Folded in a change from outside this editor.")},onWriting:()=>{v.current++},onStateChange:f,onCollab:p,onPeers:C=>{S.current=C},me:t.me})]}):m.jsx("div",{className:"empty",children:"Loading…"})}function Rpe(t){const{apiBase:e,path:n,version:i,heatMap:r,flatFiles:s,projectId:o,onOpenFile:l,onMeta:u,onRendered:f}=t,{data:h,error:p}=nn({queryKey:["render",e,n,i||""],queryFn:()=>Wt(e+"render?path="+encodeURIComponent(n)+(i?"&sha="+i:"")),retry:i?!1:void 0}),O=w.useMemo(()=>h?jpe(h.html,n,e,s,o):"",[h,n,e,s,o]),[y,v]=w.useState(null);return w.useEffect(()=>{if(v(null),!BI(O))return;let S=!1;return UI(O).then(k=>{S||v(k)}),()=>{S=!0}},[O]),w.useEffect(()=>{if(!h)return;const S=[],k=i?null:r&&r[h.path],C=yN(k||null,h.time);(h.user_name||h.user||h.author)&&S.push(MO(h)+(h.device?" on "+h.device:"")),h.time&&S.push(new Date(h.time).toLocaleString());const $=k&&vo(k)?df(k)+" / 30d":"",T=C?m.jsxs("span",{className:"meta-stale",title:C,children:[m.jsx("span",{"aria-hidden":"true",children:"⚠ "}),C]}):null;u($?m.jsxs(m.Fragment,{children:[T,T?" · ":"",S.length?S.join(" · ")+" · ":"",m.jsxs("span",{title:_l,children:[$,m.jsxs("span",{className:"sr-only",children:[" — ",_l]})]})]}):T?m.jsxs(m.Fragment,{children:[T,S.length?" · "+S.join(" · "):""]}):S.join(" · "))},[h,i,r,u]),w.useEffect(()=>{O&&f?.()},[O,y,f]),p?m.jsx($y,{version:i,err:p}):h?m.jsxs(m.Fragment,{children:[m.jsx(Ape,{findings:h.findings}),h.frontmatter?.length?m.jsx(Qpe,{pairs:h.frontmatter}):null,m.jsx("div",{dangerouslySetInnerHTML:{__html:y??O},onClick:S=>Ppe(S,n,l)})]}):null}function Qpe({pairs:t}){const[e,n]=w.useState(xq);return m.jsxs("details",{className:"fmpanel",open:e,children:[m.jsx("summary",{onClick:i=>{i.preventDefault(),n(!e),wq(!e)},children:"Properties"}),m.jsx("dl",{children:t.map(i=>m.jsxs("div",{children:[m.jsx("dt",{children:i.key}),m.jsx("dd",{children:i.code?m.jsx("code",{children:i.value}):i.value})]},i.key))})]})}function Ape({findings:t}){return t?.length?m.jsxs("div",{className:"sbadge",role:"status",children:[m.jsx("span",{className:"sb-icon",children:m.jsx(st,{name:"shield"})}),m.jsxs("div",{className:"sb-text",children:[m.jsx("b",{children:ane(t)}),m.jsx("span",{children:"Checked when this page loaded. Sharing the file asks you to confirm first."})]})]}):null}function Ppe(t,e,n){const i=t.target.closest("a");if(!i||!t.currentTarget.contains(i)||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.button!==0)return;const r=i.getAttribute("href")||"",s=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",o=i.getAttribute("data-wiki");o!==null?(t.preventDefault(),n(o)):/^([a-z]+:|\/|#)/i.test(r)||(t.preventDefault(),n(MM(s,decodeURIComponent(r))))}function jpe(t,e,n,i,r){const s=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",o=u=>n+"file?path="+encodeURIComponent(u),l=new DOMParser().parseFromString(t,"text/html");for(const u of l.querySelectorAll("img")){const f=u.getAttribute("src")||"";/^\s*data:image\/svg/i.test(f)?u.removeAttribute("src"):/^([a-z]+:|\/)/i.test(f)||u.setAttribute("src",o(MM(s,f)))}for(const u of l.querySelectorAll("a")){const f=u.getAttribute("href")||"";if(f.startsWith("wiki:")){const h=yq(decodeURIComponent(f.slice(5)),i);h?(u.setAttribute("href",Yr(h.path,r)),u.setAttribute("data-wiki",h.path)):(u.removeAttribute("href"),u.classList.add("wiki-missing"),u.setAttribute("title","No file matches this wikilink"));continue}/^\s*data:/i.test(f)?u.removeAttribute("href"):/^https?:/i.test(f)&&(u.setAttribute("target","_blank"),u.setAttribute("rel","noopener"))}return l.body.innerHTML}function Mpe(t){const[e,n]=w.useState(!1);return e?m.jsx($y,{version:t.version,err:new Error("could not be loaded")}):m.jsx("img",{src:t.src,alt:t.alt,onLoad:t.onRendered,onError:()=>n(!0)})}function $y({version:t,err:e}){return m.jsx("div",{className:"empty",children:t?"That version isn't available.":"Could not load file: "+e.message})}function kA(t){const{path:e,version:n,fileURL:i,delim:r,onRendered:s}=t,{data:o,error:l}=nn({queryKey:["text",i],queryFn:async()=>{const f=await fetch(i);if(!f.ok)throw new Error(await f.text());return f.text()},retry:n?!1:void 0});w.useEffect(()=>{o!=null&&s?.()},[o,s]);const u=w.useMemo(()=>r&&o!=null?ine(o,r,CN):null,[o,r]);return l?m.jsx($y,{version:n,err:l}):o==null?null:u?m.jsx(Dpe,{csv:u},e):m.jsx("pre",{className:"plain",children:o},e)}function Dpe({csv:t}){const[e,...n]=t.rows,i=t.rows.reduce((s,o)=>Math.max(s,o.length),0),r=Array.from({length:i},(s,o)=>o);return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"csvbox",children:m.jsxs("table",{className:"csvview",children:[m.jsx("thead",{children:m.jsx("tr",{children:r.map(s=>m.jsx("th",{children:e[s]??""},s))})}),m.jsx("tbody",{children:n.map((s,o)=>m.jsx("tr",{children:r.map(l=>m.jsx("td",{children:s[l]??""},l))},o))})]})}),t.truncated>0&&m.jsxs("p",{className:"csvnote",children:["showing ",t.rows.length.toLocaleString()," of"," ",(t.rows.length+t.truncated).toLocaleString()," rows — Download for the rest"]})]})}const Npe=[{value:"",label:"Never"},{value:"24h",label:"In 24 hours"},{value:"168h",label:"In 7 days"},{value:"720h",label:"In 30 days"}],wZ=[{value:"",label:"Same as the project"},{value:"write",label:"Write"},{value:"read",label:"Read"},{value:"none",label:"No access"}],CA=wZ.filter(t=>t.value!=="");function zpe({project:t,path:e,isDir:n,shares:i,onChanged:r,onOpenFolder:s,onClose:o}){const l=fr(),{data:u}=nD(t.id),{data:f}=c1(t.id),{data:h}=tD(!!t.org),p=h?.find(N=>N.id===t.org)?.name||"this workspace",O=_s(t.perm,"admin"),y=_s(t.perm,"write"),v=n?e+"/":e,S=w.useMemo(()=>u?.folders||[],[u]),k=n?S.find(N=>N.prefix===v):void 0,C=SN(S,v),[$,T]=w.useState(null),Q=i.find(N=>N.path===e)||$||void 0,[A,R]=w.useState(!1),[P,X]=w.useState(""),[te,G]=w.useState("read"),[Y,K]=w.useState(null),[se,H]=w.useState(""),pe=w.useRef(null),z=()=>{l.invalidateQueries({queryKey:["folders",t.id]}),r()},W=async(N,V)=>{R(!0);try{await N(),Ve(V)}catch(ne){Ve(ne.message,!0)}finally{R(!1),z()}},ce=N=>{const V=N.perms??Object.fromEntries((k?.grants||[]).map(ie=>[ie.email,ie.level])),ne=N.level??k?.default??"";return ne===""&&Object.keys(V).length===0?di("DELETE",`/api/p/${t.id}/folders?prefix=${encodeURIComponent(v)}`):di("PUT",`/api/p/${t.id}/folders`,{prefix:v,default:ne,perms:V})};async function oe(N){R(!0);try{const V=await fetch(`/api/p/${t.id}/shares`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N?{path:e,confirm:!0}:{path:e})});if(V.status===409){const{findings:ye}=await V.json();K(ye||[]);return}if(!V.ok)throw new Error(await V.text());const ne=await V.json();T({token:ne.token,url:ne.url,path:e,project:t.id}),K(null),KA("share_created");const ie=await zs(ne.url);Ve(ie?"Link created and copied.":"Link created."),r()}catch(V){Ve("Share failed: "+V.message,!0)}finally{R(!1)}}async function ae(N){if(N==="public")return oe(!1);K(null),T(null),Q&&await W(()=>di("DELETE",`/api/shares/${Q.token}`),"Link revoked — the URL no longer works.")}async function D(N){if(!Q)return;const V=se;H(N);try{await di("PATCH",`/api/shares/${Q.token}`,{expires_in:N}),r()}catch(ne){Ve(ne.message,!0),H(V)}}const j=S.filter(N=>N.prefix!==v&&N.prefix.startsWith(v)),I=`Share "${e.split("/").pop()||t.name}"`;return m.jsx(NO,{open:!0,onOpenChange:N=>!N&&o(),children:m.jsxs(zO,{className:"modal modal-wide",showCloseButton:!1,onOpenAutoFocus:N=>{N.preventDefault(),pe.current?.focus()},children:[m.jsx(vh,{asChild:!0,children:m.jsx("h3",{children:I})}),m.jsx("h4",{className:"sd-head",children:"Who can open this"}),n?m.jsxs(m.Fragment,{children:[m.jsxs("p",{className:"ps-row",children:[m.jsxs("span",{children:["Everyone in ",p," can"]}),m.jsx("select",{"aria-label":"Access for everyone in the workspace",disabled:!O||A,value:k?.default??"",onChange:N=>W(()=>ce({level:N.target.value}),"Folder access updated."),children:wZ.map(N=>m.jsx("option",{value:N.value,children:N.label},N.value))}),!k?.default&&f&&m.jsxs("span",{className:"ai-tag",children:["the project default is ",f.default]})]}),k?.default==="none"&&m.jsxs("p",{className:"ps-note",children:["A folder set to ",m.jsx("b",{children:"no access"})," is not synced to anyone outside the list below, and disappears from their file tree, history and search. Older share links into it stop working. Its ",m.jsx("i",{children:"name"})," stays visible to project members — their devices have to know not to write there. If the name has to be secret too, use a separate project."]}),j.length>0&&m.jsx("p",{className:"ps-note",children:j.length===1?`${j[0].prefix} has its own rule and keeps it — this does not reach inside it.`:`${j.length} folders inside have their own rules and keep them — this does not reach inside them.`}),(k?.grants.length||O)&&m.jsxs("div",{className:"admin-list sd-people",children:[(k?.grants||[]).map(N=>m.jsxs("div",{className:"admin-item",children:[m.jsx("span",{className:"avatar sd-avatar",style:{background:xu(N.email)},"aria-hidden":"true",children:(N.email.trim()[0]||"?").toUpperCase()}),m.jsx("span",{className:"ai-main",title:N.email,children:N.email}),m.jsx("span",{className:"role-cell",children:m.jsx("select",{"aria-label":`Access to this folder for ${N.email}`,disabled:!O||A,value:N.level,onChange:V=>{const ne=Object.fromEntries((k?.grants||[]).map(ie=>[ie.email,ie.level]));ne[N.email]=V.target.value,W(()=>ce({perms:ne}),`${N.email} updated.`)},children:CA.map(V=>m.jsx("option",{value:V.value,children:V.label},V.value))})})]},N.email)),O&&m.jsxs("div",{className:"admin-item sd-add",children:[m.jsx("input",{className:"sd-add-input",placeholder:"Email of a workspace member","aria-label":"Add someone to this folder",value:P,disabled:A,onChange:N=>X(N.target.value)}),m.jsxs("span",{className:"role-cell",children:[m.jsx("select",{"aria-label":"Access for the person being added",value:te,disabled:A,onChange:N=>G(N.target.value),children:CA.map(N=>m.jsx("option",{value:N.value,children:N.label},N.value))}),m.jsx(at,{variant:"subtle",disabled:!P.trim()||A,onClick:()=>{const N=Object.fromEntries((k?.grants||[]).map(ne=>[ne.email,ne.level]));N[P.trim().toLowerCase()]=te;const V=P.trim();X(""),W(()=>ce({perms:N}),`${V} added.`)},children:"Add"})]})]})]})]}):m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"ps-row",children:C?m.jsxs("span",{children:["Access comes from the rule on ",m.jsx("b",{children:C.prefix})," — you can"," ",m.jsx("b",{children:C.me})," here."]}):m.jsxs("span",{children:["Everyone in ",p," with access to this project can open it",f&&m.jsxs(m.Fragment,{children:[" — the project default is ",m.jsx("b",{children:f.default})]}),"."]})}),C&&m.jsx("p",{className:"ps-row",children:m.jsxs(at,{variant:"subtle",onClick:()=>s(C.prefix.replace(/\/$/,"")),children:["Open sharing for ",C.prefix]})})]}),m.jsx("h4",{className:"sd-head",children:"Public link"}),n?m.jsx("p",{className:"ps-note",children:"Public links are per file — open a file inside this folder to share it with someone who has no account."}):m.jsxs(m.Fragment,{children:[m.jsxs("p",{className:"ps-row",children:[m.jsx("span",{children:m.jsx(st,{name:Q?"globe":"lock"})}),m.jsxs("select",{"aria-label":"Public link",id:"share-public",disabled:!y||A,value:Q?"public":"restricted",onChange:N=>ae(N.target.value),children:[m.jsx("option",{value:"restricted",children:"Restricted — only people with access"}),m.jsx("option",{value:"public",children:"Anyone with the link can view"})]})]}),Y&&m.jsxs(m.Fragment,{children:[m.jsx("p",{className:"sd-warn",children:m.jsx("b",{children:"This file may contain credentials"})}),m.jsx("p",{className:"ps-note",children:one(Y)}),m.jsxs("p",{className:"ps-row",children:[m.jsx(at,{variant:"primary",disabled:A,onClick:()=>oe(!0),children:"Share anyway"}),m.jsx(at,{variant:"subtle",disabled:A,onClick:()=>K(null),children:"Cancel"})]})]}),Q&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"modal-url",children:Q.url}),m.jsxs("div",{className:"modal-expiry",children:[m.jsx("label",{htmlFor:"share-expiry",children:"Expires"}),m.jsx("select",{id:"share-expiry",value:se,disabled:!y||A,onChange:N=>D(N.target.value),children:Npe.map(N=>m.jsx("option",{value:N.value,children:N.label},N.value))}),m.jsx("span",{className:"modal-expiry-note",children:oN(Q.expires)})]})]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx(at,{ref:pe,variant:"primary",onClick:()=>zs(Q?Q.url:window.location.href).then(N=>Ve(N?"Copied.":"Select and copy the link above.")),children:"Copy link"}),m.jsx(at,{variant:"subtle",onClick:o,children:"Done"})]})]})})}function Lpe({shares:t,canRevoke:e,onChanged:n}){return t.length===0?null:m.jsxs("div",{className:"share-banner",role:"status",children:[m.jsxs("div",{className:"sb-head",children:[m.jsx(st,{name:"share"}),m.jsx("b",{children:"Publicly shared"}),m.jsxs("span",{className:"sb-count",children:[t.length," active link",t.length>1?"s":""]})]}),m.jsxs("p",{className:"sb-note",children:[m.jsx("b",{children:"Anyone with this link can view this file"})," — no account needed. It always shows the latest version until you revoke it.",t.some(i=>i.opens!==void 0)&&m.jsxs(m.Fragment,{children:[" ",lN]})]}),t.map(i=>m.jsxs("div",{className:"sb-link",children:[m.jsx("span",{className:"sb-url mono",title:i.url,children:i.url}),m.jsx("span",{className:"sb-meta",children:aN(i,!1)}),m.jsxs("span",{className:"sb-actions",children:[m.jsx(at,{variant:"subtle",onClick:()=>zs(i.url).then(r=>Ve(r?"Copied.":"Select and copy the link.")),children:"Copy link"}),m.jsx(at,{variant:"subtle",onClick:()=>window.open(i.url,"_blank"),children:"Open"}),e&&m.jsx("button",{className:"ai-del","aria-label":`Revoke the share of ${i.path}`,onClick:()=>uN(i,n),children:"Revoke"})]})]},i.token))]})}var _A=1,Zpe=.9,Ipe=.8,Xpe=.17,hS=.1,pS=.999,Vpe=.9999,Bpe=.99,Upe=/[\\\/_+.#"@\[\(\{&]/,qpe=/[\\\/_+.#"@\[\(\{&]/g,Ype=/[\s-]/,kZ=/[\s-]/g;function hw(t,e,n,i,r,s,o){if(s===e.length)return r===t.length?_A:Bpe;var l=`${r},${s}`;if(o[l]!==void 0)return o[l];for(var u=i.charAt(s),f=n.indexOf(u,r),h=0,p,O,y,v;f>=0;)p=hw(t,e,n,i,f+1,s+1,o),p>h&&(f===r?p*=_A:Upe.test(t.charAt(f-1))?(p*=Ipe,y=t.slice(r,f-1).match(qpe),y&&r>0&&(p*=Math.pow(pS,y.length))):Ype.test(t.charAt(f-1))?(p*=Zpe,v=t.slice(r,f-1).match(kZ),v&&r>0&&(p*=Math.pow(pS,v.length))):(p*=Xpe,r>0&&(p*=Math.pow(pS,f-r))),t.charAt(f)!==e.charAt(s)&&(p*=Vpe)),(pp&&(p=O*hS)),p>h&&(h=p),f=n.indexOf(u,f+1);return o[l]=h,h}function $A(t){return t.toLowerCase().replace(kZ," ")}function Fpe(t,e,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,hw(t,e,$A(t),$A(e),0,0,{})}var af='[cmdk-group=""]',gS='[cmdk-group-items=""]',Gpe='[cmdk-group-heading=""]',CZ='[cmdk-item=""]',TA=`${CZ}:not([aria-disabled="true"])`,pw="cmdk-item-select",qc="data-value",Hpe=(t,e,n)=>Fpe(t,e,n),_Z=w.createContext(void 0),Zh=()=>w.useContext(_Z),$Z=w.createContext(void 0),Wk=()=>w.useContext($Z),TZ=w.createContext(void 0),EZ=w.forwardRef((t,e)=>{let n=Yc(()=>{var j,I;return{search:"",value:(I=(j=t.value)!=null?j:t.defaultValue)!=null?I:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=Yc(()=>new Set),r=Yc(()=>new Map),s=Yc(()=>new Map),o=Yc(()=>new Set),l=RZ(t),{label:u,children:f,value:h,onValueChange:p,filter:O,shouldFilter:y,loop:v,disablePointerSelection:S=!1,vimBindings:k=!0,...C}=t,$=hi(),T=hi(),Q=hi(),A=w.useRef(null),R=age();Ul(()=>{if(h!==void 0){let j=h.trim();n.current.value=j,P.emit()}},[h]),Ul(()=>{R(6,se)},[]);let P=w.useMemo(()=>({subscribe:j=>(o.current.add(j),()=>o.current.delete(j)),snapshot:()=>n.current,setState:(j,I,N)=>{var V,ne,ie,ye;if(!Object.is(n.current[j],I)){if(n.current[j]=I,j==="search")K(),G(),R(1,Y);else if(j==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let xe=document.getElementById(Q);xe?xe.focus():(V=document.getElementById($))==null||V.focus()}if(R(7,()=>{var xe;n.current.selectedItemId=(xe=H())==null?void 0:xe.id,P.emit()}),N||R(5,se),((ne=l.current)==null?void 0:ne.value)!==void 0){let xe=I??"";(ye=(ie=l.current).onValueChange)==null||ye.call(ie,xe);return}}P.emit()}},emit:()=>{o.current.forEach(j=>j())}}),[]),X=w.useMemo(()=>({value:(j,I,N)=>{var V;I!==((V=s.current.get(j))==null?void 0:V.value)&&(s.current.set(j,{value:I,keywords:N}),n.current.filtered.items.set(j,te(I,N)),R(2,()=>{G(),P.emit()}))},item:(j,I)=>(i.current.add(j),I&&(r.current.has(I)?r.current.get(I).add(j):r.current.set(I,new Set([j]))),R(3,()=>{K(),G(),n.current.value||Y(),P.emit()}),()=>{s.current.delete(j),i.current.delete(j),n.current.filtered.items.delete(j);let N=H();R(4,()=>{K(),N?.getAttribute("id")===j&&Y(),P.emit()})}),group:j=>(r.current.has(j)||r.current.set(j,new Set),()=>{s.current.delete(j),r.current.delete(j)}),filter:()=>l.current.shouldFilter,label:u||t["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:$,inputId:Q,labelId:T,listInnerRef:A}),[]);function te(j,I){var N,V;let ne=(V=(N=l.current)==null?void 0:N.filter)!=null?V:Hpe;return j?ne(j,n.current.search,I):0}function G(){if(!n.current.search||l.current.shouldFilter===!1)return;let j=n.current.filtered.items,I=[];n.current.filtered.groups.forEach(V=>{let ne=r.current.get(V),ie=0;ne.forEach(ye=>{let xe=j.get(ye);ie=Math.max(xe,ie)}),I.push([V,ie])});let N=A.current;pe().sort((V,ne)=>{var ie,ye;let xe=V.getAttribute("id"),Le=ne.getAttribute("id");return((ie=j.get(Le))!=null?ie:0)-((ye=j.get(xe))!=null?ye:0)}).forEach(V=>{let ne=V.closest(gS);ne?ne.appendChild(V.parentElement===ne?V:V.closest(`${gS} > *`)):N.appendChild(V.parentElement===N?V:V.closest(`${gS} > *`))}),I.sort((V,ne)=>ne[1]-V[1]).forEach(V=>{var ne;let ie=(ne=A.current)==null?void 0:ne.querySelector(`${af}[${qc}="${encodeURIComponent(V[0])}"]`);ie?.parentElement.appendChild(ie)})}function Y(){let j=pe().find(N=>N.getAttribute("aria-disabled")!=="true"),I=j?.getAttribute(qc);P.setState("value",I||void 0)}function K(){var j,I,N,V;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=i.current.size;return}n.current.filtered.groups=new Set;let ne=0;for(let ie of i.current){let ye=(I=(j=s.current.get(ie))==null?void 0:j.value)!=null?I:"",xe=(V=(N=s.current.get(ie))==null?void 0:N.keywords)!=null?V:[],Le=te(ye,xe);n.current.filtered.items.set(ie,Le),Le>0&&ne++}for(let[ie,ye]of r.current)for(let xe of ye)if(n.current.filtered.items.get(xe)>0){n.current.filtered.groups.add(ie);break}n.current.filtered.count=ne}function se(){var j,I,N;let V=H();V&&(((j=V.parentElement)==null?void 0:j.firstChild)===V&&((N=(I=V.closest(af))==null?void 0:I.querySelector(Gpe))==null||N.scrollIntoView({block:"nearest"})),V.scrollIntoView({block:"nearest"}))}function H(){var j;return(j=A.current)==null?void 0:j.querySelector(`${CZ}[aria-selected="true"]`)}function pe(){var j;return Array.from(((j=A.current)==null?void 0:j.querySelectorAll(TA))||[])}function z(j){let I=pe()[j];I&&P.setState("value",I.getAttribute(qc))}function W(j){var I;let N=H(),V=pe(),ne=V.findIndex(ye=>ye===N),ie=V[ne+j];(I=l.current)!=null&&I.loop&&(ie=ne+j<0?V[V.length-1]:ne+j===V.length?V[0]:V[ne+j]),ie&&P.setState("value",ie.getAttribute(qc))}function ce(j){let I=H(),N=I?.closest(af),V;for(;N&&!V;)N=j>0?sge(N,af):oge(N,af),V=N?.querySelector(TA);V?P.setState("value",V.getAttribute(qc)):W(j)}let oe=()=>z(pe().length-1),ae=j=>{j.preventDefault(),j.metaKey?oe():j.altKey?ce(1):W(1)},D=j=>{j.preventDefault(),j.metaKey?z(0):j.altKey?ce(-1):W(-1)};return w.createElement(We.div,{ref:e,tabIndex:-1,...C,"cmdk-root":"",onKeyDown:j=>{var I;(I=C.onKeyDown)==null||I.call(C,j);let N=j.nativeEvent.isComposing||j.keyCode===229;if(!(j.defaultPrevented||N))switch(j.key){case"n":case"j":{k&&j.ctrlKey&&ae(j);break}case"ArrowDown":{ae(j);break}case"p":case"k":{k&&j.ctrlKey&&D(j);break}case"ArrowUp":{D(j);break}case"Home":{j.preventDefault(),z(0);break}case"End":{j.preventDefault(),oe();break}case"Enter":{j.preventDefault();let V=H();if(V){let ne=new Event(pw);V.dispatchEvent(ne)}}}}},w.createElement("label",{"cmdk-label":"",htmlFor:X.inputId,id:X.labelId,style:cge},u),Ey(t,j=>w.createElement($Z.Provider,{value:P},w.createElement(_Z.Provider,{value:X},j))))}),Wpe=w.forwardRef((t,e)=>{var n,i;let r=hi(),s=w.useRef(null),o=w.useContext(TZ),l=Zh(),u=RZ(t),f=(i=(n=u.current)==null?void 0:n.forceMount)!=null?i:o?.forceMount;Ul(()=>{if(!f)return l.item(r,o?.id)},[f]);let h=QZ(r,s,[t.value,t.children,s],t.keywords),p=Wk(),O=Ma(R=>R.value&&R.value===h.current),y=Ma(R=>f||l.filter()===!1?!0:R.search?R.filtered.items.get(r)>0:!0);w.useEffect(()=>{let R=s.current;if(!(!R||t.disabled))return R.addEventListener(pw,v),()=>R.removeEventListener(pw,v)},[y,t.onSelect,t.disabled]);function v(){var R,P;S(),(P=(R=u.current).onSelect)==null||P.call(R,h.current)}function S(){p.setState("value",h.current,!0)}if(!y)return null;let{disabled:k,value:C,onSelect:$,forceMount:T,keywords:Q,...A}=t;return w.createElement(We.div,{ref:yu(s,e),...A,id:r,"cmdk-item":"",role:"option","aria-disabled":!!k,"aria-selected":!!O,"data-disabled":!!k,"data-selected":!!O,onPointerMove:k||l.getDisablePointerSelection()?void 0:S,onClick:k?void 0:v},t.children)}),Kpe=w.forwardRef((t,e)=>{let{heading:n,children:i,forceMount:r,...s}=t,o=hi(),l=w.useRef(null),u=w.useRef(null),f=hi(),h=Zh(),p=Ma(y=>r||h.filter()===!1?!0:y.search?y.filtered.groups.has(o):!0);Ul(()=>h.group(o),[]),QZ(o,l,[t.value,t.heading,u]);let O=w.useMemo(()=>({id:o,forceMount:r}),[r]);return w.createElement(We.div,{ref:yu(l,e),...s,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&w.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),Ey(t,y=>w.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},w.createElement(TZ.Provider,{value:O},y))))}),Jpe=w.forwardRef((t,e)=>{let{alwaysRender:n,...i}=t,r=w.useRef(null),s=Ma(o=>!o.search);return!n&&!s?null:w.createElement(We.div,{ref:yu(r,e),...i,"cmdk-separator":"",role:"separator"})}),ege=w.forwardRef((t,e)=>{let{onValueChange:n,...i}=t,r=t.value!=null,s=Wk(),o=Ma(f=>f.search),l=Ma(f=>f.selectedItemId),u=Zh();return w.useEffect(()=>{t.value!=null&&s.setState("search",t.value)},[t.value]),w.createElement(We.input,{ref:e,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":l,id:u.inputId,type:"text",value:r?t.value:o,onChange:f=>{r||s.setState("search",f.target.value),n?.(f.target.value)}})}),tge=w.forwardRef((t,e)=>{let{children:n,label:i="Suggestions",...r}=t,s=w.useRef(null),o=w.useRef(null),l=Ma(f=>f.selectedItemId),u=Zh();return w.useEffect(()=>{if(o.current&&s.current){let f=o.current,h=s.current,p,O=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let y=f.offsetHeight;h.style.setProperty("--cmdk-list-height",y.toFixed(1)+"px")})});return O.observe(f),()=>{cancelAnimationFrame(p),O.unobserve(f)}}},[]),w.createElement(We.div,{ref:yu(s,e),...r,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":i,id:u.listId},Ey(t,f=>w.createElement("div",{ref:yu(o,u.listInnerRef),"cmdk-list-sizer":""},f)))}),nge=w.forwardRef((t,e)=>{let{open:n,onOpenChange:i,overlayClassName:r,contentClassName:s,container:o,...l}=t;return w.createElement(Tw,{open:n,onOpenChange:i},w.createElement(Rw,{container:o},w.createElement(Qw,{"cmdk-overlay":"",className:r}),w.createElement(Aw,{"aria-label":t.label,"cmdk-dialog":"",className:s},w.createElement(EZ,{ref:e,...l}))))}),ige=w.forwardRef((t,e)=>Ma(n=>n.filtered.count===0)?w.createElement(We.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),rge=w.forwardRef((t,e)=>{let{progress:n,children:i,label:r="Loading...",...s}=t;return w.createElement(We.div,{ref:e,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r},Ey(t,o=>w.createElement("div",{"aria-hidden":!0},o)))}),Ty=Object.assign(EZ,{List:tge,Item:Wpe,Input:ege,Group:Kpe,Separator:Jpe,Dialog:nge,Empty:ige,Loading:rge});function sge(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function oge(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}function RZ(t){let e=w.useRef(t);return Ul(()=>{e.current=t}),e}var Ul=typeof window>"u"?w.useEffect:w.useLayoutEffect;function Yc(t){let e=w.useRef();return e.current===void 0&&(e.current=t()),e}function Ma(t){let e=Wk(),n=()=>t(e.snapshot());return w.useSyncExternalStore(e.subscribe,n,n)}function QZ(t,e,n,i=[]){let r=w.useRef(),s=Zh();return Ul(()=>{var o;let l=(()=>{var f;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(f=h.current.textContent)==null?void 0:f.trim():r.current}})(),u=i.map(f=>f.trim());s.value(t,l,u),(o=e.current)==null||o.setAttribute(qc,l),r.current=l}),r}var age=()=>{let[t,e]=w.useState(),n=Yc(()=>new Map);return Ul(()=>{n.current.forEach(i=>i()),n.current=new Map},[t]),(i,r)=>{n.current.set(i,r),e({})}};function lge(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function Ey({asChild:t,children:e},n){return t&&w.isValidElement(e)?w.cloneElement(lge(e),{ref:e.ref},n(e.props.children)):n(e)}var cge={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function uge({className:t,...e}){return m.jsx(Ty,{"data-slot":"command",className:yt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e})}function dge({className:t,...e}){return m.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[m.jsx(BM,{className:"size-4 shrink-0 opacity-50"}),m.jsx(Ty.Input,{"data-slot":"command-input",className:yt("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...e})]})}function fge({className:t,...e}){return m.jsx(Ty.List,{"data-slot":"command-list",className:yt("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",t),...e})}function hge({className:t,...e}){return m.jsx(Ty.Item,{"data-slot":"command-item",className:yt("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",t),...e})}function EA(t,e){if(!t)return{score:0,hits:[]};const n=t.toLowerCase(),i=e.toLowerCase();let r=0,s=0,o=0;const l=[];for(let u=0;u3&&i.endsWith("ies")?r=i.slice(0,-3)+"y":i.length>3&&i.endsWith("es")?r=i.slice(0,-2):i.length>2&&i.endsWith("s")&&(r=i.slice(0,-1)),r?EA(r,e):null}const pge=1e3,gge=12,mge=4;function QA(t,e,n){if(!t.trim())return{score:0,hits:[]};const i=e.lastIndexOf("/")+1;let r=0;const s=[];for(const o of t.trim().split(/\s+/)){let l=RA(o,e),u=!1;if(!l&&n?.allowError&&o.length>=mge)for(let f=0;f0&&l.hits[0]>=i&&(r+=gge),s.push(...l.hits)}return{score:r,hits:[...new Set(s)].sort((o,l)=>o-l)}}function Oge({text:t,hits:e}){const n=[];let i=0;return e.forEach((r,s)=>{r>i&&n.push(t.slice(i,r)),n.push(m.jsx("b",{children:t[r]},s)),i=r+1}),n.push(t.slice(i)),m.jsx("span",{className:"plabel",children:n})}function yge({open:t,onClose:e,candidates:n}){const[i,r]=w.useState(""),s=w.useMemo(()=>{if(!t)return[];const l=[],u=[];for(const f of n()){const h=QA(i,f.label);h?l.push({...f,score:h.score,hits:h.hits}):u.push(f)}if(i.trim()&&l.length<40)for(const f of u){const h=QA(i,f.label,{allowError:!0});h&&l.push({...f,score:h.score,hits:h.hits})}return l.sort((f,h)=>h.score-f.score),l.slice(0,40)},[t,i,n]);w.useEffect(()=>{t&&r("")},[t]);const o=l=>{e(),l.run()};return m.jsx(NO,{open:t,onOpenChange:l=>!l&&e(),children:m.jsxs(zO,{id:"palette",className:"palette",showCloseButton:!1,"aria-describedby":void 0,children:[m.jsx(vh,{className:"sr-only",children:"Search and quick actions"}),m.jsxs(uge,{shouldFilter:!1,loop:!0,children:[m.jsxs("div",{id:"palette-inputwrap",children:[m.jsx(st,{name:"search"}),m.jsx(dge,{placeholder:"Search file names, projects, actions…",autoComplete:"off",spellCheck:!1,value:i,onValueChange:r})]}),m.jsx(fge,{children:s.length===0?m.jsx("div",{className:"pempty",children:"No matches — search covers file names, projects, and actions"}):s.map(l=>m.jsxs(hge,{value:l.kind+":"+l.label,onSelect:()=>o(l),children:[m.jsx("span",{className:"picon",children:m.jsx(st,{name:l.icon})}),m.jsx(Oge,{text:l.label,hits:l.hits}),m.jsx("span",{className:"pkind",children:l.kind})]},l.kind+":"+l.label))}),m.jsx("footer",{id:"palette-hint",children:"↑↓ navigate · ⏎ select · esc close"})]})]})})}function vge(t,e){return nn({queryKey:["heatDevices",t],queryFn:()=>Wt(t+"heat?by=device&days=30"),enabled:e,retry:!1,staleTime:6e4}).data?.devices??null}const bge=["all","human","agent","share"],Sge={all:"All reads",human:"Human reads",agent:"Agent reads",share:"Shared reads"},xge={agent:{agent:1,human:0,share:0},human:{agent:0,human:1,share:0},share:{agent:0,human:0,share:1}};function AA(t){const[e,n]=w.useState("all"),{flatFiles:i,heatMap:r,devices:s,scope:o}=t,l=v=>!o||v===o||v.startsWith(o+"/"),u=o?i.filter(v=>l(v.path)):i;if(!t.loading&&!u.length)return m.jsxs("div",{className:"insights",children:[m.jsxs("h1",{className:"in-title",children:["Knowledge insights",o?m.jsxs("span",{className:"in-scope",children:[" · ",o]}):null]}),m.jsxs("div",{className:"dl-empty in-blank",children:[m.jsx("p",{children:o?`Nothing in ${o} to chart yet.`:"Nothing to chart yet."}),m.jsx("p",{children:o?`No files under ${o} are syncing here yet.`:"This project has no files. Once a device syncs files here, the map, the reads × freshness plot and the hot path fill in on their own."}),t.installHref&&m.jsx("a",{className:"pbtn",...Cl(t.installHref),children:"Set up a device →"})]})]});const f=s&&o?s.map(v=>{const S=Object.create(null);for(const[k,C]of Object.entries(v.folders||{}))l(k)&&(S[k]=C);return{...v,folders:S}}).filter(v=>Object.keys(v.folders).length>0):s,h=Date.now(),p=u.map(v=>{const S=r&&r[v.path]||{},k=v.time?Math.max(0,(h-new Date(v.time).getTime())/864e5):0,C=e==="all"?vo(S):S[e]||0;return{path:v.path,reads:C,agent:S.agent||0,human:S.human||0,share:S.share||0,total:vo(S),days:k,danger:ON(C,k)}}),O=ite(r,new Set(i.map(v=>v.path))).filter(l).map(v=>{const S=r[v];return{path:v,reads:e==="all"?vo(S):S[e]||0,agent:S.agent||0,human:S.human||0,share:S.share||0,total:vo(S),days:0,danger:!1,orphan:!0}}).filter(v=>v.reads>0),y=O.length>0?m.jsxs("p",{className:"in-legend in-orphan-note",children:[gw(O.length,"file")," with reads ",O.length===1?"is":"are"," no longer in the project — see Hot path."]}):null;return m.jsxs("div",{className:"insights",children:[m.jsxs("h1",{className:"in-title",children:["Knowledge insights",o?m.jsxs("span",{className:"in-scope",children:[" · ",o]}):null]}),m.jsx("p",{className:"dl-sub",children:o?`Reads over the last 30 days × freshness, for ${o} and everything in it. ${_l}`:"Reads over the last 30 days × how long since each file changed. Hot but stale knowledge — read a lot, maintained by nobody — is the danger zone. "+_l}),m.jsx("div",{className:"in-lens",children:bge.map(v=>m.jsx("button",{className:"in-lens-btn"+(v===e?" active":""),onClick:()=>n(v),children:Sge[v]},v))}),m.jsx("h3",{className:"dl-h3",children:"Map — cell size = reads, color = freshness (scale below)"}),m.jsx(kge,{pts:p,onOpenFile:t.onOpenFile,onOpenFolder:t.onOpenFolder,isFolder:t.isFolder}),y,m.jsxs("h3",{className:"dl-h3 in-h3-row",children:["Reads × freshness",m.jsx("span",{className:"in-cap",children:"dot size = agent share of reads"})]}),m.jsx(_ge,{pts:p,onOpenFile:t.onOpenFile}),y,m.jsx("h3",{className:"dl-h3",children:"Hot path — top files by reads"}),m.jsx($ge,{pts:[...p,...O],lens:e,onOpenFile:t.onOpenFile,onOpenHistory:t.onOpenHistory}),f&&f.length>0&&m.jsxs(m.Fragment,{children:[m.jsx("h3",{className:"dl-h3",children:"Agent coverage — which agents read which areas"}),m.jsx(Tge,{devices:f})]})]})}const wge="rgb(150,156,164)";function AZ(t){const e=[[76,195,138],[232,196,84],[224,93,93]],n=Math.min(1,Math.max(0,t/300))*(e.length-1),i=Math.min(e.length-2,Math.floor(n)),r=n-i,s=e[i].map((o,l)=>Math.round(o+(e[i+1][l]-o)*r));return`rgb(${s[0]},${s[1]},${s[2]})`}function PA(t,e,n,i,r){const s=t.reduce((f,h)=>f+h.value,0);if(!s||i<=0||r<=0)return[];const o=t.slice().sort((f,h)=>h.value-f.value).map(f=>({it:f,a:f.value/s*i*r})),l=(f,h)=>{const O=f.reduce((v,S)=>v+S.a,0)/h;let y=0;for(const v of f){const S=v.a/O;y=Math.max(y,S/O,O/S)}return y},u=[];for(;o.length;){const f=i>=r,h=f?r:i,p=[o.shift()];for(;o.length&&l(p.concat(o[0]),h)<=l(p,h);)p.push(o.shift());const O=p.reduce((v,S)=>v+S.a,0)/h;let y=0;for(const v of p){const S=v.a/O;f?u.push({item:v.it,x:e,y:n+y,w:O,h:S}):u.push({item:v.it,x:e+y,y:n,w:S,h:O}),y+=S}f?(e+=O,i-=O):(n+=O,r-=O)}return u}const mS=15;function jA(t,e,n){const i=Math.floor((n-8)/6),r=`${t} · ${e}`;return r.length<=i?{label:r,fit:i}:{label:t.length>i?t.slice(0,Math.max(1,i-1))+"…":t,fit:i}}const gw=(t,e)=>`${t} ${e}${t===1?"":"s"}`;function kge({pts:t,onOpenFile:e,onOpenFolder:n,isFolder:i}){const o=ste(t.map(h=>h.days)),l=!!o&&ote(o.min,o.max),u=new Map;for(const h of t){const p=h.path.includes("/")?h.path.split("/")[0]:"/";let O=u.get(p);O||u.set(p,O={name:p,files:[],value:0,reads:0}),O.files.push(h),O.value+=h.reads+1,O.reads+=h.reads}const f=[];for(const h of PA([...u.values()],0,0,720,480)){const p=h.item,O=p.name==="/"?"":p.name,y=p.name==="/"?"(root)":p.name;if(f.push(m.jsx("rect",{x:h.x+1,y:h.y+1,width:Math.max(0,h.w-2),height:Math.max(0,h.h-2),rx:3,className:"in-tm-group","data-dir":O,children:m.jsx("title",{children:`${p.name==="/"?"(root)":p.name+"/"} — ${gw(p.reads,"read")}/30d · ${gw(p.files.length,"file")}`})},"g"+p.name)),h.w>46&&h.h>mS+10){const{label:S}=jA(y,p.reads,h.w);f.push(m.jsx("text",{x:h.x+5,y:h.y+12,className:"in-tm-glabel","data-dir":O,children:S},"gl"+p.name))}const v=PA(p.files.map(S=>({...S,name:S.path.split("/").pop(),value:S.reads+1})),h.x+2,h.y+mS,Math.max(0,h.w-4),Math.max(0,h.h-mS-2));for(const S of v)if(f.push(m.jsx("rect",{x:S.x+.6,y:S.y+.6,width:Math.max(.4,S.w-1.2),height:Math.max(.4,S.h-1.2),rx:1.5,fill:l?wge:AZ(S.item.days),className:"in-tm-cell","data-path":S.item.path,children:m.jsx("title",{children:`${S.item.path} — ${S.item.reads} read${S.item.reads===1?"":"s"}/30d · changed ${Math.round(S.item.days)}d ago`})},S.item.path)),S.w>54&&S.h>16){const{label:k,fit:C}=jA((S.item.danger?"⚠ ":"")+S.item.name,S.item.reads,S.w);C>=5&&f.push(m.jsx("text",{x:S.x+4.5,y:S.y+12.5,className:"in-tm-label","data-path":S.item.path,children:k},"l"+S.item.path))}}return m.jsxs(m.Fragment,{children:[m.jsx("svg",{viewBox:"0 0 720 480",className:"in-chart in-treemap",onClick:h=>{const p=h.target.closest("[data-path], [data-dir]");if(!p)return;const O=p.getAttribute("data-path");if(O)return e(O);const y=p.getAttribute("data-dir");y&&i(y)&&n(y)},children:f}),m.jsx(Cge,{range:o,flat:l})]})}function Cge({range:t,flat:e}){if(!t)return null;const n=ate(t.min,t.max);return m.jsxs("p",{className:"in-legend in-tm-legend",children:["freshness 0d",m.jsx("span",{className:"in-sw in-sw-age"+(e?" in-sw-flat":""),style:{background:`linear-gradient(to right, ${[0,60,150,300].map(AZ).join(", ")})`}}),"300d+",m.jsx("span",{className:"in-tm-range",children:e?`all files here: ${n} old — colour off, not enough range to rank`:`observed: ${n} old`})]})}function _ge({pts:t,onOpenFile:e}){const r={l:44,r:16,t:20,b:34},s=Math.max(Ic*2,...t.map(v=>v.days)),o=Math.max(ff*2,...t.map(v=>v.reads)),l=v=>Math.log10(v+1)/Math.log10(s+1),u=v=>Math.log10(v+1)/Math.log10(o+1),f=v=>3+4*v,h=f(1),p=v=>r.l+h+l(v)*(720-r.l-r.r-2*h),O=v=>360-r.b-h-u(v)*(360-r.t-r.b-2*h),y=ute(t.filter(v=>v.danger).map(v=>({path:v.path,reads:v.reads,cx:p(v.days),cy:O(v.reads),r:f(v.total?(v.agent||0)/v.total:0)})),{right:720-r.r,top:r.t+8,bottom:360-r.b-4});return m.jsxs("svg",{viewBox:"0 0 720 360",className:"in-chart",children:[m.jsx("rect",{x:p(Ic),y:r.t,width:720-r.r-p(Ic),height:O(ff)-r.t,className:"in-danger-zone"}),m.jsx("line",{x1:p(Ic),y1:r.t,x2:p(Ic),y2:360-r.b,className:"in-threshold"}),m.jsx("line",{x1:r.l,y1:O(ff),x2:720-r.r,y2:O(ff),className:"in-threshold"}),m.jsx("line",{x1:r.l,y1:360-r.b,x2:720-r.r,y2:360-r.b,className:"in-axis"}),m.jsx("line",{x1:r.l,y1:r.t,x2:r.l,y2:360-r.b,className:"in-axis"}),m.jsx("text",{x:(r.l+720-r.r)/2,y:352,className:"in-label",children:"days since last change →"}),m.jsx("text",{x:12,y:(r.t+360-r.b)/2,className:"in-label",transform:`rotate(-90 12 ${(r.t+360-r.b)/2})`,children:"reads / 30d →"}),m.jsx("text",{x:720-r.r-6,y:r.t+14,className:"in-quad in-quad-danger",textAnchor:"end",children:"hot + stale"}),m.jsx("text",{x:r.l+6,y:r.t+14,className:"in-quad",children:"hot + fresh"}),m.jsx("text",{x:720-r.r-6,y:360-r.b-8,className:"in-quad",textAnchor:"end",children:"cold + stale"}),m.jsx("text",{x:r.l+6,y:360-r.b-8,className:"in-quad",children:"cold + fresh"}),t.map(v=>{const S=v.total?(v.agent||0)/v.total:0;return m.jsx("circle",{cx:Number(p(v.days).toFixed(1)),cy:Number(O(v.reads).toFixed(1)),r:Number(f(S).toFixed(1)),className:"in-pt"+(v.danger?" danger":v.reads?"":" cold"),onClick:()=>e(v.path),children:m.jsx("title",{children:`${v.path} — ${v.reads} read${v.reads===1?"":"s"} / 30d · changed ${Math.round(v.days)}d ago`})},v.path)}),y.map(v=>m.jsx("text",{x:Number(v.x.toFixed(1)),y:Number(v.y.toFixed(1)),textAnchor:v.anchor,className:"in-pt-label",children:v.name},v.path))]})}function $ge({pts:t,lens:e,onOpenFile:n,onOpenHistory:i}){const r=t.filter(l=>l.reads>0).sort((l,u)=>u.reads-l.reads||u.days-l.days).slice(0,20);if(!r.length)return m.jsx("div",{className:"dl-empty",children:"No reads in the window yet."});const s=r[0].reads,o=r.some(l=>l.share>0);return m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"in-hotpath",children:r.map(l=>{const u=xge[e]??nte(l),f=l.reads/s*100,h=()=>l.orphan?i(l.path):n(l.path);return m.jsxs("div",{className:"in-hp-row",tabIndex:0,role:"button",title:l.orphan?`${l.reads} read${l.reads===1?"":"s"}/30d · no longer in the project — open its history`:l.danger?`${l.reads} read${l.reads===1?"":"s"}/30d · unchanged ${Math.round(l.days)}d — review this file`:l.path,onClick:h,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),h())},children:[m.jsx("span",{className:"in-hp-name"+(l.danger?" danger":""),children:l.path+(l.danger?" ⚠":"")}),l.orphan&&m.jsx("span",{className:"in-hp-gone",children:"· no longer in the project"}),m.jsxs("span",{className:"in-hp-bar",children:[m.jsx("span",{className:"in-hp-agent",style:{width:(f*u.agent).toFixed(1)+"%"}}),m.jsx("span",{className:"in-hp-human",style:{width:(f*u.human).toFixed(1)+"%"}}),m.jsx("span",{className:"in-hp-share",style:{width:(f*u.share).toFixed(1)+"%"}})]}),m.jsx("span",{className:"in-hp-count",children:l.reads})]},l.path)})}),m.jsxs("p",{className:"in-legend",children:[m.jsx("span",{className:"in-sw agent"})," agent reads ",m.jsx("span",{className:"in-sw human"})," human reads",o&&m.jsxs(m.Fragment,{children:[" ",m.jsx("span",{className:"in-sw share"})," shared reads"]})]})]})}function Tge({devices:t}){const e=new Map;for(const O of t)for(const[y,v]of Object.entries(O.folders||{}))e.set(y,(e.get(y)||0)+v);const n=[...e.entries()].sort((O,y)=>y[1]-O[1]).slice(0,12).map(O=>O[0]),i=t.slice(0,12),r=140,s=6,o=Math.min(76,Math.max(34,(720-r-8)/n.length)),l=26,u=720,f=s+i.length*l+58,h=Math.max(1,...i.flatMap(O=>n.map(y=>(O.folders||{})[y]||0))),p=O=>{const y=[23,25,31],v=[245,166,35],S=y.map((k,C)=>Math.round(k+(v[C]-k)*O));return`rgb(${S[0]},${S[1]},${S[2]})`};return m.jsxs("svg",{viewBox:`0 0 ${u} ${f}`,className:"in-chart in-matrix",children:[i.map((O,y)=>{let v=O.name||O.id||"";return v.length>20&&(v=v.slice(0,19)+"…"),m.jsxs("g",{children:[m.jsx("text",{x:r-8,y:s+y*l+17,textAnchor:"end",className:"in-label",children:v}),n.map((S,k)=>{const C=(O.folders||{})[S]||0;return m.jsx("rect",{x:r+k*o,y:s+y*l,width:o-4,height:l-4,rx:3,fill:p(Math.sqrt(C/h)),children:m.jsx("title",{children:`${O.name||O.id} × ${S||"(root)"}: ${C} read${C===1?"":"s"}/30d`})},S)})]},O.id||y)}),n.map((O,y)=>{const v=r+y*o+(o-4)/2,S=s+i.length*l+14;return m.jsx("text",{x:v,y:S,className:"in-label",textAnchor:"end",transform:`rotate(-28 ${v} ${S})`,children:O||"(root)"},O)})]})}function PZ(t){return new Set(t.entries.map(e=>e.path)).size}function Ege(t){const e=s=>(s.session?"s\0"+s.session:"n\0"+s.note)+"\0"+(s.device?.id??""),n=new Map;t.forEach((s,o)=>{if(!s.note&&!s.session)return;const l=n.get(e(s));if(l){l.entries.push(s),l.idx.push(o);return}n.set(e(s),{note:s.note??"",session:s.session,entries:[s],idx:[o]})});const i=[],r=new Set;return t.forEach((s,o)=>{const l=s.note||s.session?n.get(e(s)):void 0;if(!l||PZ(l)<2){i.push({i:o});return}r.has(l)||(r.add(l),i.push({run:l,i:o}))}),i}function Rge(t){const{filters:e,authors:n,onChange:i}=t,r=(h,p)=>i({...e,[h]:p||void 0}),[s,o]=w.useState(e?.q??""),l=w.useRef(!1);w.useEffect(()=>{l.current||o(e?.q??"")},[e?.q]),w.useEffect(()=>{if(!l.current)return;const h=setTimeout(()=>{l.current=!1,s!==(e?.q??"")&&r("q",s)},250);return()=>clearTimeout(h)},[s]);const u=e?.user&&!n.includes(e.user)?[e.user,...n]:n,f=d1(e);return m.jsxs("div",{className:"hfilters",children:[m.jsxs("label",{className:"hf-search",children:[m.jsx(st,{name:"search"}),m.jsx(Fg,{type:"search",value:s,placeholder:"path contains…","aria-label":"Filter by path",onChange:h=>{l.current=!0,o(h.target.value)}})]}),m.jsxs("select",{className:"hf-user",value:e?.user??"","aria-label":"Filter by author",onChange:h=>r("user",h.target.value),children:[m.jsx("option",{value:"",children:"Anyone"}),u.map(h=>m.jsx("option",{value:h,children:h},h))]}),m.jsxs("span",{className:"hf-dates",children:[m.jsx("span",{className:"hf-lbl",children:"UTC"}),m.jsx(Fg,{type:"date",className:"hf-date",value:e?.since??"","aria-label":"From date (UTC)",onChange:h=>r("since",h.target.value)}),m.jsx("span",{className:"hf-dash",children:"–"}),m.jsx(Fg,{type:"date",className:"hf-date",value:e?.until??"","aria-label":"To date (UTC)",onChange:h=>r("until",h.target.value)})]}),f&&m.jsx("button",{type:"button",className:"hf-clear",onClick:()=>i({}),children:"Clear"})]})}function Qge(t){const e=new Set;for(const n of t)n.user&&e.add(n.user);return[...e].sort()}function Age(t){const{apiBase:e,target:n,isFolder:i,onMeta:r,onRendered:s,restore:o,remove:l,undoRun:u,filters:f}=t,h=w.useMemo(()=>new Set(t.flatFiles.map(G=>G.path)),[t.flatFiles]),p=n?i(n)?{prefix:n+"/"}:{path:n}:{prefix:""},O=("path"in p&&p.path!==void 0?"path="+encodeURIComponent(p.path):"prefix="+encodeURIComponent(p.prefix??""))+aD(f).replace("?","&"),{data:y,error:v,isPending:S,fetchNextPage:k,hasNextPage:C,isFetchingNextPage:$}=IX({queryKey:["history",e,O],queryFn:({pageParam:G})=>Wt(e+"history?"+O+"&n=100"+(G?"&cursor="+encodeURIComponent(G):"")),initialPageParam:"",getNextPageParam:G=>G.next_cursor,staleTime:15e3}),T=w.useRef(new Set);w.useEffect(()=>{v&&r("History unavailable: "+v.message)},[v,r]),w.useEffect(()=>{y&&s?.()},[y,s]);const Q=y?y.pages.flatMap(G=>G.entries||[]):[];for(const G of Qge(Q))T.current.add(G);const A=t.onFilters&&m.jsx(Rge,{filters:f,authors:[...T.current].sort(),onChange:t.onFilters});if(!y)return m.jsxs("div",{className:"history",children:[A,S&&!v&&m.jsx("div",{className:"empty",children:"Loading…"})]});const R=G=>{for(let Y=G+1;Y{const Y=Q[G].kind==="delete"?R(G):Q[G].blob;return Y&&Y===P.get(Q[G].path)?void 0:Y},te=G=>P.get(Q[G].path)==="";return m.jsxs("div",{className:"history",children:[A,Q.length===0&&(d1(f)?m.jsxs("div",{className:"empty",children:["No changes match these filters.",m.jsx("br",{}),m.jsx("button",{type:"button",className:"btn hf-clear-empty",onClick:()=>t.onFilters?.({}),children:"Clear filters"})]}):m.jsx("div",{className:"empty",children:"No history yet."})),Ege(Q).map((G,Y)=>G.run?m.jsx(Pge,{run:G.run,known:h,onOpen:t.onOpen,apiBase:e,prevBlob:R,restoreSha:X,recreates:te,restore:o,remove:l,undoRun:u},"g"+Y):m.jsx(j1,{entry:Q[G.i],apiBase:e,onOpen:t.onOpen,diff:{apiBase:e,prev:R(G.i)},restore:o,restoreSha:X(G.i),recreates:te(G.i)},"r"+G.i)),C&&m.jsx("button",{type:"button",className:"btn hmore",onClick:()=>k(),disabled:$,children:$?"Loading…":"Load more"})]})}function Pge({run:t,known:e,onOpen:n,apiBase:i,prevBlob:r,restoreSha:s,recreates:o,restore:l,remove:u,undoRun:f}){const[h,p]=w.useState(!0),O=t.entries[0],y=MO(O),v=[O.device.name||O.device.id,O.device.os].filter(Boolean).join(" · "),S=O.session,k=O.device?.id,{data:C}=nn({queryKey:["session-reads",i,S,k],queryFn:()=>Wt(i+"heat?session="+encodeURIComponent(S)+"&device="+encodeURIComponent(k)),enabled:!!S&&!!k,staleTime:3e4}),$=new Set(C?.paths??[]),T=new Set(t.entries.map(te=>te.path)),Q=[...$].filter(te=>!T.has(te)).sort(),A=t.entries.map(te=>new Date(te.time).getTime()),R=jge(Math.min(...A),Math.max(...A)),P=PZ(t),X=!!f?.busy&&f.busy===(t.session||t.note);return m.jsxs("div",{className:"hrun"+(h?" open":""),children:[m.jsxs("div",{className:"hrun-head",children:[m.jsx("button",{type:"button",className:"hrun-toggle","aria-expanded":h,title:h?"Collapse this run":"Expand this run",onClick:()=>p(!h),children:m.jsx(st,{name:h?"chevd":"chev"})}),m.jsx("span",{className:"hrun-note",children:m.jsx(kN,{text:t.note})}),m.jsxs("span",{className:"hrun-meta",children:[$.size>0?`read ${$.size} · changed ${P}`:`${P} file${P===1?"":"s"}`," ·"," ",y,v?" · "+v:""]}),m.jsx("span",{className:"hrun-time",children:R}),f&&m.jsxs("button",{type:"button",className:"hrun-undo",disabled:X,title:"Put every file this run touched back the way it was",onClick:()=>f.onUndoRun(t),children:[m.jsx(st,{name:"hist"}),X?"undoing…":"undo this run"]})]}),h&&m.jsxs("div",{className:"hrun-body",children:[t.entries.map((te,G)=>m.jsx(j1,{entry:te,apiBase:i,onOpen:n,diff:{apiBase:i,prev:r(t.idx[G])},restore:l,remove:u,restoreSha:s(t.idx[G]),recreates:o(t.idx[G]),inRun:!0,read:$.has(te.path)},G)),Q.length>0&&m.jsxs("div",{className:"hrun-reads",children:[m.jsx("div",{className:"hrun-reads-head",children:"Read, not changed"}),Q.map(te=>m.jsxs("button",{type:"button",className:"hrun-read",onClick:()=>n(te),children:[m.jsx("span",{className:"hkind",children:"read"}),m.jsx("span",{className:"hpath",children:te}),!e.has(te)&&m.jsx("span",{className:"in-hp-gone",children:"· no longer in the project"})]},te))]}),S&&m.jsx("div",{className:"hrun-foot",children:"Reads shown are what this device reported for this session — a narrower set than the project's read totals."})]})]})}function jge(t,e){const n=new Date(t),i=new Date(e),r=o=>o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});if(n.toDateString()!==i.toDateString())return n.toLocaleString()+" – "+i.toLocaleString();const s=i.toLocaleDateString();return t===e?s+" "+r(i):s+" "+r(n)+" – "+r(i)}function Mge(t,e){return t?e(t)?t+"/ (folder)":t:"all changes"}const Dge=3,MA=2;function DA(t,e){return{key:t,want:e,attempts:0}}function Nge(t,e){return t.key!==e||t.attempts>=Dge?null:(t.attempts++,t.want)}function zge(t,e,n,i){t.key===e&&(Math.abs(n-t.want)<=MA||t.attempts===0||n>=i-MA&&nWt(e+"history?"+r+"&n=200"),staleTime:15e3}),o=s?.entries?.find(h=>h.blob===i),l=o?MO(o):"",u=o?.time?new Date(o.time).toLocaleString():"",f=e+"blob?sha="+i+"&name="+encodeURIComponent(n.split("/").pop()||n)+"&download=1";return m.jsxs("div",{className:"vbanner",role:"status",children:[m.jsx("span",{className:"vb-icon",children:m.jsx(st,{name:"clock"})}),m.jsxs("div",{className:"vb-text",children:[m.jsx("b",{children:[u&&"Version from "+u,l&&"by "+l].filter(Boolean).join(" ")||"Earlier version"}),m.jsx("span",{children:"This is not the current file."})]}),m.jsxs("div",{className:"vb-actions",children:[m.jsx("button",{className:"ai-btn",onClick:t.onViewCurrent,children:"View current"}),m.jsx("a",{className:"ai-btn",download:!0,href:f,children:"Download this version"})]})]})}function Zge(t){const{conflict:e,originalHref:n}=t,i=e.device||"another device";return m.jsxs("div",{className:"vbanner",role:"status",children:[m.jsx("span",{className:"vb-icon",children:m.jsx(st,{name:"alert"})}),m.jsxs("div",{className:"vb-text",children:[m.jsx("b",{children:"Conflict copy — a concurrent edit, preserved"}),m.jsxs("span",{children:[i," edited this file at the same time as someone else on"," ",e.when.toLocaleString(),". Rather than drop either version, beardrive kept that one here."," ",n?m.jsxs(m.Fragment,{children:["The other version lives at ",m.jsx("code",{children:e.original})]}):m.jsx(m.Fragment,{children:"The other version kept the original name."})]})]}),n&&m.jsx("div",{className:"vb-actions",children:m.jsx("button",{className:"ai-btn",onClick:n,children:"Open the other version"})})]})}function jZ(t){const{config:e,apiBase:n,route:i,hub:r,project:s}=t,o=$F(h1()),l=fr(),{tree:u,flatFiles:f,dirIndex:h,loaded:p}=hte(n,!r||!!s),O=!r||!!s,{people:y,setPeople:v}=Ste(n,i.path??"",O);vte(n,O,v);const S=pte(n,r&&!!s&&!!e.reads?.enabled),{data:k}=nD(r&&s?s?.id:void 0),C=w.useMemo(()=>k?.folders||[],[k]),$=w.useMemo(()=>new Set(C.map(ve=>ve.prefix.replace(/\/$/,""))),[C]),T=r&&!!s&&!i.path&&!i.view,Q=i.view==="dashboard"||T,A=vge(n,Q);w.useEffect(()=>{Q&&l.invalidateQueries({queryKey:["heat",n]})},[Q,n,l]);const R=i.path,P=i.view?void 0:i.version,X=R||(i.view==="dashboard"||i.view==="history")&&i.viewTarget||"",te=!!R&&h.has(R),G=!!R&&p&&!te&&f.some(ve=>ve.path===R),Y=!!R&&p&&!te&&!G,K=te&&!i.view,{data:se}=nn({queryKey:["resolve",n,R],queryFn:()=>Wt(n+"resolve?path="+encodeURIComponent(R)),enabled:Y,retry:!1,staleTime:6e4}),[H,pe]=w.useState(null);w.useEffect(()=>{!Y||!se?.to||(pe({from:R,to:se.to}),zt(Yr(se.to,s?.id,void 0,i.full,i.editing),{replace:!0}))},[Y,se,R,s?.id,i.full,i.editing]);const[z,W]=w.useState(()=>new Set),ce=w.useRef(!0);w.useEffect(()=>{if(!u||!ce.current)return;ce.current=!1;const ve=(u.children||[]).filter(Pe=>Pe.dir);ve.length===1&&W(Pe=>new Set(Pe).add(ve[0].path))},[u]),w.useEffect(()=>{!X||!p||W(ve=>{const Pe=new Set(ve);for(const rt of Vte(X))Pe.add(rt);return h.has(X)&&Pe.add(X),Pe})},[X,p,h]);const oe=w.useCallback(ve=>{W(Pe=>{const rt=new Set(Pe);return rt.has(ve)?rt.delete(ve):rt.add(ve),rt})},[]),ae=w.useRef(null),D=w.useRef(new Map),j=w.useRef(DA("",0)),I=w.useCallback(()=>{const ve=ae.current;if(!ve)return;const Pe=Nge(j.current,o);Pe!==null&&ve.scrollTo({top:Pe,behavior:"instant"})},[o]);w.useEffect(()=>{j.current=DA(o,EF()==="POP"?D.current.get(o)??0:0),I()},[o,I]);const N=w.useCallback(()=>{const ve=ae.current;ve&&(D.current.set(o,ve.scrollTop),zge(j.current,o,ve.scrollTop,ve.scrollHeight-ve.clientHeight))},[o]),V=w.useCallback((ve,Pe)=>{zt(Yr(ve,s?.id,Pe)),Fr()},[s?.id]),ne=w.useCallback(ve=>zt(Zi("history",s?.id,ve)),[s?.id]),[ie,ye]=w.useState(""),[xe,Le]=w.useState(!1),[Ue,Ke]=w.useState(!1),[Et,ht]=w.useState(!1);w.useEffect(()=>hq(()=>ht(!0)),[]);const ti=w.useRef(null),Oi=w.useRef(null),At=t.panel??null,pr=!At&&r&&!!s&&(G||te)&&_s(s.perm,"write"),gr=!At&&G&&!P&&(!r||!!s&&_s((ve=>SN(C,ve)?.me)(R)??s.perm,"write")),Ri=!!i.editing&&gr,[sn,Yi]=w.useState(!1);w.useEffect(()=>{Yi(!1)},[R,P]);const xn=w.useMemo(()=>{const ve=e.me?.name||e.me?.email||"Someone";let Pe=0;for(let rt=0;rt{Fi.current=!1},[R]);const jo=w.useCallback(()=>{Fi.current=!0,zt(Yr(R,s?.id,P,!0,i.editing))},[R,s?.id,P,i.editing]),ii=w.useCallback(()=>{Fi.current?(Fi.current=!1,history.back()):zt(Yr(R,s?.id,P,!1,i.editing),{replace:!0})},[R,s?.id,P,i.editing]);w.useLayoutEffect(()=>{if(ni)return document.body.classList.add("full-view"),document.body.classList.remove("sb-open"),jl(),()=>{document.body.classList.remove("full-view"),jl()}},[ni]),w.useEffect(()=>{if(!ni)return;const ve=Pe=>{Pe.key==="Escape"&&!Et&&ii()};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[ni,Et,ii]);const M=w.useRef(!1);w.useEffect(()=>{ni?qs.current?.focus():M.current&&mr.current?.focus(),M.current=ni},[ni]);const{data:U}=iD(s?.id,r&&!!s),q=w.useCallback(()=>{l.invalidateQueries({queryKey:["shares",s?.id]})},[l,s?.id]),he=G?(U||[]).filter(ve=>ve.path===R):[],{data:me}=nn({queryKey:["desktop-status"],queryFn:()=>Wt("/api/desktop/status"),enabled:!!e.desktop,staleTime:6e4}),Se=e.desktop&&s?me?.mounts.find(ve=>ve.project===s.id)?.server:void 0,ke=w.useCallback(async()=>{if(!Se)return;const ve=Se+window.location.pathname,Pe=await zs(ve);Ve(Pe?"Web link copied":ve,!Pe)},[Se]),_e=!At&&r&&!!s,Ae=!At&&G&&!i.view,ut=!At&&G,Zt=ut&&!jM.test(R)&&!Bg.test(R)&&!Fc.test(R),on=ut&&!Bg.test(R)&&!Ri,an=!At&&(G||r&&!!s&&te),Xe=P?n+"blob?sha="+P+"&name="+encodeURIComponent(R)+"&download=1":n+"download?path="+encodeURIComponent(R),Ct=!Fc.test(R),qt=Nf(n,R,P)+"&print=1",ln=w.useCallback(()=>{Ke(!1),Ct?window.print():Oi.current?.click()},[Ct]),yi=w.useCallback(async()=>{try{const ve=await bN(Nf(n,R,P));if(ve.kind!=="text")return Ve(ve.kind==="too-large"?"Too large to copy — use Download.":"That file isn't text — use Download.",!0);const Pe=await zs(ve.text);Ve(Pe?"Copied "+R:"Copy failed — the clipboard needs a secure (https) origin.",!Pe)}catch(ve){Ve("Copy failed: "+ve.message,!0)}},[n,R,P]),It=w.useCallback(()=>Le(!0),[]),[ri,ls]=w.useState(""),Ln=r&&!!s&&_s(s?.perm,"write"),si=w.useCallback(async(ve,Pe,rt)=>{if(await kl("Restore this version of "+ve+"?","It syncs to every device as a new change. "+(rt?"The file comes back on every device. Removing it again isn't available from History yet.":"You can restore any other version afterwards."),"Restore")){ls(ve+Pe);try{await Wr(n+"restore",{path:ve,sha:Pe}),l.invalidateQueries({queryKey:["history",n]}),l.invalidateQueries({queryKey:["tree",n]}),l.invalidateQueries({queryKey:["render",n,ve]}),l.invalidateQueries({queryKey:["text"]}),Ve("Restored "+ve+" — it syncs to every device like any other change.")}catch(_t){Ve("Restore failed: "+_t.message,!0)}finally{ls("")}}},[n,l]),[Mo,Qi]=w.useState(""),ed=w.useCallback(async ve=>{if(await kl("Remove "+ve+"?","It disappears from every synced device. History keeps it — you can restore it from the DELETED row afterwards.","Remove file",!0)){Qi(ve);try{await Wr(n+"remove",{path:ve}),l.invalidateQueries({queryKey:["history",n]}),l.invalidateQueries({queryKey:["tree",n]}),l.invalidateQueries({queryKey:["render",n,ve]}),l.invalidateQueries({queryKey:["text"]}),Ve("Removed "+ve+" — it syncs to every device like any other change.")}catch(Pe){Ve("Remove failed: "+Pe.message,!0)}finally{Qi("")}}},[n,l]),[Ih,Zr]=w.useState(""),Rn=w.useCallback(async ve=>{const Pe=ve.session||ve.note,rt=ve.session?{session:ve.session,device:ve.entries[0]?.device?.id}:{note:ve.note,device:ve.entries[0]?.device?.id};Zr(Pe);try{const _t=await Wr(n+"undo-run",{...rt,preview:!0}),Pt=new Set(_t.changed_after);if(!_t.undone.length){Ve("Nothing to undo — every file this run touched already holds its pre-run content.");return}if(!await kl("Undo this run?",m.jsxs(m.Fragment,{children:[m.jsxs("div",{children:[ve.note||Pe," — ",_t.undone.length," file",_t.undone.length===1?"":"s"]}),m.jsx("div",{className:"undo-list",children:_t.undone.map(Ir=>m.jsxs("div",{className:"undo-row",children:[m.jsx("span",{className:"undo-path",children:Ir.path}),Pt.has(Ir.path)&&m.jsx("span",{className:"undo-after",children:"changed after this run"}),m.jsx("span",{className:"undo-what",children:Ir.action==="remove"?"remove (the run created it)":"restore to pre-run version"})]},Ir.path))}),Pt.size>0&&m.jsxs("div",{className:"undo-warn",children:[Pt.size," file",Pt.size===1?" was":"s were"," changed by someone else after this run. Undoing overwrites ",Pt.size===1?"that change":"those changes"," too."]}),_t.skipped.length>0&&m.jsxs("div",{children:[_t.skipped.length," already hold",_t.skipped.length===1?"s":""," its pre-run content and will be left alone."]}),_t.refused.length>0&&m.jsxs("div",{children:[_t.refused.length," path",_t.refused.length===1?"":"s"," can't be written by the hub and will be left alone: ",_t.refused.join(", "),"."]})]}),"Undo run",!0))return;const Ya=await Wr(n+"undo-run",rt);l.invalidateQueries({queryKey:["history",n]}),l.invalidateQueries({queryKey:["tree",n]}),l.invalidateQueries({queryKey:["render",n]}),l.invalidateQueries({queryKey:["text"]});const Ys=Ya.skipped.length?`, skipped ${Ya.skipped.length} (already current)`:"";Ve(`Undid ${Ya.undone.length} file${Ya.undone.length===1?"":"s"}${Ys}.`)}catch(_t){Ve("Undo failed: "+_t.message,!0)}finally{Zr("")}},[n,l]),Qn=w.useCallback(()=>{if(!R)return ne("");ne(te?R+"/":R)},[R,te,ne]);w.useEffect(()=>{const ve=Pe=>{(Pe.metaKey||Pe.ctrlKey)&&Pe.key.toLowerCase()==="k"&&(Pe.preventDefault(),ht(rt=>!rt))};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[]);const Do=w.useCallback(()=>{const ve=[],Pe=(rt,_t,Pt,id)=>ve.push({icon:rt,label:_t,kind:Pt,run:id});if(r&&s){const rt=s.id,_t=Pt=>()=>{t.onClosePanel?.(),zt(Pt)};Pe("folder",s.name+" — project root","project",_t("/"+rt)),Pe("dashboard","Dashboard","action",_t(Zi("dashboard",rt))),Pe("terminal","Installation","action",_t(Zi("install",rt))),Pe("gear","Settings","action",_t(Zi("settings",rt)))}if(r&&s&&R&&(pr&&Pe("share","Share: "+R,"action",It),Pe("hist","History: "+R,"action",Qn),G&&Pe("download","Download: "+R,"action",()=>ti.current?.click()),on&&Pe("printer","Print: "+R,"action",ln),Zt&&Pe("copy","Copy: "+R,"action",yi)),r&&s&&Pe("hist","History: whole project","action",()=>ne("")),r)for(const rt of t.projects||[])(!s||rt.id!==s.id)&&Pe("folder","Switch to project: "+rt.name,"project",()=>zt("/"+rt.id));e.auth?.enabled&&Pe("power","Sign out","action",()=>window.location.href="/auth/logout");for(const rt of h.keys())Pe("folder",rt,"folder",()=>V(rt));for(const rt of f)Pe("doc",rt.path,"file",()=>V(rt.path));return ve},[r,s,R,G,pr,Zt,on,e.auth?.enabled,h,f,t.projects,t.onClosePanel,It,yi,ln,Qn,ne,V]);w.useEffect(()=>{if(!Ue)return;const ve=()=>Ke(!1);return document.addEventListener("click",ve),()=>document.removeEventListener("click",ve)},[Ue]);const No=w.useCallback(ve=>h.has(ve),[h]);let Xh="app",td,vi;if(At)vi=At.body;else if(i.view==="dashboard")vi=m.jsx(AA,{flatFiles:f,heatMap:S,devices:A,scope:i.viewTarget||"",loading:!p,installHref:s?Zi("install",s.id):void 0,onOpenFile:V,onOpenFolder:V,onOpenHistory:ne,isFolder:No});else if(i.view==="history")vi=m.jsx(Age,{apiBase:n,target:i.viewTarget||"",isFolder:No,flatFiles:f,onOpen:V,onMeta:ye,onRendered:I,restore:Ln?{onRestore:si,busy:ri}:void 0,remove:Ln?{onRemove:ed,busy:Mo}:void 0,undoRun:Ln?{onUndoRun:Rn,busy:Ih}:void 0,filters:i.filters,onFilters:ve=>zt(Zi("history",s?.id,i.viewTarget||"",ve))});else if(R)if(!p)vi=m.jsx("div",{className:"empty",children:"Loading…"});else if(Y)vi=m.jsxs("div",{className:"notfound",children:[m.jsx("h1",{children:"Couldn't find that"}),m.jsxs("p",{children:[m.jsx("code",{children:R})," isn't in this project right now."]}),m.jsx("p",{className:"nf-sub",children:"If it was just created, it may still be uploading or syncing from a teammate's device — this page checks again automatically every few seconds, so refresh or come back in a moment."}),m.jsx("button",{className:"pbtn",onClick:()=>l.invalidateQueries({queryKey:["tree",n]}),children:"Check again"})]});else if(te)vi=m.jsx(tne,{node:h.get(R),heatMap:S,folders:C,hub:r&&!!s,apiBase:n,onOpen:V,onFullHistory:ne,onRendered:I});else{Xh=Fc.test(R)||Bg.test(R)?"wide":"read",td="markdown",ni&&!PM.test(R)&&(td+=" bleed");const ve=wN(R);vi=m.jsxs(m.Fragment,{children:[P&&m.jsx(Lge,{apiBase:n,path:R,version:P,onViewCurrent:()=>V(R)}),ve&&m.jsx(Zge,{conflict:ve,originalHref:f.some(Pe=>Pe.path===ve.original)?()=>V(ve.original):void 0}),m.jsx(Cpe,{apiBase:n,path:R,version:P,heatMap:S,flatFiles:f,projectId:s?.id,onOpenFile:V,onMeta:ye,onRendered:I,editing:Ri,editSource:sn,me:xn})]})}else T?vi=m.jsxs(m.Fragment,{children:[m.jsx(gN,{project:s,existing:i.connect==="existing"}),m.jsx("div",{className:"home-insights",children:m.jsx(AA,{flatFiles:f,heatMap:S,devices:A,loading:!p,onOpenFile:V,onOpenFolder:V,onOpenHistory:ne,isFolder:No})})]}):vi=m.jsx("div",{className:"empty",children:"Select a file to read it."});H&&H.to===R&&(vi=m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"vbanner",role:"status",children:[m.jsx("span",{className:"vb-icon",children:m.jsx(st,{name:"link"})}),m.jsxs("div",{className:"vb-text",children:[m.jsxs("b",{children:["Moved from ",H.from]}),m.jsx("span",{children:"The URL has been updated."})]})]}),vi]}));const qa=At?At.crumb:R?m.jsx(Bte,{path:R,onOpenFolder:V}):i.view==="dashboard"?"Dashboard — "+(i.viewTarget||s?.name||""):i.view==="history"?"History — "+Mge(i.viewTarget||"",No):T?s.name:null,nd=m.jsx(bl,{nav:e.desktop?m.jsxs("span",{id:"nav-btns",children:[m.jsx("button",{className:"nav-btn",title:"Back (⌘[)","aria-label":"Back",onClick:()=>history.back(),children:m.jsx(st,{name:"chevl"})}),m.jsx("button",{className:"nav-btn",title:"Forward (⌘])","aria-label":"Forward",onClick:()=>history.forward(),children:m.jsx(st,{name:"chev"})})]}):void 0,crumb:qa,meta:ie,actions:m.jsxs(m.Fragment,{children:[m.jsx(wte,{people:y,path:R}),gr&&m.jsx(at,{id:"edit-btn",variant:"toolbar",title:Ri?"Stop editing":"Edit this file",onClick:()=>zt(Yr(R,s?.id,P,i.full,!Ri)),children:Ri?"Done":"Edit"}),Ri&&Fc.test(R)&&m.jsx(at,{id:"edit-source-btn",variant:"toolbar",title:sn?"Back to editing the page":"Edit this file's HTML markup",onClick:()=>Yi(ve=>!ve),children:sn?"Edit page":"Edit source"}),pr&&m.jsx(at,{id:"share-btn",variant:"toolbar",className:"icon-only",title:"Share","aria-label":"Share",onClick:It,children:m.jsx(st,{name:"share"})}),Ae&&m.jsx(at,{id:"full-btn",ref:mr,variant:"toolbar",className:"icon-only",title:"Fullscreen","aria-label":"Fullscreen",onClick:jo,children:m.jsx(st,{name:"expand"})}),_e&&!R&&!i.view&&m.jsxs(at,{id:"history-btn",variant:"toolbar",onClick:Qn,children:[m.jsx(st,{name:"hist"})," ",m.jsx("span",{className:"lbl",children:"History"})]}),ut&&m.jsx("a",{id:"download",hidden:!0,download:!0,href:Xe,ref:ti,children:"Download"}),on&&!Ct&&m.jsx("a",{id:"print",hidden:!0,target:"_blank",rel:"noopener",href:qt,ref:Oi,children:"Print"}),an&&m.jsx(at,{id:"more-btn",variant:"toolbar",className:"icon-only",title:"More actions","aria-label":"More actions",onClick:ve=>{ve.stopPropagation(),Ke(!Ue)},children:m.jsx(st,{name:"dots"})}),Ue&&m.jsxs("div",{id:"more-menu",role:"menu",children:[_e&&m.jsx("button",{className:"more-item",onClick:Qn,children:"History"}),ut&&m.jsx("button",{className:"more-item",onClick:()=>ti.current?.click(),children:"Download"}),on&&m.jsx("button",{id:"print-item",className:"more-item",onClick:ln,children:"Print"}),Se&&m.jsx("button",{className:"more-item",onClick:ke,children:"Copy web link"}),Zt&&m.jsx("button",{className:"more-item",onClick:yi,children:"Copy"}),r&&!!s&&m.jsx("button",{className:"more-item",onClick:()=>{t.onClosePanel?.(),zt(Zi("dashboard",s?.id,R))},children:"Dashboard"})]})]})});return m.jsxs(m.Fragment,{children:[m.jsx(vl,{vault:t.sidebar.vault,projectsNav:t.sidebar.projectsNav,orgBar:t.sidebar.orgBar,tree:m.jsx(Xte,{root:u,expanded:z,onToggle:oe,currentPath:X,listingShowing:K,restricted:$,onOpen:V}),topbar:nd,exit:ni?m.jsxs("button",{id:"exit-full",ref:qs,onClick:ii,"aria-label":"Exit fullscreen",children:[m.jsx(st,{name:"shrink"}),m.jsx("span",{className:"lbl",children:"Exit"}),m.jsx("kbd",{children:"esc"})]}):void 0,contentRef:ae,onContentScroll:N,children:m.jsxs(Gc,{width:Xh,className:td,children:[!At&&G&&m.jsx(Lpe,{shares:he,canRevoke:!!s&&_s(s.perm,"write"),onChanged:q}),vi]})}),xe&&s&&m.jsx(zpe,{project:s,path:R,isDir:te,shares:U||[],onChanged:q,onOpenFolder:ve=>zt(Yr(ve,s.id)),onClose:()=>{Le(!1),q()}}),m.jsx(yge,{open:Et,onClose:()=>ht(!1),candidates:Do})]})}function Ige({config:t}){const e=h1(),n=sD(),[i,r]=w.useState(null),[s,o]=w.useState(null);w.useEffect(()=>o(null),[e]);const l=w.useMemo(()=>{if(!t.desktop)return null;const I=e.split("?")[0].match(/^\/setup(?:\/(connect|syncing|done))?\/?$/);return I?I[1]??"welcome":null},[e,t.desktop]),u=w.useMemo(()=>{const I=e.split("?")[0].match(/^\/join\/([0-9a-f]+)\/?$/);return I?I[1]:null},[e]),f=w.useMemo(()=>new URLSearchParams(e.split("?")[1]||"").get("p")||"",[e]),h=SF(),{data:p}=bF(!u),{data:O}=tD(!u),y=!!t.auth.admin,{data:v}=rD(y),S=w.useMemo(()=>cD(e,"hub"),[e]),[k,C]=w.useState(!1),$=()=>t.desktop?zt("/setup/connect"):C(!0),T=t.upload.enabled,Q=async(I,N)=>{const V=N===mN;try{const ne=await Wr("/api/projects",{name:I,template:V?"":N});C(!1),await n(),zt("/"+ne.project.id+(V?"?connect=existing":"")),Ve(`Created “${ne.project.name}”.`)}catch(ne){Ve("Could not create the project: "+ne.message,!0)}},A=k&&!t.desktop?m.jsx(ete,{templates:t.templates??[],onCreate:Q,onClose:()=>C(!1)}):null,R=w.useMemo(()=>p&&(p.find(I=>I.id===S.project)||i&&p.find(I=>I.org===i)||p.find(I=>I.id===vq())||p[0])||null,[p,S.project,i]),P=c1(t.desktop?R?.id:void 0),X=w.useMemo(()=>!R||!t.desktop?R:{...R,perm:P.data?.me??R.perm},[R,t.desktop,P.data]);if(w.useEffect(()=>{document.title=R?lD(S,R.name):t.brand||"BearDrive"},[R,S,t.brand]),w.useEffect(()=>{R&&bq(R.id)},[R]),u)return m.jsx(Xge,{token:u,onDone:async I=>{r(I),await n();const V=!!(f?await h().catch(()=>null):null)?.projects?.some(ne=>ne.id===f);zt(V?"/"+f+"/install":"/",{replace:!0})}});const te=t.brand||"BearDrive",G=R&&O?.find(I=>I.id===R.org)||null,Y=m.jsx(DO,{name:te,onHome:()=>zt("/"),search:!!R,beta:te==="BearDrive"}),K=fr(),se=(I,N)=>{N&&Ve(N),dm(I).catch(()=>{}).finally(()=>K.invalidateQueries({queryKey:["config"]}))},H=t.me?m.jsx(Nee,{me:t.me,org:G,orgActive:!!S.org,billing:t.billing,mcp:t.mcp,signOut:t.desktop?()=>se("/api/desktop/logout"):void 0,admin:y?{pending:v?.length||0,onClick:()=>{o({kind:"hub"}),Fr()}}:void 0}):t.desktop?m.jsx(zee,{onSignIn:()=>se("/api/desktop/login","Finish signing in in your browser…")}):void 0;if(l)return m.jsx(vl,{vault:Y,topbar:m.jsx(bl,{}),children:m.jsx(Gc,{children:m.jsx(Jee,{step:l,signedIn:!!t.me,onSignIn:()=>se("/api/desktop/login","Finish signing in in your browser…")})})});if(!p||!O)return m.jsx(vl,{vault:Y,topbar:m.jsx(bl,{}),children:m.jsx(Gc,{children:m.jsx("div",{className:"empty",children:"Loading…"})})});if(t.desktop&&p.length===0)return m.jsx(hl,{to:"/setup"});if(!R)return m.jsxs(vl,{vault:Y,projectsNav:m.jsx(fb,{projects:p,onNew:$}),orgBar:H,topbar:m.jsx(bl,{}),children:[m.jsx(Gc,{children:m.jsx(Yee,{onNew:$,canCreate:T})}),A]});const pe=s?.kind==="hub"?{crumb:"Signup & access",body:m.jsx(_ee,{})}:null,z=S.org?O.find(I=>I.id===S.org):null,ce=S.org&&!z?{crumb:"Organization",body:m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"Organization not found"}),m.jsx("p",{children:"This organization doesn't exist, or you're no longer a member."}),m.jsx("p",{children:m.jsxs("a",{...Cl("/"+R.id),children:["Back to ",R.name]})})]})}:z?{crumb:"Organization",body:m.jsx(wee,{org:z,projects:p,myEmail:t.me?.email||""})}:null;if(!!S.project&&!p.some(I=>I.id===S.project)){const I=TF(p,S.project);return I?m.jsx(hl,{to:S.view?Zi(S.view,I,S.viewTarget,S.filters):Yr(S.path,I,S.version,S.full,S.editing)}):m.jsxs(vl,{vault:Y,projectsNav:m.jsx(fb,{projects:p,onNew:$}),orgBar:H,topbar:m.jsx(bl,{}),children:[m.jsx(Gc,{children:m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"Project not found"}),m.jsxs("p",{children:["There's no project called “",LO(S.project),"” in your account. It may have been renamed or deleted, or the link may be wrong."]}),m.jsx("p",{children:m.jsxs("a",{...Cl("/"+R.id),children:["Back to ",R.name]})})]})}),A]})}const ae=S.connections?{crumb:"Connected agents",body:t.mcp?m.jsx($ee,{projects:p}):m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"No agent access on this hub"}),m.jsx("p",{children:"This BearDrive hub doesn't serve an MCP endpoint."})]})}:null,D=S.billing?{crumb:"Billing",body:t.billing?m.jsx(Lee,{url:t.billing.url}):m.jsxs("div",{className:"empty",children:[m.jsx("h3",{children:"No billing on this hub"}),m.jsx("p",{children:"This BearDrive hub doesn't have a billing surface."})]})}:null,j=S.view==="settings"?{crumb:"Project settings",body:m.jsx(Xee,{project:X??R,org:G,onDeleted:async()=>{await n(),zt("/")}})}:S.view==="install"?{crumb:"Installation",body:m.jsx(gN,{project:R,existing:S.connect==="existing"})}:null;return!S.org&&!S.billing&&!S.connections&&S.project!==R.id?m.jsx(hl,{to:"/"+R.id}):S.legacyView&&S.view?m.jsx(hl,{to:Zi(S.view,R.id,S.viewTarget,S.filters)}):S.queryTarget&&S.view?m.jsx(hl,{to:Zi(S.view,R.id,S.viewTarget,S.filters)}):S.trailingSlash&&S.path?m.jsx(hl,{to:Yr(S.path,R.id,S.version,S.full,S.editing)}):m.jsxs(m.Fragment,{children:[m.jsx(jZ,{config:t,apiBase:"/api/p/"+R.id+"/",route:S,hub:!0,project:X??R,projects:p,sidebar:{vault:Y,projectsNav:m.jsx(fb,{projects:p,currentId:R.id,onNew:$,menu:{active:s?null:S.view==="dashboard"&&!S.viewTarget?"dashboard":S.view==="install"?"install":S.view==="history"&&!S.viewTarget?"history":S.view==="settings"?"settings":null,onDashboard:()=>{o(null),zt(Zi("dashboard",R.id)),Fr()},onInstall:()=>{o(null),zt(Zi("install",R.id)),Fr()},onHistory:()=>{o(null),zt(Zi("history",R.id)),Fr()},onSettings:()=>{o(null),zt(Zi("settings",R.id)),Fr()}}}),orgBar:H},panel:pe||ce||D||ae||j,onClosePanel:()=>o(null)},R.id),A]})}function Xge({token:t,onDone:e}){return w.useEffect(()=>{let n=!1;return Wr("/api/invites/"+t).then(i=>{n||(Ve(`Welcome — you joined the “${i.org.name}” team. Opening its projects…`),e(i.org.id))}).catch(i=>{n||String(i.message).includes("signing in")||(Ve("Could not accept the invite: "+i.message,!0),e(null))}),()=>{n=!0}},[t]),m.jsx(vl,{vault:m.jsx(DO,{name:"BearDrive",beta:!0}),topbar:m.jsx(bl,{}),children:m.jsx(Gc,{children:m.jsx("div",{className:"empty",children:"Joining…"})})})}function Vge({config:t}){const e=h1(),n=t.volume||"BearDrive",i=w.useMemo(()=>cD(e,"volume"),[e]),r=t.brand||t.volume;return w.useEffect(()=>{document.title=r?lD(i,r):"BearDrive"},[i,r]),i.trailingSlash&&i.path?m.jsx(hl,{to:Yr(i.path,void 0,i.version,i.full,i.editing)}):m.jsx(jZ,{config:t,apiBase:"/api/",route:i,hub:!1,sidebar:{vault:m.jsx(DO,{name:n,showSignout:t.auth.enabled,search:!0})}})}function Bge(){const{data:t}=qX();return m.jsxs(fq,{delayDuration:150,children:[t?t.mode==="hub"?m.jsx(Ige,{config:t}):m.jsx(Vge,{config:t}):m.jsx(vl,{vault:m.jsx(DO,{name:"…",showSignout:!1}),topbar:m.jsx(bl,{}),children:m.jsx("div",{className:"empty",children:"Loading…"})}),m.jsx(fF,{}),m.jsx(OF,{})]})}class Uge extends w.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,n){console.error("BearDrive: unhandled render error",e,n.componentStack)}render(){return this.state.error?m.jsxs("div",{className:"mx-auto max-w-lg p-8 text-sm",children:[m.jsx("h1",{className:"mb-2 text-lg font-semibold",children:"This page didn’t load"}),m.jsx("p",{className:"mb-4 opacity-80",children:"Something went wrong rendering this view. The rest of BearDrive is fine."}),m.jsx("p",{className:"mb-4",children:m.jsx("a",{className:"underline",href:"/",children:"Go to the project list"})}),m.jsx("pre",{className:"overflow-x-auto rounded bg-black/5 p-3 text-xs dark:bg-white/10",children:String(this.state.error)})]}):this.props.children}}const qge=new TX({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1,staleTime:3e4}}});tX.createRoot(document.getElementById("root")).render(m.jsx(w.StrictMode,{children:m.jsx(Uge,{children:m.jsx(EX,{client:qge,children:m.jsx(Bge,{})})})})); diff --git a/internal/webapp/static/index.html b/internal/webapp/static/index.html index c7f2442..083d64a 100644 --- a/internal/webapp/static/index.html +++ b/internal/webapp/static/index.html @@ -5,7 +5,7 @@ BearDrive - + diff --git a/internal/webapp/stream_guard_test.go b/internal/webapp/stream_guard_test.go index b945129..9325525 100644 --- a/internal/webapp/stream_guard_test.go +++ b/internal/webapp/stream_guard_test.go @@ -28,7 +28,12 @@ func TestStreamsRefuseAnUnflushableWriter(t *testing.T) { })) defer ts.Close() - for _, path := range []string{"/events", "/collab?path=a.md"} { + // /events is the hub's remaining long-lived stream. It used to be tested + // alongside /collab, the co-editing relay — which is gone: the hub holds + // the document now and serves it over a websocket, an upgrade rather than + // a stream this guard applies to (compression skips upgrades for the + // related reason, see compress.go). + for _, path := range []string{"/events"} { resp, err := http.Get(ts.URL + "/api/p/" + p.ID + path) if err != nil { t.Fatalf("%s: %v", path, err) @@ -63,13 +68,13 @@ func TestUnwrapRestoresStreamingThroughMiddleware(t *testing.T) { })) defer ts.Close() - resp, err := http.Get(ts.URL + "/api/p/" + p.ID + "/collab?path=a.md") + resp, err := http.Get(ts.URL + "/api/p/" + p.ID + "/events") if err != nil { t.Fatal(err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - t.Fatalf("collab stream behind the fixed middleware: %d", resp.StatusCode) + t.Fatalf("event stream behind the fixed middleware: %d", resp.StatusCode) } buf := make([]byte, 64) if n, err := resp.Body.Read(buf); err != nil || n == 0 { @@ -84,13 +89,13 @@ func TestStreamsStillOpenThroughAPlainWriter(t *testing.T) { ts := httptest.NewServer(srv.Handler()) defer ts.Close() - resp, err := http.Get(ts.URL + "/api/p/" + p.ID + "/collab?path=a.md") + resp, err := http.Get(ts.URL + "/api/p/" + p.ID + "/events") if err != nil { t.Fatal(err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - t.Fatalf("collab stream: %d", resp.StatusCode) + t.Fatalf("event stream: %d", resp.StatusCode) } buf := make([]byte, 64) n, err := resp.Body.Read(buf) // the hello frame, flushed before anything else diff --git a/internal/webapp/upload.go b/internal/webapp/upload.go index 9e0b58c..213dc41 100644 --- a/internal/webapp/upload.go +++ b/internal/webapp/upload.go @@ -516,32 +516,6 @@ func (s *Server) handleUploadContent(v *volume, w http.ResponseWriter, r *http.R // up in a heap profile. defer s.lockPath(projectID(r), p)() - // The browser says which version its buffer was built on. A mismatch means - // somebody else wrote this path in the meantime, and taking this body - // wholesale would erase their work — which is exactly what happened when a - // client lost the co-editing relay: two browsers holding different - // documents, each overwriting the other every few seconds, silently. - // - // Optional by design. A caller that sends no If-Match gets the old - // behaviour, so older clients, the MCP tools and every other writer here - // are untouched. - if base := strings.Trim(r.Header.Get("If-Match"), `"`); base != "" { - if head, ok := s.headBlob(r.Context(), v, p); ok && head != base { - // The current sha travels with the refusal, so the client can fetch - // what it missed without a second round trip to find out what to ask - // for. - writeJSONStatus(w, http.StatusConflict, map[string]any{ - "error": "this file changed since you last read it", - "sha": head, - "path": p, - }) - return - } - } - // Spool first, then charge what actually arrived. Content-Length is -1 on - // any chunked request, so max(r.ContentLength, 0) admitted an upload of any - // size against a quota of zero bytes and billed it at zero — the hole round - // 1 closed on the device door, still open on this one. tmp, size, blob, err := spool(r.Body) if err != nil { http.Error(w, fmt.Sprintf("store: %v", err), http.StatusBadGateway) @@ -596,6 +570,41 @@ func (s *Server) handleUploadContent(v *volume, w http.ResponseWriter, r *http.R return } + /* Only now, whether this write was built on the version it replaces. + + AFTER the no-op check above, and that order is load-bearing: a client + whose base is stale but whose CONTENT matches the file has nothing to + conflict about. Answering it with a 409 made the editor park a conflict + copy of text nobody disputed — three clients sharing one document + produced two such copies of identical text, which is how this was + found. A conflict is a disagreement, not a late arrival. */ + // The browser says which version its buffer was built on. A mismatch means + // somebody else wrote this path in the meantime, and taking this body + // wholesale would erase their work — which is exactly what happened when a + // client lost the co-editing relay: two browsers holding different + // documents, each overwriting the other every few seconds, silently. + // + // Optional by design. A caller that sends no If-Match gets the old + // behaviour, so older clients, the MCP tools and every other writer here + // are untouched. + if base := strings.Trim(r.Header.Get("If-Match"), `"`); base != "" { + if head, ok := s.headBlob(r.Context(), v, p); ok && head != base { + // The current sha travels with the refusal, so the client can fetch + // what it missed without a second round trip to find out what to ask + // for. + writeJSONStatus(w, http.StatusConflict, map[string]any{ + "error": "this file changed since you last read it", + "sha": head, + "path": p, + }) + return + } + } + // Spool first, then charge what actually arrived. Content-Length is -1 on + // any chunked request, so max(r.ContentLength, 0) admitted an upload of any + // size against a quota of zero bytes and billed it at zero — the hole round + // 1 closed on the device door, still open on this one. + if err := up.Upload(r.Context(), p, tmp, size, s.requestUser(r), ""); err != nil { http.Error(w, fmt.Sprintf("store: %v", err), http.StatusBadGateway) return diff --git a/internal/webapp/upload_ifmatch_test.go b/internal/webapp/upload_ifmatch_test.go index 26ac8a5..859bba0 100644 --- a/internal/webapp/upload_ifmatch_test.go +++ b/internal/webapp/upload_ifmatch_test.go @@ -172,3 +172,51 @@ func TestUploadOfIdenticalContentIsNotAChange(t *testing.T) { t.Errorf("versions after a real edit = %d, want 2", n) } } + +/* A late arrival is not a disagreement. + + If-Match is there to stop one editor's text being erased by another who + never saw it. A client whose base is stale but whose CONTENT already + matches the file has erased nothing — there is nothing to preserve — so + answering it with a 409 made the editor park a conflict copy of text + nobody disputed. Three clients sharing one hub-held document produced two + such copies of identical text, which is how this was found. */ +func TestStaleBaseWithIdenticalContentIsNotAConflict(t *testing.T) { + srv, p, _ := newHub(t, true, nil) + h := srv.Handler() + url := "/api/p/" + p.ID + "/upload/content?path=notes.md" + + first := putContent(t, h, url, "one\n", "") + var out struct{ SHA string } + if err := json.Unmarshal(first.Body.Bytes(), &out); err != nil { + t.Fatal(err) + } + stale := out.SHA + + // Somebody else moves the head on, to the text this client is about to + // send — which is what a shared document produces: everyone converges, + // then everyone saves. + if rec := putContent(t, h, url, "converged\n", ""); rec.Code != http.StatusOK { + t.Fatalf("second write: %d", rec.Code) + } + + late := putContent(t, h, url, "converged\n", stale) + if late.Code == http.StatusConflict { + t.Fatal("a write of the text the file already holds was called a conflict") + } + if late.Code != http.StatusOK { + t.Fatalf("late write = %d: %s", late.Code, late.Body.String()) + } + var got struct{ Unchanged bool } + if err := json.Unmarshal(late.Body.Bytes(), &got); err != nil { + t.Fatal(err) + } + if !got.Unchanged { + t.Error("it was taken as a change") + } + + // And a stale base with DIFFERENT content is still a conflict. + if rec := putContent(t, h, url, "actually different\n", stale); rec.Code != http.StatusConflict { + t.Errorf("a real lost update = %d, want 409", rec.Code) + } +}