From 34ab56815e32aeaf166bd69acbec52ec1b1d9170 Mon Sep 17 00:00:00 2001 From: woikos Date: Thu, 22 Jan 2026 08:07:49 +0100 Subject: [PATCH] Add database IPC split mode and blob storage abstraction (v0.53.0) Major refactoring to support running the database as a separate gRPC service: - Add gRPC database server (cmd/orly-db/) and launcher (cmd/orly-launcher/) - Add proto definitions for all database operations (proto/orlydb/v1/) - Add gRPC client implementing database.Database interface - Abstract Blossom blob storage into database interface (9 methods) - Remove BBolt database backend (pkg/bbolt/ deleted) - Hide Blossom tab in UI when blob storage unavailable - Update documentation for new architecture Database backends: badger (default), neo4j, wasmdb, grpc Files modified: - cmd/orly-db/: New gRPC database server - cmd/orly-launcher/: Process supervisor for split mode - proto/orlydb/v1/: Protocol buffer definitions - pkg/database/grpc/: gRPC client implementation - pkg/database/blob.go: Badger blob storage implementation - pkg/database/interface.go: Added blob storage methods - pkg/database/types.go: Added BlobMetadata, BlobDescriptor types - pkg/database/factory.go: Removed BBolt, added gRPC backend - pkg/neo4j/blob.go: Blob storage stubs - pkg/wasmdb/blob.go: Blob storage stubs - pkg/blossom/: Refactored to use database.Database interface - app/config/config.go: Removed BBolt config, added gRPC settings - CLAUDE.md: Updated documentation Co-Authored-By: Claude Opus 4.5 --- CLAUDE.md | 28 +- app/blossom.go | 2 +- app/config/config.go | 45 +- app/handle-relayinfo.go | 22 +- app/main.go | 15 +- app/web/dist/bundle.js | 2 +- app/web/dist/bundle.js.map | 2 +- app/web/src/App.svelte | 17 +- cmd/benchmark/relysqlite_wrapper.go | 29 + cmd/orly-db/config.go | 68 + cmd/orly-db/main.go | 122 + cmd/orly-db/service.go | 731 ++++ cmd/orly-launcher/config.go | 63 + cmd/orly-launcher/main.go | 109 + cmd/orly-launcher/supervisor.go | 310 ++ go.mod | 9 +- go.sum | 20 +- main.go | 30 +- pkg/bbolt/batcher.go | 330 -- pkg/bbolt/bbolt.go | 325 -- pkg/bbolt/bloom.go | 192 - pkg/bbolt/fetch-event.go | 134 - pkg/bbolt/get-serial-by-id.go | 179 - pkg/bbolt/graph.go | 250 -- pkg/bbolt/helpers.go | 119 - pkg/bbolt/identity.go | 66 - pkg/bbolt/import-export.go | 306 -- pkg/bbolt/import-minimal.go | 232 -- pkg/bbolt/init.go | 55 - pkg/bbolt/logger.go | 81 - pkg/bbolt/markers.go | 62 - pkg/bbolt/query-graph.go | 287 -- pkg/bbolt/save-event-bulk.go | 96 - pkg/bbolt/save-event.go | 393 -- pkg/bbolt/serial.go | 169 - pkg/bbolt/stubs.go | 233 -- pkg/blossom/server.go | 4 +- pkg/blossom/storage.go | 555 +-- pkg/database/blob.go | 569 +++ pkg/database/factory.go | 34 +- pkg/database/grpc/client.go | 875 +++++ pkg/database/grpc/init.go | 20 + pkg/database/interface.go | 11 + pkg/database/types.go | 26 + pkg/neo4j/blob.go | 57 + pkg/proto/orlydb/v1/converters.go | 619 +++ pkg/proto/orlydb/v1/service.pb.go | 4907 ++++++++++++++++++++++++ pkg/proto/orlydb/v1/service_grpc.pb.go | 2976 ++++++++++++++ pkg/proto/orlydb/v1/types.pb.go | 1209 ++++++ pkg/ratelimit/factory.go | 3 +- pkg/ratelimit/memory_monitor.go | 4 +- pkg/version/version | 2 +- pkg/wasmdb/blob.go | 61 + proto/buf.gen.yaml | 10 + proto/buf.yaml | 10 + proto/orlydb/v1/service.proto | 668 ++++ proto/orlydb/v1/types.proto | 121 + 57 files changed, 13766 insertions(+), 4108 deletions(-) create mode 100644 cmd/orly-db/config.go create mode 100644 cmd/orly-db/main.go create mode 100644 cmd/orly-db/service.go create mode 100644 cmd/orly-launcher/config.go create mode 100644 cmd/orly-launcher/main.go create mode 100644 cmd/orly-launcher/supervisor.go delete mode 100644 pkg/bbolt/batcher.go delete mode 100644 pkg/bbolt/bbolt.go delete mode 100644 pkg/bbolt/bloom.go delete mode 100644 pkg/bbolt/fetch-event.go delete mode 100644 pkg/bbolt/get-serial-by-id.go delete mode 100644 pkg/bbolt/graph.go delete mode 100644 pkg/bbolt/helpers.go delete mode 100644 pkg/bbolt/identity.go delete mode 100644 pkg/bbolt/import-export.go delete mode 100644 pkg/bbolt/import-minimal.go delete mode 100644 pkg/bbolt/init.go delete mode 100644 pkg/bbolt/logger.go delete mode 100644 pkg/bbolt/markers.go delete mode 100644 pkg/bbolt/query-graph.go delete mode 100644 pkg/bbolt/save-event-bulk.go delete mode 100644 pkg/bbolt/save-event.go delete mode 100644 pkg/bbolt/serial.go delete mode 100644 pkg/bbolt/stubs.go create mode 100644 pkg/database/blob.go create mode 100644 pkg/database/grpc/client.go create mode 100644 pkg/database/grpc/init.go create mode 100644 pkg/neo4j/blob.go create mode 100644 pkg/proto/orlydb/v1/converters.go create mode 100644 pkg/proto/orlydb/v1/service.pb.go create mode 100644 pkg/proto/orlydb/v1/service_grpc.pb.go create mode 100644 pkg/proto/orlydb/v1/types.pb.go create mode 100644 pkg/wasmdb/blob.go create mode 100644 proto/buf.gen.yaml create mode 100644 proto/buf.yaml create mode 100644 proto/orlydb/v1/service.proto create mode 100644 proto/orlydb/v1/types.proto diff --git a/CLAUDE.md b/CLAUDE.md index dc7c2b4..0f4cee5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -40,7 +40,7 @@ NOSTR_SECRET_KEY=nsec1... ./nurl https://relay.example.com/api/logs/clear |----------|---------|-------------| | `ORLY_PORT` | 3334 | Server port | | `ORLY_LOG_LEVEL` | info | trace/debug/info/warn/error | -| `ORLY_DB_TYPE` | badger | badger/bbolt/neo4j/wasmdb | +| `ORLY_DB_TYPE` | badger | badger/neo4j/wasmdb/grpc | | `ORLY_POLICY_ENABLED` | false | Enable policy system | | `ORLY_ACL_MODE` | none | none/follows/managed | | `ORLY_TLS_DOMAINS` | | Let's Encrypt domains | @@ -67,7 +67,6 @@ app/ web/ → Svelte frontend (embedded via go:embed) pkg/ database/ → Database interface + Badger implementation - bbolt/ → BBolt backend (HDD-optimized, B+tree) neo4j/ → Neo4j backend with WoT extensions wasmdb/ → WebAssembly IndexedDB backend protocol/ → Nostr protocol (ws/, auth/, publish/) @@ -151,9 +150,9 @@ Before enabling auth-required on any deployment: | Backend | Use Case | Build | |---------|----------|-------| | **Badger** (default) | Single-instance, SSD, high performance | Standard | -| **BBolt** | HDD-optimized, large archives, lower memory | `ORLY_DB_TYPE=bbolt` | | **Neo4j** | Social graph, WoT queries | `ORLY_DB_TYPE=neo4j` | | **WasmDB** | Browser/WebAssembly | `GOOS=js GOARCH=wasm` | +| **gRPC** | Remote database (IPC split mode) | `ORLY_DB_TYPE=grpc` | All implement `pkg/database.Database` interface. @@ -178,31 +177,15 @@ ORLY_GC_BATCH_SIZE=5000 ORLY_MAX_STORAGE_BYTES=107374182400 # 100GB cap ``` -**Option 2: Use BBolt for HDD/Low-Memory Deployments** -```bash -ORLY_DB_TYPE=bbolt - -# Tune for your HDD -ORLY_BBOLT_BATCH_MAX_EVENTS=10000 # Larger batches for HDD -ORLY_BBOLT_BATCH_MAX_MB=256 # 256MB batch buffer -ORLY_BBOLT_FLUSH_TIMEOUT_SEC=60 # Longer flush interval -ORLY_BBOLT_BLOOM_SIZE_MB=32 # Larger bloom filter -ORLY_BBOLT_MMAP_SIZE_MB=16384 # 16GB mmap (scales with DB size) -``` - **Migration Between Backends** ```bash -# Migrate from Badger to BBolt -./orly migrate --from badger --to bbolt +# Migrate from Badger to Neo4j +./orly migrate --from badger --to neo4j # Migrate with custom target path -./orly migrate --from badger --to bbolt --target-path /mnt/hdd/orly-archive +./orly migrate --from badger --to neo4j --target-path /mnt/ssd/orly-neo4j ``` -**BBolt vs Badger Trade-offs:** -- BBolt: Lower memory, HDD-friendly, simpler (B+tree), slower random reads -- Badger: Higher memory, SSD-optimized (LSM), faster concurrent access - ## Logging (lol.mleku.dev) ```go @@ -270,7 +253,6 @@ if (isValidNsec(nsec)) { ... } ## Dependencies - `github.com/dgraph-io/badger/v4` - Badger DB (LSM, SSD-optimized) -- `go.etcd.io/bbolt` - BBolt DB (B+tree, HDD-optimized) - `github.com/neo4j/neo4j-go-driver/v5` - Neo4j - `github.com/gorilla/websocket` - WebSocket - `github.com/ebitengine/purego` - CGO-free C loading diff --git a/app/blossom.go b/app/blossom.go index 0d13552..e0150c4 100644 --- a/app/blossom.go +++ b/app/blossom.go @@ -14,7 +14,7 @@ import ( // initializeBlossomServer creates and configures the Blossom blob storage server func initializeBlossomServer( - ctx context.Context, cfg *config.C, db *database.D, + ctx context.Context, cfg *config.C, db database.Database, ) (*blossom.Server, error) { // Create blossom server configuration blossomCfg := &blossom.Config{ diff --git a/app/config/config.go b/app/config/config.go index 7f8f250..f1d0436 100644 --- a/app/config/config.go +++ b/app/config/config.go @@ -116,16 +116,13 @@ type C struct { NIP43InviteExpiry time.Duration `env:"ORLY_NIP43_INVITE_EXPIRY" default:"24h" usage:"how long invite codes remain valid"` // Database configuration - DBType string `env:"ORLY_DB_TYPE" default:"badger" usage:"database backend to use: badger, bbolt, or neo4j"` + DBType string `env:"ORLY_DB_TYPE" default:"badger" usage:"database backend to use: badger, neo4j, or grpc"` QueryCacheDisabled bool `env:"ORLY_QUERY_CACHE_DISABLED" default:"true" usage:"disable query cache to reduce memory usage (trades memory for query performance)"` - // BBolt configuration (only used when ORLY_DB_TYPE=bbolt) - BboltBatchMaxEvents int `env:"ORLY_BBOLT_BATCH_MAX_EVENTS" default:"5000" usage:"max events before flush (tuned for HDD, only used when ORLY_DB_TYPE=bbolt)"` - BboltBatchMaxMB int `env:"ORLY_BBOLT_BATCH_MAX_MB" default:"128" usage:"max batch size in MB before flush (only used when ORLY_DB_TYPE=bbolt)"` - BboltFlushTimeout int `env:"ORLY_BBOLT_FLUSH_TIMEOUT_SEC" default:"30" usage:"max seconds before flush (only used when ORLY_DB_TYPE=bbolt)"` - BboltBloomSizeMB int `env:"ORLY_BBOLT_BLOOM_SIZE_MB" default:"16" usage:"bloom filter size in MB for edge queries (only used when ORLY_DB_TYPE=bbolt)"` - BboltNoSync bool `env:"ORLY_BBOLT_NO_SYNC" default:"false" usage:"disable fsync for performance (DANGEROUS - data loss risk, only used when ORLY_DB_TYPE=bbolt)"` - BboltMmapSizeMB int `env:"ORLY_BBOLT_MMAP_SIZE_MB" default:"8192" usage:"initial mmap size in MB (only used when ORLY_DB_TYPE=bbolt)"` + // gRPC database client settings (only used when ORLY_DB_TYPE=grpc) + GRPCServerAddress string `env:"ORLY_GRPC_SERVER" usage:"address of remote gRPC database server (only used when ORLY_DB_TYPE=grpc)"` + GRPCConnectTimeout time.Duration `env:"ORLY_GRPC_CONNECT_TIMEOUT" default:"10s" usage:"gRPC connection timeout (only used when ORLY_DB_TYPE=grpc)"` + QueryCacheSizeMB int `env:"ORLY_QUERY_CACHE_SIZE_MB" default:"512" usage:"query cache size in MB (caches database query results for faster REQ responses)"` QueryCacheMaxAge string `env:"ORLY_QUERY_CACHE_MAX_AGE" default:"5m" usage:"maximum age for cached query results (e.g., 5m, 10m, 1h)"` @@ -625,7 +622,7 @@ func PrintHelp(cfg *C, printer io.Writer) { orly - ORLY-branded assets Default location: ~/.config/%s/branding - migrate: migrate data between database backends - Example: %s migrate --from badger --to bbolt + Example: %s migrate --from badger --to neo4j - serve: start ephemeral relay with RAM-based storage at /dev/shm/orlyserve listening on 0.0.0.0:10547 with 'none' ACL mode (open relay) useful for testing and benchmarking @@ -790,25 +787,6 @@ func (cfg *C) GetGraphConfigValues() ( cfg.GraphRateLimitRPM } -// GetBboltConfigValues returns the BBolt database configuration values. -// This avoids circular imports with pkg/bbolt while allowing main.go to construct -// the BBolt-specific configuration. -func (cfg *C) GetBboltConfigValues() ( - batchMaxEvents int, - batchMaxBytes int64, - flushTimeoutSec int, - bloomSizeMB int, - noSync bool, - mmapSizeBytes int, -) { - return cfg.BboltBatchMaxEvents, - int64(cfg.BboltBatchMaxMB) * 1024 * 1024, - cfg.BboltFlushTimeout, - cfg.BboltBloomSizeMB, - cfg.BboltNoSync, - cfg.BboltMmapSizeMB * 1024 * 1024 -} - // GetNRCConfigValues returns the NRC (Nostr Relay Connect) configuration values. // This avoids circular imports with pkg/protocol/nrc while allowing main.go to construct // the NRC bridge configuration. @@ -854,3 +832,14 @@ func (cfg *C) GetFollowsThrottleConfigValues() ( cfg.FollowsThrottlePerEvent, cfg.FollowsThrottleMaxDelay } + +// GetGRPCConfigValues returns the gRPC database client configuration values. +// This avoids circular imports with pkg/database/grpc while allowing main.go to construct +// the gRPC client configuration. +func (cfg *C) GetGRPCConfigValues() ( + serverAddress string, + connectTimeout time.Duration, +) { + return cfg.GRPCServerAddress, + cfg.GRPCConnectTimeout +} diff --git a/app/handle-relayinfo.go b/app/handle-relayinfo.go index 2e7abc7..7739fc5 100644 --- a/app/handle-relayinfo.go +++ b/app/handle-relayinfo.go @@ -27,9 +27,10 @@ type GraphQueryConfig struct { // The Addresses field contains alternative WebSocket URLs for the relay (e.g., .onion). type ExtendedRelayInfo struct { *relayinfo.T - Addresses []string `json:"addresses,omitempty"` - GraphQuery *GraphQueryConfig `json:"graph_query,omitempty"` - Theme string `json:"theme,omitempty"` + Addresses []string `json:"addresses,omitempty"` + GraphQuery *GraphQueryConfig `json:"graph_query,omitempty"` + Theme string `json:"theme,omitempty"` + BlossomEnabled bool `json:"blossom_enabled,omitempty"` } // HandleRelayInfo generates and returns a relay information document in JSON @@ -204,17 +205,20 @@ func (s *Server) HandleRelayInfo(w http.ResponseWriter, r *http.Request) { } } - // Return extended info if we have addresses, graph query support, or custom theme + // Return extended info if we have addresses, graph query support, custom theme, or blossom theme := s.Config.Theme if theme != "auto" && theme != "light" && theme != "dark" { theme = "auto" } - if len(addresses) > 0 || graphConfig != nil || theme != "auto" { + // Blossom is only available if the server is actually initialized (requires Badger backend) + blossomEnabled := s.blossomServer != nil + if len(addresses) > 0 || graphConfig != nil || theme != "auto" || blossomEnabled { extInfo := &ExtendedRelayInfo{ - T: info, - Addresses: addresses, - GraphQuery: graphConfig, - Theme: theme, + T: info, + Addresses: addresses, + GraphQuery: graphConfig, + Theme: theme, + BlossomEnabled: blossomEnabled, } if err := json.NewEncoder(w).Encode(extInfo); chk.E(err) { } diff --git a/app/main.go b/app/main.go index 0bde6e2..36f4d59 100644 --- a/app/main.go +++ b/app/main.go @@ -416,11 +416,12 @@ func Run( } } - // Initialize Blossom blob storage server (only for Badger backend) - // MUST be done before UserInterface() which registers routes - if badgerDB, ok := db.(*database.D); ok && cfg.BlossomEnabled { - log.I.F("Badger backend detected, initializing Blossom server...") - if l.blossomServer, err = initializeBlossomServer(ctx, cfg, badgerDB); err != nil { + // Initialize Blossom blob storage server + // Now works with any database backend that implements blob storage methods. + // MUST be done before UserInterface() which registers routes. + if cfg.BlossomEnabled { + log.I.F("initializing Blossom server...") + if l.blossomServer, err = initializeBlossomServer(ctx, cfg, db); err != nil { log.E.F("failed to initialize blossom server: %v", err) // Continue without blossom server } else if l.blossomServer != nil { @@ -428,10 +429,8 @@ func Run( } else { log.W.F("blossom server initialization returned nil without error") } - } else if !cfg.BlossomEnabled { - log.I.F("Blossom server disabled via ORLY_BLOSSOM_ENABLED=false") } else { - log.I.F("Non-Badger backend detected (type: %T), Blossom server not available", db) + log.I.F("Blossom server disabled via ORLY_BLOSSOM_ENABLED=false") } // Initialize WireGuard VPN and NIP-46 Bunker (only for Badger backend) diff --git a/app/web/dist/bundle.js b/app/web/dist/bundle.js index 9c2c460..a54916c 100644 --- a/app/web/dist/bundle.js +++ b/app/web/dist/bundle.js @@ -21,5 +21,5 @@ function Xf(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Arra * hash-wasm (https://www.npmjs.com/package/hash-wasm) * (c) Dani Biro * @license MIT - */function ah(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function l(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,l)}a((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class ch{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then(()=>new Promise(e)),new Promise(t=>{e=t})}dispatch(e){return ah(this,void 0,void 0,function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}}var uh;const dh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,fh=null!==(uh=dh.Buffer)&&void 0!==uh?uh:null,ph=dh.TextEncoder?new dh.TextEncoder:null;function hh(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function gh(e,t){const n=t.length>>1;for(let i=0;i>>4;e[i++]=n>9?n+mh:n+yh,n=15&t[r],e[i++]=n>9?n+mh:n+yh}return String.fromCharCode.apply(null,e)}const wh=null!==fh?e=>{if("string"==typeof e){const t=fh.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(fh.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return ph.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},bh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ah=new Uint8Array(256);for(let e=0;e<64;e++)Ah[bh.charCodeAt(e)]=e;function kh(e,t=!0){const n=e.length,i=n%3,r=[],s=n-i;for(let t=0;t>18&63)+bh.charAt(n>>12&63)+bh.charAt(n>>6&63)+bh.charAt(63&n);r.push(i)}if(1===i){const i=e[n-1],s=bh.charAt(i>>2),o=bh.charAt(i<<4&63);r.push(`${s}${o}`),t&&r.push("==")}else if(2===i){const i=(e[n-2]<<8)+e[n-1],s=bh.charAt(i>>10),o=bh.charAt(i>>4&63),l=bh.charAt(i<<2&63);r.push(`${s}${o}${l}`),t&&r.push("=")}return r.join("")}function Ih(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,i=new Uint8Array(t);let r=0;for(let t=0;t>4,r+=1,i[r]=(15&s)<<4|o>>2,r+=1,i[r]=(3&o)<<6|63&l,r+=1}return i}const Ch=16384,Eh=new ch,xh=new Map;function Sh(e,t){return ah(this,void 0,void 0,function*(){let n=null,i=null,r=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const s=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),o=Eh.dispatch(()=>ah(this,void 0,void 0,function*(){if(!xh.has(e.name)){const t=Ih(e.data),n=WebAssembly.compile(t);xh.set(e.name,n)}const t=yield xh.get(e.name);n=yield WebAssembly.instantiate(t,{})})),l=(e=null)=>{r=!0,n.exports.Hash_Init(e)},a=e=>{if(!r)throw new Error("update() called before init()");(e=>{let t=0;for(;t{if(!r)throw new Error("digest() called before init()");return r=!1,n.exports.Hash_Final(s),"binary"===e?i.slice(0,t):vh(c,i,t)},d=e=>"string"==typeof e?e.length<4096:e.byteLength!0;break;case"blake2b":case"blake2s":f=(e,t)=>t<=512&&d(e);break;case"blake3":f=(e,t)=>0===t&&d(e);break;case"xxhash64":case"xxhash3":case"xxhash128":case"crc64":f=()=>!1}return yield(()=>ah(this,void 0,void 0,function*(){n||(yield o);const e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;i=new Uint8Array(t,e,Ch)}))(),{getMemory:()=>i,writeMemory:(e,t=0)=>{i.set(e,t)},getExports:()=>n.exports,setMemorySize:e=>{n.exports.Hash_SetMemorySize(e);const t=n.exports.Hash_GetBuffer(),r=n.exports.memory.buffer;i=new Uint8Array(r,t,e)},init:l,update:a,digest:u,save:()=>{if(!r)throw new Error("save() can only be called after init() and before digest()");const t=n.exports.Hash_GetState(),i=s(),o=n.exports.memory.buffer,l=new Uint8Array(o,t,i),a=new Uint8Array(4+i);return gh(a,e.hash),a.set(l,4),a},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const i=n.exports.Hash_GetState(),o=s(),l=4+o,a=n.exports.memory.buffer;if(t.length!==l)throw new Error(`Bad state length (expected ${l} bytes, got ${t.length})`);if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n{if(!f(e,r))return l(r),a(e),u("hex",s);const o=wh(e);return i.set(o),n.exports.Hash_Calculate(o.length,r,s),vh(c,i,t)},hashLength:t}})}new ch;var Bh={name:"argon2",data:"AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvEyBVgBAn9BACEBAkAgAEEAKAKICCICRg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDiAQIA4pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAQgECAEKQMAhUIoiSIQNwMAIAMgECADKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAOIBAgDikDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBCAQIAQpAwCFQgGJNwMAC98aAQN/QQAhBEEAIAIpAwAgASkDAIU3A5AIQQAgAikDCCABKQMIhTcDmAhBACACKQMQIAEpAxCFNwOgCEEAIAIpAxggASkDGIU3A6gIQQAgAikDICABKQMghTcDsAhBACACKQMoIAEpAyiFNwO4CEEAIAIpAzAgASkDMIU3A8AIQQAgAikDOCABKQM4hTcDyAhBACACKQNAIAEpA0CFNwPQCEEAIAIpA0ggASkDSIU3A9gIQQAgAikDUCABKQNQhTcD4AhBACACKQNYIAEpA1iFNwPoCEEAIAIpA2AgASkDYIU3A/AIQQAgAikDaCABKQNohTcD+AhBACACKQNwIAEpA3CFNwOACUEAIAIpA3ggASkDeIU3A4gJQQAgAikDgAEgASkDgAGFNwOQCUEAIAIpA4gBIAEpA4gBhTcDmAlBACACKQOQASABKQOQAYU3A6AJQQAgAikDmAEgASkDmAGFNwOoCUEAIAIpA6ABIAEpA6ABhTcDsAlBACACKQOoASABKQOoAYU3A7gJQQAgAikDsAEgASkDsAGFNwPACUEAIAIpA7gBIAEpA7gBhTcDyAlBACACKQPAASABKQPAAYU3A9AJQQAgAikDyAEgASkD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",hash:"e4cdc523"},Qh={name:"blake2b",data:"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",hash:"c6f286e6"};function Fh(e){return!Number.isInteger(e)||e<8||e>512||e%8!=0?new Error("Invalid variant! Valid values: 8, 16, ..., 512"):null}function $h(e=512,t=null){if(Fh(e))return Promise.reject(Fh(e));let n=null,i=e;if(null!==t){if(n=wh(t),n.length>64)return Promise.reject(new Error("Max key length is 64 bytes"));r=e,s=n.length,i=r|s<<16}var r,s;const o=e/8;return Sh(Qh,o).then(e=>{i>512&&e.writeMemory(n),e.init(i);const t={init:i>512?()=>(e.writeMemory(n),e.init(i),t):()=>(e.init(i),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:128,digestSize:o};return t})}new ch;const Dh=new DataView(new ArrayBuffer(4));function Rh(e){return Dh.setInt32(0,e,!0),new Uint8Array(Dh.buffer)}function Ph(e,t,n){return ah(this,void 0,void 0,function*(){if(n<=64){const e=yield $h(8*n);return e.update(Rh(n)),e.update(t),e.digest("binary")}const i=Math.ceil(n/32)-2,r=new Uint8Array(n);e.init(),e.update(Rh(n)),e.update(t);let s=e.digest("binary");r.set(s.subarray(0,32),0);for(let t=1;t{var t;if(!e||"object"!=typeof e)throw new Error("Invalid options parameter. It requires an object.");if(!e.password)throw new Error("Password must be specified");if(e.password=wh(e.password),e.password.length<1)throw new Error("Password must be specified");if(!e.salt)throw new Error("Salt must be specified");if(e.salt=wh(e.salt),e.salt.length<8)throw new Error("Salt should be at least 8 bytes long");if(e.secret=wh(null!==(t=e.secret)&&void 0!==t?t:""),!Number.isInteger(e.iterations)||e.iterations<1)throw new Error("Iterations should be a positive number");if(!Number.isInteger(e.parallelism)||e.parallelism<1)throw new Error("Parallelism should be a positive number");if(!Number.isInteger(e.hashLength)||e.hashLength<4)throw new Error("Hash length should be at least 4 bytes.");if(!Number.isInteger(e.memorySize))throw new Error("Memory size should be specified.");if(e.memorySize<8*e.parallelism)throw new Error("Memory size should be at least 8 * parallelism.");if(void 0===e.outputType&&(e.outputType="hex"),!["hex","binary","encoded"].includes(e.outputType))throw new Error(`Insupported output type ${e.outputType}. Valid values: ['hex', 'binary', 'encoded']`)})(e),Th(Object.assign(Object.assign({},e),{hashType:"id"}))})}new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch;const Nh={parallelism:4,iterations:8,memorySize:262144,hashLength:32,outputType:"binary"};let _h=null,Lh=0;const Mh=new Map;async function Oh(e,t){try{const n=function(){if(_h)return _h;const e=new Blob(["\n importScripts('https://cdn.jsdelivr.net/npm/hash-wasm@4.11.0/dist/argon2.umd.min.js');\n\n const ARGON2_CONFIG = {\n parallelism: 4,\n iterations: 8,\n memorySize: 262144,\n hashLength: 32,\n outputType: \"binary\"\n };\n\n self.onmessage = async function(e) {\n const { password, salt, id } = e.data;\n\n try {\n const result = await hashwasm.argon2id({\n password: password,\n salt: new Uint8Array(salt),\n ...ARGON2_CONFIG\n });\n\n self.postMessage({\n id,\n success: true,\n result: Array.from(result)\n });\n } catch (error) {\n self.postMessage({\n id,\n success: false,\n error: error.message\n });\n }\n };\n "],{type:"application/javascript"});return _h=new Worker(URL.createObjectURL(e)),_h.onmessage=function(e){const{id:t,success:n,result:i,error:r}=e.data,s=Mh.get(t);s&&(Mh.delete(t),n?s.resolve(new Uint8Array(i)):s.reject(new Error(r)))},_h.onerror=function(e){console.error("Argon2 worker error:",e)},_h}(),i=++Lh;return new Promise((r,s)=>{Mh.set(i,{resolve:r,reject:s}),n.postMessage({id:i,password:e,salt:Array.from(t)})})}catch(n){console.warn("Worker failed, falling back to main thread:",n);return await Uh({password:e,salt:t,...Nh})}}const{window:jh}=d;function Hh(e){let t,n,r,s,o,l,a,c,u,d,g,y,v,b,C,E,x,S;function B(e,t){return"extension"===e[2]?qh:Gh}let Q=B(e),$=Q(e),D=e[10]&&ig(e),R=e[11]&&rg(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("h2"),s.textContent="Login to Nostr",o=w(),l=m("button"),l.textContent="×",a=w(),c=m("div"),u=m("div"),d=m("button"),d.textContent="Extension",g=w(),y=m("button"),y.textContent="Nsec",v=w(),b=m("div"),$.c(),C=w(),D&&D.c(),E=w(),R&&R.c(),I(s,"class","svelte-4xpfbi"),I(l,"class","close-btn svelte-4xpfbi"),I(r,"class","modal-header svelte-4xpfbi"),I(d,"class","tab-btn svelte-4xpfbi"),F(d,"active","extension"===e[2]),I(y,"class","tab-btn svelte-4xpfbi"),F(y,"active","nsec"===e[2]),I(u,"class","tabs svelte-4xpfbi"),I(b,"class","tab-content svelte-4xpfbi"),I(c,"class","tab-container svelte-4xpfbi"),I(n,"class","modal svelte-4xpfbi"),F(n,"dark-theme",e[1]),I(t,"class","modal-overlay svelte-4xpfbi"),I(t,"role","button"),I(t,"tabindex","0")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),f(c,u),f(u,d),f(u,g),f(u,y),f(c,v),f(c,b),$.m(b,null),f(b,C),D&&D.m(b,null),f(b,E),R&&R.m(b,null),x||(S=[A(l,"click",e[17]),A(d,"click",e[26]),A(y,"click",e[27]),A(n,"click",k(e[24])),A(n,"keydown",k(e[25])),A(t,"click",e[17]),A(t,"keydown",e[32])],x=!0)},p(e,t){4&t[0]&&F(d,"active","extension"===e[2]),4&t[0]&&F(y,"active","nsec"===e[2]),Q===(Q=B(e))&&$?$.p(e,t):($.d(1),$=Q(e),$&&($.c(),$.m(b,C))),e[10]?D?D.p(e,t):(D=ig(e),D.c(),D.m(b,E)):D&&(D.d(1),D=null),e[11]?R?R.p(e,t):(R=rg(e),R.c(),R.m(b,null)):R&&(R.d(1),R=null),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&h(t),$.d(),D&&D.d(),R&&R.d(),x=!1,i(S)}}}function Gh(e){let t;function n(e,t){return e[14]?Kh:Jh}let i=n(e),r=i(e);return{c(){t=m("div"),r.c(),I(t,"class","nsec-login svelte-4xpfbi")},m(e,n){p(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&h(t),r.d()}}}function qh(e){let t,n,i,r,s,o,l,a=e[7]?"Connecting...":"Log in using extension";return{c(){t=m("div"),n=m("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",i=w(),r=m("button"),s=v(a),I(n,"class","svelte-4xpfbi"),I(r,"class","login-extension-btn svelte-4xpfbi"),r.disabled=e[7],I(t,"class","extension-login svelte-4xpfbi")},m(a,c){p(a,t,c),f(t,n),f(t,i),f(t,r),f(r,s),o||(l=A(r,"click",e[21]),o=!0)},p(e,t){128&t[0]&&a!==(a=e[7]?"Connecting...":"Log in using extension")&&E(s,a),128&t[0]&&(r.disabled=e[7])},d(e){e&&h(t),o=!1,l()}}}function Jh(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,S,B,Q,F,$,D,R,P,T=e[8]?"Generating...":"Generate New Key",U=e[12]&&Vh(e),N=e[4]&&Yh(e);function _(e,t){return e[9]?Zh:e[7]?Wh:zh}let L=_(e),M=L(e);return{c(){t=m("p"),t.textContent="Enter your nsec or generate a new one. Optionally\n set a password to encrypt it securely.",n=w(),r=m("button"),s=v(T),l=w(),U&&U.c(),a=w(),c=m("input"),d=w(),g=m("div"),y=m("label"),y.textContent="Encryption Password (optional but recommended):",b=w(),k=m("input"),S=w(),N&&N.c(),B=w(),Q=m("small"),Q.textContent="Password uses Argon2id with ~3 second derivation time for security.",F=w(),$=m("button"),M.c(),I(t,"class","svelte-4xpfbi"),I(r,"class","generate-btn svelte-4xpfbi"),r.disabled=o=e[7]||e[8],I(c,"type","password"),I(c,"placeholder","nsec1..."),c.disabled=u=e[7]||e[9],I(c,"class","nsec-input svelte-4xpfbi"),I(y,"class","svelte-4xpfbi"),I(k,"type","password"),I(k,"placeholder","Enter password (min 8 chars)"),k.disabled=C=e[7]||e[9],I(k,"class","password-input svelte-4xpfbi"),I(Q,"class","password-hint svelte-4xpfbi"),I(g,"class","password-section svelte-4xpfbi"),I($,"class","login-nsec-btn svelte-4xpfbi"),$.disabled=D=e[7]||e[9]||!e[3].trim()},m(i,o){p(i,t,o),p(i,n,o),p(i,r,o),f(r,s),p(i,l,o),U&&U.m(i,o),p(i,a,o),p(i,c,o),x(c,e[3]),p(i,d,o),p(i,g,o),f(g,y),f(g,b),f(g,k),x(k,e[4]),f(g,S),N&&N.m(g,null),f(g,B),f(g,Q),p(i,F,o),p(i,$,o),M.m($,null),R||(P=[A(r,"click",e[20]),A(c,"input",e[29]),A(k,"input",e[30]),A($,"click",e[22])],R=!0)},p(e,t){256&t[0]&&T!==(T=e[8]?"Generating...":"Generate New Key")&&E(s,T),384&t[0]&&o!==(o=e[7]||e[8])&&(r.disabled=o),e[12]?U?U.p(e,t):(U=Vh(e),U.c(),U.m(a.parentNode,a)):U&&(U.d(1),U=null),640&t[0]&&u!==(u=e[7]||e[9])&&(c.disabled=u),8&t[0]&&c.value!==e[3]&&x(c,e[3]),640&t[0]&&C!==(C=e[7]||e[9])&&(k.disabled=C),16&t[0]&&k.value!==e[4]&&x(k,e[4]),e[4]?N?N.p(e,t):(N=Yh(e),N.c(),N.m(g,B)):N&&(N.d(1),N=null),L!==(L=_(e))&&(M.d(1),M=L(e),M&&(M.c(),M.m($,null))),648&t[0]&&D!==(D=e[7]||e[9]||!e[3].trim())&&($.disabled=D)},d(e){e&&h(t),e&&h(n),e&&h(r),e&&h(l),U&&U.d(e),e&&h(a),e&&h(c),e&&h(d),e&&h(g),N&&N.d(),e&&h(F),e&&h($),M.d(),R=!1,i(P)}}}function Kh(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C=e[15]&&Xh(e);function E(e,t){return e[9]?ng:e[7]?tg:eg}let S=E(e),B=S(e);return{c(){t=m("p"),t.textContent="You have a stored encrypted key. Enter your\n password to unlock it.",n=w(),C&&C.c(),r=w(),s=m("input"),l=w(),a=m("button"),B.c(),u=w(),d=m("button"),g=v("Clear stored key & start fresh"),I(t,"class","svelte-4xpfbi"),I(s,"type","password"),I(s,"placeholder","Enter your password"),s.disabled=o=e[7]||e[9],I(s,"class","password-input svelte-4xpfbi"),I(a,"class","login-nsec-btn svelte-4xpfbi"),a.disabled=c=e[7]||e[9]||!e[6],I(d,"class","clear-btn svelte-4xpfbi"),d.disabled=y=e[7]||e[9]},m(i,o){p(i,t,o),p(i,n,o),C&&C.m(i,o),p(i,r,o),p(i,s,o),x(s,e[6]),p(i,l,o),p(i,a,o),B.m(a,null),p(i,u,o),p(i,d,o),f(d,g),b||(k=[A(s,"input",e[28]),A(a,"click",e[18]),A(d,"click",e[16])],b=!0)},p(e,t){e[15]?C?C.p(e,t):(C=Xh(e),C.c(),C.m(r.parentNode,r)):C&&(C.d(1),C=null),640&t[0]&&o!==(o=e[7]||e[9])&&(s.disabled=o),64&t[0]&&s.value!==e[6]&&x(s,e[6]),S!==(S=E(e))&&(B.d(1),B=S(e),B&&(B.c(),B.m(a,null))),704&t[0]&&c!==(c=e[7]||e[9]||!e[6])&&(a.disabled=c),640&t[0]&&y!==(y=e[7]||e[9])&&(d.disabled=y)},d(e){e&&h(t),e&&h(n),C&&C.d(e),e&&h(r),e&&h(s),e&&h(l),e&&h(a),B.d(),e&&h(u),e&&h(d),b=!1,i(k)}}}function Vh(e){let t,n,i,r,s;return{c(){t=m("div"),n=m("label"),n.textContent="Your new public key (npub):",i=w(),r=m("code"),s=v(e[12]),I(n,"class","svelte-4xpfbi"),I(r,"class","npub-display svelte-4xpfbi"),I(t,"class","generated-info svelte-4xpfbi")},m(e,o){p(e,t,o),f(t,n),f(t,i),f(t,r),f(r,s)},p(e,t){4096&t[0]&&E(s,e[12])},d(e){e&&h(t)}}}function Yh(e){let t,n,i,r;return{c(){t=m("input"),I(t,"type","password"),I(t,"placeholder","Confirm password"),t.disabled=n=e[7]||e[9],I(t,"class","password-input svelte-4xpfbi")},m(n,s){p(n,t,s),x(t,e[5]),i||(r=A(t,"input",e[31]),i=!0)},p(e,i){640&i[0]&&n!==(n=e[7]||e[9])&&(t.disabled=n),32&i[0]&&t.value!==e[5]&&x(t,e[5])},d(e){e&&h(t),i=!1,r()}}}function zh(e){let t;return{c(){t=v("Log in with nsec")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Wh(e){let t;return{c(){t=v("Logging in...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Zh(e){let t;return{c(){t=v("Deriving key...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Xh(e){let t,n,i,r,s,o,l,a=e[15].slice(0,16)+"",c=e[15].slice(-8)+"";return{c(){t=m("div"),n=m("label"),n.textContent="Stored public key:",i=w(),r=m("code"),s=v(a),o=v("..."),l=v(c),I(n,"class","svelte-4xpfbi"),I(r,"class","npub-display svelte-4xpfbi"),I(t,"class","stored-info svelte-4xpfbi")},m(e,a){p(e,t,a),f(t,n),f(t,i),f(t,r),f(r,s),f(r,o),f(r,l)},p(e,t){32768&t[0]&&a!==(a=e[15].slice(0,16)+"")&&E(s,a),32768&t[0]&&c!==(c=e[15].slice(-8)+"")&&E(l,c)},d(e){e&&h(t)}}}function eg(e){let t;return{c(){t=v("Unlock")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function tg(e){let t;return{c(){t=v("Unlocking...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function ng(e){let t;return{c(){t=v("Deriving key...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function ig(e){let t,n;return{c(){t=m("div"),n=v(e[10]),I(t,"class","message error-message svelte-4xpfbi")},m(e,i){p(e,t,i),f(t,n)},p(e,t){1024&t[0]&&E(n,e[10])},d(e){e&&h(t)}}}function rg(e){let t,n;return{c(){t=m("div"),n=v(e[11]),I(t,"class","message success-message svelte-4xpfbi")},m(e,i){p(e,t,i),f(t,n)},p(e,t){2048&t[0]&&E(n,e[11])},d(e){e&&h(t)}}}function sg(e){let t,n,i,r,s,o,l,a,c,u,d,g=e[13].toFixed(1)+"";return{c(){t=m("div"),n=m("div"),i=m("div"),r=w(),s=m("h3"),s.textContent="Deriving encryption key",o=w(),l=m("div"),a=v(g),c=v("s"),u=w(),d=m("p"),d.textContent="This may take 3-6 seconds for security",I(i,"class","deriving-spinner svelte-4xpfbi"),I(s,"class","svelte-4xpfbi"),I(l,"class","deriving-timer svelte-4xpfbi"),I(d,"class","deriving-note svelte-4xpfbi"),I(n,"class","deriving-modal svelte-4xpfbi"),F(n,"dark-theme",e[1]),I(t,"class","deriving-overlay svelte-4xpfbi")},m(e,h){p(e,t,h),f(t,n),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),f(l,a),f(l,c),f(n,u),f(n,d)},p(e,t){8192&t[0]&&g!==(g=e[13].toFixed(1)+"")&&E(a,g),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&h(t)}}}function og(t){let n,i,r,s,o=t[0]&&Hh(t),l=t[9]&&sg(t);return{c(){o&&o.c(),n=w(),l&&l.c(),i=b()},m(e,a){o&&o.m(e,a),p(e,n,a),l&&l.m(e,a),p(e,i,a),r||(s=A(jh,"keydown",t[23]),r=!0)},p(e,t){e[0]?o?o.p(e,t):(o=Hh(e),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null),e[9]?l?l.p(e,t):(l=sg(e),l.c(),l.m(i.parentNode,i)):l&&(l.d(1),l=null)},i:e,o:e,d(e){o&&o.d(e),e&&h(n),l&&l.d(e),e&&h(i),r=!1,s()}}}function lg(e,t,n){const i=U();let{showModal:r=!1}=t,{isDarkTheme:s=!1}=t,o="extension",l="",a="",c="",u="",d=!1,f=!1,p=!1,h="",g="",m="",y="",v=0,w=null,b=null;function A(){n(13,v=0),w=performance.now(),k()}function k(){null!==w&&(n(13,v=(performance.now()-w)/1e3),b=requestAnimationFrame(k))}function I(){w=null,b&&(cancelAnimationFrame(b),b=null)}T(()=>{I()});let C=!1,E="";function x(){n(14,C=!!localStorage.getItem("nostr_privkey_encrypted")),n(15,E=localStorage.getItem("nostr_pubkey")||"")}function S(){n(0,r=!1),n(3,l=""),n(4,a=""),n(5,c=""),n(6,u=""),n(10,h=""),n(11,g=""),m="",n(12,y=""),i("close")}function B(e){n(2,o=e),n(10,h=""),n(11,g=""),m="",n(12,y="")}async function Q(){n(7,d=!0),n(10,h=""),n(11,g="");try{if(!l.trim())throw new Error("Please enter your nsec");if(!function(e){if(!e||!e.startsWith("nsec1"))return!1;try{return"nsec"===bu(e).type}catch{return!1}}(l.trim()))throw new Error("Invalid nsec format or checksum");if(a){if(a.length<8)throw new Error("Password must be at least 8 characters");if(a!==c)throw new Error("Passwords do not match")}const e=gf.fromKey(l.trim()),t=await e.getPublicKey();if(localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),a){n(9,p=!0),A();const e=await async function(e,t){if(!e.startsWith("nsec1"))throw new Error("Invalid nsec format - must start with nsec1");try{if("nsec"!==bu(e).type)throw new Error("Invalid nsec - wrong type")}catch(e){throw new Error("Invalid nsec - bech32 checksum failed")}const n=crypto.getRandomValues(new Uint8Array(32)),i=crypto.getRandomValues(new Uint8Array(12)),r=await Oh(t,n),s=await crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!1,["encrypt"]),o=new TextEncoder,l=await crypto.subtle.encrypt({name:"AES-GCM",iv:i},s,o.encode(e)),a=new Uint8Array(n.length+i.length+l.byteLength);return a.set(n,0),a.set(i,n.length),a.set(new Uint8Array(l),n.length+i.length),btoa(String.fromCharCode(...a))}(l.trim(),a);I(),n(9,p=!1),localStorage.setItem("nostr_privkey_encrypted",e),localStorage.removeItem("nostr_privkey")}else localStorage.setItem("nostr_privkey",l.trim()),localStorage.removeItem("nostr_privkey_encrypted"),n(11,g="Successfully logged in with nsec!");i("login",{method:"nsec",pubkey:t,privateKey:l.trim(),signer:e}),setTimeout(()=>{S()},1500)}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}}P(()=>{x()});return e.$$set=e=>{"showModal"in e&&n(0,r=e.showModal),"isDarkTheme"in e&&n(1,s=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty[0]&&r&&x()},[r,s,o,l,a,c,u,d,f,p,h,g,y,v,C,E,function(){localStorage.removeItem("nostr_privkey_encrypted"),localStorage.removeItem("nostr_privkey"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_auth_method"),n(14,C=!1),n(15,E=""),n(6,u=""),n(10,h=""),n(11,g="")},S,async function(){n(7,d=!0),n(9,p=!0),A(),n(10,h=""),n(11,g="");try{if(!u)throw new Error("Please enter your password");const e=localStorage.getItem("nostr_privkey_encrypted");if(!e)throw new Error("No encrypted key found");const t=await async function(e,t){const n=new Uint8Array(atob(e).split("").map(e=>e.charCodeAt(0)));if(n.length<60)throw new Error("Invalid encrypted data - too short");const i=n.slice(0,32),r=n.slice(32,44),s=n.slice(44),o=await Oh(t,i),l=await crypto.subtle.importKey("raw",o,{name:"AES-GCM"},!1,["decrypt"]);let a;try{a=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},l,s)}catch(e){throw new Error("Decryption failed - invalid password or corrupted data")}const c=(new TextDecoder).decode(a);if(!c.startsWith("nsec1"))throw new Error("Decryption produced invalid data - not an nsec");try{if("nsec"!==bu(c).type)throw new Error("Decryption produced invalid nsec type")}catch(e){throw new Error("Decryption produced invalid nsec - bech32 checksum failed")}return c}(e,u);I(),n(9,p=!1);const r=gf.fromKey(t),s=await r.getPublicKey();i("login",{method:"nsec",pubkey:s,privateKey:t,signer:r}),S()}catch(e){I(),e.message.includes("decrypt")||e.message.includes("tag")?n(10,h="Invalid password"):n(10,h=e.message)}finally{n(7,d=!1),n(9,p=!1),I()}},B,async function(){n(8,f=!0),n(10,h=""),n(11,g="");try{const e=tu(),t=Iu("nsec",e),i=ku(nu(e));m=t,n(12,y=i),n(3,l=t),n(11,g="New key generated! Set an encryption password below to secure it.")}catch(e){n(10,h="Failed to generate key: "+e.message)}finally{n(8,f=!1)}},async function(){n(7,d=!0),n(10,h=""),n(11,g="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(11,g="Successfully logged in with extension!"),i("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{S()},1500))}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}},Q,function(e){"Escape"===e.key&&S(),"Enter"===e.key&&"nsec"===o&&Q()},function(t){N.call(this,e,t)},function(t){N.call(this,e,t)},()=>B("extension"),()=>B("nsec"),function(){u=this.value,n(6,u)},function(){l=this.value,n(3,l)},function(){a=this.value,n(4,a)},function(){c=this.value,n(5,c)},e=>"Escape"===e.key&&S()]}class ag extends ae{constructor(e){super(),le(this,e,lg,og,s,{showModal:0,isDarkTheme:1},null,[-1,-1])}}function cg(e,t,n){const i=e.slice();return i[72]=t[n],i}function ug(e,t,n){const i=e.slice();return i[75]=t[n],i}function dg(e,t,n){const i=e.slice();return i[72]=t[n],i}function fg(e,t,n){const i=e.slice();return i[72]=t[n],i}function pg(e,t,n){const i=e.slice();return i[72]=t[n],i}function hg(e,t,n){const i=e.slice();return i[72]=t[n],i}function gg(e,t,n){const i=e.slice();return i[72]=t[n],i}function mg(e){let t,n,i;return{c(){t=m("div"),n=v(e[3]),I(t,"class",i="message "+e[4]+" svelte-1y8wjwc")},m(e,i){p(e,t,i),f(t,n)},p(e,r){8&r[0]&&E(n,e[3]),16&r[0]&&i!==(i="message "+e[4]+" svelte-1y8wjwc")&&I(t,"class",i)},d(e){e&&h(t)}}}function yg(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,E,S,B,Q,F,$,D,R,P,T,U,N,_;function L(e,t){return e[5]&&e[5].length>0?wg:vg}let M=L(e),O=M(e);function j(e,t){return e[8]&&e[8].length>0?Ig:kg}let H=j(e),G=H(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Banned Pubkeys",s=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=v("Ban Pubkey"),y=w(),b=m("div"),O.c(),k=w(),C=m("div"),E=m("h3"),E.textContent="Allowed Pubkeys",S=w(),B=m("div"),Q=m("input"),F=w(),$=m("input"),D=w(),R=m("button"),P=v("Allow Pubkey"),T=w(),U=m("div"),G.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","Pubkey (64 hex chars)"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(E,"class","svelte-1y8wjwc"),I(Q,"type","text"),I(Q,"placeholder","Pubkey (64 hex chars)"),I(Q,"class","svelte-1y8wjwc"),I($,"type","text"),I($,"placeholder","Reason (optional)"),I($,"class","svelte-1y8wjwc"),R.disabled=e[2],I(R,"class","svelte-1y8wjwc"),I(B,"class","add-form svelte-1y8wjwc"),I(U,"class","list svelte-1y8wjwc"),I(C,"class","section svelte-1y8wjwc"),I(t,"class","pubkeys-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[6]),f(o,a),f(o,c),x(c,e[7]),f(o,u),f(o,d),f(d,g),f(n,y),f(n,b),O.m(b,null),f(t,k),f(t,C),f(C,E),f(C,S),f(C,B),f(B,Q),x(Q,e[9]),f(B,F),f(B,$),x($,e[10]),f(B,D),f(B,R),f(R,P),f(C,T),f(C,U),G.m(U,null),N||(_=[A(l,"input",e[43]),A(c,"input",e[44]),A(d,"click",e[25]),A(Q,"input",e[45]),A($,"input",e[46]),A(R,"click",e[26])],N=!0)},p(e,t){64&t[0]&&l.value!==e[6]&&x(l,e[6]),128&t[0]&&c.value!==e[7]&&x(c,e[7]),4&t[0]&&(d.disabled=e[2]),M===(M=L(e))&&O?O.p(e,t):(O.d(1),O=M(e),O&&(O.c(),O.m(b,null))),512&t[0]&&Q.value!==e[9]&&x(Q,e[9]),1024&t[0]&&$.value!==e[10]&&x($,e[10]),4&t[0]&&(R.disabled=e[2]),H===(H=j(e))&&G?G.p(e,t):(G.d(1),G=H(e),G&&(G.c(),G.m(U,null)))},d(e){e&&h(t),O.d(),G.d(),N=!1,i(_)}}}function vg(t){let n;return{c(){n=m("div"),n.innerHTML="

No banned pubkeys configured.

",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function wg(e){let t,n=e[5],i=[];for(let t=0;tNo allowed pubkeys configured.

",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Ig(e){let t,n=e[8],i=[];for(let t=0;t0?Bg:Sg}let M=L(e),O=M(e);let j=function(e){return e[22]&&e[22].length>0?Dg:$g}(e),H=j(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Banned Events",s=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=v("Ban Event"),y=w(),b=m("div"),O.c(),k=w(),C=m("div"),E=m("h3"),E.textContent="Allowed Events",S=w(),B=m("div"),Q=m("input"),F=w(),$=m("input"),D=w(),R=m("button"),P=v("Allow Event"),T=w(),U=m("div"),H.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","Event ID (64 hex chars)"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(E,"class","svelte-1y8wjwc"),I(Q,"type","text"),I(Q,"placeholder","Event ID (64 hex chars)"),I(Q,"class","svelte-1y8wjwc"),I($,"type","text"),I($,"placeholder","Reason (optional)"),I($,"class","svelte-1y8wjwc"),R.disabled=e[2],I(R,"class","svelte-1y8wjwc"),I(B,"class","add-form svelte-1y8wjwc"),I(U,"class","list svelte-1y8wjwc"),I(C,"class","section svelte-1y8wjwc"),I(t,"class","events-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[12]),f(o,a),f(o,c),x(c,e[13]),f(o,u),f(o,d),f(d,g),f(n,y),f(n,b),O.m(b,null),f(t,k),f(t,C),f(C,E),f(C,S),f(C,B),f(B,Q),x(Q,e[14]),f(B,F),f(B,$),x($,e[15]),f(B,D),f(B,R),f(R,P),f(C,T),f(C,U),H.m(U,null),N||(_=[A(l,"input",e[47]),A(c,"input",e[48]),A(d,"click",e[27]),A(Q,"input",e[49]),A($,"input",e[50]),A(R,"click",e[28])],N=!0)},p(e,t){4096&t[0]&&l.value!==e[12]&&x(l,e[12]),8192&t[0]&&c.value!==e[13]&&x(c,e[13]),4&t[0]&&(d.disabled=e[2]),M===(M=L(e))&&O?O.p(e,t):(O.d(1),O=M(e),O&&(O.c(),O.m(b,null))),16384&t[0]&&Q.value!==e[14]&&x(Q,e[14]),32768&t[0]&&$.value!==e[15]&&x($,e[15]),4&t[0]&&(R.disabled=e[2]),H.p(e,t)},d(e){e&&h(t),O.d(),H.d(),N=!1,i(_)}}}function Sg(t){let n;return{c(){n=m("div"),n.innerHTML="

No banned events configured.

",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Bg(e){let t,n=e[11],i=[];for(let t=0;tNo allowed events configured.

",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Dg(e){let t,n=e[22],i=[];for(let t=0;t0?Ug:Tg}let S=E(e),B=S(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Blocked IPs",s=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=v("Block IP"),y=w(),b=m("div"),B.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","IP Address"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","ips-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[17]),f(o,a),f(o,c),x(c,e[18]),f(o,u),f(o,d),f(d,g),f(n,y),f(n,b),B.m(b,null),k||(C=[A(l,"input",e[51]),A(c,"input",e[52]),A(d,"click",e[29])],k=!0)},p(e,t){131072&t[0]&&l.value!==e[17]&&x(l,e[17]),262144&t[0]&&c.value!==e[18]&&x(c,e[18]),4&t[0]&&(d.disabled=e[2]),S===(S=E(e))&&B?B.p(e,t):(B.d(1),B=S(e),B&&(B.c(),B.m(b,null)))},d(e){e&&h(t),B.d(),k=!1,i(C)}}}function Tg(t){let n;return{c(){n=m("div"),n.innerHTML="

No blocked IPs configured.

",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Ug(e){let t,n=e[16],i=[];for(let t=0;t0?Og:Mg}let E=k(e),S=E(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Allowed Event Kinds",s=w(),o=m("div"),l=m("input"),a=w(),c=m("button"),u=v("Allow Kind"),d=w(),g=m("div"),S.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","number"),I(l,"placeholder","Kind number"),I(l,"class","svelte-1y8wjwc"),c.disabled=e[2],I(c,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(g,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","kinds-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[20]),f(o,a),f(o,c),f(c,u),f(n,d),f(n,g),S.m(g,null),y||(b=[A(l,"input",e[53]),A(c,"click",e[30])],y=!0)},p(e,t){1048576&t[0]&&C(l.value)!==e[20]&&x(l,e[20]),4&t[0]&&(c.disabled=e[2]),E===(E=k(e))&&S?S.p(e,t):(S.d(1),S=E(e),S&&(S.c(),S.m(g,null)))},d(e){e&&h(t),S.d(),y=!1,i(b)}}}function Mg(t){let n;return{c(){n=m("div"),n.innerHTML="

No allowed kinds configured. All kinds are\n allowed by default.

",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Og(e){let t,n=e[19],i=[];for(let t=0;t0?qg:Gg}let g=d(e),y=g(e);return{c(){t=m("div"),n=m("div"),i=m("h3"),i.textContent="Events Needing Moderation",r=w(),s=m("button"),o=v("Refresh"),l=w(),a=m("div"),y.c(),I(i,"class","svelte-1y8wjwc"),s.disabled=e[2],I(a,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","moderation-section")},m(d,h){p(d,t,h),f(t,n),f(n,i),f(n,r),f(n,s),f(s,o),f(n,l),f(n,a),y.m(a,null),c||(u=A(s,"click",e[24]),c=!0)},p(e,t){4&t[0]&&(s.disabled=e[2]),g===(g=d(e))&&y?y.p(e,t):(y.d(1),y=g(e),y&&(y.c(),y.m(a,null)))},d(e){e&&h(t),y.d(),c=!1,u()}}}function Gg(t){let n;return{c(){n=m("div"),n.innerHTML="

No events need moderation at this time.

",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function qg(e){let t,n=e[21],i=[];for(let t=0;tManaged ACL Configuration \n

Configure access control using NIP-86 management API

\n
Owner Only: This interface is restricted to relay owners\n only.
',s=w(),V&&V.c(),o=w(),l=m("div"),a=m("button"),c=v("Pubkeys"),d=w(),g=m("button"),y=v("Events"),k=w(),C=m("button"),E=v("IPs"),S=w(),B=m("button"),Q=v("Kinds"),$=w(),D=m("button"),R=v("Moderation"),T=w(),U=m("button"),N=v("Relay Config"),L=w(),M=m("div"),Y&&Y.c(),O=w(),z&&z.c(),j=w(),W&&W.c(),H=w(),Z&&Z.c(),G=w(),X&&X.c(),q=w(),ee&&ee.c(),I(r,"class","header svelte-1y8wjwc"),I(a,"class",u="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1y8wjwc"),I(g,"class",b="tab "+("events"===t[1]?"active":"")+" svelte-1y8wjwc"),I(C,"class",x="tab "+("ips"===t[1]?"active":"")+" svelte-1y8wjwc"),I(B,"class",F="tab "+("kinds"===t[1]?"active":"")+" svelte-1y8wjwc"),I(D,"class",P="tab "+("moderation"===t[1]?"active":"")+" svelte-1y8wjwc"),I(U,"class",_="tab "+("relay"===t[1]?"active":"")+" svelte-1y8wjwc"),I(l,"class","tabs svelte-1y8wjwc"),I(M,"class","tab-content svelte-1y8wjwc")},m(e,i){p(e,n,i),f(n,r),f(n,s),V&&V.m(n,null),f(n,o),f(n,l),f(l,a),f(a,c),f(l,d),f(l,g),f(g,y),f(l,k),f(l,C),f(C,E),f(l,S),f(l,B),f(B,Q),f(l,$),f(l,D),f(D,R),f(l,T),f(l,U),f(U,N),f(n,L),f(n,M),Y&&Y.m(M,null),f(M,O),z&&z.m(M,null),f(M,j),W&&W.m(M,null),f(M,H),Z&&Z.m(M,null),f(M,G),X&&X.m(M,null),f(M,q),ee&&ee.m(M,null),J||(K=[A(a,"click",t[37]),A(g,"click",t[38]),A(C,"click",t[39]),A(B,"click",t[40]),A(D,"click",t[41]),A(U,"click",t[42])],J=!0)},p(e,t){e[3]?V?V.p(e,t):(V=mg(e),V.c(),V.m(n,o)):V&&(V.d(1),V=null),2&t[0]&&u!==(u="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(a,"class",u),2&t[0]&&b!==(b="tab "+("events"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(g,"class",b),2&t[0]&&x!==(x="tab "+("ips"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(C,"class",x),2&t[0]&&F!==(F="tab "+("kinds"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(B,"class",F),2&t[0]&&P!==(P="tab "+("moderation"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(D,"class",P),2&t[0]&&_!==(_="tab "+("relay"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(U,"class",_),"pubkeys"===e[1]?Y?Y.p(e,t):(Y=yg(e),Y.c(),Y.m(M,O)):Y&&(Y.d(1),Y=null),"events"===e[1]?z?z.p(e,t):(z=xg(e),z.c(),z.m(M,j)):z&&(z.d(1),z=null),"ips"===e[1]?W?W.p(e,t):(W=Pg(e),W.c(),W.m(M,H)):W&&(W.d(1),W=null),"kinds"===e[1]?Z?Z.p(e,t):(Z=Lg(e),Z.c(),Z.m(M,G)):Z&&(Z.d(1),Z=null),"moderation"===e[1]?X?X.p(e,t):(X=Hg(e),X.c(),X.m(M,q)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=Vg(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&h(n),V&&V.d(),Y&&Y.d(),z&&z.d(),W&&W.d(),Z&&Z.d(),X&&X.d(),ee&&ee.d(),J=!1,i(K)}}}function Zg(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="pubkeys",o=!1,l="",a="info",c=[],u="",d="",f=[],p="",h="",g=[],m="",y="",v="",w="",b=[],A="",k="",I=[],E="",x=[],S={relay_name:"",relay_description:"",relay_icon:""};async function B(){try{n(2,o=!0),console.log("Fetching relay info from /");const e=await fetch(xp()+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,S={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",S),console.log("Loaded relay info:",t),n(3,l="Relay configuration loaded successfully"),n(4,a="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,l=`Failed to fetch relay info: ${e.status}`),n(4,a="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,l=`Failed to fetch relay info: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}}async function Q(e,t=[]){try{n(2,o=!0),n(3,l="");const s={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available for authentication.");const n=xp()+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s),l=JSON.stringify(o);return`Nostr ${btoa(l)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(s)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,l=e.message),n(4,a="error"),e}finally{n(2,o=!1)}}async function F(){try{n(5,c=await Q("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function $(){try{n(8,f=await Q("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function D(){try{n(11,g=await Q("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function R(){try{n(16,b=await Q("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function T(){try{n(19,I=await Q("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function U(){try{n(2,o=!0),n(21,x=await Q("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",x)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,l=`Failed to load moderation events: ${e.message}`),n(4,a="error"),n(21,x=[])}finally{n(2,o=!1)}}async function N(e){try{await Q("disallowkind",[e]),n(3,l="Kind disallowed successfully"),n(4,a="success"),await T()}catch(e){console.error("Failed to disallow kind:",e)}}async function _(e){try{await Q("allowevent",[e,"Approved from moderation queue"]),n(3,l="Event allowed successfully"),n(4,a="success"),await U()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function L(e){try{await Q("banevent",[e,"Banned from moderation queue"]),n(3,l="Event banned successfully"),n(4,a="success"),await U()}catch(e){console.error("Failed to ban event from moderation:",e)}}P(()=>{setTimeout(()=>{B()},100)}),async function(){await Promise.all([F(),$(),D(),R(),T()])}();return e.$$set=e=>{"userSigner"in e&&n(35,i=e.userSigner),"userPubkey"in e&&n(36,r=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",S)},[S,s,o,l,a,c,u,d,f,p,h,g,m,y,v,w,b,A,k,I,E,x,[],B,U,async function(){if(u)try{await Q("banpubkey",[u,d]),n(3,l="Pubkey banned successfully"),n(4,a="success"),n(6,u=""),n(7,d=""),await F()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(p)try{await Q("allowpubkey",[p,h]),n(3,l="Pubkey allowed successfully"),n(4,a="success"),n(9,p=""),n(10,h=""),await $()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await Q("banevent",[m,y]),n(3,l="Event banned successfully"),n(4,a="success"),n(12,m=""),n(13,y=""),await D()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(v)try{await Q("allowevent",[v,w]),n(3,l="Event allowed successfully"),n(4,a="success"),n(14,v=""),n(15,w="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(A)try{await Q("blockip",[A,k]),n(3,l="IP blocked successfully"),n(4,a="success"),n(17,A=""),n(18,k=""),await R()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!E)return;const e=parseInt(E);if(isNaN(e))return n(3,l="Invalid kind number"),void n(4,a="error");try{await Q("allowkind",[e]),n(3,l="Kind allowed successfully"),n(4,a="success"),n(20,E=""),await T()}catch(e){console.error("Failed to allow kind:",e)}},N,async function(){try{n(2,o=!0),n(3,l="");const e=[];if(S.relay_name&&e.push(Q("changerelayname",[S.relay_name])),S.relay_description&&e.push(Q("changerelaydescription",[S.relay_description])),S.relay_icon&&e.push(Q("changerelayicon",[S.relay_icon])),0===e.length)return n(3,l="No changes to update"),void n(4,a="info");await Promise.all(e),n(3,l="Relay configuration updated successfully"),n(4,a="success"),await B()}catch(e){console.error("Failed to update relay configuration:",e),n(3,l=`Failed to update relay configuration: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}},_,L,i,r,()=>n(1,s="pubkeys"),()=>n(1,s="events"),()=>n(1,s="ips"),()=>n(1,s="kinds"),()=>{n(1,s="moderation"),x&&0!==x.length||U()},()=>n(1,s="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){p=this.value,n(9,p)},function(){h=this.value,n(10,h)},function(){m=this.value,n(12,m)},function(){y=this.value,n(13,y)},function(){v=this.value,n(14,v)},function(){w=this.value,n(15,w)},function(){A=this.value,n(17,A)},function(){k=this.value,n(18,k)},function(){E=C(this.value),n(20,E)},e=>N(e),e=>_(e.id),e=>L(e.id),function(){S.relay_name=this.value,n(0,S)},function(){S.relay_description=this.value,n(0,S)},function(){S.relay_icon=this.value,n(0,S)}]}class Xg extends ae{constructor(e){super(),le(this,e,Zg,Wg,s,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}function em(e,t,n){const i=e.slice();return i[28]=t[n],i}function tm(e){let t,n;return{c(){t=m("span"),n=v(e[3]),I(t,"class","permission-badge svelte-e0nvq8")},m(e,i){p(e,t,i),f(t,n)},p(e,t){8&t&&E(n,e[3])},d(e){e&&h(t)}}}function nm(e){let t,n,i,r,s,o;return{c(){t=m("div"),n=m("span"),i=w(),r=m("span"),s=v(e[9]),I(n,"class","relay-status svelte-e0nvq8"),F(n,"connected","connected"===e[10]),F(n,"error","error"===e[10]),I(r,"class","relay-name svelte-e0nvq8"),I(t,"class","relay-indicator static svelte-e0nvq8"),I(t,"title",o="Connected to "+e[9])},m(e,o){p(e,t,o),f(t,n),f(t,i),f(t,r),f(r,s)},p(e,i){1024&i&&F(n,"connected","connected"===e[10]),1024&i&&F(n,"error","error"===e[10]),512&i&&E(s,e[9]),512&i&&o!==(o="Connected to "+e[9])&&I(t,"title",o)},d(e){e&&h(t)}}}function im(e){let t,n,i,r,s,o,l,a,c,u,d,g=e[6]&&rm(e);return{c(){t=m("button"),n=m("span"),i=w(),r=m("span"),s=v(e[9]),o=w(),l=m("span"),l.textContent="▾",a=w(),g&&g.c(),c=b(),I(n,"class","relay-status svelte-e0nvq8"),F(n,"connected","connected"===e[10]),F(n,"error","error"===e[10]),I(r,"class","relay-name svelte-e0nvq8"),I(l,"class","dropdown-arrow svelte-e0nvq8"),F(l,"open",e[6]),I(t,"class","relay-indicator svelte-e0nvq8"),I(t,"title","Click to switch relays")},m(h,m){p(h,t,m),f(t,n),f(t,i),f(t,r),f(r,s),f(t,o),f(t,l),p(h,a,m),g&&g.m(h,m),p(h,c,m),u||(d=A(t,"click",e[16]),u=!0)},p(e,t){1024&t&&F(n,"connected","connected"===e[10]),1024&t&&F(n,"error","error"===e[10]),512&t&&E(s,e[9]),64&t&&F(l,"open",e[6]),e[6]?g?g.p(e,t):(g=rm(e),g.c(),g.m(c.parentNode,c)):g&&(g.d(1),g=null)},d(e){e&&h(t),e&&h(a),g&&g.d(e),e&&h(c),u=!1,d()}}}function rm(e){let t,n,r,s,o,l=e[12].length>0&&sm(e);return{c(){t=m("div"),l&&l.c(),n=w(),r=m("button"),r.textContent="Manage Relays...",I(r,"class","dropdown-item manage-btn svelte-e0nvq8"),I(t,"class","relay-dropdown svelte-e0nvq8")},m(i,a){p(i,t,a),l&&l.m(t,null),f(t,n),f(t,r),s||(o=[A(r,"click",e[18]),A(t,"click",k(e[22]))],s=!0)},p(e,i){e[12].length>0?l?l.p(e,i):(l=sm(e),l.c(),l.m(t,n)):l&&(l.d(1),l=null)},d(e){e&&h(t),l&&l.d(),s=!1,i(o)}}}function sm(e){let t,n,i,r,s,o=e[12],l=[];for(let t=0;t',o=w(),a=m("img"),u=w(),d=m("div"),g=m("span"),y=v("ORLY? dashboard\n "),B&&B.c(),b=w(),k=m("div"),D.c(),C=w(),E=m("div"),T.c(),I(s,"class","mobile-menu-btn svelte-e0nvq8"),I(s,"aria-label","Toggle menu"),l(a.src,c="/orly.png")||I(a,"src","/orly.png"),I(a,"alt","ORLY Logo"),I(a,"class","logo svelte-e0nvq8"),I(g,"class","app-title svelte-e0nvq8"),I(d,"class","header-title svelte-e0nvq8"),I(k,"class","relay-dropdown-container svelte-e0nvq8"),I(E,"class","header-buttons svelte-e0nvq8"),I(r,"class","header-content svelte-e0nvq8"),I(n,"class","main-header svelte-e0nvq8"),F(n,"dark-theme",t[0])},m(e,i){p(e,n,i),f(n,r),f(r,s),f(r,o),f(r,a),f(r,u),f(r,d),f(d,g),f(g,y),B&&B.m(g,null),f(r,b),f(r,k),D.m(k,null),f(r,C),f(r,E),T.m(E,null),x||(S=[A(window,"click",t[19]),A(s,"click",t[14])],x=!0)},p(e,[t]){e[1]&&e[2]?B?B.p(e,t):(B=tm(e),B.c(),B.m(g,null)):B&&(B.d(1),B=null),$===($=Q(e))&&D?D.p(e,t):(D.d(1),D=$(e),D&&(D.c(),D.m(k,null))),P===(P=R(e))&&T?T.p(e,t):(T.d(1),T=P(e),T&&(T.c(),T.m(E,null))),1&t&&F(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&h(n),B&&B.d(),D.d(),T.d(),x=!1,i(S)}}}function pm(e,t,n){let i,r,s,o,l;u(e,wp,e=>n(10,r=e)),u(e,mp,e=>n(21,s=e)),u(e,yp,e=>n(11,o=e)),u(e,kp,e=>n(12,l=e));let{isDarkTheme:a=!1}=t,{isLoggedIn:c=!1}=t,{userRole:d=""}=t,{currentEffectiveRole:f=""}=t,{userProfile:p=null}=t,{userPubkey:h=""}=t;const g=U();let m=!1,y=!1,v="";function w(){n(6,m=!1)}async function b(e){if(console.log("[Header] switchToRelay called with:",e),y||e===s)console.log("[Header] Skipping - already connecting or same relay");else{n(7,y=!0),n(8,v=e);try{console.log("[Header] Calling connectToRelay...");const t=await Fp(e);if(console.log("[Header] connectToRelay result:",t),t.success){Ip(e,Dp(e)),g("relayChanged",{info:t.info}),w()}else console.log("[Header] Connection failed:",t.error)}catch(e){console.error("[Header] Failed to switch relay:",e)}finally{n(7,y=!1),n(8,v="")}}}return e.$$set=e=>{"isDarkTheme"in e&&n(0,a=e.isDarkTheme),"isLoggedIn"in e&&n(1,c=e.isLoggedIn),"userRole"in e&&n(2,d=e.userRole),"currentEffectiveRole"in e&&n(3,f=e.currentEffectiveRole),"userProfile"in e&&n(4,p=e.userProfile),"userPubkey"in e&&n(5,h=e.userPubkey)},e.$$.update=()=>{2097152&e.$$.dirty&&n(9,i=function(e){try{const t=e||xp();return console.log("[Header] getRelayHost - storeUrl:",e,"resolved url:",t),new URL(t).host}catch{return e||"local"}}(s))},[a,c,d,f,p,h,m,y,v,i,r,o,l,function(){g("openSettingsDrawer")},function(){g("toggleMobileMenu")},function(){g("openLoginModal")},function(e){e.stopPropagation(),n(6,m=!m)},b,function(e){e.stopPropagation(),w(),g("openRelayModal")},function(e){m&&w()},function(e){return s===e&&"connected"===r},s,function(t){N.call(this,e,t)},e=>b(e.url)]}class hm extends ae{constructor(e){super(),le(this,e,pm,fm,s,{isDarkTheme:0,isLoggedIn:1,userRole:2,currentEffectiveRole:3,userProfile:4,userPubkey:5})}}function gm(e,t,n){const i=e.slice();return i[12]=t[n],i}function mm(t){let n,i,r;return{c(){n=m("div"),I(n,"class","mobile-overlay svelte-1uja393")},m(e,s){p(e,n,s),i||(r=A(n,"click",t[7]),i=!0)},p:e,d(e){e&&h(n),i=!1,r()}}}function ym(e){let t,n,r;function s(){return e[8](e[12])}function o(...t){return e[9](e[12],...t)}return{c(){t=m("span"),t.textContent="✕",I(t,"class","tab-close-icon svelte-1uja393"),I(t,"role","button"),I(t,"tabindex","0")},m(e,i){p(e,t,i),n||(r=[A(t,"click",k(s)),A(t,"keydown",o)],n=!0)},p(t,n){e=t},d(e){e&&h(t),n=!1,i(r)}}}function vm(e){let t,n,i,r,s,o,l,a,c,u,d=e[12].icon+"",g=e[12].label+"",y=e[12].isSearchTab&&ym(e);function b(){return e[10](e[12])}return{c(){t=m("button"),n=m("span"),i=v(d),r=w(),s=m("span"),o=v(g),l=w(),y&&y.c(),a=w(),I(n,"class","tab-icon svelte-1uja393"),I(s,"class","tab-label svelte-1uja393"),I(t,"class","tab svelte-1uja393"),F(t,"active",e[2]===e[12].id)},m(e,d){p(e,t,d),f(t,n),f(n,i),f(t,r),f(t,s),f(s,o),f(t,l),y&&y.m(t,null),f(t,a),c||(u=A(t,"click",b),c=!0)},p(n,r){e=n,2&r&&d!==(d=e[12].icon+"")&&E(i,d),2&r&&g!==(g=e[12].label+"")&&E(o,g),e[12].isSearchTab?y?y.p(e,r):(y=ym(e),y.c(),y.m(t,a)):y&&(y.d(1),y=null),6&r&&F(t,"active",e[2]===e[12].id)},d(e){e&&h(t),y&&y.d(),c=!1,u()}}}function wm(e){let t,n,i,r,s,o,l,a;return{c(){t=m("a"),n=y("svg"),i=y("path"),r=y("path"),s=w(),o=m("span"),l=v("v"),a=v(e[3]),I(i,"d","M5 6h12v2h1.5c1.38 0 2.5 1.12 2.5 2.5v1c0 1.38-1.12 2.5-2.5 2.5H17v1c0 1.66-1.34 3-3 3H8c-1.66 0-3-1.34-3-3V6zm12 6h1.5c.28 0 .5-.22.5-.5v-1c0-.28-.22-.5-.5-.5H17v2z"),I(r,"d","M9 9c1.5 0 3 .5 3 2.5S10.5 14 9 14c0-1.5.5-3.5 2-4.5"),I(r,"stroke","currentColor"),I(r,"stroke-width","1"),I(r,"fill","none"),I(n,"class","version-icon svelte-1uja393"),I(n,"viewBox","0 0 24 24"),I(n,"fill","currentColor"),I(n,"xmlns","http://www.w3.org/2000/svg"),I(o,"class","version-text svelte-1uja393"),I(t,"href","https://next.orly.dev"),I(t,"target","_blank"),I(t,"rel","noopener noreferrer"),I(t,"class","version-link svelte-1uja393")},m(e,c){p(e,t,c),f(t,n),f(n,i),f(n,r),f(t,s),f(t,o),f(o,l),f(o,a)},p(e,t){8&t&&E(a,e[3])},d(e){e&&h(t)}}}function bm(t){let n,i,r,s,o,l=t[4]&&mm(t),a=t[1],c=[];for(let e=0;e{"isDarkTheme"in e&&n(0,i=e.isDarkTheme),"tabs"in e&&n(1,r=e.tabs),"selectedTab"in e&&n(2,s=e.selectedTab),"version"in e&&n(3,o=e.version),"mobileOpen"in e&&n(4,l=e.mobileOpen)},[i,r,s,o,l,c,u,function(){a("closeMobileMenu")},e=>u(e.id),(e,t)=>"Enter"===t.key&&u(e.id),e=>c(e.id)]}class km extends ae{constructor(e){super(),le(this,e,Am,bm,s,{isDarkTheme:0,tabs:1,selectedTab:2,version:3,mobileOpen:4})}}function Im(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access export functionality.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-jzrdtj"),I(s,"class","login-btn svelte-jzrdtj"),I(n,"class","login-prompt svelte-jzrdtj")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[5]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function Cm(e){let t,n,i=e[0]&&Em(e),r=e[1]&&xm(e);return{c(){i&&i.c(),t=w(),r&&r.c(),n=b()},m(e,s){i&&i.m(e,s),p(e,t,s),r&&r.m(e,s),p(e,n,s)},p(e,s){e[0]?i?i.p(e,s):(i=Em(e),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null),e[1]?r?r.p(e,s):(r=xm(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},d(e){i&&i.d(e),e&&h(t),r&&r.d(e),e&&h(n)}}}function Em(t){let n,i,r,s,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Export My Events",r=w(),s=m("p"),s.textContent="Download your personal events as a JSONL file.",o=w(),l=m("button"),l.textContent="📤 Export My Events",I(i,"class","svelte-jzrdtj"),I(s,"class","svelte-jzrdtj"),I(l,"class","export-btn svelte-jzrdtj"),I(n,"class","export-section svelte-jzrdtj")},m(e,u){p(e,n,u),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),a||(c=A(l,"click",t[3]),a=!0)},p:e,d(e){e&&h(n),a=!1,c()}}}function xm(t){let n,i,r,s,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Export All Events",r=w(),s=m("p"),s.textContent="Download the complete database as a JSONL file. This includes\n all events from all users.",o=w(),l=m("button"),l.textContent="📤 Export All Events",I(i,"class","svelte-jzrdtj"),I(s,"class","svelte-jzrdtj"),I(l,"class","export-btn svelte-jzrdtj"),I(n,"class","export-section svelte-jzrdtj")},m(e,u){p(e,n,u),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),a||(c=A(l,"click",t[4]),a=!0)},p:e,d(e){e&&h(n),a=!1,c()}}}function Sm(t){let n;function i(e,t){return e[2]?Cm:Im}let r=i(t),s=r(t);return{c(){s.c(),n=b()},m(e,t){s.m(e,t),p(e,n,t)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&h(n)}}}function Bm(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{currentEffectiveRole:o=""}=t,{aclMode:l=""}=t;const a=U();return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"currentEffectiveRole"in e&&n(6,o=e.currentEffectiveRole),"aclMode"in e&&n(7,l=e.aclMode)},e.$$.update=()=>{129&e.$$.dirty&&n(2,i="none"===l||s),192&e.$$.dirty&&n(1,r="none"===l||"admin"===o||"owner"===o)},[s,r,i,function(){a("exportMyEvents")},function(){a("exportAllEvents")},function(){a("openLoginModal")},o,l]}class Qm extends ae{constructor(e){super(),le(this,e,Bm,Sm,s,{isLoggedIn:0,currentEffectiveRole:6,aclMode:7})}}function Fm(t){let n,i,r,s,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Import Events",r=w(),s=m("p"),s.textContent="Please log in to access import functionality.",o=w(),l=m("button"),l.textContent="Log In",I(i,"class","recovery-header svelte-nonyqh"),I(s,"class","recovery-description svelte-nonyqh"),I(l,"class","login-btn svelte-nonyqh"),I(n,"class","login-prompt svelte-nonyqh")},m(e,u){p(e,n,u),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),a||(c=A(l,"click",t[6]),a=!0)},p:e,d(e){e&&h(n),a=!1,c()}}}function $m(t){let n;return{c(){n=m("div"),n.innerHTML='

Import Events

\n

Admin or owner permission required for import functionality.

',I(n,"class","permission-denied svelte-nonyqh")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Dm(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C=e[2]&&Rm(e);return{c(){t=m("h3"),t.textContent="Import Events",n=w(),r=m("p"),r.textContent="Upload a JSONL file to import events into the database.",s=w(),o=m("div"),l=m("input"),a=w(),c=m("div"),u=m("button"),d=v("Import Events"),y=w(),C&&C.c(),I(t,"class","svelte-nonyqh"),I(r,"class","svelte-nonyqh"),I(l,"type","file"),I(l,"id","import-file"),I(l,"accept",".jsonl,.txt"),I(l,"class","svelte-nonyqh"),I(u,"class","import-btn svelte-nonyqh"),u.disabled=g=!e[1]||"Uploading..."===e[2],I(c,"class","import-row svelte-nonyqh"),I(o,"class","recovery-controls-card svelte-nonyqh")},m(i,h){p(i,t,h),p(i,n,h),p(i,r,h),p(i,s,h),p(i,o,h),f(o,l),f(o,a),f(o,c),f(c,u),f(u,d),f(c,y),C&&C.m(c,null),b||(k=[A(l,"change",e[4]),A(u,"click",e[5])],b=!0)},p(e,t){6&t&&g!==(g=!e[1]||"Uploading..."===e[2])&&(u.disabled=g),e[2]?C?C.p(e,t):(C=Rm(e),C.c(),C.m(c,null)):C&&(C.d(1),C=null)},d(e){e&&h(t),e&&h(n),e&&h(r),e&&h(s),e&&h(o),C&&C.d(),b=!1,i(k)}}}function Rm(e){let t,n;return{c(){t=m("span"),n=v(e[2]),I(t,"class","import-message svelte-nonyqh"),F(t,"uploading","Uploading..."===e[2]),F(t,"success","Upload complete"===e[2]),F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},m(e,i){p(e,t,i),f(t,n)},p(e,i){4&i&&E(n,e[2]),4&i&&F(t,"uploading","Uploading..."===e[2]),4&i&&F(t,"success","Upload complete"===e[2]),4&i&&F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},d(e){e&&h(t)}}}function Pm(t){let n;function i(e,t){return e[3]?Dm:e[0]?$m:Fm}let r=i(t),s=r(t);return{c(){n=m("div"),s.c(),I(n,"class","import-section svelte-nonyqh")},m(e,t){p(e,n,t),s.m(n,null)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&h(n),s.d()}}}function Tm(e,t,n){let i,{isLoggedIn:r=!1}=t,{currentEffectiveRole:s=""}=t,{selectedFile:o=null}=t,{aclMode:l=""}=t,{importMessage:a=""}=t;const c=U();return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,s=e.currentEffectiveRole),"selectedFile"in e&&n(1,o=e.selectedFile),"aclMode"in e&&n(8,l=e.aclMode),"importMessage"in e&&n(2,a=e.importMessage)},e.$$.update=()=>{385&e.$$.dirty&&n(3,i="none"===l||r&&("admin"===s||"owner"===s))},[r,o,a,i,function(e){c("fileSelect",e)},function(){c("importEvents")},function(){c("openLoginModal")},s,l]}class Um extends ae{constructor(e){super(),le(this,e,Tm,Pm,s,{isLoggedIn:0,currentEffectiveRole:7,selectedFile:1,aclMode:8,importMessage:2})}}const Nm={0:"Profile Metadata",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete Request",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1063:"File Metadata",1311:"Live Chat Message",1984:"Reporting",1985:"Label",9734:"Zap Request",9735:"Zap Receipt",1e4:"Mute List",10001:"Pin List",10002:"Relay List Metadata",10003:"Bookmark List",10004:"Communities List",10005:"Public Chats List",10006:"Blocked Relays List",10007:"Search Relays List",10009:"User Groups",10015:"Interests List",10030:"User Emoji List",13194:"Wallet Info",22242:"Client Auth",23194:"Wallet Request",23195:"Wallet Response",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People List",30001:"Categorized Bookmarks",30002:"Categorized Relay List",30003:"Bookmark Sets",30004:"Curation Sets",30005:"Video Sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest Sets",30017:"Create/Update Stall",30018:"Create/Update Product",30019:"Marketplace UI/UX",30020:"Product Sold As Auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji Sets",30063:"Release Artifact Sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30388:"Slide Set",30402:"Classified Listing",30403:"Draft Classified Listing",30617:"Repository Announcement",30618:"Repository State Announcement",30818:"Wiki Article",30819:"Redirects",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler Recommendation",31990:"Handler Information",34550:"Community Definition",34551:"Community Post Approval"};function _m(e,t=null){if(!e||"string"!=typeof e)return!1;return!!/^[0-9a-fA-F]+$/.test(e)&&(!t||e.length===t)}function Lm(e){const t=new Date(1e3*e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Mm(e){return Math.floor(new Date(e).getTime()/1e3)}function Om(e,t,n){const i=e.slice();return i[62]=t[n],i[64]=n,i}function jm(e,t,n){const i=e.slice();return i[65]=t[n],i}function Hm(e,t,n){const i=e.slice();return i[68]=t[n],i}function Gm(e,t,n){const i=e.slice();return i[71]=t[n],i}function qm(e,t,n){const i=e.slice();return i[71]=t[n].kind,i[74]=t[n].name,i}function Jm(e){let t,n,i,r,s,o,l=e[20],a=[];for(let t=0;t0&&Vm(t),Ge=t[17]&&zm(t),qe=t[2].length>0&&Wm(t),Je=t[18]&&Xm(t),Ke=t[3].length>0&&ey(t),Ve=t[19]&&ny(t),Ye=t[4].length>0&&iy(t),ze=t[5]&&sy(t),We=t[6]&&oy(t),Ze=t[8]&&ly(t);return{c(){n=m("div"),r=m("div"),s=m("div"),o=m("label"),o.textContent="Search Text (NIP-50)",l=w(),a=m("div"),c=m("input"),u=w(),d=m("label"),d.textContent="Event Kinds",g=w(),y=m("div"),b=m("button"),k=v(Me),S=v(" Select Kinds ("),B=v(Oe),Q=v(" selected)"),$=w(),je&&je.c(),D=w(),He&&He.c(),R=w(),P=m("label"),P.textContent="Authors (Pubkeys)",T=w(),U=m("div"),N=m("div"),_=m("input"),L=w(),M=m("button"),M.textContent="Add",O=w(),Ge&&Ge.c(),j=w(),qe&&qe.c(),H=w(),G=m("label"),G.textContent="Event IDs",q=w(),J=m("div"),K=m("div"),V=m("input"),Y=w(),z=m("button"),z.textContent="Add",W=w(),Je&&Je.c(),Z=w(),Ke&&Ke.c(),X=w(),ee=m("label"),ee.textContent="Tags (#e, #p, #a)",te=w(),ne=m("div"),ie=m("div"),re=m("span"),re.textContent="#",se=w(),oe=m("input"),le=w(),ae=m("input"),ce=w(),ue=m("button"),ue.textContent="Add",de=w(),Ve&&Ve.c(),fe=w(),Ye&&Ye.c(),pe=w(),he=m("label"),he.textContent="Since",ge=w(),me=m("div"),ye=m("input"),ve=w(),ze&&ze.c(),we=w(),be=m("label"),be.textContent="Until",Ae=w(),ke=m("div"),Ie=m("input"),Ce=w(),We&&We.c(),Ee=w(),xe=m("label"),xe.textContent="Limit",Se=w(),Be=m("div"),Qe=m("input"),Fe=w(),Ze&&Ze.c(),$e=w(),De=m("div"),Re=m("button"),Re.textContent="🧹",Pe=w(),Te=m("div"),Ue=w(),Ne=m("button"),Ne.textContent="",I(o,"for","search-text"),I(o,"class","svelte-1a1v6k0"),I(c,"id","search-text"),I(c,"type","text"),I(c,"placeholder","Search events..."),I(c,"class","filter-input svelte-1a1v6k0"),I(a,"class","field-content svelte-1a1v6k0"),I(d,"class","svelte-1a1v6k0"),I(b,"class","picker-toggle-btn svelte-1a1v6k0"),I(y,"class","field-content svelte-1a1v6k0"),I(P,"class","svelte-1a1v6k0"),I(_,"type","text"),I(_,"placeholder","64 character hex pubkey..."),I(_,"class","filter-input svelte-1a1v6k0"),I(_,"maxlength","64"),I(M,"class","add-btn svelte-1a1v6k0"),I(N,"class","input-group svelte-1a1v6k0"),I(U,"class","field-content svelte-1a1v6k0"),I(G,"class","svelte-1a1v6k0"),I(V,"type","text"),I(V,"placeholder","64 character hex event ID..."),I(V,"class","filter-input svelte-1a1v6k0"),I(V,"maxlength","64"),I(z,"class","add-btn svelte-1a1v6k0"),I(K,"class","input-group svelte-1a1v6k0"),I(J,"class","field-content svelte-1a1v6k0"),I(ee,"class","svelte-1a1v6k0"),I(re,"class","hash-prefix svelte-1a1v6k0"),I(oe,"type","text"),I(oe,"placeholder","Tag"),I(oe,"class","filter-input tag-name-input svelte-1a1v6k0"),I(oe,"maxlength","1"),I(ae,"type","text"),I(ae,"placeholder","Value..."),I(ae,"class","filter-input tag-value-input svelte-1a1v6k0"),I(ue,"class","add-btn svelte-1a1v6k0"),I(ie,"class","tag-input-group svelte-1a1v6k0"),I(ne,"class","field-content svelte-1a1v6k0"),I(he,"for","since-timestamp"),I(he,"class","svelte-1a1v6k0"),I(ye,"id","since-timestamp"),I(ye,"type","datetime-local"),ye.value=t[32](),I(ye,"class","filter-input svelte-1a1v6k0"),I(me,"class","field-content timestamp-field svelte-1a1v6k0"),I(be,"for","until-timestamp"),I(be,"class","svelte-1a1v6k0"),I(Ie,"id","until-timestamp"),I(Ie,"type","datetime-local"),Ie.value=t[33](),I(Ie,"class","filter-input svelte-1a1v6k0"),I(ke,"class","field-content timestamp-field svelte-1a1v6k0"),I(xe,"for","limit"),I(xe,"class","svelte-1a1v6k0"),I(Qe,"id","limit"),I(Qe,"type","number"),I(Qe,"placeholder","Max events to return"),I(Qe,"class","filter-input svelte-1a1v6k0"),I(Qe,"min","1"),I(Be,"class","field-content svelte-1a1v6k0"),I(s,"class","filter-grid svelte-1a1v6k0"),I(r,"class","filter-content svelte-1a1v6k0"),I(Re,"class","clear-all-btn svelte-1a1v6k0"),I(Re,"title","Clear all filters"),I(Te,"class","spacer svelte-1a1v6k0"),I(Ne,"class","json-toggle-btn svelte-1a1v6k0"),I(Ne,"title","Edit filter JSON"),F(Ne,"active",t[8]),I(De,"class","clear-column svelte-1a1v6k0"),I(n,"class","filter-builder svelte-1a1v6k0")},m(e,i){p(e,n,i),f(n,r),f(r,s),f(s,o),f(s,l),f(s,a),f(a,c),x(c,t[0]),f(s,u),f(s,d),f(s,g),f(s,y),f(y,b),f(b,k),f(b,S),f(b,B),f(b,Q),f(y,$),je&&je.m(y,null),f(y,D),He&&He.m(y,null),f(s,R),f(s,P),f(s,T),f(s,U),f(U,N),f(N,_),x(_,t[13]),f(N,L),f(N,M),f(U,O),Ge&&Ge.m(U,null),f(U,j),qe&&qe.m(U,null),f(s,H),f(s,G),f(s,q),f(s,J),f(J,K),f(K,V),x(V,t[14]),f(K,Y),f(K,z),f(J,W),Je&&Je.m(J,null),f(J,Z),Ke&&Ke.m(J,null),f(s,X),f(s,ee),f(s,te),f(s,ne),f(ne,ie),f(ie,re),f(ie,se),f(ie,oe),x(oe,t[15]),f(ie,le),f(ie,ae),x(ae,t[16]),f(ie,ce),f(ie,ue),f(ne,de),Ve&&Ve.m(ne,null),f(ne,fe),Ye&&Ye.m(ne,null),f(s,pe),f(s,he),f(s,ge),f(s,me),f(me,ye),f(me,ve),ze&&ze.m(me,null),f(s,we),f(s,be),f(s,Ae),f(s,ke),f(ke,Ie),f(ke,Ce),We&&We.m(ke,null),f(s,Ee),f(s,xe),f(s,Se),f(s,Be),f(Be,Qe),x(Qe,t[7]),f(s,Fe),Ze&&Ze.m(s,null),f(n,$e),f(n,De),f(De,Re),f(De,Pe),f(De,Te),f(De,Ue),f(De,Ne),_e||(Le=[A(c,"input",t[38]),A(b,"click",t[39]),A(_,"input",t[43]),A(_,"keydown",t[44]),A(M,"click",t[25]),A(V,"input",t[46]),A(V,"keydown",t[47]),A(z,"click",t[27]),A(oe,"input",t[49]),A(ae,"input",t[50]),A(ae,"keydown",t[51]),A(ue,"click",t[29]),A(ye,"change",t[34]),A(Ie,"change",t[35]),A(Qe,"input",t[55]),A(Re,"click",t[31]),A(Ne,"click",t[57])],_e=!0)},p(e,t){1&t[0]&&c.value!==e[0]&&x(c,e[0]),4096&t[0]&&Me!==(Me=e[12]?"▼":"▶")&&E(k,Me),2&t[0]&&Oe!==(Oe=e[1].length+"")&&E(B,Oe),e[12]?je?je.p(e,t):(je=Jm(e),je.c(),je.m(y,D)):je&&(je.d(1),je=null),e[1].length>0?He?He.p(e,t):(He=Vm(e),He.c(),He.m(y,null)):He&&(He.d(1),He=null),8192&t[0]&&_.value!==e[13]&&x(_,e[13]),e[17]?Ge?Ge.p(e,t):(Ge=zm(e),Ge.c(),Ge.m(U,j)):Ge&&(Ge.d(1),Ge=null),e[2].length>0?qe?qe.p(e,t):(qe=Wm(e),qe.c(),qe.m(U,null)):qe&&(qe.d(1),qe=null),16384&t[0]&&V.value!==e[14]&&x(V,e[14]),e[18]?Je?Je.p(e,t):(Je=Xm(e),Je.c(),Je.m(J,Z)):Je&&(Je.d(1),Je=null),e[3].length>0?Ke?Ke.p(e,t):(Ke=ey(e),Ke.c(),Ke.m(J,null)):Ke&&(Ke.d(1),Ke=null),32768&t[0]&&oe.value!==e[15]&&x(oe,e[15]),65536&t[0]&&ae.value!==e[16]&&x(ae,e[16]),e[19]?Ve?Ve.p(e,t):(Ve=ny(e),Ve.c(),Ve.m(ne,fe)):Ve&&(Ve.d(1),Ve=null),e[4].length>0?Ye?Ye.p(e,t):(Ye=iy(e),Ye.c(),Ye.m(ne,null)):Ye&&(Ye.d(1),Ye=null),e[5]?ze?ze.p(e,t):(ze=sy(e),ze.c(),ze.m(me,null)):ze&&(ze.d(1),ze=null),e[6]?We?We.p(e,t):(We=oy(e),We.c(),We.m(ke,null)):We&&(We.d(1),We=null),128&t[0]&&C(Qe.value)!==e[7]&&x(Qe,e[7]),e[8]?Ze?Ze.p(e,t):(Ze=ly(e),Ze.c(),Ze.m(s,null)):Ze&&(Ze.d(1),Ze=null),256&t[0]&&F(Ne,"active",e[8])},i:e,o:e,d(e){e&&h(n),je&&je.d(),He&&He.d(),Ge&&Ge.d(),qe&&qe.d(),Je&&Je.d(),Ke&&Ke.d(),Ve&&Ve.d(),Ye&&Ye.d(),ze&&ze.d(),We&&We.d(),Ze&&Ze.d(),_e=!1,i(Le)}}}function uy(e,t,n){let i,r;const s=U();let{searchText:o=""}=t,{selectedKinds:l=[]}=t,{pubkeys:a=[]}=t,{eventIds:c=[]}=t,{tags:u=[]}=t,{sinceTimestamp:d=null}=t,{untilTimestamp:f=null}=t,{limit:p=null}=t,{showJsonEditor:h=!1}=t,g="",m="",y=!1,v="",w="",b="",A="",k="",I="",E="",x="",S=null,B=!1;function Q(e){l.includes(e)?n(1,l=l.filter(t=>t!==e)):n(1,l=[...l,e].sort((e,t)=>e-t))}function F(e){n(1,l=l.filter(t=>t!==e))}function $(){const e=w.trim();e&&(_m(e,64)?a.includes(e)?n(17,I="Pubkey already added"):(n(2,a=[...a,e]),n(13,w=""),n(17,I="")):n(17,I="Invalid pubkey: must be 64 character hex string"))}function D(e){n(2,a=a.filter(t=>t!==e))}function R(){const e=b.trim();e&&(_m(e,64)?c.includes(e)?n(18,E="Event ID already added"):(n(3,c=[...c,e]),n(14,b=""),n(18,E="")):n(18,E="Invalid event ID: must be 64 character hex string"))}function P(e){n(3,c=c.filter(t=>t!==e))}function N(){const e=A.trim(),t=k.trim();e&&t&&(/^[a-zA-Z]$/.test(e)?u.some(n=>n.name===e&&n.value===t)?n(19,x="Tag already added"):(n(4,u=[...u,{name:e,value:t}]),n(15,A=""),n(16,k=""),n(19,x="")):n(19,x="Invalid tag name: must be single letter a-z or A-Z"))}function _(e){n(4,u=u.filter((t,n)=>n!==e))}function L(){s("apply",{searchText:o,selectedKinds:l,pubkeys:a,eventIds:c,tags:u,sinceTimestamp:d,untilTimestamp:f,limit:p})}T(()=>{S&&clearTimeout(S)});return e.$$set=e=>{"searchText"in e&&n(0,o=e.searchText),"selectedKinds"in e&&n(1,l=e.selectedKinds),"pubkeys"in e&&n(2,a=e.pubkeys),"eventIds"in e&&n(3,c=e.eventIds),"tags"in e&&n(4,u=e.tags),"sinceTimestamp"in e&&n(5,d=e.sinceTimestamp),"untilTimestamp"in e&&n(6,f=e.untilTimestamp),"limit"in e&&n(7,p=e.limit),"showJsonEditor"in e&&n(8,h=e.showJsonEditor)},e.$$.update=()=>{if(256&e.$$.dirty[0]&&h){const e=function(){const e={};return l.length>0&&(e.kinds=l),a.length>0&&(e.authors=a),c.length>0&&(e.ids=c),d&&(e.since=d),f&&(e.until=f),p&&(e.limit=p),o&&(e.search=o),u.forEach(t=>{const n=`#${t.name}`;e[n]||(e[n]=[]),e[n].push(t.value)}),e}();n(10,g=JSON.stringify(e,null,2))}255&e.$$.dirty[0]|32&e.$$.dirty[1]&&(B?(S&&clearTimeout(S),S=setTimeout(()=>{L()},1e3)):n(36,B=!0)),512&e.$$.dirty[0]|64&e.$$.dirty[1]&&n(20,r=i.filter(e=>e.kind.toString().includes(v)||e.name.toLowerCase().includes(v.toLowerCase())))},n(37,i=Object.entries(Nm).map(([e,t])=>({kind:parseInt(e),name:t})).sort((e,t)=>e.kind-t.kind)),[o,l,a,c,u,d,f,p,h,v,g,m,y,w,b,A,k,I,E,x,r,s,function(){try{const e=JSON.parse(g);n(11,m=""),n(1,l=e.kinds||[]),n(2,a=e.authors||[]),n(3,c=e.ids||[]),n(5,d=e.since||null),n(6,f=e.until||null),n(7,p=e.limit||null),n(0,o=e.search||""),n(4,u=[]),Object.keys(e).forEach(t=>{if(t.startsWith("#")&&2===t.length){const n=t.slice(1);(Array.isArray(e[t])?e[t]:[e[t]]).forEach(e=>{u.push({name:n,value:String(e)})})}}),n(4,u),S&&clearTimeout(S),L()}catch(e){n(11,m="Invalid JSON: "+e.message)}},Q,F,$,D,R,P,N,_,function(){n(0,o=""),n(1,l=[]),n(2,a=[]),n(3,c=[]),n(4,u=[]),n(5,d=null),n(6,f=null),n(7,p=null),s("clear")},function(){return d?Lm(d):""},function(){return f?Lm(f):""},function(e){const t=e.target.value;n(5,d=t?Mm(t):null)},function(e){const t=e.target.value;n(6,f=t?Mm(t):null)},B,i,function(){o=this.value,n(0,o)},()=>n(12,y=!y),function(){v=this.value,n(9,v)},e=>Q(e),e=>F(e),function(){w=this.value,n(13,w)},e=>"Enter"===e.key&&$(),e=>D(e),function(){b=this.value,n(14,b)},e=>"Enter"===e.key&&R(),e=>P(e),function(){A=this.value,n(15,A)},function(){k=this.value,n(16,k)},e=>"Enter"===e.key&&N(),e=>_(e),()=>n(5,d=null),()=>n(6,f=null),function(){p=C(this.value),n(7,p)},function(){g=this.value,n(10,g),n(8,h)},()=>s("toggleJson")]}class dy extends ae{constructor(e){super(),le(this,e,uy,cy,s,{searchText:0,selectedKinds:1,pubkeys:2,eventIds:3,tags:4,sinceTimestamp:5,untilTimestamp:6,limit:7,showJsonEditor:8},null,[-1,-1,-1])}}function fy(e,t,n){const i=e.slice();return i[28]=t[n],i}function py(e,t,n){const i=e.slice();return i[31]=t[n],i}function hy(t){let n;return{c(){n=m("div"),n.innerHTML="

❌ Read, write, admin, or owner permission required to view all\n events.

",I(n,"class","permission-denied svelte-16xix3y")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function gy(e){let t,n,i,r;function s(e,t){return e[4].length>0?yy:e[6]?void 0:my}let o=s(e),l=o&&o(e),a=e[6]&&Ey();return{c(){t=m("div"),l&&l.c(),n=w(),a&&a.c(),I(t,"class","events-view-content svelte-16xix3y")},m(s,o){p(s,t,o),l&&l.m(t,null),f(t,n),a&&a.m(t,null),i||(r=A(t,"scroll",e[9]),i=!0)},p(e,i){o===(o=s(e))&&l?l.p(e,i):(l&&l.d(1),l=o&&o(e),l&&(l.c(),l.m(t,n))),e[6]?a||(a=Ey(),a.c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&h(t),l&&l.d(),a&&a.d(),i=!1,r()}}}function my(t){let n;return{c(){n=m("div"),n.innerHTML="

No events found.

",I(n,"class","no-events svelte-16xix3y")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function yy(e){let t,n=e[4],i=[];for(let t=0;t0&&by(e);return{c(){t=m("div"),n=m("span"),n.textContent="🗑️ Delete Event",i=w(),r&&r.c(),I(n,"class","delete-event-label svelte-16xix3y"),I(t,"class","delete-event-info svelte-16xix3y")},m(e,s){p(e,t,s),f(t,n),f(t,i),r&&r.m(t,null)},p(e,n){e[28].tags&&e[28].tags.length>0?r?r.p(e,n):(r=by(e),r.c(),r.m(t,null)):r&&(r.d(1),r=null)},d(e){e&&h(t),r&&r.d()}}}function by(e){let t,n=e[28].tags.filter(Py),i=[];for(let t=0;t👤',s=w(),o=m("div"),l=m("div"),a=v(U),c=w(),u=m("div"),d=m("span"),g=v(N),y=w(),b=m("span"),k=v(_),C=w(),x=m("div"),S=m("div"),B=v(L),Q=w(),H.c(),$=w(),G&&G.c(),D=w(),K&&K.c(),R=w(),I(r,"class","events-view-avatar svelte-16xix3y"),I(l,"class","events-view-author svelte-16xix3y"),I(d,"class","kind-number svelte-16xix3y"),F(d,"delete-event",5===e[28].kind),I(b,"class","kind-name svelte-16xix3y"),I(u,"class","events-view-kind svelte-16xix3y"),I(o,"class","events-view-info svelte-16xix3y"),I(S,"class","event-timestamp svelte-16xix3y"),I(x,"class","events-view-content svelte-16xix3y"),I(n,"class","events-view-row svelte-16xix3y"),I(n,"role","button"),I(n,"tabindex","0"),I(t,"class","events-view-item svelte-16xix3y"),F(t,"expanded",e[5].has(e[28].id))},m(e,i){p(e,t,i),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(d,g),f(u,y),f(u,b),f(b,k),f(n,C),f(n,x),f(x,S),f(S,B),f(x,Q),H.m(x,null),f(n,$),G&&G.m(n,null),f(t,D),K&&K.m(t,null),f(t,R),P||(T=[A(n,"click",q),A(n,"keydown",J)],P=!0)},p(i,r){e=i,16&r[0]&&U!==(U=Fy(e[28].pubkey)+"")&&E(a,U),16&r[0]&&N!==(N=e[28].kind+"")&&E(g,N),16&r[0]&&F(d,"delete-event",5===e[28].kind),16&r[0]&&_!==(_=$y(e[28].kind)+"")&&E(k,_),16&r[0]&&L!==(L=Dy(e[28].created_at)+"")&&E(B,L),j===(j=O(e))&&H?H.p(e,r):(H.d(1),H=j(e),H&&(H.c(),H.m(x,null))),5!==e[28].kind&&("admin"===e[2]||"owner"===e[2]||"write"===e[2]&&e[28].pubkey&&e[28].pubkey===e[3])?G?G.p(e,r):(G=ky(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),48&r[0]&&(M=e[5].has(e[28].id)),M?K?K.p(e,r):(K=Iy(e),K.c(),K.m(t,R)):K&&(K.d(1),K=null),48&r[0]&&F(t,"expanded",e[5].has(e[28].id))},d(e){e&&h(t),H.d(),G&&G.d(),K&&K.d(),P=!1,i(T)}}}function Ey(e){let t;return{c(){t=m("div"),t.innerHTML='
\n

Loading events...

',I(t,"class","loading-events svelte-16xix3y")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function xy(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,E,x,S,B,Q,$,D,R,P;function T(e,t){return e[6]?By:Sy}r=new dy({props:{showJsonEditor:e[8]}}),r.$on("apply",e[17]),r.$on("clear",e[18]),r.$on("toggleJson",e[16]);let U=T(e),N=U(e);return{c(){t=m("div"),n=m("div"),ie(r.$$.fragment),s=w(),o=m("div"),l=m("div"),a=m("button"),a.innerHTML='',c=w(),u=m("div"),d=m("label"),g=m("input"),y=w(),b=m("span"),k=w(),C=m("span"),C.textContent="Only show my events",E=w(),x=m("div"),S=m("button"),B=v("🔄 Load More"),Q=w(),$=m("button"),N.c(),I(n,"class","filter-panel svelte-16xix3y"),F(n,"open",e[7]),I(a,"class","filter-btn svelte-16xix3y"),I(a,"title","Filter events"),F(a,"active",e[7]),I(g,"type","checkbox"),I(g,"class","svelte-16xix3y"),I(b,"class","toggle-slider svelte-16xix3y"),I(C,"class","toggle-label svelte-16xix3y"),I(d,"class","toggle-container svelte-16xix3y"),I(u,"class","events-view-toggle svelte-16xix3y"),I(l,"class","events-view-left svelte-16xix3y"),I(S,"class","refresh-btn svelte-16xix3y"),S.disabled=e[6],I($,"class","reload-btn svelte-16xix3y"),$.disabled=e[6],I(x,"class","events-view-buttons svelte-16xix3y"),I(o,"class","events-view-header svelte-16xix3y"),I(t,"class","events-view-footer svelte-16xix3y")},m(i,h){p(i,t,h),f(t,n),re(r,n,null),f(t,s),f(t,o),f(o,l),f(l,a),f(l,c),f(l,u),f(u,d),f(d,g),g.checked=e[0],f(d,y),f(d,b),f(d,k),f(d,C),f(o,E),f(o,x),f(x,S),f(S,B),f(x,Q),f(x,$),N.m($,null),D=!0,R||(P=[A(a,"click",e[15]),A(g,"change",e[23]),A(g,"change",e[24]),A(S,"click",e[25]),A($,"click",e[26])],R=!0)},p(e,t){const i={};256&t[0]&&(i.showJsonEditor=e[8]),r.$set(i),(!D||128&t[0])&&F(n,"open",e[7]),(!D||128&t[0])&&F(a,"active",e[7]),1&t[0]&&(g.checked=e[0]),(!D||64&t[0])&&(S.disabled=e[6]),U!==(U=T(e))&&(N.d(1),N=U(e),N&&(N.c(),N.m($,null))),(!D||64&t[0])&&($.disabled=e[6])},i(e){D||(ee(r.$$.fragment,e),D=!0)},o(e){te(r.$$.fragment,e),D=!1},d(e){e&&h(t),se(r),N.d(),R=!1,i(P)}}}function Sy(e){let t;return{c(){t=v("🔄")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function By(e){let t;return{c(){t=m("div"),I(t,"class","spinner svelte-16xix3y")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Qy(e){let t,n,i;function r(e,t){return!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?hy:gy}let s=r(e),o=s(e),l=e[1]&&("read"===e[2]||"write"===e[2]||"admin"===e[2]||"owner"===e[2])&&xy(e);return{c(){t=m("div"),o.c(),n=w(),l&&l.c(),I(t,"class","events-view-container svelte-16xix3y")},m(e,r){p(e,t,r),o.m(t,null),f(t,n),l&&l.m(t,null),i=!0},p(e,i){s===(s=r(e))&&o?o.p(e,i):(o.d(1),o=s(e),o&&(o.c(),o.m(t,n))),!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?l&&(Z(),te(l,1,1,()=>{l=null}),X()):l?(l.p(e,i),6&i[0]&&ee(l,1)):(l=xy(e),l.c(),ee(l,1),l.m(t,null))},i(e){i||(ee(l),i=!0)},o(e){te(l),i=!1},d(e){e&&h(t),o.d(),l&&l.d()}}}function Fy(e){return e?e.slice(0,8)+"..."+e.slice(-8):""}function $y(e){return{0:"Profile",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1984:"Reporting",9734:"Zap Request",9735:"Zap",1e4:"Mute List",10001:"Pin List",10002:"Relay List",22242:"Client Auth",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People",30001:"Categorized Bookmarks",30008:"Profile Badges",30009:"Badge Definition",30017:"Create or update a stall",30018:"Create or update a product",30023:"Long-form Content",30024:"Draft Long-form Content",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34550:"Community Definition"}[e]||`Kind ${e}`}function Dy(e){return new Date(1e3*e).toLocaleString()}function Ry(e){return e?e.length>100?e.slice(0,100)+"...":e:""}const Py=e=>"e"===e[0];function Ty(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:r=""}=t,{userPubkey:s=""}=t,{filteredEvents:o=[]}=t,{expandedEvents:l=new Set}=t,{isLoadingEvents:a=!1}=t,{showOnlyMyEvents:c=!1}=t,{showFilterBuilder:u=!1}=t;const d=U();let f=!1;function p(e){d("toggleEventExpansion",e)}function h(e){d("deleteEvent",e)}function g(e,t){d("copyEventToClipboard",{event:e,e:t})}function m(){d("toggleChange")}function y(e,t){d("loadAllEvents",{refresh:e,authors:t})}return e.$$set=e=>{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"userPubkey"in e&&n(3,s=e.userPubkey),"filteredEvents"in e&&n(4,o=e.filteredEvents),"expandedEvents"in e&&n(5,l=e.expandedEvents),"isLoadingEvents"in e&&n(6,a=e.isLoadingEvents),"showOnlyMyEvents"in e&&n(0,c=e.showOnlyMyEvents),"showFilterBuilder"in e&&n(7,u=e.showFilterBuilder)},[c,i,r,s,o,l,a,u,f,function(e){d("scroll",e)},p,h,g,m,y,function(){d("toggleFilterBuilder")},function(){n(8,f=!f)},function(e){d("filterApply",e.detail)},function(){d("filterClear")},e=>h(e.id),e=>p(e.id),(e,t)=>"Enter"===t.key&&p(e.id),(e,t)=>g(e,t),function(){c=this.checked,n(0,c)},()=>m(),()=>{y(!1,c&&s?[s]:null)},()=>{y(!0,c&&s?[s]:null)}]}class Uy extends ae{constructor(e){super(),le(this,e,Ty,Qy,s,{isLoggedIn:1,userRole:2,userPubkey:3,filteredEvents:4,expandedEvents:5,isLoadingEvents:6,showOnlyMyEvents:0,showFilterBuilder:7},null,[-1,-1])}}const Ny=[{kind:0,name:"Metadata",description:"User profile information (name, about, picture, nip05, etc.)",nip:"01",isReplaceable:!0,template:{kind:0,content:"",tags:[]}},{kind:1,name:"Short Text Note",description:"Short-form text post (like a tweet)",nip:"01",template:{kind:1,content:"",tags:[]}},{kind:2,name:"Recommend Relay",description:"Relay recommendation",nip:"01",deprecated:!0,template:{kind:2,content:"",tags:[]}},{kind:3,name:"Follows",description:"Following list with optional relay hints",nip:"02",isReplaceable:!0,template:{kind:3,content:"",tags:[]}},{kind:4,name:"Encrypted Direct Message",description:"Private message using NIP-04 encryption",nip:"04",deprecated:!0,template:{kind:4,content:"",tags:[]}},{kind:5,name:"Event Deletion Request",description:"Request to delete events",nip:"09",template:{kind:5,content:"",tags:[]}},{kind:6,name:"Repost",description:"Share/repost another text note",nip:"18",template:{kind:6,content:"",tags:[]}},{kind:7,name:"Reaction",description:"Like, emoji reaction to an event",nip:"25",template:{kind:7,content:"",tags:[]}},{kind:8,name:"Badge Award",description:"Award a badge to someone",nip:"58",template:{kind:8,content:"",tags:[]}},{kind:9,name:"Chat Message",description:"Chat message",nip:"C7",template:{kind:9,content:"",tags:[]}},{kind:10,name:"Group Chat Threaded Reply",description:"Threaded reply in group chat",nip:"29",deprecated:!0,template:{kind:10,content:"",tags:[]}},{kind:11,name:"Thread",description:"Thread event",nip:"7D",template:{kind:11,content:"",tags:[]}},{kind:12,name:"Group Thread Reply",description:"Reply in group thread",nip:"29",deprecated:!0,template:{kind:12,content:"",tags:[]}},{kind:13,name:"Seal",description:"Sealed/encrypted event wrapper",nip:"59",template:{kind:13,content:"",tags:[]}},{kind:14,name:"Direct Message",description:"Private direct message using NIP-17",nip:"17",template:{kind:14,content:"",tags:[]}},{kind:15,name:"File Message",description:"File message in DMs",nip:"17",template:{kind:15,content:"",tags:[]}},{kind:16,name:"Generic Repost",description:"Repost any event kind",nip:"18",template:{kind:16,content:"",tags:[]}},{kind:17,name:"Reaction to Website",description:"Reaction to a website URL",nip:"25",template:{kind:17,content:"",tags:[]}},{kind:20,name:"Picture",description:"Picture-first feed post",nip:"68",template:{kind:20,content:"",tags:[]}},{kind:21,name:"Video Event",description:"Horizontal video event",nip:"71",template:{kind:21,content:"",tags:[]}},{kind:22,name:"Short-form Video",description:"Short-form portrait video (like TikTok)",nip:"71",template:{kind:22,content:"",tags:[]}},{kind:40,name:"Channel Creation",description:"Create a public chat channel",nip:"28",template:{kind:40,content:"",tags:[]}},{kind:41,name:"Channel Metadata",description:"Set channel name, about, picture",nip:"28",template:{kind:41,content:"",tags:[]}},{kind:42,name:"Channel Message",description:"Post message in channel",nip:"28",template:{kind:42,content:"",tags:[]}},{kind:43,name:"Channel Hide Message",description:"Hide a message in channel",nip:"28",template:{kind:43,content:"",tags:[]}},{kind:44,name:"Channel Mute User",description:"Mute a user in channel",nip:"28",template:{kind:44,content:"",tags:[]}},{kind:62,name:"Request to Vanish",description:"Request permanent deletion of all user data",nip:"62",template:{kind:62,content:"",tags:[]}},{kind:64,name:"Chess (PGN)",description:"Chess game in PGN format",nip:"64",template:{kind:64,content:"",tags:[]}},{kind:443,name:"KeyPackage",description:"Marmot protocol key package",nip:null,spec:"Marmot",template:{kind:443,content:"",tags:[]}},{kind:444,name:"Welcome Message",description:"Marmot protocol welcome message",nip:null,spec:"Marmot",template:{kind:444,content:"",tags:[]}},{kind:445,name:"Group Event",description:"Marmot protocol group event",nip:null,spec:"Marmot",template:{kind:445,content:"",tags:[]}},{kind:818,name:"Merge Requests",description:"Git merge request",nip:"54",template:{kind:818,content:"",tags:[]}},{kind:1018,name:"Poll Response",description:"Response to a poll",nip:"88",template:{kind:1018,content:"",tags:[]}},{kind:1021,name:"Bid",description:"Auction bid",nip:"15",template:{kind:1021,content:"",tags:[]}},{kind:1022,name:"Bid Confirmation",description:"Confirmation of auction bid",nip:"15",template:{kind:1022,content:"",tags:[]}},{kind:1040,name:"OpenTimestamps",description:"OpenTimestamps attestation",nip:"03",template:{kind:1040,content:"",tags:[]}},{kind:1059,name:"Gift Wrap",description:"Encrypted gift-wrapped event",nip:"59",template:{kind:1059,content:"",tags:[]}},{kind:1060,name:"Gift Wrap (Kind 4)",description:"Gift wrap variant for NIP-04 compatibility",nip:"59",template:{kind:1060,content:"",tags:[]}},{kind:1063,name:"File Metadata",description:"Metadata for shared files",nip:"94",template:{kind:1063,content:"",tags:[]}},{kind:1068,name:"Poll",description:"Create a poll",nip:"88",template:{kind:1068,content:"",tags:[]}},{kind:1111,name:"Comment",description:"Comment on events or external content",nip:"22",template:{kind:1111,content:"",tags:[]}},{kind:1222,name:"Voice Message",description:"Voice message",nip:"A0",template:{kind:1222,content:"",tags:[]}},{kind:1244,name:"Voice Message Comment",description:"Comment on voice message",nip:"A0",template:{kind:1244,content:"",tags:[]}},{kind:1311,name:"Live Chat Message",description:"Message in live stream chat",nip:"53",template:{kind:1311,content:"",tags:[]}},{kind:1337,name:"Code Snippet",description:"Code snippet post",nip:"C0",template:{kind:1337,content:"",tags:[]}},{kind:1517,name:"Bitcoin Block",description:"Bitcoin block data",nip:null,spec:"Nostrocket",template:{kind:1517,content:"",tags:[]}},{kind:1617,name:"Patches",description:"Git patches",nip:"34",template:{kind:1617,content:"",tags:[]}},{kind:1618,name:"Pull Requests",description:"Git pull request",nip:"34",template:{kind:1618,content:"",tags:[]}},{kind:1619,name:"Pull Request Updates",description:"Updates to git pull request",nip:"34",template:{kind:1619,content:"",tags:[]}},{kind:1621,name:"Issues",description:"Git issues",nip:"34",template:{kind:1621,content:"",tags:[]}},{kind:1622,name:"Git Replies",description:"Replies on git objects",nip:"34",deprecated:!0,template:{kind:1622,content:"",tags:[]}},{kind:1630,name:"Status",description:"Git status",nip:"34",template:{kind:1630,content:"",tags:[]}},{kind:1631,name:"Status",description:"Git status",nip:"34",template:{kind:1631,content:"",tags:[]}},{kind:1632,name:"Status",description:"Git status",nip:"34",template:{kind:1632,content:"",tags:[]}},{kind:1633,name:"Status",description:"Git status",nip:"34",template:{kind:1633,content:"",tags:[]}},{kind:1808,name:"Live Stream",description:"Live streaming event",nip:null,spec:"zap.stream",template:{kind:1808,content:"",tags:[]}},{kind:1971,name:"Problem Tracker",description:"Problem tracking",nip:null,spec:"Nostrocket",template:{kind:1971,content:"",tags:[]}},{kind:1984,name:"Reporting",description:"Report content or users",nip:"56",template:{kind:1984,content:"",tags:[]}},{kind:1985,name:"Label",description:"Label/tag content with namespace",nip:"32",template:{kind:1985,content:"",tags:[]}},{kind:1986,name:"Relay Reviews",description:"Reviews of relays",nip:null,template:{kind:1986,content:"",tags:[]}},{kind:1987,name:"AI Embeddings",description:"AI embeddings/vector lists",nip:null,spec:"NKBIP-02",template:{kind:1987,content:"",tags:[]}},{kind:2003,name:"Torrent",description:"Torrent magnet link",nip:"35",template:{kind:2003,content:"",tags:[]}},{kind:2004,name:"Torrent Comment",description:"Comment on torrent",nip:"35",template:{kind:2004,content:"",tags:[]}},{kind:2022,name:"Coinjoin Pool",description:"Coinjoin coordination",nip:null,spec:"joinstr",template:{kind:2022,content:"",tags:[]}},{kind:4550,name:"Community Post Approval",description:"Approve post in community",nip:"72",template:{kind:4550,content:"",tags:[]}},{kind:5e3,name:"Job Request",description:"Data vending machine job request (start of range)",nip:"90",template:{kind:5e3,content:"",tags:[]}},{kind:6e3,name:"Job Result",description:"Data vending machine job result (start of range)",nip:"90",template:{kind:6e3,content:"",tags:[]}},{kind:7e3,name:"Job Feedback",description:"Feedback on job request/result",nip:"90",template:{kind:7e3,content:"",tags:[]}},{kind:7374,name:"Reserved Cashu Wallet Tokens",description:"Reserved Cashu wallet tokens",nip:"60",template:{kind:7374,content:"",tags:[]}},{kind:7375,name:"Cashu Wallet Tokens",description:"Cashu wallet tokens",nip:"60",template:{kind:7375,content:"",tags:[]}},{kind:7376,name:"Cashu Wallet History",description:"Cashu wallet transaction history",nip:"60",template:{kind:7376,content:"",tags:[]}},{kind:7516,name:"Geocache Log",description:"Geocaching log entry",nip:null,spec:"geocaching",template:{kind:7516,content:"",tags:[]}},{kind:7517,name:"Geocache Proof of Find",description:"Proof of geocache find",nip:null,spec:"geocaching",template:{kind:7517,content:"",tags:[]}},{kind:8e3,name:"Add User",description:"Add user to group",nip:"43",template:{kind:8e3,content:"",tags:[]}},{kind:8001,name:"Remove User",description:"Remove user from group",nip:"43",template:{kind:8001,content:"",tags:[]}},{kind:9e3,name:"Group Control Events",description:"Group control events (start of range)",nip:"29",template:{kind:9e3,content:"",tags:[]}},{kind:9041,name:"Zap Goal",description:"Fundraising goal for zaps",nip:"75",template:{kind:9041,content:"",tags:[]}},{kind:9321,name:"Nutzap",description:"Cashu nutzap",nip:"61",template:{kind:9321,content:"",tags:[]}},{kind:9467,name:"Tidal Login",description:"Tidal streaming login",nip:null,spec:"Tidal-nostr",template:{kind:9467,content:"",tags:[]}},{kind:9734,name:"Zap Request",description:"Request Lightning payment",nip:"57",template:{kind:9734,content:"",tags:[]}},{kind:9735,name:"Zap",description:"Lightning payment receipt",nip:"57",template:{kind:9735,content:"",tags:[]}},{kind:9802,name:"Highlights",description:"Highlighted text selection",nip:"84",template:{kind:9802,content:"",tags:[]}},{kind:1e4,name:"Mute List",description:"List of muted users/content",nip:"51",isReplaceable:!0,template:{kind:1e4,content:"",tags:[]}},{kind:10001,name:"Pin List",description:"Pinned events",nip:"51",isReplaceable:!0,template:{kind:10001,content:"",tags:[]}},{kind:10002,name:"Relay List Metadata",description:"User's preferred relays for read/write",nip:"65",isReplaceable:!0,template:{kind:10002,content:"",tags:[]}},{kind:10003,name:"Bookmark List",description:"Bookmarked events",nip:"51",isReplaceable:!0,template:{kind:10003,content:"",tags:[]}},{kind:10004,name:"Communities List",description:"Communities user belongs to",nip:"51",isReplaceable:!0,template:{kind:10004,content:"",tags:[]}},{kind:10005,name:"Public Chats List",description:"Public chats user is in",nip:"51",isReplaceable:!0,template:{kind:10005,content:"",tags:[]}},{kind:10006,name:"Blocked Relays List",description:"Relays user has blocked",nip:"51",isReplaceable:!0,template:{kind:10006,content:"",tags:[]}},{kind:10007,name:"Search Relays List",description:"Preferred search relays",nip:"51",isReplaceable:!0,template:{kind:10007,content:"",tags:[]}},{kind:10008,name:"Relay Group Configuration",description:"Relay group configuration",nip:null,isReplaceable:!0,template:{kind:10008,content:"",tags:[]}},{kind:10009,name:"User Groups",description:"Groups user belongs to",nip:"29",isReplaceable:!0,template:{kind:10009,content:"",tags:[]}},{kind:10012,name:"Favorite Relays List",description:"User's favorite relays",nip:"51",isReplaceable:!0,template:{kind:10012,content:"",tags:[]}},{kind:10013,name:"Private Event Relay List",description:"Relays for private events",nip:"37",isReplaceable:!0,template:{kind:10013,content:"",tags:[]}},{kind:10015,name:"Interests List",description:"User interests/topics",nip:"51",isReplaceable:!0,template:{kind:10015,content:"",tags:[]}},{kind:10019,name:"Nutzap Mint Recommendation",description:"Recommended Cashu mints for nutzaps",nip:"61",isReplaceable:!0,template:{kind:10019,content:"",tags:[]}},{kind:10020,name:"Media Follows",description:"Followed media accounts",nip:"51",isReplaceable:!0,template:{kind:10020,content:"",tags:[]}},{kind:10030,name:"User Emoji List",description:"Custom emoji list",nip:"51",isReplaceable:!0,template:{kind:10030,content:"",tags:[]}},{kind:10050,name:"DM Relays List",description:"Relays to receive DMs on",nip:"17",isReplaceable:!0,template:{kind:10050,content:"",tags:[]}},{kind:10051,name:"KeyPackage Relays List",description:"Marmot key package relays",nip:null,isReplaceable:!0,spec:"Marmot",template:{kind:10051,content:"",tags:[]}},{kind:10063,name:"User Server List",description:"Blossom server list",nip:null,isReplaceable:!0,spec:"Blossom",template:{kind:10063,content:"",tags:[]}},{kind:10096,name:"File Storage Server List",description:"File storage servers",nip:"96",isReplaceable:!0,deprecated:!0,template:{kind:10096,content:"",tags:[]}},{kind:10166,name:"Relay Monitor Announcement",description:"Relay monitoring announcement",nip:"66",isReplaceable:!0,template:{kind:10166,content:"",tags:[]}},{kind:10312,name:"Room Presence",description:"Presence in live room",nip:"53",isReplaceable:!0,template:{kind:10312,content:"",tags:[]}},{kind:10377,name:"Proxy Announcement",description:"Nostr proxy announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:10377,content:"",tags:[]}},{kind:11111,name:"Transport Method Announcement",description:"Transport method announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:11111,content:"",tags:[]}},{kind:12345,name:"Relay Policy Configuration",description:"Relay-internal policy configuration (admin only)",nip:null,isReplaceable:!0,spec:"orly",template:{kind:12345,content:"",tags:[]}},{kind:13004,name:"JWT Binding",description:"Link between JWT certificate and pubkey",nip:null,isReplaceable:!0,template:{kind:13004,content:"",tags:[]}},{kind:13194,name:"Wallet Service Info",description:"NWC wallet service information",nip:"47",isReplaceable:!0,template:{kind:13194,content:"",tags:[]}},{kind:13534,name:"Membership Lists",description:"Group membership lists",nip:"43",isReplaceable:!0,template:{kind:13534,content:"",tags:[]}},{kind:14388,name:"User Sound Effect Lists",description:"Sound effect lists",nip:null,isReplaceable:!0,spec:"Corny Chat",template:{kind:14388,content:"",tags:[]}},{kind:17375,name:"Cashu Wallet Event",description:"Cashu wallet event",nip:"60",isReplaceable:!0,template:{kind:17375,content:"",tags:[]}},{kind:21e3,name:"Lightning Pub RPC",description:"Lightning.Pub RPC",nip:null,isEphemeral:!0,spec:"Lightning.Pub",template:{kind:21e3,content:"",tags:[]}},{kind:22242,name:"Client Authentication",description:"Authenticate to relay",nip:"42",isEphemeral:!0,template:{kind:22242,content:"",tags:[]}},{kind:23194,name:"Wallet Request",description:"NWC wallet request",nip:"47",isEphemeral:!0,template:{kind:23194,content:"",tags:[]}},{kind:23195,name:"Wallet Response",description:"NWC wallet response",nip:"47",isEphemeral:!0,template:{kind:23195,content:"",tags:[]}},{kind:23196,name:"Wallet Notification (NIP-04)",description:"NWC wallet notification (NIP-04 encrypted)",nip:"47",isEphemeral:!0,template:{kind:23196,content:"",tags:[]}},{kind:23197,name:"Wallet Notification",description:"NWC wallet notification",nip:"47",isEphemeral:!0,template:{kind:23197,content:"",tags:[]}},{kind:24133,name:"Nostr Connect",description:"Remote signer connection",nip:"46",isEphemeral:!0,template:{kind:24133,content:"",tags:[]}},{kind:24242,name:"Blobs Stored on Mediaservers",description:"Blossom blob storage",nip:null,isEphemeral:!0,spec:"Blossom",template:{kind:24242,content:"",tags:[]}},{kind:27235,name:"HTTP Auth",description:"Authenticate HTTP requests",nip:"98",isEphemeral:!0,template:{kind:27235,content:"",tags:[]}},{kind:28934,name:"Join Request",description:"Request to join group",nip:"43",isEphemeral:!0,template:{kind:28934,content:"",tags:[]}},{kind:28935,name:"Invite Request",description:"Invite to group",nip:"43",isEphemeral:!0,template:{kind:28935,content:"",tags:[]}},{kind:28936,name:"Leave Request",description:"Leave group request",nip:"43",isEphemeral:!0,template:{kind:28936,content:"",tags:[]}},{kind:3e4,name:"Follow Sets",description:"Categorized people lists",nip:"51",isAddressable:!0,template:{kind:3e4,content:"",tags:[["d","identifier"]]}},{kind:30001,name:"Generic Lists",description:"Generic categorized lists",nip:"51",isAddressable:!0,deprecated:!0,template:{kind:30001,content:"",tags:[["d","identifier"]]}},{kind:30002,name:"Relay Sets",description:"Categorized relay lists",nip:"51",isAddressable:!0,template:{kind:30002,content:"",tags:[["d","identifier"]]}},{kind:30003,name:"Bookmark Sets",description:"Categorized bookmark lists",nip:"51",isAddressable:!0,template:{kind:30003,content:"",tags:[["d","identifier"]]}},{kind:30004,name:"Curation Sets",description:"Curated content sets",nip:"51",isAddressable:!0,template:{kind:30004,content:"",tags:[["d","identifier"]]}},{kind:30005,name:"Video Sets",description:"Video playlists",nip:"51",isAddressable:!0,template:{kind:30005,content:"",tags:[["d","identifier"]]}},{kind:30007,name:"Kind Mute Sets",description:"Muted event kinds",nip:"51",isAddressable:!0,template:{kind:30007,content:"",tags:[["d","identifier"]]}},{kind:30008,name:"Profile Badges",description:"Badges displayed on profile",nip:"58",isAddressable:!0,template:{kind:30008,content:"",tags:[["d","identifier"]]}},{kind:30009,name:"Badge Definition",description:"Define a badge/achievement",nip:"58",isAddressable:!0,template:{kind:30009,content:"",tags:[["d","identifier"]]}},{kind:30015,name:"Interest Sets",description:"Interest/topic sets",nip:"51",isAddressable:!0,template:{kind:30015,content:"",tags:[["d","identifier"]]}},{kind:30017,name:"Stall",description:"Marketplace stall definition",nip:"15",isAddressable:!0,template:{kind:30017,content:"",tags:[["d","identifier"]]}},{kind:30018,name:"Product",description:"Marketplace product listing",nip:"15",isAddressable:!0,template:{kind:30018,content:"",tags:[["d","identifier"]]}},{kind:30019,name:"Marketplace UI/UX",description:"Marketplace interface settings",nip:"15",isAddressable:!0,template:{kind:30019,content:"",tags:[["d","identifier"]]}},{kind:30020,name:"Product Sold as Auction",description:"Auction product listing",nip:"15",isAddressable:!0,template:{kind:30020,content:"",tags:[["d","identifier"]]}},{kind:30023,name:"Long-form Content",description:"Blog post, article in markdown",nip:"23",isAddressable:!0,template:{kind:30023,content:"",tags:[["d","identifier"]]}},{kind:30024,name:"Draft Long-form Content",description:"Draft article",nip:"23",isAddressable:!0,template:{kind:30024,content:"",tags:[["d","identifier"]]}},{kind:30030,name:"Emoji Sets",description:"Custom emoji sets",nip:"51",isAddressable:!0,template:{kind:30030,content:"",tags:[["d","identifier"]]}},{kind:30040,name:"Curated Publication Index",description:"Publication index",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30040,content:"",tags:[["d","identifier"]]}},{kind:30041,name:"Curated Publication Content",description:"Publication content",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30041,content:"",tags:[["d","identifier"]]}},{kind:30063,name:"Release Artifact Sets",description:"Software release artifacts",nip:"51",isAddressable:!0,template:{kind:30063,content:"",tags:[["d","identifier"]]}},{kind:30078,name:"Application-specific Data",description:"App-specific key-value storage",nip:"78",isAddressable:!0,template:{kind:30078,content:"",tags:[["d","identifier"]]}},{kind:30166,name:"Relay Discovery",description:"Relay discovery/monitoring",nip:"66",isAddressable:!0,template:{kind:30166,content:"",tags:[["d","identifier"]]}},{kind:30267,name:"App Curation Sets",description:"Curated app sets",nip:"51",isAddressable:!0,template:{kind:30267,content:"",tags:[["d","identifier"]]}},{kind:30311,name:"Live Event",description:"Live streaming event",nip:"53",isAddressable:!0,template:{kind:30311,content:"",tags:[["d","identifier"]]}},{kind:30312,name:"Interactive Room",description:"Interactive live room",nip:"53",isAddressable:!0,template:{kind:30312,content:"",tags:[["d","identifier"]]}},{kind:30313,name:"Conference Event",description:"Conference/meetup event",nip:"53",isAddressable:!0,template:{kind:30313,content:"",tags:[["d","identifier"]]}},{kind:30315,name:"User Statuses",description:"User status updates",nip:"38",isAddressable:!0,template:{kind:30315,content:"",tags:[["d","identifier"]]}},{kind:30388,name:"Slide Set",description:"Presentation slides",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:30388,content:"",tags:[["d","identifier"]]}},{kind:30402,name:"Classified Listing",description:"Classified ad listing",nip:"99",isAddressable:!0,template:{kind:30402,content:"",tags:[["d","identifier"]]}},{kind:30403,name:"Draft Classified Listing",description:"Draft classified ad",nip:"99",isAddressable:!0,template:{kind:30403,content:"",tags:[["d","identifier"]]}},{kind:30617,name:"Repository Announcements",description:"Git repository announcement",nip:"34",isAddressable:!0,template:{kind:30617,content:"",tags:[["d","identifier"]]}},{kind:30618,name:"Repository State Announcements",description:"Git repository state",nip:"34",isAddressable:!0,template:{kind:30618,content:"",tags:[["d","identifier"]]}},{kind:30818,name:"Wiki Article",description:"Wiki article",nip:"54",isAddressable:!0,template:{kind:30818,content:"",tags:[["d","identifier"]]}},{kind:30819,name:"Redirects",description:"URL redirects",nip:"54",isAddressable:!0,template:{kind:30819,content:"",tags:[["d","identifier"]]}},{kind:31234,name:"Draft Event",description:"Draft of any event",nip:"37",isAddressable:!0,template:{kind:31234,content:"",tags:[["d","identifier"]]}},{kind:31388,name:"Link Set",description:"Link collection",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:31388,content:"",tags:[["d","identifier"]]}},{kind:31890,name:"Feed",description:"Custom feed definition",nip:null,isAddressable:!0,spec:"NUD: Custom Feeds",template:{kind:31890,content:"",tags:[["d","identifier"]]}},{kind:31922,name:"Date-Based Calendar Event",description:"All-day calendar event",nip:"52",isAddressable:!0,template:{kind:31922,content:"",tags:[["d","identifier"]]}},{kind:31923,name:"Time-Based Calendar Event",description:"Calendar event with time",nip:"52",isAddressable:!0,template:{kind:31923,content:"",tags:[["d","identifier"]]}},{kind:31924,name:"Calendar",description:"Calendar definition",nip:"52",isAddressable:!0,template:{kind:31924,content:"",tags:[["d","identifier"]]}},{kind:31925,name:"Calendar Event RSVP",description:"RSVP to calendar event",nip:"52",isAddressable:!0,template:{kind:31925,content:"",tags:[["d","identifier"]]}},{kind:31989,name:"Handler Recommendation",description:"Recommended app for event kind",nip:"89",isAddressable:!0,template:{kind:31989,content:"",tags:[["d","identifier"]]}},{kind:31990,name:"Handler Information",description:"App handler declaration",nip:"89",isAddressable:!0,template:{kind:31990,content:"",tags:[["d","identifier"]]}},{kind:32123,name:"WaveLake Track",description:"WaveLake music track",nip:null,isAddressable:!0,spec:"WaveLake",template:{kind:32123,content:"",tags:[["d","identifier"]]}},{kind:32267,name:"Software Application",description:"Software application listing",nip:null,isAddressable:!0,template:{kind:32267,content:"",tags:[["d","identifier"]]}},{kind:32388,name:"User Room Favorites",description:"Favorite rooms",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:32388,content:"",tags:[["d","identifier"]]}},{kind:33388,name:"High Scores",description:"Game high scores",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:33388,content:"",tags:[["d","identifier"]]}},{kind:34235,name:"Video Event Horizontal",description:"Horizontal video event",nip:"71",isAddressable:!0,template:{kind:34235,content:"",tags:[["d","identifier"]]}},{kind:34236,name:"Video Event Vertical",description:"Vertical video event",nip:"71",isAddressable:!0,template:{kind:34236,content:"",tags:[["d","identifier"]]}},{kind:34388,name:"Sound Effects",description:"Sound effect definitions",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:34388,content:"",tags:[["d","identifier"]]}},{kind:34550,name:"Community Definition",description:"Define a community",nip:"72",isAddressable:!0,template:{kind:34550,content:"",tags:[["d","identifier"]]}},{kind:37516,name:"Geocache Listing",description:"Geocache location listing",nip:null,isAddressable:!0,spec:"geocaching",template:{kind:37516,content:"",tags:[["d","identifier"]]}},{kind:38172,name:"Cashu Mint Announcement",description:"Cashu mint announcement",nip:"87",isAddressable:!0,template:{kind:38172,content:"",tags:[["d","identifier"]]}},{kind:38173,name:"Fedimint Announcement",description:"Fedimint announcement",nip:"87",isAddressable:!0,template:{kind:38173,content:"",tags:[["d","identifier"]]}},{kind:38383,name:"Peer-to-peer Order Events",description:"P2P trading orders",nip:"69",isAddressable:!0,template:{kind:38383,content:"",tags:[["d","identifier"]]}},{kind:39e3,name:"Group Metadata Events",description:"Group metadata (start of range)",nip:"29",isAddressable:!0,template:{kind:39e3,content:"",tags:[["d","identifier"]]}},{kind:39089,name:"Starter Packs",description:"Starter pack lists",nip:"51",isAddressable:!0,template:{kind:39089,content:"",tags:[["d","identifier"]]}},{kind:39092,name:"Media Starter Packs",description:"Media starter packs",nip:"51",isAddressable:!0,template:{kind:39092,content:"",tags:[["d","identifier"]]}},{kind:39701,name:"Web Bookmarks",description:"Web URL bookmarks",nip:"B0",isAddressable:!0,template:{kind:39701,content:"",tags:[["d","identifier"]]}},{kind:39998,name:"ACL Event",description:"Access control list event",nip:null,isAddressable:!0,template:{kind:39998,content:"",tags:[["d","identifier"]]}}];function _y(e,t=null){const n=function(e){return Ny.find(t=>t.kind===e)}(e);return n?{...n.template,created_at:Math.floor(Date.now()/1e3),pubkey:t||""}:{kind:e,content:"",tags:[],created_at:Math.floor(Date.now()/1e3),pubkey:t||""}}const Ly=[{id:"all",name:"All Kinds",filter:()=>!0},{id:"regular",name:"Regular Events (0-9999)",filter:e=>e.kind<1e4&&!e.isReplaceable},{id:"replaceable",name:"Replaceable (10000-19999)",filter:e=>e.isReplaceable},{id:"ephemeral",name:"Ephemeral (20000-29999)",filter:e=>e.isEphemeral},{id:"addressable",name:"Addressable (30000-39999)",filter:e=>e.isAddressable},{id:"social",name:"Social",filter:e=>[0,1,3,6,7].includes(e.kind)},{id:"messaging",name:"Messaging",filter:e=>[4,9,10,11,12,14,15,40,41,42].includes(e.kind)},{id:"lists",name:"Lists",filter:e=>e.name.toLowerCase().includes("list")||e.name.toLowerCase().includes("set")},{id:"marketplace",name:"Marketplace",filter:e=>[30017,30018,30019,30020,1021,1022,30402,30403].includes(e.kind)},{id:"lightning",name:"Lightning/Zaps",filter:e=>[9734,9735,9041,9321,7374,7375,7376].includes(e.kind)},{id:"media",name:"Media",filter:e=>[20,21,22,1063,1222,1244].includes(e.kind)},{id:"git",name:"Git/Code",filter:e=>[818,1337,1617,1618,1619,1621,1622,30617,30618].includes(e.kind)},{id:"calendar",name:"Calendar",filter:e=>[31922,31923,31924,31925].includes(e.kind)},{id:"groups",name:"Groups",filter:e=>e.kind>=9e3&&e.kind<=9030||e.kind>=39e3&&e.kind<=39009}];function My(e,t,n){const i=e.slice();return i[13]=t[n],i}function Oy(e,t,n){const i=e.slice();return i[16]=t[n],i}function jy(e){let t,n,r,s,o,l,a,c,u,d,y,b,k,C,S,B,Q,F,$,D,R,P,T,U,N,_=e[3].length+"",L=1!==e[3].length?"s":"",M=Ly,O=[];for(let t=0;t=2e4&&e.kind<3e4?"badge-ephemeral":"badge-regular"}function zy(e){return e.isAddressable?"Addressable":e.isReplaceable?"Replaceable":e.kind>=2e4&&e.kind<3e4?"Ephemeral":"Regular"}function Wy(e,t,n){let{isOpen:i=!1}=t,{userPubkey:r=""}=t;const s=U();let o="",l="all",a=Ny;function c(e){const t=_y(e.kind,r);s("select",{kind:e,template:t}),u()}function u(){n(0,i=!1),n(1,o=""),n(2,l="all"),s("close")}return e.$$set=e=>{"isOpen"in e&&n(0,i=e.isOpen),"userPubkey"in e&&n(8,r=e.userPubkey)},e.$$.update=()=>{if(6&e.$$.dirty){let e=Ny;const t=Ly.find(e=>e.id===l);if(t&&(e=e.filter(t.filter)),o.trim()){const t=o.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.kind.toString().includes(t)||e.nip&&e.nip.includes(t))}n(3,a=e)}},[i,o,l,a,c,u,function(e){"Escape"===e.key&&u()},function(e){e.target===e.currentTarget&&u()},r,function(){o=this.value,n(1,o)},e=>n(2,l=e.id),e=>c(e)]}class Zy extends ae{constructor(e){super(),le(this,e,Wy,Vy,s,{isOpen:0,userPubkey:8})}}function Xy(e){let t,n,i,r,s,o,l,a,c,u;return{c(){t=m("div"),n=m("div"),i=m("span"),i.textContent="⚠",r=w(),s=m("span"),o=v(e[1]),l=w(),a=m("button"),a.textContent="×",I(i,"class","error-icon svelte-1gh9ysu"),I(s,"class","error-message svelte-1gh9ysu"),I(n,"class","error-content svelte-1gh9ysu"),I(a,"class","error-dismiss svelte-1gh9ysu"),I(t,"class","error-banner svelte-1gh9ysu")},m(d,h){p(d,t,h),f(t,n),f(n,i),f(n,r),f(n,s),f(s,o),f(t,l),f(t,a),c||(u=A(a,"click",e[10]),c=!0)},p(e,t){2&t&&E(o,e[1])},d(e){e&&h(t),c=!1,u()}}}function ev(e){let t,n,r,s,o,l,a,c,u,d,g,y,v,b,k,C,E,S,B,Q=e[1]&&Xy(e);function F(t){e[14](t)}let $={userPubkey:e[2]};return void 0!==e[3]&&($.isOpen=e[3]),k=new Zy({props:$}),L.push(()=>ne(k,"isOpen",F)),k.$on("select",e[8]),k.$on("close",e[9]),{c(){t=m("div"),n=m("div"),r=m("button"),r.textContent="Generate Template",s=w(),o=m("button"),o.textContent="Reformat",l=w(),a=m("button"),a.textContent="Sign",c=w(),u=m("button"),u.textContent="Publish",d=w(),Q&&Q.c(),g=w(),y=m("div"),v=m("textarea"),b=w(),ie(k.$$.fragment),I(r,"class","compose-btn template-btn svelte-1gh9ysu"),I(o,"class","compose-btn reformat-btn svelte-1gh9ysu"),I(a,"class","compose-btn sign-btn svelte-1gh9ysu"),I(u,"class","compose-btn publish-btn svelte-1gh9ysu"),I(n,"class","compose-header svelte-1gh9ysu"),I(v,"class","compose-textarea svelte-1gh9ysu"),I(v,"placeholder","Enter your Nostr event JSON here, or click 'Generate Template' to start with a template..."),I(v,"spellcheck","false"),I(y,"class","compose-editor svelte-1gh9ysu"),I(t,"class","compose-view svelte-1gh9ysu")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(n,l),f(n,a),f(n,c),f(n,u),f(t,d),Q&&Q.m(t,null),f(t,g),f(t,y),f(y,v),x(v,e[0]),p(i,b,h),re(k,i,h),E=!0,S||(B=[A(r,"click",e[7]),A(o,"click",e[4]),A(a,"click",e[5]),A(u,"click",e[6]),A(v,"input",e[13])],S=!0)},p(e,[n]){e[1]?Q?Q.p(e,n):(Q=Xy(e),Q.c(),Q.m(t,g)):Q&&(Q.d(1),Q=null),1&n&&x(v,e[0]);const i={};4&n&&(i.userPubkey=e[2]),!C&&8&n&&(C=!0,i.isOpen=e[3],q(()=>C=!1)),k.$set(i)},i(e){E||(ee(k.$$.fragment,e),E=!0)},o(e){te(k.$$.fragment,e),E=!1},d(e){e&&h(t),Q&&Q.d(),e&&h(b),se(k,e),S=!1,i(B)}}}function tv(e,t,n){let{composeEventJson:i=""}=t,{userPubkey:r=""}=t,{userRole:s=""}=t,{policyEnabled:o=!1}=t,{publishError:l=""}=t;const a=U();let c=!1;return e.$$set=e=>{"composeEventJson"in e&&n(0,i=e.composeEventJson),"userPubkey"in e&&n(2,r=e.userPubkey),"userRole"in e&&n(11,s=e.userRole),"policyEnabled"in e&&n(12,o=e.policyEnabled),"publishError"in e&&n(1,l=e.publishError)},[i,l,r,c,function(){a("reformatJson")},function(){a("signEvent")},function(){a("publishEvent")},function(){n(3,c=!0)},function(e){const{kind:t,template:r}=e.detail;n(0,i=JSON.stringify(r,null,2)),a("templateSelected",{kind:t,template:r})},function(){n(3,c=!1)},function(){n(1,l=""),a("clearError")},s,o,function(){i=this.value,n(0,i)},function(e){c=e,n(3,c)}]}class nv extends ae{constructor(e){super(),le(this,e,tv,ev,s,{composeEventJson:0,userPubkey:2,userRole:11,policyEnabled:12,publishError:1})}}function iv(e,t,n){const i=e.slice();return i[23]=t[n],i}function rv(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access sprocket management.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-fiaj1r"),I(s,"class","login-btn svelte-fiaj1r"),I(n,"class","login-prompt svelte-fiaj1r")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[18]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function sv(e){let t,n,i,r,s,o,l,a,c,u=(e[2]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="❌ Owner permission required for sprocket management.",i=w(),r=m("p"),r.innerHTML='To enable sprocket functionality, set the ORLY_OWNERS environment variable with your npub when starting the relay.',s=w(),o=m("p"),l=v("Current user role: "),a=m("strong"),c=v(u),I(n,"class","svelte-fiaj1r"),I(r,"class","svelte-fiaj1r"),I(o,"class","svelte-fiaj1r"),I(t,"class","permission-denied svelte-fiaj1r")},m(e,u){p(e,t,u),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(o,a),f(a,c)},p(e,t){4&t&&u!==(u=(e[2]||"none")+"")&&E(c,u)},d(e){e&&h(t)}}}function ov(e){let t,n,r,s,o,l,a,c,u,d,y,b,k,C,S,B,Q,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te,ne,ie,re,se,oe,le,ae,ce,ue,de,fe,pe,he,ge,me=e[3]?.is_running?"🟢 Running":"🔴 Stopped",ye=e[3]?.script_exists?"✅ Exists":"❌ Not found",ve=e[3]?.pid&&lv(e),we=e[6]&&av(e),be=e[8],Ae=[];for(let t=0;t{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"sprocketStatus"in e&&n(3,s=e.sprocketStatus),"isLoadingSprocket"in e&&n(4,o=e.isLoadingSprocket),"sprocketUploadFile"in e&&n(5,l=e.sprocketUploadFile),"sprocketScript"in e&&n(0,a=e.sprocketScript),"sprocketMessage"in e&&n(6,c=e.sprocketMessage),"sprocketMessageType"in e&&n(7,u=e.sprocketMessageType),"sprocketVersions"in e&&n(8,d=e.sprocketVersions)},[a,i,r,s,o,l,c,u,d,function(){f("restartSprocket")},function(){f("deleteSprocket")},function(e){f("sprocketFileSelect",e)},function(){f("uploadSprocketScript")},function(){f("saveSprocket")},function(){f("loadSprocket")},function(){f("loadVersions")},p,h,function(){f("openLoginModal")},function(){a=this.value,n(0,a)},e=>p(e),e=>h(e.name)]}class hv extends ae{constructor(e){super(),le(this,e,pv,fv,s,{isLoggedIn:1,userRole:2,sprocketStatus:3,isLoadingSprocket:4,sprocketUploadFile:5,sprocketScript:0,sprocketMessage:6,sprocketMessageType:7,sprocketVersions:8})}}function gv(e,t,n){const i=e.slice();return i[26]=t[n],i}function mv(e,t,n){const i=e.slice();return i[29]=t[n],i}function yv(e,t,n){const i=e.slice();return i[32]=t[n],i}function vv(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access policy configuration.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-gkxvxc"),I(s,"class","login-btn svelte-gkxvxc"),I(n,"class","login-prompt svelte-gkxvxc")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[16]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function wv(e){let t,n,i,r,s,o,l,a,c,u=(e[3]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="Policy configuration requires owner or policy admin permissions.",i=w(),r=m("p"),r.innerHTML='To become a policy admin, ask an existing policy admin to add your pubkey\n to the policy_admins list.',s=w(),o=m("p"),l=v("Current user role: "),a=m("strong"),c=v(u),I(n,"class","svelte-gkxvxc"),I(r,"class","svelte-gkxvxc"),I(o,"class","svelte-gkxvxc"),I(t,"class","permission-denied svelte-gkxvxc")},m(e,u){p(e,t,u),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(o,a),f(a,c)},p(e,t){8&t[0]&&u!==(u=(e[3]||"none")+"")&&E(c,u)},d(e){e&&h(t)}}}function bv(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,S,B,Q,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te,ne,ie,re,se,oe,le,ae,ce,ue,de,fe,pe,he,ge,me,ye,ve,we,be,Ae,ke,Ie,Ce,Ee,xe,Se,Be,Qe,Fe,$e,De,Re,Pe=e[5]?"Policy Enabled":"Policy Disabled",Te=e[10].length+"",Ue=e[4]&&Av(),Ne=e[9].length>0&&kv(e),_e=e[7]&&Cv(e);function Le(e,t){return 0===e[1].length?xv:Ev}let Me=Le(e),Oe=Me(e);function je(e,t){return 0===e[10].length?Qv:Bv}let He=je(e),Ge=He(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Policy Editor",s=w(),o=m("div"),l=m("span"),a=v(Pe),c=w(),Ue&&Ue.c(),u=w(),d=m("div"),d.innerHTML='

Edit the policy JSON below and click "Save & Publish" to update the relay's policy configuration.\n Changes are applied immediately after validation.

\n

Policy updates are published as kind 12345 events and require policy admin permissions.

',g=w(),y=m("div"),b=m("textarea"),k=w(),Ne&&Ne.c(),C=w(),S=m("div"),B=m("button"),Q=v("Load Current"),$=w(),D=m("button"),R=v("Format JSON"),P=w(),T=m("button"),U=v("Validate"),N=w(),_=m("button"),L=v("Save & Publish"),M=w(),_e&&_e.c(),O=w(),j=m("div"),H=m("h3"),H.textContent="Policy Administrators",G=w(),q=m("div"),q.innerHTML='

Policy admins can update the relay's policy configuration via kind 12345 events.\n Their follows get whitelisted if policy_follow_whitelist_enabled is true in the policy.

\n

Note: Policy admins are separate from relay admins (ORLY_ADMINS).\n Changes here update the JSON editor - click "Save & Publish" to apply.

',J=w(),K=m("div"),Oe.c(),V=w(),Y=m("div"),z=m("input"),W=w(),Z=m("button"),X=v("+ Add Admin"),te=w(),ne=m("div"),ie=m("h3"),ie.textContent="Policy Follow Whitelist",re=w(),se=m("div"),se.innerHTML='

Pubkeys followed by policy admins (kind 3 events).\n These get automatic read+write access when rules have write_allow_follows: true.

',oe=w(),le=m("div"),ae=m("span"),ce=v(Te),ue=v(" pubkey(s) in whitelist"),de=w(),fe=m("button"),pe=v("🔄 Refresh Follows"),he=w(),ge=m("div"),Ge.c(),me=w(),ye=m("div"),ve=m("h3"),ve.textContent="Policy Reference",we=w(),be=m("div"),Ae=m("h4"),Ae.textContent="Structure Overview",ke=w(),Ie=m("ul"),Ie.innerHTML='
  • kind.whitelist - Only allow these event kinds (takes precedence)
  • \n
  • kind.blacklist - Deny these event kinds (if no whitelist)
  • \n
  • global - Rules applied to all events
  • \n
  • rules - Per-kind rules (keyed by kind number as string)
  • \n
  • default_policy - "allow" or "deny" when no rules match
  • \n
  • policy_admins - Hex pubkeys that can update policy
  • \n
  • policy_follow_whitelist_enabled - Enable follow-based access
  • ',Ce=w(),Ee=m("h4"),Ee.textContent="Rule Fields",xe=w(),Se=m("ul"),Se.innerHTML='
  • description - Human-readable rule description
  • \n
  • write_allow / write_deny - Pubkey lists for write access
  • \n
  • read_allow / read_deny - Pubkey lists for read access
  • \n
  • write_allow_follows - Grant access to policy admin follows
  • \n
  • size_limit - Max total event size in bytes
  • \n
  • content_limit - Max content field size in bytes
  • \n
  • max_expiry - Max expiry offset in seconds
  • \n
  • max_age_of_event - Max age of created_at in seconds
  • \n
  • max_age_event_in_future - Max future offset in seconds
  • \n
  • must_have_tags - Required tag letters (e.g., ["d", "t"])
  • \n
  • tag_validation - Regex patterns for tag values
  • \n
  • script - Path to external validation script
  • ',Be=w(),Qe=m("h4"),Qe.textContent="Example Policy",Fe=w(),$e=m("pre"),$e.textContent=`${e[20]}`,I(r,"class","svelte-gkxvxc"),I(l,"class","status-badge svelte-gkxvxc"),F(l,"enabled",e[5]),I(o,"class","policy-status svelte-gkxvxc"),I(n,"class","policy-header svelte-gkxvxc"),I(d,"class","policy-info svelte-gkxvxc"),I(b,"class","policy-editor svelte-gkxvxc"),I(b,"placeholder","Loading policy configuration..."),b.disabled=e[6],I(b,"spellcheck","false"),I(y,"class","editor-container svelte-gkxvxc"),I(B,"class","policy-btn load-btn svelte-gkxvxc"),B.disabled=e[6],I(D,"class","policy-btn format-btn svelte-gkxvxc"),D.disabled=e[6],I(T,"class","policy-btn validate-btn svelte-gkxvxc"),T.disabled=e[6],I(_,"class","policy-btn save-btn svelte-gkxvxc"),_.disabled=e[6],I(S,"class","policy-actions svelte-gkxvxc"),I(t,"class","policy-section svelte-gkxvxc"),I(q,"class","policy-info svelte-gkxvxc"),I(K,"class","admin-list svelte-gkxvxc"),I(z,"type","text"),I(z,"placeholder","npub or hex pubkey"),z.disabled=e[6],I(z,"class","svelte-gkxvxc"),I(Z,"class","policy-btn add-btn svelte-gkxvxc"),Z.disabled=ee=e[6]||!e[11].trim(),I(Y,"class","add-admin svelte-gkxvxc"),I(j,"class","policy-section svelte-gkxvxc"),I(se,"class","policy-info svelte-gkxvxc"),I(ae,"class","follows-count svelte-gkxvxc"),I(fe,"class","policy-btn refresh-btn svelte-gkxvxc"),fe.disabled=e[6],I(le,"class","follows-header svelte-gkxvxc"),I(ge,"class","follows-list svelte-gkxvxc"),I(ne,"class","policy-section svelte-gkxvxc"),I(Ae,"class","svelte-gkxvxc"),I(Ie,"class","field-list svelte-gkxvxc"),I(Ee,"class","svelte-gkxvxc"),I(Se,"class","field-list svelte-gkxvxc"),I(Qe,"class","svelte-gkxvxc"),I($e,"class","example-json svelte-gkxvxc"),I(be,"class","reference-content svelte-gkxvxc"),I(ye,"class","policy-section svelte-gkxvxc")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(o,c),Ue&&Ue.m(o,null),f(t,u),f(t,d),f(t,g),f(t,y),f(y,b),x(b,e[0]),f(t,k),Ne&&Ne.m(t,null),f(t,C),f(t,S),f(S,B),f(B,Q),f(S,$),f(S,D),f(D,R),f(S,P),f(S,T),f(T,U),f(S,N),f(S,_),f(_,L),f(t,M),_e&&_e.m(t,null),p(i,O,h),p(i,j,h),f(j,H),f(j,G),f(j,q),f(j,J),f(j,K),Oe.m(K,null),f(j,V),f(j,Y),f(Y,z),x(z,e[11]),f(Y,W),f(Y,Z),f(Z,X),p(i,te,h),p(i,ne,h),f(ne,ie),f(ne,re),f(ne,se),f(ne,oe),f(ne,le),f(le,ae),f(ae,ce),f(ae,ue),f(le,de),f(le,fe),f(fe,pe),f(ne,he),f(ne,ge),Ge.m(ge,null),p(i,me,h),p(i,ye,h),f(ye,ve),f(ye,we),f(ye,be),f(be,Ae),f(be,ke),f(be,Ie),f(be,Ce),f(be,Ee),f(be,xe),f(be,Se),f(be,Be),f(be,Qe),f(be,Fe),f(be,$e),De||(Re=[A(b,"input",e[21]),A(B,"click",e[12]),A(D,"click",e[15]),A(T,"click",e[13]),A(_,"click",e[14]),A(z,"input",e[23]),A(z,"keydown",e[24]),A(Z,"click",e[18]),A(fe,"click",e[17])],De=!0)},p(e,n){32&n[0]&&Pe!==(Pe=e[5]?"Policy Enabled":"Policy Disabled")&&E(a,Pe),32&n[0]&&F(l,"enabled",e[5]),e[4]?Ue||(Ue=Av(),Ue.c(),Ue.m(o,null)):Ue&&(Ue.d(1),Ue=null),64&n[0]&&(b.disabled=e[6]),1&n[0]&&x(b,e[0]),e[9].length>0?Ne?Ne.p(e,n):(Ne=kv(e),Ne.c(),Ne.m(t,C)):Ne&&(Ne.d(1),Ne=null),64&n[0]&&(B.disabled=e[6]),64&n[0]&&(D.disabled=e[6]),64&n[0]&&(T.disabled=e[6]),64&n[0]&&(_.disabled=e[6]),e[7]?_e?_e.p(e,n):(_e=Cv(e),_e.c(),_e.m(t,null)):_e&&(_e.d(1),_e=null),Me===(Me=Le(e))&&Oe?Oe.p(e,n):(Oe.d(1),Oe=Me(e),Oe&&(Oe.c(),Oe.m(K,null))),64&n[0]&&(z.disabled=e[6]),2048&n[0]&&z.value!==e[11]&&x(z,e[11]),2112&n[0]&&ee!==(ee=e[6]||!e[11].trim())&&(Z.disabled=ee),1024&n[0]&&Te!==(Te=e[10].length+"")&&E(ce,Te),64&n[0]&&(fe.disabled=e[6]),He===(He=je(e))&&Ge?Ge.p(e,n):(Ge.d(1),Ge=He(e),Ge&&(Ge.c(),Ge.m(ge,null)))},d(e){e&&h(t),Ue&&Ue.d(),Ne&&Ne.d(),_e&&_e.d(),e&&h(O),e&&h(j),Oe.d(),e&&h(te),e&&h(ne),Ge.d(),e&&h(me),e&&h(ye),De=!1,i(Re)}}}function Av(e){let t;return{c(){t=m("span"),t.textContent="Policy Admin",I(t,"class","admin-badge svelte-gkxvxc")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function kv(e){let t,n,i,r,s=e[9],o=[];for(let t=0;t{"isLoggedIn"in e&&n(2,i=e.isLoggedIn),"userRole"in e&&n(3,r=e.userRole),"isPolicyAdmin"in e&&n(4,s=e.isPolicyAdmin),"policyEnabled"in e&&n(5,o=e.policyEnabled),"policyJson"in e&&n(0,l=e.policyJson),"isLoadingPolicy"in e&&n(6,a=e.isLoadingPolicy),"policyMessage"in e&&n(7,c=e.policyMessage),"policyMessageType"in e&&n(8,u=e.policyMessageType),"validationErrors"in e&&n(9,d=e.validationErrors),"policyAdmins"in e&&n(1,f=e.policyAdmins),"policyFollows"in e&&n(10,p=e.policyFollows)},e.$$.update=()=>{if(1&e.$$.dirty[0])try{if(l){const e=JSON.parse(l);n(1,f=e.policy_admins||[])}}catch(e){}},[l,f,i,r,s,o,a,c,u,d,p,g,function(){h("loadPolicy")},function(){h("validatePolicy")},function(){h("savePolicy")},function(){h("formatJson")},function(){h("openLoginModal")},function(){h("refreshFollows")},m,y,'{\n "kind": {\n "whitelist": [0, 1, 3, 6, 7, 10002],\n "blacklist": []\n },\n "global": {\n "description": "Global rules applied to all events",\n "size_limit": 65536,\n "max_age_of_event": 86400,\n "max_age_event_in_future": 300\n },\n "rules": {\n "1": {\n "description": "Kind 1 (short text notes)",\n "content_limit": 8192,\n "write_allow_follows": true\n },\n "30023": {\n "description": "Long-form articles",\n "content_limit": 100000,\n "tag_validation": {\n "d": "^[a-z0-9-]{1,64}$",\n "t": "^[a-z0-9-]{1,32}$"\n }\n }\n },\n "default_policy": "allow",\n "policy_admins": [""],\n "policy_follow_whitelist_enabled": true\n}',function(){l=this.value,n(0,l)},e=>y(e),function(){g=this.value,n(11,g)},e=>"Enter"===e.key&&m()]}class Rv extends ae{constructor(e){super(),le(this,e,Dv,$v,s,{isLoggedIn:2,userRole:3,isPolicyAdmin:4,policyEnabled:5,policyJson:0,isLoadingPolicy:6,policyMessage:7,policyMessageType:8,validationErrors:9,policyAdmins:1,policyFollows:10},null,[-1,-1])}}const Pv=[{id:"social",name:"Social/Notes",description:"User profiles, notes, follows, reposts, reactions, and relay lists",kinds:[0,1,3,6,7,10002]},{id:"dm",name:"Direct Messages",description:"Encrypted direct messages (legacy and NIP-17 gift-wrapped)",kinds:[4,14,1059]},{id:"longform",name:"Long-form Content",description:"Blog posts and article drafts",kinds:[30023,30024]},{id:"media",name:"Media",description:"File metadata and media attachments",kinds:[1063,20,21,22]},{id:"marketplace_nip15",name:"Marketplace (NIP-15)",description:"Legacy NIP-15 stalls and products",kinds:[30017,30018,30019,30020]},{id:"marketplace_nip99",name:"Marketplace (NIP-99/Gamma)",description:"NIP-99 classified listings, collections, shipping, reviews (Plebeian Market)",kinds:[30402,30403,30405,30406,31555]},{id:"order_communication",name:"Order Communication",description:"Gamma Markets order messages and payment receipts (kinds 16, 17)",kinds:[16,17]},{id:"groups_nip29",name:"Group Messaging (NIP-29)",description:"Simple relay-based group chat messages",kinds:[9,10,11,12]},{id:"groups_nip72",name:"Communities (NIP-72)",description:"Community definitions and threaded discussions",kinds:[34550,1111,4550]},{id:"lists",name:"Lists/Bookmarks",description:"Mute lists, pin lists, and parameterized list events",kinds:[1e4,10001,3e4,30001]}];function Tv(e,t,n){const i=e.slice();return i[90]=t[n],i}function Uv(e,t,n){const i=e.slice();return i[98]=t[n],i}function Nv(e,t,n){const i=e.slice();return i[93]=t[n],i}function _v(e,t,n){const i=e.slice();return i[103]=t[n],i}function Lv(e,t,n){const i=e.slice();return i[106]=t[n],i}function Mv(e,t,n){const i=e.slice();return i[106]=t[n],i}function Ov(e,t,n){const i=e.slice();return i[93]=t[n],i}function jv(e,t,n){const i=e.slice();return i[90]=t[n],i}function Hv(e){let t,n,i;return{c(){t=m("div"),n=v(e[2]),I(t,"class",i="message "+e[3]+" svelte-1i0huu3")},m(e,i){p(e,t,i),f(t,n)},p(e,r){4&r[0]&&E(n,e[2]),8&r[0]&&i!==(i="message "+e[3]+" svelte-1i0huu3")&&I(t,"class",i)},d(e){e&&h(t)}}}function Gv(e){let t;function n(e,t){return e[5]?Kv:Jv}let i=n(e),r=i(e);return{c(){r.c(),t=b()},m(e,n){r.m(e,n),p(e,t,n)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t.parentNode,t)))},d(e){r.d(e),e&&h(t)}}}function qv(e){let t,n,r,s,o,l,a,c,u,d,y,v,b,k,E,S,B,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X=Pv,ee=[];for(let t=0;tInitial Configuration \n

    Configure curating mode before the relay will accept events. Select which event kinds to allow and set rate limiting parameters.

    ',r=w(),s=m("div"),o=m("h4"),o.textContent="Allowed Event Kinds",l=w(),a=m("p"),a.textContent="Select categories of events to allow. At least one must be selected.",c=w(),u=m("div");for(let e=0;e0?zv:Yv}let B=S(e),Q=B(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Trusted Publishers",r=w(),s=m("p"),s.textContent="Trusted users can publish unlimited events without rate limiting.",o=w(),l=m("div"),a=m("input"),c=w(),u=m("input"),d=w(),g=m("button"),y=v("Trust"),b=w(),k=m("div"),Q.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(a,"type","text"),I(a,"placeholder","Pubkey (64 hex chars)"),I(a,"class","svelte-1i0huu3"),I(u,"type","text"),I(u,"placeholder","Note (optional)"),I(u,"class","svelte-1i0huu3"),g.disabled=e[1],I(g,"class","svelte-1i0huu3"),I(l,"class","add-form svelte-1i0huu3"),I(k,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a),x(a,e[13]),f(l,c),f(l,u),x(u,e[14]),f(l,d),f(l,g),f(g,y),f(t,b),f(t,k),Q.m(k,null),C||(E=[A(a,"input",e[58]),A(u,"input",e[59]),A(g,"click",e[60])],C=!0)},p(e,t){8192&t[0]&&a.value!==e[13]&&x(a,e[13]),16384&t[0]&&u.value!==e[14]&&x(u,e[14]),2&t[0]&&(g.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(k,null)))},d(e){e&&h(t),Q.d(),C=!1,i(E)}}}function Yv(t){let n;return{c(){n=m("div"),n.textContent="No trusted pubkeys yet.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function zv(e){let t,n=e[12],i=[];for(let t=0;t0?tw:ew}let B=S(e),Q=B(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Blacklisted Publishers",r=w(),s=m("p"),s.textContent="Blacklisted users cannot publish any events.",o=w(),l=m("div"),a=m("input"),c=w(),u=m("input"),d=w(),g=m("button"),y=v("Blacklist"),b=w(),k=m("div"),Q.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(a,"type","text"),I(a,"placeholder","Pubkey (64 hex chars)"),I(a,"class","svelte-1i0huu3"),I(u,"type","text"),I(u,"placeholder","Reason (optional)"),I(u,"class","svelte-1i0huu3"),g.disabled=e[1],I(g,"class","svelte-1i0huu3"),I(l,"class","add-form svelte-1i0huu3"),I(k,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a),x(a,e[16]),f(l,c),f(l,u),x(u,e[17]),f(l,d),f(l,g),f(g,y),f(t,b),f(t,k),Q.m(k,null),C||(E=[A(a,"input",e[63]),A(u,"input",e[64]),A(g,"click",e[65])],C=!0)},p(e,t){65536&t[0]&&a.value!==e[16]&&x(a,e[16]),131072&t[0]&&u.value!==e[17]&&x(u,e[17]),2&t[0]&&(g.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(k,null)))},d(e){e&&h(t),Q.d(),C=!1,i(E)}}}function ew(t){let n;return{c(){n=m("div"),n.textContent="No blacklisted pubkeys.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function tw(e){let t,n=e[15],i=[];for(let t=0;t0?ow:sw}let x=E(e),S=x(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Unclassified Users",r=w(),s=m("p"),s.textContent="Users who have posted events but haven't been classified. Sorted by event count.",o=w(),l=m("div"),a=m("button"),c=v("Refresh"),u=w(),d=m("button"),g=v("Scan Database"),y=w(),b=m("div"),S.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(a,"class","refresh-btn svelte-1i0huu3"),a.disabled=e[1],I(d,"class","scan-btn svelte-1i0huu3"),d.disabled=e[1],I(l,"class","button-row svelte-1i0huu3"),I(b,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a),f(a,c),f(l,u),f(l,d),f(d,g),f(t,y),f(t,b),S.m(b,null),k||(C=[A(a,"click",e[21]),A(d,"click",e[22])],k=!0)},p(e,t){2&t[0]&&(a.disabled=e[1]),2&t[0]&&(d.disabled=e[1]),x===(x=E(e))&&S?S.p(e,t):(S.d(1),S=x(e),S&&(S.c(),S.m(b,null)))},d(e){e&&h(t),S.d(),k=!1,i(C)}}}function sw(t){let n;return{c(){n=m("div"),n.textContent="No unclassified users.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function ow(e){let t,n=e[18],i=[];for(let t=0;t0?uw:cw}let y=g(e),b=y(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Spam Events",i=w(),r=m("p"),r.textContent="Events flagged as spam are hidden from query results but remain in the database.",s=w(),o=m("button"),l=v("Refresh"),a=w(),c=m("div"),b.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],I(c,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(h,g){p(h,t,g),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(t,a),f(t,c),b.m(c,null),u||(d=A(o,"click",e[23]),u=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),y===(y=g(e))&&b?b.p(e,t):(b.d(1),b=y(e),b&&(b.c(),b.m(c,null)))},d(e){e&&h(t),b.d(),u=!1,d()}}}function cw(t){let n;return{c(){n=m("div"),n.textContent="No spam events flagged.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function uw(e){let t,n=e[19],i=[];for(let t=0;t0?gw:hw}let y=g(e),b=y(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Blocked IP Addresses",i=w(),r=m("p"),r.textContent="IP addresses blocked due to rate limit violations.",s=w(),o=m("button"),l=v("Refresh"),a=w(),c=m("div"),b.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],I(c,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(h,g){p(h,t,g),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(t,a),f(t,c),b.m(c,null),u||(d=A(o,"click",e[24]),u=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),y===(y=g(e))&&b?b.p(e,t):(b.d(1),b=y(e),b&&(b.c(),b.m(c,null)))},d(e){e&&h(t),b.d(),u=!1,d()}}}function hw(t){let n;return{c(){n=m("div"),n.textContent="No blocked IPs.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function gw(e){let t,n=e[20],i=[];for(let t=0;t100*t&&(i=i.substring(0,100*t)),i}function Ow(e,t=6){if(!e)return!1;return e.split("\n").length>t||e.length>100*t}function jw(e){return{0:"Metadata",1:"Text Note",3:"Follow List",4:"Encrypted DM",6:"Repost",7:"Reaction",14:"Chat Message",16:"Order Message",17:"Payment Receipt",1063:"File Metadata",10002:"Relay List",30017:"Stall",30018:"Product (NIP-15)",30023:"Long-form",30078:"App Data",30402:"Product (NIP-99)",30405:"Collection",30406:"Shipping",31555:"Review"}[e]||`Kind ${e}`}function Hw(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="trusted",o=!1,l="",a="info",c=!1,u=null,d=null,f=[],p=0,h=0,g=!1,m={},y={daily_limit:50,first_ban_hours:1,second_ban_hours:168,categories:[],custom_kinds:"",kind_ranges:[]},v=[],w="",b="",A=[],k="",I="",E=[],x=[],S=[];async function B(e,t=[]){try{n(1,o=!0),n(2,l="");const s={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available.");const n=xp()+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s);return`Nostr ${btoa(JSON.stringify(o))}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(s)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(2,l=e.message),n(3,a="error"),e}finally{n(1,o=!1)}}async function Q(){await Promise.all([F(),$(),D(),R(),T()])}async function F(){try{n(12,v=await B("listtrustedpubkeys"))}catch(e){console.error("Failed to load trusted pubkeys:",e),n(12,v=[])}}async function $(){try{n(15,A=await B("listblacklistedpubkeys"))}catch(e){console.error("Failed to load blacklisted pubkeys:",e),n(15,A=[])}}async function D(){try{n(18,E=await B("listunclassifiedusers"))}catch(e){console.error("Failed to load unclassified users:",e),n(18,E=[])}}async function R(){try{n(19,x=await B("listspamevents"))}catch(e){console.error("Failed to load spam events:",e),n(19,x=[])}}async function T(){try{n(20,S=await B("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e),n(20,S=[])}}async function U(e=null,t=""){const i=e||w,r=e?t:b;if(i)try{await B("trustpubkey",[i,r]),n(2,l="Pubkey trusted successfully"),n(3,a="success"),n(13,w=""),n(14,b=""),await F(),await D()}catch(e){console.error("Failed to trust pubkey:",e)}}async function N(e){try{await B("untrustpubkey",[e]),n(2,l="Pubkey untrusted"),n(3,a="success"),await F()}catch(e){console.error("Failed to untrust pubkey:",e)}}async function _(e=null,t=""){const i=e||k,r=e?t:I;if(i)try{await B("blacklistpubkey",[i,r]),n(2,l="Pubkey blacklisted"),n(3,a="success"),n(16,k=""),n(17,I=""),await $(),await D()}catch(e){console.error("Failed to blacklist pubkey:",e)}}async function L(e){try{await B("unblacklistpubkey",[e]),n(2,l="Pubkey removed from blacklist"),n(3,a="success"),await $()}catch(e){console.error("Failed to remove from blacklist:",e)}}async function M(e){try{await B("unmarkspam",[e]),n(2,l="Spam mark removed"),n(3,a="success"),await R()}catch(e){console.error("Failed to unmark spam:",e)}}async function O(e){if(confirm("Permanently delete this event?"))try{await B("deleteevent",[e]),n(2,l="Event deleted"),n(3,a="success"),await R()}catch(e){console.error("Failed to delete event:",e)}}async function j(e){try{await B("unblockip",[e]),n(2,l="IP unblocked"),n(3,a="success"),await T()}catch(e){console.error("Failed to unblock IP:",e)}}function H(e){y.categories.includes(e)?n(11,y.categories=y.categories.filter(t=>t!==e),y):n(11,y.categories=[...y.categories,e],y)}async function G(){if(!i||!r)return n(2,l="Please log in with a Nostr extension to publish configuration"),void n(3,a="error");if(0===y.categories.length&&!y.custom_kinds.trim())return n(2,l="Please select at least one kind category or enter custom kinds"),void n(3,a="error");try{n(1,o=!0),n(2,l="");const e=[["d","curating-config"],["daily_limit",String(y.daily_limit)],["first_ban_hours",String(y.first_ban_hours)],["second_ban_hours",String(y.second_ban_hours)]];for(const t of y.categories)e.push(["kind_category",t]);const t=function(e){if(!e||!e.trim())return[];const t=new Set,n=e.split(",").map(e=>e.trim());for(const e of n)if(e)if(e.includes("-")){const[n,i]=e.split("-").map(e=>parseInt(e.trim(),10));if(!isNaN(n)&&!isNaN(i)&&n<=i&&i-n<=1e3)for(let e=n;e<=i;e++)t.add(e)}else{const n=parseInt(e,10);isNaN(n)||t.add(n)}return Array.from(t).sort((e,t)=>e-t)}(y.custom_kinds);for(const n of t)e.push(["kind",String(n)]);const s={kind:30078,created_at:Math.floor(Date.now()/1e3),tags:e,content:"Curating relay configuration",pubkey:r},u=await i.signEvent(s),d=new WebSocket(Sp());await new Promise((e,t)=>{d.onopen=()=>{d.send(JSON.stringify(["EVENT",u]))},d.onmessage=n=>{const i=JSON.parse(n.data);"OK"===i[0]&&(!0===i[2]?e():t(new Error(i[3]||"Event rejected")))},d.onerror=e=>t(new Error("WebSocket error")),setTimeout(()=>t(new Error("Timeout")),1e4)}),d.close(),n(2,l="Configuration published successfully"),n(3,a="success"),n(4,c=!0),await Q()}catch(e){console.error("Failed to publish configuration:",e),n(2,l=`Failed to publish: ${e.message}`),n(3,a="error")}finally{n(1,o=!1)}}function q(e,t="info"){n(2,l=e),n(3,a=t)}async function J(e,t){console.log("openUserDetail called:",e,t),n(5,u=e),n(6,d=t),n(7,f=[]),n(8,p=0),h=0,n(10,m={}),console.log("selectedUser set to:",u),await V()}function K(){n(5,u=null),n(6,d=null),n(7,f=[]),n(8,p=0),h=0,n(10,m={})}async function V(){if(console.log("loadUserEvents called, selectedUser:",u,"loadingEvents:",g),u&&!g)try{n(9,g=!0),console.log("Calling geteventsforpubkey API...");const e=await B("geteventsforpubkey",[u,100,h]);console.log("API result:",e),e&&(n(7,f=0===h?e.events||[]:[...f,...e.events||[]]),n(8,p=e.total||0))}catch(e){console.error("Failed to load user events:",e),q("Failed to load events: "+e.message,"error")}finally{n(9,g=!1)}}function Y(e){n(10,m={...m,[e]:!m[e]})}P(async()=>{await async function(){try{const e=await B("isconfigured");n(4,c=!0===e),c&&(await async function(){try{const e=await B("getcuratingconfig");e&&n(11,y={daily_limit:e.daily_limit||50,first_ban_hours:e.first_ban_hours||1,second_ban_hours:e.second_ban_hours||168,categories:e.categories||[],custom_kinds:e.custom_kinds?e.custom_kinds.join(", "):"",kind_ranges:e.kind_ranges||[]})}catch(e){console.error("Failed to load config:",e)}}(),await Q())}catch(e){console.error("Failed to check configuration:",e),n(4,c=!1)}}()});return e.$$set=e=>{"userSigner"in e&&n(44,i=e.userSigner),"userPubkey"in e&&n(45,r=e.userPubkey)},[s,o,l,a,c,u,d,f,p,g,m,y,v,w,b,A,k,I,E,x,S,D,async function(){try{const e=await B("scanpubkeys");q(`Database scanned: ${e.total_pubkeys} pubkeys, ${e.total_events} events (${e.skipped} skipped)`,"success"),await D()}catch(e){console.error("Failed to scan database:",e),q("Failed to scan database: "+e.message,"error")}},R,T,U,N,_,L,M,O,j,H,G,async function(){await G()},J,K,async function(){h=f.length,await V()},Y,async function(){await U(u,""),await Q(),K()},async function(){await _(u,""),await Q(),K()},async function(){await N(u),await Q(),K()},async function(){await L(u),await Q(),K()},async function(){if(confirm(`Delete ALL ${p} events from this user? This cannot be undone.`))try{n(1,o=!0);q(`Deleted ${(await B("deleteeventsforpubkey",[u])).deleted} events`,"success"),n(7,f=[]),n(8,p=0),h=0,await V()}catch(e){console.error("Failed to delete events:",e),q("Failed to delete events: "+e.message,"error")}finally{n(1,o=!1)}},i,r,e=>H(e.id),function(){y.custom_kinds=this.value,n(11,y)},function(){y.daily_limit=C(this.value),n(11,y)},function(){y.first_ban_hours=C(this.value),n(11,y)},function(){y.second_ban_hours=C(this.value),n(11,y)},e=>Y(e.id),()=>n(0,s="trusted"),()=>n(0,s="blacklist"),()=>n(0,s="unclassified"),()=>n(0,s="spam"),()=>n(0,s="ips"),()=>n(0,s="settings"),function(){w=this.value,n(13,w)},function(){b=this.value,n(14,b)},()=>U(),e=>N(e.pubkey),e=>J(e.pubkey,"trusted"),function(){k=this.value,n(16,k)},function(){I=this.value,n(17,I)},()=>_(),e=>L(e.pubkey),e=>J(e.pubkey,"blacklisted"),e=>U(e.pubkey,""),e=>_(e.pubkey,""),e=>J(e.pubkey,"unclassified"),e=>M(e.event_id),e=>O(e.event_id),e=>j(e.ip),e=>H(e.id),function(){y.custom_kinds=this.value,n(11,y)},function(){y.daily_limit=C(this.value),n(11,y)},function(){y.first_ban_hours=C(this.value),n(11,y)},function(){y.second_ban_hours=C(this.value),n(11,y)}]}class Gw extends ae{constructor(e){super(),le(this,e,Hw,Nw,s,{userSigner:44,userPubkey:45},null,[-1,-1,-1,-1])}}function qw(e,t,n){const i=e.slice();return i[58]=t[n],i}function Jw(e,t,n){const i=e.slice();return i[55]=t[n],i}function Kw(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to view your Blossom storage.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-on0yal"),I(s,"class","login-btn svelte-on0yal"),I(n,"class","login-prompt svelte-on0yal")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[21]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function Vw(e){let t,n,i,r,s,o,l,a,c,u,d,g,y,b,k=e[0]||e[12]?"Loading...":"Refresh";function C(e,t){return e[13]?Ww:e[10]?zw:Yw}let x=C(e),S=x(e),B=e[14]&&!e[10]&&!e[13]&&Xw(e),Q=!e[10]&&!e[13]&&eb(e),F=e[2]&&nb(e);function $(e,t){return e[10]&&!e[13]?rb:ib}let D=$(e),R=D(e);return{c(){t=m("div"),n=m("div"),S.c(),i=w(),r=m("div"),B&&B.c(),s=w(),o=m("button"),l=v("🔄 "),a=v(k),u=w(),Q&&Q.c(),d=w(),F&&F.c(),g=w(),R.c(),I(o,"class","refresh-btn svelte-on0yal"),o.disabled=c=e[0]||e[12],I(r,"class","header-buttons svelte-on0yal"),I(n,"class","header-section svelte-on0yal"),I(t,"class","blossom-view svelte-on0yal")},m(c,h){p(c,t,h),f(t,n),S.m(n,null),f(n,i),f(n,r),B&&B.m(r,null),f(r,s),f(r,o),f(o,l),f(o,a),f(t,u),Q&&Q.m(t,null),f(t,d),F&&F.m(t,null),f(t,g),R.m(t,null),y||(b=A(o,"click",e[31]),y=!0)},p(e,l){x===(x=C(e))&&S?S.p(e,l):(S.d(1),S=x(e),S&&(S.c(),S.m(n,i))),!e[14]||e[10]||e[13]?B&&(B.d(1),B=null):B?B.p(e,l):(B=Xw(e),B.c(),B.m(r,s)),4097&l[0]&&k!==(k=e[0]||e[12]?"Loading...":"Refresh")&&E(a,k),4097&l[0]&&c!==(c=e[0]||e[12])&&(o.disabled=c),e[10]||e[13]?Q&&(Q.d(1),Q=null):Q?Q.p(e,l):(Q=eb(e),Q.c(),Q.m(t,d)),e[2]?F?F.p(e,l):(F=nb(e),F.c(),F.m(t,g)):F&&(F.d(1),F=null),D===(D=$(e))&&R?R.p(e,l):(R.d(1),R=D(e),R&&(R.c(),R.m(t,null)))},d(e){e&&h(t),S.d(),B&&B.d(),Q&&Q.d(),F&&F.d(),R.d(),y=!1,b()}}}function Yw(t){let n;return{c(){n=m("h3"),n.textContent="Blossom Media Storage",I(n,"class","svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function zw(t){let n,i,r,s,o;return{c(){n=m("button"),n.textContent="← Back",i=w(),r=m("h3"),r.textContent="All Users Storage",I(n,"class","back-btn svelte-on0yal"),I(r,"class","svelte-on0yal")},m(e,l){p(e,n,l),p(e,i,l),p(e,r,l),s||(o=A(n,"click",t[28]),s=!0)},p:e,d(e){e&&h(n),e&&h(i),e&&h(r),s=!1,o()}}}function Ww(e){let t,n,i,r,s,o,l,a=(e[13].profile?.name||Rb(e[26](e[13].pubkey)))+"",c=e[13].profile?.picture&&Zw(e);return{c(){t=m("button"),t.textContent="← Back",n=w(),i=m("h3"),c&&c.c(),r=w(),s=v(a),I(t,"class","back-btn svelte-on0yal"),I(i,"class","user-header svelte-on0yal")},m(a,u){p(a,t,u),p(a,n,u),p(a,i,u),c&&c.m(i,null),f(i,r),f(i,s),o||(l=A(t,"click",e[30]),o=!0)},p(e,t){e[13].profile?.picture?c?c.p(e,t):(c=Zw(e),c.c(),c.m(i,r)):c&&(c.d(1),c=null),8192&t[0]&&a!==(a=(e[13].profile?.name||Rb(e[26](e[13].pubkey)))+"")&&E(s,a)},d(e){e&&h(t),e&&h(n),e&&h(i),c&&c.d(),o=!1,l()}}}function Zw(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[13].profile.picture)||I(t,"src",n),I(t,"alt",""),I(t,"class","header-avatar svelte-on0yal")},m(e,n){p(e,t,n)},p(e,i){8192&i[0]&&!l(t.src,n=e[13].profile.picture)&&I(t,"src",n)},d(e){e&&h(t)}}}function Xw(e){let t,n,i,r;return{c(){t=m("button"),n=v("Admin"),I(t,"class","admin-btn svelte-on0yal"),t.disabled=e[0]},m(s,o){p(s,t,o),f(t,n),i||(r=A(t,"click",e[27]),i=!0)},p(e,n){1&n[0]&&(t.disabled=e[0])},d(e){e&&h(t),i=!1,r()}}}function eb(e){let t,n,r,s,o,l,a,c,u,d,g=e[3].length>0&&tb(e);return{c(){t=m("div"),n=m("span"),n.textContent="Upload new files",r=w(),s=m("input"),o=w(),g&&g.c(),l=w(),a=m("button"),c=v("Select Files"),I(n,"class","upload-label svelte-on0yal"),I(s,"type","file"),s.multiple=!0,I(s,"class","file-input-hidden svelte-on0yal"),I(a,"class","select-btn svelte-on0yal"),a.disabled=e[4],I(t,"class","upload-section svelte-on0yal")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),e[40](s),f(t,o),g&&g.m(t,null),f(t,l),f(t,a),f(a,c),u||(d=[A(s,"change",e[23]),A(a,"click",e[24])],u=!0)},p(e,n){e[3].length>0?g?g.p(e,n):(g=tb(e),g.c(),g.m(t,l)):g&&(g.d(1),g=null),16&n[0]&&(a.disabled=e[4])},d(n){n&&h(t),e[40](null),g&&g.d(),u=!1,i(d)}}}function tb(e){let t,n,i,r,s,o,l,a,c=e[3].length+"",u=(e[4]?e[5]:"Upload")+"";return{c(){t=m("span"),n=v(c),i=v(" file(s) selected"),r=w(),s=m("button"),o=v(u),I(t,"class","selected-count svelte-on0yal"),I(s,"class","upload-btn svelte-on0yal"),s.disabled=e[4]},m(c,u){p(c,t,u),f(t,n),f(t,i),p(c,r,u),p(c,s,u),f(s,o),l||(a=A(s,"click",e[25]),l=!0)},p(e,t){8&t[0]&&c!==(c=e[3].length+"")&&E(n,c),48&t[0]&&u!==(u=(e[4]?e[5]:"Upload")+"")&&E(o,u),16&t[0]&&(s.disabled=e[4])},d(e){e&&h(t),e&&h(r),e&&h(s),l=!1,a()}}}function nb(e){let t,n;return{c(){t=m("div"),n=v(e[2]),I(t,"class","error-message svelte-on0yal")},m(e,i){p(e,t,i),f(t,n)},p(e,t){4&t[0]&&E(n,e[2])},d(e){e&&h(t)}}}function ib(e){let t,n,i;function r(e,i){return 1&i[0]&&(t=null),null==t&&(t=!(!e[0]||0!==e[32]().length)),t?lb:(null==n&&(n=!(0!==e[32]().length)),n?ob:sb)}let s=r(e,[-1,-1]),o=s(e);return{c(){o.c(),i=b()},m(e,t){o.m(e,t),p(e,i,t)},p(e,t){s===(s=r(e,t))&&o?o.p(e,t):(o.d(1),o=s(e),o&&(o.c(),o.m(i.parentNode,i)))},d(e){o.d(e),e&&h(i)}}}function rb(e){let t;function n(e,t){return e[12]?hb:0===e[11].length?pb:fb}let i=n(e),r=i(e);return{c(){r.c(),t=b()},m(e,n){r.m(e,n),p(e,t,n)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t.parentNode,t)))},d(e){r.d(e),e&&h(t)}}}function sb(e){let t,n=e[32](),i=[];for(let t=0;tNo users have uploaded files yet.

    ",I(n,"class","empty-state svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function hb(t){let n;return{c(){n=m("div"),n.textContent="Loading user statistics...",I(n,"class","loading svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function gb(t){let n;return{c(){n=m("div"),I(n,"class","user-avatar-placeholder svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function mb(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[55].profile.picture)||I(t,"src",n),I(t,"alt",""),I(t,"class","user-avatar svelte-on0yal")},m(e,n){p(e,t,n)},p(e,i){2048&i[0]&&!l(t.src,n=e[55].profile.picture)&&I(t,"src",n)},d(e){e&&h(t)}}}function yb(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,x,S,B,Q,F,$,D,R,P,T,U=(e[55].profile?.name||Rb(e[26](e[55].pubkey)))+"",N=e[26](e[55].pubkey)+"",_=Rb(e[26](e[55].pubkey))+"",L=e[55].blob_count+"",M=Bb(e[55].total_size_bytes)+"";function O(e,t){return e[55].profile?.picture?mb:gb}let j=O(e),H=j(e);function G(){return e[41](e[55])}function q(...t){return e[42](e[55],...t)}return{c(){t=m("div"),n=m("div"),H.c(),r=w(),s=m("div"),o=m("div"),l=v(U),a=w(),c=m("div"),u=m("span"),d=v(N),g=w(),y=m("span"),b=v(_),C=w(),x=m("div"),S=m("span"),B=v(L),Q=v(" files"),F=w(),$=m("span"),D=v(M),R=w(),I(n,"class","user-avatar-container svelte-on0yal"),I(o,"class","user-name svelte-on0yal"),I(u,"class","npub-full svelte-on0yal"),I(y,"class","npub-truncated svelte-on0yal"),I(c,"class","user-npub svelte-on0yal"),I(c,"title",k=e[55].pubkey),I(s,"class","user-info svelte-on0yal"),I(S,"class","blob-count svelte-on0yal"),I($,"class","total-size svelte-on0yal"),I(x,"class","user-stats svelte-on0yal"),I(t,"class","user-stat-item svelte-on0yal"),I(t,"role","button"),I(t,"tabindex","0")},m(e,i){p(e,t,i),f(t,n),H.m(n,null),f(t,r),f(t,s),f(s,o),f(o,l),f(s,a),f(s,c),f(c,u),f(u,d),f(c,g),f(c,y),f(y,b),f(t,C),f(t,x),f(x,S),f(S,B),f(S,Q),f(x,F),f(x,$),f($,D),f(t,R),P||(T=[A(t,"click",G),A(t,"keypress",q)],P=!0)},p(t,i){j===(j=O(e=t))&&H?H.p(e,i):(H.d(1),H=j(e),H&&(H.c(),H.m(n,null))),2048&i[0]&&U!==(U=(e[55].profile?.name||Rb(e[26](e[55].pubkey)))+"")&&E(l,U),2048&i[0]&&N!==(N=e[26](e[55].pubkey)+"")&&E(d,N),2048&i[0]&&_!==(_=Rb(e[26](e[55].pubkey))+"")&&E(b,_),2048&i[0]&&k!==(k=e[55].pubkey)&&I(c,"title",k),2048&i[0]&&L!==(L=e[55].blob_count+"")&&E(B,L),2048&i[0]&&M!==(M=Bb(e[55].total_size_bytes)+"")&&E(D,M)},d(e){e&&h(t),H.d(),P=!1,i(T)}}}function vb(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,C,x,S,B,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te=Fb(e[8].sha256)+"",ne=(e[8].type||"unknown")+"",ie="image"===$b(e[8].type),re=Bb(e[8].size)+"",se=Qb(e[8].uploaded)+"",oe=ie&&wb(e);function le(e,t){return 256&t[0]&&(S=null),256&t[0]&&(B=null),256&t[0]&&(Q=null),null==S&&(S=!("image"!==$b(e[8].type))),S?Ib:(null==B&&(B=!("video"!==$b(e[8].type))),B?kb:(null==Q&&(Q=!("audio"!==$b(e[8].type))),Q?Ab:bb))}let ae=le(e,[-1,-1]),ce=ae(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("div"),o=m("span"),l=v(te),a=w(),c=m("span"),u=v(ne),d=w(),g=m("div"),oe&&oe.c(),y=w(),b=m("button"),b.textContent="X",C=w(),x=m("div"),ce.c(),F=w(),$=m("div"),D=m("div"),R=m("span"),P=v("Size: "),T=v(re),U=w(),N=m("span"),_=v("Uploaded: "),L=v(se),M=w(),O=m("div"),j=m("input"),G=w(),q=m("button"),q.textContent="Copy",J=w(),K=m("div"),V=m("a"),Y=v("Open in New Tab"),W=w(),Z=m("button"),Z.textContent="Delete",I(o,"class","modal-hash svelte-on0yal"),I(c,"class","modal-type svelte-on0yal"),I(s,"class","modal-title svelte-on0yal"),I(b,"class","close-btn svelte-on0yal"),I(g,"class","modal-controls svelte-on0yal"),I(r,"class","modal-header svelte-on0yal"),I(x,"class","modal-body svelte-on0yal"),I(D,"class","blob-details svelte-on0yal"),I(j,"type","text"),j.readOnly=!0,j.value=H=e[20](e[8]),I(j,"class","blob-url-input svelte-on0yal"),I(q,"class","copy-btn svelte-on0yal"),I(O,"class","blob-url-section svelte-on0yal"),I(V,"href",z=e[20](e[8])),I(V,"target","_blank"),I(V,"rel","noopener noreferrer"),I(V,"class","action-btn svelte-on0yal"),I(Z,"class","action-btn danger svelte-on0yal"),I(K,"class","modal-actions svelte-on0yal"),I($,"class","modal-footer svelte-on0yal"),I(n,"class","modal-content svelte-on0yal"),I(n,"role","dialog"),I(t,"class","modal-overlay svelte-on0yal"),I(t,"role","button"),I(t,"tabindex","0")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(s,o),f(o,l),f(s,a),f(s,c),f(c,u),f(r,d),f(r,g),oe&&oe.m(g,null),f(g,y),f(g,b),f(n,C),f(n,x),ce.m(x,null),f(n,F),f(n,$),f($,D),f(D,R),f(R,P),f(R,T),f(D,U),f(D,N),f(N,_),f(N,L),f($,M),f($,O),f(O,j),f(O,G),f(O,q),f($,J),f($,K),f(K,V),f(V,Y),f(K,W),f(K,Z),X||(ee=[A(b,"click",e[16]),A(j,"click",Pb),A(q,"click",e[46]),A(Z,"click",e[47]),A(n,"click",k(e[38])),A(n,"keypress",k(e[39])),A(t,"click",e[16]),A(t,"keypress",e[48])],X=!0)},p(e,t){256&t[0]&&te!==(te=Fb(e[8].sha256)+"")&&E(l,te),256&t[0]&&ne!==(ne=(e[8].type||"unknown")+"")&&E(u,ne),256&t[0]&&(ie="image"===$b(e[8].type)),ie?oe?oe.p(e,t):(oe=wb(e),oe.c(),oe.m(g,y)):oe&&(oe.d(1),oe=null),ae===(ae=le(e,t))&&ce?ce.p(e,t):(ce.d(1),ce=ae(e),ce&&(ce.c(),ce.m(x,null))),256&t[0]&&re!==(re=Bb(e[8].size)+"")&&E(T,re),256&t[0]&&se!==(se=Qb(e[8].uploaded)+"")&&E(L,se),256&t[0]&&H!==(H=e[20](e[8]))&&j.value!==H&&(j.value=H),256&t[0]&&z!==(z=e[20](e[8]))&&I(V,"href",z)},d(e){e&&h(t),oe&&oe.d(),ce.d(),X=!1,i(ee)}}}function wb(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k=Math.round(100*e[9])+"";return{c(){t=m("button"),n=v("-"),s=w(),o=m("span"),l=v(k),a=v("%"),c=w(),u=m("button"),d=v("+"),I(t,"class","zoom-btn svelte-on0yal"),t.disabled=r=e[9]<=Eb,I(o,"class","zoom-level svelte-on0yal"),I(u,"class","zoom-btn svelte-on0yal"),u.disabled=g=e[9]>=xb},m(i,r){p(i,t,r),f(t,n),p(i,s,r),p(i,o,r),f(o,l),f(o,a),p(i,c,r),p(i,u,r),f(u,d),y||(b=[A(t,"click",e[18]),A(u,"click",e[17])],y=!0)},p(e,n){512&n[0]&&r!==(r=e[9]<=Eb)&&(t.disabled=r),512&n[0]&&k!==(k=Math.round(100*e[9])+"")&&E(l,k),512&n[0]&&g!==(g=e[9]>=xb)&&(u.disabled=g)},d(e){e&&h(t),e&&h(s),e&&h(o),e&&h(c),e&&h(u),y=!1,i(b)}}}function bb(e){let t,n,i,r,s,o,l,a,c,u=Db(e[8].type)+"";return{c(){t=m("div"),n=m("div"),i=v(u),r=w(),s=m("p"),s.textContent="Preview not available for this file type.",o=w(),l=m("a"),a=v("Download File"),I(n,"class","file-icon svelte-on0yal"),I(l,"href",c=e[20](e[8])),I(l,"target","_blank"),I(l,"rel","noopener noreferrer"),I(l,"class","download-link svelte-on0yal"),I(t,"class","file-preview svelte-on0yal")},m(e,c){p(e,t,c),f(t,n),f(n,i),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a)},p(e,t){256&t[0]&&u!==(u=Db(e[8].type)+"")&&E(i,u),256&t[0]&&c!==(c=e[20](e[8]))&&I(l,"href",c)},d(e){e&&h(t)}}}function Ab(e){let t,n,i;return{c(){t=m("div"),n=m("audio"),n.controls=!0,l(n.src,i=e[20](e[8]))||I(n,"src",i),I(n,"class","svelte-on0yal"),I(t,"class","media-container audio svelte-on0yal")},m(e,i){p(e,t,i),f(t,n)},p(e,t){256&t[0]&&!l(n.src,i=e[20](e[8]))&&I(n,"src",i)},d(e){e&&h(t)}}}function kb(e){let t,n,i,r;return{c(){t=m("div"),n=m("video"),i=m("track"),I(i,"kind","captions"),n.controls=!0,l(n.src,r=e[20](e[8]))||I(n,"src",r),I(n,"class","svelte-on0yal"),I(t,"class","media-container svelte-on0yal")},m(e,r){p(e,t,r),f(t,n),f(n,i)},p(e,t){256&t[0]&&!l(n.src,r=e[20](e[8]))&&I(n,"src",r)},d(e){e&&h(t)}}}function Ib(e){let t,n,i;return{c(){t=m("div"),n=m("img"),l(n.src,i=e[20](e[8]))||I(n,"src",i),I(n,"alt","Blob content"),I(n,"class","svelte-on0yal"),I(t,"class","media-container svelte-on0yal"),S(t,"transform","scale("+e[9]+")")},m(e,i){p(e,t,i),f(t,n)},p(e,r){256&r[0]&&!l(n.src,i=e[20](e[8]))&&I(n,"src",i),512&r[0]&&S(t,"transform","scale("+e[9]+")")},d(e){e&&h(t)}}}function Cb(t){let n,i,r,s;function o(e,t){return e[1]?Vw:Kw}let l=o(t),a=l(t),c=t[7]&&t[8]&&vb(t);return{c(){a.c(),n=w(),c&&c.c(),i=b()},m(e,o){a.m(e,o),p(e,n,o),c&&c.m(e,o),p(e,i,o),r||(s=A(window,"keydown",t[19]),r=!0)},p(e,t){l===(l=o(e))&&a?a.p(e,t):(a.d(1),a=l(e),a&&(a.c(),a.m(n.parentNode,n))),e[7]&&e[8]?c?c.p(e,t):(c=vb(e),c.c(),c.m(i.parentNode,i)):c&&(c.d(1),c=null)},i:e,o:e,d(e){a.d(e),e&&h(n),c&&c.d(e),e&&h(i),r=!1,s()}}}const Eb=.25,xb=4;async function Sb(e,t,n=null){if(!e)return console.log("No signer available for Blossom auth"),null;try{const i=Math.floor(Date.now()/1e3),r=[["t",t],["expiration",(i+60).toString()]];n&&r.push(["x",n]);const s={kind:24242,created_at:i,tags:r,content:`Blossom ${t} operation`},o=await e.signEvent(s);return btoa(JSON.stringify(o)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating Blossom auth:",e),null}}function Bb(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=0,i=e;for(;i>=1024&&ne.target.select();function Tb(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{userPubkey:o=""}=t,{userSigner:l=null}=t,{currentEffectiveRole:a=""}=t;const c=U();let u,d=[],f=!1,p="",h=[],g=!1,m="",y=!1,v=null,w=1,b=!1,A=[],k=!1,I=null,C=[],E=!1;async function x(){if(o){n(0,f=!0),n(2,p="");try{const e=`${xp()}/blossom/list/${o}`,t=await Sb(l,"list"),n=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!n.ok)throw new Error(`Failed to load blobs: ${n.statusText}`);const i=await n.json();d=Array.isArray(i)?i:[],d.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0)),console.log("Loaded blobs:",d)}catch(e){console.error("Error loading blobs:",e),n(2,p=e.message||"Failed to load blobs")}finally{n(0,f=!1)}}}function S(e){n(8,v=e),n(9,w=1),n(7,y=!0)}function B(){n(7,y=!1),n(8,v=null),n(9,w=1)}function Q(){wEb&&n(9,w=Math.max(Eb,w-.25))}function $(e){return e.url?e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:e.url.startsWith("/")?`${xp()}${e.url}`:`http://${e.url}`:`${xp()}/blossom/${e.sha256}`}async function D(e){if(confirm(`Delete blob ${Fb(e.sha256)}?`))try{const t=`${xp()}/blossom/${e.sha256}`,n=await Sb(l,"delete",e.sha256),i=await fetch(t,{method:"DELETE",headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to delete: ${i.statusText}`);d=d.filter(t=>t.sha256!==e.sha256),v?.sha256===e.sha256&&B()}catch(e){console.error("Error deleting blob:",e),alert(`Failed to delete blob: ${e.message}`)}}async function R(){n(12,k=!0),n(2,p="");try{const e=`${xp()}/blossom/admin/users`,t=await Sb(l,"admin"),i=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!i.ok)throw new Error(`Failed to load user stats: ${i.statusText}`);n(11,A=await i.json());for(const e of A)Wp(e.pubkey).then(t=>{e.profile=t||{name:"",picture:""},n(11,A)}).catch(()=>{e.profile={name:"",picture:""}})}catch(e){console.error("Error fetching admin user stats:",e),n(2,p=e.message||"Failed to load user stats")}finally{n(12,k=!1)}}async function T(e){n(0,f=!0),n(2,p="");try{const t=`${xp()}/blossom/list/${e}`,n=await Sb(l,"list"),i=await fetch(t,{headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to load user blobs: ${i.statusText}`);C=await i.json(),C.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0))}catch(e){console.error("Error loading user blobs:",e),n(2,p=e.message||"Failed to load user blobs")}finally{n(0,f=!1)}}async function _(e){n(13,I={pubkey:e.pubkey,profile:e.profile}),await T(e.pubkey)}P(()=>{i&&!E&&(n(37,E=!0),x())});return e.$$set=e=>{"isLoggedIn"in e&&n(33,s=e.isLoggedIn),"userPubkey"in e&&n(34,o=e.userPubkey),"userSigner"in e&&n(35,l=e.userSigner),"currentEffectiveRole"in e&&n(36,a=e.currentEffectiveRole)},e.$$.update=()=>{12&e.$$.dirty[1]&&n(1,i=s&&o),32&e.$$.dirty[1]&&n(14,r="admin"===a||"owner"===a),3&e.$$.dirty[0]|64&e.$$.dirty[1]&&(!i||E||f||(n(37,E=!0),x()))},[f,i,p,h,g,m,u,y,v,w,b,A,k,I,r,S,B,Q,F,function(e){y&&("Escape"===e.key?B():"+"===e.key||"="===e.key?Q():"-"===e.key&&F())},$,function(){c("openLoginModal")},D,function(e){n(3,h=Array.from(e.target.files))},function(){u?.click()},async function(){if(0===h.length)return;n(4,g=!0),n(2,p="");const e=[],t=[];for(let i=0;i0&&await x(),t.length>0&&n(2,p=`Failed to upload: ${t.map(e=>e.name).join(", ")}`)},function(e){try{return ku(e)}catch(t){return Fb(e)}},function(){n(10,b=!0),R()},function(){n(10,b=!1),n(11,A=[]),n(13,I=null),C=[]},_,function(){n(13,I=null),C=[]},function(){I?T(I.pubkey):b?R():x()},function(){return I?C:d},s,o,l,a,E,function(t){N.call(this,e,t)},function(t){N.call(this,e,t)},function(e){L[e?"unshift":"push"](()=>{u=e,n(6,u)})},e=>_(e),(e,t)=>"Enter"===t.key&&_(e),e=>D(e),e=>S(e),(e,t)=>"Enter"===t.key&&S(e),()=>{navigator.clipboard.writeText($(v))},()=>D(v),e=>"Enter"===e.key&&B()]}class Ub extends ae{constructor(e){super(),le(this,e,Tb,Cb,s,{isLoggedIn:33,userPubkey:34,userSigner:35,currentEffectiveRole:36},null,[-1,-1])}}function Nb(e,t,n){const i=e.slice();return i[29]=t[n],i}function _b(e,t,n){const i=e.slice();return i[32]=t[n],i}function Lb(e){let t,n,i;function r(e,t){return e[0]?Ob:jb}let s=r(e),o=s(e);return{c(){t=m("div"),n=m("p"),n.textContent="Log viewer is only available to relay owners.",i=w(),o.c(),I(n,"class","svelte-w6h7aj"),I(t,"class","login-prompt svelte-w6h7aj")},m(e,r){p(e,t,r),f(t,n),f(t,i),o.m(t,null)},p(e,n){s===(s=r(e))&&o?o.p(e,n):(o.d(1),o=s(e),o&&(o.c(),o.m(t,null)))},d(e){e&&h(t),o.d()}}}function Mb(e){let t,n,r,s,o,l,a,c,u,d,y,b,k,C,x,S,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,q=e[3]?"Loading...":"Refresh",J=e[2].length+"",K=e[12],V=[];for(let t=0;te[18].call(u)),I(l,"class","level-selector svelte-w6h7aj"),I(y,"class","clear-btn svelte-w6h7aj"),y.disabled=k=e[3]||0===e[2].length,I(x,"class","refresh-btn svelte-w6h7aj"),x.disabled=e[3],I(o,"class","header-controls svelte-w6h7aj"),I(n,"class","header-section svelte-w6h7aj"),I(D,"class","log-info svelte-w6h7aj"),I(O,"class","log-list svelte-w6h7aj"),I(t,"class","log-view svelte-w6h7aj")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(l,c),f(l,u);for(let e=0;eNo logs available.

    ",I(n,"class","empty-state svelte-w6h7aj")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Kb(e){let t,n,i,r,s=e[29].file+"",o=e[29].line+"";return{c(){t=m("span"),n=v(s),i=v(":"),r=v(o),I(t,"class","log-location svelte-w6h7aj")},m(e,s){p(e,t,s),f(t,n),f(t,i),f(t,r)},p(e,t){4&t[0]&&s!==(s=e[29].file+"")&&E(n,s),4&t[0]&&o!==(o=e[29].line+"")&&E(r,o)},d(e){e&&h(t)}}}function Vb(e){let t,n,i,r,s,o,l,a,c,u,d,g=Xb(e[29].timestamp)+"",y=e[29].level+"",b=e[29].message+"",A=e[29].file&&Kb(e);return{c(){t=m("div"),n=m("span"),i=v(g),r=w(),s=m("span"),o=v(y),a=w(),A&&A.c(),c=w(),u=m("span"),d=v(b),I(n,"class","log-timestamp svelte-w6h7aj"),I(s,"class",l="log-level "+eA(e[29].level)+" svelte-w6h7aj"),I(u,"class","log-message svelte-w6h7aj"),I(t,"class","log-entry svelte-w6h7aj")},m(e,l){p(e,t,l),f(t,n),f(n,i),f(t,r),f(t,s),f(s,o),f(t,a),A&&A.m(t,null),f(t,c),f(t,u),f(u,d)},p(e,n){4&n[0]&&g!==(g=Xb(e[29].timestamp)+"")&&E(i,g),4&n[0]&&y!==(y=e[29].level+"")&&E(o,y),4&n[0]&&l!==(l="log-level "+eA(e[29].level)+" svelte-w6h7aj")&&I(s,"class",l),e[29].file?A?A.p(e,n):(A=Kb(e),A.c(),A.m(t,c)):A&&(A.d(1),A=null),4&n[0]&&b!==(b=e[29].message+"")&&E(d,b)},d(e){e&&h(t),A&&A.d()}}}function Yb(e){let t;return{c(){t=m("span"),t.textContent="End of logs"},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function zb(e){let t;return{c(){t=m("span"),t.textContent="Scroll for more"},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Wb(e){let t;return{c(){t=m("span"),t.textContent="Loading more..."},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Zb(t){let n;function i(e,t){return e[4]?Mb:Lb}let r=i(t),s=r(t);return{c(){s.c(),n=b()},m(e,t){s.m(e,t),p(e,n,t)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&h(n)}}}function Xb(e){if(!e)return"";return new Date(e).toLocaleString()}function eA(e){switch(e?.toUpperCase()){case"TRC":case"TRACE":return"level-trace";case"DBG":case"DEBUG":return"level-debug";case"INF":case"INFO":default:return"level-info";case"WRN":case"WARN":return"level-warn";case"ERR":case"ERROR":return"level-error";case"FTL":case"FATAL":return"level-fatal"}}function tA(e,t,n){let i,{isLoggedIn:r=!1}=t,{userRole:s=""}=t,{userSigner:o=null}=t;const l=U();let a=[],c=!1,u=!0,d=0,f=0,p="",h="info",g="info";const m=["trace","debug","info","warn","error","fatal"];let y,v,w;async function b(e="GET",t="/api/logs"){if(!o)return null;try{const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",`${xp()}${t}`],["method",e]],content:""},i=await o.signEvent(n);return btoa(JSON.stringify(i)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating auth header:",e),null}}async function A(e=!1){if(!c){n(3,c=!0),n(7,p=""),e&&(d=0,n(2,a=[]));try{const t=`/api/logs?offset=${d}&limit=100`,i=await b("GET",t),r=`${xp()}${t}`,s=await fetch(r,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!s.ok)throw new Error(`Failed to load logs: ${s.statusText}`);const o=await s.json();n(2,a=e?o.logs||[]:[...a,...o.logs||[]]),n(6,f=o.total||0),n(5,u=o.has_more||!1),d=a.length}catch(e){console.error("Error loading logs:",e),n(7,p=e.message||"Failed to load logs")}finally{n(3,c=!1)}}}async function k(){try{const e=await fetch(`${xp()}/api/logs/level`);if(e.ok){const t=await e.json();n(8,h=t.level||"info"),n(9,g=h)}}catch(e){console.error("Error loading log level:",e)}}P(()=>{i&&(A(!0),k(),function(){if(!v)return;w=new IntersectionObserver(e=>{e[0].isIntersecting&&u&&!c&&u&&!c&&A(!1)},{threshold:.1}),w.observe(v)}())}),T(()=>{w&&w.disconnect()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"userRole"in e&&n(1,s=e.userRole),"userSigner"in e&&n(17,o=e.userSigner)},e.$$.update=()=>{3&e.$$.dirty[0]&&n(4,i=r&&"owner"===s),28&e.$$.dirty[0]&&i&&0===a.length&&!c&&(A(!0),k())},[r,s,a,c,i,u,f,p,h,g,y,v,m,A,async function(){if(g!==h)try{const e=await b("POST","/api/logs/level"),t=await fetch(`${xp()}/api/logs/level`,{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Nostr ${e}`}:{}},body:JSON.stringify({level:g})});if(!t.ok)throw new Error(`Failed to set log level: ${t.statusText}`);const i=await t.json();n(8,h=i.level),n(9,g=h)}catch(e){console.error("Error setting log level:",e),n(7,p=e.message||"Failed to set log level"),n(9,g=h)}},async function(){if(confirm("Are you sure you want to clear all logs?"))try{const e=await b("POST","/api/logs/clear"),t=await fetch(`${xp()}/api/logs/clear`,{method:"POST",headers:e?{Authorization:`Nostr ${e}`}:{}});if(!t.ok)throw new Error(`Failed to clear logs: ${t.statusText}`);n(2,a=[]),d=0,n(5,u=!1),n(6,f=0)}catch(e){console.error("Error clearing logs:",e),n(7,p=e.message||"Failed to clear logs")}},function(){l("openLoginModal")},o,function(){g=Q(this),n(9,g),n(12,m)},()=>A(!0),function(e){L[e?"unshift":"push"](()=>{v=e,n(11,v)})},function(e){L[e?"unshift":"push"](()=>{y=e,n(10,y)})}]}class nA extends ae{constructor(e){super(),le(this,e,tA,Zb,s,{isLoggedIn:0,userRole:1,userSigner:17},null,[-1,-1])}}async function iA(e,t,n,i){if(!e||!t)return console.log("createNIP98Auth: No signer or pubkey available",{hasSigner:!!e,hasPubkey:!!t}),null;try{const t={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",i],["method",n.toUpperCase()]],content:""};console.log("createNIP98Auth: Signing event for",n,i);const r=await e.signEvent(t);console.log("createNIP98Auth: Signed event:",{id:r.id,pubkey:r.pubkey,kind:r.kind,created_at:r.created_at,tags:r.tags,hasSig:!!r.sig});const s=JSON.stringify(r);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("createNIP98Auth: Error:",e),null}}async function rA(){try{const e=await fetch(xp(),{headers:{Accept:"application/nostr+json"}});if(e.ok)return await e.json()}catch(e){console.error("Error fetching relay info:",e)}return null}async function sA(){const e=xp();console.log("[api] fetchNRCConfig using base URL:",e);try{const t=await fetch(`${e}/api/nrc/config`);if(t.ok)return await t.json()}catch(e){console.error("Error fetching NRC config:",e)}return{enabled:!1,badger_required:!0}}function oA(e){return Up[e]||`Kind ${e}`}function lA(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function aA(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function cA(e){return e?new Date(1e3*e).toLocaleString():""}async function uA(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){console.error("Failed to copy to clipboard:",t);try{const t=document.createElement("textarea");return t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch(e){return console.error("Fallback copy also failed:",e),!1}}}function dA(e,t=!0){if(!e)return;const n=e.textContent,i=e.style.backgroundColor;t?(e.textContent="",e.style.backgroundColor="#4CAF50"):(e.textContent="L",e.style.backgroundColor="#f44336"),setTimeout(()=>{e.textContent=n,e.style.backgroundColor=i},2e3)}function fA(e,t,n){const i=e.slice();return i[34]=t[n],i}function pA(e){let t,n,r,s,o,l,a,c,u,d,g,y,k,C,S,B,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V=(e[5].rendezvous_url||"Not configured")+"",Y=e[4].length+"";function z(e,t){return 0===e[4].length?vA:yA}let W=z(e),Z=W(e),X=e[7]&&AA(e);return{c(){t=m("div"),n=m("div"),n.innerHTML='Status: \n Enabled',r=w(),s=m("div"),o=m("span"),o.textContent="Rendezvous:",l=w(),a=m("span"),c=v(V),u=w(),d=m("div"),g=m("h3"),g.textContent="Create New Connection",y=w(),k=m("div"),C=m("div"),S=m("label"),S.textContent="Device Label",B=w(),Q=m("input"),F=w(),$=m("button"),D=v("+ Create Connection"),P=w(),T=m("div"),U=m("h3"),N=v("Connections ("),_=v(Y),L=v(")"),M=w(),Z.c(),O=w(),j=m("button"),H=v("Refresh"),G=w(),X&&X.c(),q=b(),I(n,"class","status-item svelte-1rsf7jk"),I(o,"class","status-label svelte-1rsf7jk"),I(a,"class","status-value svelte-1rsf7jk"),I(s,"class","status-item svelte-1rsf7jk"),I(t,"class","config-status svelte-1rsf7jk"),I(g,"class","svelte-1rsf7jk"),I(S,"for","new-label"),I(S,"class","svelte-1rsf7jk"),I(Q,"type","text"),I(Q,"id","new-label"),I(Q,"placeholder","e.g., Phone, Laptop, Tablet"),Q.disabled=e[6],I(Q,"class","svelte-1rsf7jk"),I(C,"class","form-group svelte-1rsf7jk"),I($,"class","create-btn svelte-1rsf7jk"),$.disabled=R=e[6]||!e[9].trim(),I(k,"class","create-form svelte-1rsf7jk"),I(d,"class","section svelte-1rsf7jk"),I(U,"class","svelte-1rsf7jk"),I(j,"class","refresh-btn svelte-1rsf7jk"),j.disabled=e[6],I(T,"class","section svelte-1rsf7jk")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(s,o),f(s,l),f(s,a),f(a,c),p(i,u,h),p(i,d,h),f(d,g),f(d,y),f(d,k),f(k,C),f(C,S),f(C,B),f(C,Q),x(Q,e[9]),f(k,F),f(k,$),f($,D),p(i,P,h),p(i,T,h),f(T,U),f(U,N),f(U,_),f(U,L),f(T,M),Z.m(T,null),f(T,O),f(T,j),f(j,H),p(i,G,h),X&&X.m(i,h),p(i,q,h),J||(K=[A(Q,"input",e[27]),A($,"click",e[14]),A(j,"click",e[13])],J=!0)},p(e,t){32&t[0]&&V!==(V=(e[5].rendezvous_url||"Not configured")+"")&&E(c,V),64&t[0]&&(Q.disabled=e[6]),512&t[0]&&Q.value!==e[9]&&x(Q,e[9]),576&t[0]&&R!==(R=e[6]||!e[9].trim())&&($.disabled=R),16&t[0]&&Y!==(Y=e[4].length+"")&&E(_,Y),W===(W=z(e))&&Z?Z.p(e,t):(Z.d(1),Z=W(e),Z&&(Z.c(),Z.m(T,O))),64&t[0]&&(j.disabled=e[6]),e[7]?X?X.p(e,t):(X=AA(e),X.c(),X.m(q.parentNode,q)):X&&(X.d(1),X=null)},d(e){e&&h(t),e&&h(u),e&&h(d),e&&h(P),e&&h(T),Z.d(),e&&h(G),X&&X.d(e),e&&h(q),J=!1,i(K)}}}function hA(e){let t,n,i,r,s,o,l,a=(e[1]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="Owner permission required for relay connection management.",i=w(),r=m("p"),s=v("Current role: "),o=m("strong"),l=v(a),I(n,"class","svelte-1rsf7jk"),I(r,"class","svelte-1rsf7jk"),I(t,"class","permission-denied svelte-1rsf7jk")},m(e,a){p(e,t,a),f(t,n),f(t,i),f(t,r),f(r,s),f(r,o),f(o,l)},p(e,t){2&t[0]&&a!==(a=(e[1]||"none")+"")&&E(l,a)},d(e){e&&h(t)}}}function gA(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to manage relay connections.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-1rsf7jk"),I(s,"class","login-btn svelte-1rsf7jk"),I(n,"class","login-prompt svelte-1rsf7jk")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[19]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function mA(e){let t;function n(e,t){return e[3]?IA:kA}let i=n(e),r=i(e);return{c(){t=m("div"),r.c(),I(t,"class","not-enabled svelte-1rsf7jk")},m(e,n){p(e,t,n),r.m(t,null)},p(e,s){i!==(i=n(e))&&(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&h(t),r.d()}}}function yA(e){let t,n=e[4],i=[];for(let t=0;tORLY_NRC_ENABLED=true and configure ORLY_NRC_RENDEZVOUS_URL to enable.',I(t,"class","svelte-1rsf7jk"),I(i,"class","svelte-1rsf7jk")},m(e,r){p(e,t,r),p(e,n,r),p(e,i,r)},d(e){e&&h(t),e&&h(n),e&&h(i)}}}function IA(e){let t,n,i;return{c(){t=m("p"),t.textContent="NRC requires the Badger database backend.",n=w(),i=m("p"),i.innerHTML='Set ORLY_DB_TYPE=badger to enable NRC functionality.',I(t,"class","svelte-1rsf7jk"),I(i,"class","svelte-1rsf7jk")},m(e,r){p(e,t,r),p(e,n,r),p(e,i,r)},d(e){e&&h(t),e&&h(n),e&&h(i)}}}function CA(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,C,x,S,B,Q;return{c(){t=m("div"),n=m("div"),r=m("h3"),s=v('Connection URI for "'),o=v(e[12]),l=v('"'),a=w(),c=m("p"),c.textContent="Copy this URI to your Nostr client to connect to this relay remotely.\n Keep it secret - anyone with this URI can access your relay.",u=w(),d=m("div"),g=m("textarea"),y=w(),b=m("div"),C=m("button"),C.textContent="Copy to Clipboard",x=w(),S=m("button"),S.textContent="Close",I(r,"class","svelte-1rsf7jk"),I(c,"class","modal-description svelte-1rsf7jk"),g.readOnly=!0,g.value=e[11],I(g,"class","svelte-1rsf7jk"),I(d,"class","uri-display svelte-1rsf7jk"),I(C,"class","copy-btn svelte-1rsf7jk"),I(S,"class","close-btn svelte-1rsf7jk"),I(b,"class","modal-actions svelte-1rsf7jk"),I(n,"class","modal svelte-1rsf7jk"),I(t,"class","modal-overlay svelte-1rsf7jk")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),f(n,u),f(n,d),f(d,g),f(n,y),f(n,b),f(b,C),f(b,x),f(b,S),B||(Q=[A(C,"click",e[17]),A(S,"click",e[18]),A(n,"click",k(e[26])),A(t,"click",e[18])],B=!0)},p(e,t){4096&t[0]&&E(o,e[12]),2048&t[0]&&(g.value=e[11])},d(e){e&&h(t),B=!1,i(Q)}}}function EA(t){let n,i,r,s,o,l,a;function c(e,t){return e[2]?e[0]?"owner"!==e[1]?hA:pA:gA:mA}let u=c(t),d=u(t),g=t[10]&&CA(t);return{c(){n=m("div"),i=m("h2"),i.textContent="Relay Connect",r=w(),s=m("p"),s.textContent="Nostr Relay Connect (NRC) allows remote access to this relay through a public relay tunnel.\n Create connection strings for your devices to sync securely.",o=w(),d.c(),l=w(),g&&g.c(),a=b(),I(i,"class","svelte-1rsf7jk"),I(s,"class","description svelte-1rsf7jk"),I(n,"class","relay-connect-view svelte-1rsf7jk")},m(e,t){p(e,n,t),f(n,i),f(n,r),f(n,s),f(n,o),d.m(n,null),p(e,l,t),g&&g.m(e,t),p(e,a,t)},p(e,t){u===(u=c(e))&&d?d.p(e,t):(d.d(1),d=u(e),d&&(d.c(),d.m(n,null))),e[10]?g?g.p(e,t):(g=CA(e),g.c(),g.m(a.parentNode,a)):g&&(g.d(1),g=null)},i:e,o:e,d(e){e&&h(n),d.d(),e&&h(l),g&&g.d(e),e&&h(a)}}}function xA(e){return e?new Date(1e3*e).toLocaleString():"Never"}function SA(e,t,n){let i,r;u(e,mp,e=>n(25,r=e));let{isLoggedIn:s=!1}=t,{userRole:o=""}=t,{userSigner:l=null}=t,{userPubkey:a=""}=t;const c=U();let d=!1,f=!1,p=[],h={},g=!1,m="",y="info",v="",w=!1,b="",A="",k=!1,I="";async function C(){console.log("[RelayConnectView] loadNRCConfig called, current relayUrl:",r);try{const e=await sA();console.log("[RelayConnectView] NRC config result:",e),n(2,d=e.enabled),n(3,f=e.badger_required),d&&s&&"owner"===o&&await E()}catch(e){console.error("Failed to load NRC config:",e)}}async function E(){if(s&&l&&a){n(6,g=!0);try{const e=await async function(e,t){const n=`${xp()}/api/nrc/connections`,i=await iA(e,t,"GET",n),r=await fetch(n,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!r.ok){const e=await r.text();throw new Error(e||`Failed to get NRC connections: ${r.statusText}`)}return await r.json()}(l,a);n(4,p=e.connections||[]),n(5,h=e.config||{})}catch(e){B(`Failed to load connections: ${e.message}`,"error")}finally{n(6,g=!1)}}}async function x(e,t){if(confirm(`Are you sure you want to delete the connection "${t}"? This will revoke access for any device using this connection.`)){n(6,g=!0);try{await async function(e,t,n){const i=`${xp()}/api/nrc/connections/${n}`,r=await iA(e,t,"DELETE",i),s=await fetch(i,{method:"DELETE",headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to delete NRC connection: ${s.statusText}`)}return await s.json()}(l,a,e),await E(),B(`Connection "${t}" deleted`,"success")}catch(e){B(`Failed to delete connection: ${e.message}`,"error")}finally{n(6,g=!1)}}}async function S(e,t){n(6,g=!0);try{const i=await async function(e,t,n){const i=`${xp()}/api/nrc/connections/${n}/uri`,r=await iA(e,t,"GET",i),s=await fetch(i,{headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to get NRC URI: ${s.statusText}`)}return await s.json()}(l,a,e);n(11,b=i.uri),n(12,A=t),n(10,w=!0)}catch(e){B(`Failed to get URI: ${e.message}`,"error")}finally{n(6,g=!1)}}function B(e,t="info"){n(7,m=e),n(8,y=t),setTimeout(()=>{m===e&&n(7,m="")},5e3)}P(async()=>{n(23,I=r||""),await C(),n(22,k=!0)});return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"userRole"in e&&n(1,o=e.userRole),"userSigner"in e&&n(20,l=e.userSigner),"userPubkey"in e&&n(21,a=e.userPubkey)},e.$$.update=()=>{33554432&e.$$.dirty[0]&&n(24,i=r),29360128&e.$$.dirty[0]&&k&&i!==I&&(n(23,I=i),console.log("[RelayConnectView] Relay changed, reloading..."),n(4,p=[]),n(5,h={}),n(2,d=!1),C()),7&e.$$.dirty[0]&&s&&"owner"===o&&d&&E()},[s,o,d,f,p,h,g,m,y,v,w,b,A,E,async function(){if(v.trim()){n(6,g=!0);try{const e=await async function(e,t,n){const i=`${xp()}/api/nrc/connections`,r=await iA(e,t,"POST",i),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...r?{Authorization:`Nostr ${r}`}:{}},body:JSON.stringify({label:n})});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to create NRC connection: ${s.statusText}`)}return await s.json()}(l,a,v.trim());n(11,b=e.uri),n(12,A=e.label),n(10,w=!0),n(9,v=""),await E(),B(`Connection "${e.label}" created successfully`,"success")}catch(e){B(`Failed to create connection: ${e.message}`,"error")}finally{n(6,g=!1)}}else B("Please enter a label for the connection","error")},x,S,async function(e){const t=await uA(b);dA(e.target.closest("button"),t),t||B("Failed to copy to clipboard","error")},function(){n(10,w=!1),n(11,b=""),n(12,A="")},function(){c("openLoginModal")},l,a,k,I,i,r,function(t){N.call(this,e,t)},function(){v=this.value,n(9,v)},e=>S(e.id,e.label),e=>x(e.id,e.label)]}class BA extends ae{constructor(e){super(),le(this,e,SA,EA,s,{isLoggedIn:0,userRole:1,userSigner:20,userPubkey:21},null,[-1,-1])}}function QA(e){let t,n,i,r,s,o,l,a,c,u,d;return{c(){t=m("div"),n=m("div"),i=m("h3"),i.textContent="Active Filter",r=w(),s=m("button"),s.textContent="🧹 Sweep",o=w(),l=m("div"),a=m("pre"),c=v(e[2]),I(i,"class","svelte-1tyqaa5"),I(s,"class","sweep-btn svelte-1tyqaa5"),I(s,"title","Clear filter"),I(n,"class","filter-display-header svelte-1tyqaa5"),I(a,"class","filter-json svelte-1tyqaa5"),I(l,"class","filter-json-container svelte-1tyqaa5"),I(t,"class","filter-display svelte-1tyqaa5")},m(h,g){p(h,t,g),f(t,n),f(n,i),f(n,r),f(n,s),f(t,o),f(t,l),f(l,a),f(a,c),u||(d=A(s,"click",e[3]),u=!0)},p(e,t){4&t&&E(c,e[2])},d(e){e&&h(t),u=!1,d()}}}function FA(t){let n,i=t[0]&&t[1]&&QA(t);return{c(){i&&i.c(),n=b()},m(e,t){i&&i.m(e,t),p(e,n,t)},p(e,[t]){e[0]&&e[1]?i?i.p(e,t):(i=QA(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&h(n)}}}function $A(e,t,n){let i,r;const s=U();let{filter:o={}}=t,{showFilter:l=!0}=t;return e.$$set=e=>{"filter"in e&&n(4,o=e.filter),"showFilter"in e&&n(0,l=e.showFilter)},e.$$.update=()=>{16&e.$$.dirty&&n(2,i=function(e){return JSON.stringify(e,null,2)}(o)),16&e.$$.dirty&&n(1,r=Object.keys(o).length>0)},[l,r,i,function(){s("sweep")},o]}class DA extends ae{constructor(e){super(),le(this,e,$A,FA,s,{filter:4,showFilter:0})}}function RA(e,t,n){const i=e.slice();return i[20]=t[n],i}function PA(e){let t,n,r,s,o,l,a,c,u,d,g,y,v,b,C,E,S,B,Q,$,D,R,P,T,U,N;function _(e,t){return e[3]&&!e[5]?UA:TA}let L=_(e),M=L(e),O=e[4]&&NA(e);function j(e,t){return e[6].length>0?LA:_A}let H=j(e),G=H(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("h2"),s.textContent="Relay Manager",o=w(),l=m("button"),l.textContent="×",a=w(),c=m("div"),u=m("div"),d=m("div"),d.textContent="Add Relay",g=w(),y=m("div"),v=m("input"),b=w(),C=m("button"),M.c(),S=w(),O&&O.c(),B=w(),Q=m("div"),$=m("div"),$.textContent="Saved Relays",D=w(),G.c(),R=w(),P=m("div"),T=m("button"),T.textContent="Done",I(s,"class","svelte-6a0diz"),I(l,"class","close-btn svelte-6a0diz"),I(r,"class","modal-header svelte-6a0diz"),I(d,"class","section-header svelte-6a0diz"),I(v,"type","text"),I(v,"placeholder","wss://relay.example.com"),v.disabled=e[3],I(v,"class","url-input svelte-6a0diz"),I(C,"class","add-btn svelte-6a0diz"),C.disabled=E=e[3]||!e[2].trim(),I(y,"class","input-row svelte-6a0diz"),I(u,"class","add-relay-section svelte-6a0diz"),I($,"class","section-header svelte-6a0diz"),I(Q,"class","saved-relays-section svelte-6a0diz"),I(T,"class","done-btn svelte-6a0diz"),I(P,"class","button-group svelte-6a0diz"),I(c,"class","modal-content svelte-6a0diz"),I(n,"class","modal svelte-6a0diz"),F(n,"dark",e[1]),I(t,"class","modal-overlay svelte-6a0diz")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),f(c,u),f(u,d),f(u,g),f(u,y),f(y,v),x(v,e[2]),f(y,b),f(y,C),M.m(C,null),f(c,S),O&&O.m(c,null),f(c,B),f(c,Q),f(Q,$),f(Q,D),G.m(Q,null),f(c,R),f(c,P),f(P,T),U||(N=[A(l,"click",e[7]),A(v,"input",e[14]),A(v,"keydown",e[11]),A(C,"click",e[9]),A(T,"click",e[7]),A(n,"click",k(e[13])),A(t,"click",e[7])],U=!0)},p(e,t){8&t&&(v.disabled=e[3]),4&t&&v.value!==e[2]&&x(v,e[2]),L!==(L=_(e))&&(M.d(1),M=L(e),M&&(M.c(),M.m(C,null))),12&t&&E!==(E=e[3]||!e[2].trim())&&(C.disabled=E),e[4]?O?O.p(e,t):(O=NA(e),O.c(),O.m(c,B)):O&&(O.d(1),O=null),H===(H=j(e))&&G?G.p(e,t):(G.d(1),G=H(e),G&&(G.c(),G.m(Q,null))),2&t&&F(n,"dark",e[1])},d(e){e&&h(t),M.d(),O&&O.d(),G.d(),U=!1,i(N)}}}function TA(e){let t;return{c(){t=v("Add")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function UA(e){let t;return{c(){t=v("Adding...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function NA(e){let t,n;return{c(){t=m("div"),n=v(e[4]),I(t,"class","error-message svelte-6a0diz")},m(e,i){p(e,t,i),f(t,n)},p(e,t){16&t&&E(n,e[4])},d(e){e&&h(t)}}}function _A(t){let n;return{c(){n=m("div"),n.textContent="No saved relays. Add one above to get started.",I(n,"class","empty-state svelte-6a0diz")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function LA(e){let t,n=e[6],i=[];for(let t=0;tn(17,i=e)),u(e,mp,e=>n(18,r=e)),u(e,kp,e=>n(6,s=e));const o=U();let{showModal:l=!1}=t,{isDarkTheme:a=!1}=t,c="",d=!1,f="",p="";function h(){n(0,l=!1),n(4,f=""),o("close")}async function g(e=null){const t=e||c.trim();if(t){n(3,d=!0),n(5,p=t),n(4,f="");try{const e=await Fp(t);if(e.success){Ip(t,Dp(t)),n(2,c=""),o("connected",{info:e.info}),h()}else n(4,f=e.error||"Failed to connect")}catch(e){n(4,f=e.message||"Connection failed")}finally{n(3,d=!1),n(5,p="")}}else n(4,f="Please enter a relay URL")}async function m(){const e=c.trim();if(e){n(3,d=!0),n(4,f="");try{const t=await Fp(e);if(t.success){Ip(e,Dp(e)),n(2,c=""),o("connected",{info:t.info})}else n(4,f=t.error||"Failed to connect")}catch(e){n(4,f=e.message||"Connection failed")}finally{n(3,d=!1)}}else n(4,f="Please enter a relay URL")}function y(e,t){t.stopPropagation(),function(e){kp.update(t=>t.filter(t=>t.url!==e))}(e)}return e.$$set=e=>{"showModal"in e&&n(0,l=e.showModal),"isDarkTheme"in e&&n(1,a=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty&&l&&(n(2,c=""),n(4,f=""))},[l,a,c,d,f,p,s,h,g,m,y,function(e){"Enter"!==e.key||d?"Escape"===e.key&&h():m()},function(e){return r===e&&"connected"===i},function(t){N.call(this,e,t)},function(){c=this.value,n(2,c),n(0,l)},e=>g(e.url),(e,t)=>y(e.url,t)]}class qA extends ae{constructor(e){super(),le(this,e,GA,HA,s,{showModal:0,isDarkTheme:1})}}class JA{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,i,r]=n;e&&i?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!i&&(console.error("Authentication failed:",r),this.authPromise&&(this.authPromise.reject(new Error(r||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const i=["EVENT",e];this.ws.send(JSON.stringify(i));const r=this.ws.onmessage,s=setTimeout(()=>{this.ws.onmessage=r,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async i=>{try{const o=JSON.parse(i.data),[l,a,c,u]=o;if("OK"===l&&a===e.id)if(c)clearTimeout(s),this.ws.onmessage=r,console.log("Event published successfully:",a),t({success:!0,eventId:a,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required"))return void console.log("Authentication required, waiting for AUTH challenge...");clearTimeout(s),this.ws.onmessage=r,n(new Error(`Publish failed: ${u}`))}else if("AUTH"===l){this.challenge=o[1],console.log("Received AUTH challenge during publish:",this.challenge);try{await this.authenticate(),console.log("Authentication successful, retrying event publish...");const t=["EVENT",e];this.ws.send(JSON.stringify(t))}catch(e){clearTimeout(s),this.ws.onmessage=r,n(new Error(`Authentication failed: ${e.message}`))}}else await this.handleMessage(o)}catch(e){clearTimeout(s),this.ws.onmessage=r,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function KA(e,t,n,i){const r=new JA(e,n,i);try{await r.connect();return await r.publishEvent(t)}finally{r.close()}}function VA(e,t,n){const i=e.slice();return i[191]=t[n],i}function YA(e,t,n){const i=e.slice();return i[201]=t[n],i}function zA(e,t,n){const i=e.slice();return i[194]=t[n],i}function WA(e,t,n){const i=e.slice();i[194]=t[n];const r=i[57](i[194]);return i[195]=r,i}function ZA(e,t,n){const i=e.slice();return i[198]=t[n],i}function XA(t){let n;function i(e,t){return e[1]?hk:pk}let r=i(t),s=r(t);return{c(){n=m("div"),s.c(),I(n,"class","welcome-message svelte-1qbmv87")},m(e,t){p(e,n,t),s.m(n,null)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&h(n),s.d()}}}function ek(e){let t,n,i=e[6],r=[];for(let t=0;tte(r[e],1,1,()=>{r[e]=null});return{c(){for(let e=0;e=0||""!==t[38]&&parseInt(t[38])>=0,R=Tp,P=[];for(let e=0;eEvent Recovery \n

    Search and recover old versions of replaceable events

    ',s=w(),o=m("div"),l=m("div"),a=m("div"),c=m("label"),c.textContent="Select Event Kind:",u=w(),d=m("select"),y=m("option"),y.textContent="Choose a replaceable kind...";for(let e=0;et[128].call(d)),I(a,"class","kind-selector svelte-1qbmv87"),I(k,"for","custom-kind"),I(k,"class","svelte-1qbmv87"),I(S,"id","custom-kind"),I(S,"type","number"),I(S,"placeholder","e.g., 10001"),I(S,"min","0"),I(S,"class","svelte-1qbmv87"),I(b,"class","custom-kind-input svelte-1qbmv87"),I(l,"class","recovery-controls svelte-1qbmv87"),I(o,"class","recovery-controls-card svelte-1qbmv87"),I(n,"class","recovery-tab svelte-1qbmv87")},m(e,i){p(e,n,i),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(a,c),f(a,u),f(a,d),f(d,y);for(let e=0;e=0||""!==e[38]&&parseInt(e[38])>=0),D?T?T.p(e,t):(T=Ek(e),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},i:e,o:e,d(e){e&&h(n),g(P,e),T&&T.d(),F=!1,i($)}}}function nk(t){let n,i,r=t[45],o=Pk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Pk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function ik(t){let n,i,r=t[45],o=Tk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Tk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function rk(e){let t,n,i;function r(t){e[127](t)}let s={isLoggedIn:e[1],userRole:e[4],isPolicyAdmin:lI,policyEnabled:e[8],isLoadingPolicy:e[29],policyMessage:e[30],policyMessageType:e[31],validationErrors:e[32],policyFollows:e[33]};return void 0!==e[28]&&(s.policyJson=e[28]),t=new Rv({props:s}),L.push(()=>ne(t,"policyJson",r)),t.$on("loadPolicy",e[69]),t.$on("validatePolicy",e[70]),t.$on("savePolicy",e[71]),t.$on("formatJson",e[72]),t.$on("addPolicyAdmin",e[73]),t.$on("removePolicyAdmin",e[74]),t.$on("refreshFollows",e[75]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,n){re(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),536870912&i[0]&&(r.isLoadingPolicy=e[29]),1073741824&i[0]&&(r.policyMessage=e[30]),1&i[1]&&(r.policyMessageType=e[31]),2&i[1]&&(r.validationErrors=e[32]),4&i[1]&&(r.policyFollows=e[33]),!n&&268435456&i[0]&&(n=!0,r.policyJson=e[28],q(()=>n=!1)),t.$set(r)},i(e){i||(ee(t.$$.fragment,e),i=!0)},o(e){te(t.$$.fragment,e),i=!1},d(e){se(t,e)}}}function sk(e){let t,n,i;function r(t){e[124](t)}let s={isLoggedIn:e[1],userRole:e[4],sprocketStatus:e[22],isLoadingSprocket:e[24],sprocketUploadFile:e[27],sprocketMessage:e[25],sprocketMessageType:e[26],sprocketVersions:e[23]};return void 0!==e[21]&&(s.sprocketScript=e[21]),t=new hv({props:s}),L.push(()=>ne(t,"sprocketScript",r)),t.$on("restartSprocket",e[64]),t.$on("deleteSprocket",e[65]),t.$on("sprocketFileSelect",e[76]),t.$on("uploadSprocketScript",e[77]),t.$on("saveSprocket",e[63]),t.$on("loadSprocket",e[62]),t.$on("loadVersions",e[66]),t.$on("loadVersion",e[125]),t.$on("deleteVersion",e[126]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,n){re(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),4194304&i[0]&&(r.sprocketStatus=e[22]),16777216&i[0]&&(r.isLoadingSprocket=e[24]),134217728&i[0]&&(r.sprocketUploadFile=e[27]),33554432&i[0]&&(r.sprocketMessage=e[25]),67108864&i[0]&&(r.sprocketMessageType=e[26]),8388608&i[0]&&(r.sprocketVersions=e[23]),!n&&2097152&i[0]&&(n=!0,r.sprocketScript=e[21],q(()=>n=!1)),t.$set(r)},i(e){i||(ee(t.$$.fragment,e),i=!0)},o(e){te(t.$$.fragment,e),i=!1},d(e){se(t,e)}}}function ok(e){let t,n,i,r;const s=[_k,Nk,Uk],o=[];function l(e,t){return"curating"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=s[n](e),{c(){t=m("div"),i.c(),I(t,"class","curation-view-container")},m(e,i){p(e,t,i),o[n].m(t,null),r=!0},p(e,r){let a=n;n=l(e),n===a?o[n].p(e,r):(Z(),te(o[a],1,1,()=>{o[a]=null}),X(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),ee(i,1),i.m(t,null))},i(e){r||(ee(i),r=!0)},o(e){te(i),r=!1},d(e){e&&h(t),o[n].d()}}}function lk(e){let t,n,i,r;const s=[jk,Ok,Mk],o=[];function l(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=s[n](e),{c(){t=m("div"),i.c(),I(t,"class","managed-acl-view svelte-1qbmv87")},m(e,i){p(e,t,i),o[n].m(t,null),r=!0},p(e,r){let a=n;n=l(e),n===a?o[n].p(e,r):(Z(),te(o[a],1,1,()=>{o[a]=null}),X(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),ee(i,1),i.m(t,null))},i(e){r||(ee(i),r=!0)},o(e){te(i),r=!1},d(e){e&&h(t),o[n].d()}}}function ak(e){let t,n,i;function r(t){e[123](t)}let s={userPubkey:e[2],userRole:e[4],policyEnabled:e[8],publishError:e[36]};return void 0!==e[35]&&(s.composeEventJson=e[35]),t=new nv({props:s}),L.push(()=>ne(t,"composeEventJson",r)),t.$on("reformatJson",e[101]),t.$on("signEvent",e[102]),t.$on("publishEvent",e[103]),t.$on("clearError",e[104]),{c(){ie(t.$$.fragment)},m(e,n){re(t,e,n),i=!0},p(e,i){const r={};4&i[0]&&(r.userPubkey=e[2]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),32&i[1]&&(r.publishError=e[36]),!n&&16&i[1]&&(n=!0,r.composeEventJson=e[35],q(()=>n=!1)),t.$set(r)},i(e){i||(ee(t.$$.fragment,e),i=!0)},o(e){te(t.$$.fragment,e),i=!1},d(e){se(t,e)}}}function ck(t){let n,i,r=t[45],o=Gk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Gk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function uk(e){let t,n;return t=new Uy({props:{isLoggedIn:e[1],userRole:e[4],userPubkey:e[2],filteredEvents:e[43],expandedEvents:e[20],isLoadingEvents:e[7],showOnlyMyEvents:oI,showFilterBuilder:e[17]}}),t.$on("scroll",e[100]),t.$on("toggleEventExpansion",e[119]),t.$on("deleteEvent",e[120]),t.$on("copyEventToClipboard",e[121]),t.$on("toggleChange",e[50]),t.$on("loadAllEvents",e[122]),t.$on("toggleFilterBuilder",e[87]),t.$on("filterApply",e[88]),t.$on("filterClear",e[89]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),4&n[0]&&(i.userPubkey=e[2]),4096&n[1]&&(i.filteredEvents=e[43]),1048576&n[0]&&(i.expandedEvents=e[20]),128&n[0]&&(i.isLoadingEvents=e[7]),131072&n[0]&&(i.showFilterBuilder=e[17]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function dk(e){let t,n;return t=new Um({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],selectedFile:e[18],aclMode:e[9],importMessage:e[19]}}),t.$on("fileSelect",e[97]),t.$on("importEvents",e[98]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),262144&n[0]&&(i.selectedFile=e[18]),512&n[0]&&(i.aclMode=e[9]),524288&n[0]&&(i.importMessage=e[19]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function fk(e){let t,n;return t=new Qm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],aclMode:e[9]}}),t.$on("exportMyEvents",e[96]),t.$on("exportAllEvents",e[95]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),512&n[0]&&(i.aclMode=e[9]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function pk(t){let n;return{c(){n=m("p"),n.textContent="Log in to access your user dashboard",I(n,"class","svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function hk(e){let t,n,i,r=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=m("p"),n=v("Welcome "),i=v(r),I(t,"class","svelte-1qbmv87")},m(e,r){p(e,t,r),f(t,n),f(t,i)},p(e,t){12&t[0]&&r!==(r=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(i,r)},d(e){e&&h(t)}}}function gk(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,x,S,B,Q,F,$,D=e[201].label+"",R=e[47].get(e[201].id)?.isLoading,P=!e[47].get(e[201].id)?.hasMore&&e[47].get(e[201].id)?.events?.length>0;function T(){return e[133](e[201])}function U(e,t){return 64&t[0]&&(k=null),64&t[0]&&(C=null),null==k&&(k=!!(e[47].get(e[201].id)?.events?.length>0)),k?yk:(null==C&&(C=!e[47].get(e[201].id)?.isLoading),C?mk:void 0)}g=new DA({props:{filter:e[47].get(e[201].id)?.filter||{}}}),g.$on("sweep",function(){return e[134](e[201])});let N=U(e,[-1,-1,-1,-1,-1,-1,-1]),_=N&&N(e),L=R&&Ak(),M=P&&kk();function O(...t){return e[139](e[201],...t)}return{c(){t=m("div"),n=m("div"),r=m("h2"),s=v("🔍 "),o=v(D),l=w(),a=m("button"),c=v("🔄 Refresh"),d=w(),ie(g.$$.fragment),y=w(),b=m("div"),_&&_.c(),x=w(),L&&L.c(),S=w(),M&&M.c(),B=w(),I(r,"class","svelte-1qbmv87"),I(a,"class","refresh-btn svelte-1qbmv87"),a.disabled=u=e[47].get(e[201].id)?.isLoading,I(n,"class","search-results-header svelte-1qbmv87"),I(b,"class","search-results-content svelte-1qbmv87"),I(t,"class","search-results-view svelte-1qbmv87")},m(e,i){p(e,t,i),f(t,n),f(n,r),f(r,s),f(r,o),f(n,l),f(n,a),f(a,c),f(t,d),re(g,t,null),f(t,y),f(t,b),_&&_.m(b,null),f(b,x),L&&L.m(b,null),f(b,S),M&&M.m(b,null),f(t,B),Q=!0,F||($=[A(a,"click",T),A(b,"scroll",O)],F=!0)},p(t,n){e=t,(!Q||64&n[0])&&D!==(D=e[201].label+"")&&E(o,D),(!Q||64&n[0]&&u!==(u=e[47].get(e[201].id)?.isLoading))&&(a.disabled=u);const i={};64&n[0]&&(i.filter=e[47].get(e[201].id)?.filter||{}),g.$set(i),N===(N=U(e,n))&&_?_.p(e,n):(_&&_.d(1),_=N&&N(e),_&&(_.c(),_.m(b,x))),64&n[0]&&(R=e[47].get(e[201].id)?.isLoading),R?L||(L=Ak(),L.c(),L.m(b,S)):L&&(L.d(1),L=null),64&n[0]&&(P=!e[47].get(e[201].id)?.hasMore&&e[47].get(e[201].id)?.events?.length>0),P?M||(M=kk(),M.c(),M.m(b,null)):M&&(M.d(1),M=null)},i(e){Q||(ee(g.$$.fragment,e),Q=!0)},o(e){te(g.$$.fragment,e),Q=!1},d(e){e&&h(t),se(g),_&&_.d(),L&&L.d(),M&&M.d(),F=!1,i($)}}}function mk(t){let n;return{c(){n=m("div"),n.innerHTML='

    No search results found.

    ',I(n,"class","no-search-results svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function yk(e){let t,n=e[47].get(e[201].id).events,i=[];for(let t=0;t👤',s=w(),o=m("div"),l=m("div"),a=v(_),c=w(),u=m("div"),d=m("span"),g=v(L),y=w(),b=m("span"),k=v(M),C=w(),x=m("div"),S=m("div"),B=v(O),Q=w(),$=m("div"),D=v(j),R=w(),G&&G.c(),P=w(),K&&K.c(),T=w(),I(r,"class","search-result-avatar svelte-1qbmv87"),I(l,"class","search-result-author svelte-1qbmv87"),I(d,"class","kind-number svelte-1qbmv87"),I(b,"class","kind-name svelte-1qbmv87"),I(u,"class","search-result-kind svelte-1qbmv87"),I(o,"class","search-result-info svelte-1qbmv87"),I(S,"class","event-timestamp svelte-1qbmv87"),I($,"class","event-content-single-line svelte-1qbmv87"),I(x,"class","search-result-content svelte-1qbmv87"),I(n,"class","search-result-row svelte-1qbmv87"),I(n,"role","button"),I(n,"tabindex","0"),I(t,"class","search-result-item svelte-1qbmv87"),F(t,"expanded",e[20].has(e[194].id))},m(e,i){p(e,t,i),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(d,g),f(u,y),f(u,b),f(b,k),f(n,C),f(n,x),f(x,S),f(S,B),f(x,Q),f(x,$),f($,D),f(n,R),G&&G.m(n,null),f(t,P),K&&K.m(t,null),f(t,T),U||(N=[A(n,"click",q),A(n,"keydown",J)],U=!0)},p(i,r){e=i,64&r[0]&&_!==(_=lA(e[194].pubkey)+"")&&E(a,_),64&r[0]&&L!==(L=e[194].kind+"")&&E(g,L),64&r[0]&&M!==(M=oA(e[194].kind)+"")&&E(k,M),64&r[0]&&O!==(O=cA(e[194].created_at)+"")&&E(B,O),64&r[0]&&j!==(j=aA(e[194].content)+"")&&E(D,j),5!==e[194].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[194].pubkey&&e[194].pubkey===e[2])?G?G.p(e,r):(G=vk(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),1048640&r[0]&&(H=e[20].has(e[194].id)),H?K?K.p(e,r):(K=wk(e),K.c(),K.m(t,T)):K&&(K.d(1),K=null),1048640&r[0]|65536&r[1]&&F(t,"expanded",e[20].has(e[194].id))},d(e){e&&h(t),G&&G.d(),K&&K.d(),U=!1,i(N)}}}function Ak(e){let t;return{c(){t=m("div"),t.innerHTML='
    \n

    Searching...

    ',I(t,"class","loading-search-results svelte-1qbmv87")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function kk(e){let t;return{c(){t=m("div"),t.innerHTML='

    No more search results to load.

    ',I(t,"class","end-of-search-results svelte-1qbmv87")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Ik(e){let t,n,i=e[201].id===e[5]&&gk(e);return{c(){i&&i.c(),t=b()},m(e,r){i&&i.m(e,r),p(e,t,r),n=!0},p(e,n){e[201].id===e[5]?i?(i.p(e,n),96&n[0]&&ee(i,1)):(i=gk(e),i.c(),ee(i,1),i.m(t.parentNode,t)):i&&(Z(),te(i,1,1,()=>{i=null}),X())},i(e){n||(ee(i),n=!0)},o(e){te(i),n=!1},d(e){i&&i.d(e),e&&h(t)}}}function Ck(t){let n,i,r=t[198].label+"";return{c(){n=m("option"),i=v(r),n.__value=t[198].value,n.value=n.__value},m(e,t){p(e,n,t),f(n,i)},p:e,d(e){e&&h(n)}}}function Ek(e){let t;function n(e,t){return e[40]?Bk:0===e[39].length?Sk:xk}let i=n(e),r=i(e);return{c(){t=m("div"),r.c(),I(t,"class","recovery-results svelte-1qbmv87")},m(e,n){p(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&h(t),r.d()}}}function xk(e){let t,n,i,r=e[39],s=[];for(let t=0;tORLY_ACL_MODE=curating in your\n environment variables and restart the relay.',I(i,"class","svelte-1qbmv87"),I(s,"class","svelte-1qbmv87"),I(l,"class","svelte-1qbmv87"),I(g,"class","svelte-1qbmv87"),I(n,"class","acl-mode-warning svelte-1qbmv87")},m(e,t){p(e,n,t),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),f(l,a),f(l,c),f(c,u),f(n,d),f(n,g)},p(e,t){512&t[0]&&y!==(y=(e[9]||"unknown")+"")&&E(u,y)},i:e,o:e,d(e){e&&h(n)}}}function Lk(e){let t,n;return t=new Gw({props:{userSigner:e[14],userPubkey:e[2]}}),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};16384&n[0]&&(i.userSigner=e[14]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function Mk(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in with owner permissions to access\n managed ACL configuration.",r=w(),s=m("button"),s.textContent="Log In",I(s,"class","login-btn svelte-1qbmv87"),I(n,"class","access-denied")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[79]),o=!0)},p:e,i:e,o:e,d(e){e&&h(n),o=!1,l()}}}function Ok(t){let n,i,r=t[45],o=Hk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Hk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function jk(t){let n,i,r,s,o,l,a,c,u,d,g,y=(t[9]||"unknown")+"";return{c(){n=m("div"),i=m("h3"),i.textContent="⚠️ Managed ACL Mode Not Active",r=w(),s=m("p"),s.textContent='To use the Managed ACL interface, you need to set\n the ACL mode to "managed" in your relay\n configuration.',o=w(),l=m("p"),a=v("Current ACL mode: "),c=m("strong"),u=v(y),d=w(),g=m("p"),g.innerHTML='Please set ORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',I(i,"class","svelte-1qbmv87"),I(s,"class","svelte-1qbmv87"),I(l,"class","svelte-1qbmv87"),I(g,"class","svelte-1qbmv87"),I(n,"class","acl-mode-warning svelte-1qbmv87")},m(e,t){p(e,n,t),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),f(l,a),f(l,c),f(c,u),f(n,d),f(n,g)},p(e,t){512&t[0]&&y!==(y=(e[9]||"unknown")+"")&&E(u,y)},i:e,o:e,d(e){e&&h(n)}}}function Hk(e){let t,n;return t=new Xg({props:{userSigner:e[14],userPubkey:e[2]}}),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};16384&n[0]&&(i.userSigner=e[14]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function Gk(e){let t,n;return t=new Ub({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[14],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),4&n[0]&&(i.userPubkey=e[2]),16384&n[0]&&(i.userSigner=e[14]),1024&n[0]&&(i.currentEffectiveRole=e[10]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function qk(e){let t,n,r,s,o,l,a,c,u,d,g;function y(e,t){return e[3]?Kk:e[1]&&e[2]?Jk:void 0}let v=y(e),b=v&&v(e),C=e[46]&&tI(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("h2"),s.textContent="Settings",o=w(),l=m("button"),l.textContent="✕",a=w(),c=m("div"),b&&b.c(),u=w(),C&&C.c(),I(s,"class","svelte-1qbmv87"),I(l,"class","close-btn svelte-1qbmv87"),I(r,"class","drawer-header svelte-1qbmv87"),I(c,"class","drawer-content"),I(n,"class","settings-drawer svelte-1qbmv87"),F(n,"dark-theme",e[0]),I(t,"class","drawer-overlay svelte-1qbmv87"),I(t,"role","button"),I(t,"tabindex","0")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),b&&b.m(c,null),f(c,u),C&&C.m(c,null),d||(g=[A(l,"click",e[84]),A(n,"click",k(e[114])),A(n,"keydown",k(e[115])),A(t,"click",e[84]),A(t,"keydown",e[142])],d=!0)},p(e,t){v===(v=y(e))&&b?b.p(e,t):(b&&b.d(1),b=v&&v(e),b&&(b.c(),b.m(c,u))),e[46]?C?C.p(e,t):(C=tI(e),C.c(),C.m(c,null)):C&&(C.d(1),C=null),1&t[0]&&F(n,"dark-theme",e[0])},d(e){e&&h(t),b&&b.d(),C&&C.d(),d=!1,i(g)}}}function Jk(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,x,S,B=e[2].slice(0,16)+"",Q=e[2].slice(-8)+"";return{c(){t=m("div"),n=m("button"),n.textContent="Log out",r=w(),s=m("h3"),s.textContent="Profile Loading",o=w(),l=m("p"),l.textContent="Your profile metadata is being loaded...",a=w(),c=m("button"),c.textContent="Retry Loading Profile",u=w(),d=m("div"),g=m("strong"),g.textContent="Public Key:",y=w(),b=v(B),k=v("..."),C=v(Q),I(n,"class","logout-btn floating svelte-1qbmv87"),I(s,"class","svelte-1qbmv87"),I(l,"class","svelte-1qbmv87"),I(c,"class","retry-profile-btn svelte-1qbmv87"),I(d,"class","user-pubkey-display svelte-1qbmv87"),I(t,"class","profile-loading-section svelte-1qbmv87")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(t,a),f(t,c),f(t,u),f(t,d),f(d,g),f(d,y),f(d,b),f(d,k),f(d,C),x||(S=[A(n,"click",e[81]),A(c,"click",e[94])],x=!0)},p(e,t){4&t[0]&&B!==(B=e[2].slice(0,16)+"")&&E(b,B),4&t[0]&&Q!==(Q=e[2].slice(-8)+"")&&E(C,Q)},d(e){e&&h(t),x=!1,i(S)}}}function Kk(e){let t,n,i,r,s,o,l,a,c,u,d,g,y,k,C,x=(e[3].name||"Unknown User")+"",S=e[3].banner&&Vk(e);function B(e,t){return e[3].picture?zk:Yk}let Q=B(e),F=Q(e),$=e[3].nip05&&Wk(e),D=e[3].about&&Zk(e),R=e[4]&&"read"!==e[4]&&Xk(e);return{c(){t=m("div"),n=m("div"),S&&S.c(),i=w(),r=m("button"),r.textContent="Log out",s=w(),F.c(),o=w(),l=m("div"),a=m("h3"),c=v(x),u=w(),$&&$.c(),d=w(),D&&D.c(),g=w(),R&&R.c(),y=b(),I(r,"class","logout-btn floating svelte-1qbmv87"),I(a,"class","profile-username svelte-1qbmv87"),I(l,"class","name-row svelte-1qbmv87"),I(n,"class","profile-hero svelte-1qbmv87"),I(t,"class","profile-section svelte-1qbmv87")},m(h,m){p(h,t,m),f(t,n),S&&S.m(n,null),f(n,i),f(n,r),f(n,s),F.m(n,null),f(n,o),f(n,l),f(l,a),f(a,c),f(l,u),$&&$.m(l,null),f(t,d),D&&D.m(t,null),p(h,g,m),R&&R.m(h,m),p(h,y,m),k||(C=A(r,"click",e[81]),k=!0)},p(e,r){e[3].banner?S?S.p(e,r):(S=Vk(e),S.c(),S.m(n,i)):S&&(S.d(1),S=null),Q===(Q=B(e))&&F?F.p(e,r):(F.d(1),F=Q(e),F&&(F.c(),F.m(n,o))),8&r[0]&&x!==(x=(e[3].name||"Unknown User")+"")&&E(c,x),e[3].nip05?$?$.p(e,r):($=Wk(e),$.c(),$.m(l,null)):$&&($.d(1),$=null),e[3].about?D?D.p(e,r):(D=Zk(e),D.c(),D.m(t,null)):D&&(D.d(1),D=null),e[4]&&"read"!==e[4]?R?R.p(e,r):(R=Xk(e),R.c(),R.m(y.parentNode,y)):R&&(R.d(1),R=null)},d(e){e&&h(t),S&&S.d(),F.d(),$&&$.d(),D&&D.d(),e&&h(g),R&&R.d(e),e&&h(y),k=!1,C()}}}function Vk(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[3].banner)||I(t,"src",n),I(t,"alt","Profile banner"),I(t,"class","profile-banner svelte-1qbmv87")},m(e,n){p(e,t,n)},p(e,i){8&i[0]&&!l(t.src,n=e[3].banner)&&I(t,"src",n)},d(e){e&&h(t)}}}function Yk(t){let n;return{c(){n=m("div"),n.textContent="👤",I(n,"class","profile-avatar-placeholder overlap svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function zk(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[3].picture)||I(t,"src",n),I(t,"alt","User avatar"),I(t,"class","profile-avatar overlap svelte-1qbmv87")},m(e,n){p(e,t,n)},p(e,i){8&i[0]&&!l(t.src,n=e[3].picture)&&I(t,"src",n)},d(e){e&&h(t)}}}function Wk(e){let t,n,i=e[3].nip05+"";return{c(){t=m("span"),n=v(i),I(t,"class","profile-nip05-inline svelte-1qbmv87")},m(e,i){p(e,t,i),f(t,n)},p(e,t){8&t[0]&&i!==(i=e[3].nip05+"")&&E(n,i)},d(e){e&&h(t)}}}function Zk(e){let t,n;return{c(){t=m("div"),n=m("p"),I(n,"class","profile-about svelte-1qbmv87"),I(t,"class","about-card svelte-1qbmv87")},m(i,r){p(i,t,r),f(t,n),n.innerHTML=e[42]},p(e,t){2048&t[1]&&(n.innerHTML=e[42])},d(e){e&&h(t)}}}function Xk(e){let t,n,i,r,s,o,l=e[106](),a=[];for(let t=0;t\n Not connected',I(n,"class","relay-disconnected svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function iI(e){let t,n,i,r,s,o,l,a=(e[44].name||"Unknown relay")+"",c=e[44].description&&rI(e);return{c(){t=m("div"),n=m("div"),i=v(a),r=w(),c&&c.c(),s=w(),o=m("div"),l=v(e[45]),I(n,"class","relay-name svelte-1qbmv87"),I(o,"class","relay-url svelte-1qbmv87"),I(t,"class","relay-info-card svelte-1qbmv87")},m(e,a){p(e,t,a),f(t,n),f(n,i),f(t,r),c&&c.m(t,null),f(t,s),f(t,o),f(o,l)},p(e,n){8192&n[1]&&a!==(a=(e[44].name||"Unknown relay")+"")&&E(i,a),e[44].description?c?c.p(e,n):(c=rI(e),c.c(),c.m(t,s)):c&&(c.d(1),c=null),16384&n[1]&&E(l,e[45])},d(e){e&&h(t),c&&c.d()}}}function rI(e){let t,n,i=e[44].description+"";return{c(){t=m("div"),n=v(i),I(t,"class","relay-description svelte-1qbmv87")},m(e,i){p(e,t,i),f(t,n)},p(e,t){8192&t[1]&&i!==(i=e[44].description+"")&&E(n,i)},d(e){e&&h(t)}}}function sI(e){let t,n,i,r,s,o,l,a,c,u,d,g,y,v,b,A,k;t=new hm({props:{isDarkTheme:e[0],isLoggedIn:e[1],userRole:e[4],currentEffectiveRole:e[10],userProfile:e[3],userPubkey:e[2]}}),t.$on("openSettingsDrawer",e[83]),t.$on("openLoginModal",e[79]),t.$on("openRelayModal",e[59]),t.$on("relayChanged",e[58]),t.$on("toggleMobileMenu",e[85]),r=new km({props:{isDarkTheme:e[0],tabs:e[11],selectedTab:e[5],version:e[34],mobileOpen:e[16]}}),r.$on("selectTab",e[117]),r.$on("closeSearchTab",e[118]),r.$on("closeMobileMenu",e[86]);const C=[fk,dk,uk,ck,ak,lk,ok,sk,rk,ik,nk,tk,ek,XA],E=[];function x(e,t){return 96&t[0]&&(l=null),"export"===e[5]?0:"import"===e[5]?1:"events"===e[5]?2:"blossom"===e[5]?3:"compose"===e[5]?4:"managed-acl"===e[5]?5:"curation"===e[5]?6:"sprocket"===e[5]?7:"policy"===e[5]?8:"relay-connect"===e[5]?9:"logs"===e[5]?10:"recovery"===e[5]?11:(null==l&&(l=!!e[6].some(e[116])),l?12:13)}a=x(e,[-1,-1,-1,-1,-1,-1,-1]),c=E[a]=C[a](e);let S=e[15]&&qk(e);function B(t){e[143](t)}let Q={isDarkTheme:e[0]};function $(t){e[144](t)}void 0!==e[12]&&(Q.showModal=e[12]),g=new ag({props:Q}),L.push(()=>ne(g,"showModal",B)),g.$on("login",e[80]),g.$on("close",e[82]);let D={isDarkTheme:e[0]};return void 0!==e[13]&&(D.showModal=e[13]),b=new qA({props:D}),L.push(()=>ne(b,"showModal",$)),b.$on("connected",e[61]),b.$on("close",e[60]),{c(){ie(t.$$.fragment),n=w(),i=m("div"),ie(r.$$.fragment),s=w(),o=m("main"),c.c(),u=w(),S&&S.c(),d=w(),ie(g.$$.fragment),v=w(),ie(b.$$.fragment),I(o,"class","main-content svelte-1qbmv87"),I(i,"class","app-container svelte-1qbmv87"),F(i,"dark-theme",e[0])},m(e,l){re(t,e,l),p(e,n,l),p(e,i,l),re(r,i,null),f(i,s),f(i,o),E[a].m(o,null),p(e,u,l),S&&S.m(e,l),p(e,d,l),re(g,e,l),p(e,v,l),re(b,e,l),k=!0},p(e,n){const s={};1&n[0]&&(s.isDarkTheme=e[0]),2&n[0]&&(s.isLoggedIn=e[1]),16&n[0]&&(s.userRole=e[4]),1024&n[0]&&(s.currentEffectiveRole=e[10]),8&n[0]&&(s.userProfile=e[3]),4&n[0]&&(s.userPubkey=e[2]),t.$set(s);const l={};1&n[0]&&(l.isDarkTheme=e[0]),2048&n[0]&&(l.tabs=e[11]),32&n[0]&&(l.selectedTab=e[5]),8&n[1]&&(l.version=e[34]),65536&n[0]&&(l.mobileOpen=e[16]),r.$set(l);let u=a;a=x(e,n),a===u?E[a].p(e,n):(Z(),te(E[u],1,1,()=>{E[u]=null}),X(),c=E[a],c?c.p(e,n):(c=E[a]=C[a](e),c.c()),ee(c,1),c.m(o,null)),(!k||1&n[0])&&F(i,"dark-theme",e[0]),e[15]?S?S.p(e,n):(S=qk(e),S.c(),S.m(d.parentNode,d)):S&&(S.d(1),S=null);const f={};1&n[0]&&(f.isDarkTheme=e[0]),!y&&4096&n[0]&&(y=!0,f.showModal=e[12],q(()=>y=!1)),g.$set(f);const p={};1&n[0]&&(p.isDarkTheme=e[0]),!A&&8192&n[0]&&(A=!0,p.showModal=e[13],q(()=>A=!1)),b.$set(p)},i(e){k||(ee(t.$$.fragment,e),ee(r.$$.fragment,e),ee(c),ee(g.$$.fragment,e),ee(b.$$.fragment,e),k=!0)},o(e){te(t.$$.fragment,e),te(r.$$.fragment,e),te(c),te(g.$$.fragment,e),te(b.$$.fragment,e),k=!1},d(e){se(t,e),e&&h(n),e&&h(i),se(r),E[a].d(),e&&h(u),S&&S.d(e),e&&h(d),se(g,e),e&&h(v),se(b,e)}}}let oI=!1,lI=!1;function aI(e,t,n){let i,r,s,o,l,a,d,f,p;u(e,vp,e=>n(44,a=e)),u(e,bp,e=>n(113,d=e)),u(e,mp,e=>n(45,f=e)),u(e,yp,e=>n(46,p=e)),"undefined"!=typeof window&&(window.debugIndexedDB=lh);let h=!1,g=!1,m=!1,y=!1,v="",w="",b=null,A=null,k=null,I="",E=null,x=!1,S=!1,B=localStorage.getItem("selectedTab")||"export",F=!1,$={},D=[],R=[],P=null,T="",U=new Set,_=!1,L=!0,M=null,O="",j=new Map,H=[],G=0,q=[],J=!1,K=!0,V=null,Y="",z=null,W=[],Z=!1,X="",ee="info",te=!1,ne=null,ie="",re=!1,se=!1,oe="",le="info",ae=[],ce=[],ue=!1,de="",fe="",pe="",he="",ge=null,me="",ye=[],ve=!1,we=!0,be=null;function Ae(e){U.has(e)?U.delete(e):U.add(e),n(20,U)}async function ke(e,t){const n=JSON.stringify(e),i=await uA(n);dA(t.target.closest(".copy-json-btn"),i),i||alert("Failed to copy to clipboard. Please copy manually.")}async function Ie(e){if(!y)return void alert("Please log in first");const t=R.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===I||"owner"===I||"write"===I&&t.pubkey&&t.pubkey===v){if(confirm("Are you sure you want to delete this event?"))try{if(!E)throw new Error("Signer not available for signing");const i={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",i),console.log("User pubkey:",v),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const r=await E.signEvent(i);console.log("Signed delete event:",r),console.log("Signed delete event pubkey:",r.pubkey),console.log("Delete event tags:",r.tags);const s=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;try{const e=await KA(s,r,E,v);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const o=t.pubkey&&t.pubkey===v;if(o){const t=await Op.publish(r);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await ih(e,{timeout:5e3});n?(console.warn("Event still exists after deletion attempt:",n),alert(`Warning: Delete event was accepted by ${t.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await rh(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===v);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(107,R=R.filter(t=>t.id!==e)),q=q.filter(t=>t.id!==e),H=H.filter(t=>t.id!==e);for(const[t,n]of j)n.events&&(n.events=n.events.filter(t=>t.id!==e),j.set(t,n));Fe(),console.log("Reloading events to show delete event...");const i=oI&&y&&v?[v]:null;await Ze(!0,i),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=new Mp;await i.connectToRelay(t);const s=await i.publish(r);if(console.log("Delete event published to local relay only:",s),!(s.success&&s.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await ih(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${s.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await rh(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===v);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(107,R=R.filter(t=>t.id!==e)),q=q.filter(t=>t.id!==e),H=H.filter(t=>t.id!==e);for(const[t,n]of j)n.events&&(n.events=n.events.filter(t=>t.id!==e),j.set(t,n));Fe(),console.log("Reloading events to show delete event...");const t=oI&&y&&v?[v]:null;await Ze(!0,t),alert("Event deleted successfully (local relay only - admin/owner deleting other user's event)")}}}catch(e){console.error("Failed to delete event:",e),alert("Failed to delete event: "+e.message)}}else alert("You do not have permission to delete this event")}async function Ce(){const e=me?parseInt(me):ge;if(null==e||isNaN(e))console.log("No valid kind to load, kindToUse:",e);else if(y){console.log("Loading recovery events for kind:",e,"user:",v),n(40,ve=!0);try{const t=[{kinds:[e],authors:[v],limit:100}];be&&(t[0].until=be),console.log("Recovery filters:",t);const i=await oh(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",i.length),console.log("Recovery events kinds:",i.map(e=>e.kind)),n(39,ye=be?[...ye,...i]:i),i.length>0?(be=Math.min(...i.map(e=>e.created_at)),n(41,we=100===i.length)):n(41,we=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(40,ve=!1)}}else console.log("Not logged in, cannot load recovery events")}async function Ee(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const i={...e};if(i.created_at=Math.floor(Date.now()/1e3),i.id="",i.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(i.tags=i.tags.filter(e=>"d"!==e[0]),i.tags.push(t))}if(E){const e=await E.signEvent(i);console.log("Signed event for repost:",e);const r=await Op.publish(e,[t]);console.log("Repost publish result:",r),r.success&&r.okCount>0?(alert("Event reposted successfully!"),n(41,we=!1),await Ce()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event:",e),alert("Error reposting event: "+e.message)}}async function xe(e){if(confirm("Are you sure you want to repost this event to all your write relays?"))try{const t=await async function(){if(!v)return[];try{const e=await Yp([{kinds:[10002],authors:[v],limit:1}]);if(0===e.length)return console.log("No relay list event found for user"),[];const t=e[0];console.log("Found relay list event:",t);const n=[];for(const e of t.tags)if("r"===e[0]&&e.length>=2){const t=e[1],i=e.length>=3?e[2]:null;i&&"write"!==i||n.push(t)}return console.log("Found write relays:",n),n}catch(e){return console.error("Error fetching user write relays:",e),[]}}(),i=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=[i,...t.filter(e=>e!==i)];1===r.length&&alert("No write relays found in your relay list. Only posting to local relay."),console.log("Reposting event to all relays:",r,e);const s={...e};if(s.created_at=Math.floor(Date.now()/1e3),s.id="",s.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(s.tags=s.tags.filter(e=>"d"!==e[0]),s.tags.push(t))}if(E){const e=await E.signEvent(s);console.log("Signed event for repost to all:",e);const t=await Op.publish(e,r);console.log("Repost to all publish result:",t),t.success&&t.okCount>0?(alert(`Event reposted successfully to ${r.length} relays!`),n(41,we=!1),await Ce()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event to all:",e),alert("Error reposting event to all: "+e.message)}}let Se="auto";if("undefined"!=typeof window&&window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");h=e.matches,e.addEventListener("change",e=>{"auto"===Se&&n(0,h=e.matches)}),(async()=>{try{const e=await rA();e?.theme&&"auto"!==e.theme&&(Se=e.theme,n(0,h="dark"===e.theme))}catch(e){console.log("Could not fetch relay theme config:",e)}})()}if("undefined"!=typeof localStorage){const e=localStorage.getItem("nostr_auth_method"),t=localStorage.getItem("nostr_pubkey");e&&t&&(y=!0,v=t,w=e,"extension"===e&&window.nostr&&(E=window.nostr)),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const i=JSON.parse(t);i.selectedTab&&Le.some(e=>e.id===i.selectedTab)&&n(5,B=i.selectedTab),i.expandedEvents&&n(20,U=new Set(i.expandedEvents)),i.globalEventsCache&&(H=i.globalEventsCache),i.globalCacheTimestamp&&(G=i.globalCacheTimestamp),void 0!==i.hasMoreEvents&&(L=i.hasMoreEvents),i.oldestEventTimestamp&&(M=i.oldestEventTimestamp),void 0!==i.hasMoreMyEvents&&(K=i.hasMoreMyEvents),i.oldestMyEventTimestamp&&(V=i.oldestMyEventTimestamp),H.length>0&&((e=G)&&Date.now()-et.created_at-e.created_at),G=Date.now(),Fe()}async function De(){if(y&&"owner"===I&&te)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/status`,{method:"GET",headers:{Authorization:`Nostr ${await nt("GET",`${xp()}/api/sprocket/status`)}`,"Content-Type":"application/json"}});e.ok?n(22,z=await e.json()):Ue("Failed to load sprocket status","error")}catch(e){Ue(`Error loading sprocket status: ${e.message}`,"error")}finally{n(24,Z=!1)}}async function Re(){if(y&&"owner"===I)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/versions`,{method:"GET",headers:{Authorization:`Nostr ${await nt("GET",`${xp()}/api/sprocket/versions`)}`,"Content-Type":"application/json"}});e.ok?n(23,W=await e.json()):Ue("Failed to load versions","error")}catch(e){Ue(`Error loading versions: ${e.message}`,"error")}finally{n(24,Z=!1)}}async function Pe(e){y&&"owner"===I&&(n(21,Y=e.content),Ue(`Loaded version: ${e.name}`,"success"))}async function Te(e){if(y&&"owner"===I&&confirm(`Are you sure you want to delete version ${e}?`))try{n(24,Z=!0);const t=await fetch(`${xp()}/api/sprocket/delete-version`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/delete-version`)}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)Ue(`Version ${e} deleted successfully`,"success"),await Re();else{Ue(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){Ue(`Error deleting version: ${e.message}`,"error")}finally{n(24,Z=!1)}}function Ue(e,t="info"){n(25,X=e),n(26,ee=t),setTimeout(()=>{n(25,X="")},5e3)}function Ne(e,t="info"){n(30,oe=e),n(31,le=t),"error"!==t&&setTimeout(()=>{n(30,oe="")},5e3)}async function _e(){if(n(32,ae=[]),!ie.trim())return n(32,ae=["Policy JSON is empty"]),Ne("Validation failed","error"),!1;try{const e=JSON.parse(ie);if("object"!=typeof e||null===e)return n(32,ae=["Policy must be a JSON object"]),Ne("Validation failed","error"),!1;if(e.policy_admins)if(Array.isArray(e.policy_admins))for(const t of e.policy_admins)"string"==typeof t&&/^[0-9a-fA-F]{64}$/.test(t)||ae.push(`Invalid policy_admin pubkey: ${t}`);else ae.push("policy_admins must be an array");if(e.rules)if("object"!=typeof e.rules)ae.push("rules must be an object");else for(const[t,n]of Object.entries(e.rules))if(/^\d+$/.test(t)||ae.push(`Invalid kind number: ${t}`),n.tag_validation&&"object"==typeof n.tag_validation)for(const[e,t]of Object.entries(n.tag_validation))try{new RegExp(t)}catch(n){ae.push(`Invalid regex for tag '${e}': ${t}`)}return e.default_policy&&!["allow","deny"].includes(e.default_policy)&&ae.push("default_policy must be 'allow' or 'deny'"),ae.length>0?(Ne("Validation failed - see errors below","error"),!1):(Ne("Validation passed","success"),!0)}catch(e){return n(32,ae=[`JSON parse error: ${e.message}`]),Ne("Invalid JSON syntax","error"),!1}}const Le=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"blossom",icon:"🌸",label:"Blossom"},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"curation",icon:"📋",label:"Curation",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0},{id:"policy",icon:"📜",label:"Policy",requiresOwner:!0},{id:"relay-connect",icon:"🔗",label:"Relay Connect",requiresOwner:!0},{id:"logs",icon:"📋",label:"Logs",requiresOwner:!0}];function Me(e){n(5,B=e),"sprocket"===e&&y&&"owner"===I&&te&&(De(),Re()),Fe()}function Oe(){n(15,x=!1)}function je(e){He(e)}function He(e){n(6,D=D.filter(t=>t.id!==e)),j.delete(e),B===e&&n(5,B="export")}async function Ge(e,t=!0){const n=j.get(e);if(n&&!n.isLoading){n.isLoading=!0,j.set(e,n);try{const i={...n.filter};!t&&n.oldestTimestamp&&(i.until=n.oldestTimestamp),t||(i.limit=200),console.log("Loading search results with filter:",i);const r=await nh([i],{timeout:3e4});if(console.log("Received search results:",r.length,"events"),n.events=t?r.sort((e,t)=>t.created_at-e.created_at):[...n.events,...r].sort((e,t)=>t.created_at-e.created_at),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!n.oldestTimestamp||et.created_at-e.created_at):[...q,...t].sort((e,t)=>t.created_at-e.created_at),t.length>0){const e=Math.min(...t.map(e=>e.created_at));(!V||e{if("myevents"===B){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&async function(){!J&&K&&await We(!1)}()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{J=!1}}}else alert("Please log in first")}async function Ze(e=!1,t=null){if(!y||"read"!==I&&"write"!==I&&"admin"!==I&&"owner"!==I)alert("Read, write, admin, or owner permission required");else if(!_){n(7,_=!0),e&&(M=null);try{console.log("Loading events with authors filter:",t,"including delete events");const i=e?Math.floor(Date.now()/1e3):M,r=$.authors||t,s=await async function(e={}){const{limit:t=100,since:n=null,until:i=null,authors:r=null,kinds:s=null,...o}=e,l=Math.floor(Date.now()/1e3),a=n||l-15768e4,c=[{...o}];return c[0].since=a,i&&(c[0].until=i),r&&(c[0].authors=r),s&&(c[0].kinds=s),t&&(c[0].limit=t),await nh(c,{timeout:3e4})}({...$,limit:e?100:200,until:$.until||i,authors:r});if(console.log("Received events:",s.length,"events"),t&&s.length>0){const e=s.filter(e=>e.pubkey&&e.pubkey!==v);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",s.length)}if(e?(n(107,R=s.sort((e,t)=>t.created_at-e.created_at)),$e(s)):(n(107,R=[...R,...s].sort((e,t)=>t.created_at-e.created_at)),$e(R)),s.length>0){const e=Math.min(...s.map(e=>e.created_at));(!M||e{if("events"===B){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&Xe()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(7,_=!1)}}}async function Xe(){await Ze(!1)}let et=!1;async function tt(e,t){if(!y||!v)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",e],["method",t.toUpperCase()]],content:"",pubkey:v};let i;if(E&&"extension"===w)try{i=await E.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==w)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),i=n}const r=JSON.stringify(i);return`Nostr ${btoa(r)}`}async function nt(e,t){if(!y||!v)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",t],["method",e.toUpperCase()]],content:"",pubkey:v};let i;if(E&&"extension"===w)try{i=await E.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==w)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),i=n}const r=JSON.stringify(i);return btoa(r)}function it(e,t){const n=e.toLowerCase();if(n.includes("policy")||n.includes("blocked")||n.includes("denied")){let n=`Policy Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} may be restricted by the relay's policy configuration.`),re&&(n+="\n\nThe relay has policy enforcement enabled. Contact a relay administrator to allow this event kind or adjust your permissions."),n}if(n.includes("auth")||n.includes("permission")||n.includes("unauthorized"))return`Permission Error: ${e}\n\nYour current permissions may not allow publishing this type of event. Current role: ${I||"unknown"}. Contact a relay administrator to upgrade your permissions.`;if(n.includes("kind")||n.includes("not allowed")||n.includes("restricted")){let n=`Event Type Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} is not currently allowed on this relay.`),n+="\n\nThe relay administrator may need to update the policy configuration to allow this event kind.",n}return n.includes("rate")||n.includes("limit")||n.includes("too many")?`Rate Limit Error: ${e}\n\nPlease wait a moment before trying again.`:n.includes("size")||n.includes("too large")||n.includes("content")?`Size Limit Error: ${e}\n\nThe event may exceed the relay's size limits. Try reducing the content length.`:`Publishing failed: ${e}`}function rt(e){n(108,O=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",l)}O=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(6&e.$$.dirty[0]|16384&e.$$.dirty[3]&&n(43,i=R.sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(42,r=b?.about?(t=b.about,t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):"").replace(/\n{2,}/g,"
    "):""),16&e.$$.dirty[0]|32768&e.$$.dirty[3]&&n(10,l=O&&""!==O?O:I),1810&e.$$.dirty[0]|1277952&e.$$.dirty[3]&&n(112,s=Le.filter(e=>{const t=l;if(e.requiresAdmin&&(!y||"admin"!==t&&"owner"!==t))return!1;if(e.requiresOwner&&(!y||"owner"!==t))return!1;if(e.requiresWrite&&(!y||"read"===t))return!1;return!(["sprocket","policy","managed-acl","curation","logs","relay-connect"].includes(e.id)&&!d)&&(!("sprocket"===e.id&&!te)&&(!("policy"===e.id&&!re)&&(!("relay-connect"===e.id&&!ue)&&(("managed-acl"!==e.id||"managed"===de)&&(("curation"!==e.id||"curating"===de)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:y,userRole:I,viewAsRole:O,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0))))))})),64&e.$$.dirty[0]|524288&e.$$.dirty[3]&&n(11,o=[...s,...D]),2578&e.$$.dirty[0]|524288&e.$$.dirty[3]&&console.log("Tabs debug:",{isLoggedIn:y,userRole:I,aclMode:de,filteredBaseTabs:s.map(e=>e.id),allTabs:o.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(h?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&y&&v&&!b&&Je(),182&e.$$.dirty[0]|278528&e.$$.dirty[3]&&"events"===B&&y&&("read"===I||"write"===I||"admin"===I||"owner"===I)&&0===R.length&&!et&&!_){n(111,et=!0);Ze(!0,null)}32&e.$$.dirty[0]|16384&e.$$.dirty[3]&&("events"!==B||"events"===B&&R.length>0)&&n(111,et=!1),32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",B)},[h,y,v,b,I,B,D,_,re,de,l,o,g,m,E,x,S,F,P,T,U,Y,z,W,Z,X,ee,ne,ie,se,oe,le,ae,ce,fe,pe,he,ge,me,ye,ve,we,r,i,a,f,p,j,Ae,ke,async function(){console.log("Toggle changed, showOnlyMyEvents:",oI),n(111,et=!1),await Ze(!0,null)},Ie,Ce,Ee,xe,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",ge),null!=ge?(n(38,me=""),n(39,ye=[]),be=null,n(41,we=!0),Ce()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",me);const e=parseInt(me);""!==me&&!isNaN(e)&&e>=0&&(n(37,ge=null),n(39,ye=[]),be=null,n(41,we=!0),Ce())},function(e){const t=ye.filter(t=>t.kind===e.kind&&t.pubkey===e.pubkey),n=Math.max(...t.map(e=>e.created_at));return e.created_at===n},async function(e){console.log("Relay changed:",e.detail?.info?.name),Op.reset(),await async function(){console.log("[nostr] Clearing IndexedDB cache...");try{const e=(await Jp()).transaction(qp,"readwrite").objectStore(qp);await new Promise((t,n)=>{const i=e.clear();i.onsuccess=()=>t(),i.onerror=()=>n(i.error)}),console.log("[nostr] IndexedDB cache cleared")}catch(e){console.warn("[nostr] Failed to clear IndexedDB cache",e)}}(),H=[],G=0,n(111,et=!1),n(107,R=[]),q=[],L=!0,K=!0,M=null,j.clear(),n(6,D=[]),Be(),"events"===B&&y?Ze(!0):"myevents"===B&&y&&We(!0)},Qe,function(){n(13,m=!1)},async function(e){console.log("Connected to relay:",e.detail?.info?.name),Op&&Op.refreshRelays(),await Be()},async function(){if(y&&"owner"===I)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/status`,{method:"GET",headers:{Authorization:`Nostr ${await nt("GET",`${xp()}/api/sprocket/status`)}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(21,Y=t.script_content||""),n(22,z=t),Ue("Script loaded successfully","success")}else Ue("Failed to load script","error")}catch(e){Ue(`Error loading script: ${e.message}`,"error")}finally{n(24,Z=!1)}},async function(){if(y&&"owner"===I)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:Y});if(e.ok)Ue("Script saved and updated successfully","success"),await De(),await Re();else{Ue(`Failed to save script: ${await e.text()}`,"error")}}catch(e){Ue(`Error saving script: ${e.message}`,"error")}finally{n(24,Z=!1)}},async function(){if(y&&"owner"===I)try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/restart`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/restart`)}`,"Content-Type":"application/json"}});if(e.ok)Ue("Sprocket restarted successfully","success"),await De();else{Ue(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){Ue(`Error restarting sprocket: ${e.message}`,"error")}finally{n(24,Z=!1)}},async function(){if(y&&"owner"===I&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(24,Z=!0);const e=await fetch(`${xp()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(21,Y=""),Ue("Sprocket script deleted successfully","success"),await De(),await Re();else{Ue(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){Ue(`Error deleting script: ${e.message}`,"error")}finally{n(24,Z=!1)}},Re,Pe,Te,async function(){if(y&&("owner"===I||lI))try{n(29,se=!0),n(32,ae=[]);const e={kinds:[12345],limit:1},t=await oh(e);if(t&&t.length>0){n(28,ie=t[0].content);try{n(28,ie=JSON.stringify(JSON.parse(ie),null,2))}catch(e){}Ne("Policy loaded successfully","success")}else{const e=await fetch(`${xp()}/api/policy`,{method:"GET",headers:{Authorization:`Nostr ${await nt("GET",`${xp()}/api/policy`)}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(28,ie=JSON.stringify(t,null,2)),Ne("Policy loaded from file","success")}else Ne("No policy configuration found","info"),n(28,ie="")}}catch(e){Ne(`Error loading policy: ${e.message}`,"error")}finally{n(29,se=!1)}},_e,async function(){if(!y||"owner"!==I&&!lI)return;if(await _e())try{n(29,se=!0);const e={kind:12345,created_at:Math.floor(Date.now()/1e3),tags:[],content:ie},t=await KA(e,E);t.success?Ne("Policy updated successfully","success"):Ne(`Failed to publish policy: ${t.error||"Unknown error"}`,"error")}catch(e){Ne(`Error saving policy: ${e.message}`,"error")}finally{n(29,se=!1)}},function(){try{const e=JSON.parse(ie);n(28,ie=JSON.stringify(e,null,2)),Ne("JSON formatted","success")}catch(e){Ne(`Cannot format: ${e.message}`,"error")}},function(e){const t=e.detail;if(!t)return void Ne("Please enter a pubkey","error");const i=function(e){if(!e)return null;if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(e.startsWith("npub1"))try{const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n=e.slice(5);let i=[];for(const e of n){const n=t.indexOf(e.toLowerCase());if(-1===n)throw new Error("Invalid character in npub");i.push(...[...Array(5)].map((e,t)=>n>>4-t&1))}i=i.slice(0,-30);const r=[];for(let e=0;e+8<=i.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|i[e+n];r.push(t)}return r.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Failed to decode npub:",e),null}return null}(t);if(i&&64===i.length)try{const e=JSON.parse(ie||"{}");if(e.policy_admins||(e.policy_admins=[]),e.policy_admins.includes(i))return void Ne("Admin already in list","warning");e.policy_admins.push(i),n(28,ie=JSON.stringify(e,null,2)),Ne("Admin added - click 'Save & Publish' to apply","info")}catch(e){Ne(`Error adding admin: ${e.message}`,"error")}else Ne("Invalid pubkey format. Use hex (64 chars) or npub","error")},function(e){const t=e.detail;try{const e=JSON.parse(ie||"{}");e.policy_admins&&(e.policy_admins=e.policy_admins.filter(e=>e!==t),n(28,ie=JSON.stringify(e,null,2)),Ne("Admin removed - click 'Save & Publish' to apply","info"))}catch(e){Ne(`Error removing admin: ${e.message}`,"error")}},async function(){if(y&&("owner"===I||lI))try{n(29,se=!0),n(33,ce=[]);let e=[];try{e=JSON.parse(ie||"{}").policy_admins||[]}catch(e){return void Ne("Cannot parse policy JSON to get admins","error")}if(0===e.length)return void Ne("No policy admins configured","warning");const t={kinds:[3],authors:e,limit:e.length},i=await oh(t),r=new Set;for(const e of i)if(e.tags)for(const t of e.tags)"p"===t[0]&&t[1]&&64===t[1].length&&r.add(t[1]);n(33,ce=Array.from(r)),Ne(`Loaded ${ce.length} follows from ${i.length} admin(s)`,"success")}catch(e){Ne(`Error loading follows: ${e.message}`,"error")}finally{n(29,se=!1)}},function(e){n(27,ne=e.target.files[0])},async function(){if(y&&"owner"===I&&ne)try{n(24,Z=!0);const e=await ne.text(),t=await fetch(`${xp()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await nt("POST",`${xp()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(21,Y=e),Ue("Script uploaded and updated successfully","success"),await De(),await Re();else{Ue(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){Ue(`Error uploading script: ${e.message}`,"error")}finally{n(24,Z=!1),n(27,ne=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},Me,function(){y||n(12,g=!0)},async function(e){const{method:t,pubkey:i,privateKey:r,signer:s}=e.detail;n(1,y=!0),n(2,v=i),w=t,n(14,E=s),n(12,g=!1);try{if(await sh(),"extension"===t&&s)Op.setSigner(s);else if("nsec"===t&&r){const e=new gf(r);Op.setSigner(e)}n(3,b=await Wp(i)),console.log("Profile loaded:",b),A=await async function(e){console.log(`[nostr] Fetching relay list for pubkey: ${e?.substring(0,8)}...`);const t=[{kinds:[10002],authors:[e],limit:1}];try{const e=await nh(t,{timeout:1e4,useCache:!0});if(e.length>0){const t=e.sort((e,t)=>t.created_at-e.created_at)[0];return console.log("[nostr] Relay list found on local relay"),Xp(t)}}catch(e){console.warn("[nostr] Failed to fetch relay list from local relay:",e)}console.log("[nostr] Relay list not found locally, trying fallback relays...");try{const e=await eh(t);if(e){await Kp(e);try{await Op.publish(e)}catch(e){console.warn("[nostr] Failed to publish relay list to local relay:",e)}return Xp(e)}}catch(e){console.warn("[nostr] Failed to fetch relay list from fallback relays:",e)}return console.log("[nostr] No relay list found for pubkey"),null}(i),A&&console.log("User relay list loaded:",A.all.length,"relays"),k=await async function(e){console.log(`[nostr] Fetching contact list for pubkey: ${e?.substring(0,8)}...`);const t=[{kinds:[3],authors:[e],limit:1}];try{const e=await nh(t,{timeout:1e4,useCache:!0});if(e.length>0){const t=e.sort((e,t)=>t.created_at-e.created_at)[0];return console.log("[nostr] Contact list found on local relay"),th(t)}}catch(e){console.warn("[nostr] Failed to fetch contact list from local relay:",e)}console.log("[nostr] Contact list not found locally, trying fallback relays...");try{const e=await eh(t);if(e){await Kp(e);try{await Op.publish(e)}catch(e){console.warn("[nostr] Failed to publish contact list to local relay:",e)}return th(e)}}catch(e){console.warn("[nostr] Failed to fetch contact list from fallback relays:",e)}return console.log("[nostr] No contact list found for pubkey"),null}(i),k&&console.log("User contact list loaded:",k.follows.length,"follows")}catch(e){console.error("Failed to load profile:",e)}await Ke(),await Ye()},function(){n(1,y=!1),n(2,v=""),w="",n(3,b=null),A=null,k=null,n(4,I=""),n(14,E=null),userPrivkey=null,n(15,x=!1),q=[],n(107,R=[]),H=[],G=0,Fe(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(12,g=!1)},function(){n(15,x=!0)},Oe,function(){n(16,S=!S)},function(){n(16,S=!1)},function(){n(17,F=!F)},function(e){const{searchText:t,selectedKinds:n,pubkeys:i,eventIds:r,tags:s,sinceTimestamp:o,untilTimestamp:l,limit:a}=e.detail,c=function({searchText:e=null,kinds:t=[],authors:n=[],ids:i=[],tags:r=[],since:s=null,until:o=null,limit:l=null}){const a={};return e&&e.trim()&&(a.search=e.trim()),t&&t.length>0&&(a.kinds=t),n&&n.length>0&&(a.authors=n),i&&i.length>0&&(a.ids=i),r&&r.length>0&&r.forEach(e=>{if(e.name&&e.value){const t=`#${e.name}`;a[t]||(a[t]=[]),a[t].push(e.value)}}),s&&(a.since=s),o&&(a.until=o),l&&l>0&&(a.limit=l),a}({searchText:t,kinds:n,authors:i,ids:r,tags:s,since:o,until:l,limit:a||100});$=c,Ze(!0,null)},function(){$={},Ze(!0,null)},je,He,Ge,qe,Je,async function(){await ze([])},async function(){await ze([v])},function(e){n(18,P=e.detail.target.files[0])},async function(){if("none"!==de&&(!y||"admin"!==I&&"owner"!==I))return n(19,T="Admin or owner permission required"),void setTimeout(()=>{n(19,T="")},5e3);if(!P)return n(19,T="Please select a file"),void setTimeout(()=>{n(19,T="")},5e3);try{n(19,T="Uploading...");const e={};"none"!==de&&y&&(e.Authorization=await tt(`${xp()}/api/import`,"POST"));const t=new FormData;t.append("file",P);const i=await fetch(`${xp()}/api/import`,{method:"POST",headers:e,body:t});if(!i.ok)throw new Error(`Import failed: ${i.status} ${i.statusText}`);await i.json();n(19,T="Upload complete"),n(18,P=null),document.getElementById("import-file").value="",setTimeout(()=>{n(19,T="")},5e3)}catch(e){console.error("Import failed:",e),n(19,T="Import failed: "+e.message),setTimeout(()=>{n(19,T="")},5e3)}},Ze,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:i}=e.target;n-t-i<100&&Xe()},function(){try{if(!pe.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(pe);n(35,pe=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!pe.trim())return void alert("Please enter an event to sign");if(!y||!v)return void alert("Please log in to sign events");if(!E)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(pe);e.pubkey=v,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await E.signEvent(e);n(35,pe=JSON.stringify(t,null,2)),alert("Event signed successfully!")}catch(e){console.error("Error signing event:",e),alert("Error signing event: "+e.message)}},async function(){n(36,he="");try{if(!pe.trim())return void n(36,he="Please enter an event to publish");if(!y)return void n(36,he="Please log in to publish events");if(!E)return void n(36,he="No signer available. Please log in with a valid authentication method.");let e;try{e=JSON.parse(pe)}catch(e){return void n(36,he=`Invalid JSON: ${e.message}`)}if(!e.id||!e.sig)return void n(36,he='Event must be signed before publishing. Please click "Sign" first.');if("read"===I)return void n(36,he=`Permission denied: Your current role is "${I}" which does not allow publishing events. Contact a relay administrator to upgrade your permissions.`);const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=await KA(t,e,E,v);if(i.success)n(36,he=""),alert("Event published successfully to ORLY relay!");else{const t=i.reason||"Unknown error";n(36,he=it(t,e.kind))}}catch(e){console.error("Error publishing event:",e);const t=e.message||"Unknown error";n(36,he=it(t,null))}},function(){n(36,he="")},rt,function(){const e=["owner","admin","write","read"],t=e.indexOf(I);return-1===t?["read"]:e.slice(t)},R,O,te,ue,et,s,d,function(t){N.call(this,e,t)},function(t){N.call(this,e,t)},e=>e.id===B,e=>Me(e.detail),e=>He(e.detail),e=>Ae(e.detail),e=>Ie(e.detail),e=>ke(e.detail.event,e.detail.e),e=>Ze(e.detail.refresh,e.detail.authors),function(e){pe=e,n(35,pe)},function(e){Y=e,n(21,Y)},e=>Pe(e.detail),e=>Te(e.detail),function(e){ie=e,n(28,ie)},function(){ge=Q(this),n(37,ge)},function(){me=C(this.value),n(38,me)},e=>xe(e),e=>Ee(e),(e,t)=>ke(e,t),e=>Ge(e.id,!0),e=>je(e.id),e=>Ie(e.id),e=>Ae(e.id),(e,t)=>"Enter"===t.key&&Ae(e.id),(e,t)=>ke(e,t),(e,t)=>qe(t,e.id),e=>rt(e===I?"":e),()=>{Oe(),Qe()},e=>"Escape"===e.key&&Oe(),function(e){g=e,n(12,g)},function(e){m=e,n(13,m)}]}!function(){const e=!!localStorage.getItem("relayUrl"),t="file:"===window.location.protocol,n=!["3334","7777","443","80",""].includes(window.location.port),i=Cp||e||t||n;yp.set(i),Ep&&!c(mp)&&mp.set(Ep),console.log("[config] Initialized:",{standaloneMode:i,buildStandalone:Cp,hasStoredRelay:e,isNonRelayPort:n,port:window.location.port,relayUrl:c(mp)||"(same origin)"})}();return new class extends ae{constructor(e){super(),le(this,e,aI,sI,s,{},null,[-1,-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); + */function ah(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function l(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,l)}a((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class ch{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then(()=>new Promise(e)),new Promise(t=>{e=t})}dispatch(e){return ah(this,void 0,void 0,function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}})}}var uh;const dh="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,fh=null!==(uh=dh.Buffer)&&void 0!==uh?uh:null,ph=dh.TextEncoder?new dh.TextEncoder:null;function hh(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function gh(e,t){const n=t.length>>1;for(let i=0;i>>4;e[i++]=n>9?n+mh:n+yh,n=15&t[r],e[i++]=n>9?n+mh:n+yh}return String.fromCharCode.apply(null,e)}const wh=null!==fh?e=>{if("string"==typeof e){const t=fh.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(fh.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return ph.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},bh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ah=new Uint8Array(256);for(let e=0;e<64;e++)Ah[bh.charCodeAt(e)]=e;function kh(e,t=!0){const n=e.length,i=n%3,r=[],s=n-i;for(let t=0;t>18&63)+bh.charAt(n>>12&63)+bh.charAt(n>>6&63)+bh.charAt(63&n);r.push(i)}if(1===i){const i=e[n-1],s=bh.charAt(i>>2),o=bh.charAt(i<<4&63);r.push(`${s}${o}`),t&&r.push("==")}else if(2===i){const i=(e[n-2]<<8)+e[n-1],s=bh.charAt(i>>10),o=bh.charAt(i>>4&63),l=bh.charAt(i<<2&63);r.push(`${s}${o}${l}`),t&&r.push("=")}return r.join("")}function Ih(e){const t=function(e){let t=Math.floor(.75*e.length);const n=e.length;return"="===e[n-1]&&(t-=1,"="===e[n-2]&&(t-=1)),t}(e),n=e.length,i=new Uint8Array(t);let r=0;for(let t=0;t>4,r+=1,i[r]=(15&s)<<4|o>>2,r+=1,i[r]=(3&o)<<6|63&l,r+=1}return i}const Ch=16384,Eh=new ch,xh=new Map;function Sh(e,t){return ah(this,void 0,void 0,function*(){let n=null,i=null,r=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const s=()=>new DataView(n.exports.memory.buffer).getUint32(n.exports.STATE_SIZE,!0),o=Eh.dispatch(()=>ah(this,void 0,void 0,function*(){if(!xh.has(e.name)){const t=Ih(e.data),n=WebAssembly.compile(t);xh.set(e.name,n)}const t=yield xh.get(e.name);n=yield WebAssembly.instantiate(t,{})})),l=(e=null)=>{r=!0,n.exports.Hash_Init(e)},a=e=>{if(!r)throw new Error("update() called before init()");(e=>{let t=0;for(;t{if(!r)throw new Error("digest() called before init()");return r=!1,n.exports.Hash_Final(s),"binary"===e?i.slice(0,t):vh(c,i,t)},d=e=>"string"==typeof e?e.length<4096:e.byteLength!0;break;case"blake2b":case"blake2s":f=(e,t)=>t<=512&&d(e);break;case"blake3":f=(e,t)=>0===t&&d(e);break;case"xxhash64":case"xxhash3":case"xxhash128":case"crc64":f=()=>!1}return yield(()=>ah(this,void 0,void 0,function*(){n||(yield o);const e=n.exports.Hash_GetBuffer(),t=n.exports.memory.buffer;i=new Uint8Array(t,e,Ch)}))(),{getMemory:()=>i,writeMemory:(e,t=0)=>{i.set(e,t)},getExports:()=>n.exports,setMemorySize:e=>{n.exports.Hash_SetMemorySize(e);const t=n.exports.Hash_GetBuffer(),r=n.exports.memory.buffer;i=new Uint8Array(r,t,e)},init:l,update:a,digest:u,save:()=>{if(!r)throw new Error("save() can only be called after init() and before digest()");const t=n.exports.Hash_GetState(),i=s(),o=n.exports.memory.buffer,l=new Uint8Array(o,t,i),a=new Uint8Array(4+i);return gh(a,e.hash),a.set(l,4),a},load:t=>{if(!(t instanceof Uint8Array))throw new Error("load() expects an Uint8Array generated by save()");const i=n.exports.Hash_GetState(),o=s(),l=4+o,a=n.exports.memory.buffer;if(t.length!==l)throw new Error(`Bad state length (expected ${l} bytes, got ${t.length})`);if(!function(e,t){if(e.length!==2*t.length)return!1;for(let n=0;n{if(!f(e,r))return l(r),a(e),u("hex",s);const o=wh(e);return i.set(o),n.exports.Hash_Calculate(o.length,r,s),vh(c,i,t)},hashLength:t}})}new ch;var Bh={name:"argon2",data:"AGFzbQEAAAABKQVgAX8Bf2AAAX9gEH9/f39/f39/f39/f39/f38AYAR/f39/AGACf38AAwYFAAECAwQFBgEBAoCAAgYIAX8BQZCoBAsHQQQGbWVtb3J5AgASSGFzaF9TZXRNZW1vcnlTaXplAAAOSGFzaF9HZXRCdWZmZXIAAQ5IYXNoX0NhbGN1bGF0ZQAECvEyBVgBAn9BACEBAkAgAEEAKAKICCICRg0AAkAgACACayIAQRB2IABBgIB8cSAASWoiAEAAQX9HDQBB/wHADwtBACEBQQBBACkDiAggAEEQdK18NwOICAsgAcALcAECfwJAQQAoAoAIIgANAEEAPwBBEHQiADYCgAhBACgCiAgiAUGAgCBGDQACQEGAgCAgAWsiAEEQdiAAQYCAfHEgAElqIgBAAEF/Rw0AQQAPC0EAQQApA4gIIABBEHStfDcDiAhBACgCgAghAAsgAAvcDgECfiAAIAQpAwAiECAAKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAMIBAgDCkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgBCAQIAQpAwCFQiiJIhA3AwAgACAQIAApAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAwgECAMKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAEIBAgBCkDAIVCAYk3AwAgASAFKQMAIhAgASkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDSAQIA0pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAEgECABKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACANIBAgDSkDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAIgBikDACIQIAIpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIA4gECAOKQMAhUIgiSIQNwMAIAogECAKKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACACIBAgAikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDiAQIA4pAwCFQjCJIhA3AwAgCiAQIAopAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACADIAcpAwAiECADKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAPIBAgDykDAIVCIIkiEDcDACALIBAgCykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAyAQIAMpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA8gECAPKQMAhUIwiSIQNwMAIAsgECALKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgACAFKQMAIhAgACkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDyAQIA8pAwCFQiCJIhA3AwAgCiAQIAopAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAUgECAFKQMAhUIoiSIQNwMAIAAgECAAKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAPIBAgDykDAIVCMIkiEDcDACAKIBAgCikDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBSAQIAUpAwCFQgGJNwMAIAEgBikDACIQIAEpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAwgECAMKQMAhUIgiSIQNwMAIAsgECALKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACAGIBAgBikDAIVCKIkiEDcDACABIBAgASkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgDCAQIAwpAwCFQjCJIhA3AwAgCyAQIAspAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIAYgECAGKQMAhUIBiTcDACACIAcpAwAiECACKQMAIhF8IBFCAYZC/v///x+DIBBC/////w+DfnwiEDcDACANIBAgDSkDAIVCIIkiEDcDACAIIBAgCCkDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgByAQIAcpAwCFQiiJIhA3AwAgAiAQIAIpAwAiEXwgEEL/////D4MgEUIBhkL+////H4N+fCIQNwMAIA0gECANKQMAhUIwiSIQNwMAIAggECAIKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAHIBAgBykDAIVCAYk3AwAgAyAEKQMAIhAgAykDACIRfCARQgGGQv7///8fgyAQQv////8Pg358IhA3AwAgDiAQIA4pAwCFQiCJIhA3AwAgCSAQIAkpAwAiEXwgEUIBhkL+////H4MgEEL/////D4N+fCIQNwMAIAQgECAEKQMAhUIoiSIQNwMAIAMgECADKQMAIhF8IBBC/////w+DIBFCAYZC/v///x+DfnwiEDcDACAOIBAgDikDAIVCMIkiEDcDACAJIBAgCSkDACIRfCAQQv////8PgyARQgGGQv7///8fg358IhA3AwAgBCAQIAQpAwCFQgGJNwMAC98aAQN/QQAhBEEAIAIpAwAgASkDAIU3A5AIQQAgAikDCCABKQMIhTcDmAhBACACKQMQIAEpAxCFNwOgCEEAIAIpAxggASkDGIU3A6gIQQAgAikDICABKQMghTcDsAhBACACKQMoIAEpAyiFNwO4CEEAIAIpAzAgASkDMIU3A8AIQQAgAikDOCABKQM4hTcDyAhBACACKQNAIAEpA0CFNwPQCEEAIAIpA0ggASkDSIU3A9gIQQAgAikDUCABKQNQhTcD4AhBACACKQNYIAEpA1iFNwPoCEEAIAIpA2AgASkDYIU3A/AIQQAgAikDaCABKQNohTcD+AhBACACKQNwIAEpA3CFNwOACUEAIAIpA3ggASkDeIU3A4gJQQAgAikDgAEgASkDgAGFNwOQCUEAIAIpA4gBIAEpA4gBhTcDmAlBACACKQOQASABKQOQAYU3A6AJQQAgAikDmAEgASkDmAGFNwOoCUEAIAIpA6ABIAEpA6ABhTcDsAlBACACKQOoASABKQOoAYU3A7gJQQAgAikDsAEgASkDsAGFNwPACUEAIAIpA7gBIAEpA7gBhTcDyAlBACACKQPAASABKQPAAYU3A9AJQQAgAikDyAEgASkD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",hash:"e4cdc523"},Qh={name:"blake2b",data:"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",hash:"c6f286e6"};function Fh(e){return!Number.isInteger(e)||e<8||e>512||e%8!=0?new Error("Invalid variant! Valid values: 8, 16, ..., 512"):null}function $h(e=512,t=null){if(Fh(e))return Promise.reject(Fh(e));let n=null,i=e;if(null!==t){if(n=wh(t),n.length>64)return Promise.reject(new Error("Max key length is 64 bytes"));r=e,s=n.length,i=r|s<<16}var r,s;const o=e/8;return Sh(Qh,o).then(e=>{i>512&&e.writeMemory(n),e.init(i);const t={init:i>512?()=>(e.writeMemory(n),e.init(i),t):()=>(e.init(i),t),update:n=>(e.update(n),t),digest:t=>e.digest(t),save:()=>e.save(),load:n=>(e.load(n),t),blockSize:128,digestSize:o};return t})}new ch;const Dh=new DataView(new ArrayBuffer(4));function Rh(e){return Dh.setInt32(0,e,!0),new Uint8Array(Dh.buffer)}function Ph(e,t,n){return ah(this,void 0,void 0,function*(){if(n<=64){const e=yield $h(8*n);return e.update(Rh(n)),e.update(t),e.digest("binary")}const i=Math.ceil(n/32)-2,r=new Uint8Array(n);e.init(),e.update(Rh(n)),e.update(t);let s=e.digest("binary");r.set(s.subarray(0,32),0);for(let t=1;t{var t;if(!e||"object"!=typeof e)throw new Error("Invalid options parameter. It requires an object.");if(!e.password)throw new Error("Password must be specified");if(e.password=wh(e.password),e.password.length<1)throw new Error("Password must be specified");if(!e.salt)throw new Error("Salt must be specified");if(e.salt=wh(e.salt),e.salt.length<8)throw new Error("Salt should be at least 8 bytes long");if(e.secret=wh(null!==(t=e.secret)&&void 0!==t?t:""),!Number.isInteger(e.iterations)||e.iterations<1)throw new Error("Iterations should be a positive number");if(!Number.isInteger(e.parallelism)||e.parallelism<1)throw new Error("Parallelism should be a positive number");if(!Number.isInteger(e.hashLength)||e.hashLength<4)throw new Error("Hash length should be at least 4 bytes.");if(!Number.isInteger(e.memorySize))throw new Error("Memory size should be specified.");if(e.memorySize<8*e.parallelism)throw new Error("Memory size should be at least 8 * parallelism.");if(void 0===e.outputType&&(e.outputType="hex"),!["hex","binary","encoded"].includes(e.outputType))throw new Error(`Insupported output type ${e.outputType}. Valid values: ['hex', 'binary', 'encoded']`)})(e),Th(Object.assign(Object.assign({},e),{hashType:"id"}))})}new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch,new ch;const Nh={parallelism:4,iterations:8,memorySize:262144,hashLength:32,outputType:"binary"};let _h=null,Lh=0;const Mh=new Map;async function Oh(e,t){try{const n=function(){if(_h)return _h;const e=new Blob(["\n importScripts('https://cdn.jsdelivr.net/npm/hash-wasm@4.11.0/dist/argon2.umd.min.js');\n\n const ARGON2_CONFIG = {\n parallelism: 4,\n iterations: 8,\n memorySize: 262144,\n hashLength: 32,\n outputType: \"binary\"\n };\n\n self.onmessage = async function(e) {\n const { password, salt, id } = e.data;\n\n try {\n const result = await hashwasm.argon2id({\n password: password,\n salt: new Uint8Array(salt),\n ...ARGON2_CONFIG\n });\n\n self.postMessage({\n id,\n success: true,\n result: Array.from(result)\n });\n } catch (error) {\n self.postMessage({\n id,\n success: false,\n error: error.message\n });\n }\n };\n "],{type:"application/javascript"});return _h=new Worker(URL.createObjectURL(e)),_h.onmessage=function(e){const{id:t,success:n,result:i,error:r}=e.data,s=Mh.get(t);s&&(Mh.delete(t),n?s.resolve(new Uint8Array(i)):s.reject(new Error(r)))},_h.onerror=function(e){console.error("Argon2 worker error:",e)},_h}(),i=++Lh;return new Promise((r,s)=>{Mh.set(i,{resolve:r,reject:s}),n.postMessage({id:i,password:e,salt:Array.from(t)})})}catch(n){console.warn("Worker failed, falling back to main thread:",n);return await Uh({password:e,salt:t,...Nh})}}const{window:jh}=d;function Hh(e){let t,n,r,s,o,l,a,c,u,d,g,y,v,b,C,E,x,S;function B(e,t){return"extension"===e[2]?qh:Gh}let Q=B(e),$=Q(e),D=e[10]&&ig(e),R=e[11]&&rg(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("h2"),s.textContent="Login to Nostr",o=w(),l=m("button"),l.textContent="×",a=w(),c=m("div"),u=m("div"),d=m("button"),d.textContent="Extension",g=w(),y=m("button"),y.textContent="Nsec",v=w(),b=m("div"),$.c(),C=w(),D&&D.c(),E=w(),R&&R.c(),I(s,"class","svelte-4xpfbi"),I(l,"class","close-btn svelte-4xpfbi"),I(r,"class","modal-header svelte-4xpfbi"),I(d,"class","tab-btn svelte-4xpfbi"),F(d,"active","extension"===e[2]),I(y,"class","tab-btn svelte-4xpfbi"),F(y,"active","nsec"===e[2]),I(u,"class","tabs svelte-4xpfbi"),I(b,"class","tab-content svelte-4xpfbi"),I(c,"class","tab-container svelte-4xpfbi"),I(n,"class","modal svelte-4xpfbi"),F(n,"dark-theme",e[1]),I(t,"class","modal-overlay svelte-4xpfbi"),I(t,"role","button"),I(t,"tabindex","0")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),f(c,u),f(u,d),f(u,g),f(u,y),f(c,v),f(c,b),$.m(b,null),f(b,C),D&&D.m(b,null),f(b,E),R&&R.m(b,null),x||(S=[A(l,"click",e[17]),A(d,"click",e[26]),A(y,"click",e[27]),A(n,"click",k(e[24])),A(n,"keydown",k(e[25])),A(t,"click",e[17]),A(t,"keydown",e[32])],x=!0)},p(e,t){4&t[0]&&F(d,"active","extension"===e[2]),4&t[0]&&F(y,"active","nsec"===e[2]),Q===(Q=B(e))&&$?$.p(e,t):($.d(1),$=Q(e),$&&($.c(),$.m(b,C))),e[10]?D?D.p(e,t):(D=ig(e),D.c(),D.m(b,E)):D&&(D.d(1),D=null),e[11]?R?R.p(e,t):(R=rg(e),R.c(),R.m(b,null)):R&&(R.d(1),R=null),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&h(t),$.d(),D&&D.d(),R&&R.d(),x=!1,i(S)}}}function Gh(e){let t;function n(e,t){return e[14]?Kh:Jh}let i=n(e),r=i(e);return{c(){t=m("div"),r.c(),I(t,"class","nsec-login svelte-4xpfbi")},m(e,n){p(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&h(t),r.d()}}}function qh(e){let t,n,i,r,s,o,l,a=e[7]?"Connecting...":"Log in using extension";return{c(){t=m("div"),n=m("p"),n.textContent="Login using a NIP-07 compatible browser\n extension like nos2x or Alby.",i=w(),r=m("button"),s=v(a),I(n,"class","svelte-4xpfbi"),I(r,"class","login-extension-btn svelte-4xpfbi"),r.disabled=e[7],I(t,"class","extension-login svelte-4xpfbi")},m(a,c){p(a,t,c),f(t,n),f(t,i),f(t,r),f(r,s),o||(l=A(r,"click",e[21]),o=!0)},p(e,t){128&t[0]&&a!==(a=e[7]?"Connecting...":"Log in using extension")&&E(s,a),128&t[0]&&(r.disabled=e[7])},d(e){e&&h(t),o=!1,l()}}}function Jh(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,S,B,Q,F,$,D,R,P,T=e[8]?"Generating...":"Generate New Key",U=e[12]&&Vh(e),N=e[4]&&Yh(e);function _(e,t){return e[9]?Zh:e[7]?Wh:zh}let L=_(e),M=L(e);return{c(){t=m("p"),t.textContent="Enter your nsec or generate a new one. Optionally\n set a password to encrypt it securely.",n=w(),r=m("button"),s=v(T),l=w(),U&&U.c(),a=w(),c=m("input"),d=w(),g=m("div"),y=m("label"),y.textContent="Encryption Password (optional but recommended):",b=w(),k=m("input"),S=w(),N&&N.c(),B=w(),Q=m("small"),Q.textContent="Password uses Argon2id with ~3 second derivation time for security.",F=w(),$=m("button"),M.c(),I(t,"class","svelte-4xpfbi"),I(r,"class","generate-btn svelte-4xpfbi"),r.disabled=o=e[7]||e[8],I(c,"type","password"),I(c,"placeholder","nsec1..."),c.disabled=u=e[7]||e[9],I(c,"class","nsec-input svelte-4xpfbi"),I(y,"class","svelte-4xpfbi"),I(k,"type","password"),I(k,"placeholder","Enter password (min 8 chars)"),k.disabled=C=e[7]||e[9],I(k,"class","password-input svelte-4xpfbi"),I(Q,"class","password-hint svelte-4xpfbi"),I(g,"class","password-section svelte-4xpfbi"),I($,"class","login-nsec-btn svelte-4xpfbi"),$.disabled=D=e[7]||e[9]||!e[3].trim()},m(i,o){p(i,t,o),p(i,n,o),p(i,r,o),f(r,s),p(i,l,o),U&&U.m(i,o),p(i,a,o),p(i,c,o),x(c,e[3]),p(i,d,o),p(i,g,o),f(g,y),f(g,b),f(g,k),x(k,e[4]),f(g,S),N&&N.m(g,null),f(g,B),f(g,Q),p(i,F,o),p(i,$,o),M.m($,null),R||(P=[A(r,"click",e[20]),A(c,"input",e[29]),A(k,"input",e[30]),A($,"click",e[22])],R=!0)},p(e,t){256&t[0]&&T!==(T=e[8]?"Generating...":"Generate New Key")&&E(s,T),384&t[0]&&o!==(o=e[7]||e[8])&&(r.disabled=o),e[12]?U?U.p(e,t):(U=Vh(e),U.c(),U.m(a.parentNode,a)):U&&(U.d(1),U=null),640&t[0]&&u!==(u=e[7]||e[9])&&(c.disabled=u),8&t[0]&&c.value!==e[3]&&x(c,e[3]),640&t[0]&&C!==(C=e[7]||e[9])&&(k.disabled=C),16&t[0]&&k.value!==e[4]&&x(k,e[4]),e[4]?N?N.p(e,t):(N=Yh(e),N.c(),N.m(g,B)):N&&(N.d(1),N=null),L!==(L=_(e))&&(M.d(1),M=L(e),M&&(M.c(),M.m($,null))),648&t[0]&&D!==(D=e[7]||e[9]||!e[3].trim())&&($.disabled=D)},d(e){e&&h(t),e&&h(n),e&&h(r),e&&h(l),U&&U.d(e),e&&h(a),e&&h(c),e&&h(d),e&&h(g),N&&N.d(),e&&h(F),e&&h($),M.d(),R=!1,i(P)}}}function Kh(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C=e[15]&&Xh(e);function E(e,t){return e[9]?ng:e[7]?tg:eg}let S=E(e),B=S(e);return{c(){t=m("p"),t.textContent="You have a stored encrypted key. Enter your\n password to unlock it.",n=w(),C&&C.c(),r=w(),s=m("input"),l=w(),a=m("button"),B.c(),u=w(),d=m("button"),g=v("Clear stored key & start fresh"),I(t,"class","svelte-4xpfbi"),I(s,"type","password"),I(s,"placeholder","Enter your password"),s.disabled=o=e[7]||e[9],I(s,"class","password-input svelte-4xpfbi"),I(a,"class","login-nsec-btn svelte-4xpfbi"),a.disabled=c=e[7]||e[9]||!e[6],I(d,"class","clear-btn svelte-4xpfbi"),d.disabled=y=e[7]||e[9]},m(i,o){p(i,t,o),p(i,n,o),C&&C.m(i,o),p(i,r,o),p(i,s,o),x(s,e[6]),p(i,l,o),p(i,a,o),B.m(a,null),p(i,u,o),p(i,d,o),f(d,g),b||(k=[A(s,"input",e[28]),A(a,"click",e[18]),A(d,"click",e[16])],b=!0)},p(e,t){e[15]?C?C.p(e,t):(C=Xh(e),C.c(),C.m(r.parentNode,r)):C&&(C.d(1),C=null),640&t[0]&&o!==(o=e[7]||e[9])&&(s.disabled=o),64&t[0]&&s.value!==e[6]&&x(s,e[6]),S!==(S=E(e))&&(B.d(1),B=S(e),B&&(B.c(),B.m(a,null))),704&t[0]&&c!==(c=e[7]||e[9]||!e[6])&&(a.disabled=c),640&t[0]&&y!==(y=e[7]||e[9])&&(d.disabled=y)},d(e){e&&h(t),e&&h(n),C&&C.d(e),e&&h(r),e&&h(s),e&&h(l),e&&h(a),B.d(),e&&h(u),e&&h(d),b=!1,i(k)}}}function Vh(e){let t,n,i,r,s;return{c(){t=m("div"),n=m("label"),n.textContent="Your new public key (npub):",i=w(),r=m("code"),s=v(e[12]),I(n,"class","svelte-4xpfbi"),I(r,"class","npub-display svelte-4xpfbi"),I(t,"class","generated-info svelte-4xpfbi")},m(e,o){p(e,t,o),f(t,n),f(t,i),f(t,r),f(r,s)},p(e,t){4096&t[0]&&E(s,e[12])},d(e){e&&h(t)}}}function Yh(e){let t,n,i,r;return{c(){t=m("input"),I(t,"type","password"),I(t,"placeholder","Confirm password"),t.disabled=n=e[7]||e[9],I(t,"class","password-input svelte-4xpfbi")},m(n,s){p(n,t,s),x(t,e[5]),i||(r=A(t,"input",e[31]),i=!0)},p(e,i){640&i[0]&&n!==(n=e[7]||e[9])&&(t.disabled=n),32&i[0]&&t.value!==e[5]&&x(t,e[5])},d(e){e&&h(t),i=!1,r()}}}function zh(e){let t;return{c(){t=v("Log in with nsec")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Wh(e){let t;return{c(){t=v("Logging in...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Zh(e){let t;return{c(){t=v("Deriving key...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Xh(e){let t,n,i,r,s,o,l,a=e[15].slice(0,16)+"",c=e[15].slice(-8)+"";return{c(){t=m("div"),n=m("label"),n.textContent="Stored public key:",i=w(),r=m("code"),s=v(a),o=v("..."),l=v(c),I(n,"class","svelte-4xpfbi"),I(r,"class","npub-display svelte-4xpfbi"),I(t,"class","stored-info svelte-4xpfbi")},m(e,a){p(e,t,a),f(t,n),f(t,i),f(t,r),f(r,s),f(r,o),f(r,l)},p(e,t){32768&t[0]&&a!==(a=e[15].slice(0,16)+"")&&E(s,a),32768&t[0]&&c!==(c=e[15].slice(-8)+"")&&E(l,c)},d(e){e&&h(t)}}}function eg(e){let t;return{c(){t=v("Unlock")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function tg(e){let t;return{c(){t=v("Unlocking...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function ng(e){let t;return{c(){t=v("Deriving key...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function ig(e){let t,n;return{c(){t=m("div"),n=v(e[10]),I(t,"class","message error-message svelte-4xpfbi")},m(e,i){p(e,t,i),f(t,n)},p(e,t){1024&t[0]&&E(n,e[10])},d(e){e&&h(t)}}}function rg(e){let t,n;return{c(){t=m("div"),n=v(e[11]),I(t,"class","message success-message svelte-4xpfbi")},m(e,i){p(e,t,i),f(t,n)},p(e,t){2048&t[0]&&E(n,e[11])},d(e){e&&h(t)}}}function sg(e){let t,n,i,r,s,o,l,a,c,u,d,g=e[13].toFixed(1)+"";return{c(){t=m("div"),n=m("div"),i=m("div"),r=w(),s=m("h3"),s.textContent="Deriving encryption key",o=w(),l=m("div"),a=v(g),c=v("s"),u=w(),d=m("p"),d.textContent="This may take 3-6 seconds for security",I(i,"class","deriving-spinner svelte-4xpfbi"),I(s,"class","svelte-4xpfbi"),I(l,"class","deriving-timer svelte-4xpfbi"),I(d,"class","deriving-note svelte-4xpfbi"),I(n,"class","deriving-modal svelte-4xpfbi"),F(n,"dark-theme",e[1]),I(t,"class","deriving-overlay svelte-4xpfbi")},m(e,h){p(e,t,h),f(t,n),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),f(l,a),f(l,c),f(n,u),f(n,d)},p(e,t){8192&t[0]&&g!==(g=e[13].toFixed(1)+"")&&E(a,g),2&t[0]&&F(n,"dark-theme",e[1])},d(e){e&&h(t)}}}function og(t){let n,i,r,s,o=t[0]&&Hh(t),l=t[9]&&sg(t);return{c(){o&&o.c(),n=w(),l&&l.c(),i=b()},m(e,a){o&&o.m(e,a),p(e,n,a),l&&l.m(e,a),p(e,i,a),r||(s=A(jh,"keydown",t[23]),r=!0)},p(e,t){e[0]?o?o.p(e,t):(o=Hh(e),o.c(),o.m(n.parentNode,n)):o&&(o.d(1),o=null),e[9]?l?l.p(e,t):(l=sg(e),l.c(),l.m(i.parentNode,i)):l&&(l.d(1),l=null)},i:e,o:e,d(e){o&&o.d(e),e&&h(n),l&&l.d(e),e&&h(i),r=!1,s()}}}function lg(e,t,n){const i=U();let{showModal:r=!1}=t,{isDarkTheme:s=!1}=t,o="extension",l="",a="",c="",u="",d=!1,f=!1,p=!1,h="",g="",m="",y="",v=0,w=null,b=null;function A(){n(13,v=0),w=performance.now(),k()}function k(){null!==w&&(n(13,v=(performance.now()-w)/1e3),b=requestAnimationFrame(k))}function I(){w=null,b&&(cancelAnimationFrame(b),b=null)}T(()=>{I()});let C=!1,E="";function x(){n(14,C=!!localStorage.getItem("nostr_privkey_encrypted")),n(15,E=localStorage.getItem("nostr_pubkey")||"")}function S(){n(0,r=!1),n(3,l=""),n(4,a=""),n(5,c=""),n(6,u=""),n(10,h=""),n(11,g=""),m="",n(12,y=""),i("close")}function B(e){n(2,o=e),n(10,h=""),n(11,g=""),m="",n(12,y="")}async function Q(){n(7,d=!0),n(10,h=""),n(11,g="");try{if(!l.trim())throw new Error("Please enter your nsec");if(!function(e){if(!e||!e.startsWith("nsec1"))return!1;try{return"nsec"===bu(e).type}catch{return!1}}(l.trim()))throw new Error("Invalid nsec format or checksum");if(a){if(a.length<8)throw new Error("Password must be at least 8 characters");if(a!==c)throw new Error("Passwords do not match")}const e=gf.fromKey(l.trim()),t=await e.getPublicKey();if(localStorage.setItem("nostr_auth_method","nsec"),localStorage.setItem("nostr_pubkey",t),a){n(9,p=!0),A();const e=await async function(e,t){if(!e.startsWith("nsec1"))throw new Error("Invalid nsec format - must start with nsec1");try{if("nsec"!==bu(e).type)throw new Error("Invalid nsec - wrong type")}catch(e){throw new Error("Invalid nsec - bech32 checksum failed")}const n=crypto.getRandomValues(new Uint8Array(32)),i=crypto.getRandomValues(new Uint8Array(12)),r=await Oh(t,n),s=await crypto.subtle.importKey("raw",r,{name:"AES-GCM"},!1,["encrypt"]),o=new TextEncoder,l=await crypto.subtle.encrypt({name:"AES-GCM",iv:i},s,o.encode(e)),a=new Uint8Array(n.length+i.length+l.byteLength);return a.set(n,0),a.set(i,n.length),a.set(new Uint8Array(l),n.length+i.length),btoa(String.fromCharCode(...a))}(l.trim(),a);I(),n(9,p=!1),localStorage.setItem("nostr_privkey_encrypted",e),localStorage.removeItem("nostr_privkey")}else localStorage.setItem("nostr_privkey",l.trim()),localStorage.removeItem("nostr_privkey_encrypted"),n(11,g="Successfully logged in with nsec!");i("login",{method:"nsec",pubkey:t,privateKey:l.trim(),signer:e}),setTimeout(()=>{S()},1500)}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}}P(()=>{x()});return e.$$set=e=>{"showModal"in e&&n(0,r=e.showModal),"isDarkTheme"in e&&n(1,s=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty[0]&&r&&x()},[r,s,o,l,a,c,u,d,f,p,h,g,y,v,C,E,function(){localStorage.removeItem("nostr_privkey_encrypted"),localStorage.removeItem("nostr_privkey"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_auth_method"),n(14,C=!1),n(15,E=""),n(6,u=""),n(10,h=""),n(11,g="")},S,async function(){n(7,d=!0),n(9,p=!0),A(),n(10,h=""),n(11,g="");try{if(!u)throw new Error("Please enter your password");const e=localStorage.getItem("nostr_privkey_encrypted");if(!e)throw new Error("No encrypted key found");const t=await async function(e,t){const n=new Uint8Array(atob(e).split("").map(e=>e.charCodeAt(0)));if(n.length<60)throw new Error("Invalid encrypted data - too short");const i=n.slice(0,32),r=n.slice(32,44),s=n.slice(44),o=await Oh(t,i),l=await crypto.subtle.importKey("raw",o,{name:"AES-GCM"},!1,["decrypt"]);let a;try{a=await crypto.subtle.decrypt({name:"AES-GCM",iv:r},l,s)}catch(e){throw new Error("Decryption failed - invalid password or corrupted data")}const c=(new TextDecoder).decode(a);if(!c.startsWith("nsec1"))throw new Error("Decryption produced invalid data - not an nsec");try{if("nsec"!==bu(c).type)throw new Error("Decryption produced invalid nsec type")}catch(e){throw new Error("Decryption produced invalid nsec - bech32 checksum failed")}return c}(e,u);I(),n(9,p=!1);const r=gf.fromKey(t),s=await r.getPublicKey();i("login",{method:"nsec",pubkey:s,privateKey:t,signer:r}),S()}catch(e){I(),e.message.includes("decrypt")||e.message.includes("tag")?n(10,h="Invalid password"):n(10,h=e.message)}finally{n(7,d=!1),n(9,p=!1),I()}},B,async function(){n(8,f=!0),n(10,h=""),n(11,g="");try{const e=tu(),t=Iu("nsec",e),i=ku(nu(e));m=t,n(12,y=i),n(3,l=t),n(11,g="New key generated! Set an encryption password below to secure it.")}catch(e){n(10,h="Failed to generate key: "+e.message)}finally{n(8,f=!1)}},async function(){n(7,d=!0),n(10,h=""),n(11,g="");try{if(!window.nostr)throw new Error("No Nostr extension found. Please install a NIP-07 compatible extension like nos2x or Alby.");const e=await window.nostr.getPublicKey();e&&(localStorage.setItem("nostr_auth_method","extension"),localStorage.setItem("nostr_pubkey",e),n(11,g="Successfully logged in with extension!"),i("login",{method:"extension",pubkey:e,signer:window.nostr}),setTimeout(()=>{S()},1500))}catch(e){n(10,h=e.message)}finally{n(7,d=!1)}},Q,function(e){"Escape"===e.key&&S(),"Enter"===e.key&&"nsec"===o&&Q()},function(t){N.call(this,e,t)},function(t){N.call(this,e,t)},()=>B("extension"),()=>B("nsec"),function(){u=this.value,n(6,u)},function(){l=this.value,n(3,l)},function(){a=this.value,n(4,a)},function(){c=this.value,n(5,c)},e=>"Escape"===e.key&&S()]}class ag extends ae{constructor(e){super(),le(this,e,lg,og,s,{showModal:0,isDarkTheme:1},null,[-1,-1])}}function cg(e,t,n){const i=e.slice();return i[72]=t[n],i}function ug(e,t,n){const i=e.slice();return i[75]=t[n],i}function dg(e,t,n){const i=e.slice();return i[72]=t[n],i}function fg(e,t,n){const i=e.slice();return i[72]=t[n],i}function pg(e,t,n){const i=e.slice();return i[72]=t[n],i}function hg(e,t,n){const i=e.slice();return i[72]=t[n],i}function gg(e,t,n){const i=e.slice();return i[72]=t[n],i}function mg(e){let t,n,i;return{c(){t=m("div"),n=v(e[3]),I(t,"class",i="message "+e[4]+" svelte-1y8wjwc")},m(e,i){p(e,t,i),f(t,n)},p(e,r){8&r[0]&&E(n,e[3]),16&r[0]&&i!==(i="message "+e[4]+" svelte-1y8wjwc")&&I(t,"class",i)},d(e){e&&h(t)}}}function yg(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,E,S,B,Q,F,$,D,R,P,T,U,N,_;function L(e,t){return e[5]&&e[5].length>0?wg:vg}let M=L(e),O=M(e);function j(e,t){return e[8]&&e[8].length>0?Ig:kg}let H=j(e),G=H(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Banned Pubkeys",s=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=v("Ban Pubkey"),y=w(),b=m("div"),O.c(),k=w(),C=m("div"),E=m("h3"),E.textContent="Allowed Pubkeys",S=w(),B=m("div"),Q=m("input"),F=w(),$=m("input"),D=w(),R=m("button"),P=v("Allow Pubkey"),T=w(),U=m("div"),G.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","Pubkey (64 hex chars)"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(E,"class","svelte-1y8wjwc"),I(Q,"type","text"),I(Q,"placeholder","Pubkey (64 hex chars)"),I(Q,"class","svelte-1y8wjwc"),I($,"type","text"),I($,"placeholder","Reason (optional)"),I($,"class","svelte-1y8wjwc"),R.disabled=e[2],I(R,"class","svelte-1y8wjwc"),I(B,"class","add-form svelte-1y8wjwc"),I(U,"class","list svelte-1y8wjwc"),I(C,"class","section svelte-1y8wjwc"),I(t,"class","pubkeys-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[6]),f(o,a),f(o,c),x(c,e[7]),f(o,u),f(o,d),f(d,g),f(n,y),f(n,b),O.m(b,null),f(t,k),f(t,C),f(C,E),f(C,S),f(C,B),f(B,Q),x(Q,e[9]),f(B,F),f(B,$),x($,e[10]),f(B,D),f(B,R),f(R,P),f(C,T),f(C,U),G.m(U,null),N||(_=[A(l,"input",e[43]),A(c,"input",e[44]),A(d,"click",e[25]),A(Q,"input",e[45]),A($,"input",e[46]),A(R,"click",e[26])],N=!0)},p(e,t){64&t[0]&&l.value!==e[6]&&x(l,e[6]),128&t[0]&&c.value!==e[7]&&x(c,e[7]),4&t[0]&&(d.disabled=e[2]),M===(M=L(e))&&O?O.p(e,t):(O.d(1),O=M(e),O&&(O.c(),O.m(b,null))),512&t[0]&&Q.value!==e[9]&&x(Q,e[9]),1024&t[0]&&$.value!==e[10]&&x($,e[10]),4&t[0]&&(R.disabled=e[2]),H===(H=j(e))&&G?G.p(e,t):(G.d(1),G=H(e),G&&(G.c(),G.m(U,null)))},d(e){e&&h(t),O.d(),G.d(),N=!1,i(_)}}}function vg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No banned pubkeys configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function wg(e){let t,n=e[5],i=[];for(let t=0;tNo allowed pubkeys configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Ig(e){let t,n=e[8],i=[];for(let t=0;t0?Bg:Sg}let M=L(e),O=M(e);let j=function(e){return e[22]&&e[22].length>0?Dg:$g}(e),H=j(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Banned Events",s=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=v("Ban Event"),y=w(),b=m("div"),O.c(),k=w(),C=m("div"),E=m("h3"),E.textContent="Allowed Events",S=w(),B=m("div"),Q=m("input"),F=w(),$=m("input"),D=w(),R=m("button"),P=v("Allow Event"),T=w(),U=m("div"),H.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","Event ID (64 hex chars)"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(E,"class","svelte-1y8wjwc"),I(Q,"type","text"),I(Q,"placeholder","Event ID (64 hex chars)"),I(Q,"class","svelte-1y8wjwc"),I($,"type","text"),I($,"placeholder","Reason (optional)"),I($,"class","svelte-1y8wjwc"),R.disabled=e[2],I(R,"class","svelte-1y8wjwc"),I(B,"class","add-form svelte-1y8wjwc"),I(U,"class","list svelte-1y8wjwc"),I(C,"class","section svelte-1y8wjwc"),I(t,"class","events-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[12]),f(o,a),f(o,c),x(c,e[13]),f(o,u),f(o,d),f(d,g),f(n,y),f(n,b),O.m(b,null),f(t,k),f(t,C),f(C,E),f(C,S),f(C,B),f(B,Q),x(Q,e[14]),f(B,F),f(B,$),x($,e[15]),f(B,D),f(B,R),f(R,P),f(C,T),f(C,U),H.m(U,null),N||(_=[A(l,"input",e[47]),A(c,"input",e[48]),A(d,"click",e[27]),A(Q,"input",e[49]),A($,"input",e[50]),A(R,"click",e[28])],N=!0)},p(e,t){4096&t[0]&&l.value!==e[12]&&x(l,e[12]),8192&t[0]&&c.value!==e[13]&&x(c,e[13]),4&t[0]&&(d.disabled=e[2]),M===(M=L(e))&&O?O.p(e,t):(O.d(1),O=M(e),O&&(O.c(),O.m(b,null))),16384&t[0]&&Q.value!==e[14]&&x(Q,e[14]),32768&t[0]&&$.value!==e[15]&&x($,e[15]),4&t[0]&&(R.disabled=e[2]),H.p(e,t)},d(e){e&&h(t),O.d(),H.d(),N=!1,i(_)}}}function Sg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No banned events configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Bg(e){let t,n=e[11],i=[];for(let t=0;tNo allowed events configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Dg(e){let t,n=e[22],i=[];for(let t=0;t0?Ug:Tg}let S=E(e),B=S(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Blocked IPs",s=w(),o=m("div"),l=m("input"),a=w(),c=m("input"),u=w(),d=m("button"),g=v("Block IP"),y=w(),b=m("div"),B.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","text"),I(l,"placeholder","IP Address"),I(l,"class","svelte-1y8wjwc"),I(c,"type","text"),I(c,"placeholder","Reason (optional)"),I(c,"class","svelte-1y8wjwc"),d.disabled=e[2],I(d,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(b,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","ips-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[17]),f(o,a),f(o,c),x(c,e[18]),f(o,u),f(o,d),f(d,g),f(n,y),f(n,b),B.m(b,null),k||(C=[A(l,"input",e[51]),A(c,"input",e[52]),A(d,"click",e[29])],k=!0)},p(e,t){131072&t[0]&&l.value!==e[17]&&x(l,e[17]),262144&t[0]&&c.value!==e[18]&&x(c,e[18]),4&t[0]&&(d.disabled=e[2]),S===(S=E(e))&&B?B.p(e,t):(B.d(1),B=S(e),B&&(B.c(),B.m(b,null)))},d(e){e&&h(t),B.d(),k=!1,i(C)}}}function Tg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No blocked IPs configured.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Ug(e){let t,n=e[16],i=[];for(let t=0;t0?Og:Mg}let E=k(e),S=E(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Allowed Event Kinds",s=w(),o=m("div"),l=m("input"),a=w(),c=m("button"),u=v("Allow Kind"),d=w(),g=m("div"),S.c(),I(r,"class","svelte-1y8wjwc"),I(l,"type","number"),I(l,"placeholder","Kind number"),I(l,"class","svelte-1y8wjwc"),c.disabled=e[2],I(c,"class","svelte-1y8wjwc"),I(o,"class","add-form svelte-1y8wjwc"),I(g,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","kinds-section")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),x(l,e[20]),f(o,a),f(o,c),f(c,u),f(n,d),f(n,g),S.m(g,null),y||(b=[A(l,"input",e[53]),A(c,"click",e[30])],y=!0)},p(e,t){1048576&t[0]&&C(l.value)!==e[20]&&x(l,e[20]),4&t[0]&&(c.disabled=e[2]),E===(E=k(e))&&S?S.p(e,t):(S.d(1),S=E(e),S&&(S.c(),S.m(g,null)))},d(e){e&&h(t),S.d(),y=!1,i(b)}}}function Mg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No allowed kinds configured. All kinds are\n allowed by default.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Og(e){let t,n=e[19],i=[];for(let t=0;t0?qg:Gg}let g=d(e),y=g(e);return{c(){t=m("div"),n=m("div"),i=m("h3"),i.textContent="Events Needing Moderation",r=w(),s=m("button"),o=v("Refresh"),l=w(),a=m("div"),y.c(),I(i,"class","svelte-1y8wjwc"),s.disabled=e[2],I(a,"class","list svelte-1y8wjwc"),I(n,"class","section svelte-1y8wjwc"),I(t,"class","moderation-section")},m(d,h){p(d,t,h),f(t,n),f(n,i),f(n,r),f(n,s),f(s,o),f(n,l),f(n,a),y.m(a,null),c||(u=A(s,"click",e[24]),c=!0)},p(e,t){4&t[0]&&(s.disabled=e[2]),g===(g=d(e))&&y?y.p(e,t):(y.d(1),y=g(e),y&&(y.c(),y.m(a,null)))},d(e){e&&h(t),y.d(),c=!1,u()}}}function Gg(t){let n;return{c(){n=m("div"),n.innerHTML="

    No events need moderation at this time.

    ",I(n,"class","no-items svelte-1y8wjwc")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function qg(e){let t,n=e[21],i=[];for(let t=0;tManaged ACL Configuration \n

    Configure access control using NIP-86 management API

    \n
    Owner Only: This interface is restricted to relay owners\n only.
    ',s=w(),V&&V.c(),o=w(),l=m("div"),a=m("button"),c=v("Pubkeys"),d=w(),g=m("button"),y=v("Events"),k=w(),C=m("button"),E=v("IPs"),S=w(),B=m("button"),Q=v("Kinds"),$=w(),D=m("button"),R=v("Moderation"),T=w(),U=m("button"),N=v("Relay Config"),L=w(),M=m("div"),Y&&Y.c(),O=w(),z&&z.c(),j=w(),W&&W.c(),H=w(),Z&&Z.c(),G=w(),X&&X.c(),q=w(),ee&&ee.c(),I(r,"class","header svelte-1y8wjwc"),I(a,"class",u="tab "+("pubkeys"===t[1]?"active":"")+" svelte-1y8wjwc"),I(g,"class",b="tab "+("events"===t[1]?"active":"")+" svelte-1y8wjwc"),I(C,"class",x="tab "+("ips"===t[1]?"active":"")+" svelte-1y8wjwc"),I(B,"class",F="tab "+("kinds"===t[1]?"active":"")+" svelte-1y8wjwc"),I(D,"class",P="tab "+("moderation"===t[1]?"active":"")+" svelte-1y8wjwc"),I(U,"class",_="tab "+("relay"===t[1]?"active":"")+" svelte-1y8wjwc"),I(l,"class","tabs svelte-1y8wjwc"),I(M,"class","tab-content svelte-1y8wjwc")},m(e,i){p(e,n,i),f(n,r),f(n,s),V&&V.m(n,null),f(n,o),f(n,l),f(l,a),f(a,c),f(l,d),f(l,g),f(g,y),f(l,k),f(l,C),f(C,E),f(l,S),f(l,B),f(B,Q),f(l,$),f(l,D),f(D,R),f(l,T),f(l,U),f(U,N),f(n,L),f(n,M),Y&&Y.m(M,null),f(M,O),z&&z.m(M,null),f(M,j),W&&W.m(M,null),f(M,H),Z&&Z.m(M,null),f(M,G),X&&X.m(M,null),f(M,q),ee&&ee.m(M,null),J||(K=[A(a,"click",t[37]),A(g,"click",t[38]),A(C,"click",t[39]),A(B,"click",t[40]),A(D,"click",t[41]),A(U,"click",t[42])],J=!0)},p(e,t){e[3]?V?V.p(e,t):(V=mg(e),V.c(),V.m(n,o)):V&&(V.d(1),V=null),2&t[0]&&u!==(u="tab "+("pubkeys"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(a,"class",u),2&t[0]&&b!==(b="tab "+("events"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(g,"class",b),2&t[0]&&x!==(x="tab "+("ips"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(C,"class",x),2&t[0]&&F!==(F="tab "+("kinds"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(B,"class",F),2&t[0]&&P!==(P="tab "+("moderation"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(D,"class",P),2&t[0]&&_!==(_="tab "+("relay"===e[1]?"active":"")+" svelte-1y8wjwc")&&I(U,"class",_),"pubkeys"===e[1]?Y?Y.p(e,t):(Y=yg(e),Y.c(),Y.m(M,O)):Y&&(Y.d(1),Y=null),"events"===e[1]?z?z.p(e,t):(z=xg(e),z.c(),z.m(M,j)):z&&(z.d(1),z=null),"ips"===e[1]?W?W.p(e,t):(W=Pg(e),W.c(),W.m(M,H)):W&&(W.d(1),W=null),"kinds"===e[1]?Z?Z.p(e,t):(Z=Lg(e),Z.c(),Z.m(M,G)):Z&&(Z.d(1),Z=null),"moderation"===e[1]?X?X.p(e,t):(X=Hg(e),X.c(),X.m(M,q)):X&&(X.d(1),X=null),"relay"===e[1]?ee?ee.p(e,t):(ee=Vg(e),ee.c(),ee.m(M,null)):ee&&(ee.d(1),ee=null)},i:e,o:e,d(e){e&&h(n),V&&V.d(),Y&&Y.d(),z&&z.d(),W&&W.d(),Z&&Z.d(),X&&X.d(),ee&&ee.d(),J=!1,i(K)}}}function Zg(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="pubkeys",o=!1,l="",a="info",c=[],u="",d="",f=[],p="",h="",g=[],m="",y="",v="",w="",b=[],A="",k="",I=[],E="",x=[],S={relay_name:"",relay_description:"",relay_icon:""};async function B(){try{n(2,o=!0),console.log("Fetching relay info from /");const e=await fetch(xp()+"/",{headers:{Accept:"application/nostr+json"}});if(console.log("Response status:",e.status),console.log("Response headers:",e.headers),e.ok){const t=await e.json();console.log("Raw relay info:",t),n(0,S={relay_name:t.name||"",relay_description:t.description||"",relay_icon:t.icon||""}),console.log("Updated relayConfig:",S),console.log("Loaded relay info:",t),n(3,l="Relay configuration loaded successfully"),n(4,a="success")}else console.error("Failed to fetch relay info, status:",e.status),n(3,l=`Failed to fetch relay info: ${e.status}`),n(4,a="error")}catch(e){console.error("Failed to fetch relay info:",e),n(3,l=`Failed to fetch relay info: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}}async function Q(e,t=[]){try{n(2,o=!0),n(3,l="");const s={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available for authentication. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available for authentication.");const n=xp()+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s),l=JSON.stringify(o);return`Nostr ${btoa(l)}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(s)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(3,l=e.message),n(4,a="error"),e}finally{n(2,o=!1)}}async function F(){try{n(5,c=await Q("listbannedpubkeys"))}catch(e){console.error("Failed to load banned pubkeys:",e)}}async function $(){try{n(8,f=await Q("listallowedpubkeys"))}catch(e){console.error("Failed to load allowed pubkeys:",e)}}async function D(){try{n(11,g=await Q("listbannedevents"))}catch(e){console.error("Failed to load banned events:",e)}}async function R(){try{n(16,b=await Q("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e)}}async function T(){try{n(19,I=await Q("listallowedkinds"))}catch(e){console.error("Failed to load allowed kinds:",e)}}async function U(){try{n(2,o=!0),n(21,x=await Q("listeventsneedingmoderation")),console.log("Loaded events needing moderation:",x)}catch(e){console.error("Failed to load events needing moderation:",e),n(3,l=`Failed to load moderation events: ${e.message}`),n(4,a="error"),n(21,x=[])}finally{n(2,o=!1)}}async function N(e){try{await Q("disallowkind",[e]),n(3,l="Kind disallowed successfully"),n(4,a="success"),await T()}catch(e){console.error("Failed to disallow kind:",e)}}async function _(e){try{await Q("allowevent",[e,"Approved from moderation queue"]),n(3,l="Event allowed successfully"),n(4,a="success"),await U()}catch(e){console.error("Failed to allow event from moderation:",e)}}async function L(e){try{await Q("banevent",[e,"Banned from moderation queue"]),n(3,l="Event banned successfully"),n(4,a="success"),await U()}catch(e){console.error("Failed to ban event from moderation:",e)}}P(()=>{setTimeout(()=>{B()},100)}),async function(){await Promise.all([F(),$(),D(),R(),T()])}();return e.$$set=e=>{"userSigner"in e&&n(35,i=e.userSigner),"userPubkey"in e&&n(36,r=e.userPubkey)},e.$$.update=()=>{1&e.$$.dirty[0]&&console.log("relayConfig changed:",S)},[S,s,o,l,a,c,u,d,f,p,h,g,m,y,v,w,b,A,k,I,E,x,[],B,U,async function(){if(u)try{await Q("banpubkey",[u,d]),n(3,l="Pubkey banned successfully"),n(4,a="success"),n(6,u=""),n(7,d=""),await F()}catch(e){console.error("Failed to ban pubkey:",e)}},async function(){if(p)try{await Q("allowpubkey",[p,h]),n(3,l="Pubkey allowed successfully"),n(4,a="success"),n(9,p=""),n(10,h=""),await $()}catch(e){console.error("Failed to allow pubkey:",e)}},async function(){if(m)try{await Q("banevent",[m,y]),n(3,l="Event banned successfully"),n(4,a="success"),n(12,m=""),n(13,y=""),await D()}catch(e){console.error("Failed to ban event:",e)}},async function(){if(v)try{await Q("allowevent",[v,w]),n(3,l="Event allowed successfully"),n(4,a="success"),n(14,v=""),n(15,w="")}catch(e){console.error("Failed to allow event:",e)}},async function(){if(A)try{await Q("blockip",[A,k]),n(3,l="IP blocked successfully"),n(4,a="success"),n(17,A=""),n(18,k=""),await R()}catch(e){console.error("Failed to block IP:",e)}},async function(){if(!E)return;const e=parseInt(E);if(isNaN(e))return n(3,l="Invalid kind number"),void n(4,a="error");try{await Q("allowkind",[e]),n(3,l="Kind allowed successfully"),n(4,a="success"),n(20,E=""),await T()}catch(e){console.error("Failed to allow kind:",e)}},N,async function(){try{n(2,o=!0),n(3,l="");const e=[];if(S.relay_name&&e.push(Q("changerelayname",[S.relay_name])),S.relay_description&&e.push(Q("changerelaydescription",[S.relay_description])),S.relay_icon&&e.push(Q("changerelayicon",[S.relay_icon])),0===e.length)return n(3,l="No changes to update"),void n(4,a="info");await Promise.all(e),n(3,l="Relay configuration updated successfully"),n(4,a="success"),await B()}catch(e){console.error("Failed to update relay configuration:",e),n(3,l=`Failed to update relay configuration: ${e.message}`),n(4,a="error")}finally{n(2,o=!1)}},_,L,i,r,()=>n(1,s="pubkeys"),()=>n(1,s="events"),()=>n(1,s="ips"),()=>n(1,s="kinds"),()=>{n(1,s="moderation"),x&&0!==x.length||U()},()=>n(1,s="relay"),function(){u=this.value,n(6,u)},function(){d=this.value,n(7,d)},function(){p=this.value,n(9,p)},function(){h=this.value,n(10,h)},function(){m=this.value,n(12,m)},function(){y=this.value,n(13,y)},function(){v=this.value,n(14,v)},function(){w=this.value,n(15,w)},function(){A=this.value,n(17,A)},function(){k=this.value,n(18,k)},function(){E=C(this.value),n(20,E)},e=>N(e),e=>_(e.id),e=>L(e.id),function(){S.relay_name=this.value,n(0,S)},function(){S.relay_description=this.value,n(0,S)},function(){S.relay_icon=this.value,n(0,S)}]}class Xg extends ae{constructor(e){super(),le(this,e,Zg,Wg,s,{userSigner:35,userPubkey:36},null,[-1,-1,-1])}}function em(e,t,n){const i=e.slice();return i[28]=t[n],i}function tm(e){let t,n;return{c(){t=m("span"),n=v(e[3]),I(t,"class","permission-badge svelte-e0nvq8")},m(e,i){p(e,t,i),f(t,n)},p(e,t){8&t&&E(n,e[3])},d(e){e&&h(t)}}}function nm(e){let t,n,i,r,s,o;return{c(){t=m("div"),n=m("span"),i=w(),r=m("span"),s=v(e[9]),I(n,"class","relay-status svelte-e0nvq8"),F(n,"connected","connected"===e[10]),F(n,"error","error"===e[10]),I(r,"class","relay-name svelte-e0nvq8"),I(t,"class","relay-indicator static svelte-e0nvq8"),I(t,"title",o="Connected to "+e[9])},m(e,o){p(e,t,o),f(t,n),f(t,i),f(t,r),f(r,s)},p(e,i){1024&i&&F(n,"connected","connected"===e[10]),1024&i&&F(n,"error","error"===e[10]),512&i&&E(s,e[9]),512&i&&o!==(o="Connected to "+e[9])&&I(t,"title",o)},d(e){e&&h(t)}}}function im(e){let t,n,i,r,s,o,l,a,c,u,d,g=e[6]&&rm(e);return{c(){t=m("button"),n=m("span"),i=w(),r=m("span"),s=v(e[9]),o=w(),l=m("span"),l.textContent="▾",a=w(),g&&g.c(),c=b(),I(n,"class","relay-status svelte-e0nvq8"),F(n,"connected","connected"===e[10]),F(n,"error","error"===e[10]),I(r,"class","relay-name svelte-e0nvq8"),I(l,"class","dropdown-arrow svelte-e0nvq8"),F(l,"open",e[6]),I(t,"class","relay-indicator svelte-e0nvq8"),I(t,"title","Click to switch relays")},m(h,m){p(h,t,m),f(t,n),f(t,i),f(t,r),f(r,s),f(t,o),f(t,l),p(h,a,m),g&&g.m(h,m),p(h,c,m),u||(d=A(t,"click",e[16]),u=!0)},p(e,t){1024&t&&F(n,"connected","connected"===e[10]),1024&t&&F(n,"error","error"===e[10]),512&t&&E(s,e[9]),64&t&&F(l,"open",e[6]),e[6]?g?g.p(e,t):(g=rm(e),g.c(),g.m(c.parentNode,c)):g&&(g.d(1),g=null)},d(e){e&&h(t),e&&h(a),g&&g.d(e),e&&h(c),u=!1,d()}}}function rm(e){let t,n,r,s,o,l=e[12].length>0&&sm(e);return{c(){t=m("div"),l&&l.c(),n=w(),r=m("button"),r.textContent="Manage Relays...",I(r,"class","dropdown-item manage-btn svelte-e0nvq8"),I(t,"class","relay-dropdown svelte-e0nvq8")},m(i,a){p(i,t,a),l&&l.m(t,null),f(t,n),f(t,r),s||(o=[A(r,"click",e[18]),A(t,"click",k(e[22]))],s=!0)},p(e,i){e[12].length>0?l?l.p(e,i):(l=sm(e),l.c(),l.m(t,n)):l&&(l.d(1),l=null)},d(e){e&&h(t),l&&l.d(),s=!1,i(o)}}}function sm(e){let t,n,i,r,s,o=e[12],l=[];for(let t=0;t',o=w(),a=m("img"),u=w(),d=m("div"),g=m("span"),y=v("ORLY? dashboard\n "),B&&B.c(),b=w(),k=m("div"),D.c(),C=w(),E=m("div"),T.c(),I(s,"class","mobile-menu-btn svelte-e0nvq8"),I(s,"aria-label","Toggle menu"),l(a.src,c="/orly.png")||I(a,"src","/orly.png"),I(a,"alt","ORLY Logo"),I(a,"class","logo svelte-e0nvq8"),I(g,"class","app-title svelte-e0nvq8"),I(d,"class","header-title svelte-e0nvq8"),I(k,"class","relay-dropdown-container svelte-e0nvq8"),I(E,"class","header-buttons svelte-e0nvq8"),I(r,"class","header-content svelte-e0nvq8"),I(n,"class","main-header svelte-e0nvq8"),F(n,"dark-theme",t[0])},m(e,i){p(e,n,i),f(n,r),f(r,s),f(r,o),f(r,a),f(r,u),f(r,d),f(d,g),f(g,y),B&&B.m(g,null),f(r,b),f(r,k),D.m(k,null),f(r,C),f(r,E),T.m(E,null),x||(S=[A(window,"click",t[19]),A(s,"click",t[14])],x=!0)},p(e,[t]){e[1]&&e[2]?B?B.p(e,t):(B=tm(e),B.c(),B.m(g,null)):B&&(B.d(1),B=null),$===($=Q(e))&&D?D.p(e,t):(D.d(1),D=$(e),D&&(D.c(),D.m(k,null))),P===(P=R(e))&&T?T.p(e,t):(T.d(1),T=P(e),T&&(T.c(),T.m(E,null))),1&t&&F(n,"dark-theme",e[0])},i:e,o:e,d(e){e&&h(n),B&&B.d(),D.d(),T.d(),x=!1,i(S)}}}function pm(e,t,n){let i,r,s,o,l;u(e,wp,e=>n(10,r=e)),u(e,mp,e=>n(21,s=e)),u(e,yp,e=>n(11,o=e)),u(e,kp,e=>n(12,l=e));let{isDarkTheme:a=!1}=t,{isLoggedIn:c=!1}=t,{userRole:d=""}=t,{currentEffectiveRole:f=""}=t,{userProfile:p=null}=t,{userPubkey:h=""}=t;const g=U();let m=!1,y=!1,v="";function w(){n(6,m=!1)}async function b(e){if(console.log("[Header] switchToRelay called with:",e),y||e===s)console.log("[Header] Skipping - already connecting or same relay");else{n(7,y=!0),n(8,v=e);try{console.log("[Header] Calling connectToRelay...");const t=await Fp(e);if(console.log("[Header] connectToRelay result:",t),t.success){Ip(e,Dp(e)),g("relayChanged",{info:t.info}),w()}else console.log("[Header] Connection failed:",t.error)}catch(e){console.error("[Header] Failed to switch relay:",e)}finally{n(7,y=!1),n(8,v="")}}}return e.$$set=e=>{"isDarkTheme"in e&&n(0,a=e.isDarkTheme),"isLoggedIn"in e&&n(1,c=e.isLoggedIn),"userRole"in e&&n(2,d=e.userRole),"currentEffectiveRole"in e&&n(3,f=e.currentEffectiveRole),"userProfile"in e&&n(4,p=e.userProfile),"userPubkey"in e&&n(5,h=e.userPubkey)},e.$$.update=()=>{2097152&e.$$.dirty&&n(9,i=function(e){try{const t=e||xp();return console.log("[Header] getRelayHost - storeUrl:",e,"resolved url:",t),new URL(t).host}catch{return e||"local"}}(s))},[a,c,d,f,p,h,m,y,v,i,r,o,l,function(){g("openSettingsDrawer")},function(){g("toggleMobileMenu")},function(){g("openLoginModal")},function(e){e.stopPropagation(),n(6,m=!m)},b,function(e){e.stopPropagation(),w(),g("openRelayModal")},function(e){m&&w()},function(e){return s===e&&"connected"===r},s,function(t){N.call(this,e,t)},e=>b(e.url)]}class hm extends ae{constructor(e){super(),le(this,e,pm,fm,s,{isDarkTheme:0,isLoggedIn:1,userRole:2,currentEffectiveRole:3,userProfile:4,userPubkey:5})}}function gm(e,t,n){const i=e.slice();return i[12]=t[n],i}function mm(t){let n,i,r;return{c(){n=m("div"),I(n,"class","mobile-overlay svelte-1uja393")},m(e,s){p(e,n,s),i||(r=A(n,"click",t[7]),i=!0)},p:e,d(e){e&&h(n),i=!1,r()}}}function ym(e){let t,n,r;function s(){return e[8](e[12])}function o(...t){return e[9](e[12],...t)}return{c(){t=m("span"),t.textContent="✕",I(t,"class","tab-close-icon svelte-1uja393"),I(t,"role","button"),I(t,"tabindex","0")},m(e,i){p(e,t,i),n||(r=[A(t,"click",k(s)),A(t,"keydown",o)],n=!0)},p(t,n){e=t},d(e){e&&h(t),n=!1,i(r)}}}function vm(e){let t,n,i,r,s,o,l,a,c,u,d=e[12].icon+"",g=e[12].label+"",y=e[12].isSearchTab&&ym(e);function b(){return e[10](e[12])}return{c(){t=m("button"),n=m("span"),i=v(d),r=w(),s=m("span"),o=v(g),l=w(),y&&y.c(),a=w(),I(n,"class","tab-icon svelte-1uja393"),I(s,"class","tab-label svelte-1uja393"),I(t,"class","tab svelte-1uja393"),F(t,"active",e[2]===e[12].id)},m(e,d){p(e,t,d),f(t,n),f(n,i),f(t,r),f(t,s),f(s,o),f(t,l),y&&y.m(t,null),f(t,a),c||(u=A(t,"click",b),c=!0)},p(n,r){e=n,2&r&&d!==(d=e[12].icon+"")&&E(i,d),2&r&&g!==(g=e[12].label+"")&&E(o,g),e[12].isSearchTab?y?y.p(e,r):(y=ym(e),y.c(),y.m(t,a)):y&&(y.d(1),y=null),6&r&&F(t,"active",e[2]===e[12].id)},d(e){e&&h(t),y&&y.d(),c=!1,u()}}}function wm(e){let t,n,i,r,s,o,l,a;return{c(){t=m("a"),n=y("svg"),i=y("path"),r=y("path"),s=w(),o=m("span"),l=v("v"),a=v(e[3]),I(i,"d","M5 6h12v2h1.5c1.38 0 2.5 1.12 2.5 2.5v1c0 1.38-1.12 2.5-2.5 2.5H17v1c0 1.66-1.34 3-3 3H8c-1.66 0-3-1.34-3-3V6zm12 6h1.5c.28 0 .5-.22.5-.5v-1c0-.28-.22-.5-.5-.5H17v2z"),I(r,"d","M9 9c1.5 0 3 .5 3 2.5S10.5 14 9 14c0-1.5.5-3.5 2-4.5"),I(r,"stroke","currentColor"),I(r,"stroke-width","1"),I(r,"fill","none"),I(n,"class","version-icon svelte-1uja393"),I(n,"viewBox","0 0 24 24"),I(n,"fill","currentColor"),I(n,"xmlns","http://www.w3.org/2000/svg"),I(o,"class","version-text svelte-1uja393"),I(t,"href","https://next.orly.dev"),I(t,"target","_blank"),I(t,"rel","noopener noreferrer"),I(t,"class","version-link svelte-1uja393")},m(e,c){p(e,t,c),f(t,n),f(n,i),f(n,r),f(t,s),f(t,o),f(o,l),f(o,a)},p(e,t){8&t&&E(a,e[3])},d(e){e&&h(t)}}}function bm(t){let n,i,r,s,o,l=t[4]&&mm(t),a=t[1],c=[];for(let e=0;e{"isDarkTheme"in e&&n(0,i=e.isDarkTheme),"tabs"in e&&n(1,r=e.tabs),"selectedTab"in e&&n(2,s=e.selectedTab),"version"in e&&n(3,o=e.version),"mobileOpen"in e&&n(4,l=e.mobileOpen)},[i,r,s,o,l,c,u,function(){a("closeMobileMenu")},e=>u(e.id),(e,t)=>"Enter"===t.key&&u(e.id),e=>c(e.id)]}class km extends ae{constructor(e){super(),le(this,e,Am,bm,s,{isDarkTheme:0,tabs:1,selectedTab:2,version:3,mobileOpen:4})}}function Im(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access export functionality.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-jzrdtj"),I(s,"class","login-btn svelte-jzrdtj"),I(n,"class","login-prompt svelte-jzrdtj")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[5]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function Cm(e){let t,n,i=e[0]&&Em(e),r=e[1]&&xm(e);return{c(){i&&i.c(),t=w(),r&&r.c(),n=b()},m(e,s){i&&i.m(e,s),p(e,t,s),r&&r.m(e,s),p(e,n,s)},p(e,s){e[0]?i?i.p(e,s):(i=Em(e),i.c(),i.m(t.parentNode,t)):i&&(i.d(1),i=null),e[1]?r?r.p(e,s):(r=xm(e),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},d(e){i&&i.d(e),e&&h(t),r&&r.d(e),e&&h(n)}}}function Em(t){let n,i,r,s,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Export My Events",r=w(),s=m("p"),s.textContent="Download your personal events as a JSONL file.",o=w(),l=m("button"),l.textContent="📤 Export My Events",I(i,"class","svelte-jzrdtj"),I(s,"class","svelte-jzrdtj"),I(l,"class","export-btn svelte-jzrdtj"),I(n,"class","export-section svelte-jzrdtj")},m(e,u){p(e,n,u),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),a||(c=A(l,"click",t[3]),a=!0)},p:e,d(e){e&&h(n),a=!1,c()}}}function xm(t){let n,i,r,s,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Export All Events",r=w(),s=m("p"),s.textContent="Download the complete database as a JSONL file. This includes\n all events from all users.",o=w(),l=m("button"),l.textContent="📤 Export All Events",I(i,"class","svelte-jzrdtj"),I(s,"class","svelte-jzrdtj"),I(l,"class","export-btn svelte-jzrdtj"),I(n,"class","export-section svelte-jzrdtj")},m(e,u){p(e,n,u),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),a||(c=A(l,"click",t[4]),a=!0)},p:e,d(e){e&&h(n),a=!1,c()}}}function Sm(t){let n;function i(e,t){return e[2]?Cm:Im}let r=i(t),s=r(t);return{c(){s.c(),n=b()},m(e,t){s.m(e,t),p(e,n,t)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&h(n)}}}function Bm(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{currentEffectiveRole:o=""}=t,{aclMode:l=""}=t;const a=U();return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"currentEffectiveRole"in e&&n(6,o=e.currentEffectiveRole),"aclMode"in e&&n(7,l=e.aclMode)},e.$$.update=()=>{129&e.$$.dirty&&n(2,i="none"===l||s),192&e.$$.dirty&&n(1,r="none"===l||"admin"===o||"owner"===o)},[s,r,i,function(){a("exportMyEvents")},function(){a("exportAllEvents")},function(){a("openLoginModal")},o,l]}class Qm extends ae{constructor(e){super(),le(this,e,Bm,Sm,s,{isLoggedIn:0,currentEffectiveRole:6,aclMode:7})}}function Fm(t){let n,i,r,s,o,l,a,c;return{c(){n=m("div"),i=m("h3"),i.textContent="Import Events",r=w(),s=m("p"),s.textContent="Please log in to access import functionality.",o=w(),l=m("button"),l.textContent="Log In",I(i,"class","recovery-header svelte-nonyqh"),I(s,"class","recovery-description svelte-nonyqh"),I(l,"class","login-btn svelte-nonyqh"),I(n,"class","login-prompt svelte-nonyqh")},m(e,u){p(e,n,u),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),a||(c=A(l,"click",t[6]),a=!0)},p:e,d(e){e&&h(n),a=!1,c()}}}function $m(t){let n;return{c(){n=m("div"),n.innerHTML='

    Import Events

    \n

    Admin or owner permission required for import functionality.

    ',I(n,"class","permission-denied svelte-nonyqh")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Dm(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C=e[2]&&Rm(e);return{c(){t=m("h3"),t.textContent="Import Events",n=w(),r=m("p"),r.textContent="Upload a JSONL file to import events into the database.",s=w(),o=m("div"),l=m("input"),a=w(),c=m("div"),u=m("button"),d=v("Import Events"),y=w(),C&&C.c(),I(t,"class","svelte-nonyqh"),I(r,"class","svelte-nonyqh"),I(l,"type","file"),I(l,"id","import-file"),I(l,"accept",".jsonl,.txt"),I(l,"class","svelte-nonyqh"),I(u,"class","import-btn svelte-nonyqh"),u.disabled=g=!e[1]||"Uploading..."===e[2],I(c,"class","import-row svelte-nonyqh"),I(o,"class","recovery-controls-card svelte-nonyqh")},m(i,h){p(i,t,h),p(i,n,h),p(i,r,h),p(i,s,h),p(i,o,h),f(o,l),f(o,a),f(o,c),f(c,u),f(u,d),f(c,y),C&&C.m(c,null),b||(k=[A(l,"change",e[4]),A(u,"click",e[5])],b=!0)},p(e,t){6&t&&g!==(g=!e[1]||"Uploading..."===e[2])&&(u.disabled=g),e[2]?C?C.p(e,t):(C=Rm(e),C.c(),C.m(c,null)):C&&(C.d(1),C=null)},d(e){e&&h(t),e&&h(n),e&&h(r),e&&h(s),e&&h(o),C&&C.d(),b=!1,i(k)}}}function Rm(e){let t,n;return{c(){t=m("span"),n=v(e[2]),I(t,"class","import-message svelte-nonyqh"),F(t,"uploading","Uploading..."===e[2]),F(t,"success","Upload complete"===e[2]),F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},m(e,i){p(e,t,i),f(t,n)},p(e,i){4&i&&E(n,e[2]),4&i&&F(t,"uploading","Uploading..."===e[2]),4&i&&F(t,"success","Upload complete"===e[2]),4&i&&F(t,"error",e[2].startsWith("Import failed")||e[2].startsWith("Admin")||e[2].startsWith("Please"))},d(e){e&&h(t)}}}function Pm(t){let n;function i(e,t){return e[3]?Dm:e[0]?$m:Fm}let r=i(t),s=r(t);return{c(){n=m("div"),s.c(),I(n,"class","import-section svelte-nonyqh")},m(e,t){p(e,n,t),s.m(n,null)},p(e,[t]){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&h(n),s.d()}}}function Tm(e,t,n){let i,{isLoggedIn:r=!1}=t,{currentEffectiveRole:s=""}=t,{selectedFile:o=null}=t,{aclMode:l=""}=t,{importMessage:a=""}=t;const c=U();return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"currentEffectiveRole"in e&&n(7,s=e.currentEffectiveRole),"selectedFile"in e&&n(1,o=e.selectedFile),"aclMode"in e&&n(8,l=e.aclMode),"importMessage"in e&&n(2,a=e.importMessage)},e.$$.update=()=>{385&e.$$.dirty&&n(3,i="none"===l||r&&("admin"===s||"owner"===s))},[r,o,a,i,function(e){c("fileSelect",e)},function(){c("importEvents")},function(){c("openLoginModal")},s,l]}class Um extends ae{constructor(e){super(),le(this,e,Tm,Pm,s,{isLoggedIn:0,currentEffectiveRole:7,selectedFile:1,aclMode:8,importMessage:2})}}const Nm={0:"Profile Metadata",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete Request",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1063:"File Metadata",1311:"Live Chat Message",1984:"Reporting",1985:"Label",9734:"Zap Request",9735:"Zap Receipt",1e4:"Mute List",10001:"Pin List",10002:"Relay List Metadata",10003:"Bookmark List",10004:"Communities List",10005:"Public Chats List",10006:"Blocked Relays List",10007:"Search Relays List",10009:"User Groups",10015:"Interests List",10030:"User Emoji List",13194:"Wallet Info",22242:"Client Auth",23194:"Wallet Request",23195:"Wallet Response",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People List",30001:"Categorized Bookmarks",30002:"Categorized Relay List",30003:"Bookmark Sets",30004:"Curation Sets",30005:"Video Sets",30008:"Profile Badges",30009:"Badge Definition",30015:"Interest Sets",30017:"Create/Update Stall",30018:"Create/Update Product",30019:"Marketplace UI/UX",30020:"Product Sold As Auction",30023:"Long-form Content",30024:"Draft Long-form Content",30030:"Emoji Sets",30063:"Release Artifact Sets",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30388:"Slide Set",30402:"Classified Listing",30403:"Draft Classified Listing",30617:"Repository Announcement",30618:"Repository State Announcement",30818:"Wiki Article",30819:"Redirects",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler Recommendation",31990:"Handler Information",34550:"Community Definition",34551:"Community Post Approval"};function _m(e,t=null){if(!e||"string"!=typeof e)return!1;return!!/^[0-9a-fA-F]+$/.test(e)&&(!t||e.length===t)}function Lm(e){const t=new Date(1e3*e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Mm(e){return Math.floor(new Date(e).getTime()/1e3)}function Om(e,t,n){const i=e.slice();return i[62]=t[n],i[64]=n,i}function jm(e,t,n){const i=e.slice();return i[65]=t[n],i}function Hm(e,t,n){const i=e.slice();return i[68]=t[n],i}function Gm(e,t,n){const i=e.slice();return i[71]=t[n],i}function qm(e,t,n){const i=e.slice();return i[71]=t[n].kind,i[74]=t[n].name,i}function Jm(e){let t,n,i,r,s,o,l=e[20],a=[];for(let t=0;t0&&Vm(t),Ge=t[17]&&zm(t),qe=t[2].length>0&&Wm(t),Je=t[18]&&Xm(t),Ke=t[3].length>0&&ey(t),Ve=t[19]&&ny(t),Ye=t[4].length>0&&iy(t),ze=t[5]&&sy(t),We=t[6]&&oy(t),Ze=t[8]&&ly(t);return{c(){n=m("div"),r=m("div"),s=m("div"),o=m("label"),o.textContent="Search Text (NIP-50)",l=w(),a=m("div"),c=m("input"),u=w(),d=m("label"),d.textContent="Event Kinds",g=w(),y=m("div"),b=m("button"),k=v(Me),S=v(" Select Kinds ("),B=v(Oe),Q=v(" selected)"),$=w(),je&&je.c(),D=w(),He&&He.c(),R=w(),P=m("label"),P.textContent="Authors (Pubkeys)",T=w(),U=m("div"),N=m("div"),_=m("input"),L=w(),M=m("button"),M.textContent="Add",O=w(),Ge&&Ge.c(),j=w(),qe&&qe.c(),H=w(),G=m("label"),G.textContent="Event IDs",q=w(),J=m("div"),K=m("div"),V=m("input"),Y=w(),z=m("button"),z.textContent="Add",W=w(),Je&&Je.c(),Z=w(),Ke&&Ke.c(),X=w(),ee=m("label"),ee.textContent="Tags (#e, #p, #a)",te=w(),ne=m("div"),ie=m("div"),re=m("span"),re.textContent="#",se=w(),oe=m("input"),le=w(),ae=m("input"),ce=w(),ue=m("button"),ue.textContent="Add",de=w(),Ve&&Ve.c(),fe=w(),Ye&&Ye.c(),pe=w(),he=m("label"),he.textContent="Since",ge=w(),me=m("div"),ye=m("input"),ve=w(),ze&&ze.c(),we=w(),be=m("label"),be.textContent="Until",Ae=w(),ke=m("div"),Ie=m("input"),Ce=w(),We&&We.c(),Ee=w(),xe=m("label"),xe.textContent="Limit",Se=w(),Be=m("div"),Qe=m("input"),Fe=w(),Ze&&Ze.c(),$e=w(),De=m("div"),Re=m("button"),Re.textContent="🧹",Pe=w(),Te=m("div"),Ue=w(),Ne=m("button"),Ne.textContent="",I(o,"for","search-text"),I(o,"class","svelte-1a1v6k0"),I(c,"id","search-text"),I(c,"type","text"),I(c,"placeholder","Search events..."),I(c,"class","filter-input svelte-1a1v6k0"),I(a,"class","field-content svelte-1a1v6k0"),I(d,"class","svelte-1a1v6k0"),I(b,"class","picker-toggle-btn svelte-1a1v6k0"),I(y,"class","field-content svelte-1a1v6k0"),I(P,"class","svelte-1a1v6k0"),I(_,"type","text"),I(_,"placeholder","64 character hex pubkey..."),I(_,"class","filter-input svelte-1a1v6k0"),I(_,"maxlength","64"),I(M,"class","add-btn svelte-1a1v6k0"),I(N,"class","input-group svelte-1a1v6k0"),I(U,"class","field-content svelte-1a1v6k0"),I(G,"class","svelte-1a1v6k0"),I(V,"type","text"),I(V,"placeholder","64 character hex event ID..."),I(V,"class","filter-input svelte-1a1v6k0"),I(V,"maxlength","64"),I(z,"class","add-btn svelte-1a1v6k0"),I(K,"class","input-group svelte-1a1v6k0"),I(J,"class","field-content svelte-1a1v6k0"),I(ee,"class","svelte-1a1v6k0"),I(re,"class","hash-prefix svelte-1a1v6k0"),I(oe,"type","text"),I(oe,"placeholder","Tag"),I(oe,"class","filter-input tag-name-input svelte-1a1v6k0"),I(oe,"maxlength","1"),I(ae,"type","text"),I(ae,"placeholder","Value..."),I(ae,"class","filter-input tag-value-input svelte-1a1v6k0"),I(ue,"class","add-btn svelte-1a1v6k0"),I(ie,"class","tag-input-group svelte-1a1v6k0"),I(ne,"class","field-content svelte-1a1v6k0"),I(he,"for","since-timestamp"),I(he,"class","svelte-1a1v6k0"),I(ye,"id","since-timestamp"),I(ye,"type","datetime-local"),ye.value=t[32](),I(ye,"class","filter-input svelte-1a1v6k0"),I(me,"class","field-content timestamp-field svelte-1a1v6k0"),I(be,"for","until-timestamp"),I(be,"class","svelte-1a1v6k0"),I(Ie,"id","until-timestamp"),I(Ie,"type","datetime-local"),Ie.value=t[33](),I(Ie,"class","filter-input svelte-1a1v6k0"),I(ke,"class","field-content timestamp-field svelte-1a1v6k0"),I(xe,"for","limit"),I(xe,"class","svelte-1a1v6k0"),I(Qe,"id","limit"),I(Qe,"type","number"),I(Qe,"placeholder","Max events to return"),I(Qe,"class","filter-input svelte-1a1v6k0"),I(Qe,"min","1"),I(Be,"class","field-content svelte-1a1v6k0"),I(s,"class","filter-grid svelte-1a1v6k0"),I(r,"class","filter-content svelte-1a1v6k0"),I(Re,"class","clear-all-btn svelte-1a1v6k0"),I(Re,"title","Clear all filters"),I(Te,"class","spacer svelte-1a1v6k0"),I(Ne,"class","json-toggle-btn svelte-1a1v6k0"),I(Ne,"title","Edit filter JSON"),F(Ne,"active",t[8]),I(De,"class","clear-column svelte-1a1v6k0"),I(n,"class","filter-builder svelte-1a1v6k0")},m(e,i){p(e,n,i),f(n,r),f(r,s),f(s,o),f(s,l),f(s,a),f(a,c),x(c,t[0]),f(s,u),f(s,d),f(s,g),f(s,y),f(y,b),f(b,k),f(b,S),f(b,B),f(b,Q),f(y,$),je&&je.m(y,null),f(y,D),He&&He.m(y,null),f(s,R),f(s,P),f(s,T),f(s,U),f(U,N),f(N,_),x(_,t[13]),f(N,L),f(N,M),f(U,O),Ge&&Ge.m(U,null),f(U,j),qe&&qe.m(U,null),f(s,H),f(s,G),f(s,q),f(s,J),f(J,K),f(K,V),x(V,t[14]),f(K,Y),f(K,z),f(J,W),Je&&Je.m(J,null),f(J,Z),Ke&&Ke.m(J,null),f(s,X),f(s,ee),f(s,te),f(s,ne),f(ne,ie),f(ie,re),f(ie,se),f(ie,oe),x(oe,t[15]),f(ie,le),f(ie,ae),x(ae,t[16]),f(ie,ce),f(ie,ue),f(ne,de),Ve&&Ve.m(ne,null),f(ne,fe),Ye&&Ye.m(ne,null),f(s,pe),f(s,he),f(s,ge),f(s,me),f(me,ye),f(me,ve),ze&&ze.m(me,null),f(s,we),f(s,be),f(s,Ae),f(s,ke),f(ke,Ie),f(ke,Ce),We&&We.m(ke,null),f(s,Ee),f(s,xe),f(s,Se),f(s,Be),f(Be,Qe),x(Qe,t[7]),f(s,Fe),Ze&&Ze.m(s,null),f(n,$e),f(n,De),f(De,Re),f(De,Pe),f(De,Te),f(De,Ue),f(De,Ne),_e||(Le=[A(c,"input",t[38]),A(b,"click",t[39]),A(_,"input",t[43]),A(_,"keydown",t[44]),A(M,"click",t[25]),A(V,"input",t[46]),A(V,"keydown",t[47]),A(z,"click",t[27]),A(oe,"input",t[49]),A(ae,"input",t[50]),A(ae,"keydown",t[51]),A(ue,"click",t[29]),A(ye,"change",t[34]),A(Ie,"change",t[35]),A(Qe,"input",t[55]),A(Re,"click",t[31]),A(Ne,"click",t[57])],_e=!0)},p(e,t){1&t[0]&&c.value!==e[0]&&x(c,e[0]),4096&t[0]&&Me!==(Me=e[12]?"▼":"▶")&&E(k,Me),2&t[0]&&Oe!==(Oe=e[1].length+"")&&E(B,Oe),e[12]?je?je.p(e,t):(je=Jm(e),je.c(),je.m(y,D)):je&&(je.d(1),je=null),e[1].length>0?He?He.p(e,t):(He=Vm(e),He.c(),He.m(y,null)):He&&(He.d(1),He=null),8192&t[0]&&_.value!==e[13]&&x(_,e[13]),e[17]?Ge?Ge.p(e,t):(Ge=zm(e),Ge.c(),Ge.m(U,j)):Ge&&(Ge.d(1),Ge=null),e[2].length>0?qe?qe.p(e,t):(qe=Wm(e),qe.c(),qe.m(U,null)):qe&&(qe.d(1),qe=null),16384&t[0]&&V.value!==e[14]&&x(V,e[14]),e[18]?Je?Je.p(e,t):(Je=Xm(e),Je.c(),Je.m(J,Z)):Je&&(Je.d(1),Je=null),e[3].length>0?Ke?Ke.p(e,t):(Ke=ey(e),Ke.c(),Ke.m(J,null)):Ke&&(Ke.d(1),Ke=null),32768&t[0]&&oe.value!==e[15]&&x(oe,e[15]),65536&t[0]&&ae.value!==e[16]&&x(ae,e[16]),e[19]?Ve?Ve.p(e,t):(Ve=ny(e),Ve.c(),Ve.m(ne,fe)):Ve&&(Ve.d(1),Ve=null),e[4].length>0?Ye?Ye.p(e,t):(Ye=iy(e),Ye.c(),Ye.m(ne,null)):Ye&&(Ye.d(1),Ye=null),e[5]?ze?ze.p(e,t):(ze=sy(e),ze.c(),ze.m(me,null)):ze&&(ze.d(1),ze=null),e[6]?We?We.p(e,t):(We=oy(e),We.c(),We.m(ke,null)):We&&(We.d(1),We=null),128&t[0]&&C(Qe.value)!==e[7]&&x(Qe,e[7]),e[8]?Ze?Ze.p(e,t):(Ze=ly(e),Ze.c(),Ze.m(s,null)):Ze&&(Ze.d(1),Ze=null),256&t[0]&&F(Ne,"active",e[8])},i:e,o:e,d(e){e&&h(n),je&&je.d(),He&&He.d(),Ge&&Ge.d(),qe&&qe.d(),Je&&Je.d(),Ke&&Ke.d(),Ve&&Ve.d(),Ye&&Ye.d(),ze&&ze.d(),We&&We.d(),Ze&&Ze.d(),_e=!1,i(Le)}}}function uy(e,t,n){let i,r;const s=U();let{searchText:o=""}=t,{selectedKinds:l=[]}=t,{pubkeys:a=[]}=t,{eventIds:c=[]}=t,{tags:u=[]}=t,{sinceTimestamp:d=null}=t,{untilTimestamp:f=null}=t,{limit:p=null}=t,{showJsonEditor:h=!1}=t,g="",m="",y=!1,v="",w="",b="",A="",k="",I="",E="",x="",S=null,B=!1;function Q(e){l.includes(e)?n(1,l=l.filter(t=>t!==e)):n(1,l=[...l,e].sort((e,t)=>e-t))}function F(e){n(1,l=l.filter(t=>t!==e))}function $(){const e=w.trim();e&&(_m(e,64)?a.includes(e)?n(17,I="Pubkey already added"):(n(2,a=[...a,e]),n(13,w=""),n(17,I="")):n(17,I="Invalid pubkey: must be 64 character hex string"))}function D(e){n(2,a=a.filter(t=>t!==e))}function R(){const e=b.trim();e&&(_m(e,64)?c.includes(e)?n(18,E="Event ID already added"):(n(3,c=[...c,e]),n(14,b=""),n(18,E="")):n(18,E="Invalid event ID: must be 64 character hex string"))}function P(e){n(3,c=c.filter(t=>t!==e))}function N(){const e=A.trim(),t=k.trim();e&&t&&(/^[a-zA-Z]$/.test(e)?u.some(n=>n.name===e&&n.value===t)?n(19,x="Tag already added"):(n(4,u=[...u,{name:e,value:t}]),n(15,A=""),n(16,k=""),n(19,x="")):n(19,x="Invalid tag name: must be single letter a-z or A-Z"))}function _(e){n(4,u=u.filter((t,n)=>n!==e))}function L(){s("apply",{searchText:o,selectedKinds:l,pubkeys:a,eventIds:c,tags:u,sinceTimestamp:d,untilTimestamp:f,limit:p})}T(()=>{S&&clearTimeout(S)});return e.$$set=e=>{"searchText"in e&&n(0,o=e.searchText),"selectedKinds"in e&&n(1,l=e.selectedKinds),"pubkeys"in e&&n(2,a=e.pubkeys),"eventIds"in e&&n(3,c=e.eventIds),"tags"in e&&n(4,u=e.tags),"sinceTimestamp"in e&&n(5,d=e.sinceTimestamp),"untilTimestamp"in e&&n(6,f=e.untilTimestamp),"limit"in e&&n(7,p=e.limit),"showJsonEditor"in e&&n(8,h=e.showJsonEditor)},e.$$.update=()=>{if(256&e.$$.dirty[0]&&h){const e=function(){const e={};return l.length>0&&(e.kinds=l),a.length>0&&(e.authors=a),c.length>0&&(e.ids=c),d&&(e.since=d),f&&(e.until=f),p&&(e.limit=p),o&&(e.search=o),u.forEach(t=>{const n=`#${t.name}`;e[n]||(e[n]=[]),e[n].push(t.value)}),e}();n(10,g=JSON.stringify(e,null,2))}255&e.$$.dirty[0]|32&e.$$.dirty[1]&&(B?(S&&clearTimeout(S),S=setTimeout(()=>{L()},1e3)):n(36,B=!0)),512&e.$$.dirty[0]|64&e.$$.dirty[1]&&n(20,r=i.filter(e=>e.kind.toString().includes(v)||e.name.toLowerCase().includes(v.toLowerCase())))},n(37,i=Object.entries(Nm).map(([e,t])=>({kind:parseInt(e),name:t})).sort((e,t)=>e.kind-t.kind)),[o,l,a,c,u,d,f,p,h,v,g,m,y,w,b,A,k,I,E,x,r,s,function(){try{const e=JSON.parse(g);n(11,m=""),n(1,l=e.kinds||[]),n(2,a=e.authors||[]),n(3,c=e.ids||[]),n(5,d=e.since||null),n(6,f=e.until||null),n(7,p=e.limit||null),n(0,o=e.search||""),n(4,u=[]),Object.keys(e).forEach(t=>{if(t.startsWith("#")&&2===t.length){const n=t.slice(1);(Array.isArray(e[t])?e[t]:[e[t]]).forEach(e=>{u.push({name:n,value:String(e)})})}}),n(4,u),S&&clearTimeout(S),L()}catch(e){n(11,m="Invalid JSON: "+e.message)}},Q,F,$,D,R,P,N,_,function(){n(0,o=""),n(1,l=[]),n(2,a=[]),n(3,c=[]),n(4,u=[]),n(5,d=null),n(6,f=null),n(7,p=null),s("clear")},function(){return d?Lm(d):""},function(){return f?Lm(f):""},function(e){const t=e.target.value;n(5,d=t?Mm(t):null)},function(e){const t=e.target.value;n(6,f=t?Mm(t):null)},B,i,function(){o=this.value,n(0,o)},()=>n(12,y=!y),function(){v=this.value,n(9,v)},e=>Q(e),e=>F(e),function(){w=this.value,n(13,w)},e=>"Enter"===e.key&&$(),e=>D(e),function(){b=this.value,n(14,b)},e=>"Enter"===e.key&&R(),e=>P(e),function(){A=this.value,n(15,A)},function(){k=this.value,n(16,k)},e=>"Enter"===e.key&&N(),e=>_(e),()=>n(5,d=null),()=>n(6,f=null),function(){p=C(this.value),n(7,p)},function(){g=this.value,n(10,g),n(8,h)},()=>s("toggleJson")]}class dy extends ae{constructor(e){super(),le(this,e,uy,cy,s,{searchText:0,selectedKinds:1,pubkeys:2,eventIds:3,tags:4,sinceTimestamp:5,untilTimestamp:6,limit:7,showJsonEditor:8},null,[-1,-1,-1])}}function fy(e,t,n){const i=e.slice();return i[28]=t[n],i}function py(e,t,n){const i=e.slice();return i[31]=t[n],i}function hy(t){let n;return{c(){n=m("div"),n.innerHTML="

    ❌ Read, write, admin, or owner permission required to view all\n events.

    ",I(n,"class","permission-denied svelte-16xix3y")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function gy(e){let t,n,i,r;function s(e,t){return e[4].length>0?yy:e[6]?void 0:my}let o=s(e),l=o&&o(e),a=e[6]&&Ey();return{c(){t=m("div"),l&&l.c(),n=w(),a&&a.c(),I(t,"class","events-view-content svelte-16xix3y")},m(s,o){p(s,t,o),l&&l.m(t,null),f(t,n),a&&a.m(t,null),i||(r=A(t,"scroll",e[9]),i=!0)},p(e,i){o===(o=s(e))&&l?l.p(e,i):(l&&l.d(1),l=o&&o(e),l&&(l.c(),l.m(t,n))),e[6]?a||(a=Ey(),a.c(),a.m(t,null)):a&&(a.d(1),a=null)},d(e){e&&h(t),l&&l.d(),a&&a.d(),i=!1,r()}}}function my(t){let n;return{c(){n=m("div"),n.innerHTML="

    No events found.

    ",I(n,"class","no-events svelte-16xix3y")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function yy(e){let t,n=e[4],i=[];for(let t=0;t0&&by(e);return{c(){t=m("div"),n=m("span"),n.textContent="🗑️ Delete Event",i=w(),r&&r.c(),I(n,"class","delete-event-label svelte-16xix3y"),I(t,"class","delete-event-info svelte-16xix3y")},m(e,s){p(e,t,s),f(t,n),f(t,i),r&&r.m(t,null)},p(e,n){e[28].tags&&e[28].tags.length>0?r?r.p(e,n):(r=by(e),r.c(),r.m(t,null)):r&&(r.d(1),r=null)},d(e){e&&h(t),r&&r.d()}}}function by(e){let t,n=e[28].tags.filter(Py),i=[];for(let t=0;t👤',s=w(),o=m("div"),l=m("div"),a=v(U),c=w(),u=m("div"),d=m("span"),g=v(N),y=w(),b=m("span"),k=v(_),C=w(),x=m("div"),S=m("div"),B=v(L),Q=w(),H.c(),$=w(),G&&G.c(),D=w(),K&&K.c(),R=w(),I(r,"class","events-view-avatar svelte-16xix3y"),I(l,"class","events-view-author svelte-16xix3y"),I(d,"class","kind-number svelte-16xix3y"),F(d,"delete-event",5===e[28].kind),I(b,"class","kind-name svelte-16xix3y"),I(u,"class","events-view-kind svelte-16xix3y"),I(o,"class","events-view-info svelte-16xix3y"),I(S,"class","event-timestamp svelte-16xix3y"),I(x,"class","events-view-content svelte-16xix3y"),I(n,"class","events-view-row svelte-16xix3y"),I(n,"role","button"),I(n,"tabindex","0"),I(t,"class","events-view-item svelte-16xix3y"),F(t,"expanded",e[5].has(e[28].id))},m(e,i){p(e,t,i),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(d,g),f(u,y),f(u,b),f(b,k),f(n,C),f(n,x),f(x,S),f(S,B),f(x,Q),H.m(x,null),f(n,$),G&&G.m(n,null),f(t,D),K&&K.m(t,null),f(t,R),P||(T=[A(n,"click",q),A(n,"keydown",J)],P=!0)},p(i,r){e=i,16&r[0]&&U!==(U=Fy(e[28].pubkey)+"")&&E(a,U),16&r[0]&&N!==(N=e[28].kind+"")&&E(g,N),16&r[0]&&F(d,"delete-event",5===e[28].kind),16&r[0]&&_!==(_=$y(e[28].kind)+"")&&E(k,_),16&r[0]&&L!==(L=Dy(e[28].created_at)+"")&&E(B,L),j===(j=O(e))&&H?H.p(e,r):(H.d(1),H=j(e),H&&(H.c(),H.m(x,null))),5!==e[28].kind&&("admin"===e[2]||"owner"===e[2]||"write"===e[2]&&e[28].pubkey&&e[28].pubkey===e[3])?G?G.p(e,r):(G=ky(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),48&r[0]&&(M=e[5].has(e[28].id)),M?K?K.p(e,r):(K=Iy(e),K.c(),K.m(t,R)):K&&(K.d(1),K=null),48&r[0]&&F(t,"expanded",e[5].has(e[28].id))},d(e){e&&h(t),H.d(),G&&G.d(),K&&K.d(),P=!1,i(T)}}}function Ey(e){let t;return{c(){t=m("div"),t.innerHTML='
    \n

    Loading events...

    ',I(t,"class","loading-events svelte-16xix3y")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function xy(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,E,x,S,B,Q,$,D,R,P;function T(e,t){return e[6]?By:Sy}r=new dy({props:{showJsonEditor:e[8]}}),r.$on("apply",e[17]),r.$on("clear",e[18]),r.$on("toggleJson",e[16]);let U=T(e),N=U(e);return{c(){t=m("div"),n=m("div"),ie(r.$$.fragment),s=w(),o=m("div"),l=m("div"),a=m("button"),a.innerHTML='',c=w(),u=m("div"),d=m("label"),g=m("input"),y=w(),b=m("span"),k=w(),C=m("span"),C.textContent="Only show my events",E=w(),x=m("div"),S=m("button"),B=v("🔄 Load More"),Q=w(),$=m("button"),N.c(),I(n,"class","filter-panel svelte-16xix3y"),F(n,"open",e[7]),I(a,"class","filter-btn svelte-16xix3y"),I(a,"title","Filter events"),F(a,"active",e[7]),I(g,"type","checkbox"),I(g,"class","svelte-16xix3y"),I(b,"class","toggle-slider svelte-16xix3y"),I(C,"class","toggle-label svelte-16xix3y"),I(d,"class","toggle-container svelte-16xix3y"),I(u,"class","events-view-toggle svelte-16xix3y"),I(l,"class","events-view-left svelte-16xix3y"),I(S,"class","refresh-btn svelte-16xix3y"),S.disabled=e[6],I($,"class","reload-btn svelte-16xix3y"),$.disabled=e[6],I(x,"class","events-view-buttons svelte-16xix3y"),I(o,"class","events-view-header svelte-16xix3y"),I(t,"class","events-view-footer svelte-16xix3y")},m(i,h){p(i,t,h),f(t,n),re(r,n,null),f(t,s),f(t,o),f(o,l),f(l,a),f(l,c),f(l,u),f(u,d),f(d,g),g.checked=e[0],f(d,y),f(d,b),f(d,k),f(d,C),f(o,E),f(o,x),f(x,S),f(S,B),f(x,Q),f(x,$),N.m($,null),D=!0,R||(P=[A(a,"click",e[15]),A(g,"change",e[23]),A(g,"change",e[24]),A(S,"click",e[25]),A($,"click",e[26])],R=!0)},p(e,t){const i={};256&t[0]&&(i.showJsonEditor=e[8]),r.$set(i),(!D||128&t[0])&&F(n,"open",e[7]),(!D||128&t[0])&&F(a,"active",e[7]),1&t[0]&&(g.checked=e[0]),(!D||64&t[0])&&(S.disabled=e[6]),U!==(U=T(e))&&(N.d(1),N=U(e),N&&(N.c(),N.m($,null))),(!D||64&t[0])&&($.disabled=e[6])},i(e){D||(ee(r.$$.fragment,e),D=!0)},o(e){te(r.$$.fragment,e),D=!1},d(e){e&&h(t),se(r),N.d(),R=!1,i(P)}}}function Sy(e){let t;return{c(){t=v("🔄")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function By(e){let t;return{c(){t=m("div"),I(t,"class","spinner svelte-16xix3y")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Qy(e){let t,n,i;function r(e,t){return!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?hy:gy}let s=r(e),o=s(e),l=e[1]&&("read"===e[2]||"write"===e[2]||"admin"===e[2]||"owner"===e[2])&&xy(e);return{c(){t=m("div"),o.c(),n=w(),l&&l.c(),I(t,"class","events-view-container svelte-16xix3y")},m(e,r){p(e,t,r),o.m(t,null),f(t,n),l&&l.m(t,null),i=!0},p(e,i){s===(s=r(e))&&o?o.p(e,i):(o.d(1),o=s(e),o&&(o.c(),o.m(t,n))),!e[1]||"read"!==e[2]&&"write"!==e[2]&&"admin"!==e[2]&&"owner"!==e[2]?l&&(Z(),te(l,1,1,()=>{l=null}),X()):l?(l.p(e,i),6&i[0]&&ee(l,1)):(l=xy(e),l.c(),ee(l,1),l.m(t,null))},i(e){i||(ee(l),i=!0)},o(e){te(l),i=!1},d(e){e&&h(t),o.d(),l&&l.d()}}}function Fy(e){return e?e.slice(0,8)+"..."+e.slice(-8):""}function $y(e){return{0:"Profile",1:"Text Note",2:"Recommend Relay",3:"Contacts",4:"Encrypted DM",5:"Delete",6:"Repost",7:"Reaction",8:"Badge Award",16:"Generic Repost",40:"Channel Creation",41:"Channel Metadata",42:"Channel Message",43:"Channel Hide Message",44:"Channel Mute User",1984:"Reporting",9734:"Zap Request",9735:"Zap",1e4:"Mute List",10001:"Pin List",10002:"Relay List",22242:"Client Auth",24133:"Nostr Connect",27235:"HTTP Auth",3e4:"Categorized People",30001:"Categorized Bookmarks",30008:"Profile Badges",30009:"Badge Definition",30017:"Create or update a stall",30018:"Create or update a product",30023:"Long-form Content",30024:"Draft Long-form Content",30078:"Application-specific Data",30311:"Live Event",30315:"User Statuses",30402:"Classified Listing",30403:"Draft Classified Listing",31922:"Date-Based Calendar Event",31923:"Time-Based Calendar Event",31924:"Calendar",31925:"Calendar Event RSVP",31989:"Handler recommendation",31990:"Handler information",34550:"Community Definition"}[e]||`Kind ${e}`}function Dy(e){return new Date(1e3*e).toLocaleString()}function Ry(e){return e?e.length>100?e.slice(0,100)+"...":e:""}const Py=e=>"e"===e[0];function Ty(e,t,n){let{isLoggedIn:i=!1}=t,{userRole:r=""}=t,{userPubkey:s=""}=t,{filteredEvents:o=[]}=t,{expandedEvents:l=new Set}=t,{isLoadingEvents:a=!1}=t,{showOnlyMyEvents:c=!1}=t,{showFilterBuilder:u=!1}=t;const d=U();let f=!1;function p(e){d("toggleEventExpansion",e)}function h(e){d("deleteEvent",e)}function g(e,t){d("copyEventToClipboard",{event:e,e:t})}function m(){d("toggleChange")}function y(e,t){d("loadAllEvents",{refresh:e,authors:t})}return e.$$set=e=>{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"userPubkey"in e&&n(3,s=e.userPubkey),"filteredEvents"in e&&n(4,o=e.filteredEvents),"expandedEvents"in e&&n(5,l=e.expandedEvents),"isLoadingEvents"in e&&n(6,a=e.isLoadingEvents),"showOnlyMyEvents"in e&&n(0,c=e.showOnlyMyEvents),"showFilterBuilder"in e&&n(7,u=e.showFilterBuilder)},[c,i,r,s,o,l,a,u,f,function(e){d("scroll",e)},p,h,g,m,y,function(){d("toggleFilterBuilder")},function(){n(8,f=!f)},function(e){d("filterApply",e.detail)},function(){d("filterClear")},e=>h(e.id),e=>p(e.id),(e,t)=>"Enter"===t.key&&p(e.id),(e,t)=>g(e,t),function(){c=this.checked,n(0,c)},()=>m(),()=>{y(!1,c&&s?[s]:null)},()=>{y(!0,c&&s?[s]:null)}]}class Uy extends ae{constructor(e){super(),le(this,e,Ty,Qy,s,{isLoggedIn:1,userRole:2,userPubkey:3,filteredEvents:4,expandedEvents:5,isLoadingEvents:6,showOnlyMyEvents:0,showFilterBuilder:7},null,[-1,-1])}}const Ny=[{kind:0,name:"Metadata",description:"User profile information (name, about, picture, nip05, etc.)",nip:"01",isReplaceable:!0,template:{kind:0,content:"",tags:[]}},{kind:1,name:"Short Text Note",description:"Short-form text post (like a tweet)",nip:"01",template:{kind:1,content:"",tags:[]}},{kind:2,name:"Recommend Relay",description:"Relay recommendation",nip:"01",deprecated:!0,template:{kind:2,content:"",tags:[]}},{kind:3,name:"Follows",description:"Following list with optional relay hints",nip:"02",isReplaceable:!0,template:{kind:3,content:"",tags:[]}},{kind:4,name:"Encrypted Direct Message",description:"Private message using NIP-04 encryption",nip:"04",deprecated:!0,template:{kind:4,content:"",tags:[]}},{kind:5,name:"Event Deletion Request",description:"Request to delete events",nip:"09",template:{kind:5,content:"",tags:[]}},{kind:6,name:"Repost",description:"Share/repost another text note",nip:"18",template:{kind:6,content:"",tags:[]}},{kind:7,name:"Reaction",description:"Like, emoji reaction to an event",nip:"25",template:{kind:7,content:"",tags:[]}},{kind:8,name:"Badge Award",description:"Award a badge to someone",nip:"58",template:{kind:8,content:"",tags:[]}},{kind:9,name:"Chat Message",description:"Chat message",nip:"C7",template:{kind:9,content:"",tags:[]}},{kind:10,name:"Group Chat Threaded Reply",description:"Threaded reply in group chat",nip:"29",deprecated:!0,template:{kind:10,content:"",tags:[]}},{kind:11,name:"Thread",description:"Thread event",nip:"7D",template:{kind:11,content:"",tags:[]}},{kind:12,name:"Group Thread Reply",description:"Reply in group thread",nip:"29",deprecated:!0,template:{kind:12,content:"",tags:[]}},{kind:13,name:"Seal",description:"Sealed/encrypted event wrapper",nip:"59",template:{kind:13,content:"",tags:[]}},{kind:14,name:"Direct Message",description:"Private direct message using NIP-17",nip:"17",template:{kind:14,content:"",tags:[]}},{kind:15,name:"File Message",description:"File message in DMs",nip:"17",template:{kind:15,content:"",tags:[]}},{kind:16,name:"Generic Repost",description:"Repost any event kind",nip:"18",template:{kind:16,content:"",tags:[]}},{kind:17,name:"Reaction to Website",description:"Reaction to a website URL",nip:"25",template:{kind:17,content:"",tags:[]}},{kind:20,name:"Picture",description:"Picture-first feed post",nip:"68",template:{kind:20,content:"",tags:[]}},{kind:21,name:"Video Event",description:"Horizontal video event",nip:"71",template:{kind:21,content:"",tags:[]}},{kind:22,name:"Short-form Video",description:"Short-form portrait video (like TikTok)",nip:"71",template:{kind:22,content:"",tags:[]}},{kind:40,name:"Channel Creation",description:"Create a public chat channel",nip:"28",template:{kind:40,content:"",tags:[]}},{kind:41,name:"Channel Metadata",description:"Set channel name, about, picture",nip:"28",template:{kind:41,content:"",tags:[]}},{kind:42,name:"Channel Message",description:"Post message in channel",nip:"28",template:{kind:42,content:"",tags:[]}},{kind:43,name:"Channel Hide Message",description:"Hide a message in channel",nip:"28",template:{kind:43,content:"",tags:[]}},{kind:44,name:"Channel Mute User",description:"Mute a user in channel",nip:"28",template:{kind:44,content:"",tags:[]}},{kind:62,name:"Request to Vanish",description:"Request permanent deletion of all user data",nip:"62",template:{kind:62,content:"",tags:[]}},{kind:64,name:"Chess (PGN)",description:"Chess game in PGN format",nip:"64",template:{kind:64,content:"",tags:[]}},{kind:443,name:"KeyPackage",description:"Marmot protocol key package",nip:null,spec:"Marmot",template:{kind:443,content:"",tags:[]}},{kind:444,name:"Welcome Message",description:"Marmot protocol welcome message",nip:null,spec:"Marmot",template:{kind:444,content:"",tags:[]}},{kind:445,name:"Group Event",description:"Marmot protocol group event",nip:null,spec:"Marmot",template:{kind:445,content:"",tags:[]}},{kind:818,name:"Merge Requests",description:"Git merge request",nip:"54",template:{kind:818,content:"",tags:[]}},{kind:1018,name:"Poll Response",description:"Response to a poll",nip:"88",template:{kind:1018,content:"",tags:[]}},{kind:1021,name:"Bid",description:"Auction bid",nip:"15",template:{kind:1021,content:"",tags:[]}},{kind:1022,name:"Bid Confirmation",description:"Confirmation of auction bid",nip:"15",template:{kind:1022,content:"",tags:[]}},{kind:1040,name:"OpenTimestamps",description:"OpenTimestamps attestation",nip:"03",template:{kind:1040,content:"",tags:[]}},{kind:1059,name:"Gift Wrap",description:"Encrypted gift-wrapped event",nip:"59",template:{kind:1059,content:"",tags:[]}},{kind:1060,name:"Gift Wrap (Kind 4)",description:"Gift wrap variant for NIP-04 compatibility",nip:"59",template:{kind:1060,content:"",tags:[]}},{kind:1063,name:"File Metadata",description:"Metadata for shared files",nip:"94",template:{kind:1063,content:"",tags:[]}},{kind:1068,name:"Poll",description:"Create a poll",nip:"88",template:{kind:1068,content:"",tags:[]}},{kind:1111,name:"Comment",description:"Comment on events or external content",nip:"22",template:{kind:1111,content:"",tags:[]}},{kind:1222,name:"Voice Message",description:"Voice message",nip:"A0",template:{kind:1222,content:"",tags:[]}},{kind:1244,name:"Voice Message Comment",description:"Comment on voice message",nip:"A0",template:{kind:1244,content:"",tags:[]}},{kind:1311,name:"Live Chat Message",description:"Message in live stream chat",nip:"53",template:{kind:1311,content:"",tags:[]}},{kind:1337,name:"Code Snippet",description:"Code snippet post",nip:"C0",template:{kind:1337,content:"",tags:[]}},{kind:1517,name:"Bitcoin Block",description:"Bitcoin block data",nip:null,spec:"Nostrocket",template:{kind:1517,content:"",tags:[]}},{kind:1617,name:"Patches",description:"Git patches",nip:"34",template:{kind:1617,content:"",tags:[]}},{kind:1618,name:"Pull Requests",description:"Git pull request",nip:"34",template:{kind:1618,content:"",tags:[]}},{kind:1619,name:"Pull Request Updates",description:"Updates to git pull request",nip:"34",template:{kind:1619,content:"",tags:[]}},{kind:1621,name:"Issues",description:"Git issues",nip:"34",template:{kind:1621,content:"",tags:[]}},{kind:1622,name:"Git Replies",description:"Replies on git objects",nip:"34",deprecated:!0,template:{kind:1622,content:"",tags:[]}},{kind:1630,name:"Status",description:"Git status",nip:"34",template:{kind:1630,content:"",tags:[]}},{kind:1631,name:"Status",description:"Git status",nip:"34",template:{kind:1631,content:"",tags:[]}},{kind:1632,name:"Status",description:"Git status",nip:"34",template:{kind:1632,content:"",tags:[]}},{kind:1633,name:"Status",description:"Git status",nip:"34",template:{kind:1633,content:"",tags:[]}},{kind:1808,name:"Live Stream",description:"Live streaming event",nip:null,spec:"zap.stream",template:{kind:1808,content:"",tags:[]}},{kind:1971,name:"Problem Tracker",description:"Problem tracking",nip:null,spec:"Nostrocket",template:{kind:1971,content:"",tags:[]}},{kind:1984,name:"Reporting",description:"Report content or users",nip:"56",template:{kind:1984,content:"",tags:[]}},{kind:1985,name:"Label",description:"Label/tag content with namespace",nip:"32",template:{kind:1985,content:"",tags:[]}},{kind:1986,name:"Relay Reviews",description:"Reviews of relays",nip:null,template:{kind:1986,content:"",tags:[]}},{kind:1987,name:"AI Embeddings",description:"AI embeddings/vector lists",nip:null,spec:"NKBIP-02",template:{kind:1987,content:"",tags:[]}},{kind:2003,name:"Torrent",description:"Torrent magnet link",nip:"35",template:{kind:2003,content:"",tags:[]}},{kind:2004,name:"Torrent Comment",description:"Comment on torrent",nip:"35",template:{kind:2004,content:"",tags:[]}},{kind:2022,name:"Coinjoin Pool",description:"Coinjoin coordination",nip:null,spec:"joinstr",template:{kind:2022,content:"",tags:[]}},{kind:4550,name:"Community Post Approval",description:"Approve post in community",nip:"72",template:{kind:4550,content:"",tags:[]}},{kind:5e3,name:"Job Request",description:"Data vending machine job request (start of range)",nip:"90",template:{kind:5e3,content:"",tags:[]}},{kind:6e3,name:"Job Result",description:"Data vending machine job result (start of range)",nip:"90",template:{kind:6e3,content:"",tags:[]}},{kind:7e3,name:"Job Feedback",description:"Feedback on job request/result",nip:"90",template:{kind:7e3,content:"",tags:[]}},{kind:7374,name:"Reserved Cashu Wallet Tokens",description:"Reserved Cashu wallet tokens",nip:"60",template:{kind:7374,content:"",tags:[]}},{kind:7375,name:"Cashu Wallet Tokens",description:"Cashu wallet tokens",nip:"60",template:{kind:7375,content:"",tags:[]}},{kind:7376,name:"Cashu Wallet History",description:"Cashu wallet transaction history",nip:"60",template:{kind:7376,content:"",tags:[]}},{kind:7516,name:"Geocache Log",description:"Geocaching log entry",nip:null,spec:"geocaching",template:{kind:7516,content:"",tags:[]}},{kind:7517,name:"Geocache Proof of Find",description:"Proof of geocache find",nip:null,spec:"geocaching",template:{kind:7517,content:"",tags:[]}},{kind:8e3,name:"Add User",description:"Add user to group",nip:"43",template:{kind:8e3,content:"",tags:[]}},{kind:8001,name:"Remove User",description:"Remove user from group",nip:"43",template:{kind:8001,content:"",tags:[]}},{kind:9e3,name:"Group Control Events",description:"Group control events (start of range)",nip:"29",template:{kind:9e3,content:"",tags:[]}},{kind:9041,name:"Zap Goal",description:"Fundraising goal for zaps",nip:"75",template:{kind:9041,content:"",tags:[]}},{kind:9321,name:"Nutzap",description:"Cashu nutzap",nip:"61",template:{kind:9321,content:"",tags:[]}},{kind:9467,name:"Tidal Login",description:"Tidal streaming login",nip:null,spec:"Tidal-nostr",template:{kind:9467,content:"",tags:[]}},{kind:9734,name:"Zap Request",description:"Request Lightning payment",nip:"57",template:{kind:9734,content:"",tags:[]}},{kind:9735,name:"Zap",description:"Lightning payment receipt",nip:"57",template:{kind:9735,content:"",tags:[]}},{kind:9802,name:"Highlights",description:"Highlighted text selection",nip:"84",template:{kind:9802,content:"",tags:[]}},{kind:1e4,name:"Mute List",description:"List of muted users/content",nip:"51",isReplaceable:!0,template:{kind:1e4,content:"",tags:[]}},{kind:10001,name:"Pin List",description:"Pinned events",nip:"51",isReplaceable:!0,template:{kind:10001,content:"",tags:[]}},{kind:10002,name:"Relay List Metadata",description:"User's preferred relays for read/write",nip:"65",isReplaceable:!0,template:{kind:10002,content:"",tags:[]}},{kind:10003,name:"Bookmark List",description:"Bookmarked events",nip:"51",isReplaceable:!0,template:{kind:10003,content:"",tags:[]}},{kind:10004,name:"Communities List",description:"Communities user belongs to",nip:"51",isReplaceable:!0,template:{kind:10004,content:"",tags:[]}},{kind:10005,name:"Public Chats List",description:"Public chats user is in",nip:"51",isReplaceable:!0,template:{kind:10005,content:"",tags:[]}},{kind:10006,name:"Blocked Relays List",description:"Relays user has blocked",nip:"51",isReplaceable:!0,template:{kind:10006,content:"",tags:[]}},{kind:10007,name:"Search Relays List",description:"Preferred search relays",nip:"51",isReplaceable:!0,template:{kind:10007,content:"",tags:[]}},{kind:10008,name:"Relay Group Configuration",description:"Relay group configuration",nip:null,isReplaceable:!0,template:{kind:10008,content:"",tags:[]}},{kind:10009,name:"User Groups",description:"Groups user belongs to",nip:"29",isReplaceable:!0,template:{kind:10009,content:"",tags:[]}},{kind:10012,name:"Favorite Relays List",description:"User's favorite relays",nip:"51",isReplaceable:!0,template:{kind:10012,content:"",tags:[]}},{kind:10013,name:"Private Event Relay List",description:"Relays for private events",nip:"37",isReplaceable:!0,template:{kind:10013,content:"",tags:[]}},{kind:10015,name:"Interests List",description:"User interests/topics",nip:"51",isReplaceable:!0,template:{kind:10015,content:"",tags:[]}},{kind:10019,name:"Nutzap Mint Recommendation",description:"Recommended Cashu mints for nutzaps",nip:"61",isReplaceable:!0,template:{kind:10019,content:"",tags:[]}},{kind:10020,name:"Media Follows",description:"Followed media accounts",nip:"51",isReplaceable:!0,template:{kind:10020,content:"",tags:[]}},{kind:10030,name:"User Emoji List",description:"Custom emoji list",nip:"51",isReplaceable:!0,template:{kind:10030,content:"",tags:[]}},{kind:10050,name:"DM Relays List",description:"Relays to receive DMs on",nip:"17",isReplaceable:!0,template:{kind:10050,content:"",tags:[]}},{kind:10051,name:"KeyPackage Relays List",description:"Marmot key package relays",nip:null,isReplaceable:!0,spec:"Marmot",template:{kind:10051,content:"",tags:[]}},{kind:10063,name:"User Server List",description:"Blossom server list",nip:null,isReplaceable:!0,spec:"Blossom",template:{kind:10063,content:"",tags:[]}},{kind:10096,name:"File Storage Server List",description:"File storage servers",nip:"96",isReplaceable:!0,deprecated:!0,template:{kind:10096,content:"",tags:[]}},{kind:10166,name:"Relay Monitor Announcement",description:"Relay monitoring announcement",nip:"66",isReplaceable:!0,template:{kind:10166,content:"",tags:[]}},{kind:10312,name:"Room Presence",description:"Presence in live room",nip:"53",isReplaceable:!0,template:{kind:10312,content:"",tags:[]}},{kind:10377,name:"Proxy Announcement",description:"Nostr proxy announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:10377,content:"",tags:[]}},{kind:11111,name:"Transport Method Announcement",description:"Transport method announcement",nip:null,isReplaceable:!0,spec:"Nostr Epoxy",template:{kind:11111,content:"",tags:[]}},{kind:12345,name:"Relay Policy Configuration",description:"Relay-internal policy configuration (admin only)",nip:null,isReplaceable:!0,spec:"orly",template:{kind:12345,content:"",tags:[]}},{kind:13004,name:"JWT Binding",description:"Link between JWT certificate and pubkey",nip:null,isReplaceable:!0,template:{kind:13004,content:"",tags:[]}},{kind:13194,name:"Wallet Service Info",description:"NWC wallet service information",nip:"47",isReplaceable:!0,template:{kind:13194,content:"",tags:[]}},{kind:13534,name:"Membership Lists",description:"Group membership lists",nip:"43",isReplaceable:!0,template:{kind:13534,content:"",tags:[]}},{kind:14388,name:"User Sound Effect Lists",description:"Sound effect lists",nip:null,isReplaceable:!0,spec:"Corny Chat",template:{kind:14388,content:"",tags:[]}},{kind:17375,name:"Cashu Wallet Event",description:"Cashu wallet event",nip:"60",isReplaceable:!0,template:{kind:17375,content:"",tags:[]}},{kind:21e3,name:"Lightning Pub RPC",description:"Lightning.Pub RPC",nip:null,isEphemeral:!0,spec:"Lightning.Pub",template:{kind:21e3,content:"",tags:[]}},{kind:22242,name:"Client Authentication",description:"Authenticate to relay",nip:"42",isEphemeral:!0,template:{kind:22242,content:"",tags:[]}},{kind:23194,name:"Wallet Request",description:"NWC wallet request",nip:"47",isEphemeral:!0,template:{kind:23194,content:"",tags:[]}},{kind:23195,name:"Wallet Response",description:"NWC wallet response",nip:"47",isEphemeral:!0,template:{kind:23195,content:"",tags:[]}},{kind:23196,name:"Wallet Notification (NIP-04)",description:"NWC wallet notification (NIP-04 encrypted)",nip:"47",isEphemeral:!0,template:{kind:23196,content:"",tags:[]}},{kind:23197,name:"Wallet Notification",description:"NWC wallet notification",nip:"47",isEphemeral:!0,template:{kind:23197,content:"",tags:[]}},{kind:24133,name:"Nostr Connect",description:"Remote signer connection",nip:"46",isEphemeral:!0,template:{kind:24133,content:"",tags:[]}},{kind:24242,name:"Blobs Stored on Mediaservers",description:"Blossom blob storage",nip:null,isEphemeral:!0,spec:"Blossom",template:{kind:24242,content:"",tags:[]}},{kind:27235,name:"HTTP Auth",description:"Authenticate HTTP requests",nip:"98",isEphemeral:!0,template:{kind:27235,content:"",tags:[]}},{kind:28934,name:"Join Request",description:"Request to join group",nip:"43",isEphemeral:!0,template:{kind:28934,content:"",tags:[]}},{kind:28935,name:"Invite Request",description:"Invite to group",nip:"43",isEphemeral:!0,template:{kind:28935,content:"",tags:[]}},{kind:28936,name:"Leave Request",description:"Leave group request",nip:"43",isEphemeral:!0,template:{kind:28936,content:"",tags:[]}},{kind:3e4,name:"Follow Sets",description:"Categorized people lists",nip:"51",isAddressable:!0,template:{kind:3e4,content:"",tags:[["d","identifier"]]}},{kind:30001,name:"Generic Lists",description:"Generic categorized lists",nip:"51",isAddressable:!0,deprecated:!0,template:{kind:30001,content:"",tags:[["d","identifier"]]}},{kind:30002,name:"Relay Sets",description:"Categorized relay lists",nip:"51",isAddressable:!0,template:{kind:30002,content:"",tags:[["d","identifier"]]}},{kind:30003,name:"Bookmark Sets",description:"Categorized bookmark lists",nip:"51",isAddressable:!0,template:{kind:30003,content:"",tags:[["d","identifier"]]}},{kind:30004,name:"Curation Sets",description:"Curated content sets",nip:"51",isAddressable:!0,template:{kind:30004,content:"",tags:[["d","identifier"]]}},{kind:30005,name:"Video Sets",description:"Video playlists",nip:"51",isAddressable:!0,template:{kind:30005,content:"",tags:[["d","identifier"]]}},{kind:30007,name:"Kind Mute Sets",description:"Muted event kinds",nip:"51",isAddressable:!0,template:{kind:30007,content:"",tags:[["d","identifier"]]}},{kind:30008,name:"Profile Badges",description:"Badges displayed on profile",nip:"58",isAddressable:!0,template:{kind:30008,content:"",tags:[["d","identifier"]]}},{kind:30009,name:"Badge Definition",description:"Define a badge/achievement",nip:"58",isAddressable:!0,template:{kind:30009,content:"",tags:[["d","identifier"]]}},{kind:30015,name:"Interest Sets",description:"Interest/topic sets",nip:"51",isAddressable:!0,template:{kind:30015,content:"",tags:[["d","identifier"]]}},{kind:30017,name:"Stall",description:"Marketplace stall definition",nip:"15",isAddressable:!0,template:{kind:30017,content:"",tags:[["d","identifier"]]}},{kind:30018,name:"Product",description:"Marketplace product listing",nip:"15",isAddressable:!0,template:{kind:30018,content:"",tags:[["d","identifier"]]}},{kind:30019,name:"Marketplace UI/UX",description:"Marketplace interface settings",nip:"15",isAddressable:!0,template:{kind:30019,content:"",tags:[["d","identifier"]]}},{kind:30020,name:"Product Sold as Auction",description:"Auction product listing",nip:"15",isAddressable:!0,template:{kind:30020,content:"",tags:[["d","identifier"]]}},{kind:30023,name:"Long-form Content",description:"Blog post, article in markdown",nip:"23",isAddressable:!0,template:{kind:30023,content:"",tags:[["d","identifier"]]}},{kind:30024,name:"Draft Long-form Content",description:"Draft article",nip:"23",isAddressable:!0,template:{kind:30024,content:"",tags:[["d","identifier"]]}},{kind:30030,name:"Emoji Sets",description:"Custom emoji sets",nip:"51",isAddressable:!0,template:{kind:30030,content:"",tags:[["d","identifier"]]}},{kind:30040,name:"Curated Publication Index",description:"Publication index",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30040,content:"",tags:[["d","identifier"]]}},{kind:30041,name:"Curated Publication Content",description:"Publication content",nip:null,isAddressable:!0,spec:"NKBIP-01",template:{kind:30041,content:"",tags:[["d","identifier"]]}},{kind:30063,name:"Release Artifact Sets",description:"Software release artifacts",nip:"51",isAddressable:!0,template:{kind:30063,content:"",tags:[["d","identifier"]]}},{kind:30078,name:"Application-specific Data",description:"App-specific key-value storage",nip:"78",isAddressable:!0,template:{kind:30078,content:"",tags:[["d","identifier"]]}},{kind:30166,name:"Relay Discovery",description:"Relay discovery/monitoring",nip:"66",isAddressable:!0,template:{kind:30166,content:"",tags:[["d","identifier"]]}},{kind:30267,name:"App Curation Sets",description:"Curated app sets",nip:"51",isAddressable:!0,template:{kind:30267,content:"",tags:[["d","identifier"]]}},{kind:30311,name:"Live Event",description:"Live streaming event",nip:"53",isAddressable:!0,template:{kind:30311,content:"",tags:[["d","identifier"]]}},{kind:30312,name:"Interactive Room",description:"Interactive live room",nip:"53",isAddressable:!0,template:{kind:30312,content:"",tags:[["d","identifier"]]}},{kind:30313,name:"Conference Event",description:"Conference/meetup event",nip:"53",isAddressable:!0,template:{kind:30313,content:"",tags:[["d","identifier"]]}},{kind:30315,name:"User Statuses",description:"User status updates",nip:"38",isAddressable:!0,template:{kind:30315,content:"",tags:[["d","identifier"]]}},{kind:30388,name:"Slide Set",description:"Presentation slides",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:30388,content:"",tags:[["d","identifier"]]}},{kind:30402,name:"Classified Listing",description:"Classified ad listing",nip:"99",isAddressable:!0,template:{kind:30402,content:"",tags:[["d","identifier"]]}},{kind:30403,name:"Draft Classified Listing",description:"Draft classified ad",nip:"99",isAddressable:!0,template:{kind:30403,content:"",tags:[["d","identifier"]]}},{kind:30617,name:"Repository Announcements",description:"Git repository announcement",nip:"34",isAddressable:!0,template:{kind:30617,content:"",tags:[["d","identifier"]]}},{kind:30618,name:"Repository State Announcements",description:"Git repository state",nip:"34",isAddressable:!0,template:{kind:30618,content:"",tags:[["d","identifier"]]}},{kind:30818,name:"Wiki Article",description:"Wiki article",nip:"54",isAddressable:!0,template:{kind:30818,content:"",tags:[["d","identifier"]]}},{kind:30819,name:"Redirects",description:"URL redirects",nip:"54",isAddressable:!0,template:{kind:30819,content:"",tags:[["d","identifier"]]}},{kind:31234,name:"Draft Event",description:"Draft of any event",nip:"37",isAddressable:!0,template:{kind:31234,content:"",tags:[["d","identifier"]]}},{kind:31388,name:"Link Set",description:"Link collection",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:31388,content:"",tags:[["d","identifier"]]}},{kind:31890,name:"Feed",description:"Custom feed definition",nip:null,isAddressable:!0,spec:"NUD: Custom Feeds",template:{kind:31890,content:"",tags:[["d","identifier"]]}},{kind:31922,name:"Date-Based Calendar Event",description:"All-day calendar event",nip:"52",isAddressable:!0,template:{kind:31922,content:"",tags:[["d","identifier"]]}},{kind:31923,name:"Time-Based Calendar Event",description:"Calendar event with time",nip:"52",isAddressable:!0,template:{kind:31923,content:"",tags:[["d","identifier"]]}},{kind:31924,name:"Calendar",description:"Calendar definition",nip:"52",isAddressable:!0,template:{kind:31924,content:"",tags:[["d","identifier"]]}},{kind:31925,name:"Calendar Event RSVP",description:"RSVP to calendar event",nip:"52",isAddressable:!0,template:{kind:31925,content:"",tags:[["d","identifier"]]}},{kind:31989,name:"Handler Recommendation",description:"Recommended app for event kind",nip:"89",isAddressable:!0,template:{kind:31989,content:"",tags:[["d","identifier"]]}},{kind:31990,name:"Handler Information",description:"App handler declaration",nip:"89",isAddressable:!0,template:{kind:31990,content:"",tags:[["d","identifier"]]}},{kind:32123,name:"WaveLake Track",description:"WaveLake music track",nip:null,isAddressable:!0,spec:"WaveLake",template:{kind:32123,content:"",tags:[["d","identifier"]]}},{kind:32267,name:"Software Application",description:"Software application listing",nip:null,isAddressable:!0,template:{kind:32267,content:"",tags:[["d","identifier"]]}},{kind:32388,name:"User Room Favorites",description:"Favorite rooms",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:32388,content:"",tags:[["d","identifier"]]}},{kind:33388,name:"High Scores",description:"Game high scores",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:33388,content:"",tags:[["d","identifier"]]}},{kind:34235,name:"Video Event Horizontal",description:"Horizontal video event",nip:"71",isAddressable:!0,template:{kind:34235,content:"",tags:[["d","identifier"]]}},{kind:34236,name:"Video Event Vertical",description:"Vertical video event",nip:"71",isAddressable:!0,template:{kind:34236,content:"",tags:[["d","identifier"]]}},{kind:34388,name:"Sound Effects",description:"Sound effect definitions",nip:null,isAddressable:!0,spec:"Corny Chat",template:{kind:34388,content:"",tags:[["d","identifier"]]}},{kind:34550,name:"Community Definition",description:"Define a community",nip:"72",isAddressable:!0,template:{kind:34550,content:"",tags:[["d","identifier"]]}},{kind:37516,name:"Geocache Listing",description:"Geocache location listing",nip:null,isAddressable:!0,spec:"geocaching",template:{kind:37516,content:"",tags:[["d","identifier"]]}},{kind:38172,name:"Cashu Mint Announcement",description:"Cashu mint announcement",nip:"87",isAddressable:!0,template:{kind:38172,content:"",tags:[["d","identifier"]]}},{kind:38173,name:"Fedimint Announcement",description:"Fedimint announcement",nip:"87",isAddressable:!0,template:{kind:38173,content:"",tags:[["d","identifier"]]}},{kind:38383,name:"Peer-to-peer Order Events",description:"P2P trading orders",nip:"69",isAddressable:!0,template:{kind:38383,content:"",tags:[["d","identifier"]]}},{kind:39e3,name:"Group Metadata Events",description:"Group metadata (start of range)",nip:"29",isAddressable:!0,template:{kind:39e3,content:"",tags:[["d","identifier"]]}},{kind:39089,name:"Starter Packs",description:"Starter pack lists",nip:"51",isAddressable:!0,template:{kind:39089,content:"",tags:[["d","identifier"]]}},{kind:39092,name:"Media Starter Packs",description:"Media starter packs",nip:"51",isAddressable:!0,template:{kind:39092,content:"",tags:[["d","identifier"]]}},{kind:39701,name:"Web Bookmarks",description:"Web URL bookmarks",nip:"B0",isAddressable:!0,template:{kind:39701,content:"",tags:[["d","identifier"]]}},{kind:39998,name:"ACL Event",description:"Access control list event",nip:null,isAddressable:!0,template:{kind:39998,content:"",tags:[["d","identifier"]]}}];function _y(e,t=null){const n=function(e){return Ny.find(t=>t.kind===e)}(e);return n?{...n.template,created_at:Math.floor(Date.now()/1e3),pubkey:t||""}:{kind:e,content:"",tags:[],created_at:Math.floor(Date.now()/1e3),pubkey:t||""}}const Ly=[{id:"all",name:"All Kinds",filter:()=>!0},{id:"regular",name:"Regular Events (0-9999)",filter:e=>e.kind<1e4&&!e.isReplaceable},{id:"replaceable",name:"Replaceable (10000-19999)",filter:e=>e.isReplaceable},{id:"ephemeral",name:"Ephemeral (20000-29999)",filter:e=>e.isEphemeral},{id:"addressable",name:"Addressable (30000-39999)",filter:e=>e.isAddressable},{id:"social",name:"Social",filter:e=>[0,1,3,6,7].includes(e.kind)},{id:"messaging",name:"Messaging",filter:e=>[4,9,10,11,12,14,15,40,41,42].includes(e.kind)},{id:"lists",name:"Lists",filter:e=>e.name.toLowerCase().includes("list")||e.name.toLowerCase().includes("set")},{id:"marketplace",name:"Marketplace",filter:e=>[30017,30018,30019,30020,1021,1022,30402,30403].includes(e.kind)},{id:"lightning",name:"Lightning/Zaps",filter:e=>[9734,9735,9041,9321,7374,7375,7376].includes(e.kind)},{id:"media",name:"Media",filter:e=>[20,21,22,1063,1222,1244].includes(e.kind)},{id:"git",name:"Git/Code",filter:e=>[818,1337,1617,1618,1619,1621,1622,30617,30618].includes(e.kind)},{id:"calendar",name:"Calendar",filter:e=>[31922,31923,31924,31925].includes(e.kind)},{id:"groups",name:"Groups",filter:e=>e.kind>=9e3&&e.kind<=9030||e.kind>=39e3&&e.kind<=39009}];function My(e,t,n){const i=e.slice();return i[13]=t[n],i}function Oy(e,t,n){const i=e.slice();return i[16]=t[n],i}function jy(e){let t,n,r,s,o,l,a,c,u,d,y,b,k,C,S,B,Q,F,$,D,R,P,T,U,N,_=e[3].length+"",L=1!==e[3].length?"s":"",M=Ly,O=[];for(let t=0;t=2e4&&e.kind<3e4?"badge-ephemeral":"badge-regular"}function zy(e){return e.isAddressable?"Addressable":e.isReplaceable?"Replaceable":e.kind>=2e4&&e.kind<3e4?"Ephemeral":"Regular"}function Wy(e,t,n){let{isOpen:i=!1}=t,{userPubkey:r=""}=t;const s=U();let o="",l="all",a=Ny;function c(e){const t=_y(e.kind,r);s("select",{kind:e,template:t}),u()}function u(){n(0,i=!1),n(1,o=""),n(2,l="all"),s("close")}return e.$$set=e=>{"isOpen"in e&&n(0,i=e.isOpen),"userPubkey"in e&&n(8,r=e.userPubkey)},e.$$.update=()=>{if(6&e.$$.dirty){let e=Ny;const t=Ly.find(e=>e.id===l);if(t&&(e=e.filter(t.filter)),o.trim()){const t=o.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.kind.toString().includes(t)||e.nip&&e.nip.includes(t))}n(3,a=e)}},[i,o,l,a,c,u,function(e){"Escape"===e.key&&u()},function(e){e.target===e.currentTarget&&u()},r,function(){o=this.value,n(1,o)},e=>n(2,l=e.id),e=>c(e)]}class Zy extends ae{constructor(e){super(),le(this,e,Wy,Vy,s,{isOpen:0,userPubkey:8})}}function Xy(e){let t,n,i,r,s,o,l,a,c,u;return{c(){t=m("div"),n=m("div"),i=m("span"),i.textContent="⚠",r=w(),s=m("span"),o=v(e[1]),l=w(),a=m("button"),a.textContent="×",I(i,"class","error-icon svelte-1gh9ysu"),I(s,"class","error-message svelte-1gh9ysu"),I(n,"class","error-content svelte-1gh9ysu"),I(a,"class","error-dismiss svelte-1gh9ysu"),I(t,"class","error-banner svelte-1gh9ysu")},m(d,h){p(d,t,h),f(t,n),f(n,i),f(n,r),f(n,s),f(s,o),f(t,l),f(t,a),c||(u=A(a,"click",e[10]),c=!0)},p(e,t){2&t&&E(o,e[1])},d(e){e&&h(t),c=!1,u()}}}function ev(e){let t,n,r,s,o,l,a,c,u,d,g,y,v,b,k,C,E,S,B,Q=e[1]&&Xy(e);function F(t){e[14](t)}let $={userPubkey:e[2]};return void 0!==e[3]&&($.isOpen=e[3]),k=new Zy({props:$}),L.push(()=>ne(k,"isOpen",F)),k.$on("select",e[8]),k.$on("close",e[9]),{c(){t=m("div"),n=m("div"),r=m("button"),r.textContent="Generate Template",s=w(),o=m("button"),o.textContent="Reformat",l=w(),a=m("button"),a.textContent="Sign",c=w(),u=m("button"),u.textContent="Publish",d=w(),Q&&Q.c(),g=w(),y=m("div"),v=m("textarea"),b=w(),ie(k.$$.fragment),I(r,"class","compose-btn template-btn svelte-1gh9ysu"),I(o,"class","compose-btn reformat-btn svelte-1gh9ysu"),I(a,"class","compose-btn sign-btn svelte-1gh9ysu"),I(u,"class","compose-btn publish-btn svelte-1gh9ysu"),I(n,"class","compose-header svelte-1gh9ysu"),I(v,"class","compose-textarea svelte-1gh9ysu"),I(v,"placeholder","Enter your Nostr event JSON here, or click 'Generate Template' to start with a template..."),I(v,"spellcheck","false"),I(y,"class","compose-editor svelte-1gh9ysu"),I(t,"class","compose-view svelte-1gh9ysu")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(n,l),f(n,a),f(n,c),f(n,u),f(t,d),Q&&Q.m(t,null),f(t,g),f(t,y),f(y,v),x(v,e[0]),p(i,b,h),re(k,i,h),E=!0,S||(B=[A(r,"click",e[7]),A(o,"click",e[4]),A(a,"click",e[5]),A(u,"click",e[6]),A(v,"input",e[13])],S=!0)},p(e,[n]){e[1]?Q?Q.p(e,n):(Q=Xy(e),Q.c(),Q.m(t,g)):Q&&(Q.d(1),Q=null),1&n&&x(v,e[0]);const i={};4&n&&(i.userPubkey=e[2]),!C&&8&n&&(C=!0,i.isOpen=e[3],q(()=>C=!1)),k.$set(i)},i(e){E||(ee(k.$$.fragment,e),E=!0)},o(e){te(k.$$.fragment,e),E=!1},d(e){e&&h(t),Q&&Q.d(),e&&h(b),se(k,e),S=!1,i(B)}}}function tv(e,t,n){let{composeEventJson:i=""}=t,{userPubkey:r=""}=t,{userRole:s=""}=t,{policyEnabled:o=!1}=t,{publishError:l=""}=t;const a=U();let c=!1;return e.$$set=e=>{"composeEventJson"in e&&n(0,i=e.composeEventJson),"userPubkey"in e&&n(2,r=e.userPubkey),"userRole"in e&&n(11,s=e.userRole),"policyEnabled"in e&&n(12,o=e.policyEnabled),"publishError"in e&&n(1,l=e.publishError)},[i,l,r,c,function(){a("reformatJson")},function(){a("signEvent")},function(){a("publishEvent")},function(){n(3,c=!0)},function(e){const{kind:t,template:r}=e.detail;n(0,i=JSON.stringify(r,null,2)),a("templateSelected",{kind:t,template:r})},function(){n(3,c=!1)},function(){n(1,l=""),a("clearError")},s,o,function(){i=this.value,n(0,i)},function(e){c=e,n(3,c)}]}class nv extends ae{constructor(e){super(),le(this,e,tv,ev,s,{composeEventJson:0,userPubkey:2,userRole:11,policyEnabled:12,publishError:1})}}function iv(e,t,n){const i=e.slice();return i[23]=t[n],i}function rv(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access sprocket management.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-fiaj1r"),I(s,"class","login-btn svelte-fiaj1r"),I(n,"class","login-prompt svelte-fiaj1r")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[18]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function sv(e){let t,n,i,r,s,o,l,a,c,u=(e[2]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="❌ Owner permission required for sprocket management.",i=w(),r=m("p"),r.innerHTML='To enable sprocket functionality, set the ORLY_OWNERS environment variable with your npub when starting the relay.',s=w(),o=m("p"),l=v("Current user role: "),a=m("strong"),c=v(u),I(n,"class","svelte-fiaj1r"),I(r,"class","svelte-fiaj1r"),I(o,"class","svelte-fiaj1r"),I(t,"class","permission-denied svelte-fiaj1r")},m(e,u){p(e,t,u),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(o,a),f(a,c)},p(e,t){4&t&&u!==(u=(e[2]||"none")+"")&&E(c,u)},d(e){e&&h(t)}}}function ov(e){let t,n,r,s,o,l,a,c,u,d,y,b,k,C,S,B,Q,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te,ne,ie,re,se,oe,le,ae,ce,ue,de,fe,pe,he,ge,me=e[3]?.is_running?"🟢 Running":"🔴 Stopped",ye=e[3]?.script_exists?"✅ Exists":"❌ Not found",ve=e[3]?.pid&&lv(e),we=e[6]&&av(e),be=e[8],Ae=[];for(let t=0;t{"isLoggedIn"in e&&n(1,i=e.isLoggedIn),"userRole"in e&&n(2,r=e.userRole),"sprocketStatus"in e&&n(3,s=e.sprocketStatus),"isLoadingSprocket"in e&&n(4,o=e.isLoadingSprocket),"sprocketUploadFile"in e&&n(5,l=e.sprocketUploadFile),"sprocketScript"in e&&n(0,a=e.sprocketScript),"sprocketMessage"in e&&n(6,c=e.sprocketMessage),"sprocketMessageType"in e&&n(7,u=e.sprocketMessageType),"sprocketVersions"in e&&n(8,d=e.sprocketVersions)},[a,i,r,s,o,l,c,u,d,function(){f("restartSprocket")},function(){f("deleteSprocket")},function(e){f("sprocketFileSelect",e)},function(){f("uploadSprocketScript")},function(){f("saveSprocket")},function(){f("loadSprocket")},function(){f("loadVersions")},p,h,function(){f("openLoginModal")},function(){a=this.value,n(0,a)},e=>p(e),e=>h(e.name)]}class hv extends ae{constructor(e){super(),le(this,e,pv,fv,s,{isLoggedIn:1,userRole:2,sprocketStatus:3,isLoadingSprocket:4,sprocketUploadFile:5,sprocketScript:0,sprocketMessage:6,sprocketMessageType:7,sprocketVersions:8})}}function gv(e,t,n){const i=e.slice();return i[26]=t[n],i}function mv(e,t,n){const i=e.slice();return i[29]=t[n],i}function yv(e,t,n){const i=e.slice();return i[32]=t[n],i}function vv(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to access policy configuration.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-gkxvxc"),I(s,"class","login-btn svelte-gkxvxc"),I(n,"class","login-prompt svelte-gkxvxc")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[16]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function wv(e){let t,n,i,r,s,o,l,a,c,u=(e[3]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="Policy configuration requires owner or policy admin permissions.",i=w(),r=m("p"),r.innerHTML='To become a policy admin, ask an existing policy admin to add your pubkey\n to the policy_admins list.',s=w(),o=m("p"),l=v("Current user role: "),a=m("strong"),c=v(u),I(n,"class","svelte-gkxvxc"),I(r,"class","svelte-gkxvxc"),I(o,"class","svelte-gkxvxc"),I(t,"class","permission-denied svelte-gkxvxc")},m(e,u){p(e,t,u),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(o,a),f(a,c)},p(e,t){8&t[0]&&u!==(u=(e[3]||"none")+"")&&E(c,u)},d(e){e&&h(t)}}}function bv(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,S,B,Q,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te,ne,ie,re,se,oe,le,ae,ce,ue,de,fe,pe,he,ge,me,ye,ve,we,be,Ae,ke,Ie,Ce,Ee,xe,Se,Be,Qe,Fe,$e,De,Re,Pe=e[5]?"Policy Enabled":"Policy Disabled",Te=e[10].length+"",Ue=e[4]&&Av(),Ne=e[9].length>0&&kv(e),_e=e[7]&&Cv(e);function Le(e,t){return 0===e[1].length?xv:Ev}let Me=Le(e),Oe=Me(e);function je(e,t){return 0===e[10].length?Qv:Bv}let He=je(e),Ge=He(e);return{c(){t=m("div"),n=m("div"),r=m("h3"),r.textContent="Policy Editor",s=w(),o=m("div"),l=m("span"),a=v(Pe),c=w(),Ue&&Ue.c(),u=w(),d=m("div"),d.innerHTML='

    Edit the policy JSON below and click "Save & Publish" to update the relay's policy configuration.\n Changes are applied immediately after validation.

    \n

    Policy updates are published as kind 12345 events and require policy admin permissions.

    ',g=w(),y=m("div"),b=m("textarea"),k=w(),Ne&&Ne.c(),C=w(),S=m("div"),B=m("button"),Q=v("Load Current"),$=w(),D=m("button"),R=v("Format JSON"),P=w(),T=m("button"),U=v("Validate"),N=w(),_=m("button"),L=v("Save & Publish"),M=w(),_e&&_e.c(),O=w(),j=m("div"),H=m("h3"),H.textContent="Policy Administrators",G=w(),q=m("div"),q.innerHTML='

    Policy admins can update the relay's policy configuration via kind 12345 events.\n Their follows get whitelisted if policy_follow_whitelist_enabled is true in the policy.

    \n

    Note: Policy admins are separate from relay admins (ORLY_ADMINS).\n Changes here update the JSON editor - click "Save & Publish" to apply.

    ',J=w(),K=m("div"),Oe.c(),V=w(),Y=m("div"),z=m("input"),W=w(),Z=m("button"),X=v("+ Add Admin"),te=w(),ne=m("div"),ie=m("h3"),ie.textContent="Policy Follow Whitelist",re=w(),se=m("div"),se.innerHTML='

    Pubkeys followed by policy admins (kind 3 events).\n These get automatic read+write access when rules have write_allow_follows: true.

    ',oe=w(),le=m("div"),ae=m("span"),ce=v(Te),ue=v(" pubkey(s) in whitelist"),de=w(),fe=m("button"),pe=v("🔄 Refresh Follows"),he=w(),ge=m("div"),Ge.c(),me=w(),ye=m("div"),ve=m("h3"),ve.textContent="Policy Reference",we=w(),be=m("div"),Ae=m("h4"),Ae.textContent="Structure Overview",ke=w(),Ie=m("ul"),Ie.innerHTML='
  • kind.whitelist - Only allow these event kinds (takes precedence)
  • \n
  • kind.blacklist - Deny these event kinds (if no whitelist)
  • \n
  • global - Rules applied to all events
  • \n
  • rules - Per-kind rules (keyed by kind number as string)
  • \n
  • default_policy - "allow" or "deny" when no rules match
  • \n
  • policy_admins - Hex pubkeys that can update policy
  • \n
  • policy_follow_whitelist_enabled - Enable follow-based access
  • ',Ce=w(),Ee=m("h4"),Ee.textContent="Rule Fields",xe=w(),Se=m("ul"),Se.innerHTML='
  • description - Human-readable rule description
  • \n
  • write_allow / write_deny - Pubkey lists for write access
  • \n
  • read_allow / read_deny - Pubkey lists for read access
  • \n
  • write_allow_follows - Grant access to policy admin follows
  • \n
  • size_limit - Max total event size in bytes
  • \n
  • content_limit - Max content field size in bytes
  • \n
  • max_expiry - Max expiry offset in seconds
  • \n
  • max_age_of_event - Max age of created_at in seconds
  • \n
  • max_age_event_in_future - Max future offset in seconds
  • \n
  • must_have_tags - Required tag letters (e.g., ["d", "t"])
  • \n
  • tag_validation - Regex patterns for tag values
  • \n
  • script - Path to external validation script
  • ',Be=w(),Qe=m("h4"),Qe.textContent="Example Policy",Fe=w(),$e=m("pre"),$e.textContent=`${e[20]}`,I(r,"class","svelte-gkxvxc"),I(l,"class","status-badge svelte-gkxvxc"),F(l,"enabled",e[5]),I(o,"class","policy-status svelte-gkxvxc"),I(n,"class","policy-header svelte-gkxvxc"),I(d,"class","policy-info svelte-gkxvxc"),I(b,"class","policy-editor svelte-gkxvxc"),I(b,"placeholder","Loading policy configuration..."),b.disabled=e[6],I(b,"spellcheck","false"),I(y,"class","editor-container svelte-gkxvxc"),I(B,"class","policy-btn load-btn svelte-gkxvxc"),B.disabled=e[6],I(D,"class","policy-btn format-btn svelte-gkxvxc"),D.disabled=e[6],I(T,"class","policy-btn validate-btn svelte-gkxvxc"),T.disabled=e[6],I(_,"class","policy-btn save-btn svelte-gkxvxc"),_.disabled=e[6],I(S,"class","policy-actions svelte-gkxvxc"),I(t,"class","policy-section svelte-gkxvxc"),I(q,"class","policy-info svelte-gkxvxc"),I(K,"class","admin-list svelte-gkxvxc"),I(z,"type","text"),I(z,"placeholder","npub or hex pubkey"),z.disabled=e[6],I(z,"class","svelte-gkxvxc"),I(Z,"class","policy-btn add-btn svelte-gkxvxc"),Z.disabled=ee=e[6]||!e[11].trim(),I(Y,"class","add-admin svelte-gkxvxc"),I(j,"class","policy-section svelte-gkxvxc"),I(se,"class","policy-info svelte-gkxvxc"),I(ae,"class","follows-count svelte-gkxvxc"),I(fe,"class","policy-btn refresh-btn svelte-gkxvxc"),fe.disabled=e[6],I(le,"class","follows-header svelte-gkxvxc"),I(ge,"class","follows-list svelte-gkxvxc"),I(ne,"class","policy-section svelte-gkxvxc"),I(Ae,"class","svelte-gkxvxc"),I(Ie,"class","field-list svelte-gkxvxc"),I(Ee,"class","svelte-gkxvxc"),I(Se,"class","field-list svelte-gkxvxc"),I(Qe,"class","svelte-gkxvxc"),I($e,"class","example-json svelte-gkxvxc"),I(be,"class","reference-content svelte-gkxvxc"),I(ye,"class","policy-section svelte-gkxvxc")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(o,c),Ue&&Ue.m(o,null),f(t,u),f(t,d),f(t,g),f(t,y),f(y,b),x(b,e[0]),f(t,k),Ne&&Ne.m(t,null),f(t,C),f(t,S),f(S,B),f(B,Q),f(S,$),f(S,D),f(D,R),f(S,P),f(S,T),f(T,U),f(S,N),f(S,_),f(_,L),f(t,M),_e&&_e.m(t,null),p(i,O,h),p(i,j,h),f(j,H),f(j,G),f(j,q),f(j,J),f(j,K),Oe.m(K,null),f(j,V),f(j,Y),f(Y,z),x(z,e[11]),f(Y,W),f(Y,Z),f(Z,X),p(i,te,h),p(i,ne,h),f(ne,ie),f(ne,re),f(ne,se),f(ne,oe),f(ne,le),f(le,ae),f(ae,ce),f(ae,ue),f(le,de),f(le,fe),f(fe,pe),f(ne,he),f(ne,ge),Ge.m(ge,null),p(i,me,h),p(i,ye,h),f(ye,ve),f(ye,we),f(ye,be),f(be,Ae),f(be,ke),f(be,Ie),f(be,Ce),f(be,Ee),f(be,xe),f(be,Se),f(be,Be),f(be,Qe),f(be,Fe),f(be,$e),De||(Re=[A(b,"input",e[21]),A(B,"click",e[12]),A(D,"click",e[15]),A(T,"click",e[13]),A(_,"click",e[14]),A(z,"input",e[23]),A(z,"keydown",e[24]),A(Z,"click",e[18]),A(fe,"click",e[17])],De=!0)},p(e,n){32&n[0]&&Pe!==(Pe=e[5]?"Policy Enabled":"Policy Disabled")&&E(a,Pe),32&n[0]&&F(l,"enabled",e[5]),e[4]?Ue||(Ue=Av(),Ue.c(),Ue.m(o,null)):Ue&&(Ue.d(1),Ue=null),64&n[0]&&(b.disabled=e[6]),1&n[0]&&x(b,e[0]),e[9].length>0?Ne?Ne.p(e,n):(Ne=kv(e),Ne.c(),Ne.m(t,C)):Ne&&(Ne.d(1),Ne=null),64&n[0]&&(B.disabled=e[6]),64&n[0]&&(D.disabled=e[6]),64&n[0]&&(T.disabled=e[6]),64&n[0]&&(_.disabled=e[6]),e[7]?_e?_e.p(e,n):(_e=Cv(e),_e.c(),_e.m(t,null)):_e&&(_e.d(1),_e=null),Me===(Me=Le(e))&&Oe?Oe.p(e,n):(Oe.d(1),Oe=Me(e),Oe&&(Oe.c(),Oe.m(K,null))),64&n[0]&&(z.disabled=e[6]),2048&n[0]&&z.value!==e[11]&&x(z,e[11]),2112&n[0]&&ee!==(ee=e[6]||!e[11].trim())&&(Z.disabled=ee),1024&n[0]&&Te!==(Te=e[10].length+"")&&E(ce,Te),64&n[0]&&(fe.disabled=e[6]),He===(He=je(e))&&Ge?Ge.p(e,n):(Ge.d(1),Ge=He(e),Ge&&(Ge.c(),Ge.m(ge,null)))},d(e){e&&h(t),Ue&&Ue.d(),Ne&&Ne.d(),_e&&_e.d(),e&&h(O),e&&h(j),Oe.d(),e&&h(te),e&&h(ne),Ge.d(),e&&h(me),e&&h(ye),De=!1,i(Re)}}}function Av(e){let t;return{c(){t=m("span"),t.textContent="Policy Admin",I(t,"class","admin-badge svelte-gkxvxc")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function kv(e){let t,n,i,r,s=e[9],o=[];for(let t=0;t{"isLoggedIn"in e&&n(2,i=e.isLoggedIn),"userRole"in e&&n(3,r=e.userRole),"isPolicyAdmin"in e&&n(4,s=e.isPolicyAdmin),"policyEnabled"in e&&n(5,o=e.policyEnabled),"policyJson"in e&&n(0,l=e.policyJson),"isLoadingPolicy"in e&&n(6,a=e.isLoadingPolicy),"policyMessage"in e&&n(7,c=e.policyMessage),"policyMessageType"in e&&n(8,u=e.policyMessageType),"validationErrors"in e&&n(9,d=e.validationErrors),"policyAdmins"in e&&n(1,f=e.policyAdmins),"policyFollows"in e&&n(10,p=e.policyFollows)},e.$$.update=()=>{if(1&e.$$.dirty[0])try{if(l){const e=JSON.parse(l);n(1,f=e.policy_admins||[])}}catch(e){}},[l,f,i,r,s,o,a,c,u,d,p,g,function(){h("loadPolicy")},function(){h("validatePolicy")},function(){h("savePolicy")},function(){h("formatJson")},function(){h("openLoginModal")},function(){h("refreshFollows")},m,y,'{\n "kind": {\n "whitelist": [0, 1, 3, 6, 7, 10002],\n "blacklist": []\n },\n "global": {\n "description": "Global rules applied to all events",\n "size_limit": 65536,\n "max_age_of_event": 86400,\n "max_age_event_in_future": 300\n },\n "rules": {\n "1": {\n "description": "Kind 1 (short text notes)",\n "content_limit": 8192,\n "write_allow_follows": true\n },\n "30023": {\n "description": "Long-form articles",\n "content_limit": 100000,\n "tag_validation": {\n "d": "^[a-z0-9-]{1,64}$",\n "t": "^[a-z0-9-]{1,32}$"\n }\n }\n },\n "default_policy": "allow",\n "policy_admins": [""],\n "policy_follow_whitelist_enabled": true\n}',function(){l=this.value,n(0,l)},e=>y(e),function(){g=this.value,n(11,g)},e=>"Enter"===e.key&&m()]}class Rv extends ae{constructor(e){super(),le(this,e,Dv,$v,s,{isLoggedIn:2,userRole:3,isPolicyAdmin:4,policyEnabled:5,policyJson:0,isLoadingPolicy:6,policyMessage:7,policyMessageType:8,validationErrors:9,policyAdmins:1,policyFollows:10},null,[-1,-1])}}const Pv=[{id:"social",name:"Social/Notes",description:"User profiles, notes, follows, reposts, reactions, and relay lists",kinds:[0,1,3,6,7,10002]},{id:"dm",name:"Direct Messages",description:"Encrypted direct messages (legacy and NIP-17 gift-wrapped)",kinds:[4,14,1059]},{id:"longform",name:"Long-form Content",description:"Blog posts and article drafts",kinds:[30023,30024]},{id:"media",name:"Media",description:"File metadata and media attachments",kinds:[1063,20,21,22]},{id:"marketplace_nip15",name:"Marketplace (NIP-15)",description:"Legacy NIP-15 stalls and products",kinds:[30017,30018,30019,30020]},{id:"marketplace_nip99",name:"Marketplace (NIP-99/Gamma)",description:"NIP-99 classified listings, collections, shipping, reviews (Plebeian Market)",kinds:[30402,30403,30405,30406,31555]},{id:"order_communication",name:"Order Communication",description:"Gamma Markets order messages and payment receipts (kinds 16, 17)",kinds:[16,17]},{id:"groups_nip29",name:"Group Messaging (NIP-29)",description:"Simple relay-based group chat messages",kinds:[9,10,11,12]},{id:"groups_nip72",name:"Communities (NIP-72)",description:"Community definitions and threaded discussions",kinds:[34550,1111,4550]},{id:"lists",name:"Lists/Bookmarks",description:"Mute lists, pin lists, and parameterized list events",kinds:[1e4,10001,3e4,30001]}];function Tv(e,t,n){const i=e.slice();return i[90]=t[n],i}function Uv(e,t,n){const i=e.slice();return i[98]=t[n],i}function Nv(e,t,n){const i=e.slice();return i[93]=t[n],i}function _v(e,t,n){const i=e.slice();return i[103]=t[n],i}function Lv(e,t,n){const i=e.slice();return i[106]=t[n],i}function Mv(e,t,n){const i=e.slice();return i[106]=t[n],i}function Ov(e,t,n){const i=e.slice();return i[93]=t[n],i}function jv(e,t,n){const i=e.slice();return i[90]=t[n],i}function Hv(e){let t,n,i;return{c(){t=m("div"),n=v(e[2]),I(t,"class",i="message "+e[3]+" svelte-1i0huu3")},m(e,i){p(e,t,i),f(t,n)},p(e,r){4&r[0]&&E(n,e[2]),8&r[0]&&i!==(i="message "+e[3]+" svelte-1i0huu3")&&I(t,"class",i)},d(e){e&&h(t)}}}function Gv(e){let t;function n(e,t){return e[5]?Kv:Jv}let i=n(e),r=i(e);return{c(){r.c(),t=b()},m(e,n){r.m(e,n),p(e,t,n)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t.parentNode,t)))},d(e){r.d(e),e&&h(t)}}}function qv(e){let t,n,r,s,o,l,a,c,u,d,y,v,b,k,E,S,B,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X=Pv,ee=[];for(let t=0;tInitial Configuration \n

    Configure curating mode before the relay will accept events. Select which event kinds to allow and set rate limiting parameters.

    ',r=w(),s=m("div"),o=m("h4"),o.textContent="Allowed Event Kinds",l=w(),a=m("p"),a.textContent="Select categories of events to allow. At least one must be selected.",c=w(),u=m("div");for(let e=0;e0?zv:Yv}let B=S(e),Q=B(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Trusted Publishers",r=w(),s=m("p"),s.textContent="Trusted users can publish unlimited events without rate limiting.",o=w(),l=m("div"),a=m("input"),c=w(),u=m("input"),d=w(),g=m("button"),y=v("Trust"),b=w(),k=m("div"),Q.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(a,"type","text"),I(a,"placeholder","Pubkey (64 hex chars)"),I(a,"class","svelte-1i0huu3"),I(u,"type","text"),I(u,"placeholder","Note (optional)"),I(u,"class","svelte-1i0huu3"),g.disabled=e[1],I(g,"class","svelte-1i0huu3"),I(l,"class","add-form svelte-1i0huu3"),I(k,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a),x(a,e[13]),f(l,c),f(l,u),x(u,e[14]),f(l,d),f(l,g),f(g,y),f(t,b),f(t,k),Q.m(k,null),C||(E=[A(a,"input",e[58]),A(u,"input",e[59]),A(g,"click",e[60])],C=!0)},p(e,t){8192&t[0]&&a.value!==e[13]&&x(a,e[13]),16384&t[0]&&u.value!==e[14]&&x(u,e[14]),2&t[0]&&(g.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(k,null)))},d(e){e&&h(t),Q.d(),C=!1,i(E)}}}function Yv(t){let n;return{c(){n=m("div"),n.textContent="No trusted pubkeys yet.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function zv(e){let t,n=e[12],i=[];for(let t=0;t0?tw:ew}let B=S(e),Q=B(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Blacklisted Publishers",r=w(),s=m("p"),s.textContent="Blacklisted users cannot publish any events.",o=w(),l=m("div"),a=m("input"),c=w(),u=m("input"),d=w(),g=m("button"),y=v("Blacklist"),b=w(),k=m("div"),Q.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(a,"type","text"),I(a,"placeholder","Pubkey (64 hex chars)"),I(a,"class","svelte-1i0huu3"),I(u,"type","text"),I(u,"placeholder","Reason (optional)"),I(u,"class","svelte-1i0huu3"),g.disabled=e[1],I(g,"class","svelte-1i0huu3"),I(l,"class","add-form svelte-1i0huu3"),I(k,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a),x(a,e[16]),f(l,c),f(l,u),x(u,e[17]),f(l,d),f(l,g),f(g,y),f(t,b),f(t,k),Q.m(k,null),C||(E=[A(a,"input",e[63]),A(u,"input",e[64]),A(g,"click",e[65])],C=!0)},p(e,t){65536&t[0]&&a.value!==e[16]&&x(a,e[16]),131072&t[0]&&u.value!==e[17]&&x(u,e[17]),2&t[0]&&(g.disabled=e[1]),B===(B=S(e))&&Q?Q.p(e,t):(Q.d(1),Q=B(e),Q&&(Q.c(),Q.m(k,null)))},d(e){e&&h(t),Q.d(),C=!1,i(E)}}}function ew(t){let n;return{c(){n=m("div"),n.textContent="No blacklisted pubkeys.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function tw(e){let t,n=e[15],i=[];for(let t=0;t0?ow:sw}let x=E(e),S=x(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Unclassified Users",r=w(),s=m("p"),s.textContent="Users who have posted events but haven't been classified. Sorted by event count.",o=w(),l=m("div"),a=m("button"),c=v("Refresh"),u=w(),d=m("button"),g=v("Scan Database"),y=w(),b=m("div"),S.c(),I(n,"class","svelte-1i0huu3"),I(s,"class","help-text svelte-1i0huu3"),I(a,"class","refresh-btn svelte-1i0huu3"),a.disabled=e[1],I(d,"class","scan-btn svelte-1i0huu3"),d.disabled=e[1],I(l,"class","button-row svelte-1i0huu3"),I(b,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a),f(a,c),f(l,u),f(l,d),f(d,g),f(t,y),f(t,b),S.m(b,null),k||(C=[A(a,"click",e[21]),A(d,"click",e[22])],k=!0)},p(e,t){2&t[0]&&(a.disabled=e[1]),2&t[0]&&(d.disabled=e[1]),x===(x=E(e))&&S?S.p(e,t):(S.d(1),S=x(e),S&&(S.c(),S.m(b,null)))},d(e){e&&h(t),S.d(),k=!1,i(C)}}}function sw(t){let n;return{c(){n=m("div"),n.textContent="No unclassified users.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function ow(e){let t,n=e[18],i=[];for(let t=0;t0?uw:cw}let y=g(e),b=y(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Spam Events",i=w(),r=m("p"),r.textContent="Events flagged as spam are hidden from query results but remain in the database.",s=w(),o=m("button"),l=v("Refresh"),a=w(),c=m("div"),b.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],I(c,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(h,g){p(h,t,g),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(t,a),f(t,c),b.m(c,null),u||(d=A(o,"click",e[23]),u=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),y===(y=g(e))&&b?b.p(e,t):(b.d(1),b=y(e),b&&(b.c(),b.m(c,null)))},d(e){e&&h(t),b.d(),u=!1,d()}}}function cw(t){let n;return{c(){n=m("div"),n.textContent="No spam events flagged.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function uw(e){let t,n=e[19],i=[];for(let t=0;t0?gw:hw}let y=g(e),b=y(e);return{c(){t=m("div"),n=m("h3"),n.textContent="Blocked IP Addresses",i=w(),r=m("p"),r.textContent="IP addresses blocked due to rate limit violations.",s=w(),o=m("button"),l=v("Refresh"),a=w(),c=m("div"),b.c(),I(n,"class","svelte-1i0huu3"),I(r,"class","help-text svelte-1i0huu3"),I(o,"class","refresh-btn svelte-1i0huu3"),o.disabled=e[1],I(c,"class","list svelte-1i0huu3"),I(t,"class","section svelte-1i0huu3")},m(h,g){p(h,t,g),f(t,n),f(t,i),f(t,r),f(t,s),f(t,o),f(o,l),f(t,a),f(t,c),b.m(c,null),u||(d=A(o,"click",e[24]),u=!0)},p(e,t){2&t[0]&&(o.disabled=e[1]),y===(y=g(e))&&b?b.p(e,t):(b.d(1),b=y(e),b&&(b.c(),b.m(c,null)))},d(e){e&&h(t),b.d(),u=!1,d()}}}function hw(t){let n;return{c(){n=m("div"),n.textContent="No blocked IPs.",I(n,"class","empty svelte-1i0huu3")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function gw(e){let t,n=e[20],i=[];for(let t=0;t100*t&&(i=i.substring(0,100*t)),i}function Ow(e,t=6){if(!e)return!1;return e.split("\n").length>t||e.length>100*t}function jw(e){return{0:"Metadata",1:"Text Note",3:"Follow List",4:"Encrypted DM",6:"Repost",7:"Reaction",14:"Chat Message",16:"Order Message",17:"Payment Receipt",1063:"File Metadata",10002:"Relay List",30017:"Stall",30018:"Product (NIP-15)",30023:"Long-form",30078:"App Data",30402:"Product (NIP-99)",30405:"Collection",30406:"Shipping",31555:"Review"}[e]||`Kind ${e}`}function Hw(e,t,n){let{userSigner:i}=t,{userPubkey:r}=t,s="trusted",o=!1,l="",a="info",c=!1,u=null,d=null,f=[],p=0,h=0,g=!1,m={},y={daily_limit:50,first_ban_hours:1,second_ban_hours:168,categories:[],custom_kinds:"",kind_ranges:[]},v=[],w="",b="",A=[],k="",I="",E=[],x=[],S=[];async function B(e,t=[]){try{n(1,o=!0),n(2,l="");const s={method:e,params:t},a=await async function(e,t){if(!i)throw new Error("No signer available. Please log in with a Nostr extension.");if(!r)throw new Error("No user pubkey available.");const n=xp()+t,s={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",n],["method",e]],content:"",pubkey:r},o=await i.signEvent(s);return`Nostr ${btoa(JSON.stringify(o))}`}("POST","/api/nip86"),c=await fetch("/api/nip86",{method:"POST",headers:{"Content-Type":"application/nostr+json+rpc",Authorization:a},body:JSON.stringify(s)});if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);const u=await c.json();if(u.error)throw new Error(u.error);return u.result}catch(e){throw console.error("NIP-86 API error:",e),n(2,l=e.message),n(3,a="error"),e}finally{n(1,o=!1)}}async function Q(){await Promise.all([F(),$(),D(),R(),T()])}async function F(){try{n(12,v=await B("listtrustedpubkeys"))}catch(e){console.error("Failed to load trusted pubkeys:",e),n(12,v=[])}}async function $(){try{n(15,A=await B("listblacklistedpubkeys"))}catch(e){console.error("Failed to load blacklisted pubkeys:",e),n(15,A=[])}}async function D(){try{n(18,E=await B("listunclassifiedusers"))}catch(e){console.error("Failed to load unclassified users:",e),n(18,E=[])}}async function R(){try{n(19,x=await B("listspamevents"))}catch(e){console.error("Failed to load spam events:",e),n(19,x=[])}}async function T(){try{n(20,S=await B("listblockedips"))}catch(e){console.error("Failed to load blocked IPs:",e),n(20,S=[])}}async function U(e=null,t=""){const i=e||w,r=e?t:b;if(i)try{await B("trustpubkey",[i,r]),n(2,l="Pubkey trusted successfully"),n(3,a="success"),n(13,w=""),n(14,b=""),await F(),await D()}catch(e){console.error("Failed to trust pubkey:",e)}}async function N(e){try{await B("untrustpubkey",[e]),n(2,l="Pubkey untrusted"),n(3,a="success"),await F()}catch(e){console.error("Failed to untrust pubkey:",e)}}async function _(e=null,t=""){const i=e||k,r=e?t:I;if(i)try{await B("blacklistpubkey",[i,r]),n(2,l="Pubkey blacklisted"),n(3,a="success"),n(16,k=""),n(17,I=""),await $(),await D()}catch(e){console.error("Failed to blacklist pubkey:",e)}}async function L(e){try{await B("unblacklistpubkey",[e]),n(2,l="Pubkey removed from blacklist"),n(3,a="success"),await $()}catch(e){console.error("Failed to remove from blacklist:",e)}}async function M(e){try{await B("unmarkspam",[e]),n(2,l="Spam mark removed"),n(3,a="success"),await R()}catch(e){console.error("Failed to unmark spam:",e)}}async function O(e){if(confirm("Permanently delete this event?"))try{await B("deleteevent",[e]),n(2,l="Event deleted"),n(3,a="success"),await R()}catch(e){console.error("Failed to delete event:",e)}}async function j(e){try{await B("unblockip",[e]),n(2,l="IP unblocked"),n(3,a="success"),await T()}catch(e){console.error("Failed to unblock IP:",e)}}function H(e){y.categories.includes(e)?n(11,y.categories=y.categories.filter(t=>t!==e),y):n(11,y.categories=[...y.categories,e],y)}async function G(){if(!i||!r)return n(2,l="Please log in with a Nostr extension to publish configuration"),void n(3,a="error");if(0===y.categories.length&&!y.custom_kinds.trim())return n(2,l="Please select at least one kind category or enter custom kinds"),void n(3,a="error");try{n(1,o=!0),n(2,l="");const e=[["d","curating-config"],["daily_limit",String(y.daily_limit)],["first_ban_hours",String(y.first_ban_hours)],["second_ban_hours",String(y.second_ban_hours)]];for(const t of y.categories)e.push(["kind_category",t]);const t=function(e){if(!e||!e.trim())return[];const t=new Set,n=e.split(",").map(e=>e.trim());for(const e of n)if(e)if(e.includes("-")){const[n,i]=e.split("-").map(e=>parseInt(e.trim(),10));if(!isNaN(n)&&!isNaN(i)&&n<=i&&i-n<=1e3)for(let e=n;e<=i;e++)t.add(e)}else{const n=parseInt(e,10);isNaN(n)||t.add(n)}return Array.from(t).sort((e,t)=>e-t)}(y.custom_kinds);for(const n of t)e.push(["kind",String(n)]);const s={kind:30078,created_at:Math.floor(Date.now()/1e3),tags:e,content:"Curating relay configuration",pubkey:r},u=await i.signEvent(s),d=new WebSocket(Sp());await new Promise((e,t)=>{d.onopen=()=>{d.send(JSON.stringify(["EVENT",u]))},d.onmessage=n=>{const i=JSON.parse(n.data);"OK"===i[0]&&(!0===i[2]?e():t(new Error(i[3]||"Event rejected")))},d.onerror=e=>t(new Error("WebSocket error")),setTimeout(()=>t(new Error("Timeout")),1e4)}),d.close(),n(2,l="Configuration published successfully"),n(3,a="success"),n(4,c=!0),await Q()}catch(e){console.error("Failed to publish configuration:",e),n(2,l=`Failed to publish: ${e.message}`),n(3,a="error")}finally{n(1,o=!1)}}function q(e,t="info"){n(2,l=e),n(3,a=t)}async function J(e,t){console.log("openUserDetail called:",e,t),n(5,u=e),n(6,d=t),n(7,f=[]),n(8,p=0),h=0,n(10,m={}),console.log("selectedUser set to:",u),await V()}function K(){n(5,u=null),n(6,d=null),n(7,f=[]),n(8,p=0),h=0,n(10,m={})}async function V(){if(console.log("loadUserEvents called, selectedUser:",u,"loadingEvents:",g),u&&!g)try{n(9,g=!0),console.log("Calling geteventsforpubkey API...");const e=await B("geteventsforpubkey",[u,100,h]);console.log("API result:",e),e&&(n(7,f=0===h?e.events||[]:[...f,...e.events||[]]),n(8,p=e.total||0))}catch(e){console.error("Failed to load user events:",e),q("Failed to load events: "+e.message,"error")}finally{n(9,g=!1)}}function Y(e){n(10,m={...m,[e]:!m[e]})}P(async()=>{await async function(){try{const e=await B("isconfigured");n(4,c=!0===e),c&&(await async function(){try{const e=await B("getcuratingconfig");e&&n(11,y={daily_limit:e.daily_limit||50,first_ban_hours:e.first_ban_hours||1,second_ban_hours:e.second_ban_hours||168,categories:e.categories||[],custom_kinds:e.custom_kinds?e.custom_kinds.join(", "):"",kind_ranges:e.kind_ranges||[]})}catch(e){console.error("Failed to load config:",e)}}(),await Q())}catch(e){console.error("Failed to check configuration:",e),n(4,c=!1)}}()});return e.$$set=e=>{"userSigner"in e&&n(44,i=e.userSigner),"userPubkey"in e&&n(45,r=e.userPubkey)},[s,o,l,a,c,u,d,f,p,g,m,y,v,w,b,A,k,I,E,x,S,D,async function(){try{const e=await B("scanpubkeys");q(`Database scanned: ${e.total_pubkeys} pubkeys, ${e.total_events} events (${e.skipped} skipped)`,"success"),await D()}catch(e){console.error("Failed to scan database:",e),q("Failed to scan database: "+e.message,"error")}},R,T,U,N,_,L,M,O,j,H,G,async function(){await G()},J,K,async function(){h=f.length,await V()},Y,async function(){await U(u,""),await Q(),K()},async function(){await _(u,""),await Q(),K()},async function(){await N(u),await Q(),K()},async function(){await L(u),await Q(),K()},async function(){if(confirm(`Delete ALL ${p} events from this user? This cannot be undone.`))try{n(1,o=!0);q(`Deleted ${(await B("deleteeventsforpubkey",[u])).deleted} events`,"success"),n(7,f=[]),n(8,p=0),h=0,await V()}catch(e){console.error("Failed to delete events:",e),q("Failed to delete events: "+e.message,"error")}finally{n(1,o=!1)}},i,r,e=>H(e.id),function(){y.custom_kinds=this.value,n(11,y)},function(){y.daily_limit=C(this.value),n(11,y)},function(){y.first_ban_hours=C(this.value),n(11,y)},function(){y.second_ban_hours=C(this.value),n(11,y)},e=>Y(e.id),()=>n(0,s="trusted"),()=>n(0,s="blacklist"),()=>n(0,s="unclassified"),()=>n(0,s="spam"),()=>n(0,s="ips"),()=>n(0,s="settings"),function(){w=this.value,n(13,w)},function(){b=this.value,n(14,b)},()=>U(),e=>N(e.pubkey),e=>J(e.pubkey,"trusted"),function(){k=this.value,n(16,k)},function(){I=this.value,n(17,I)},()=>_(),e=>L(e.pubkey),e=>J(e.pubkey,"blacklisted"),e=>U(e.pubkey,""),e=>_(e.pubkey,""),e=>J(e.pubkey,"unclassified"),e=>M(e.event_id),e=>O(e.event_id),e=>j(e.ip),e=>H(e.id),function(){y.custom_kinds=this.value,n(11,y)},function(){y.daily_limit=C(this.value),n(11,y)},function(){y.first_ban_hours=C(this.value),n(11,y)},function(){y.second_ban_hours=C(this.value),n(11,y)}]}class Gw extends ae{constructor(e){super(),le(this,e,Hw,Nw,s,{userSigner:44,userPubkey:45},null,[-1,-1,-1,-1])}}function qw(e,t,n){const i=e.slice();return i[58]=t[n],i}function Jw(e,t,n){const i=e.slice();return i[55]=t[n],i}function Kw(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to view your Blossom storage.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-on0yal"),I(s,"class","login-btn svelte-on0yal"),I(n,"class","login-prompt svelte-on0yal")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[21]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function Vw(e){let t,n,i,r,s,o,l,a,c,u,d,g,y,b,k=e[0]||e[12]?"Loading...":"Refresh";function C(e,t){return e[13]?Ww:e[10]?zw:Yw}let x=C(e),S=x(e),B=e[14]&&!e[10]&&!e[13]&&Xw(e),Q=!e[10]&&!e[13]&&eb(e),F=e[2]&&nb(e);function $(e,t){return e[10]&&!e[13]?rb:ib}let D=$(e),R=D(e);return{c(){t=m("div"),n=m("div"),S.c(),i=w(),r=m("div"),B&&B.c(),s=w(),o=m("button"),l=v("🔄 "),a=v(k),u=w(),Q&&Q.c(),d=w(),F&&F.c(),g=w(),R.c(),I(o,"class","refresh-btn svelte-on0yal"),o.disabled=c=e[0]||e[12],I(r,"class","header-buttons svelte-on0yal"),I(n,"class","header-section svelte-on0yal"),I(t,"class","blossom-view svelte-on0yal")},m(c,h){p(c,t,h),f(t,n),S.m(n,null),f(n,i),f(n,r),B&&B.m(r,null),f(r,s),f(r,o),f(o,l),f(o,a),f(t,u),Q&&Q.m(t,null),f(t,d),F&&F.m(t,null),f(t,g),R.m(t,null),y||(b=A(o,"click",e[31]),y=!0)},p(e,l){x===(x=C(e))&&S?S.p(e,l):(S.d(1),S=x(e),S&&(S.c(),S.m(n,i))),!e[14]||e[10]||e[13]?B&&(B.d(1),B=null):B?B.p(e,l):(B=Xw(e),B.c(),B.m(r,s)),4097&l[0]&&k!==(k=e[0]||e[12]?"Loading...":"Refresh")&&E(a,k),4097&l[0]&&c!==(c=e[0]||e[12])&&(o.disabled=c),e[10]||e[13]?Q&&(Q.d(1),Q=null):Q?Q.p(e,l):(Q=eb(e),Q.c(),Q.m(t,d)),e[2]?F?F.p(e,l):(F=nb(e),F.c(),F.m(t,g)):F&&(F.d(1),F=null),D===(D=$(e))&&R?R.p(e,l):(R.d(1),R=D(e),R&&(R.c(),R.m(t,null)))},d(e){e&&h(t),S.d(),B&&B.d(),Q&&Q.d(),F&&F.d(),R.d(),y=!1,b()}}}function Yw(t){let n;return{c(){n=m("h3"),n.textContent="Blossom Media Storage",I(n,"class","svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function zw(t){let n,i,r,s,o;return{c(){n=m("button"),n.textContent="← Back",i=w(),r=m("h3"),r.textContent="All Users Storage",I(n,"class","back-btn svelte-on0yal"),I(r,"class","svelte-on0yal")},m(e,l){p(e,n,l),p(e,i,l),p(e,r,l),s||(o=A(n,"click",t[28]),s=!0)},p:e,d(e){e&&h(n),e&&h(i),e&&h(r),s=!1,o()}}}function Ww(e){let t,n,i,r,s,o,l,a=(e[13].profile?.name||Rb(e[26](e[13].pubkey)))+"",c=e[13].profile?.picture&&Zw(e);return{c(){t=m("button"),t.textContent="← Back",n=w(),i=m("h3"),c&&c.c(),r=w(),s=v(a),I(t,"class","back-btn svelte-on0yal"),I(i,"class","user-header svelte-on0yal")},m(a,u){p(a,t,u),p(a,n,u),p(a,i,u),c&&c.m(i,null),f(i,r),f(i,s),o||(l=A(t,"click",e[30]),o=!0)},p(e,t){e[13].profile?.picture?c?c.p(e,t):(c=Zw(e),c.c(),c.m(i,r)):c&&(c.d(1),c=null),8192&t[0]&&a!==(a=(e[13].profile?.name||Rb(e[26](e[13].pubkey)))+"")&&E(s,a)},d(e){e&&h(t),e&&h(n),e&&h(i),c&&c.d(),o=!1,l()}}}function Zw(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[13].profile.picture)||I(t,"src",n),I(t,"alt",""),I(t,"class","header-avatar svelte-on0yal")},m(e,n){p(e,t,n)},p(e,i){8192&i[0]&&!l(t.src,n=e[13].profile.picture)&&I(t,"src",n)},d(e){e&&h(t)}}}function Xw(e){let t,n,i,r;return{c(){t=m("button"),n=v("Admin"),I(t,"class","admin-btn svelte-on0yal"),t.disabled=e[0]},m(s,o){p(s,t,o),f(t,n),i||(r=A(t,"click",e[27]),i=!0)},p(e,n){1&n[0]&&(t.disabled=e[0])},d(e){e&&h(t),i=!1,r()}}}function eb(e){let t,n,r,s,o,l,a,c,u,d,g=e[3].length>0&&tb(e);return{c(){t=m("div"),n=m("span"),n.textContent="Upload new files",r=w(),s=m("input"),o=w(),g&&g.c(),l=w(),a=m("button"),c=v("Select Files"),I(n,"class","upload-label svelte-on0yal"),I(s,"type","file"),s.multiple=!0,I(s,"class","file-input-hidden svelte-on0yal"),I(a,"class","select-btn svelte-on0yal"),a.disabled=e[4],I(t,"class","upload-section svelte-on0yal")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),e[40](s),f(t,o),g&&g.m(t,null),f(t,l),f(t,a),f(a,c),u||(d=[A(s,"change",e[23]),A(a,"click",e[24])],u=!0)},p(e,n){e[3].length>0?g?g.p(e,n):(g=tb(e),g.c(),g.m(t,l)):g&&(g.d(1),g=null),16&n[0]&&(a.disabled=e[4])},d(n){n&&h(t),e[40](null),g&&g.d(),u=!1,i(d)}}}function tb(e){let t,n,i,r,s,o,l,a,c=e[3].length+"",u=(e[4]?e[5]:"Upload")+"";return{c(){t=m("span"),n=v(c),i=v(" file(s) selected"),r=w(),s=m("button"),o=v(u),I(t,"class","selected-count svelte-on0yal"),I(s,"class","upload-btn svelte-on0yal"),s.disabled=e[4]},m(c,u){p(c,t,u),f(t,n),f(t,i),p(c,r,u),p(c,s,u),f(s,o),l||(a=A(s,"click",e[25]),l=!0)},p(e,t){8&t[0]&&c!==(c=e[3].length+"")&&E(n,c),48&t[0]&&u!==(u=(e[4]?e[5]:"Upload")+"")&&E(o,u),16&t[0]&&(s.disabled=e[4])},d(e){e&&h(t),e&&h(r),e&&h(s),l=!1,a()}}}function nb(e){let t,n;return{c(){t=m("div"),n=v(e[2]),I(t,"class","error-message svelte-on0yal")},m(e,i){p(e,t,i),f(t,n)},p(e,t){4&t[0]&&E(n,e[2])},d(e){e&&h(t)}}}function ib(e){let t,n,i;function r(e,i){return 1&i[0]&&(t=null),null==t&&(t=!(!e[0]||0!==e[32]().length)),t?lb:(null==n&&(n=!(0!==e[32]().length)),n?ob:sb)}let s=r(e,[-1,-1]),o=s(e);return{c(){o.c(),i=b()},m(e,t){o.m(e,t),p(e,i,t)},p(e,t){s===(s=r(e,t))&&o?o.p(e,t):(o.d(1),o=s(e),o&&(o.c(),o.m(i.parentNode,i)))},d(e){o.d(e),e&&h(i)}}}function rb(e){let t;function n(e,t){return e[12]?hb:0===e[11].length?pb:fb}let i=n(e),r=i(e);return{c(){r.c(),t=b()},m(e,n){r.m(e,n),p(e,t,n)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t.parentNode,t)))},d(e){r.d(e),e&&h(t)}}}function sb(e){let t,n=e[32](),i=[];for(let t=0;tNo users have uploaded files yet.

    ",I(n,"class","empty-state svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function hb(t){let n;return{c(){n=m("div"),n.textContent="Loading user statistics...",I(n,"class","loading svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function gb(t){let n;return{c(){n=m("div"),I(n,"class","user-avatar-placeholder svelte-on0yal")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function mb(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[55].profile.picture)||I(t,"src",n),I(t,"alt",""),I(t,"class","user-avatar svelte-on0yal")},m(e,n){p(e,t,n)},p(e,i){2048&i[0]&&!l(t.src,n=e[55].profile.picture)&&I(t,"src",n)},d(e){e&&h(t)}}}function yb(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,x,S,B,Q,F,$,D,R,P,T,U=(e[55].profile?.name||Rb(e[26](e[55].pubkey)))+"",N=e[26](e[55].pubkey)+"",_=Rb(e[26](e[55].pubkey))+"",L=e[55].blob_count+"",M=Bb(e[55].total_size_bytes)+"";function O(e,t){return e[55].profile?.picture?mb:gb}let j=O(e),H=j(e);function G(){return e[41](e[55])}function q(...t){return e[42](e[55],...t)}return{c(){t=m("div"),n=m("div"),H.c(),r=w(),s=m("div"),o=m("div"),l=v(U),a=w(),c=m("div"),u=m("span"),d=v(N),g=w(),y=m("span"),b=v(_),C=w(),x=m("div"),S=m("span"),B=v(L),Q=v(" files"),F=w(),$=m("span"),D=v(M),R=w(),I(n,"class","user-avatar-container svelte-on0yal"),I(o,"class","user-name svelte-on0yal"),I(u,"class","npub-full svelte-on0yal"),I(y,"class","npub-truncated svelte-on0yal"),I(c,"class","user-npub svelte-on0yal"),I(c,"title",k=e[55].pubkey),I(s,"class","user-info svelte-on0yal"),I(S,"class","blob-count svelte-on0yal"),I($,"class","total-size svelte-on0yal"),I(x,"class","user-stats svelte-on0yal"),I(t,"class","user-stat-item svelte-on0yal"),I(t,"role","button"),I(t,"tabindex","0")},m(e,i){p(e,t,i),f(t,n),H.m(n,null),f(t,r),f(t,s),f(s,o),f(o,l),f(s,a),f(s,c),f(c,u),f(u,d),f(c,g),f(c,y),f(y,b),f(t,C),f(t,x),f(x,S),f(S,B),f(S,Q),f(x,F),f(x,$),f($,D),f(t,R),P||(T=[A(t,"click",G),A(t,"keypress",q)],P=!0)},p(t,i){j===(j=O(e=t))&&H?H.p(e,i):(H.d(1),H=j(e),H&&(H.c(),H.m(n,null))),2048&i[0]&&U!==(U=(e[55].profile?.name||Rb(e[26](e[55].pubkey)))+"")&&E(l,U),2048&i[0]&&N!==(N=e[26](e[55].pubkey)+"")&&E(d,N),2048&i[0]&&_!==(_=Rb(e[26](e[55].pubkey))+"")&&E(b,_),2048&i[0]&&k!==(k=e[55].pubkey)&&I(c,"title",k),2048&i[0]&&L!==(L=e[55].blob_count+"")&&E(B,L),2048&i[0]&&M!==(M=Bb(e[55].total_size_bytes)+"")&&E(D,M)},d(e){e&&h(t),H.d(),P=!1,i(T)}}}function vb(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,C,x,S,B,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V,Y,z,W,Z,X,ee,te=Fb(e[8].sha256)+"",ne=(e[8].type||"unknown")+"",ie="image"===$b(e[8].type),re=Bb(e[8].size)+"",se=Qb(e[8].uploaded)+"",oe=ie&&wb(e);function le(e,t){return 256&t[0]&&(S=null),256&t[0]&&(B=null),256&t[0]&&(Q=null),null==S&&(S=!("image"!==$b(e[8].type))),S?Ib:(null==B&&(B=!("video"!==$b(e[8].type))),B?kb:(null==Q&&(Q=!("audio"!==$b(e[8].type))),Q?Ab:bb))}let ae=le(e,[-1,-1]),ce=ae(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("div"),o=m("span"),l=v(te),a=w(),c=m("span"),u=v(ne),d=w(),g=m("div"),oe&&oe.c(),y=w(),b=m("button"),b.textContent="X",C=w(),x=m("div"),ce.c(),F=w(),$=m("div"),D=m("div"),R=m("span"),P=v("Size: "),T=v(re),U=w(),N=m("span"),_=v("Uploaded: "),L=v(se),M=w(),O=m("div"),j=m("input"),G=w(),q=m("button"),q.textContent="Copy",J=w(),K=m("div"),V=m("a"),Y=v("Open in New Tab"),W=w(),Z=m("button"),Z.textContent="Delete",I(o,"class","modal-hash svelte-on0yal"),I(c,"class","modal-type svelte-on0yal"),I(s,"class","modal-title svelte-on0yal"),I(b,"class","close-btn svelte-on0yal"),I(g,"class","modal-controls svelte-on0yal"),I(r,"class","modal-header svelte-on0yal"),I(x,"class","modal-body svelte-on0yal"),I(D,"class","blob-details svelte-on0yal"),I(j,"type","text"),j.readOnly=!0,j.value=H=e[20](e[8]),I(j,"class","blob-url-input svelte-on0yal"),I(q,"class","copy-btn svelte-on0yal"),I(O,"class","blob-url-section svelte-on0yal"),I(V,"href",z=e[20](e[8])),I(V,"target","_blank"),I(V,"rel","noopener noreferrer"),I(V,"class","action-btn svelte-on0yal"),I(Z,"class","action-btn danger svelte-on0yal"),I(K,"class","modal-actions svelte-on0yal"),I($,"class","modal-footer svelte-on0yal"),I(n,"class","modal-content svelte-on0yal"),I(n,"role","dialog"),I(t,"class","modal-overlay svelte-on0yal"),I(t,"role","button"),I(t,"tabindex","0")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(s,o),f(o,l),f(s,a),f(s,c),f(c,u),f(r,d),f(r,g),oe&&oe.m(g,null),f(g,y),f(g,b),f(n,C),f(n,x),ce.m(x,null),f(n,F),f(n,$),f($,D),f(D,R),f(R,P),f(R,T),f(D,U),f(D,N),f(N,_),f(N,L),f($,M),f($,O),f(O,j),f(O,G),f(O,q),f($,J),f($,K),f(K,V),f(V,Y),f(K,W),f(K,Z),X||(ee=[A(b,"click",e[16]),A(j,"click",Pb),A(q,"click",e[46]),A(Z,"click",e[47]),A(n,"click",k(e[38])),A(n,"keypress",k(e[39])),A(t,"click",e[16]),A(t,"keypress",e[48])],X=!0)},p(e,t){256&t[0]&&te!==(te=Fb(e[8].sha256)+"")&&E(l,te),256&t[0]&&ne!==(ne=(e[8].type||"unknown")+"")&&E(u,ne),256&t[0]&&(ie="image"===$b(e[8].type)),ie?oe?oe.p(e,t):(oe=wb(e),oe.c(),oe.m(g,y)):oe&&(oe.d(1),oe=null),ae===(ae=le(e,t))&&ce?ce.p(e,t):(ce.d(1),ce=ae(e),ce&&(ce.c(),ce.m(x,null))),256&t[0]&&re!==(re=Bb(e[8].size)+"")&&E(T,re),256&t[0]&&se!==(se=Qb(e[8].uploaded)+"")&&E(L,se),256&t[0]&&H!==(H=e[20](e[8]))&&j.value!==H&&(j.value=H),256&t[0]&&z!==(z=e[20](e[8]))&&I(V,"href",z)},d(e){e&&h(t),oe&&oe.d(),ce.d(),X=!1,i(ee)}}}function wb(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k=Math.round(100*e[9])+"";return{c(){t=m("button"),n=v("-"),s=w(),o=m("span"),l=v(k),a=v("%"),c=w(),u=m("button"),d=v("+"),I(t,"class","zoom-btn svelte-on0yal"),t.disabled=r=e[9]<=Eb,I(o,"class","zoom-level svelte-on0yal"),I(u,"class","zoom-btn svelte-on0yal"),u.disabled=g=e[9]>=xb},m(i,r){p(i,t,r),f(t,n),p(i,s,r),p(i,o,r),f(o,l),f(o,a),p(i,c,r),p(i,u,r),f(u,d),y||(b=[A(t,"click",e[18]),A(u,"click",e[17])],y=!0)},p(e,n){512&n[0]&&r!==(r=e[9]<=Eb)&&(t.disabled=r),512&n[0]&&k!==(k=Math.round(100*e[9])+"")&&E(l,k),512&n[0]&&g!==(g=e[9]>=xb)&&(u.disabled=g)},d(e){e&&h(t),e&&h(s),e&&h(o),e&&h(c),e&&h(u),y=!1,i(b)}}}function bb(e){let t,n,i,r,s,o,l,a,c,u=Db(e[8].type)+"";return{c(){t=m("div"),n=m("div"),i=v(u),r=w(),s=m("p"),s.textContent="Preview not available for this file type.",o=w(),l=m("a"),a=v("Download File"),I(n,"class","file-icon svelte-on0yal"),I(l,"href",c=e[20](e[8])),I(l,"target","_blank"),I(l,"rel","noopener noreferrer"),I(l,"class","download-link svelte-on0yal"),I(t,"class","file-preview svelte-on0yal")},m(e,c){p(e,t,c),f(t,n),f(n,i),f(t,r),f(t,s),f(t,o),f(t,l),f(l,a)},p(e,t){256&t[0]&&u!==(u=Db(e[8].type)+"")&&E(i,u),256&t[0]&&c!==(c=e[20](e[8]))&&I(l,"href",c)},d(e){e&&h(t)}}}function Ab(e){let t,n,i;return{c(){t=m("div"),n=m("audio"),n.controls=!0,l(n.src,i=e[20](e[8]))||I(n,"src",i),I(n,"class","svelte-on0yal"),I(t,"class","media-container audio svelte-on0yal")},m(e,i){p(e,t,i),f(t,n)},p(e,t){256&t[0]&&!l(n.src,i=e[20](e[8]))&&I(n,"src",i)},d(e){e&&h(t)}}}function kb(e){let t,n,i,r;return{c(){t=m("div"),n=m("video"),i=m("track"),I(i,"kind","captions"),n.controls=!0,l(n.src,r=e[20](e[8]))||I(n,"src",r),I(n,"class","svelte-on0yal"),I(t,"class","media-container svelte-on0yal")},m(e,r){p(e,t,r),f(t,n),f(n,i)},p(e,t){256&t[0]&&!l(n.src,r=e[20](e[8]))&&I(n,"src",r)},d(e){e&&h(t)}}}function Ib(e){let t,n,i;return{c(){t=m("div"),n=m("img"),l(n.src,i=e[20](e[8]))||I(n,"src",i),I(n,"alt","Blob content"),I(n,"class","svelte-on0yal"),I(t,"class","media-container svelte-on0yal"),S(t,"transform","scale("+e[9]+")")},m(e,i){p(e,t,i),f(t,n)},p(e,r){256&r[0]&&!l(n.src,i=e[20](e[8]))&&I(n,"src",i),512&r[0]&&S(t,"transform","scale("+e[9]+")")},d(e){e&&h(t)}}}function Cb(t){let n,i,r,s;function o(e,t){return e[1]?Vw:Kw}let l=o(t),a=l(t),c=t[7]&&t[8]&&vb(t);return{c(){a.c(),n=w(),c&&c.c(),i=b()},m(e,o){a.m(e,o),p(e,n,o),c&&c.m(e,o),p(e,i,o),r||(s=A(window,"keydown",t[19]),r=!0)},p(e,t){l===(l=o(e))&&a?a.p(e,t):(a.d(1),a=l(e),a&&(a.c(),a.m(n.parentNode,n))),e[7]&&e[8]?c?c.p(e,t):(c=vb(e),c.c(),c.m(i.parentNode,i)):c&&(c.d(1),c=null)},i:e,o:e,d(e){a.d(e),e&&h(n),c&&c.d(e),e&&h(i),r=!1,s()}}}const Eb=.25,xb=4;async function Sb(e,t,n=null){if(!e)return console.log("No signer available for Blossom auth"),null;try{const i=Math.floor(Date.now()/1e3),r=[["t",t],["expiration",(i+60).toString()]];n&&r.push(["x",n]);const s={kind:24242,created_at:i,tags:r,content:`Blossom ${t} operation`},o=await e.signEvent(s);return btoa(JSON.stringify(o)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating Blossom auth:",e),null}}function Bb(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=0,i=e;for(;i>=1024&&ne.target.select();function Tb(e,t,n){let i,r,{isLoggedIn:s=!1}=t,{userPubkey:o=""}=t,{userSigner:l=null}=t,{currentEffectiveRole:a=""}=t;const c=U();let u,d=[],f=!1,p="",h=[],g=!1,m="",y=!1,v=null,w=1,b=!1,A=[],k=!1,I=null,C=[],E=!1;async function x(){if(o){n(0,f=!0),n(2,p="");try{const e=`${xp()}/blossom/list/${o}`,t=await Sb(l,"list"),n=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!n.ok)throw new Error(`Failed to load blobs: ${n.statusText}`);const i=await n.json();d=Array.isArray(i)?i:[],d.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0)),console.log("Loaded blobs:",d)}catch(e){console.error("Error loading blobs:",e),n(2,p=e.message||"Failed to load blobs")}finally{n(0,f=!1)}}}function S(e){n(8,v=e),n(9,w=1),n(7,y=!0)}function B(){n(7,y=!1),n(8,v=null),n(9,w=1)}function Q(){wEb&&n(9,w=Math.max(Eb,w-.25))}function $(e){return e.url?e.url.startsWith("http://")||e.url.startsWith("https://")?e.url:e.url.startsWith("/")?`${xp()}${e.url}`:`http://${e.url}`:`${xp()}/blossom/${e.sha256}`}async function D(e){if(confirm(`Delete blob ${Fb(e.sha256)}?`))try{const t=`${xp()}/blossom/${e.sha256}`,n=await Sb(l,"delete",e.sha256),i=await fetch(t,{method:"DELETE",headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to delete: ${i.statusText}`);d=d.filter(t=>t.sha256!==e.sha256),v?.sha256===e.sha256&&B()}catch(e){console.error("Error deleting blob:",e),alert(`Failed to delete blob: ${e.message}`)}}async function R(){n(12,k=!0),n(2,p="");try{const e=`${xp()}/blossom/admin/users`,t=await Sb(l,"admin"),i=await fetch(e,{headers:t?{Authorization:`Nostr ${t}`}:{}});if(!i.ok)throw new Error(`Failed to load user stats: ${i.statusText}`);n(11,A=await i.json());for(const e of A)Wp(e.pubkey).then(t=>{e.profile=t||{name:"",picture:""},n(11,A)}).catch(()=>{e.profile={name:"",picture:""}})}catch(e){console.error("Error fetching admin user stats:",e),n(2,p=e.message||"Failed to load user stats")}finally{n(12,k=!1)}}async function T(e){n(0,f=!0),n(2,p="");try{const t=`${xp()}/blossom/list/${e}`,n=await Sb(l,"list"),i=await fetch(t,{headers:n?{Authorization:`Nostr ${n}`}:{}});if(!i.ok)throw new Error(`Failed to load user blobs: ${i.statusText}`);C=await i.json(),C.sort((e,t)=>(t.uploaded||0)-(e.uploaded||0))}catch(e){console.error("Error loading user blobs:",e),n(2,p=e.message||"Failed to load user blobs")}finally{n(0,f=!1)}}async function _(e){n(13,I={pubkey:e.pubkey,profile:e.profile}),await T(e.pubkey)}P(()=>{i&&!E&&(n(37,E=!0),x())});return e.$$set=e=>{"isLoggedIn"in e&&n(33,s=e.isLoggedIn),"userPubkey"in e&&n(34,o=e.userPubkey),"userSigner"in e&&n(35,l=e.userSigner),"currentEffectiveRole"in e&&n(36,a=e.currentEffectiveRole)},e.$$.update=()=>{12&e.$$.dirty[1]&&n(1,i=s&&o),32&e.$$.dirty[1]&&n(14,r="admin"===a||"owner"===a),3&e.$$.dirty[0]|64&e.$$.dirty[1]&&(!i||E||f||(n(37,E=!0),x()))},[f,i,p,h,g,m,u,y,v,w,b,A,k,I,r,S,B,Q,F,function(e){y&&("Escape"===e.key?B():"+"===e.key||"="===e.key?Q():"-"===e.key&&F())},$,function(){c("openLoginModal")},D,function(e){n(3,h=Array.from(e.target.files))},function(){u?.click()},async function(){if(0===h.length)return;n(4,g=!0),n(2,p="");const e=[],t=[];for(let i=0;i0&&await x(),t.length>0&&n(2,p=`Failed to upload: ${t.map(e=>e.name).join(", ")}`)},function(e){try{return ku(e)}catch(t){return Fb(e)}},function(){n(10,b=!0),R()},function(){n(10,b=!1),n(11,A=[]),n(13,I=null),C=[]},_,function(){n(13,I=null),C=[]},function(){I?T(I.pubkey):b?R():x()},function(){return I?C:d},s,o,l,a,E,function(t){N.call(this,e,t)},function(t){N.call(this,e,t)},function(e){L[e?"unshift":"push"](()=>{u=e,n(6,u)})},e=>_(e),(e,t)=>"Enter"===t.key&&_(e),e=>D(e),e=>S(e),(e,t)=>"Enter"===t.key&&S(e),()=>{navigator.clipboard.writeText($(v))},()=>D(v),e=>"Enter"===e.key&&B()]}class Ub extends ae{constructor(e){super(),le(this,e,Tb,Cb,s,{isLoggedIn:33,userPubkey:34,userSigner:35,currentEffectiveRole:36},null,[-1,-1])}}function Nb(e,t,n){const i=e.slice();return i[29]=t[n],i}function _b(e,t,n){const i=e.slice();return i[32]=t[n],i}function Lb(e){let t,n,i;function r(e,t){return e[0]?Ob:jb}let s=r(e),o=s(e);return{c(){t=m("div"),n=m("p"),n.textContent="Log viewer is only available to relay owners.",i=w(),o.c(),I(n,"class","svelte-w6h7aj"),I(t,"class","login-prompt svelte-w6h7aj")},m(e,r){p(e,t,r),f(t,n),f(t,i),o.m(t,null)},p(e,n){s===(s=r(e))&&o?o.p(e,n):(o.d(1),o=s(e),o&&(o.c(),o.m(t,null)))},d(e){e&&h(t),o.d()}}}function Mb(e){let t,n,r,s,o,l,a,c,u,d,y,b,k,C,x,S,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,q=e[3]?"Loading...":"Refresh",J=e[2].length+"",K=e[12],V=[];for(let t=0;te[18].call(u)),I(l,"class","level-selector svelte-w6h7aj"),I(y,"class","clear-btn svelte-w6h7aj"),y.disabled=k=e[3]||0===e[2].length,I(x,"class","refresh-btn svelte-w6h7aj"),x.disabled=e[3],I(o,"class","header-controls svelte-w6h7aj"),I(n,"class","header-section svelte-w6h7aj"),I(D,"class","log-info svelte-w6h7aj"),I(O,"class","log-list svelte-w6h7aj"),I(t,"class","log-view svelte-w6h7aj")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(l,c),f(l,u);for(let e=0;eNo logs available.

    ",I(n,"class","empty-state svelte-w6h7aj")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function Kb(e){let t,n,i,r,s=e[29].file+"",o=e[29].line+"";return{c(){t=m("span"),n=v(s),i=v(":"),r=v(o),I(t,"class","log-location svelte-w6h7aj")},m(e,s){p(e,t,s),f(t,n),f(t,i),f(t,r)},p(e,t){4&t[0]&&s!==(s=e[29].file+"")&&E(n,s),4&t[0]&&o!==(o=e[29].line+"")&&E(r,o)},d(e){e&&h(t)}}}function Vb(e){let t,n,i,r,s,o,l,a,c,u,d,g=Xb(e[29].timestamp)+"",y=e[29].level+"",b=e[29].message+"",A=e[29].file&&Kb(e);return{c(){t=m("div"),n=m("span"),i=v(g),r=w(),s=m("span"),o=v(y),a=w(),A&&A.c(),c=w(),u=m("span"),d=v(b),I(n,"class","log-timestamp svelte-w6h7aj"),I(s,"class",l="log-level "+eA(e[29].level)+" svelte-w6h7aj"),I(u,"class","log-message svelte-w6h7aj"),I(t,"class","log-entry svelte-w6h7aj")},m(e,l){p(e,t,l),f(t,n),f(n,i),f(t,r),f(t,s),f(s,o),f(t,a),A&&A.m(t,null),f(t,c),f(t,u),f(u,d)},p(e,n){4&n[0]&&g!==(g=Xb(e[29].timestamp)+"")&&E(i,g),4&n[0]&&y!==(y=e[29].level+"")&&E(o,y),4&n[0]&&l!==(l="log-level "+eA(e[29].level)+" svelte-w6h7aj")&&I(s,"class",l),e[29].file?A?A.p(e,n):(A=Kb(e),A.c(),A.m(t,c)):A&&(A.d(1),A=null),4&n[0]&&b!==(b=e[29].message+"")&&E(d,b)},d(e){e&&h(t),A&&A.d()}}}function Yb(e){let t;return{c(){t=m("span"),t.textContent="End of logs"},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function zb(e){let t;return{c(){t=m("span"),t.textContent="Scroll for more"},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Wb(e){let t;return{c(){t=m("span"),t.textContent="Loading more..."},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Zb(t){let n;function i(e,t){return e[4]?Mb:Lb}let r=i(t),s=r(t);return{c(){s.c(),n=b()},m(e,t){s.m(e,t),p(e,n,t)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n.parentNode,n)))},i:e,o:e,d(e){s.d(e),e&&h(n)}}}function Xb(e){if(!e)return"";return new Date(e).toLocaleString()}function eA(e){switch(e?.toUpperCase()){case"TRC":case"TRACE":return"level-trace";case"DBG":case"DEBUG":return"level-debug";case"INF":case"INFO":default:return"level-info";case"WRN":case"WARN":return"level-warn";case"ERR":case"ERROR":return"level-error";case"FTL":case"FATAL":return"level-fatal"}}function tA(e,t,n){let i,{isLoggedIn:r=!1}=t,{userRole:s=""}=t,{userSigner:o=null}=t;const l=U();let a=[],c=!1,u=!0,d=0,f=0,p="",h="info",g="info";const m=["trace","debug","info","warn","error","fatal"];let y,v,w;async function b(e="GET",t="/api/logs"){if(!o)return null;try{const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",`${xp()}${t}`],["method",e]],content:""},i=await o.signEvent(n);return btoa(JSON.stringify(i)).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("Error creating auth header:",e),null}}async function A(e=!1){if(!c){n(3,c=!0),n(7,p=""),e&&(d=0,n(2,a=[]));try{const t=`/api/logs?offset=${d}&limit=100`,i=await b("GET",t),r=`${xp()}${t}`,s=await fetch(r,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!s.ok)throw new Error(`Failed to load logs: ${s.statusText}`);const o=await s.json();n(2,a=e?o.logs||[]:[...a,...o.logs||[]]),n(6,f=o.total||0),n(5,u=o.has_more||!1),d=a.length}catch(e){console.error("Error loading logs:",e),n(7,p=e.message||"Failed to load logs")}finally{n(3,c=!1)}}}async function k(){try{const e=await fetch(`${xp()}/api/logs/level`);if(e.ok){const t=await e.json();n(8,h=t.level||"info"),n(9,g=h)}}catch(e){console.error("Error loading log level:",e)}}P(()=>{i&&(A(!0),k(),function(){if(!v)return;w=new IntersectionObserver(e=>{e[0].isIntersecting&&u&&!c&&u&&!c&&A(!1)},{threshold:.1}),w.observe(v)}())}),T(()=>{w&&w.disconnect()});return e.$$set=e=>{"isLoggedIn"in e&&n(0,r=e.isLoggedIn),"userRole"in e&&n(1,s=e.userRole),"userSigner"in e&&n(17,o=e.userSigner)},e.$$.update=()=>{3&e.$$.dirty[0]&&n(4,i=r&&"owner"===s),28&e.$$.dirty[0]&&i&&0===a.length&&!c&&(A(!0),k())},[r,s,a,c,i,u,f,p,h,g,y,v,m,A,async function(){if(g!==h)try{const e=await b("POST","/api/logs/level"),t=await fetch(`${xp()}/api/logs/level`,{method:"POST",headers:{"Content-Type":"application/json",...e?{Authorization:`Nostr ${e}`}:{}},body:JSON.stringify({level:g})});if(!t.ok)throw new Error(`Failed to set log level: ${t.statusText}`);const i=await t.json();n(8,h=i.level),n(9,g=h)}catch(e){console.error("Error setting log level:",e),n(7,p=e.message||"Failed to set log level"),n(9,g=h)}},async function(){if(confirm("Are you sure you want to clear all logs?"))try{const e=await b("POST","/api/logs/clear"),t=await fetch(`${xp()}/api/logs/clear`,{method:"POST",headers:e?{Authorization:`Nostr ${e}`}:{}});if(!t.ok)throw new Error(`Failed to clear logs: ${t.statusText}`);n(2,a=[]),d=0,n(5,u=!1),n(6,f=0)}catch(e){console.error("Error clearing logs:",e),n(7,p=e.message||"Failed to clear logs")}},function(){l("openLoginModal")},o,function(){g=Q(this),n(9,g),n(12,m)},()=>A(!0),function(e){L[e?"unshift":"push"](()=>{v=e,n(11,v)})},function(e){L[e?"unshift":"push"](()=>{y=e,n(10,y)})}]}class nA extends ae{constructor(e){super(),le(this,e,tA,Zb,s,{isLoggedIn:0,userRole:1,userSigner:17},null,[-1,-1])}}async function iA(e,t,n,i){if(!e||!t)return console.log("createNIP98Auth: No signer or pubkey available",{hasSigner:!!e,hasPubkey:!!t}),null;try{const t={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",i],["method",n.toUpperCase()]],content:""};console.log("createNIP98Auth: Signing event for",n,i);const r=await e.signEvent(t);console.log("createNIP98Auth: Signed event:",{id:r.id,pubkey:r.pubkey,kind:r.kind,created_at:r.created_at,tags:r.tags,hasSig:!!r.sig});const s=JSON.stringify(r);return btoa(s).replace(/\+/g,"-").replace(/\//g,"_")}catch(e){return console.error("createNIP98Auth: Error:",e),null}}async function rA(){try{const e=await fetch(xp(),{headers:{Accept:"application/nostr+json"}});if(e.ok)return await e.json()}catch(e){console.error("Error fetching relay info:",e)}return null}async function sA(){const e=xp();console.log("[api] fetchNRCConfig using base URL:",e);try{const t=await fetch(`${e}/api/nrc/config`);if(t.ok)return await t.json()}catch(e){console.error("Error fetching NRC config:",e)}return{enabled:!1,badger_required:!0}}function oA(e){return Up[e]||`Kind ${e}`}function lA(e){return e?e.slice(0,8)+"..."+e.slice(-8):"unknown"}function aA(e,t=100){return e?e.length>t?e.slice(0,t)+"...":e:""}function cA(e){return e?new Date(1e3*e).toLocaleString():""}async function uA(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){console.error("Failed to copy to clipboard:",t);try{const t=document.createElement("textarea");return t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),!0}catch(e){return console.error("Fallback copy also failed:",e),!1}}}function dA(e,t=!0){if(!e)return;const n=e.textContent,i=e.style.backgroundColor;t?(e.textContent="",e.style.backgroundColor="#4CAF50"):(e.textContent="L",e.style.backgroundColor="#f44336"),setTimeout(()=>{e.textContent=n,e.style.backgroundColor=i},2e3)}function fA(e,t,n){const i=e.slice();return i[34]=t[n],i}function pA(e){let t,n,r,s,o,l,a,c,u,d,g,y,k,C,S,B,Q,F,$,D,R,P,T,U,N,_,L,M,O,j,H,G,q,J,K,V=(e[5].rendezvous_url||"Not configured")+"",Y=e[4].length+"";function z(e,t){return 0===e[4].length?vA:yA}let W=z(e),Z=W(e),X=e[7]&&AA(e);return{c(){t=m("div"),n=m("div"),n.innerHTML='Status: \n Enabled',r=w(),s=m("div"),o=m("span"),o.textContent="Rendezvous:",l=w(),a=m("span"),c=v(V),u=w(),d=m("div"),g=m("h3"),g.textContent="Create New Connection",y=w(),k=m("div"),C=m("div"),S=m("label"),S.textContent="Device Label",B=w(),Q=m("input"),F=w(),$=m("button"),D=v("+ Create Connection"),P=w(),T=m("div"),U=m("h3"),N=v("Connections ("),_=v(Y),L=v(")"),M=w(),Z.c(),O=w(),j=m("button"),H=v("Refresh"),G=w(),X&&X.c(),q=b(),I(n,"class","status-item svelte-1rsf7jk"),I(o,"class","status-label svelte-1rsf7jk"),I(a,"class","status-value svelte-1rsf7jk"),I(s,"class","status-item svelte-1rsf7jk"),I(t,"class","config-status svelte-1rsf7jk"),I(g,"class","svelte-1rsf7jk"),I(S,"for","new-label"),I(S,"class","svelte-1rsf7jk"),I(Q,"type","text"),I(Q,"id","new-label"),I(Q,"placeholder","e.g., Phone, Laptop, Tablet"),Q.disabled=e[6],I(Q,"class","svelte-1rsf7jk"),I(C,"class","form-group svelte-1rsf7jk"),I($,"class","create-btn svelte-1rsf7jk"),$.disabled=R=e[6]||!e[9].trim(),I(k,"class","create-form svelte-1rsf7jk"),I(d,"class","section svelte-1rsf7jk"),I(U,"class","svelte-1rsf7jk"),I(j,"class","refresh-btn svelte-1rsf7jk"),j.disabled=e[6],I(T,"class","section svelte-1rsf7jk")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(s,o),f(s,l),f(s,a),f(a,c),p(i,u,h),p(i,d,h),f(d,g),f(d,y),f(d,k),f(k,C),f(C,S),f(C,B),f(C,Q),x(Q,e[9]),f(k,F),f(k,$),f($,D),p(i,P,h),p(i,T,h),f(T,U),f(U,N),f(U,_),f(U,L),f(T,M),Z.m(T,null),f(T,O),f(T,j),f(j,H),p(i,G,h),X&&X.m(i,h),p(i,q,h),J||(K=[A(Q,"input",e[27]),A($,"click",e[14]),A(j,"click",e[13])],J=!0)},p(e,t){32&t[0]&&V!==(V=(e[5].rendezvous_url||"Not configured")+"")&&E(c,V),64&t[0]&&(Q.disabled=e[6]),512&t[0]&&Q.value!==e[9]&&x(Q,e[9]),576&t[0]&&R!==(R=e[6]||!e[9].trim())&&($.disabled=R),16&t[0]&&Y!==(Y=e[4].length+"")&&E(_,Y),W===(W=z(e))&&Z?Z.p(e,t):(Z.d(1),Z=W(e),Z&&(Z.c(),Z.m(T,O))),64&t[0]&&(j.disabled=e[6]),e[7]?X?X.p(e,t):(X=AA(e),X.c(),X.m(q.parentNode,q)):X&&(X.d(1),X=null)},d(e){e&&h(t),e&&h(u),e&&h(d),e&&h(P),e&&h(T),Z.d(),e&&h(G),X&&X.d(e),e&&h(q),J=!1,i(K)}}}function hA(e){let t,n,i,r,s,o,l,a=(e[1]||"none")+"";return{c(){t=m("div"),n=m("p"),n.textContent="Owner permission required for relay connection management.",i=w(),r=m("p"),s=v("Current role: "),o=m("strong"),l=v(a),I(n,"class","svelte-1rsf7jk"),I(r,"class","svelte-1rsf7jk"),I(t,"class","permission-denied svelte-1rsf7jk")},m(e,a){p(e,t,a),f(t,n),f(t,i),f(t,r),f(r,s),f(r,o),f(o,l)},p(e,t){2&t[0]&&a!==(a=(e[1]||"none")+"")&&E(l,a)},d(e){e&&h(t)}}}function gA(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in to manage relay connections.",r=w(),s=m("button"),s.textContent="Log In",I(i,"class","svelte-1rsf7jk"),I(s,"class","login-btn svelte-1rsf7jk"),I(n,"class","login-prompt svelte-1rsf7jk")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[19]),o=!0)},p:e,d(e){e&&h(n),o=!1,l()}}}function mA(e){let t;function n(e,t){return e[3]?IA:kA}let i=n(e),r=i(e);return{c(){t=m("div"),r.c(),I(t,"class","not-enabled svelte-1rsf7jk")},m(e,n){p(e,t,n),r.m(t,null)},p(e,s){i!==(i=n(e))&&(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&h(t),r.d()}}}function yA(e){let t,n=e[4],i=[];for(let t=0;tORLY_NRC_ENABLED=true and configure ORLY_NRC_RENDEZVOUS_URL to enable.',I(t,"class","svelte-1rsf7jk"),I(i,"class","svelte-1rsf7jk")},m(e,r){p(e,t,r),p(e,n,r),p(e,i,r)},d(e){e&&h(t),e&&h(n),e&&h(i)}}}function IA(e){let t,n,i;return{c(){t=m("p"),t.textContent="NRC requires the Badger database backend.",n=w(),i=m("p"),i.innerHTML='Set ORLY_DB_TYPE=badger to enable NRC functionality.',I(t,"class","svelte-1rsf7jk"),I(i,"class","svelte-1rsf7jk")},m(e,r){p(e,t,r),p(e,n,r),p(e,i,r)},d(e){e&&h(t),e&&h(n),e&&h(i)}}}function CA(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,C,x,S,B,Q;return{c(){t=m("div"),n=m("div"),r=m("h3"),s=v('Connection URI for "'),o=v(e[12]),l=v('"'),a=w(),c=m("p"),c.textContent="Copy this URI to your Nostr client to connect to this relay remotely.\n Keep it secret - anyone with this URI can access your relay.",u=w(),d=m("div"),g=m("textarea"),y=w(),b=m("div"),C=m("button"),C.textContent="Copy to Clipboard",x=w(),S=m("button"),S.textContent="Close",I(r,"class","svelte-1rsf7jk"),I(c,"class","modal-description svelte-1rsf7jk"),g.readOnly=!0,g.value=e[11],I(g,"class","svelte-1rsf7jk"),I(d,"class","uri-display svelte-1rsf7jk"),I(C,"class","copy-btn svelte-1rsf7jk"),I(S,"class","close-btn svelte-1rsf7jk"),I(b,"class","modal-actions svelte-1rsf7jk"),I(n,"class","modal svelte-1rsf7jk"),I(t,"class","modal-overlay svelte-1rsf7jk")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),f(n,u),f(n,d),f(d,g),f(n,y),f(n,b),f(b,C),f(b,x),f(b,S),B||(Q=[A(C,"click",e[17]),A(S,"click",e[18]),A(n,"click",k(e[26])),A(t,"click",e[18])],B=!0)},p(e,t){4096&t[0]&&E(o,e[12]),2048&t[0]&&(g.value=e[11])},d(e){e&&h(t),B=!1,i(Q)}}}function EA(t){let n,i,r,s,o,l,a;function c(e,t){return e[2]?e[0]?"owner"!==e[1]?hA:pA:gA:mA}let u=c(t),d=u(t),g=t[10]&&CA(t);return{c(){n=m("div"),i=m("h2"),i.textContent="Relay Connect",r=w(),s=m("p"),s.textContent="Nostr Relay Connect (NRC) allows remote access to this relay through a public relay tunnel.\n Create connection strings for your devices to sync securely.",o=w(),d.c(),l=w(),g&&g.c(),a=b(),I(i,"class","svelte-1rsf7jk"),I(s,"class","description svelte-1rsf7jk"),I(n,"class","relay-connect-view svelte-1rsf7jk")},m(e,t){p(e,n,t),f(n,i),f(n,r),f(n,s),f(n,o),d.m(n,null),p(e,l,t),g&&g.m(e,t),p(e,a,t)},p(e,t){u===(u=c(e))&&d?d.p(e,t):(d.d(1),d=u(e),d&&(d.c(),d.m(n,null))),e[10]?g?g.p(e,t):(g=CA(e),g.c(),g.m(a.parentNode,a)):g&&(g.d(1),g=null)},i:e,o:e,d(e){e&&h(n),d.d(),e&&h(l),g&&g.d(e),e&&h(a)}}}function xA(e){return e?new Date(1e3*e).toLocaleString():"Never"}function SA(e,t,n){let i,r;u(e,mp,e=>n(25,r=e));let{isLoggedIn:s=!1}=t,{userRole:o=""}=t,{userSigner:l=null}=t,{userPubkey:a=""}=t;const c=U();let d=!1,f=!1,p=[],h={},g=!1,m="",y="info",v="",w=!1,b="",A="",k=!1,I="";async function C(){console.log("[RelayConnectView] loadNRCConfig called, current relayUrl:",r);try{const e=await sA();console.log("[RelayConnectView] NRC config result:",e),n(2,d=e.enabled),n(3,f=e.badger_required),d&&s&&"owner"===o&&await E()}catch(e){console.error("Failed to load NRC config:",e)}}async function E(){if(s&&l&&a){n(6,g=!0);try{const e=await async function(e,t){const n=`${xp()}/api/nrc/connections`,i=await iA(e,t,"GET",n),r=await fetch(n,{headers:i?{Authorization:`Nostr ${i}`}:{}});if(!r.ok){const e=await r.text();throw new Error(e||`Failed to get NRC connections: ${r.statusText}`)}return await r.json()}(l,a);n(4,p=e.connections||[]),n(5,h=e.config||{})}catch(e){B(`Failed to load connections: ${e.message}`,"error")}finally{n(6,g=!1)}}}async function x(e,t){if(confirm(`Are you sure you want to delete the connection "${t}"? This will revoke access for any device using this connection.`)){n(6,g=!0);try{await async function(e,t,n){const i=`${xp()}/api/nrc/connections/${n}`,r=await iA(e,t,"DELETE",i),s=await fetch(i,{method:"DELETE",headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to delete NRC connection: ${s.statusText}`)}return await s.json()}(l,a,e),await E(),B(`Connection "${t}" deleted`,"success")}catch(e){B(`Failed to delete connection: ${e.message}`,"error")}finally{n(6,g=!1)}}}async function S(e,t){n(6,g=!0);try{const i=await async function(e,t,n){const i=`${xp()}/api/nrc/connections/${n}/uri`,r=await iA(e,t,"GET",i),s=await fetch(i,{headers:r?{Authorization:`Nostr ${r}`}:{}});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to get NRC URI: ${s.statusText}`)}return await s.json()}(l,a,e);n(11,b=i.uri),n(12,A=t),n(10,w=!0)}catch(e){B(`Failed to get URI: ${e.message}`,"error")}finally{n(6,g=!1)}}function B(e,t="info"){n(7,m=e),n(8,y=t),setTimeout(()=>{m===e&&n(7,m="")},5e3)}P(async()=>{n(23,I=r||""),await C(),n(22,k=!0)});return e.$$set=e=>{"isLoggedIn"in e&&n(0,s=e.isLoggedIn),"userRole"in e&&n(1,o=e.userRole),"userSigner"in e&&n(20,l=e.userSigner),"userPubkey"in e&&n(21,a=e.userPubkey)},e.$$.update=()=>{33554432&e.$$.dirty[0]&&n(24,i=r),29360128&e.$$.dirty[0]&&k&&i!==I&&(n(23,I=i),console.log("[RelayConnectView] Relay changed, reloading..."),n(4,p=[]),n(5,h={}),n(2,d=!1),C()),7&e.$$.dirty[0]&&s&&"owner"===o&&d&&E()},[s,o,d,f,p,h,g,m,y,v,w,b,A,E,async function(){if(v.trim()){n(6,g=!0);try{const e=await async function(e,t,n){const i=`${xp()}/api/nrc/connections`,r=await iA(e,t,"POST",i),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...r?{Authorization:`Nostr ${r}`}:{}},body:JSON.stringify({label:n})});if(!s.ok){const e=await s.text();throw new Error(e||`Failed to create NRC connection: ${s.statusText}`)}return await s.json()}(l,a,v.trim());n(11,b=e.uri),n(12,A=e.label),n(10,w=!0),n(9,v=""),await E(),B(`Connection "${e.label}" created successfully`,"success")}catch(e){B(`Failed to create connection: ${e.message}`,"error")}finally{n(6,g=!1)}}else B("Please enter a label for the connection","error")},x,S,async function(e){const t=await uA(b);dA(e.target.closest("button"),t),t||B("Failed to copy to clipboard","error")},function(){n(10,w=!1),n(11,b=""),n(12,A="")},function(){c("openLoginModal")},l,a,k,I,i,r,function(t){N.call(this,e,t)},function(){v=this.value,n(9,v)},e=>S(e.id,e.label),e=>x(e.id,e.label)]}class BA extends ae{constructor(e){super(),le(this,e,SA,EA,s,{isLoggedIn:0,userRole:1,userSigner:20,userPubkey:21},null,[-1,-1])}}function QA(e){let t,n,i,r,s,o,l,a,c,u,d;return{c(){t=m("div"),n=m("div"),i=m("h3"),i.textContent="Active Filter",r=w(),s=m("button"),s.textContent="🧹 Sweep",o=w(),l=m("div"),a=m("pre"),c=v(e[2]),I(i,"class","svelte-1tyqaa5"),I(s,"class","sweep-btn svelte-1tyqaa5"),I(s,"title","Clear filter"),I(n,"class","filter-display-header svelte-1tyqaa5"),I(a,"class","filter-json svelte-1tyqaa5"),I(l,"class","filter-json-container svelte-1tyqaa5"),I(t,"class","filter-display svelte-1tyqaa5")},m(h,g){p(h,t,g),f(t,n),f(n,i),f(n,r),f(n,s),f(t,o),f(t,l),f(l,a),f(a,c),u||(d=A(s,"click",e[3]),u=!0)},p(e,t){4&t&&E(c,e[2])},d(e){e&&h(t),u=!1,d()}}}function FA(t){let n,i=t[0]&&t[1]&&QA(t);return{c(){i&&i.c(),n=b()},m(e,t){i&&i.m(e,t),p(e,n,t)},p(e,[t]){e[0]&&e[1]?i?i.p(e,t):(i=QA(e),i.c(),i.m(n.parentNode,n)):i&&(i.d(1),i=null)},i:e,o:e,d(e){i&&i.d(e),e&&h(n)}}}function $A(e,t,n){let i,r;const s=U();let{filter:o={}}=t,{showFilter:l=!0}=t;return e.$$set=e=>{"filter"in e&&n(4,o=e.filter),"showFilter"in e&&n(0,l=e.showFilter)},e.$$.update=()=>{16&e.$$.dirty&&n(2,i=function(e){return JSON.stringify(e,null,2)}(o)),16&e.$$.dirty&&n(1,r=Object.keys(o).length>0)},[l,r,i,function(){s("sweep")},o]}class DA extends ae{constructor(e){super(),le(this,e,$A,FA,s,{filter:4,showFilter:0})}}function RA(e,t,n){const i=e.slice();return i[20]=t[n],i}function PA(e){let t,n,r,s,o,l,a,c,u,d,g,y,v,b,C,E,S,B,Q,$,D,R,P,T,U,N;function _(e,t){return e[3]&&!e[5]?UA:TA}let L=_(e),M=L(e),O=e[4]&&NA(e);function j(e,t){return e[6].length>0?LA:_A}let H=j(e),G=H(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("h2"),s.textContent="Relay Manager",o=w(),l=m("button"),l.textContent="×",a=w(),c=m("div"),u=m("div"),d=m("div"),d.textContent="Add Relay",g=w(),y=m("div"),v=m("input"),b=w(),C=m("button"),M.c(),S=w(),O&&O.c(),B=w(),Q=m("div"),$=m("div"),$.textContent="Saved Relays",D=w(),G.c(),R=w(),P=m("div"),T=m("button"),T.textContent="Done",I(s,"class","svelte-6a0diz"),I(l,"class","close-btn svelte-6a0diz"),I(r,"class","modal-header svelte-6a0diz"),I(d,"class","section-header svelte-6a0diz"),I(v,"type","text"),I(v,"placeholder","wss://relay.example.com"),v.disabled=e[3],I(v,"class","url-input svelte-6a0diz"),I(C,"class","add-btn svelte-6a0diz"),C.disabled=E=e[3]||!e[2].trim(),I(y,"class","input-row svelte-6a0diz"),I(u,"class","add-relay-section svelte-6a0diz"),I($,"class","section-header svelte-6a0diz"),I(Q,"class","saved-relays-section svelte-6a0diz"),I(T,"class","done-btn svelte-6a0diz"),I(P,"class","button-group svelte-6a0diz"),I(c,"class","modal-content svelte-6a0diz"),I(n,"class","modal svelte-6a0diz"),F(n,"dark",e[1]),I(t,"class","modal-overlay svelte-6a0diz")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),f(c,u),f(u,d),f(u,g),f(u,y),f(y,v),x(v,e[2]),f(y,b),f(y,C),M.m(C,null),f(c,S),O&&O.m(c,null),f(c,B),f(c,Q),f(Q,$),f(Q,D),G.m(Q,null),f(c,R),f(c,P),f(P,T),U||(N=[A(l,"click",e[7]),A(v,"input",e[14]),A(v,"keydown",e[11]),A(C,"click",e[9]),A(T,"click",e[7]),A(n,"click",k(e[13])),A(t,"click",e[7])],U=!0)},p(e,t){8&t&&(v.disabled=e[3]),4&t&&v.value!==e[2]&&x(v,e[2]),L!==(L=_(e))&&(M.d(1),M=L(e),M&&(M.c(),M.m(C,null))),12&t&&E!==(E=e[3]||!e[2].trim())&&(C.disabled=E),e[4]?O?O.p(e,t):(O=NA(e),O.c(),O.m(c,B)):O&&(O.d(1),O=null),H===(H=j(e))&&G?G.p(e,t):(G.d(1),G=H(e),G&&(G.c(),G.m(Q,null))),2&t&&F(n,"dark",e[1])},d(e){e&&h(t),M.d(),O&&O.d(),G.d(),U=!1,i(N)}}}function TA(e){let t;return{c(){t=v("Add")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function UA(e){let t;return{c(){t=v("Adding...")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function NA(e){let t,n;return{c(){t=m("div"),n=v(e[4]),I(t,"class","error-message svelte-6a0diz")},m(e,i){p(e,t,i),f(t,n)},p(e,t){16&t&&E(n,e[4])},d(e){e&&h(t)}}}function _A(t){let n;return{c(){n=m("div"),n.textContent="No saved relays. Add one above to get started.",I(n,"class","empty-state svelte-6a0diz")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function LA(e){let t,n=e[6],i=[];for(let t=0;tn(17,i=e)),u(e,mp,e=>n(18,r=e)),u(e,kp,e=>n(6,s=e));const o=U();let{showModal:l=!1}=t,{isDarkTheme:a=!1}=t,c="",d=!1,f="",p="";function h(){n(0,l=!1),n(4,f=""),o("close")}async function g(e=null){const t=e||c.trim();if(t){n(3,d=!0),n(5,p=t),n(4,f="");try{const e=await Fp(t);if(e.success){Ip(t,Dp(t)),n(2,c=""),o("connected",{info:e.info}),h()}else n(4,f=e.error||"Failed to connect")}catch(e){n(4,f=e.message||"Connection failed")}finally{n(3,d=!1),n(5,p="")}}else n(4,f="Please enter a relay URL")}async function m(){const e=c.trim();if(e){n(3,d=!0),n(4,f="");try{const t=await Fp(e);if(t.success){Ip(e,Dp(e)),n(2,c=""),o("connected",{info:t.info})}else n(4,f=t.error||"Failed to connect")}catch(e){n(4,f=e.message||"Connection failed")}finally{n(3,d=!1)}}else n(4,f="Please enter a relay URL")}function y(e,t){t.stopPropagation(),function(e){kp.update(t=>t.filter(t=>t.url!==e))}(e)}return e.$$set=e=>{"showModal"in e&&n(0,l=e.showModal),"isDarkTheme"in e&&n(1,a=e.isDarkTheme)},e.$$.update=()=>{1&e.$$.dirty&&l&&(n(2,c=""),n(4,f=""))},[l,a,c,d,f,p,s,h,g,m,y,function(e){"Enter"!==e.key||d?"Escape"===e.key&&h():m()},function(e){return r===e&&"connected"===i},function(t){N.call(this,e,t)},function(){c=this.value,n(2,c),n(0,l)},e=>g(e.url),(e,t)=>y(e.url,t)]}class qA extends ae{constructor(e){super(),le(this,e,GA,HA,s,{showModal:0,isDarkTheme:1})}}class JA{constructor(e,t,n){this.relayUrl=e,this.userSigner=t,this.userPubkey=n,this.ws=null,this.challenge=null,this.isAuthenticated=!1,this.authPromise=null}async connect(){return new Promise((e,t)=>{this.ws=new WebSocket(this.relayUrl),this.ws.onopen=()=>{console.log("WebSocket connected to relay:",this.relayUrl),e()},this.ws.onmessage=async e=>{try{const t=JSON.parse(e.data);await this.handleMessage(t)}catch(e){console.error("Error parsing relay message:",e)}},this.ws.onerror=e=>{console.error("WebSocket error:",e),t(new Error("Failed to connect to relay"))},this.ws.onclose=()=>{console.log("WebSocket connection closed"),this.isAuthenticated=!1,this.challenge=null},setTimeout(()=>{this.ws.readyState!==WebSocket.OPEN&&t(new Error("Connection timeout"))},1e4)})}async handleMessage(e){const[t,...n]=e;switch(t){case"AUTH":this.challenge=n[0],console.log("Received AUTH challenge:",this.challenge),await this.authenticate();break;case"OK":const[e,i,r]=n;e&&i?(console.log("Authentication successful for event:",e),this.isAuthenticated=!0,this.authPromise&&(this.authPromise.resolve(),this.authPromise=null)):e&&!i&&(console.error("Authentication failed:",r),this.authPromise&&(this.authPromise.reject(new Error(r||"Authentication failed")),this.authPromise=null));break;case"NOTICE":console.log("Relay notice:",n[0]);break;default:console.log("Unhandled message type:",t,n)}}async authenticate(){if(!this.challenge)throw new Error("No challenge received from relay");if(!this.userSigner)throw new Error("No signer available for authentication");try{const e={kind:22242,created_at:Math.floor(Date.now()/1e3),tags:[["relay",this.relayUrl],["challenge",this.challenge]],content:"",pubkey:this.userPubkey},t=["AUTH",await this.userSigner.signEvent(e)];return this.ws.send(JSON.stringify(t)),console.log("Sent authentication event to relay"),new Promise((e,t)=>{this.authPromise={resolve:e,reject:t},setTimeout(()=>{this.authPromise&&(this.authPromise.reject(new Error("Authentication timeout")),this.authPromise=null)},1e4)})}catch(e){throw console.error("Authentication error:",e),e}}async publishEvent(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");return new Promise((t,n)=>{const i=["EVENT",e];this.ws.send(JSON.stringify(i));const r=this.ws.onmessage,s=setTimeout(()=>{this.ws.onmessage=r,n(new Error("Publish timeout"))},15e3);this.ws.onmessage=async i=>{try{const o=JSON.parse(i.data),[l,a,c,u]=o;if("OK"===l&&a===e.id)if(c)clearTimeout(s),this.ws.onmessage=r,console.log("Event published successfully:",a),t({success:!0,eventId:a,reason:u});else{if(console.error("Event publish failed:",u),u&&u.includes("auth-required"))return void console.log("Authentication required, waiting for AUTH challenge...");clearTimeout(s),this.ws.onmessage=r,n(new Error(`Publish failed: ${u}`))}else if("AUTH"===l){this.challenge=o[1],console.log("Received AUTH challenge during publish:",this.challenge);try{await this.authenticate(),console.log("Authentication successful, retrying event publish...");const t=["EVENT",e];this.ws.send(JSON.stringify(t))}catch(e){clearTimeout(s),this.ws.onmessage=r,n(new Error(`Authentication failed: ${e.message}`))}}else await this.handleMessage(o)}catch(e){clearTimeout(s),this.ws.onmessage=r,n(e)}}})}close(){this.ws&&(this.ws.close(),this.ws=null),this.isAuthenticated=!1,this.challenge=null}getAuthenticated(){return this.isAuthenticated}}async function KA(e,t,n,i){const r=new JA(e,n,i);try{await r.connect();return await r.publishEvent(t)}finally{r.close()}}function VA(e,t,n){const i=e.slice();return i[192]=t[n],i}function YA(e,t,n){const i=e.slice();return i[202]=t[n],i}function zA(e,t,n){const i=e.slice();return i[195]=t[n],i}function WA(e,t,n){const i=e.slice();i[195]=t[n];const r=i[57](i[195]);return i[196]=r,i}function ZA(e,t,n){const i=e.slice();return i[199]=t[n],i}function XA(t){let n;function i(e,t){return e[1]?hk:pk}let r=i(t),s=r(t);return{c(){n=m("div"),s.c(),I(n,"class","welcome-message svelte-1qbmv87")},m(e,t){p(e,n,t),s.m(n,null)},p(e,t){r===(r=i(e))&&s?s.p(e,t):(s.d(1),s=r(e),s&&(s.c(),s.m(n,null)))},i:e,o:e,d(e){e&&h(n),s.d()}}}function ek(e){let t,n,i=e[6],r=[];for(let t=0;tte(r[e],1,1,()=>{r[e]=null});return{c(){for(let e=0;e=0||""!==t[39]&&parseInt(t[39])>=0,R=Tp,P=[];for(let e=0;eEvent Recovery \n

    Search and recover old versions of replaceable events

    ',s=w(),o=m("div"),l=m("div"),a=m("div"),c=m("label"),c.textContent="Select Event Kind:",u=w(),d=m("select"),y=m("option"),y.textContent="Choose a replaceable kind...";for(let e=0;et[129].call(d)),I(a,"class","kind-selector svelte-1qbmv87"),I(k,"for","custom-kind"),I(k,"class","svelte-1qbmv87"),I(S,"id","custom-kind"),I(S,"type","number"),I(S,"placeholder","e.g., 10001"),I(S,"min","0"),I(S,"class","svelte-1qbmv87"),I(b,"class","custom-kind-input svelte-1qbmv87"),I(l,"class","recovery-controls svelte-1qbmv87"),I(o,"class","recovery-controls-card svelte-1qbmv87"),I(n,"class","recovery-tab svelte-1qbmv87")},m(e,i){p(e,n,i),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(a,c),f(a,u),f(a,d),f(d,y);for(let e=0;e=0||""!==e[39]&&parseInt(e[39])>=0),D?T?T.p(e,t):(T=Ek(e),T.c(),T.m(n,null)):T&&(T.d(1),T=null)},i:e,o:e,d(e){e&&h(n),g(P,e),T&&T.d(),F=!1,i($)}}}function nk(t){let n,i,r=t[45],o=Pk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Pk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function ik(t){let n,i,r=t[45],o=Tk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Tk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function rk(e){let t,n,i;function r(t){e[128](t)}let s={isLoggedIn:e[1],userRole:e[4],isPolicyAdmin:lI,policyEnabled:e[8],isLoadingPolicy:e[30],policyMessage:e[31],policyMessageType:e[32],validationErrors:e[33],policyFollows:e[34]};return void 0!==e[29]&&(s.policyJson=e[29]),t=new Rv({props:s}),L.push(()=>ne(t,"policyJson",r)),t.$on("loadPolicy",e[69]),t.$on("validatePolicy",e[70]),t.$on("savePolicy",e[71]),t.$on("formatJson",e[72]),t.$on("addPolicyAdmin",e[73]),t.$on("removePolicyAdmin",e[74]),t.$on("refreshFollows",e[75]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,n){re(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),1073741824&i[0]&&(r.isLoadingPolicy=e[30]),1&i[1]&&(r.policyMessage=e[31]),2&i[1]&&(r.policyMessageType=e[32]),4&i[1]&&(r.validationErrors=e[33]),8&i[1]&&(r.policyFollows=e[34]),!n&&536870912&i[0]&&(n=!0,r.policyJson=e[29],q(()=>n=!1)),t.$set(r)},i(e){i||(ee(t.$$.fragment,e),i=!0)},o(e){te(t.$$.fragment,e),i=!1},d(e){se(t,e)}}}function sk(e){let t,n,i;function r(t){e[125](t)}let s={isLoggedIn:e[1],userRole:e[4],sprocketStatus:e[23],isLoadingSprocket:e[25],sprocketUploadFile:e[28],sprocketMessage:e[26],sprocketMessageType:e[27],sprocketVersions:e[24]};return void 0!==e[22]&&(s.sprocketScript=e[22]),t=new hv({props:s}),L.push(()=>ne(t,"sprocketScript",r)),t.$on("restartSprocket",e[64]),t.$on("deleteSprocket",e[65]),t.$on("sprocketFileSelect",e[76]),t.$on("uploadSprocketScript",e[77]),t.$on("saveSprocket",e[63]),t.$on("loadSprocket",e[62]),t.$on("loadVersions",e[66]),t.$on("loadVersion",e[126]),t.$on("deleteVersion",e[127]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,n){re(t,e,n),i=!0},p(e,i){const r={};2&i[0]&&(r.isLoggedIn=e[1]),16&i[0]&&(r.userRole=e[4]),8388608&i[0]&&(r.sprocketStatus=e[23]),33554432&i[0]&&(r.isLoadingSprocket=e[25]),268435456&i[0]&&(r.sprocketUploadFile=e[28]),67108864&i[0]&&(r.sprocketMessage=e[26]),134217728&i[0]&&(r.sprocketMessageType=e[27]),16777216&i[0]&&(r.sprocketVersions=e[24]),!n&&4194304&i[0]&&(n=!0,r.sprocketScript=e[22],q(()=>n=!1)),t.$set(r)},i(e){i||(ee(t.$$.fragment,e),i=!0)},o(e){te(t.$$.fragment,e),i=!1},d(e){se(t,e)}}}function ok(e){let t,n,i,r;const s=[_k,Nk,Uk],o=[];function l(e,t){return"curating"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=s[n](e),{c(){t=m("div"),i.c(),I(t,"class","curation-view-container")},m(e,i){p(e,t,i),o[n].m(t,null),r=!0},p(e,r){let a=n;n=l(e),n===a?o[n].p(e,r):(Z(),te(o[a],1,1,()=>{o[a]=null}),X(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),ee(i,1),i.m(t,null))},i(e){r||(ee(i),r=!0)},o(e){te(i),r=!1},d(e){e&&h(t),o[n].d()}}}function lk(e){let t,n,i,r;const s=[jk,Ok,Mk],o=[];function l(e,t){return"managed"!==e[9]?0:e[1]&&"owner"===e[4]?1:2}return n=l(e),i=o[n]=s[n](e),{c(){t=m("div"),i.c(),I(t,"class","managed-acl-view svelte-1qbmv87")},m(e,i){p(e,t,i),o[n].m(t,null),r=!0},p(e,r){let a=n;n=l(e),n===a?o[n].p(e,r):(Z(),te(o[a],1,1,()=>{o[a]=null}),X(),i=o[n],i?i.p(e,r):(i=o[n]=s[n](e),i.c()),ee(i,1),i.m(t,null))},i(e){r||(ee(i),r=!0)},o(e){te(i),r=!1},d(e){e&&h(t),o[n].d()}}}function ak(e){let t,n,i;function r(t){e[124](t)}let s={userPubkey:e[2],userRole:e[4],policyEnabled:e[8],publishError:e[37]};return void 0!==e[36]&&(s.composeEventJson=e[36]),t=new nv({props:s}),L.push(()=>ne(t,"composeEventJson",r)),t.$on("reformatJson",e[101]),t.$on("signEvent",e[102]),t.$on("publishEvent",e[103]),t.$on("clearError",e[104]),{c(){ie(t.$$.fragment)},m(e,n){re(t,e,n),i=!0},p(e,i){const r={};4&i[0]&&(r.userPubkey=e[2]),16&i[0]&&(r.userRole=e[4]),256&i[0]&&(r.policyEnabled=e[8]),64&i[1]&&(r.publishError=e[37]),!n&&32&i[1]&&(n=!0,r.composeEventJson=e[36],q(()=>n=!1)),t.$set(r)},i(e){i||(ee(t.$$.fragment,e),i=!0)},o(e){te(t.$$.fragment,e),i=!1},d(e){se(t,e)}}}function ck(t){let n,i,r=t[45],o=Gk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Gk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function uk(e){let t,n;return t=new Uy({props:{isLoggedIn:e[1],userRole:e[4],userPubkey:e[2],filteredEvents:e[44],expandedEvents:e[21],isLoadingEvents:e[7],showOnlyMyEvents:oI,showFilterBuilder:e[18]}}),t.$on("scroll",e[100]),t.$on("toggleEventExpansion",e[120]),t.$on("deleteEvent",e[121]),t.$on("copyEventToClipboard",e[122]),t.$on("toggleChange",e[50]),t.$on("loadAllEvents",e[123]),t.$on("toggleFilterBuilder",e[87]),t.$on("filterApply",e[88]),t.$on("filterClear",e[89]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),16&n[0]&&(i.userRole=e[4]),4&n[0]&&(i.userPubkey=e[2]),8192&n[1]&&(i.filteredEvents=e[44]),2097152&n[0]&&(i.expandedEvents=e[21]),128&n[0]&&(i.isLoadingEvents=e[7]),262144&n[0]&&(i.showFilterBuilder=e[18]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function dk(e){let t,n;return t=new Um({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],selectedFile:e[19],aclMode:e[9],importMessage:e[20]}}),t.$on("fileSelect",e[97]),t.$on("importEvents",e[98]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),524288&n[0]&&(i.selectedFile=e[19]),512&n[0]&&(i.aclMode=e[9]),1048576&n[0]&&(i.importMessage=e[20]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function fk(e){let t,n;return t=new Qm({props:{isLoggedIn:e[1],currentEffectiveRole:e[10],aclMode:e[9]}}),t.$on("exportMyEvents",e[96]),t.$on("exportAllEvents",e[95]),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),1024&n[0]&&(i.currentEffectiveRole=e[10]),512&n[0]&&(i.aclMode=e[9]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function pk(t){let n;return{c(){n=m("p"),n.textContent="Log in to access your user dashboard",I(n,"class","svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function hk(e){let t,n,i,r=(e[3]?.name||e[2].slice(0,8)+"...")+"";return{c(){t=m("p"),n=v("Welcome "),i=v(r),I(t,"class","svelte-1qbmv87")},m(e,r){p(e,t,r),f(t,n),f(t,i)},p(e,t){12&t[0]&&r!==(r=(e[3]?.name||e[2].slice(0,8)+"...")+"")&&E(i,r)},d(e){e&&h(t)}}}function gk(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,x,S,B,Q,F,$,D=e[202].label+"",R=e[47].get(e[202].id)?.isLoading,P=!e[47].get(e[202].id)?.hasMore&&e[47].get(e[202].id)?.events?.length>0;function T(){return e[134](e[202])}function U(e,t){return 64&t[0]&&(k=null),64&t[0]&&(C=null),null==k&&(k=!!(e[47].get(e[202].id)?.events?.length>0)),k?yk:(null==C&&(C=!e[47].get(e[202].id)?.isLoading),C?mk:void 0)}g=new DA({props:{filter:e[47].get(e[202].id)?.filter||{}}}),g.$on("sweep",function(){return e[135](e[202])});let N=U(e,[-1,-1,-1,-1,-1,-1,-1]),_=N&&N(e),L=R&&Ak(),M=P&&kk();function O(...t){return e[140](e[202],...t)}return{c(){t=m("div"),n=m("div"),r=m("h2"),s=v("🔍 "),o=v(D),l=w(),a=m("button"),c=v("🔄 Refresh"),d=w(),ie(g.$$.fragment),y=w(),b=m("div"),_&&_.c(),x=w(),L&&L.c(),S=w(),M&&M.c(),B=w(),I(r,"class","svelte-1qbmv87"),I(a,"class","refresh-btn svelte-1qbmv87"),a.disabled=u=e[47].get(e[202].id)?.isLoading,I(n,"class","search-results-header svelte-1qbmv87"),I(b,"class","search-results-content svelte-1qbmv87"),I(t,"class","search-results-view svelte-1qbmv87")},m(e,i){p(e,t,i),f(t,n),f(n,r),f(r,s),f(r,o),f(n,l),f(n,a),f(a,c),f(t,d),re(g,t,null),f(t,y),f(t,b),_&&_.m(b,null),f(b,x),L&&L.m(b,null),f(b,S),M&&M.m(b,null),f(t,B),Q=!0,F||($=[A(a,"click",T),A(b,"scroll",O)],F=!0)},p(t,n){e=t,(!Q||64&n[0])&&D!==(D=e[202].label+"")&&E(o,D),(!Q||64&n[0]&&u!==(u=e[47].get(e[202].id)?.isLoading))&&(a.disabled=u);const i={};64&n[0]&&(i.filter=e[47].get(e[202].id)?.filter||{}),g.$set(i),N===(N=U(e,n))&&_?_.p(e,n):(_&&_.d(1),_=N&&N(e),_&&(_.c(),_.m(b,x))),64&n[0]&&(R=e[47].get(e[202].id)?.isLoading),R?L||(L=Ak(),L.c(),L.m(b,S)):L&&(L.d(1),L=null),64&n[0]&&(P=!e[47].get(e[202].id)?.hasMore&&e[47].get(e[202].id)?.events?.length>0),P?M||(M=kk(),M.c(),M.m(b,null)):M&&(M.d(1),M=null)},i(e){Q||(ee(g.$$.fragment,e),Q=!0)},o(e){te(g.$$.fragment,e),Q=!1},d(e){e&&h(t),se(g),_&&_.d(),L&&L.d(),M&&M.d(),F=!1,i($)}}}function mk(t){let n;return{c(){n=m("div"),n.innerHTML='

    No search results found.

    ',I(n,"class","no-search-results svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function yk(e){let t,n=e[47].get(e[202].id).events,i=[];for(let t=0;t👤',s=w(),o=m("div"),l=m("div"),a=v(_),c=w(),u=m("div"),d=m("span"),g=v(L),y=w(),b=m("span"),k=v(M),C=w(),x=m("div"),S=m("div"),B=v(O),Q=w(),$=m("div"),D=v(j),R=w(),G&&G.c(),P=w(),K&&K.c(),T=w(),I(r,"class","search-result-avatar svelte-1qbmv87"),I(l,"class","search-result-author svelte-1qbmv87"),I(d,"class","kind-number svelte-1qbmv87"),I(b,"class","kind-name svelte-1qbmv87"),I(u,"class","search-result-kind svelte-1qbmv87"),I(o,"class","search-result-info svelte-1qbmv87"),I(S,"class","event-timestamp svelte-1qbmv87"),I($,"class","event-content-single-line svelte-1qbmv87"),I(x,"class","search-result-content svelte-1qbmv87"),I(n,"class","search-result-row svelte-1qbmv87"),I(n,"role","button"),I(n,"tabindex","0"),I(t,"class","search-result-item svelte-1qbmv87"),F(t,"expanded",e[21].has(e[195].id))},m(e,i){p(e,t,i),f(t,n),f(n,r),f(n,s),f(n,o),f(o,l),f(l,a),f(o,c),f(o,u),f(u,d),f(d,g),f(u,y),f(u,b),f(b,k),f(n,C),f(n,x),f(x,S),f(S,B),f(x,Q),f(x,$),f($,D),f(n,R),G&&G.m(n,null),f(t,P),K&&K.m(t,null),f(t,T),U||(N=[A(n,"click",q),A(n,"keydown",J)],U=!0)},p(i,r){e=i,64&r[0]&&_!==(_=lA(e[195].pubkey)+"")&&E(a,_),64&r[0]&&L!==(L=e[195].kind+"")&&E(g,L),64&r[0]&&M!==(M=oA(e[195].kind)+"")&&E(k,M),64&r[0]&&O!==(O=cA(e[195].created_at)+"")&&E(B,O),64&r[0]&&j!==(j=aA(e[195].content)+"")&&E(D,j),5!==e[195].kind&&("admin"===e[4]||"owner"===e[4]||"write"===e[4]&&e[195].pubkey&&e[195].pubkey===e[2])?G?G.p(e,r):(G=vk(e),G.c(),G.m(n,null)):G&&(G.d(1),G=null),2097216&r[0]&&(H=e[21].has(e[195].id)),H?K?K.p(e,r):(K=wk(e),K.c(),K.m(t,T)):K&&(K.d(1),K=null),2097216&r[0]|65536&r[1]&&F(t,"expanded",e[21].has(e[195].id))},d(e){e&&h(t),G&&G.d(),K&&K.d(),U=!1,i(N)}}}function Ak(e){let t;return{c(){t=m("div"),t.innerHTML='
    \n

    Searching...

    ',I(t,"class","loading-search-results svelte-1qbmv87")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function kk(e){let t;return{c(){t=m("div"),t.innerHTML='

    No more search results to load.

    ',I(t,"class","end-of-search-results svelte-1qbmv87")},m(e,n){p(e,t,n)},d(e){e&&h(t)}}}function Ik(e){let t,n,i=e[202].id===e[5]&&gk(e);return{c(){i&&i.c(),t=b()},m(e,r){i&&i.m(e,r),p(e,t,r),n=!0},p(e,n){e[202].id===e[5]?i?(i.p(e,n),96&n[0]&&ee(i,1)):(i=gk(e),i.c(),ee(i,1),i.m(t.parentNode,t)):i&&(Z(),te(i,1,1,()=>{i=null}),X())},i(e){n||(ee(i),n=!0)},o(e){te(i),n=!1},d(e){i&&i.d(e),e&&h(t)}}}function Ck(t){let n,i,r=t[199].label+"";return{c(){n=m("option"),i=v(r),n.__value=t[199].value,n.value=n.__value},m(e,t){p(e,n,t),f(n,i)},p:e,d(e){e&&h(n)}}}function Ek(e){let t;function n(e,t){return e[41]?Bk:0===e[40].length?Sk:xk}let i=n(e),r=i(e);return{c(){t=m("div"),r.c(),I(t,"class","recovery-results svelte-1qbmv87")},m(e,n){p(e,t,n),r.m(t,null)},p(e,s){i===(i=n(e))&&r?r.p(e,s):(r.d(1),r=i(e),r&&(r.c(),r.m(t,null)))},d(e){e&&h(t),r.d()}}}function xk(e){let t,n,i,r=e[40],s=[];for(let t=0;tORLY_ACL_MODE=curating in your\n environment variables and restart the relay.',I(i,"class","svelte-1qbmv87"),I(s,"class","svelte-1qbmv87"),I(l,"class","svelte-1qbmv87"),I(g,"class","svelte-1qbmv87"),I(n,"class","acl-mode-warning svelte-1qbmv87")},m(e,t){p(e,n,t),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),f(l,a),f(l,c),f(c,u),f(n,d),f(n,g)},p(e,t){512&t[0]&&y!==(y=(e[9]||"unknown")+"")&&E(u,y)},i:e,o:e,d(e){e&&h(n)}}}function Lk(e){let t,n;return t=new Gw({props:{userSigner:e[15],userPubkey:e[2]}}),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};32768&n[0]&&(i.userSigner=e[15]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function Mk(t){let n,i,r,s,o,l;return{c(){n=m("div"),i=m("p"),i.textContent="Please log in with owner permissions to access\n managed ACL configuration.",r=w(),s=m("button"),s.textContent="Log In",I(s,"class","login-btn svelte-1qbmv87"),I(n,"class","access-denied")},m(e,a){p(e,n,a),f(n,i),f(n,r),f(n,s),o||(l=A(s,"click",t[79]),o=!0)},p:e,i:e,o:e,d(e){e&&h(n),o=!1,l()}}}function Ok(t){let n,i,r=t[45],o=Hk(t);return{c(){o.c(),n=b()},m(e,t){o.m(e,t),p(e,n,t),i=!0},p(t,i){16384&i[1]&&s(r,r=t[45])?(Z(),te(o,1,1,e),X(),o=Hk(t),o.c(),ee(o,1),o.m(n.parentNode,n)):o.p(t,i)},i(e){i||(ee(o),i=!0)},o(e){te(o),i=!1},d(e){e&&h(n),o.d(e)}}}function jk(t){let n,i,r,s,o,l,a,c,u,d,g,y=(t[9]||"unknown")+"";return{c(){n=m("div"),i=m("h3"),i.textContent="⚠️ Managed ACL Mode Not Active",r=w(),s=m("p"),s.textContent='To use the Managed ACL interface, you need to set\n the ACL mode to "managed" in your relay\n configuration.',o=w(),l=m("p"),a=v("Current ACL mode: "),c=m("strong"),u=v(y),d=w(),g=m("p"),g.innerHTML='Please set ORLY_ACL_MODE=managed in your\n environment variables and restart the relay.',I(i,"class","svelte-1qbmv87"),I(s,"class","svelte-1qbmv87"),I(l,"class","svelte-1qbmv87"),I(g,"class","svelte-1qbmv87"),I(n,"class","acl-mode-warning svelte-1qbmv87")},m(e,t){p(e,n,t),f(n,i),f(n,r),f(n,s),f(n,o),f(n,l),f(l,a),f(l,c),f(c,u),f(n,d),f(n,g)},p(e,t){512&t[0]&&y!==(y=(e[9]||"unknown")+"")&&E(u,y)},i:e,o:e,d(e){e&&h(n)}}}function Hk(e){let t,n;return t=new Xg({props:{userSigner:e[15],userPubkey:e[2]}}),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};32768&n[0]&&(i.userSigner=e[15]),4&n[0]&&(i.userPubkey=e[2]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function Gk(e){let t,n;return t=new Ub({props:{isLoggedIn:e[1],userPubkey:e[2],userSigner:e[15],currentEffectiveRole:e[10]}}),t.$on("openLoginModal",e[79]),{c(){ie(t.$$.fragment)},m(e,i){re(t,e,i),n=!0},p(e,n){const i={};2&n[0]&&(i.isLoggedIn=e[1]),4&n[0]&&(i.userPubkey=e[2]),32768&n[0]&&(i.userSigner=e[15]),1024&n[0]&&(i.currentEffectiveRole=e[10]),t.$set(i)},i(e){n||(ee(t.$$.fragment,e),n=!0)},o(e){te(t.$$.fragment,e),n=!1},d(e){se(t,e)}}}function qk(e){let t,n,r,s,o,l,a,c,u,d,g;function y(e,t){return e[3]?Kk:e[1]&&e[2]?Jk:void 0}let v=y(e),b=v&&v(e),C=e[46]&&tI(e);return{c(){t=m("div"),n=m("div"),r=m("div"),s=m("h2"),s.textContent="Settings",o=w(),l=m("button"),l.textContent="✕",a=w(),c=m("div"),b&&b.c(),u=w(),C&&C.c(),I(s,"class","svelte-1qbmv87"),I(l,"class","close-btn svelte-1qbmv87"),I(r,"class","drawer-header svelte-1qbmv87"),I(c,"class","drawer-content"),I(n,"class","settings-drawer svelte-1qbmv87"),F(n,"dark-theme",e[0]),I(t,"class","drawer-overlay svelte-1qbmv87"),I(t,"role","button"),I(t,"tabindex","0")},m(i,h){p(i,t,h),f(t,n),f(n,r),f(r,s),f(r,o),f(r,l),f(n,a),f(n,c),b&&b.m(c,null),f(c,u),C&&C.m(c,null),d||(g=[A(l,"click",e[84]),A(n,"click",k(e[115])),A(n,"keydown",k(e[116])),A(t,"click",e[84]),A(t,"keydown",e[143])],d=!0)},p(e,t){v===(v=y(e))&&b?b.p(e,t):(b&&b.d(1),b=v&&v(e),b&&(b.c(),b.m(c,u))),e[46]?C?C.p(e,t):(C=tI(e),C.c(),C.m(c,null)):C&&(C.d(1),C=null),1&t[0]&&F(n,"dark-theme",e[0])},d(e){e&&h(t),b&&b.d(),C&&C.d(),d=!1,i(g)}}}function Jk(e){let t,n,r,s,o,l,a,c,u,d,g,y,b,k,C,x,S,B=e[2].slice(0,16)+"",Q=e[2].slice(-8)+"";return{c(){t=m("div"),n=m("button"),n.textContent="Log out",r=w(),s=m("h3"),s.textContent="Profile Loading",o=w(),l=m("p"),l.textContent="Your profile metadata is being loaded...",a=w(),c=m("button"),c.textContent="Retry Loading Profile",u=w(),d=m("div"),g=m("strong"),g.textContent="Public Key:",y=w(),b=v(B),k=v("..."),C=v(Q),I(n,"class","logout-btn floating svelte-1qbmv87"),I(s,"class","svelte-1qbmv87"),I(l,"class","svelte-1qbmv87"),I(c,"class","retry-profile-btn svelte-1qbmv87"),I(d,"class","user-pubkey-display svelte-1qbmv87"),I(t,"class","profile-loading-section svelte-1qbmv87")},m(i,h){p(i,t,h),f(t,n),f(t,r),f(t,s),f(t,o),f(t,l),f(t,a),f(t,c),f(t,u),f(t,d),f(d,g),f(d,y),f(d,b),f(d,k),f(d,C),x||(S=[A(n,"click",e[81]),A(c,"click",e[94])],x=!0)},p(e,t){4&t[0]&&B!==(B=e[2].slice(0,16)+"")&&E(b,B),4&t[0]&&Q!==(Q=e[2].slice(-8)+"")&&E(C,Q)},d(e){e&&h(t),x=!1,i(S)}}}function Kk(e){let t,n,i,r,s,o,l,a,c,u,d,g,y,k,C,x=(e[3].name||"Unknown User")+"",S=e[3].banner&&Vk(e);function B(e,t){return e[3].picture?zk:Yk}let Q=B(e),F=Q(e),$=e[3].nip05&&Wk(e),D=e[3].about&&Zk(e),R=e[4]&&"read"!==e[4]&&Xk(e);return{c(){t=m("div"),n=m("div"),S&&S.c(),i=w(),r=m("button"),r.textContent="Log out",s=w(),F.c(),o=w(),l=m("div"),a=m("h3"),c=v(x),u=w(),$&&$.c(),d=w(),D&&D.c(),g=w(),R&&R.c(),y=b(),I(r,"class","logout-btn floating svelte-1qbmv87"),I(a,"class","profile-username svelte-1qbmv87"),I(l,"class","name-row svelte-1qbmv87"),I(n,"class","profile-hero svelte-1qbmv87"),I(t,"class","profile-section svelte-1qbmv87")},m(h,m){p(h,t,m),f(t,n),S&&S.m(n,null),f(n,i),f(n,r),f(n,s),F.m(n,null),f(n,o),f(n,l),f(l,a),f(a,c),f(l,u),$&&$.m(l,null),f(t,d),D&&D.m(t,null),p(h,g,m),R&&R.m(h,m),p(h,y,m),k||(C=A(r,"click",e[81]),k=!0)},p(e,r){e[3].banner?S?S.p(e,r):(S=Vk(e),S.c(),S.m(n,i)):S&&(S.d(1),S=null),Q===(Q=B(e))&&F?F.p(e,r):(F.d(1),F=Q(e),F&&(F.c(),F.m(n,o))),8&r[0]&&x!==(x=(e[3].name||"Unknown User")+"")&&E(c,x),e[3].nip05?$?$.p(e,r):($=Wk(e),$.c(),$.m(l,null)):$&&($.d(1),$=null),e[3].about?D?D.p(e,r):(D=Zk(e),D.c(),D.m(t,null)):D&&(D.d(1),D=null),e[4]&&"read"!==e[4]?R?R.p(e,r):(R=Xk(e),R.c(),R.m(y.parentNode,y)):R&&(R.d(1),R=null)},d(e){e&&h(t),S&&S.d(),F.d(),$&&$.d(),D&&D.d(),e&&h(g),R&&R.d(e),e&&h(y),k=!1,C()}}}function Vk(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[3].banner)||I(t,"src",n),I(t,"alt","Profile banner"),I(t,"class","profile-banner svelte-1qbmv87")},m(e,n){p(e,t,n)},p(e,i){8&i[0]&&!l(t.src,n=e[3].banner)&&I(t,"src",n)},d(e){e&&h(t)}}}function Yk(t){let n;return{c(){n=m("div"),n.textContent="👤",I(n,"class","profile-avatar-placeholder overlap svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function zk(e){let t,n;return{c(){t=m("img"),l(t.src,n=e[3].picture)||I(t,"src",n),I(t,"alt","User avatar"),I(t,"class","profile-avatar overlap svelte-1qbmv87")},m(e,n){p(e,t,n)},p(e,i){8&i[0]&&!l(t.src,n=e[3].picture)&&I(t,"src",n)},d(e){e&&h(t)}}}function Wk(e){let t,n,i=e[3].nip05+"";return{c(){t=m("span"),n=v(i),I(t,"class","profile-nip05-inline svelte-1qbmv87")},m(e,i){p(e,t,i),f(t,n)},p(e,t){8&t[0]&&i!==(i=e[3].nip05+"")&&E(n,i)},d(e){e&&h(t)}}}function Zk(e){let t,n;return{c(){t=m("div"),n=m("p"),I(n,"class","profile-about svelte-1qbmv87"),I(t,"class","about-card svelte-1qbmv87")},m(i,r){p(i,t,r),f(t,n),n.innerHTML=e[43]},p(e,t){4096&t[1]&&(n.innerHTML=e[43])},d(e){e&&h(t)}}}function Xk(e){let t,n,i,r,s,o,l=e[106](),a=[];for(let t=0;t\n Not connected',I(n,"class","relay-disconnected svelte-1qbmv87")},m(e,t){p(e,n,t)},p:e,d(e){e&&h(n)}}}function iI(e){let t,n,i,r,s,o,l,a=(e[12].name||"Unknown relay")+"",c=e[12].description&&rI(e);return{c(){t=m("div"),n=m("div"),i=v(a),r=w(),c&&c.c(),s=w(),o=m("div"),l=v(e[45]),I(n,"class","relay-name svelte-1qbmv87"),I(o,"class","relay-url svelte-1qbmv87"),I(t,"class","relay-info-card svelte-1qbmv87")},m(e,a){p(e,t,a),f(t,n),f(n,i),f(t,r),c&&c.m(t,null),f(t,s),f(t,o),f(o,l)},p(e,n){4096&n[0]&&a!==(a=(e[12].name||"Unknown relay")+"")&&E(i,a),e[12].description?c?c.p(e,n):(c=rI(e),c.c(),c.m(t,s)):c&&(c.d(1),c=null),16384&n[1]&&E(l,e[45])},d(e){e&&h(t),c&&c.d()}}}function rI(e){let t,n,i=e[12].description+"";return{c(){t=m("div"),n=v(i),I(t,"class","relay-description svelte-1qbmv87")},m(e,i){p(e,t,i),f(t,n)},p(e,t){4096&t[0]&&i!==(i=e[12].description+"")&&E(n,i)},d(e){e&&h(t)}}}function sI(e){let t,n,i,r,s,o,l,a,c,u,d,g,y,v,b,A,k;t=new hm({props:{isDarkTheme:e[0],isLoggedIn:e[1],userRole:e[4],currentEffectiveRole:e[10],userProfile:e[3],userPubkey:e[2]}}),t.$on("openSettingsDrawer",e[83]),t.$on("openLoginModal",e[79]),t.$on("openRelayModal",e[59]),t.$on("relayChanged",e[58]),t.$on("toggleMobileMenu",e[85]),r=new km({props:{isDarkTheme:e[0],tabs:e[11],selectedTab:e[5],version:e[35],mobileOpen:e[17]}}),r.$on("selectTab",e[118]),r.$on("closeSearchTab",e[119]),r.$on("closeMobileMenu",e[86]);const C=[fk,dk,uk,ck,ak,lk,ok,sk,rk,ik,nk,tk,ek,XA],E=[];function x(e,t){return 96&t[0]&&(l=null),"export"===e[5]?0:"import"===e[5]?1:"events"===e[5]?2:"blossom"===e[5]?3:"compose"===e[5]?4:"managed-acl"===e[5]?5:"curation"===e[5]?6:"sprocket"===e[5]?7:"policy"===e[5]?8:"relay-connect"===e[5]?9:"logs"===e[5]?10:"recovery"===e[5]?11:(null==l&&(l=!!e[6].some(e[117])),l?12:13)}a=x(e,[-1,-1,-1,-1,-1,-1,-1]),c=E[a]=C[a](e);let S=e[16]&&qk(e);function B(t){e[144](t)}let Q={isDarkTheme:e[0]};function $(t){e[145](t)}void 0!==e[13]&&(Q.showModal=e[13]),g=new ag({props:Q}),L.push(()=>ne(g,"showModal",B)),g.$on("login",e[80]),g.$on("close",e[82]);let D={isDarkTheme:e[0]};return void 0!==e[14]&&(D.showModal=e[14]),b=new qA({props:D}),L.push(()=>ne(b,"showModal",$)),b.$on("connected",e[61]),b.$on("close",e[60]),{c(){ie(t.$$.fragment),n=w(),i=m("div"),ie(r.$$.fragment),s=w(),o=m("main"),c.c(),u=w(),S&&S.c(),d=w(),ie(g.$$.fragment),v=w(),ie(b.$$.fragment),I(o,"class","main-content svelte-1qbmv87"),I(i,"class","app-container svelte-1qbmv87"),F(i,"dark-theme",e[0])},m(e,l){re(t,e,l),p(e,n,l),p(e,i,l),re(r,i,null),f(i,s),f(i,o),E[a].m(o,null),p(e,u,l),S&&S.m(e,l),p(e,d,l),re(g,e,l),p(e,v,l),re(b,e,l),k=!0},p(e,n){const s={};1&n[0]&&(s.isDarkTheme=e[0]),2&n[0]&&(s.isLoggedIn=e[1]),16&n[0]&&(s.userRole=e[4]),1024&n[0]&&(s.currentEffectiveRole=e[10]),8&n[0]&&(s.userProfile=e[3]),4&n[0]&&(s.userPubkey=e[2]),t.$set(s);const l={};1&n[0]&&(l.isDarkTheme=e[0]),2048&n[0]&&(l.tabs=e[11]),32&n[0]&&(l.selectedTab=e[5]),16&n[1]&&(l.version=e[35]),131072&n[0]&&(l.mobileOpen=e[17]),r.$set(l);let u=a;a=x(e,n),a===u?E[a].p(e,n):(Z(),te(E[u],1,1,()=>{E[u]=null}),X(),c=E[a],c?c.p(e,n):(c=E[a]=C[a](e),c.c()),ee(c,1),c.m(o,null)),(!k||1&n[0])&&F(i,"dark-theme",e[0]),e[16]?S?S.p(e,n):(S=qk(e),S.c(),S.m(d.parentNode,d)):S&&(S.d(1),S=null);const f={};1&n[0]&&(f.isDarkTheme=e[0]),!y&&8192&n[0]&&(y=!0,f.showModal=e[13],q(()=>y=!1)),g.$set(f);const p={};1&n[0]&&(p.isDarkTheme=e[0]),!A&&16384&n[0]&&(A=!0,p.showModal=e[14],q(()=>A=!1)),b.$set(p)},i(e){k||(ee(t.$$.fragment,e),ee(r.$$.fragment,e),ee(c),ee(g.$$.fragment,e),ee(b.$$.fragment,e),k=!0)},o(e){te(t.$$.fragment,e),te(r.$$.fragment,e),te(c),te(g.$$.fragment,e),te(b.$$.fragment,e),k=!1},d(e){se(t,e),e&&h(n),e&&h(i),se(r),E[a].d(),e&&h(u),S&&S.d(e),e&&h(d),se(g,e),e&&h(v),se(b,e)}}}let oI=!1,lI=!1;function aI(e,t,n){let i,r,s,o,l,a,d,f,p;u(e,vp,e=>n(12,a=e)),u(e,bp,e=>n(114,d=e)),u(e,mp,e=>n(45,f=e)),u(e,yp,e=>n(46,p=e)),"undefined"!=typeof window&&(window.debugIndexedDB=lh);let h=!1,g=!1,m=!1,y=!1,v="",w="",b=null,A=null,k=null,I="",E=null,x=!1,S=!1,B=localStorage.getItem("selectedTab")||"export",F=!1,$={},D=[],R=[],P=null,T="",U=new Set,_=!1,L=!0,M=null,O="",j=new Map,H=[],G=0,q=[],J=!1,K=!0,V=null,Y="",z=null,W=[],Z=!1,X="",ee="info",te=!1,ne=null,ie="",re=!1,se=!1,oe="",le="info",ae=[],ce=[],ue=!1,de=!0,fe="",pe="",he="",ge="",me=null,ye="",ve=[],we=!1,be=!0,Ae=null;function ke(e){U.has(e)?U.delete(e):U.add(e),n(21,U)}async function Ie(e,t){const n=JSON.stringify(e),i=await uA(n);dA(t.target.closest(".copy-json-btn"),i),i||alert("Failed to copy to clipboard. Please copy manually.")}async function Ce(e){if(!y)return void alert("Please log in first");const t=R.find(t=>t.id===e);if(!t)return void alert("Event not found");if("admin"===I||"owner"===I||"write"===I&&t.pubkey&&t.pubkey===v){if(confirm("Are you sure you want to delete this event?"))try{if(!E)throw new Error("Signer not available for signing");const i={kind:5,created_at:Math.floor(Date.now()/1e3),tags:[["e",e]],content:""};console.log("Created delete event template:",i),console.log("User pubkey:",v),console.log("Target event:",t),console.log("Target event pubkey:",t.pubkey);const r=await E.signEvent(i);console.log("Signed delete event:",r),console.log("Signed delete event pubkey:",r.pubkey),console.log("Delete event tags:",r.tags);const s=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;try{const e=await KA(s,r,E,v);e.success?console.log("Delete event published successfully to ORLY relay"):console.error("Failed to publish delete event:",e.reason)}catch(e){console.error("Error publishing delete event:",e)}const o=t.pubkey&&t.pubkey===v;if(o){const t=await Op.publish(r);if(console.log("Delete event published:",t),!(t.success&&t.okCount>0))throw new Error("No relays accepted the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const n=await ih(e,{timeout:5e3});n?(console.warn("Event still exists after deletion attempt:",n),alert(`Warning: Delete event was accepted by ${t.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await rh(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===v);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(107,R=R.filter(t=>t.id!==e)),q=q.filter(t=>t.id!==e),H=H.filter(t=>t.id!==e);for(const[t,n]of j)n.events&&(n.events=n.events.filter(t=>t.id!==e),j.set(t,n));$e(),console.log("Reloading events to show delete event...");const i=oI&&y&&v?[v]:null;await Xe(!0,i),alert(`Event deleted successfully (accepted by ${t.okCount} relay(s))`)}}else{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=new Mp;await i.connectToRelay(t);const s=await i.publish(r);if(console.log("Delete event published to local relay only:",s),!(s.success&&s.okCount>0))throw new Error("Local relay did not accept the delete event");{await new Promise(e=>setTimeout(e,2e3));try{const t=await ih(e,{timeout:5e3});t?(console.warn("Event still exists after deletion attempt:",t),alert(`Warning: Delete event was accepted by ${s.okCount} relay(s), but the event still exists on the relay. This may indicate the relay does not properly handle delete events.`)):console.log("Event successfully deleted and verified")}catch(e){console.log("Could not fetch event after deletion (likely deleted):",e.message)}try{const t=await rh(e,{timeout:5e3});if(t.length>0){console.log(`Delete event verification: Found ${t.length} delete event(s) targeting ${e}`);const n=t.find(e=>e.pubkey&&e.pubkey===v);n?console.log("Our delete event found in database:",n.id):console.warn("Our delete event not found in database, but other delete events exist")}else console.warn("No delete events found in database for target event:",e)}catch(e){console.log("Could not verify delete event in database:",e.message)}n(107,R=R.filter(t=>t.id!==e)),q=q.filter(t=>t.id!==e),H=H.filter(t=>t.id!==e);for(const[t,n]of j)n.events&&(n.events=n.events.filter(t=>t.id!==e),j.set(t,n));$e(),console.log("Reloading events to show delete event...");const t=oI&&y&&v?[v]:null;await Xe(!0,t),alert("Event deleted successfully (local relay only - admin/owner deleting other user's event)")}}}catch(e){console.error("Failed to delete event:",e),alert("Failed to delete event: "+e.message)}}else alert("You do not have permission to delete this event")}async function Ee(){const e=ye?parseInt(ye):me;if(null==e||isNaN(e))console.log("No valid kind to load, kindToUse:",e);else if(y){console.log("Loading recovery events for kind:",e,"user:",v),n(41,we=!0);try{const t=[{kinds:[e],authors:[v],limit:100}];Ae&&(t[0].until=Ae),console.log("Recovery filters:",t);const i=await oh(t,{timeout:3e4,cacheFirst:!0});console.log("Recovery events received:",i.length),console.log("Recovery events kinds:",i.map(e=>e.kind)),n(40,ve=Ae?[...ve,...i]:i),i.length>0?(Ae=Math.min(...i.map(e=>e.created_at)),n(42,be=100===i.length)):n(42,be=!1)}catch(e){console.error("Failed to load recovery events:",e)}finally{n(41,we=!1)}}else console.log("Not logged in, cannot load recovery events")}async function xe(e){if(confirm("Are you sure you want to repost this event?"))try{const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`;console.log("Reposting event to local relay:",t,e);const i={...e};if(i.created_at=Math.floor(Date.now()/1e3),i.id="",i.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(i.tags=i.tags.filter(e=>"d"!==e[0]),i.tags.push(t))}if(E){const e=await E.signEvent(i);console.log("Signed event for repost:",e);const r=await Op.publish(e,[t]);console.log("Repost publish result:",r),r.success&&r.okCount>0?(alert("Event reposted successfully!"),n(42,be=!1),await Ee()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event:",e),alert("Error reposting event: "+e.message)}}async function Se(e){if(confirm("Are you sure you want to repost this event to all your write relays?"))try{const t=await async function(){if(!v)return[];try{const e=await Yp([{kinds:[10002],authors:[v],limit:1}]);if(0===e.length)return console.log("No relay list event found for user"),[];const t=e[0];console.log("Found relay list event:",t);const n=[];for(const e of t.tags)if("r"===e[0]&&e.length>=2){const t=e[1],i=e.length>=3?e[2]:null;i&&"write"!==i||n.push(t)}return console.log("Found write relays:",n),n}catch(e){return console.error("Error fetching user write relays:",e),[]}}(),i=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,r=[i,...t.filter(e=>e!==i)];1===r.length&&alert("No write relays found in your relay list. Only posting to local relay."),console.log("Reposting event to all relays:",r,e);const s={...e};if(s.created_at=Math.floor(Date.now()/1e3),s.id="",s.sig="",e.kind>=3e4&&e.kind<=39999){const t=e.tags.find(e=>"d"===e[0]);t&&(s.tags=s.tags.filter(e=>"d"!==e[0]),s.tags.push(t))}if(E){const e=await E.signEvent(s);console.log("Signed event for repost to all:",e);const t=await Op.publish(e,r);console.log("Repost to all publish result:",t),t.success&&t.okCount>0?(alert(`Event reposted successfully to ${r.length} relays!`),n(42,be=!1),await Ee()):alert("Failed to repost event. Check console for details.")}else alert("No signer available. Please log in.")}catch(e){console.error("Error reposting event to all:",e),alert("Error reposting event to all: "+e.message)}}let Be="auto";if("undefined"!=typeof window&&window.matchMedia){const e=window.matchMedia("(prefers-color-scheme: dark)");h=e.matches,e.addEventListener("change",e=>{"auto"===Be&&n(0,h=e.matches)}),(async()=>{try{const e=await rA();e?.theme&&"auto"!==e.theme&&(Be=e.theme,n(0,h="dark"===e.theme)),e&&"boolean"==typeof e.blossom_enabled&&n(111,de=e.blossom_enabled)}catch(e){console.log("Could not fetch relay theme config:",e)}})()}if("undefined"!=typeof localStorage){const e=localStorage.getItem("nostr_auth_method"),t=localStorage.getItem("nostr_pubkey");e&&t&&(y=!0,v=t,w=e,"extension"===e&&window.nostr&&(E=window.nostr)),function(){if("undefined"==typeof localStorage)return;try{const t=localStorage.getItem("app_state");if(t){const i=JSON.parse(t);i.selectedTab&&Me.some(e=>e.id===i.selectedTab)&&n(5,B=i.selectedTab),i.expandedEvents&&n(21,U=new Set(i.expandedEvents)),i.globalEventsCache&&(H=i.globalEventsCache),i.globalCacheTimestamp&&(G=i.globalCacheTimestamp),void 0!==i.hasMoreEvents&&(L=i.hasMoreEvents),i.oldestEventTimestamp&&(M=i.oldestEventTimestamp),void 0!==i.hasMoreMyEvents&&(K=i.hasMoreMyEvents),i.oldestMyEventTimestamp&&(V=i.oldestMyEventTimestamp),H.length>0&&((e=G)&&Date.now()-et.created_at-e.created_at),G=Date.now(),$e()}async function Re(){if(y&&"owner"===I&&te)try{n(25,Z=!0);const e=await fetch(`${xp()}/api/sprocket/status`,{method:"GET",headers:{Authorization:`Nostr ${await it("GET",`${xp()}/api/sprocket/status`)}`,"Content-Type":"application/json"}});e.ok?n(23,z=await e.json()):Ne("Failed to load sprocket status","error")}catch(e){Ne(`Error loading sprocket status: ${e.message}`,"error")}finally{n(25,Z=!1)}}async function Pe(){if(y&&"owner"===I)try{n(25,Z=!0);const e=await fetch(`${xp()}/api/sprocket/versions`,{method:"GET",headers:{Authorization:`Nostr ${await it("GET",`${xp()}/api/sprocket/versions`)}`,"Content-Type":"application/json"}});e.ok?n(24,W=await e.json()):Ne("Failed to load versions","error")}catch(e){Ne(`Error loading versions: ${e.message}`,"error")}finally{n(25,Z=!1)}}async function Te(e){y&&"owner"===I&&(n(22,Y=e.content),Ne(`Loaded version: ${e.name}`,"success"))}async function Ue(e){if(y&&"owner"===I&&confirm(`Are you sure you want to delete version ${e}?`))try{n(25,Z=!0);const t=await fetch(`${xp()}/api/sprocket/delete-version`,{method:"POST",headers:{Authorization:`Nostr ${await it("POST",`${xp()}/api/sprocket/delete-version`)}`,"Content-Type":"application/json"},body:JSON.stringify({filename:e})});if(t.ok)Ne(`Version ${e} deleted successfully`,"success"),await Pe();else{Ne(`Failed to delete version: ${await t.text()}`,"error")}}catch(e){Ne(`Error deleting version: ${e.message}`,"error")}finally{n(25,Z=!1)}}function Ne(e,t="info"){n(26,X=e),n(27,ee=t),setTimeout(()=>{n(26,X="")},5e3)}function _e(e,t="info"){n(31,oe=e),n(32,le=t),"error"!==t&&setTimeout(()=>{n(31,oe="")},5e3)}async function Le(){if(n(33,ae=[]),!ie.trim())return n(33,ae=["Policy JSON is empty"]),_e("Validation failed","error"),!1;try{const e=JSON.parse(ie);if("object"!=typeof e||null===e)return n(33,ae=["Policy must be a JSON object"]),_e("Validation failed","error"),!1;if(e.policy_admins)if(Array.isArray(e.policy_admins))for(const t of e.policy_admins)"string"==typeof t&&/^[0-9a-fA-F]{64}$/.test(t)||ae.push(`Invalid policy_admin pubkey: ${t}`);else ae.push("policy_admins must be an array");if(e.rules)if("object"!=typeof e.rules)ae.push("rules must be an object");else for(const[t,n]of Object.entries(e.rules))if(/^\d+$/.test(t)||ae.push(`Invalid kind number: ${t}`),n.tag_validation&&"object"==typeof n.tag_validation)for(const[e,t]of Object.entries(n.tag_validation))try{new RegExp(t)}catch(n){ae.push(`Invalid regex for tag '${e}': ${t}`)}return e.default_policy&&!["allow","deny"].includes(e.default_policy)&&ae.push("default_policy must be 'allow' or 'deny'"),ae.length>0?(_e("Validation failed - see errors below","error"),!1):(_e("Validation passed","success"),!0)}catch(e){return n(33,ae=[`JSON parse error: ${e.message}`]),_e("Invalid JSON syntax","error"),!1}}const Me=[{id:"export",icon:"📤",label:"Export"},{id:"import",icon:"💾",label:"Import",requiresAdmin:!0},{id:"events",icon:"📡",label:"Events"},{id:"blossom",icon:"🌸",label:"Blossom"},{id:"compose",icon:"✏️",label:"Compose",requiresWrite:!0},{id:"recovery",icon:"🔄",label:"Recovery"},{id:"managed-acl",icon:"🛡️",label:"Managed ACL",requiresOwner:!0},{id:"curation",icon:"📋",label:"Curation",requiresOwner:!0},{id:"sprocket",icon:"⚙️",label:"Sprocket",requiresOwner:!0},{id:"policy",icon:"📜",label:"Policy",requiresOwner:!0},{id:"relay-connect",icon:"🔗",label:"Relay Connect",requiresOwner:!0},{id:"logs",icon:"📋",label:"Logs",requiresOwner:!0}];function Oe(e){n(5,B=e),"sprocket"===e&&y&&"owner"===I&&te&&(Re(),Pe()),$e()}function je(){n(16,x=!1)}function He(e){Ge(e)}function Ge(e){n(6,D=D.filter(t=>t.id!==e)),j.delete(e),B===e&&n(5,B="export")}async function qe(e,t=!0){const n=j.get(e);if(n&&!n.isLoading){n.isLoading=!0,j.set(e,n);try{const i={...n.filter};!t&&n.oldestTimestamp&&(i.until=n.oldestTimestamp),t||(i.limit=200),console.log("Loading search results with filter:",i);const r=await nh([i],{timeout:3e4});if(console.log("Received search results:",r.length,"events"),n.events=t?r.sort((e,t)=>t.created_at-e.created_at):[...n.events,...r].sort((e,t)=>t.created_at-e.created_at),r.length>0){const e=Math.min(...r.map(e=>e.created_at));(!n.oldestTimestamp||et.created_at-e.created_at):[...q,...t].sort((e,t)=>t.created_at-e.created_at),t.length>0){const e=Math.min(...t.map(e=>e.created_at));(!V||e{if("myevents"===B){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&async function(){!J&&K&&await Ze(!1)}()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{J=!1}}}else alert("Please log in first")}async function Xe(e=!1,t=null){if(!y||"read"!==I&&"write"!==I&&"admin"!==I&&"owner"!==I)alert("Read, write, admin, or owner permission required");else if(!_){n(7,_=!0),e&&(M=null);try{console.log("Loading events with authors filter:",t,"including delete events");const i=e?Math.floor(Date.now()/1e3):M,r=$.authors||t,s=await async function(e={}){const{limit:t=100,since:n=null,until:i=null,authors:r=null,kinds:s=null,...o}=e,l=Math.floor(Date.now()/1e3),a=n||l-15768e4,c=[{...o}];return c[0].since=a,i&&(c[0].until=i),r&&(c[0].authors=r),s&&(c[0].kinds=s),t&&(c[0].limit=t),await nh(c,{timeout:3e4})}({...$,limit:e?100:200,until:$.until||i,authors:r});if(console.log("Received events:",s.length,"events"),t&&s.length>0){const e=s.filter(e=>e.pubkey&&e.pubkey!==v);e.length>0&&console.warn("Server returned non-user events:",e.length,"out of",s.length)}if(e?(n(107,R=s.sort((e,t)=>t.created_at-e.created_at)),De(s)):(n(107,R=[...R,...s].sort((e,t)=>t.created_at-e.created_at)),De(R)),s.length>0){const e=Math.min(...s.map(e=>e.created_at));(!M||e{if("events"===B){const e=document.querySelectorAll(".events-view-content")[0];e&&e.scrollHeight<=e.clientHeight&&et()}},100)}catch(e){console.error("Failed to load events:",e),alert("Failed to load events: "+e.message)}finally{n(7,_=!1)}}}async function et(){await Xe(!1)}let tt=!1;async function nt(e,t){if(!y||!v)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",e],["method",t.toUpperCase()]],content:"",pubkey:v};let i;if(E&&"extension"===w)try{i=await E.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==w)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),i=n}const r=JSON.stringify(i);return`Nostr ${btoa(r)}`}async function it(e,t){if(!y||!v)throw new Error("Not logged in");const n={kind:27235,created_at:Math.floor(Date.now()/1e3),tags:[["u",t],["method",e.toUpperCase()]],content:"",pubkey:v};let i;if(E&&"extension"===w)try{i=await E.signEvent(n)}catch(e){throw new Error("Failed to sign with extension: "+e.message)}else{if("nsec"!==w)throw new Error("No valid signer available");n.id="mock-id-"+Date.now(),n.sig="mock-signature-"+Date.now(),i=n}const r=JSON.stringify(i);return btoa(r)}function rt(e,t){const n=e.toLowerCase();if(n.includes("policy")||n.includes("blocked")||n.includes("denied")){let n=`Policy Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} may be restricted by the relay's policy configuration.`),re&&(n+="\n\nThe relay has policy enforcement enabled. Contact a relay administrator to allow this event kind or adjust your permissions."),n}if(n.includes("auth")||n.includes("permission")||n.includes("unauthorized"))return`Permission Error: ${e}\n\nYour current permissions may not allow publishing this type of event. Current role: ${I||"unknown"}. Contact a relay administrator to upgrade your permissions.`;if(n.includes("kind")||n.includes("not allowed")||n.includes("restricted")){let n=`Event Type Error: ${e}`;return null!==t&&(n+=`\n\nKind ${t} is not currently allowed on this relay.`),n+="\n\nThe relay administrator may need to update the policy configuration to allow this event kind.",n}return n.includes("rate")||n.includes("limit")||n.includes("too many")?`Rate Limit Error: ${e}\n\nPlease wait a moment before trying again.`:n.includes("size")||n.includes("too large")||n.includes("content")?`Size Limit Error: ${e}\n\nThe event may exceed the relay's size limits. Try reducing the content length.`:`Publishing failed: ${e}`}function st(e){n(108,O=e),localStorage.setItem("viewAsRole",e),console.log("View as role changed to:",e,"Current effective role:",l)}O=localStorage.getItem("viewAsRole")||"";return e.$$.update=()=>{var t;if(4096&e.$$.dirty[0]&&a&&"boolean"==typeof a.blossom_enabled&&n(111,de=a.blossom_enabled),6&e.$$.dirty[0]|16384&e.$$.dirty[3]&&n(44,i=R.sort((e,t)=>t.created_at-e.created_at)),8&e.$$.dirty[0]&&n(43,r=b?.about?(t=b.about,t?t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"):"").replace(/\n{2,}/g,"
    "):""),16&e.$$.dirty[0]|32768&e.$$.dirty[3]&&n(10,l=O&&""!==O?O:I),1810&e.$$.dirty[0]|2588672&e.$$.dirty[3]&&n(113,s=Me.filter(e=>{const t=l;if(e.requiresAdmin&&(!y||"admin"!==t&&"owner"!==t))return!1;if(e.requiresOwner&&(!y||"owner"!==t))return!1;if(e.requiresWrite&&(!y||"read"===t))return!1;return!(["sprocket","policy","managed-acl","curation","logs","relay-connect"].includes(e.id)&&!d)&&(!("sprocket"===e.id&&!te)&&(!("policy"===e.id&&!re)&&(!("relay-connect"===e.id&&!ue)&&(("managed-acl"!==e.id||"managed"===fe)&&(("curation"!==e.id||"curating"===fe)&&(!("blossom"===e.id&&!de)&&(console.log(`Tab ${e.id} filter check:`,{isLoggedIn:y,userRole:I,viewAsRole:O,currentRole:t,requiresAdmin:e.requiresAdmin,requiresOwner:e.requiresOwner,requiresWrite:e.requiresWrite,visible:!0}),!0)))))))})),64&e.$$.dirty[0]|1048576&e.$$.dirty[3]&&n(11,o=[...s,...D]),2578&e.$$.dirty[0]|1048576&e.$$.dirty[3]&&console.log("Tabs debug:",{isLoggedIn:y,userRole:I,aclMode:fe,filteredBaseTabs:s.map(e=>e.id),allTabs:o.map(e=>e.id)}),1&e.$$.dirty[0]&&"undefined"!=typeof document&&(h?document.body.classList.add("dark-theme"):document.body.classList.remove("dark-theme")),14&e.$$.dirty[0]&&y&&v&&!b&&Ke(),182&e.$$.dirty[0]|540672&e.$$.dirty[3]&&"events"===B&&y&&("read"===I||"write"===I||"admin"===I||"owner"===I)&&0===R.length&&!tt&&!_){n(112,tt=!0);Xe(!0,null)}32&e.$$.dirty[0]|16384&e.$$.dirty[3]&&("events"!==B||"events"===B&&R.length>0)&&n(112,tt=!1),32&e.$$.dirty[0]&&localStorage.setItem("selectedTab",B)},[h,y,v,b,I,B,D,_,re,fe,l,o,a,g,m,E,x,S,F,P,T,U,Y,z,W,Z,X,ee,ne,ie,se,oe,le,ae,ce,pe,he,ge,me,ye,ve,we,be,r,i,f,p,j,ke,Ie,async function(){console.log("Toggle changed, showOnlyMyEvents:",oI),n(112,tt=!1),await Xe(!0,null)},Ce,Ee,xe,Se,function(){console.log("selectRecoveryKind called, recoverySelectedKind:",me),null!=me?(n(39,ye=""),n(40,ve=[]),Ae=null,n(42,be=!0),Ee()):console.log("No kind selected, skipping load")},function(){console.log("handleCustomKindInput called, recoveryCustomKind:",ye);const e=parseInt(ye);""!==ye&&!isNaN(e)&&e>=0&&(n(38,me=null),n(40,ve=[]),Ae=null,n(42,be=!0),Ee())},function(e){const t=ve.filter(t=>t.kind===e.kind&&t.pubkey===e.pubkey),n=Math.max(...t.map(e=>e.created_at));return e.created_at===n},async function(e){console.log("Relay changed:",e.detail?.info?.name),Op.reset(),await async function(){console.log("[nostr] Clearing IndexedDB cache...");try{const e=(await Jp()).transaction(qp,"readwrite").objectStore(qp);await new Promise((t,n)=>{const i=e.clear();i.onsuccess=()=>t(),i.onerror=()=>n(i.error)}),console.log("[nostr] IndexedDB cache cleared")}catch(e){console.warn("[nostr] Failed to clear IndexedDB cache",e)}}(),H=[],G=0,n(112,tt=!1),n(107,R=[]),q=[],L=!0,K=!0,M=null,j.clear(),n(6,D=[]),Qe(),"events"===B&&y?Xe(!0):"myevents"===B&&y&&Ze(!0)},Fe,function(){n(14,m=!1)},async function(e){console.log("Connected to relay:",e.detail?.info?.name),Op&&Op.refreshRelays(),await Qe()},async function(){if(y&&"owner"===I)try{n(25,Z=!0);const e=await fetch(`${xp()}/api/sprocket/status`,{method:"GET",headers:{Authorization:`Nostr ${await it("GET",`${xp()}/api/sprocket/status`)}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(22,Y=t.script_content||""),n(23,z=t),Ne("Script loaded successfully","success")}else Ne("Failed to load script","error")}catch(e){Ne(`Error loading script: ${e.message}`,"error")}finally{n(25,Z=!1)}},async function(){if(y&&"owner"===I)try{n(25,Z=!0);const e=await fetch(`${xp()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await it("POST",`${xp()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:Y});if(e.ok)Ne("Script saved and updated successfully","success"),await Re(),await Pe();else{Ne(`Failed to save script: ${await e.text()}`,"error")}}catch(e){Ne(`Error saving script: ${e.message}`,"error")}finally{n(25,Z=!1)}},async function(){if(y&&"owner"===I)try{n(25,Z=!0);const e=await fetch(`${xp()}/api/sprocket/restart`,{method:"POST",headers:{Authorization:`Nostr ${await it("POST",`${xp()}/api/sprocket/restart`)}`,"Content-Type":"application/json"}});if(e.ok)Ne("Sprocket restarted successfully","success"),await Re();else{Ne(`Failed to restart sprocket: ${await e.text()}`,"error")}}catch(e){Ne(`Error restarting sprocket: ${e.message}`,"error")}finally{n(25,Z=!1)}},async function(){if(y&&"owner"===I&&confirm("Are you sure you want to delete the sprocket script? This will stop the current process."))try{n(25,Z=!0);const e=await fetch(`${xp()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await it("POST",`${xp()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:""});if(e.ok)n(22,Y=""),Ne("Sprocket script deleted successfully","success"),await Re(),await Pe();else{Ne(`Failed to delete script: ${await e.text()}`,"error")}}catch(e){Ne(`Error deleting script: ${e.message}`,"error")}finally{n(25,Z=!1)}},Pe,Te,Ue,async function(){if(y&&("owner"===I||lI))try{n(30,se=!0),n(33,ae=[]);const e={kinds:[12345],limit:1},t=await oh(e);if(t&&t.length>0){n(29,ie=t[0].content);try{n(29,ie=JSON.stringify(JSON.parse(ie),null,2))}catch(e){}_e("Policy loaded successfully","success")}else{const e=await fetch(`${xp()}/api/policy`,{method:"GET",headers:{Authorization:`Nostr ${await it("GET",`${xp()}/api/policy`)}`,"Content-Type":"application/json"}});if(e.ok){const t=await e.json();n(29,ie=JSON.stringify(t,null,2)),_e("Policy loaded from file","success")}else _e("No policy configuration found","info"),n(29,ie="")}}catch(e){_e(`Error loading policy: ${e.message}`,"error")}finally{n(30,se=!1)}},Le,async function(){if(!y||"owner"!==I&&!lI)return;if(await Le())try{n(30,se=!0);const e={kind:12345,created_at:Math.floor(Date.now()/1e3),tags:[],content:ie},t=await KA(e,E);t.success?_e("Policy updated successfully","success"):_e(`Failed to publish policy: ${t.error||"Unknown error"}`,"error")}catch(e){_e(`Error saving policy: ${e.message}`,"error")}finally{n(30,se=!1)}},function(){try{const e=JSON.parse(ie);n(29,ie=JSON.stringify(e,null,2)),_e("JSON formatted","success")}catch(e){_e(`Cannot format: ${e.message}`,"error")}},function(e){const t=e.detail;if(!t)return void _e("Please enter a pubkey","error");const i=function(e){if(!e)return null;if(/^[0-9a-fA-F]{64}$/.test(e))return e.toLowerCase();if(e.startsWith("npub1"))try{const t="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n=e.slice(5);let i=[];for(const e of n){const n=t.indexOf(e.toLowerCase());if(-1===n)throw new Error("Invalid character in npub");i.push(...[...Array(5)].map((e,t)=>n>>4-t&1))}i=i.slice(0,-30);const r=[];for(let e=0;e+8<=i.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|i[e+n];r.push(t)}return r.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Failed to decode npub:",e),null}return null}(t);if(i&&64===i.length)try{const e=JSON.parse(ie||"{}");if(e.policy_admins||(e.policy_admins=[]),e.policy_admins.includes(i))return void _e("Admin already in list","warning");e.policy_admins.push(i),n(29,ie=JSON.stringify(e,null,2)),_e("Admin added - click 'Save & Publish' to apply","info")}catch(e){_e(`Error adding admin: ${e.message}`,"error")}else _e("Invalid pubkey format. Use hex (64 chars) or npub","error")},function(e){const t=e.detail;try{const e=JSON.parse(ie||"{}");e.policy_admins&&(e.policy_admins=e.policy_admins.filter(e=>e!==t),n(29,ie=JSON.stringify(e,null,2)),_e("Admin removed - click 'Save & Publish' to apply","info"))}catch(e){_e(`Error removing admin: ${e.message}`,"error")}},async function(){if(y&&("owner"===I||lI))try{n(30,se=!0),n(34,ce=[]);let e=[];try{e=JSON.parse(ie||"{}").policy_admins||[]}catch(e){return void _e("Cannot parse policy JSON to get admins","error")}if(0===e.length)return void _e("No policy admins configured","warning");const t={kinds:[3],authors:e,limit:e.length},i=await oh(t),r=new Set;for(const e of i)if(e.tags)for(const t of e.tags)"p"===t[0]&&t[1]&&64===t[1].length&&r.add(t[1]);n(34,ce=Array.from(r)),_e(`Loaded ${ce.length} follows from ${i.length} admin(s)`,"success")}catch(e){_e(`Error loading follows: ${e.message}`,"error")}finally{n(30,se=!1)}},function(e){n(28,ne=e.target.files[0])},async function(){if(y&&"owner"===I&&ne)try{n(25,Z=!0);const e=await ne.text(),t=await fetch(`${xp()}/api/sprocket/update`,{method:"POST",headers:{Authorization:`Nostr ${await it("POST",`${xp()}/api/sprocket/update`)}`,"Content-Type":"text/plain"},body:e});if(t.ok)n(22,Y=e),Ne("Script uploaded and updated successfully","success"),await Re(),await Pe();else{Ne(`Failed to upload script: ${await t.text()}`,"error")}}catch(e){Ne(`Error uploading script: ${e.message}`,"error")}finally{n(25,Z=!1),n(28,ne=null);const e=document.getElementById("sprocket-upload-file");e&&(e.value="")}},Oe,function(){y||n(13,g=!0)},async function(e){const{method:t,pubkey:i,privateKey:r,signer:s}=e.detail;n(1,y=!0),n(2,v=i),w=t,n(15,E=s),n(13,g=!1);try{if(await sh(),"extension"===t&&s)Op.setSigner(s);else if("nsec"===t&&r){const e=new gf(r);Op.setSigner(e)}n(3,b=await Wp(i)),console.log("Profile loaded:",b),A=await async function(e){console.log(`[nostr] Fetching relay list for pubkey: ${e?.substring(0,8)}...`);const t=[{kinds:[10002],authors:[e],limit:1}];try{const e=await nh(t,{timeout:1e4,useCache:!0});if(e.length>0){const t=e.sort((e,t)=>t.created_at-e.created_at)[0];return console.log("[nostr] Relay list found on local relay"),Xp(t)}}catch(e){console.warn("[nostr] Failed to fetch relay list from local relay:",e)}console.log("[nostr] Relay list not found locally, trying fallback relays...");try{const e=await eh(t);if(e){await Kp(e);try{await Op.publish(e)}catch(e){console.warn("[nostr] Failed to publish relay list to local relay:",e)}return Xp(e)}}catch(e){console.warn("[nostr] Failed to fetch relay list from fallback relays:",e)}return console.log("[nostr] No relay list found for pubkey"),null}(i),A&&console.log("User relay list loaded:",A.all.length,"relays"),k=await async function(e){console.log(`[nostr] Fetching contact list for pubkey: ${e?.substring(0,8)}...`);const t=[{kinds:[3],authors:[e],limit:1}];try{const e=await nh(t,{timeout:1e4,useCache:!0});if(e.length>0){const t=e.sort((e,t)=>t.created_at-e.created_at)[0];return console.log("[nostr] Contact list found on local relay"),th(t)}}catch(e){console.warn("[nostr] Failed to fetch contact list from local relay:",e)}console.log("[nostr] Contact list not found locally, trying fallback relays...");try{const e=await eh(t);if(e){await Kp(e);try{await Op.publish(e)}catch(e){console.warn("[nostr] Failed to publish contact list to local relay:",e)}return th(e)}}catch(e){console.warn("[nostr] Failed to fetch contact list from fallback relays:",e)}return console.log("[nostr] No contact list found for pubkey"),null}(i),k&&console.log("User contact list loaded:",k.follows.length,"follows")}catch(e){console.error("Failed to load profile:",e)}await Ve(),await ze()},function(){n(1,y=!1),n(2,v=""),w="",n(3,b=null),A=null,k=null,n(4,I=""),n(15,E=null),userPrivkey=null,n(16,x=!1),q=[],n(107,R=[]),H=[],G=0,$e(),"undefined"!=typeof localStorage&&(localStorage.removeItem("nostr_auth_method"),localStorage.removeItem("nostr_pubkey"),localStorage.removeItem("nostr_privkey"))},function(){n(13,g=!1)},function(){n(16,x=!0)},je,function(){n(17,S=!S)},function(){n(17,S=!1)},function(){n(18,F=!F)},function(e){const{searchText:t,selectedKinds:n,pubkeys:i,eventIds:r,tags:s,sinceTimestamp:o,untilTimestamp:l,limit:a}=e.detail,c=function({searchText:e=null,kinds:t=[],authors:n=[],ids:i=[],tags:r=[],since:s=null,until:o=null,limit:l=null}){const a={};return e&&e.trim()&&(a.search=e.trim()),t&&t.length>0&&(a.kinds=t),n&&n.length>0&&(a.authors=n),i&&i.length>0&&(a.ids=i),r&&r.length>0&&r.forEach(e=>{if(e.name&&e.value){const t=`#${e.name}`;a[t]||(a[t]=[]),a[t].push(e.value)}}),s&&(a.since=s),o&&(a.until=o),l&&l>0&&(a.limit=l),a}({searchText:t,kinds:n,authors:i,ids:r,tags:s,since:o,until:l,limit:a||100});$=c,Xe(!0,null)},function(){$={},Xe(!0,null)},He,Ge,qe,Je,Ke,async function(){await We([])},async function(){await We([v])},function(e){n(19,P=e.detail.target.files[0])},async function(){if("none"!==fe&&(!y||"admin"!==I&&"owner"!==I))return n(20,T="Admin or owner permission required"),void setTimeout(()=>{n(20,T="")},5e3);if(!P)return n(20,T="Please select a file"),void setTimeout(()=>{n(20,T="")},5e3);try{n(20,T="Uploading...");const e={};"none"!==fe&&y&&(e.Authorization=await nt(`${xp()}/api/import`,"POST"));const t=new FormData;t.append("file",P);const i=await fetch(`${xp()}/api/import`,{method:"POST",headers:e,body:t});if(!i.ok)throw new Error(`Import failed: ${i.status} ${i.statusText}`);await i.json();n(20,T="Upload complete"),n(19,P=null),document.getElementById("import-file").value="",setTimeout(()=>{n(20,T="")},5e3)}catch(e){console.error("Import failed:",e),n(20,T="Import failed: "+e.message),setTimeout(()=>{n(20,T="")},5e3)}},Xe,function(e){const{scrollTop:t,scrollHeight:n,clientHeight:i}=e.target;n-t-i<100&&et()},function(){try{if(!he.trim())return void alert("Please enter some JSON to reformat");const e=JSON.parse(he);n(36,he=JSON.stringify(e,null,2))}catch(e){alert("Invalid JSON: "+e.message)}},async function(){try{if(!he.trim())return void alert("Please enter an event to sign");if(!y||!v)return void alert("Please log in to sign events");if(!E)return void alert("No signer available. Please log in with a valid authentication method.");const e=JSON.parse(he);e.pubkey=v,e.created_at=Math.floor(Date.now()/1e3),delete e.id,delete e.sig;const t=await E.signEvent(e);n(36,he=JSON.stringify(t,null,2)),alert("Event signed successfully!")}catch(e){console.error("Error signing event:",e),alert("Error signing event: "+e.message)}},async function(){n(37,ge="");try{if(!he.trim())return void n(37,ge="Please enter an event to publish");if(!y)return void n(37,ge="Please log in to publish events");if(!E)return void n(37,ge="No signer available. Please log in with a valid authentication method.");let e;try{e=JSON.parse(he)}catch(e){return void n(37,ge=`Invalid JSON: ${e.message}`)}if(!e.id||!e.sig)return void n(37,ge='Event must be signed before publishing. Please click "Sign" first.');if("read"===I)return void n(37,ge=`Permission denied: Your current role is "${I}" which does not allow publishing events. Contact a relay administrator to upgrade your permissions.`);const t=`${window.location.protocol.startsWith("https")?"wss:":"ws:"}//${window.location.host}/`,i=await KA(t,e,E,v);if(i.success)n(37,ge=""),alert("Event published successfully to ORLY relay!");else{const t=i.reason||"Unknown error";n(37,ge=rt(t,e.kind))}}catch(e){console.error("Error publishing event:",e);const t=e.message||"Unknown error";n(37,ge=rt(t,null))}},function(){n(37,ge="")},st,function(){const e=["owner","admin","write","read"],t=e.indexOf(I);return-1===t?["read"]:e.slice(t)},R,O,te,ue,de,tt,s,d,function(t){N.call(this,e,t)},function(t){N.call(this,e,t)},e=>e.id===B,e=>Oe(e.detail),e=>Ge(e.detail),e=>ke(e.detail),e=>Ce(e.detail),e=>Ie(e.detail.event,e.detail.e),e=>Xe(e.detail.refresh,e.detail.authors),function(e){he=e,n(36,he)},function(e){Y=e,n(22,Y)},e=>Te(e.detail),e=>Ue(e.detail),function(e){ie=e,n(29,ie)},function(){me=Q(this),n(38,me)},function(){ye=C(this.value),n(39,ye)},e=>Se(e),e=>xe(e),(e,t)=>Ie(e,t),e=>qe(e.id,!0),e=>He(e.id),e=>Ce(e.id),e=>ke(e.id),(e,t)=>"Enter"===t.key&&ke(e.id),(e,t)=>Ie(e,t),(e,t)=>Je(t,e.id),e=>st(e===I?"":e),()=>{je(),Fe()},e=>"Escape"===e.key&&je(),function(e){g=e,n(13,g)},function(e){m=e,n(14,m)}]}!function(){const e=!!localStorage.getItem("relayUrl"),t="file:"===window.location.protocol,n=!["3334","7777","443","80",""].includes(window.location.port),i=Cp||e||t||n;yp.set(i),Ep&&!c(mp)&&mp.set(Ep),console.log("[config] Initialized:",{standaloneMode:i,buildStandalone:Cp,hasStoredRelay:e,isNonRelayPort:n,port:window.location.port,relayUrl:c(mp)||"(same origin)"})}();return new class extends ae{constructor(e){super(),le(this,e,aI,sI,s,{},null,[-1,-1,-1,-1,-1,-1,-1])}}({target:document.body,props:{name:"world"}})}(); //# sourceMappingURL=bundle.js.map diff --git a/app/web/dist/bundle.js.map b/app/web/dist/bundle.js.map index 63a05af..87f3845 100644 --- a/app/web/dist/bundle.js.map +++ b/app/web/dist/bundle.js.map @@ -1 +1 @@ -{"version":3,"file":"bundle.js","sources":["../node_modules/svelte/internal/index.mjs","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/crypto.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_sha2.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/utils.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/modular.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/curve.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/abstract/weierstrass.js","../node_modules/nostr-tools/node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/_shortw_utils.js","../node_modules/nostr-tools/node_modules/@noble/curves/esm/secp256k1.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/crypto.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/utils.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/_assert.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/_sha2.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/sha256.js","../node_modules/nostr-tools/lib/esm/pool.js","../node_modules/nostr-tools/node_modules/@scure/base/lib/esm/index.js","../node_modules/@noble/ciphers/esm/_assert.js","../node_modules/@noble/ciphers/esm/utils.js","../node_modules/@noble/ciphers/esm/aes.js","../node_modules/@noble/ciphers/esm/_arx.js","../node_modules/@noble/ciphers/esm/chacha.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/hmac.js","../node_modules/nostr-tools/node_modules/@noble/hashes/esm/hkdf.js","../node_modules/nostr-tools/lib/esm/index.js","../node_modules/nostr-tools/lib/esm/kinds.js","../node_modules/tslib/tslib.es6.mjs","../node_modules/rxjs/dist/esm5/internal/util/isFunction.js","../node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js","../node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js","../node_modules/rxjs/dist/esm5/internal/util/arrRemove.js","../node_modules/rxjs/dist/esm5/internal/Subscription.js","../node_modules/rxjs/dist/esm5/internal/config.js","../node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js","../node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js","../node_modules/rxjs/dist/esm5/internal/util/noop.js","../node_modules/rxjs/dist/esm5/internal/util/errorContext.js","../node_modules/rxjs/dist/esm5/internal/Subscriber.js","../node_modules/rxjs/dist/esm5/internal/symbol/observable.js","../node_modules/rxjs/dist/esm5/internal/util/identity.js","../node_modules/rxjs/dist/esm5/internal/Observable.js","../node_modules/rxjs/dist/esm5/internal/util/pipe.js","../node_modules/rxjs/dist/esm5/internal/util/lift.js","../node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js","../node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js","../node_modules/rxjs/dist/esm5/internal/Subject.js","../node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js","../node_modules/rxjs/dist/esm5/internal/ReplaySubject.js","../node_modules/rxjs/dist/esm5/internal/scheduler/Action.js","../node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js","../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js","../node_modules/rxjs/dist/esm5/internal/Scheduler.js","../node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js","../node_modules/rxjs/dist/esm5/internal/scheduler/async.js","../node_modules/rxjs/dist/esm5/internal/observable/empty.js","../node_modules/rxjs/dist/esm5/internal/util/isScheduler.js","../node_modules/rxjs/dist/esm5/internal/util/args.js","../node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js","../node_modules/rxjs/dist/esm5/internal/util/isPromise.js","../node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js","../node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js","../node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js","../node_modules/rxjs/dist/esm5/internal/symbol/iterator.js","../node_modules/rxjs/dist/esm5/internal/util/isIterable.js","../node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js","../node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js","../node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js","../node_modules/rxjs/dist/esm5/internal/operators/observeOn.js","../node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js","../node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js","../node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js","../node_modules/rxjs/dist/esm5/internal/observable/from.js","../node_modules/rxjs/dist/esm5/internal/observable/of.js","../node_modules/rxjs/dist/esm5/internal/operators/map.js","../node_modules/rxjs/dist/esm5/internal/util/mapOneOrManyArgs.js","../node_modules/rxjs/dist/esm5/internal/util/argsArgArrayOrObject.js","../node_modules/rxjs/dist/esm5/internal/observable/combineLatest.js","../node_modules/rxjs/dist/esm5/internal/util/createObject.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js","../node_modules/rxjs/dist/esm5/internal/observable/concat.js","../node_modules/rxjs/dist/esm5/internal/operators/concatAll.js","../node_modules/rxjs/dist/esm5/internal/observable/defer.js","../node_modules/rxjs/dist/esm5/internal/observable/timer.js","../node_modules/rxjs/dist/esm5/internal/util/isDate.js","../node_modules/rxjs/dist/esm5/internal/observable/merge.js","../node_modules/rxjs/dist/esm5/internal/operators/filter.js","../node_modules/rxjs/dist/esm5/internal/operators/take.js","../node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js","../node_modules/rxjs/dist/esm5/internal/operators/endWith.js","../node_modules/rxjs/dist/esm5/internal/operators/finalize.js","../node_modules/rxjs/dist/esm5/internal/operators/merge.js","../node_modules/rxjs/dist/esm5/internal/operators/mergeWith.js","../node_modules/rxjs/dist/esm5/internal/operators/scan.js","../node_modules/rxjs/dist/esm5/internal/operators/scanInternals.js","../node_modules/rxjs/dist/esm5/internal/operators/share.js","../node_modules/rxjs/dist/esm5/internal/operators/switchMap.js","../node_modules/rxjs/dist/esm5/internal/operators/tap.js","../node_modules/applesauce-core/dist/helpers/tags.js","../node_modules/nostr-tools/lib/esm/pure.js","../node_modules/applesauce-core/dist/helpers/cache.js","../node_modules/nostr-tools/lib/esm/utils.js","../node_modules/applesauce-core/dist/helpers/event.js","../node_modules/applesauce-core/dist/helpers/time.js","../node_modules/applesauce-core/dist/helpers/expiration.js","../node_modules/nostr-tools/lib/esm/nip19.js","../node_modules/applesauce-core/dist/helpers/url.js","../node_modules/applesauce-core/dist/helpers/relays.js","../node_modules/applesauce-core/dist/helpers/string.js","../node_modules/@noble/hashes/esm/crypto.js","../node_modules/@noble/hashes/esm/utils.js","../node_modules/applesauce-core/dist/helpers/pointers.js","../node_modules/applesauce-core/dist/helpers/groups.js","../node_modules/applesauce-core/dist/helpers/encrypted-content.js","../node_modules/applesauce-core/dist/helpers/hidden-content.js","../node_modules/applesauce-core/dist/helpers/hidden-tags.js","../node_modules/applesauce-core/dist/helpers/event-tags.js","../node_modules/applesauce-core/dist/helpers/lru.js","../node_modules/ms/index.js","../node_modules/debug/src/common.js","../node_modules/debug/src/browser.js","../node_modules/applesauce-core/dist/logger.js","../node_modules/applesauce-core/dist/event-store/event-memory.js","../node_modules/hash-sum/hash-sum.js","../node_modules/applesauce-core/dist/helpers/filter.js","../node_modules/applesauce-core/dist/models/blossom.js","../node_modules/applesauce-core/dist/helpers/blossom.js","../node_modules/applesauce-core/dist/helpers/profile.js","../node_modules/applesauce-core/dist/helpers/json.js","../node_modules/light-bolt11-decoder/node_modules/@scure/base/lib/index.js","../node_modules/light-bolt11-decoder/bolt11.js","../node_modules/applesauce-core/dist/helpers/comment.js","../node_modules/applesauce-core/dist/helpers/contacts.js","../node_modules/applesauce-core/dist/helpers/encrypted-content-cache.js","../node_modules/applesauce-core/dist/helpers/event-cache.js","../node_modules/applesauce-core/dist/helpers/lnurl.js","../node_modules/applesauce-core/dist/helpers/mailboxes.js","../node_modules/applesauce-core/dist/helpers/mutes.js","../node_modules/applesauce-core/dist/helpers/reports.js","../node_modules/applesauce-core/dist/helpers/threading.js","../node_modules/applesauce-core/dist/observable/claim-events.js","../node_modules/applesauce-core/dist/observable/claim-latest.js","../node_modules/applesauce-core/dist/observable/defined.js","../node_modules/applesauce-core/dist/observable/with-immediate-value.js","../node_modules/applesauce-core/dist/models/common.js","../node_modules/rxjs/dist/esm5/internal/operators/ignoreElements.js","../node_modules/rxjs/dist/esm5/internal/operators/takeUntil.js","../node_modules/rxjs/dist/esm5/internal/operators/repeat.js","../node_modules/applesauce-core/dist/observable/watch-event-updates.js","../node_modules/applesauce-core/dist/models/contacts.js","../node_modules/applesauce-core/dist/models/comments.js","../node_modules/applesauce-core/dist/models/mailboxes.js","../node_modules/applesauce-core/dist/models/mutes.js","../node_modules/applesauce-core/dist/models/profile.js","../node_modules/applesauce-core/dist/models/reactions.js","../node_modules/applesauce-core/dist/models/thread.js","../node_modules/applesauce-core/dist/event-store/model-mixin.js","../node_modules/applesauce-core/dist/event-store/event-store.js","../node_modules/applesauce-core/dist/helpers/delete.js","../node_modules/applesauce-core/dist/promise/deferred.js","../node_modules/applesauce-signers/dist/signers/amber-clipboard-signer.js","../node_modules/applesauce-signers/dist/helpers/nostr-connect.js","../node_modules/applesauce-signers/dist/signers/private-key-signer.js","../node_modules/applesauce-signers/node_modules/@noble/secp256k1/lib/esm/index.js","../node_modules/applesauce-signers/node_modules/@scure/base/lib/esm/index.js","../node_modules/applesauce-signers/dist/signers/serial-port-signer.js","../node_modules/svelte/store/index.mjs","../src/stores.js","../src/config.js","../src/constants.js","../src/nostr.js","../node_modules/hash-wasm/dist/index.esm.js","../src/nsec-crypto.js","../src/LoginModal.svelte","../src/ManagedACL.svelte","../src/Header.svelte","../src/Sidebar.svelte","../src/ExportView.svelte","../src/ImportView.svelte","../src/helpers.tsx","../src/FilterBuilder.svelte","../src/EventsView.svelte","../src/eventKinds.js","../src/EventTemplateSelector.svelte","../src/ComposeView.svelte","../src/SprocketView.svelte","../src/PolicyView.svelte","../src/kindCategories.js","../src/CurationView.svelte","../src/BlossomView.svelte","../src/LogView.svelte","../src/api.js","../src/utils.js","../src/RelayConnectView.svelte","../src/FilterDisplay.svelte","../src/RelayConnectModal.svelte","../src/websocket-auth.js","../src/App.svelte","../src/main.js"],"sourcesContent":["function noop() { }\nconst identity = x => x;\nfunction assign(tar, src) {\n // @ts-ignore\n for (const k in src)\n tar[k] = src[k];\n return tar;\n}\n// Adapted from https://github.com/then/is-promise/blob/master/index.js\n// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE\nfunction is_promise(value) {\n return !!value && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';\n}\nfunction add_location(element, file, line, column, char) {\n element.__svelte_meta = {\n loc: { file, line, column, char }\n };\n}\nfunction run(fn) {\n return fn();\n}\nfunction blank_object() {\n return Object.create(null);\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === 'function';\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');\n}\nlet src_url_equal_anchor;\nfunction src_url_equal(element_src, url) {\n if (!src_url_equal_anchor) {\n src_url_equal_anchor = document.createElement('a');\n }\n src_url_equal_anchor.href = url;\n return element_src === src_url_equal_anchor.href;\n}\nfunction not_equal(a, b) {\n return a != a ? b == b : a !== b;\n}\nfunction is_empty(obj) {\n return Object.keys(obj).length === 0;\n}\nfunction validate_store(store, name) {\n if (store != null && typeof store.subscribe !== 'function') {\n throw new Error(`'${name}' is not a store with a 'subscribe' method`);\n }\n}\nfunction subscribe(store, ...callbacks) {\n if (store == null) {\n return noop;\n }\n const unsub = store.subscribe(...callbacks);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, _ => value = _)();\n return value;\n}\nfunction component_subscribe(component, store, callback) {\n component.$$.on_destroy.push(subscribe(store, callback));\n}\nfunction create_slot(definition, ctx, $$scope, fn) {\n if (definition) {\n const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n return definition[0](slot_ctx);\n }\n}\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n return definition[1] && fn\n ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))\n : $$scope.ctx;\n}\nfunction get_slot_changes(definition, $$scope, dirty, fn) {\n if (definition[2] && fn) {\n const lets = definition[2](fn(dirty));\n if ($$scope.dirty === undefined) {\n return lets;\n }\n if (typeof lets === 'object') {\n const merged = [];\n const len = Math.max($$scope.dirty.length, lets.length);\n for (let i = 0; i < len; i += 1) {\n merged[i] = $$scope.dirty[i] | lets[i];\n }\n return merged;\n }\n return $$scope.dirty | lets;\n }\n return $$scope.dirty;\n}\nfunction update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {\n if (slot_changes) {\n const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n slot.p(slot_context, slot_changes);\n }\n}\nfunction update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {\n const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn);\n}\nfunction get_all_dirty_from_scope($$scope) {\n if ($$scope.ctx.length > 32) {\n const dirty = [];\n const length = $$scope.ctx.length / 32;\n for (let i = 0; i < length; i++) {\n dirty[i] = -1;\n }\n return dirty;\n }\n return -1;\n}\nfunction exclude_internal_props(props) {\n const result = {};\n for (const k in props)\n if (k[0] !== '$')\n result[k] = props[k];\n return result;\n}\nfunction compute_rest_props(props, keys) {\n const rest = {};\n keys = new Set(keys);\n for (const k in props)\n if (!keys.has(k) && k[0] !== '$')\n rest[k] = props[k];\n return rest;\n}\nfunction compute_slots(slots) {\n const result = {};\n for (const key in slots) {\n result[key] = true;\n }\n return result;\n}\nfunction once(fn) {\n let ran = false;\n return function (...args) {\n if (ran)\n return;\n ran = true;\n fn.call(this, ...args);\n };\n}\nfunction null_to_empty(value) {\n return value == null ? '' : value;\n}\nfunction set_store_value(store, ret, value) {\n store.set(value);\n return ret;\n}\nconst has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\nfunction action_destroyer(action_result) {\n return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\nfunction split_css_unit(value) {\n const split = typeof value === 'string' && value.match(/^\\s*(-?[\\d.]+)([^\\s]*)\\s*$/);\n return split ? [parseFloat(split[1]), split[2] || 'px'] : [value, 'px'];\n}\nconst contenteditable_truthy_values = ['', true, 1, 'true', 'contenteditable'];\n\nconst is_client = typeof window !== 'undefined';\nlet now = is_client\n ? () => window.performance.now()\n : () => Date.now();\nlet raf = is_client ? cb => requestAnimationFrame(cb) : noop;\n// used internally for testing\nfunction set_now(fn) {\n now = fn;\n}\nfunction set_raf(fn) {\n raf = fn;\n}\n\nconst tasks = new Set();\nfunction run_tasks(now) {\n tasks.forEach(task => {\n if (!task.c(now)) {\n tasks.delete(task);\n task.f();\n }\n });\n if (tasks.size !== 0)\n raf(run_tasks);\n}\n/**\n * For testing purposes only!\n */\nfunction clear_loops() {\n tasks.clear();\n}\n/**\n * Creates a new task that runs on each raf frame\n * until it returns a falsy value or is aborted\n */\nfunction loop(callback) {\n let task;\n if (tasks.size === 0)\n raf(run_tasks);\n return {\n promise: new Promise(fulfill => {\n tasks.add(task = { c: callback, f: fulfill });\n }),\n abort() {\n tasks.delete(task);\n }\n };\n}\n\nconst globals = (typeof window !== 'undefined'\n ? window\n : typeof globalThis !== 'undefined'\n ? globalThis\n : global);\n\n/**\n * Resize observer singleton.\n * One listener per element only!\n * https://groups.google.com/a/chromium.org/g/blink-dev/c/z6ienONUb5A/m/F5-VcUZtBAAJ\n */\nclass ResizeObserverSingleton {\n constructor(options) {\n this.options = options;\n this._listeners = 'WeakMap' in globals ? new WeakMap() : undefined;\n }\n observe(element, listener) {\n this._listeners.set(element, listener);\n this._getObserver().observe(element, this.options);\n return () => {\n this._listeners.delete(element);\n this._observer.unobserve(element); // this line can probably be removed\n };\n }\n _getObserver() {\n var _a;\n return (_a = this._observer) !== null && _a !== void 0 ? _a : (this._observer = new ResizeObserver((entries) => {\n var _a;\n for (const entry of entries) {\n ResizeObserverSingleton.entries.set(entry.target, entry);\n (_a = this._listeners.get(entry.target)) === null || _a === void 0 ? void 0 : _a(entry);\n }\n }));\n }\n}\n// Needs to be written like this to pass the tree-shake-test\nResizeObserverSingleton.entries = 'WeakMap' in globals ? new WeakMap() : undefined;\n\n// Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM\n// at the end of hydration without touching the remaining nodes.\nlet is_hydrating = false;\nfunction start_hydrating() {\n is_hydrating = true;\n}\nfunction end_hydrating() {\n is_hydrating = false;\n}\nfunction upper_bound(low, high, key, value) {\n // Return first index of value larger than input value in the range [low, high)\n while (low < high) {\n const mid = low + ((high - low) >> 1);\n if (key(mid) <= value) {\n low = mid + 1;\n }\n else {\n high = mid;\n }\n }\n return low;\n}\nfunction init_hydrate(target) {\n if (target.hydrate_init)\n return;\n target.hydrate_init = true;\n // We know that all children have claim_order values since the unclaimed have been detached if target is not \n let children = target.childNodes;\n // If target is , there may be children without claim_order\n if (target.nodeName === 'HEAD') {\n const myChildren = [];\n for (let i = 0; i < children.length; i++) {\n const node = children[i];\n if (node.claim_order !== undefined) {\n myChildren.push(node);\n }\n }\n children = myChildren;\n }\n /*\n * Reorder claimed children optimally.\n * We can reorder claimed children optimally by finding the longest subsequence of\n * nodes that are already claimed in order and only moving the rest. The longest\n * subsequence of nodes that are claimed in order can be found by\n * computing the longest increasing subsequence of .claim_order values.\n *\n * This algorithm is optimal in generating the least amount of reorder operations\n * possible.\n *\n * Proof:\n * We know that, given a set of reordering operations, the nodes that do not move\n * always form an increasing subsequence, since they do not move among each other\n * meaning that they must be already ordered among each other. Thus, the maximal\n * set of nodes that do not move form a longest increasing subsequence.\n */\n // Compute longest increasing subsequence\n // m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j\n const m = new Int32Array(children.length + 1);\n // Predecessor indices + 1\n const p = new Int32Array(children.length);\n m[0] = -1;\n let longest = 0;\n for (let i = 0; i < children.length; i++) {\n const current = children[i].claim_order;\n // Find the largest subsequence length such that it ends in a value less than our current value\n // upper_bound returns first greater value, so we subtract one\n // with fast path for when we are on the current longest subsequence\n const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1;\n p[i] = m[seqLen] + 1;\n const newLen = seqLen + 1;\n // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.\n m[newLen] = i;\n longest = Math.max(newLen, longest);\n }\n // The longest increasing subsequence of nodes (initially reversed)\n const lis = [];\n // The rest of the nodes, nodes that will be moved\n const toMove = [];\n let last = children.length - 1;\n for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {\n lis.push(children[cur - 1]);\n for (; last >= cur; last--) {\n toMove.push(children[last]);\n }\n last--;\n }\n for (; last >= 0; last--) {\n toMove.push(children[last]);\n }\n lis.reverse();\n // We sort the nodes being moved to guarantee that their insertion order matches the claim order\n toMove.sort((a, b) => a.claim_order - b.claim_order);\n // Finally, we move the nodes\n for (let i = 0, j = 0; i < toMove.length; i++) {\n while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) {\n j++;\n }\n const anchor = j < lis.length ? lis[j] : null;\n target.insertBefore(toMove[i], anchor);\n }\n}\nfunction append(target, node) {\n target.appendChild(node);\n}\nfunction append_styles(target, style_sheet_id, styles) {\n const append_styles_to = get_root_for_style(target);\n if (!append_styles_to.getElementById(style_sheet_id)) {\n const style = element('style');\n style.id = style_sheet_id;\n style.textContent = styles;\n append_stylesheet(append_styles_to, style);\n }\n}\nfunction get_root_for_style(node) {\n if (!node)\n return document;\n const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;\n if (root && root.host) {\n return root;\n }\n return node.ownerDocument;\n}\nfunction append_empty_stylesheet(node) {\n const style_element = element('style');\n append_stylesheet(get_root_for_style(node), style_element);\n return style_element.sheet;\n}\nfunction append_stylesheet(node, style) {\n append(node.head || node, style);\n return style.sheet;\n}\nfunction append_hydration(target, node) {\n if (is_hydrating) {\n init_hydrate(target);\n if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentNode !== target))) {\n target.actual_end_child = target.firstChild;\n }\n // Skip nodes of undefined ordering\n while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) {\n target.actual_end_child = target.actual_end_child.nextSibling;\n }\n if (node !== target.actual_end_child) {\n // We only insert if the ordering of this node should be modified or the parent node is not target\n if (node.claim_order !== undefined || node.parentNode !== target) {\n target.insertBefore(node, target.actual_end_child);\n }\n }\n else {\n target.actual_end_child = node.nextSibling;\n }\n }\n else if (node.parentNode !== target || node.nextSibling !== null) {\n target.appendChild(node);\n }\n}\nfunction insert(target, node, anchor) {\n target.insertBefore(node, anchor || null);\n}\nfunction insert_hydration(target, node, anchor) {\n if (is_hydrating && !anchor) {\n append_hydration(target, node);\n }\n else if (node.parentNode !== target || node.nextSibling != anchor) {\n target.insertBefore(node, anchor || null);\n }\n}\nfunction detach(node) {\n if (node.parentNode) {\n node.parentNode.removeChild(node);\n }\n}\nfunction destroy_each(iterations, detaching) {\n for (let i = 0; i < iterations.length; i += 1) {\n if (iterations[i])\n iterations[i].d(detaching);\n }\n}\nfunction element(name) {\n return document.createElement(name);\n}\nfunction element_is(name, is) {\n return document.createElement(name, { is });\n}\nfunction object_without_properties(obj, exclude) {\n const target = {};\n for (const k in obj) {\n if (has_prop(obj, k)\n // @ts-ignore\n && exclude.indexOf(k) === -1) {\n // @ts-ignore\n target[k] = obj[k];\n }\n }\n return target;\n}\nfunction svg_element(name) {\n return document.createElementNS('http://www.w3.org/2000/svg', name);\n}\nfunction text(data) {\n return document.createTextNode(data);\n}\nfunction space() {\n return text(' ');\n}\nfunction empty() {\n return text('');\n}\nfunction comment(content) {\n return document.createComment(content);\n}\nfunction listen(node, event, handler, options) {\n node.addEventListener(event, handler, options);\n return () => node.removeEventListener(event, handler, options);\n}\nfunction prevent_default(fn) {\n return function (event) {\n event.preventDefault();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_propagation(fn) {\n return function (event) {\n event.stopPropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_immediate_propagation(fn) {\n return function (event) {\n event.stopImmediatePropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction self(fn) {\n return function (event) {\n // @ts-ignore\n if (event.target === this)\n fn.call(this, event);\n };\n}\nfunction trusted(fn) {\n return function (event) {\n // @ts-ignore\n if (event.isTrusted)\n fn.call(this, event);\n };\n}\nfunction attr(node, attribute, value) {\n if (value == null)\n node.removeAttribute(attribute);\n else if (node.getAttribute(attribute) !== value)\n node.setAttribute(attribute, value);\n}\n/**\n * List of attributes that should always be set through the attr method,\n * because updating them through the property setter doesn't work reliably.\n * In the example of `width`/`height`, the problem is that the setter only\n * accepts numeric values, but the attribute can also be set to a string like `50%`.\n * If this list becomes too big, rethink this approach.\n */\nconst always_set_through_set_attribute = ['width', 'height'];\nfunction set_attributes(node, attributes) {\n // @ts-ignore\n const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n for (const key in attributes) {\n if (attributes[key] == null) {\n node.removeAttribute(key);\n }\n else if (key === 'style') {\n node.style.cssText = attributes[key];\n }\n else if (key === '__value') {\n node.value = node[key] = attributes[key];\n }\n else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) {\n node[key] = attributes[key];\n }\n else {\n attr(node, key, attributes[key]);\n }\n }\n}\nfunction set_svg_attributes(node, attributes) {\n for (const key in attributes) {\n attr(node, key, attributes[key]);\n }\n}\nfunction set_custom_element_data_map(node, data_map) {\n Object.keys(data_map).forEach((key) => {\n set_custom_element_data(node, key, data_map[key]);\n });\n}\nfunction set_custom_element_data(node, prop, value) {\n if (prop in node) {\n node[prop] = typeof node[prop] === 'boolean' && value === '' ? true : value;\n }\n else {\n attr(node, prop, value);\n }\n}\nfunction set_dynamic_element_data(tag) {\n return (/-/.test(tag)) ? set_custom_element_data_map : set_attributes;\n}\nfunction xlink_attr(node, attribute, value) {\n node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\nfunction get_binding_group_value(group, __value, checked) {\n const value = new Set();\n for (let i = 0; i < group.length; i += 1) {\n if (group[i].checked)\n value.add(group[i].__value);\n }\n if (!checked) {\n value.delete(__value);\n }\n return Array.from(value);\n}\nfunction init_binding_group(group) {\n let _inputs;\n return {\n /* push */ p(...inputs) {\n _inputs = inputs;\n _inputs.forEach(input => group.push(input));\n },\n /* remove */ r() {\n _inputs.forEach(input => group.splice(group.indexOf(input), 1));\n }\n };\n}\nfunction init_binding_group_dynamic(group, indexes) {\n let _group = get_binding_group(group);\n let _inputs;\n function get_binding_group(group) {\n for (let i = 0; i < indexes.length; i++) {\n group = group[indexes[i]] = group[indexes[i]] || [];\n }\n return group;\n }\n function push() {\n _inputs.forEach(input => _group.push(input));\n }\n function remove() {\n _inputs.forEach(input => _group.splice(_group.indexOf(input), 1));\n }\n return {\n /* update */ u(new_indexes) {\n indexes = new_indexes;\n const new_group = get_binding_group(group);\n if (new_group !== _group) {\n remove();\n _group = new_group;\n push();\n }\n },\n /* push */ p(...inputs) {\n _inputs = inputs;\n push();\n },\n /* remove */ r: remove\n };\n}\nfunction to_number(value) {\n return value === '' ? null : +value;\n}\nfunction time_ranges_to_array(ranges) {\n const array = [];\n for (let i = 0; i < ranges.length; i += 1) {\n array.push({ start: ranges.start(i), end: ranges.end(i) });\n }\n return array;\n}\nfunction children(element) {\n return Array.from(element.childNodes);\n}\nfunction init_claim_info(nodes) {\n if (nodes.claim_info === undefined) {\n nodes.claim_info = { last_index: 0, total_claimed: 0 };\n }\n}\nfunction claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {\n // Try to find nodes in an order such that we lengthen the longest increasing subsequence\n init_claim_info(nodes);\n const resultNode = (() => {\n // We first try to find an element after the previous one\n for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n return node;\n }\n }\n // Otherwise, we try to find one before\n // We iterate in reverse so that we don't go too far back\n for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {\n const node = nodes[i];\n if (predicate(node)) {\n const replacement = processNode(node);\n if (replacement === undefined) {\n nodes.splice(i, 1);\n }\n else {\n nodes[i] = replacement;\n }\n if (!dontUpdateLastIndex) {\n nodes.claim_info.last_index = i;\n }\n else if (replacement === undefined) {\n // Since we spliced before the last_index, we decrease it\n nodes.claim_info.last_index--;\n }\n return node;\n }\n }\n // If we can't find any matching node, we create a new one\n return createNode();\n })();\n resultNode.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n return resultNode;\n}\nfunction claim_element_base(nodes, name, attributes, create_element) {\n return claim_node(nodes, (node) => node.nodeName === name, (node) => {\n const remove = [];\n for (let j = 0; j < node.attributes.length; j++) {\n const attribute = node.attributes[j];\n if (!attributes[attribute.name]) {\n remove.push(attribute.name);\n }\n }\n remove.forEach(v => node.removeAttribute(v));\n return undefined;\n }, () => create_element(name));\n}\nfunction claim_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, element);\n}\nfunction claim_svg_element(nodes, name, attributes) {\n return claim_element_base(nodes, name, attributes, svg_element);\n}\nfunction claim_text(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 3, (node) => {\n const dataStr = '' + data;\n if (node.data.startsWith(dataStr)) {\n if (node.data.length !== dataStr.length) {\n return node.splitText(dataStr.length);\n }\n }\n else {\n node.data = dataStr;\n }\n }, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements\n );\n}\nfunction claim_space(nodes) {\n return claim_text(nodes, ' ');\n}\nfunction claim_comment(nodes, data) {\n return claim_node(nodes, (node) => node.nodeType === 8, (node) => {\n node.data = '' + data;\n return undefined;\n }, () => comment(data), true);\n}\nfunction find_comment(nodes, text, start) {\n for (let i = start; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeType === 8 /* comment node */ && node.textContent.trim() === text) {\n return i;\n }\n }\n return nodes.length;\n}\nfunction claim_html_tag(nodes, is_svg) {\n // find html opening tag\n const start_index = find_comment(nodes, 'HTML_TAG_START', 0);\n const end_index = find_comment(nodes, 'HTML_TAG_END', start_index);\n if (start_index === end_index) {\n return new HtmlTagHydration(undefined, is_svg);\n }\n init_claim_info(nodes);\n const html_tag_nodes = nodes.splice(start_index, end_index - start_index + 1);\n detach(html_tag_nodes[0]);\n detach(html_tag_nodes[html_tag_nodes.length - 1]);\n const claimed_nodes = html_tag_nodes.slice(1, html_tag_nodes.length - 1);\n for (const n of claimed_nodes) {\n n.claim_order = nodes.claim_info.total_claimed;\n nodes.claim_info.total_claimed += 1;\n }\n return new HtmlTagHydration(claimed_nodes, is_svg);\n}\nfunction set_data(text, data) {\n data = '' + data;\n if (text.data === data)\n return;\n text.data = data;\n}\nfunction set_data_contenteditable(text, data) {\n data = '' + data;\n if (text.wholeText === data)\n return;\n text.data = data;\n}\nfunction set_data_maybe_contenteditable(text, data, attr_value) {\n if (~contenteditable_truthy_values.indexOf(attr_value)) {\n set_data_contenteditable(text, data);\n }\n else {\n set_data(text, data);\n }\n}\nfunction set_input_value(input, value) {\n input.value = value == null ? '' : value;\n}\nfunction set_input_type(input, type) {\n try {\n input.type = type;\n }\n catch (e) {\n // do nothing\n }\n}\nfunction set_style(node, key, value, important) {\n if (value == null) {\n node.style.removeProperty(key);\n }\n else {\n node.style.setProperty(key, value, important ? 'important' : '');\n }\n}\nfunction select_option(select, value, mounting) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n if (option.__value === value) {\n option.selected = true;\n return;\n }\n }\n if (!mounting || value !== undefined) {\n select.selectedIndex = -1; // no option should be selected\n }\n}\nfunction select_options(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n option.selected = ~value.indexOf(option.__value);\n }\n}\nfunction select_value(select) {\n const selected_option = select.querySelector(':checked');\n return selected_option && selected_option.__value;\n}\nfunction select_multiple_value(select) {\n return [].map.call(select.querySelectorAll(':checked'), option => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\nlet crossorigin;\nfunction is_crossorigin() {\n if (crossorigin === undefined) {\n crossorigin = false;\n try {\n if (typeof window !== 'undefined' && window.parent) {\n void window.parent.document;\n }\n }\n catch (error) {\n crossorigin = true;\n }\n }\n return crossorigin;\n}\nfunction add_iframe_resize_listener(node, fn) {\n const computed_style = getComputedStyle(node);\n if (computed_style.position === 'static') {\n node.style.position = 'relative';\n }\n const iframe = element('iframe');\n iframe.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +\n 'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;');\n iframe.setAttribute('aria-hidden', 'true');\n iframe.tabIndex = -1;\n const crossorigin = is_crossorigin();\n let unsubscribe;\n if (crossorigin) {\n iframe.src = \"data:text/html,\";\n unsubscribe = listen(window, 'message', (event) => {\n if (event.source === iframe.contentWindow)\n fn();\n });\n }\n else {\n iframe.src = 'about:blank';\n iframe.onload = () => {\n unsubscribe = listen(iframe.contentWindow, 'resize', fn);\n // make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n // see https://github.com/sveltejs/svelte/issues/4233\n fn();\n };\n }\n append(node, iframe);\n return () => {\n if (crossorigin) {\n unsubscribe();\n }\n else if (unsubscribe && iframe.contentWindow) {\n unsubscribe();\n }\n detach(iframe);\n };\n}\nconst resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'content-box' });\nconst resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'border-box' });\nconst resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'device-pixel-content-box' });\nfunction toggle_class(element, name, toggle) {\n element.classList[toggle ? 'add' : 'remove'](name);\n}\nfunction custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n const e = document.createEvent('CustomEvent');\n e.initCustomEvent(type, bubbles, cancelable, detail);\n return e;\n}\nfunction query_selector_all(selector, parent = document.body) {\n return Array.from(parent.querySelectorAll(selector));\n}\nfunction head_selector(nodeId, head) {\n const result = [];\n let started = 0;\n for (const node of head.childNodes) {\n if (node.nodeType === 8 /* comment node */) {\n const comment = node.textContent.trim();\n if (comment === `HEAD_${nodeId}_END`) {\n started -= 1;\n result.push(node);\n }\n else if (comment === `HEAD_${nodeId}_START`) {\n started += 1;\n result.push(node);\n }\n }\n else if (started > 0) {\n result.push(node);\n }\n }\n return result;\n}\nclass HtmlTag {\n constructor(is_svg = false) {\n this.is_svg = false;\n this.is_svg = is_svg;\n this.e = this.n = null;\n }\n c(html) {\n this.h(html);\n }\n m(html, target, anchor = null) {\n if (!this.e) {\n if (this.is_svg)\n this.e = svg_element(target.nodeName);\n /** #7364 target for