mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-10-23 09:42:21 +00:00
Implement repeater CLI interface
This commit is contained in:
1 parent
e401a32049
commit
e262bd677a
18 files changed
+1155
-617
No files matched your search
@@ -181,6 +181,7 @@ All endpoints are prefixed with `/api` (e.g., `/api/health`).
|
||||
| GET | `/api/contacts` | List contacts |
|
||||
| POST | `/api/contacts/sync` | Pull from radio |
|
||||
| POST | `/api/contacts/{key}/telemetry` | Request telemetry from repeater |
|
||||
| POST | `/api/contacts/{key}/command` | Send CLI command to repeater |
|
||||
| GET | `/api/channels` | List channels |
|
||||
| POST | `/api/channels` | Create channel |
|
||||
| GET | `/api/messages` | List with filters |
|
||||
|
||||
+55
-1
@@ -360,7 +360,7 @@ PYTHONPATH=. uv run pytest tests/ -v
|
||||
Key test files:
|
||||
- `tests/test_decoder.py` - Channel + direct message decryption, key exchange, real-world test vectors
|
||||
- `tests/test_keystore.py` - Ephemeral key store operations
|
||||
- `tests/test_event_handlers.py` - ACK tracking, repeat detection
|
||||
- `tests/test_event_handlers.py` - ACK tracking, repeat detection, CLI response filtering
|
||||
- `tests/test_api.py` - API endpoint tests
|
||||
|
||||
## Common Tasks
|
||||
@@ -443,3 +443,57 @@ class TelemetryResponse(BaseModel):
|
||||
neighbors: list[NeighborInfo]
|
||||
acl: list[AclEntry]
|
||||
```
|
||||
|
||||
## Repeater CLI Commands
|
||||
|
||||
After login via telemetry endpoint, you can send CLI commands to repeaters:
|
||||
|
||||
### Endpoint
|
||||
|
||||
`POST /api/contacts/{key}/command` - Send a CLI command (assumes already logged in)
|
||||
|
||||
### Request/Response
|
||||
|
||||
```python
|
||||
class CommandRequest(BaseModel):
|
||||
command: str # CLI command to send
|
||||
|
||||
class CommandResponse(BaseModel):
|
||||
command: str # Echo of sent command
|
||||
response: str # Response from repeater
|
||||
sender_timestamp: int | None # Timestamp from response
|
||||
```
|
||||
|
||||
### Common Commands
|
||||
|
||||
```
|
||||
get name / set name <value> # Repeater name
|
||||
get tx / set tx <dbm> # TX power
|
||||
get radio / set radio <freq,bw,sf,cr> # Radio params
|
||||
tempradio <freq,bw,sf,cr,mins> # Temporary radio change
|
||||
setperm <pubkey> <0-3> # ACL: 0=guest, 1=ro, 2=rw, 3=admin
|
||||
clock / clock sync # Get/sync time
|
||||
ver # Firmware version
|
||||
reboot # Restart repeater
|
||||
```
|
||||
|
||||
### CLI Response Filtering
|
||||
|
||||
CLI responses have `txt_type=1` (vs `txt_type=0` for normal messages). The event handler
|
||||
in `event_handlers.py` skips these to prevent duplicates—the command endpoint returns
|
||||
the response directly, so we don't also store/broadcast via WebSocket.
|
||||
|
||||
```python
|
||||
# In on_contact_message()
|
||||
txt_type = payload.get("txt_type", 0)
|
||||
if txt_type == 1:
|
||||
return # Skip CLI responses
|
||||
```
|
||||
|
||||
### Helper Function
|
||||
|
||||
`prepare_repeater_connection()` handles the login dance:
|
||||
1. Sync contacts from radio
|
||||
2. Remove contact if exists (clears stale auth)
|
||||
3. Re-add with flood mode (`out_path_len=-1`)
|
||||
4. Send login with password
|
||||
@@ -44,6 +44,14 @@ async def on_contact_message(event: "Event") -> None:
|
||||
The packet processor cannot decrypt these without the node's private key.
|
||||
"""
|
||||
payload = event.payload
|
||||
|
||||
# Skip CLI command responses (txt_type=1) - these are handled by the command endpoint
|
||||
# and should not be stored in the database or broadcast via WebSocket
|
||||
txt_type = payload.get("txt_type", 0)
|
||||
if txt_type == 1:
|
||||
logger.debug("Skipping CLI response from %s (txt_type=1)", payload.get("pubkey_prefix"))
|
||||
return
|
||||
|
||||
logger.debug("Received direct message from %s", payload.get("pubkey_prefix"))
|
||||
|
||||
# Get full public key if available, otherwise use prefix
|
||||
|
||||
@@ -166,3 +166,15 @@ class TelemetryResponse(BaseModel):
|
||||
full_events: int = Field(description="Full event queue count")
|
||||
neighbors: list[NeighborInfo] = Field(default_factory=list, description="List of neighbors seen by repeater")
|
||||
acl: list[AclEntry] = Field(default_factory=list, description="Access control list")
|
||||
|
||||
|
||||
class CommandRequest(BaseModel):
|
||||
"""Request to send a CLI command to a repeater."""
|
||||
command: str = Field(min_length=1, description="CLI command to send")
|
||||
|
||||
|
||||
class CommandResponse(BaseModel):
|
||||
"""Response from a repeater CLI command."""
|
||||
command: str = Field(description="The command that was sent")
|
||||
response: str = Field(description="Response from the repeater")
|
||||
sender_timestamp: int | None = Field(default=None, description="Timestamp from the repeater's response")
|
||||
+157
-51
@@ -4,7 +4,16 @@ from fastapi import APIRouter, HTTPException, Query
|
||||
from meshcore import EventType
|
||||
|
||||
from app.dependencies import require_connected
|
||||
from app.models import Contact, TelemetryRequest, TelemetryResponse, NeighborInfo, AclEntry, CONTACT_TYPE_REPEATER
|
||||
from app.models import (
|
||||
Contact,
|
||||
TelemetryRequest,
|
||||
TelemetryResponse,
|
||||
NeighborInfo,
|
||||
AclEntry,
|
||||
CommandRequest,
|
||||
CommandResponse,
|
||||
CONTACT_TYPE_REPEATER,
|
||||
)
|
||||
|
||||
# ACL permission level names
|
||||
ACL_PERMISSION_NAMES = {
|
||||
@@ -20,6 +29,70 @@ logger = logging.getLogger(__name__)
|
||||
router = APIRouter(prefix="/contacts", tags=["contacts"])
|
||||
|
||||
|
||||
async def prepare_repeater_connection(mc, contact: Contact, password: str) -> None:
|
||||
"""Prepare connection to a repeater by removing/re-adding with flood mode and logging in.
|
||||
|
||||
This clears any stale auth state on the radio and establishes a fresh connection.
|
||||
|
||||
Args:
|
||||
mc: MeshCore instance
|
||||
contact: The repeater contact
|
||||
password: Password for login (empty string for no password)
|
||||
|
||||
Raises:
|
||||
HTTPException: If contact cannot be added or login fails
|
||||
"""
|
||||
# Sync contacts from radio to ensure our cache is up-to-date
|
||||
logger.info("Syncing contacts from radio before repeater connection")
|
||||
await mc.ensure_contacts()
|
||||
|
||||
# Remove contact if it exists (clears any stale auth state on radio)
|
||||
radio_contact = mc.get_contact_by_key_prefix(contact.public_key[:12])
|
||||
if radio_contact:
|
||||
logger.info("Removing existing contact %s from radio", contact.public_key[:12])
|
||||
await mc.commands.remove_contact(contact.public_key)
|
||||
await mc.commands.get_contacts()
|
||||
|
||||
# Add contact fresh with flood mode (matching test_telemetry.py pattern)
|
||||
logger.info("Adding repeater %s to radio with flood mode", contact.public_key[:12])
|
||||
contact_data = {
|
||||
"public_key": contact.public_key,
|
||||
"adv_name": contact.name or "",
|
||||
"type": contact.type,
|
||||
"flags": contact.flags,
|
||||
"out_path": "",
|
||||
"out_path_len": -1, # Flood mode
|
||||
"adv_lat": contact.lat or 0.0,
|
||||
"adv_lon": contact.lon or 0.0,
|
||||
"last_advert": contact.last_advert or 0,
|
||||
}
|
||||
add_result = await mc.commands.add_contact(contact_data)
|
||||
if add_result.type == EventType.ERROR:
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail=f"Failed to add contact to radio: {add_result.payload}"
|
||||
)
|
||||
|
||||
# Refresh and verify
|
||||
await mc.commands.get_contacts()
|
||||
radio_contact = mc.get_contact_by_key_prefix(contact.public_key[:12])
|
||||
if not radio_contact:
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail="Failed to add contact to radio - contact not found after add"
|
||||
)
|
||||
|
||||
# Send login with password
|
||||
logger.info("Sending login to repeater %s", contact.public_key[:12])
|
||||
login_result = await mc.commands.send_login(contact.public_key, password)
|
||||
|
||||
if login_result.type == EventType.ERROR:
|
||||
raise HTTPException(
|
||||
status_code=401,
|
||||
detail=f"Login failed: {login_result.payload}"
|
||||
)
|
||||
|
||||
|
||||
@router.get("", response_model=list[Contact])
|
||||
async def list_contacts(
|
||||
limit: int = Query(default=100, ge=1, le=1000),
|
||||
@@ -167,56 +240,8 @@ async def request_telemetry(public_key: str, request: TelemetryRequest) -> Telem
|
||||
detail=f"Contact is not a repeater (type={contact.type}, expected {CONTACT_TYPE_REPEATER})"
|
||||
)
|
||||
|
||||
# Sync contacts from radio to ensure our cache is up-to-date
|
||||
logger.info("Syncing contacts from radio before telemetry request")
|
||||
await mc.ensure_contacts()
|
||||
|
||||
# Remove contact if it exists (clears any stale auth state on radio)
|
||||
radio_contact = mc.get_contact_by_key_prefix(contact.public_key[:12])
|
||||
if radio_contact:
|
||||
logger.info("Removing existing contact %s from radio", contact.public_key[:12])
|
||||
await mc.commands.remove_contact(contact.public_key)
|
||||
await mc.commands.get_contacts()
|
||||
|
||||
# Add contact fresh with flood mode (matching test_telemetry.py pattern)
|
||||
logger.info("Adding repeater %s to radio with flood mode", contact.public_key[:12])
|
||||
contact_data = {
|
||||
"public_key": contact.public_key,
|
||||
"adv_name": contact.name or "",
|
||||
"type": contact.type,
|
||||
"flags": contact.flags,
|
||||
"out_path": "",
|
||||
"out_path_len": -1, # Flood mode
|
||||
"adv_lat": contact.lat or 0.0,
|
||||
"adv_lon": contact.lon or 0.0,
|
||||
"last_advert": contact.last_advert or 0,
|
||||
}
|
||||
add_result = await mc.commands.add_contact(contact_data)
|
||||
if add_result.type == EventType.ERROR:
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail=f"Failed to add contact to radio: {add_result.payload}"
|
||||
)
|
||||
|
||||
# Refresh and verify
|
||||
await mc.commands.get_contacts()
|
||||
radio_contact = mc.get_contact_by_key_prefix(contact.public_key[:12])
|
||||
if not radio_contact:
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail="Failed to add contact to radio - contact not found after add"
|
||||
)
|
||||
|
||||
# Send login with password
|
||||
password = request.password
|
||||
logger.info("Sending login to repeater %s", contact.public_key[:12])
|
||||
login_result = await mc.commands.send_login(contact.public_key, password)
|
||||
|
||||
if login_result.type == EventType.ERROR:
|
||||
raise HTTPException(
|
||||
status_code=401,
|
||||
detail=f"Login failed: {login_result.payload}"
|
||||
)
|
||||
# Prepare connection (add/remove dance + login)
|
||||
await prepare_repeater_connection(mc, contact, request.password)
|
||||
|
||||
# Request status with retries
|
||||
logger.info("Requesting status from repeater %s", contact.public_key[:12])
|
||||
@@ -323,3 +348,84 @@ async def request_telemetry(public_key: str, request: TelemetryRequest) -> Telem
|
||||
neighbors=neighbors,
|
||||
acl=acl_entries,
|
||||
)
|
||||
|
||||
|
||||
@router.post("/{public_key}/command", response_model=CommandResponse)
|
||||
async def send_repeater_command(public_key: str, request: CommandRequest) -> CommandResponse:
|
||||
"""Send a CLI command to a repeater.
|
||||
|
||||
The contact must be a repeater (type=2). This endpoint assumes the user has already
|
||||
logged in via the telemetry endpoint - it does NOT perform the add/remove dance
|
||||
or login again.
|
||||
|
||||
Common commands:
|
||||
- get name, set name <value>
|
||||
- get tx, set tx <dbm>
|
||||
- get radio, set radio <freq,bw,sf,cr>
|
||||
- tempradio <freq,bw,sf,cr,minutes>
|
||||
- setperm <pubkey> <permission> (0=guest, 1=read-only, 2=read-write, 3=admin)
|
||||
- clock, clock sync
|
||||
- reboot
|
||||
- ver
|
||||
"""
|
||||
mc = require_connected()
|
||||
|
||||
# Get contact from database
|
||||
contact = await ContactRepository.get_by_key_or_prefix(public_key)
|
||||
if not contact:
|
||||
raise HTTPException(status_code=404, detail="Contact not found")
|
||||
|
||||
# Verify it's a repeater
|
||||
if contact.type != CONTACT_TYPE_REPEATER:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail=f"Contact is not a repeater (type={contact.type}, expected {CONTACT_TYPE_REPEATER})"
|
||||
)
|
||||
|
||||
# Send the command
|
||||
logger.info("Sending command to repeater %s: %s", contact.public_key[:12], request.command)
|
||||
|
||||
send_result = await mc.commands.send_cmd(contact.public_key, request.command)
|
||||
|
||||
if send_result.type == EventType.ERROR:
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail=f"Failed to send command: {send_result.payload}"
|
||||
)
|
||||
|
||||
# Wait for response (MESSAGES_WAITING event, then get_msg)
|
||||
try:
|
||||
wait_result = await mc.wait_for_event(EventType.MESSAGES_WAITING, timeout=10.0)
|
||||
|
||||
if wait_result is None:
|
||||
# Timeout - no response received
|
||||
logger.warning("No response from repeater %s for command: %s", contact.public_key[:12], request.command)
|
||||
return CommandResponse(
|
||||
command=request.command,
|
||||
response="(no response - command may have been processed)"
|
||||
)
|
||||
|
||||
response_event = await mc.commands.get_msg()
|
||||
|
||||
if response_event.type == EventType.ERROR:
|
||||
return CommandResponse(
|
||||
command=request.command,
|
||||
response=f"(error: {response_event.payload})"
|
||||
)
|
||||
|
||||
# Extract the response text and timestamp from the payload
|
||||
response_text = response_event.payload.get("text", str(response_event.payload))
|
||||
sender_timestamp = response_event.payload.get("timestamp")
|
||||
logger.info("Received response from %s: %s", contact.public_key[:12], response_text)
|
||||
|
||||
return CommandResponse(
|
||||
command=request.command,
|
||||
response=response_text,
|
||||
sender_timestamp=sender_timestamp,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error("Error waiting for response: %s", e)
|
||||
return CommandResponse(
|
||||
command=request.command,
|
||||
response=f"(error waiting for response: {e})"
|
||||
)
|
||||
+50
-8
@@ -144,6 +144,9 @@ await api.reconnectRadio(); // Returns { status, message, connected }
|
||||
|
||||
// Repeater telemetry
|
||||
await api.requestTelemetry(publicKey, password); // Returns TelemetryResponse
|
||||
|
||||
// Repeater CLI commands (after login)
|
||||
await api.sendRepeaterCommand(publicKey, 'ver'); // Returns CommandResponse
|
||||
```
|
||||
|
||||
### API Proxy (Development)
|
||||
@@ -232,6 +235,12 @@ interface TelemetryResponse {
|
||||
neighbors: NeighborInfo[];
|
||||
acl: AclEntry[];
|
||||
}
|
||||
|
||||
interface CommandResponse {
|
||||
command: string;
|
||||
response: string;
|
||||
sender_timestamp: number | null;
|
||||
}
|
||||
```
|
||||
|
||||
## Component Patterns
|
||||
@@ -264,24 +273,56 @@ messageInputRef.current?.appendText(`@[${sender}] `);
|
||||
|
||||
### Repeater Mode
|
||||
|
||||
When selecting a repeater contact (type=2), MessageInput switches to password mode:
|
||||
Repeater contacts (type=2) have a two-phase interaction:
|
||||
|
||||
**Phase 1: Login (password mode)**
|
||||
- Input type changes to `password`
|
||||
- Button shows "Fetch" instead of "Send"
|
||||
- Submitting requests telemetry instead of sending a message
|
||||
- Enter "." for empty password
|
||||
- Enter "." for empty password (converted to empty string)
|
||||
- Submitting requests telemetry + logs in
|
||||
|
||||
**Phase 2: CLI commands (after login)**
|
||||
- Input switches back to normal text
|
||||
- Placeholder shows "Enter CLI command..."
|
||||
- Commands sent via `/contacts/{key}/command` endpoint
|
||||
- Responses displayed as local messages (not persisted to database)
|
||||
|
||||
```typescript
|
||||
// State tracking
|
||||
const [repeaterLoggedIn, setRepeaterLoggedIn] = useState(false);
|
||||
|
||||
// Reset on conversation change
|
||||
useEffect(() => {
|
||||
setRepeaterLoggedIn(false);
|
||||
}, [activeConversation?.id]);
|
||||
|
||||
// Mode switches after successful telemetry
|
||||
const isRepeaterMode = activeContactIsRepeater && !repeaterLoggedIn;
|
||||
|
||||
<MessageInput
|
||||
onSend={activeContactIsRepeater ? handleTelemetryRequest : handleSendMessage}
|
||||
isRepeaterMode={activeContactIsRepeater}
|
||||
onSend={isRepeaterMode ? handleTelemetryRequest :
|
||||
(repeaterLoggedIn ? handleRepeaterCommand : handleSendMessage)}
|
||||
isRepeaterMode={isRepeaterMode}
|
||||
placeholder={repeaterLoggedIn ? 'Enter CLI command...' : undefined}
|
||||
/>
|
||||
```
|
||||
|
||||
Telemetry response is displayed as three local messages (not persisted):
|
||||
1. **[Telemetry]** - Battery voltage, uptime, signal quality, packet stats
|
||||
2. **[Neighbors]** - Sorted by SNR (highest first), with resolved names
|
||||
3. **[ACL]** - Access control list with permission levels
|
||||
1. **Telemetry** - Battery voltage, uptime, signal quality, packet stats
|
||||
2. **Neighbors** - Sorted by SNR (highest first), with resolved names
|
||||
3. **ACL** - Access control list with permission levels
|
||||
|
||||
### Repeater Message Rendering
|
||||
|
||||
Repeater CLI responses often contain colons (e.g., `clock: 12:30:00`). To prevent
|
||||
incorrect sender parsing, MessageList skips `parseSenderFromText()` for repeater contacts:
|
||||
|
||||
```typescript
|
||||
const isRepeater = contact?.type === CONTACT_TYPE_REPEATER;
|
||||
const { sender, content } = isRepeater
|
||||
? { sender: null, content: msg.text } // Preserve full text
|
||||
: parseSenderFromText(msg.text);
|
||||
```
|
||||
|
||||
### Unread Count Tracking
|
||||
|
||||
@@ -432,6 +473,7 @@ npm run test # Watch mode
|
||||
- `contactAvatar.test.ts` - Avatar text extraction, color generation, repeater handling
|
||||
- `messageDeduplication.test.ts` - Message deduplication logic
|
||||
- `websocket.test.ts` - WebSocket message routing
|
||||
- `repeaterMode.test.ts` - Repeater CLI parsing, password "." conversion
|
||||
|
||||
### Test Setup
|
||||
|
||||
|
||||
-537
@@ -1,537 +0,0 @@
|
||||
var Yv=Object.defineProperty;var Zv=(a,r,o)=>r in a?Yv(a,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[r]=o;var Ln=(a,r,o)=>Zv(a,typeof r!="symbol"?r+"":r,o);function Xv(a,r){for(var o=0;o<r.length;o++){const t=r[o];if(typeof t!="string"&&!Array.isArray(t)){for(const u in t)if(u!=="default"&&!(u in a)){const l=Object.getOwnPropertyDescriptor(t,u);l&&Object.defineProperty(a,u,l.get?l:{enumerable:!0,get:()=>t[u]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))t(u);new MutationObserver(u=>{for(const l of u)if(l.type==="childList")for(const m of l.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&t(m)}).observe(document,{childList:!0,subtree:!0});function o(u){const l={};return u.integrity&&(l.integrity=u.integrity),u.referrerPolicy&&(l.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?l.credentials="include":u.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function t(u){if(u.ep)return;u.ep=!0;const l=o(u);fetch(u.href,l)}})();var Yc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fo(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function Vg(a){if(Object.prototype.hasOwnProperty.call(a,"__esModule"))return a;var r=a.default;if(typeof r=="function"){var o=function t(){return this instanceof t?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};o.prototype=r.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(a).forEach(function(t){var u=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(o,t,u.get?u:{enumerable:!0,get:function(){return a[t]}})}),o}var Zc={exports:{}},br={},Xc={exports:{}},Pe={};/**
|
||||
* @license React
|
||||
* react.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var Mm;function Jv(){if(Mm)return Pe;Mm=1;var a=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),t=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),m=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),g=Symbol.iterator;function f(j){return j===null||typeof j!="object"?null:(j=g&&j[g]||j["@@iterator"],typeof j=="function"?j:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,q={};function v(j,I,V){this.props=j,this.context=I,this.refs=q,this.updater=V||x}v.prototype.isReactComponent={},v.prototype.setState=function(j,I){if(typeof j!="object"&&typeof j!="function"&&j!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,j,I,"setState")},v.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function A(){}A.prototype=v.prototype;function C(j,I,V){this.props=j,this.context=I,this.refs=q,this.updater=V||x}var w=C.prototype=new A;w.constructor=C,k(w,v.prototype),w.isPureReactComponent=!0;var _=Array.isArray,z=Object.prototype.hasOwnProperty,D={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function F(j,I,V){var Q,de={},he=null,ge=null;if(I!=null)for(Q in I.ref!==void 0&&(ge=I.ref),I.key!==void 0&&(he=""+I.key),I)z.call(I,Q)&&!R.hasOwnProperty(Q)&&(de[Q]=I[Q]);var se=arguments.length-2;if(se===1)de.children=V;else if(1<se){for(var ce=Array(se),je=0;je<se;je++)ce[je]=arguments[je+2];de.children=ce}if(j&&j.defaultProps)for(Q in se=j.defaultProps,se)de[Q]===void 0&&(de[Q]=se[Q]);return{$$typeof:a,type:j,key:he,ref:ge,props:de,_owner:D.current}}function O(j,I){return{$$typeof:a,type:j.type,key:I,ref:j.ref,props:j.props,_owner:j._owner}}function P(j){return typeof j=="object"&&j!==null&&j.$$typeof===a}function T(j){var I={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(V){return I[V]})}var W=/\/+/g;function H(j,I){return typeof j=="object"&&j!==null&&j.key!=null?T(""+j.key):I.toString(36)}function Y(j,I,V,Q,de){var he=typeof j;(he==="undefined"||he==="boolean")&&(j=null);var ge=!1;if(j===null)ge=!0;else switch(he){case"string":case"number":ge=!0;break;case"object":switch(j.$$typeof){case a:case r:ge=!0}}if(ge)return ge=j,de=de(ge),j=Q===""?"."+H(ge,0):Q,_(de)?(V="",j!=null&&(V=j.replace(W,"$&/")+"/"),Y(de,I,V,"",function(je){return je})):de!=null&&(P(de)&&(de=O(de,V+(!de.key||ge&&ge.key===de.key?"":(""+de.key).replace(W,"$&/")+"/")+j)),I.push(de)),1;if(ge=0,Q=Q===""?".":Q+":",_(j))for(var se=0;se<j.length;se++){he=j[se];var ce=Q+H(he,se);ge+=Y(he,I,V,ce,de)}else if(ce=f(j),typeof ce=="function")for(j=ce.call(j),se=0;!(he=j.next()).done;)he=he.value,ce=Q+H(he,se++),ge+=Y(he,I,V,ce,de);else if(he==="object")throw I=String(j),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(j).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.");return ge}function ae(j,I,V){if(j==null)return j;var Q=[],de=0;return Y(j,Q,"","",function(he){return I.call(V,he,de++)}),Q}function ee(j){if(j._status===-1){var I=j._result;I=I(),I.then(function(V){(j._status===0||j._status===-1)&&(j._status=1,j._result=V)},function(V){(j._status===0||j._status===-1)&&(j._status=2,j._result=V)}),j._status===-1&&(j._status=0,j._result=I)}if(j._status===1)return j._result.default;throw j._result}var ne={current:null},$={transition:null},re={ReactCurrentDispatcher:ne,ReactCurrentBatchConfig:$,ReactCurrentOwner:D};function ie(){throw Error("act(...) is not supported in production builds of React.")}return Pe.Children={map:ae,forEach:function(j,I,V){ae(j,function(){I.apply(this,arguments)},V)},count:function(j){var I=0;return ae(j,function(){I++}),I},toArray:function(j){return ae(j,function(I){return I})||[]},only:function(j){if(!P(j))throw Error("React.Children.only expected to receive a single React element child.");return j}},Pe.Component=v,Pe.Fragment=o,Pe.Profiler=u,Pe.PureComponent=C,Pe.StrictMode=t,Pe.Suspense=h,Pe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=re,Pe.act=ie,Pe.cloneElement=function(j,I,V){if(j==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+j+".");var Q=k({},j.props),de=j.key,he=j.ref,ge=j._owner;if(I!=null){if(I.ref!==void 0&&(he=I.ref,ge=D.current),I.key!==void 0&&(de=""+I.key),j.type&&j.type.defaultProps)var se=j.type.defaultProps;for(ce in I)z.call(I,ce)&&!R.hasOwnProperty(ce)&&(Q[ce]=I[ce]===void 0&&se!==void 0?se[ce]:I[ce])}var ce=arguments.length-2;if(ce===1)Q.children=V;else if(1<ce){se=Array(ce);for(var je=0;je<ce;je++)se[je]=arguments[je+2];Q.children=se}return{$$typeof:a,type:j.type,key:de,ref:he,props:Q,_owner:ge}},Pe.createConLine truncated
|
||||
* @license React
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var Lm;function ek(){if(Lm)return br;Lm=1;var a=Tu(),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),t=Object.prototype.hasOwnProperty,u=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function m(c,h,d){var y,g={},f=null,x=null;d!==void 0&&(f=""+d),h.key!==void 0&&(f=""+h.key),h.ref!==void 0&&(x=h.ref);for(y in h)t.call(h,y)&&!l.hasOwnProperty(y)&&(g[y]=h[y]);if(c&&c.defaultProps)for(y in h=c.defaultProps,h)g[y]===void 0&&(g[y]=h[y]);return{$$typeof:r,type:c,key:f,ref:x,props:g,_owner:u.current}}return br.Fragment=o,br.jsx=m,br.jsxs=m,br}var Hm;function ik(){return Hm||(Hm=1,Zc.exports=ek()),Zc.exports}var B=ik(),S=Tu();const me=Fo(S),Pu=Xv({__proto__:null,default:me},[S]);var Ks={},Jc={exports:{}},aa={},eu={exports:{}},iu={};/**
|
||||
* @license React
|
||||
* scheduler.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var Vm;function ak(){return Vm||(Vm=1,(function(a){function r($,re){var ie=$.length;$.push(re);e:for(;0<ie;){var j=ie-1>>>1,I=$[j];if(0<u(I,re))$[j]=re,$[ie]=I,ie=j;else break e}}function o($){return $.length===0?null:$[0]}function t($){if($.length===0)return null;var re=$[0],ie=$.pop();if(ie!==re){$[0]=ie;e:for(var j=0,I=$.length,V=I>>>1;j<V;){var Q=2*(j+1)-1,de=$[Q],he=Q+1,ge=$[he];if(0>u(de,ie))he<I&&0>u(ge,de)?($[j]=ge,$[he]=ie,j=he):($[j]=de,$[Q]=ie,j=Q);else if(he<I&&0>u(ge,ie))$[j]=ge,$[he]=ie,j=he;else break e}}return re}function u($,re){var ie=$.sortIndex-re.sortIndex;return ie!==0?ie:$.id-re.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;a.unstable_now=function(){return l.now()}}else{var m=Date,c=m.now();a.unstable_now=function(){return m.now()-c}}var h=[],d=[],y=1,g=null,f=3,x=!1,k=!1,q=!1,v=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w($){for(var re=o(d);re!==null;){if(re.callback===null)t(d);else if(re.startTime<=$)t(d),re.sortIndex=re.expirationTime,r(h,re);else break;re=o(d)}}function _($){if(q=!1,w($),!k)if(o(h)!==null)k=!0,ee(z);else{var re=o(d);re!==null&&ne(_,re.startTime-$)}}function z($,re){k=!1,q&&(q=!1,A(F),F=-1),x=!0;var ie=f;try{for(w(re),g=o(h);g!==null&&(!(g.expirationTime>re)||$&&!T());){var j=g.callback;if(typeof j=="function"){g.callback=null,f=g.priorityLevel;var I=j(g.expirationTime<=re);re=a.unstable_now(),typeof I=="function"?g.callback=I:g===o(h)&&t(h),w(re)}else t(h);g=o(h)}if(g!==null)var V=!0;else{var Q=o(d);Q!==null&&ne(_,Q.startTime-re),V=!1}return V}finally{g=null,f=ie,x=!1}}var D=!1,R=null,F=-1,O=5,P=-1;function T(){return!(a.unstable_now()-P<O)}function W(){if(R!==null){var $=a.unstable_now();P=$;var re=!0;try{re=R(!0,$)}finally{re?H():(D=!1,R=null)}}else D=!1}var H;if(typeof C=="function")H=function(){C(W)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,ae=Y.port2;Y.port1.onmessage=W,H=function(){ae.postMessage(null)}}else H=function(){v(W,0)};function ee($){R=$,D||(D=!0,H())}function ne($,re){F=v(function(){$(a.unstable_now())},re)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function($){$.callback=null},a.unstable_continueExecution=function(){k||x||(k=!0,ee(z))},a.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<$?Math.floor(1e3/$):5},a.unstable_getCurrentPriorityLevel=function(){return f},a.unstable_getFirstCallbackNode=function(){return o(h)},a.unstable_next=function($){switch(f){case 1:case 2:case 3:var re=3;break;default:re=f}var ie=f;f=re;try{return $()}finally{f=ie}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function($,re){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var ie=f;f=$;try{return re()}finally{f=ie}},a.unstable_scheduleCallback=function($,re,ie){var j=a.unstable_now();switch(typeof ie=="object"&&ie!==null?(ie=ie.delay,ie=typeof ie=="number"&&0<ie?j+ie:j):ie=j,$){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=ie+I,$={id:y++,callback:re,priorityLevel:$,startTime:ie,expirationTime:I,sortIndex:-1},ie>j?($.sortIndex=ie,r(d,$),o(h)===null&&$===o(d)&&(q?(A(F),F=-1):q=!0,ne(_,ie-j))):($.sortIndex=I,r(h,$),k||x||(k=!0,ee(z))),$},a.unstable_shouldYield=T,a.unstable_wrapCallback=function($){var re=f;return function(){var ie=f;f=re;try{return $.apply(this,arguments)}finally{f=ie}}}})(iu)),iu}var Um;function nk(){return Um||(Um=1,eu.exports=ak()),eu.exports}/**
|
||||
* @license React
|
||||
* react-dom.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var Wm;function ok(){if(Wm)return aa;Wm=1;var a=Tu(),r=nk();function o(e){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)i+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var t=new Set,u={};function l(e,i){m(e,i),m(e+"Capture",i)}function m(e,i){for(u[e]=i,e=0;e<i.length;e++)t.add(i[e])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,y={},g={};function f(e){return h.call(g,e)?!0:h.call(y,e)?!1:d.test(e)?g[e]=!0:(y[e]=!0,!1)}function x(e,i,n,s){if(n!==null&&n.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return s?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,i,n,s){if(i===null||typeof i>"u"||x(e,i,n,s))return!0;if(s)return!1;if(n!==null)switch(n.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function q(e,i,n,s,p,b,E){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=s,this.attributeNamespace=p,this.mustUseProperty=n,this.propertyName=e,this.type=i,this.sanitizeURL=b,this.removeEmptyString=E}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){v[e]=new q(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var i=e[0];v[i]=new q(i,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){v[e]=new q(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){v[e]=new q(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){v[e]=new q(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){v[e]=new q(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){v[e]=new q(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){v[e]=new q(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){v[e]=new q(e,5,!1,e.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function C(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var i=e.replace(A,C);v[i]=new q(i,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var i=e.replace(A,C);v[i]=new q(i,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var i=e.replace(A,C);v[i]=new q(i,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){v[e]=new q(e,1,!1,e.toLowerCase(),null,!1,!1)}),v.xlinkHref=new q("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){v[e]=new q(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,i,n,s){var p=v.hasOwnProperty(i)?v[i]:null;(p!==null?p.type!==0:s||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=
Line truncated
|
||||
`+j+e}var V=!1;function Q(e,i){if(!e||V)return"";V=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(X){var s=X}Reflect.construct(e,[],i)}else{try{i.call()}catch(X){s=X}e.call(i.prototype)}else{try{throw Error()}catch(X){s=X}e()}}catch(X){if(X&&s&&typeof X.stack=="string"){for(var p=X.stack.split(`
|
||||
`),b=s.stack.split(`
|
||||
`),E=p.length-1,N=b.length-1;1<=E&&0<=N&&p[E]!==b[N];)N--;for(;1<=E&&0<=N;E--,N--)if(p[E]!==b[N]){if(E!==1||N!==1)do if(E--,N--,0>N||p[E]!==b[N]){var M=`
|
||||
`+p[E].replace(" at new "," at ");return e.displayName&&M.includes("<anonymous>")&&(M=M.replace("<anonymous>",e.displayName)),M}while(1<=E&&0<=N);break}}}finally{V=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?I(e):""}function de(e){switch(e.tag){case 5:return I(e.type);case 16:return I("Lazy");case 13:return I("Suspense");case 19:return I("SuspenseList");case 0:case 2:case 15:return e=Q(e.type,!1),e;case 11:return e=Q(e.type.render,!1),e;case 1:return e=Q(e.type,!0),e;default:return""}}function he(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case D:return"Portal";case O:return"Profiler";case F:return"StrictMode";case H:return"Suspense";case Y:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case T:return(e.displayName||"Context")+".Consumer";case P:return(e._context.displayName||"Context")+".Provider";case W:var i=e.render;return e=e.displayName,e||(e=i.displayName||i.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ae:return i=e.displayName||null,i!==null?i:he(e.type)||"Memo";case ee:i=e._payload,e=e._init;try{return he(e(i))}catch{}}return null}function ge(e){var i=e.type;switch(e.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=i.render,e=e.displayName||e.name||"",i.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return he(i);case 8:return i===F?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function se(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ce(e){var i=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function je(e){var i=ce(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,i),s=""+e[i];if(!e.hasOwnProperty(i)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var p=n.get,b=n.set;return Object.defineProperty(e,i,{configurable:!0,get:function(){return p.call(this)},set:function(E){s=""+E,b.call(this,E)}}),Object.defineProperty(e,i,{enumerable:n.enumerable}),{getValue:function(){return s},setValue:function(E){s=""+E},stopTracking:function(){e._valueTracker=null,delete e[i]}}}}function De(e){e._valueTracker||(e._valueTracker=je(e))}function Ze(e){if(!e)return!1;var i=e._valueTracker;if(!i)return!0;var n=i.getValue(),s="";return e&&(s=ce(e)?e.checked?"true":"false":e.value),e=s,e!==n?(i.setValue(e),!0):!1}function ai(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Le(e,i){var n=i.checked;return ie({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function He(e,i){var n=i.defaultValue==null?"":i.defaultValue,s=i.checked!=null?i.checked:i.defaultChecked;n=se(i.value!=null?i.value:n),e._wrapperState={initialChecked:s,initialValue:n,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Me(e,i){i=i.checked,i!=null&&w(e,"checked",i,!1)}function Ve(e,i){Me(e,i);var n=se(i.value),s=i.type;if(n!=null)s==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}i.hasOwnProperty("value")?ni(e,i.type,n):i.hasOwnProperty("defaultValue")&&ni(e,i.type,se(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(e.defaultChecked=!!i.defaultChecked)}function Qe(e,i,n){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var s=i.type;if(!(s!=="submit"&&s!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+e._wrapperState.initialValue,n||i===e.value||(e.value=i),e.defaultValue=i}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ni(e,i,n){(i!=="number"||ai(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var fi=Array.isArray;function si(e,i,n,s){if(e=e.options,i){i={};for(var p=0;p<n.length;p++)i["$"+n[p]]=!0;for(n=0;n<e.length;n++)p=i.hasOwnProperty("$"+e[n].value),e[n].selected!==p&&(e[n].selected=p),p&&s&&(e[n].defaultSelected=!0)}else{for(n=""+se(n),i=null,p=0;p<e.length;p++){if(e[p].value===n){e[p].selected=!0,s&&(e[p].defaultSelected=!0);return}i!==null||e[p].disabled||(i=e[p])}i!==null&&(i.selected=!0)}}function Ue(e,i){if(i.dangerouslySetInnerHTML
Line truncated
|
||||
`).replace(cv,"")}function ls(e,i,n){if(i=op(i),op(e)!==i&&n)throw Error(o(425))}function cs(){}var Ll=null,Hl=null;function Vl(e,i){return e==="textarea"||e==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Ul=typeof setTimeout=="function"?setTimeout:void 0,uv=typeof clearTimeout=="function"?clearTimeout:void 0,rp=typeof Promise=="function"?Promise:void 0,dv=typeof queueMicrotask=="function"?queueMicrotask:typeof rp<"u"?function(e){return rp.resolve(null).then(e).catch(pv)}:Ul;function pv(e){setTimeout(function(){throw e})}function Wl(e,i){var n=i,s=0;do{var p=n.nextSibling;if(e.removeChild(n),p&&p.nodeType===8)if(n=p.data,n==="/$"){if(s===0){e.removeChild(p),Uo(i);return}s--}else n!=="$"&&n!=="$?"&&n!=="$!"||s++;n=p}while(n);Uo(i)}function un(e){for(;e!=null;e=e.nextSibling){var i=e.nodeType;if(i===1||i===3)break;if(i===8){if(i=e.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return e}function sp(e){e=e.previousSibling;for(var i=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(i===0)return e;i--}else n==="/$"&&i++}e=e.previousSibling}return null}var so=Math.random().toString(36).slice(2),Fa="__reactFiber$"+so,ir="__reactProps$"+so,Va="__reactContainer$"+so,$l="__reactEvents$"+so,mv="__reactListeners$"+so,hv="__reactHandles$"+so;function Sn(e){var i=e[Fa];if(i)return i;for(var n=e.parentNode;n;){if(i=n[Va]||n[Fa]){if(n=i.alternate,i.child!==null||n!==null&&n.child!==null)for(e=sp(e);e!==null;){if(n=e[Fa])return n;e=sp(e)}return i}e=n,n=e.parentNode}return null}function ar(e){return e=e[Fa]||e[Va],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function to(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(o(33))}function us(e){return e[ir]||null}var Ql=[],lo=-1;function dn(e){return{current:e}}function li(e){0>lo||(e.current=Ql[lo],Ql[lo]=null,lo--)}function ri(e,i){lo++,Ql[lo]=e.current,e.current=i}var pn={},Li=dn(pn),Zi=dn(!1),Bn=pn;function co(e,i){var n=e.type.contextTypes;if(!n)return pn;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===i)return s.__reactInternalMemoizedMaskedChildContext;var p={},b;for(b in n)p[b]=i[b];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=p),p}function Xi(e){return e=e.childContextTypes,e!=null}function ds(){li(Zi),li(Li)}function tp(e,i,n){if(Li.current!==pn)throw Error(o(168));ri(Li,i),ri(Zi,n)}function lp(e,i,n){var s=e.stateNode;if(i=i.childContextTypes,typeof s.getChildContext!="function")return n;s=s.getChildContext();for(var p in s)if(!(p in i))throw Error(o(108,ge(e)||"Unknown",p));return ie({},n,s)}function ps(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||pn,Bn=Li.current,ri(Li,e),ri(Zi,Zi.current),!0}function cp(e,i,n){var s=e.stateNode;if(!s)throw Error(o(169));n?(e=lp(e,i,Bn),s.__reactInternalMemoizedMergedChildContext=e,li(Zi),li(Li),ri(Li,e)):li(Zi),ri(Zi,n)}var Ua=null,ms=!1,Gl=!1;function up(e){Ua===null?Ua=[e]:Ua.push(e)}function gv(e){ms=!0,up(e)}function mn(){if(!Gl&&Ua!==null){Gl=!0;var e=0,i=Xe;try{var n=Ua;for(Xe=1;e<n.length;e++){var s=n[e];do s=s(!0);while(s!==null)}Ua=null,ms=!1}catch(p){throw Ua!==null&&(Ua=Ua.slice(e+1)),pd(yl,mn),p}finally{Xe=i,Gl=!1}}return null}var uo=[],po=0,hs=null,gs=0,da=[],pa=0,_n=null,Wa=1,$a="";function Dn(e,i){uo[po++]=gs,uo[po++]=hs,hs=e,gs=i}function dp(e,i,n){da[pa++]=Wa,da[pa++]=$a,da[pa++]=_n,_n=e;var s=Wa;e=$a;var p=32-xa(s)-1;s&=~(1<<p),n+=1;var b=32-xa(i)+p;if(30<b){var E=p-p%5;b=(s&(1<<E)-1).toString(32),s>>=E,p-=E,Wa=1<<32-xa(i)+p|n<<p|s,$a=b+e}else Wa=1<<b|n<<p|s,$a=e}function Kl(e){e.return!==null&&(Dn(e,1),dp(e,1,0))}function Yl(e){for(;e===hs;)hs=uo[--po],uo[po]=null,gs=uo[--po],uo[po]=null;for(;e===_n;)_n=da[--pa],da[pa]=null,$a=da[--pa],da[pa]=null,Wa=da[--pa],da[pa]=null}var sa=null,ta=null,ci=!1,qa=null;function pp(e,i){var n=ya(5,null,null,0);n.elementType="DELETED",n.stateNode=i,n.return=e,i=e.deletions,i===null?(e.deletions=[n],e.flags|=16):i.push(n)}function mp(e,i){switch(e.tag){case 5:var n=e.type;return i=i.nodeType!==1||n.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(e.stateNode=i,sa=e,ta=un(i.firstChild),!0):!1;case 6:return i=e.pendingProps===""||i.nodeType!==3?null:i,i!==null?(e.stateNode=i,sa=e,ta=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(n=_n!==null?{id:Wa,overflow:$a}:null,e.memoizedState={dehydrated:i,treeContext:n,retryLane:1073741824},n=ya(18,null,null,0),n.stateNode=i,n.return=e,e.child=n,sa=e,ta=null,!0):!1;default:return!1}}function Zl(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Xl(e){if(ci){var i=ta;if(i){var n=i;if(!mp(e,i)){if(Zl(e))throw Error(o(418));i=un(n.nextSibling);var s=sa;i&&mp(e,i)?pp(s,n):(e.flags=e.flags&-4097|2,ci=!1,sa=e)}}else{if(Zl(e))throw Error(o(418));e.flags=e.flags&-4097|2,ci=!1,sa=e}}}function hp(e){for(e=e
Line truncated
|
||||
Error generating stack: `+b.message+`
|
||||
`+b.stack}return{value:e,source:i,stack:p,digest:null}}function kc(e,i,n){return{value:e,source:null,stack:n??null,digest:i??null}}function wc(e,i){try{console.error(i.value)}catch(n){setTimeout(function(){throw n})}}var qv=typeof WeakMap=="function"?WeakMap:Map;function Gp(e,i,n){n=Ga(-1,n),n.tag=3,n.payload={element:null};var s=i.value;return n.callback=function(){Ts||(Ts=!0,Pc=s),wc(e,i)},n}function Kp(e,i,n){n=Ga(-1,n),n.tag=3;var s=e.type.getDerivedStateFromError;if(typeof s=="function"){var p=i.value;n.payload=function(){return s(p)},n.callback=function(){wc(e,i)}}var b=e.stateNode;return b!==null&&typeof b.componentDidCatch=="function"&&(n.callback=function(){wc(e,i),typeof s!="function"&&(bn===null?bn=new Set([this]):bn.add(this));var E=i.stack;this.componentDidCatch(i.value,{componentStack:E!==null?E:""})}),n}function Yp(e,i,n){var s=e.pingCache;if(s===null){s=e.pingCache=new qv;var p=new Set;s.set(i,p)}else p=s.get(i),p===void 0&&(p=new Set,s.set(i,p));p.has(n)||(p.add(n),e=Iv.bind(null,e,i,n),i.then(e,e))}function Zp(e){do{var i;if((i=e.tag===13)&&(i=e.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return e;e=e.return}while(e!==null);return null}function Xp(e,i,n,s,p){return(e.mode&1)===0?(e===i?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(i=Ga(-1,1),i.tag=2,gn(n,i,1))),n.lanes|=1),e):(e.flags|=65536,e.lanes=p,e)}var jv=_.ReactCurrentOwner,Ji=!1;function $i(e,i,n,s){i.child=e===null?fp(i,null,n,s):ho(i,e.child,n,s)}function Jp(e,i,n,s,p){n=n.render;var b=i.ref;return yo(i,p),s=pc(e,i,n,s,b,p),n=mc(),e!==null&&!Ji?(i.updateQueue=e.updateQueue,i.flags&=-2053,e.lanes&=~p,Ka(e,i,p)):(ci&&n&&Kl(i),i.flags|=1,$i(e,i,s,p),i.child)}function em(e,i,n,s,p){if(e===null){var b=n.type;return typeof b=="function"&&!Vc(b)&&b.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(i.tag=15,i.type=b,im(e,i,b,s,p)):(e=Ls(n.type,null,s,i,i.mode,p),e.ref=i.ref,e.return=i,i.child=e)}if(b=e.child,(e.lanes&p)===0){var E=b.memoizedProps;if(n=n.compare,n=n!==null?n:Yo,n(E,s)&&e.ref===i.ref)return Ka(e,i,p)}return i.flags|=1,e=wn(b,s),e.ref=i.ref,e.return=i,i.child=e}function im(e,i,n,s,p){if(e!==null){var b=e.memoizedProps;if(Yo(b,s)&&e.ref===i.ref)if(Ji=!1,i.pendingProps=s=b,(e.lanes&p)!==0)(e.flags&131072)!==0&&(Ji=!0);else return i.lanes=e.lanes,Ka(e,i,p)}return xc(e,i,n,s,p)}function am(e,i,n){var s=i.pendingProps,p=s.children,b=e!==null?e.memoizedState:null;if(s.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},ri(ko,la),la|=n;else{if((n&1073741824)===0)return e=b!==null?b.baseLanes|n:n,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:e,cachePool:null,transitions:null},i.updateQueue=null,ri(ko,la),la|=e,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},s=b!==null?b.baseLanes:n,ri(ko,la),la|=s}else b!==null?(s=b.baseLanes|n,i.memoizedState=null):s=n,ri(ko,la),la|=s;return $i(e,i,p,n),i.child}function nm(e,i){var n=i.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(i.flags|=512,i.flags|=2097152)}function xc(e,i,n,s,p){var b=Xi(n)?Bn:Li.current;return b=co(i,b),yo(i,p),n=pc(e,i,n,s,b,p),s=mc(),e!==null&&!Ji?(i.updateQueue=e.updateQueue,i.flags&=-2053,e.lanes&=~p,Ka(e,i,p)):(ci&&s&&Kl(i),i.flags|=1,$i(e,i,n,p),i.child)}function om(e,i,n,s,p){if(Xi(n)){var b=!0;ps(i)}else b=!1;if(yo(i,p),i.stateNode===null)Bs(e,i),$p(i,n,s),vc(i,n,s,p),s=!0;else if(e===null){var E=i.stateNode,N=i.memoizedProps;E.props=N;var M=E.context,X=n.contextType;typeof X=="object"&&X!==null?X=ma(X):(X=Xi(n)?Bn:Li.current,X=co(i,X));var le=n.getDerivedStateFromProps,ue=typeof le=="function"||typeof E.getSnapshotBeforeUpdate=="function";ue||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(N!==s||M!==X)&&Qp(i,E,s,X),hn=!1;var te=i.memoizedState;E.state=te,ws(i,s,E,p),M=i.memoizedState,N!==s||te!==M||Zi.current||hn?(typeof le=="function"&&(fc(i,n,le,s),M=i.memoizedState),(N=hn||Wp(i,n,N,s,te,M,X))?(ue||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(i.flags|=4194308)):(typeof E.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=s,i.memoizedState=M),E.props=s,E.state=M,E.context=X,s=N):(typeof E.componentDidMount=="function"&&(i.flags|=4194308),s=!1)}else{E=i.stateNode,kp(e,i),N=i.memoizedProps,X=i.type===i.elementType?N:ja(i.type,N),E.props=X,ue=i.pendingProps,te=E.context,M=n.contextType,typeof M=="object"&&M!==null?M=ma(M):(M=Xi(n)?Bn:Li.current,M=co(i,M));var ye=n.getDerivedStateFromProps;(le=typeof ye=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(N!==ue||te!==M)&&Qp(i,E,s,M),hn=!1,te=i.memoizedState,E
Line truncated
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const ck=a=>a.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),uk=a=>a.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,o,t)=>t?t.toUpperCase():o.toLowerCase()),Gm=a=>{const r=uk(a);return r.charAt(0).toUpperCase()+r.slice(1)},Wg=(...a)=>a.filter((r,o,t)=>!!r&&r.trim()!==""&&t.indexOf(r)===o).join(" ").trim(),dk=a=>{for(const r in a)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/var pk={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const mk=S.forwardRef(({color:a="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:t,className:u="",children:l,iconNode:m,...c},h)=>S.createElement("svg",{ref:h,...pk,width:r,height:r,stroke:a,strokeWidth:t?Number(o)*24/Number(r):o,className:Wg("lucide",u),...!l&&!dk(c)&&{"aria-hidden":"true"},...c},[...m.map(([d,y])=>S.createElement(d,y)),...Array.isArray(l)?l:[l]]));/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const Nu=(a,r)=>{const o=S.forwardRef(({className:t,...u},l)=>S.createElement(mk,{ref:l,iconNode:r,className:Wg(`lucide-${ck(Gm(a))}`,`lucide-${a}`,t),...u}));return o.displayName=Gm(a),o};/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const hk=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],gk=Nu("check",hk);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const yk=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],bk=Nu("menu",yk);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const fk=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],$g=Nu("x",fk);var Qg=Ug();const Gg=Fo(Qg);function vk(a){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",r.appendChild(o),o.styleSheet?o.styleSheet.cssText=a:o.appendChild(document.createTextNode(a))}const kk=a=>{switch(a){case"success":return zk;case"info":return jk;case"warning":return qk;case"error":return Ak;default:return null}},wk=Array(12).fill(0),xk=({visible:a,className:r})=>me.createElement("div",{className:["sonner-loading-wrapper",r].filter(Boolean).join(" "),"data-visible":a},me.createElement("div",{className:"sonner-spinner"},wk.map((o,t)=>me.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),zk=me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},me.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),qk=me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},me.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),jk=me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},me.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Ak=me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},me.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Ck=me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},me.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),me.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Ek=()=>{const[a,r]=me.useState(document.hidden);return me.useEffect(()=>{const o=()=>{r(document.hidden)};return document.addEventListener("visibilitychange",o),()=>window.removeEventListener("visibilitychange",o)},[]),a};let ku=1;class Sk{constructor(){this.subscribe=r=>(this.subscribers.push(r),()=>{const o=this.subscribers.indexOf(r);this.subscribers.splice(o,1)}),this.publish=r=>{this.subscribers.forEach(o=>o(r))},this.addToast=r=>{this.publish(r),this.toasts=[...this.toasts,r]},this.create=r=>{var o;const{message:t,...u}=r,l=typeof(r==null?void 0:r.id)=="number"||((o=r.id)==null?void 0:o.length)>0?r.id:ku++,m=this.toasts.find(h=>h.id===l),c=r.dismissible===void 0?!0:r.dismissible;return this.dismissedToasts.has(l)&&this.dismissedToasts.delete(l),m?this.toasts=this.toasts.map(h=>h.id===l?(this.publish({...h,...r,id:l,title:t}),{...h,...r,id:l,dismissible:c,title:t}):h):this.addToast({title:t,...u,dismissible:c,id:l}),l},this.dismiss=r=>(r?(this.dismissedToasts.add(r),requestAnimationFrame(()=>this.subscribers.forEach(o=>o({id:r,dismiss:!0})))):this.toasts.forEach(o=>{this.subscribers.forEach(t=>t({id:o.id,dismiss:!0}))}),r),this.message=(r,o)=>this.create({...o,message:r}),this.error=(r,o)=>this.create({...o,message:r,type:"error"}),this.success=(r,o)=>this.create({...o,type:"success",message:r}),this.info=(r,o)=>this.create({...o,type:"info",message:r}),this.warning=(r,o)=>this.create({...o,type:"warning",message:r}),this.loading=(r,o)=>this.create({...o,type:"loading",message:r}),this.promise=(r,o)=>{if(!o)return;let t;o.loading!==void 0&&(t=this.create({...o,promise:r,type:"loading",message:o.loading,description:typeof o.description!="function"?o.description:void 0}));const u=Promise.resolve(r instanceof Function?r():r);let l=t!==void 0,m;const c=u.then(async d=>{if(m=["resolve",d],me.isValidElement(d))l=!1,this.create({id:t,type:"default",message:d});else if(_k(d)&&!d.ok){l=!1;const g=typeof o.error=="function"?await o.error(`HTTP error! status: ${d.status}`):o.error,f=typeof o.description=="function"?await o.description(`HTTP error! status: ${d.status}`):o.description,k=typeof g=="object"&&!me.isValidElement(g)?g:{message:g};this.create({id:t,type:"error",description:f,...k})}else if(d instanceof Error){l=!1;const g=typeof o.error=="function"?await o.error(d):o.error,Line truncated
|
||||
`).map((ie,j,I)=>B.jsxs("span",{children:[ax(ie,c),j<I.length-1&&B.jsx("br",{})]},j)),!ae&&B.jsx("span",{className:"text-[10px] text-muted-foreground/50 ml-2",children:th(z.sender_timestamp||z.received_at)}),z.outgoing&&(z.acked?" ✓":" ?")]})]})]},z.id)})]}),g&&B.jsx("button",{onClick:q,className:"absolute bottom-4 right-4 w-10 h-10 rounded-full bg-muted hover:bg-accent border border-border flex items-center justify-center shadow-lg transition-opacity",title:"Scroll to bottom",children:B.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground",children:B.jsx("polyline",{points:"6 9 12 15 18 9"})})})]})}const ox=S.forwardRef(function({onSend:r,disabled:o,placeholder:t,isRepeaterMode:u},l){const[m,c]=S.useState(""),[h,d]=S.useState(!1),y=S.useRef(null);S.useImperativeHandle(l,()=>({appendText:k=>{var q;c(v=>v+k),(q=y.current)==null||q.focus()}}));const g=S.useCallback(async k=>{k.preventDefault();const q=m.trim();if(u){if(h||o)return;const v=q==="."?"":q;d(!0);try{await r(v),c("")}catch(A){console.error("Failed to request telemetry:",A)}finally{d(!1)}}else{if(!q||h||o)return;d(!0);try{await r(q),c("")}catch(v){console.error("Failed to send message:",v)}finally{d(!1)}}},[m,h,o,r,u]),f=S.useCallback(k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),g(k))},[g]),x=u?m.trim().length>0||m===".":m.trim().length>0;return B.jsxs("form",{className:"px-4 py-3 border-t border-border flex gap-2",onSubmit:g,children:[B.jsx(qi,{ref:y,type:u?"password":"text",value:m,onChange:k=>c(k.target.value),onKeyDown:f,placeholder:t||(u?"Enter password (or . for none)...":"Type a message..."),disabled:o||h,className:"flex-1"}),B.jsx(La,{type:"submit",disabled:o||h||!x,children:h?u?"Fetching...":"Sending...":u?"Fetch":"Send"})]})});function Bi(a,r,{checkForDefaultPrevented:o=!0}={}){return function(u){if(a==null||a(u),o===!1||!u.defaultPrevented)return r==null?void 0:r(u)}}function rx(a,r){const o=S.createContext(r),t=l=>{const{children:m,...c}=l,h=S.useMemo(()=>c,Object.values(c));return B.jsx(o.Provider,{value:h,children:m})};t.displayName=a+"Provider";function u(l){const m=S.useContext(o);if(m)return m;if(r!==void 0)return r;throw new Error(`\`${l}\` must be used within \`${a}\``)}return[t,u]}function Lr(a,r=[]){let o=[];function t(l,m){const c=S.createContext(m),h=o.length;o=[...o,m];const d=g=>{var A;const{scope:f,children:x,...k}=g,q=((A=f==null?void 0:f[a])==null?void 0:A[h])||c,v=S.useMemo(()=>k,Object.values(k));return B.jsx(q.Provider,{value:v,children:x})};d.displayName=l+"Provider";function y(g,f){var q;const x=((q=f==null?void 0:f[a])==null?void 0:q[h])||c,k=S.useContext(x);if(k)return k;if(m!==void 0)return m;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[d,y]}const u=()=>{const l=o.map(m=>S.createContext(m));return function(c){const h=(c==null?void 0:c[a])||l;return S.useMemo(()=>({[`__scope${a}`]:{...c,[a]:h}}),[c,h])}};return u.scopeName=a,[t,sx(u,...r)]}function sx(...a){const r=a[0];if(a.length===1)return r;const o=()=>{const t=a.map(u=>({useScope:u(),scopeName:u.scopeName}));return function(l){const m=t.reduce((c,{useScope:h,scopeName:d})=>{const g=h(l)[`__scope${d}`];return{...c,...g}},{});return S.useMemo(()=>({[`__scope${r.scopeName}`]:m}),[m])}};return o.scopeName=r.scopeName,o}var _o=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},tx=Pu[" useId ".trim().toString()]||(()=>{}),lx=0;function Pr(a){const[r,o]=S.useState(tx());return _o(()=>{o(t=>t??String(lx++))},[a]),r?`radix-${r}`:""}var cx=Pu[" useInsertionEffect ".trim().toString()]||_o;function al({prop:a,defaultProp:r,onChange:o=()=>{},caller:t}){const[u,l,m]=ux({defaultProp:r,onChange:o}),c=a!==void 0,h=c?a:u;{const y=S.useRef(a!==void 0);S.useEffect(()=>{const g=y.current;g!==c&&console.warn(`${t} is changing from ${g?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),y.current=c},[c,t])}const d=S.useCallback(y=>{var g;if(c){const f=dx(y)?y(a):y;f!==a&&((g=m.current)==null||g.call(m,f))}else l(y)},[c,a,l,m]);return[h,d]}function ux({defaultProp:a,onChange:r}){const[o,t]=S.useState(a),u=S.useRef(o),l=S.useRef(r);return cx(()=>{l.current=r},[r]),S.useEffect(()=>{var m;u.current!==o&&((m=l.current)==null||m.call(l,o),u.current=o)},[o,u]),[o,t,l]}function dx(a){return typeof a=="function"}function px(a){const r=mx(a),o=S.forwardRef((t,u)=>{const{children:l,...m}=t,c=S.Children.toArray(l),h=c.find(gx);if(h){const d=h.props.children,y=c.map(g=>g===h?S.Children.count(d)>1?S.Children.only(null):S.isValidElement(d)?d.props.children:null:g);return B.jsx(r,{...m,ref:u,children:S.isValidElement(d)?S.cloneElement(d,void 0,y):null})}return B.jsx(r,{...m,ref:u,children:l})});return o.displayNamLine truncated
|
||||
.`.concat(Lx,` {
|
||||
overflow: hidden `).concat(t,`;
|
||||
padding-right: `).concat(c,"px ").concat(t,`;
|
||||
}
|
||||
body[`).concat(Eo,`] {
|
||||
overflow: hidden `).concat(t,`;
|
||||
overscroll-behavior: contain;
|
||||
`).concat([r&&"position: relative ".concat(t,";"),o==="margin"&&`
|
||||
padding-left: `.concat(u,`px;
|
||||
padding-top: `).concat(l,`px;
|
||||
padding-right: `).concat(m,`px;
|
||||
margin-left:0;
|
||||
margin-top:0;
|
||||
margin-right: `).concat(c,"px ").concat(t,`;
|
||||
`),o==="padding"&&"padding-right: ".concat(c,"px ").concat(t,";")].filter(Boolean).join(""),`
|
||||
}
|
||||
|
||||
.`).concat(ot,` {
|
||||
right: `).concat(c,"px ").concat(t,`;
|
||||
}
|
||||
|
||||
.`).concat(rt,` {
|
||||
margin-right: `).concat(c,"px ").concat(t,`;
|
||||
}
|
||||
|
||||
.`).concat(ot," .").concat(ot,` {
|
||||
right: 0 `).concat(t,`;
|
||||
}
|
||||
|
||||
.`).concat(rt," .").concat(rt,` {
|
||||
margin-right: 0 `).concat(t,`;
|
||||
}
|
||||
|
||||
body[`).concat(Eo,`] {
|
||||
`).concat(Hx,": ").concat(c,`px;
|
||||
}
|
||||
`)},yh=function(){var a=parseInt(document.body.getAttribute(Eo)||"0",10);return isFinite(a)?a:0},tz=function(){S.useEffect(function(){return document.body.setAttribute(Eo,(yh()+1).toString()),function(){var a=yh()-1;a<=0?document.body.removeAttribute(Eo):document.body.setAttribute(Eo,a.toString())}},[])},lz=function(a){var r=a.noRelative,o=a.noImportant,t=a.gapMode,u=t===void 0?"margin":t;tz();var l=S.useMemo(function(){return oz(u)},[u]);return S.createElement(rz,{styles:sz(l,!r,u,o?"":"!important")})},Au=!1;if(typeof window<"u")try{var et=Object.defineProperty({},"passive",{get:function(){return Au=!0,!0}});window.addEventListener("test",et,et),window.removeEventListener("test",et,et)}catch{Au=!1}var qo=Au?{passive:!1}:!1,cz=function(a){return a.tagName==="TEXTAREA"},zy=function(a,r){if(!(a instanceof Element))return!1;var o=window.getComputedStyle(a);return o[r]!=="hidden"&&!(o.overflowY===o.overflowX&&!cz(a)&&o[r]==="visible")},uz=function(a){return zy(a,"overflowY")},dz=function(a){return zy(a,"overflowX")},bh=function(a,r){var o=r.ownerDocument,t=r;do{typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&(t=t.host);var u=qy(a,t);if(u){var l=jy(a,t),m=l[1],c=l[2];if(m>c)return!0}t=t.parentNode}while(t&&t!==o.body);return!1},pz=function(a){var r=a.scrollTop,o=a.scrollHeight,t=a.clientHeight;return[r,o,t]},mz=function(a){var r=a.scrollLeft,o=a.scrollWidth,t=a.clientWidth;return[r,o,t]},qy=function(a,r){return a==="v"?uz(r):dz(r)},jy=function(a,r){return a==="v"?pz(r):mz(r)},hz=function(a,r){return a==="h"&&r==="rtl"?-1:1},gz=function(a,r,o,t,u){var l=hz(a,window.getComputedStyle(r).direction),m=l*t,c=o.target,h=r.contains(c),d=!1,y=m>0,g=0,f=0;do{if(!c)break;var x=jy(a,c),k=x[0],q=x[1],v=x[2],A=q-v-l*k;(k||A)&&qy(a,c)&&(g+=A,f+=k);var C=c.parentNode;c=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!h&&c!==document.body||h&&(r.contains(c)||r===c));return(y&&Math.abs(g)<1||!y&&Math.abs(f)<1)&&(d=!0),d},it=function(a){return"changedTouches"in a?[a.changedTouches[0].clientX,a.changedTouches[0].clientY]:[0,0]},fh=function(a){return[a.deltaX,a.deltaY]},vh=function(a){return a&&"current"in a?a.current:a},yz=function(a,r){return a[0]===r[0]&&a[1]===r[1]},bz=function(a){return`
|
||||
.block-interactivity-`.concat(a,` {pointer-events: none;}
|
||||
.allow-interactivity-`).concat(a,` {pointer-events: all;}
|
||||
`)},fz=0,jo=[];function vz(a){var r=S.useRef([]),o=S.useRef([0,0]),t=S.useRef(),u=S.useState(fz++)[0],l=S.useState(xy)[0],m=S.useRef(a);S.useEffect(function(){m.current=a},[a]),S.useEffect(function(){if(a.inert){document.body.classList.add("block-interactivity-".concat(u));var q=Ox([a.lockRef.current],(a.shards||[]).map(vh),!0).filter(Boolean);return q.forEach(function(v){return v.classList.add("allow-interactivity-".concat(u))}),function(){document.body.classList.remove("block-interactivity-".concat(u)),q.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(u))})}}},[a.inert,a.lockRef.current,a.shards]);var c=S.useCallback(function(q,v){if("touches"in q&&q.touches.length===2||q.type==="wheel"&&q.ctrlKey)return!m.current.allowPinchZoom;var A=it(q),C=o.current,w="deltaX"in q?q.deltaX:C[0]-A[0],_="deltaY"in q?q.deltaY:C[1]-A[1],z,D=q.target,R=Math.abs(w)>Math.abs(_)?"h":"v";if("touches"in q&&R==="h"&&D.type==="range")return!1;var F=window.getSelection(),O=F&&F.anchorNode,P=O?O===D||O.contains(D):!1;if(P)return!1;var T=bh(R,D);if(!T)return!0;if(T?z=R:(z=R==="v"?"h":"v",T=bh(R,D)),!T)return!1;if(!t.current&&"changedTouches"in q&&(w||_)&&(t.current=z),!z)return!0;var W=t.current||z;return gz(W,v,q,W==="h"?w:_)},[]),h=S.useCallback(function(q){var v=q;if(!(!jo.length||jo[jo.length-1]!==l)){var A="deltaY"in v?fh(v):it(v),C=r.current.filter(function(z){return z.name===v.type&&(z.target===v.target||v.target===z.shadowParent)&&yz(z.delta,A)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var w=(m.current.shards||[]).map(vh).filter(Boolean).filter(function(z){return z.contains(v.target)}),_=w.length>0?c(v,w[0]):!m.current.noIsolation;_&&v.cancelable&&v.preventDefault()}}},[]),d=S.useCallback(function(q,v,A,C){var w={name:q,delta:v,target:A,should:C,shadowParent:kz(A)};r.current.push(w),setTimeout(function(){r.current=r.current.filter(function(_){return _!==w})},1)},[]),y=S.useCallback(function(q){o.current=it(q),t.current=void 0},[]),g=S.useCallback(function(q){d(q.type,fh(q),q.target,c(q,a.lockRef.current))},[]),f=S.useCallback(function(q){d(q.type,it(q),q.target,c(q,a.lockRef.current))},[]);S.useEffect(function(){return jo.push(l),a.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:f}),document.addEventListener("wheel",h,qo),document.addEventListener("touchmove",h,qo),document.addEventListener("touchstart",y,qo),function(){jo=jo.filter(function(q){return q!==l}),document.removeEventListener("wheel",h,qo),document.removeEventListener("touchmove",h,qo),document.removeEventListener("touchstart",y,qo)}},[]);var x=a.removeScrollBar,k=a.inert;return S.createElement(S.Fragment,null,k?S.createElement(l,{styles:bz(u)}):null,x?S.createElement(lz,{noRelative:a.noRelative,gapMode:a.gapMode}):null)}function kz(a){for(var r=null;a!==null;)a instanceof ShadowRoot&&(r=a.host,a=a.host),a=a.parentNode;return r}const wz=Kx(wy,vz);var Ay=S.forwardRef(function(a,r){return S.createElement(nl,Oa({},a,{ref:r,sideCar:wz}))});Ay.classNames=nl.classNames;var xz=function(a){if(typeof document>"u")return null;var r=Array.isArray(a)?a[0]:a;return r.ownerDocument.body},Ao=new WeakMap,at=new WeakMap,nt={},pu=0,Cy=function(a){return a&&(a.host||Cy(a.parentNode))},zz=function(a,r){return r.map(function(o){if(a.contains(o))return o;var t=Cy(o);return t&&a.contains(t)?t:(console.error("aria-hidden",o,"in not contained inside",a,". Doing nothing"),null)}).filter(function(o){return!!o})},qz=function(a,r,o,t){var u=zz(r,Array.isArray(a)?a:[a]);nt[o]||(nt[o]=new WeakMap);var l=nt[o],m=[],c=new Set,h=new Set(u),d=function(g){!g||c.has(g)||(c.add(g),d(g.parentNode))};u.forEach(d);var y=function(g){!g||h.has(g)||Array.prototype.forEach.call(g.children,function(f){if(c.has(f))y(f);else try{var x=f.getAttribute(t),k=x!==null&&x!=="false",q=(Ao.get(f)||0)+1,v=(l.get(f)||0)+1;Ao.set(f,q),l.set(f,v),m.push(f),q===1&&k&&at.set(f,!0),v===1&&f.setAttribute(o,"true"),k||f.setAttribute(t,"true")}catch(A){console.error("aria-hidden: cannot operate on ",f,A)}})};return y(r),c.clear(),pu++,function(){m.forEach(function(g){var f=Ao.get(g)-1,x=l.get(g)-1;Ao.set(g,f),l.set(g,x),f||(at.has(g)||g.removeAttribute(t),at.delete(g)),x||g.removeAttribute(o)}),pu--,pu||(Ao=new WeakMap,Ao=new WeakMap,at=new WeakMap,nt={})}},jz=function(a,r,o){o===void 0&&(o="data-aria-hidden");var t=Array.from(Array.isArray(a)?a:[a]),u=xz(a);return u?(t.push.apply(t,Array.from(u.querySelectorAll("[aria-live], script"))),qz(t,u,o,"aria-hidden")):function(){return null}};function Az(a){const r=Cz(a),o=S.forwardRef((t,u)=>{const{children:l,...m}=t,c=S.Children.toArray(l),h=c.find(Sz);if(h){const d=h.props.children,y=c.map(g=>g===h?S.Children.count(d)>1?S.Children.only(null):S.isValidElement(d)?d.props.children:null:g);return B.jsx(r,{...m,ref:u,children:S.isValidElement(d)?S.cloneElement(d,void 0,y):null})}return B.jsx(r,{...m,ref:u,children:l})});return o.displayName=`${a}.Slot`,o}function Cz(a){const r=S.forwardRef((o,t)=>{const{children:u
Line truncated
|
||||
|
||||
If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.
|
||||
|
||||
For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return S.useEffect(()=>{a&&(document.getElementById(a)||console.error(o))},[o,a]),null},Oz="DialogDescriptionWarning",Lz=({contentRef:a,descriptionId:r})=>{const t=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Hy(Oz).contentName}}.`;return S.useEffect(()=>{var l;const u=(l=a.current)==null?void 0:l.getAttribute("aria-describedby");r&&u&&(document.getElementById(r)||console.warn(t))},[t,a,r]),null},Vy=Sy,Uy=Dy,rl=Fy,sl=Ry,tl=Py,ll=Iy,Wy=Oy;const $y=Vy,Hz=Uy,Qy=S.forwardRef(({className:a,...r},o)=>B.jsx(rl,{ref:o,className:$e("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...r}));Qy.displayName=rl.displayName;const Vu=S.forwardRef(({className:a,children:r,...o},t)=>B.jsxs(Hz,{children:[B.jsx(Qy,{}),B.jsxs(sl,{ref:t,className:$e("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...o,children:[r,B.jsxs(Wy,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[B.jsx($g,{className:"h-4 w-4"}),B.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Vu.displayName=sl.displayName;const Uu=({className:a,...r})=>B.jsx("div",{className:$e("flex flex-col space-y-1.5 text-center sm:text-left",a),...r});Uu.displayName="DialogHeader";const Wu=({className:a,...r})=>B.jsx("div",{className:$e("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...r});Wu.displayName="DialogFooter";const $u=S.forwardRef(({className:a,...r},o)=>B.jsx(tl,{ref:o,className:$e("text-lg font-semibold leading-none tracking-tight",a),...r}));$u.displayName=tl.displayName;const Vz=S.forwardRef(({className:a,...r},o)=>B.jsx(ll,{ref:o,className:$e("text-sm text-muted-foreground",a),...r}));Vz.displayName=ll.displayName;function kh(a){const r=Uz(a),o=S.forwardRef((t,u)=>{const{children:l,...m}=t,c=S.Children.toArray(l),h=c.find($z);if(h){const d=h.props.children,y=c.map(g=>g===h?S.Children.count(d)>1?S.Children.only(null):S.isValidElement(d)?d.props.children:null:g);return B.jsx(r,{...m,ref:u,children:S.isValidElement(d)?S.cloneElement(d,void 0,y):null})}return B.jsx(r,{...m,ref:u,children:l})});return o.displayName=`${a}.Slot`,o}function Uz(a){const r=S.forwardRef((o,t)=>{const{children:u,...l}=o;if(S.isValidElement(u)){const m=Gz(u),c=Qz(l,u.props);return u.type!==S.Fragment&&(c.ref=t?Or(t,m):m),S.cloneElement(u,c)}return S.Children.count(u)>1?S.Children.only(null):null});return r.displayName=`${a}.SlotClone`,r}var Wz=Symbol("radix.slottable");function $z(a){return S.isValidElement(a)&&typeof a.type=="function"&&"__radixId"in a.type&&a.type.__radixId===Wz}function Qz(a,r){const o={...r};for(const t in r){const u=a[t],l=r[t];/^on[A-Z]/.test(t)?u&&l?o[t]=(...c)=>{const h=l(...c);return u(...c),h}:u&&(o[t]=u):t==="style"?o[t]={...u,...l}:t==="className"&&(o[t]=[u,l].filter(Boolean).join(" "))}return{...a,...o}}function Gz(a){var t,u;let r=(t=Object.getOwnPropertyDescriptor(a.props,"ref"))==null?void 0:t.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?a.ref:(r=(u=Object.getOwnPropertyDescriptor(a,"ref"))==null?void 0:u.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?a.props.ref:a.props.ref||a.ref)}function Kz(a){const r=a+"CollectionProvider",[o,t]=Lr(r),[u,l]=o(r,{collectionRef:{current:null},itemMap:new Map}),m=q=>{const{scope:v,children:A}=q,C=me.useRef(null),w=me.useRef(new Map).current;return B.jsx(u,{scope:v,itemMap:w,collectionRef:C,children:A})};m.displayName=r;const c=a+"CollectionSlot",h=kh(c),d=me.forwardRef((q,v)=>{const{scope:A,children:C}=q,w=l(c,A),_=ba(v,w.collectionRef);return B.jsx(h,{ref:_,children:C})});d.displayName=c;const y=a+"CollectionItemSlot",g="data-radix-collection-item",f=kh(y),x=me.forwardRef((q,v)=>{const{scope:A,children:C,...w}=q,_=me.useRef(null),z=ba(v,_),D=l(y,A);return me.useEffect(()=>(D.itemMap.set(_,{ref:_,...w}),()=>void D.itemMap.delete(_))),B.jsx(f,{[g]:"",ref:z,children:C})});x.displayName=y;function k(q){const v=l(a+"CollectionConsumer",q);return me.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const w=Array.from(C.querySelectorAll(`[${g}]`));return Array.from(v.itemMap.values()).sort((D,R)=>w.indexOf(D.ref.current)-w.indexOf(R.ref.current))},[v.coll
Line truncated
|
||||
(c) 2012 by Cédric Mesnil. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/return(function(t){var u=o,l=u.lib,m=l.WordArray,c=l.Hasher,h=u.algo,d=m.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=m.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),g=m.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=m.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),x=m.create([0,1518500249,1859775393,2400959708,2840853838]),k=m.create([1352829926,1548603684,1836072691,2053994217,0]),q=h.RIPEMD160=c.extend({_doReset:function(){this._hash=m.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(D,R){for(var F=0;F<16;F++){var O=R+F,P=D[O];D[O]=(P<<8|P>>>24)&16711935|(P<<24|P>>>8)&4278255360}var T=this._hash.words,W=x.words,H=k.words,Y=d.words,ae=y.words,ee=g.words,ne=f.words,$,re,ie,j,I,V,Q,de,he,ge;V=$=T[0],Q=re=T[1],de=ie=T[2],he=j=T[3],ge=I=T[4];for(var se,F=0;F<80;F+=1)se=$+D[R+Y[F]]|0,F<16?se+=v(re,ie,j)+W[0]:F<32?se+=A(re,ie,j)+W[1]:F<48?se+=C(re,ie,j)+W[2]:F<64?se+=w(re,ie,j)+W[3]:se+=_(re,ie,j)+W[4],se=se|0,se=z(se,ee[F]),se=se+I|0,$=I,I=j,j=z(ie,10),ie=re,re=se,se=V+D[R+ae[F]]|0,F<16?se+=_(Q,de,he)+H[0]:F<32?se+=w(Q,de,he)+H[1]:F<48?se+=C(Q,de,he)+H[2]:F<64?se+=A(Q,de,he)+H[3]:se+=v(Q,de,he)+H[4],se=se|0,se=z(se,ne[F]),se=se+ge|0,V=ge,ge=he,he=z(de,10),de=Q,Q=se;se=T[1]+ie+he|0,T[1]=T[2]+j+ge|0,T[2]=T[3]+I+V|0,T[3]=T[4]+$+Q|0,T[4]=T[0]+re+de|0,T[0]=se},_doFinalize:function(){var D=this._data,R=D.words,F=this._nDataBytes*8,O=D.sigBytes*8;R[O>>>5]|=128<<24-O%32,R[(O+64>>>9<<4)+14]=(F<<8|F>>>24)&16711935|(F<<24|F>>>8)&4278255360,D.sigBytes=(R.length+1)*4,this._process();for(var P=this._hash,T=P.words,W=0;W<5;W++){var H=T[W];T[W]=(H<<8|H>>>24)&16711935|(H<<24|H>>>8)&4278255360}return P},clone:function(){var D=c.clone.call(this);return D._hash=this._hash.clone(),D}});function v(D,R,F){return D^R^F}function A(D,R,F){return D&R|~D&F}function C(D,R,F){return(D|~R)^F}function w(D,R,F){return D&F|R&~F}function _(D,R,F){return D^(R|~F)}function z(D,R){return D<<R|D>>>32-R}u.RIPEMD160=c._createHelper(q),u.HmacRIPEMD160=c._createHmacHelper(q)})(),o.RIPEMD160})})(wt)),wt.exports}var xt={exports:{}},rq=xt.exports,Oh;function pl(){return Oh||(Oh=1,(function(a,r){(function(o,t){a.exports=t(Ie())})(rq,function(o){(function(){var t=o,u=t.lib,l=u.Base,m=t.enc,c=m.Utf8,h=t.algo;h.HMAC=l.extend({init:function(d,y){d=this._hasher=new d.init,typeof y=="string"&&(y=c.parse(y));var g=d.blockSize,f=g*4;y.sigBytes>f&&(y=d.finalize(y)),y.clamp();for(var x=this._oKey=y.clone(),k=this._iKey=y.clone(),q=x.words,v=k.words,A=0;A<g;A++)q[A]^=1549556828,v[A]^=909522486;x.sigBytes=k.sigBytes=f,this.reset()},reset:function(){var d=this._hasher;d.reset(),d.update(this._iKey)},update:function(d){return this._hasher.update(d),this},finalize:function(d){var y=this._hasher,g=y.finalize(d);y.reset();var f=y.finalize(this._oKey.clone().concat(g));return f}})})()})})(xt)),xt.exports}var zt={exports:{}},sq=zt.exports,Lh;function tq(){return Lh||(Lh=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Vr(),pl())})(sq,function(o){return(function(){var t=o,u=t.lib,l=u.Base,m=u.WordArray,c=t.algo,h=c.SHA256,d=c.HMAC,y=c.PBKDF2=l.extend({cfg:l.extend({keySize:128/32,hasher:h,iterations:25e4}),init:function(g){this.cfg=this.cfg.extend(g)},compute:function(g,f){for(var x=this.cfg,k=d.create(x.hasher,g),q=m.create(),v=m.create([1]),A=q.words,C=v.words,w=x.keySize,_=x.iterations;A.length<w;){var z=k.update(f).finalize(v);k.reset();for(var D=z.words,R=D.length,F=z,O=1;O<_;O++){F=k.finalize(F),k.reset();for(var P=F.words,T=0;T<R;T++)D[T]^=P[T]}q.concat(z),C[0]++}return q.sigBytes=w*4,q}});t.PBKDF2=function(g,f,x){return y.create(x).compute(g,f)}})(),o.PBKDF2})})(zt)),zt.exports}var qt={exports:{}},lq=qt.exports,Hh;function Cn(){return Hh||(Hh=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Sb(),pl())})(lq,function(o){return(function(){var t=o,u=t.lib,l=u.Base,m=u.WordArray,c=t.algo,h=c.MD5,d=c.EvpKDF=l.extend({cfg:l.extend({keySize:128/32,hasher:h,iterations:1}),init:function(y){this.cfg=this.cfg.extend(y)},compute:function(y,g){for(var f,x=this.cfg,k=x.hasher.create(),q=m.create(),v=q.words,A=x.keySize,C=x.iterations;v.length<A;){f&&k.update(f),f=k.update(y).finalize(g),k.reset();for(var w=1;w<C;w++)f=k.finalize(f),k.reset();q.concat(f)}return q.sigBytes=A*4,q}});t.EvpKDF=function(y,g,f){return d.create(f).compute(y,g)}})(),o.EvpKDF})})(qt)),qt.exports}var jt={exports:{}},cq=jt.exports,Vh;Line truncated
|
||||
* Counter block mode compatible with Dr Brian Gladman fileenc.c
|
||||
* derived from CryptoJS.mode.CTR
|
||||
* Jan Hruby jhruby.web@gmail.com
|
||||
*/return o.mode.CTRGladman=(function(){var t=o.lib.BlockCipherMode.extend();function u(c){if((c>>24&255)===255){var h=c>>16&255,d=c>>8&255,y=c&255;h===255?(h=0,d===255?(d=0,y===255?y=0:++y):++d):++h,c=0,c+=h<<16,c+=d<<8,c+=y}else c+=1<<24;return c}function l(c){return(c[0]=u(c[0]))===0&&(c[1]=u(c[1])),c}var m=t.Encryptor=t.extend({processBlock:function(c,h){var d=this._cipher,y=d.blockSize,g=this._iv,f=this._counter;g&&(f=this._counter=g.slice(0),this._iv=void 0),l(f);var x=f.slice(0);d.encryptBlock(x,0);for(var k=0;k<y;k++)c[h+k]^=x[k]}});return t.Decryptor=m,t})(),o.mode.CTRGladman})})(Et)),Et.exports}var St={exports:{}},yq=St.exports,Qh;function bq(){return Qh||(Qh=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Ti())})(yq,function(o){return o.mode.OFB=(function(){var t=o.lib.BlockCipherMode.extend(),u=t.Encryptor=t.extend({processBlock:function(l,m){var c=this._cipher,h=c.blockSize,d=this._iv,y=this._keystream;d&&(y=this._keystream=d.slice(0),this._iv=void 0),c.encryptBlock(y,0);for(var g=0;g<h;g++)l[m+g]^=y[g]}});return t.Decryptor=u,t})(),o.mode.OFB})})(St)),St.exports}var Bt={exports:{}},fq=Bt.exports,Gh;function vq(){return Gh||(Gh=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Ti())})(fq,function(o){return o.mode.ECB=(function(){var t=o.lib.BlockCipherMode.extend();return t.Encryptor=t.extend({processBlock:function(u,l){this._cipher.encryptBlock(u,l)}}),t.Decryptor=t.extend({processBlock:function(u,l){this._cipher.decryptBlock(u,l)}}),t})(),o.mode.ECB})})(Bt)),Bt.exports}var _t={exports:{}},kq=_t.exports,Kh;function wq(){return Kh||(Kh=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Ti())})(kq,function(o){return o.pad.AnsiX923={pad:function(t,u){var l=t.sigBytes,m=u*4,c=m-l%m,h=l+c-1;t.clamp(),t.words[h>>>2]|=c<<24-h%4*8,t.sigBytes+=c},unpad:function(t){var u=t.words[t.sigBytes-1>>>2]&255;t.sigBytes-=u}},o.pad.Ansix923})})(_t)),_t.exports}var Dt={exports:{}},xq=Dt.exports,Yh;function zq(){return Yh||(Yh=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Ti())})(xq,function(o){return o.pad.Iso10126={pad:function(t,u){var l=u*4,m=l-t.sigBytes%l;t.concat(o.lib.WordArray.random(m-1)).concat(o.lib.WordArray.create([m<<24],1))},unpad:function(t){var u=t.words[t.sigBytes-1>>>2]&255;t.sigBytes-=u}},o.pad.Iso10126})})(Dt)),Dt.exports}var Ft={exports:{}},qq=Ft.exports,Zh;function jq(){return Zh||(Zh=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Ti())})(qq,function(o){return o.pad.Iso97971={pad:function(t,u){t.concat(o.lib.WordArray.create([2147483648],1)),o.pad.ZeroPadding.pad(t,u)},unpad:function(t){o.pad.ZeroPadding.unpad(t),t.sigBytes--}},o.pad.Iso97971})})(Ft)),Ft.exports}var Rt={exports:{}},Aq=Rt.exports,Xh;function Cq(){return Xh||(Xh=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Ti())})(Aq,function(o){return o.pad.ZeroPadding={pad:function(t,u){var l=u*4;t.clamp(),t.sigBytes+=l-(t.sigBytes%l||l)},unpad:function(t){for(var u=t.words,l=t.sigBytes-1,l=t.sigBytes-1;l>=0;l--)if(u[l>>>2]>>>24-l%4*8&255){t.sigBytes=l+1;break}}},o.pad.ZeroPadding})})(Rt)),Rt.exports}var Tt={exports:{}},Eq=Tt.exports,Jh;function Sq(){return Jh||(Jh=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Ti())})(Eq,function(o){return o.pad.NoPadding={pad:function(){},unpad:function(){}},o.pad.NoPadding})})(Tt)),Tt.exports}var Pt={exports:{}},Bq=Pt.exports,eg;function _q(){return eg||(eg=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Ti())})(Bq,function(o){return(function(t){var u=o,l=u.lib,m=l.CipherParams,c=u.enc,h=c.Hex,d=u.format;d.Hex={stringify:function(y){return y.ciphertext.toString(h)},parse:function(y){var g=h.parse(y);return m.create({ciphertext:g})}}})(),o.format.Hex})})(Pt)),Pt.exports}var Nt={exports:{}},Dq=Nt.exports,ig;function Fq(){return ig||(ig=1,(function(a,r){(function(o,t,u){a.exports=t(Ie(),Xn(),Jn(),Cn(),Ti())})(Dq,function(o){return(function(){var t=o,u=t.lib,l=u.BlockCipher,m=t.algo,c=[],h=[],d=[],y=[],g=[],f=[],x=[],k=[],q=[],v=[];(function(){for(var w=[],_=0;_<256;_++)_<128?w[_]=_<<1:w[_]=_<<1^283;for(var z=0,D=0,_=0;_<256;_++){var R=D^D<<1^D<<2^D<<3^D<<4;R=R>>>8^R&255^99,c[z]=R,h[R]=z;var F=w[z],O=w[F],P=w[O],T=w[R]*257^R*16843008;d[z]=T<<24|T>>>8,y[z]=T<<16|T>>>16,g[z]=T<<8|T>>>24,f[z]=T;var T=P*16843009^O*65537^F*257^z*16843008;x[R]=T<<24|T>>>8,k[R]=T<<16|T>>>16,q[R]=T<<8|T>>>24,v[R]=T,z?(z=F^w[w[w[P^F]]],D^=w[w[D]]):z=D=1}})();var A=[0,1,2,4,8,16,32,64,128,27,54],C=m.AES=l.extend({_doReset:function(){var w;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var _=this._keyPriorReset=this._key,z=_.words,D=_.sigBytes/4,R=this._nRounds=D+6,F=(R+1)*4,O=this._keySchedule=[],P=0;P<F;P++)P<D?O[P]=z[P]:(w=O[P-1],P%D?D>6&&P%D==4&&(w=c[w>>>24]<<24|c[w>>>16&255]<<16|c[w>>>8&255]<<8|c[w&255]):(w=w<<8|w>>>24,w=c[w>>>24]<<24|c[w>>>16&255]<<16|c[w>>>8&255]<<8|c[w&255],w^=A[P/D|0]<<24),O[P]=O[P-D]^w);for(var T=this._invKeySchedule=[],W=0;W<F;W++){var P=F-W;if(W%4)var w=O[P];else var w=O[P-4];W<4||P<=4?T[W]=w:T[W]=x[c[w>>>24]]^k[c[w>>>16&255]]^q[c[w>>>8&255]]^v[c[w&255]]}}},encryptBlock:Line truncated
|
||||
• Timestamp (4 bytes) - send time as unix timestamp
|
||||
• Request Type (1 byte) - type of request (GetStats, GetTelemetryData, etc.)
|
||||
• Request Data (remaining bytes) - additional request-specific data`,startByte:c+h,endByte:c+u.length-1,value:f});const x={type:a.PayloadType.Request,version:a.PayloadVersion.Version1,isValid:!0,timestamp:0,requestType:a.RequestType.GetStats,requestData:"",destinationHash:d,sourceHash:y,cipherMac:g,ciphertext:f};return l!=null&&l.includeSegments&&(x.segments=m),x}catch(m){return{type:a.PayloadType.Request,version:a.PayloadVersion.Version1,isValid:!1,errors:[m instanceof Error?m.message:"Failed to decode request payload"],timestamp:0,requestType:a.RequestType.GetStats,requestData:"",destinationHash:"",sourceHash:"",cipherMac:"",ciphertext:""}}}}return jr.RequestPayloadDecoder=o,jr}var Ar={},qg;function gj(){if(qg)return Ar;qg=1,Object.defineProperty(Ar,"__esModule",{value:!0}),Ar.ResponsePayloadDecoder=void 0;const a=ua(),r=Mi();class o{static decode(u,l){try{if(u.length<4){const k={type:a.PayloadType.Response,version:a.PayloadVersion.Version1,isValid:!1,errors:["Response payload too short (minimum 4 bytes: dest + source + MAC)"],destinationHash:"",sourceHash:"",cipherMac:"",ciphertext:"",ciphertextLength:0};return l!=null&&l.includeSegments&&(k.segments=[{name:"Invalid Response Data",description:"Response payload too short (minimum 4 bytes required)",startByte:l.segmentOffset||0,endByte:(l.segmentOffset||0)+u.length-1,value:(0,r.bytesToHex)(u)}]),k}const m=[],c=(l==null?void 0:l.segmentOffset)||0;let h=0;const d=(0,r.byteToHex)(u[h]);l!=null&&l.includeSegments&&m.push({name:"Destination Hash",description:"First byte of destination node public key",startByte:c+h,endByte:c+h,value:d}),h+=1;const y=(0,r.byteToHex)(u[h]);l!=null&&l.includeSegments&&m.push({name:"Source Hash",description:"First byte of source node public key",startByte:c+h,endByte:c+h,value:y}),h+=1;const g=(0,r.bytesToHex)(u.subarray(h,h+2));l!=null&&l.includeSegments&&m.push({name:"Cipher MAC",description:"MAC for encrypted data in next field",startByte:c+h,endByte:c+h+1,value:g}),h+=2;const f=(0,r.bytesToHex)(u.subarray(h));l!=null&&l.includeSegments&&u.length>h&&m.push({name:"Ciphertext",description:"Encrypted response data (tag + content)",startByte:c+h,endByte:c+u.length-1,value:f});const x={type:a.PayloadType.Response,version:a.PayloadVersion.Version1,isValid:!0,destinationHash:d,sourceHash:y,cipherMac:g,ciphertext:f,ciphertextLength:u.length-4};return l!=null&&l.includeSegments&&(x.segments=m),x}catch(m){return{type:a.PayloadType.Response,version:a.PayloadVersion.Version1,isValid:!1,errors:[m instanceof Error?m.message:"Failed to decode response payload"],destinationHash:"",sourceHash:"",cipherMac:"",ciphertext:"",ciphertextLength:0}}}}return Ar.ResponsePayloadDecoder=o,Ar}var Cr={},jg;function yj(){if(jg)return Cr;jg=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.AnonRequestPayloadDecoder=void 0;const a=ua(),r=Mi();class o{static decode(u,l){try{if(u.length<35){const k={type:a.PayloadType.AnonRequest,version:a.PayloadVersion.Version1,isValid:!1,errors:["AnonRequest payload too short (minimum 35 bytes: dest + public key + MAC)"],destinationHash:"",senderPublicKey:"",cipherMac:"",ciphertext:"",ciphertextLength:0};return l!=null&&l.includeSegments&&(k.segments=[{name:"Invalid AnonRequest Data",description:"AnonRequest payload too short (minimum 35 bytes required: 1 for dest hash + 32 for public key + 2 for MAC)",startByte:l.segmentOffset||0,endByte:(l.segmentOffset||0)+u.length-1,value:(0,r.bytesToHex)(u)}]),k}const m=[],c=(l==null?void 0:l.segmentOffset)||0;let h=0;const d=(0,r.byteToHex)(u[0]);l!=null&&l.includeSegments&&m.push({name:"Destination Hash",description:`First byte of destination node public key: 0x${d}`,startByte:c+h,endByte:c+h,value:d}),h+=1;const y=(0,r.bytesToHex)(u.subarray(1,33));l!=null&&l.includeSegments&&m.push({name:"Sender Public Key",description:"Ed25519 public key of the sender (32 bytes)",startByte:c+h,endByte:c+h+31,value:y}),h+=32;const g=(0,r.bytesToHex)(u.subarray(33,35));l!=null&&l.includeSegments&&m.push({name:"Cipher MAC",description:"MAC for encrypted data verification (2 bytes)",startByte:c+h,endByte:c+h+1,value:g}),h+=2;const f=(0,r.bytesToHex)(u.subarray(35));l!=null&&l.includeSegments&&u.length>35&&m.push({name:"Ciphertext",description:`Encrypted message data (${u.length-35} bytes). Contains encrypted plaintext with this structure:
|
||||
• Timestamp (4 bytes) - send time as unix timestamp
|
||||
• Sync Timestamp (4 bytes) - room server only, sender's "sync messages SINCE x" timestamp
|
||||
• Password (remaining bytes) - password for repeater/room`,startByte:c+h,endByte:c+u.length-1,value:f});const x={type:a.PayloadType.AnonRequest,version:a.PayloadVersion.Version1,isValid:!0,destinationHash:d,senderPublicKey:y,cipherMac:g,ciphertext:f,ciphertextLength:u.length-35};return l!=null&&l.includeSegments&&(x.segments=m),x}catch(m){return{type:a.PayloadType.AnonRequest,version:a.PayloadVersion.Version1,isValid:!1,errors:[m instanceof Error?m.message:"Failed to decode AnonRequest payload"],destinationHash:"",senderPublicKey:"",cipherMac:"",ciphertext:"",ciphertextLength:0}}}}return Cr.AnonRequestPayloadDecoder=o,Cr}var Er={},Ag;function bj(){if(Ag)return Er;Ag=1,Object.defineProperty(Er,"__esModule",{value:!0}),Er.AckPayloadDecoder=void 0;const a=ua(),r=Mi();class o{static decode(u,l){try{if(u.length<4){const y={type:a.PayloadType.Ack,version:a.PayloadVersion.Version1,isValid:!1,errors:["Ack payload too short (minimum 4 bytes for checksum)"],checksum:""};return l!=null&&l.includeSegments&&(y.segments=[{name:"Invalid Ack Data",description:"Ack payload too short (minimum 4 bytes required for checksum)",startByte:l.segmentOffset||0,endByte:(l.segmentOffset||0)+u.length-1,value:(0,r.bytesToHex)(u)}]),y}const m=[],c=(l==null?void 0:l.segmentOffset)||0,h=(0,r.bytesToHex)(u.subarray(0,4));l!=null&&l.includeSegments&&m.push({name:"Checksum",description:`CRC checksum of message timestamp, text, and sender pubkey: 0x${h}`,startByte:c,endByte:c+3,value:h}),l!=null&&l.includeSegments&&u.length>4&&m.push({name:"Additional Data",description:"Extra data in Ack payload",startByte:c+4,endByte:c+u.length-1,value:(0,r.bytesToHex)(u.subarray(4))});const d={type:a.PayloadType.Ack,version:a.PayloadVersion.Version1,isValid:!0,checksum:h};return l!=null&&l.includeSegments&&(d.segments=m),d}catch(m){return{type:a.PayloadType.Ack,version:a.PayloadVersion.Version1,isValid:!1,errors:[m instanceof Error?m.message:"Failed to decode Ack payload"],checksum:""}}}}return Er.AckPayloadDecoder=o,Er}var Sr={},Cg;function fj(){if(Cg)return Sr;Cg=1,Object.defineProperty(Sr,"__esModule",{value:!0}),Sr.PathPayloadDecoder=void 0;const a=ua(),r=Mi();class o{static decode(u){try{if(u.length<2)return{type:a.PayloadType.Path,version:a.PayloadVersion.Version1,isValid:!1,errors:["Path payload too short (minimum 2 bytes: path length + extra type)"],pathLength:0,pathHashes:[],extraType:0,extraData:""};const l=u[0];if(u.length<1+l+1)return{type:a.PayloadType.Path,version:a.PayloadVersion.Version1,isValid:!1,errors:[`Path payload too short (need ${1+l+1} bytes for path length + path + extra type)`],pathLength:l,pathHashes:[],extraType:0,extraData:""};const m=[];for(let d=0;d<l;d++)m.push((0,r.byteToHex)(u[1+d]));const c=u[1+l];let h="";return u.length>1+l+1&&(h=(0,r.bytesToHex)(u.subarray(1+l+1))),{type:a.PayloadType.Path,version:a.PayloadVersion.Version1,isValid:!0,pathLength:l,pathHashes:m,extraType:c,extraData:h}}catch(l){return{type:a.PayloadType.Path,version:a.PayloadVersion.Version1,isValid:!1,errors:[l instanceof Error?l.message:"Failed to decode Path payload"],pathLength:0,pathHashes:[],extraType:0,extraData:""}}}}return Sr.PathPayloadDecoder=o,Sr}var Br={},Eg;function vj(){if(Eg)return Br;Eg=1,Object.defineProperty(Br,"__esModule",{value:!0}),Br.TextMessagePayloadDecoder=void 0;const a=ua(),r=Mi();class o{static decode(u,l){try{if(u.length<4){const k={type:a.PayloadType.TextMessage,version:a.PayloadVersion.Version1,isValid:!1,errors:["TextMessage payload too short (minimum 4 bytes: dest + source + MAC)"],destinationHash:"",sourceHash:"",cipherMac:"",ciphertext:"",ciphertextLength:0};return l!=null&&l.includeSegments&&(k.segments=[{name:"Invalid TextMessage Data",description:"TextMessage payload too short (minimum 4 bytes required)",startByte:l.segmentOffset||0,endByte:(l.segmentOffset||0)+u.length-1,value:(0,r.bytesToHex)(u)}]),k}const m=[],c=(l==null?void 0:l.segmentOffset)||0;let h=0;const d=(0,r.byteToHex)(u[h]);l!=null&&l.includeSegments&&m.push({name:"Destination Hash",description:"First byte of destination node public key",startByte:c+h,endByte:c+h,value:d}),h+=1;const y=(0,r.byteToHex)(u[h]);l!=null&&l.includeSegments&&m.push({name:"Source Hash",description:"First byte of source node public key",startByte:c+h,endByte:c+h,value:y}),h+=1;const g=(0,r.bytesToHex)(u.subarray(h,h+2));l!=null&&l.includeSegments&&m.push({name:"Cipher MAC",description:"MAC for encrypted data in next field",startByte:c+h,endByte:c+h+1,value:g}),h+=2;const f=(0,r.bytesToHex)(u.subarray(h));l!=null&&l.includeSegments&&u.length>h&&m.push({name:"Ciphertext",description:"Encrypted message data (timestamp + message text)",startByte:c+h,endByte:c+u.length-1,value:f});const x={type:a.PayloadType.TextMessage,version:a.PayloadVersion.Version1,isValid:!0,destinationHash:d,sourceHash:y,cipherMac:g,ciphertext:f,ciphertextLength:u.length-4};return l!=null&&l.includeSegments&&(x.segments=m),x}catch(m){return{type:a.PayloadType.TextMessage,version:a.PayloadVersion.Version1,i
Line truncated
|
||||
// SHA256 round constants
|
||||
const K: array<u32, 64> = array<u32, 64>(
|
||||
0x428a2f98u, 0x71374491u, 0xb5c0fbcfu, 0xe9b5dba5u, 0x3956c25bu, 0x59f111f1u, 0x923f82a4u, 0xab1c5ed5u,
|
||||
0xd807aa98u, 0x12835b01u, 0x243185beu, 0x550c7dc3u, 0x72be5d74u, 0x80deb1feu, 0x9bdc06a7u, 0xc19bf174u,
|
||||
0xe49b69c1u, 0xefbe4786u, 0x0fc19dc6u, 0x240ca1ccu, 0x2de92c6fu, 0x4a7484aau, 0x5cb0a9dcu, 0x76f988dau,
|
||||
0x983e5152u, 0xa831c66du, 0xb00327c8u, 0xbf597fc7u, 0xc6e00bf3u, 0xd5a79147u, 0x06ca6351u, 0x14292967u,
|
||||
0x27b70a85u, 0x2e1b2138u, 0x4d2c6dfcu, 0x53380d13u, 0x650a7354u, 0x766a0abbu, 0x81c2c92eu, 0x92722c85u,
|
||||
0xa2bfe8a1u, 0xa81a664bu, 0xc24b8b70u, 0xc76c51a3u, 0xd192e819u, 0xd6990624u, 0xf40e3585u, 0x106aa070u,
|
||||
0x19a4c116u, 0x1e376c08u, 0x2748774cu, 0x34b0bcb5u, 0x391c0cb3u, 0x4ed8aa4au, 0x5b9cca4fu, 0x682e6ff3u,
|
||||
0x748f82eeu, 0x78a5636fu, 0x84c87814u, 0x8cc70208u, 0x90befffau, 0xa4506cebu, 0xbef9a3f7u, 0xc67178f2u
|
||||
);
|
||||
|
||||
// Character lookup table (a-z = 0-25, 0-9 = 26-35, dash = 36)
|
||||
const CHARS: array<u32, 37> = array<u32, 37>(
|
||||
0x61u, 0x62u, 0x63u, 0x64u, 0x65u, 0x66u, 0x67u, 0x68u, 0x69u, 0x6au, // a-j
|
||||
0x6bu, 0x6cu, 0x6du, 0x6eu, 0x6fu, 0x70u, 0x71u, 0x72u, 0x73u, 0x74u, // k-t
|
||||
0x75u, 0x76u, 0x77u, 0x78u, 0x79u, 0x7au, // u-z
|
||||
0x30u, 0x31u, 0x32u, 0x33u, 0x34u, 0x35u, 0x36u, 0x37u, 0x38u, 0x39u, // 0-9
|
||||
0x2du // dash
|
||||
);
|
||||
|
||||
struct Params {
|
||||
target_channel_hash: u32,
|
||||
batch_offset: u32,
|
||||
name_length: u32,
|
||||
batch_size: u32,
|
||||
target_mac: u32, // First 2 bytes of target MAC (in high 16 bits)
|
||||
ciphertext_words: u32, // Number of 32-bit words in ciphertext
|
||||
ciphertext_len_bits: u32, // Length of ciphertext in bits
|
||||
verify_mac: u32, // 1 to verify MAC, 0 to skip
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<uniform> params: Params;
|
||||
@group(0) @binding(1) var<storage, read_write> match_count: atomic<u32>;
|
||||
@group(0) @binding(2) var<storage, read_write> match_indices: array<u32>;
|
||||
@group(0) @binding(3) var<storage, read> ciphertext: array<u32>; // Ciphertext data
|
||||
|
||||
fn rotr(x: u32, n: u32) -> u32 {
|
||||
return (x >> n) | (x << (32u - n));
|
||||
}
|
||||
|
||||
fn ch(x: u32, y: u32, z: u32) -> u32 {
|
||||
return (x & y) ^ (~x & z);
|
||||
}
|
||||
|
||||
fn maj(x: u32, y: u32, z: u32) -> u32 {
|
||||
return (x & y) ^ (x & z) ^ (y & z);
|
||||
}
|
||||
|
||||
fn sigma0(x: u32) -> u32 {
|
||||
return rotr(x, 2u) ^ rotr(x, 13u) ^ rotr(x, 22u);
|
||||
}
|
||||
|
||||
fn sigma1(x: u32) -> u32 {
|
||||
return rotr(x, 6u) ^ rotr(x, 11u) ^ rotr(x, 25u);
|
||||
}
|
||||
|
||||
fn gamma0(x: u32) -> u32 {
|
||||
return rotr(x, 7u) ^ rotr(x, 18u) ^ (x >> 3u);
|
||||
}
|
||||
|
||||
fn gamma1(x: u32) -> u32 {
|
||||
return rotr(x, 17u) ^ rotr(x, 19u) ^ (x >> 10u);
|
||||
}
|
||||
|
||||
// Convert index to room name bytes, returns the hash as a u32 for the first byte check
|
||||
fn index_to_room_name(idx: u32, length: u32, msg: ptr<function, array<u32, 16>>) -> bool {
|
||||
// Message starts with '#' (0x23)
|
||||
var byte_pos = 0u;
|
||||
var word_idx = 0u;
|
||||
var current_word = 0x23000000u; // '#' in big-endian position 0
|
||||
byte_pos = 1u;
|
||||
|
||||
var remaining = idx;
|
||||
var prev_was_dash = false;
|
||||
|
||||
// Generate room name from index
|
||||
for (var i = 0u; i < length; i++) {
|
||||
let char_count = select(37u, 36u, i == 0u || i == length - 1u); // no dash at start/end
|
||||
var char_idx = remaining % char_count;
|
||||
remaining = remaining / char_count;
|
||||
|
||||
// Check for consecutive dashes (invalid)
|
||||
let is_dash = char_idx == 36u && i > 0u && i < length - 1u;
|
||||
if (is_dash && prev_was_dash) {
|
||||
return false; // Invalid: consecutive dashes
|
||||
}
|
||||
prev_was_dash = is_dash;
|
||||
|
||||
// Map char index to actual character
|
||||
let c = CHARS[char_idx];
|
||||
|
||||
// Pack byte into current word (big-endian)
|
||||
let shift = (3u - byte_pos % 4u) * 8u;
|
||||
if (byte_pos % 4u == 0u && byte_pos > 0u) {
|
||||
(*msg)[word_idx] = current_word;
|
||||
word_idx = word_idx + 1u;
|
||||
current_word = 0u;
|
||||
}
|
||||
current_word = current_word | (c << shift);
|
||||
byte_pos = byte_pos + 1u;
|
||||
}
|
||||
|
||||
// Add padding: 0x80 followed by zeros, then length in bits
|
||||
let msg_len_bits = (length + 1u) * 8u; // +1 for '#'
|
||||
|
||||
// Add 0x80 padding byte
|
||||
let shift = (3u - byte_pos % 4u) * 8u;
|
||||
if (byte_pos % 4u == 0u) {
|
||||
(*msg)[word_idx] = current_word;
|
||||
word_idx = word_idx + 1u;
|
||||
current_word = 0x80000000u;
|
||||
} else {
|
||||
current_word = current_word | (0x80u << shift);
|
||||
}
|
||||
byte_pos = byte_pos + 1u;
|
||||
|
||||
// Store current word
|
||||
if (byte_pos % 4u == 0u || word_idx < 14u) {
|
||||
(*msg)[word_idx] = current_word;
|
||||
word_idx = word_idx + 1u;
|
||||
}
|
||||
|
||||
// Zero-fill until word 14
|
||||
for (var i = word_idx; i < 14u; i++) {
|
||||
(*msg)[i] = 0u;
|
||||
}
|
||||
|
||||
// Length in bits (64-bit, but we only use lower 32 bits for short messages)
|
||||
(*msg)[14u] = 0u;
|
||||
(*msg)[15u] = msg_len_bits;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
fn sha256_block(msg: ptr<function, array<u32, 16>>) -> array<u32, 8> {
|
||||
// Initialize hash values
|
||||
var h: array<u32, 8> = array<u32, 8>(
|
||||
0x6a09e667u, 0xbb67ae85u, 0x3c6ef372u, 0xa54ff53au,
|
||||
0x510e527fu, 0x9b05688cu, 0x1f83d9abu, 0x5be0cd19u
|
||||
);
|
||||
|
||||
// Message schedule
|
||||
var w: array<u32, 64>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
w[i] = (*msg)[i];
|
||||
}
|
||||
for (var i = 16u; i < 64u; i++) {
|
||||
w[i] = gamma1(w[i-2u]) + w[i-7u] + gamma0(w[i-15u]) + w[i-16u];
|
||||
}
|
||||
|
||||
// Compression
|
||||
var a = h[0]; var b = h[1]; var c = h[2]; var d = h[3];
|
||||
var e = h[4]; var f = h[5]; var g = h[6]; var hh = h[7];
|
||||
|
||||
for (var i = 0u; i < 64u; i++) {
|
||||
let t1 = hh + sigma1(e) + ch(e, f, g) + K[i] + w[i];
|
||||
let t2 = sigma0(a) + maj(a, b, c);
|
||||
hh = g; g = f; f = e; e = d + t1;
|
||||
d = c; c = b; b = a; a = t1 + t2;
|
||||
}
|
||||
|
||||
h[0] = h[0] + a; h[1] = h[1] + b; h[2] = h[2] + c; h[3] = h[3] + d;
|
||||
h[4] = h[4] + e; h[5] = h[5] + f; h[6] = h[6] + g; h[7] = h[7] + hh;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
// Compute SHA256 of the key (16 bytes) to get channel hash
|
||||
fn sha256_key(key: array<u32, 4>) -> u32 {
|
||||
var msg: array<u32, 16>;
|
||||
|
||||
// Key bytes (16 bytes = 4 words)
|
||||
msg[0] = key[0];
|
||||
msg[1] = key[1];
|
||||
msg[2] = key[2];
|
||||
msg[3] = key[3];
|
||||
|
||||
// Padding: 0x80 followed by zeros
|
||||
msg[4] = 0x80000000u;
|
||||
for (var i = 5u; i < 14u; i++) {
|
||||
msg[i] = 0u;
|
||||
}
|
||||
|
||||
// Length: 128 bits
|
||||
msg[14] = 0u;
|
||||
msg[15] = 128u;
|
||||
|
||||
let hash = sha256_block(&msg);
|
||||
|
||||
// Return first byte of hash (big-endian)
|
||||
return hash[0] >> 24u;
|
||||
}
|
||||
|
||||
// HMAC-SHA256 for MAC verification
|
||||
// Key is 16 bytes (4 words), padded to 32 bytes with zeros for MeshCore
|
||||
// Returns first 2 bytes of HMAC (as u32 in high 16 bits)
|
||||
fn hmac_sha256_mac(key: array<u32, 4>, ciphertext_len: u32) -> u32 {
|
||||
// HMAC: H((K' ^ opad) || H((K' ^ ipad) || message))
|
||||
// K' is 64 bytes (32 bytes key + 32 bytes zero padding for MeshCore, then padded to 64)
|
||||
// ipad = 0x36 repeated, opad = 0x5c repeated
|
||||
|
||||
// Build padded key (64 bytes = 16 words)
|
||||
// MeshCore uses 32-byte secret: 16-byte key + 16 zero bytes
|
||||
var k_pad: array<u32, 16>;
|
||||
k_pad[0] = key[0];
|
||||
k_pad[1] = key[1];
|
||||
k_pad[2] = key[2];
|
||||
k_pad[3] = key[3];
|
||||
for (var i = 4u; i < 16u; i++) {
|
||||
k_pad[i] = 0u;
|
||||
}
|
||||
|
||||
// Inner hash: SHA256((K' ^ ipad) || message)
|
||||
// First block: K' ^ ipad (64 bytes)
|
||||
var inner_block: array<u32, 16>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
inner_block[i] = k_pad[i] ^ 0x36363636u;
|
||||
}
|
||||
|
||||
// Initialize hash state with first block
|
||||
var h: array<u32, 8> = sha256_block(&inner_block);
|
||||
|
||||
// Process ciphertext blocks (continuing from h state)
|
||||
let ciphertext_words = params.ciphertext_words;
|
||||
var word_idx = 0u;
|
||||
|
||||
// Process full 64-byte blocks of ciphertext
|
||||
while (word_idx + 16u <= ciphertext_words) {
|
||||
var block: array<u32, 16>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
block[i] = ciphertext[word_idx + i];
|
||||
}
|
||||
h = sha256_block_continue(&block, h);
|
||||
word_idx = word_idx + 16u;
|
||||
}
|
||||
|
||||
// Final block with remaining ciphertext + padding
|
||||
var final_block: array<u32, 16>;
|
||||
var remaining = ciphertext_words - word_idx;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
if (i < remaining) {
|
||||
final_block[i] = ciphertext[word_idx + i];
|
||||
} else if (i == remaining) {
|
||||
// Add 0x80 padding
|
||||
final_block[i] = 0x80000000u;
|
||||
} else {
|
||||
final_block[i] = 0u;
|
||||
}
|
||||
}
|
||||
|
||||
// Add length (64 bytes of ipad + ciphertext length)
|
||||
let total_bits = 512u + params.ciphertext_len_bits;
|
||||
if (remaining < 14u) {
|
||||
final_block[14] = 0u;
|
||||
final_block[15] = total_bits;
|
||||
h = sha256_block_continue(&final_block, h);
|
||||
} else {
|
||||
// Need extra block for length
|
||||
h = sha256_block_continue(&final_block, h);
|
||||
var len_block: array<u32, 16>;
|
||||
for (var i = 0u; i < 14u; i++) {
|
||||
len_block[i] = 0u;
|
||||
}
|
||||
len_block[14] = 0u;
|
||||
len_block[15] = total_bits;
|
||||
h = sha256_block_continue(&len_block, h);
|
||||
}
|
||||
|
||||
let inner_hash = h;
|
||||
|
||||
// Outer hash: SHA256((K' ^ opad) || inner_hash)
|
||||
var outer_block: array<u32, 16>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
outer_block[i] = k_pad[i] ^ 0x5c5c5c5cu;
|
||||
}
|
||||
h = sha256_block(&outer_block);
|
||||
|
||||
// Second block: inner_hash (32 bytes) + padding
|
||||
var hash_block: array<u32, 16>;
|
||||
for (var i = 0u; i < 8u; i++) {
|
||||
hash_block[i] = inner_hash[i];
|
||||
}
|
||||
hash_block[8] = 0x80000000u;
|
||||
for (var i = 9u; i < 14u; i++) {
|
||||
hash_block[i] = 0u;
|
||||
}
|
||||
hash_block[14] = 0u;
|
||||
hash_block[15] = 512u + 256u; // 64 bytes opad + 32 bytes inner hash
|
||||
|
||||
h = sha256_block_continue(&hash_block, h);
|
||||
|
||||
// Return first 2 bytes (high 16 bits of first word)
|
||||
return h[0] & 0xFFFF0000u;
|
||||
}
|
||||
|
||||
// SHA256 block computation continuing from existing state
|
||||
fn sha256_block_continue(msg: ptr<function, array<u32, 16>>, h_in: array<u32, 8>) -> array<u32, 8> {
|
||||
var h = h_in;
|
||||
|
||||
// Message schedule
|
||||
var w: array<u32, 64>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
w[i] = (*msg)[i];
|
||||
}
|
||||
for (var i = 16u; i < 64u; i++) {
|
||||
w[i] = gamma1(w[i-2u]) + w[i-7u] + gamma0(w[i-15u]) + w[i-16u];
|
||||
}
|
||||
|
||||
// Compression
|
||||
var a = h[0]; var b = h[1]; var c = h[2]; var d = h[3];
|
||||
var e = h[4]; var f = h[5]; var g = h[6]; var hh = h[7];
|
||||
|
||||
for (var i = 0u; i < 64u; i++) {
|
||||
let t1 = hh + sigma1(e) + ch(e, f, g) + K[i] + w[i];
|
||||
let t2 = sigma0(a) + maj(a, b, c);
|
||||
hh = g; g = f; f = e; e = d + t1;
|
||||
d = c; c = b; b = a; a = t1 + t2;
|
||||
}
|
||||
|
||||
h[0] = h[0] + a; h[1] = h[1] + b; h[2] = h[2] + c; h[3] = h[3] + d;
|
||||
h[4] = h[4] + e; h[5] = h[5] + f; h[6] = h[6] + g; h[7] = h[7] + hh;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
// Process a single candidate and record match if found
|
||||
fn process_candidate(name_idx: u32) {
|
||||
// Generate message for this room name
|
||||
var msg: array<u32, 16>;
|
||||
let valid = index_to_room_name(name_idx, params.name_length, &msg);
|
||||
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute SHA256("#roomname") - this gives us the key
|
||||
let key_hash = sha256_block(&msg);
|
||||
|
||||
// Take first 16 bytes (4 words) as the key
|
||||
var key: array<u32, 4>;
|
||||
key[0] = key_hash[0];
|
||||
key[1] = key_hash[1];
|
||||
key[2] = key_hash[2];
|
||||
key[3] = key_hash[3];
|
||||
|
||||
// Compute SHA256(key) to get channel hash
|
||||
let channel_hash = sha256_key(key);
|
||||
|
||||
// Check if channel hash matches target
|
||||
if (channel_hash != params.target_channel_hash) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Channel hash matches - verify MAC if enabled
|
||||
if (params.verify_mac == 1u) {
|
||||
let computed_mac = hmac_sha256_mac(key, params.ciphertext_len_bits);
|
||||
if (computed_mac != params.target_mac) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Found a match - record the index
|
||||
let match_idx = atomicAdd(&match_count, 1u);
|
||||
if (match_idx < 1024u) { // Limit stored matches
|
||||
match_indices[match_idx] = name_idx;
|
||||
}
|
||||
}
|
||||
|
||||
// Each thread processes 16 candidates to amortize thread overhead
|
||||
const CANDIDATES_PER_THREAD: u32 = 16u;
|
||||
|
||||
@compute @workgroup_size(256)
|
||||
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
||||
let base_idx = global_id.x * CANDIDATES_PER_THREAD;
|
||||
|
||||
for (var i = 0u; i < CANDIDATES_PER_THREAD; i++) {
|
||||
let idx = base_idx + i;
|
||||
if (idx >= params.batch_size) {
|
||||
return;
|
||||
}
|
||||
let name_idx = params.batch_offset + idx;
|
||||
process_candidate(name_idx);
|
||||
}
|
||||
}
|
||||
`}async init(){if(!navigator.gpu)return console.warn("WebGPU not supported"),!1;try{const r=await navigator.gpu.requestAdapter();if(!r)return console.warn("No GPU adapter found"),!1;this.device=await r.requestDevice(),this.bindGroupLayout=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:3,visibility:GPUShaderStage.COMPUTE,buffer:{type:"read-only-storage"}}]}),this.paramsBuffer=this.device.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.matchCountBuffer=this.device.createBuffer({size:4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST}),this.matchIndicesBuffer=this.device.createBuffer({size:1024*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC});for(let u=0;u<2;u++)this.matchCountReadBuffers[u]=this.device.createBuffer({size:4,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),this.matchIndicesReadBuffers[u]=this.device.createBuffer({size:1024*4,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST});const o=this.device.createShaderModule({code:this.shaderCode}),t=this.device.createPipelineLayout({bindGroupLayouts:[this.bindGroupLayout]});return this.pipeline=this.device.createComputePipeline({layout:t,compute:{module:o,entryPoint:"main"}}),!0}catch(r){return console.error("WebGPU initialization failed:",r),!1}}isAvailable(){return this.device!==null&&this.pipeline!==null}indexToRoomName(r,o){return Gn(o,r)}countNamesForLength(r){return Rr(r)}async runBatch(r,o,t,u,l,m){if(!this.device||!this.pipeline||!this.bindGroupLayout||!this.paramsBuffer||!this.matchCountBuffer||!this.matchIndicesBuffer||!this.matchCountReadBuffers[0]||!this.matchCountReadBuffers[1]||!this.matchIndicesReadBuffers[0]||!this.matchIndicesReadBuffers[1])throw new Error("GPU not initialized");const c=this.currentReadBufferIndex;this.currentReadBufferIndex=1-this.currentReadBufferIndex;const h=this.matchCountReadBuffers[c],d=this.matchIndicesReadBuffers[c],y=l&&m?1:0;let g,f=0,x=0;if(y){const z=new Uint8Array(l.length/2);for(let P=0;P<z.length;P++)z[P]=parseInt(l.substr(P*2,2),16);f=z.length*8;const D=Math.ceil(z.length/4)*4,R=new Uint8Array(D);R.set(z),g=new Uint32Array(D/4);for(let P=0;P<g.length;P++)g[P]=R[P*4]<<24|R[P*4+1]<<16|R[P*4+2]<<8|R[P*4+3];const F=parseInt(m.substr(0,2),16),O=parseInt(m.substr(2,2),16);x=F<<24|O<<16}else g=new Uint32Array([0]);const k=Math.max(g.length*4,4);(!this.ciphertextBuffer||this.ciphertextBufferSize<k)&&(this.ciphertextBuffer&&this.ciphertextBuffer.destroy(),this.ciphertextBuffer=this.device.createBuffer({size:k,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),this.ciphertextBufferSize=k,this.bindGroupDirty=!0);const q=new Uint32Array([r,t,o,u,x,g.length,f,y]);this.device.queue.writeBuffer(this.paramsBuffer,0,q),this.device.queue.writeBuffer(this.ciphertextBuffer,0,g),this.device.queue.writeBuffer(this.matchCountBuffer,0,hl.ZERO_DATA),(this.bindGroupDirty||!this.bindGroup)&&(this.bindGroup=this.device.createBindGroup({layout:this.bindGroupLayout,entries:[{binding:0,resource:{buffer:this.paramsBuffer}},{binding:1,resource:{buffer:this.matchCountBuffer}},{binding:2,resource:{buffer:this.matchIndicesBuffer}},{binding:3,resource:{buffer:this.ciphertextBuffer}}]}),this.bindGroupDirty=!1);const v=this.device.createCommandEncoder(),A=v.beginComputePass();A.setPipeline(this.pipeline),A.setBindGroup(0,this.bindGroup),A.dispatchWorkgroups(Math.ceil(u/(256*16))),A.end(),v.copyBufferToBuffer(this.matchCountBuffer,0,h,0,4),v.copyBufferToBuffer(this.matchIndicesBuffer,0,d,0,1024*4),this.device.queue.submit([v.finish()]),await h.mapAsync(GPUMapMode.READ);const w=new Uint32Array(h.getMappedRange())[0];h.unmap();const _=[];if(w>0){await d.mapAsync(GPUMapMode.READ);const z=new Uint32Array(d.getMappedRange());for(let D=0;D<Math.min(w,1024);D++)_.push(z[D]);d.unmap()}return _}destroy(){var r,o,t,u,l,m,c,h;(r=this.paramsBuffer)==null||r.destroy(),(o=this.matchCountBuffer)==null||o.destroy(),(t=this.matchIndicesBuffer)==null||t.destroy(),(u=this.ciphertextBuffer)==null||u.destroy(),(l=this.matchCountReadBuffers[0])==null||l.destroy(),(m=this.matchCountReadBuffers[1])==null||m.destroy(),(c=this.matchIndicesReadBuffers[0])==null||c.destroy(),(h=this.matchIndicesReadBuffers[1])==null||h.destroy(),this.paramsBuffer=null,this.matchCountBuffer=null,this.matchIndicesBuffer=null,this.ciphertextBuffer=null,this.ciphertextBufferSize=0,this.matchCountReadBuffers=[null,null],this.matchIndicesReadBuffers=[null,null],this.currentReadBufferIndex=0,this.bindGroup=null,this.bindGroupDirty=!0,this.device&&(this.device.destroy(),this.device=null),this.pipeline=null,this.bindGroupLayout=null}}hl.ZERO_DATA=new Uint32Array([0]);function Fj(){return typeof navigator<"u"&&"gpu"in navigator}class Ig{runBatch(r,o,t,u,l,m){const c=[],h=r.toString(16).padStart(2,"0")
Line truncated
|
||||
`).map(l=>l.trim().toLowerCase()).filter(l=>l.length>0);this.wordlist=u.filter(Mg)}setWordlist(r){this.wordlist=r.map(o=>o.trim().toLowerCase()).filter(Mg)}abort(){this.abortFlag=!0}isGpuAvailable(){return Fj()}async decodePacket(r){var t;const o=r.trim().replace(/\s+/g,"").replace(/^0x/i,"");if(!o||!/^[0-9a-fA-F]+$/.test(o))return null;try{const l=(t=(await Tg.MeshCorePacketDecoder.decodeWithVerification(o,{})).payload)==null?void 0:t.decoded;return!(l!=null&&l.channelHash)||!(l!=null&&l.ciphertext)||!(l!=null&&l.cipherMac)?null:{channelHash:l.channelHash,ciphertext:l.ciphertext,cipherMac:l.cipherMac,isGroupText:!0}}catch{return null}}async crack(r,o,t){this.abortFlag=!1,this.useTimestampFilter=(o==null?void 0:o.useTimestampFilter)??!0,this.useUtf8Filter=(o==null?void 0:o.useUtf8Filter)??!0,this.validSeconds=(o==null?void 0:o.validSeconds)??Du,this.useCpu=(o==null?void 0:o.forceCpu)??!1;const u=(o==null?void 0:o.maxLength)??8,l=(o==null?void 0:o.startingLength)??1,m=(o==null?void 0:o.useDictionary)??!0,c=(o==null?void 0:o.startFromType)??"bruteforce",h=r.toLowerCase(),d=await this.decodePacket(h);if(!d)return{found:!1,error:"Invalid packet or not a GroupText packet"};const{channelHash:y,ciphertext:g,cipherMac:f}=d,x=parseInt(y,16);this.useCpu?this.cpuInstance||(this.cpuInstance=new Ig):this.gpuInstance||(this.gpuInstance=new hl,await this.gpuInstance.init()||(this.useCpu=!0,this.cpuInstance=new Ig));const k=performance.now();let q=0,v=performance.now(),A=l,C=0,w=0,_=!1;if(o!=null&&o.startFrom){const H=o.startFrom.toLowerCase();if(c==="dictionary"){const Y=this.wordlist.indexOf(H);Y>=0&&(w=Y+1)}else{_=!0;const Y=Bj(H);Y&&(A=Math.max(l,Y.length),C=Y.index+1,C>=Rr(A)&&(A++,C=0))}}let z=0;m&&!_&&this.wordlist.length>0&&(z+=this.wordlist.length-w);for(let H=A;H<=u;H++)z+=Rr(H);z-=C;const D=(H,Y,ae)=>{if(!t)return;const ne=(performance.now()-k)/1e3,$=ne>0?Math.round(q/ne):0,re=z-q,ie=$>0?re/$:0;t({checked:q,total:z,percent:z>0?Math.min(100,q/z*100):0,rateKeysPerSec:$,etaSeconds:ie,elapsedSeconds:ne,currentLength:Y,currentPosition:ae,phase:H})},R=H=>{if(!Zb(g,f,H))return{valid:!1};const Y=Tg.ChannelCrypto.decryptGroupTextMessage(g,f,H);return!Y.success||!Y.data?{valid:!1}:this.useTimestampFilter&&!_j(Y.data.timestamp,this.validSeconds)?{valid:!1}:this.useUtf8Filter&&!Dj(Y.data.message)?{valid:!1}:{valid:!0,message:Y.data.message}};if(!_&&w===0&&A===l&&C===0){D("public-key",0,_u);const H=Ru($t);if(y===H){const Y=R($t);if(Y.valid)return{found:!0,roomName:_u,key:$t,decryptedMessage:Y.message}}}if(m&&!_&&this.wordlist.length>0)for(let H=w;H<this.wordlist.length;H++){if(this.abortFlag)return{found:!1,aborted:!0,resumeFrom:this.wordlist[H],resumeType:"dictionary"};const Y=this.wordlist[H],ae=Fu("#"+Y),ee=Ru(ae);if(parseInt(ee,16)===x){const $=R(ae);if($.valid)return{found:!0,roomName:Y,key:ae,decryptedMessage:$.message,resumeFrom:Y,resumeType:"dictionary"}}q++;const ne=performance.now();ne-v>=200&&(D("wordlist",Y.length,Y),v=ne,await new Promise($=>setTimeout($,0)))}const F=this.useCpu?1024:32768,O=(o==null?void 0:o.gpuDispatchMs)??1e3;let P=F,T=!1;for(let H=A;H<=u;H++){if(this.abortFlag)return{found:!1,aborted:!0,resumeFrom:Gn(H,0)||void 0,resumeType:"bruteforce"};const Y=Rr(H);let ae=H===A?C:0;for(;ae<Y;){if(this.abortFlag)return{found:!1,aborted:!0,resumeFrom:Gn(H,ae)||void 0,resumeType:"bruteforce"};const ee=Math.min(P,Y-ae),ne=performance.now();let $;this.useCpu?$=this.cpuInstance.runBatch(x,H,ae,ee,g,f):$=await this.gpuInstance.runBatch(x,H,ae,ee,g,f);const re=performance.now()-ne;if(q+=ee,!this.useCpu&&!T&&ee>=F&&re>0){const j=O/re,I=Math.round(ee*j),V=Math.pow(2,Math.round(Math.log2(Math.max(F,I))));P=Math.max(F,V),T=!0}for(const j of $){const I=Gn(H,j);if(!I)continue;const V=Fu("#"+I),Q=R(V);if(Q.valid)return{found:!0,roomName:I,key:V,decryptedMessage:Q.message,resumeFrom:I,resumeType:"bruteforce"}}ae+=ee;const ie=performance.now();if(ie-v>=200){const j=Gn(H,Math.min(ae,Y-1))||"";D("bruteforce",H,j),v=ie,await new Promise(I=>setTimeout(I,0))}}}return{found:!1,resumeFrom:Gn(u,Rr(u)-1)||void 0,resumeType:"bruteforce"}}destroy(){this.gpuInstance&&(this.gpuInstance.destroy(),this.gpuInstance=null),this.cpuInstance&&(this.cpuInstance.destroy(),this.cpuInstance=null)}}const Ij=["a","aa","aaa","aah","aahed","aahing","aahs","aal","aalii","aaliis","aals","aam","aani","aardvark","aardvarks","aardwolf","aardwolves","aargh","aaron","aaronic","aaronical","aaronite","aaronitic","aarrgh","aarrghh","aaru","aas","aasvogel","aasvogels","ab","aba","ababdeh","ababua","abac","abaca","abacay","abacas","abacate","abacaxi","abaci","abacinate","abacination","abacisci","abaciscus","abacist","aback","abacli","abacot","abacterial","abactinal","abactinally","abaction","abactor","abaculi","abaculus","abacus","abacuses","abada","abaddon","abadejo","abadengo","abadia","abadite","abaff","abaft","abay","abayah","abaisance","abaised","abaiser","abaisse","abaissed","abaka","abakas","abalation","abalienate","abalienated","abalienating","abaliena
Line truncated
|
||||
NoSleep enabled for older iOS devices. This can interrupt
|
||||
active or long-running network requests from completing successfully.
|
||||
See https://github.com/richtr/NoSleep.js/issues/15 for more details.
|
||||
`),this.noSleepTimer=window.setInterval(()=>{document.hidden||(window.location.href=window.location.href.split("#")[0],window.setTimeout(window.stop,0))},15e3),this.enabled=!0,Promise.resolve()):this.noSleepVideo.play().then(c=>(this.enabled=!0,c)).catch(c=>{throw this.enabled=!1,c})}disable(){t()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):o()?this.noSleepTimer&&(console.warn(`
|
||||
NoSleep now disabled for older iOS devices.
|
||||
`),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}}return fu=u,fu}var Lj=Oj();const Hj=Fo(Lj);function Vj({packets:a,channels:r,onChannelCreate:o,onRunningChange:t}){const[u,l]=S.useState(!1),[m,c]=S.useState(6),[h,d]=S.useState(!1),[y,g]=S.useState(!0),[f,x]=S.useState(!1),[k,q]=S.useState(null),[v,A]=S.useState(new Map),[C,w]=S.useState([]),[_,z]=S.useState(!1),[D,R]=S.useState(null),[F,O]=S.useState(null),P=S.useRef(null),T=S.useRef(null),W=S.useRef(!1),H=S.useRef(!1),Y=S.useRef(!1),ae=S.useRef(new Map),ee=S.useRef(!1),ne=S.useRef(6),$=S.useRef(!0),re=S.useRef(!1),ie=S.useRef(new Set);S.useEffect(()=>{const ce=new Nj;P.current=ce,R(ce.isGpuAvailable());const je=new Hj;return T.current=je,ce.setWordlist(Ij),z(!0),()=>{ce.destroy(),P.current=null,je.disable(),T.current=null}},[]),S.useEffect(()=>{const ce=()=>{Je.getUndecryptedPacketCount().then(({count:De})=>O(De)).catch(()=>O(null))};ce();const je=setInterval(ce,3e4);return()=>clearInterval(je)},[]);const j=new Set(r.map(ce=>ce.key.toUpperCase())),I=a.filter(ce=>ce.payload_type==="GROUP_TEXT"&&!ce.decrypted);S.useEffect(()=>{A(ce=>{const je=new Map(ce);let De=!1;for(const Ze of I)je.has(Ze.id)||(je.set(Ze.id,{packet:Ze,attempts:0,lastAttemptLength:0,status:"pending"}),De=!0);return De?(ae.current=je,je):ce})},[I.length]),S.useEffect(()=>{ae.current=v},[v]),S.useEffect(()=>{ee.current=h},[h]),S.useEffect(()=>{ne.current=m},[m]),S.useEffect(()=>{$.current=y},[y]),S.useEffect(()=>{re.current=f},[f]),S.useEffect(()=>{ie.current=new Set(I.map(ce=>ce.id))},[I]),S.useEffect(()=>{t==null||t(u)},[u,t]);const V=Array.from(v.values()).filter(ce=>ce.status==="pending").length,Q=Array.from(v.values()).filter(ce=>ce.status==="cracked").length,de=Array.from(v.values()).filter(ce=>ce.status==="failed").length,he=S.useCallback(async()=>{if(Y.current||!P.current||!W.current)return;const ce=ae.current;let je=null,De=null;for(const[He,Me]of ce.entries())if(Me.status==="pending"){je=Me,De=He;break}if(!je&&ee.current){const He=Array.from(ce.entries()).filter(([,Me])=>Me.status==="failed"&&Me.lastAttemptLength<10);He.length>0&&(He.sort((Me,Ve)=>Me[1].lastAttemptLength-Ve[1].lastAttemptLength),[De,je]=He[0])}if(!je||De===null){W.current&&setTimeout(()=>he(),1e3);return}if(!ie.current.has(De)){A(He=>{const Me=new Map(He);return Me.delete(De),Me}),W.current&&setTimeout(()=>he(),10);return}Y.current=!0;const Ze=ne.current,ai=je.lastAttemptLength>0,Le=ai?je.lastAttemptLength+1:Ze;try{const He=await P.current.crack(je.packet.data,{maxLength:Le,useTimestampFilter:!0,useUtf8Filter:!0,...re.current&&{gpuDispatchMs:1e4},...ai&&{useDictionary:!1,startingLength:Le}},Me=>{q(Me)});if(H.current){H.current=!1,Y.current=!1,q(null);return}if(He.found&&He.roomName&&He.key){A(Qe=>{const ni=new Map(Qe),fi=ni.get(De);return fi&&ni.set(De,{...fi,status:"cracked",attempts:fi.attempts+1,lastAttemptLength:Le}),ni});const Me={roomName:He.roomName,key:He.key,packetId:De,message:He.decryptedMessage||"",crackedAt:Date.now()};w(Qe=>[...Qe,Me]);const Ve=He.key.toUpperCase();if(!j.has(Ve))try{const Qe="#"+He.roomName;await o(Qe,He.key),$.current&&await Je.decryptHistoricalPackets({key_type:"channel",channel_name:Qe})}catch(Qe){console.error("Failed to create channel or decrypt historical:",Qe)}}else A(Me=>{const Ve=new Map(Me),Qe=Ve.get(De);return Qe&&Ve.set(De,{...Qe,status:"failed",attempts:Qe.attempts+1,lastAttemptLength:Le}),Ve})}catch(He){console.error("Cracking error:",He),A(Me=>{const Ve=new Map(Me),Qe=Ve.get(De);return Qe&&Ve.set(De,{...Qe,status:"failed",attempts:Qe.attempts+1,lastAttemptLength:Le}),Ve})}Y.current=!1,q(null),W.current&&setTimeout(()=>he(),100)},[j,o]),ge=()=>{var ce;if(!D){alert("WebGPU is not available in your browser. Please use Chrome 113+ or Edge 113+.");return}l(!0),W.current=!0,H.current=!1,(ce=T.current)==null||ce.enable(),he()},se=()=>{var ce,je;l(!1),W.current=!1,H.current=!0,(ce=P.current)==null||ce.abort(),(je=T.current)==null||je.disable()};return B.jsxs("div",{className:"flex flex-col h-full p-3 gap-3 bg-background border-t border-border",children:[B.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[B.jsx("button",{onClick:u?se:ge,disabled:!_||D===!1,className:$e("px-4 py-1.5 rounded text-sm font-medium",u?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90","disabled:opacity-50 disabled:cursor-not-allowed"),children:u?"Stop":"Start Cracking"}),B.jsxs("div",{className:"flex items-center gap-2",children:[B.jsx("label",{className:"text-sm text-muted-foreground",children:"Max Length:"}),B.jsx("input",{type:"number",min:1,max:10,value:m,onChange:ce=>c(Math.min(10,Math.max(1,parseInt(ce.target.value)||6))),className:"w-14 px-2 py-1 text-sm bg-muted border border-border rounded"})]}),B.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground cursor-pointer",children:[B.jsx("input",{type:"checkbox",c
Line truncated
|
||||
`)}function Yj(a){if(a<3600)return`0:${Math.floor(a/60).toString().padStart(2,"0")}`;if(a<86400){const t=Math.floor(a/3600),u=Math.floor(a%3600/60);return`${t}:${u.toString().padStart(2,"0")}`}const r=Math.floor(a/86400),o=Math.floor(a%86400/3600);return`${r}d ${o}h`}function Zj(a){if(a.length===0)return`[Neighbors]
|
||||
No neighbors reported`;const r=[`[Neighbors] (${a.length})`];for(const o of a){const t=o.name||o.pubkey_prefix,u=o.snr>=0?`+${o.snr.toFixed(1)}`:o.snr.toFixed(1);r.push(`${t}, ${u} dB [last heard ${Yj(o.last_heard_seconds)} ago]`)}return r.join(`
|
||||
`)}function Xj(a){if(a.length===0)return`[ACL]
|
||||
No ACL entries`;const r=[`[ACL] (${a.length})`];for(const o of a){const t=o.name||o.pubkey_prefix;r.push(`${t}: ${o.permission_name}`)}return r.join(`
|
||||
`)}function Jj(a){return`${a.type}-${a.conversation_key}-${a.text}-${a.sender_timestamp}`}function eA(){const a=window.location.hash.slice(1);if(!a)return null;if(a==="raw")return{type:"raw",name:"raw"};const r=a.indexOf("/");if(r===-1)return null;const o=a.slice(0,r),t=decodeURIComponent(a.slice(r+1));return(o==="channel"||o==="contact")&&t?{type:o,name:t}:null}function iA(a){if(!a)return"";if(a.type==="raw")return"#raw";const r=a.type==="channel"&&a.name.startsWith("#")?a.name.slice(1):a.name;return`#${a.type}/${encodeURIComponent(r)}`}function aA(){const a=S.useRef(null),r=S.useRef(null),o=S.useRef(new Set),[t,u]=S.useState(null),[l,m]=S.useState(null),[c,h]=S.useState(null),[d,y]=S.useState([]),[g,f]=S.useState([]),[x,k]=S.useState([]),[q,v]=S.useState(!1),[A,C]=S.useState(!1),[w,_]=S.useState([]),[z,D]=S.useState(null),[R,F]=S.useState(!1),[O,P]=S.useState(!1),[T,W]=S.useState(!1),[H,Y]=S.useState(!1),[ae,ee]=S.useState(0),[ne,$]=S.useState(!1),[re,ie]=S.useState(!1),[j,I]=S.useState(Zm),[V,Q]=S.useState({}),de=S.useRef(null),he=S.useMemo(()=>({onHealth:J=>{const L=de.current;de.current=J,u(J),L!==null&&L.radio_connected!==J.radio_connected&&(J.radio_connected?Tr.success("Radio connected",{description:J.serial_port?`Connected to ${J.serial_port}`:void 0}):Tr.error("Radio disconnected",{description:"Check radio connection and power"}))},onError:J=>{Tr.error(J.message,{description:J.details})},onContacts:J=>y(J),onChannels:J=>f(J),onMessage:J=>{const L=r.current,Z=Jj(J);if(o.current.has(Z)){console.debug("Duplicate message content ignored:",Z.slice(0,50));return}if(o.current.add(Z),o.current.size>1e3){const Ce=Array.from(o.current);o.current=new Set(Ce.slice(-500))}let oe=null;J.type==="CHAN"&&J.conversation_key?oe=an("channel",J.conversation_key):J.type==="PRIV"&&J.conversation_key&&(oe=an("contact",J.conversation_key));const ze=L?J.type==="CHAN"&&L.type==="channel"?J.conversation_key===L.id:J.type==="PRIV"&&L.type==="contact"?J.conversation_key&&Kg(L.id,J.conversation_key):!1:!1;if(ze&&k(Ce=>Ce.some(Fe=>Fe.id===J.id)?Ce:[...Ce,J]),oe){const Ce=J.received_at||Math.floor(Date.now()/1e3),Fe=au(oe,Ce);I(Fe),!J.outgoing&&!ze&&Q(_e=>({..._e,[oe]:(_e[oe]||0)+1}))}},onContact:J=>{y(L=>{const Z=L.findIndex(oe=>oe.public_key===J.public_key);if(Z>=0){const oe=[...L],ze=L[Z];return oe[Z]={...ze,...J,name:J.name??ze.name,last_path:J.last_path??ze.last_path,lat:J.lat??ze.lat,lon:J.lon??ze.lon},oe}return[...L,J]})},onRawPacket:J=>{_(L=>{if(L.some(oe=>oe.id===J.id))return L;const Z=[...L,J];return Z.length>Hg?Z.slice(-Hg):Z})},onMessageAcked:J=>{k(L=>{const Z=L.findIndex(oe=>oe.id===J);if(Z>=0){const oe=[...L];return oe[Z]={...L[Z],acked:!0},oe}return L})}}),[]);lk(he);const ge=S.useCallback(async()=>{try{const J=await Je.getRadioConfig();m(J)}catch(J){console.error("Failed to fetch config:",J)}},[]),se=S.useCallback(async()=>{try{const J=await Je.getSettings();h(J)}catch(J){console.error("Failed to fetch app settings:",J)}},[]),ce=S.useCallback(async()=>{try{const J=await Je.getUndecryptedPacketCount();ee(J.count)}catch(J){console.error("Failed to fetch undecrypted count:",J)}},[]),je=200,De=S.useCallback(async(J=!1)=>{if(!z){k([]),v(!1);return}J&&F(!0);try{const L=await Je.getMessages({type:z.type==="channel"?"CHAN":"PRIV",conversation_key:z.id,limit:je});k(L),v(L.length>=je)}catch(L){console.error("Failed to fetch messages:",L)}finally{J&&F(!1)}},[z]),Ze=S.useCallback(async()=>{if(!(!z||A||!q)){C(!0);try{const J=await Je.getMessages({type:z.type==="channel"?"CHAN":"PRIV",conversation_key:z.id,limit:je,offset:x.length});J.length>0&&k(L=>[...L,...J]),v(J.length>=je)}catch(J){console.error("Failed to fetch older messages:",J)}finally{C(!1)}}},[z,A,q,x.length]);S.useEffect(()=>{ge(),se(),ce()},[ge,se,ce]);const ai=S.useCallback(()=>{const J=eA();if(!J)return null;if(J.type==="raw")return{type:"raw",id:"raw",name:"Raw Packet Feed"};if(J.type==="channel"){const L=g.find(Z=>Z.name===J.name||Z.name===`#${J.name}`);if(L)return{type:"channel",id:L.key,name:L.name}}if(J.type==="contact"){const L=d.find(Z=>Kn(Z.name,Z.public_key)===J.name);if(L)return{type:"contact",id:L.public_key,name:Kn(L.name,L.public_key)}}return null},[g,d]),Le=S.useRef(!1);S.useEffect(()=>{if(Le.current||z||g.length===0&&d.length===0)return;const J=ai();if(J){D(J),Le.current=!0;return}const L=g.find(Z=>Z.name==="Public");L&&(D({type:"channel",id:L.key,name:L.name}),Le.current=!0)},[g,d,z,ai]);const He=S.useRef(new Set),Me=S.useRef(new Set);S.useEffect(()=>{const J=g.filter(oe=>!He.current.has(oe.key)),L=d.filter(oe=>oe.public_key&&!Me.current.has(oe.public_key));if(J.length===0&&L.length===0)return;J.forEach(oe=>He.current.add(oe.key)),L.forEach(oe=>Me.current.add(oe.public_key)),(async()=>{const oe=[...J.map(ze=>({type:"CHAN",conversation_key:ze.key})),...L.map(ze=>({type:"PRIV",conversation_key:ze.public_key}))];if(oe.length!==0)try{const ze=await Je.getMessagesBulk(oe,100),Ce=Kk(),Fe={},_e={};for(const Re of J){const di=ze[`CHAN:${Re.key}`]||[];if(d
Line truncated
|
||||
+537
@@ -0,0 +1,537 @@
|
||||
var Zv=Object.defineProperty;var Xv=(a,r,o)=>r in a?Zv(a,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):a[r]=o;var Ln=(a,r,o)=>Xv(a,typeof r!="symbol"?r+"":r,o);function Jv(a,r){for(var o=0;o<r.length;o++){const s=r[o];if(typeof s!="string"&&!Array.isArray(s)){for(const u in s)if(u!=="default"&&!(u in a)){const l=Object.getOwnPropertyDescriptor(s,u);l&&Object.defineProperty(a,u,l.get?l:{enumerable:!0,get:()=>s[u]})}}}return Object.freeze(Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))s(u);new MutationObserver(u=>{for(const l of u)if(l.type==="childList")for(const m of l.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&s(m)}).observe(document,{childList:!0,subtree:!0});function o(u){const l={};return u.integrity&&(l.integrity=u.integrity),u.referrerPolicy&&(l.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?l.credentials="include":u.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(u){if(u.ep)return;u.ep=!0;const l=o(u);fetch(u.href,l)}})();var Zc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fo(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}function Vg(a){if(Object.prototype.hasOwnProperty.call(a,"__esModule"))return a;var r=a.default;if(typeof r=="function"){var o=function s(){return this instanceof s?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};o.prototype=r.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(a).forEach(function(s){var u=Object.getOwnPropertyDescriptor(a,s);Object.defineProperty(o,s,u.get?u:{enumerable:!0,get:function(){return a[s]}})}),o}var Xc={exports:{}},br={},Jc={exports:{}},Ne={};/**
|
||||
* @license React
|
||||
* react.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var Mm;function ek(){if(Mm)return Ne;Mm=1;var a=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),u=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),m=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),g=Symbol.iterator;function f(q){return q===null||typeof q!="object"?null:(q=g&&q[g]||q["@@iterator"],typeof q=="function"?q:null)}var z={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function v(q,I,L){this.props=q,this.context=I,this.refs=j,this.updater=L||z}v.prototype.isReactComponent={},v.prototype.setState=function(q,I){if(typeof q!="object"&&typeof q!="function"&&q!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,q,I,"setState")},v.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function A(){}A.prototype=v.prototype;function C(q,I,L){this.props=q,this.context=I,this.refs=j,this.updater=L||z}var w=C.prototype=new A;w.constructor=C,k(w,v.prototype),w.isPureReactComponent=!0;var _=Array.isArray,x=Object.prototype.hasOwnProperty,D={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function F(q,I,L){var Q,de={},ge=null,be=null;if(I!=null)for(Q in I.ref!==void 0&&(be=I.ref),I.key!==void 0&&(ge=""+I.key),I)x.call(I,Q)&&!R.hasOwnProperty(Q)&&(de[Q]=I[Q]);var se=arguments.length-2;if(se===1)de.children=L;else if(1<se){for(var ce=Array(se),Ae=0;Ae<se;Ae++)ce[Ae]=arguments[Ae+2];de.children=ce}if(q&&q.defaultProps)for(Q in se=q.defaultProps,se)de[Q]===void 0&&(de[Q]=se[Q]);return{$$typeof:a,type:q,key:ge,ref:be,props:de,_owner:D.current}}function O(q,I){return{$$typeof:a,type:q.type,key:I,ref:q.ref,props:q.props,_owner:q._owner}}function N(q){return typeof q=="object"&&q!==null&&q.$$typeof===a}function T(q){var I={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(L){return I[L]})}var W=/\/+/g;function H(q,I){return typeof q=="object"&&q!==null&&q.key!=null?T(""+q.key):I.toString(36)}function K(q,I,L,Q,de){var ge=typeof q;(ge==="undefined"||ge==="boolean")&&(q=null);var be=!1;if(q===null)be=!0;else switch(ge){case"string":case"number":be=!0;break;case"object":switch(q.$$typeof){case a:case r:be=!0}}if(be)return be=q,de=de(be),q=Q===""?"."+H(be,0):Q,_(de)?(L="",q!=null&&(L=q.replace(W,"$&/")+"/"),K(de,I,L,"",function(Ae){return Ae})):de!=null&&(N(de)&&(de=O(de,L+(!de.key||be&&be.key===de.key?"":(""+de.key).replace(W,"$&/")+"/")+q)),I.push(de)),1;if(be=0,Q=Q===""?".":Q+":",_(q))for(var se=0;se<q.length;se++){ge=q[se];var ce=Q+H(ge,se);be+=K(ge,I,L,ce,de)}else if(ce=f(q),typeof ce=="function")for(q=ce.call(q),se=0;!(ge=q.next()).done;)ge=ge.value,ce=Q+H(ge,se++),be+=K(ge,I,L,ce,de);else if(ge==="object")throw I=String(q),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.");return be}function ae(q,I,L){if(q==null)return q;var Q=[],de=0;return K(q,Q,"","",function(ge){return I.call(L,ge,de++)}),Q}function X(q){if(q._status===-1){var I=q._result;I=I(),I.then(function(L){(q._status===0||q._status===-1)&&(q._status=1,q._result=L)},function(L){(q._status===0||q._status===-1)&&(q._status=2,q._result=L)}),q._status===-1&&(q._status=0,q._result=I)}if(q._status===1)return q._result.default;throw q._result}var ne={current:null},$={transition:null},oe={ReactCurrentDispatcher:ne,ReactCurrentBatchConfig:$,ReactCurrentOwner:D};function ee(){throw Error("act(...) is not supported in production builds of React.")}return Ne.Children={map:ae,forEach:function(q,I,L){ae(q,function(){I.apply(this,arguments)},L)},count:function(q){var I=0;return ae(q,function(){I++}),I},toArray:function(q){return ae(q,function(I){return I})||[]},only:function(q){if(!N(q))throw Error("React.Children.only expected to receive a single React element child.");return q}},Ne.Component=v,Ne.Fragment=o,Ne.Profiler=u,Ne.PureComponent=C,Ne.StrictMode=s,Ne.Suspense=h,Ne.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=oe,Ne.act=ee,Ne.cloneElement=function(q,I,L){if(q==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+q+".");var Q=k({},q.props),de=q.key,ge=q.ref,be=q._owner;if(I!=null){if(I.ref!==void 0&&(ge=I.ref,be=D.current),I.key!==void 0&&(de=""+I.key),q.type&&q.type.defaultProps)var se=q.type.defaultProps;for(ce in I)x.call(I,ce)&&!R.hasOwnProperty(ce)&&(Q[ce]=I[ce]===void 0&&se!==void 0?se[ce]:I[ce])}var ce=arguments.length-2;if(ce===1)Q.children=L;else if(1<ce){se=Array(ce);for(var Ae=0;Ae<ce;Ae++)se[Ae]=arguments[Ae+2];Q.children=se}return{$$typeof:a,type:q.type,key:de,ref:ge,props:Q,_owner:be}},Ne.createContLine truncated
|
||||
* @license React
|
||||
* react-jsx-runtime.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var Lm;function ik(){if(Lm)return br;Lm=1;var a=Tu(),r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,u=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function m(c,h,d){var y,g={},f=null,z=null;d!==void 0&&(f=""+d),h.key!==void 0&&(f=""+h.key),h.ref!==void 0&&(z=h.ref);for(y in h)s.call(h,y)&&!l.hasOwnProperty(y)&&(g[y]=h[y]);if(c&&c.defaultProps)for(y in h=c.defaultProps,h)g[y]===void 0&&(g[y]=h[y]);return{$$typeof:r,type:c,key:f,ref:z,props:g,_owner:u.current}}return br.Fragment=o,br.jsx=m,br.jsxs=m,br}var Hm;function ak(){return Hm||(Hm=1,Xc.exports=ik()),Xc.exports}var B=ak(),S=Tu();const he=Fo(S),Pu=Jv({__proto__:null,default:he},[S]);var Ks={},eu={exports:{}},aa={},iu={exports:{}},au={};/**
|
||||
* @license React
|
||||
* scheduler.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var Vm;function nk(){return Vm||(Vm=1,(function(a){function r($,oe){var ee=$.length;$.push(oe);e:for(;0<ee;){var q=ee-1>>>1,I=$[q];if(0<u(I,oe))$[q]=oe,$[ee]=I,ee=q;else break e}}function o($){return $.length===0?null:$[0]}function s($){if($.length===0)return null;var oe=$[0],ee=$.pop();if(ee!==oe){$[0]=ee;e:for(var q=0,I=$.length,L=I>>>1;q<L;){var Q=2*(q+1)-1,de=$[Q],ge=Q+1,be=$[ge];if(0>u(de,ee))ge<I&&0>u(be,de)?($[q]=be,$[ge]=ee,q=ge):($[q]=de,$[Q]=ee,q=Q);else if(ge<I&&0>u(be,ee))$[q]=be,$[ge]=ee,q=ge;else break e}}return oe}function u($,oe){var ee=$.sortIndex-oe.sortIndex;return ee!==0?ee:$.id-oe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;a.unstable_now=function(){return l.now()}}else{var m=Date,c=m.now();a.unstable_now=function(){return m.now()-c}}var h=[],d=[],y=1,g=null,f=3,z=!1,k=!1,j=!1,v=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w($){for(var oe=o(d);oe!==null;){if(oe.callback===null)s(d);else if(oe.startTime<=$)s(d),oe.sortIndex=oe.expirationTime,r(h,oe);else break;oe=o(d)}}function _($){if(j=!1,w($),!k)if(o(h)!==null)k=!0,X(x);else{var oe=o(d);oe!==null&&ne(_,oe.startTime-$)}}function x($,oe){k=!1,j&&(j=!1,A(F),F=-1),z=!0;var ee=f;try{for(w(oe),g=o(h);g!==null&&(!(g.expirationTime>oe)||$&&!T());){var q=g.callback;if(typeof q=="function"){g.callback=null,f=g.priorityLevel;var I=q(g.expirationTime<=oe);oe=a.unstable_now(),typeof I=="function"?g.callback=I:g===o(h)&&s(h),w(oe)}else s(h);g=o(h)}if(g!==null)var L=!0;else{var Q=o(d);Q!==null&&ne(_,Q.startTime-oe),L=!1}return L}finally{g=null,f=ee,z=!1}}var D=!1,R=null,F=-1,O=5,N=-1;function T(){return!(a.unstable_now()-N<O)}function W(){if(R!==null){var $=a.unstable_now();N=$;var oe=!0;try{oe=R(!0,$)}finally{oe?H():(D=!1,R=null)}}else D=!1}var H;if(typeof C=="function")H=function(){C(W)};else if(typeof MessageChannel<"u"){var K=new MessageChannel,ae=K.port2;K.port1.onmessage=W,H=function(){ae.postMessage(null)}}else H=function(){v(W,0)};function X($){R=$,D||(D=!0,H())}function ne($,oe){F=v(function(){$(a.unstable_now())},oe)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function($){$.callback=null},a.unstable_continueExecution=function(){k||z||(k=!0,X(x))},a.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<$?Math.floor(1e3/$):5},a.unstable_getCurrentPriorityLevel=function(){return f},a.unstable_getFirstCallbackNode=function(){return o(h)},a.unstable_next=function($){switch(f){case 1:case 2:case 3:var oe=3;break;default:oe=f}var ee=f;f=oe;try{return $()}finally{f=ee}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function($,oe){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var ee=f;f=$;try{return oe()}finally{f=ee}},a.unstable_scheduleCallback=function($,oe,ee){var q=a.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?q+ee:q):ee=q,$){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=ee+I,$={id:y++,callback:oe,priorityLevel:$,startTime:ee,expirationTime:I,sortIndex:-1},ee>q?($.sortIndex=ee,r(d,$),o(h)===null&&$===o(d)&&(j?(A(F),F=-1):j=!0,ne(_,ee-q))):($.sortIndex=I,r(h,$),k||z||(k=!0,X(x))),$},a.unstable_shouldYield=T,a.unstable_wrapCallback=function($){var oe=f;return function(){var ee=f;f=oe;try{return $.apply(this,arguments)}finally{f=ee}}}})(au)),au}var Um;function ok(){return Um||(Um=1,iu.exports=nk()),iu.exports}/**
|
||||
* @license React
|
||||
* react-dom.production.min.js
|
||||
*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/var Wm;function rk(){if(Wm)return aa;Wm=1;var a=Tu(),r=ok();function o(e){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)i+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,u={};function l(e,i){m(e,i),m(e+"Capture",i)}function m(e,i){for(u[e]=i,e=0;e<i.length;e++)s.add(i[e])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,y={},g={};function f(e){return h.call(g,e)?!0:h.call(y,e)?!1:d.test(e)?g[e]=!0:(y[e]=!0,!1)}function z(e,i,n,t){if(n!==null&&n.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return t?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function k(e,i,n,t){if(i===null||typeof i>"u"||z(e,i,n,t))return!0;if(t)return!1;if(n!==null)switch(n.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function j(e,i,n,t,p,b,E){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=t,this.attributeNamespace=p,this.mustUseProperty=n,this.propertyName=e,this.type=i,this.sanitizeURL=b,this.removeEmptyString=E}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){v[e]=new j(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var i=e[0];v[i]=new j(i,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){v[e]=new j(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){v[e]=new j(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){v[e]=new j(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){v[e]=new j(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){v[e]=new j(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){v[e]=new j(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){v[e]=new j(e,5,!1,e.toLowerCase(),null,!1,!1)});var A=/[\-:]([a-z])/g;function C(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var i=e.replace(A,C);v[i]=new j(i,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var i=e.replace(A,C);v[i]=new j(i,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var i=e.replace(A,C);v[i]=new j(i,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){v[e]=new j(e,1,!1,e.toLowerCase(),null,!1,!1)}),v.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){v[e]=new j(e,1,!1,e.toLowerCase(),null,!0,!0)});function w(e,i,n,t){var p=v.hasOwnProperty(i)?v[i]:null;(p!==null?p.type!==0:t||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=
Line truncated
|
||||
`+q+e}var L=!1;function Q(e,i){if(!e||L)return"";L=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(Z){var t=Z}Reflect.construct(e,[],i)}else{try{i.call()}catch(Z){t=Z}e.call(i.prototype)}else{try{throw Error()}catch(Z){t=Z}e()}}catch(Z){if(Z&&t&&typeof Z.stack=="string"){for(var p=Z.stack.split(`
|
||||
`),b=t.stack.split(`
|
||||
`),E=p.length-1,P=b.length-1;1<=E&&0<=P&&p[E]!==b[P];)P--;for(;1<=E&&0<=P;E--,P--)if(p[E]!==b[P]){if(E!==1||P!==1)do if(E--,P--,0>P||p[E]!==b[P]){var M=`
|
||||
`+p[E].replace(" at new "," at ");return e.displayName&&M.includes("<anonymous>")&&(M=M.replace("<anonymous>",e.displayName)),M}while(1<=E&&0<=P);break}}}finally{L=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?I(e):""}function de(e){switch(e.tag){case 5:return I(e.type);case 16:return I("Lazy");case 13:return I("Suspense");case 19:return I("SuspenseList");case 0:case 2:case 15:return e=Q(e.type,!1),e;case 11:return e=Q(e.type.render,!1),e;case 1:return e=Q(e.type,!0),e;default:return""}}function ge(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case D:return"Portal";case O:return"Profiler";case F:return"StrictMode";case H:return"Suspense";case K:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case T:return(e.displayName||"Context")+".Consumer";case N:return(e._context.displayName||"Context")+".Provider";case W:var i=e.render;return e=e.displayName,e||(e=i.displayName||i.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ae:return i=e.displayName||null,i!==null?i:ge(e.type)||"Memo";case X:i=e._payload,e=e._init;try{return ge(e(i))}catch{}}return null}function be(e){var i=e.type;switch(e.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=i.render,e=e.displayName||e.name||"",i.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ge(i);case 8:return i===F?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function se(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ce(e){var i=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function Ae(e){var i=ce(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,i),t=""+e[i];if(!e.hasOwnProperty(i)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var p=n.get,b=n.set;return Object.defineProperty(e,i,{configurable:!0,get:function(){return p.call(this)},set:function(E){t=""+E,b.call(this,E)}}),Object.defineProperty(e,i,{enumerable:n.enumerable}),{getValue:function(){return t},setValue:function(E){t=""+E},stopTracking:function(){e._valueTracker=null,delete e[i]}}}}function Fe(e){e._valueTracker||(e._valueTracker=Ae(e))}function He(e){if(!e)return!1;var i=e._valueTracker;if(!i)return!0;var n=i.getValue(),t="";return e&&(t=ce(e)?e.checked?"true":"false":e.value),e=t,e!==n?(i.setValue(e),!0):!1}function ai(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Qe(e,i){var n=i.checked;return ee({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Oe(e,i){var n=i.defaultValue==null?"":i.defaultValue,t=i.checked!=null?i.checked:i.defaultChecked;n=se(i.value!=null?i.value:n),e._wrapperState={initialChecked:t,initialValue:n,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function Me(e,i){i=i.checked,i!=null&&w(e,"checked",i,!1)}function Xe(e,i){Me(e,i);var n=se(i.value),t=i.type;if(n!=null)t==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(t==="submit"||t==="reset"){e.removeAttribute("value");return}i.hasOwnProperty("value")?Ge(e,i.type,n):i.hasOwnProperty("defaultValue")&&Ge(e,i.type,se(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(e.defaultChecked=!!i.defaultChecked)}function Ve(e,i,n){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var t=i.type;if(!(t!=="submit"&&t!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+e._wrapperState.initialValue,n||i===e.value||(e.value=i),e.defaultValue=i}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ge(e,i,n){(i!=="number"||ai(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var yi=Array.isArray;function si(e,i,n,t){if(e=e.options,i){i={};for(var p=0;p<n.length;p++)i["$"+n[p]]=!0;for(n=0;n<e.length;n++)p=i.hasOwnProperty("$"+e[n].value),e[n].selected!==p&&(e[n].selected=p),p&&t&&(e[n].defaultSelected=!0)}else{for(n=""+se(n),i=null,p=0;p<e.length;p++){if(e[p].value===n){e[p].selected=!0,t&&(e[p].defaultSelected=!0);return}i!==null||e[p].disabled||(i=e[p])}i!==null&&(i.selected=!0)}}function Le(e,i){if(i.dangerouslySetInnerHTML!
Line truncated
|
||||
`).replace(uv,"")}function ls(e,i,n){if(i=op(i),op(e)!==i&&n)throw Error(o(425))}function cs(){}var Hl=null,Vl=null;function Ul(e,i){return e==="textarea"||e==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Wl=typeof setTimeout=="function"?setTimeout:void 0,dv=typeof clearTimeout=="function"?clearTimeout:void 0,rp=typeof Promise=="function"?Promise:void 0,pv=typeof queueMicrotask=="function"?queueMicrotask:typeof rp<"u"?function(e){return rp.resolve(null).then(e).catch(mv)}:Wl;function mv(e){setTimeout(function(){throw e})}function $l(e,i){var n=i,t=0;do{var p=n.nextSibling;if(e.removeChild(n),p&&p.nodeType===8)if(n=p.data,n==="/$"){if(t===0){e.removeChild(p),Uo(i);return}t--}else n!=="$"&&n!=="$?"&&n!=="$!"||t++;n=p}while(n);Uo(i)}function un(e){for(;e!=null;e=e.nextSibling){var i=e.nodeType;if(i===1||i===3)break;if(i===8){if(i=e.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return e}function sp(e){e=e.previousSibling;for(var i=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(i===0)return e;i--}else n==="/$"&&i++}e=e.previousSibling}return null}var so=Math.random().toString(36).slice(2),Fa="__reactFiber$"+so,ir="__reactProps$"+so,Va="__reactContainer$"+so,Ql="__reactEvents$"+so,hv="__reactListeners$"+so,gv="__reactHandles$"+so;function Sn(e){var i=e[Fa];if(i)return i;for(var n=e.parentNode;n;){if(i=n[Va]||n[Fa]){if(n=i.alternate,i.child!==null||n!==null&&n.child!==null)for(e=sp(e);e!==null;){if(n=e[Fa])return n;e=sp(e)}return i}e=n,n=e.parentNode}return null}function ar(e){return e=e[Fa]||e[Va],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function to(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(o(33))}function us(e){return e[ir]||null}var Gl=[],lo=-1;function dn(e){return{current:e}}function li(e){0>lo||(e.current=Gl[lo],Gl[lo]=null,lo--)}function ri(e,i){lo++,Gl[lo]=e.current,e.current=i}var pn={},Li=dn(pn),Zi=dn(!1),Bn=pn;function co(e,i){var n=e.type.contextTypes;if(!n)return pn;var t=e.stateNode;if(t&&t.__reactInternalMemoizedUnmaskedChildContext===i)return t.__reactInternalMemoizedMaskedChildContext;var p={},b;for(b in n)p[b]=i[b];return t&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=p),p}function Xi(e){return e=e.childContextTypes,e!=null}function ds(){li(Zi),li(Li)}function tp(e,i,n){if(Li.current!==pn)throw Error(o(168));ri(Li,i),ri(Zi,n)}function lp(e,i,n){var t=e.stateNode;if(i=i.childContextTypes,typeof t.getChildContext!="function")return n;t=t.getChildContext();for(var p in t)if(!(p in i))throw Error(o(108,be(e)||"Unknown",p));return ee({},n,t)}function ps(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||pn,Bn=Li.current,ri(Li,e),ri(Zi,Zi.current),!0}function cp(e,i,n){var t=e.stateNode;if(!t)throw Error(o(169));n?(e=lp(e,i,Bn),t.__reactInternalMemoizedMergedChildContext=e,li(Zi),li(Li),ri(Li,e)):li(Zi),ri(Zi,n)}var Ua=null,ms=!1,Kl=!1;function up(e){Ua===null?Ua=[e]:Ua.push(e)}function yv(e){ms=!0,up(e)}function mn(){if(!Kl&&Ua!==null){Kl=!0;var e=0,i=ii;try{var n=Ua;for(ii=1;e<n.length;e++){var t=n[e];do t=t(!0);while(t!==null)}Ua=null,ms=!1}catch(p){throw Ua!==null&&(Ua=Ua.slice(e+1)),pd(bl,mn),p}finally{ii=i,Kl=!1}}return null}var uo=[],po=0,hs=null,gs=0,pa=[],ma=0,_n=null,Wa=1,$a="";function Dn(e,i){uo[po++]=gs,uo[po++]=hs,hs=e,gs=i}function dp(e,i,n){pa[ma++]=Wa,pa[ma++]=$a,pa[ma++]=_n,_n=e;var t=Wa;e=$a;var p=32-wa(t)-1;t&=~(1<<p),n+=1;var b=32-wa(i)+p;if(30<b){var E=p-p%5;b=(t&(1<<E)-1).toString(32),t>>=E,p-=E,Wa=1<<32-wa(i)+p|n<<p|t,$a=b+e}else Wa=1<<b|n<<p|t,$a=e}function Yl(e){e.return!==null&&(Dn(e,1),dp(e,1,0))}function Zl(e){for(;e===hs;)hs=uo[--po],uo[po]=null,gs=uo[--po],uo[po]=null;for(;e===_n;)_n=pa[--ma],pa[ma]=null,$a=pa[--ma],pa[ma]=null,Wa=pa[--ma],pa[ma]=null}var sa=null,ta=null,ci=!1,za=null;function pp(e,i){var n=ba(5,null,null,0);n.elementType="DELETED",n.stateNode=i,n.return=e,i=e.deletions,i===null?(e.deletions=[n],e.flags|=16):i.push(n)}function mp(e,i){switch(e.tag){case 5:var n=e.type;return i=i.nodeType!==1||n.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(e.stateNode=i,sa=e,ta=un(i.firstChild),!0):!1;case 6:return i=e.pendingProps===""||i.nodeType!==3?null:i,i!==null?(e.stateNode=i,sa=e,ta=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(n=_n!==null?{id:Wa,overflow:$a}:null,e.memoizedState={dehydrated:i,treeContext:n,retryLane:1073741824},n=ba(18,null,null,0),n.stateNode=i,n.return=e,e.child=n,sa=e,ta=null,!0):!1;default:return!1}}function Xl(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Jl(e){if(ci){var i=ta;if(i){var n=i;if(!mp(e,i)){if(Xl(e))throw Error(o(418));i=un(n.nextSibling);var t=sa;i&&mp(e,i)?pp(t,n):(e.flags=e.flags&-4097|2,ci=!1,sa=e)}}else{if(Xl(e))throw Error(o(418));e.flags=e.flags&-4097|2,ci=!1,sa=e}}}function hp(e){for(e=e
Line truncated
|
||||
Error generating stack: `+b.message+`
|
||||
`+b.stack}return{value:e,source:i,stack:p,digest:null}}function wc(e,i,n){return{value:e,source:null,stack:n??null,digest:i??null}}function xc(e,i){try{console.error(i.value)}catch(n){setTimeout(function(){throw n})}}var jv=typeof WeakMap=="function"?WeakMap:Map;function Gp(e,i,n){n=Ga(-1,n),n.tag=3,n.payload={element:null};var t=i.value;return n.callback=function(){Ts||(Ts=!0,Nc=t),xc(e,i)},n}function Kp(e,i,n){n=Ga(-1,n),n.tag=3;var t=e.type.getDerivedStateFromError;if(typeof t=="function"){var p=i.value;n.payload=function(){return t(p)},n.callback=function(){xc(e,i)}}var b=e.stateNode;return b!==null&&typeof b.componentDidCatch=="function"&&(n.callback=function(){xc(e,i),typeof t!="function"&&(bn===null?bn=new Set([this]):bn.add(this));var E=i.stack;this.componentDidCatch(i.value,{componentStack:E!==null?E:""})}),n}function Yp(e,i,n){var t=e.pingCache;if(t===null){t=e.pingCache=new jv;var p=new Set;t.set(i,p)}else p=t.get(i),p===void 0&&(p=new Set,t.set(i,p));p.has(n)||(p.add(n),e=Mv.bind(null,e,i,n),i.then(e,e))}function Zp(e){do{var i;if((i=e.tag===13)&&(i=e.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return e;e=e.return}while(e!==null);return null}function Xp(e,i,n,t,p){return(e.mode&1)===0?(e===i?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(i=Ga(-1,1),i.tag=2,gn(n,i,1))),n.lanes|=1),e):(e.flags|=65536,e.lanes=p,e)}var Av=_.ReactCurrentOwner,Ji=!1;function $i(e,i,n,t){i.child=e===null?fp(i,null,n,t):ho(i,e.child,n,t)}function Jp(e,i,n,t,p){n=n.render;var b=i.ref;return yo(i,p),t=mc(e,i,n,t,b,p),n=hc(),e!==null&&!Ji?(i.updateQueue=e.updateQueue,i.flags&=-2053,e.lanes&=~p,Ka(e,i,p)):(ci&&n&&Yl(i),i.flags|=1,$i(e,i,t,p),i.child)}function em(e,i,n,t,p){if(e===null){var b=n.type;return typeof b=="function"&&!Uc(b)&&b.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(i.tag=15,i.type=b,im(e,i,b,t,p)):(e=Ls(n.type,null,t,i,i.mode,p),e.ref=i.ref,e.return=i,i.child=e)}if(b=e.child,(e.lanes&p)===0){var E=b.memoizedProps;if(n=n.compare,n=n!==null?n:Yo,n(E,t)&&e.ref===i.ref)return Ka(e,i,p)}return i.flags|=1,e=wn(b,t),e.ref=i.ref,e.return=i,i.child=e}function im(e,i,n,t,p){if(e!==null){var b=e.memoizedProps;if(Yo(b,t)&&e.ref===i.ref)if(Ji=!1,i.pendingProps=t=b,(e.lanes&p)!==0)(e.flags&131072)!==0&&(Ji=!0);else return i.lanes=e.lanes,Ka(e,i,p)}return zc(e,i,n,t,p)}function am(e,i,n){var t=i.pendingProps,p=t.children,b=e!==null?e.memoizedState:null;if(t.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},ri(ko,la),la|=n;else{if((n&1073741824)===0)return e=b!==null?b.baseLanes|n:n,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:e,cachePool:null,transitions:null},i.updateQueue=null,ri(ko,la),la|=e,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},t=b!==null?b.baseLanes:n,ri(ko,la),la|=t}else b!==null?(t=b.baseLanes|n,i.memoizedState=null):t=n,ri(ko,la),la|=t;return $i(e,i,p,n),i.child}function nm(e,i){var n=i.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(i.flags|=512,i.flags|=2097152)}function zc(e,i,n,t,p){var b=Xi(n)?Bn:Li.current;return b=co(i,b),yo(i,p),n=mc(e,i,n,t,b,p),t=hc(),e!==null&&!Ji?(i.updateQueue=e.updateQueue,i.flags&=-2053,e.lanes&=~p,Ka(e,i,p)):(ci&&t&&Yl(i),i.flags|=1,$i(e,i,n,p),i.child)}function om(e,i,n,t,p){if(Xi(n)){var b=!0;ps(i)}else b=!1;if(yo(i,p),i.stateNode===null)Bs(e,i),$p(i,n,t),kc(i,n,t,p),t=!0;else if(e===null){var E=i.stateNode,P=i.memoizedProps;E.props=P;var M=E.context,Z=n.contextType;typeof Z=="object"&&Z!==null?Z=ha(Z):(Z=Xi(n)?Bn:Li.current,Z=co(i,Z));var le=n.getDerivedStateFromProps,ue=typeof le=="function"||typeof E.getSnapshotBeforeUpdate=="function";ue||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(P!==t||M!==Z)&&Qp(i,E,t,Z),hn=!1;var te=i.memoizedState;E.state=te,ws(i,t,E,p),M=i.memoizedState,P!==t||te!==M||Zi.current||hn?(typeof le=="function"&&(vc(i,n,le,t),M=i.memoizedState),(P=hn||Wp(i,n,P,t,te,M,Z))?(ue||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount()),typeof E.componentDidMount=="function"&&(i.flags|=4194308)):(typeof E.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=t,i.memoizedState=M),E.props=t,E.state=M,E.context=Z,t=P):(typeof E.componentDidMount=="function"&&(i.flags|=4194308),t=!1)}else{E=i.stateNode,kp(e,i),P=i.memoizedProps,Z=i.type===i.elementType?P:qa(i.type,P),E.props=Z,ue=i.pendingProps,te=E.context,M=n.contextType,typeof M=="object"&&M!==null?M=ha(M):(M=Xi(n)?Bn:Li.current,M=co(i,M));var fe=n.getDerivedStateFromProps;(le=typeof fe=="function"||typeof E.getSnapshotBeforeUpdate=="function")||typeof E.UNSAFE_componentWillReceiveProps!="function"&&typeof E.componentWillReceiveProps!="function"||(P!==ue||te!==M)&&Qp(i,E,t,M),hn=!1,te=i.memoizedState,E
Line truncated
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const uk=a=>a.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),dk=a=>a.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,o,s)=>s?s.toUpperCase():o.toLowerCase()),Gm=a=>{const r=dk(a);return r.charAt(0).toUpperCase()+r.slice(1)},Wg=(...a)=>a.filter((r,o,s)=>!!r&&r.trim()!==""&&s.indexOf(r)===o).join(" ").trim(),pk=a=>{for(const r in a)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/var mk={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const hk=S.forwardRef(({color:a="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:s,className:u="",children:l,iconNode:m,...c},h)=>S.createElement("svg",{ref:h,...mk,width:r,height:r,stroke:a,strokeWidth:s?Number(o)*24/Number(r):o,className:Wg("lucide",u),...!l&&!pk(c)&&{"aria-hidden":"true"},...c},[...m.map(([d,y])=>S.createElement(d,y)),...Array.isArray(l)?l:[l]]));/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const Nu=(a,r)=>{const o=S.forwardRef(({className:s,...u},l)=>S.createElement(hk,{ref:l,iconNode:r,className:Wg(`lucide-${uk(Gm(a))}`,`lucide-${a}`,s),...u}));return o.displayName=Gm(a),o};/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const gk=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],yk=Nu("check",gk);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const bk=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],fk=Nu("menu",bk);/**
|
||||
* @license lucide-react v0.562.0 - ISC
|
||||
*
|
||||
* This source code is licensed under the ISC license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/const vk=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],$g=Nu("x",vk);var Qg=Ug();const Gg=Fo(Qg);function kk(a){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css",r.appendChild(o),o.styleSheet?o.styleSheet.cssText=a:o.appendChild(document.createTextNode(a))}const wk=a=>{switch(a){case"success":return qk;case"info":return Ak;case"warning":return jk;case"error":return Ck;default:return null}},xk=Array(12).fill(0),zk=({visible:a,className:r})=>he.createElement("div",{className:["sonner-loading-wrapper",r].filter(Boolean).join(" "),"data-visible":a},he.createElement("div",{className:"sonner-spinner"},xk.map((o,s)=>he.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),qk=he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},he.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),jk=he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},he.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),Ak=he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},he.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),Ck=he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},he.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),Ek=he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},he.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),he.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),Sk=()=>{const[a,r]=he.useState(document.hidden);return he.useEffect(()=>{const o=()=>{r(document.hidden)};return document.addEventListener("visibilitychange",o),()=>window.removeEventListener("visibilitychange",o)},[]),a};let ku=1;class Bk{constructor(){this.subscribe=r=>(this.subscribers.push(r),()=>{const o=this.subscribers.indexOf(r);this.subscribers.splice(o,1)}),this.publish=r=>{this.subscribers.forEach(o=>o(r))},this.addToast=r=>{this.publish(r),this.toasts=[...this.toasts,r]},this.create=r=>{var o;const{message:s,...u}=r,l=typeof(r==null?void 0:r.id)=="number"||((o=r.id)==null?void 0:o.length)>0?r.id:ku++,m=this.toasts.find(h=>h.id===l),c=r.dismissible===void 0?!0:r.dismissible;return this.dismissedToasts.has(l)&&this.dismissedToasts.delete(l),m?this.toasts=this.toasts.map(h=>h.id===l?(this.publish({...h,...r,id:l,title:s}),{...h,...r,id:l,dismissible:c,title:s}):h):this.addToast({title:s,...u,dismissible:c,id:l}),l},this.dismiss=r=>(r?(this.dismissedToasts.add(r),requestAnimationFrame(()=>this.subscribers.forEach(o=>o({id:r,dismiss:!0})))):this.toasts.forEach(o=>{this.subscribers.forEach(s=>s({id:o.id,dismiss:!0}))}),r),this.message=(r,o)=>this.create({...o,message:r}),this.error=(r,o)=>this.create({...o,message:r,type:"error"}),this.success=(r,o)=>this.create({...o,type:"success",message:r}),this.info=(r,o)=>this.create({...o,type:"info",message:r}),this.warning=(r,o)=>this.create({...o,type:"warning",message:r}),this.loading=(r,o)=>this.create({...o,type:"loading",message:r}),this.promise=(r,o)=>{if(!o)return;let s;o.loading!==void 0&&(s=this.create({...o,promise:r,type:"loading",message:o.loading,description:typeof o.description!="function"?o.description:void 0}));const u=Promise.resolve(r instanceof Function?r():r);let l=s!==void 0,m;const c=u.then(async d=>{if(m=["resolve",d],he.isValidElement(d))l=!1,this.create({id:s,type:"default",message:d});else if(Dk(d)&&!d.ok){l=!1;const g=typeof o.error=="function"?await o.error(`HTTP error! status: ${d.status}`):o.error,f=typeof o.description=="function"?await o.description(`HTTP error! status: ${d.status}`):o.description,k=typeof g=="object"&&!he.isValidElement(g)?g:{message:g};this.create({id:s,type:"error",description:f,...k})}else if(d instanceof Error){l=!1;const g=typeof o.error=="function"?await o.error(d):o.error,Line truncated
|
||||
`).map((q,I,L)=>B.jsxs("span",{children:[nx(q,c),I<L.length-1&&B.jsx("br",{})]},I)),!X&&B.jsx("span",{className:"text-[10px] text-muted-foreground/50 ml-2",children:th(x.sender_timestamp||x.received_at)}),x.outgoing&&(x.acked?" ✓":" ?")]})]})]},x.id)})]}),g&&B.jsx("button",{onClick:j,className:"absolute bottom-4 right-4 w-10 h-10 rounded-full bg-muted hover:bg-accent border border-border flex items-center justify-center shadow-lg transition-opacity",title:"Scroll to bottom",children:B.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-muted-foreground",children:B.jsx("polyline",{points:"6 9 12 15 18 9"})})})]})}const rx=S.forwardRef(function({onSend:r,disabled:o,placeholder:s,isRepeaterMode:u},l){const[m,c]=S.useState(""),[h,d]=S.useState(!1),y=S.useRef(null);S.useImperativeHandle(l,()=>({appendText:k=>{var j;c(v=>v+k),(j=y.current)==null||j.focus()}}));const g=S.useCallback(async k=>{var v;k.preventDefault();const j=m.trim();if(u){if(h||o)return;const A=j==="."?"":j;d(!0);try{await r(A),c("")}catch(C){console.error("Failed to request telemetry:",C)}finally{d(!1)}}else{if(!j||h||o)return;d(!0);try{await r(j),c(""),(v=y.current)==null||v.focus()}catch(A){console.error("Failed to send message:",A)}finally{d(!1)}}},[m,h,o,r,u]),f=S.useCallback(k=>{k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),g(k))},[g]),z=u?m.trim().length>0||m===".":m.trim().length>0;return B.jsxs("form",{className:"px-4 py-3 border-t border-border flex gap-2",onSubmit:g,children:[B.jsx(zi,{ref:y,type:u?"password":"text",value:m,onChange:k=>c(k.target.value),onKeyDown:f,placeholder:s||(u?"Enter password (or . for none)...":"Type a message..."),disabled:o||h,className:"flex-1"}),B.jsx(La,{type:"submit",disabled:o||h||!z,children:h?u?"Fetching...":"Sending...":u?"Fetch":"Send"})]})});function Si(a,r,{checkForDefaultPrevented:o=!0}={}){return function(u){if(a==null||a(u),o===!1||!u.defaultPrevented)return r==null?void 0:r(u)}}function sx(a,r){const o=S.createContext(r),s=l=>{const{children:m,...c}=l,h=S.useMemo(()=>c,Object.values(c));return B.jsx(o.Provider,{value:h,children:m})};s.displayName=a+"Provider";function u(l){const m=S.useContext(o);if(m)return m;if(r!==void 0)return r;throw new Error(`\`${l}\` must be used within \`${a}\``)}return[s,u]}function Lr(a,r=[]){let o=[];function s(l,m){const c=S.createContext(m),h=o.length;o=[...o,m];const d=g=>{var A;const{scope:f,children:z,...k}=g,j=((A=f==null?void 0:f[a])==null?void 0:A[h])||c,v=S.useMemo(()=>k,Object.values(k));return B.jsx(j.Provider,{value:v,children:z})};d.displayName=l+"Provider";function y(g,f){var j;const z=((j=f==null?void 0:f[a])==null?void 0:j[h])||c,k=S.useContext(z);if(k)return k;if(m!==void 0)return m;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[d,y]}const u=()=>{const l=o.map(m=>S.createContext(m));return function(c){const h=(c==null?void 0:c[a])||l;return S.useMemo(()=>({[`__scope${a}`]:{...c,[a]:h}}),[c,h])}};return u.scopeName=a,[s,tx(u,...r)]}function tx(...a){const r=a[0];if(a.length===1)return r;const o=()=>{const s=a.map(u=>({useScope:u(),scopeName:u.scopeName}));return function(l){const m=s.reduce((c,{useScope:h,scopeName:d})=>{const g=h(l)[`__scope${d}`];return{...c,...g}},{});return S.useMemo(()=>({[`__scope${r.scopeName}`]:m}),[m])}};return o.scopeName=r.scopeName,o}var _o=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},lx=Pu[" useId ".trim().toString()]||(()=>{}),cx=0;function Pr(a){const[r,o]=S.useState(lx());return _o(()=>{o(s=>s??String(cx++))},[a]),r?`radix-${r}`:""}var ux=Pu[" useInsertionEffect ".trim().toString()]||_o;function nl({prop:a,defaultProp:r,onChange:o=()=>{},caller:s}){const[u,l,m]=dx({defaultProp:r,onChange:o}),c=a!==void 0,h=c?a:u;{const y=S.useRef(a!==void 0);S.useEffect(()=>{const g=y.current;g!==c&&console.warn(`${s} is changing from ${g?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),y.current=c},[c,s])}const d=S.useCallback(y=>{var g;if(c){const f=px(y)?y(a):y;f!==a&&((g=m.current)==null||g.call(m,f))}else l(y)},[c,a,l,m]);return[h,d]}function dx({defaultProp:a,onChange:r}){const[o,s]=S.useState(a),u=S.useRef(o),l=S.useRef(r);return ux(()=>{l.current=r},[r]),S.useEffect(()=>{var m;u.current!==o&&((m=l.current)==null||m.call(l,o),u.current=o)},[o,u]),[o,s,l]}function px(a){return typeof a=="function"}function mx(a){const r=hx(a),o=S.forwardRef((s,u)=>{const{children:l,...m}=s,c=S.Children.toArray(l),h=c.find(yx);if(h){const d=h.props.children,y=c.map(g=>g===h?S.Children.count(d)>1?S.Children.only(null):S.isValidElement(d)?d.props.children:null:g);return B.jsx(r,{...m,ref:u,children:S.isValidElement(d)?S.cloneElement(d,void 0,y):null})}return B.jsx(r,{...m,ref:u,Line truncated
|
||||
.`.concat(Hx,` {
|
||||
overflow: hidden `).concat(s,`;
|
||||
padding-right: `).concat(c,"px ").concat(s,`;
|
||||
}
|
||||
body[`).concat(Eo,`] {
|
||||
overflow: hidden `).concat(s,`;
|
||||
overscroll-behavior: contain;
|
||||
`).concat([r&&"position: relative ".concat(s,";"),o==="margin"&&`
|
||||
padding-left: `.concat(u,`px;
|
||||
padding-top: `).concat(l,`px;
|
||||
padding-right: `).concat(m,`px;
|
||||
margin-left:0;
|
||||
margin-top:0;
|
||||
margin-right: `).concat(c,"px ").concat(s,`;
|
||||
`),o==="padding"&&"padding-right: ".concat(c,"px ").concat(s,";")].filter(Boolean).join(""),`
|
||||
}
|
||||
|
||||
.`).concat(ot,` {
|
||||
right: `).concat(c,"px ").concat(s,`;
|
||||
}
|
||||
|
||||
.`).concat(rt,` {
|
||||
margin-right: `).concat(c,"px ").concat(s,`;
|
||||
}
|
||||
|
||||
.`).concat(ot," .").concat(ot,` {
|
||||
right: 0 `).concat(s,`;
|
||||
}
|
||||
|
||||
.`).concat(rt," .").concat(rt,` {
|
||||
margin-right: 0 `).concat(s,`;
|
||||
}
|
||||
|
||||
body[`).concat(Eo,`] {
|
||||
`).concat(Vx,": ").concat(c,`px;
|
||||
}
|
||||
`)},yh=function(){var a=parseInt(document.body.getAttribute(Eo)||"0",10);return isFinite(a)?a:0},lz=function(){S.useEffect(function(){return document.body.setAttribute(Eo,(yh()+1).toString()),function(){var a=yh()-1;a<=0?document.body.removeAttribute(Eo):document.body.setAttribute(Eo,a.toString())}},[])},cz=function(a){var r=a.noRelative,o=a.noImportant,s=a.gapMode,u=s===void 0?"margin":s;lz();var l=S.useMemo(function(){return rz(u)},[u]);return S.createElement(sz,{styles:tz(l,!r,u,o?"":"!important")})},Au=!1;if(typeof window<"u")try{var et=Object.defineProperty({},"passive",{get:function(){return Au=!0,!0}});window.addEventListener("test",et,et),window.removeEventListener("test",et,et)}catch{Au=!1}var qo=Au?{passive:!1}:!1,uz=function(a){return a.tagName==="TEXTAREA"},qy=function(a,r){if(!(a instanceof Element))return!1;var o=window.getComputedStyle(a);return o[r]!=="hidden"&&!(o.overflowY===o.overflowX&&!uz(a)&&o[r]==="visible")},dz=function(a){return qy(a,"overflowY")},pz=function(a){return qy(a,"overflowX")},bh=function(a,r){var o=r.ownerDocument,s=r;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var u=jy(a,s);if(u){var l=Ay(a,s),m=l[1],c=l[2];if(m>c)return!0}s=s.parentNode}while(s&&s!==o.body);return!1},mz=function(a){var r=a.scrollTop,o=a.scrollHeight,s=a.clientHeight;return[r,o,s]},hz=function(a){var r=a.scrollLeft,o=a.scrollWidth,s=a.clientWidth;return[r,o,s]},jy=function(a,r){return a==="v"?dz(r):pz(r)},Ay=function(a,r){return a==="v"?mz(r):hz(r)},gz=function(a,r){return a==="h"&&r==="rtl"?-1:1},yz=function(a,r,o,s,u){var l=gz(a,window.getComputedStyle(r).direction),m=l*s,c=o.target,h=r.contains(c),d=!1,y=m>0,g=0,f=0;do{if(!c)break;var z=Ay(a,c),k=z[0],j=z[1],v=z[2],A=j-v-l*k;(k||A)&&jy(a,c)&&(g+=A,f+=k);var C=c.parentNode;c=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}while(!h&&c!==document.body||h&&(r.contains(c)||r===c));return(y&&Math.abs(g)<1||!y&&Math.abs(f)<1)&&(d=!0),d},it=function(a){return"changedTouches"in a?[a.changedTouches[0].clientX,a.changedTouches[0].clientY]:[0,0]},fh=function(a){return[a.deltaX,a.deltaY]},vh=function(a){return a&&"current"in a?a.current:a},bz=function(a,r){return a[0]===r[0]&&a[1]===r[1]},fz=function(a){return`
|
||||
.block-interactivity-`.concat(a,` {pointer-events: none;}
|
||||
.allow-interactivity-`).concat(a,` {pointer-events: all;}
|
||||
`)},vz=0,jo=[];function kz(a){var r=S.useRef([]),o=S.useRef([0,0]),s=S.useRef(),u=S.useState(vz++)[0],l=S.useState(zy)[0],m=S.useRef(a);S.useEffect(function(){m.current=a},[a]),S.useEffect(function(){if(a.inert){document.body.classList.add("block-interactivity-".concat(u));var j=Lx([a.lockRef.current],(a.shards||[]).map(vh),!0).filter(Boolean);return j.forEach(function(v){return v.classList.add("allow-interactivity-".concat(u))}),function(){document.body.classList.remove("block-interactivity-".concat(u)),j.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(u))})}}},[a.inert,a.lockRef.current,a.shards]);var c=S.useCallback(function(j,v){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!m.current.allowPinchZoom;var A=it(j),C=o.current,w="deltaX"in j?j.deltaX:C[0]-A[0],_="deltaY"in j?j.deltaY:C[1]-A[1],x,D=j.target,R=Math.abs(w)>Math.abs(_)?"h":"v";if("touches"in j&&R==="h"&&D.type==="range")return!1;var F=window.getSelection(),O=F&&F.anchorNode,N=O?O===D||O.contains(D):!1;if(N)return!1;var T=bh(R,D);if(!T)return!0;if(T?x=R:(x=R==="v"?"h":"v",T=bh(R,D)),!T)return!1;if(!s.current&&"changedTouches"in j&&(w||_)&&(s.current=x),!x)return!0;var W=s.current||x;return yz(W,v,j,W==="h"?w:_)},[]),h=S.useCallback(function(j){var v=j;if(!(!jo.length||jo[jo.length-1]!==l)){var A="deltaY"in v?fh(v):it(v),C=r.current.filter(function(x){return x.name===v.type&&(x.target===v.target||v.target===x.shadowParent)&&bz(x.delta,A)})[0];if(C&&C.should){v.cancelable&&v.preventDefault();return}if(!C){var w=(m.current.shards||[]).map(vh).filter(Boolean).filter(function(x){return x.contains(v.target)}),_=w.length>0?c(v,w[0]):!m.current.noIsolation;_&&v.cancelable&&v.preventDefault()}}},[]),d=S.useCallback(function(j,v,A,C){var w={name:j,delta:v,target:A,should:C,shadowParent:wz(A)};r.current.push(w),setTimeout(function(){r.current=r.current.filter(function(_){return _!==w})},1)},[]),y=S.useCallback(function(j){o.current=it(j),s.current=void 0},[]),g=S.useCallback(function(j){d(j.type,fh(j),j.target,c(j,a.lockRef.current))},[]),f=S.useCallback(function(j){d(j.type,it(j),j.target,c(j,a.lockRef.current))},[]);S.useEffect(function(){return jo.push(l),a.setCallbacks({onScrollCapture:g,onWheelCapture:g,onTouchMoveCapture:f}),document.addEventListener("wheel",h,qo),document.addEventListener("touchmove",h,qo),document.addEventListener("touchstart",y,qo),function(){jo=jo.filter(function(j){return j!==l}),document.removeEventListener("wheel",h,qo),document.removeEventListener("touchmove",h,qo),document.removeEventListener("touchstart",y,qo)}},[]);var z=a.removeScrollBar,k=a.inert;return S.createElement(S.Fragment,null,k?S.createElement(l,{styles:fz(u)}):null,z?S.createElement(cz,{noRelative:a.noRelative,gapMode:a.gapMode}):null)}function wz(a){for(var r=null;a!==null;)a instanceof ShadowRoot&&(r=a.host,a=a.host),a=a.parentNode;return r}const xz=Yx(xy,kz);var Cy=S.forwardRef(function(a,r){return S.createElement(ol,Oa({},a,{ref:r,sideCar:xz}))});Cy.classNames=ol.classNames;var zz=function(a){if(typeof document>"u")return null;var r=Array.isArray(a)?a[0]:a;return r.ownerDocument.body},Ao=new WeakMap,at=new WeakMap,nt={},mu=0,Ey=function(a){return a&&(a.host||Ey(a.parentNode))},qz=function(a,r){return r.map(function(o){if(a.contains(o))return o;var s=Ey(o);return s&&a.contains(s)?s:(console.error("aria-hidden",o,"in not contained inside",a,". Doing nothing"),null)}).filter(function(o){return!!o})},jz=function(a,r,o,s){var u=qz(r,Array.isArray(a)?a:[a]);nt[o]||(nt[o]=new WeakMap);var l=nt[o],m=[],c=new Set,h=new Set(u),d=function(g){!g||c.has(g)||(c.add(g),d(g.parentNode))};u.forEach(d);var y=function(g){!g||h.has(g)||Array.prototype.forEach.call(g.children,function(f){if(c.has(f))y(f);else try{var z=f.getAttribute(s),k=z!==null&&z!=="false",j=(Ao.get(f)||0)+1,v=(l.get(f)||0)+1;Ao.set(f,j),l.set(f,v),m.push(f),j===1&&k&&at.set(f,!0),v===1&&f.setAttribute(o,"true"),k||f.setAttribute(s,"true")}catch(A){console.error("aria-hidden: cannot operate on ",f,A)}})};return y(r),c.clear(),mu++,function(){m.forEach(function(g){var f=Ao.get(g)-1,z=l.get(g)-1;Ao.set(g,f),l.set(g,z),f||(at.has(g)||g.removeAttribute(s),at.delete(g)),z||g.removeAttribute(o)}),mu--,mu||(Ao=new WeakMap,Ao=new WeakMap,at=new WeakMap,nt={})}},Az=function(a,r,o){o===void 0&&(o="data-aria-hidden");var s=Array.from(Array.isArray(a)?a:[a]),u=zz(a);return u?(s.push.apply(s,Array.from(u.querySelectorAll("[aria-live], script"))),jz(s,u,o,"aria-hidden")):function(){return null}};function Cz(a){const r=Ez(a),o=S.forwardRef((s,u)=>{const{children:l,...m}=s,c=S.Children.toArray(l),h=c.find(Bz);if(h){const d=h.props.children,y=c.map(g=>g===h?S.Children.count(d)>1?S.Children.only(null):S.isValidElement(d)?d.props.children:null:g);return B.jsx(r,{...m,ref:u,children:S.isValidElement(d)?S.cloneElement(d,void 0,y):null})}return B.jsx(r,{...m,ref:u,children:l})});return o.displayName=`${a}.Slot`,o}function Ez(a){const r=S.forwardRef((o,s)=>{const{children:u
Line truncated
|
||||
|
||||
If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.
|
||||
|
||||
For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return S.useEffect(()=>{a&&(document.getElementById(a)||console.error(o))},[o,a]),null},Lz="DialogDescriptionWarning",Hz=({contentRef:a,descriptionId:r})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Vy(Lz).contentName}}.`;return S.useEffect(()=>{var l;const u=(l=a.current)==null?void 0:l.getAttribute("aria-describedby");r&&u&&(document.getElementById(r)||console.warn(s))},[s,a,r]),null},Uy=By,Wy=Fy,sl=Ry,tl=Ty,ll=Ny,cl=My,$y=Ly;const Qy=Uy,Vz=Wy,Gy=S.forwardRef(({className:a,...r},o)=>B.jsx(sl,{ref:o,className:$e("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...r}));Gy.displayName=sl.displayName;const Vu=S.forwardRef(({className:a,children:r,...o},s)=>B.jsxs(Vz,{children:[B.jsx(Gy,{}),B.jsxs(tl,{ref:s,className:$e("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...o,children:[r,B.jsxs($y,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[B.jsx($g,{className:"h-4 w-4"}),B.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Vu.displayName=tl.displayName;const Uu=({className:a,...r})=>B.jsx("div",{className:$e("flex flex-col space-y-1.5 text-center sm:text-left",a),...r});Uu.displayName="DialogHeader";const Wu=({className:a,...r})=>B.jsx("div",{className:$e("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...r});Wu.displayName="DialogFooter";const $u=S.forwardRef(({className:a,...r},o)=>B.jsx(ll,{ref:o,className:$e("text-lg font-semibold leading-none tracking-tight",a),...r}));$u.displayName=ll.displayName;const Uz=S.forwardRef(({className:a,...r},o)=>B.jsx(cl,{ref:o,className:$e("text-sm text-muted-foreground",a),...r}));Uz.displayName=cl.displayName;function kh(a){const r=Wz(a),o=S.forwardRef((s,u)=>{const{children:l,...m}=s,c=S.Children.toArray(l),h=c.find(Qz);if(h){const d=h.props.children,y=c.map(g=>g===h?S.Children.count(d)>1?S.Children.only(null):S.isValidElement(d)?d.props.children:null:g);return B.jsx(r,{...m,ref:u,children:S.isValidElement(d)?S.cloneElement(d,void 0,y):null})}return B.jsx(r,{...m,ref:u,children:l})});return o.displayName=`${a}.Slot`,o}function Wz(a){const r=S.forwardRef((o,s)=>{const{children:u,...l}=o;if(S.isValidElement(u)){const m=Kz(u),c=Gz(l,u.props);return u.type!==S.Fragment&&(c.ref=s?Or(s,m):m),S.cloneElement(u,c)}return S.Children.count(u)>1?S.Children.only(null):null});return r.displayName=`${a}.SlotClone`,r}var $z=Symbol("radix.slottable");function Qz(a){return S.isValidElement(a)&&typeof a.type=="function"&&"__radixId"in a.type&&a.type.__radixId===$z}function Gz(a,r){const o={...r};for(const s in r){const u=a[s],l=r[s];/^on[A-Z]/.test(s)?u&&l?o[s]=(...c)=>{const h=l(...c);return u(...c),h}:u&&(o[s]=u):s==="style"?o[s]={...u,...l}:s==="className"&&(o[s]=[u,l].filter(Boolean).join(" "))}return{...a,...o}}function Kz(a){var s,u;let r=(s=Object.getOwnPropertyDescriptor(a.props,"ref"))==null?void 0:s.get,o=r&&"isReactWarning"in r&&r.isReactWarning;return o?a.ref:(r=(u=Object.getOwnPropertyDescriptor(a,"ref"))==null?void 0:u.get,o=r&&"isReactWarning"in r&&r.isReactWarning,o?a.props.ref:a.props.ref||a.ref)}function Yz(a){const r=a+"CollectionProvider",[o,s]=Lr(r),[u,l]=o(r,{collectionRef:{current:null},itemMap:new Map}),m=j=>{const{scope:v,children:A}=j,C=he.useRef(null),w=he.useRef(new Map).current;return B.jsx(u,{scope:v,itemMap:w,collectionRef:C,children:A})};m.displayName=r;const c=a+"CollectionSlot",h=kh(c),d=he.forwardRef((j,v)=>{const{scope:A,children:C}=j,w=l(c,A),_=fa(v,w.collectionRef);return B.jsx(h,{ref:_,children:C})});d.displayName=c;const y=a+"CollectionItemSlot",g="data-radix-collection-item",f=kh(y),z=he.forwardRef((j,v)=>{const{scope:A,children:C,...w}=j,_=he.useRef(null),x=fa(v,_),D=l(y,A);return he.useEffect(()=>(D.itemMap.set(_,{ref:_,...w}),()=>void D.itemMap.delete(_))),B.jsx(f,{[g]:"",ref:x,children:C})});z.displayName=y;function k(j){const v=l(a+"CollectionConsumer",j);return he.useCallback(()=>{const C=v.collectionRef.current;if(!C)return[];const w=Array.from(C.querySelectorAll(`[${g}]`));return Array.from(v.itemMap.values()).sort((D,R)=>w.indexOf(D.ref.current)-w.indexOf(R.ref.current))},[v.coll
Line truncated
|
||||
(c) 2012 by Cédric Mesnil. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/return(function(s){var u=o,l=u.lib,m=l.WordArray,c=l.Hasher,h=u.algo,d=m.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),y=m.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),g=m.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),f=m.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),z=m.create([0,1518500249,1859775393,2400959708,2840853838]),k=m.create([1352829926,1548603684,1836072691,2053994217,0]),j=h.RIPEMD160=c.extend({_doReset:function(){this._hash=m.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(D,R){for(var F=0;F<16;F++){var O=R+F,N=D[O];D[O]=(N<<8|N>>>24)&16711935|(N<<24|N>>>8)&4278255360}var T=this._hash.words,W=z.words,H=k.words,K=d.words,ae=y.words,X=g.words,ne=f.words,$,oe,ee,q,I,L,Q,de,ge,be;L=$=T[0],Q=oe=T[1],de=ee=T[2],ge=q=T[3],be=I=T[4];for(var se,F=0;F<80;F+=1)se=$+D[R+K[F]]|0,F<16?se+=v(oe,ee,q)+W[0]:F<32?se+=A(oe,ee,q)+W[1]:F<48?se+=C(oe,ee,q)+W[2]:F<64?se+=w(oe,ee,q)+W[3]:se+=_(oe,ee,q)+W[4],se=se|0,se=x(se,X[F]),se=se+I|0,$=I,I=q,q=x(ee,10),ee=oe,oe=se,se=L+D[R+ae[F]]|0,F<16?se+=_(Q,de,ge)+H[0]:F<32?se+=w(Q,de,ge)+H[1]:F<48?se+=C(Q,de,ge)+H[2]:F<64?se+=A(Q,de,ge)+H[3]:se+=v(Q,de,ge)+H[4],se=se|0,se=x(se,ne[F]),se=se+be|0,L=be,be=ge,ge=x(de,10),de=Q,Q=se;se=T[1]+ee+ge|0,T[1]=T[2]+q+be|0,T[2]=T[3]+I+L|0,T[3]=T[4]+$+Q|0,T[4]=T[0]+oe+de|0,T[0]=se},_doFinalize:function(){var D=this._data,R=D.words,F=this._nDataBytes*8,O=D.sigBytes*8;R[O>>>5]|=128<<24-O%32,R[(O+64>>>9<<4)+14]=(F<<8|F>>>24)&16711935|(F<<24|F>>>8)&4278255360,D.sigBytes=(R.length+1)*4,this._process();for(var N=this._hash,T=N.words,W=0;W<5;W++){var H=T[W];T[W]=(H<<8|H>>>24)&16711935|(H<<24|H>>>8)&4278255360}return N},clone:function(){var D=c.clone.call(this);return D._hash=this._hash.clone(),D}});function v(D,R,F){return D^R^F}function A(D,R,F){return D&R|~D&F}function C(D,R,F){return(D|~R)^F}function w(D,R,F){return D&F|R&~F}function _(D,R,F){return D^(R|~F)}function x(D,R){return D<<R|D>>>32-R}u.RIPEMD160=c._createHelper(j),u.HmacRIPEMD160=c._createHmacHelper(j)})(),o.RIPEMD160})})(wt)),wt.exports}var xt={exports:{}},sq=xt.exports,Oh;function ml(){return Oh||(Oh=1,(function(a,r){(function(o,s){a.exports=s(Ie())})(sq,function(o){(function(){var s=o,u=s.lib,l=u.Base,m=s.enc,c=m.Utf8,h=s.algo;h.HMAC=l.extend({init:function(d,y){d=this._hasher=new d.init,typeof y=="string"&&(y=c.parse(y));var g=d.blockSize,f=g*4;y.sigBytes>f&&(y=d.finalize(y)),y.clamp();for(var z=this._oKey=y.clone(),k=this._iKey=y.clone(),j=z.words,v=k.words,A=0;A<g;A++)j[A]^=1549556828,v[A]^=909522486;z.sigBytes=k.sigBytes=f,this.reset()},reset:function(){var d=this._hasher;d.reset(),d.update(this._iKey)},update:function(d){return this._hasher.update(d),this},finalize:function(d){var y=this._hasher,g=y.finalize(d);y.reset();var f=y.finalize(this._oKey.clone().concat(g));return f}})})()})})(xt)),xt.exports}var zt={exports:{}},tq=zt.exports,Lh;function lq(){return Lh||(Lh=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Vr(),ml())})(tq,function(o){return(function(){var s=o,u=s.lib,l=u.Base,m=u.WordArray,c=s.algo,h=c.SHA256,d=c.HMAC,y=c.PBKDF2=l.extend({cfg:l.extend({keySize:128/32,hasher:h,iterations:25e4}),init:function(g){this.cfg=this.cfg.extend(g)},compute:function(g,f){for(var z=this.cfg,k=d.create(z.hasher,g),j=m.create(),v=m.create([1]),A=j.words,C=v.words,w=z.keySize,_=z.iterations;A.length<w;){var x=k.update(f).finalize(v);k.reset();for(var D=x.words,R=D.length,F=x,O=1;O<_;O++){F=k.finalize(F),k.reset();for(var N=F.words,T=0;T<R;T++)D[T]^=N[T]}j.concat(x),C[0]++}return j.sigBytes=w*4,j}});s.PBKDF2=function(g,f,z){return y.create(z).compute(g,f)}})(),o.PBKDF2})})(zt)),zt.exports}var qt={exports:{}},cq=qt.exports,Hh;function Cn(){return Hh||(Hh=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Bb(),ml())})(cq,function(o){return(function(){var s=o,u=s.lib,l=u.Base,m=u.WordArray,c=s.algo,h=c.MD5,d=c.EvpKDF=l.extend({cfg:l.extend({keySize:128/32,hasher:h,iterations:1}),init:function(y){this.cfg=this.cfg.extend(y)},compute:function(y,g){for(var f,z=this.cfg,k=z.hasher.create(),j=m.create(),v=j.words,A=z.keySize,C=z.iterations;v.length<A;){f&&k.update(f),f=k.update(y).finalize(g),k.reset();for(var w=1;w<C;w++)f=k.finalize(f),k.reset();j.concat(f)}return j.sigBytes=A*4,j}});s.EvpKDF=function(y,g,f){return d.create(f).compute(y,g)}})(),o.EvpKDF})})(qt)),qt.exports}var jt={exports:{}},uq=jt.exports,Vh;fuLine truncated
|
||||
* Counter block mode compatible with Dr Brian Gladman fileenc.c
|
||||
* derived from CryptoJS.mode.CTR
|
||||
* Jan Hruby jhruby.web@gmail.com
|
||||
*/return o.mode.CTRGladman=(function(){var s=o.lib.BlockCipherMode.extend();function u(c){if((c>>24&255)===255){var h=c>>16&255,d=c>>8&255,y=c&255;h===255?(h=0,d===255?(d=0,y===255?y=0:++y):++d):++h,c=0,c+=h<<16,c+=d<<8,c+=y}else c+=1<<24;return c}function l(c){return(c[0]=u(c[0]))===0&&(c[1]=u(c[1])),c}var m=s.Encryptor=s.extend({processBlock:function(c,h){var d=this._cipher,y=d.blockSize,g=this._iv,f=this._counter;g&&(f=this._counter=g.slice(0),this._iv=void 0),l(f);var z=f.slice(0);d.encryptBlock(z,0);for(var k=0;k<y;k++)c[h+k]^=z[k]}});return s.Decryptor=m,s})(),o.mode.CTRGladman})})(Et)),Et.exports}var St={exports:{}},bq=St.exports,Qh;function fq(){return Qh||(Qh=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Ri())})(bq,function(o){return o.mode.OFB=(function(){var s=o.lib.BlockCipherMode.extend(),u=s.Encryptor=s.extend({processBlock:function(l,m){var c=this._cipher,h=c.blockSize,d=this._iv,y=this._keystream;d&&(y=this._keystream=d.slice(0),this._iv=void 0),c.encryptBlock(y,0);for(var g=0;g<h;g++)l[m+g]^=y[g]}});return s.Decryptor=u,s})(),o.mode.OFB})})(St)),St.exports}var Bt={exports:{}},vq=Bt.exports,Gh;function kq(){return Gh||(Gh=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Ri())})(vq,function(o){return o.mode.ECB=(function(){var s=o.lib.BlockCipherMode.extend();return s.Encryptor=s.extend({processBlock:function(u,l){this._cipher.encryptBlock(u,l)}}),s.Decryptor=s.extend({processBlock:function(u,l){this._cipher.decryptBlock(u,l)}}),s})(),o.mode.ECB})})(Bt)),Bt.exports}var _t={exports:{}},wq=_t.exports,Kh;function xq(){return Kh||(Kh=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Ri())})(wq,function(o){return o.pad.AnsiX923={pad:function(s,u){var l=s.sigBytes,m=u*4,c=m-l%m,h=l+c-1;s.clamp(),s.words[h>>>2]|=c<<24-h%4*8,s.sigBytes+=c},unpad:function(s){var u=s.words[s.sigBytes-1>>>2]&255;s.sigBytes-=u}},o.pad.Ansix923})})(_t)),_t.exports}var Dt={exports:{}},zq=Dt.exports,Yh;function qq(){return Yh||(Yh=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Ri())})(zq,function(o){return o.pad.Iso10126={pad:function(s,u){var l=u*4,m=l-s.sigBytes%l;s.concat(o.lib.WordArray.random(m-1)).concat(o.lib.WordArray.create([m<<24],1))},unpad:function(s){var u=s.words[s.sigBytes-1>>>2]&255;s.sigBytes-=u}},o.pad.Iso10126})})(Dt)),Dt.exports}var Ft={exports:{}},jq=Ft.exports,Zh;function Aq(){return Zh||(Zh=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Ri())})(jq,function(o){return o.pad.Iso97971={pad:function(s,u){s.concat(o.lib.WordArray.create([2147483648],1)),o.pad.ZeroPadding.pad(s,u)},unpad:function(s){o.pad.ZeroPadding.unpad(s),s.sigBytes--}},o.pad.Iso97971})})(Ft)),Ft.exports}var Rt={exports:{}},Cq=Rt.exports,Xh;function Eq(){return Xh||(Xh=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Ri())})(Cq,function(o){return o.pad.ZeroPadding={pad:function(s,u){var l=u*4;s.clamp(),s.sigBytes+=l-(s.sigBytes%l||l)},unpad:function(s){for(var u=s.words,l=s.sigBytes-1,l=s.sigBytes-1;l>=0;l--)if(u[l>>>2]>>>24-l%4*8&255){s.sigBytes=l+1;break}}},o.pad.ZeroPadding})})(Rt)),Rt.exports}var Tt={exports:{}},Sq=Tt.exports,Jh;function Bq(){return Jh||(Jh=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Ri())})(Sq,function(o){return o.pad.NoPadding={pad:function(){},unpad:function(){}},o.pad.NoPadding})})(Tt)),Tt.exports}var Pt={exports:{}},_q=Pt.exports,eg;function Dq(){return eg||(eg=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Ri())})(_q,function(o){return(function(s){var u=o,l=u.lib,m=l.CipherParams,c=u.enc,h=c.Hex,d=u.format;d.Hex={stringify:function(y){return y.ciphertext.toString(h)},parse:function(y){var g=h.parse(y);return m.create({ciphertext:g})}}})(),o.format.Hex})})(Pt)),Pt.exports}var Nt={exports:{}},Fq=Nt.exports,ig;function Rq(){return ig||(ig=1,(function(a,r){(function(o,s,u){a.exports=s(Ie(),Xn(),Jn(),Cn(),Ri())})(Fq,function(o){return(function(){var s=o,u=s.lib,l=u.BlockCipher,m=s.algo,c=[],h=[],d=[],y=[],g=[],f=[],z=[],k=[],j=[],v=[];(function(){for(var w=[],_=0;_<256;_++)_<128?w[_]=_<<1:w[_]=_<<1^283;for(var x=0,D=0,_=0;_<256;_++){var R=D^D<<1^D<<2^D<<3^D<<4;R=R>>>8^R&255^99,c[x]=R,h[R]=x;var F=w[x],O=w[F],N=w[O],T=w[R]*257^R*16843008;d[x]=T<<24|T>>>8,y[x]=T<<16|T>>>16,g[x]=T<<8|T>>>24,f[x]=T;var T=N*16843009^O*65537^F*257^x*16843008;z[R]=T<<24|T>>>8,k[R]=T<<16|T>>>16,j[R]=T<<8|T>>>24,v[R]=T,x?(x=F^w[w[w[N^F]]],D^=w[w[D]]):x=D=1}})();var A=[0,1,2,4,8,16,32,64,128,27,54],C=m.AES=l.extend({_doReset:function(){var w;if(!(this._nRounds&&this._keyPriorReset===this._key)){for(var _=this._keyPriorReset=this._key,x=_.words,D=_.sigBytes/4,R=this._nRounds=D+6,F=(R+1)*4,O=this._keySchedule=[],N=0;N<F;N++)N<D?O[N]=x[N]:(w=O[N-1],N%D?D>6&&N%D==4&&(w=c[w>>>24]<<24|c[w>>>16&255]<<16|c[w>>>8&255]<<8|c[w&255]):(w=w<<8|w>>>24,w=c[w>>>24]<<24|c[w>>>16&255]<<16|c[w>>>8&255]<<8|c[w&255],w^=A[N/D|0]<<24),O[N]=O[N-D]^w);for(var T=this._invKeySchedule=[],W=0;W<F;W++){var N=F-W;if(W%4)var w=O[N];else var w=O[N-4];W<4||N<=4?T[W]=w:T[W]=z[c[w>>>24]]^k[c[w>>>16&255]]^j[c[w>>>8&255]]^v[c[w&255]]}}},encryptBlock:Line truncated
|
||||
• Timestamp (4 bytes) - send time as unix timestamp
|
||||
• Request Type (1 byte) - type of request (GetStats, GetTelemetryData, etc.)
|
||||
• Request Data (remaining bytes) - additional request-specific data`,startByte:c+h,endByte:c+u.length-1,value:f});const z={type:a.PayloadType.Request,version:a.PayloadVersion.Version1,isValid:!0,timestamp:0,requestType:a.RequestType.GetStats,requestData:"",destinationHash:d,sourceHash:y,cipherMac:g,ciphertext:f};return l!=null&&l.includeSegments&&(z.segments=m),z}catch(m){return{type:a.PayloadType.Request,version:a.PayloadVersion.Version1,isValid:!1,errors:[m instanceof Error?m.message:"Failed to decode request payload"],timestamp:0,requestType:a.RequestType.GetStats,requestData:"",destinationHash:"",sourceHash:"",cipherMac:"",ciphertext:""}}}}return jr.RequestPayloadDecoder=o,jr}var Ar={},qg;function yj(){if(qg)return Ar;qg=1,Object.defineProperty(Ar,"__esModule",{value:!0}),Ar.ResponsePayloadDecoder=void 0;const a=ua(),r=Ii();class o{static decode(u,l){try{if(u.length<4){const k={type:a.PayloadType.Response,version:a.PayloadVersion.Version1,isValid:!1,errors:["Response payload too short (minimum 4 bytes: dest + source + MAC)"],destinationHash:"",sourceHash:"",cipherMac:"",ciphertext:"",ciphertextLength:0};return l!=null&&l.includeSegments&&(k.segments=[{name:"Invalid Response Data",description:"Response payload too short (minimum 4 bytes required)",startByte:l.segmentOffset||0,endByte:(l.segmentOffset||0)+u.length-1,value:(0,r.bytesToHex)(u)}]),k}const m=[],c=(l==null?void 0:l.segmentOffset)||0;let h=0;const d=(0,r.byteToHex)(u[h]);l!=null&&l.includeSegments&&m.push({name:"Destination Hash",description:"First byte of destination node public key",startByte:c+h,endByte:c+h,value:d}),h+=1;const y=(0,r.byteToHex)(u[h]);l!=null&&l.includeSegments&&m.push({name:"Source Hash",description:"First byte of source node public key",startByte:c+h,endByte:c+h,value:y}),h+=1;const g=(0,r.bytesToHex)(u.subarray(h,h+2));l!=null&&l.includeSegments&&m.push({name:"Cipher MAC",description:"MAC for encrypted data in next field",startByte:c+h,endByte:c+h+1,value:g}),h+=2;const f=(0,r.bytesToHex)(u.subarray(h));l!=null&&l.includeSegments&&u.length>h&&m.push({name:"Ciphertext",description:"Encrypted response data (tag + content)",startByte:c+h,endByte:c+u.length-1,value:f});const z={type:a.PayloadType.Response,version:a.PayloadVersion.Version1,isValid:!0,destinationHash:d,sourceHash:y,cipherMac:g,ciphertext:f,ciphertextLength:u.length-4};return l!=null&&l.includeSegments&&(z.segments=m),z}catch(m){return{type:a.PayloadType.Response,version:a.PayloadVersion.Version1,isValid:!1,errors:[m instanceof Error?m.message:"Failed to decode response payload"],destinationHash:"",sourceHash:"",cipherMac:"",ciphertext:"",ciphertextLength:0}}}}return Ar.ResponsePayloadDecoder=o,Ar}var Cr={},jg;function bj(){if(jg)return Cr;jg=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.AnonRequestPayloadDecoder=void 0;const a=ua(),r=Ii();class o{static decode(u,l){try{if(u.length<35){const k={type:a.PayloadType.AnonRequest,version:a.PayloadVersion.Version1,isValid:!1,errors:["AnonRequest payload too short (minimum 35 bytes: dest + public key + MAC)"],destinationHash:"",senderPublicKey:"",cipherMac:"",ciphertext:"",ciphertextLength:0};return l!=null&&l.includeSegments&&(k.segments=[{name:"Invalid AnonRequest Data",description:"AnonRequest payload too short (minimum 35 bytes required: 1 for dest hash + 32 for public key + 2 for MAC)",startByte:l.segmentOffset||0,endByte:(l.segmentOffset||0)+u.length-1,value:(0,r.bytesToHex)(u)}]),k}const m=[],c=(l==null?void 0:l.segmentOffset)||0;let h=0;const d=(0,r.byteToHex)(u[0]);l!=null&&l.includeSegments&&m.push({name:"Destination Hash",description:`First byte of destination node public key: 0x${d}`,startByte:c+h,endByte:c+h,value:d}),h+=1;const y=(0,r.bytesToHex)(u.subarray(1,33));l!=null&&l.includeSegments&&m.push({name:"Sender Public Key",description:"Ed25519 public key of the sender (32 bytes)",startByte:c+h,endByte:c+h+31,value:y}),h+=32;const g=(0,r.bytesToHex)(u.subarray(33,35));l!=null&&l.includeSegments&&m.push({name:"Cipher MAC",description:"MAC for encrypted data verification (2 bytes)",startByte:c+h,endByte:c+h+1,value:g}),h+=2;const f=(0,r.bytesToHex)(u.subarray(35));l!=null&&l.includeSegments&&u.length>35&&m.push({name:"Ciphertext",description:`Encrypted message data (${u.length-35} bytes). Contains encrypted plaintext with this structure:
|
||||
• Timestamp (4 bytes) - send time as unix timestamp
|
||||
• Sync Timestamp (4 bytes) - room server only, sender's "sync messages SINCE x" timestamp
|
||||
• Password (remaining bytes) - password for repeater/room`,startByte:c+h,endByte:c+u.length-1,value:f});const z={type:a.PayloadType.AnonRequest,version:a.PayloadVersion.Version1,isValid:!0,destinationHash:d,senderPublicKey:y,cipherMac:g,ciphertext:f,ciphertextLength:u.length-35};return l!=null&&l.includeSegments&&(z.segments=m),z}catch(m){return{type:a.PayloadType.AnonRequest,version:a.PayloadVersion.Version1,isValid:!1,errors:[m instanceof Error?m.message:"Failed to decode AnonRequest payload"],destinationHash:"",senderPublicKey:"",cipherMac:"",ciphertext:"",ciphertextLength:0}}}}return Cr.AnonRequestPayloadDecoder=o,Cr}var Er={},Ag;function fj(){if(Ag)return Er;Ag=1,Object.defineProperty(Er,"__esModule",{value:!0}),Er.AckPayloadDecoder=void 0;const a=ua(),r=Ii();class o{static decode(u,l){try{if(u.length<4){const y={type:a.PayloadType.Ack,version:a.PayloadVersion.Version1,isValid:!1,errors:["Ack payload too short (minimum 4 bytes for checksum)"],checksum:""};return l!=null&&l.includeSegments&&(y.segments=[{name:"Invalid Ack Data",description:"Ack payload too short (minimum 4 bytes required for checksum)",startByte:l.segmentOffset||0,endByte:(l.segmentOffset||0)+u.length-1,value:(0,r.bytesToHex)(u)}]),y}const m=[],c=(l==null?void 0:l.segmentOffset)||0,h=(0,r.bytesToHex)(u.subarray(0,4));l!=null&&l.includeSegments&&m.push({name:"Checksum",description:`CRC checksum of message timestamp, text, and sender pubkey: 0x${h}`,startByte:c,endByte:c+3,value:h}),l!=null&&l.includeSegments&&u.length>4&&m.push({name:"Additional Data",description:"Extra data in Ack payload",startByte:c+4,endByte:c+u.length-1,value:(0,r.bytesToHex)(u.subarray(4))});const d={type:a.PayloadType.Ack,version:a.PayloadVersion.Version1,isValid:!0,checksum:h};return l!=null&&l.includeSegments&&(d.segments=m),d}catch(m){return{type:a.PayloadType.Ack,version:a.PayloadVersion.Version1,isValid:!1,errors:[m instanceof Error?m.message:"Failed to decode Ack payload"],checksum:""}}}}return Er.AckPayloadDecoder=o,Er}var Sr={},Cg;function vj(){if(Cg)return Sr;Cg=1,Object.defineProperty(Sr,"__esModule",{value:!0}),Sr.PathPayloadDecoder=void 0;const a=ua(),r=Ii();class o{static decode(u){try{if(u.length<2)return{type:a.PayloadType.Path,version:a.PayloadVersion.Version1,isValid:!1,errors:["Path payload too short (minimum 2 bytes: path length + extra type)"],pathLength:0,pathHashes:[],extraType:0,extraData:""};const l=u[0];if(u.length<1+l+1)return{type:a.PayloadType.Path,version:a.PayloadVersion.Version1,isValid:!1,errors:[`Path payload too short (need ${1+l+1} bytes for path length + path + extra type)`],pathLength:l,pathHashes:[],extraType:0,extraData:""};const m=[];for(let d=0;d<l;d++)m.push((0,r.byteToHex)(u[1+d]));const c=u[1+l];let h="";return u.length>1+l+1&&(h=(0,r.bytesToHex)(u.subarray(1+l+1))),{type:a.PayloadType.Path,version:a.PayloadVersion.Version1,isValid:!0,pathLength:l,pathHashes:m,extraType:c,extraData:h}}catch(l){return{type:a.PayloadType.Path,version:a.PayloadVersion.Version1,isValid:!1,errors:[l instanceof Error?l.message:"Failed to decode Path payload"],pathLength:0,pathHashes:[],extraType:0,extraData:""}}}}return Sr.PathPayloadDecoder=o,Sr}var Br={},Eg;function kj(){if(Eg)return Br;Eg=1,Object.defineProperty(Br,"__esModule",{value:!0}),Br.TextMessagePayloadDecoder=void 0;const a=ua(),r=Ii();class o{static decode(u,l){try{if(u.length<4){const k={type:a.PayloadType.TextMessage,version:a.PayloadVersion.Version1,isValid:!1,errors:["TextMessage payload too short (minimum 4 bytes: dest + source + MAC)"],destinationHash:"",sourceHash:"",cipherMac:"",ciphertext:"",ciphertextLength:0};return l!=null&&l.includeSegments&&(k.segments=[{name:"Invalid TextMessage Data",description:"TextMessage payload too short (minimum 4 bytes required)",startByte:l.segmentOffset||0,endByte:(l.segmentOffset||0)+u.length-1,value:(0,r.bytesToHex)(u)}]),k}const m=[],c=(l==null?void 0:l.segmentOffset)||0;let h=0;const d=(0,r.byteToHex)(u[h]);l!=null&&l.includeSegments&&m.push({name:"Destination Hash",description:"First byte of destination node public key",startByte:c+h,endByte:c+h,value:d}),h+=1;const y=(0,r.byteToHex)(u[h]);l!=null&&l.includeSegments&&m.push({name:"Source Hash",description:"First byte of source node public key",startByte:c+h,endByte:c+h,value:y}),h+=1;const g=(0,r.bytesToHex)(u.subarray(h,h+2));l!=null&&l.includeSegments&&m.push({name:"Cipher MAC",description:"MAC for encrypted data in next field",startByte:c+h,endByte:c+h+1,value:g}),h+=2;const f=(0,r.bytesToHex)(u.subarray(h));l!=null&&l.includeSegments&&u.length>h&&m.push({name:"Ciphertext",description:"Encrypted message data (timestamp + message text)",startByte:c+h,endByte:c+u.length-1,value:f});const z={type:a.PayloadType.TextMessage,version:a.PayloadVersion.Version1,isValid:!0,destinationHash:d,sourceHash:y,cipherMac:g,ciphertext:f,ciphertextLength:u.length-4};return l!=null&&l.includeSegments&&(z.segments=m),z}catch(m){return{type:a.PayloadType.TextMessage,version:a.PayloadVersion.Version1,i
Line truncated
|
||||
// SHA256 round constants
|
||||
const K: array<u32, 64> = array<u32, 64>(
|
||||
0x428a2f98u, 0x71374491u, 0xb5c0fbcfu, 0xe9b5dba5u, 0x3956c25bu, 0x59f111f1u, 0x923f82a4u, 0xab1c5ed5u,
|
||||
0xd807aa98u, 0x12835b01u, 0x243185beu, 0x550c7dc3u, 0x72be5d74u, 0x80deb1feu, 0x9bdc06a7u, 0xc19bf174u,
|
||||
0xe49b69c1u, 0xefbe4786u, 0x0fc19dc6u, 0x240ca1ccu, 0x2de92c6fu, 0x4a7484aau, 0x5cb0a9dcu, 0x76f988dau,
|
||||
0x983e5152u, 0xa831c66du, 0xb00327c8u, 0xbf597fc7u, 0xc6e00bf3u, 0xd5a79147u, 0x06ca6351u, 0x14292967u,
|
||||
0x27b70a85u, 0x2e1b2138u, 0x4d2c6dfcu, 0x53380d13u, 0x650a7354u, 0x766a0abbu, 0x81c2c92eu, 0x92722c85u,
|
||||
0xa2bfe8a1u, 0xa81a664bu, 0xc24b8b70u, 0xc76c51a3u, 0xd192e819u, 0xd6990624u, 0xf40e3585u, 0x106aa070u,
|
||||
0x19a4c116u, 0x1e376c08u, 0x2748774cu, 0x34b0bcb5u, 0x391c0cb3u, 0x4ed8aa4au, 0x5b9cca4fu, 0x682e6ff3u,
|
||||
0x748f82eeu, 0x78a5636fu, 0x84c87814u, 0x8cc70208u, 0x90befffau, 0xa4506cebu, 0xbef9a3f7u, 0xc67178f2u
|
||||
);
|
||||
|
||||
// Character lookup table (a-z = 0-25, 0-9 = 26-35, dash = 36)
|
||||
const CHARS: array<u32, 37> = array<u32, 37>(
|
||||
0x61u, 0x62u, 0x63u, 0x64u, 0x65u, 0x66u, 0x67u, 0x68u, 0x69u, 0x6au, // a-j
|
||||
0x6bu, 0x6cu, 0x6du, 0x6eu, 0x6fu, 0x70u, 0x71u, 0x72u, 0x73u, 0x74u, // k-t
|
||||
0x75u, 0x76u, 0x77u, 0x78u, 0x79u, 0x7au, // u-z
|
||||
0x30u, 0x31u, 0x32u, 0x33u, 0x34u, 0x35u, 0x36u, 0x37u, 0x38u, 0x39u, // 0-9
|
||||
0x2du // dash
|
||||
);
|
||||
|
||||
struct Params {
|
||||
target_channel_hash: u32,
|
||||
batch_offset: u32,
|
||||
name_length: u32,
|
||||
batch_size: u32,
|
||||
target_mac: u32, // First 2 bytes of target MAC (in high 16 bits)
|
||||
ciphertext_words: u32, // Number of 32-bit words in ciphertext
|
||||
ciphertext_len_bits: u32, // Length of ciphertext in bits
|
||||
verify_mac: u32, // 1 to verify MAC, 0 to skip
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<uniform> params: Params;
|
||||
@group(0) @binding(1) var<storage, read_write> match_count: atomic<u32>;
|
||||
@group(0) @binding(2) var<storage, read_write> match_indices: array<u32>;
|
||||
@group(0) @binding(3) var<storage, read> ciphertext: array<u32>; // Ciphertext data
|
||||
|
||||
fn rotr(x: u32, n: u32) -> u32 {
|
||||
return (x >> n) | (x << (32u - n));
|
||||
}
|
||||
|
||||
fn ch(x: u32, y: u32, z: u32) -> u32 {
|
||||
return (x & y) ^ (~x & z);
|
||||
}
|
||||
|
||||
fn maj(x: u32, y: u32, z: u32) -> u32 {
|
||||
return (x & y) ^ (x & z) ^ (y & z);
|
||||
}
|
||||
|
||||
fn sigma0(x: u32) -> u32 {
|
||||
return rotr(x, 2u) ^ rotr(x, 13u) ^ rotr(x, 22u);
|
||||
}
|
||||
|
||||
fn sigma1(x: u32) -> u32 {
|
||||
return rotr(x, 6u) ^ rotr(x, 11u) ^ rotr(x, 25u);
|
||||
}
|
||||
|
||||
fn gamma0(x: u32) -> u32 {
|
||||
return rotr(x, 7u) ^ rotr(x, 18u) ^ (x >> 3u);
|
||||
}
|
||||
|
||||
fn gamma1(x: u32) -> u32 {
|
||||
return rotr(x, 17u) ^ rotr(x, 19u) ^ (x >> 10u);
|
||||
}
|
||||
|
||||
// Convert index to room name bytes, returns the hash as a u32 for the first byte check
|
||||
fn index_to_room_name(idx: u32, length: u32, msg: ptr<function, array<u32, 16>>) -> bool {
|
||||
// Message starts with '#' (0x23)
|
||||
var byte_pos = 0u;
|
||||
var word_idx = 0u;
|
||||
var current_word = 0x23000000u; // '#' in big-endian position 0
|
||||
byte_pos = 1u;
|
||||
|
||||
var remaining = idx;
|
||||
var prev_was_dash = false;
|
||||
|
||||
// Generate room name from index
|
||||
for (var i = 0u; i < length; i++) {
|
||||
let char_count = select(37u, 36u, i == 0u || i == length - 1u); // no dash at start/end
|
||||
var char_idx = remaining % char_count;
|
||||
remaining = remaining / char_count;
|
||||
|
||||
// Check for consecutive dashes (invalid)
|
||||
let is_dash = char_idx == 36u && i > 0u && i < length - 1u;
|
||||
if (is_dash && prev_was_dash) {
|
||||
return false; // Invalid: consecutive dashes
|
||||
}
|
||||
prev_was_dash = is_dash;
|
||||
|
||||
// Map char index to actual character
|
||||
let c = CHARS[char_idx];
|
||||
|
||||
// Pack byte into current word (big-endian)
|
||||
let shift = (3u - byte_pos % 4u) * 8u;
|
||||
if (byte_pos % 4u == 0u && byte_pos > 0u) {
|
||||
(*msg)[word_idx] = current_word;
|
||||
word_idx = word_idx + 1u;
|
||||
current_word = 0u;
|
||||
}
|
||||
current_word = current_word | (c << shift);
|
||||
byte_pos = byte_pos + 1u;
|
||||
}
|
||||
|
||||
// Add padding: 0x80 followed by zeros, then length in bits
|
||||
let msg_len_bits = (length + 1u) * 8u; // +1 for '#'
|
||||
|
||||
// Add 0x80 padding byte
|
||||
let shift = (3u - byte_pos % 4u) * 8u;
|
||||
if (byte_pos % 4u == 0u) {
|
||||
(*msg)[word_idx] = current_word;
|
||||
word_idx = word_idx + 1u;
|
||||
current_word = 0x80000000u;
|
||||
} else {
|
||||
current_word = current_word | (0x80u << shift);
|
||||
}
|
||||
byte_pos = byte_pos + 1u;
|
||||
|
||||
// Store current word
|
||||
if (byte_pos % 4u == 0u || word_idx < 14u) {
|
||||
(*msg)[word_idx] = current_word;
|
||||
word_idx = word_idx + 1u;
|
||||
}
|
||||
|
||||
// Zero-fill until word 14
|
||||
for (var i = word_idx; i < 14u; i++) {
|
||||
(*msg)[i] = 0u;
|
||||
}
|
||||
|
||||
// Length in bits (64-bit, but we only use lower 32 bits for short messages)
|
||||
(*msg)[14u] = 0u;
|
||||
(*msg)[15u] = msg_len_bits;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
fn sha256_block(msg: ptr<function, array<u32, 16>>) -> array<u32, 8> {
|
||||
// Initialize hash values
|
||||
var h: array<u32, 8> = array<u32, 8>(
|
||||
0x6a09e667u, 0xbb67ae85u, 0x3c6ef372u, 0xa54ff53au,
|
||||
0x510e527fu, 0x9b05688cu, 0x1f83d9abu, 0x5be0cd19u
|
||||
);
|
||||
|
||||
// Message schedule
|
||||
var w: array<u32, 64>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
w[i] = (*msg)[i];
|
||||
}
|
||||
for (var i = 16u; i < 64u; i++) {
|
||||
w[i] = gamma1(w[i-2u]) + w[i-7u] + gamma0(w[i-15u]) + w[i-16u];
|
||||
}
|
||||
|
||||
// Compression
|
||||
var a = h[0]; var b = h[1]; var c = h[2]; var d = h[3];
|
||||
var e = h[4]; var f = h[5]; var g = h[6]; var hh = h[7];
|
||||
|
||||
for (var i = 0u; i < 64u; i++) {
|
||||
let t1 = hh + sigma1(e) + ch(e, f, g) + K[i] + w[i];
|
||||
let t2 = sigma0(a) + maj(a, b, c);
|
||||
hh = g; g = f; f = e; e = d + t1;
|
||||
d = c; c = b; b = a; a = t1 + t2;
|
||||
}
|
||||
|
||||
h[0] = h[0] + a; h[1] = h[1] + b; h[2] = h[2] + c; h[3] = h[3] + d;
|
||||
h[4] = h[4] + e; h[5] = h[5] + f; h[6] = h[6] + g; h[7] = h[7] + hh;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
// Compute SHA256 of the key (16 bytes) to get channel hash
|
||||
fn sha256_key(key: array<u32, 4>) -> u32 {
|
||||
var msg: array<u32, 16>;
|
||||
|
||||
// Key bytes (16 bytes = 4 words)
|
||||
msg[0] = key[0];
|
||||
msg[1] = key[1];
|
||||
msg[2] = key[2];
|
||||
msg[3] = key[3];
|
||||
|
||||
// Padding: 0x80 followed by zeros
|
||||
msg[4] = 0x80000000u;
|
||||
for (var i = 5u; i < 14u; i++) {
|
||||
msg[i] = 0u;
|
||||
}
|
||||
|
||||
// Length: 128 bits
|
||||
msg[14] = 0u;
|
||||
msg[15] = 128u;
|
||||
|
||||
let hash = sha256_block(&msg);
|
||||
|
||||
// Return first byte of hash (big-endian)
|
||||
return hash[0] >> 24u;
|
||||
}
|
||||
|
||||
// HMAC-SHA256 for MAC verification
|
||||
// Key is 16 bytes (4 words), padded to 32 bytes with zeros for MeshCore
|
||||
// Returns first 2 bytes of HMAC (as u32 in high 16 bits)
|
||||
fn hmac_sha256_mac(key: array<u32, 4>, ciphertext_len: u32) -> u32 {
|
||||
// HMAC: H((K' ^ opad) || H((K' ^ ipad) || message))
|
||||
// K' is 64 bytes (32 bytes key + 32 bytes zero padding for MeshCore, then padded to 64)
|
||||
// ipad = 0x36 repeated, opad = 0x5c repeated
|
||||
|
||||
// Build padded key (64 bytes = 16 words)
|
||||
// MeshCore uses 32-byte secret: 16-byte key + 16 zero bytes
|
||||
var k_pad: array<u32, 16>;
|
||||
k_pad[0] = key[0];
|
||||
k_pad[1] = key[1];
|
||||
k_pad[2] = key[2];
|
||||
k_pad[3] = key[3];
|
||||
for (var i = 4u; i < 16u; i++) {
|
||||
k_pad[i] = 0u;
|
||||
}
|
||||
|
||||
// Inner hash: SHA256((K' ^ ipad) || message)
|
||||
// First block: K' ^ ipad (64 bytes)
|
||||
var inner_block: array<u32, 16>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
inner_block[i] = k_pad[i] ^ 0x36363636u;
|
||||
}
|
||||
|
||||
// Initialize hash state with first block
|
||||
var h: array<u32, 8> = sha256_block(&inner_block);
|
||||
|
||||
// Process ciphertext blocks (continuing from h state)
|
||||
let ciphertext_words = params.ciphertext_words;
|
||||
var word_idx = 0u;
|
||||
|
||||
// Process full 64-byte blocks of ciphertext
|
||||
while (word_idx + 16u <= ciphertext_words) {
|
||||
var block: array<u32, 16>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
block[i] = ciphertext[word_idx + i];
|
||||
}
|
||||
h = sha256_block_continue(&block, h);
|
||||
word_idx = word_idx + 16u;
|
||||
}
|
||||
|
||||
// Final block with remaining ciphertext + padding
|
||||
var final_block: array<u32, 16>;
|
||||
var remaining = ciphertext_words - word_idx;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
if (i < remaining) {
|
||||
final_block[i] = ciphertext[word_idx + i];
|
||||
} else if (i == remaining) {
|
||||
// Add 0x80 padding
|
||||
final_block[i] = 0x80000000u;
|
||||
} else {
|
||||
final_block[i] = 0u;
|
||||
}
|
||||
}
|
||||
|
||||
// Add length (64 bytes of ipad + ciphertext length)
|
||||
let total_bits = 512u + params.ciphertext_len_bits;
|
||||
if (remaining < 14u) {
|
||||
final_block[14] = 0u;
|
||||
final_block[15] = total_bits;
|
||||
h = sha256_block_continue(&final_block, h);
|
||||
} else {
|
||||
// Need extra block for length
|
||||
h = sha256_block_continue(&final_block, h);
|
||||
var len_block: array<u32, 16>;
|
||||
for (var i = 0u; i < 14u; i++) {
|
||||
len_block[i] = 0u;
|
||||
}
|
||||
len_block[14] = 0u;
|
||||
len_block[15] = total_bits;
|
||||
h = sha256_block_continue(&len_block, h);
|
||||
}
|
||||
|
||||
let inner_hash = h;
|
||||
|
||||
// Outer hash: SHA256((K' ^ opad) || inner_hash)
|
||||
var outer_block: array<u32, 16>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
outer_block[i] = k_pad[i] ^ 0x5c5c5c5cu;
|
||||
}
|
||||
h = sha256_block(&outer_block);
|
||||
|
||||
// Second block: inner_hash (32 bytes) + padding
|
||||
var hash_block: array<u32, 16>;
|
||||
for (var i = 0u; i < 8u; i++) {
|
||||
hash_block[i] = inner_hash[i];
|
||||
}
|
||||
hash_block[8] = 0x80000000u;
|
||||
for (var i = 9u; i < 14u; i++) {
|
||||
hash_block[i] = 0u;
|
||||
}
|
||||
hash_block[14] = 0u;
|
||||
hash_block[15] = 512u + 256u; // 64 bytes opad + 32 bytes inner hash
|
||||
|
||||
h = sha256_block_continue(&hash_block, h);
|
||||
|
||||
// Return first 2 bytes (high 16 bits of first word)
|
||||
return h[0] & 0xFFFF0000u;
|
||||
}
|
||||
|
||||
// SHA256 block computation continuing from existing state
|
||||
fn sha256_block_continue(msg: ptr<function, array<u32, 16>>, h_in: array<u32, 8>) -> array<u32, 8> {
|
||||
var h = h_in;
|
||||
|
||||
// Message schedule
|
||||
var w: array<u32, 64>;
|
||||
for (var i = 0u; i < 16u; i++) {
|
||||
w[i] = (*msg)[i];
|
||||
}
|
||||
for (var i = 16u; i < 64u; i++) {
|
||||
w[i] = gamma1(w[i-2u]) + w[i-7u] + gamma0(w[i-15u]) + w[i-16u];
|
||||
}
|
||||
|
||||
// Compression
|
||||
var a = h[0]; var b = h[1]; var c = h[2]; var d = h[3];
|
||||
var e = h[4]; var f = h[5]; var g = h[6]; var hh = h[7];
|
||||
|
||||
for (var i = 0u; i < 64u; i++) {
|
||||
let t1 = hh + sigma1(e) + ch(e, f, g) + K[i] + w[i];
|
||||
let t2 = sigma0(a) + maj(a, b, c);
|
||||
hh = g; g = f; f = e; e = d + t1;
|
||||
d = c; c = b; b = a; a = t1 + t2;
|
||||
}
|
||||
|
||||
h[0] = h[0] + a; h[1] = h[1] + b; h[2] = h[2] + c; h[3] = h[3] + d;
|
||||
h[4] = h[4] + e; h[5] = h[5] + f; h[6] = h[6] + g; h[7] = h[7] + hh;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
// Process a single candidate and record match if found
|
||||
fn process_candidate(name_idx: u32) {
|
||||
// Generate message for this room name
|
||||
var msg: array<u32, 16>;
|
||||
let valid = index_to_room_name(name_idx, params.name_length, &msg);
|
||||
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute SHA256("#roomname") - this gives us the key
|
||||
let key_hash = sha256_block(&msg);
|
||||
|
||||
// Take first 16 bytes (4 words) as the key
|
||||
var key: array<u32, 4>;
|
||||
key[0] = key_hash[0];
|
||||
key[1] = key_hash[1];
|
||||
key[2] = key_hash[2];
|
||||
key[3] = key_hash[3];
|
||||
|
||||
// Compute SHA256(key) to get channel hash
|
||||
let channel_hash = sha256_key(key);
|
||||
|
||||
// Check if channel hash matches target
|
||||
if (channel_hash != params.target_channel_hash) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Channel hash matches - verify MAC if enabled
|
||||
if (params.verify_mac == 1u) {
|
||||
let computed_mac = hmac_sha256_mac(key, params.ciphertext_len_bits);
|
||||
if (computed_mac != params.target_mac) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Found a match - record the index
|
||||
let match_idx = atomicAdd(&match_count, 1u);
|
||||
if (match_idx < 1024u) { // Limit stored matches
|
||||
match_indices[match_idx] = name_idx;
|
||||
}
|
||||
}
|
||||
|
||||
// Each thread processes 16 candidates to amortize thread overhead
|
||||
const CANDIDATES_PER_THREAD: u32 = 16u;
|
||||
|
||||
@compute @workgroup_size(256)
|
||||
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
||||
let base_idx = global_id.x * CANDIDATES_PER_THREAD;
|
||||
|
||||
for (var i = 0u; i < CANDIDATES_PER_THREAD; i++) {
|
||||
let idx = base_idx + i;
|
||||
if (idx >= params.batch_size) {
|
||||
return;
|
||||
}
|
||||
let name_idx = params.batch_offset + idx;
|
||||
process_candidate(name_idx);
|
||||
}
|
||||
}
|
||||
`}async init(){if(!navigator.gpu)return console.warn("WebGPU not supported"),!1;try{const r=await navigator.gpu.requestAdapter();if(!r)return console.warn("No GPU adapter found"),!1;this.device=await r.requestDevice(),this.bindGroupLayout=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:3,visibility:GPUShaderStage.COMPUTE,buffer:{type:"read-only-storage"}}]}),this.paramsBuffer=this.device.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.matchCountBuffer=this.device.createBuffer({size:4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST}),this.matchIndicesBuffer=this.device.createBuffer({size:1024*4,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC});for(let u=0;u<2;u++)this.matchCountReadBuffers[u]=this.device.createBuffer({size:4,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),this.matchIndicesReadBuffers[u]=this.device.createBuffer({size:1024*4,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST});const o=this.device.createShaderModule({code:this.shaderCode}),s=this.device.createPipelineLayout({bindGroupLayouts:[this.bindGroupLayout]});return this.pipeline=this.device.createComputePipeline({layout:s,compute:{module:o,entryPoint:"main"}}),!0}catch(r){return console.error("WebGPU initialization failed:",r),!1}}isAvailable(){return this.device!==null&&this.pipeline!==null}indexToRoomName(r,o){return Gn(o,r)}countNamesForLength(r){return Rr(r)}async runBatch(r,o,s,u,l,m){if(!this.device||!this.pipeline||!this.bindGroupLayout||!this.paramsBuffer||!this.matchCountBuffer||!this.matchIndicesBuffer||!this.matchCountReadBuffers[0]||!this.matchCountReadBuffers[1]||!this.matchIndicesReadBuffers[0]||!this.matchIndicesReadBuffers[1])throw new Error("GPU not initialized");const c=this.currentReadBufferIndex;this.currentReadBufferIndex=1-this.currentReadBufferIndex;const h=this.matchCountReadBuffers[c],d=this.matchIndicesReadBuffers[c],y=l&&m?1:0;let g,f=0,z=0;if(y){const x=new Uint8Array(l.length/2);for(let N=0;N<x.length;N++)x[N]=parseInt(l.substr(N*2,2),16);f=x.length*8;const D=Math.ceil(x.length/4)*4,R=new Uint8Array(D);R.set(x),g=new Uint32Array(D/4);for(let N=0;N<g.length;N++)g[N]=R[N*4]<<24|R[N*4+1]<<16|R[N*4+2]<<8|R[N*4+3];const F=parseInt(m.substr(0,2),16),O=parseInt(m.substr(2,2),16);z=F<<24|O<<16}else g=new Uint32Array([0]);const k=Math.max(g.length*4,4);(!this.ciphertextBuffer||this.ciphertextBufferSize<k)&&(this.ciphertextBuffer&&this.ciphertextBuffer.destroy(),this.ciphertextBuffer=this.device.createBuffer({size:k,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),this.ciphertextBufferSize=k,this.bindGroupDirty=!0);const j=new Uint32Array([r,s,o,u,z,g.length,f,y]);this.device.queue.writeBuffer(this.paramsBuffer,0,j),this.device.queue.writeBuffer(this.ciphertextBuffer,0,g),this.device.queue.writeBuffer(this.matchCountBuffer,0,gl.ZERO_DATA),(this.bindGroupDirty||!this.bindGroup)&&(this.bindGroup=this.device.createBindGroup({layout:this.bindGroupLayout,entries:[{binding:0,resource:{buffer:this.paramsBuffer}},{binding:1,resource:{buffer:this.matchCountBuffer}},{binding:2,resource:{buffer:this.matchIndicesBuffer}},{binding:3,resource:{buffer:this.ciphertextBuffer}}]}),this.bindGroupDirty=!1);const v=this.device.createCommandEncoder(),A=v.beginComputePass();A.setPipeline(this.pipeline),A.setBindGroup(0,this.bindGroup),A.dispatchWorkgroups(Math.ceil(u/(256*16))),A.end(),v.copyBufferToBuffer(this.matchCountBuffer,0,h,0,4),v.copyBufferToBuffer(this.matchIndicesBuffer,0,d,0,1024*4),this.device.queue.submit([v.finish()]),await h.mapAsync(GPUMapMode.READ);const w=new Uint32Array(h.getMappedRange())[0];h.unmap();const _=[];if(w>0){await d.mapAsync(GPUMapMode.READ);const x=new Uint32Array(d.getMappedRange());for(let D=0;D<Math.min(w,1024);D++)_.push(x[D]);d.unmap()}return _}destroy(){var r,o,s,u,l,m,c,h;(r=this.paramsBuffer)==null||r.destroy(),(o=this.matchCountBuffer)==null||o.destroy(),(s=this.matchIndicesBuffer)==null||s.destroy(),(u=this.ciphertextBuffer)==null||u.destroy(),(l=this.matchCountReadBuffers[0])==null||l.destroy(),(m=this.matchCountReadBuffers[1])==null||m.destroy(),(c=this.matchIndicesReadBuffers[0])==null||c.destroy(),(h=this.matchIndicesReadBuffers[1])==null||h.destroy(),this.paramsBuffer=null,this.matchCountBuffer=null,this.matchIndicesBuffer=null,this.ciphertextBuffer=null,this.ciphertextBufferSize=0,this.matchCountReadBuffers=[null,null],this.matchIndicesReadBuffers=[null,null],this.currentReadBufferIndex=0,this.bindGroup=null,this.bindGroupDirty=!0,this.device&&(this.device.destroy(),this.device=null),this.pipeline=null,this.bindGroupLayout=null}}gl.ZERO_DATA=new Uint32Array([0]);function Rj(){return typeof navigator<"u"&&"gpu"in navigator}class Ig{runBatch(r,o,s,u,l,m){const c=[],h=r.toString(16).padStart(2,"0")
Line truncated
|
||||
`).map(l=>l.trim().toLowerCase()).filter(l=>l.length>0);this.wordlist=u.filter(Mg)}setWordlist(r){this.wordlist=r.map(o=>o.trim().toLowerCase()).filter(Mg)}abort(){this.abortFlag=!0}isGpuAvailable(){return Rj()}async decodePacket(r){var s;const o=r.trim().replace(/\s+/g,"").replace(/^0x/i,"");if(!o||!/^[0-9a-fA-F]+$/.test(o))return null;try{const l=(s=(await Tg.MeshCorePacketDecoder.decodeWithVerification(o,{})).payload)==null?void 0:s.decoded;return!(l!=null&&l.channelHash)||!(l!=null&&l.ciphertext)||!(l!=null&&l.cipherMac)?null:{channelHash:l.channelHash,ciphertext:l.ciphertext,cipherMac:l.cipherMac,isGroupText:!0}}catch{return null}}async crack(r,o,s){this.abortFlag=!1,this.useTimestampFilter=(o==null?void 0:o.useTimestampFilter)??!0,this.useUtf8Filter=(o==null?void 0:o.useUtf8Filter)??!0,this.validSeconds=(o==null?void 0:o.validSeconds)??Du,this.useCpu=(o==null?void 0:o.forceCpu)??!1;const u=(o==null?void 0:o.maxLength)??8,l=(o==null?void 0:o.startingLength)??1,m=(o==null?void 0:o.useDictionary)??!0,c=(o==null?void 0:o.startFromType)??"bruteforce",h=r.toLowerCase(),d=await this.decodePacket(h);if(!d)return{found:!1,error:"Invalid packet or not a GroupText packet"};const{channelHash:y,ciphertext:g,cipherMac:f}=d,z=parseInt(y,16);this.useCpu?this.cpuInstance||(this.cpuInstance=new Ig):this.gpuInstance||(this.gpuInstance=new gl,await this.gpuInstance.init()||(this.useCpu=!0,this.cpuInstance=new Ig));const k=performance.now();let j=0,v=performance.now(),A=l,C=0,w=0,_=!1;if(o!=null&&o.startFrom){const H=o.startFrom.toLowerCase();if(c==="dictionary"){const K=this.wordlist.indexOf(H);K>=0&&(w=K+1)}else{_=!0;const K=_j(H);K&&(A=Math.max(l,K.length),C=K.index+1,C>=Rr(A)&&(A++,C=0))}}let x=0;m&&!_&&this.wordlist.length>0&&(x+=this.wordlist.length-w);for(let H=A;H<=u;H++)x+=Rr(H);x-=C;const D=(H,K,ae)=>{if(!s)return;const ne=(performance.now()-k)/1e3,$=ne>0?Math.round(j/ne):0,oe=x-j,ee=$>0?oe/$:0;s({checked:j,total:x,percent:x>0?Math.min(100,j/x*100):0,rateKeysPerSec:$,etaSeconds:ee,elapsedSeconds:ne,currentLength:K,currentPosition:ae,phase:H})},R=H=>{if(!Xb(g,f,H))return{valid:!1};const K=Tg.ChannelCrypto.decryptGroupTextMessage(g,f,H);return!K.success||!K.data?{valid:!1}:this.useTimestampFilter&&!Dj(K.data.timestamp,this.validSeconds)?{valid:!1}:this.useUtf8Filter&&!Fj(K.data.message)?{valid:!1}:{valid:!0,message:K.data.message}};if(!_&&w===0&&A===l&&C===0){D("public-key",0,_u);const H=Ru($t);if(y===H){const K=R($t);if(K.valid)return{found:!0,roomName:_u,key:$t,decryptedMessage:K.message}}}if(m&&!_&&this.wordlist.length>0)for(let H=w;H<this.wordlist.length;H++){if(this.abortFlag)return{found:!1,aborted:!0,resumeFrom:this.wordlist[H],resumeType:"dictionary"};const K=this.wordlist[H],ae=Fu("#"+K),X=Ru(ae);if(parseInt(X,16)===z){const $=R(ae);if($.valid)return{found:!0,roomName:K,key:ae,decryptedMessage:$.message,resumeFrom:K,resumeType:"dictionary"}}j++;const ne=performance.now();ne-v>=200&&(D("wordlist",K.length,K),v=ne,await new Promise($=>setTimeout($,0)))}const F=this.useCpu?1024:32768,O=(o==null?void 0:o.gpuDispatchMs)??1e3;let N=F,T=!1;for(let H=A;H<=u;H++){if(this.abortFlag)return{found:!1,aborted:!0,resumeFrom:Gn(H,0)||void 0,resumeType:"bruteforce"};const K=Rr(H);let ae=H===A?C:0;for(;ae<K;){if(this.abortFlag)return{found:!1,aborted:!0,resumeFrom:Gn(H,ae)||void 0,resumeType:"bruteforce"};const X=Math.min(N,K-ae),ne=performance.now();let $;this.useCpu?$=this.cpuInstance.runBatch(z,H,ae,X,g,f):$=await this.gpuInstance.runBatch(z,H,ae,X,g,f);const oe=performance.now()-ne;if(j+=X,!this.useCpu&&!T&&X>=F&&oe>0){const q=O/oe,I=Math.round(X*q),L=Math.pow(2,Math.round(Math.log2(Math.max(F,I))));N=Math.max(F,L),T=!0}for(const q of $){const I=Gn(H,q);if(!I)continue;const L=Fu("#"+I),Q=R(L);if(Q.valid)return{found:!0,roomName:I,key:L,decryptedMessage:Q.message,resumeFrom:I,resumeType:"bruteforce"}}ae+=X;const ee=performance.now();if(ee-v>=200){const q=Gn(H,Math.min(ae,K-1))||"";D("bruteforce",H,q),v=ee,await new Promise(I=>setTimeout(I,0))}}}return{found:!1,resumeFrom:Gn(u,Rr(u)-1)||void 0,resumeType:"bruteforce"}}destroy(){this.gpuInstance&&(this.gpuInstance.destroy(),this.gpuInstance=null),this.cpuInstance&&(this.cpuInstance.destroy(),this.cpuInstance=null)}}const Mj=["a","aa","aaa","aah","aahed","aahing","aahs","aal","aalii","aaliis","aals","aam","aani","aardvark","aardvarks","aardwolf","aardwolves","aargh","aaron","aaronic","aaronical","aaronite","aaronitic","aarrgh","aarrghh","aaru","aas","aasvogel","aasvogels","ab","aba","ababdeh","ababua","abac","abaca","abacay","abacas","abacate","abacaxi","abaci","abacinate","abacination","abacisci","abaciscus","abacist","aback","abacli","abacot","abacterial","abactinal","abactinally","abaction","abactor","abaculi","abaculus","abacus","abacuses","abada","abaddon","abadejo","abadengo","abadia","abadite","abaff","abaft","abay","abayah","abaisance","abaised","abaiser","abaisse","abaissed","abaka","abakas","abalation","abalienate","abalienated","abalienating","abalienation","ab
Line truncated
|
||||
NoSleep enabled for older iOS devices. This can interrupt
|
||||
active or long-running network requests from completing successfully.
|
||||
See https://github.com/richtr/NoSleep.js/issues/15 for more details.
|
||||
`),this.noSleepTimer=window.setInterval(()=>{document.hidden||(window.location.href=window.location.href.split("#")[0],window.setTimeout(window.stop,0))},15e3),this.enabled=!0,Promise.resolve()):this.noSleepVideo.play().then(c=>(this.enabled=!0,c)).catch(c=>{throw this.enabled=!1,c})}disable(){s()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):o()?this.noSleepTimer&&(console.warn(`
|
||||
NoSleep now disabled for older iOS devices.
|
||||
`),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}}return vu=u,vu}var Hj=Lj();const Vj=Fo(Hj);function Uj({packets:a,channels:r,onChannelCreate:o,onRunningChange:s}){const[u,l]=S.useState(!1),[m,c]=S.useState(6),[h,d]=S.useState(!1),[y,g]=S.useState(!0),[f,z]=S.useState(!1),[k,j]=S.useState(null),[v,A]=S.useState(new Map),[C,w]=S.useState([]),[_,x]=S.useState(!1),[D,R]=S.useState(null),[F,O]=S.useState(null),N=S.useRef(null),T=S.useRef(null),W=S.useRef(!1),H=S.useRef(!1),K=S.useRef(!1),ae=S.useRef(new Map),X=S.useRef(!1),ne=S.useRef(6),$=S.useRef(!0),oe=S.useRef(!1),ee=S.useRef(new Set);S.useEffect(()=>{const ce=new Ij;N.current=ce,R(ce.isGpuAvailable());const Ae=new Vj;return T.current=Ae,ce.setWordlist(Mj),x(!0),()=>{ce.destroy(),N.current=null,Ae.disable(),T.current=null}},[]),S.useEffect(()=>{const ce=()=>{ei.getUndecryptedPacketCount().then(({count:Fe})=>O(Fe)).catch(()=>O(null))};ce();const Ae=setInterval(ce,3e4);return()=>clearInterval(Ae)},[]);const q=new Set(r.map(ce=>ce.key.toUpperCase())),I=a.filter(ce=>ce.payload_type==="GROUP_TEXT"&&!ce.decrypted);S.useEffect(()=>{A(ce=>{const Ae=new Map(ce);let Fe=!1;for(const He of I)Ae.has(He.id)||(Ae.set(He.id,{packet:He,attempts:0,lastAttemptLength:0,status:"pending"}),Fe=!0);return Fe?(ae.current=Ae,Ae):ce})},[I.length]),S.useEffect(()=>{ae.current=v},[v]),S.useEffect(()=>{X.current=h},[h]),S.useEffect(()=>{ne.current=m},[m]),S.useEffect(()=>{$.current=y},[y]),S.useEffect(()=>{oe.current=f},[f]),S.useEffect(()=>{ee.current=new Set(I.map(ce=>ce.id))},[I]),S.useEffect(()=>{s==null||s(u)},[u,s]);const L=Array.from(v.values()).filter(ce=>ce.status==="pending").length,Q=Array.from(v.values()).filter(ce=>ce.status==="cracked").length,de=Array.from(v.values()).filter(ce=>ce.status==="failed").length,ge=S.useCallback(async()=>{if(K.current||!N.current||!W.current)return;const ce=ae.current;let Ae=null,Fe=null;for(const[Oe,Me]of ce.entries())if(Me.status==="pending"){Ae=Me,Fe=Oe;break}if(!Ae&&X.current){const Oe=Array.from(ce.entries()).filter(([,Me])=>Me.status==="failed"&&Me.lastAttemptLength<10);Oe.length>0&&(Oe.sort((Me,Xe)=>Me[1].lastAttemptLength-Xe[1].lastAttemptLength),[Fe,Ae]=Oe[0])}if(!Ae||Fe===null){W.current&&setTimeout(()=>ge(),1e3);return}if(!ee.current.has(Fe)){A(Oe=>{const Me=new Map(Oe);return Me.delete(Fe),Me}),W.current&&setTimeout(()=>ge(),10);return}K.current=!0;const He=ne.current,ai=Ae.lastAttemptLength>0,Qe=ai?Ae.lastAttemptLength+1:He;try{const Oe=await N.current.crack(Ae.packet.data,{maxLength:Qe,useTimestampFilter:!0,useUtf8Filter:!0,...oe.current&&{gpuDispatchMs:1e4},...ai&&{useDictionary:!1,startingLength:Qe}},Me=>{j(Me)});if(H.current){H.current=!1,K.current=!1,j(null);return}if(Oe.found&&Oe.roomName&&Oe.key){A(Ve=>{const Ge=new Map(Ve),yi=Ge.get(Fe);return yi&&Ge.set(Fe,{...yi,status:"cracked",attempts:yi.attempts+1,lastAttemptLength:Qe}),Ge});const Me={roomName:Oe.roomName,key:Oe.key,packetId:Fe,message:Oe.decryptedMessage||"",crackedAt:Date.now()};w(Ve=>[...Ve,Me]);const Xe=Oe.key.toUpperCase();if(!q.has(Xe))try{const Ve="#"+Oe.roomName;await o(Ve,Oe.key),$.current&&await ei.decryptHistoricalPackets({key_type:"channel",channel_name:Ve})}catch(Ve){console.error("Failed to create channel or decrypt historical:",Ve)}}else A(Me=>{const Xe=new Map(Me),Ve=Xe.get(Fe);return Ve&&Xe.set(Fe,{...Ve,status:"failed",attempts:Ve.attempts+1,lastAttemptLength:Qe}),Xe})}catch(Oe){console.error("Cracking error:",Oe),A(Me=>{const Xe=new Map(Me),Ve=Xe.get(Fe);return Ve&&Xe.set(Fe,{...Ve,status:"failed",attempts:Ve.attempts+1,lastAttemptLength:Qe}),Xe})}K.current=!1,j(null),W.current&&setTimeout(()=>ge(),100)},[q,o]),be=()=>{var ce;if(!D){alert("WebGPU is not available in your browser. Please use Chrome 113+ or Edge 113+.");return}l(!0),W.current=!0,H.current=!1,(ce=T.current)==null||ce.enable(),ge()},se=()=>{var ce,Ae;l(!1),W.current=!1,H.current=!0,(ce=N.current)==null||ce.abort(),(Ae=T.current)==null||Ae.disable()};return B.jsxs("div",{className:"flex flex-col h-full p-3 gap-3 bg-background border-t border-border",children:[B.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[B.jsx("button",{onClick:u?se:be,disabled:!_||D===!1,className:$e("px-4 py-1.5 rounded text-sm font-medium",u?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90","disabled:opacity-50 disabled:cursor-not-allowed"),children:u?"Stop":"Start Cracking"}),B.jsxs("div",{className:"flex items-center gap-2",children:[B.jsx("label",{className:"text-sm text-muted-foreground",children:"Max Length:"}),B.jsx("input",{type:"number",min:1,max:10,value:m,onChange:ce=>c(Math.min(10,Math.max(1,parseInt(ce.target.value)||6))),className:"w-14 px-2 py-1 text-sm bg-muted border border-border rounded"})]}),B.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground cursor-pointer",children:[B.jsx("input",{type:"checkbox",chec
Line truncated
|
||||
`)}function Yj(a){if(a.length===0)return`Neighbors
|
||||
No neighbors reported`;const r=[...a].sort((s,u)=>u.snr-s.snr),o=[`Neighbors (${r.length})`];for(const s of r){const u=s.name||s.pubkey_prefix,l=s.snr>=0?`+${s.snr.toFixed(1)}`:s.snr.toFixed(1);o.push(`${u}, ${l} dB [${Qt(s.last_heard_seconds)} ago]`)}return o.join(`
|
||||
`)}function Zj(a){if(a.length===0)return`ACL
|
||||
No ACL entries`;const r=[`ACL (${a.length})`];for(const o of a){const s=o.name||o.pubkey_prefix;r.push(`${s}: ${o.permission_name}`)}return r.join(`
|
||||
`)}function Xj(a){return`${a.type}-${a.conversation_key}-${a.text}-${a.sender_timestamp}`}function Jj(){const a=window.location.hash.slice(1);if(!a)return null;if(a==="raw")return{type:"raw",name:"raw"};const r=a.indexOf("/");if(r===-1)return null;const o=a.slice(0,r),s=decodeURIComponent(a.slice(r+1));return(o==="channel"||o==="contact")&&s?{type:o,name:s}:null}function eA(a){if(!a)return"";if(a.type==="raw")return"#raw";const r=a.type==="channel"&&a.name.startsWith("#")?a.name.slice(1):a.name;return`#${a.type}/${encodeURIComponent(r)}`}function iA(){const a=S.useRef(null),r=S.useRef(null),o=S.useRef(new Set),[s,u]=S.useState(null),[l,m]=S.useState(null),[c,h]=S.useState(null),[d,y]=S.useState([]),[g,f]=S.useState([]),[z,k]=S.useState([]),[j,v]=S.useState(!1),[A,C]=S.useState(!1),[w,_]=S.useState([]),[x,D]=S.useState(null),[R,F]=S.useState(!1),[O,N]=S.useState(!1),[T,W]=S.useState(!1),[H,K]=S.useState(!1),[ae,X]=S.useState(0),[ne,$]=S.useState(!1),[oe,ee]=S.useState(!1),[q,I]=S.useState(!1),[L,Q]=S.useState(Zm),[de,ge]=S.useState({}),be=S.useRef(null),se=S.useMemo(()=>({onHealth:V=>{const J=be.current;be.current=V,u(V),J!==null&&J.radio_connected!==V.radio_connected&&(V.radio_connected?Tr.success("Radio connected",{description:V.serial_port?`Connected to ${V.serial_port}`:void 0}):Tr.error("Radio disconnected",{description:"Check radio connection and power"}))},onError:V=>{Tr.error(V.message,{description:V.details})},onContacts:V=>y(V),onChannels:V=>f(V),onMessage:V=>{const J=r.current,re=Xj(V);if(o.current.has(re)){console.debug("Duplicate message content ignored:",re.slice(0,50));return}if(o.current.add(re),o.current.size>1e3){const _e=Array.from(o.current);o.current=new Set(_e.slice(-500))}let ye=null;V.type==="CHAN"&&V.conversation_key?ye=an("channel",V.conversation_key):V.type==="PRIV"&&V.conversation_key&&(ye=an("contact",V.conversation_key));const ve=J?V.type==="CHAN"&&J.type==="channel"?V.conversation_key===J.id:V.type==="PRIV"&&J.type==="contact"?V.conversation_key&&Kg(J.id,V.conversation_key):!1:!1;if(ve&&k(_e=>_e.some(ni=>ni.id===V.id)?_e:[..._e,V]),ye){const _e=V.received_at||Math.floor(Date.now()/1e3),ni=nu(ye,_e);Q(ni),!V.outgoing&&!ve&&ge(Ce=>({...Ce,[ye]:(Ce[ye]||0)+1}))}},onContact:V=>{y(J=>{const re=J.findIndex(ye=>ye.public_key===V.public_key);if(re>=0){const ye=[...J],ve=J[re];return ye[re]={...ve,...V,name:V.name??ve.name,last_path:V.last_path??ve.last_path,lat:V.lat??ve.lat,lon:V.lon??ve.lon},ye}return[...J,V]})},onRawPacket:V=>{_(J=>{if(J.some(ye=>ye.id===V.id))return J;const re=[...J,V];return re.length>Hg?re.slice(-Hg):re})},onMessageAcked:V=>{k(J=>{const re=J.findIndex(ye=>ye.id===V);if(re>=0){const ye=[...J];return ye[re]={...J[re],acked:!0},ye}return J})}}),[]);ck(se);const ce=S.useCallback(async()=>{try{const V=await ei.getRadioConfig();m(V)}catch(V){console.error("Failed to fetch config:",V)}},[]),Ae=S.useCallback(async()=>{try{const V=await ei.getSettings();h(V)}catch(V){console.error("Failed to fetch app settings:",V)}},[]),Fe=S.useCallback(async()=>{try{const V=await ei.getUndecryptedPacketCount();X(V.count)}catch(V){console.error("Failed to fetch undecrypted count:",V)}},[]),He=200,ai=S.useCallback(async(V=!1)=>{if(!x){k([]),v(!1);return}V&&F(!0);try{const J=await ei.getMessages({type:x.type==="channel"?"CHAN":"PRIV",conversation_key:x.id,limit:He});k(J),v(J.length>=He)}catch(J){console.error("Failed to fetch messages:",J)}finally{V&&F(!1)}},[x]),Qe=S.useCallback(async()=>{if(!(!x||A||!j)){C(!0);try{const V=await ei.getMessages({type:x.type==="channel"?"CHAN":"PRIV",conversation_key:x.id,limit:He,offset:z.length});V.length>0&&k(J=>[...J,...V]),v(V.length>=He)}catch(V){console.error("Failed to fetch older messages:",V)}finally{C(!1)}}},[x,A,j,z.length]);S.useEffect(()=>{ce(),Ae(),Fe()},[ce,Ae,Fe]);const Oe=S.useCallback(()=>{const V=Jj();if(!V)return null;if(V.type==="raw")return{type:"raw",id:"raw",name:"Raw Packet Feed"};if(V.type==="channel"){const J=g.find(re=>re.name===V.name||re.name===`#${V.name}`);if(J)return{type:"channel",id:J.key,name:J.name}}if(V.type==="contact"){const J=d.find(re=>Kn(re.name,re.public_key)===V.name);if(J)return{type:"contact",id:J.public_key,name:Kn(J.name,J.public_key)}}return null},[g,d]),Me=S.useRef(!1);S.useEffect(()=>{if(Me.current||x||g.length===0&&d.length===0)return;const V=Oe();if(V){D(V),Me.current=!0;return}const J=g.find(re=>re.name==="Public");J&&(D({type:"channel",id:J.key,name:J.name}),Me.current=!0)},[g,d,x,Oe]);const Xe=S.useRef(new Set),Ve=S.useRef(new Set);S.useEffect(()=>{const V=g.filter(ye=>!Xe.current.has(ye.key)),J=d.filter(ye=>ye.public_key&&!Ve.current.has(ye.public_key));if(V.length===0&&J.length===0)return;V.forEach(ye=>Xe.current.add(ye.key)),J.forEach(ye=>Ve.current.add(ye.public_key)),(async()=>{const ye=[...V.map(ve=>({type:"CHAN",conversation_key:ve.key})),...J.map(ve=>({type:"PRIV",conversation_key:ve.public_key}))];if(ye.length!==0)try{const ve=await ei.getMessagesBulk(ye,100),_e=Yk(),ni={},Ce={};for(const T
Line truncated
|
||||
Vendored
+1
-1
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>RemoteTerm for MeshCore</title>
|
||||
<script type="module" crossorigin src="/assets/index-DJfUQN-2.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-Dj98vxU3.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CtV9BARe.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
+88
-9
@@ -61,10 +61,9 @@ function formatDuration(seconds: number): string {
|
||||
}
|
||||
|
||||
// Format telemetry response as human-readable text
|
||||
// Note: Avoid "Word: " pattern at line start - it triggers sender extraction in MessageList
|
||||
function formatTelemetry(telemetry: TelemetryResponse): string {
|
||||
const lines = [
|
||||
`[Telemetry]`,
|
||||
`Telemetry`,
|
||||
`Battery Voltage: ${telemetry.battery_volts.toFixed(3)}V`,
|
||||
`Uptime: ${formatDuration(telemetry.uptime_seconds)}`,
|
||||
`TX Airtime: ${formatDuration(telemetry.airtime_seconds)}`,
|
||||
@@ -88,11 +87,11 @@ function formatTelemetry(telemetry: TelemetryResponse): string {
|
||||
// Format neighbors list as human-readable text
|
||||
function formatNeighbors(neighbors: NeighborInfo[]): string {
|
||||
if (neighbors.length === 0) {
|
||||
return '[Neighbors]\nNo neighbors reported';
|
||||
return 'Neighbors\nNo neighbors reported';
|
||||
}
|
||||
// Sort by SNR descending (highest first)
|
||||
const sorted = [...neighbors].sort((a, b) => b.snr - a.snr);
|
||||
const lines = [`[Neighbors] (${sorted.length})`];
|
||||
const lines = [`Neighbors (${sorted.length})`];
|
||||
for (const n of sorted) {
|
||||
const name = n.name || n.pubkey_prefix;
|
||||
const snr = n.snr >= 0 ? `+${n.snr.toFixed(1)}` : n.snr.toFixed(1);
|
||||
@@ -104,9 +103,9 @@ function formatNeighbors(neighbors: NeighborInfo[]): string {
|
||||
// Format ACL list as human-readable text
|
||||
function formatAcl(acl: AclEntry[]): string {
|
||||
if (acl.length === 0) {
|
||||
return '[ACL]\nNo ACL entries';
|
||||
return 'ACL\nNo ACL entries';
|
||||
}
|
||||
const lines = [`[ACL] (${acl.length})`];
|
||||
const lines = [`ACL (${acl.length})`];
|
||||
for (const entry of acl) {
|
||||
const name = entry.name || entry.pubkey_prefix;
|
||||
lines.push(`${name}: ${entry.permission_name}`);
|
||||
@@ -172,6 +171,8 @@ export function App() {
|
||||
const [undecryptedCount, setUndecryptedCount] = useState(0);
|
||||
const [showCracker, setShowCracker] = useState(false);
|
||||
const [crackerRunning, setCrackerRunning] = useState(false);
|
||||
// Track if we've logged into the current repeater (for CLI command mode)
|
||||
const [repeaterLoggedIn, setRepeaterLoggedIn] = useState(false);
|
||||
// Track last message times (persisted in localStorage, used for sorting)
|
||||
const [lastMessageTimes, setLastMessageTimes] = useState<ConversationTimes>(getLastMessageTimes);
|
||||
// Track unread counts (calculated on load and incremented during session)
|
||||
@@ -555,6 +556,9 @@ export function App() {
|
||||
useEffect(() => {
|
||||
activeConversationRef.current = activeConversation;
|
||||
|
||||
// Reset repeater login state when conversation changes
|
||||
setRepeaterLoggedIn(false);
|
||||
|
||||
// Mark conversation as read when user views it
|
||||
if (activeConversation && activeConversation.type !== 'raw') {
|
||||
const key = getStateKey(
|
||||
@@ -670,6 +674,9 @@ export function App() {
|
||||
|
||||
// Add all messages to the list
|
||||
setMessages((prev) => [...prev, telemetryMessage, neighborsMessage, aclMessage]);
|
||||
|
||||
// Mark as logged in for CLI command mode
|
||||
setRepeaterLoggedIn(true);
|
||||
} catch (err) {
|
||||
// Show error as a local message
|
||||
const errorMessage: Message = {
|
||||
@@ -691,6 +698,72 @@ export function App() {
|
||||
[activeConversation, activeContactIsRepeater]
|
||||
);
|
||||
|
||||
// Send CLI command to a repeater (after logged in)
|
||||
const handleRepeaterCommand = useCallback(
|
||||
async (command: string) => {
|
||||
if (!activeConversation || activeConversation.type !== 'contact') return;
|
||||
if (!activeContactIsRepeater || !repeaterLoggedIn) return;
|
||||
|
||||
const now = Math.floor(Date.now() / 1000);
|
||||
|
||||
// Show the command as an outgoing message
|
||||
const commandMessage: Message = {
|
||||
id: -Date.now(),
|
||||
type: 'PRIV',
|
||||
conversation_key: activeConversation.id,
|
||||
text: `> ${command}`,
|
||||
sender_timestamp: now,
|
||||
received_at: now,
|
||||
path_len: null,
|
||||
txt_type: 0,
|
||||
signature: null,
|
||||
outgoing: true,
|
||||
acked: true,
|
||||
};
|
||||
setMessages((prev) => [...prev, commandMessage]);
|
||||
|
||||
try {
|
||||
const response = await api.sendRepeaterCommand(activeConversation.id, command);
|
||||
|
||||
// Use the actual timestamp from the repeater if available
|
||||
const responseTimestamp = response.sender_timestamp ?? now;
|
||||
|
||||
// Show the response
|
||||
const responseMessage: Message = {
|
||||
id: -Date.now() - 1,
|
||||
type: 'PRIV',
|
||||
conversation_key: activeConversation.id,
|
||||
text: response.response,
|
||||
sender_timestamp: responseTimestamp,
|
||||
received_at: now,
|
||||
path_len: null,
|
||||
txt_type: 0,
|
||||
signature: null,
|
||||
outgoing: false,
|
||||
acked: true,
|
||||
};
|
||||
|
||||
setMessages((prev) => [...prev, responseMessage]);
|
||||
} catch (err) {
|
||||
const errorMessage: Message = {
|
||||
id: -Date.now() - 1,
|
||||
type: 'PRIV',
|
||||
conversation_key: activeConversation.id,
|
||||
text: `Command failed: ${err instanceof Error ? err.message : 'Unknown error'}`,
|
||||
sender_timestamp: now,
|
||||
received_at: now,
|
||||
path_len: null,
|
||||
txt_type: 0,
|
||||
signature: null,
|
||||
outgoing: false,
|
||||
acked: true,
|
||||
};
|
||||
setMessages((prev) => [...prev, errorMessage]);
|
||||
}
|
||||
},
|
||||
[activeConversation, activeContactIsRepeater, repeaterLoggedIn]
|
||||
);
|
||||
|
||||
// Config save handler
|
||||
const handleSaveConfig = useCallback(async (update: RadioConfigUpdate) => {
|
||||
await api.updateRadioConfig(update);
|
||||
@@ -983,14 +1056,20 @@ export function App() {
|
||||
/>
|
||||
<MessageInput
|
||||
ref={messageInputRef}
|
||||
onSend={activeContactIsRepeater ? handleTelemetryRequest : handleSendMessage}
|
||||
onSend={
|
||||
activeContactIsRepeater
|
||||
? (repeaterLoggedIn ? handleRepeaterCommand : handleTelemetryRequest)
|
||||
: handleSendMessage
|
||||
}
|
||||
disabled={!health?.radio_connected}
|
||||
isRepeaterMode={activeContactIsRepeater}
|
||||
isRepeaterMode={activeContactIsRepeater && !repeaterLoggedIn}
|
||||
placeholder={
|
||||
!health?.radio_connected
|
||||
? 'Radio not connected'
|
||||
: activeContactIsRepeater
|
||||
? `Enter password for ${activeConversation.name} (or . for none)...`
|
||||
? (repeaterLoggedIn
|
||||
? 'Send CLI command (requires admin login)...'
|
||||
: `Enter password for ${activeConversation.name} (or . for none)...`)
|
||||
: `Message ${activeConversation.name}...`
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -2,6 +2,7 @@ import type {
|
||||
AppSettings,
|
||||
AppSettingsUpdate,
|
||||
Channel,
|
||||
CommandResponse,
|
||||
Contact,
|
||||
HealthStatus,
|
||||
Message,
|
||||
@@ -86,6 +87,11 @@ export const api = {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ password }),
|
||||
}),
|
||||
sendRepeaterCommand: (publicKey: string, command: string) =>
|
||||
fetchJson<CommandResponse>(`/contacts/${publicKey}/command`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ command }),
|
||||
}),
|
||||
|
||||
// Channels
|
||||
getChannels: () => fetchJson<Channel[]>('/channels'),
|
||||
|
||||
@@ -44,9 +44,12 @@ export const MessageInput = forwardRef<MessageInputHandle, MessageInputProps>(
|
||||
setText('');
|
||||
} catch (err) {
|
||||
console.error('Failed to request telemetry:', err);
|
||||
return;
|
||||
} finally {
|
||||
setSending(false);
|
||||
}
|
||||
// Refocus after React re-enables the input (now in CLI command mode)
|
||||
setTimeout(() => inputRef.current?.focus(), 0);
|
||||
} else {
|
||||
if (!trimmed || sending || disabled) return;
|
||||
setSending(true);
|
||||
@@ -55,9 +58,12 @@ export const MessageInput = forwardRef<MessageInputHandle, MessageInputProps>(
|
||||
setText('');
|
||||
} catch (err) {
|
||||
console.error('Failed to send message:', err);
|
||||
return;
|
||||
} finally {
|
||||
setSending(false);
|
||||
}
|
||||
// Refocus after React re-enables the input
|
||||
setTimeout(() => inputRef.current?.focus(), 0);
|
||||
}
|
||||
},
|
||||
[text, sending, disabled, onSend, isRepeaterMode]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useLayoutEffect, useRef, useCallback, useState, type ReactNode } from 'react';
|
||||
import type { Contact, Message } from '../types';
|
||||
import { CONTACT_TYPE_REPEATER } from '../types';
|
||||
import { formatTime, parseSenderFromText } from '../utils/messageParser';
|
||||
import { pubkeysMatch } from '../utils/pubkey';
|
||||
import { ContactAvatar } from './ContactAvatar';
|
||||
@@ -207,9 +208,14 @@ export function MessageList({
|
||||
</div>
|
||||
)}
|
||||
{sortedMessages.map((msg, index) => {
|
||||
const { sender, content } = parseSenderFromText(msg.text);
|
||||
// For DMs, look up contact; for channel messages, use parsed sender
|
||||
const contact = msg.type === 'PRIV' ? getContact(msg.conversation_key) : null;
|
||||
const isRepeater = contact?.type === CONTACT_TYPE_REPEATER;
|
||||
|
||||
// Skip sender parsing for repeater messages (CLI responses often have colons)
|
||||
const { sender, content } = isRepeater
|
||||
? { sender: null, content: msg.text }
|
||||
: parseSenderFromText(msg.text);
|
||||
const displaySender = msg.outgoing
|
||||
? 'You'
|
||||
: contact?.name || sender || msg.conversation_key?.slice(0, 8) || 'Unknown';
|
||||
|
||||
@@ -38,13 +38,6 @@ describe('parseSenderFromText', () => {
|
||||
expect(result.content).toBe('Note:this is not a sender');
|
||||
});
|
||||
|
||||
it('rejects sender containing square brackets', () => {
|
||||
const result = parseSenderFromText('[System]: Alert message');
|
||||
|
||||
expect(result.sender).toBeNull();
|
||||
expect(result.content).toBe('[System]: Alert message');
|
||||
});
|
||||
|
||||
it('rejects sender containing colon', () => {
|
||||
const result = parseSenderFromText('12:30: Time announcement');
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* Tests for repeater-specific behavior.
|
||||
*
|
||||
* These tests verify edge cases in repeater interactions that could easily
|
||||
* regress if the code is modified:
|
||||
*
|
||||
* 1. Repeater messages should NOT have sender parsed from text (colons are common in CLI output)
|
||||
* 2. Password field "." should convert to empty string (for repeaters with no password)
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { parseSenderFromText } from '../utils/messageParser';
|
||||
import { CONTACT_TYPE_REPEATER, CONTACT_TYPE_CLIENT } from '../types';
|
||||
|
||||
describe('Repeater message sender parsing', () => {
|
||||
/**
|
||||
* CLI responses from repeaters often contain colons (e.g., "clock: 12:30:00").
|
||||
* If we parse these like normal channel messages, we'd incorrectly extract
|
||||
* "clock" as a sender name, breaking the display.
|
||||
*
|
||||
* The fix in MessageList.tsx is to check if the contact is a repeater and
|
||||
* skip parseSenderFromText entirely. These tests document the expected
|
||||
* behavior pattern.
|
||||
*/
|
||||
|
||||
it('parseSenderFromText would incorrectly parse CLI responses with colons', () => {
|
||||
// This demonstrates WHY we skip parsing for repeaters
|
||||
const cliResponse = 'clock: 2024-01-09 12:30:00';
|
||||
const parsed = parseSenderFromText(cliResponse);
|
||||
|
||||
// Without the repeater check, we'd get this incorrect result:
|
||||
expect(parsed.sender).toBe('clock');
|
||||
expect(parsed.content).toBe('2024-01-09 12:30:00');
|
||||
// This would display as "clock" sent "2024-01-09 12:30:00" - WRONG!
|
||||
});
|
||||
|
||||
it('repeater messages should bypass parsing entirely', () => {
|
||||
// This documents the correct behavior: skip parsing for repeaters
|
||||
const cliResponse = 'clock: 2024-01-09 12:30:00';
|
||||
const contactType = CONTACT_TYPE_REPEATER;
|
||||
|
||||
// The pattern used in MessageList.tsx:
|
||||
const isRepeater = contactType === CONTACT_TYPE_REPEATER;
|
||||
const { sender, content } = isRepeater
|
||||
? { sender: null, content: cliResponse }
|
||||
: parseSenderFromText(cliResponse);
|
||||
|
||||
// Correct: full text preserved, no sender extracted
|
||||
expect(sender).toBeNull();
|
||||
expect(content).toBe('clock: 2024-01-09 12:30:00');
|
||||
});
|
||||
|
||||
it('non-repeater messages still get sender parsed', () => {
|
||||
const channelMessage = 'Alice: Hello everyone!';
|
||||
const contactType = CONTACT_TYPE_CLIENT;
|
||||
|
||||
const isRepeater = contactType === CONTACT_TYPE_REPEATER;
|
||||
const { sender, content } = isRepeater
|
||||
? { sender: null, content: channelMessage }
|
||||
: parseSenderFromText(channelMessage);
|
||||
|
||||
// Normal behavior: sender extracted
|
||||
expect(sender).toBe('Alice');
|
||||
expect(content).toBe('Hello everyone!');
|
||||
});
|
||||
|
||||
it('handles various CLI response formats that would be mis-parsed', () => {
|
||||
const cliResponses = [
|
||||
'ver: 1.2.3',
|
||||
'tx: 20 dBm',
|
||||
'name: MyRepeater',
|
||||
'radio: 915.0,125,9,5',
|
||||
'Error: command not found',
|
||||
'uptime: 3d 12h 30m',
|
||||
];
|
||||
|
||||
for (const response of cliResponses) {
|
||||
// All of these would be incorrectly parsed without the repeater check
|
||||
const parsed = parseSenderFromText(response);
|
||||
expect(parsed.sender).not.toBeNull();
|
||||
|
||||
// But with repeater check, they're preserved
|
||||
const isRepeater = true;
|
||||
const { sender, content } = isRepeater
|
||||
? { sender: null, content: response }
|
||||
: parseSenderFromText(response);
|
||||
|
||||
expect(sender).toBeNull();
|
||||
expect(content).toBe(response);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Repeater password handling', () => {
|
||||
/**
|
||||
* The "." password convention allows users to specify an empty password
|
||||
* for repeaters that don't require authentication. Without this, users
|
||||
* couldn't submit an empty password through the form.
|
||||
*/
|
||||
|
||||
it('"." converts to empty password', () => {
|
||||
// This is the logic in MessageInput.tsx handleSubmit
|
||||
const trimmed = '.';
|
||||
const password = trimmed === '.' ? '' : trimmed;
|
||||
|
||||
expect(password).toBe('');
|
||||
});
|
||||
|
||||
it('normal password is passed through unchanged', () => {
|
||||
const trimmed = 'mySecretPassword';
|
||||
const password = trimmed === '.' ? '' : trimmed;
|
||||
|
||||
expect(password).toBe('mySecretPassword');
|
||||
});
|
||||
|
||||
it('"." with surrounding whitespace still works after trim', () => {
|
||||
// In MessageInput, text.trim() is called before the check
|
||||
const text = ' . ';
|
||||
const trimmed = text.trim();
|
||||
const password = trimmed === '.' ? '' : trimmed;
|
||||
|
||||
expect(password).toBe('');
|
||||
});
|
||||
|
||||
it('".." is NOT converted (only single dot)', () => {
|
||||
const trimmed = '..';
|
||||
const password = trimmed === '.' ? '' : trimmed;
|
||||
|
||||
// Double dot is passed through as-is (it's a valid password)
|
||||
expect(password).toBe('..');
|
||||
});
|
||||
});
|
||||
@@ -149,3 +149,9 @@ export interface TelemetryResponse {
|
||||
neighbors: NeighborInfo[];
|
||||
acl: AclEntry[];
|
||||
}
|
||||
|
||||
export interface CommandResponse {
|
||||
command: string;
|
||||
response: string;
|
||||
sender_timestamp: number | null;
|
||||
}
|
||||
@@ -6,8 +6,8 @@ export function parseSenderFromText(text: string): { sender: string | null; cont
|
||||
const colonIndex = text.indexOf(': ');
|
||||
if (colonIndex > 0 && colonIndex < 50) {
|
||||
const potentialSender = text.substring(0, colonIndex);
|
||||
// Check for invalid characters that would indicate it's not a sender
|
||||
if (!/[:\[\]]/.test(potentialSender)) {
|
||||
// Check for colon in potential sender (would indicate it's not a simple name)
|
||||
if (!potentialSender.includes(':')) {
|
||||
return {
|
||||
sender: potentialSender,
|
||||
content: text.substring(colonIndex + 2),
|
||||
|
||||
@@ -193,3 +193,90 @@ class TestAckEventHandler:
|
||||
await on_ack(MockEvent())
|
||||
|
||||
mock_repo.mark_acked.assert_not_called()
|
||||
|
||||
|
||||
class TestContactMessageCLIFiltering:
|
||||
"""Test that CLI responses (txt_type=1) are filtered out.
|
||||
|
||||
This prevents duplicate messages when sending CLI commands to repeaters:
|
||||
the command endpoint returns the response directly, so we must NOT also
|
||||
persist/broadcast it via the normal message handler.
|
||||
"""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cli_response_skipped_not_stored(self):
|
||||
"""CLI responses (txt_type=1) are not stored in database."""
|
||||
from app.event_handlers import on_contact_message
|
||||
|
||||
with patch("app.event_handlers.MessageRepository") as mock_repo, \
|
||||
patch("app.event_handlers.ContactRepository") as mock_contact_repo, \
|
||||
patch("app.event_handlers.broadcast_event") as mock_broadcast:
|
||||
|
||||
class MockEvent:
|
||||
payload = {
|
||||
"pubkey_prefix": "abc123def456",
|
||||
"text": "clock: 2024-01-01 12:00:00",
|
||||
"txt_type": 1, # CLI response
|
||||
"sender_timestamp": 1700000000,
|
||||
}
|
||||
|
||||
await on_contact_message(MockEvent())
|
||||
|
||||
# Should NOT store in database
|
||||
mock_repo.create.assert_not_called()
|
||||
# Should NOT broadcast via WebSocket
|
||||
mock_broadcast.assert_not_called()
|
||||
# Should NOT update contact last_contacted
|
||||
mock_contact_repo.update_last_contacted.assert_not_called()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_normal_message_still_processed(self):
|
||||
"""Normal messages (txt_type=0) are still processed normally."""
|
||||
from app.event_handlers import on_contact_message
|
||||
|
||||
with patch("app.event_handlers.MessageRepository") as mock_repo, \
|
||||
patch("app.event_handlers.ContactRepository") as mock_contact_repo, \
|
||||
patch("app.event_handlers.broadcast_event") as mock_broadcast:
|
||||
|
||||
mock_repo.create = AsyncMock(return_value=42)
|
||||
mock_contact_repo.get_by_key_prefix = AsyncMock(return_value=None)
|
||||
|
||||
class MockEvent:
|
||||
payload = {
|
||||
"pubkey_prefix": "abc123def456",
|
||||
"text": "Hello, this is a normal message",
|
||||
"txt_type": 0, # Normal message (default)
|
||||
"sender_timestamp": 1700000000,
|
||||
}
|
||||
|
||||
await on_contact_message(MockEvent())
|
||||
|
||||
# SHOULD store in database
|
||||
mock_repo.create.assert_called_once()
|
||||
# SHOULD broadcast via WebSocket
|
||||
mock_broadcast.assert_called_once()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_missing_txt_type_defaults_to_normal(self):
|
||||
"""Messages without txt_type field are treated as normal (not filtered)."""
|
||||
from app.event_handlers import on_contact_message
|
||||
|
||||
with patch("app.event_handlers.MessageRepository") as mock_repo, \
|
||||
patch("app.event_handlers.ContactRepository") as mock_contact_repo, \
|
||||
patch("app.event_handlers.broadcast_event") as mock_broadcast:
|
||||
|
||||
mock_repo.create = AsyncMock(return_value=42)
|
||||
mock_contact_repo.get_by_key_prefix = AsyncMock(return_value=None)
|
||||
|
||||
class MockEvent:
|
||||
payload = {
|
||||
"pubkey_prefix": "abc123def456",
|
||||
"text": "Message without txt_type field",
|
||||
"sender_timestamp": 1700000000,
|
||||
# No txt_type field
|
||||
}
|
||||
|
||||
await on_contact_message(MockEvent())
|
||||
|
||||
# SHOULD still be processed (defaults to txt_type=0)
|
||||
mock_repo.create.assert_called_once()
|
||||
Reference in new issue
Block a user