agent-message 0.1.0 → 0.1.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 +56 -38
- package/npm/bin/{agent-messenger.mjs → agent-message.mjs} +15 -15
- package/npm/runtime/bin/{agent-messenger-cli-darwin-amd64 → agent-message-cli-darwin-amd64} +0 -0
- package/npm/runtime/bin/{agent-messenger-cli-darwin-arm64 → agent-message-cli-darwin-arm64} +0 -0
- package/npm/runtime/bin/{agent-messenger-server-darwin-amd64 → agent-message-server-darwin-amd64} +0 -0
- package/npm/runtime/bin/{agent-messenger-server-darwin-arm64 → agent-message-server-darwin-arm64} +0 -0
- package/npm/runtime/web-dist/assets/{index-BgmjffS2.js → index-4VmoBZF3.js} +1 -1
- package/npm/runtime/web-dist/index.html +3 -3
- package/npm/runtime/web-dist/manifest.webmanifest +1 -1
- package/npm/runtime/web-dist/sw.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,11 +1,57 @@
|
|
|
1
|
-
# Agent
|
|
1
|
+
# Agent Message
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
```bash
|
|
4
|
+
npm install -g agent-message
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Agent Message is a direct-message stack with three clients:
|
|
4
8
|
- HTTP/SSE server (`server/`)
|
|
5
9
|
- Web app (`web/`)
|
|
6
10
|
- CLI (`cli/`)
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
## Install With npm (macOS)
|
|
13
|
+
|
|
14
|
+
Install the packaged app from npm on macOS (`arm64` and `x64`).
|
|
15
|
+
|
|
16
|
+
The installed `agent-message` command keeps the existing CLI behavior and also adds local stack lifecycle commands:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
agent-message start
|
|
20
|
+
agent-message status
|
|
21
|
+
agent-message stop
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Default ports:
|
|
25
|
+
- API: `127.0.0.1:8080`
|
|
26
|
+
- Web: `127.0.0.1:8788`
|
|
27
|
+
|
|
28
|
+
After `agent-message start`, open `http://127.0.0.1:8788` in your browser.
|
|
29
|
+
The bundled CLI continues to work from the same command:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
agent-message register alice 1234
|
|
33
|
+
agent-message login alice 1234
|
|
34
|
+
agent-message ls
|
|
35
|
+
agent-message open bob
|
|
36
|
+
agent-message send bob "hello"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
You can override the runtime location and ports when needed:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
agent-message start --runtime-dir /tmp/agent-message --api-port 28080 --web-port 28788
|
|
43
|
+
agent-message status --runtime-dir /tmp/agent-message --api-port 28080 --web-port 28788
|
|
44
|
+
agent-message stop --runtime-dir /tmp/agent-message
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
PWA install:
|
|
48
|
+
- Open the deployed web app in Safari on iPhone.
|
|
49
|
+
- Use `Share -> Add to Home Screen`.
|
|
50
|
+
- The app now ships with a web app manifest, service worker, and Apple touch icon so it can be installed like a standalone app.
|
|
51
|
+
|
|
52
|
+
## Run From Source
|
|
53
|
+
|
|
54
|
+
This section covers local development and local production-like testing from a checked-out repository.
|
|
9
55
|
|
|
10
56
|
## Prerequisites
|
|
11
57
|
|
|
@@ -25,7 +71,7 @@ go run .
|
|
|
25
71
|
Default server settings:
|
|
26
72
|
- `SERVER_ADDR=:8080`
|
|
27
73
|
- `DB_DRIVER=sqlite`
|
|
28
|
-
- `SQLITE_DSN=./
|
|
74
|
+
- `SQLITE_DSN=./agent_message.sqlite`
|
|
29
75
|
- `UPLOAD_DIR=./uploads`
|
|
30
76
|
- `CORS_ALLOWED_ORIGINS=*`
|
|
31
77
|
|
|
@@ -46,7 +92,7 @@ This starts:
|
|
|
46
92
|
- `postgres` on `localhost:5432`
|
|
47
93
|
- `server` on `localhost:8080` with:
|
|
48
94
|
- `DB_DRIVER=postgres`
|
|
49
|
-
- `POSTGRES_DSN=postgres://agent:agent@postgres:5432/
|
|
95
|
+
- `POSTGRES_DSN=postgres://agent:agent@postgres:5432/agent_message?sslmode=disable`
|
|
50
96
|
|
|
51
97
|
To stop and remove containers:
|
|
52
98
|
|
|
@@ -95,7 +141,7 @@ From the project root, you can start the SQLite-backed API server and the produc
|
|
|
95
141
|
|
|
96
142
|
This will:
|
|
97
143
|
- build `web/dist`
|
|
98
|
-
- build the Go server binary into `~/.agent-
|
|
144
|
+
- build the Go server binary into `~/.agent-message/bin`
|
|
99
145
|
- start the API on `127.0.0.1:18080`
|
|
100
146
|
- start the local web gateway on `127.0.0.1:8788`
|
|
101
147
|
|
|
@@ -112,29 +158,7 @@ If you also want to start or stop the named tunnel that serves `https://agent.na
|
|
|
112
158
|
./dev-stop --with-tunnel
|
|
113
159
|
```
|
|
114
160
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
The repo now includes a publishable npm package surface for macOS (`arm64` and `x64`). The npm command keeps the existing CLI behavior and also adds local stack lifecycle commands:
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
agent-messenger start
|
|
121
|
-
agent-messenger status
|
|
122
|
-
agent-messenger stop
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
Default npm launcher ports:
|
|
126
|
-
- API: `127.0.0.1:8080`
|
|
127
|
-
- Web: `127.0.0.1:8788`
|
|
128
|
-
|
|
129
|
-
You can override runtime location and ports when needed:
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
agent-messenger start --runtime-dir /tmp/agent-messenger --api-port 28080 --web-port 28788
|
|
133
|
-
agent-messenger status --runtime-dir /tmp/agent-messenger --api-port 28080 --web-port 28788
|
|
134
|
-
agent-messenger stop --runtime-dir /tmp/agent-messenger
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
When publishing, `npm pack` / `npm publish` will run the package `prepack` hook, which:
|
|
161
|
+
When publishing from the repo, `npm pack` / `npm publish` will run the package `prepack` hook, which:
|
|
138
162
|
- builds `web/dist`
|
|
139
163
|
- bundles `deploy/agent_gateway.mjs`
|
|
140
164
|
- cross-compiles macOS `arm64` and `x64` binaries for the Go CLI and API server into `npm/runtime/`
|
|
@@ -145,18 +169,12 @@ You can run the same packaging step manually from the repo root:
|
|
|
145
169
|
npm run prepare:npm-bundle
|
|
146
170
|
```
|
|
147
171
|
|
|
148
|
-
PWA install:
|
|
149
|
-
|
|
150
|
-
- Open the deployed web app in Safari on iPhone.
|
|
151
|
-
- Use `Share -> Add to Home Screen`.
|
|
152
|
-
- The app now ships with a web app manifest, service worker, and Apple touch icon so it can be installed like a standalone app.
|
|
153
|
-
|
|
154
172
|
## Claude Code Skill
|
|
155
173
|
|
|
156
|
-
Install the
|
|
174
|
+
Install the Agent Message CLI skill to give Claude Code full knowledge of this project's CLI commands, flags, and json_render component catalog:
|
|
157
175
|
|
|
158
176
|
```bash
|
|
159
|
-
npx skills add https://github.com/siisee11/agent-
|
|
177
|
+
npx skills add https://github.com/siisee11/agent-message --skill agent-message-cli
|
|
160
178
|
```
|
|
161
179
|
|
|
162
180
|
## CLI Quickstart
|
|
@@ -192,7 +210,7 @@ go run . --server-url http://localhost:8080 unreact 1 👍
|
|
|
192
210
|
go run . --server-url http://localhost:8080 watch bob
|
|
193
211
|
```
|
|
194
212
|
|
|
195
|
-
CLI config is stored at `~/.agent-
|
|
213
|
+
CLI config is stored at `~/.agent-message/config` by default.
|
|
196
214
|
Each successful `login` or `register` also saves a named profile, and `go run . profile switch <username>` swaps the active account locally.
|
|
197
215
|
|
|
198
216
|
## Validation and Constraints (Phase 7)
|
|
@@ -59,15 +59,15 @@ async function main() {
|
|
|
59
59
|
|
|
60
60
|
function printRootUsage() {
|
|
61
61
|
console.error(`Usage:
|
|
62
|
-
agent-
|
|
63
|
-
agent-
|
|
64
|
-
agent-
|
|
65
|
-
agent-
|
|
62
|
+
agent-message start [--runtime-dir <dir>] [--api-host <host>] [--api-port <port>] [--web-host <host>] [--web-port <port>]
|
|
63
|
+
agent-message stop [--runtime-dir <dir>]
|
|
64
|
+
agent-message status [--runtime-dir <dir>] [--api-host <host>] [--api-port <port>] [--web-host <host>] [--web-port <port>]
|
|
65
|
+
agent-message <existing-cli-command> [...args]`)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function parseLifecycleOptions(args) {
|
|
69
69
|
const options = {
|
|
70
|
-
runtimeDir: join(os.homedir(), '.agent-
|
|
70
|
+
runtimeDir: join(os.homedir(), '.agent-message'),
|
|
71
71
|
apiHost: DEFAULT_API_HOST,
|
|
72
72
|
apiPort: DEFAULT_API_PORT,
|
|
73
73
|
webHost: DEFAULT_WEB_HOST,
|
|
@@ -128,8 +128,8 @@ async function ensureBundleReady() {
|
|
|
128
128
|
const requiredPaths = [
|
|
129
129
|
bundleGatewayPath,
|
|
130
130
|
bundleWebDistDir,
|
|
131
|
-
resolveBinaryPath('agent-
|
|
132
|
-
resolveBinaryPath('agent-
|
|
131
|
+
resolveBinaryPath('agent-message-server'),
|
|
132
|
+
resolveBinaryPath('agent-message-cli'),
|
|
133
133
|
]
|
|
134
134
|
|
|
135
135
|
for (const target of requiredPaths) {
|
|
@@ -140,8 +140,8 @@ async function ensureBundleReady() {
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
await access(resolveBinaryPath('agent-
|
|
144
|
-
await access(resolveBinaryPath('agent-
|
|
143
|
+
await access(resolveBinaryPath('agent-message-server'), constants.X_OK)
|
|
144
|
+
await access(resolveBinaryPath('agent-message-cli'), constants.X_OK)
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
function resolveBinaryPath(baseName) {
|
|
@@ -170,7 +170,7 @@ function runtimePaths(runtimeDir) {
|
|
|
170
170
|
gatewayLog: join(runtimeDir, 'logs', 'gateway.log'),
|
|
171
171
|
serverPidfile: join(runtimeDir, 'server.pid'),
|
|
172
172
|
gatewayPidfile: join(runtimeDir, 'gateway.pid'),
|
|
173
|
-
sqlitePath: join(runtimeDir, '
|
|
173
|
+
sqlitePath: join(runtimeDir, 'agent_message.sqlite'),
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -185,7 +185,7 @@ async function startStack(options) {
|
|
|
185
185
|
writeFileSync(paths.serverLog, '')
|
|
186
186
|
writeFileSync(paths.gatewayLog, '')
|
|
187
187
|
|
|
188
|
-
const serverBinary = resolveBinaryPath('agent-
|
|
188
|
+
const serverBinary = resolveBinaryPath('agent-message-server')
|
|
189
189
|
const gatewayChild = { pid: null }
|
|
190
190
|
|
|
191
191
|
try {
|
|
@@ -221,7 +221,7 @@ async function startStack(options) {
|
|
|
221
221
|
throw error
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
console.log('Agent
|
|
224
|
+
console.log('Agent Message is up.')
|
|
225
225
|
console.log(`API: http://${options.apiHost}:${options.apiPort}`)
|
|
226
226
|
console.log(`Web: http://${options.webHost}:${options.webPort}`)
|
|
227
227
|
console.log(`Logs: ${paths.serverLog} ${paths.gatewayLog}`)
|
|
@@ -234,9 +234,9 @@ async function stopStack(options, { quiet }) {
|
|
|
234
234
|
|
|
235
235
|
if (!quiet) {
|
|
236
236
|
if (stoppedServer || stoppedGateway) {
|
|
237
|
-
console.log('Agent
|
|
237
|
+
console.log('Agent Message is stopped.')
|
|
238
238
|
} else {
|
|
239
|
-
console.log('Agent
|
|
239
|
+
console.log('Agent Message is not running.')
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
}
|
|
@@ -258,7 +258,7 @@ async function printStatus(options) {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
function delegateToBundledCli(args) {
|
|
261
|
-
const cliBinary = resolveBinaryPath('agent-
|
|
261
|
+
const cliBinary = resolveBinaryPath('agent-message-cli')
|
|
262
262
|
const result = spawnSync(cliBinary, args, {
|
|
263
263
|
stdio: 'inherit',
|
|
264
264
|
env: process.env,
|
|
Binary file
|
|
Binary file
|
package/npm/runtime/bin/{agent-messenger-server-darwin-amd64 → agent-message-server-darwin-amd64}
RENAMED
|
Binary file
|
package/npm/runtime/bin/{agent-messenger-server-darwin-arm64 → agent-message-server-darwin-arm64}
RENAMED
|
Binary file
|
|
@@ -73,7 +73,7 @@ Error generating stack: `+a.message+`
|
|
|
73
73
|
* LICENSE.md file in the root directory of this source tree.
|
|
74
74
|
*
|
|
75
75
|
* @license MIT
|
|
76
|
-
*/function uu(){return uu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},uu.apply(this,arguments)}function V0(e,t){if(e==null)return{};var n={},a=Object.keys(e),r,i;for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&(n[r]=e[r]);return n}function MT(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function DT(e,t){return e.button===0&&(!t||t==="_self")&&!MT(e)}const kT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],UT=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],LT="6";try{window.__reactRouterVersion=LT}catch{}const $T=p.createContext({isTransitioning:!1}),BT="startTransition",Hp=SE[BT];function ZT(e){let{basename:t,children:n,future:a,window:r}=e,i=p.useRef();i.current==null&&(i.current=$w({window:r,v5Compat:!0}));let l=i.current,[s,o]=p.useState({action:l.action,location:l.location}),{v7_startTransition:u}=a||{},f=p.useCallback(c=>{u&&Hp?Hp(()=>o(c)):o(c)},[o,u]);return p.useLayoutEffect(()=>l.listen(f),[l,f]),p.useEffect(()=>AT(a),[a]),p.createElement(RT,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:l,future:a})}const PT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",qT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Q0=p.forwardRef(function(t,n){let{onClick:a,relative:r,reloadDocument:i,replace:l,state:s,target:o,to:u,preventScrollReset:f,viewTransition:c}=t,d=V0(t,kT),{basename:m}=p.useContext(Kn),_,y=!1;if(typeof u=="string"&&qT.test(u)&&(_=u,PT))try{let g=new URL(window.location.href),b=u.startsWith("//")?new URL(g.protocol+u):new URL(u),w=Qi(b.pathname,m);b.origin===g.origin&&w!=null?u=w+b.search+b.hash:y=!0}catch{}let E=cT(u,{relative:r}),v=VT(u,{replace:l,state:s,target:o,preventScrollReset:f,relative:r,viewTransition:c});function h(g){a&&a(g),g.defaultPrevented||v(g)}return p.createElement("a",uu({},d,{href:_||E,onClick:y||i?a:h,ref:n,target:o}))}),HT=p.forwardRef(function(t,n){let{"aria-current":a="page",caseSensitive:r=!1,className:i="",end:l=!1,style:s,to:o,viewTransition:u,children:f}=t,c=V0(t,UT),d=$u(o,{relative:c.relative}),m=Fa(),_=p.useContext(B0),{navigator:y,basename:E}=p.useContext(Kn),v=_!=null&&QT(d)&&u===!0,h=y.encodeLocation?y.encodeLocation(d).pathname:d.pathname,g=m.pathname,b=_&&_.navigation&&_.navigation.location?_.navigation.location.pathname:null;r||(g=g.toLowerCase(),b=b?b.toLowerCase():null,h=h.toLowerCase()),b&&E&&(b=Qi(b,E)||b);const w=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let C=g===h||!l&&g.startsWith(h)&&g.charAt(w)==="/",O=b!=null&&(b===h||!l&&b.startsWith(h)&&b.charAt(h.length)==="/"),T={isActive:C,isPending:O,isTransitioning:v},R=C?a:void 0,D;typeof i=="function"?D=i(T):D=[i,C?"active":null,O?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let Q=typeof s=="function"?s(T):s;return p.createElement(Q0,uu({},c,{"aria-current":R,className:D,ref:n,style:Q,to:o,viewTransition:u}),typeof f=="function"?f(T):f)});var od;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(od||(od={}));var Gp;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Gp||(Gp={}));function GT(e){let t=p.useContext(Uu);return t||Re(!1),t}function VT(e,t){let{target:n,replace:a,state:r,preventScrollReset:i,relative:l,viewTransition:s}=t===void 0?{}:t,o=As(),u=Fa(),f=$u(e,{relative:l});return p.useCallback(c=>{if(DT(c,n)){c.preventDefault();let d=a!==void 0?a:ou(u)===ou(f);o(e,{replace:d,state:r,preventScrollReset:i,relative:l,viewTransition:s})}},[u,o,f,a,r,n,e,i,l,s])}function QT(e,t){t===void 0&&(t={});let n=p.useContext($T);n==null&&Re(!1);let{basename:a}=GT(od.useViewTransitionState),r=$u(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Qi(n.currentLocation.pathname,a)||n.currentLocation.pathname,l=Qi(n.nextLocation.pathname,a)||n.nextLocation.pathname;return ld(r.pathname,l)!=null||ld(r.pathname,i)!=null}const YT="modulepreload",IT=function(e){return"/"+e},Vp={},FT=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),s=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));r=Promise.allSettled(n.map(o=>{if(o=IT(o),o in Vp)return;Vp[o]=!0;const u=o.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${f}`))return;const c=document.createElement("link");if(c.rel=u?"stylesheet":YT,u||(c.as="script"),c.crossOrigin="",c.href=o,s&&c.setAttribute("nonce",s),document.head.appendChild(c),u)return new Promise((d,m)=>{c.addEventListener("load",d),c.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${o}`)))})}))}function i(l){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=l,window.dispatchEvent(s),!s.defaultPrevented)throw l}return r.then(l=>{for(const s of l||[])s.status==="rejected"&&i(s.reason);return t().catch(i)})};function JT(e={}){const{immediate:t=!1,onNeedRefresh:n,onOfflineReady:a,onRegistered:r,onRegisteredSW:i,onRegisterError:l}=e;let s,o;const u=async(c=!0)=>{await o};async function f(){if("serviceWorker"in navigator){if(s=await FT(async()=>{const{Workbox:c}=await import("./workbox-window.prod.es5-vqzQaGvo.js");return{Workbox:c}},[]).then(({Workbox:c})=>new c("/sw.js",{scope:"/",type:"classic"})).catch(c=>{l==null||l(c)}),!s)return;s.addEventListener("activated",c=>{(c.isUpdate||c.isExternal)&&window.location.reload()}),s.addEventListener("installed",c=>{c.isUpdate||a==null||a()}),s.register({immediate:t}).then(c=>{i?i("/sw.js",c):r==null||r(c)}).catch(c=>{l==null||l(c)})}}return o=f(),u}const XT="text";function Y0(e){return e.kind==="json_render"?"json_render":XT}function KT(e){return e.json_render_spec??null}function $n(e){return{...e,kind:Y0(e)}}function Rh(e){return Y0(e)==="json_render"?{kind:"json_render",textContent:null,jsonRenderSpec:KT(e)}:{kind:"text",textContent:e.content??null,jsonRenderSpec:null}}function WT(e){return{...e,message:$n(e.message)}}function eO(e){return{...e,last_message:e.last_message?$n(e.last_message):void 0}}class Ca extends Error{constructor(n,a,r){super(n);Wa(this,"status");Wa(this,"path");this.name="ApiError",this.status=a,this.path=r}}const tO="";function nO(e){return e.replace(/\/+$/,"")}function aO(e,t){const n=t.startsWith("/")?t:`/${t}`;return e===""?n:`${e}${n}`}function rO(e,t){if(!t)return e;const n=new URLSearchParams;for(const[r,i]of Object.entries(t))i!==void 0&&n.set(r,String(i));const a=n.toString();return a===""?e:`${e}?${a}`}function iO(e){return typeof e=="object"&&e!==null}function lO(e){return"attachment"in e}function sO(e){return"attachmentUrl"in e}class oO{constructor(t={}){Wa(this,"baseUrl");Wa(this,"getToken");Wa(this,"onUnauthorized");Wa(this,"token",null);const n=t.baseUrl??tO;this.baseUrl=nO(n),this.getToken=t.getToken,this.onUnauthorized=t.onUnauthorized}setAuthToken(t){this.token=t}getAuthToken(){return this.getToken?this.getToken()??this.token:this.token}async register(t){return this.requestJSON({method:"POST",path:"/api/auth/register",auth:!1,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async login(t){return this.requestJSON({method:"POST",path:"/api/auth/login",auth:!1,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async logout(){await this.requestVoid({method:"DELETE",path:"/api/auth/logout"})}async getMe(){return this.requestJSON({method:"GET",path:"/api/users/me"})}async searchUsers(t){return this.requestJSON({method:"GET",path:"/api/users",query:{username:t.username,limit:t.limit}})}async listConversations(t={}){return(await this.requestJSON({method:"GET",path:"/api/conversations",query:{limit:t.limit}})).map(eO)}async startConversation(t){return this.requestJSON({method:"POST",path:"/api/conversations",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async getConversation(t){return this.requestJSON({method:"GET",path:`/api/conversations/${encodeURIComponent(t)}`})}async listMessages(t,n={}){return(await this.requestJSON({method:"GET",path:`/api/conversations/${encodeURIComponent(t)}/messages`,query:{before:n.before,limit:n.limit}})).map(WT)}async sendMessage(t,n){const a=`/api/conversations/${encodeURIComponent(t)}/messages`;if(lO(n)){const r=new FormData;return n.content&&n.content.trim()!==""&&r.set("content",n.content),r.set("attachment",n.attachment),this.requestJSON({method:"POST",path:a,body:r}).then($n)}if(sO(n)){const r=new FormData;return n.content&&n.content.trim()!==""&&r.set("content",n.content),r.set("attachment_url",n.attachmentUrl),n.attachmentType&&r.set("attachment_type",n.attachmentType),this.requestJSON({method:"POST",path:a,body:r}).then($n)}return this.requestJSON({method:"POST",path:a,headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n.content})}).then($n)}async editMessage(t,n){return this.requestJSON({method:"PATCH",path:`/api/messages/${encodeURIComponent(t)}`,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then($n)}async deleteMessage(t){return this.requestJSON({method:"DELETE",path:`/api/messages/${encodeURIComponent(t)}`}).then($n)}async toggleReaction(t,n){return this.requestJSON({method:"POST",path:`/api/messages/${encodeURIComponent(t)}/reactions`,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async removeReaction(t,n){return this.requestJSON({method:"DELETE",path:`/api/messages/${encodeURIComponent(t)}/reactions/${encodeURIComponent(n)}`})}async uploadFile(t,n="file"){const a=new FormData;return a.set(n,t),this.requestJSON({method:"POST",path:"/api/upload",body:a})}async requestJSON(t){return await(await this.request(t)).json()}async requestVoid(t){await this.request(t)}async request(t){const n=rO(aO(this.baseUrl,t.path),t.query),a=new Headers(t.headers??{});if(t.auth??!0){const l=this.getAuthToken();l&&a.set("Authorization",`Bearer ${l}`)}const i=await fetch(n,{method:t.method,headers:a,body:t.body});if(i.ok)return i;throw i.status===401&&this.onUnauthorized&&this.onUnauthorized(),await this.toApiError(i,t.path)}async toApiError(t,n){const a=t.headers.get("Content-Type")??"";let r=`Request failed with status ${t.status}`;if(a.includes("application/json"))try{const i=await t.json();iO(i)&&typeof i.error=="string"&&i.error.trim()!==""&&(r=i.error)}catch{}else try{const i=(await t.text()).trim();i!==""&&(r=i)}catch{}return new Ca(r,t.status,n)}}function uO(e={}){return new oO(e)}const nt=uO(),ud="agent_messenger.auth_token",I0=p.createContext(void 0);function cO(){try{return window.localStorage.getItem(ud)}catch{return null}}function Qp(e){try{if(e===null){window.localStorage.removeItem(ud);return}window.localStorage.setItem(ud,e)}catch{}}function fO({children:e}){const[t,n]=p.useState("loading"),[a,r]=p.useState(null),[i,l]=p.useState(null),s=p.useCallback(d=>{nt.setAuthToken(d.token),Qp(d.token),r(d.token),l(d.user),n("authenticated")},[]),o=p.useCallback(()=>{nt.setAuthToken(null),Qp(null),r(null),l(null),n("unauthenticated")},[]);p.useEffect(()=>{const d=cO();if(!d){n("unauthenticated");return}let m=!1;return nt.setAuthToken(d),r(d),nt.getMe().then(_=>{m||(l(_),n("authenticated"))}).catch(()=>{m||o()}),()=>{m=!0}},[o]);const u=p.useCallback(async d=>{const m={username:d.username.trim(),pin:d.pin.trim()};try{const _=await nt.login(m);return s(_),{mode:"login"}}catch(_){if(!(_ instanceof Ca)||_.status!==401)throw _;try{const y=await nt.register(m);return s(y),{mode:"register"}}catch(y){throw y instanceof Ca&&y.status===409?new Ca("invalid credentials",401,"/api/auth/login"):y}}},[s]),f=p.useCallback(async()=>{try{await nt.logout()}catch(d){if(!(d instanceof Ca)||d.status!==401)throw d}finally{o()}},[o]),c=p.useMemo(()=>({status:t,isAuthenticated:t==="authenticated",token:a,user:i,loginWithAutoRegister:u,logout:f}),[u,f,t,a,i]);return S.jsx(I0.Provider,{value:c,children:e})}function Ns(){const e=p.useContext(I0);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Yp="Start a conversation",F0="This message was deleted",Ip="[json-render]";function dO(e){if(e.attachment_type==="image")return"[image]";if(e.attachment_type==="file")return"[file]"}function hO(e){var r;if(!e)return Yp;if(e.deleted)return F0;const t=Rh(e),n=dO(e);if(t.kind==="json_render")return n?`${n} ${Ip}`:Ip;const a=(r=t.textContent)==null?void 0:r.trim();return n&&a?`${n} ${a}`:a||n||Yp}function Oo(e,t){return e.sender_id===t&&!e.deleted}function zc(e,t){return Oo(e,t)?Rh(e).kind==="text":!1}function mO(e){var a;if(e.deleted)return{variant:"deleted",textContent:null,jsonRenderSpec:null};const t=Rh(e);if(t.kind==="json_render")return{variant:"json_render",textContent:null,jsonRenderSpec:t.jsonRenderSpec};const n=(a=t.textContent)==null?void 0:a.trim();return n?{variant:"text",textContent:n,jsonRenderSpec:null}:{variant:"empty",textContent:null,jsonRenderSpec:null}}const pO=vO();function vO(){return"/api/events"}function gO(e){return typeof e=="object"&&e!==null}function yO(e){return e==="message.new"||e==="message.edited"||e==="message.deleted"||e==="reaction.added"||e==="reaction.removed"}function bO(e){let t;try{t=JSON.parse(e)}catch{return null}if(!gO(t))return null;const n=t.type;if(typeof n!="string"||n.trim()==="")return null;const a=t.data;if(!yO(n))return{type:n,data:a};switch(n){case"message.new":return{type:n,data:$n(a)};case"message.edited":return{type:n,data:$n(a)};case"message.deleted":return{type:n,data:a};case"reaction.added":return{type:n,data:a};case"reaction.removed":return{type:n,data:a}}}function SO(e){const{token:t,enabled:n=!0,eventURL:a=pO,onOpen:r,onError:i,onEvent:l,onMessageNew:s,onMessageEdited:o,onMessageDeleted:u,onReactionAdded:f,onReactionRemoved:c}=e,[d,m]=p.useState("idle"),[_,y]=p.useState(null),E=p.useRef(null);return p.useEffect(()=>{var w;if(!n||!t){(w=E.current)==null||w.close(),E.current=null,m("idle"),y(null);return}const v=t.trim();if(v===""){m("idle"),y(null);return}const h=a.includes("?")?`${a}&token=${encodeURIComponent(v)}`:`${a}?token=${encodeURIComponent(v)}`;m("connecting");const g=new EventSource(h);E.current=g;const b=C=>O=>{const T=bO(O.data);T&&(y(T),l==null||l(T),C==null||C(T))};return g.onopen=()=>{m("open"),r==null||r()},g.onerror=()=>{m(g.readyState===EventSource.CLOSED?"closed":"connecting"),i==null||i()},g.addEventListener("message.new",b(s)),g.addEventListener("message.edited",b(o)),g.addEventListener("message.deleted",b(u)),g.addEventListener("reaction.added",b(f)),g.addEventListener("reaction.removed",b(c)),()=>{g.close(),E.current===g&&(E.current=null)}},[n,a,i,l,u,o,s,r,f,c,t]),p.useMemo(()=>({status:d,lastEvent:_}),[_,d])}function J0(e){return{id:e.sender_id,username:"me",created_at:e.created_at}}function X0(e,t){return!e||e.pages.length===0?{pageParams:[void 0],pages:[[t]]}:e.pages.some(a=>a.some(r=>r.message.id===t.message.id))?e:{...e,pages:[[t,...e.pages[0]],...e.pages.slice(1)]}}function _O(e,t){if(!e)return e;let n=!1;const a=e.pages.map(r=>r.map(i=>i.message.id!==t?i:(n=!0,{...i,message:{...i.message,deleted:!0,content:void 0,attachment_url:void 0,attachment_type:void 0}})));return n?{...e,pages:a}:e}function cd(e,t){if(!e)return e;let n=!1;const a=e.pages.map(r=>r.map(i=>i.message.id!==t.id?i:(n=!0,{...i,message:t})));return n?{...e,pages:a}:e}function EO(e,t,n){return t&&e.sender_id===t.id?t:(n==null?void 0:n.participant_a.id)===e.sender_id?n.participant_a:(n==null?void 0:n.participant_b.id)===e.sender_id?n.participant_b:J0(e)}function xO(e,t){const n=e[t.message_id]??[];return n.some(r=>r.emoji===t.emoji&&r.user_id===t.user_id)?e:{...e,[t.message_id]:[...n,t]}}function wO(e,t){const n=e[t.message_id]??[],a=n.filter(r=>!(r.emoji===t.emoji&&r.user_id===t.user_id));if(a.length===n.length)return e;if(a.length===0){const{[t.message_id]:r,...i}=e;return i}return{...e,[t.message_id]:a}}const K0=p.createContext(void 0);function TO({children:e}){const t=Cs(),{isAuthenticated:n,token:a,user:r}=Ns(),[i,l]=p.useState({}),s=p.useCallback(()=>{t.invalidateQueries({queryKey:["conversations"]})},[t]),o=p.useCallback(y=>{const E=["messages",y.conversation_id];if(t.getQueryData(E)!==void 0){const h=t.getQueryData(["conversation",y.conversation_id]);t.setQueryData(E,g=>X0(g,{message:y,sender:EO(y,r,h)}))}s()},[s,t,r]),u=p.useCallback(y=>{t.setQueryData(["messages",y.conversation_id],E=>cd(E,y)),s()},[s,t]),f=p.useCallback(y=>{t.setQueriesData({queryKey:["messages"]},E=>_O(E,y)),s()},[s,t]),c=p.useCallback(y=>{l(E=>xO(E,y))},[]),d=p.useCallback(y=>{l(E=>wO(E,y))},[]);p.useEffect(()=>{a||l({})},[a]);const m=SO({token:a,enabled:!!(n&&a),onMessageNew:({data:y})=>o(y),onMessageEdited:({data:y})=>u(y),onMessageDeleted:({data:y})=>f(y.id),onReactionAdded:({data:y})=>c(y),onReactionRemoved:({data:y})=>d(y)}),_=p.useMemo(()=>({status:m.status,messageReactions:i,applyReactionAdded:c,applyReactionRemoved:d}),[c,d,m.status,i]);return S.jsx(K0.Provider,{value:_,children:e})}function W0(){const e=p.useContext(K0);if(!e)throw new Error("useRealtime must be used within RealtimeProvider");return e}const OO="_page_h90ug_1",CO="_shell_h90ug_11",AO="_header_h90ug_22",NO="_headerTop_h90ug_30",zO="_eyebrow_h90ug_37",RO="_brand_h90ug_45",jO="_headerMeta_h90ug_51",MO="_currentUser_h90ug_59",DO="_statusBadge_h90ug_65",kO="_logoutButton_h90ug_78",UO="_composerSection_h90ug_94",LO="_listSection_h90ug_95",$O="_sectionHeading_h90ug_115",BO="_sectionTitle_h90ug_119",ZO="_sectionCopy_h90ug_125",PO="_searchForm_h90ug_131",qO="_searchInput_h90ug_137",HO="_searchSubmit_h90ug_152",GO="_searchResults_h90ug_168",VO="_searchResultButton_h90ug_176",QO="_searchResultName_h90ug_195",YO="_searchResultAction_h90ug_199",IO="_conversationList_h90ug_204",FO="_conversationItem_h90ug_215",JO="_conversationItemActive_h90ug_231",XO="_conversationMeta_h90ug_237",KO="_conversationName_h90ug_244",WO="_conversationTime_h90ug_249",eC="_conversationPreview_h90ug_254",tC="_conversationId_h90ug_263",nC="_statusText_h90ug_267",aC="_errorMessage_h90ug_273",rC="_emptyState_h90ug_279",iC="_emptyTitle_h90ug_284",lC="_emptyCopy_h90ug_290",K={page:OO,shell:CO,header:AO,headerTop:NO,eyebrow:zO,brand:RO,headerMeta:jO,currentUser:MO,statusBadge:DO,logoutButton:kO,composerSection:UO,listSection:LO,sectionHeading:$O,sectionTitle:BO,sectionCopy:ZO,searchForm:PO,searchInput:qO,searchSubmit:HO,searchResults:GO,searchResultButton:VO,searchResultName:QO,searchResultAction:YO,conversationList:IO,conversationItem:FO,conversationItemActive:JO,conversationMeta:XO,conversationName:KO,conversationTime:WO,conversationPreview:eC,conversationId:tC,statusText:nC,errorMessage:aC,emptyState:rC,emptyTitle:iC,emptyCopy:lC},sC=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function Js(e,t){return e instanceof Ca||e instanceof Error&&e.message.trim()!==""?e.message:t}function oC(e){if(!e)return"";const t=Date.parse(e.created_at);return Number.isNaN(t)?"":sC.format(new Date(t))}function uC(e,t){return e?t?e.filter(n=>n.id!==t):e:[]}function cC(e,t){return e.other_user.id===t}function fC(){const e=As(),t=Cs(),{user:n,logout:a}=Ns(),r=W0(),[i,l]=p.useState(""),[s,o]=p.useState(null),u=i.trim(),f=rd({queryKey:["conversations"],queryFn:()=>nt.listConversations()}),c=rd({queryKey:["users","search",u],queryFn:()=>nt.searchUsers({username:u,limit:8}),enabled:u.length>0}),d=p.useMemo(()=>uC(c.data,n==null?void 0:n.id),[n==null?void 0:n.id,c.data]),m=Hl({mutationFn:b=>nt.startConversation({username:b}),onSuccess:async b=>{o(null),l(""),await t.invalidateQueries({queryKey:["conversations"]}),e(`/dm/${b.conversation.id}`)},onError:b=>{o(Js(b,"Failed to start the conversation."))}}),_=Hl({mutationFn:()=>a(),onSuccess:()=>{e("/login",{replace:!0})},onError:b=>{o(Js(b,"Failed to sign out."))}});function y(b){b.preventDefault();const w=u;w!==""&&(o(null),m.mutate(w))}function E(b){o(null),m.mutate(b)}function v(b){const w=hO(b.last_message),C=oC(b.last_message),O=b.conversation.id;return S.jsxs(HT,{className:({isActive:T})=>`${K.conversationItem}${T?` ${K.conversationItemActive}`:""}`,to:`/dm/${b.conversation.id}`,children:[S.jsxs("div",{className:K.conversationMeta,children:[S.jsx("span",{className:K.conversationName,children:b.other_user.username}),S.jsx("span",{className:K.conversationTime,children:C})]}),S.jsx("p",{className:K.conversationPreview,title:w,children:w}),S.jsx("span",{className:K.conversationId,children:O})]},b.conversation.id)}const h=f.data??[],g=u.length>0;return S.jsx("main",{className:K.page,children:S.jsxs("section",{className:K.shell,children:[S.jsxs("header",{className:K.header,children:[S.jsxs("div",{className:K.headerTop,children:[S.jsxs("div",{children:[S.jsx("p",{className:K.eyebrow,children:"Messages"}),S.jsx("h1",{className:K.brand,children:"Agent Messenger"})]}),S.jsx("button",{className:K.logoutButton,disabled:_.isPending,onClick:()=>_.mutate(),type:"button",children:_.isPending?"Signing out...":"Logout"})]}),S.jsxs("div",{className:K.headerMeta,children:[S.jsx("p",{className:K.currentUser,children:n?`@${n.username}`:"Unknown user"}),S.jsx("span",{className:K.statusBadge,children:r.status==="open"?"Live":r.status==="connecting"?"Connecting":"Offline"})]})]}),S.jsxs("section",{className:K.composerSection,children:[S.jsxs("div",{className:K.sectionHeading,children:[S.jsx("h2",{className:K.sectionTitle,children:"Start a conversation"}),S.jsx("p",{className:K.sectionCopy,children:"Enter a username to open a DM right away."})]}),S.jsxs("form",{className:K.searchForm,onSubmit:y,children:[S.jsx("input",{"aria-label":"Search username",className:K.searchInput,onChange:b=>l(b.target.value),placeholder:"@username",value:i}),S.jsx("button",{className:K.searchSubmit,disabled:u.length===0||m.isPending,type:"submit",children:m.isPending?"Opening...":"Open"})]}),s?S.jsx("p",{className:K.errorMessage,children:s}):null,g&&c.isLoading?S.jsx("p",{className:K.statusText,children:"Searching users..."}):null,g&&c.isError?S.jsx("p",{className:K.errorMessage,children:Js(c.error,"Failed to find users.")}):null,g&&c.isSuccess?S.jsxs("ul",{className:K.searchResults,children:[d.map(b=>{const w=h.some(C=>cC(C,b.id));return S.jsx("li",{children:S.jsxs("button",{className:K.searchResultButton,onClick:()=>E(b.username),type:"button",children:[S.jsxs("span",{className:K.searchResultName,children:["@",b.username]}),S.jsx("span",{className:K.searchResultAction,children:w?"Open chat":"New chat"})]})},b.id)}),d.length===0?S.jsx("li",{className:K.statusText,children:"No users found."}):null]}):null]}),S.jsxs("section",{className:K.listSection,children:[S.jsxs("div",{className:K.sectionHeading,children:[S.jsx("h2",{className:K.sectionTitle,children:"Conversations"}),S.jsx("p",{className:K.sectionCopy,children:h.length>0?`${h.length} conversation${h.length===1?"":"s"}`:"No open conversations yet."})]}),f.isLoading?S.jsx("p",{className:K.statusText,children:"Loading conversations..."}):null,f.isError?S.jsx("p",{className:K.errorMessage,children:Js(f.error,"Failed to load conversations.")}):null,f.isSuccess&&h.length===0?S.jsxs("div",{className:K.emptyState,children:[S.jsx("p",{className:K.emptyTitle,children:"No conversations yet"}),S.jsx("p",{className:K.emptyCopy,children:"Search for a username above to start your first DM."})]}):null,f.isSuccess&&h.length>0?S.jsx("nav",{"aria-label":"Conversation list",className:K.conversationList,children:h.map(v)}):null]})]})})}function A(e,t,n){function a(s,o){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:o,constr:l,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,o);const u=l.prototype,f=Object.keys(u);for(let c=0;c<f.length;c++){const d=f[c];d in s||(s[d]=u[d].bind(s))}}const r=(n==null?void 0:n.Parent)??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function l(s){var o;const u=n!=null&&n.Parent?new i:this;a(u,s),(o=u._zod).deferred??(o.deferred=[]);for(const f of u._zod.deferred)f();return u}return Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:s=>{var o,u;return n!=null&&n.Parent&&s instanceof n.Parent?!0:(u=(o=s==null?void 0:s._zod)==null?void 0:o.traits)==null?void 0:u.has(e)}}),Object.defineProperty(l,"name",{value:e}),l}class _i extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class eS extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const tS={};function Va(e){return tS}function nS(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function fd(e,t){return typeof t=="bigint"?t.toString():t}function jh(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Mh(e){return e==null}function Dh(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function dC(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let r=(a.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(a)){const o=a.match(/\d?e-(\d?)/);o!=null&&o[1]&&(r=Number.parseInt(o[1]))}const i=n>r?n:r,l=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return l%s/10**i}const Fp=Symbol("evaluating");function ue(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==Fp)return a===void 0&&(a=Fp,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Ur(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ja(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Jp(e){return JSON.stringify(e)}function hC(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const aS="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function cu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const mC=jh(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Yi(e){if(cu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(cu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function rS(e){return Yi(e)?{...e}:Array.isArray(e)?[...e]:e}const pC=new Set(["string","number","symbol"]);function Ii(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xa(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(a._zod.parent=e),a}function Y(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function vC(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const gC={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function yC(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=Ja(e._zod.def,{get shape(){const l={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(l[s]=n.shape[s])}return Ur(this,"shape",l),l},checks:[]});return Xa(e,i)}function bC(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=Ja(e._zod.def,{get shape(){const l={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete l[s]}return Ur(this,"shape",l),l},checks:[]});return Xa(e,i)}function SC(e,t){if(!Yi(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const l in t)if(Object.getOwnPropertyDescriptor(i,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=Ja(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Ur(this,"shape",i),i}});return Xa(e,r)}function _C(e,t){if(!Yi(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ja(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Ur(this,"shape",a),a}});return Xa(e,n)}function EC(e,t){const n=Ja(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Ur(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return Xa(e,n)}function xC(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const l=Ja(t._zod.def,{get shape(){const s=t._zod.def.shape,o={...s};if(n)for(const u in n){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(o[u]=e?new e({type:"optional",innerType:s[u]}):s[u])}else for(const u in s)o[u]=e?new e({type:"optional",innerType:s[u]}):s[u];return Ur(this,"shape",o),o},checks:[]});return Xa(t,l)}function wC(e,t,n){const a=Ja(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const l in n){if(!(l in i))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(i[l]=new e({type:"nonoptional",innerType:r[l]}))}else for(const l in r)i[l]=new e({type:"nonoptional",innerType:r[l]});return Ur(this,"shape",i),i}});return Xa(t,a)}function di(e,t=0){var n;if(e.aborted===!0)return!0;for(let a=t;a<e.issues.length;a++)if(((n=e.issues[a])==null?void 0:n.continue)!==!0)return!0;return!1}function hi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function Xs(e){return typeof e=="string"?e:e==null?void 0:e.message}function Qa(e,t,n){var r,i,l,s,o,u;const a={...e,path:e.path??[]};if(!e.message){const f=Xs((l=(i=(r=e.inst)==null?void 0:r._zod.def)==null?void 0:i.error)==null?void 0:l.call(i,e))??Xs((s=t==null?void 0:t.error)==null?void 0:s.call(t,e))??Xs((o=n.customError)==null?void 0:o.call(n,e))??Xs((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";a.message=f}return delete a.inst,delete a.continue,t!=null&&t.reportInput||delete a.input,a}function kh(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function os(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const iS=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,fd,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},lS=A("$ZodError",iS),sS=A("$ZodError",iS,{Parent:Error});function TC(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function OC(e,t=n=>n.message){const n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(l=>a({issues:l}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let l=n,s=0;for(;s<i.path.length;){const o=i.path[s];s===i.path.length-1?(l[o]=l[o]||{_errors:[]},l[o]._errors.push(t(i))):l[o]=l[o]||{_errors:[]},l=l[o],s++}}};return a(e),n}const Uh=e=>(t,n,a,r)=>{const i=a?Object.assign(a,{async:!1}):{async:!1},l=t._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw new _i;if(l.issues.length){const s=new((r==null?void 0:r.Err)??e)(l.issues.map(o=>Qa(o,i,Va())));throw aS(s,r==null?void 0:r.callee),s}return l.value},Lh=e=>async(t,n,a,r)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let l=t._zod.run({value:n,issues:[]},i);if(l instanceof Promise&&(l=await l),l.issues.length){const s=new((r==null?void 0:r.Err)??e)(l.issues.map(o=>Qa(o,i,Va())));throw aS(s,r==null?void 0:r.callee),s}return l.value},Bu=e=>(t,n,a)=>{const r=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new _i;return i.issues.length?{success:!1,error:new(e??lS)(i.issues.map(l=>Qa(l,r,Va())))}:{success:!0,data:i.value}},CC=Bu(sS),Zu=e=>async(t,n,a)=>{const r=a?Object.assign(a,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(l=>Qa(l,r,Va())))}:{success:!0,data:i.value}},AC=Zu(sS),NC=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Uh(e)(t,n,r)},zC=e=>(t,n,a)=>Uh(e)(t,n,a),RC=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Lh(e)(t,n,r)},jC=e=>async(t,n,a)=>Lh(e)(t,n,a),MC=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Bu(e)(t,n,r)},DC=e=>(t,n,a)=>Bu(e)(t,n,a),kC=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Zu(e)(t,n,r)},UC=e=>async(t,n,a)=>Zu(e)(t,n,a),LC=/^[cC][^\s-]{8,}$/,$C=/^[0-9a-z]+$/,BC=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ZC=/^[0-9a-vA-V]{20}$/,PC=/^[A-Za-z0-9]{27}$/,qC=/^[a-zA-Z0-9_-]{21}$/,HC=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,GC=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Xp=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,VC=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,QC="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function YC(){return new RegExp(QC,"u")}const IC=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,FC=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,JC=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,XC=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,KC=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,oS=/^[A-Za-z0-9_-]*$/,WC=/^\+[1-9]\d{6,14}$/,uS="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",eA=new RegExp(`^${uS}$`);function cS(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tA(e){return new RegExp(`^${cS(e)}$`)}function nA(e){const t=cS({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${uS}T(?:${a})$`)}const aA=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},rA=/^-?\d+$/,fS=/^-?\d+(?:\.\d+)?$/,iA=/^(?:true|false)$/i,lA=/^null$/i,sA=/^[^A-Z]*$/,oA=/^[^a-z]*$/,zt=A("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),dS={number:"number",bigint:"bigint",object:"date"},hS=A("$ZodCheckLessThan",(e,t)=>{zt.init(e,t);const n=dS[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mS=A("$ZodCheckGreaterThan",(e,t)=>{zt.init(e,t);const n=dS[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uA=A("$ZodCheckMultipleOf",(e,t)=>{zt.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):dC(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),cA=A("$ZodCheckNumberFormat",(e,t)=>{var l;zt.init(e,t),t.format=t.format||"float64";const n=(l=t.format)==null?void 0:l.includes("int"),a=n?"int":"number",[r,i]=gC[t.format];e._zod.onattach.push(s=>{const o=s._zod.bag;o.format=t.format,o.minimum=r,o.maximum=i,n&&(o.pattern=rA)}),e._zod.check=s=>{const o=s.value;if(n){if(!Number.isInteger(o)){s.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});return}if(!Number.isSafeInteger(o)){o>0?s.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):s.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}o<r&&s.issues.push({origin:"number",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),o>i&&s.issues.push({origin:"number",input:o,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),fA=A("$ZodCheckMaxLength",(e,t)=>{var n;zt.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Mh(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;if(r.length<=t.maximum)return;const l=kh(r);a.issues.push({origin:l,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),dA=A("$ZodCheckMinLength",(e,t)=>{var n;zt.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Mh(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;if(r.length>=t.minimum)return;const l=kh(r);a.issues.push({origin:l,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),hA=A("$ZodCheckLengthEquals",(e,t)=>{var n;zt.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Mh(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=a=>{const r=a.value,i=r.length;if(i===t.length)return;const l=kh(r),s=i>t.length;a.issues.push({origin:l,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),Pu=A("$ZodCheckStringFormat",(e,t)=>{var n,a;zt.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),mA=A("$ZodCheckRegex",(e,t)=>{Pu.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),pA=A("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=sA),Pu.init(e,t)}),vA=A("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=oA),Pu.init(e,t)}),gA=A("$ZodCheckIncludes",(e,t)=>{zt.init(e,t);const n=Ii(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),yA=A("$ZodCheckStartsWith",(e,t)=>{zt.init(e,t);const n=new RegExp(`^${Ii(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),bA=A("$ZodCheckEndsWith",(e,t)=>{zt.init(e,t);const n=new RegExp(`.*${Ii(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),SA=A("$ZodCheckOverwrite",(e,t)=>{zt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class _A{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
|
|
76
|
+
*/function uu(){return uu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},uu.apply(this,arguments)}function V0(e,t){if(e==null)return{};var n={},a=Object.keys(e),r,i;for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&(n[r]=e[r]);return n}function MT(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function DT(e,t){return e.button===0&&(!t||t==="_self")&&!MT(e)}const kT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],UT=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],LT="6";try{window.__reactRouterVersion=LT}catch{}const $T=p.createContext({isTransitioning:!1}),BT="startTransition",Hp=SE[BT];function ZT(e){let{basename:t,children:n,future:a,window:r}=e,i=p.useRef();i.current==null&&(i.current=$w({window:r,v5Compat:!0}));let l=i.current,[s,o]=p.useState({action:l.action,location:l.location}),{v7_startTransition:u}=a||{},f=p.useCallback(c=>{u&&Hp?Hp(()=>o(c)):o(c)},[o,u]);return p.useLayoutEffect(()=>l.listen(f),[l,f]),p.useEffect(()=>AT(a),[a]),p.createElement(RT,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:l,future:a})}const PT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",qT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Q0=p.forwardRef(function(t,n){let{onClick:a,relative:r,reloadDocument:i,replace:l,state:s,target:o,to:u,preventScrollReset:f,viewTransition:c}=t,d=V0(t,kT),{basename:m}=p.useContext(Kn),_,y=!1;if(typeof u=="string"&&qT.test(u)&&(_=u,PT))try{let g=new URL(window.location.href),b=u.startsWith("//")?new URL(g.protocol+u):new URL(u),w=Qi(b.pathname,m);b.origin===g.origin&&w!=null?u=w+b.search+b.hash:y=!0}catch{}let E=cT(u,{relative:r}),v=VT(u,{replace:l,state:s,target:o,preventScrollReset:f,relative:r,viewTransition:c});function h(g){a&&a(g),g.defaultPrevented||v(g)}return p.createElement("a",uu({},d,{href:_||E,onClick:y||i?a:h,ref:n,target:o}))}),HT=p.forwardRef(function(t,n){let{"aria-current":a="page",caseSensitive:r=!1,className:i="",end:l=!1,style:s,to:o,viewTransition:u,children:f}=t,c=V0(t,UT),d=$u(o,{relative:c.relative}),m=Fa(),_=p.useContext(B0),{navigator:y,basename:E}=p.useContext(Kn),v=_!=null&&QT(d)&&u===!0,h=y.encodeLocation?y.encodeLocation(d).pathname:d.pathname,g=m.pathname,b=_&&_.navigation&&_.navigation.location?_.navigation.location.pathname:null;r||(g=g.toLowerCase(),b=b?b.toLowerCase():null,h=h.toLowerCase()),b&&E&&(b=Qi(b,E)||b);const w=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let C=g===h||!l&&g.startsWith(h)&&g.charAt(w)==="/",O=b!=null&&(b===h||!l&&b.startsWith(h)&&b.charAt(h.length)==="/"),T={isActive:C,isPending:O,isTransitioning:v},R=C?a:void 0,D;typeof i=="function"?D=i(T):D=[i,C?"active":null,O?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let Q=typeof s=="function"?s(T):s;return p.createElement(Q0,uu({},c,{"aria-current":R,className:D,ref:n,style:Q,to:o,viewTransition:u}),typeof f=="function"?f(T):f)});var od;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(od||(od={}));var Gp;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Gp||(Gp={}));function GT(e){let t=p.useContext(Uu);return t||Re(!1),t}function VT(e,t){let{target:n,replace:a,state:r,preventScrollReset:i,relative:l,viewTransition:s}=t===void 0?{}:t,o=As(),u=Fa(),f=$u(e,{relative:l});return p.useCallback(c=>{if(DT(c,n)){c.preventDefault();let d=a!==void 0?a:ou(u)===ou(f);o(e,{replace:d,state:r,preventScrollReset:i,relative:l,viewTransition:s})}},[u,o,f,a,r,n,e,i,l,s])}function QT(e,t){t===void 0&&(t={});let n=p.useContext($T);n==null&&Re(!1);let{basename:a}=GT(od.useViewTransitionState),r=$u(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Qi(n.currentLocation.pathname,a)||n.currentLocation.pathname,l=Qi(n.nextLocation.pathname,a)||n.nextLocation.pathname;return ld(r.pathname,l)!=null||ld(r.pathname,i)!=null}const YT="modulepreload",IT=function(e){return"/"+e},Vp={},FT=function(t,n,a){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),s=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));r=Promise.allSettled(n.map(o=>{if(o=IT(o),o in Vp)return;Vp[o]=!0;const u=o.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${f}`))return;const c=document.createElement("link");if(c.rel=u?"stylesheet":YT,u||(c.as="script"),c.crossOrigin="",c.href=o,s&&c.setAttribute("nonce",s),document.head.appendChild(c),u)return new Promise((d,m)=>{c.addEventListener("load",d),c.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${o}`)))})}))}function i(l){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=l,window.dispatchEvent(s),!s.defaultPrevented)throw l}return r.then(l=>{for(const s of l||[])s.status==="rejected"&&i(s.reason);return t().catch(i)})};function JT(e={}){const{immediate:t=!1,onNeedRefresh:n,onOfflineReady:a,onRegistered:r,onRegisteredSW:i,onRegisterError:l}=e;let s,o;const u=async(c=!0)=>{await o};async function f(){if("serviceWorker"in navigator){if(s=await FT(async()=>{const{Workbox:c}=await import("./workbox-window.prod.es5-vqzQaGvo.js");return{Workbox:c}},[]).then(({Workbox:c})=>new c("/sw.js",{scope:"/",type:"classic"})).catch(c=>{l==null||l(c)}),!s)return;s.addEventListener("activated",c=>{(c.isUpdate||c.isExternal)&&window.location.reload()}),s.addEventListener("installed",c=>{c.isUpdate||a==null||a()}),s.register({immediate:t}).then(c=>{i?i("/sw.js",c):r==null||r(c)}).catch(c=>{l==null||l(c)})}}return o=f(),u}const XT="text";function Y0(e){return e.kind==="json_render"?"json_render":XT}function KT(e){return e.json_render_spec??null}function $n(e){return{...e,kind:Y0(e)}}function Rh(e){return Y0(e)==="json_render"?{kind:"json_render",textContent:null,jsonRenderSpec:KT(e)}:{kind:"text",textContent:e.content??null,jsonRenderSpec:null}}function WT(e){return{...e,message:$n(e.message)}}function eO(e){return{...e,last_message:e.last_message?$n(e.last_message):void 0}}class Ca extends Error{constructor(n,a,r){super(n);Wa(this,"status");Wa(this,"path");this.name="ApiError",this.status=a,this.path=r}}const tO="";function nO(e){return e.replace(/\/+$/,"")}function aO(e,t){const n=t.startsWith("/")?t:`/${t}`;return e===""?n:`${e}${n}`}function rO(e,t){if(!t)return e;const n=new URLSearchParams;for(const[r,i]of Object.entries(t))i!==void 0&&n.set(r,String(i));const a=n.toString();return a===""?e:`${e}?${a}`}function iO(e){return typeof e=="object"&&e!==null}function lO(e){return"attachment"in e}function sO(e){return"attachmentUrl"in e}class oO{constructor(t={}){Wa(this,"baseUrl");Wa(this,"getToken");Wa(this,"onUnauthorized");Wa(this,"token",null);const n=t.baseUrl??tO;this.baseUrl=nO(n),this.getToken=t.getToken,this.onUnauthorized=t.onUnauthorized}setAuthToken(t){this.token=t}getAuthToken(){return this.getToken?this.getToken()??this.token:this.token}async register(t){return this.requestJSON({method:"POST",path:"/api/auth/register",auth:!1,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async login(t){return this.requestJSON({method:"POST",path:"/api/auth/login",auth:!1,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async logout(){await this.requestVoid({method:"DELETE",path:"/api/auth/logout"})}async getMe(){return this.requestJSON({method:"GET",path:"/api/users/me"})}async searchUsers(t){return this.requestJSON({method:"GET",path:"/api/users",query:{username:t.username,limit:t.limit}})}async listConversations(t={}){return(await this.requestJSON({method:"GET",path:"/api/conversations",query:{limit:t.limit}})).map(eO)}async startConversation(t){return this.requestJSON({method:"POST",path:"/api/conversations",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async getConversation(t){return this.requestJSON({method:"GET",path:`/api/conversations/${encodeURIComponent(t)}`})}async listMessages(t,n={}){return(await this.requestJSON({method:"GET",path:`/api/conversations/${encodeURIComponent(t)}/messages`,query:{before:n.before,limit:n.limit}})).map(WT)}async sendMessage(t,n){const a=`/api/conversations/${encodeURIComponent(t)}/messages`;if(lO(n)){const r=new FormData;return n.content&&n.content.trim()!==""&&r.set("content",n.content),r.set("attachment",n.attachment),this.requestJSON({method:"POST",path:a,body:r}).then($n)}if(sO(n)){const r=new FormData;return n.content&&n.content.trim()!==""&&r.set("content",n.content),r.set("attachment_url",n.attachmentUrl),n.attachmentType&&r.set("attachment_type",n.attachmentType),this.requestJSON({method:"POST",path:a,body:r}).then($n)}return this.requestJSON({method:"POST",path:a,headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n.content})}).then($n)}async editMessage(t,n){return this.requestJSON({method:"PATCH",path:`/api/messages/${encodeURIComponent(t)}`,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then($n)}async deleteMessage(t){return this.requestJSON({method:"DELETE",path:`/api/messages/${encodeURIComponent(t)}`}).then($n)}async toggleReaction(t,n){return this.requestJSON({method:"POST",path:`/api/messages/${encodeURIComponent(t)}/reactions`,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async removeReaction(t,n){return this.requestJSON({method:"DELETE",path:`/api/messages/${encodeURIComponent(t)}/reactions/${encodeURIComponent(n)}`})}async uploadFile(t,n="file"){const a=new FormData;return a.set(n,t),this.requestJSON({method:"POST",path:"/api/upload",body:a})}async requestJSON(t){return await(await this.request(t)).json()}async requestVoid(t){await this.request(t)}async request(t){const n=rO(aO(this.baseUrl,t.path),t.query),a=new Headers(t.headers??{});if(t.auth??!0){const l=this.getAuthToken();l&&a.set("Authorization",`Bearer ${l}`)}const i=await fetch(n,{method:t.method,headers:a,body:t.body});if(i.ok)return i;throw i.status===401&&this.onUnauthorized&&this.onUnauthorized(),await this.toApiError(i,t.path)}async toApiError(t,n){const a=t.headers.get("Content-Type")??"";let r=`Request failed with status ${t.status}`;if(a.includes("application/json"))try{const i=await t.json();iO(i)&&typeof i.error=="string"&&i.error.trim()!==""&&(r=i.error)}catch{}else try{const i=(await t.text()).trim();i!==""&&(r=i)}catch{}return new Ca(r,t.status,n)}}function uO(e={}){return new oO(e)}const nt=uO(),ud="agent_message.auth_token",I0=p.createContext(void 0);function cO(){try{return window.localStorage.getItem(ud)}catch{return null}}function Qp(e){try{if(e===null){window.localStorage.removeItem(ud);return}window.localStorage.setItem(ud,e)}catch{}}function fO({children:e}){const[t,n]=p.useState("loading"),[a,r]=p.useState(null),[i,l]=p.useState(null),s=p.useCallback(d=>{nt.setAuthToken(d.token),Qp(d.token),r(d.token),l(d.user),n("authenticated")},[]),o=p.useCallback(()=>{nt.setAuthToken(null),Qp(null),r(null),l(null),n("unauthenticated")},[]);p.useEffect(()=>{const d=cO();if(!d){n("unauthenticated");return}let m=!1;return nt.setAuthToken(d),r(d),nt.getMe().then(_=>{m||(l(_),n("authenticated"))}).catch(()=>{m||o()}),()=>{m=!0}},[o]);const u=p.useCallback(async d=>{const m={username:d.username.trim(),pin:d.pin.trim()};try{const _=await nt.login(m);return s(_),{mode:"login"}}catch(_){if(!(_ instanceof Ca)||_.status!==401)throw _;try{const y=await nt.register(m);return s(y),{mode:"register"}}catch(y){throw y instanceof Ca&&y.status===409?new Ca("invalid credentials",401,"/api/auth/login"):y}}},[s]),f=p.useCallback(async()=>{try{await nt.logout()}catch(d){if(!(d instanceof Ca)||d.status!==401)throw d}finally{o()}},[o]),c=p.useMemo(()=>({status:t,isAuthenticated:t==="authenticated",token:a,user:i,loginWithAutoRegister:u,logout:f}),[u,f,t,a,i]);return S.jsx(I0.Provider,{value:c,children:e})}function Ns(){const e=p.useContext(I0);if(!e)throw new Error("useAuth must be used within AuthProvider");return e}const Yp="Start a conversation",F0="This message was deleted",Ip="[json-render]";function dO(e){if(e.attachment_type==="image")return"[image]";if(e.attachment_type==="file")return"[file]"}function hO(e){var r;if(!e)return Yp;if(e.deleted)return F0;const t=Rh(e),n=dO(e);if(t.kind==="json_render")return n?`${n} ${Ip}`:Ip;const a=(r=t.textContent)==null?void 0:r.trim();return n&&a?`${n} ${a}`:a||n||Yp}function Oo(e,t){return e.sender_id===t&&!e.deleted}function zc(e,t){return Oo(e,t)?Rh(e).kind==="text":!1}function mO(e){var a;if(e.deleted)return{variant:"deleted",textContent:null,jsonRenderSpec:null};const t=Rh(e);if(t.kind==="json_render")return{variant:"json_render",textContent:null,jsonRenderSpec:t.jsonRenderSpec};const n=(a=t.textContent)==null?void 0:a.trim();return n?{variant:"text",textContent:n,jsonRenderSpec:null}:{variant:"empty",textContent:null,jsonRenderSpec:null}}const pO=vO();function vO(){return"/api/events"}function gO(e){return typeof e=="object"&&e!==null}function yO(e){return e==="message.new"||e==="message.edited"||e==="message.deleted"||e==="reaction.added"||e==="reaction.removed"}function bO(e){let t;try{t=JSON.parse(e)}catch{return null}if(!gO(t))return null;const n=t.type;if(typeof n!="string"||n.trim()==="")return null;const a=t.data;if(!yO(n))return{type:n,data:a};switch(n){case"message.new":return{type:n,data:$n(a)};case"message.edited":return{type:n,data:$n(a)};case"message.deleted":return{type:n,data:a};case"reaction.added":return{type:n,data:a};case"reaction.removed":return{type:n,data:a}}}function SO(e){const{token:t,enabled:n=!0,eventURL:a=pO,onOpen:r,onError:i,onEvent:l,onMessageNew:s,onMessageEdited:o,onMessageDeleted:u,onReactionAdded:f,onReactionRemoved:c}=e,[d,m]=p.useState("idle"),[_,y]=p.useState(null),E=p.useRef(null);return p.useEffect(()=>{var w;if(!n||!t){(w=E.current)==null||w.close(),E.current=null,m("idle"),y(null);return}const v=t.trim();if(v===""){m("idle"),y(null);return}const h=a.includes("?")?`${a}&token=${encodeURIComponent(v)}`:`${a}?token=${encodeURIComponent(v)}`;m("connecting");const g=new EventSource(h);E.current=g;const b=C=>O=>{const T=bO(O.data);T&&(y(T),l==null||l(T),C==null||C(T))};return g.onopen=()=>{m("open"),r==null||r()},g.onerror=()=>{m(g.readyState===EventSource.CLOSED?"closed":"connecting"),i==null||i()},g.addEventListener("message.new",b(s)),g.addEventListener("message.edited",b(o)),g.addEventListener("message.deleted",b(u)),g.addEventListener("reaction.added",b(f)),g.addEventListener("reaction.removed",b(c)),()=>{g.close(),E.current===g&&(E.current=null)}},[n,a,i,l,u,o,s,r,f,c,t]),p.useMemo(()=>({status:d,lastEvent:_}),[_,d])}function J0(e){return{id:e.sender_id,username:"me",created_at:e.created_at}}function X0(e,t){return!e||e.pages.length===0?{pageParams:[void 0],pages:[[t]]}:e.pages.some(a=>a.some(r=>r.message.id===t.message.id))?e:{...e,pages:[[t,...e.pages[0]],...e.pages.slice(1)]}}function _O(e,t){if(!e)return e;let n=!1;const a=e.pages.map(r=>r.map(i=>i.message.id!==t?i:(n=!0,{...i,message:{...i.message,deleted:!0,content:void 0,attachment_url:void 0,attachment_type:void 0}})));return n?{...e,pages:a}:e}function cd(e,t){if(!e)return e;let n=!1;const a=e.pages.map(r=>r.map(i=>i.message.id!==t.id?i:(n=!0,{...i,message:t})));return n?{...e,pages:a}:e}function EO(e,t,n){return t&&e.sender_id===t.id?t:(n==null?void 0:n.participant_a.id)===e.sender_id?n.participant_a:(n==null?void 0:n.participant_b.id)===e.sender_id?n.participant_b:J0(e)}function xO(e,t){const n=e[t.message_id]??[];return n.some(r=>r.emoji===t.emoji&&r.user_id===t.user_id)?e:{...e,[t.message_id]:[...n,t]}}function wO(e,t){const n=e[t.message_id]??[],a=n.filter(r=>!(r.emoji===t.emoji&&r.user_id===t.user_id));if(a.length===n.length)return e;if(a.length===0){const{[t.message_id]:r,...i}=e;return i}return{...e,[t.message_id]:a}}const K0=p.createContext(void 0);function TO({children:e}){const t=Cs(),{isAuthenticated:n,token:a,user:r}=Ns(),[i,l]=p.useState({}),s=p.useCallback(()=>{t.invalidateQueries({queryKey:["conversations"]})},[t]),o=p.useCallback(y=>{const E=["messages",y.conversation_id];if(t.getQueryData(E)!==void 0){const h=t.getQueryData(["conversation",y.conversation_id]);t.setQueryData(E,g=>X0(g,{message:y,sender:EO(y,r,h)}))}s()},[s,t,r]),u=p.useCallback(y=>{t.setQueryData(["messages",y.conversation_id],E=>cd(E,y)),s()},[s,t]),f=p.useCallback(y=>{t.setQueriesData({queryKey:["messages"]},E=>_O(E,y)),s()},[s,t]),c=p.useCallback(y=>{l(E=>xO(E,y))},[]),d=p.useCallback(y=>{l(E=>wO(E,y))},[]);p.useEffect(()=>{a||l({})},[a]);const m=SO({token:a,enabled:!!(n&&a),onMessageNew:({data:y})=>o(y),onMessageEdited:({data:y})=>u(y),onMessageDeleted:({data:y})=>f(y.id),onReactionAdded:({data:y})=>c(y),onReactionRemoved:({data:y})=>d(y)}),_=p.useMemo(()=>({status:m.status,messageReactions:i,applyReactionAdded:c,applyReactionRemoved:d}),[c,d,m.status,i]);return S.jsx(K0.Provider,{value:_,children:e})}function W0(){const e=p.useContext(K0);if(!e)throw new Error("useRealtime must be used within RealtimeProvider");return e}const OO="_page_h90ug_1",CO="_shell_h90ug_11",AO="_header_h90ug_22",NO="_headerTop_h90ug_30",zO="_eyebrow_h90ug_37",RO="_brand_h90ug_45",jO="_headerMeta_h90ug_51",MO="_currentUser_h90ug_59",DO="_statusBadge_h90ug_65",kO="_logoutButton_h90ug_78",UO="_composerSection_h90ug_94",LO="_listSection_h90ug_95",$O="_sectionHeading_h90ug_115",BO="_sectionTitle_h90ug_119",ZO="_sectionCopy_h90ug_125",PO="_searchForm_h90ug_131",qO="_searchInput_h90ug_137",HO="_searchSubmit_h90ug_152",GO="_searchResults_h90ug_168",VO="_searchResultButton_h90ug_176",QO="_searchResultName_h90ug_195",YO="_searchResultAction_h90ug_199",IO="_conversationList_h90ug_204",FO="_conversationItem_h90ug_215",JO="_conversationItemActive_h90ug_231",XO="_conversationMeta_h90ug_237",KO="_conversationName_h90ug_244",WO="_conversationTime_h90ug_249",eC="_conversationPreview_h90ug_254",tC="_conversationId_h90ug_263",nC="_statusText_h90ug_267",aC="_errorMessage_h90ug_273",rC="_emptyState_h90ug_279",iC="_emptyTitle_h90ug_284",lC="_emptyCopy_h90ug_290",K={page:OO,shell:CO,header:AO,headerTop:NO,eyebrow:zO,brand:RO,headerMeta:jO,currentUser:MO,statusBadge:DO,logoutButton:kO,composerSection:UO,listSection:LO,sectionHeading:$O,sectionTitle:BO,sectionCopy:ZO,searchForm:PO,searchInput:qO,searchSubmit:HO,searchResults:GO,searchResultButton:VO,searchResultName:QO,searchResultAction:YO,conversationList:IO,conversationItem:FO,conversationItemActive:JO,conversationMeta:XO,conversationName:KO,conversationTime:WO,conversationPreview:eC,conversationId:tC,statusText:nC,errorMessage:aC,emptyState:rC,emptyTitle:iC,emptyCopy:lC},sC=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function Js(e,t){return e instanceof Ca||e instanceof Error&&e.message.trim()!==""?e.message:t}function oC(e){if(!e)return"";const t=Date.parse(e.created_at);return Number.isNaN(t)?"":sC.format(new Date(t))}function uC(e,t){return e?t?e.filter(n=>n.id!==t):e:[]}function cC(e,t){return e.other_user.id===t}function fC(){const e=As(),t=Cs(),{user:n,logout:a}=Ns(),r=W0(),[i,l]=p.useState(""),[s,o]=p.useState(null),u=i.trim(),f=rd({queryKey:["conversations"],queryFn:()=>nt.listConversations()}),c=rd({queryKey:["users","search",u],queryFn:()=>nt.searchUsers({username:u,limit:8}),enabled:u.length>0}),d=p.useMemo(()=>uC(c.data,n==null?void 0:n.id),[n==null?void 0:n.id,c.data]),m=Hl({mutationFn:b=>nt.startConversation({username:b}),onSuccess:async b=>{o(null),l(""),await t.invalidateQueries({queryKey:["conversations"]}),e(`/dm/${b.conversation.id}`)},onError:b=>{o(Js(b,"Failed to start the conversation."))}}),_=Hl({mutationFn:()=>a(),onSuccess:()=>{e("/login",{replace:!0})},onError:b=>{o(Js(b,"Failed to sign out."))}});function y(b){b.preventDefault();const w=u;w!==""&&(o(null),m.mutate(w))}function E(b){o(null),m.mutate(b)}function v(b){const w=hO(b.last_message),C=oC(b.last_message),O=b.conversation.id;return S.jsxs(HT,{className:({isActive:T})=>`${K.conversationItem}${T?` ${K.conversationItemActive}`:""}`,to:`/dm/${b.conversation.id}`,children:[S.jsxs("div",{className:K.conversationMeta,children:[S.jsx("span",{className:K.conversationName,children:b.other_user.username}),S.jsx("span",{className:K.conversationTime,children:C})]}),S.jsx("p",{className:K.conversationPreview,title:w,children:w}),S.jsx("span",{className:K.conversationId,children:O})]},b.conversation.id)}const h=f.data??[],g=u.length>0;return S.jsx("main",{className:K.page,children:S.jsxs("section",{className:K.shell,children:[S.jsxs("header",{className:K.header,children:[S.jsxs("div",{className:K.headerTop,children:[S.jsxs("div",{children:[S.jsx("p",{className:K.eyebrow,children:"Messages"}),S.jsx("h1",{className:K.brand,children:"Agent Message"})]}),S.jsx("button",{className:K.logoutButton,disabled:_.isPending,onClick:()=>_.mutate(),type:"button",children:_.isPending?"Signing out...":"Logout"})]}),S.jsxs("div",{className:K.headerMeta,children:[S.jsx("p",{className:K.currentUser,children:n?`@${n.username}`:"Unknown user"}),S.jsx("span",{className:K.statusBadge,children:r.status==="open"?"Live":r.status==="connecting"?"Connecting":"Offline"})]})]}),S.jsxs("section",{className:K.composerSection,children:[S.jsxs("div",{className:K.sectionHeading,children:[S.jsx("h2",{className:K.sectionTitle,children:"Start a conversation"}),S.jsx("p",{className:K.sectionCopy,children:"Enter a username to open a DM right away."})]}),S.jsxs("form",{className:K.searchForm,onSubmit:y,children:[S.jsx("input",{"aria-label":"Search username",className:K.searchInput,onChange:b=>l(b.target.value),placeholder:"@username",value:i}),S.jsx("button",{className:K.searchSubmit,disabled:u.length===0||m.isPending,type:"submit",children:m.isPending?"Opening...":"Open"})]}),s?S.jsx("p",{className:K.errorMessage,children:s}):null,g&&c.isLoading?S.jsx("p",{className:K.statusText,children:"Searching users..."}):null,g&&c.isError?S.jsx("p",{className:K.errorMessage,children:Js(c.error,"Failed to find users.")}):null,g&&c.isSuccess?S.jsxs("ul",{className:K.searchResults,children:[d.map(b=>{const w=h.some(C=>cC(C,b.id));return S.jsx("li",{children:S.jsxs("button",{className:K.searchResultButton,onClick:()=>E(b.username),type:"button",children:[S.jsxs("span",{className:K.searchResultName,children:["@",b.username]}),S.jsx("span",{className:K.searchResultAction,children:w?"Open chat":"New chat"})]})},b.id)}),d.length===0?S.jsx("li",{className:K.statusText,children:"No users found."}):null]}):null]}),S.jsxs("section",{className:K.listSection,children:[S.jsxs("div",{className:K.sectionHeading,children:[S.jsx("h2",{className:K.sectionTitle,children:"Conversations"}),S.jsx("p",{className:K.sectionCopy,children:h.length>0?`${h.length} conversation${h.length===1?"":"s"}`:"No open conversations yet."})]}),f.isLoading?S.jsx("p",{className:K.statusText,children:"Loading conversations..."}):null,f.isError?S.jsx("p",{className:K.errorMessage,children:Js(f.error,"Failed to load conversations.")}):null,f.isSuccess&&h.length===0?S.jsxs("div",{className:K.emptyState,children:[S.jsx("p",{className:K.emptyTitle,children:"No conversations yet"}),S.jsx("p",{className:K.emptyCopy,children:"Search for a username above to start your first DM."})]}):null,f.isSuccess&&h.length>0?S.jsx("nav",{"aria-label":"Conversation list",className:K.conversationList,children:h.map(v)}):null]})]})})}function A(e,t,n){function a(s,o){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:o,constr:l,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,o);const u=l.prototype,f=Object.keys(u);for(let c=0;c<f.length;c++){const d=f[c];d in s||(s[d]=u[d].bind(s))}}const r=(n==null?void 0:n.Parent)??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function l(s){var o;const u=n!=null&&n.Parent?new i:this;a(u,s),(o=u._zod).deferred??(o.deferred=[]);for(const f of u._zod.deferred)f();return u}return Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:s=>{var o,u;return n!=null&&n.Parent&&s instanceof n.Parent?!0:(u=(o=s==null?void 0:s._zod)==null?void 0:o.traits)==null?void 0:u.has(e)}}),Object.defineProperty(l,"name",{value:e}),l}class _i extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class eS extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const tS={};function Va(e){return tS}function nS(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>t.indexOf(+a)===-1).map(([a,r])=>r)}function fd(e,t){return typeof t=="bigint"?t.toString():t}function jh(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Mh(e){return e==null}function Dh(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function dC(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let r=(a.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(a)){const o=a.match(/\d?e-(\d?)/);o!=null&&o[1]&&(r=Number.parseInt(o[1]))}const i=n>r?n:r,l=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return l%s/10**i}const Fp=Symbol("evaluating");function ue(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==Fp)return a===void 0&&(a=Fp,a=n()),a},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Ur(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ja(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Jp(e){return JSON.stringify(e)}function hC(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const aS="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function cu(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const mC=jh(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Yi(e){if(cu(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(cu(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function rS(e){return Yi(e)?{...e}:Array.isArray(e)?[...e]:e}const pC=new Set(["string","number","symbol"]);function Ii(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xa(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(a._zod.parent=e),a}function Y(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function vC(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const gC={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function yC(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=Ja(e._zod.def,{get shape(){const l={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(l[s]=n.shape[s])}return Ur(this,"shape",l),l},checks:[]});return Xa(e,i)}function bC(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=Ja(e._zod.def,{get shape(){const l={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete l[s]}return Ur(this,"shape",l),l},checks:[]});return Xa(e,i)}function SC(e,t){if(!Yi(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const l in t)if(Object.getOwnPropertyDescriptor(i,l)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=Ja(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Ur(this,"shape",i),i}});return Xa(e,r)}function _C(e,t){if(!Yi(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ja(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Ur(this,"shape",a),a}});return Xa(e,n)}function EC(e,t){const n=Ja(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Ur(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return Xa(e,n)}function xC(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const l=Ja(t._zod.def,{get shape(){const s=t._zod.def.shape,o={...s};if(n)for(const u in n){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(o[u]=e?new e({type:"optional",innerType:s[u]}):s[u])}else for(const u in s)o[u]=e?new e({type:"optional",innerType:s[u]}):s[u];return Ur(this,"shape",o),o},checks:[]});return Xa(t,l)}function wC(e,t,n){const a=Ja(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const l in n){if(!(l in i))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(i[l]=new e({type:"nonoptional",innerType:r[l]}))}else for(const l in r)i[l]=new e({type:"nonoptional",innerType:r[l]});return Ur(this,"shape",i),i}});return Xa(t,a)}function di(e,t=0){var n;if(e.aborted===!0)return!0;for(let a=t;a<e.issues.length;a++)if(((n=e.issues[a])==null?void 0:n.continue)!==!0)return!0;return!1}function hi(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function Xs(e){return typeof e=="string"?e:e==null?void 0:e.message}function Qa(e,t,n){var r,i,l,s,o,u;const a={...e,path:e.path??[]};if(!e.message){const f=Xs((l=(i=(r=e.inst)==null?void 0:r._zod.def)==null?void 0:i.error)==null?void 0:l.call(i,e))??Xs((s=t==null?void 0:t.error)==null?void 0:s.call(t,e))??Xs((o=n.customError)==null?void 0:o.call(n,e))??Xs((u=n.localeError)==null?void 0:u.call(n,e))??"Invalid input";a.message=f}return delete a.inst,delete a.continue,t!=null&&t.reportInput||delete a.input,a}function kh(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function os(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const iS=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,fd,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},lS=A("$ZodError",iS),sS=A("$ZodError",iS,{Parent:Error});function TC(e,t=n=>n.message){const n={},a=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):a.push(t(r));return{formErrors:a,fieldErrors:n}}function OC(e,t=n=>n.message){const n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(l=>a({issues:l}));else if(i.code==="invalid_key")a({issues:i.issues});else if(i.code==="invalid_element")a({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let l=n,s=0;for(;s<i.path.length;){const o=i.path[s];s===i.path.length-1?(l[o]=l[o]||{_errors:[]},l[o]._errors.push(t(i))):l[o]=l[o]||{_errors:[]},l=l[o],s++}}};return a(e),n}const Uh=e=>(t,n,a,r)=>{const i=a?Object.assign(a,{async:!1}):{async:!1},l=t._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw new _i;if(l.issues.length){const s=new((r==null?void 0:r.Err)??e)(l.issues.map(o=>Qa(o,i,Va())));throw aS(s,r==null?void 0:r.callee),s}return l.value},Lh=e=>async(t,n,a,r)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let l=t._zod.run({value:n,issues:[]},i);if(l instanceof Promise&&(l=await l),l.issues.length){const s=new((r==null?void 0:r.Err)??e)(l.issues.map(o=>Qa(o,i,Va())));throw aS(s,r==null?void 0:r.callee),s}return l.value},Bu=e=>(t,n,a)=>{const r=a?{...a,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new _i;return i.issues.length?{success:!1,error:new(e??lS)(i.issues.map(l=>Qa(l,r,Va())))}:{success:!0,data:i.value}},CC=Bu(sS),Zu=e=>async(t,n,a)=>{const r=a?Object.assign(a,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(l=>Qa(l,r,Va())))}:{success:!0,data:i.value}},AC=Zu(sS),NC=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Uh(e)(t,n,r)},zC=e=>(t,n,a)=>Uh(e)(t,n,a),RC=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Lh(e)(t,n,r)},jC=e=>async(t,n,a)=>Lh(e)(t,n,a),MC=e=>(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Bu(e)(t,n,r)},DC=e=>(t,n,a)=>Bu(e)(t,n,a),kC=e=>async(t,n,a)=>{const r=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Zu(e)(t,n,r)},UC=e=>async(t,n,a)=>Zu(e)(t,n,a),LC=/^[cC][^\s-]{8,}$/,$C=/^[0-9a-z]+$/,BC=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ZC=/^[0-9a-vA-V]{20}$/,PC=/^[A-Za-z0-9]{27}$/,qC=/^[a-zA-Z0-9_-]{21}$/,HC=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,GC=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Xp=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,VC=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,QC="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function YC(){return new RegExp(QC,"u")}const IC=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,FC=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,JC=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,XC=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,KC=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,oS=/^[A-Za-z0-9_-]*$/,WC=/^\+[1-9]\d{6,14}$/,uS="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",eA=new RegExp(`^${uS}$`);function cS(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tA(e){return new RegExp(`^${cS(e)}$`)}function nA(e){const t=cS({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${uS}T(?:${a})$`)}const aA=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},rA=/^-?\d+$/,fS=/^-?\d+(?:\.\d+)?$/,iA=/^(?:true|false)$/i,lA=/^null$/i,sA=/^[^A-Z]*$/,oA=/^[^a-z]*$/,zt=A("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),dS={number:"number",bigint:"bigint",object:"date"},hS=A("$ZodCheckLessThan",(e,t)=>{zt.init(e,t);const n=dS[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mS=A("$ZodCheckGreaterThan",(e,t)=>{zt.init(e,t);const n=dS[typeof t.value];e._zod.onattach.push(a=>{const r=a._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),uA=A("$ZodCheckMultipleOf",(e,t)=>{zt.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):dC(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),cA=A("$ZodCheckNumberFormat",(e,t)=>{var l;zt.init(e,t),t.format=t.format||"float64";const n=(l=t.format)==null?void 0:l.includes("int"),a=n?"int":"number",[r,i]=gC[t.format];e._zod.onattach.push(s=>{const o=s._zod.bag;o.format=t.format,o.minimum=r,o.maximum=i,n&&(o.pattern=rA)}),e._zod.check=s=>{const o=s.value;if(n){if(!Number.isInteger(o)){s.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});return}if(!Number.isSafeInteger(o)){o>0?s.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):s.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}o<r&&s.issues.push({origin:"number",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),o>i&&s.issues.push({origin:"number",input:o,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),fA=A("$ZodCheckMaxLength",(e,t)=>{var n;zt.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Mh(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const r=a.value;if(r.length<=t.maximum)return;const l=kh(r);a.issues.push({origin:l,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),dA=A("$ZodCheckMinLength",(e,t)=>{var n;zt.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Mh(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const r=a.value;if(r.length>=t.minimum)return;const l=kh(r);a.issues.push({origin:l,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),hA=A("$ZodCheckLengthEquals",(e,t)=>{var n;zt.init(e,t),(n=e._zod.def).when??(n.when=a=>{const r=a.value;return!Mh(r)&&r.length!==void 0}),e._zod.onattach.push(a=>{const r=a._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=a=>{const r=a.value,i=r.length;if(i===t.length)return;const l=kh(r),s=i>t.length;a.issues.push({origin:l,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),Pu=A("$ZodCheckStringFormat",(e,t)=>{var n,a;zt.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),mA=A("$ZodCheckRegex",(e,t)=>{Pu.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),pA=A("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=sA),Pu.init(e,t)}),vA=A("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=oA),Pu.init(e,t)}),gA=A("$ZodCheckIncludes",(e,t)=>{zt.init(e,t);const n=Ii(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(a)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),yA=A("$ZodCheckStartsWith",(e,t)=>{zt.init(e,t);const n=new RegExp(`^${Ii(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),bA=A("$ZodCheckEndsWith",(e,t)=>{zt.init(e,t);const n=new RegExp(`.*${Ii(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const r=a._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),SA=A("$ZodCheckOverwrite",(e,t)=>{zt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class _A{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
|
|
77
77
|
`).filter(l=>l),r=Math.min(...a.map(l=>l.length-l.trimStart().length)),i=a.map(l=>l.slice(r)).map(l=>" ".repeat(this.indent*2)+l);for(const l of i)this.content.push(l)}compile(){const t=Function,n=this==null?void 0:this.args,r=[...((this==null?void 0:this.content)??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
|
|
78
78
|
`))}}const EA={major:4,minor:3,patch:6},_e=A("$ZodType",(e,t)=>{var r;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=EA;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const i of a)for(const l of i._zod.onattach)l(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const i=(s,o,u)=>{let f=di(s),c;for(const d of o){if(d._zod.def.when){if(!d._zod.def.when(s))continue}else if(f)continue;const m=s.issues.length,_=d._zod.check(s);if(_ instanceof Promise&&(u==null?void 0:u.async)===!1)throw new _i;if(c||_ instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await _,s.issues.length!==m&&(f||(f=di(s,m)))});else{if(s.issues.length===m)continue;f||(f=di(s,m))}}return c?c.then(()=>s):s},l=(s,o,u)=>{if(di(s))return s.aborted=!0,s;const f=i(o,a,u);if(f instanceof Promise){if(u.async===!1)throw new _i;return f.then(c=>e._zod.parse(c,u))}return e._zod.parse(f,u)};e._zod.run=(s,o)=>{if(o.skipChecks)return e._zod.parse(s,o);if(o.direction==="backward"){const f=e._zod.parse({value:s.value,issues:[]},{...o,skipChecks:!0});return f instanceof Promise?f.then(c=>l(c,s,o)):l(f,s,o)}const u=e._zod.parse(s,o);if(u instanceof Promise){if(o.async===!1)throw new _i;return u.then(f=>i(f,a,o))}return i(u,a,o)}}ue(e,"~standard",()=>({validate:i=>{var l;try{const s=CC(e,i);return s.success?{value:s.data}:{issues:(l=s.error)==null?void 0:l.issues}}catch{return AC(e,i).then(o=>{var u;return o.success?{value:o.data}:{issues:(u=o.error)==null?void 0:u.issues}})}},vendor:"zod",version:1}))}),$h=A("$ZodString",(e,t)=>{var n;_e.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??aA(e._zod.bag),e._zod.parse=(a,r)=>{if(t.coerce)try{a.value=String(a.value)}catch{}return typeof a.value=="string"||a.issues.push({expected:"string",code:"invalid_type",input:a.value,inst:e}),a}}),Ne=A("$ZodStringFormat",(e,t)=>{Pu.init(e,t),$h.init(e,t)}),xA=A("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=GC),Ne.init(e,t)}),wA=A("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Xp(a))}else t.pattern??(t.pattern=Xp());Ne.init(e,t)}),TA=A("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=VC),Ne.init(e,t)}),OA=A("$ZodURL",(e,t)=>{Ne.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),r=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=r.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),CA=A("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=YC()),Ne.init(e,t)}),AA=A("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=qC),Ne.init(e,t)}),NA=A("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=LC),Ne.init(e,t)}),zA=A("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=$C),Ne.init(e,t)}),RA=A("$ZodULID",(e,t)=>{t.pattern??(t.pattern=BC),Ne.init(e,t)}),jA=A("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ZC),Ne.init(e,t)}),MA=A("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=PC),Ne.init(e,t)}),DA=A("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=nA(t)),Ne.init(e,t)}),kA=A("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=eA),Ne.init(e,t)}),UA=A("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=tA(t)),Ne.init(e,t)}),LA=A("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=HC),Ne.init(e,t)}),$A=A("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=IC),Ne.init(e,t),e._zod.bag.format="ipv4"}),BA=A("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=FC),Ne.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),ZA=A("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=JC),Ne.init(e,t)}),PA=A("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=XC),Ne.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[r,i]=a;if(!i)throw new Error;const l=Number(i);if(`${l}`!==i)throw new Error;if(l<0||l>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function pS(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const qA=A("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=KC),Ne.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{pS(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function HA(e){if(!oS.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return pS(n)}const GA=A("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=oS),Ne.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{HA(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),VA=A("$ZodE164",(e,t)=>{t.pattern??(t.pattern=WC),Ne.init(e,t)});function QA(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const r=JSON.parse(atob(a));return!("typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const YA=A("$ZodJWT",(e,t)=>{Ne.init(e,t),e._zod.check=n=>{QA(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),vS=A("$ZodNumber",(e,t)=>{_e.init(e,t),e._zod.pattern=e._zod.bag.pattern??fS,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),IA=A("$ZodNumberFormat",(e,t)=>{cA.init(e,t),vS.init(e,t)}),FA=A("$ZodBoolean",(e,t)=>{_e.init(e,t),e._zod.pattern=iA,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),JA=A("$ZodNull",(e,t)=>{_e.init(e,t),e._zod.pattern=lA,e._zod.values=new Set([null]),e._zod.parse=(n,a)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),XA=A("$ZodAny",(e,t)=>{_e.init(e,t),e._zod.parse=n=>n}),KA=A("$ZodUnknown",(e,t)=>{_e.init(e,t),e._zod.parse=n=>n}),WA=A("$ZodNever",(e,t)=>{_e.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Kp(e,t,n){e.issues.length&&t.issues.push(...hi(n,e.issues)),t.value[n]=e.value}const eN=A("$ZodArray",(e,t)=>{_e.init(e,t),e._zod.parse=(n,a)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let l=0;l<r.length;l++){const s=r[l],o=t.element._zod.run({value:s,issues:[]},a);o instanceof Promise?i.push(o.then(u=>Kp(u,n,l))):Kp(o,n,l)}return i.length?Promise.all(i).then(()=>n):n}});function fu(e,t,n,a,r){if(e.issues.length){if(r&&!(n in a))return;t.issues.push(...hi(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function gS(e){var a,r,i,l;const t=Object.keys(e.shape);for(const s of t)if(!((l=(i=(r=(a=e.shape)==null?void 0:a[s])==null?void 0:r._zod)==null?void 0:i.traits)!=null&&l.has("$ZodType")))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);const n=vC(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function yS(e,t,n,a,r,i){const l=[],s=r.keySet,o=r.catchall._zod,u=o.def.type,f=o.optout==="optional";for(const c in t){if(s.has(c))continue;if(u==="never"){l.push(c);continue}const d=o.run({value:t[c],issues:[]},a);d instanceof Promise?e.push(d.then(m=>fu(m,n,c,t,f))):fu(d,n,c,t,f)}return l.length&&n.issues.push({code:"unrecognized_keys",keys:l,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const tN=A("$ZodObject",(e,t)=>{_e.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const o={...s};return Object.defineProperty(t,"shape",{value:o}),o}})}const a=jh(()=>gS(t));ue(e._zod,"propValues",()=>{const s=t.shape,o={};for(const u in s){const f=s[u]._zod;if(f.values){o[u]??(o[u]=new Set);for(const c of f.values)o[u].add(c)}}return o});const r=cu,i=t.catchall;let l;e._zod.parse=(s,o)=>{l??(l=a.value);const u=s.value;if(!r(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};const f=[],c=l.shape;for(const d of l.keys){const m=c[d],_=m._zod.optout==="optional",y=m._zod.run({value:u[d],issues:[]},o);y instanceof Promise?f.push(y.then(E=>fu(E,s,d,u,_))):fu(y,s,d,u,_)}return i?yS(f,u,s,o,a.value,e):f.length?Promise.all(f).then(()=>s):s}}),nN=A("$ZodObjectJIT",(e,t)=>{tN.init(e,t);const n=e._zod.parse,a=jh(()=>gS(t)),r=d=>{var g;const m=new _A(["shape","payload","ctx"]),_=a.value,y=b=>{const w=Jp(b);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};m.write("const input = payload.value;");const E=Object.create(null);let v=0;for(const b of _.keys)E[b]=`key_${v++}`;m.write("const newResult = {};");for(const b of _.keys){const w=E[b],C=Jp(b),O=d[b],T=((g=O==null?void 0:O._zod)==null?void 0:g.optout)==="optional";m.write(`const ${w} = ${y(b)};`),T?m.write(`
|
|
79
79
|
if (${w}.issues.length) {
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
<meta name="mobile-web-app-capable" content="yes" />
|
|
8
8
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
9
9
|
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
|
|
10
|
-
<meta name="apple-mobile-web-app-title" content="
|
|
10
|
+
<meta name="apple-mobile-web-app-title" content="Agent Message" />
|
|
11
11
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
12
12
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
|
|
13
13
|
<link rel="mask-icon" href="/masked-icon.svg" color="#2454d6" />
|
|
14
|
-
<title>Agent
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<title>Agent Message</title>
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-4VmoBZF3.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/assets/index-D_RPU5JN.css">
|
|
17
17
|
<link rel="manifest" href="/manifest.webmanifest"></head>
|
|
18
18
|
<body>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"Agent
|
|
1
|
+
{"name":"Agent Message","short_name":"Agent Message","description":"Phone-first direct messaging app for Agent Message.","start_url":"/","display":"standalone","background_color":"#edf3ff","theme_color":"#2454d6","lang":"en","scope":"/","orientation":"portrait","icons":[{"src":"/pwa-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/pwa-512x512.png","sizes":"512x512","type":"image/png"},{"src":"/pwa-512x512.png","sizes":"512x512","type":"image/png","purpose":"maskable"}]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
if(!self.define){let e,i={};const
|
|
1
|
+
if(!self.define){let e,i={};const f=(f,n)=>(f=new URL(f+".js",n).href,i[f]||new Promise(i=>{if("document"in self){const e=document.createElement("script");e.src=f,e.onload=i,document.head.appendChild(e)}else e=f,importScripts(f),i()}).then(()=>{let e=i[f];if(!e)throw new Error(`Module ${f} didn’t register its module`);return e}));self.define=(n,s)=>{const r=e||("document"in self?document.currentScript.src:"")||location.href;if(i[r])return;let o={};const c=e=>f(e,r),a={module:{uri:r},exports:o,require:c};i[r]=Promise.all(n.map(e=>a[e]||c(e))).then(e=>(s(...e),o))}}define(["./workbox-8c29f6e4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"pwa-artwork.svg",revision:"b6cd912f47cb1084766ffa3461841ff6"},{url:"pwa-512x512.png",revision:"982f113d9857d46ffc5756532cbfe29e"},{url:"pwa-192x192.png",revision:"e678c656ea024adfa691790ebad2b931"},{url:"masked-icon.svg",revision:"b6cd912f47cb1084766ffa3461841ff6"},{url:"manifest.webmanifest",revision:"f9d9be1d3c520fbbfc262ce9dfd18387"},{url:"index.html",revision:"cda4e7ee531be8e2e0364489a035dee3"},{url:"favicon.svg",revision:"b6cd912f47cb1084766ffa3461841ff6"},{url:"apple-touch-icon.png",revision:"daa24c2b94e19a9aaee9f4e93b71f52e"},{url:"assets/workbox-window.prod.es5-vqzQaGvo.js",revision:null},{url:"assets/index-D_RPU5JN.css",revision:null},{url:"assets/index-4VmoBZF3.js",revision:null},{url:"apple-touch-icon.png",revision:"daa24c2b94e19a9aaee9f4e93b71f52e"},{url:"favicon.svg",revision:"b6cd912f47cb1084766ffa3461841ff6"},{url:"masked-icon.svg",revision:"b6cd912f47cb1084766ffa3461841ff6"},{url:"pwa-192x192.png",revision:"e678c656ea024adfa691790ebad2b931"},{url:"pwa-512x512.png",revision:"982f113d9857d46ffc5756532cbfe29e"},{url:"manifest.webmanifest",revision:"f9d9be1d3c520fbbfc262ce9dfd18387"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("/index.html")))});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-message",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Agent
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Agent Message CLI and local stack launcher for macOS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"agent-
|
|
7
|
+
"agent-message": "./npm/bin/agent-message.mjs"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"README.md",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
],
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
|
-
"url": "https://github.com/siisee11/agent-
|
|
31
|
+
"url": "https://github.com/siisee11/agent-message.git"
|
|
32
32
|
}
|
|
33
33
|
}
|