github-stars-organizer 0.1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -23
- package/dist/app/apple-touch-icon.png +0 -0
- package/dist/app/assets/{backups-DxRMQO9O.js → backups-bxixTSN9.js} +1 -1
- package/dist/app/assets/{badge-Ba4FNylI.js → badge-BI8BnSpx.js} +1 -1
- package/dist/app/assets/button-j3ddoMPG.js +14 -0
- package/dist/app/assets/{coerce-B4B_TTls.js → coerce-CLwOVTKZ.js} +1 -1
- package/dist/app/assets/{download-CzXogqy0.js → download-BE4lcLN2.js} +1 -1
- package/dist/app/assets/{explore-CrybvCPL.js → explore-c7E93yLq.js} +1 -1
- package/dist/app/assets/{history-C-bdlEYN.js → history-CwU1iI1t.js} +1 -1
- package/dist/app/assets/{index-C_V67CMR.js → index-D00n1Vsd.js} +3 -3
- package/dist/app/assets/{list._listId-BHMtNFq8.js → list._listId-B_ZPye2o.js} +1 -1
- package/dist/app/assets/list._listId-DQE4KiA8.js +2 -0
- package/dist/app/assets/{local-sync-DQzF1V9q.js → local-sync-93kiPKY6.js} +1 -1
- package/dist/app/assets/{registry-BKuxwL5K.js → registry-CFdu_QCX.js} +1 -1
- package/dist/app/assets/{routes-C_O77OAA.js → routes-DkgX4EzU.js} +1 -1
- package/dist/app/assets/routes-DnP52mv4.js +2 -0
- package/dist/app/assets/{schemas-D_ddKDHk.js → schemas-D4rG9WO5.js} +1 -1
- package/dist/app/assets/{star-DgcTDj5Y.js → star-DX2rWFRo.js} +1 -1
- package/dist/app/favicon.svg +6 -1
- package/dist/app/index.html +9 -8
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/dist/app/assets/button-ZbiqMfUE.js +0 -14
- package/dist/app/assets/list._listId-tfkSZzxB.js +0 -2
- package/dist/app/assets/routes-lhdAnl7w.js +0 -2
- package/dist/app/icons.svg +0 -24
package/README.md
CHANGED
|
@@ -1,33 +1,16 @@
|
|
|
1
1
|
# github-stars-organizer
|
|
2
2
|
|
|
3
|
-
Search, tag, rate and
|
|
4
|
-
score for every repo. Runs on your machine with the GitHub login you already have.
|
|
3
|
+
Search, tag, rate and sort your GitHub stars into Lists that sync back to GitHub.
|
|
5
4
|
|
|
6
5
|
```bash
|
|
7
|
-
gh auth login # once, if you haven't
|
|
8
6
|
npx github-stars-organizer
|
|
9
7
|
```
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
are written to GitHub; tags, ratings and notes are saved in your browser. Set `GITHUB_TOKEN` to use
|
|
13
|
-
a different token, `--port` to use another port, `--no-open` to skip opening the browser.
|
|
9
|
+
Uses your `gh` login (or `GITHUB_TOKEN`) and opens http://127.0.0.1:5185. Ctrl-C to quit.
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
restore never unstars or deletes anything. GitHub dates a re-starred repo the day it was restored.
|
|
11
|
+
- Backs up your stars and Lists to `~/.github-stars-organizer/backups/` before every launch.
|
|
12
|
+
- Talks only to `api.github.com`. No telemetry; your data stays on your machine.
|
|
18
13
|
|
|
19
|
-
|
|
14
|
+
Source and demo: https://github.com/armanckeser/github-stars-organizer
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
telemetry. What it keeps stays on your computer, in that browser's storage and the backups folder.
|
|
23
|
-
|
|
24
|
-
## License
|
|
25
|
-
|
|
26
|
-
Copyright (C) 2026 Armanc Keser. Free software under the GNU Affero General Public License, version 3
|
|
27
|
-
or (at your option) any later version; see `LICENSE`. It comes with ABSOLUTELY NO WARRANTY.
|
|
28
|
-
`dist/THIRD-PARTY-LICENSES.txt` and `dist/app/THIRD-PARTY-LICENSES.txt` list the licenses of the
|
|
29
|
-
packages bundled into it.
|
|
30
|
-
|
|
31
|
-
Not affiliated with or endorsed by GitHub. GitHub is a trademark of GitHub, Inc.
|
|
32
|
-
|
|
33
|
-
Source, demo and a self-hosted version: https://github.com/armanckeser/github-stars-organizer
|
|
16
|
+
Copyright (C) 2026 Armanc Keser. AGPL-3.0-or-later, with absolutely no warranty. Bundled licenses are in `dist/THIRD-PARTY-LICENSES.txt`. Not affiliated with or endorsed by GitHub.
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{H as e,K as t,Q as n,R as r,U as i,V as a,W as o,et as s,n as c,rt as l,t as u}from"./button-ZbiqMfUE.js";import{t as d}from"./download-CzXogqy0.js";import{t as ee}from"./history-C-bdlEYN.js";import{Pn as f,a as p,at as m,c as h,d as te,g,i as _,it as v,n as ne,o as y,r as b,rt as re,s as x,u as S,y as C}from"./schemas-D_ddKDHk.js";import{t as w}from"./local-sync-DQzF1V9q.js";var T=r(`upload`,[[`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`}]]),E=l(s(),1),D=n();function ie({...e}){return(0,D.jsx)(te,{"data-slot":`dialog`,...e})}function ae({...e}){return(0,D.jsx)(g,{"data-slot":`dialog-portal`,...e})}function O({className:e,...t}){return(0,D.jsx)(m,{"data-slot":`dialog-overlay`,className:c(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function k({className:e,children:t,showCloseButton:n=!0,...r}){return(0,D.jsxs)(ae,{children:[(0,D.jsx)(O,{}),(0,D.jsxs)(C,{"data-slot":`dialog-content`,className:c(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,D.jsxs)(v,{"data-slot":`dialog-close`,render:(0,D.jsx)(u,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,D.jsx)(f,{}),(0,D.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function A({className:e,...t}){return(0,D.jsx)(`div`,{"data-slot":`dialog-header`,className:c(`flex flex-col gap-2`,e),...t})}function j({className:e,showCloseButton:t=!1,children:n,...r}){return(0,D.jsxs)(`div`,{"data-slot":`dialog-footer`,className:c(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,D.jsx)(v,{render:(0,D.jsx)(u,{variant:`outline`}),children:`Close`})]})}function M({className:e,...t}){return(0,D.jsx)(S,{"data-slot":`dialog-title`,className:c(`font-heading text-base leading-none font-medium`,e),...t})}function N({className:e,...t}){return(0,D.jsx)(re,{"data-slot":`dialog-description`,className:c(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}var P=`github-stars-organizer-backup`,F=x({githubId:y().int(),nodeId:h(),fullName:h()}),I=F.extend({starredAt:h()}),L=x({id:h(),name:h(),description:h().nullable(),isPrivate:_(),repos:b(F)}),R=x({repos:b(x({githubId:y().int(),notes:h().nullable(),usefulnessRating:y().int().min(1).max(5).nullable()})),tags:b(x({id:h(),name:h(),color:h()})),repoTags:b(x({githubId:y().int(),tagId:h()}))}),z=x({format:p(P),version:p(1),createdAt:h(),login:h(),reason:ne([`launch`,`manual`,`before-restore`,`uploaded`]),stars:b(I),lists:b(L),local:R.optional()}),B=class extends Error{};function V(e){let t=z.safeParse(e);if(t.success)return t.data;let n=e;if(n?.format!==`github-stars-organizer-backup`)throw new B(`This file isn't a Stars Organizer backup.`);if(typeof n.version==`number`&&n.version>1)throw new B("This backup was made by a newer version. Update with `npx github-stars-organizer@latest`.");let r=t.error.issues[0];throw new B(`This backup is damaged (${r.path.join(`.`)}: ${r.message}).`)}x({local:R.optional()});function H(e){return e.restar.length+e.recreateLists.length+e.addToLists.length}function U({repos:e,tags:t,repo_tags:n}){let r=new Map(e.map(e=>[e.id,e.github_id]));return{repos:e.filter(e=>e.notes||e.usefulness_rating!==null).map(e=>({githubId:e.github_id,notes:e.notes||null,usefulnessRating:e.usefulness_rating})),tags:t.map(({id:e,name:t,color:n})=>({id:e,name:t,color:n})),repoTags:n.flatMap(e=>{let t=r.get(e.repo_id);return t===void 0?[]:[{githubId:t,tagId:e.tag_id}]})}}function W(e,t,n){let r=new Map(t.repos.map(e=>[e.github_id,e])),i=e.repos.flatMap(e=>{let t=r.get(e.githubId);if(!t)return[];let n={id:t.id};return!t.notes&&e.notes&&(n.notes=e.notes),t.usefulness_rating===null&&e.usefulnessRating!==null&&(n.usefulness_rating=e.usefulnessRating),Object.keys(n).length>1?[n]:[]}),a=new Map(t.tags.map(e=>[e.name.toLowerCase(),e.id])),o=[],s=new Map;for(let t of e.tags){let e=a.get(t.name.toLowerCase());if(e){s.set(t.id,e);continue}let r={id:n(),name:t.name,color:t.color};o.push(r),a.set(r.name.toLowerCase(),r.id),s.set(t.id,r.id)}let c=new Set(t.repo_tags.map(e=>`${e.repo_id}:${e.tag_id}`));return{repos:i,tags:o,repo_tags:e.repoTags.flatMap(e=>{let t=r.get(e.githubId),i=s.get(e.tagId);if(!t||!i)return[];let a=`${t.id}:${i}`;return c.has(a)?[]:(c.add(a),[{id:n(),repo_id:t.id,tag_id:i}])})}}async function G(){return await Promise.all([a.preload(),i.preload(),e.preload()]),{repos:a.toArray,tags:i.toArray,repo_tags:e.toArray}}async function K(){return t.backUpNow({local:U(await G())})}async function q(e){let n=await t.readBackup(e.id),r=n.local?n:{...n,local:U(await G())},i=URL.createObjectURL(new Blob([JSON.stringify(r,null,2)],{type:`application/json`})),a=document.createElement(`a`);a.href=i,a.download=`stars-organizer-${n.login}-${e.id}.json`,a.click(),URL.revokeObjectURL(i)}async function J(e){let n;try{n=JSON.parse(await e.text())}catch{throw Error(`${e.name} isn't a JSON file.`)}return t.uploadBackup(V(n))}async function oe(t){let n=W(t,await G(),()=>crypto.randomUUID());return await o(()=>{for(let e of n.repos)a.update(e.id,t=>{Object.assign(t,e)});n.tags.length&&i.insert(n.tags),n.repo_tags.length&&e.insert(n.repo_tags)}),{notesAndRatings:n.repos.length,tags:n.tags.length,tagLinks:n.repo_tags.length}}async function se(e){let n=await t.applyRestore({backupId:e.id});await w();let{local:r}=await t.readBackup(e.id);return{...n,local:r?await oe(r):null}}var ce={launch:`On launch`,manual:`Backed up by hand`,"before-restore":`Before a restore`,uploaded:`From a file`},Y=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function X(e){return e instanceof Error?e.message:String(e)}function Z(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function le(){return(0,D.jsx)(ue,{})}function ue(){let[e,n]=(0,E.useState)(null),[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)(null),l=(0,E.useRef)(null);async function f(){n(await t.listBackups())}(0,E.useEffect)(()=>{f().catch(e=>i(`Couldn't read the backups: ${X(e)}`))},[]);async function p(e,t){o(!0),i(e);try{i(await t()),await f()}catch(e){i(X(e))}finally{o(!1)}}function m(){p(`Backing up...`,async()=>{let e=await K();return`Backed up ${Z(e.stars,`star`)} and ${Z(e.lists,`List`)}, with your tags, ratings and notes.`})}function h(e){e&&p(`Reading ${e.name}...`,async()=>(c(await J(e)),`Kept a copy of ${e.name}.`))}return(0,D.jsxs)(`div`,{className:`max-w-3xl space-y-6`,children:[(0,D.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`h1`,{className:`font-display text-2xl font-bold tracking-tight`,children:`Backups`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Each launch backs up your stars and Lists before the app can change anything. A restore only adds back what is missing: it never unstars a repo or deletes a List.`}),e&&(0,D.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Saved in `,(0,D.jsx)(`code`,{children:e.directory})]})]}),(0,D.jsx)(u,{onClick:m,disabled:a,children:`Back up now`})]}),r&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm`,children:r}),(0,D.jsxs)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:[e?.backups.length===0&&(0,D.jsx)(`li`,{className:`p-4 text-sm text-muted-foreground`,children:`No backups yet.`}),e?.backups.map(e=>(0,D.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 p-3`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium`,children:Y.format(new Date(e.createdAt))}),(0,D.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[ce[e.reason],` · `,Z(e.stars,`star`),` · `,Z(e.lists,`List`)]})]}),(0,D.jsxs)(u,{variant:`ghost`,size:`sm`,disabled:a,onClick:()=>void p(`Preparing the file...`,async()=>(await q(e),`Downloaded.`)),children:[(0,D.jsx)(d,{className:`mr-1.5 size-4`}),`Download`]}),(0,D.jsxs)(u,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>c(e),children:[(0,D.jsx)(ee,{className:`mr-1.5 size-4`}),`Restore...`]})]},e.id))]}),(0,D.jsxs)(`section`,{className:`space-y-2`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Restore from a file`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A backup you downloaded, from this computer or another. You see what it would change before anything does.`}),(0,D.jsx)(`input`,{ref:l,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{h(e.target.files?.[0]),e.target.value=``}}),(0,D.jsxs)(u,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>l.current?.click(),children:[(0,D.jsx)(T,{className:`mr-1.5 size-4`}),`Choose a file`]})]}),s&&(0,D.jsx)(de,{backup:s,onClose:()=>c(null),onRestored:()=>void f()})]})}var Q=5;function $({names:e}){let t=e.length-Q;return(0,D.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[e.slice(0,Q).join(`, `),t>0&&`, and ${t} more`]})}function de({backup:e,onClose:n,onRestored:r}){let[i,a]=(0,E.useState)({step:`planning`});(0,E.useEffect)(()=>{Promise.all([t.planRestore({backupId:e.id}),t.readBackup(e.id)]).then(([e,t])=>a({step:`review`,plan:e,hasLocal:t.local!==void 0})).catch(e=>a({step:`failed`,message:X(e)}))},[e.id]);async function o(){a({step:`applying`});try{a({step:`done`,result:await se(e)}),r()}catch(e){a({step:`failed`,message:X(e)})}}return(0,D.jsx)(ie,{open:!0,onOpenChange:e=>{!e&&i.step!==`applying`&&n()},children:(0,D.jsxs)(k,{children:[(0,D.jsxs)(A,{children:[(0,D.jsxs)(M,{children:[`Restore the backup from `,Y.format(new Date(e.createdAt))]}),(0,D.jsx)(N,{children:`Only adds what GitHub is missing. Nothing you starred or made since is touched.`})]}),(0,D.jsx)(fe,{state:i}),(0,D.jsxs)(j,{children:[i.step===`review`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(u,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,D.jsx)(u,{onClick:()=>void o(),disabled:H(i.plan)===0&&!i.hasLocal,children:`Restore`})]}),(i.step===`done`||i.step===`failed`)&&(0,D.jsx)(u,{onClick:n,children:`Close`})]})]})})}function fe({state:e}){switch(e.step){case`planning`:return(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Comparing the backup with GitHub...`});case`applying`:return(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Restoring. Leave this open until it finishes.`});case`failed`:return(0,D.jsx)(`p`,{className:`text-sm text-destructive`,children:e.message});case`review`:return(0,D.jsx)(pe,{plan:e.plan,hasLocal:e.hasLocal});case`done`:return(0,D.jsx)(he,{result:e.result})}}function pe({plan:e,hasLocal:t}){let n=new Set(e.addToLists.map(e=>e.repo.fullName));return H(e)===0?(0,D.jsxs)(`p`,{className:`text-sm`,children:[`GitHub already has every star and List in this backup.`,t&&` Restoring fills in any tags, ratings and notes this browser is missing.`]}):(0,D.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[e.restar.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{children:[`Star `,Z(e.restar.length,`repo`),` again. GitHub dates them today, so they move to the top.`]}),(0,D.jsx)($,{names:e.restar.map(e=>e.fullName)})]}),e.recreateLists.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{children:[`Recreate `,Z(e.recreateLists.length,`List`),`.`]}),(0,D.jsx)($,{names:e.recreateLists.map(e=>e.isPrivate?`${e.name} (private)`:e.name)})]}),n.size>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{children:[`Put `,Z(n.size,`repo`),` back in their Lists.`]}),(0,D.jsx)($,{names:[...n]})]}),t&&(0,D.jsx)(`p`,{children:`Fill in tags, ratings and notes this browser is missing. Nothing you have is overwritten.`}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A backup of how things are now is taken first, so you can go back.`})]})}function me(e){let t=[e.notesAndRatings>0&&`notes or ratings on ${Z(e.notesAndRatings,`repo`)}`,e.tagLinks>0&&Z(e.tagLinks,`tag`)].filter(e=>e!==!1);return t.length===0?`This browser already had every tag, rating and note.`:`Filled in ${t.join(` and `)}.`}function he({result:e}){return(0,D.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,D.jsxs)(`p`,{children:[`Starred `,Z(e.restarred,`repo`),` again, recreated `,Z(e.recreatedLists,`List`),`, and re-added`,` `,Z(e.addedToLists,`List entry`,`List entries`),`.`,e.local&&` ${me(e.local)}`]}),e.failed.length>0&&(0,D.jsxs)(`div`,{className:`rounded-md border border-destructive/40 p-2`,children:[(0,D.jsxs)(`p`,{className:`font-medium text-destructive`,children:[`GitHub refused `,Z(e.failed.length,`change`),`:`]}),(0,D.jsx)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:e.failed.map(e=>(0,D.jsxs)(`li`,{children:[e.what,`: `,e.reason]},e.what))})]})]})}export{le as component};
|
|
1
|
+
import{H as e,K as t,Q as n,R as r,U as i,V as a,W as o,et as s,n as c,rt as l,t as u}from"./button-j3ddoMPG.js";import{t as d}from"./download-BE4lcLN2.js";import{t as ee}from"./history-CwU1iI1t.js";import{Pn as f,a as p,at as m,c as h,d as te,g,i as _,it as v,n as ne,o as y,r as b,rt as re,s as x,u as S,y as C}from"./schemas-D4rG9WO5.js";import{t as w}from"./local-sync-93kiPKY6.js";var T=r(`upload`,[[`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`}]]),E=l(s(),1),D=n();function ie({...e}){return(0,D.jsx)(te,{"data-slot":`dialog`,...e})}function ae({...e}){return(0,D.jsx)(g,{"data-slot":`dialog-portal`,...e})}function O({className:e,...t}){return(0,D.jsx)(m,{"data-slot":`dialog-overlay`,className:c(`fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0`,e),...t})}function k({className:e,children:t,showCloseButton:n=!0,...r}){return(0,D.jsxs)(ae,{children:[(0,D.jsx)(O,{}),(0,D.jsxs)(C,{"data-slot":`dialog-content`,className:c(`fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[t,n&&(0,D.jsxs)(v,{"data-slot":`dialog-close`,render:(0,D.jsx)(u,{variant:`ghost`,className:`absolute top-2 right-2`,size:`icon-sm`}),children:[(0,D.jsx)(f,{}),(0,D.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function A({className:e,...t}){return(0,D.jsx)(`div`,{"data-slot":`dialog-header`,className:c(`flex flex-col gap-2`,e),...t})}function j({className:e,showCloseButton:t=!1,children:n,...r}){return(0,D.jsxs)(`div`,{"data-slot":`dialog-footer`,className:c(`-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,D.jsx)(v,{render:(0,D.jsx)(u,{variant:`outline`}),children:`Close`})]})}function M({className:e,...t}){return(0,D.jsx)(S,{"data-slot":`dialog-title`,className:c(`font-heading text-base leading-none font-medium`,e),...t})}function N({className:e,...t}){return(0,D.jsx)(re,{"data-slot":`dialog-description`,className:c(`text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground`,e),...t})}var P=`github-stars-organizer-backup`,F=x({githubId:y().int(),nodeId:h(),fullName:h()}),I=F.extend({starredAt:h()}),L=x({id:h(),name:h(),description:h().nullable(),isPrivate:_(),repos:b(F)}),R=x({repos:b(x({githubId:y().int(),notes:h().nullable(),usefulnessRating:y().int().min(1).max(5).nullable()})),tags:b(x({id:h(),name:h(),color:h()})),repoTags:b(x({githubId:y().int(),tagId:h()}))}),z=x({format:p(P),version:p(1),createdAt:h(),login:h(),reason:ne([`launch`,`manual`,`before-restore`,`uploaded`]),stars:b(I),lists:b(L),local:R.optional()}),B=class extends Error{};function V(e){let t=z.safeParse(e);if(t.success)return t.data;let n=e;if(n?.format!==`github-stars-organizer-backup`)throw new B(`This file isn't a Stars Organizer backup.`);if(typeof n.version==`number`&&n.version>1)throw new B("This backup was made by a newer version. Update with `npx github-stars-organizer@latest`.");let r=t.error.issues[0];throw new B(`This backup is damaged (${r.path.join(`.`)}: ${r.message}).`)}x({local:R.optional()});function H(e){return e.restar.length+e.recreateLists.length+e.addToLists.length}function U({repos:e,tags:t,repo_tags:n}){let r=new Map(e.map(e=>[e.id,e.github_id]));return{repos:e.filter(e=>e.notes||e.usefulness_rating!==null).map(e=>({githubId:e.github_id,notes:e.notes||null,usefulnessRating:e.usefulness_rating})),tags:t.map(({id:e,name:t,color:n})=>({id:e,name:t,color:n})),repoTags:n.flatMap(e=>{let t=r.get(e.repo_id);return t===void 0?[]:[{githubId:t,tagId:e.tag_id}]})}}function W(e,t,n){let r=new Map(t.repos.map(e=>[e.github_id,e])),i=e.repos.flatMap(e=>{let t=r.get(e.githubId);if(!t)return[];let n={id:t.id};return!t.notes&&e.notes&&(n.notes=e.notes),t.usefulness_rating===null&&e.usefulnessRating!==null&&(n.usefulness_rating=e.usefulnessRating),Object.keys(n).length>1?[n]:[]}),a=new Map(t.tags.map(e=>[e.name.toLowerCase(),e.id])),o=[],s=new Map;for(let t of e.tags){let e=a.get(t.name.toLowerCase());if(e){s.set(t.id,e);continue}let r={id:n(),name:t.name,color:t.color};o.push(r),a.set(r.name.toLowerCase(),r.id),s.set(t.id,r.id)}let c=new Set(t.repo_tags.map(e=>`${e.repo_id}:${e.tag_id}`));return{repos:i,tags:o,repo_tags:e.repoTags.flatMap(e=>{let t=r.get(e.githubId),i=s.get(e.tagId);if(!t||!i)return[];let a=`${t.id}:${i}`;return c.has(a)?[]:(c.add(a),[{id:n(),repo_id:t.id,tag_id:i}])})}}async function G(){return await Promise.all([a.preload(),i.preload(),e.preload()]),{repos:a.toArray,tags:i.toArray,repo_tags:e.toArray}}async function K(){return t.backUpNow({local:U(await G())})}async function q(e){let n=await t.readBackup(e.id),r=n.local?n:{...n,local:U(await G())},i=URL.createObjectURL(new Blob([JSON.stringify(r,null,2)],{type:`application/json`})),a=document.createElement(`a`);a.href=i,a.download=`stars-organizer-${n.login}-${e.id}.json`,a.click(),URL.revokeObjectURL(i)}async function J(e){let n;try{n=JSON.parse(await e.text())}catch{throw Error(`${e.name} isn't a JSON file.`)}return t.uploadBackup(V(n))}async function oe(t){let n=W(t,await G(),()=>crypto.randomUUID());return await o(()=>{for(let e of n.repos)a.update(e.id,t=>{Object.assign(t,e)});n.tags.length&&i.insert(n.tags),n.repo_tags.length&&e.insert(n.repo_tags)}),{notesAndRatings:n.repos.length,tags:n.tags.length,tagLinks:n.repo_tags.length}}async function se(e){let n=await t.applyRestore({backupId:e.id});await w();let{local:r}=await t.readBackup(e.id);return{...n,local:r?await oe(r):null}}var ce={launch:`On launch`,manual:`Backed up by hand`,"before-restore":`Before a restore`,uploaded:`From a file`},Y=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`});function X(e){return e instanceof Error?e.message:String(e)}function Z(e,t,n=`${t}s`){return`${e} ${e===1?t:n}`}function le(){return(0,D.jsx)(ue,{})}function ue(){let[e,n]=(0,E.useState)(null),[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(!1),[s,c]=(0,E.useState)(null),l=(0,E.useRef)(null);async function f(){n(await t.listBackups())}(0,E.useEffect)(()=>{f().catch(e=>i(`Couldn't read the backups: ${X(e)}`))},[]);async function p(e,t){o(!0),i(e);try{i(await t()),await f()}catch(e){i(X(e))}finally{o(!1)}}function m(){p(`Backing up...`,async()=>{let e=await K();return`Backed up ${Z(e.stars,`star`)} and ${Z(e.lists,`List`)}, with your tags, ratings and notes.`})}function h(e){e&&p(`Reading ${e.name}...`,async()=>(c(await J(e)),`Kept a copy of ${e.name}.`))}return(0,D.jsxs)(`div`,{className:`max-w-3xl space-y-6`,children:[(0,D.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`h1`,{className:`font-display text-2xl font-bold tracking-tight`,children:`Backups`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Each launch backs up your stars and Lists before the app can change anything. A restore only adds back what is missing: it never unstars a repo or deletes a List.`}),e&&(0,D.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Saved in `,(0,D.jsx)(`code`,{children:e.directory})]})]}),(0,D.jsx)(u,{onClick:m,disabled:a,children:`Back up now`})]}),r&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm`,children:r}),(0,D.jsxs)(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,children:[e?.backups.length===0&&(0,D.jsx)(`li`,{className:`p-4 text-sm text-muted-foreground`,children:`No backups yet.`}),e?.backups.map(e=>(0,D.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 p-3`,children:[(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(`p`,{className:`text-sm font-medium`,children:Y.format(new Date(e.createdAt))}),(0,D.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[ce[e.reason],` · `,Z(e.stars,`star`),` · `,Z(e.lists,`List`)]})]}),(0,D.jsxs)(u,{variant:`ghost`,size:`sm`,disabled:a,onClick:()=>void p(`Preparing the file...`,async()=>(await q(e),`Downloaded.`)),children:[(0,D.jsx)(d,{className:`mr-1.5 size-4`}),`Download`]}),(0,D.jsxs)(u,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>c(e),children:[(0,D.jsx)(ee,{className:`mr-1.5 size-4`}),`Restore...`]})]},e.id))]}),(0,D.jsxs)(`section`,{className:`space-y-2`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Restore from a file`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A backup you downloaded, from this computer or another. You see what it would change before anything does.`}),(0,D.jsx)(`input`,{ref:l,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{h(e.target.files?.[0]),e.target.value=``}}),(0,D.jsxs)(u,{variant:`outline`,size:`sm`,disabled:a,onClick:()=>l.current?.click(),children:[(0,D.jsx)(T,{className:`mr-1.5 size-4`}),`Choose a file`]})]}),s&&(0,D.jsx)(de,{backup:s,onClose:()=>c(null),onRestored:()=>void f()})]})}var Q=5;function $({names:e}){let t=e.length-Q;return(0,D.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[e.slice(0,Q).join(`, `),t>0&&`, and ${t} more`]})}function de({backup:e,onClose:n,onRestored:r}){let[i,a]=(0,E.useState)({step:`planning`});(0,E.useEffect)(()=>{Promise.all([t.planRestore({backupId:e.id}),t.readBackup(e.id)]).then(([e,t])=>a({step:`review`,plan:e,hasLocal:t.local!==void 0})).catch(e=>a({step:`failed`,message:X(e)}))},[e.id]);async function o(){a({step:`applying`});try{a({step:`done`,result:await se(e)}),r()}catch(e){a({step:`failed`,message:X(e)})}}return(0,D.jsx)(ie,{open:!0,onOpenChange:e=>{!e&&i.step!==`applying`&&n()},children:(0,D.jsxs)(k,{children:[(0,D.jsxs)(A,{children:[(0,D.jsxs)(M,{children:[`Restore the backup from `,Y.format(new Date(e.createdAt))]}),(0,D.jsx)(N,{children:`Only adds what GitHub is missing. Nothing you starred or made since is touched.`})]}),(0,D.jsx)(fe,{state:i}),(0,D.jsxs)(j,{children:[i.step===`review`&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(u,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,D.jsx)(u,{onClick:()=>void o(),disabled:H(i.plan)===0&&!i.hasLocal,children:`Restore`})]}),(i.step===`done`||i.step===`failed`)&&(0,D.jsx)(u,{onClick:n,children:`Close`})]})]})})}function fe({state:e}){switch(e.step){case`planning`:return(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Comparing the backup with GitHub...`});case`applying`:return(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Restoring. Leave this open until it finishes.`});case`failed`:return(0,D.jsx)(`p`,{className:`text-sm text-destructive`,children:e.message});case`review`:return(0,D.jsx)(pe,{plan:e.plan,hasLocal:e.hasLocal});case`done`:return(0,D.jsx)(he,{result:e.result})}}function pe({plan:e,hasLocal:t}){let n=new Set(e.addToLists.map(e=>e.repo.fullName));return H(e)===0?(0,D.jsxs)(`p`,{className:`text-sm`,children:[`GitHub already has every star and List in this backup.`,t&&` Restoring fills in any tags, ratings and notes this browser is missing.`]}):(0,D.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[e.restar.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{children:[`Star `,Z(e.restar.length,`repo`),` again. GitHub dates them today, so they move to the top.`]}),(0,D.jsx)($,{names:e.restar.map(e=>e.fullName)})]}),e.recreateLists.length>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{children:[`Recreate `,Z(e.recreateLists.length,`List`),`.`]}),(0,D.jsx)($,{names:e.recreateLists.map(e=>e.isPrivate?`${e.name} (private)`:e.name)})]}),n.size>0&&(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`p`,{children:[`Put `,Z(n.size,`repo`),` back in their Lists.`]}),(0,D.jsx)($,{names:[...n]})]}),t&&(0,D.jsx)(`p`,{children:`Fill in tags, ratings and notes this browser is missing. Nothing you have is overwritten.`}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A backup of how things are now is taken first, so you can go back.`})]})}function me(e){let t=[e.notesAndRatings>0&&`notes or ratings on ${Z(e.notesAndRatings,`repo`)}`,e.tagLinks>0&&Z(e.tagLinks,`tag`)].filter(e=>e!==!1);return t.length===0?`This browser already had every tag, rating and note.`:`Filled in ${t.join(` and `)}.`}function he({result:e}){return(0,D.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,D.jsxs)(`p`,{children:[`Starred `,Z(e.restarred,`repo`),` again, recreated `,Z(e.recreatedLists,`List`),`, and re-added`,` `,Z(e.addedToLists,`List entry`,`List entries`),`.`,e.local&&` ${me(e.local)}`]}),e.failed.length>0&&(0,D.jsxs)(`div`,{className:`rounded-md border border-destructive/40 p-2`,children:[(0,D.jsxs)(`p`,{className:`font-medium text-destructive`,children:[`GitHub refused `,Z(e.failed.length,`change`),`:`]}),(0,D.jsx)(`ul`,{className:`mt-1 space-y-0.5 text-xs`,children:e.failed.map(e=>(0,D.jsxs)(`li`,{children:[e.what,`: `,e.reason]},e.what))})]})]})}export{le as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e,a as t,m as n,n as r,r as i}from"./button-
|
|
1
|
+
import{R as e,a as t,m as n,n as r,r as i}from"./button-j3ddoMPG.js";var a=e(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]);function o(e){return t(e.defaultTagName??`div`,e,e)}var s=i(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function c({className:e,variant:t=`default`,render:i,...a}){return o({defaultTagName:`span`,props:n({className:r(s({variant:t}),e)},a),render:i,state:{slot:`badge`,variant:t}})}export{a as n,c as t};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/esm-hHQKpih6.js","assets/sync-persistence-f8LlQoHO.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{A as e,D as t,E as n,P as r,_ as i,b as a,f as o,g as s,h as c,j as l,m as u,n as d,r as f,v as p}from"./sync-persistence-f8LlQoHO.js";var m=Object.create,h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,b=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),x=(e,t)=>{let n={};for(var r in e)h(n,r,{get:e[r],enumerable:!0});return t||h(n,Symbol.toStringTag,{value:`Module`}),n},ee=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!y.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e},S=(e,t,n)=>(n=e==null?{}:m(v(e)),ee(t||!e||!e.__esModule?h(n,`default`,{value:e,enumerable:!0}):n,e)),C=b((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var ee=Array.isArray;function S(){}var C={H:null,A:null,T:null,S:null},w=Object.prototype.hasOwnProperty;function T(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function te(e,t){return T(e.type,t,e.props)}function E(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function D(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ne=/\/+/g;function O(e,t){return typeof e==`object`&&e&&e.key!=null?D(``+e.key):t.toString(36)}function k(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(S,S):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function A(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,A(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+O(e,0):a,ee(o)?(i=``,c!=null&&(i=c.replace(ne,`$&/`)+`/`),A(o,r,i,``,function(e){return e})):o!=null&&(E(o)&&(o=te(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ne,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(ee(e))for(var u=0;u<e.length;u++)a=e[u],s=l+O(a,u),c+=A(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+O(a,u++),c+=A(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return A(k(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function j(e,t,n){if(e==null)return e;var r=[],i=0;return A(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function re(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var M=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},ie={map:j,forEach:function(e,t,n){j(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return j(e,function(){t++}),t},toArray:function(e){return j(e,function(e){return e})||[]},only:function(e){if(!E(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=ie,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=C,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return C.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!w.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return T(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)w.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return T(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=E,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:re}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=C.T,n={};C.T=n;try{var r=e(),i=C.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(S,M)}catch(e){M(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),C.T=t}},e.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},e.use=function(e){return C.H.use(e)},e.useActionState=function(e,t,n){return C.H.useActionState(e,t,n)},e.useCallback=function(e,t){return C.H.useCallback(e,t)},e.useContext=function(e){return C.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return C.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return C.H.useEffect(e,t)},e.useEffectEvent=function(e){return C.H.useEffectEvent(e)},e.useId=function(){return C.H.useId()},e.useImperativeHandle=function(e,t,n){return C.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return C.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return C.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return C.H.useMemo(e,t)},e.useOptimistic=function(e,t){return C.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return C.H.useReducer(e,t,n)},e.useRef=function(e){return C.H.useRef(e)},e.useState=function(e){return C.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return C.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return C.H.useTransition()},e.version=`19.2.5`})),w=b(((e,t)=>{t.exports=C()})),T=b((e=>{var t=w();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.5`})),te=b(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=T()})),E=b((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),D=b(((e,t)=>{t.exports=E()})),ne=b((e=>{var t=w();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),O=b(((e,t)=>{t.exports=ne()})),k=b((e=>{var t=w(),n=O();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),A=b(((e,t)=>{t.exports=k()}));function j(e){let{initialData:t,onInsert:n,onUpdate:i,onDelete:a,id:o,...s}=e,c=o??r(),l=new Set;n||l.add(`insert`),i||l.add(`update`),a||l.add(`delete`);let u=re(t,l),d=async e=>{let t;return n&&(t=await n(e)??{}),u.confirmOperationsSync(e.transaction.mutations),t},p=async e=>{let t;return i&&(t=await i(e)??{}),u.confirmOperationsSync(e.transaction.mutations),t},m=async e=>{let t;return a&&(t=await a(e)??{}),u.confirmOperationsSync(e.transaction.mutations),t},h=e=>{let t=e.mutations.filter(e=>e.collection.id===c);t.length!==0&&u.confirmOperationsSync(t)};return f({...s,id:c,sync:u.sync,onInsert:d,onUpdate:p,onDelete:m,utils:{acceptMutations:h},startSync:!0,gcTime:0},()=>j({...e,id:c}))}function re(e,t){let n=null,r=null,i=null,a=null,o={rowUpdateMode:`full`,sync:o=>{let{begin:c,write:l,commit:u,markReady:d}=o;if(n=c,r=l,i=u,a=o.collection,o.collection._state.isLocalOnly=!0,o.collection._state.localOnlyDirectWrite={types:t,write:s},e&&e.length>0){for(let t of e){let e=o.collection.getKeyFromItem(t);o.collection._state.pendingLocalChanges.add(e)}c(),e.forEach(e=>{l({type:`insert`,value:e})}),u()}return d(),()=>{}},getSyncMetadata:()=>({})},s=e=>{!n||!r||!i||(n(),e.forEach(e=>{r&&r({type:e.type,value:e.modified})}),i())};return{sync:o,confirmOperationsSync:s,collection:a}}var M=class{constructor(e){this.options=e,this.completed=new Set,this.ez=new Map,this.generation=0,this.loadSubset=e=>{let t=o(e);if(!e.refetch&&this.completed.has(t))return this.options.onDeduplicate?.(e),!0;let n=e.signal||e.refetch?void 0:this.ez.get(t);if(n)return n.then(()=>this.options.onDeduplicate?.(e)).catch(()=>{}),n;let r=this.generation,i=this.options.loadSubset(e);if(i===!0)return r===this.generation&&!e.signal?.aborted&&this.completed.add(t),!0;let a=i.then(n=>(r===this.generation&&!e.signal?.aborted&&this.completed.add(t),n)).finally(()=>{this.ez.get(t)===a&&this.ez.delete(t)});return!e.signal&&r===this.generation&&this.ez.set(t,a),a}}reset(){this.completed.clear(),this.ez.clear(),this.generation++}},ie=Object.defineProperty,ae=Object.defineProperties,oe=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,ce=e=>{throw TypeError(e)},F=(e,t,n)=>t in e?ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||={})N.call(t,n)&&F(e,n,t[n]);if(se)for(var n of se(t))P.call(t,n)&&F(e,n,t[n]);return e},L=(e,t)=>ae(e,oe(t)),le=(e,t)=>{var n={};for(var r in e)N.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&se)for(var r of se(e))t.indexOf(r)<0&&P.call(e,r)&&(n[r]=e[r]);return n},ue=(e,t,n)=>t.has(e)||ce(`Cannot `+n),R=(e,t,n)=>(ue(e,t,`read from private field`),n?n.call(e):t.get(e)),z=(e,t,n)=>t.has(e)?ce(`Cannot add the same private member more than once`):t instanceof WeakSet?t.add(e):t.set(e,n),B=(e,t,n,r)=>(ue(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),V=(e,t,n)=>(ue(e,t,`access private method`),n),de=(e,t,n,r)=>({set _(r){B(e,t,r,n)},get _(){return R(e,t,r)}}),H=class e extends Error{constructor(e,t,n,r,i,a){super(a||`HTTP Error ${e} at ${i}: ${t??JSON.stringify(n)}`),this.url=i,this.name=`FetchError`,this.status=e,this.text=t,this.json=n,this.headers=r}static async fromResponse(t,n){let r=t.status,i=Object.fromEntries([...t.headers.entries()]),a,o,s=t.headers.get(`content-type`);return t.bodyUsed||(s&&s.includes(`application/json`)?o=await t.json():a=await t.text()),new e(r,a,o,i,n)}},fe=class extends Error{constructor(){super(`Fetch with backoff aborted`),this.name=`FetchBackoffAbortError`}},pe=class extends Error{constructor(){super(`Invalid shape options: missing required url parameter`),this.name=`MissingShapeUrlError`}},me=class extends Error{constructor(){super(`Invalid signal option. It must be an instance of AbortSignal.`),this.name=`InvalidSignalError`}},he=class extends Error{constructor(){super(`shapeHandle is required if this isn't an initial fetch (i.e. offset > -1)`),this.name=`MissingShapeHandleError`}},ge=class extends Error{constructor(e){super(`Cannot use reserved Electric parameter names in custom params: ${e.join(`, `)}`),this.name=`ReservedParamError`}},_e=class extends Error{constructor(e){super(`Column "${e??`unknown`}" does not allow NULL values`),this.name=`ParserNullValueError`}},ve=class extends Error{constructor(e,t){let n=`The response for the shape request to ${e} didn't include the following required headers:
|
|
3
|
+
`;t.forEach(e=>{n+=`- ${e}
|
|
4
|
+
`}),n+=`
|
|
5
|
+
This is often due to a proxy not setting CORS correctly so that all Electric headers can be read by the client.`,n+=`
|
|
6
|
+
For more information visit the troubleshooting guide: /docs/guides/troubleshooting/missing-headers`,super(n)}},ye=class extends Error{constructor(e){super(e),this.name=`StaleCacheError`}},be=e=>Number(e),xe=e=>e===`true`||e===`t`,Se=e=>BigInt(e),Ce=e=>JSON.parse(e),U=e=>e,we={int2:be,int4:be,int8:Se,bool:xe,float4:be,float8:be,json:Ce,jsonb:Ce};function Te(e,t){let n=0,r=null,i=``,a=!1,o=0,s;function c(e,n,r){let i=e.slice(n,r);return i=i===`NULL`?null:i,t?t(i):i}function l(e){let u=[];for(;n<e.length;n++){if(r=e[n],a)r===`\\`?i+=e[++n]:r===`"`?(u.push(t?t(i):i),i=``,a=e[n+1]===`"`,o=n+2):i+=r;else if(r===`"`)a=!0;else if(r===`{`)o=++n,u.push(l(e));else if(r===`}`){a=!1,o<n&&u.push(c(e,o,n)),o=n+1;break}else r===`,`&&s!==`}`&&s!==`"`&&(u.push(c(e,o,n)),o=n+1);s=r}return o<n&&u.push(u.push(c(e,o,n+1))),u}return l(e)[0]}var Ee=class{constructor(e,t){this.parser=I(I({},we),e),this.transformer=t}parse(e,t){return JSON.parse(e,(e,n)=>(e===`value`||e===`old_value`)&&typeof n==`object`&&n?this.transformMessageValue(n,t):n)}parseSnapshotData(e,t){return e.map(e=>{let n=e;return n.value&&typeof n.value==`object`&&n.value!==null&&(n.value=this.transformMessageValue(n.value,t)),n.old_value&&typeof n.old_value==`object`&&n.old_value!==null&&(n.old_value=this.transformMessageValue(n.old_value,t)),n})}transformMessageValue(e,t){let n=e;return Object.keys(n).forEach(e=>{n[e]=this.parseRow(e,n[e],t)}),this.transformer?this.transformer(n):n}parseRow(e,t,n){let r=n[e];if(!r)return t;let i=r,{type:a,dims:o}=i,s=le(i,[`type`,`dims`]),c=De(this.parser[a]??U,r,e);return o&&o>0?De((e,t)=>Te(e,c),r,e)(t):c(t,s)}};function De(e,t,n){let r=!(t.not_null??!1);return i=>{if(i===null){if(!r)throw new _e(n??`unknown`);return null}return e(i,t)}}function Oe(e){return`"${e.replace(/"/g,`""`)}"`}function ke(e,t){if(!e||!t)return e??``;let n=new Set(`SELECT.FROM.WHERE.AND.OR.NOT.IN.IS.NULL.NULLS.FIRST.LAST.TRUE.FALSE.LIKE.ILIKE.BETWEEN.ASC.DESC.LIMIT.OFFSET.ORDER.BY.GROUP.HAVING.DISTINCT.AS.ON.JOIN.LEFT.RIGHT.INNER.OUTER.CROSS.CASE.WHEN.THEN.ELSE.END.CAST.LOWER.UPPER.COALESCE.NULLIF`.split(`.`)),r=[],i=0;for(;i<e.length;){let t=e[i];if(t===`'`||t===`"`){let n=i,a=t;for(i++;i<e.length;)if(e[i]===a)if(e[i+1]===a)i+=2;else{i++;break}else i++;r.push({start:n,end:i})}else i++}let a=e=>r.some(t=>e>=t.start&&e<t.end),o=RegExp(`(?<![a-zA-Z0-9_])([a-zA-Z_][a-zA-Z0-9_]*)(?![a-zA-Z0-9_])`,`g`);return e.replace(o,(e,r,i)=>a(i)||n.has(e.toUpperCase())||e.startsWith(`$`)?e:t(e))}function Ae(e){return e!=null&&`key`in e}function je(e){return e!=null&&`headers`in e&&`control`in e.headers}function Me(e){return je(e)&&e.headers.control===`up-to-date`}function W(e){if(e.headers.control!=`up-to-date`)return;let t=e.headers.global_last_seen_lsn;return t?`${t}_0`:void 0}function Ne(e,t){return typeof t==`bigint`?t.toString():t}function Pe(e){return JSON.stringify(e,Ne)}function Fe(e,t){let n=BigInt(e),r=BigInt(t.xmin),i=BigInt(t.xmax),a=t.xip_list.map(BigInt);return n<r||n<i&&!a.includes(n)}var Ie=`electric-cursor`,Le=`electric-handle`,Re=`electric-offset`,ze=`electric-schema`,Be=`electric-up-to-date`,Ve=`columns`,He=`cursor`,Ue=`expired_handle`,We=`handle`,Ge=`live`,Ke=`offset`,qe=`table`,Je=`where`,Ye=`replica`,Xe=`params`,Ze=`experimental_live_sse`,Qe=`live_sse`,$e=`force-disconnect-and-refresh`,et=`pause-stream`,tt=`system-wake`,nt=`log`,rt=`subset__where`,it=`subset__limit`,at=`subset__offset`,ot=`subset__order_by`,st=`subset__params`,ct=`subset__where_expr`,lt=`subset__order_by_expr`,ut=`cache-buster`,dt=[Ge,Qe,Ze,We,Ke,He,Ue,nt,rt,it,at,ot,st,ct,lt,ut],ft=[429],pt={initialDelay:1e3,maxDelay:32e3,multiplier:2,maxRetries:1/0};function mt(e){if(!e)return 0;let t=Number(e);if(Number.isFinite(t)&&t>0)return t*1e3;let n=Date.parse(e);if(!isNaN(n)){let e=n-Date.now();return Math.max(0,Math.min(e,36e5))}return 0}function ht(e,t=pt){let{initialDelay:n,maxDelay:r,multiplier:i,debug:a=!1,onFailedAttempt:o,maxRetries:s=1/0}=t;return async(...t)=>{let c=t[0],l=t[1],u=n,d=0;for(;;)try{let n=await e(...t);if(n.ok)return n;throw await H.fromResponse(n,c.toString())}catch(e){if(o?.(),l?.signal?.aborted)throw new fe;if(e instanceof H&&!ft.includes(e.status)&&e.status>=400&&e.status<500)throw e;{if(d++,d>s)throw a&&console.log(`Max retries reached (${d}/${s}), giving up`),e;let t=e instanceof H&&e.headers?mt(e.headers[`retry-after`]):0,n=Math.random()*u,o=Math.min(n,r),c=Math.max(t,o);a&&console.log(`Retry attempt #${d} after ${c}ms (${t>0?`server+client`:`client`}, serverMin=${t}ms, clientBackoff=${o}ms)`),await new Promise(e=>setTimeout(e,c)),u=Math.min(u*i,r)}}}}var gt=[201,204,205];function _t(e){return async(...t)=>{let n=t[0],r=await e(...t);try{if(r.status<200||gt.includes(r.status))return r;let e=await r.text();return new Response(e,r)}catch(e){throw t[1]?.signal?.aborted?new fe:new H(r.status,void 0,void 0,Object.fromEntries([...r.headers.entries()]),n.toString(),e instanceof Error?e.message:typeof e==`string`?e:`failed to read body`)}}}var vt={maxChunksToPrefetch:2};function yt(e,t=vt){let{maxChunksToPrefetch:n}=t,r;return async(...t)=>{let i=t[0].toString();if(Ft(t[0],t[1])!==`GET`)return r?.abort(),r=void 0,e(...t);let a=r?.consume(...t);if(a)return a;r?.abort(),r=void 0;let o=await e(...t),s=Mt(i,o);return s&&(r=new jt({fetchClient:e,maxPrefetchedRequests:n,url:s,requestInit:t[1]})),o}}var bt=[Re,Le],xt=[Ie],St=[ze];function Ct(e){return async(...t)=>{let n=await e(...t);if(n.ok){let e=n.headers,r=[],i=t=>r.push(...t.filter(t=>!e.has(t))),a=t[0].toString(),o=new URL(a);if([rt,st,it,at,ot].some(e=>o.searchParams.has(e)))return n;if(i(bt),o.searchParams.get(Ge)===`true`&&i(xt),(!o.searchParams.has(Ge)||o.searchParams.get(Ge)===`false`)&&i(St),r.length>0)throw new ve(a,r)}return n}}var wt,Tt,Et,Dt,Ot,kt,At,jt=class{constructor(e){z(this,kt),z(this,wt),z(this,Tt),z(this,Et,new Map),z(this,Dt),z(this,Ot),B(this,wt,e.fetchClient??((...e)=>fetch(...e))),B(this,Tt,e.maxPrefetchedRequests),B(this,Dt,e.url.toString()),B(this,Ot,R(this,Dt)),V(this,kt,At).call(this,e.url,e.requestInit)}abort(){R(this,Et).forEach(([e,t])=>t.abort()),R(this,Et).clear()}consume(...e){let t=e[0].toString(),n=R(this,Et).get(t);if(!n||t!==R(this,Dt))return;let[r,i]=n;if(i.signal.aborted){R(this,Et).delete(t);return}return R(this,Et).delete(t),r.then(n=>{let r=Mt(t,n);B(this,Dt,r),R(this,Ot)&&!R(this,Et).has(R(this,Ot))&&V(this,kt,At).call(this,R(this,Ot),e[1])}).catch(()=>{}),r}};wt=new WeakMap,Tt=new WeakMap,Et=new WeakMap,Dt=new WeakMap,Ot=new WeakMap,kt=new WeakSet,At=function(...e){let t=e[0].toString();if(R(this,Et).size>=R(this,Tt))return;let n=new AbortController;try{let{signal:r,cleanup:i}=Nt(n,e[1]?.signal),a=R(this,wt).call(this,t,L(I({},e[1]??{}),{signal:r}));R(this,Et).set(t,[a,n]),a.then(r=>{if(!r.ok||n.signal.aborted)return;let i=Mt(t,r);if(!i||i===t){B(this,Ot,void 0);return}return B(this,Ot,i),V(this,kt,At).call(this,i,e[1])}).catch(()=>{}).finally(i)}catch{}};function Mt(e,t){let n=t.headers.get(Le),r=t.headers.get(Re),i=t.headers.has(Be);if(!n||!r||i)return;let a=new URL(e);if(a.searchParams.has(Ge))return;let o=a.searchParams.get(Ue);if(o&&n===o){console.warn(`[Electric] Received stale cached response with expired shape handle. This should not happen and indicates a proxy/CDN caching misconfiguration. The response contained handle "${n}" which was previously marked as expired. Check that your proxy includes all query parameters (especially 'handle' and 'offset') in its cache key. Skipping prefetch to prevent infinite 409 loop.`);return}return a.searchParams.set(We,n),a.searchParams.set(Ke,r),a.searchParams.sort(),a.toString()}function Nt(e,t){let n=Pt;if(t)if(t.aborted)e.abort();else{let r=()=>e.abort();t.addEventListener(`abort`,r,{once:!0,signal:e.signal}),n=()=>t.removeEventListener(`abort`,r)}return{signal:e.signal,cleanup:n}}function Pt(){}function Ft(e,t){return t?.method?t.method.toUpperCase():typeof Request<`u`&&e instanceof Request?e.method.toUpperCase():`GET`}function It(e,t){switch(e.type){case`ref`:return Oe(t?t(e.column):e.column);case`val`:return`$${e.paramIndex}`;case`func`:return Lt(e,t);default:throw Error(`Unknown expression type: ${JSON.stringify(e)}`)}}function Lt(e,t){let n=e.args.map(e=>It(e,t));switch(e.name){case`eq`:return`${n[0]} = ${n[1]}`;case`gt`:return`${n[0]} > ${n[1]}`;case`gte`:return`${n[0]} >= ${n[1]}`;case`lt`:return`${n[0]} < ${n[1]}`;case`lte`:return`${n[0]} <= ${n[1]}`;case`and`:return n.map(e=>`(${e})`).join(` AND `);case`or`:return n.map(e=>`(${e})`).join(` OR `);case`not`:return`NOT (${n[0]})`;case`in`:return`${n[0]} = ANY(${n[1]})`;case`like`:return`${n[0]} LIKE ${n[1]}`;case`ilike`:return`${n[0]} ILIKE ${n[1]}`;case`isNull`:case`isUndefined`:return`${n[0]} IS NULL`;case`upper`:return`UPPER(${n[0]})`;case`lower`:return`LOWER(${n[0]})`;case`length`:return`LENGTH(${n[0]})`;case`concat`:return`CONCAT(${n.join(`, `)})`;case`coalesce`:return`COALESCE(${n.join(`, `)})`;default:throw Error(`Unknown function: ${e.name}`)}}function Rt(e,t){return e.map(e=>{let n=Oe(t?t(e.column):e.column);return e.direction===`desc`&&(n+=` DESC`),e.nulls===`first`&&(n+=` NULLS FIRST`),e.nulls===`last`&&(n+=` NULLS LAST`),n}).join(`, `)}async function zt(e,t){let n=e.getReader(),r;for(;!(r=await n.read()).done;)t(r.value)}function Bt(e){let t,n,r,i=!1;return function(a){t===void 0?(t=a,n=0,r=-1):t=Ht(t,a);let o=t.length,s=0;for(;n<o;){i&&=(t[n]===10&&(s=++n),!1);let a=-1;for(;n<o&&a===-1;++n)switch(t[n]){case 58:r===-1&&(r=n-s);break;case 13:i=!0;case 10:a=n;break}if(a===-1)break;e(t.subarray(s,a),r),s=n,r=-1}s===o?t=void 0:s!==0&&(t=t.subarray(s),n-=s)}}function Vt(e,t,n){let r=Ut(),i=new TextDecoder;return function(a,o){if(a.length===0)n?.(r),r=Ut();else if(o>0){let n=i.decode(a.subarray(0,o)),s=o+(a[o+1]===32?2:1),c=i.decode(a.subarray(s));switch(n){case`data`:r.data=r.data?r.data+`
|
|
7
|
+
`+c:c;break;case`event`:r.event=c;break;case`id`:e(r.id=c);break;case`retry`:let n=parseInt(c,10);isNaN(n)||t(r.retry=n);break}}}}function Ht(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function Ut(){return{data:``,event:``,id:``,retry:void 0}}var Wt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},Gt=`text/event-stream`,Kt=1e3,qt=`last-event-id`;function Jt(e,t){var{signal:n,headers:r,onopen:i,onmessage:a,onclose:o,onerror:s,openWhenHidden:c,fetch:l}=t,u=Wt(t,[`signal`,`headers`,`onopen`,`onmessage`,`onclose`,`onerror`,`openWhenHidden`,`fetch`]);return new Promise((t,d)=>{let f=Object.assign({},r);f.accept||=Gt;let p;function m(){p.abort(),typeof document<`u`&&!document.hidden&&b()}typeof document<`u`&&!c&&document.addEventListener(`visibilitychange`,m);let h=Kt,g=0;function _(){typeof document<`u`&&document.removeEventListener(`visibilitychange`,m),clearTimeout(g),p.abort()}n?.addEventListener(`abort`,()=>{_()});let v=l??window.fetch,y=i??Yt;async function b(){p=new AbortController;let r=n.aborted?n:p.signal;try{let n=await v(e,Object.assign(Object.assign({},u),{headers:f,signal:r}));await y(n),await zt(n.body,Bt(Vt(e=>{e?f[qt]=e:delete f[qt]},e=>{h=e},a))),o?.(),_(),t()}catch(e){if(r.aborted)_(),d(e);else if(!p.signal.aborted)try{let t=s?.(e)??h;clearTimeout(g),g=setTimeout(b,t)}catch(e){_(),d(e)}}}b()})}function Yt(e){let t=e.headers.get(`content-type`);if(!t?.startsWith(Gt))throw Error(`Expected content-type to be ${Gt}, Actual: ${t}`)}var Xt=new class{constructor(){this.data={},this.max=250,this.storageKey=`electric_expired_shapes`,this.load()}getExpiredHandle(e){let t=this.data[e];return t?(t.lastUsed=Date.now(),this.save(),t.expiredHandle):null}markExpired(e,t){this.data[e]={expiredHandle:t,lastUsed:Date.now()};let n=Object.keys(this.data);if(n.length>this.max){let e=n.reduce((e,t)=>this.data[t].lastUsed<this.data[e].lastUsed?t:e);delete this.data[e]}this.save()}save(){if(!(typeof localStorage>`u`))try{localStorage.setItem(this.storageKey,JSON.stringify(this.data))}catch{}}load(){if(!(typeof localStorage>`u`))try{let e=localStorage.getItem(this.storageKey);e&&(this.data=JSON.parse(e))}catch{this.data={}}}clear(){this.data={},this.save()}delete(e){delete this.data[e],this.save()}},Zt=new class{constructor(){this.data={},this.storageKey=`electric_up_to_date_tracker`,this.cacheTTL=6e4,this.maxEntries=250,this.writeThrottleMs=6e4,this.lastWriteTime=0,this.load(),this.cleanup()}recordUpToDate(e,t){this.data[e]={timestamp:Date.now(),cursor:t};let n=Object.keys(this.data);if(n.length>this.maxEntries){let e=n.reduce((e,t)=>this.data[t].timestamp<this.data[e].timestamp?t:e);delete this.data[e]}this.scheduleSave()}scheduleSave(){let e=Date.now(),t=e-this.lastWriteTime;if(t>=this.writeThrottleMs)this.lastWriteTime=e,this.save();else if(!this.pendingSaveTimer){let e=this.writeThrottleMs-t;this.pendingSaveTimer=setTimeout(()=>{this.lastWriteTime=Date.now(),this.pendingSaveTimer=void 0,this.save()},e)}}shouldEnterReplayMode(e){let t=this.data[e];return!t||Date.now()-t.timestamp>=this.cacheTTL?null:t.cursor}cleanup(){let e=Date.now(),t=Object.keys(this.data),n=!1;for(let r of t)e-this.data[r].timestamp>this.cacheTTL&&(delete this.data[r],n=!0);n&&this.save()}save(){if(!(typeof localStorage>`u`))try{localStorage.setItem(this.storageKey,JSON.stringify(this.data))}catch{}}load(){if(!(typeof localStorage>`u`))try{let e=localStorage.getItem(this.storageKey);e&&(this.data=JSON.parse(e))}catch{this.data={}}}clear(){this.data={},this.pendingSaveTimer&&=(clearTimeout(this.pendingSaveTimer),void 0),this.save()}delete(e){delete this.data[e],this.save()}},Qt,$t,en,tn,nn=class{constructor(){z(this,Qt),this.activeSnapshots=new Map,this.xmaxSnapshots=new Map,this.snapshotsByDatabaseLsn=new Map}addSnapshot(e,t){V(this,Qt,$t).call(this,e.snapshot_mark);let n=BigInt(e.xmax),r=BigInt(e.database_lsn);this.activeSnapshots.set(e.snapshot_mark,{xmin:BigInt(e.xmin),xmax:n,xip_list:e.xip_list.map(BigInt),keys:t,databaseLsn:r}),V(this,Qt,en).call(this,this.xmaxSnapshots,n,e.snapshot_mark),V(this,Qt,en).call(this,this.snapshotsByDatabaseLsn,r,e.snapshot_mark)}removeSnapshot(e){V(this,Qt,$t).call(this,e),this.activeSnapshots.delete(e)}shouldRejectMessage(e){let t=e.headers.txids||[];if(t.length===0)return!1;let n=Math.max(...t);for(let[e,t]of this.xmaxSnapshots.entries())if(n>=e)for(let e of t)this.removeSnapshot(e);return[...this.activeSnapshots.values()].some(t=>t.keys.has(e.key)&&Fe(n,t))}lastSeenUpdate(e){for(let[t,n]of this.snapshotsByDatabaseLsn.entries())if(t<=e)for(let e of n)this.removeSnapshot(e)}};Qt=new WeakSet,$t=function(e){let t=this.activeSnapshots.get(e);t&&(V(this,Qt,tn).call(this,this.xmaxSnapshots,t.xmax,e),V(this,Qt,tn).call(this,this.snapshotsByDatabaseLsn,t.databaseLsn,e))},en=function(e,t,n){let r=e.get(t);r?r.add(n):e.set(t,new Set([n]))},tn=function(e,t,n){let r=e.get(t);r&&(r.delete(n),r.size===0&&e.delete(t))};var rn=class{get isUpToDate(){return!1}get staleCacheBuster(){}get staleCacheRetryCount(){return 0}get sseFallbackToLongPolling(){return!1}get consecutiveShortSseConnections(){return 0}get replayCursor(){}canEnterReplayMode(){return!1}enterReplayMode(e){return this}shouldUseSse(e){return!1}handleSseConnectionClosed(e){return{state:this,fellBackToLongPolling:!1,wasShortConnection:!1}}applyUrlParams(e,t){}handleResponseMetadata(e){return{action:`ignored`,state:this}}handleMessageBatch(e){return{state:this,suppressBatch:!1,becameUpToDate:!1}}pause(){return new bn(this)}toErrorState(e){return new xn(this,e)}markMustRefetch(e){return new sn({handle:e,offset:`-1`,liveCacheBuster:``,lastSyncedAt:this.lastSyncedAt,schema:void 0})}},G,an=class extends rn{constructor(e){super(),z(this,G),B(this,G,e)}get handle(){return R(this,G).handle}get offset(){return R(this,G).offset}get schema(){return R(this,G).schema}get liveCacheBuster(){return R(this,G).liveCacheBuster}get lastSyncedAt(){return R(this,G).lastSyncedAt}get currentFields(){return R(this,G)}applyUrlParams(e,t){e.searchParams.set(Ke,R(this,G).offset),R(this,G).handle&&e.searchParams.set(We,R(this,G).handle)}parseResponseFields(e){let t=e.responseHandle,n=t&&t!==e.expiredHandle?t:R(this,G).handle,r=e.responseOffset??R(this,G).offset,i=e.responseCursor??R(this,G).liveCacheBuster;return{handle:n,offset:r,schema:R(this,G).schema??e.responseSchema,liveCacheBuster:i,lastSyncedAt:e.status===204?e.now:R(this,G).lastSyncedAt}}checkStaleResponse(e){let t=e.responseHandle,n=e.expiredHandle;if(!t||t!==n)return null;let r=this.staleCacheRetryCount+1;return{action:`stale-retry`,state:new fn(L(I({},this.currentFields),{staleCacheBuster:e.createCacheBuster(),staleCacheRetryCount:r})),exceededMaxRetries:r>e.maxStaleCacheRetries}}handleMessageBatch(e){if(!e.hasMessages||!e.hasUpToDateMessage)return{state:this,suppressBatch:!1,becameUpToDate:!1};let t=R(this,G).offset;e.isSse&&e.upToDateOffset&&(t=e.upToDateOffset);let n={handle:R(this,G).handle,offset:t,schema:R(this,G).schema,liveCacheBuster:R(this,G).liveCacheBuster,lastSyncedAt:e.now};return this.onUpToDate(n,e)}onUpToDate(e,t){return{state:new gn(e),suppressBatch:!1,becameUpToDate:!0}}};G=new WeakMap;var on=class extends an{handleResponseMetadata(e){let t=this.checkStaleResponse(e);if(t)return t;let n=this.parseResponseFields(e);return e.status===204?{action:`accepted`,state:new gn(n,{sseFallbackToLongPolling:!0})}:{action:`accepted`,state:new cn(n)}}canEnterReplayMode(){return!0}enterReplayMode(e){return new yn(L(I({},this.currentFields),{replayCursor:e}))}},sn=class e extends on{constructor(e){super(e),this.kind=`initial`}withHandle(t){return new e(L(I({},this.currentFields),{handle:t}))}},cn=class e extends on{constructor(e){super(e),this.kind=`syncing`}withHandle(t){return new e(L(I({},this.currentFields),{handle:t}))}},ln,un,dn=class e extends on{constructor(e){let t=e,{staleCacheBuster:n,staleCacheRetryCount:r}=t,i=le(t,[`staleCacheBuster`,`staleCacheRetryCount`]);super(i),this.kind=`stale-retry`,z(this,ln),z(this,un),B(this,ln,n),B(this,un,r)}get staleCacheBuster(){return R(this,ln)}get staleCacheRetryCount(){return R(this,un)}canEnterReplayMode(){return!1}withHandle(t){return new e(L(I({},this.currentFields),{handle:t,staleCacheBuster:R(this,ln),staleCacheRetryCount:R(this,un)}))}applyUrlParams(e,t){super.applyUrlParams(e,t),e.searchParams.set(ut,R(this,ln))}};ln=new WeakMap,un=new WeakMap;var fn=dn,pn,mn,hn=class e extends an{constructor(e,t){super(e),this.kind=`live`,z(this,pn),z(this,mn),B(this,pn,t?.consecutiveShortSseConnections??0),B(this,mn,t?.sseFallbackToLongPolling??!1)}get isUpToDate(){return!0}get consecutiveShortSseConnections(){return R(this,pn)}get sseFallbackToLongPolling(){return R(this,mn)}withHandle(t){return new e(L(I({},this.currentFields),{handle:t}),this.sseState)}applyUrlParams(e,t){super.applyUrlParams(e,t),t.isSnapshotRequest||(e.searchParams.set(He,this.liveCacheBuster),t.canLongPoll&&e.searchParams.set(Ge,`true`))}get sseState(){return{consecutiveShortSseConnections:R(this,pn),sseFallbackToLongPolling:R(this,mn)}}handleResponseMetadata(t){return this.checkStaleResponse(t)||{action:`accepted`,state:new e(this.parseResponseFields(t),this.sseState)}}onUpToDate(t,n){return{state:new e(t,this.sseState),suppressBatch:!1,becameUpToDate:!0}}shouldUseSse(e){return e.liveSseEnabled&&!e.isRefreshing&&!e.resumingFromPause&&!R(this,mn)}handleSseConnectionClosed(t){let n=R(this,pn),r=R(this,mn),i=!1,a=!1;return t.connectionDuration<t.minConnectionDuration&&!t.wasAborted?(a=!0,n+=1,n>=t.maxShortConnections&&(r=!0,i=!0)):t.connectionDuration>=t.minConnectionDuration&&(n=0),{state:new e(this.currentFields,{consecutiveShortSseConnections:n,sseFallbackToLongPolling:r}),fellBackToLongPolling:i,wasShortConnection:a}}};pn=new WeakMap,mn=new WeakMap;var gn=hn,_n,vn=class e extends an{constructor(e){let t=e,{replayCursor:n}=t,r=le(t,[`replayCursor`]);super(r),this.kind=`replaying`,z(this,_n),B(this,_n,n)}get replayCursor(){return R(this,_n)}withHandle(t){return new e(L(I({},this.currentFields),{handle:t,replayCursor:R(this,_n)}))}handleResponseMetadata(t){return this.checkStaleResponse(t)||{action:`accepted`,state:new e(L(I({},this.parseResponseFields(t)),{replayCursor:R(this,_n)}))}}onUpToDate(e,t){let n=!t.isSse&&R(this,_n)===t.currentCursor;return{state:new gn(e),suppressBatch:n,becameUpToDate:!0}}};_n=new WeakMap;var yn=vn,bn=class e extends rn{constructor(t){super(),this.kind=`paused`,this.previousState=t instanceof e?t.previousState:t}get handle(){return this.previousState.handle}get offset(){return this.previousState.offset}get schema(){return this.previousState.schema}get liveCacheBuster(){return this.previousState.liveCacheBuster}get lastSyncedAt(){return this.previousState.lastSyncedAt}get isUpToDate(){return this.previousState.isUpToDate}get staleCacheBuster(){return this.previousState.staleCacheBuster}get staleCacheRetryCount(){return this.previousState.staleCacheRetryCount}get sseFallbackToLongPolling(){return this.previousState.sseFallbackToLongPolling}get consecutiveShortSseConnections(){return this.previousState.consecutiveShortSseConnections}get replayCursor(){return this.previousState.replayCursor}handleResponseMetadata(t){let n=this.previousState.handleResponseMetadata(t);if(n.action===`accepted`)return{action:`accepted`,state:new e(n.state)};if(n.action===`ignored`)return{action:`ignored`,state:this};if(n.action===`stale-retry`)return{action:`stale-retry`,state:new e(n.state),exceededMaxRetries:n.exceededMaxRetries};throw Error(`PausedState.handleResponseMetadata: unhandled transition action "${n.action}"`)}withHandle(t){return new e(this.previousState.withHandle(t))}applyUrlParams(e,t){this.previousState.applyUrlParams(e,t)}pause(){return this}resume(){return this.previousState}},xn=class e extends rn{constructor(t,n){super(),this.kind=`error`,this.previousState=t instanceof e?t.previousState:t,this.error=n}get handle(){return this.previousState.handle}get offset(){return this.previousState.offset}get schema(){return this.previousState.schema}get liveCacheBuster(){return this.previousState.liveCacheBuster}get lastSyncedAt(){return this.previousState.lastSyncedAt}get isUpToDate(){return this.previousState.isUpToDate}get staleCacheBuster(){return this.previousState.staleCacheBuster}get staleCacheRetryCount(){return this.previousState.staleCacheRetryCount}get sseFallbackToLongPolling(){return this.previousState.sseFallbackToLongPolling}get consecutiveShortSseConnections(){return this.previousState.consecutiveShortSseConnections}get replayCursor(){return this.previousState.replayCursor}withHandle(t){return new e(this.previousState.withHandle(t),this.error)}applyUrlParams(e,t){this.previousState.applyUrlParams(e,t)}retry(){return this.previousState}reset(e){return this.previousState.markMustRefetch(e)}};function Sn(e){return new sn({handle:e.handle,offset:e.offset,liveCacheBuster:``,lastSyncedAt:void 0,schema:void 0})}var Cn,wn,Tn,En=class{constructor(e){z(this,Cn,new Set),z(this,wn),z(this,Tn),B(this,wn,e.onAcquired),B(this,Tn,e.onReleased)}acquire(e){if(R(this,Cn).has(e)){console.warn(`[Electric] PauseLock: "${e}" already held \u2014 ignoring duplicate acquire`);return}let t=R(this,Cn).size===0;R(this,Cn).add(e),t&&R(this,wn).call(this)}release(e){if(!R(this,Cn).delete(e)){console.warn(`[Electric] PauseLock: "${e}" not held \u2014 ignoring release (possible acquire/release mismatch)`);return}R(this,Cn).size===0&&R(this,Tn).call(this)}get isPaused(){return R(this,Cn).size>0}isHeldBy(e){return R(this,Cn).has(e)}releaseAllMatching(e){for(let t of R(this,Cn))t.startsWith(e)&&R(this,Cn).delete(t)}};Cn=new WeakMap,wn=new WeakMap,Tn=new WeakMap;var Dn=new Set([He,We,Ge,Ke,ut]),On=`https://electric-sql.com/docs/guides/troubleshooting`;function kn(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}async function An(e){return typeof e==`function`?e():e}async function jn(e){let t=Object.entries(e),n=await Promise.all(t.map(async([e,t])=>{if(t===void 0)return[e,void 0];let n=await An(t);return[e,Array.isArray(n)?n.join(`,`):n]}));return Object.fromEntries(n.filter(([e,t])=>t!==void 0))}async function Mn(e){if(!e)return{};let t=Object.entries(e),n=await Promise.all(t.map(async([e,t])=>[e,await An(t)]));return Object.fromEntries(n)}function Nn(e){let t=new URL(e.origin+e.pathname);for(let[n,r]of e.searchParams)dt.includes(n)||t.searchParams.append(n,r);return t.searchParams.sort(),t.toString()}var Pn,Fn,In,Ln,Rn,zn,K,Bn,Vn,Hn,Un,Wn,Gn,q,Kn,qn,Jn,Yn,Xn,Zn,Qn,$n,er,tr,nr,rr,ir,ar,or,sr,cr,lr,ur,dr,fr,pr,mr,hr,gr,_r,vr,yr,br,xr,Sr,Cr,wr,Tr,Er,Dr,Or,kr,Ar,jr,Mr,Nr,Pr,Fr,Ir,Lr,Rr,zr,Br,Vr=class{constructor(e){z(this,q),z(this,Pn,null),z(this,Fn),z(this,In),z(this,Ln),z(this,Rn,new Map),z(this,zn,!1),z(this,K),z(this,Bn,!1),z(this,Vn),z(this,Hn),z(this,Un),z(this,Wn,0),z(this,Gn,0),z(this,qn),z(this,Jn),z(this,Yn),z(this,Xn,Promise.resolve([])),z(this,Zn,new nn),z(this,Qn),z(this,$n),z(this,er),z(this,tr,1e3),z(this,nr,3),z(this,rr,100),z(this,ir,5e3),z(this,ar),z(this,or),z(this,sr,3),z(this,cr,[]),z(this,lr,500),z(this,ur,5),z(this,dr,100),z(this,fr,5e3),z(this,pr,0),z(this,mr,5),z(this,hr),z(this,gr,5),z(this,_r,null),z(this,vr,null),z(this,yr,0),z(this,br,50),this.options=I({subscribe:!0},e),Wr(this.options),B(this,K,Sn({offset:this.options.offset??`-1`,handle:this.options.handle})),B(this,Qn,new En({onAcquired:()=>{var e;B(this,K,R(this,K).pause()),R(this,zn)&&((e=R(this,Un))==null||e.abort(et))},onReleased:()=>{R(this,zn)&&(this.options.signal?.aborted||V(this,q,xr).call(this).catch(()=>{}))}}));let t;if(e.columnMapper){let n=t=>{let n={};for(let[r,i]of Object.entries(t)){let t=e.columnMapper.decode(r);n[t]=i}return n};t=e.transformer?t=>e.transformer(n(t)):n}else t=e.transformer;B(this,Ln,new Ee(e.parser,t)),B(this,Hn,this.options.onError),B(this,Vn,this.options.log??`full`);let n=ht(e.fetchClient??((...e)=>fetch(...e)),L(I({},e.backoffOptions??pt),{onFailedAttempt:()=>{var t,n;B(this,Bn,!1),(n=(t=e.backoffOptions)?.onFailedAttempt)==null||n.call(t)}}));B(this,In,Ct(yt(n))),B(this,Fn,_t(R(this,In))),V(this,q,Ir).call(this)}get shapeHandle(){return R(this,K).handle}get error(){return R(this,Pn)}get isUpToDate(){return R(this,K).isUpToDate}get lastOffset(){return R(this,K).offset}get mode(){return R(this,Vn)}subscribe(e,t=()=>{}){let n={};return R(this,Rn).set(n,[e,t]),R(this,zn)||V(this,q,xr).call(this),()=>{R(this,Rn).delete(n)}}unsubscribeAll(){var e,t;R(this,Rn).clear(),(e=R(this,ar))==null||e.call(this),(t=R(this,or))==null||t.call(this)}lastSyncedAt(){return R(this,K).lastSyncedAt}lastSynced(){return R(this,K).lastSyncedAt===void 0?1/0:Date.now()-R(this,K).lastSyncedAt}isConnected(){return R(this,Bn)}isLoading(){return!R(this,K).isUpToDate}hasStarted(){return R(this,zn)}isPaused(){return R(this,Qn).isPaused}async forceDisconnectAndRefresh(){var e;de(this,Wn)._++;try{R(this,K).isUpToDate&&!R(this,Un)?.signal.aborted&&((e=R(this,Un))==null||e.abort($e)),await V(this,q,Mr).call(this)}finally{de(this,Wn)._--}}async requestSnapshot(e){if(R(this,Vn)===`full`)throw Error(`Snapshot requests are not supported in ${R(this,Vn)} mode, as the consumer is guaranteed to observe all data`);R(this,zn)||V(this,q,xr).call(this).catch(()=>{});let t=`snapshot-${++de(this,Gn)._}`;R(this,Qn).acquire(t);let n=setTimeout(()=>{console.warn(`[Electric] Snapshot "${t}" has held the pause lock for 30s \u2014 possible hung request or leaked lock. Current holders: ${[...new Set([t])].join(`, `)}`,Error(`stack trace`))},3e4);try{let{metadata:t,data:n,responseOffset:r,responseHandle:i}=await this.fetchSnapshot(e),a=n.concat([{headers:I({control:`snapshot-end`},t)},{headers:I({control:`subset-end`},e)}]);if(R(this,Zn).addSnapshot(t,new Set(n.map(e=>e.key))),V(this,q,Or).call(this,a,!1),r!==null||i!==null){let e=R(this,K).handleResponseMetadata({status:200,responseHandle:i,responseOffset:r,responseCursor:null,expiredHandle:null,now:Date.now(),maxStaleCacheRetries:R(this,sr),createCacheBuster:kn});e.action===`accepted`?B(this,K,e.state):console.warn(`[Electric] Snapshot response metadata was not accepted by state "${R(this,K).kind}" (action: ${e.action}). Stream offset was not advanced from snapshot.`,Error(`stack trace`))}return{metadata:t,data:n}}finally{clearTimeout(n),R(this,Qn).release(t)}}async fetchSnapshot(e){return V(this,q,zr).call(this,e,0)}};Pn=new WeakMap,Fn=new WeakMap,In=new WeakMap,Ln=new WeakMap,Rn=new WeakMap,zn=new WeakMap,K=new WeakMap,Bn=new WeakMap,Vn=new WeakMap,Hn=new WeakMap,Un=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,q=new WeakSet,Kn=function(){return R(this,Wn)>0},qn=new WeakMap,Jn=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,$n=new WeakMap,er=new WeakMap,tr=new WeakMap,nr=new WeakMap,rr=new WeakMap,ir=new WeakMap,ar=new WeakMap,or=new WeakMap,sr=new WeakMap,cr=new WeakMap,lr=new WeakMap,ur=new WeakMap,dr=new WeakMap,fr=new WeakMap,pr=new WeakMap,mr=new WeakMap,hr=new WeakMap,gr=new WeakMap,_r=new WeakMap,vr=new WeakMap,yr=new WeakMap,br=new WeakMap,xr=async function(){B(this,zn,!0),V(this,q,Lr).call(this);try{await V(this,q,Cr).call(this)}catch(e){if(B(this,Pn,e),e instanceof Error&&B(this,K,R(this,K).toErrorState(e)),R(this,Hn)){let t=await R(this,Hn).call(this,e),n=!(e instanceof ve);if(t&&typeof t==`object`&&n){if(t.params&&(this.options.params=I(I({},this.options.params??{}),t.params)),t.headers&&(this.options.headers=I(I({},this.options.headers??{}),t.headers)),de(this,yr)._++,R(this,yr)>R(this,br)){console.warn(`[Electric] onError retry loop exhausted after ${R(this,br)} consecutive retries. The error was never resolved by the onError handler. Error: ${e instanceof Error?e.message:String(e)}`,Error(`stack trace`)),e instanceof Error&&V(this,q,Pr).call(this,e),V(this,q,Sr).call(this);return}return B(this,Pn,null),R(this,K)instanceof xn&&B(this,K,R(this,K).retry()),B(this,pr,0),B(this,cr,[]),B(this,zn,!1),V(this,q,xr).call(this)}e instanceof Error&&V(this,q,Pr).call(this,e),V(this,q,Sr).call(this);return}throw e instanceof Error&&V(this,q,Pr).call(this,e),V(this,q,Sr).call(this),e}V(this,q,Sr).call(this)},Sr=function(){var e,t;B(this,Bn,!1),(e=R(this,Yn))==null||e.call(this),(t=R(this,or))==null||t.call(this)},Cr=async function(e){var t;if(R(this,K)instanceof xn)throw R(this,K).error;let n=e??R(this,hr);if(R(this,Qn).isPaused){n&&B(this,hr,n);return}if(!this.options.subscribe&&(this.options.signal?.aborted||R(this,K).isUpToDate))return;R(this,K).isUpToDate?(B(this,pr,0),B(this,cr,[])):await V(this,q,wr).call(this);let r=!1;R(this,K)instanceof bn&&(r=!0,B(this,K,R(this,K).resume()));let{url:i,signal:a}=this.options,{fetchUrl:o,requestHeaders:s}=await V(this,q,Tr).call(this,i,r);n&&(o.searchParams.set(ut,n),o.searchParams.sort());let c=await V(this,q,Er).call(this,a),l=R(this,Un);if(R(this,Qn).isPaused){c&&a&&a.removeEventListener(`abort`,c),n&&B(this,hr,n),B(this,Un,void 0);return}B(this,hr,void 0);try{await V(this,q,kr).call(this,{fetchUrl:o,requestAbortController:l,headers:s,resumingFromPause:r})}catch(e){let t=l.signal.reason,n=l.signal.aborted&&(t===$e||t===tt);if((e instanceof H||e instanceof fe)&&n)return V(this,q,Cr).call(this);if(e instanceof fe)return;if(e instanceof ye)return V(this,q,Cr).call(this);if(!(e instanceof H))throw e;if(e.status==409){if(R(this,K).handle){let e=Nn(o);Xt.markExpired(e,R(this,K).handle)}let t=e.headers[Le];t||console.warn(`[Electric] Received 409 response without a shape handle header. This likely indicates a proxy or CDN stripping required headers.`,Error(`stack trace`));let n=kn();return V(this,q,Rr).call(this,t),await V(this,q,Nr).call(this,[{headers:{control:`must-refetch`}}]),V(this,q,Cr).call(this,n)}else throw e}finally{c&&a&&a.removeEventListener(`abort`,c),B(this,Un,void 0)}return(t=R(this,Jn))==null||t.call(this),V(this,q,Cr).call(this)},wr=async function(){let e=Date.now(),t=R(this,K).offset;if(B(this,cr,R(this,cr).filter(t=>e-t.timestamp<R(this,lr))),R(this,cr).push({timestamp:e,offset:t}),R(this,cr).filter(e=>e.offset===t).length<R(this,ur))return;if(de(this,pr)._++,R(this,pr)>=R(this,mr))throw new H(502,void 0,void 0,{},this.options.url,`Client is stuck in a fast retry loop (${R(this,ur)} requests in ${R(this,lr)}ms at the same offset, repeated ${R(this,mr)} times). Client-side caches were cleared automatically on first detection, but the loop persists. This usually indicates a proxy or CDN misconfiguration. Common causes:
|
|
8
|
+
- Proxy is not including query parameters (handle, offset) in its cache key
|
|
9
|
+
- CDN is serving stale 409 responses
|
|
10
|
+
- Proxy is stripping required Electric headers from responses
|
|
11
|
+
For more information visit the troubleshooting guide: ${On}`);if(R(this,pr)===1){if(console.warn(`[Electric] Detected fast retry loop (${R(this,ur)} requests in ${R(this,lr)}ms at the same offset). Clearing client-side caches and resetting stream to recover. If this persists, check that your proxy includes all query parameters (especially 'handle' and 'offset') in its cache key, and that required Electric headers are forwarded to the client. For more information visit the troubleshooting guide: ${On}`,Error(`stack trace`)),R(this,$n)){let e=Nn(R(this,$n));Xt.delete(e),Zt.delete(e)}else Xt.clear(),Zt.clear();V(this,q,Rr).call(this),B(this,cr,[]);return}let n=Math.min(R(this,fr),R(this,dr)*2**R(this,pr)),r=Math.floor(Math.random()*n);await new Promise(e=>setTimeout(e,r)),B(this,cr,[])},Tr=async function(e,t,n){let[r,i]=await Promise.all([Mn(this.options.headers),this.options.params?jn(Kr(this.options.params)):void 0]);i&&Ur(i);let a=new URL(e);if(i){if(i.table&&Gr(a,qe,i.table),i.where&&typeof i.where==`string`&&Gr(a,Je,ke(i.where,this.options.columnMapper?.encode)),i.columns){let e=await An(this.options.params?.columns);if(Array.isArray(e)){let t=e.map(String);this.options.columnMapper&&(t=t.map(this.options.columnMapper.encode)),Gr(a,Ve,t.map(Oe).join(`,`))}else Gr(a,Ve,i.columns)}i.replica&&Gr(a,Ye,i.replica),i.params&&Gr(a,Xe,i.params);let e=I({},i);delete e.table,delete e.where,delete e.columns,delete e.replica,delete e.params;for(let[t,n]of Object.entries(e))Gr(a,t,n)}n&&(n.whereExpr?(Gr(a,rt,It(n.whereExpr,this.options.columnMapper?.encode)),a.searchParams.set(ct,JSON.stringify(n.whereExpr))):n.where&&typeof n.where==`string`&&Gr(a,rt,ke(n.where,this.options.columnMapper?.encode)),n.params&&a.searchParams.set(st,Pe(n.params)),n.limit!==void 0&&Gr(a,it,n.limit),n.offset!==void 0&&Gr(a,at,n.offset),n.orderByExpr?(Gr(a,ot,Rt(n.orderByExpr,this.options.columnMapper?.encode)),a.searchParams.set(lt,JSON.stringify(n.orderByExpr))):n.orderBy&&typeof n.orderBy==`string`&&Gr(a,ot,ke(n.orderBy,this.options.columnMapper?.encode))),R(this,K).applyUrlParams(a,{isSnapshotRequest:n!==void 0,canLongPoll:!R(this,q,Kn)&&!t}),a.searchParams.set(nt,R(this,Vn));let o=Nn(a),s=Xt.getExpiredHandle(o);return s&&a.searchParams.set(Ue,s),a.searchParams.sort(),{fetchUrl:a,requestHeaders:r}},Er=async function(e){var t;if(B(this,Un,new AbortController),e){let n=()=>{var t;(t=R(this,Un))==null||t.abort(e.reason)};return e.addEventListener(`abort`,n,{once:!0}),e.aborted&&((t=R(this,Un))==null||t.abort(e.reason)),n}},Dr=async function(e){let{headers:t,status:n}=e,r=t.get(Le),i=R(this,$n)?Nn(R(this,$n)):null,a=i?Xt.getExpiredHandle(i):null;if(R(this,vr)){let{shapeKey:e,staleHandle:t}=R(this,vr);B(this,vr,null),i===e&&r===t&&console.warn(`[Electric] Self-healing retry received the same handle "${t}" that was just marked expired. This means your proxy/CDN is serving a stale cached response and ignoring cache-buster query params. The client will proceed with this stale data to avoid a permanent failure, but it may be out of date until the cache refreshes. Fix: configure your proxy/CDN to include all query parameters (especially 'handle' and 'offset') in its cache key. For more information visit the troubleshooting guide: ${On}`,Error(`stack trace`))}let o=R(this,K).handleResponseMetadata({status:n,responseHandle:r,responseOffset:t.get(Re),responseCursor:t.get(Ie),responseSchema:Hr(t),expiredHandle:a,now:Date.now(),maxStaleCacheRetries:R(this,sr),createCacheBuster:kn});if(B(this,K,o.state),n===204&&B(this,_r,null),o.action===`accepted`&&n===204&&B(this,yr,0),o.action===`stale-retry`)throw await e.body?.cancel(),o.exceededMaxRetries?i&&(Xt.delete(i),R(this,_r)!==i)?(console.warn(`[Electric] Stale cache retries exhausted (${R(this,sr)} attempts). Clearing expired handle entry and attempting self-healing retry without the expired_handle parameter. For more information visit the troubleshooting guide: ${On}`,Error(`stack trace`)),B(this,_r,i),r&&B(this,vr,{shapeKey:i,staleHandle:r}),V(this,q,Rr).call(this),new ye(`Expired handle entry evicted for self-healing retry`)):new H(502,void 0,void 0,{},R(this,$n)?.toString()??``,`CDN continues serving stale cached responses after ${R(this,sr)} retry attempts. This indicates a severe proxy/CDN misconfiguration. Check that your proxy includes all query parameters (especially 'handle' and 'offset') in its cache key. For more information visit the troubleshooting guide: ${On}`):(console.warn(`[Electric] Received stale cached response with expired shape handle. This should not happen and indicates a proxy/CDN caching misconfiguration. The response contained handle "${r}" which was previously marked as expired. Check that your proxy includes all query parameters (especially 'handle' and 'offset') in its cache key. For more information visit the troubleshooting guide: ${On} Retrying with a random cache buster to bypass the stale cache (attempt ${R(this,K).staleCacheRetryCount}/${R(this,sr)}).`,Error(`stack trace`)),new ye(`Received stale cached response with expired handle "${r}". This indicates a proxy/CDN caching misconfiguration. Check that your proxy includes all query parameters (especially 'handle' and 'offset') in its cache key.`));return o.action===`ignored`?(console.warn(`[Electric] Response was ignored by state "${R(this,K).kind}". The response body will be skipped. This may indicate a proxy/CDN caching issue or a client state machine bug.`,Error(`stack trace`)),!1):!0},Or=async function(e,t=!1){if(!Array.isArray(e)){console.warn(`[Electric] #onMessages called with non-array argument (${typeof e}). This is a client bug \u2014 please report it.`,Error(`stack trace`));return}if(e.length===0)return;B(this,yr,0);let n=e[e.length-1],r=Me(n),i=r?W(n):void 0,a=R(this,K).handleMessageBatch({hasMessages:!0,hasUpToDateMessage:r,isSse:t,upToDateOffset:i,now:Date.now(),currentCursor:R(this,K).liveCacheBuster});if(B(this,K,a.state),r){if(a.suppressBatch)return;if(R(this,$n)){let e=Nn(R(this,$n));Zt.recordUpToDate(e,R(this,K).liveCacheBuster),B(this,_r,null)}}let o=e.filter(e=>Ae(e)?!R(this,Zn).shouldRejectMessage(e):!0);await V(this,q,Nr).call(this,o)},kr=async function(e){if(B(this,$n,e.fetchUrl),!R(this,K).isUpToDate&&R(this,K).canEnterReplayMode()){let t=Nn(e.fetchUrl),n=Zt.shouldEnterReplayMode(t);n&&B(this,K,R(this,K).enterReplayMode(n))}let t=this.options.liveSse??this.options.experimentalLiveSse;return R(this,K).shouldUseSse({liveSseEnabled:!!t,isRefreshing:R(this,q,Kn),resumingFromPause:!!e.resumingFromPause})?(e.fetchUrl.searchParams.set(Ze,`true`),e.fetchUrl.searchParams.set(Qe,`true`),V(this,q,jr).call(this,e)):V(this,q,Ar).call(this,e)},Ar=async function(e){let{fetchUrl:t,requestAbortController:n,headers:r}=e,i=await R(this,Fn).call(this,t.toString(),{signal:n.signal,headers:r});if(B(this,Bn,!0),!await V(this,q,Dr).call(this,i))return;let a=R(this,K).schema,o=await i.text()||`[]`,s=R(this,Ln).parse(o,a);if(!Array.isArray(s)){let e=Pe(s)?.slice(0,200);throw new H(i.status,`Received non-array response body from shape endpoint. This may indicate a proxy or CDN is returning an unexpected response. Expected a JSON array, got ${typeof s}: ${e}`,void 0,Object.fromEntries(i.headers.entries()),t.toString())}await V(this,q,Or).call(this,s)},jr=async function(e){let{fetchUrl:t,requestAbortController:n,headers:r}=e,i=R(this,In);B(this,er,Date.now());let a=L(I({},r),{Accept:`text/event-stream`}),o=!1;try{let e=[];await Jt(t.toString(),{headers:a,fetch:i,onopen:async e=>{if(B(this,Bn,!0),!await V(this,q,Dr).call(this,e))throw o=!0,Error(`stale response ignored`)},onmessage:t=>{if(t.data){let n=R(this,K).schema,r=R(this,Ln).parse(t.data,n);e.push(r),Me(r)&&(V(this,q,Or).call(this,e,!0),e=[])}},onerror:e=>{throw e},signal:n.signal})}catch(e){if(o)return;if(n.signal.aborted)throw new fe;if(e instanceof H||e instanceof ye||e instanceof ve)throw e}finally{let e=Date.now()-R(this,er),t=n.signal.aborted,r=R(this,K).handleSseConnectionClosed({connectionDuration:e,wasAborted:t,minConnectionDuration:R(this,tr),maxShortConnections:R(this,nr)});if(B(this,K,r.state),r.fellBackToLongPolling)console.warn(`[Electric] SSE connections are closing immediately (possibly due to proxy buffering or misconfiguration). Falling back to long polling. Your proxy must support streaming SSE responses (not buffer the complete response). Configuration: Nginx add 'X-Accel-Buffering: no', Caddy add 'flush_interval -1' to reverse_proxy. Note: Do NOT disable caching entirely - Electric uses cache headers to enable request collapsing for efficiency.`,Error(`stack trace`));else if(r.wasShortConnection){let e=Math.min(R(this,ir),R(this,rr)*2**R(this,K).consecutiveShortSseConnections),t=Math.floor(Math.random()*e);await new Promise(e=>setTimeout(e,t))}}},Mr=async function(){if(R(this,Qn).isPaused)throw Error(`Cannot wait for next tick while PauseLock is held — this would deadlock because the request loop is paused`);return R(this,qn)?R(this,qn):(B(this,qn,new Promise((e,t)=>{B(this,Jn,e),B(this,Yn,t)})),R(this,qn).finally(()=>{B(this,qn,void 0),B(this,Jn,void 0),B(this,Yn,void 0)}),R(this,qn))},Nr=async function(e){return B(this,Xn,R(this,Xn).then(()=>Promise.all(Array.from(R(this,Rn).values()).map(async([t,n])=>{try{await t(e)}catch(e){queueMicrotask(()=>{throw e})}})))),R(this,Xn)},Pr=function(e){R(this,Rn).forEach(([t,n])=>{n?.(e)})},Fr=function(){return typeof document==`object`&&typeof document.hidden==`boolean`&&typeof document.addEventListener==`function`},Ir=function(){if(V(this,q,Fr).call(this)){let e=()=>{document.hidden?R(this,Qn).acquire(`visibility`):R(this,Qn).release(`visibility`)};document.addEventListener(`visibilitychange`,e),B(this,ar,()=>{document.removeEventListener(`visibilitychange`,e),B(this,ar,void 0)})}},Lr=function(){if(V(this,q,Fr).call(this)||R(this,or))return;let e=2e3,t=Date.now(),n=setInterval(()=>{let n=Date.now(),r=n-t;t=n,r>e+4e3&&!R(this,Qn).isPaused&&R(this,Un)&&(de(this,Wn)._++,R(this,Un).abort(tt),queueMicrotask(()=>{de(this,Wn)._--}))},e);typeof n==`object`&&`unref`in n&&n.unref(),B(this,or,()=>{clearInterval(n),B(this,or,void 0)})},Rr=function(e){B(this,K,R(this,K).markMustRefetch(e)),B(this,Bn,!1),R(this,Qn).releaseAllMatching(`snapshot`)},zr=async function(e,t,n){let r=(e.method??this.options.subsetMethod??`GET`)===`POST`,i,a;if(r){let t=await V(this,q,Tr).call(this,this.options.url,!0);i=t.fetchUrl,a={method:`POST`,headers:L(I({},t.requestHeaders),{"Content-Type":`application/json`}),body:Pe(V(this,q,Br).call(this,e))}}else{let t=await V(this,q,Tr).call(this,this.options.url,!0,e);i=t.fetchUrl,a={headers:t.requestHeaders}}n&&(i.searchParams.set(ut,n),i.searchParams.sort());let o=R(this,K).handle,s;try{s=await R(this,Fn).call(this,i.toString(),a)}catch(n){if(n instanceof H&&n.status===409){let r=t+1;if(r>R(this,gr))throw new H(502,void 0,void 0,{},i.toString(),`Snapshot request stuck in 409 retry loop after ${R(this,gr)} attempts. This indicates a proxy/CDN misconfiguration. For more information visit the troubleshooting guide: ${On}`);if(o){let e=Nn(i);Xt.markExpired(e,o)}let a=n.headers[Le];a?B(this,K,R(this,K).withHandle(a)):console.warn(`[Electric] Received 409 response without a shape handle header. This likely indicates a proxy or CDN stripping required headers.`,Error(`stack trace`));let s=kn();return V(this,q,zr).call(this,e,r,s)}throw n}if(!s.ok)throw await H.fromResponse(s,i.toString());let c=R(this,K).schema??Hr(s.headers,{required:!0,url:i.toString()}),{metadata:l,data:u}=await s.json();return{metadata:l,data:R(this,Ln).parseSnapshotData(u,c),responseOffset:s.headers.get(Re)||null,responseHandle:s.headers.get(Le)}},Br=function(e){let t={};return e.whereExpr?(t.where=It(e.whereExpr,this.options.columnMapper?.encode),t.where_expr=e.whereExpr):e.where&&typeof e.where==`string`&&(t.where=ke(e.where,this.options.columnMapper?.encode)),e.params&&(t.params=e.params),e.limit!==void 0&&(t.limit=e.limit),e.offset!==void 0&&(t.offset=e.offset),e.orderByExpr?(t.order_by=Rt(e.orderByExpr,this.options.columnMapper?.encode),t.order_by_expr=e.orderByExpr):e.orderBy&&typeof e.orderBy==`string`&&(t.order_by=ke(e.orderBy,this.options.columnMapper?.encode)),t},Vr.Replica={FULL:`full`,DEFAULT:`default`};function Hr(e,t){let n=e.get(ze);if(!n){if(t?.required&&t?.url)throw new ve(t.url,[ze]);return{}}return JSON.parse(n)}function Ur(e){if(!e)return;let t=Object.keys(e).filter(e=>Dn.has(e));if(t.length>0)throw new ge(t)}function Wr(e){if(!e.url)throw new pe;if(e.signal&&!(e.signal instanceof AbortSignal))throw new me;if(e.offset!==void 0&&e.offset!==`-1`&&e.offset!==`now`&&!e.handle)throw new he;Ur(e.params)}function Gr(e,t,n){if(!(n===void 0||n==null))if(typeof n==`string`)e.searchParams.set(t,n);else if(typeof n==`object`)for(let[r,i]of Object.entries(n))e.searchParams.set(`${t}[${r}]`,i);else e.searchParams.set(t,n.toString())}function Kr(e){return Array.isArray(e.params)?L(I({},e),{params:Object.fromEntries(e.params.map((e,t)=>[t+1,e]))}):e}var qr=b(((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}})),Jr=b(((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=c,n.disable=o,n.enable=i,n.enabled=s,n.humanize=qr(),n.destroy=l,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,`enabled`,{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(t===void 0?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}function l(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n})),Yr=S(b(((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t={}.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=Jr()(e);var{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}}))(),1),Xr=class extends l{constructor(e,t){super(`${t?`[${t}] `:``}${e}`),this.name=`ElectricDBCollectionError`}},Zr=class extends Xr{constructor(e,t){super(`Expected number in awaitTxId, received ${e}`,t),this.name=`ExpectedNumberInAwaitTxIdError`}},Qr=class extends Xr{constructor(e,t){super(`Timeout waiting for txId: ${e}`,t),this.name=`TimeoutWaitingForTxIdError`}},$r=class extends Xr{constructor(e){super(`Timeout waiting for custom match function`,e),this.name=`TimeoutWaitingForMatchError`}},ei=class extends Xr{constructor(e){super(`Stream aborted`,e),this.name=`StreamAbortedError`}};function ti(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`bigint`)return e.toString();if(typeof e==`boolean`)return e?`true`:`false`;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return`{${e.map(e=>e==null?`NULL`:typeof e==`string`?`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`:ti(e)).join(`,`)}}`;let t;try{t=JSON.stringify(e)}catch{t=String(e)}throw Error(`Cannot serialize value: ${t}`)}function ni(e,t){let{where:n,orderBy:r,limit:i}=e,a=t?.encodeColumnName,o=[],s={params:o};n&&(s.where=ii(n,o,a)),r&&(s.orderBy=ai(r,o,a)),i&&(s.limit=i),n||(s.where=`true = true`);let c=o.reduce((e,t,n)=>{let r=ti(t);return t!=null&&(e[`${n+1}`]=r),e},{});return{...s,params:c}}function ri(e,t){return`"${(t?t(e):e).replace(/"/g,`""`)}"`}function ii(e,t,n){switch(e.type){case`val`:return t.push(e.value),`$${t.length}`;case`ref`:if(e.path.length!==1)throw Error(`Compiler can't handle nested properties: ${e.path.join(`.`)}`);return ri(e.path[0],n);case`func`:return ci(e,t,n);default:throw Error(`Unknown expression type`)}}function ai(e,t,n){return e.map(e=>oi(e,t,n)).join(`,`)}function oi(e,t,n){let{expression:r,compareOptions:i}=e,a=ii(r,t,n);return i.direction===`desc`&&(a=`${a} DESC`),i.nulls===`first`&&(a=`${a} NULLS FIRST`),i.nulls===`last`&&(a=`${a} NULLS LAST`),a}function si(e){return e.type===`val`&&(e.value===null||e.value===void 0)}function ci(e,t=[],n){let{name:r,args:i}=e,a=fi(r);if(ui(r)&&i.findIndex(e=>si(e))!==-1)throw Error(`Cannot use null/undefined value with '${r}' operator. Comparisons with null always evaluate to UNKNOWN in SQL. Use isNull() or isUndefined() to check for null values, or filter out null values before building the query.`);if(r===`not`){if(i.length!==1)throw Error(`NOT expects 1 argument`);let e=i[0];if(e?.type===`func`&&(e.name===`isNull`||e.name===`isUndefined`)){if(e.args.length!==1)throw Error(`${e.name} expects 1 argument`);let r=e.args[0],i=ii(r,t,n);return`${r.type===`func`?`(${i})`:i} IS NOT NULL`}}let o=i.findIndex(e=>e.type===`val`&&typeof e.value==`boolean`);if(i.length===2&&di(r)&&o!==-1){let e=i[o].value,a=i[+(o===0)],s=`(${ii(a,t,n)})`,c=(r===`lt`||r===`lte`)==(o===1),l=r===`lte`||r===`gte`;return l&&e===c?`${s} = ${s}`:!l&&e!==c?`${s} <> ${s}`:`${s} = ${c?`FALSE`:`TRUE`}`}let s=i.map(e=>{let i=ii(e,t,n);return e.type===`func`&&(e.name===`and`||e.name===`or`||r!==`and`&&r!==`or`&&r!==`not`&&(li(e.name)||e.name===`not`||e.name===`isNull`||e.name===`isUndefined`))?`(${i})`:i});if(r===`isNull`||r===`isUndefined`){if(s.length!==1)throw Error(`${r} expects 1 argument`);return`${s[0]} ${a}`}if(r===`not`)return`${a} (${s[0]})`;if(li(r)){if((r===`and`||r===`or`)&&s.length>2)return s.join(` ${a} `);if(s.length!==2)throw Error(`Binary operator ${r} expects 2 arguments`);let[e,t]=s;if(r===`in`){let n=i[0],r=i[1];if(n.type===`val`&&Array.isArray(n.value))throw Error(`Array-valued 'in' left operand; expected a scalar`);return r.type===`ref`&&n.type===`val`?`${e} = ANY(${t}) AND ${t} @> ARRAY[${e}] AND ${t} IS NOT NULL`:`${e} ${a}(${t})`}return`${e} ${a} ${t}`}return`${a}(${s.join(`,`)})`}function li(e){return[`eq`,`gt`,`gte`,`lt`,`lte`,`and`,`or`,`in`,`like`,`ilike`].includes(e)}function ui(e){return[`eq`,`gt`,`gte`,`lt`,`lte`,`like`,`ilike`,`in`].includes(e)}function di(e){return[`gt`,`gte`,`lt`,`lte`].includes(e)}function fi(e){let t={eq:`=`,gt:`>`,gte:`>=`,lt:`<`,lte:`<=`,add:`+`,and:`AND`,or:`OR`,not:`NOT`,isUndefined:`IS NULL`,isNull:`IS NULL`,in:`= ANY`,like:`LIKE`,ilike:`ILIKE`,upper:`UPPER`,lower:`LOWER`,length:`LENGTH`,concat:`CONCAT`,coalesce:`COALESCE`}[e];if(!t)throw Error(`Unknown operator/function: ${e}`);return t}function pi(e){return e.split(`/`).map(e=>e===``?null:e)}function mi(e,t){if(t>=e.length)throw Error(`Position out of bounds`);return e[t]}function hi(e){return e}function gi(e){return e.length}function _i(e,t){let{pos:n,value:r}=hi(t);return mi(e,n)===r}function vi(e,t,n,r){for(let i=0;i<r;i++){let r=mi(e,i);if(r!==null){let e=n[i];e.has(r)||e.set(r,new Set),e.get(r).add(t)}}}function yi(e,t,n,r){for(let i=0;i<r;i++){let r=mi(e,i);if(r!==null){let e=n[i];if(e){let n=e.get(r);n&&(n.delete(t),n.size===0&&e.delete(r))}}}}function bi(e,t){let{pos:n,value:r}=hi(e);return t[n]?.get(r)??new Set}function xi(e){return e.map(e=>{let t=[];for(let n=0;n<e.length;n++)e[n]!==null&&t.push(n);return t})}function Si(e,t){return t.some(t=>t.every(t=>e[t]))}function Ci(e){return e.headers.event===`move-out`}function wi(e){return e.headers.event===`move-in`}var J=Yr.default.debug(`ts/db:electric`),Ti=Symbol(`electricTestHooks`);function Ei(e){let t=e.hydratedResumeState;return{version:1,...t?{resume:t}:{},seenTxids:Array.from(e.seenTxids).sort((e,t)=>e-t)}}function Di(e,t){let n=ki(t);n&&(e.hydratedResumeState=n.resume,e.seenTxids=new Set(n.seenTxids))}function Oi(e){if(!e||typeof e!=`object`)return;let t=e;if(t.kind===`resume`&&typeof t.offset==`string`&&typeof t.handle==`string`&&typeof t.shapeId==`string`&&typeof t.updatedAt==`number`&&Number.isFinite(t.updatedAt))return{kind:`resume`,offset:t.offset,handle:t.handle,shapeId:t.shapeId,updatedAt:t.updatedAt,...typeof t.requiresTagState==`boolean`&&{requiresTagState:t.requiresTagState}};if(t.kind===`reset`&&typeof t.updatedAt==`number`&&Number.isFinite(t.updatedAt))return{kind:`reset`,updatedAt:t.updatedAt}}function ki(e){if(!e||typeof e!=`object`)return;let t=e;if(t.version!==1||!Array.isArray(t.seenTxids)||!t.seenTxids.every(e=>typeof e==`number`&&Number.isFinite(e)))return;let n=t.resume===void 0?void 0:Oi(t.resume);if(!(t.resume!==void 0&&n===void 0))return{version:1,...n?{resume:n}:{},seenTxids:Array.from(new Set(t.seenTxids)).sort((e,t)=>e-t)}}function Ai(e,t){let n=ki(e),r=ki(t);if(!r)return e;if(!n)return r;let i=ji(n.resume,r.resume);return{version:1,...i?{resume:i}:{},seenTxids:Array.from(new Set([...n.seenTxids,...r.seenTxids])).sort((e,t)=>e-t)}}function ji(e,t){return e?t?t.updatedAt>e.updatedAt?t:t.updatedAt<e.updatedAt||e.kind===t.kind&&(e.kind===`reset`||t.kind===`resume`&&e.offset===t.offset&&e.handle===t.handle&&e.shapeId===t.shapeId)?e:{kind:`reset`,updatedAt:e.updatedAt}:e:t}function Mi(e){return je(e)&&e.headers.control===`up-to-date`}function Ni(e){return je(e)&&e.headers.control===`must-refetch`}function Pi(e){return je(e)&&e.headers.control===`snapshot-end`}function Fi(e){return je(e)&&e.headers.control===`subset-end`}function Ii(e){return{xmin:e.headers.xmin,xmax:e.headers.xmax,xip_list:e.headers.xip_list}}function Li(e){if(e==null)return e;if(Array.isArray(e))return e.map(e=>Li(e));if(e instanceof Date)return e.toISOString();if(typeof e==`object`){let t=e,n={},r=Object.keys(t).sort((e,t)=>e<t?-1:+(e>t));for(let e of r)n[e]=Li(t[e]);return n}return e}function Ri(e){return JSON.stringify(Li({url:e.url,params:e.params??null}))}function zi(e){return`txids`in e.headers&&Array.isArray(e.headers.txids)}var Bi=e=>e.reason??new t,Vi=(e,t)=>{if(!t)return e;let n=()=>{},r=new Promise((e,r)=>{let i=()=>r(Bi(t));t.addEventListener(`abort`,i,{once:!0}),n=()=>t.removeEventListener(`abort`,i),t.aborted&&i()});return Promise.race([e,r]).finally(n)};function Hi({stream:e,syncMode:t,isBufferingInitialSync:n,waitForFullSnapshot:r,waitForEstablishedSnapshot:i,begin:o,write:s,commit:c,getCommitCursor:l,waitForCommitsAfter:u,recordSnapshotRow:d,collectionId:f,encodeColumnName:p,signal:m,isCleanupAbort:h,beforeSnapshot:g}){if(t===`eager`)return null;let _=p?{encodeColumnName:p}:void 0,v=f?`[${f}] `:``,y;function b(e,t){return m.aborted&&h()?(J(`${v}Ignoring ${t} error during cleanup: %o`,e),!0):(J(`${v}Error in ${t}: %o`,e),!1)}return new M({loadSubset:async f=>{let p=l(),x=()=>{if(m.aborted)throw Bi(m);if(f.signal?.aborted)throw Bi(f.signal)},ee=()=>{if(!m.aborted)return!1;if(!h())throw Bi(m);return!0},S=t=>{let n=()=>(x(),e.requestSnapshot(t)),r=y?y.then(n):n();return y=r.then(()=>void 0,()=>void 0),Vi(r,f.signal)};x(),g&&(await g(),x());let C=async e=>{let t=f.signal;try{await Vi(e,t)}catch(e){if(m.aborted&&h())return;throw t?.aborted?Bi(t):e}if(!(m.aborted&&h())&&t?.aborted)throw Bi(t)};if(r)return C(r());if(n()){let t=ni(f,_);try{let{data:r}=await e.fetchSnapshot(t);if(!n())return J(`${v}Ignoring snapshot - sync completed while fetching`),C(i());if(x(),r.length>0){o();for(let e of r)s({type:`insert`,value:e.value,metadata:{...e.headers}});let e=c(f.signal);for(let e of r)d?.(e.value,e);e!==!0&&await e,J(`${v}Applied snapshot with ${r.length} rows`)}}catch(e){if(b(e,`fetchSnapshot`))return;throw f.signal?.aborted?Bi(f.signal):e}if(f.signal?.aborted)throw Bi(f.signal);return}if(t===`progressive`)return C(i());let{cursor:w,where:T,orderBy:te,limit:E}=f;x();try{if(w){let e=ni({where:T?a(T,w.whereCurrent):w.whereCurrent,orderBy:te},_),t=ni({where:T?a(T,w.whereFrom):w.whereFrom,orderBy:te,limit:E},_);J(`${v}Requesting cursor.whereCurrent snapshot (all ties)`),J(`${v}Requesting cursor.whereFrom snapshot (with limit ${E})`),await S(e),await S(t)}else await S(ni(f,_))}catch(e){if(f.signal?.aborted)throw Bi(f.signal);if(b(e,`requestSnapshot`))return;throw e}if(f.signal?.aborted)throw Bi(f.signal);if(!ee()){if(await Vi(u(p),f.signal),f.signal?.aborted)throw Bi(f.signal);ee()}}})}var Ui=class{constructor(e){this.collectionId=e,this.evidence={seenTxids:new Set,seenSnapshots:[]},this.pendingMatches=new Map,this.pendingTxidWaits=new Map,this.matchBuffer={committedMessages:[],pendingMessages:[]},this.nextWaiterId=0,this.epoch=0,this.active=!1,this.utils={awaitTxId:(e,t)=>this.awaitTxId(e,t),awaitMatch:(e,t)=>this.awaitMatch(e,t)}}start(){return this.active&&this.retire(),this.active=!0,this.epoch++,this.matchBuffer={committedMessages:[],pendingMessages:[]},this.epoch}isActive(e){return this.active&&this.epoch===e}retire(e){if(!(e!==void 0&&!this.isActive(e))){this.active=!1,this.epoch++;for(let e of this.pendingMatches.values())clearTimeout(e.timeoutId),e.reject(new ei(this.collectionId));this.pendingMatches.clear();for(let e of this.pendingTxidWaits.values())clearTimeout(e.timeoutId),e.reject(new ei(this.collectionId));this.pendingTxidWaits.clear(),this.matchBuffer={committedMessages:[],pendingMessages:[]},this.evidence.hydratedResumeState=void 0}}forgetEvidenceAfterScopedRecovery(){this.evidence.seenTxids.clear(),this.evidence.seenSnapshots.length=0,this.evidence.hydratedResumeState=void 0}exportMeta(){return Ei(this.evidence)}importMeta(e){Di(this.evidence,e),this.resolveTxidWaiters()}get resumeState(){return this.evidence.hydratedResumeState}set resumeState(e){this.evidence.hydratedResumeState=e}publishEvidence(e,t){e.forEach(e=>this.evidence.seenTxids.add(e)),this.evidence.seenSnapshots.push(...t),this.resolveTxidWaiters()}hasTxid(e){return this.evidence.seenTxids.has(e)||this.evidence.seenSnapshots.some(t=>Fe(e,t))}resolveTxidWaiters(){for(let[e,t]of this.pendingTxidWaits)this.hasTxid(t.txId)&&(clearTimeout(t.timeoutId),this.pendingTxidWaits.delete(e),t.resolve(!0))}async awaitTxId(e,t=15e3){if(J(`${this.collectionId?`[${this.collectionId}] `:``}awaitTxId called with txid %d`,e),typeof e!=`number`)throw new Zr(typeof e,this.collectionId);return this.hasTxid(e)?!0:new Promise((n,r)=>{let i=this.nextWaiterId++,a=setTimeout(()=>{this.pendingTxidWaits.delete(i),r(new Qr(e,this.collectionId))},t);this.pendingTxidWaits.set(i,{txId:e,resolve:n,reject:r,timeoutId:a})})}async awaitMatch(e,t=15e3){J(`${this.collectionId?`[${this.collectionId}] `:``}awaitMatch called with custom function`);for(let t of this.matchBuffer.committedMessages)if(e(t))return!0;for(let n of this.matchBuffer.pendingMessages)if(e(n))return this.registerMatch(e,t,!0);return this.registerMatch(e,t,!1)}registerMatch(e,t,n){return new Promise((r,i)=>{let a=this.nextWaiterId++,o=setTimeout(()=>{this.pendingMatches.delete(a),i(new $r(this.collectionId))},t);this.pendingMatches.set(a,{matchFn:e,resolve:r,reject:i,timeoutId:o,matched:n})})}beginMatchGeneration(e){if(e.some(Ni)){this.matchBuffer={committedMessages:[],pendingMessages:[]};for(let e of this.pendingMatches.values())e.matched=!1}}observeMatchMessage(e){if(Ae(e)||Ci(e)||wi(e)){this.matchBuffer.pendingMessages.push(e);let t=this.matchBuffer.committedMessages.length+this.matchBuffer.pendingMessages.length-1e3;if(t>0){let e=Math.min(t,this.matchBuffer.committedMessages.length);this.matchBuffer.committedMessages.splice(0,e),t-=e,t>0&&this.matchBuffer.pendingMessages.splice(0,t)}}let t=this.epoch;for(let[n,r]of this.pendingMatches)if(!r.matched){try{r.matched=r.matchFn(e)}catch(e){clearTimeout(r.timeoutId),this.pendingMatches.delete(n),r.reject(e instanceof Error?e:Error(String(e)))}if(!this.isActive(t))return}}commitMatches(){this.matchBuffer.committedMessages.push(...this.matchBuffer.pendingMessages),this.matchBuffer.pendingMessages=[],this.matchBuffer.committedMessages.length>1e3&&this.matchBuffer.committedMessages.splice(0,this.matchBuffer.committedMessages.length-1e3);for(let[e,t]of this.pendingMatches)t.matched&&(clearTimeout(t.timeoutId),this.pendingMatches.delete(e),t.resolve(!0))}};function Wi(e){let t=new Ui(e.id),r=t,i=e.syncMode??`eager`,a=i===`progressive`?`on-demand`:i,o=new WeakMap,l=(e,t)=>r.utils.awaitTxId(e,t),u=(e,t)=>r.utils.awaitMatch(e,t),d=Gi(e.shapeOptions,{getLifecycle:e=>o.get(e)??t,syncMode:i,collectionId:e.id,testHooks:e[Ti]}),p=async(e,t)=>{if((typeof e==`object`&&e||typeof e==`function`)&&`txid`in e){let r=e;n(`electric-collection-txid-return`,"[TanStack DB] DEPRECATED: Returning { txid } from mutation handlers is deprecated and will be removed in v1.0. Use `await collection.utils.awaitTxId(txid)` instead of returning { txid }. See migration guide: https://tanstack.com/db/latest/docs/collections/electric-collection#persistence-handlers--synchronization");let i=r.timeout;Array.isArray(r.txid)?await Promise.all(r.txid.map(e=>t(e,i))):await t(r.txid,i)}},m=e=>e.collection?.utils?.awaitTxId??l,h=e.onInsert?async t=>{await p(await e.onInsert(t),m(t))}:void 0,g=e.onUpdate?async t=>{await p(await e.onUpdate(t),m(t))}:void 0,_=e.onDelete?async t=>{await p(await e.onDelete(t),m(t))}:void 0,{shapeOptions:v,onInsert:y,onUpdate:b,onDelete:x,...ee}=e,S={awaitTxId:l,awaitMatch:u},C=()=>{let n=t;return t=new Ui(e.id),r=n,n},w=(e,t)=>{let n=C(),r;return Object.assign(t,n.utils),c({...e,sync:t=>(o.has(t.collection)||(r=t.collection,o.set(t.collection,n)),e.sync(t)),exportSyncMeta:()=>n.exportMeta(),importSyncMeta:e=>n.importMeta(e),mergeSyncMeta:Ai},()=>{n.retire(),r&&o.delete(r)})},T=s({...d,exportSyncMeta:()=>t.exportMeta(),importSyncMeta:e=>t.importMeta(e),mergeSyncMeta:Ai},w),te={...ee,syncMode:a,sync:T,onInsert:h,onUpdate:g,onDelete:_,utils:S};return Object.defineProperty(te,`utils`,{enumerable:!0,get:()=>({...S})}),f(te,()=>Wi(e))}function Gi(n,r){let{getLifecycle:i,syncMode:a,collectionId:o,testHooks:s}=r,c,l=()=>{let e=new Map,t=t=>{let n=e.get(t);if(n)return n;let r=pi(t);return e.set(t,r),r},n=new Map,r=[],i,a=new Map,s,c=e=>{if(r.length<e)for(let t=r.length;t<e;t++)r[t]=new Map},l=(e,n,a)=>{for(let s of e){let e=t(s);i===void 0&&(i=gi(e),c(i));let l=gi(e);if(l!==i){J(`${o?`[${o}] `:``}Tag length mismatch: expected ${i}, got ${l}`);continue}a.add(s),vi(e,n,r,i)}},u=(n,a,o)=>{if(i!==void 0)for(let s of n){let n=t(s);o.delete(s),yi(n,a,r,i),e.delete(s)}},d=(e,r,i,o)=>{n.has(i)||n.set(i,new Set);let c=n.get(i);return e&&(l(e,i,c),s===void 0&&(s=xi(e.map(t)))),r&&u(r,i,c),o&&o.length>0&&a.set(i,[...o]),c},f=()=>{n.clear(),r.length=0,i=void 0,a.clear(),s=void 0},p=o=>{if(i===void 0)return;let s=n.get(o);if(s){for(let n of s){let a=t(n);gi(a)===i&&yi(a,o,r,i),e.delete(n)}n.delete(o),a.delete(o)}},m=(o,c)=>{let l=n.get(o);if(!l)return!1;let u=a.get(o);if(u&&s){if(u[c.pos]=!1,!Si(u,s)){for(let n of l)yi(t(n),o,r,i),e.delete(n);return n.delete(o),a.delete(o),!0}return!1}for(let e of l){let n=t(e);_i(n,c)&&(l.delete(e),yi(n,o,r,i))}return l.size===0?(n.delete(o),!0):!1};return{hasTags:()=>i!==void 0,processTagsForChangeMessage:d,clearTagTrackingState:f,clearTagsForRow:p,processMoveOutEvent:(e,t,n,a,s)=>{if(i===void 0)return J(`${o?`[${o}] `:``}Received move-out message but no tag length set yet, ignoring`),a;let c=a;for(let i of e){let e=bi(i,r);for(let r of e)m(r,i)&&(c||=(t(),!0),n({type:`delete`,key:r}),s(r))}return c},processMoveInEvent:e=>{if(i===void 0){J(`${o?`[${o}] `:``}Received move-in message but no tag length set yet, ignoring`);return}for(let t of e){let e=bi(t,r);for(let n of e){let e=a.get(n);e&&(e[t.pos]=!0)}}}}},u=new WeakMap,f=(e,t=!1)=>{let r=u.has(e.collection),f=u.get(e.collection);f||(f=l(),u.set(e.collection,f));let{processTagsForChangeMessage:m,clearTagTrackingState:h,clearTagsForRow:g,processMoveOutEvent:_,processMoveInEvent:v}=f;t&&h();let y=i(e.collection);t&&y.forgetEvidenceAfterScopedRecovery();let b=y.start(),x=()=>y.isActive(b);Object.assign(e.collection.utils,y.utils);let{begin:ee,write:S,commit:C,markReady:w,markError:T,truncate:te,collection:E,metadata:D}=e,ne=0,O=new Map,k=e=>{let t=++ne,n=C(e);if(n===!0)return!0;O.set(t,n);let r=()=>O.delete(t);return n.then(r,r),n},A=async e=>{await Promise.all(Array.from(O,([t,n])=>t>e?n:void 0))},j=D===void 0?null:d(D.persistence),re=j?.hydrateBaseline,M=j?.resumeSnapshot,ie=M?.certify,ae=M?.getKeySetEvidence,oe=M?.expectCurrentCommit,se=ae?.(),N=t?void 0:D?.collection.get(`electric:resume`),P=Oi(N),ce=N!==void 0&&P===void 0,F=ji(P,y.resumeState),I=Ri({url:n.url,params:n.params}),L=F?.kind===`resume`&&F.shapeId!==I,le=F?.kind===`resume`&&ae!==void 0&&se?.status!==`consistent`,ue=j?.managedCacheGeneration===!0&&se?.status===`incompatible`,R=!t&&(ue||n.offset===void 0&&n.handle===void 0&&(F!==void 0||ce)&&(ce||L||F?.kind===`reset`||le||!r&&F?.kind===`resume`&&F.requiresTagState!==!1)),z=a===`on-demand`&&R&&j?.managedCacheGeneration===!0&&j.startScopedRecovery!==void 0;z&&y.forgetEvidenceAfterScopedRecovery();let B=a===`on-demand`&&(!R||z),V=a===`on-demand`&&!B,de=V||a===`progressive`,H=()=>{},fe=()=>{},pe=Promise.resolve(),me=()=>{de&&(pe=new Promise((e,t)=>{H=t=>e(t===!0?void 0:t),fe=t}),pe.catch(()=>void 0))};me();let he=n.offset===void 0&&n.handle===void 0&&F?.kind===`resume`&&!L&&!R,ge=n.offset!==void 0&&n.offset!==`-1`;!he&&!ge&&h();let _e=n.params?.replica===`full`,ve=he&&ie!==void 0,ye=a!==`on-demand`&&(he||ge&&!_e),be=(a===`eager`||R&&!z)&&!he&&!ge&&re!==void 0,xe=null,Se=0,Ce=(e,t=Se)=>{!x()||Se!==t||(e&&a===`progressive`&&s?.beforeMarkingReady?(xe=s.beforeMarkingReady(),xe.then(()=>{Se===t&&w()})):w())},U=new AbortController,we=!1,Te=!1,Ee=!1,De=!1,Oe=e=>{Ee||(Te=!0,T(e))},ke=(e,t)=>{De||E.status!==`loading`||(t===void 0?x()?Ce(e,Se):w():(Te=!0,T(t)))},je=()=>{let e=x()&&E.status===`loading`;U.abort(),e&&Oe(new ei(o))};n.signal&&(n.signal.addEventListener(`abort`,je,{once:!0}),n.signal.aborted&&je()),U.signal.addEventListener(`abort`,()=>{fe(new ei(o)),y.retire(b)});let Me=new Vr({...n,log:B?`changes_only`:void 0,offset:n.offset??(he?F.offset:B?`now`:void 0),handle:n.handle??(he?F.handle:void 0),signal:U.signal,onError:async e=>{if(!x()||U.signal.aborted)return;Se++;let t=e=>{fe(e),E.status===`loading`&&Oe(e)};if(n.onError){let r;try{r=await n.onError(e)}catch(e){throw t(e),e}return(!r||typeof r!=`object`)&&t(e),r}else{let n=E.status===`loading`;t(e),console.error(`An error occurred while syncing collection: ${E.id},
|
|
12
|
+
`+(n?`the initial sync has been marked as failed.
|
|
13
|
+
`:`the last ready snapshot has been preserved.
|
|
14
|
+
`)+`You can provide an 'onError' handler on the shapeOptions to handle this error, and this message will not be logged.`,e)}}}),W=!1,Ne=new Set,Pe=[],Fe=a===`progressive`&&ye;Fe&&H(!0);let Ie=!1,Le=0,Re=()=>a===`progressive`&&!Fe&&!Ie,ze=[],Be=new Map,Ve=new Map,He=!0,Ue=0,We=(e,t)=>{Ue++,Ve.set(e,t)},Ge=()=>{Ue++,Ve.clear(),Be.clear(),He=!1},Ke=()=>{let e=Ue,t=k();if(D?.persistence){let n=()=>{Ue===e&&(Ve.clear(),He=!0)};t===!0?n():t.then(n,()=>void 0)}return t},qe=()=>{ee(),D?.persistence?.reserveCommitTurn()},Je=new Set,Ye=!1,Xe=()=>{if(!x()||Ye||z||t)return;let e=Me.shapeHandle,n=Me.lastOffset;if(!e||n===`-1`)return;let r={kind:`resume`,offset:n,handle:e,shapeId:I,updatedAt:Date.now(),requiresTagState:f.hasTags()};y.resumeState=r,D?.collection.set(`electric:resume`,r)},Ze=(e=!1)=>{let t={kind:`reset`,updatedAt:Math.max(Date.now(),F?.updatedAt??0,y.resumeState?.updatedAt??0)+1};y.resumeState=t,D&&(ee(),D.collection.set(`electric:resume`,t),e&&oe?.(),k())};R&&!z&&(ce||L||F?.kind===`resume`)&&Ze(!0);let Qe=z?F?.kind===`reset`?F:y.resumeState?.kind===`reset`?y.resumeState:{kind:`reset`,updatedAt:Date.now()}:void 0;Qe&&(y.resumeState=Qe);let $e=Qe&&j?.startScopedRecovery?j.startScopedRecovery({key:`electric:resume`,value:Qe}):void 0,et=e=>{if(!Ae(e))return;let t=e.headers.tags,n=e.headers.removed_tags,r=t||n,i=e.headers.active_conditions,a=E.getKeyFromItem(e.value),o=e.headers.operation,s=o===`delete`,c=o===`insert`&&Je.has(a);s?Je.delete(a):Je.add(a),s?g(a):r&&m(t,n,a,i),S({type:c?`update`:o,value:e.value,metadata:{...e.headers}})},tt=Hi({stream:Me,syncMode:a,isBufferingInitialSync:Re,waitForFullSnapshot:V?()=>pe:void 0,waitForEstablishedSnapshot:()=>pe,begin:ee,write:S,commit:k,getCommitCursor:()=>ne,waitForCommitsAfter:A,recordSnapshotRow:(e,t)=>{We(E.getKeyFromItem(e),!0),Be.set(E.getKeyFromItem(e),t)},collectionId:o,encodeColumnName:n.columnMapper?.encode,signal:U.signal,isCleanupAbort:()=>we,beforeSnapshot:$e?()=>$e:void 0}),nt=$e??(ye||be?re?(async()=>{await re();let e=ae?.();if(he&&e?.status!==`consistent`)throw Error(`Electric persisted resume baseline could not be certified during hydration`)})():void 0:ve?(async()=>{if(await ie(),ae?.()?.status!==`consistent`)throw Error(`Electric persisted resume baseline could not be certified`)})():void 0),rt=!nt,it=[],at=()=>{},ot=()=>{if(Ye=!0,W){let e=new AbortController;e.abort(),k(e.signal),W=!1}Je.clear(),Ne.clear(),Pe.length=0,Ze(),Se++,at(),U.abort(),T(Error(`Electric resume state referenced an unseen row; a full snapshot is required`))},st=e=>{if(!x()||Ye)return;if(be&&(be=!1,qe(),W=!0,te(),Ge(),Je.clear(),h(),Ie=!0,Le++),!D?.persistence&&!W){Ve.clear(),He=!0;for(let e of E._state.pendingSyncedTransactions){e.truncate&&(Ve.clear(),He=!1);for(let t of e.operations)Ve.set(t.key,t.type!==`delete`)}for(let e of ze)Ae(e)&&Ve.set(E.getKeyFromItem(e.value),e.headers.operation!==`delete`)}let t=null;y.beginMatchGeneration(e);for(let n of e){if(y.observeMatchMessage(n),!x())return;if(zi(n)&&(!Re()||W)&&n.headers.txids?.forEach(e=>Ne.add(e)),Ae(n)){let e=E.getKeyFromItem(n.value),t=n.headers.operation,r=Ve.get(e)??(He&&E._state.syncedData.has(e));if(t===`update`&&!r){if(ye&&!Ie){ot();return}if(!_e)continue}We(e,t!==`delete`),t!==`update`&&Be.delete(e)}if(Ae(n)){let e=n.headers.schema;if(e&&typeof e==`string`&&(c=e),Re()&&!W){if(n.headers.operation===`update`){let e=E.getKeyFromItem(n.value),t=Be.get(e);t&&(ze.push(t),Be.delete(e))}ze.push(n)}else W||=(qe(),!0),et(n)}else Pi(n)?(!Re()||W)&&Pe.push(Ii(n)):Mi(n)?t=`up-to-date`:Fi(n)?t!==`up-to-date`&&(t=`subset-end`):Ci(n)?Re()&&!W?ze.push(n):W=_(n.headers.patterns,qe,S,W,e=>{We(e,!1),Je.delete(e)}):wi(n)?Re()&&!W?ze.push(n):v(n.headers.patterns):Ni(n)&&(Fe&&me(),J(`${o?`[${o}] `:``}Received must-refetch message, starting transaction with truncate`),Ze(),W||=(qe(),!0),te(),h(),Je.clear(),Ge(),Ie=!0,Le++,tt?.reset(),t=null,Fe=!1,ze.length=0,Be.clear())}if(!(R&&!z&&Ie&&t===`subset-end`)&&t!==null){let e=!0,n=Re(),r=Ie&&t===`up-to-date`,i=Le;if(Re()&&t===`up-to-date`&&!W){J(`${o?`[${o}] `:``}Progressive mode: Performing atomic swap with ${ze.length} buffered messages`),qe(),te(),h(),Je.clear();for(let e of ze)Ae(e)?(et(e),zi(e)&&e.headers.txids?.forEach(e=>Ne.add(e))):Pi(e)?Pe.push(Ii(e)):Ci(e)?_(e.headers.patterns,ee,S,!0,e=>{We(e,!1),Je.delete(e)}):wi(e)&&v(e.headers.patterns);Xe(),e=Ke(),ze.length=0,Be.clear(),J(`${o?`[${o}] `:``}Progressive mode: Atomic swap complete, now in normal sync mode`)}else W?((!Ie||r)&&Xe(),e=Ke(),W=!1):t===`up-to-date`&&D&&(qe(),Xe(),e=Ke());let a=Se,s=p(e),c=t===`up-to-date`&&E.status===`loading`;if(t===`up-to-date`&&H(e),s===!0?Ce(n,a):c?(Ee=!0,s.then(()=>ke(n),e=>ke(n,e))):s.then(()=>Ce(n,a),()=>void 0),e!==!0&&e.then(()=>void 0,e=>{!x()||U.signal.aborted||(Se++,at(),U.abort(),E.status!==`error`&&T(e))}),r){let t=()=>{Le===i&&(Ie=!1)};e===!0?t():e.then(t,()=>void 0)}t===`up-to-date`&&(Fe=!0),Ne.size>0&&J(`${o?`[${o}] `:``}new txids synced from pg %O`,Array.from(Ne)),Pe.forEach(e=>J(`${o?`[${o}] `:``}new snapshot synced from pg %o`,e)),y.publishEvidence(Ne,Pe),Ne.clear(),Pe.length=0,y.commitMatches()}};return at=Me.subscribe(e=>{if(!rt){it.push([...e]);return}st(e)},e=>{fe(e),x()&&!U.signal.aborted&&E.status===`loading`&&Oe(e)}),!rt&&nt&&nt.then(()=>{U.signal.aborted||(rt=!0,it.splice(0).forEach(st))},e=>{U.signal.aborted||(it.length=0,Ye=!0,fe(e),Ze(),Se++,at(),U.abort(),T(e))}),{loadSubset:tt?.loadSubset,cleanup:()=>{if(De=!0,!U.signal.aborted&&!Te&&(we=!0),n.signal?.removeEventListener(`abort`,je),at(),U.abort(),W){W=!1;let e=new AbortController;e.abort();let t=k(e.signal);t!==!0&&t.catch(()=>void 0)}it.length=0,tt?.reset(),y.retire(b)}}};return{getSyncMetadata:()=>({relation:n.params?.table?[c||`public`,n.params.table]:void 0}),sync:n=>{if(a!==`on-demand`||!n.metadata?.persistence?.managedCacheGeneration)return f(n);let r=f(n),i,o=new Promise(e=>{i=e}),s,c,l=0,u=!1,d=!1,p=()=>d,m=()=>{if(u)return Promise.resolve();u=!0;try{return Promise.resolve(r.cleanup())}catch(e){return Promise.reject(e)}},h=e=>{let t=e.catch(e=>{throw c={error:e},e}).finally(()=>{s===t&&(s=void 0)});return s=t,t},g=e=>{p()||e!==l||(r=f(n,!0),u=!1,o=new Promise(e=>{i=e}))};return{loadSubset:async e=>{for(;!p();){if(c)throw c.error;if(e.signal?.aborted)throw e.signal.reason??new t;let n=r,i=o,a=n.loadSubset?.(e)??!0;if(await Promise.race([Promise.resolve(a).then(()=>`settled`),i.then(()=>`retired`)])===`settled`)return;s&&await Vi(s,e.signal)}if(c)throw c.error},restartAfterScopedRecovery:e=>{if(p())return Promise.resolve();if(c)return Promise.reject(c.error);let t=++l;i();let n=m();if(s){let r=s;return h((async()=>{await Promise.all([r,n]),await e,g(t)})())}return h((async()=>{await n,await e,g(t)})())},cleanup:async()=>{d=!0,i();try{await s}catch(t){if(!(t instanceof e))throw t}await m()}}}}}var Ki=`http://localhost:4000`;async function qi(e,t){let n=await fetch(`${Ki}/api/${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(`API error: ${n.status}`);return n.json()}async function Ji(e,t){let n=await fetch(`${Ki}/api/${e}/${t}`,{method:`DELETE`});if(!n.ok)throw Error(`API error: ${n.status}`);return n.json()}async function Yi(e,t,n){let r=await fetch(`${Ki}/api/${e}/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok)throw Error(`API error: ${r.status}`);return r.json()}async function Xi(e){let t=await fetch(`${Ki}/api/lists/create`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(`API error: ${t.status}`);return t.json()}async function Zi(e){let t=await fetch(`${Ki}/api/lists/${e}/delete`,{method:`DELETE`});if(!t.ok)throw Error(`API error: ${t.status}`);return t.json()}async function Qi(e,t){let n=await fetch(`${Ki}/api/lists/${e}/update`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(`API error: ${n.status}`);return n.json()}async function $i(e){let t=await fetch(`${Ki}/api/repos/${e}/unstar`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(!t.ok)throw Error(`API error: ${t.status}`);return t.json()}async function ea(e,t){let n=await fetch(`${Ki}/api/lists/${e}/add-repo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(`API error: ${n.status}`);return n.json()}async function ta(e,t){let n=await fetch(`${Ki}/api/lists/${e}/remove-repo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({repo_id:t})});if(!n.ok)throw Error(`API error: ${n.status}`);return n.json()}var na=`local`,ra=na===`demo`,ia=(ra?Object.values(Object.assign({}))[0]:void 0)?.user??null;async function aa(e,t,n){let r=await fetch(`/api/local/${t}`,{method:e,headers:{"Content-Type":`application/json`},body:e===`GET`?void 0:JSON.stringify(n)}),i=await r.json();if(!r.ok)throw Error(i.error??`GitHub request failed (${r.status}).`);return i}var oa={importStars:()=>aa(`POST`,`import`,{}),scoreHealth:e=>aa(`POST`,`health`,e),createList:e=>aa(`POST`,`lists`,e),updateList:(e,t)=>aa(`PATCH`,`lists/${encodeURIComponent(e)}`,t),deleteList:e=>aa(`DELETE`,`lists/${encodeURIComponent(e)}`,{}),changeMembership:e=>aa(`POST`,`membership`,e),unstar:e=>aa(`POST`,`unstar`,e),listBackups:()=>aa(`GET`,`backups`,void 0),backUpNow:e=>aa(`POST`,`backups`,e),readBackup:e=>aa(`GET`,`backups/${encodeURIComponent(e)}`,void 0),uploadBackup:e=>aa(`POST`,`backups/upload`,e),planRestore:e=>aa(`POST`,`restore/plan`,e),applyRestore:e=>aa(`POST`,`restore/apply`,e)},sa=`modulepreload`,ca=function(e){return`/`+e},la={},ua=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=ca(t,n),t in la)return;la[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:sa,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},da=`http://localhost:4000`;function fa(e){return new URL(`${da}/api/electric/${e}`,window.location.origin).toString()}var pa=await ma();async function ma(){let e=await ua(()=>import(`./esm-hHQKpih6.js`),__vite__mapDeps([0,1]));return{persistence:e.createBrowserWASQLitePersistence({database:await e.openBrowserWASQLiteOPFSDatabase({databaseName:`stars-organizer.sqlite`}),coordinator:new e.BrowserCollectionCoordinator({dbName:`stars-organizer`})}),persistedCollectionOptions:e.persistedCollectionOptions}}var ha=1;function ga(e,t){let n=e=>e.id;if(pa){let r=t.local;return pa.persistedCollectionOptions({id:e,getKey:n,persistence:pa.persistence,schemaVersion:ha,onInsert:r.insert&&(async({transaction:e})=>{for(let t of e.mutations)await r.insert(t.modified,e)}),onUpdate:r.update&&(async({transaction:e})=>{for(let t of e.mutations)await r.update(t.original,t.changes)}),onDelete:r.delete&&(async({transaction:e})=>{for(let t of e.mutations)await r.delete(t.original,e)})})}let{server:r}=t;return Wi({id:e,shapeOptions:{url:fa(e)},getKey:n,onInsert:r.insert&&(async({transaction:e,collection:t})=>{for(let n of e.mutations)await t.utils.awaitTxId((await r.insert(n.modified)).txid)}),onUpdate:r.update&&(async({transaction:e,collection:t})=>{for(let n of e.mutations)await t.utils.awaitTxId((await r.update(n.original,n.changes)).txid)}),onDelete:r.delete&&(async({transaction:e,collection:t})=>{for(let n of e.mutations)await t.utils.awaitTxId((await r.delete(n.original)).txid)})})}var _a=u(ga(`repos`,{server:{insert:e=>qi(`repos`,e),update:(e,t)=>Yi(`repos`,e.id,t),delete:e=>$i(e.id)},local:{delete:async(e,t)=>{await oa.unstar({owner:e.owner,name:e.name}),Ca(t,()=>wa(ya,t=>t.repo_id===e.id)),Ca(t,()=>wa(xa,t=>t.repo_id===e.id))}}})),va=u(ga(`lists`,{server:{insert:e=>Xi({name:e.name,description:e.description}),update:(e,t)=>Qi(e.id,t),delete:e=>Zi(e.id)},local:{insert:async(e,t)=>{let{githubListId:n}=await oa.createList({name:e.name,description:e.description??null});Ca(t,()=>va.update(e.id,e=>{e.github_list_id=n}))},update:async(e,t)=>{e.github_list_id&&await oa.updateList(e.github_list_id,{name:t.name,description:t.description})},delete:async(e,t)=>{e.github_list_id&&await oa.deleteList(e.github_list_id),Ca(t,()=>wa(ya,t=>t.list_id===e.id))}}})),ya=u(ga(`list_items`,{server:{insert:e=>ea(e.list_id,{repo_id:e.repo_id}),delete:e=>ta(e.list_id,e.repo_id)},local:{insert:e=>Ta(e,`add`),delete:e=>Ta(e,`remove`)}})),ba=u(ga(`tags`,{server:{insert:e=>qi(`tags`,e),delete:e=>Ji(`tags`,e.id)},local:{}})),xa=u(ga(`repo_tags`,{server:{insert:e=>qi(`repo_tags`,e),delete:e=>Ji(`repo_tags`,e.id)},local:{}}));async function Sa(e){let t=i({mutationFn:async({transaction:e})=>{for(let t of[_a,va,ya,ba,xa])await t.utils.acceptMutations(e)}});t.mutate(e),await t.isPersisted.promise}function Ca(e,t){e.isPersisted.promise.then(()=>Sa(t))}function wa(e,t){let n=e.toArray.filter(t).map(e=>e.id);n.length>0&&e.delete(n)}async function Ta(e,t){let n=_a.get(e.repo_id),r=va.get(e.list_id)?.github_list_id;if(n?.node_id){if(!r)throw Error(`That List is still being created on GitHub. Try again in a moment.`);await oa.changeMembership({repoNodeId:n.node_id,repoGithubId:n.github_id,githubListId:r,change:t})}}var Y=S(w(),1),Ea=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Da=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Oa=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),ka=e=>{let t=Oa(e);return t.charAt(0).toUpperCase()+t.slice(1)},Aa={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`},ja=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},Ma=(0,Y.createContext)({}),Na=()=>(0,Y.useContext)(Ma),Pa=(0,Y.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=Na()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,Y.createElement)(`svg`,{ref:c,...Aa,width:t??l??Aa.width,height:t??l??Aa.height,stroke:e??f,strokeWidth:m,className:Ea(`lucide`,p,i),...!a&&!ja(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,Y.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),Fa=(e,t)=>{let n=(0,Y.forwardRef)(({className:n,...r},i)=>(0,Y.createElement)(Pa,{ref:i,iconNode:t,className:Ea(`lucide-${Da(ka(e))}`,`lucide-${e}`,n),...r}));return n.displayName=ka(e),n};function Ia(){return typeof window<`u`}function La(e){return Ba(e)?(e.nodeName||``).toLowerCase():`#document`}function Ra(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function za(e){return((Ba(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Ba(e){return Ia()?e instanceof Node||e instanceof Ra(e).Node:!1}function Va(e){return Ia()?e instanceof Element||e instanceof Ra(e).Element:!1}function Ha(e){return Ia()?e instanceof HTMLElement||e instanceof Ra(e).HTMLElement:!1}function Ua(e){return!Ia()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Ra(e).ShadowRoot}function Wa(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=to(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Ga(e){return/^(table|td|th)$/.test(La(e))}function Ka(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var qa=/transform|translate|scale|rotate|perspective|filter/,Ja=/paint|layout|strict|content/,Ya=e=>!!e&&e!==`none`,Xa;function Za(e){let t=Va(e)?to(e):e;return Ya(t.transform)||Ya(t.translate)||Ya(t.scale)||Ya(t.rotate)||Ya(t.perspective)||!$a()&&(Ya(t.backdropFilter)||Ya(t.filter))||qa.test(t.willChange||``)||Ja.test(t.contain||``)}function Qa(e){let t=ro(e);for(;Ha(t)&&!eo(t);){if(Za(t))return t;if(Ka(t))return null;t=ro(t)}return null}function $a(){return Xa??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Xa}function eo(e){return/^(html|body|#document)$/.test(La(e))}function to(e){return Ra(e).getComputedStyle(e)}function no(e){return Va(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ro(e){if(La(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Ua(e)&&e.host||za(e);return Ua(t)?t.host:t}function io(e){let t=ro(e);return eo(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ha(t)&&Wa(t)?t:io(t)}function ao(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=io(e),i=r===e.ownerDocument?.body,a=Ra(r);if(i){let e=oo(a);return t.concat(a,a.visualViewport||[],Wa(r)?r:[],e&&n?ao(e):[])}else return t.concat(r,ao(r,[],n))}function oo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}var so={};function co(e,t){let n=Y.useRef(so);return n.current===so&&(n.current=e(t)),n}var lo=Y[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],uo=lo&&lo!==Y.useLayoutEffect?lo:e=>e();function fo(e){let t=co(po).current;return t.next=e,uo(t.effect),t.trampoline}function po(){let e={next:void 0,callback:mo,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function mo(){}var ho={...Y},go=typeof document<`u`?Y.useLayoutEffect:()=>{};function _o(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}var vo={};function yo(e,t,n,r,i){if(!n&&!r&&!i&&!e)return xo(t);let a=xo(e);return t&&(a=So(a,t)),n&&(a=So(a,n)),r&&(a=So(a,r)),i&&(a=So(a,i)),a}function bo(e){if(e.length===0)return vo;if(e.length===1)return xo(e[0]);let t=xo(e[0]);for(let n=1;n<e.length;n+=1)t=So(t,e[n]);return t}function xo(e){return Eo(e)?{...Do(e,vo)}:Co(e)}function So(e,t){return Eo(t)?Do(t,e):wo(e,t)}function Co(e){let t={...e};for(let e in t){let n=t[e];To(e,n)&&(t[e]=ko(n))}return t}function wo(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=_o(e.style,r);break;case`className`:e[n]=jo(e.className,r);break;default:To(n,r)?e[n]=Oo(e[n],r):e[n]=r}}return e}function To(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Eo(e){return typeof e==`function`}function Do(e,t){return Eo(e)?e(t):e??vo}function Oo(e,t){return t?e?(...n)=>{let r=n[0];if(Mo(r)){let i=r;Ao(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:ko(t):e}function ko(e){return e&&((...t)=>{let n=t[0];return Mo(n)&&Ao(n),e(...t)})}function Ao(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function jo(e,t){return t?e?t+` `+e:t:e}function Mo(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function No(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var Po=No(`https://base-ui.com/production-error`,`Base UI`),Fo=Y.createContext(void 0);function Io(e=!1){let t=Y.useContext(Fo);if(t===void 0&&!e)throw Error(Po(16));return t}function Lo(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:Y.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function Ro(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=Y.useRef(null),s=Io(!0),c=a??s!==void 0,{props:l}=Lo({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),u=Y.useCallback(()=>{let e=o.current;zo(e)&&c&&t&&l.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,l.disabled,c]);return go(u,[u]),{getButtonProps:Y.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...u}=e;return yo({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Ao(e),o?.(e),e.baseUIHandlerPrevented))return;let r=e.target===e.currentTarget,a=e.currentTarget,s=zo(a),l=!i&&Bo(a),u=r&&(i?s:!l),d=e.key===`Enter`,f=e.key===` `,p=a.getAttribute(`role`),m=p?.startsWith(`menuitem`)||p===`option`||p===`gridcell`;if(r&&c&&f){if(e.defaultPrevented&&m)return;e.preventDefault(),l||i&&s?(a.click(),e.preventBaseUIHandler()):u&&(n?.(e),e.preventBaseUIHandler());return}u&&(!i&&(f||d)&&e.preventDefault(),!i&&d&&n?.(e))},onKeyUp(e){if(!t){if(Ao(e),a?.(e),e.target===e.currentTarget&&i&&c&&zo(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&e.key===` `&&n?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?void 0:{role:`button`},l,u)},[t,l,c,i]),buttonRef:fo(e=>{o.current=e,u()})}}function zo(e){return Ha(e)&&e.tagName===`BUTTON`}function Bo(e){return!!(e?.tagName===`A`&&e?.href)}function Vo(e,t,n,r){let i=co(Uo).current;return Wo(i,e,t,n,r)&&Ko(i,[e,t,n,r]),i.callback}function Ho(e){let t=co(Uo).current;return Go(t,e)&&Ko(t,e),t.callback}function Uo(){return{callback:null,cleanup:null,refs:[]}}function Wo(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Go(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Ko(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var qo=19;function Jo(e){return qo>=e}function Yo(e){if(!Y.isValidElement(e))return null;let t=e,n=t.props;return(Jo(19)?n?.ref:t.ref)??null}function Xo(){}var Zo=Object.freeze([]),Qo=Object.freeze({});function $o(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function es(e,t){return typeof e==`function`?e(t):e}function ts(e,t){return typeof e==`function`?e(t):e}function ns(e,t,n={}){let r=t.render,i=rs(t,n);return n.enabled===!1?null:os(e,r,i,n.state??Qo)}function rs(e,t={}){let{className:n,style:r,render:i}=e,{state:a=Qo,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?es(n,a):void 0,d=l?ts(r,a):void 0,f=l?$o(a,c):Qo,p=l&&s?is(s):void 0,m=l?_o(f,p)??{}:Qo;return typeof document<`u`&&(l?Array.isArray(o)?m.ref=Ho([m.ref,Yo(i),...o]):m.ref=Vo(m.ref,Yo(i),o):Vo(null,null)),l?(u!==void 0&&(m.className=jo(m.className,u)),d!==void 0&&(m.style=_o(m.style,d)),m):Qo}function is(e){return Array.isArray(e)?bo(e):yo(void 0,e)}var as=Symbol.for(`react.lazy`);function os(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=yo(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===as&&(i=Y.Children.toArray(t)[0]),Y.cloneElement(i,e)}if(e&&typeof e==`string`)return ss(e,n);throw Error(Po(8))}function ss(e,t){return e===`button`?(0,Y.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,Y.createElement)(`img`,{alt:``,...t,key:t.key}):Y.createElement(e,t)}var cs=Y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,focusableWhenDisabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{getButtonProps:l,buttonRef:u}=Ro({disabled:i,focusableWhenDisabled:a,native:o});return ns(`button`,e,{state:{disabled:i},ref:[t,u],props:[c,l]})});function ls(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=ls(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function us(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=ls(e))&&(r&&(r+=` `),r+=t);return r}var ds=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,fs=us,ps=(e,t)=>n=>{if(t?.variants==null)return fs(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=ds(t)||ds(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return fs(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},ms=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},hs=(e,t)=>({classGroupId:e,validator:t}),gs=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),_s=`-`,vs=[],ys=`arbitrary..`,bs=e=>{let t=Cs(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Ss(e);let n=e.split(_s);return xs(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?ms(i,t):t:i||vs}return n[e]||vs}}},xs=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=xs(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(_s):e.slice(t).join(_s),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Ss=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?ys+r:void 0})(),Cs=e=>{let{theme:t,classGroups:n}=e;return ws(n,t)},ws=(e,t)=>{let n=gs();for(let r in e){let i=e[r];Ts(i,n,r,t)}return n},Ts=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Es(i,t,n,r)}},Es=(e,t,n,r)=>{if(typeof e==`string`){Ds(e,t,n);return}if(typeof e==`function`){Os(e,t,n,r);return}ks(e,t,n,r)},Ds=(e,t,n)=>{let r=e===``?t:As(t,e);r.classGroupId=n},Os=(e,t,n,r)=>{if(js(e)){Ts(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(hs(n,e))},ks=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Ts(o,As(t,a),n,r)}},As=(e,t)=>{let n=e,r=t.split(_s),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=gs(),n.nextPart.set(t,i)),n=i}return n},js=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Ms=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Ns=`!`,Ps=`:`,Fs=[],Is=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Ls=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===Ps){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Ns)?(c=s.slice(0,-1),l=!0):s.startsWith(Ns)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return Is(t,l,c,u)};if(t){let e=t+Ps,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Is(Fs,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},Rs=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},zs=e=>({cache:Ms(e.cacheSize),parseClassName:Ls(e),sortModifiers:Rs(e),...bs(e)}),Bs=/\s+/,Vs=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(Bs),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+Ns:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},Hs=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=Us(n))&&(i&&(i+=` `),i+=r);return i},Us=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Us(e[r]))&&(n&&(n+=` `),n+=t);return n},Ws=(e,...t)=>{let n,r,i,a,o=o=>(n=zs(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=Vs(e,n);return i(e,a),a};return a=o,(...e)=>a(Hs(...e))},Gs=[],X=e=>{let t=t=>t[e]||Gs;return t.isThemeGetter=!0,t},Ks=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,qs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Js=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ys=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Xs=/\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$/,Zs=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Qs=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,$s=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ec=e=>Js.test(e),Z=e=>!!e&&!Number.isNaN(Number(e)),tc=e=>!!e&&Number.isInteger(Number(e)),nc=e=>e.endsWith(`%`)&&Z(e.slice(0,-1)),rc=e=>Ys.test(e),ic=()=>!0,ac=e=>Xs.test(e)&&!Zs.test(e),oc=()=>!1,sc=e=>Qs.test(e),cc=e=>$s.test(e),lc=e=>!Q(e)&&!$(e),uc=e=>Tc(e,kc,oc),Q=e=>Ks.test(e),dc=e=>Tc(e,Ac,ac),fc=e=>Tc(e,jc,Z),pc=e=>Tc(e,Nc,ic),mc=e=>Tc(e,Mc,oc),hc=e=>Tc(e,Dc,oc),gc=e=>Tc(e,Oc,cc),_c=e=>Tc(e,Pc,sc),$=e=>qs.test(e),vc=e=>Ec(e,Ac),yc=e=>Ec(e,Mc),bc=e=>Ec(e,Dc),xc=e=>Ec(e,kc),Sc=e=>Ec(e,Oc),Cc=e=>Ec(e,Pc,!0),wc=e=>Ec(e,Nc,!0),Tc=(e,t,n)=>{let r=Ks.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Ec=(e,t,n=!1)=>{let r=qs.exec(e);return r?r[1]?t(r[1]):n:!1},Dc=e=>e===`position`||e===`percentage`,Oc=e=>e===`image`||e===`url`,kc=e=>e===`length`||e===`size`||e===`bg-size`,Ac=e=>e===`length`,jc=e=>e===`number`,Mc=e=>e===`family-name`,Nc=e=>e===`number`||e===`weight`,Pc=e=>e===`shadow`,Fc=Ws(()=>{let e=X(`color`),t=X(`font`),n=X(`text`),r=X(`font-weight`),i=X(`tracking`),a=X(`leading`),o=X(`breakpoint`),s=X(`container`),c=X(`spacing`),l=X(`radius`),u=X(`shadow`),d=X(`inset-shadow`),f=X(`text-shadow`),p=X(`drop-shadow`),m=X(`blur`),h=X(`perspective`),g=X(`aspect`),_=X(`ease`),v=X(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],ee=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],S=()=>[`auto`,`contain`,`none`],C=()=>[$,Q,c],w=()=>[ec,`full`,`auto`,...C()],T=()=>[tc,`none`,`subgrid`,$,Q],te=()=>[`auto`,{span:[`full`,tc,$,Q]},tc,$,Q],E=()=>[tc,`auto`,$,Q],D=()=>[`auto`,`min`,`max`,`fr`,$,Q],ne=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],O=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],k=()=>[`auto`,...C()],A=()=>[ec,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...C()],j=()=>[ec,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...C()],re=()=>[ec,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...C()],M=()=>[e,$,Q],ie=()=>[...b(),bc,hc,{position:[$,Q]}],ae=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],oe=()=>[`auto`,`cover`,`contain`,xc,uc,{size:[$,Q]}],se=()=>[nc,vc,dc],N=()=>[``,`none`,`full`,l,$,Q],P=()=>[``,Z,vc,dc],ce=()=>[`solid`,`dashed`,`dotted`,`double`],F=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],I=()=>[Z,nc,bc,hc],L=()=>[``,`none`,m,$,Q],le=()=>[`none`,Z,$,Q],ue=()=>[`none`,Z,$,Q],R=()=>[Z,$,Q],z=()=>[ec,`full`,...C()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[rc],breakpoint:[rc],color:[ic],container:[rc],"drop-shadow":[rc],ease:[`in`,`out`,`in-out`],font:[lc],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[rc],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[rc],shadow:[rc],spacing:[`px`,Z],text:[rc],"text-shadow":[rc],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,ec,Q,$,g]}],container:[`container`],columns:[{columns:[Z,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"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:x()}],overflow:[{overflow:ee()}],"overflow-x":[{"overflow-x":ee()}],"overflow-y":[{"overflow-y":ee()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:w()}],"inset-x":[{"inset-x":w()}],"inset-y":[{"inset-y":w()}],start:[{"inset-s":w(),start:w()}],end:[{"inset-e":w(),end:w()}],"inset-bs":[{"inset-bs":w()}],"inset-be":[{"inset-be":w()}],top:[{top:w()}],right:[{right:w()}],bottom:[{bottom:w()}],left:[{left:w()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[tc,`auto`,$,Q]}],basis:[{basis:[ec,`full`,`auto`,s,...C()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Z,ec,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,Z,$,Q]}],shrink:[{shrink:[``,Z,$,Q]}],order:[{order:[tc,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":T()}],"col-start-end":[{col:te()}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":T()}],"row-start-end":[{row:te()}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...ne(),`normal`]}],"justify-items":[{"justify-items":[...O(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...O()]}],"align-content":[{content:[`normal`,...ne()]}],"align-items":[{items:[...O(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...O(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ne()}],"place-items":[{"place-items":[...O(),`baseline`]}],"place-self":[{"place-self":[`auto`,...O()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pbs:[{pbs:C()}],pbe:[{pbe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:k()}],mx:[{mx:k()}],my:[{my:k()}],ms:[{ms:k()}],me:[{me:k()}],mbs:[{mbs:k()}],mbe:[{mbe:k()}],mt:[{mt:k()}],mr:[{mr:k()}],mb:[{mb:k()}],ml:[{ml:k()}],"space-x":[{"space-x":C()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":C()}],"space-y-reverse":[`space-y-reverse`],size:[{size:A()}],"inline-size":[{inline:[`auto`,...j()]}],"min-inline-size":[{"min-inline":[`auto`,...j()]}],"max-inline-size":[{"max-inline":[`none`,...j()]}],"block-size":[{block:[`auto`,...re()]}],"min-block-size":[{"min-block":[`auto`,...re()]}],"max-block-size":[{"max-block":[`none`,...re()]}],w:[{w:[s,`screen`,...A()]}],"min-w":[{"min-w":[s,`screen`,`none`,...A()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...A()]}],h:[{h:[`screen`,`lh`,...A()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...A()]}],"max-h":[{"max-h":[`screen`,`lh`,...A()]}],"font-size":[{text:[`base`,n,vc,dc]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,wc,pc]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,nc,Q]}],"font-family":[{font:[yc,mc,t]}],"font-features":[{"font-features":[Q]}],"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:[i,$,Q]}],"line-clamp":[{"line-clamp":[Z,`none`,$,fc]}],leading:[{leading:[a,...C()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...ce(),`wavy`]}],"text-decoration-thickness":[{decoration:[Z,`from-font`,`auto`,$,dc]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[Z,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:C()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],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`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:ae()}],"bg-size":[{bg:oe()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},tc,$,Q],radial:[``,$,Q],conic:[tc,$,Q]},Sc,gc]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:se()}],"gradient-via-pos":[{via:se()}],"gradient-to-pos":[{to:se()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:N()}],"rounded-s":[{"rounded-s":N()}],"rounded-e":[{"rounded-e":N()}],"rounded-t":[{"rounded-t":N()}],"rounded-r":[{"rounded-r":N()}],"rounded-b":[{"rounded-b":N()}],"rounded-l":[{"rounded-l":N()}],"rounded-ss":[{"rounded-ss":N()}],"rounded-se":[{"rounded-se":N()}],"rounded-ee":[{"rounded-ee":N()}],"rounded-es":[{"rounded-es":N()}],"rounded-tl":[{"rounded-tl":N()}],"rounded-tr":[{"rounded-tr":N()}],"rounded-br":[{"rounded-br":N()}],"rounded-bl":[{"rounded-bl":N()}],"border-w":[{border:P()}],"border-w-x":[{"border-x":P()}],"border-w-y":[{"border-y":P()}],"border-w-s":[{"border-s":P()}],"border-w-e":[{"border-e":P()}],"border-w-bs":[{"border-bs":P()}],"border-w-be":[{"border-be":P()}],"border-w-t":[{"border-t":P()}],"border-w-r":[{"border-r":P()}],"border-w-b":[{"border-b":P()}],"border-w-l":[{"border-l":P()}],"divide-x":[{"divide-x":P()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":P()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...ce(),`hidden`,`none`]}],"divide-style":[{divide:[...ce(),`hidden`,`none`]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...ce(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Z,$,Q]}],"outline-w":[{outline:[``,Z,vc,dc]}],"outline-color":[{outline:M()}],shadow:[{shadow:[``,`none`,u,Cc,_c]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":[`none`,d,Cc,_c]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:P()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[Z,dc]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":[`none`,f,Cc,_c]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[Z,$,Q]}],"mix-blend":[{"mix-blend":[...F(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":F()}],"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":[Z]}],"mask-image-linear-from-pos":[{"mask-linear-from":I()}],"mask-image-linear-to-pos":[{"mask-linear-to":I()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":I()}],"mask-image-t-to-pos":[{"mask-t-to":I()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":I()}],"mask-image-r-to-pos":[{"mask-r-to":I()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":I()}],"mask-image-b-to-pos":[{"mask-b-to":I()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":I()}],"mask-image-l-to-pos":[{"mask-l-to":I()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":I()}],"mask-image-x-to-pos":[{"mask-x-to":I()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":I()}],"mask-image-y-to-pos":[{"mask-y-to":I()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":I()}],"mask-image-radial-to-pos":[{"mask-radial-to":I()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"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":b()}],"mask-image-conic-pos":[{"mask-conic":[Z]}],"mask-image-conic-from-pos":[{"mask-conic-from":I()}],"mask-image-conic-to-pos":[{"mask-conic-to":I()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:ae()}],"mask-size":[{mask:oe()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:L()}],brightness:[{brightness:[Z,$,Q]}],contrast:[{contrast:[Z,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Cc,_c]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:[``,Z,$,Q]}],"hue-rotate":[{"hue-rotate":[Z,$,Q]}],invert:[{invert:[``,Z,$,Q]}],saturate:[{saturate:[Z,$,Q]}],sepia:[{sepia:[``,Z,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":L()}],"backdrop-brightness":[{"backdrop-brightness":[Z,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[Z,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Z,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Z,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,Z,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[Z,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[Z,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,Z,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Z,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[Z,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:le()}],"rotate-x":[{"rotate-x":le()}],"rotate-y":[{"rotate-y":le()}],"rotate-z":[{"rotate-z":le()}],scale:[{scale:ue()}],"scale-x":[{"scale-x":ue()}],"scale-y":[{"scale-y":ue()}],"scale-z":[{"scale-z":ue()}],"scale-3d":[`scale-3d`],skew:[{skew:R()}],"skew-x":[{"skew-x":R()}],"skew-y":[{"skew-y":R()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:z()}],"translate-x":[{"translate-x":z()}],"translate-y":[{"translate-y":z()}],"translate-z":[{"translate-z":z()}],"translate-none":[`translate-none`],accent:[{accent:M()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:M()}],"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`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mbs":[{"scroll-mbs":C()}],"scroll-mbe":[{"scroll-mbe":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pbs":[{"scroll-pbs":C()}],"scroll-pbe":[{"scroll-pbe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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`,$,Q]}],fill:[{fill:[`none`,...M()]}],"stroke-w":[{stroke:[Z,vc,dc,fc]}],stroke:[{stroke:[`none`,...M()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{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`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Ic(...e){return Fc(us(e))}var Lc=D(),Rc=ps(`group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 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 [a]:hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function zc({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,Lc.jsx)(cs,{"data-slot":`button`,className:Ic(Rc({variant:t,size:n,className:e})),...r})}export{te as $,Ha as A,ya as B,La as C,Ra as D,ro as E,Ga as F,ua as G,xa as H,Ka as I,ia as J,oa as K,$a as L,Ba as M,Wa as N,Za as O,Ua as P,D as Q,Fa as R,oo as S,ao as T,ba as U,_a as V,Sa as W,A as X,na as Y,O as Z,fo as _,ns as a,Qa as b,Xo as c,Ro as d,w as et,Io as f,ho as g,go as h,us as i,eo as j,Va as k,Jo as l,yo as m,Ic as n,x as nt,Zo as o,Po as p,ra as q,ps as r,S as rt,Qo as s,zc as t,b as tt,Vo as u,co as v,no as w,za as x,to as y,va as z};
|