pywire 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pywire/__init__.py CHANGED
@@ -1,2 +1,12 @@
1
+ try:
2
+ from ._version import __version__
3
+ except ImportError:
4
+ from importlib.metadata import version, PackageNotFoundError
5
+
6
+ try:
7
+ __version__ = version("pywire")
8
+ except PackageNotFoundError:
9
+ __version__ = "unknown"
10
+
1
11
  from .runtime.app import PyWire as PyWire
2
12
  from .core.wire import wire as wire
pywire/_version.py ADDED
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '0.1.5'
32
+ __version_tuple__ = version_tuple = (0, 1, 5)
33
+
34
+ __commit_id__ = commit_id = None
pywire/cli/main.py CHANGED
@@ -8,6 +8,8 @@ from typing import Any, Optional
8
8
  import rich.panel
9
9
  import rich_click as click
10
10
 
11
+ from pywire import __version__
12
+
11
13
  # Astro-like styling configuration (Cyan Theme)
12
14
  click.rich_click.USE_RICH_MARKUP = True
13
15
  click.rich_click.STYLE_HELPTEXT_FIRST = True
@@ -141,18 +143,19 @@ def panel_init(self, *args, **kwargs):
141
143
  rich.panel.Panel.__init__ = panel_init # type: ignore[method-assign]
142
144
 
143
145
 
144
- @click.group()
145
- @click.version_option()
146
- def cli() -> None:
147
- """
148
- [bold white on cyan] pywire [/] [bold cyan]v0.1.3[/] Build faster python web apps.
146
+ @click.group(
147
+ help=f"""
148
+ [bold white on cyan] pywire [/] [bold cyan]v{__version__}[/] Build faster python web apps.
149
149
 
150
- Run [bold cyan]pywire dev APP[/] to start development server.
151
- Run [bold cyan]pywire run APP[/] to start production server.
150
+ Run [bold cyan]pywire dev APP[/] to start development server.
151
+ Run [bold cyan]pywire run APP[/] to start production server.
152
152
 
153
- [dim]APP should be a string in format 'module:instance', e.g. 'src.main:app' or 'main:app'
154
- If not provided, pywire tries to discover it in main.py, app.py, etc.[/dim]
155
- """
153
+ [dim]APP should be a string in format 'module:instance', e.g. 'src.main:app' or 'main:app'
154
+ If not provided, pywire tries to discover it in main.py, app.py, etc.[/dim]
155
+ """
156
+ )
157
+ @click.version_option(__version__)
158
+ def cli() -> None:
156
159
  pass
157
160
 
158
161
 
pywire/client/build.mjs CHANGED
@@ -1,6 +1,9 @@
1
1
  import * as esbuild from 'esbuild'
2
2
  import { resolve, dirname } from 'path'
3
3
  import { fileURLToPath } from 'url'
4
+ import { createRequire } from 'module'
5
+ const require = createRequire(import.meta.url)
6
+ const { version } = require('./package.json')
4
7
 
5
8
  const __dirname = dirname(fileURLToPath(import.meta.url))
6
9
 
@@ -38,7 +41,7 @@ function getBuildOptions(bundle) {
38
41
  'process.env.NODE_ENV': isDev ? '"development"' : '"production"',
39
42
  },
40
43
  banner: {
41
- js: `/* PyWire Client ${bundle.name} v0.1.3 - https://github.com/pywire/pywire */`,
44
+ js: `/* PyWire Client ${bundle.name} v${version} - https://github.com/pywire/pywire */`,
42
45
  },
43
46
  }
44
47
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pywire-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.5",
4
4
  "description": "PyWire client-side library with transport fallbacks",
5
5
  "type": "module",
6
6
  "private": true,
@@ -1,4 +1,5 @@
1
1
  import { TransportManager, TransportConfig } from './transport-manager'
2
+ import { version as clientVersion } from '../../package.json'
2
3
  import { DOMUpdater } from './dom-updater'
3
4
  import { ServerMessage, ClientMessage, EventData, RelocateMessage } from './transports'
4
5
  import { UnifiedEventHandler } from '../events/handler'
@@ -242,6 +243,10 @@ export class PyWireApp {
242
243
  }
243
244
  break
244
245
 
246
+ case 'init':
247
+ console.log(`PyWire Client v${clientVersion} • Server v${msg.version}`)
248
+ break
249
+
245
250
  default:
246
251
  console.warn('PyWire: Unknown message type', msg)
247
252
  }
@@ -36,13 +36,19 @@ export interface StackFrame {
36
36
  }
37
37
 
38
38
  export interface ServerMessage {
39
- type: 'update' | 'reload' | 'error' | 'console' | 'error_trace'
39
+ type: 'update' | 'reload' | 'error' | 'console' | 'error_trace' | 'init'
40
40
  html?: string
41
41
  regions?: Array<{ region: string; html: string }>
42
42
  error?: string
43
43
  level?: 'info' | 'warn' | 'error'
44
44
  lines?: string[]
45
45
  trace?: StackFrame[]
46
+ version?: string
47
+ }
48
+
49
+ export interface InitMessage {
50
+ type: 'init'
51
+ version: string
46
52
  }
47
53
 
48
54
  export interface ConsoleMessage {
@@ -35,9 +35,13 @@ export class HTTPTransport extends BaseTransport {
35
35
  }
36
36
 
37
37
  const buffer = await response.arrayBuffer()
38
- const data = decode(buffer) as { sessionId: string }
38
+ const data = decode(buffer) as { sessionId: string; version?: string }
39
39
  this.sessionId = data.sessionId
40
40
 
41
+ if (data.version) {
42
+ this.notifyHandlers({ type: 'init', version: data.version })
43
+ }
44
+
41
45
  console.log('PyWire: HTTP transport connected')
42
46
  this.notifyStatus(true)
43
47
 
@@ -10,7 +10,8 @@
10
10
  "declaration": false,
11
11
  "outDir": "./dist",
12
12
  "rootDir": "./src",
13
- "lib": ["ES2020", "DOM", "DOM.Iterable"]
13
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
14
+ "resolveJsonModule": true
14
15
  },
15
16
  "include": ["src/**/*"],
16
17
  "exclude": ["node_modules", "dist"]
@@ -1485,45 +1485,8 @@ class CodeGenerator:
1485
1485
 
1486
1486
  for node in python_ast.body:
1487
1487
  if isinstance(node, (ast.Import, ast.ImportFrom)):
1488
- # Skip imports - already handled
1488
+ # Skip imports - already handled at module level
1489
1489
  continue
1490
- elif isinstance(node, ast.Assign):
1491
- # Module-level assignments become class attributes
1492
- # UNLESS they target 'self' (e.g. self.x = 1), which makes no sense at class level
1493
- # and implies instance initialization.
1494
-
1495
- is_instance_assign = False
1496
- for target in node.targets:
1497
- # Check if target is Attribute(value=Name(id='self'))
1498
- if (
1499
- isinstance(target, ast.Attribute)
1500
- and isinstance(target.value, ast.Name)
1501
- and target.value.id == "self"
1502
- ):
1503
- is_instance_assign = True
1504
- break
1505
-
1506
- # Also check if value is a Call (like wire()) or mutable structure.
1507
- # These should be instance-level to avoid shared state.
1508
- is_mutable_init = isinstance(
1509
- node.value,
1510
- (
1511
- ast.Call,
1512
- ast.List,
1513
- ast.Dict,
1514
- ast.Set,
1515
- ast.ListComp,
1516
- ast.DictComp,
1517
- ast.SetComp,
1518
- ),
1519
- )
1520
-
1521
- if is_instance_assign or is_mutable_init:
1522
- top_level_statements.append(node)
1523
- else:
1524
- # Simple literals (int, str) stay class attributes
1525
- transformed.append(node)
1526
-
1527
1490
  elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
1528
1491
  # Check for decorators
1529
1492
  new_decorators = []
@@ -1544,8 +1507,10 @@ class CodeGenerator:
1544
1507
  # Classes are moved to module level, skip here
1545
1508
  continue
1546
1509
  else:
1547
- # Other statements (Expr, If, For, While, Try)
1548
- # Move to top-level init
1510
+ # ALL other statements (Assign, AnnAssign, AugAssign, Expr, If, For, While, Try, etc.)
1511
+ # are moved to __top_level_init__ for consistent instance-scope execution.
1512
+ # This ensures that dependent code (e.g., conn = ...; conn.row_factory = ...)
1513
+ # all runs in the same scope at instance creation time.
1549
1514
  top_level_statements.append(node)
1550
1515
 
1551
1516
  if top_level_statements:
pywire/runtime/app.py CHANGED
@@ -12,6 +12,7 @@ from starlette.responses import JSONResponse, PlainTextResponse, Response
12
12
  from starlette.routing import Mount, Route, WebSocketRoute
13
13
  from starlette.staticfiles import StaticFiles
14
14
 
15
+ from pywire import __version__
15
16
  from pywire.runtime.error_page import ErrorPage
16
17
  from pywire.runtime.http_transport import HTTPTransportHandler
17
18
  from pywire.runtime.router import Router
@@ -208,7 +209,7 @@ class PyWire:
208
209
  "transports": ["websocket", "http"],
209
210
  # WebTransport requires HTTP/3 - only available when running with Hypercorn
210
211
  "webtransport": False,
211
- "version": "0.1.0",
212
+ "version": __version__,
212
213
  }
213
214
  )
214
215
 
@@ -12,6 +12,7 @@ from starlette.requests import Request
12
12
  from starlette.responses import Response
13
13
 
14
14
  from pywire.runtime.page import BasePage
15
+ from pywire import __version__
15
16
 
16
17
 
17
18
  @dataclass
@@ -118,7 +119,8 @@ class HTTPTransportHandler:
118
119
  self.start_cleanup_task()
119
120
 
120
121
  return Response(
121
- msgpack.packb({"sessionId": session_id}), media_type="application/x-msgpack"
122
+ msgpack.packb({"sessionId": session_id, "version": __version__}),
123
+ media_type="application/x-msgpack",
122
124
  )
123
125
 
124
126
  async def poll(self, request: Request) -> Response:
pywire/runtime/loader.py CHANGED
@@ -80,6 +80,9 @@ class PageLoader:
80
80
  module_any.load_layout = self.load_layout
81
81
  module_any.load_component = self.load_component
82
82
 
83
+ # Inject __file__ for relative path resolution
84
+ module.__file__ = str(pywire_file)
85
+
83
86
  exec(code, module.__dict__)
84
87
 
85
88
  page_class = self._find_page_class(module, pywire_file)
@@ -12,6 +12,7 @@ from starlette.websockets import WebSocket, WebSocketDisconnect
12
12
 
13
13
  from pywire.runtime.logging import log_callback_ctx
14
14
  from pywire.runtime.page import BasePage
15
+ from pywire import __version__
15
16
 
16
17
 
17
18
  class WebSocketHandler:
@@ -34,6 +35,11 @@ class WebSocketHandler:
34
35
  await websocket.accept()
35
36
  self.active_connections.add(websocket)
36
37
 
38
+ # Send init message
39
+ await websocket.send_bytes(
40
+ msgpack.packb({"type": "init", "version": __version__})
41
+ )
42
+
37
43
  try:
38
44
  # Create isolated page instance for this connection
39
45
  # We need to reconstruct the page based on current URL
@@ -1,3 +1,3 @@
1
- /* PyWire Client core v0.1.3 - https://github.com/pywire/pywire */
2
- "use strict";var PyWireCore=(()=>{var ie=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ge=Object.prototype.hasOwnProperty;var Ye=(s,e,t)=>e in s?ie(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Je=(s,e)=>{for(var t in e)ie(s,t,{get:e[t],enumerable:!0})},qe=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Xe(e))!Ge.call(s,i)&&i!==t&&ie(s,i,{get:()=>e[i],enumerable:!(n=Ve(e,i))||n.enumerable});return s};var Ze=s=>qe(ie({},"__esModule",{value:!0}),s);var c=(s,e,t)=>(Ye(s,typeof e!="symbol"?e+"":e,t),t);var Rt={};Je(Rt,{DOMUpdater:()=>b,HTTPTransport:()=>F,PyWireApp:()=>O,TransportManager:()=>_,WebSocketTransport:()=>z,WebTransportTransport:()=>L,app:()=>Ee});var B=class{constructor(){this.messageHandlers=[];this.statusHandlers=[];this.connected=!1}onMessage(e){this.messageHandlers.push(e)}onStatusChange(e){this.statusHandlers.push(e)}isConnected(){return this.connected}notifyHandlers(e){for(let t of this.messageHandlers)try{t(e)}catch(n){console.error("PyWire: Error in message handler",n)}}notifyStatus(e){if(this.connected!==e){this.connected=e;for(let t of this.statusHandlers)try{t(e)}catch(n){console.error("PyWire: Error in status handler",n)}}}};var L=class s extends B{constructor(t){super();this.name="WebTransport";this.transport=null;this.writer=null;this.encoder=new TextEncoder;this.decoder=new TextDecoder;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`https://${window.location.host}/_pywire/webtransport`}static isSupported(){return typeof WebTransport<"u"}async connect(){if(!s.isSupported())throw new Error("WebTransport not supported in this browser");try{let t={},n=window.PYWIRE_CERT_HASH;n&&Array.isArray(n)&&(t.serverCertificateHashes=[{algorithm:"sha-256",value:new Uint8Array(n).buffer}],console.log("PyWire: Using explicit certificate hash for WebTransport")),this.transport=new WebTransport(this.url,t),await this.transport.ready,console.log("PyWire: WebTransport ready"),this.connected=!0,this.startReading()}catch(t){throw this.handleDisconnect(),t}}async startReading(){if(!this.transport)return;let t=this.transport.incomingBidirectionalStreams.getReader();try{for(;;){let{value:n,done:i}=await t.read();if(i)break;this.handleStream(n)}}catch(n){this.connected&&(console.error("PyWire: WebTransport read error",n),this.handleDisconnect())}}async handleStream(t){let n=t.readable.getReader();try{for(;;){let{value:i,done:r}=await n.read();if(r)break;if(i){let o=this.decoder.decode(i);try{let a=JSON.parse(o);this.notifyHandlers(a)}catch(a){console.error("PyWire: Error parsing WebTransport message",a)}}}}catch(i){console.error("PyWire: Stream read error",i)}}async send(t){if(!this.transport||!this.connected){console.warn("PyWire: Cannot send message, WebTransport not connected");return}try{let n=await this.transport.createBidirectionalStream(),i=n.writable.getWriter(),r=this.encoder.encode(JSON.stringify(t));await i.write(r),await i.close(),this.handleStream(n)}catch(n){console.error("PyWire: WebTransport send error",n)}}disconnect(){this.transport&&(this.transport.close(),this.transport=null),this.writer=null,this.connected=!1}handleDisconnect(){this.connected=!1,this.transport=null,this.writer=null}};function Pe(s){let e=s.length,t=0,n=0;for(;n<e;){let i=s.charCodeAt(n++);if(i&4294967168)if(!(i&4294965248))t+=2;else{if(i>=55296&&i<=56319&&n<e){let r=s.charCodeAt(n);(r&64512)===56320&&(++n,i=((i&1023)<<10)+(r&1023)+65536)}i&4294901760?t+=4:t+=3}else{t++;continue}}return t}function Qe(s,e,t){let n=s.length,i=t,r=0;for(;r<n;){let o=s.charCodeAt(r++);if(o&4294967168)if(!(o&4294965248))e[i++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&r<n){let a=s.charCodeAt(r);(a&64512)===56320&&(++r,o=((o&1023)<<10)+(a&1023)+65536)}o&4294901760?(e[i++]=o>>18&7|240,e[i++]=o>>12&63|128,e[i++]=o>>6&63|128):(e[i++]=o>>12&15|224,e[i++]=o>>6&63|128)}else{e[i++]=o;continue}e[i++]=o&63|128}}var je=new TextEncoder,et=50;function tt(s,e,t){je.encodeInto(s,e.subarray(t))}function Be(s,e,t){s.length>et?tt(s,e,t):Qe(s,e,t)}var nt=4096;function xe(s,e,t){let n=e,i=n+t,r=[],o="";for(;n<i;){let a=s[n++];if(!(a&128))r.push(a);else if((a&224)===192){let d=s[n++]&63;r.push((a&31)<<6|d)}else if((a&240)===224){let d=s[n++]&63,w=s[n++]&63;r.push((a&31)<<12|d<<6|w)}else if((a&248)===240){let d=s[n++]&63,w=s[n++]&63,g=s[n++]&63,m=(a&7)<<18|d<<12|w<<6|g;m>65535&&(m-=65536,r.push(m>>>10&1023|55296),m=56320|m&1023),r.push(m)}else r.push(a);r.length>=nt&&(o+=String.fromCharCode(...r),r.length=0)}return r.length>0&&(o+=String.fromCharCode(...r)),o}var it=new TextDecoder,st=200;function rt(s,e,t){let n=s.subarray(e,e+t);return it.decode(n)}function Ie(s,e,t){return t>st?rt(s,e,t):xe(s,e,t)}var W=class{constructor(e,t){c(this,"type");c(this,"data");this.type=e,this.data=t}};var x=class s extends Error{constructor(e){super(e);let t=Object.create(s.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:s.name})}};function Le(s,e,t){let n=t/4294967296,i=t;s.setUint32(e,n),s.setUint32(e+4,i)}function se(s,e,t){let n=Math.floor(t/4294967296),i=t;s.setUint32(e,n),s.setUint32(e+4,i)}function re(s,e){let t=s.getInt32(e),n=s.getUint32(e+4);return t*4294967296+n}function We(s,e){let t=s.getUint32(e),n=s.getUint32(e+4);return t*4294967296+n}var ot=-1,at=4294967296-1,ct=17179869184-1;function dt({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=ct)if(e===0&&s<=at){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{let t=s/4294967296,n=s&4294967295,i=new Uint8Array(8),r=new DataView(i.buffer);return r.setUint32(0,e<<2|t&3),r.setUint32(4,n),i}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),se(n,4,s),t}}function lt(s){let e=s.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,i=Math.floor(n/1e9);return{sec:t+i,nsec:n-i*1e9}}function ht(s){if(s instanceof Date){let e=lt(s);return dt(e)}else return null}function ft(s){let e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),n=e.getUint32(4),i=(t&3)*4294967296+n,r=t>>>2;return{sec:i,nsec:r}}case 12:{let t=re(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new x(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function ut(s){let e=ft(s);return new Date(e.sec*1e3+e.nsec/1e6)}var Ce={type:ot,encode:ht,decode:ut};var oe=class oe{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register(Ce)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let i=-1-e;this.builtInEncoders[i]=t,this.builtInDecoders[i]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let i=this.builtInEncoders[n];if(i!=null){let r=i(e,t);if(r!=null){let o=-1-n;return new W(o,r)}}}for(let n=0;n<this.encoders.length;n++){let i=this.encoders[n];if(i!=null){let r=i(e,t);if(r!=null){let o=n;return new W(o,r)}}}return e instanceof W?e:null}decode(e,t,n){let i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,n):new W(t,e)}};c(oe,"defaultCodec",new oe);var $=oe;function pt(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function G(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):pt(s)?new Uint8Array(s):Uint8Array.from(s)}var gt=100,mt=2048,ae=class s{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"maxDepth");c(this,"initialBufferSize");c(this,"sortKeys");c(this,"forceFloat32");c(this,"ignoreUndefined");c(this,"forceIntegerToFloat");c(this,"pos");c(this,"view");c(this,"bytes");c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??gt,this.initialBufferSize=e?.initialBufferSize??mt,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new s({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),i=new DataView(t);n.set(this.bytes),this.view=i,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Pe(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),Be(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=G(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let i of e)this.doEncode(i,t+1)}countWithoutUndefined(e,t){let n=0;for(let i of t)e[i]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(let r of n){let o=e[r];this.ignoreUndefined&&o===void 0||(this.encodeString(r),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),i=n.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(n);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),Le(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),se(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function N(s,e){return new ae(e).encodeSharedRef(s)}function ce(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}var wt=16,yt=16,de=class{constructor(e=wt,t=yt){c(this,"hit",0);c(this,"miss",0);c(this,"caches");c(this,"maxKeyLength");c(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let i=this.caches[n-1];e:for(let r of i){let o=r.bytes;for(let a=0;a<n;a++)if(o[a]!==e[t+a])continue e;return r.str}return null}store(e,t){let n=this.caches[e.length-1],i={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)}decode(e,t,n){let i=this.find(e,t,n);if(i!=null)return this.hit++,i;this.miss++;let r=xe(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,r),r}};var ve="array",q="map_key",He="map_value",xt=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new x("The type of key must be string or number but "+typeof s)},Se=class{constructor(){c(this,"stack",[]);c(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=ve,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=q,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===ve){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===q||e.type===He){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},J=-1,Te=new DataView(new ArrayBuffer(0)),vt=new Uint8Array(Te.buffer);try{Te.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var De=new RangeError("Insufficient data"),St=new de,le=class s{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"rawStrings");c(this,"maxStrLength");c(this,"maxBinLength");c(this,"maxArrayLength");c(this,"maxMapLength");c(this,"maxExtLength");c(this,"keyDecoder");c(this,"mapKeyConverter");c(this,"totalPos",0);c(this,"pos",0);c(this,"view",Te);c(this,"bytes",vt);c(this,"headByte",J);c(this,"stack",new Se);c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:St,this.mapKeyConverter=e?.mapKeyConverter??xt}clone(){return new s({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=J,this.stack.reset()}setBuffer(e){let t=G(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===J&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=G(e),i=new Uint8Array(t.length+n.length);i.set(t),i.set(n,t.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),t=!0}catch(d){if(!(d instanceof RangeError))throw d}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:i,pos:r,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${ce(i)} at ${o} (${r} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,i=-1;for await(let r of e){if(t&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(r),n&&(i=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else{let i=e-160;t=this.decodeString(i,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let i=this.lookU8();t=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();t=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();t=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===196){let i=this.lookU8();t=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();t=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();t=this.decodeBinary(i,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let i=this.lookU8();t=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();t=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();t=this.decodeExtension(i,4)}else throw new x(`Unrecognized type byte: ${ce(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let i=n.top();if(i.type===ve)if(i.array[i.position]=t,i.position++,i.position===i.size)t=i.array,n.release(i);else continue e;else if(i.type===q){if(t==="__proto__")throw new x("The key __proto__ is not allowed");i.key=this.mapKeyConverter(t),i.type=He;continue e}else if(i.map[i.key]=t,i.readCount++,i.readCount===i.size)t=i.map,n.release(i);else{i.key=null,i.type=q;continue e}}return t}}readHeadByte(){return this.headByte===J&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=J}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new x(`Unrecognized array type byte: ${ce(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new x(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new x(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new x(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw De;let n=this.pos+t,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,n,e):i=Ie(this.bytes,n,e),this.pos+=t+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===q:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new x(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw De;let n=this.pos+t,i=this.bytes.subarray(n,n+e);return this.pos+=t+e,i}decodeExtension(e,t){if(e>this.maxExtLength)throw new x(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=We(this.view,this.pos);return this.pos+=8,e}readI64(){let e=re(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function C(s,e){return new le(e).decode(s)}var z=class extends B{constructor(t){super();this.name="WebSocket";this.socket=null;this.reconnectAttempts=0;this.maxReconnectDelay=5e3;this.shouldReconnect=!0;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_pywire/ws`}connect(){return new Promise((t,n)=>{try{this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("PyWire: WebSocket connected"),this.notifyStatus(!0),this.reconnectAttempts=0,t()},this.socket.onmessage=i=>{try{let r=C(i.data);this.notifyHandlers(r)}catch(r){console.error("PyWire: Error parsing WebSocket message",r)}},this.socket.onclose=()=>{console.log("PyWire: WebSocket disconnected"),this.notifyStatus(!1),this.shouldReconnect&&this.scheduleReconnect()},this.socket.onerror=i=>{console.error("PyWire: WebSocket error",i),this.connected||n(new Error("WebSocket connection failed"))}}catch(i){n(i)}})}send(t){this.socket&&this.socket.readyState===WebSocket.OPEN?this.socket.send(N(t)):console.warn("PyWire: Cannot send message, WebSocket not open")}disconnect(){this.shouldReconnect=!1,this.socket&&(this.socket.close(),this.socket=null),this.notifyStatus(!1)}scheduleReconnect(){let t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.maxReconnectDelay);console.log(`PyWire: Reconnecting in ${t}ms...`),setTimeout(()=>{this.reconnectAttempts++,this.connect().catch(()=>{})},t)}};var F=class extends B{constructor(t){super();this.name="HTTP";this.polling=!1;this.pollAbortController=null;this.sessionId=null;this.baseUrl=t||`${window.location.origin}/_pywire`}async connect(){try{let t=await fetch(`${this.baseUrl}/session`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack"},body:N({path:window.location.pathname+window.location.search})});if(!t.ok)throw new Error(`HTTP session init failed: ${t.status}`);let n=await t.arrayBuffer(),i=C(n);this.sessionId=i.sessionId,console.log("PyWire: HTTP transport connected"),this.notifyStatus(!0),this.startPolling()}catch(t){throw console.error("PyWire: HTTP transport connection failed",t),t}}async startPolling(){if(!this.polling)for(this.polling=!0;this.polling&&this.connected;)try{this.pollAbortController=new AbortController;let t=await fetch(`${this.baseUrl}/poll?session=${this.sessionId}`,{method:"GET",signal:this.pollAbortController.signal,headers:{Accept:"application/x-msgpack"}});if(!t.ok){if(t.status===404){console.warn("PyWire: HTTP session expired, reconnecting..."),this.notifyStatus(!1),await this.connect();return}throw new Error(`Poll failed: ${t.status}`)}let n=await t.arrayBuffer(),i=C(n);for(let r of i)this.notifyHandlers(r)}catch(t){if(t instanceof Error&&t.name==="AbortError")break;console.error("PyWire: HTTP poll error",t),await this.sleep(1e3)}}async send(t){if(!this.connected||!this.sessionId){console.warn("PyWire: Cannot send message, HTTP transport not connected");return}try{let n=await fetch(`${this.baseUrl}/event`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack","X-PyWire-Session":this.sessionId},body:N(t)});if(!n.ok)throw new Error(`Event send failed: ${n.status}`);let i=await n.arrayBuffer(),r=C(i);this.notifyHandlers(r)}catch(n){console.error("PyWire: HTTP send error",n)}}disconnect(){this.polling=!1,this.notifyStatus(!1),this.pollAbortController&&(this.pollAbortController.abort(),this.pollAbortController=null),this.sessionId=null}sleep(t){return new Promise(n=>setTimeout(n,t))}};var Tt={enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0},_=class{constructor(e={}){this.transport=null;this.messageHandlers=[];this.statusHandlers=[];this.config={...Tt,...e}}async connect(){let e=this.getTransportPriority();for(let t of e)try{console.log(`PyWire: Trying ${t.name}...`),this.transport=new t;for(let n of this.messageHandlers)this.transport.onMessage(n);this.transport.onStatusChange(n=>{this.notifyStatusHandlers(n)}),await this.transport.connect(),console.log(`PyWire: Connected via ${this.transport.name}`);return}catch(n){console.warn(`PyWire: ${t.name} failed, trying next...`,n),this.transport=null}throw new Error("PyWire: All transports failed")}getTransportPriority(){let e=[];return this.config.enableWebTransport&&L.isSupported()&&window.location.protocol==="https:"&&e.push(L),this.config.enableWebSocket&&typeof WebSocket<"u"&&e.push(z),this.config.enableHTTP&&e.push(F),e}send(e){this.transport?this.transport.send(e):console.warn("PyWire: No active transport")}onMessage(e){this.messageHandlers.push(e),this.transport&&this.transport.onMessage(e)}onStatusChange(e){this.statusHandlers.push(e)}notifyStatusHandlers(e){for(let t of this.statusHandlers)t(e)}disconnect(){this.transport&&(this.transport.disconnect(),this.transport=null,this.notifyStatusHandlers(!1))}getActiveTransport(){return this.transport?.name||null}isConnected(){return this.transport?.isConnected()||!1}};var Re=11;function bt(s,e){var t=e.attributes,n,i,r,o,a;if(!(e.nodeType===Re||s.nodeType===Re)){for(var d=t.length-1;d>=0;d--)n=t[d],i=n.name,r=n.namespaceURI,o=n.value,r?(i=n.localName||i,a=s.getAttributeNS(r,i),a!==o&&(n.prefix==="xmlns"&&(i=n.name),s.setAttributeNS(r,i,o))):(a=s.getAttribute(i),a!==o&&s.setAttribute(i,o));for(var w=s.attributes,g=w.length-1;g>=0;g--)n=w[g],i=n.name,r=n.namespaceURI,r?(i=n.localName||i,e.hasAttributeNS(r,i)||s.removeAttributeNS(r,i)):e.hasAttribute(i)||s.removeAttribute(i)}}var he,Ut="http://www.w3.org/1999/xhtml",v=typeof document>"u"?void 0:document,Et=!!v&&"content"in v.createElement("template"),At=!!v&&v.createRange&&"createContextualFragment"in v.createRange();function Mt(s){var e=v.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function kt(s){he||(he=v.createRange(),he.selectNode(v.body));var e=he.createContextualFragment(s);return e.childNodes[0]}function Pt(s){var e=v.createElement("body");return e.innerHTML=s,e.childNodes[0]}function Bt(s){return s=s.trim(),Et?Mt(s):At?kt(s):Pt(s)}function fe(s,e){var t=s.nodeName,n=e.nodeName,i,r;return t===n?!0:(i=t.charCodeAt(0),r=n.charCodeAt(0),i<=90&&r>=97?t===n.toUpperCase():r<=90&&i>=97?n===t.toUpperCase():!1)}function It(s,e){return!e||e===Ut?v.createElement(s):v.createElementNS(e,s)}function Lt(s,e){for(var t=s.firstChild;t;){var n=t.nextSibling;e.appendChild(t),t=n}return e}function be(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var $e={OPTION:function(s,e){var t=s.parentNode;if(t){var n=t.nodeName.toUpperCase();n==="OPTGROUP"&&(t=t.parentNode,n=t&&t.nodeName.toUpperCase()),n==="SELECT"&&!t.hasAttribute("multiple")&&(s.hasAttribute("selected")&&!e.selected&&(s.setAttribute("selected","selected"),s.removeAttribute("selected")),t.selectedIndex=-1)}be(s,e,"selected")},INPUT:function(s,e){be(s,e,"checked"),be(s,e,"disabled"),s.value!==e.value&&(s.value=e.value),e.hasAttribute("value")||s.removeAttribute("value")},TEXTAREA:function(s,e){var t=e.value;s.value!==t&&(s.value=t);var n=s.firstChild;if(n){var i=n.nodeValue;if(i==t||!t&&i==s.placeholder)return;n.nodeValue=t}},SELECT:function(s,e){if(!e.hasAttribute("multiple")){for(var t=-1,n=0,i=s.firstChild,r,o;i;)if(o=i.nodeName&&i.nodeName.toUpperCase(),o==="OPTGROUP")r=i,i=r.firstChild,i||(i=r.nextSibling,r=null);else{if(o==="OPTION"){if(i.hasAttribute("selected")){t=n;break}n++}i=i.nextSibling,!i&&r&&(i=r.nextSibling,r=null)}s.selectedIndex=t}}},Z=1,Ne=11,ze=3,Fe=8;function I(){}function Wt(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function Ct(s){return function(t,n,i){if(i||(i={}),typeof n=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var r=n;n=v.createElement("html"),n.innerHTML=r}else n=Bt(n);else n.nodeType===Ne&&(n=n.firstElementChild);var o=i.getNodeKey||Wt,a=i.onBeforeNodeAdded||I,d=i.onNodeAdded||I,w=i.onBeforeElUpdated||I,g=i.onElUpdated||I,m=i.onBeforeNodeDiscarded||I,E=i.onNodeDiscarded||I,V=i.onBeforeElChildrenUpdated||I,S=i.skipFromChildren||I,X=i.addChild||function(l,h){return l.appendChild(h)},D=i.childrenOnly===!0,T=Object.create(null),A=[];function M(l){A.push(l)}function Ae(l,h){if(l.nodeType===Z)for(var p=l.firstChild;p;){var f=void 0;h&&(f=o(p))?M(f):(E(p),p.firstChild&&Ae(p,h)),p=p.nextSibling}}function Q(l,h,p){m(l)!==!1&&(h&&h.removeChild(l),E(l),Ae(l,p))}function pe(l){if(l.nodeType===Z||l.nodeType===Ne)for(var h=l.firstChild;h;){var p=o(h);p&&(T[p]=h),pe(h),h=h.nextSibling}}pe(t);function ge(l){d(l);for(var h=l.firstChild;h;){var p=h.nextSibling,f=o(h);if(f){var u=T[f];u&&fe(h,u)?(h.parentNode.replaceChild(u,h),j(u,h)):ge(h)}else ge(h);h=p}}function _e(l,h,p){for(;h;){var f=h.nextSibling;(p=o(h))?M(p):Q(h,l,!0),h=f}}function j(l,h,p){var f=o(h);if(f&&delete T[f],!p){var u=w(l,h);if(u===!1||(u instanceof HTMLElement&&(l=u,pe(l)),s(l,h),g(l),V(l,h)===!1))return}l.nodeName!=="TEXTAREA"?Ke(l,h):$e.TEXTAREA(l,h)}function Ke(l,h){var p=S(l,h),f=h.firstChild,u=l.firstChild,H,U,R,te,k;e:for(;f;){for(te=f.nextSibling,H=o(f);!p&&u;){if(R=u.nextSibling,f.isSameNode&&f.isSameNode(u)){f=te,u=R;continue e}U=o(u);var ne=u.nodeType,P=void 0;if(ne===f.nodeType&&(ne===Z?(H?H!==U&&((k=T[H])?R===k?P=!1:(l.insertBefore(k,u),U?M(U):Q(u,l,!0),u=k,U=o(u)):P=!1):U&&(P=!1),P=P!==!1&&fe(u,f),P&&j(u,f)):(ne===ze||ne==Fe)&&(P=!0,u.nodeValue!==f.nodeValue&&(u.nodeValue=f.nodeValue))),P){f=te,u=R;continue e}U?M(U):Q(u,l,!0),u=R}if(H&&(k=T[H])&&fe(k,f))p||X(l,k),j(k,f);else{var ye=a(f);ye!==!1&&(ye&&(f=ye),f.actualize&&(f=f.actualize(l.ownerDocument||v)),X(l,f),ge(f))}f=te,u=R}_e(l,u,U);var ke=$e[l.nodeName];ke&&ke(l,h)}var y=t,ee=y.nodeType,Me=n.nodeType;if(!D){if(ee===Z)Me===Z?fe(t,n)||(E(t),y=Lt(t,It(n.nodeName,n.namespaceURI))):y=n;else if(ee===ze||ee===Fe){if(Me===ee)return y.nodeValue!==n.nodeValue&&(y.nodeValue=n.nodeValue),y;y=n}}if(y===n)E(t);else{if(n.isSameNode&&n.isSameNode(y))return;if(j(y,n,D),A)for(var me=0,Oe=A.length;me<Oe;me++){var we=T[A[me]];we&&Q(we,we.parentNode,!1)}}return!D&&y!==t&&t.parentNode&&(y.actualize&&(y=y.actualize(t.ownerDocument||v)),t.parentNode.replaceChild(y,t)),y}}var Dt=Ct(bt),Ue=Dt;var K=class K{constructor(e=!1){this.debug=e}getNodeKey(e){if(e instanceof HTMLElement){for(let t of e.attributes)if(t.name.startsWith("data-on-"))return`${e.tagName}-${t.name}-${t.value}`;if(e.id&&!e.id.startsWith("pywire-uid-"))return e.id;if((e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&e.name)return`${e.tagName}-name-${e.name}`}}getElementSelector(e){if(e.id)return`#${e.id}`;let t=[],n=e;for(;n&&n!==document.body&&t.length<5;){let i=n.tagName.toLowerCase();if(n.id){i=`#${n.id}`,t.unshift(i);break}(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)&&n.name&&(i+=`[name="${n.name}"]`);for(let r of n.attributes)if(r.name.startsWith("data-on-")){i+=`[${r.name}="${r.value}"]`;break}if(n.parentElement){let o=Array.from(n.parentElement.children).filter(a=>a.tagName===n.tagName);if(o.length>1){let a=o.indexOf(n)+1;i+=`:nth-of-type(${a})`}}t.unshift(i),n=n.parentElement}return t.join(" > ")}captureFocusState(){let e=document.activeElement;if(!e||e===document.body||e===document.documentElement)return null;let t={selector:this.getElementSelector(e),id:e.id||null,tagName:e.tagName,selectionStart:null,selectionEnd:null,scrollTop:0,scrollLeft:0,value:""};return(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd,t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft,t.value=e.value),t}restoreFocusState(e){if(!e)return;let t=null;if(e.id&&(t=document.getElementById(e.id)),!t&&e.selector)try{t=document.querySelector(e.selector)}catch{}if(t&&(t.focus(),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){if(e.value&&t.value!==e.value&&(t.value=e.value),e.selectionStart!==null&&e.selectionEnd!==null)try{t.setSelectionRange(e.selectionStart,e.selectionEnd)}catch{}t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft}}applyUpdate(e,t){K.isUpdating=!0,this.debug&&console.log("[DOMUpdater] Starting update, isUpdating =",K.isUpdating);try{let n=this.captureFocusState();if(Ue){try{Ue(e,t,{getNodeKey:i=>this.getNodeKey(i),onBeforeElUpdated:(i,r)=>{if(i instanceof HTMLInputElement&&r instanceof HTMLInputElement)if(i.type==="checkbox"||i.type==="radio")r.checked=i.checked;else{let o=r.value||"",a=i.value||"";(a.startsWith(o)||o.startsWith(a))&&(r.value=a)}if(i instanceof HTMLTextAreaElement&&r instanceof HTMLTextAreaElement){let o=r.value||"",a=i.value||"";(a.startsWith(o)||o.startsWith(a))&&(r.value=a)}return i instanceof HTMLSelectElement&&r instanceof HTMLSelectElement&&(i.value&&Array.from(r.options).some(o=>o.value===i.value)?r.value=i.value:i.selectedIndex>=0&&i.selectedIndex<r.options.length&&(r.selectedIndex=i.selectedIndex)),i.id&&i.id.startsWith("pywire-uid-")&&!r.id&&(r.id=i.id),!0},onBeforeNodeDiscarded:()=>!0})}catch(i){console.error("Morphdom failed:",i),e===document.documentElement&&(document.open(),document.write(t),document.close())}this.restoreFocusState(n)}else e===document.documentElement&&(document.open(),document.write(t),document.close())}finally{setTimeout(()=>{K.isUpdating=!1},0)}}update(e){let t=/<html[\s>]/i.test(e),n=/<body[\s>]/i.test(e);if(!t&&document.body){if(n){this.applyUpdate(document.body,e);return}let i=`<body>${e}</body>`;this.applyUpdate(document.body,i);return}this.applyUpdate(document.documentElement,e)}updateRegion(e,t){let n=document.querySelector(`[data-pw-region="${e}"]`);if(!n){this.debug&&console.warn("[DOMUpdater] Region not found:",e);return}this.applyUpdate(n,t),n.getAttribute("data-pw-region")||n.setAttribute("data-pw-region",e)}};K.isUpdating=!1;var b=K;var ue=class{constructor(e){this.debouncers=new Map;this.throttlers=new Map;this.supportedEvents=["click","submit","input","change","keydown","keyup","focus","blur","mouseenter","mouseleave","scroll","contextmenu"];this.suppressDuringUpdate=["focus","blur","mouseenter","mouseleave"];this.app=e}debugLog(...e){this.app.getConfig().debug&&console.log(...e)}init(){this.supportedEvents.forEach(e=>{let t=e==="mouseenter"||e==="mouseleave"||e==="focus"||e==="blur"||e==="scroll"?{capture:!0}:void 0;document.addEventListener(e,n=>this.handleEvent(n),t)})}getHandlers(e,t){let n=`data-on-${t}`,i=e.getAttribute(n);if(!i)return[];if(i.trim().startsWith("["))try{let r=JSON.parse(i);if(Array.isArray(r))return r.flatMap(o=>{if(!o||typeof o!="object")return[];let a="handler"in o&&typeof o.handler=="string"?o.handler:null;if(!a)return[];let d="modifiers"in o&&Array.isArray(o.modifiers)?o.modifiers.filter(g=>typeof g=="string"):[],w="args"in o&&Array.isArray(o.args)?o.args:void 0;return[{name:a,modifiers:d,args:w}]})}catch(r){console.error("Error parsing event handlers:",r)}else{let r=e.getAttribute(`data-modifiers-${t}`),o=r?r.split(" ").filter(a=>a):[];return[{name:i,modifiers:o,args:void 0}]}return[]}async handleEvent(e){let t=e.type;if(b.isUpdating&&this.suppressDuringUpdate.includes(t)){this.debugLog("[Handler] SUPPRESSING event during update:",t,"isUpdating=",b.isUpdating);return}this.debugLog("[Handler] Processing event:",t,"isUpdating=",b.isUpdating);let n=e.composedPath?e.composedPath():[],i=!1;for(let r of n){if(i)break;if(r instanceof HTMLElement){let o=r,a=this.getHandlers(o,t);if(a.length>0){this.debugLog("[handleEvent] Found handlers on",o.tagName,a);for(let d of a)!d.modifiers.includes("window")&&!d.modifiers.includes("outside")&&(this.processEvent(o,t,d.name,d.modifiers,e,d.args),e.cancelBubble&&(i=!0))}}}this.handleGlobalEvent(e)}handleGlobalEvent(e){let t=e.type,n=`[data-modifiers-${t}*="window"]`,i=`[data-modifiers-${t}*="outside"]`;document.querySelectorAll(`${n}, ${i}`).forEach(o=>{if(!(o instanceof HTMLElement))return;let a=this.getHandlers(o,t);for(let d of a)if(d.modifiers.includes("window")&&this.processEvent(o,t,d.name,d.modifiers,e,d.args),d.modifiers.includes("outside")){let w=e.target;w&&!o.contains(w)&&this.processEvent(o,t,d.name,d.modifiers,e,d.args)}})}processEvent(e,t,n,i,r,o){if(this.debugLog("[processEvent]",t,"handler:",n,"modifiers:",i),(i.includes("prevent")||t==="submit")&&(this.debugLog("[processEvent] Calling preventDefault"),r.preventDefault()),i.includes("stop")&&r.stopPropagation(),i.includes("self")&&r.target!==e||i.includes("shift")&&(!("shiftKey"in r)||!r.shiftKey)||i.includes("ctrl")&&(!("ctrlKey"in r)||!r.ctrlKey)||i.includes("alt")&&(!("altKey"in r)||!r.altKey)||i.includes("meta")&&(!("metaKey"in r)||!r.metaKey)||i.includes("cmd")&&(!("metaKey"in r)||!r.metaKey))return;if(r instanceof KeyboardEvent){let m=["enter","escape","space","tab","up","down","left","right"],E=["shift","ctrl","alt","meta","cmd","window","outside","prevent","stop","self","debounce","throttle"],V=i.filter(S=>E.includes(S)||S.startsWith("debounce")||S.startsWith("throttle")||S.endsWith("ms")?!1:m.includes(S)||S.length===1);if(V.length>0){let S=r.key.toLowerCase();this.debugLog("[processEvent] Key check. Pressed:",S,"Modifiers:",V);let X={escape:"escape",esc:"escape",enter:"enter",space:" ",spacebar:" "," ":" ",tab:"tab",up:"arrowup",arrowup:"arrowup",down:"arrowdown",arrowdown:"arrowdown",left:"arrowleft",arrowleft:"arrowleft",right:"arrowright",arrowright:"arrowright"},D=X[S]||S,T=!1;for(let A of V){let M=X[A]||A;if(this.debugLog("[processEvent] Comparing constraint:",A,"->",M,"vs",D,"code:",r.code),M===D){T=!0;break}if(r.code&&r.code.toLowerCase()===`key${M}`){T=!0;break}}if(!T){this.debugLog("[processEvent] No key match found.");return}}}let a=i.find(m=>m.startsWith("debounce")),d=i.find(m=>m.startsWith("throttle")),g=`${e.id||this.getUniqueId(e)}-${t}-${n}`;if(a){let m=this.parseDuration(i,250);this.debouncers.has(g)&&window.clearTimeout(this.debouncers.get(g));let E=window.setTimeout(()=>{this.debouncers.delete(g),this.dispatchEvent(e,t,n,r,o)},m);this.debouncers.set(g,E);return}if(d){let m=this.parseDuration(i,250);if(this.throttlers.has(g))return;this.throttlers.set(g,Date.now()),this.dispatchEvent(e,t,n,r,o),window.setTimeout(()=>{this.throttlers.delete(g)},m);return}this.dispatchEvent(e,t,n,r,o)}dispatchEvent(e,t,n,i,r){let o={};r&&r.length>0?r.forEach((d,w)=>{o[`arg${w}`]=d}):o=this.getArgs(e);let a={type:t,id:e.id,args:o};if(e instanceof HTMLInputElement?(a.value=e.value,(e.type==="checkbox"||e.type==="radio")&&(a.checked=e.checked)):(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(a.value=e.value),i instanceof KeyboardEvent&&(a.key=i.key,a.keyCode=i.keyCode),t==="submit"&&e instanceof HTMLFormElement){let d=new FormData(e),w={};d.forEach((g,m)=>{g instanceof File||(w[m]=g.toString())}),a.formData=w}this.app.sendEvent(n,a)}parseDuration(e,t){let n=e.findIndex(a=>a.startsWith("debounce")),i=e.findIndex(a=>a.startsWith("throttle")),r=n!==-1?n:i;if(r!==-1&&e[r+1]){let a=e[r+1];if(a.endsWith("ms")){let d=parseInt(a);if(!isNaN(d))return d}}let o=e[r];if(o&&o.includes("-")){let a=o.split("-"),d=parseInt(a[1]);if(!isNaN(d))return d}return t}getUniqueId(e){return e.id||(e.id="pywire-uid-"+Math.random().toString(36).substr(2,9)),e.id}getArgs(e){let t={};if(e instanceof HTMLElement){for(let n in e.dataset)if(n.startsWith("arg"))try{t[n]=JSON.parse(e.dataset[n]||"null")}catch{t[n]=e.dataset[n]}}return t}};var Ht={autoInit:!0,enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0,debug:!1},O=class{constructor(e={}){this.initialized=!1;this.siblingPaths=[];this.pathRegexes=[];this.pjaxEnabled=!1;this.isConnected=!1;this.config={...Ht,...e},this.transport=new _(this.config),this.updater=new b(this.config.debug),this.eventHandler=new ue(this)}getConfig(){return this.config}async init(){if(!this.initialized){this.initialized=!0,this.transport.onMessage(e=>this.handleMessage(e)),this.transport.onStatusChange(e=>this.handleStatusChange(e));try{await this.transport.connect()}catch(e){console.error("PyWire: Failed to connect:",e)}this.loadSPAMetadata(),this.setupSPANavigation(),this.eventHandler.init(),console.log(`PyWire: Initialized (transport: ${this.transport.getActiveTransport()}, spa_paths: ${this.siblingPaths.length}, pjax: ${this.pjaxEnabled})`)}}handleStatusChange(e){this.isConnected=e}loadSPAMetadata(){let e=document.getElementById("_pywire_spa_meta");if(e)try{let t=JSON.parse(e.textContent||"{}");this.siblingPaths=t.sibling_paths||[],this.pjaxEnabled=!!t.enable_pjax,t.debug!==void 0&&(this.config.debug=!!t.debug),this.pathRegexes=this.siblingPaths.map(n=>this.patternToRegex(n))}catch(t){console.warn("PyWire: Failed to parse SPA metadata",t)}}patternToRegex(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return t=t.replace(/:(\\w+)(:\\w+)?/g,"([^/]+)"),t=t.replace(/\\{(\\w+)(:\\w+)?\\}/g,"([^/]+)"),new RegExp(`^${t}$`)}isSiblingPath(e){return this.pathRegexes.some(t=>t.test(e))}setupSPANavigation(){window.addEventListener("popstate",()=>{this.sendRelocate(window.location.pathname+window.location.search)}),!(this.siblingPaths.length===0&&!this.pjaxEnabled)&&document.addEventListener("click",e=>{let t=e.target.closest("a[href]");if(!t||t.origin!==window.location.origin||t.hasAttribute("download")||t.target==="_blank")return;let n=!1;(this.pjaxEnabled||this.isSiblingPath(t.pathname))&&(n=!0),n&&(e.preventDefault(),this.navigateTo(t.pathname+t.search))})}navigateTo(e){if(!this.isConnected){console.warn("PyWire: Navigation blocked - Offline");return}history.pushState({},"",e),this.sendRelocate(e)}sendRelocate(e){let t={type:"relocate",path:e};this.transport.send(t)}sendEvent(e,t){let n={type:"event",handler:e,path:window.location.pathname+window.location.search,data:t};this.transport.send(n)}async handleMessage(e){switch(e.type){case"update":e.regions&&e.regions.length>0?e.regions.forEach(t=>{this.updater.updateRegion(t.region,t.html)}):e.html&&this.updater.update(e.html);break;case"reload":console.log("PyWire: Reloading..."),window.location.reload();break;case"error":console.error("PyWire: Server error:",e.error);break;case"error_trace":console.error("PyWire: Error:",e.error);break;case"console":if(e.lines&&e.lines.length>0){let t="PyWire Server:",n=e.lines.join(`
3
- `);e.level==="error"?console.error(t,n):e.level==="warn"?console.warn(t,n):console.log(t,n)}break;default:console.warn("PyWire: Unknown message type",e)}}getTransport(){return this.transport.getActiveTransport()}disconnect(){this.transport.disconnect()}};var Ee=new O;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Ee.init()):Ee.init();return Ze(Rt);})();
1
+ /* PyWire Client core v0.1.5 - https://github.com/pywire/pywire */
2
+ "use strict";var PyWireCore=(()=>{var ie=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Je=(s,e,t)=>e in s?ie(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var qe=(s,e)=>{for(var t in e)ie(s,t,{get:e[t],enumerable:!0})},Ze=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ge(e))!Ye.call(s,i)&&i!==t&&ie(s,i,{get:()=>e[i],enumerable:!(n=Xe(e,i))||n.enumerable});return s};var Qe=s=>Ze(ie({},"__esModule",{value:!0}),s);var c=(s,e,t)=>(Je(s,typeof e!="symbol"?e+"":e,t),t);var Nt={};qe(Nt,{DOMUpdater:()=>T,HTTPTransport:()=>F,PyWireApp:()=>O,TransportManager:()=>_,WebSocketTransport:()=>z,WebTransportTransport:()=>W,app:()=>Ee});var I=class{constructor(){this.messageHandlers=[];this.statusHandlers=[];this.connected=!1}onMessage(e){this.messageHandlers.push(e)}onStatusChange(e){this.statusHandlers.push(e)}isConnected(){return this.connected}notifyHandlers(e){for(let t of this.messageHandlers)try{t(e)}catch(n){console.error("PyWire: Error in message handler",n)}}notifyStatus(e){if(this.connected!==e){this.connected=e;for(let t of this.statusHandlers)try{t(e)}catch(n){console.error("PyWire: Error in status handler",n)}}}};var W=class s extends I{constructor(t){super();this.name="WebTransport";this.transport=null;this.writer=null;this.encoder=new TextEncoder;this.decoder=new TextDecoder;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`https://${window.location.host}/_pywire/webtransport`}static isSupported(){return typeof WebTransport<"u"}async connect(){if(!s.isSupported())throw new Error("WebTransport not supported in this browser");try{let t={},n=window.PYWIRE_CERT_HASH;n&&Array.isArray(n)&&(t.serverCertificateHashes=[{algorithm:"sha-256",value:new Uint8Array(n).buffer}],console.log("PyWire: Using explicit certificate hash for WebTransport")),this.transport=new WebTransport(this.url,t),await this.transport.ready,console.log("PyWire: WebTransport ready"),this.connected=!0,this.startReading()}catch(t){throw this.handleDisconnect(),t}}async startReading(){if(!this.transport)return;let t=this.transport.incomingBidirectionalStreams.getReader();try{for(;;){let{value:n,done:i}=await t.read();if(i)break;this.handleStream(n)}}catch(n){this.connected&&(console.error("PyWire: WebTransport read error",n),this.handleDisconnect())}}async handleStream(t){let n=t.readable.getReader();try{for(;;){let{value:i,done:r}=await n.read();if(r)break;if(i){let o=this.decoder.decode(i);try{let a=JSON.parse(o);this.notifyHandlers(a)}catch(a){console.error("PyWire: Error parsing WebTransport message",a)}}}}catch(i){console.error("PyWire: Stream read error",i)}}async send(t){if(!this.transport||!this.connected){console.warn("PyWire: Cannot send message, WebTransport not connected");return}try{let n=await this.transport.createBidirectionalStream(),i=n.writable.getWriter(),r=this.encoder.encode(JSON.stringify(t));await i.write(r),await i.close(),this.handleStream(n)}catch(n){console.error("PyWire: WebTransport send error",n)}}disconnect(){this.transport&&(this.transport.close(),this.transport=null),this.writer=null,this.connected=!1}handleDisconnect(){this.connected=!1,this.transport=null,this.writer=null}};function Pe(s){let e=s.length,t=0,n=0;for(;n<e;){let i=s.charCodeAt(n++);if(i&4294967168)if(!(i&4294965248))t+=2;else{if(i>=55296&&i<=56319&&n<e){let r=s.charCodeAt(n);(r&64512)===56320&&(++n,i=((i&1023)<<10)+(r&1023)+65536)}i&4294901760?t+=4:t+=3}else{t++;continue}}return t}function je(s,e,t){let n=s.length,i=t,r=0;for(;r<n;){let o=s.charCodeAt(r++);if(o&4294967168)if(!(o&4294965248))e[i++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&r<n){let a=s.charCodeAt(r);(a&64512)===56320&&(++r,o=((o&1023)<<10)+(a&1023)+65536)}o&4294901760?(e[i++]=o>>18&7|240,e[i++]=o>>12&63|128,e[i++]=o>>6&63|128):(e[i++]=o>>12&15|224,e[i++]=o>>6&63|128)}else{e[i++]=o;continue}e[i++]=o&63|128}}var et=new TextEncoder,tt=50;function nt(s,e,t){et.encodeInto(s,e.subarray(t))}function Ie(s,e,t){s.length>tt?nt(s,e,t):je(s,e,t)}var it=4096;function xe(s,e,t){let n=e,i=n+t,r=[],o="";for(;n<i;){let a=s[n++];if(!(a&128))r.push(a);else if((a&224)===192){let d=s[n++]&63;r.push((a&31)<<6|d)}else if((a&240)===224){let d=s[n++]&63,y=s[n++]&63;r.push((a&31)<<12|d<<6|y)}else if((a&248)===240){let d=s[n++]&63,y=s[n++]&63,g=s[n++]&63,m=(a&7)<<18|d<<12|y<<6|g;m>65535&&(m-=65536,r.push(m>>>10&1023|55296),m=56320|m&1023),r.push(m)}else r.push(a);r.length>=it&&(o+=String.fromCharCode(...r),r.length=0)}return r.length>0&&(o+=String.fromCharCode(...r)),o}var st=new TextDecoder,rt=200;function ot(s,e,t){let n=s.subarray(e,e+t);return st.decode(n)}function Be(s,e,t){return t>rt?ot(s,e,t):xe(s,e,t)}var C=class{constructor(e,t){c(this,"type");c(this,"data");this.type=e,this.data=t}};var x=class s extends Error{constructor(e){super(e);let t=Object.create(s.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:s.name})}};function We(s,e,t){let n=t/4294967296,i=t;s.setUint32(e,n),s.setUint32(e+4,i)}function se(s,e,t){let n=Math.floor(t/4294967296),i=t;s.setUint32(e,n),s.setUint32(e+4,i)}function re(s,e){let t=s.getInt32(e),n=s.getUint32(e+4);return t*4294967296+n}function Ce(s,e){let t=s.getUint32(e),n=s.getUint32(e+4);return t*4294967296+n}var at=-1,ct=4294967296-1,dt=17179869184-1;function lt({sec:s,nsec:e}){if(s>=0&&e>=0&&s<=dt)if(e===0&&s<=ct){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,s),t}else{let t=s/4294967296,n=s&4294967295,i=new Uint8Array(8),r=new DataView(i.buffer);return r.setUint32(0,e<<2|t&3),r.setUint32(4,n),i}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),se(n,4,s),t}}function ht(s){let e=s.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,i=Math.floor(n/1e9);return{sec:t+i,nsec:n-i*1e9}}function ft(s){if(s instanceof Date){let e=ht(s);return lt(e)}else return null}function ut(s){let e=new DataView(s.buffer,s.byteOffset,s.byteLength);switch(s.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),n=e.getUint32(4),i=(t&3)*4294967296+n,r=t>>>2;return{sec:i,nsec:r}}case 12:{let t=re(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new x(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${s.length}`)}}function pt(s){let e=ut(s);return new Date(e.sec*1e3+e.nsec/1e6)}var Le={type:at,encode:ft,decode:pt};var oe=class oe{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register(Le)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let i=-1-e;this.builtInEncoders[i]=t,this.builtInDecoders[i]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let i=this.builtInEncoders[n];if(i!=null){let r=i(e,t);if(r!=null){let o=-1-n;return new C(o,r)}}}for(let n=0;n<this.encoders.length;n++){let i=this.encoders[n];if(i!=null){let r=i(e,t);if(r!=null){let o=n;return new C(o,r)}}}return e instanceof C?e:null}decode(e,t,n){let i=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return i?i(e,t,n):new C(t,e)}};c(oe,"defaultCodec",new oe);var $=oe;function gt(s){return s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer}function G(s){return s instanceof Uint8Array?s:ArrayBuffer.isView(s)?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):gt(s)?new Uint8Array(s):Uint8Array.from(s)}var mt=100,yt=2048,ae=class s{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"maxDepth");c(this,"initialBufferSize");c(this,"sortKeys");c(this,"forceFloat32");c(this,"ignoreUndefined");c(this,"forceIntegerToFloat");c(this,"pos");c(this,"view");c(this,"bytes");c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??mt,this.initialBufferSize=e?.initialBufferSize??yt,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new s({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),i=new DataView(t);n.set(this.bytes),this.view=i,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Pe(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),Ie(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=G(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let i of e)this.doEncode(i,t+1)}countWithoutUndefined(e,t){let n=0;for(let i of t)e[i]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let i=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(i<16)this.writeU8(128+i);else if(i<65536)this.writeU8(222),this.writeU16(i);else if(i<4294967296)this.writeU8(223),this.writeU32(i);else throw new Error(`Too large map object: ${i}`);for(let r of n){let o=e[r];this.ignoreUndefined&&o===void 0||(this.encodeString(r),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),i=n.length;if(i>=4294967296)throw new Error(`Too large extension object: ${i}`);this.writeU8(201),this.writeU32(i),this.writeI8(e.type),this.writeU8a(n);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),We(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),se(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function N(s,e){return new ae(e).encodeSharedRef(s)}function ce(s){return`${s<0?"-":""}0x${Math.abs(s).toString(16).padStart(2,"0")}`}var wt=16,xt=16,de=class{constructor(e=wt,t=xt){c(this,"hit",0);c(this,"miss",0);c(this,"caches");c(this,"maxKeyLength");c(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let i=this.caches[n-1];e:for(let r of i){let o=r.bytes;for(let a=0;a<n;a++)if(o[a]!==e[t+a])continue e;return r.str}return null}store(e,t){let n=this.caches[e.length-1],i={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=i:n.push(i)}decode(e,t,n){let i=this.find(e,t,n);if(i!=null)return this.hit++,i;this.miss++;let r=xe(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,r),r}};var ve="array",q="map_key",He="map_value",vt=s=>{if(typeof s=="string"||typeof s=="number")return s;throw new x("The type of key must be string or number but "+typeof s)},Se=class{constructor(){c(this,"stack",[]);c(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=ve,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=q,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===ve){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===q||e.type===He){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},J=-1,be=new DataView(new ArrayBuffer(0)),St=new Uint8Array(be.buffer);try{be.getInt8(0)}catch(s){if(!(s instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var De=new RangeError("Insufficient data"),bt=new de,le=class s{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"rawStrings");c(this,"maxStrLength");c(this,"maxBinLength");c(this,"maxArrayLength");c(this,"maxMapLength");c(this,"maxExtLength");c(this,"keyDecoder");c(this,"mapKeyConverter");c(this,"totalPos",0);c(this,"pos",0);c(this,"view",be);c(this,"bytes",St);c(this,"headByte",J);c(this,"stack",new Se);c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:bt,this.mapKeyConverter=e?.mapKeyConverter??vt}clone(){return new s({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=J,this.stack.reset()}setBuffer(e){let t=G(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===J&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=G(e),i=new Uint8Array(t.length+n.length);i.set(t),i.set(n,t.length),this.setBuffer(i)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),t=!0}catch(d){if(!(d instanceof RangeError))throw d}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:i,pos:r,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${ce(i)} at ${o} (${r} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,i=-1;for await(let r of e){if(t&&i===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(r),n&&(i=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--i!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let i=e-128;if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e<160){let i=e-144;if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else{let i=e-160;t=this.decodeString(i,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let i=this.lookU8();t=this.decodeString(i,1)}else if(e===218){let i=this.lookU16();t=this.decodeString(i,2)}else if(e===219){let i=this.lookU32();t=this.decodeString(i,4)}else if(e===220){let i=this.readU16();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===221){let i=this.readU32();if(i!==0){this.pushArrayState(i),this.complete();continue e}else t=[]}else if(e===222){let i=this.readU16();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===223){let i=this.readU32();if(i!==0){this.pushMapState(i),this.complete();continue e}else t={}}else if(e===196){let i=this.lookU8();t=this.decodeBinary(i,1)}else if(e===197){let i=this.lookU16();t=this.decodeBinary(i,2)}else if(e===198){let i=this.lookU32();t=this.decodeBinary(i,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let i=this.lookU8();t=this.decodeExtension(i,1)}else if(e===200){let i=this.lookU16();t=this.decodeExtension(i,2)}else if(e===201){let i=this.lookU32();t=this.decodeExtension(i,4)}else throw new x(`Unrecognized type byte: ${ce(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let i=n.top();if(i.type===ve)if(i.array[i.position]=t,i.position++,i.position===i.size)t=i.array,n.release(i);else continue e;else if(i.type===q){if(t==="__proto__")throw new x("The key __proto__ is not allowed");i.key=this.mapKeyConverter(t),i.type=He;continue e}else if(i.map[i.key]=t,i.readCount++,i.readCount===i.size)t=i.map,n.release(i);else{i.key=null,i.type=q;continue e}}return t}}readHeadByte(){return this.headByte===J&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=J}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new x(`Unrecognized array type byte: ${ce(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new x(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new x(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new x(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw De;let n=this.pos+t,i;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?i=this.keyDecoder.decode(this.bytes,n,e):i=Be(this.bytes,n,e),this.pos+=t+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===q:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new x(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw De;let n=this.pos+t,i=this.bytes.subarray(n,n+e);return this.pos+=t+e,i}decodeExtension(e,t){if(e>this.maxExtLength)throw new x(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),i=this.decodeBinary(e,t+1);return this.extensionCodec.decode(i,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=Ce(this.view,this.pos);return this.pos+=8,e}readI64(){let e=re(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function L(s,e){return new le(e).decode(s)}var z=class extends I{constructor(t){super();this.name="WebSocket";this.socket=null;this.reconnectAttempts=0;this.maxReconnectDelay=5e3;this.shouldReconnect=!0;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_pywire/ws`}connect(){return new Promise((t,n)=>{try{this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("PyWire: WebSocket connected"),this.notifyStatus(!0),this.reconnectAttempts=0,t()},this.socket.onmessage=i=>{try{let r=L(i.data);this.notifyHandlers(r)}catch(r){console.error("PyWire: Error parsing WebSocket message",r)}},this.socket.onclose=()=>{console.log("PyWire: WebSocket disconnected"),this.notifyStatus(!1),this.shouldReconnect&&this.scheduleReconnect()},this.socket.onerror=i=>{console.error("PyWire: WebSocket error",i),this.connected||n(new Error("WebSocket connection failed"))}}catch(i){n(i)}})}send(t){this.socket&&this.socket.readyState===WebSocket.OPEN?this.socket.send(N(t)):console.warn("PyWire: Cannot send message, WebSocket not open")}disconnect(){this.shouldReconnect=!1,this.socket&&(this.socket.close(),this.socket=null),this.notifyStatus(!1)}scheduleReconnect(){let t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.maxReconnectDelay);console.log(`PyWire: Reconnecting in ${t}ms...`),setTimeout(()=>{this.reconnectAttempts++,this.connect().catch(()=>{})},t)}};var F=class extends I{constructor(t){super();this.name="HTTP";this.polling=!1;this.pollAbortController=null;this.sessionId=null;this.baseUrl=t||`${window.location.origin}/_pywire`}async connect(){try{let t=await fetch(`${this.baseUrl}/session`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack"},body:N({path:window.location.pathname+window.location.search})});if(!t.ok)throw new Error(`HTTP session init failed: ${t.status}`);let n=await t.arrayBuffer(),i=L(n);this.sessionId=i.sessionId,i.version&&this.notifyHandlers({type:"init",version:i.version}),console.log("PyWire: HTTP transport connected"),this.notifyStatus(!0),this.startPolling()}catch(t){throw console.error("PyWire: HTTP transport connection failed",t),t}}async startPolling(){if(!this.polling)for(this.polling=!0;this.polling&&this.connected;)try{this.pollAbortController=new AbortController;let t=await fetch(`${this.baseUrl}/poll?session=${this.sessionId}`,{method:"GET",signal:this.pollAbortController.signal,headers:{Accept:"application/x-msgpack"}});if(!t.ok){if(t.status===404){console.warn("PyWire: HTTP session expired, reconnecting..."),this.notifyStatus(!1),await this.connect();return}throw new Error(`Poll failed: ${t.status}`)}let n=await t.arrayBuffer(),i=L(n);for(let r of i)this.notifyHandlers(r)}catch(t){if(t instanceof Error&&t.name==="AbortError")break;console.error("PyWire: HTTP poll error",t),await this.sleep(1e3)}}async send(t){if(!this.connected||!this.sessionId){console.warn("PyWire: Cannot send message, HTTP transport not connected");return}try{let n=await fetch(`${this.baseUrl}/event`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack","X-PyWire-Session":this.sessionId},body:N(t)});if(!n.ok)throw new Error(`Event send failed: ${n.status}`);let i=await n.arrayBuffer(),r=L(i);this.notifyHandlers(r)}catch(n){console.error("PyWire: HTTP send error",n)}}disconnect(){this.polling=!1,this.notifyStatus(!1),this.pollAbortController&&(this.pollAbortController.abort(),this.pollAbortController=null),this.sessionId=null}sleep(t){return new Promise(n=>setTimeout(n,t))}};var Tt={enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0},_=class{constructor(e={}){this.transport=null;this.messageHandlers=[];this.statusHandlers=[];this.config={...Tt,...e}}async connect(){let e=this.getTransportPriority();for(let t of e)try{console.log(`PyWire: Trying ${t.name}...`),this.transport=new t;for(let n of this.messageHandlers)this.transport.onMessage(n);this.transport.onStatusChange(n=>{this.notifyStatusHandlers(n)}),await this.transport.connect(),console.log(`PyWire: Connected via ${this.transport.name}`);return}catch(n){console.warn(`PyWire: ${t.name} failed, trying next...`,n),this.transport=null}throw new Error("PyWire: All transports failed")}getTransportPriority(){let e=[];return this.config.enableWebTransport&&W.isSupported()&&window.location.protocol==="https:"&&e.push(W),this.config.enableWebSocket&&typeof WebSocket<"u"&&e.push(z),this.config.enableHTTP&&e.push(F),e}send(e){this.transport?this.transport.send(e):console.warn("PyWire: No active transport")}onMessage(e){this.messageHandlers.push(e),this.transport&&this.transport.onMessage(e)}onStatusChange(e){this.statusHandlers.push(e)}notifyStatusHandlers(e){for(let t of this.statusHandlers)t(e)}disconnect(){this.transport&&(this.transport.disconnect(),this.transport=null,this.notifyStatusHandlers(!1))}getActiveTransport(){return this.transport?.name||null}isConnected(){return this.transport?.isConnected()||!1}};var Re="0.1.5";var $e=11;function Et(s,e){var t=e.attributes,n,i,r,o,a;if(!(e.nodeType===$e||s.nodeType===$e)){for(var d=t.length-1;d>=0;d--)n=t[d],i=n.name,r=n.namespaceURI,o=n.value,r?(i=n.localName||i,a=s.getAttributeNS(r,i),a!==o&&(n.prefix==="xmlns"&&(i=n.name),s.setAttributeNS(r,i,o))):(a=s.getAttribute(i),a!==o&&s.setAttribute(i,o));for(var y=s.attributes,g=y.length-1;g>=0;g--)n=y[g],i=n.name,r=n.namespaceURI,r?(i=n.localName||i,e.hasAttributeNS(r,i)||s.removeAttributeNS(r,i)):e.hasAttribute(i)||s.removeAttribute(i)}}var he,At="http://www.w3.org/1999/xhtml",v=typeof document>"u"?void 0:document,kt=!!v&&"content"in v.createElement("template"),Mt=!!v&&v.createRange&&"createContextualFragment"in v.createRange();function Pt(s){var e=v.createElement("template");return e.innerHTML=s,e.content.childNodes[0]}function It(s){he||(he=v.createRange(),he.selectNode(v.body));var e=he.createContextualFragment(s);return e.childNodes[0]}function Bt(s){var e=v.createElement("body");return e.innerHTML=s,e.childNodes[0]}function Wt(s){return s=s.trim(),kt?Pt(s):Mt?It(s):Bt(s)}function fe(s,e){var t=s.nodeName,n=e.nodeName,i,r;return t===n?!0:(i=t.charCodeAt(0),r=n.charCodeAt(0),i<=90&&r>=97?t===n.toUpperCase():r<=90&&i>=97?n===t.toUpperCase():!1)}function Ct(s,e){return!e||e===At?v.createElement(s):v.createElementNS(e,s)}function Lt(s,e){for(var t=s.firstChild;t;){var n=t.nextSibling;e.appendChild(t),t=n}return e}function Te(s,e,t){s[t]!==e[t]&&(s[t]=e[t],s[t]?s.setAttribute(t,""):s.removeAttribute(t))}var Ne={OPTION:function(s,e){var t=s.parentNode;if(t){var n=t.nodeName.toUpperCase();n==="OPTGROUP"&&(t=t.parentNode,n=t&&t.nodeName.toUpperCase()),n==="SELECT"&&!t.hasAttribute("multiple")&&(s.hasAttribute("selected")&&!e.selected&&(s.setAttribute("selected","selected"),s.removeAttribute("selected")),t.selectedIndex=-1)}Te(s,e,"selected")},INPUT:function(s,e){Te(s,e,"checked"),Te(s,e,"disabled"),s.value!==e.value&&(s.value=e.value),e.hasAttribute("value")||s.removeAttribute("value")},TEXTAREA:function(s,e){var t=e.value;s.value!==t&&(s.value=t);var n=s.firstChild;if(n){var i=n.nodeValue;if(i==t||!t&&i==s.placeholder)return;n.nodeValue=t}},SELECT:function(s,e){if(!e.hasAttribute("multiple")){for(var t=-1,n=0,i=s.firstChild,r,o;i;)if(o=i.nodeName&&i.nodeName.toUpperCase(),o==="OPTGROUP")r=i,i=r.firstChild,i||(i=r.nextSibling,r=null);else{if(o==="OPTION"){if(i.hasAttribute("selected")){t=n;break}n++}i=i.nextSibling,!i&&r&&(i=r.nextSibling,r=null)}s.selectedIndex=t}}},Z=1,ze=11,Fe=3,_e=8;function B(){}function Dt(s){if(s)return s.getAttribute&&s.getAttribute("id")||s.id}function Ht(s){return function(t,n,i){if(i||(i={}),typeof n=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var r=n;n=v.createElement("html"),n.innerHTML=r}else n=Wt(n);else n.nodeType===ze&&(n=n.firstElementChild);var o=i.getNodeKey||Dt,a=i.onBeforeNodeAdded||B,d=i.onNodeAdded||B,y=i.onBeforeElUpdated||B,g=i.onElUpdated||B,m=i.onBeforeNodeDiscarded||B,E=i.onNodeDiscarded||B,V=i.onBeforeElChildrenUpdated||B,S=i.skipFromChildren||B,X=i.addChild||function(l,h){return l.appendChild(h)},D=i.childrenOnly===!0,b=Object.create(null),A=[];function k(l){A.push(l)}function Ae(l,h){if(l.nodeType===Z)for(var p=l.firstChild;p;){var f=void 0;h&&(f=o(p))?k(f):(E(p),p.firstChild&&Ae(p,h)),p=p.nextSibling}}function Q(l,h,p){m(l)!==!1&&(h&&h.removeChild(l),E(l),Ae(l,p))}function pe(l){if(l.nodeType===Z||l.nodeType===ze)for(var h=l.firstChild;h;){var p=o(h);p&&(b[p]=h),pe(h),h=h.nextSibling}}pe(t);function ge(l){d(l);for(var h=l.firstChild;h;){var p=h.nextSibling,f=o(h);if(f){var u=b[f];u&&fe(h,u)?(h.parentNode.replaceChild(u,h),j(u,h)):ge(h)}else ge(h);h=p}}function Ke(l,h,p){for(;h;){var f=h.nextSibling;(p=o(h))?k(p):Q(h,l,!0),h=f}}function j(l,h,p){var f=o(h);if(f&&delete b[f],!p){var u=y(l,h);if(u===!1||(u instanceof HTMLElement&&(l=u,pe(l)),s(l,h),g(l),V(l,h)===!1))return}l.nodeName!=="TEXTAREA"?Oe(l,h):Ne.TEXTAREA(l,h)}function Oe(l,h){var p=S(l,h),f=h.firstChild,u=l.firstChild,H,U,R,te,M;e:for(;f;){for(te=f.nextSibling,H=o(f);!p&&u;){if(R=u.nextSibling,f.isSameNode&&f.isSameNode(u)){f=te,u=R;continue e}U=o(u);var ne=u.nodeType,P=void 0;if(ne===f.nodeType&&(ne===Z?(H?H!==U&&((M=b[H])?R===M?P=!1:(l.insertBefore(M,u),U?k(U):Q(u,l,!0),u=M,U=o(u)):P=!1):U&&(P=!1),P=P!==!1&&fe(u,f),P&&j(u,f)):(ne===Fe||ne==_e)&&(P=!0,u.nodeValue!==f.nodeValue&&(u.nodeValue=f.nodeValue))),P){f=te,u=R;continue e}U?k(U):Q(u,l,!0),u=R}if(H&&(M=b[H])&&fe(M,f))p||X(l,M),j(M,f);else{var we=a(f);we!==!1&&(we&&(f=we),f.actualize&&(f=f.actualize(l.ownerDocument||v)),X(l,f),ge(f))}f=te,u=R}Ke(l,u,U);var Me=Ne[l.nodeName];Me&&Me(l,h)}var w=t,ee=w.nodeType,ke=n.nodeType;if(!D){if(ee===Z)ke===Z?fe(t,n)||(E(t),w=Lt(t,Ct(n.nodeName,n.namespaceURI))):w=n;else if(ee===Fe||ee===_e){if(ke===ee)return w.nodeValue!==n.nodeValue&&(w.nodeValue=n.nodeValue),w;w=n}}if(w===n)E(t);else{if(n.isSameNode&&n.isSameNode(w))return;if(j(w,n,D),A)for(var me=0,Ve=A.length;me<Ve;me++){var ye=b[A[me]];ye&&Q(ye,ye.parentNode,!1)}}return!D&&w!==t&&t.parentNode&&(w.actualize&&(w=w.actualize(t.ownerDocument||v)),t.parentNode.replaceChild(w,t)),w}}var Rt=Ht(Et),Ue=Rt;var K=class K{constructor(e=!1){this.debug=e}getNodeKey(e){if(e instanceof HTMLElement){for(let t of e.attributes)if(t.name.startsWith("data-on-"))return`${e.tagName}-${t.name}-${t.value}`;if(e.id&&!e.id.startsWith("pywire-uid-"))return e.id;if((e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&e.name)return`${e.tagName}-name-${e.name}`}}getElementSelector(e){if(e.id)return`#${e.id}`;let t=[],n=e;for(;n&&n!==document.body&&t.length<5;){let i=n.tagName.toLowerCase();if(n.id){i=`#${n.id}`,t.unshift(i);break}(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)&&n.name&&(i+=`[name="${n.name}"]`);for(let r of n.attributes)if(r.name.startsWith("data-on-")){i+=`[${r.name}="${r.value}"]`;break}if(n.parentElement){let o=Array.from(n.parentElement.children).filter(a=>a.tagName===n.tagName);if(o.length>1){let a=o.indexOf(n)+1;i+=`:nth-of-type(${a})`}}t.unshift(i),n=n.parentElement}return t.join(" > ")}captureFocusState(){let e=document.activeElement;if(!e||e===document.body||e===document.documentElement)return null;let t={selector:this.getElementSelector(e),id:e.id||null,tagName:e.tagName,selectionStart:null,selectionEnd:null,scrollTop:0,scrollLeft:0,value:""};return(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd,t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft,t.value=e.value),t}restoreFocusState(e){if(!e)return;let t=null;if(e.id&&(t=document.getElementById(e.id)),!t&&e.selector)try{t=document.querySelector(e.selector)}catch{}if(t&&(t.focus(),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){if(e.value&&t.value!==e.value&&(t.value=e.value),e.selectionStart!==null&&e.selectionEnd!==null)try{t.setSelectionRange(e.selectionStart,e.selectionEnd)}catch{}t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft}}applyUpdate(e,t){K.isUpdating=!0,this.debug&&console.log("[DOMUpdater] Starting update, isUpdating =",K.isUpdating);try{let n=this.captureFocusState();if(Ue){try{Ue(e,t,{getNodeKey:i=>this.getNodeKey(i),onBeforeElUpdated:(i,r)=>{if(i instanceof HTMLInputElement&&r instanceof HTMLInputElement)if(i.type==="checkbox"||i.type==="radio")r.checked=i.checked;else{let o=r.value||"",a=i.value||"";(a.startsWith(o)||o.startsWith(a))&&(r.value=a)}if(i instanceof HTMLTextAreaElement&&r instanceof HTMLTextAreaElement){let o=r.value||"",a=i.value||"";(a.startsWith(o)||o.startsWith(a))&&(r.value=a)}return i instanceof HTMLSelectElement&&r instanceof HTMLSelectElement&&(i.value&&Array.from(r.options).some(o=>o.value===i.value)?r.value=i.value:i.selectedIndex>=0&&i.selectedIndex<r.options.length&&(r.selectedIndex=i.selectedIndex)),i.id&&i.id.startsWith("pywire-uid-")&&!r.id&&(r.id=i.id),!0},onBeforeNodeDiscarded:()=>!0})}catch(i){console.error("Morphdom failed:",i),e===document.documentElement&&(document.open(),document.write(t),document.close())}this.restoreFocusState(n)}else e===document.documentElement&&(document.open(),document.write(t),document.close())}finally{setTimeout(()=>{K.isUpdating=!1},0)}}update(e){let t=/<html[\s>]/i.test(e),n=/<body[\s>]/i.test(e);if(!t&&document.body){if(n){this.applyUpdate(document.body,e);return}let i=`<body>${e}</body>`;this.applyUpdate(document.body,i);return}this.applyUpdate(document.documentElement,e)}updateRegion(e,t){let n=document.querySelector(`[data-pw-region="${e}"]`);if(!n){this.debug&&console.warn("[DOMUpdater] Region not found:",e);return}this.applyUpdate(n,t),n.getAttribute("data-pw-region")||n.setAttribute("data-pw-region",e)}};K.isUpdating=!1;var T=K;var ue=class{constructor(e){this.debouncers=new Map;this.throttlers=new Map;this.supportedEvents=["click","submit","input","change","keydown","keyup","focus","blur","mouseenter","mouseleave","scroll","contextmenu"];this.suppressDuringUpdate=["focus","blur","mouseenter","mouseleave"];this.app=e}debugLog(...e){this.app.getConfig().debug&&console.log(...e)}init(){this.supportedEvents.forEach(e=>{let t=e==="mouseenter"||e==="mouseleave"||e==="focus"||e==="blur"||e==="scroll"?{capture:!0}:void 0;document.addEventListener(e,n=>this.handleEvent(n),t)})}getHandlers(e,t){let n=`data-on-${t}`,i=e.getAttribute(n);if(!i)return[];if(i.trim().startsWith("["))try{let r=JSON.parse(i);if(Array.isArray(r))return r.flatMap(o=>{if(!o||typeof o!="object")return[];let a="handler"in o&&typeof o.handler=="string"?o.handler:null;if(!a)return[];let d="modifiers"in o&&Array.isArray(o.modifiers)?o.modifiers.filter(g=>typeof g=="string"):[],y="args"in o&&Array.isArray(o.args)?o.args:void 0;return[{name:a,modifiers:d,args:y}]})}catch(r){console.error("Error parsing event handlers:",r)}else{let r=e.getAttribute(`data-modifiers-${t}`),o=r?r.split(" ").filter(a=>a):[];return[{name:i,modifiers:o,args:void 0}]}return[]}async handleEvent(e){let t=e.type;if(T.isUpdating&&this.suppressDuringUpdate.includes(t)){this.debugLog("[Handler] SUPPRESSING event during update:",t,"isUpdating=",T.isUpdating);return}this.debugLog("[Handler] Processing event:",t,"isUpdating=",T.isUpdating);let n=e.composedPath?e.composedPath():[],i=!1;for(let r of n){if(i)break;if(r instanceof HTMLElement){let o=r,a=this.getHandlers(o,t);if(a.length>0){this.debugLog("[handleEvent] Found handlers on",o.tagName,a);for(let d of a)!d.modifiers.includes("window")&&!d.modifiers.includes("outside")&&(this.processEvent(o,t,d.name,d.modifiers,e,d.args),e.cancelBubble&&(i=!0))}}}this.handleGlobalEvent(e)}handleGlobalEvent(e){let t=e.type,n=`[data-modifiers-${t}*="window"]`,i=`[data-modifiers-${t}*="outside"]`;document.querySelectorAll(`${n}, ${i}`).forEach(o=>{if(!(o instanceof HTMLElement))return;let a=this.getHandlers(o,t);for(let d of a)if(d.modifiers.includes("window")&&this.processEvent(o,t,d.name,d.modifiers,e,d.args),d.modifiers.includes("outside")){let y=e.target;y&&!o.contains(y)&&this.processEvent(o,t,d.name,d.modifiers,e,d.args)}})}processEvent(e,t,n,i,r,o){if(this.debugLog("[processEvent]",t,"handler:",n,"modifiers:",i),(i.includes("prevent")||t==="submit")&&(this.debugLog("[processEvent] Calling preventDefault"),r.preventDefault()),i.includes("stop")&&r.stopPropagation(),i.includes("self")&&r.target!==e||i.includes("shift")&&(!("shiftKey"in r)||!r.shiftKey)||i.includes("ctrl")&&(!("ctrlKey"in r)||!r.ctrlKey)||i.includes("alt")&&(!("altKey"in r)||!r.altKey)||i.includes("meta")&&(!("metaKey"in r)||!r.metaKey)||i.includes("cmd")&&(!("metaKey"in r)||!r.metaKey))return;if(r instanceof KeyboardEvent){let m=["enter","escape","space","tab","up","down","left","right"],E=["shift","ctrl","alt","meta","cmd","window","outside","prevent","stop","self","debounce","throttle"],V=i.filter(S=>E.includes(S)||S.startsWith("debounce")||S.startsWith("throttle")||S.endsWith("ms")?!1:m.includes(S)||S.length===1);if(V.length>0){let S=r.key.toLowerCase();this.debugLog("[processEvent] Key check. Pressed:",S,"Modifiers:",V);let X={escape:"escape",esc:"escape",enter:"enter",space:" ",spacebar:" "," ":" ",tab:"tab",up:"arrowup",arrowup:"arrowup",down:"arrowdown",arrowdown:"arrowdown",left:"arrowleft",arrowleft:"arrowleft",right:"arrowright",arrowright:"arrowright"},D=X[S]||S,b=!1;for(let A of V){let k=X[A]||A;if(this.debugLog("[processEvent] Comparing constraint:",A,"->",k,"vs",D,"code:",r.code),k===D){b=!0;break}if(r.code&&r.code.toLowerCase()===`key${k}`){b=!0;break}}if(!b){this.debugLog("[processEvent] No key match found.");return}}}let a=i.find(m=>m.startsWith("debounce")),d=i.find(m=>m.startsWith("throttle")),g=`${e.id||this.getUniqueId(e)}-${t}-${n}`;if(a){let m=this.parseDuration(i,250);this.debouncers.has(g)&&window.clearTimeout(this.debouncers.get(g));let E=window.setTimeout(()=>{this.debouncers.delete(g),this.dispatchEvent(e,t,n,r,o)},m);this.debouncers.set(g,E);return}if(d){let m=this.parseDuration(i,250);if(this.throttlers.has(g))return;this.throttlers.set(g,Date.now()),this.dispatchEvent(e,t,n,r,o),window.setTimeout(()=>{this.throttlers.delete(g)},m);return}this.dispatchEvent(e,t,n,r,o)}dispatchEvent(e,t,n,i,r){let o={};r&&r.length>0?r.forEach((d,y)=>{o[`arg${y}`]=d}):o=this.getArgs(e);let a={type:t,id:e.id,args:o};if(e instanceof HTMLInputElement?(a.value=e.value,(e.type==="checkbox"||e.type==="radio")&&(a.checked=e.checked)):(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(a.value=e.value),i instanceof KeyboardEvent&&(a.key=i.key,a.keyCode=i.keyCode),t==="submit"&&e instanceof HTMLFormElement){let d=new FormData(e),y={};d.forEach((g,m)=>{g instanceof File||(y[m]=g.toString())}),a.formData=y}this.app.sendEvent(n,a)}parseDuration(e,t){let n=e.findIndex(a=>a.startsWith("debounce")),i=e.findIndex(a=>a.startsWith("throttle")),r=n!==-1?n:i;if(r!==-1&&e[r+1]){let a=e[r+1];if(a.endsWith("ms")){let d=parseInt(a);if(!isNaN(d))return d}}let o=e[r];if(o&&o.includes("-")){let a=o.split("-"),d=parseInt(a[1]);if(!isNaN(d))return d}return t}getUniqueId(e){return e.id||(e.id="pywire-uid-"+Math.random().toString(36).substr(2,9)),e.id}getArgs(e){let t={};if(e instanceof HTMLElement){for(let n in e.dataset)if(n.startsWith("arg"))try{t[n]=JSON.parse(e.dataset[n]||"null")}catch{t[n]=e.dataset[n]}}return t}};var $t={autoInit:!0,enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0,debug:!1},O=class{constructor(e={}){this.initialized=!1;this.siblingPaths=[];this.pathRegexes=[];this.pjaxEnabled=!1;this.isConnected=!1;this.config={...$t,...e},this.transport=new _(this.config),this.updater=new T(this.config.debug),this.eventHandler=new ue(this)}getConfig(){return this.config}async init(){if(!this.initialized){this.initialized=!0,this.transport.onMessage(e=>this.handleMessage(e)),this.transport.onStatusChange(e=>this.handleStatusChange(e));try{await this.transport.connect()}catch(e){console.error("PyWire: Failed to connect:",e)}this.loadSPAMetadata(),this.setupSPANavigation(),this.eventHandler.init(),console.log(`PyWire: Initialized (transport: ${this.transport.getActiveTransport()}, spa_paths: ${this.siblingPaths.length}, pjax: ${this.pjaxEnabled})`)}}handleStatusChange(e){this.isConnected=e}loadSPAMetadata(){let e=document.getElementById("_pywire_spa_meta");if(e)try{let t=JSON.parse(e.textContent||"{}");this.siblingPaths=t.sibling_paths||[],this.pjaxEnabled=!!t.enable_pjax,t.debug!==void 0&&(this.config.debug=!!t.debug),this.pathRegexes=this.siblingPaths.map(n=>this.patternToRegex(n))}catch(t){console.warn("PyWire: Failed to parse SPA metadata",t)}}patternToRegex(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return t=t.replace(/:(\\w+)(:\\w+)?/g,"([^/]+)"),t=t.replace(/\\{(\\w+)(:\\w+)?\\}/g,"([^/]+)"),new RegExp(`^${t}$`)}isSiblingPath(e){return this.pathRegexes.some(t=>t.test(e))}setupSPANavigation(){window.addEventListener("popstate",()=>{this.sendRelocate(window.location.pathname+window.location.search)}),!(this.siblingPaths.length===0&&!this.pjaxEnabled)&&document.addEventListener("click",e=>{let t=e.target.closest("a[href]");if(!t||t.origin!==window.location.origin||t.hasAttribute("download")||t.target==="_blank")return;let n=!1;(this.pjaxEnabled||this.isSiblingPath(t.pathname))&&(n=!0),n&&(e.preventDefault(),this.navigateTo(t.pathname+t.search))})}navigateTo(e){if(!this.isConnected){console.warn("PyWire: Navigation blocked - Offline");return}history.pushState({},"",e),this.sendRelocate(e)}sendRelocate(e){let t={type:"relocate",path:e};this.transport.send(t)}sendEvent(e,t){let n={type:"event",handler:e,path:window.location.pathname+window.location.search,data:t};this.transport.send(n)}async handleMessage(e){switch(e.type){case"update":e.regions&&e.regions.length>0?e.regions.forEach(t=>{this.updater.updateRegion(t.region,t.html)}):e.html&&this.updater.update(e.html);break;case"reload":console.log("PyWire: Reloading..."),window.location.reload();break;case"error":console.error("PyWire: Server error:",e.error);break;case"error_trace":console.error("PyWire: Error:",e.error);break;case"console":if(e.lines&&e.lines.length>0){let t="PyWire Server:",n=e.lines.join(`
3
+ `);e.level==="error"?console.error(t,n):e.level==="warn"?console.warn(t,n):console.log(t,n)}break;case"init":console.log(`PyWire Client v${Re} \u2022 Server v${e.version}`);break;default:console.warn("PyWire: Unknown message type",e)}}getTransport(){return this.transport.getActiveTransport()}disconnect(){this.transport.disconnect()}};var Ee=new O;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Ee.init()):Ee.init();return Qe(Nt);})();
@@ -1,6 +1,6 @@
1
- /* PyWire Client dev v0.1.3 - https://github.com/pywire/pywire */
2
- "use strict";var PyWire=(()=>{var oe=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Ze=(i,e,t)=>e in i?oe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Qe=(i,e)=>{for(var t in e)oe(i,t,{get:e[t],enumerable:!0})},je=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Je(e))!qe.call(i,r)&&r!==t&&oe(i,r,{get:()=>e[r],enumerable:!(n=Ye(e,r))||n.enumerable});return i};var et=i=>je(oe({},"__esModule",{value:!0}),i);var c=(i,e,t)=>(Ze(i,typeof e!="symbol"?e+"":e,t),t);var Ft={};Qe(Ft,{DOMUpdater:()=>T,ErrorTraceHandler:()=>X,HTTPTransport:()=>z,PyWireApp:()=>O,PyWireDevApp:()=>G,StatusOverlay:()=>V,TransportManager:()=>_,WebSocketTransport:()=>F,WebTransportTransport:()=>C,app:()=>Me});var B=class{constructor(){this.messageHandlers=[];this.statusHandlers=[];this.connected=!1}onMessage(e){this.messageHandlers.push(e)}onStatusChange(e){this.statusHandlers.push(e)}isConnected(){return this.connected}notifyHandlers(e){for(let t of this.messageHandlers)try{t(e)}catch(n){console.error("PyWire: Error in message handler",n)}}notifyStatus(e){if(this.connected!==e){this.connected=e;for(let t of this.statusHandlers)try{t(e)}catch(n){console.error("PyWire: Error in status handler",n)}}}};var C=class i extends B{constructor(t){super();this.name="WebTransport";this.transport=null;this.writer=null;this.encoder=new TextEncoder;this.decoder=new TextDecoder;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`https://${window.location.host}/_pywire/webtransport`}static isSupported(){return typeof WebTransport<"u"}async connect(){if(!i.isSupported())throw new Error("WebTransport not supported in this browser");try{let t={},n=window.PYWIRE_CERT_HASH;n&&Array.isArray(n)&&(t.serverCertificateHashes=[{algorithm:"sha-256",value:new Uint8Array(n).buffer}],console.log("PyWire: Using explicit certificate hash for WebTransport")),this.transport=new WebTransport(this.url,t),await this.transport.ready,console.log("PyWire: WebTransport ready"),this.connected=!0,this.startReading()}catch(t){throw this.handleDisconnect(),t}}async startReading(){if(!this.transport)return;let t=this.transport.incomingBidirectionalStreams.getReader();try{for(;;){let{value:n,done:r}=await t.read();if(r)break;this.handleStream(n)}}catch(n){this.connected&&(console.error("PyWire: WebTransport read error",n),this.handleDisconnect())}}async handleStream(t){let n=t.readable.getReader();try{for(;;){let{value:r,done:s}=await n.read();if(s)break;if(r){let o=this.decoder.decode(r);try{let a=JSON.parse(o);this.notifyHandlers(a)}catch(a){console.error("PyWire: Error parsing WebTransport message",a)}}}}catch(r){console.error("PyWire: Stream read error",r)}}async send(t){if(!this.transport||!this.connected){console.warn("PyWire: Cannot send message, WebTransport not connected");return}try{let n=await this.transport.createBidirectionalStream(),r=n.writable.getWriter(),s=this.encoder.encode(JSON.stringify(t));await r.write(s),await r.close(),this.handleStream(n)}catch(n){console.error("PyWire: WebTransport send error",n)}}disconnect(){this.transport&&(this.transport.close(),this.transport=null),this.writer=null,this.connected=!1}handleDisconnect(){this.connected=!1,this.transport=null,this.writer=null}};function Ce(i){let e=i.length,t=0,n=0;for(;n<e;){let r=i.charCodeAt(n++);if(r&4294967168)if(!(r&4294965248))t+=2;else{if(r>=55296&&r<=56319&&n<e){let s=i.charCodeAt(n);(s&64512)===56320&&(++n,r=((r&1023)<<10)+(s&1023)+65536)}r&4294901760?t+=4:t+=3}else{t++;continue}}return t}function tt(i,e,t){let n=i.length,r=t,s=0;for(;s<n;){let o=i.charCodeAt(s++);if(o&4294967168)if(!(o&4294965248))e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&s<n){let a=i.charCodeAt(s);(a&64512)===56320&&(++s,o=((o&1023)<<10)+(a&1023)+65536)}o&4294901760?(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128):(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128)}else{e[r++]=o;continue}e[r++]=o&63|128}}var nt=new TextEncoder,rt=50;function it(i,e,t){nt.encodeInto(i,e.subarray(t))}function Le(i,e,t){i.length>rt?it(i,e,t):tt(i,e,t)}var st=4096;function be(i,e,t){let n=e,r=n+t,s=[],o="";for(;n<r;){let a=i[n++];if(!(a&128))s.push(a);else if((a&224)===192){let l=i[n++]&63;s.push((a&31)<<6|l)}else if((a&240)===224){let l=i[n++]&63,p=i[n++]&63;s.push((a&31)<<12|l<<6|p)}else if((a&248)===240){let l=i[n++]&63,p=i[n++]&63,y=i[n++]&63,g=(a&7)<<18|l<<12|p<<6|y;g>65535&&(g-=65536,s.push(g>>>10&1023|55296),g=56320|g&1023),s.push(g)}else s.push(a);s.length>=st&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}var ot=new TextDecoder,at=200;function ct(i,e,t){let n=i.subarray(e,e+t);return ot.decode(n)}function We(i,e,t){return t>at?ct(i,e,t):be(i,e,t)}var L=class{constructor(e,t){c(this,"type");c(this,"data");this.type=e,this.data=t}};var x=class i extends Error{constructor(e){super(e);let t=Object.create(i.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:i.name})}};function He(i,e,t){let n=t/4294967296,r=t;i.setUint32(e,n),i.setUint32(e+4,r)}function ae(i,e,t){let n=Math.floor(t/4294967296),r=t;i.setUint32(e,n),i.setUint32(e+4,r)}function ce(i,e){let t=i.getInt32(e),n=i.getUint32(e+4);return t*4294967296+n}function De(i,e){let t=i.getUint32(e),n=i.getUint32(e+4);return t*4294967296+n}var lt=-1,dt=4294967296-1,ht=17179869184-1;function ft({sec:i,nsec:e}){if(i>=0&&e>=0&&i<=ht)if(e===0&&i<=dt){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,i),t}else{let t=i/4294967296,n=i&4294967295,r=new Uint8Array(8),s=new DataView(r.buffer);return s.setUint32(0,e<<2|t&3),s.setUint32(4,n),r}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),ae(n,4,i),t}}function ut(i){let e=i.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,r=Math.floor(n/1e9);return{sec:t+r,nsec:n-r*1e9}}function pt(i){if(i instanceof Date){let e=ut(i);return ft(e)}else return null}function gt(i){let e=new DataView(i.buffer,i.byteOffset,i.byteLength);switch(i.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),n=e.getUint32(4),r=(t&3)*4294967296+n,s=t>>>2;return{sec:r,nsec:s}}case 12:{let t=ce(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new x(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${i.length}`)}}function mt(i){let e=gt(i);return new Date(e.sec*1e3+e.nsec/1e6)}var Re={type:lt,encode:pt,decode:mt};var le=class le{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register(Re)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let s=r(e,t);if(s!=null){let o=-1-n;return new L(o,s)}}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let s=r(e,t);if(s!=null){let o=n;return new L(o,s)}}}return e instanceof L?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new L(t,e)}};c(le,"defaultCodec",new le);var $=le;function yt(i){return i instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&i instanceof SharedArrayBuffer}function q(i){return i instanceof Uint8Array?i:ArrayBuffer.isView(i)?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):yt(i)?new Uint8Array(i):Uint8Array.from(i)}var wt=100,xt=2048,de=class i{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"maxDepth");c(this,"initialBufferSize");c(this,"sortKeys");c(this,"forceFloat32");c(this,"ignoreUndefined");c(this,"forceIntegerToFloat");c(this,"pos");c(this,"view");c(this,"bytes");c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??wt,this.initialBufferSize=e?.initialBufferSize??xt,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new i({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Ce(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),Le(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=q(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let n=0;for(let r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(let s of n){let o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),r=n.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(n);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),He(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),ae(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function N(i,e){return new de(e).encodeSharedRef(i)}function he(i){return`${i<0?"-":""}0x${Math.abs(i).toString(16).padStart(2,"0")}`}var vt=16,St=16,fe=class{constructor(e=vt,t=St){c(this,"hit",0);c(this,"miss",0);c(this,"caches");c(this,"maxKeyLength");c(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];e:for(let s of r){let o=s.bytes;for(let a=0;a<n;a++)if(o[a]!==e[t+a])continue e;return s.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){let r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;let s=be(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,s),s}};var Te="array",j="map_key",Ne="map_value",bt=i=>{if(typeof i=="string"||typeof i=="number")return i;throw new x("The type of key must be string or number but "+typeof i)},Ue=class{constructor(){c(this,"stack",[]);c(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=Te,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=j,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Te){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===j||e.type===Ne){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Q=-1,Ee=new DataView(new ArrayBuffer(0)),Tt=new Uint8Array(Ee.buffer);try{Ee.getInt8(0)}catch(i){if(!(i instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var $e=new RangeError("Insufficient data"),Ut=new fe,ue=class i{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"rawStrings");c(this,"maxStrLength");c(this,"maxBinLength");c(this,"maxArrayLength");c(this,"maxMapLength");c(this,"maxExtLength");c(this,"keyDecoder");c(this,"mapKeyConverter");c(this,"totalPos",0);c(this,"pos",0);c(this,"view",Ee);c(this,"bytes",Tt);c(this,"headByte",Q);c(this,"stack",new Ue);c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??$.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Ut,this.mapKeyConverter=e?.mapKeyConverter??bt}clone(){return new i({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Q,this.stack.reset()}setBuffer(e){let t=q(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Q&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=q(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),t=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${he(r)} at ${o} (${s} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let s of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){let r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{let r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){let r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){let r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){let r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){let r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){let r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){let r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){let r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){let r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){let r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){let r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){let r=this.lookU32();t=this.decodeExtension(r,4)}else throw new x(`Unrecognized type byte: ${he(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let r=n.top();if(r.type===Te)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,n.release(r);else continue e;else if(r.type===j){if(t==="__proto__")throw new x("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=Ne;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,n.release(r);else{r.key=null,r.type=j;continue e}}return t}}readHeadByte(){return this.headByte===Q&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Q}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new x(`Unrecognized array type byte: ${he(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new x(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new x(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new x(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw $e;let n=this.pos+t,r;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?r=this.keyDecoder.decode(this.bytes,n,e):r=We(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===j:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new x(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw $e;let n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new x(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=De(this.view,this.pos);return this.pos+=8,e}readI64(){let e=ce(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function W(i,e){return new ue(e).decode(i)}var F=class extends B{constructor(t){super();this.name="WebSocket";this.socket=null;this.reconnectAttempts=0;this.maxReconnectDelay=5e3;this.shouldReconnect=!0;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_pywire/ws`}connect(){return new Promise((t,n)=>{try{this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("PyWire: WebSocket connected"),this.notifyStatus(!0),this.reconnectAttempts=0,t()},this.socket.onmessage=r=>{try{let s=W(r.data);this.notifyHandlers(s)}catch(s){console.error("PyWire: Error parsing WebSocket message",s)}},this.socket.onclose=()=>{console.log("PyWire: WebSocket disconnected"),this.notifyStatus(!1),this.shouldReconnect&&this.scheduleReconnect()},this.socket.onerror=r=>{console.error("PyWire: WebSocket error",r),this.connected||n(new Error("WebSocket connection failed"))}}catch(r){n(r)}})}send(t){this.socket&&this.socket.readyState===WebSocket.OPEN?this.socket.send(N(t)):console.warn("PyWire: Cannot send message, WebSocket not open")}disconnect(){this.shouldReconnect=!1,this.socket&&(this.socket.close(),this.socket=null),this.notifyStatus(!1)}scheduleReconnect(){let t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.maxReconnectDelay);console.log(`PyWire: Reconnecting in ${t}ms...`),setTimeout(()=>{this.reconnectAttempts++,this.connect().catch(()=>{})},t)}};var z=class extends B{constructor(t){super();this.name="HTTP";this.polling=!1;this.pollAbortController=null;this.sessionId=null;this.baseUrl=t||`${window.location.origin}/_pywire`}async connect(){try{let t=await fetch(`${this.baseUrl}/session`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack"},body:N({path:window.location.pathname+window.location.search})});if(!t.ok)throw new Error(`HTTP session init failed: ${t.status}`);let n=await t.arrayBuffer(),r=W(n);this.sessionId=r.sessionId,console.log("PyWire: HTTP transport connected"),this.notifyStatus(!0),this.startPolling()}catch(t){throw console.error("PyWire: HTTP transport connection failed",t),t}}async startPolling(){if(!this.polling)for(this.polling=!0;this.polling&&this.connected;)try{this.pollAbortController=new AbortController;let t=await fetch(`${this.baseUrl}/poll?session=${this.sessionId}`,{method:"GET",signal:this.pollAbortController.signal,headers:{Accept:"application/x-msgpack"}});if(!t.ok){if(t.status===404){console.warn("PyWire: HTTP session expired, reconnecting..."),this.notifyStatus(!1),await this.connect();return}throw new Error(`Poll failed: ${t.status}`)}let n=await t.arrayBuffer(),r=W(n);for(let s of r)this.notifyHandlers(s)}catch(t){if(t instanceof Error&&t.name==="AbortError")break;console.error("PyWire: HTTP poll error",t),await this.sleep(1e3)}}async send(t){if(!this.connected||!this.sessionId){console.warn("PyWire: Cannot send message, HTTP transport not connected");return}try{let n=await fetch(`${this.baseUrl}/event`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack","X-PyWire-Session":this.sessionId},body:N(t)});if(!n.ok)throw new Error(`Event send failed: ${n.status}`);let r=await n.arrayBuffer(),s=W(r);this.notifyHandlers(s)}catch(n){console.error("PyWire: HTTP send error",n)}}disconnect(){this.polling=!1,this.notifyStatus(!1),this.pollAbortController&&(this.pollAbortController.abort(),this.pollAbortController=null),this.sessionId=null}sleep(t){return new Promise(n=>setTimeout(n,t))}};var Et={enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0},_=class{constructor(e={}){this.transport=null;this.messageHandlers=[];this.statusHandlers=[];this.config={...Et,...e}}async connect(){let e=this.getTransportPriority();for(let t of e)try{console.log(`PyWire: Trying ${t.name}...`),this.transport=new t;for(let n of this.messageHandlers)this.transport.onMessage(n);this.transport.onStatusChange(n=>{this.notifyStatusHandlers(n)}),await this.transport.connect(),console.log(`PyWire: Connected via ${this.transport.name}`);return}catch(n){console.warn(`PyWire: ${t.name} failed, trying next...`,n),this.transport=null}throw new Error("PyWire: All transports failed")}getTransportPriority(){let e=[];return this.config.enableWebTransport&&C.isSupported()&&window.location.protocol==="https:"&&e.push(C),this.config.enableWebSocket&&typeof WebSocket<"u"&&e.push(F),this.config.enableHTTP&&e.push(z),e}send(e){this.transport?this.transport.send(e):console.warn("PyWire: No active transport")}onMessage(e){this.messageHandlers.push(e),this.transport&&this.transport.onMessage(e)}onStatusChange(e){this.statusHandlers.push(e)}notifyStatusHandlers(e){for(let t of this.statusHandlers)t(e)}disconnect(){this.transport&&(this.transport.disconnect(),this.transport=null,this.notifyStatusHandlers(!1))}getActiveTransport(){return this.transport?.name||null}isConnected(){return this.transport?.isConnected()||!1}};var Fe=11;function At(i,e){var t=e.attributes,n,r,s,o,a;if(!(e.nodeType===Fe||i.nodeType===Fe)){for(var l=t.length-1;l>=0;l--)n=t[l],r=n.name,s=n.namespaceURI,o=n.value,s?(r=n.localName||r,a=i.getAttributeNS(s,r),a!==o&&(n.prefix==="xmlns"&&(r=n.name),i.setAttributeNS(s,r,o))):(a=i.getAttribute(r),a!==o&&i.setAttribute(r,o));for(var p=i.attributes,y=p.length-1;y>=0;y--)n=p[y],r=n.name,s=n.namespaceURI,s?(r=n.localName||r,e.hasAttributeNS(s,r)||i.removeAttributeNS(s,r)):e.hasAttribute(r)||i.removeAttribute(r)}}var pe,kt="http://www.w3.org/1999/xhtml",v=typeof document>"u"?void 0:document,Mt=!!v&&"content"in v.createElement("template"),Pt=!!v&&v.createRange&&"createContextualFragment"in v.createRange();function Bt(i){var e=v.createElement("template");return e.innerHTML=i,e.content.childNodes[0]}function It(i){pe||(pe=v.createRange(),pe.selectNode(v.body));var e=pe.createContextualFragment(i);return e.childNodes[0]}function Ct(i){var e=v.createElement("body");return e.innerHTML=i,e.childNodes[0]}function Lt(i){return i=i.trim(),Mt?Bt(i):Pt?It(i):Ct(i)}function ge(i,e){var t=i.nodeName,n=e.nodeName,r,s;return t===n?!0:(r=t.charCodeAt(0),s=n.charCodeAt(0),r<=90&&s>=97?t===n.toUpperCase():s<=90&&r>=97?n===t.toUpperCase():!1)}function Wt(i,e){return!e||e===kt?v.createElement(i):v.createElementNS(e,i)}function Ht(i,e){for(var t=i.firstChild;t;){var n=t.nextSibling;e.appendChild(t),t=n}return e}function Ae(i,e,t){i[t]!==e[t]&&(i[t]=e[t],i[t]?i.setAttribute(t,""):i.removeAttribute(t))}var ze={OPTION:function(i,e){var t=i.parentNode;if(t){var n=t.nodeName.toUpperCase();n==="OPTGROUP"&&(t=t.parentNode,n=t&&t.nodeName.toUpperCase()),n==="SELECT"&&!t.hasAttribute("multiple")&&(i.hasAttribute("selected")&&!e.selected&&(i.setAttribute("selected","selected"),i.removeAttribute("selected")),t.selectedIndex=-1)}Ae(i,e,"selected")},INPUT:function(i,e){Ae(i,e,"checked"),Ae(i,e,"disabled"),i.value!==e.value&&(i.value=e.value),e.hasAttribute("value")||i.removeAttribute("value")},TEXTAREA:function(i,e){var t=e.value;i.value!==t&&(i.value=t);var n=i.firstChild;if(n){var r=n.nodeValue;if(r==t||!t&&r==i.placeholder)return;n.nodeValue=t}},SELECT:function(i,e){if(!e.hasAttribute("multiple")){for(var t=-1,n=0,r=i.firstChild,s,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")s=r,r=s.firstChild,r||(r=s.nextSibling,s=null);else{if(o==="OPTION"){if(r.hasAttribute("selected")){t=n;break}n++}r=r.nextSibling,!r&&s&&(r=s.nextSibling,s=null)}i.selectedIndex=t}}},ee=1,_e=11,Ke=3,Oe=8;function I(){}function Dt(i){if(i)return i.getAttribute&&i.getAttribute("id")||i.id}function Rt(i){return function(t,n,r){if(r||(r={}),typeof n=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var s=n;n=v.createElement("html"),n.innerHTML=s}else n=Lt(n);else n.nodeType===_e&&(n=n.firstElementChild);var o=r.getNodeKey||Dt,a=r.onBeforeNodeAdded||I,l=r.onNodeAdded||I,p=r.onBeforeElUpdated||I,y=r.onElUpdated||I,g=r.onBeforeNodeDiscarded||I,E=r.onNodeDiscarded||I,Y=r.onBeforeElChildrenUpdated||I,S=r.skipFromChildren||I,J=r.addChild||function(d,h){return d.appendChild(h)},H=r.childrenOnly===!0,b=Object.create(null),A=[];function k(d){A.push(d)}function Pe(d,h){if(d.nodeType===ee)for(var m=d.firstChild;m;){var f=void 0;h&&(f=o(m))?k(f):(E(m),m.firstChild&&Pe(m,h)),m=m.nextSibling}}function te(d,h,m){g(d)!==!1&&(h&&h.removeChild(d),E(d),Pe(d,m))}function ye(d){if(d.nodeType===ee||d.nodeType===_e)for(var h=d.firstChild;h;){var m=o(h);m&&(b[m]=h),ye(h),h=h.nextSibling}}ye(t);function we(d){l(d);for(var h=d.firstChild;h;){var m=h.nextSibling,f=o(h);if(f){var u=b[f];u&&ge(h,u)?(h.parentNode.replaceChild(u,h),ne(u,h)):we(h)}else we(h);h=m}}function Ve(d,h,m){for(;h;){var f=h.nextSibling;(m=o(h))?k(m):te(h,d,!0),h=f}}function ne(d,h,m){var f=o(h);if(f&&delete b[f],!m){var u=p(d,h);if(u===!1||(u instanceof HTMLElement&&(d=u,ye(d)),i(d,h),y(d),Y(d,h)===!1))return}d.nodeName!=="TEXTAREA"?Xe(d,h):ze.TEXTAREA(d,h)}function Xe(d,h){var m=S(d,h),f=h.firstChild,u=d.firstChild,D,U,R,ie,M;e:for(;f;){for(ie=f.nextSibling,D=o(f);!m&&u;){if(R=u.nextSibling,f.isSameNode&&f.isSameNode(u)){f=ie,u=R;continue e}U=o(u);var se=u.nodeType,P=void 0;if(se===f.nodeType&&(se===ee?(D?D!==U&&((M=b[D])?R===M?P=!1:(d.insertBefore(M,u),U?k(U):te(u,d,!0),u=M,U=o(u)):P=!1):U&&(P=!1),P=P!==!1&&ge(u,f),P&&ne(u,f)):(se===Ke||se==Oe)&&(P=!0,u.nodeValue!==f.nodeValue&&(u.nodeValue=f.nodeValue))),P){f=ie,u=R;continue e}U?k(U):te(u,d,!0),u=R}if(D&&(M=b[D])&&ge(M,f))m||J(d,M),ne(M,f);else{var Se=a(f);Se!==!1&&(Se&&(f=Se),f.actualize&&(f=f.actualize(d.ownerDocument||v)),J(d,f),we(f))}f=ie,u=R}Ve(d,u,U);var Ie=ze[d.nodeName];Ie&&Ie(d,h)}var w=t,re=w.nodeType,Be=n.nodeType;if(!H){if(re===ee)Be===ee?ge(t,n)||(E(t),w=Ht(t,Wt(n.nodeName,n.namespaceURI))):w=n;else if(re===Ke||re===Oe){if(Be===re)return w.nodeValue!==n.nodeValue&&(w.nodeValue=n.nodeValue),w;w=n}}if(w===n)E(t);else{if(n.isSameNode&&n.isSameNode(w))return;if(ne(w,n,H),A)for(var xe=0,Ge=A.length;xe<Ge;xe++){var ve=b[A[xe]];ve&&te(ve,ve.parentNode,!1)}}return!H&&w!==t&&t.parentNode&&(w.actualize&&(w=w.actualize(t.ownerDocument||v)),t.parentNode.replaceChild(w,t)),w}}var $t=Rt(At),ke=$t;var K=class K{constructor(e=!1){this.debug=e}getNodeKey(e){if(e instanceof HTMLElement){for(let t of e.attributes)if(t.name.startsWith("data-on-"))return`${e.tagName}-${t.name}-${t.value}`;if(e.id&&!e.id.startsWith("pywire-uid-"))return e.id;if((e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&e.name)return`${e.tagName}-name-${e.name}`}}getElementSelector(e){if(e.id)return`#${e.id}`;let t=[],n=e;for(;n&&n!==document.body&&t.length<5;){let r=n.tagName.toLowerCase();if(n.id){r=`#${n.id}`,t.unshift(r);break}(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)&&n.name&&(r+=`[name="${n.name}"]`);for(let s of n.attributes)if(s.name.startsWith("data-on-")){r+=`[${s.name}="${s.value}"]`;break}if(n.parentElement){let o=Array.from(n.parentElement.children).filter(a=>a.tagName===n.tagName);if(o.length>1){let a=o.indexOf(n)+1;r+=`:nth-of-type(${a})`}}t.unshift(r),n=n.parentElement}return t.join(" > ")}captureFocusState(){let e=document.activeElement;if(!e||e===document.body||e===document.documentElement)return null;let t={selector:this.getElementSelector(e),id:e.id||null,tagName:e.tagName,selectionStart:null,selectionEnd:null,scrollTop:0,scrollLeft:0,value:""};return(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd,t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft,t.value=e.value),t}restoreFocusState(e){if(!e)return;let t=null;if(e.id&&(t=document.getElementById(e.id)),!t&&e.selector)try{t=document.querySelector(e.selector)}catch{}if(t&&(t.focus(),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){if(e.value&&t.value!==e.value&&(t.value=e.value),e.selectionStart!==null&&e.selectionEnd!==null)try{t.setSelectionRange(e.selectionStart,e.selectionEnd)}catch{}t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft}}applyUpdate(e,t){K.isUpdating=!0,this.debug&&console.log("[DOMUpdater] Starting update, isUpdating =",K.isUpdating);try{let n=this.captureFocusState();if(ke){try{ke(e,t,{getNodeKey:r=>this.getNodeKey(r),onBeforeElUpdated:(r,s)=>{if(r instanceof HTMLInputElement&&s instanceof HTMLInputElement)if(r.type==="checkbox"||r.type==="radio")s.checked=r.checked;else{let o=s.value||"",a=r.value||"";(a.startsWith(o)||o.startsWith(a))&&(s.value=a)}if(r instanceof HTMLTextAreaElement&&s instanceof HTMLTextAreaElement){let o=s.value||"",a=r.value||"";(a.startsWith(o)||o.startsWith(a))&&(s.value=a)}return r instanceof HTMLSelectElement&&s instanceof HTMLSelectElement&&(r.value&&Array.from(s.options).some(o=>o.value===r.value)?s.value=r.value:r.selectedIndex>=0&&r.selectedIndex<s.options.length&&(s.selectedIndex=r.selectedIndex)),r.id&&r.id.startsWith("pywire-uid-")&&!s.id&&(s.id=r.id),!0},onBeforeNodeDiscarded:()=>!0})}catch(r){console.error("Morphdom failed:",r),e===document.documentElement&&(document.open(),document.write(t),document.close())}this.restoreFocusState(n)}else e===document.documentElement&&(document.open(),document.write(t),document.close())}finally{setTimeout(()=>{K.isUpdating=!1},0)}}update(e){let t=/<html[\s>]/i.test(e),n=/<body[\s>]/i.test(e);if(!t&&document.body){if(n){this.applyUpdate(document.body,e);return}let r=`<body>${e}</body>`;this.applyUpdate(document.body,r);return}this.applyUpdate(document.documentElement,e)}updateRegion(e,t){let n=document.querySelector(`[data-pw-region="${e}"]`);if(!n){this.debug&&console.warn("[DOMUpdater] Region not found:",e);return}this.applyUpdate(n,t),n.getAttribute("data-pw-region")||n.setAttribute("data-pw-region",e)}};K.isUpdating=!1;var T=K;var me=class{constructor(e){this.debouncers=new Map;this.throttlers=new Map;this.supportedEvents=["click","submit","input","change","keydown","keyup","focus","blur","mouseenter","mouseleave","scroll","contextmenu"];this.suppressDuringUpdate=["focus","blur","mouseenter","mouseleave"];this.app=e}debugLog(...e){this.app.getConfig().debug&&console.log(...e)}init(){this.supportedEvents.forEach(e=>{let t=e==="mouseenter"||e==="mouseleave"||e==="focus"||e==="blur"||e==="scroll"?{capture:!0}:void 0;document.addEventListener(e,n=>this.handleEvent(n),t)})}getHandlers(e,t){let n=`data-on-${t}`,r=e.getAttribute(n);if(!r)return[];if(r.trim().startsWith("["))try{let s=JSON.parse(r);if(Array.isArray(s))return s.flatMap(o=>{if(!o||typeof o!="object")return[];let a="handler"in o&&typeof o.handler=="string"?o.handler:null;if(!a)return[];let l="modifiers"in o&&Array.isArray(o.modifiers)?o.modifiers.filter(y=>typeof y=="string"):[],p="args"in o&&Array.isArray(o.args)?o.args:void 0;return[{name:a,modifiers:l,args:p}]})}catch(s){console.error("Error parsing event handlers:",s)}else{let s=e.getAttribute(`data-modifiers-${t}`),o=s?s.split(" ").filter(a=>a):[];return[{name:r,modifiers:o,args:void 0}]}return[]}async handleEvent(e){let t=e.type;if(T.isUpdating&&this.suppressDuringUpdate.includes(t)){this.debugLog("[Handler] SUPPRESSING event during update:",t,"isUpdating=",T.isUpdating);return}this.debugLog("[Handler] Processing event:",t,"isUpdating=",T.isUpdating);let n=e.composedPath?e.composedPath():[],r=!1;for(let s of n){if(r)break;if(s instanceof HTMLElement){let o=s,a=this.getHandlers(o,t);if(a.length>0){this.debugLog("[handleEvent] Found handlers on",o.tagName,a);for(let l of a)!l.modifiers.includes("window")&&!l.modifiers.includes("outside")&&(this.processEvent(o,t,l.name,l.modifiers,e,l.args),e.cancelBubble&&(r=!0))}}}this.handleGlobalEvent(e)}handleGlobalEvent(e){let t=e.type,n=`[data-modifiers-${t}*="window"]`,r=`[data-modifiers-${t}*="outside"]`;document.querySelectorAll(`${n}, ${r}`).forEach(o=>{if(!(o instanceof HTMLElement))return;let a=this.getHandlers(o,t);for(let l of a)if(l.modifiers.includes("window")&&this.processEvent(o,t,l.name,l.modifiers,e,l.args),l.modifiers.includes("outside")){let p=e.target;p&&!o.contains(p)&&this.processEvent(o,t,l.name,l.modifiers,e,l.args)}})}processEvent(e,t,n,r,s,o){if(this.debugLog("[processEvent]",t,"handler:",n,"modifiers:",r),(r.includes("prevent")||t==="submit")&&(this.debugLog("[processEvent] Calling preventDefault"),s.preventDefault()),r.includes("stop")&&s.stopPropagation(),r.includes("self")&&s.target!==e||r.includes("shift")&&(!("shiftKey"in s)||!s.shiftKey)||r.includes("ctrl")&&(!("ctrlKey"in s)||!s.ctrlKey)||r.includes("alt")&&(!("altKey"in s)||!s.altKey)||r.includes("meta")&&(!("metaKey"in s)||!s.metaKey)||r.includes("cmd")&&(!("metaKey"in s)||!s.metaKey))return;if(s instanceof KeyboardEvent){let g=["enter","escape","space","tab","up","down","left","right"],E=["shift","ctrl","alt","meta","cmd","window","outside","prevent","stop","self","debounce","throttle"],Y=r.filter(S=>E.includes(S)||S.startsWith("debounce")||S.startsWith("throttle")||S.endsWith("ms")?!1:g.includes(S)||S.length===1);if(Y.length>0){let S=s.key.toLowerCase();this.debugLog("[processEvent] Key check. Pressed:",S,"Modifiers:",Y);let J={escape:"escape",esc:"escape",enter:"enter",space:" ",spacebar:" "," ":" ",tab:"tab",up:"arrowup",arrowup:"arrowup",down:"arrowdown",arrowdown:"arrowdown",left:"arrowleft",arrowleft:"arrowleft",right:"arrowright",arrowright:"arrowright"},H=J[S]||S,b=!1;for(let A of Y){let k=J[A]||A;if(this.debugLog("[processEvent] Comparing constraint:",A,"->",k,"vs",H,"code:",s.code),k===H){b=!0;break}if(s.code&&s.code.toLowerCase()===`key${k}`){b=!0;break}}if(!b){this.debugLog("[processEvent] No key match found.");return}}}let a=r.find(g=>g.startsWith("debounce")),l=r.find(g=>g.startsWith("throttle")),y=`${e.id||this.getUniqueId(e)}-${t}-${n}`;if(a){let g=this.parseDuration(r,250);this.debouncers.has(y)&&window.clearTimeout(this.debouncers.get(y));let E=window.setTimeout(()=>{this.debouncers.delete(y),this.dispatchEvent(e,t,n,s,o)},g);this.debouncers.set(y,E);return}if(l){let g=this.parseDuration(r,250);if(this.throttlers.has(y))return;this.throttlers.set(y,Date.now()),this.dispatchEvent(e,t,n,s,o),window.setTimeout(()=>{this.throttlers.delete(y)},g);return}this.dispatchEvent(e,t,n,s,o)}dispatchEvent(e,t,n,r,s){let o={};s&&s.length>0?s.forEach((l,p)=>{o[`arg${p}`]=l}):o=this.getArgs(e);let a={type:t,id:e.id,args:o};if(e instanceof HTMLInputElement?(a.value=e.value,(e.type==="checkbox"||e.type==="radio")&&(a.checked=e.checked)):(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(a.value=e.value),r instanceof KeyboardEvent&&(a.key=r.key,a.keyCode=r.keyCode),t==="submit"&&e instanceof HTMLFormElement){let l=new FormData(e),p={};l.forEach((y,g)=>{y instanceof File||(p[g]=y.toString())}),a.formData=p}this.app.sendEvent(n,a)}parseDuration(e,t){let n=e.findIndex(a=>a.startsWith("debounce")),r=e.findIndex(a=>a.startsWith("throttle")),s=n!==-1?n:r;if(s!==-1&&e[s+1]){let a=e[s+1];if(a.endsWith("ms")){let l=parseInt(a);if(!isNaN(l))return l}}let o=e[s];if(o&&o.includes("-")){let a=o.split("-"),l=parseInt(a[1]);if(!isNaN(l))return l}return t}getUniqueId(e){return e.id||(e.id="pywire-uid-"+Math.random().toString(36).substr(2,9)),e.id}getArgs(e){let t={};if(e instanceof HTMLElement){for(let n in e.dataset)if(n.startsWith("arg"))try{t[n]=JSON.parse(e.dataset[n]||"null")}catch{t[n]=e.dataset[n]}}return t}};var Nt={autoInit:!0,enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0,debug:!1},O=class{constructor(e={}){this.initialized=!1;this.siblingPaths=[];this.pathRegexes=[];this.pjaxEnabled=!1;this.isConnected=!1;this.config={...Nt,...e},this.transport=new _(this.config),this.updater=new T(this.config.debug),this.eventHandler=new me(this)}getConfig(){return this.config}async init(){if(!this.initialized){this.initialized=!0,this.transport.onMessage(e=>this.handleMessage(e)),this.transport.onStatusChange(e=>this.handleStatusChange(e));try{await this.transport.connect()}catch(e){console.error("PyWire: Failed to connect:",e)}this.loadSPAMetadata(),this.setupSPANavigation(),this.eventHandler.init(),console.log(`PyWire: Initialized (transport: ${this.transport.getActiveTransport()}, spa_paths: ${this.siblingPaths.length}, pjax: ${this.pjaxEnabled})`)}}handleStatusChange(e){this.isConnected=e}loadSPAMetadata(){let e=document.getElementById("_pywire_spa_meta");if(e)try{let t=JSON.parse(e.textContent||"{}");this.siblingPaths=t.sibling_paths||[],this.pjaxEnabled=!!t.enable_pjax,t.debug!==void 0&&(this.config.debug=!!t.debug),this.pathRegexes=this.siblingPaths.map(n=>this.patternToRegex(n))}catch(t){console.warn("PyWire: Failed to parse SPA metadata",t)}}patternToRegex(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return t=t.replace(/:(\\w+)(:\\w+)?/g,"([^/]+)"),t=t.replace(/\\{(\\w+)(:\\w+)?\\}/g,"([^/]+)"),new RegExp(`^${t}$`)}isSiblingPath(e){return this.pathRegexes.some(t=>t.test(e))}setupSPANavigation(){window.addEventListener("popstate",()=>{this.sendRelocate(window.location.pathname+window.location.search)}),!(this.siblingPaths.length===0&&!this.pjaxEnabled)&&document.addEventListener("click",e=>{let t=e.target.closest("a[href]");if(!t||t.origin!==window.location.origin||t.hasAttribute("download")||t.target==="_blank")return;let n=!1;(this.pjaxEnabled||this.isSiblingPath(t.pathname))&&(n=!0),n&&(e.preventDefault(),this.navigateTo(t.pathname+t.search))})}navigateTo(e){if(!this.isConnected){console.warn("PyWire: Navigation blocked - Offline");return}history.pushState({},"",e),this.sendRelocate(e)}sendRelocate(e){let t={type:"relocate",path:e};this.transport.send(t)}sendEvent(e,t){let n={type:"event",handler:e,path:window.location.pathname+window.location.search,data:t};this.transport.send(n)}async handleMessage(e){switch(e.type){case"update":e.regions&&e.regions.length>0?e.regions.forEach(t=>{this.updater.updateRegion(t.region,t.html)}):e.html&&this.updater.update(e.html);break;case"reload":console.log("PyWire: Reloading..."),window.location.reload();break;case"error":console.error("PyWire: Server error:",e.error);break;case"error_trace":console.error("PyWire: Error:",e.error);break;case"console":if(e.lines&&e.lines.length>0){let t="PyWire Server:",n=e.lines.join(`
3
- `);e.level==="error"?console.error(t,n):e.level==="warn"?console.warn(t,n):console.log(t,n)}break;default:console.warn("PyWire: Unknown message type",e)}}getTransport(){return this.transport.getActiveTransport()}disconnect(){this.transport.disconnect()}};var V=class{constructor(){this.element=null;this.create()}create(){this.element=document.createElement("div"),this.element.style.cssText=`
1
+ /* PyWire Client dev v0.1.5 - https://github.com/pywire/pywire */
2
+ "use strict";var PyWire=(()=>{var oe=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var Ze=Object.prototype.hasOwnProperty;var Qe=(i,e,t)=>e in i?oe(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var je=(i,e)=>{for(var t in e)oe(i,t,{get:e[t],enumerable:!0})},et=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of qe(e))!Ze.call(i,r)&&r!==t&&oe(i,r,{get:()=>e[r],enumerable:!(n=Je(e,r))||n.enumerable});return i};var tt=i=>et(oe({},"__esModule",{value:!0}),i);var c=(i,e,t)=>(Qe(i,typeof e!="symbol"?e+"":e,t),t);var _t={};je(_t,{DOMUpdater:()=>T,ErrorTraceHandler:()=>X,HTTPTransport:()=>z,PyWireApp:()=>O,PyWireDevApp:()=>G,StatusOverlay:()=>V,TransportManager:()=>_,WebSocketTransport:()=>F,WebTransportTransport:()=>C,app:()=>Me});var B=class{constructor(){this.messageHandlers=[];this.statusHandlers=[];this.connected=!1}onMessage(e){this.messageHandlers.push(e)}onStatusChange(e){this.statusHandlers.push(e)}isConnected(){return this.connected}notifyHandlers(e){for(let t of this.messageHandlers)try{t(e)}catch(n){console.error("PyWire: Error in message handler",n)}}notifyStatus(e){if(this.connected!==e){this.connected=e;for(let t of this.statusHandlers)try{t(e)}catch(n){console.error("PyWire: Error in status handler",n)}}}};var C=class i extends B{constructor(t){super();this.name="WebTransport";this.transport=null;this.writer=null;this.encoder=new TextEncoder;this.decoder=new TextDecoder;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`https://${window.location.host}/_pywire/webtransport`}static isSupported(){return typeof WebTransport<"u"}async connect(){if(!i.isSupported())throw new Error("WebTransport not supported in this browser");try{let t={},n=window.PYWIRE_CERT_HASH;n&&Array.isArray(n)&&(t.serverCertificateHashes=[{algorithm:"sha-256",value:new Uint8Array(n).buffer}],console.log("PyWire: Using explicit certificate hash for WebTransport")),this.transport=new WebTransport(this.url,t),await this.transport.ready,console.log("PyWire: WebTransport ready"),this.connected=!0,this.startReading()}catch(t){throw this.handleDisconnect(),t}}async startReading(){if(!this.transport)return;let t=this.transport.incomingBidirectionalStreams.getReader();try{for(;;){let{value:n,done:r}=await t.read();if(r)break;this.handleStream(n)}}catch(n){this.connected&&(console.error("PyWire: WebTransport read error",n),this.handleDisconnect())}}async handleStream(t){let n=t.readable.getReader();try{for(;;){let{value:r,done:s}=await n.read();if(s)break;if(r){let o=this.decoder.decode(r);try{let a=JSON.parse(o);this.notifyHandlers(a)}catch(a){console.error("PyWire: Error parsing WebTransport message",a)}}}}catch(r){console.error("PyWire: Stream read error",r)}}async send(t){if(!this.transport||!this.connected){console.warn("PyWire: Cannot send message, WebTransport not connected");return}try{let n=await this.transport.createBidirectionalStream(),r=n.writable.getWriter(),s=this.encoder.encode(JSON.stringify(t));await r.write(s),await r.close(),this.handleStream(n)}catch(n){console.error("PyWire: WebTransport send error",n)}}disconnect(){this.transport&&(this.transport.close(),this.transport=null),this.writer=null,this.connected=!1}handleDisconnect(){this.connected=!1,this.transport=null,this.writer=null}};function Ce(i){let e=i.length,t=0,n=0;for(;n<e;){let r=i.charCodeAt(n++);if(r&4294967168)if(!(r&4294965248))t+=2;else{if(r>=55296&&r<=56319&&n<e){let s=i.charCodeAt(n);(s&64512)===56320&&(++n,r=((r&1023)<<10)+(s&1023)+65536)}r&4294901760?t+=4:t+=3}else{t++;continue}}return t}function nt(i,e,t){let n=i.length,r=t,s=0;for(;s<n;){let o=i.charCodeAt(s++);if(o&4294967168)if(!(o&4294965248))e[r++]=o>>6&31|192;else{if(o>=55296&&o<=56319&&s<n){let a=i.charCodeAt(s);(a&64512)===56320&&(++s,o=((o&1023)<<10)+(a&1023)+65536)}o&4294901760?(e[r++]=o>>18&7|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128):(e[r++]=o>>12&15|224,e[r++]=o>>6&63|128)}else{e[r++]=o;continue}e[r++]=o&63|128}}var rt=new TextEncoder,it=50;function st(i,e,t){rt.encodeInto(i,e.subarray(t))}function We(i,e,t){i.length>it?st(i,e,t):nt(i,e,t)}var ot=4096;function Se(i,e,t){let n=e,r=n+t,s=[],o="";for(;n<r;){let a=i[n++];if(!(a&128))s.push(a);else if((a&224)===192){let l=i[n++]&63;s.push((a&31)<<6|l)}else if((a&240)===224){let l=i[n++]&63,p=i[n++]&63;s.push((a&31)<<12|l<<6|p)}else if((a&248)===240){let l=i[n++]&63,p=i[n++]&63,y=i[n++]&63,g=(a&7)<<18|l<<12|p<<6|y;g>65535&&(g-=65536,s.push(g>>>10&1023|55296),g=56320|g&1023),s.push(g)}else s.push(a);s.length>=ot&&(o+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(o+=String.fromCharCode(...s)),o}var at=new TextDecoder,ct=200;function lt(i,e,t){let n=i.subarray(e,e+t);return at.decode(n)}function Le(i,e,t){return t>ct?lt(i,e,t):Se(i,e,t)}var W=class{constructor(e,t){c(this,"type");c(this,"data");this.type=e,this.data=t}};var x=class i extends Error{constructor(e){super(e);let t=Object.create(i.prototype);Object.setPrototypeOf(this,t),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:i.name})}};function He(i,e,t){let n=t/4294967296,r=t;i.setUint32(e,n),i.setUint32(e+4,r)}function ae(i,e,t){let n=Math.floor(t/4294967296),r=t;i.setUint32(e,n),i.setUint32(e+4,r)}function ce(i,e){let t=i.getInt32(e),n=i.getUint32(e+4);return t*4294967296+n}function De(i,e){let t=i.getUint32(e),n=i.getUint32(e+4);return t*4294967296+n}var dt=-1,ht=4294967296-1,ft=17179869184-1;function ut({sec:i,nsec:e}){if(i>=0&&e>=0&&i<=ft)if(e===0&&i<=ht){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,i),t}else{let t=i/4294967296,n=i&4294967295,r=new Uint8Array(8),s=new DataView(r.buffer);return s.setUint32(0,e<<2|t&3),s.setUint32(4,n),r}else{let t=new Uint8Array(12),n=new DataView(t.buffer);return n.setUint32(0,e),ae(n,4,i),t}}function pt(i){let e=i.getTime(),t=Math.floor(e/1e3),n=(e-t*1e3)*1e6,r=Math.floor(n/1e9);return{sec:t+r,nsec:n-r*1e9}}function gt(i){if(i instanceof Date){let e=pt(i);return ut(e)}else return null}function mt(i){let e=new DataView(i.buffer,i.byteOffset,i.byteLength);switch(i.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{let t=e.getUint32(0),n=e.getUint32(4),r=(t&3)*4294967296+n,s=t>>>2;return{sec:r,nsec:s}}case 12:{let t=ce(e,4),n=e.getUint32(0);return{sec:t,nsec:n}}default:throw new x(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${i.length}`)}}function yt(i){let e=mt(i);return new Date(e.sec*1e3+e.nsec/1e6)}var $e={type:dt,encode:gt,decode:yt};var le=class le{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register($e)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let s=r(e,t);if(s!=null){let o=-1-n;return new W(o,s)}}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let s=r(e,t);if(s!=null){let o=n;return new W(o,s)}}}return e instanceof W?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new W(t,e)}};c(le,"defaultCodec",new le);var R=le;function wt(i){return i instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&i instanceof SharedArrayBuffer}function q(i){return i instanceof Uint8Array?i:ArrayBuffer.isView(i)?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):wt(i)?new Uint8Array(i):Uint8Array.from(i)}var xt=100,vt=2048,de=class i{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"maxDepth");c(this,"initialBufferSize");c(this,"sortKeys");c(this,"forceFloat32");c(this,"ignoreUndefined");c(this,"forceIntegerToFloat");c(this,"pos");c(this,"view");c(this,"bytes");c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??R.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.maxDepth=e?.maxDepth??xt,this.initialBufferSize=e?.initialBufferSize??vt,this.sortKeys=e?.sortKeys??!1,this.forceFloat32=e?.forceFloat32??!1,this.ignoreUndefined=e?.ignoreUndefined??!1,this.forceIntegerToFloat=e?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new i({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,t){if(t>this.maxDepth)throw new Error(`Too deep objects in depth ${t}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,t)}ensureBufferSizeToWrite(e){let t=this.pos+e;this.view.byteLength<t&&this.resizeBuffer(t*2)}resizeBuffer(e){let t=new ArrayBuffer(e),n=new Uint8Array(t),r=new DataView(t);n.set(this.bytes),this.view=r,this.bytes=n}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){let n=Ce(e);this.ensureBufferSizeToWrite(5+n),this.writeStringHeader(n),We(e,this.bytes,this.pos),this.pos+=n}encodeObject(e,t){let n=this.extensionCodec.tryToEncode(e,this.context);if(n!=null)this.encodeExtension(n);else if(Array.isArray(e))this.encodeArray(e,t);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,t);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){let t=e.byteLength;if(t<256)this.writeU8(196),this.writeU8(t);else if(t<65536)this.writeU8(197),this.writeU16(t);else if(t<4294967296)this.writeU8(198),this.writeU32(t);else throw new Error(`Too large binary: ${t}`);let n=q(e);this.writeU8a(n)}encodeArray(e,t){let n=e.length;if(n<16)this.writeU8(144+n);else if(n<65536)this.writeU8(220),this.writeU16(n);else if(n<4294967296)this.writeU8(221),this.writeU32(n);else throw new Error(`Too large array: ${n}`);for(let r of e)this.doEncode(r,t+1)}countWithoutUndefined(e,t){let n=0;for(let r of t)e[r]!==void 0&&n++;return n}encodeMap(e,t){let n=Object.keys(e);this.sortKeys&&n.sort();let r=this.ignoreUndefined?this.countWithoutUndefined(e,n):n.length;if(r<16)this.writeU8(128+r);else if(r<65536)this.writeU8(222),this.writeU16(r);else if(r<4294967296)this.writeU8(223),this.writeU32(r);else throw new Error(`Too large map object: ${r}`);for(let s of n){let o=e[s];this.ignoreUndefined&&o===void 0||(this.encodeString(s),this.doEncode(o,t+1))}}encodeExtension(e){if(typeof e.data=="function"){let n=e.data(this.pos+6),r=n.length;if(r>=4294967296)throw new Error(`Too large extension object: ${r}`);this.writeU8(201),this.writeU32(r),this.writeI8(e.type),this.writeU8a(n);return}let t=e.data.length;if(t===1)this.writeU8(212);else if(t===2)this.writeU8(213);else if(t===4)this.writeU8(214);else if(t===8)this.writeU8(215);else if(t===16)this.writeU8(216);else if(t<256)this.writeU8(199),this.writeU8(t);else if(t<65536)this.writeU8(200),this.writeU16(t);else if(t<4294967296)this.writeU8(201),this.writeU32(t);else throw new Error(`Too large extension object: ${t}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){let t=e.length;this.ensureBufferSizeToWrite(t),this.bytes.set(e,this.pos),this.pos+=t}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),He(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),ae(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}};function N(i,e){return new de(e).encodeSharedRef(i)}function he(i){return`${i<0?"-":""}0x${Math.abs(i).toString(16).padStart(2,"0")}`}var bt=16,St=16,fe=class{constructor(e=bt,t=St){c(this,"hit",0);c(this,"miss",0);c(this,"caches");c(this,"maxKeyLength");c(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let n=0;n<this.maxKeyLength;n++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];e:for(let s of r){let o=s.bytes;for(let a=0;a<n;a++)if(o[a]!==e[t+a])continue e;return s.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(e,t,n){let r=this.find(e,t,n);if(r!=null)return this.hit++,r;this.miss++;let s=Se(e,t,n),o=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(o,s),s}};var Te="array",j="map_key",Ne="map_value",Tt=i=>{if(typeof i=="string"||typeof i=="number")return i;throw new x("The type of key must be string or number but "+typeof i)},Ue=class{constructor(){c(this,"stack",[]);c(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=Te,t.position=0,t.size=e,t.array=new Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=j,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===Te){let n=e;n.size=0,n.array=void 0,n.position=0,n.type=void 0}if(e.type===j||e.type===Ne){let n=e;n.size=0,n.map=void 0,n.readCount=0,n.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}},Q=-1,Ee=new DataView(new ArrayBuffer(0)),Ut=new Uint8Array(Ee.buffer);try{Ee.getInt8(0)}catch(i){if(!(i instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var Re=new RangeError("Insufficient data"),Et=new fe,ue=class i{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"rawStrings");c(this,"maxStrLength");c(this,"maxBinLength");c(this,"maxArrayLength");c(this,"maxMapLength");c(this,"maxExtLength");c(this,"keyDecoder");c(this,"mapKeyConverter");c(this,"totalPos",0);c(this,"pos",0);c(this,"view",Ee);c(this,"bytes",Ut);c(this,"headByte",Q);c(this,"stack",new Ue);c(this,"entered",!1);this.extensionCodec=e?.extensionCodec??R.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??4294967295,this.maxBinLength=e?.maxBinLength??4294967295,this.maxArrayLength=e?.maxArrayLength??4294967295,this.maxMapLength=e?.maxMapLength??4294967295,this.maxExtLength=e?.maxExtLength??4294967295,this.keyDecoder=e?.keyDecoder!==void 0?e.keyDecoder:Et,this.mapKeyConverter=e?.mapKeyConverter??Tt}clone(){return new i({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Q,this.stack.reset()}setBuffer(e){let t=q(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===Q&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=q(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return new RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let a of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{n=this.doDecodeSync(),t=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:s,totalPos:o}=this;throw new RangeError(`Insufficient data in parsing ${he(r)} at ${o} (${s} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let s of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(o){if(!(o instanceof RangeError))throw o}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let r=e-128;if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e<160){let r=e-144;if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else{let r=e-160;t=this.decodeString(r,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)this.useBigInt64?t=this.readU64AsBigInt():t=this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)this.useBigInt64?t=this.readI64AsBigInt():t=this.readI64();else if(e===217){let r=this.lookU8();t=this.decodeString(r,1)}else if(e===218){let r=this.lookU16();t=this.decodeString(r,2)}else if(e===219){let r=this.lookU32();t=this.decodeString(r,4)}else if(e===220){let r=this.readU16();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===221){let r=this.readU32();if(r!==0){this.pushArrayState(r),this.complete();continue e}else t=[]}else if(e===222){let r=this.readU16();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===223){let r=this.readU32();if(r!==0){this.pushMapState(r),this.complete();continue e}else t={}}else if(e===196){let r=this.lookU8();t=this.decodeBinary(r,1)}else if(e===197){let r=this.lookU16();t=this.decodeBinary(r,2)}else if(e===198){let r=this.lookU32();t=this.decodeBinary(r,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let r=this.lookU8();t=this.decodeExtension(r,1)}else if(e===200){let r=this.lookU16();t=this.decodeExtension(r,2)}else if(e===201){let r=this.lookU32();t=this.decodeExtension(r,4)}else throw new x(`Unrecognized type byte: ${he(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let r=n.top();if(r.type===Te)if(r.array[r.position]=t,r.position++,r.position===r.size)t=r.array,n.release(r);else continue e;else if(r.type===j){if(t==="__proto__")throw new x("The key __proto__ is not allowed");r.key=this.mapKeyConverter(t),r.type=Ne;continue e}else if(r.map[r.key]=t,r.readCount++,r.readCount===r.size)t=r.map,n.release(r);else{r.key=null,r.type=j;continue e}}return t}}readHeadByte(){return this.headByte===Q&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=Q}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new x(`Unrecognized array type byte: ${he(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new x(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new x(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new x(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw Re;let n=this.pos+t,r;return this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?r=this.keyDecoder.decode(this.bytes,n,e):r=Le(this.bytes,n,e),this.pos+=t+e,r}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===j:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new x(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw Re;let n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new x(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=De(this.view,this.pos);return this.pos+=8,e}readI64(){let e=ce(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function L(i,e){return new ue(e).decode(i)}var F=class extends B{constructor(t){super();this.name="WebSocket";this.socket=null;this.reconnectAttempts=0;this.maxReconnectDelay=5e3;this.shouldReconnect=!0;this.url=t||this.getDefaultUrl()}getDefaultUrl(){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/_pywire/ws`}connect(){return new Promise((t,n)=>{try{this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{console.log("PyWire: WebSocket connected"),this.notifyStatus(!0),this.reconnectAttempts=0,t()},this.socket.onmessage=r=>{try{let s=L(r.data);this.notifyHandlers(s)}catch(s){console.error("PyWire: Error parsing WebSocket message",s)}},this.socket.onclose=()=>{console.log("PyWire: WebSocket disconnected"),this.notifyStatus(!1),this.shouldReconnect&&this.scheduleReconnect()},this.socket.onerror=r=>{console.error("PyWire: WebSocket error",r),this.connected||n(new Error("WebSocket connection failed"))}}catch(r){n(r)}})}send(t){this.socket&&this.socket.readyState===WebSocket.OPEN?this.socket.send(N(t)):console.warn("PyWire: Cannot send message, WebSocket not open")}disconnect(){this.shouldReconnect=!1,this.socket&&(this.socket.close(),this.socket=null),this.notifyStatus(!1)}scheduleReconnect(){let t=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.maxReconnectDelay);console.log(`PyWire: Reconnecting in ${t}ms...`),setTimeout(()=>{this.reconnectAttempts++,this.connect().catch(()=>{})},t)}};var z=class extends B{constructor(t){super();this.name="HTTP";this.polling=!1;this.pollAbortController=null;this.sessionId=null;this.baseUrl=t||`${window.location.origin}/_pywire`}async connect(){try{let t=await fetch(`${this.baseUrl}/session`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack"},body:N({path:window.location.pathname+window.location.search})});if(!t.ok)throw new Error(`HTTP session init failed: ${t.status}`);let n=await t.arrayBuffer(),r=L(n);this.sessionId=r.sessionId,r.version&&this.notifyHandlers({type:"init",version:r.version}),console.log("PyWire: HTTP transport connected"),this.notifyStatus(!0),this.startPolling()}catch(t){throw console.error("PyWire: HTTP transport connection failed",t),t}}async startPolling(){if(!this.polling)for(this.polling=!0;this.polling&&this.connected;)try{this.pollAbortController=new AbortController;let t=await fetch(`${this.baseUrl}/poll?session=${this.sessionId}`,{method:"GET",signal:this.pollAbortController.signal,headers:{Accept:"application/x-msgpack"}});if(!t.ok){if(t.status===404){console.warn("PyWire: HTTP session expired, reconnecting..."),this.notifyStatus(!1),await this.connect();return}throw new Error(`Poll failed: ${t.status}`)}let n=await t.arrayBuffer(),r=L(n);for(let s of r)this.notifyHandlers(s)}catch(t){if(t instanceof Error&&t.name==="AbortError")break;console.error("PyWire: HTTP poll error",t),await this.sleep(1e3)}}async send(t){if(!this.connected||!this.sessionId){console.warn("PyWire: Cannot send message, HTTP transport not connected");return}try{let n=await fetch(`${this.baseUrl}/event`,{method:"POST",headers:{"Content-Type":"application/x-msgpack",Accept:"application/x-msgpack","X-PyWire-Session":this.sessionId},body:N(t)});if(!n.ok)throw new Error(`Event send failed: ${n.status}`);let r=await n.arrayBuffer(),s=L(r);this.notifyHandlers(s)}catch(n){console.error("PyWire: HTTP send error",n)}}disconnect(){this.polling=!1,this.notifyStatus(!1),this.pollAbortController&&(this.pollAbortController.abort(),this.pollAbortController=null),this.sessionId=null}sleep(t){return new Promise(n=>setTimeout(n,t))}};var At={enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0},_=class{constructor(e={}){this.transport=null;this.messageHandlers=[];this.statusHandlers=[];this.config={...At,...e}}async connect(){let e=this.getTransportPriority();for(let t of e)try{console.log(`PyWire: Trying ${t.name}...`),this.transport=new t;for(let n of this.messageHandlers)this.transport.onMessage(n);this.transport.onStatusChange(n=>{this.notifyStatusHandlers(n)}),await this.transport.connect(),console.log(`PyWire: Connected via ${this.transport.name}`);return}catch(n){console.warn(`PyWire: ${t.name} failed, trying next...`,n),this.transport=null}throw new Error("PyWire: All transports failed")}getTransportPriority(){let e=[];return this.config.enableWebTransport&&C.isSupported()&&window.location.protocol==="https:"&&e.push(C),this.config.enableWebSocket&&typeof WebSocket<"u"&&e.push(F),this.config.enableHTTP&&e.push(z),e}send(e){this.transport?this.transport.send(e):console.warn("PyWire: No active transport")}onMessage(e){this.messageHandlers.push(e),this.transport&&this.transport.onMessage(e)}onStatusChange(e){this.statusHandlers.push(e)}notifyStatusHandlers(e){for(let t of this.statusHandlers)t(e)}disconnect(){this.transport&&(this.transport.disconnect(),this.transport=null,this.notifyStatusHandlers(!1))}getActiveTransport(){return this.transport?.name||null}isConnected(){return this.transport?.isConnected()||!1}};var Fe="0.1.5";var ze=11;function Mt(i,e){var t=e.attributes,n,r,s,o,a;if(!(e.nodeType===ze||i.nodeType===ze)){for(var l=t.length-1;l>=0;l--)n=t[l],r=n.name,s=n.namespaceURI,o=n.value,s?(r=n.localName||r,a=i.getAttributeNS(s,r),a!==o&&(n.prefix==="xmlns"&&(r=n.name),i.setAttributeNS(s,r,o))):(a=i.getAttribute(r),a!==o&&i.setAttribute(r,o));for(var p=i.attributes,y=p.length-1;y>=0;y--)n=p[y],r=n.name,s=n.namespaceURI,s?(r=n.localName||r,e.hasAttributeNS(s,r)||i.removeAttributeNS(s,r)):e.hasAttribute(r)||i.removeAttribute(r)}}var pe,Pt="http://www.w3.org/1999/xhtml",v=typeof document>"u"?void 0:document,Bt=!!v&&"content"in v.createElement("template"),It=!!v&&v.createRange&&"createContextualFragment"in v.createRange();function Ct(i){var e=v.createElement("template");return e.innerHTML=i,e.content.childNodes[0]}function Wt(i){pe||(pe=v.createRange(),pe.selectNode(v.body));var e=pe.createContextualFragment(i);return e.childNodes[0]}function Lt(i){var e=v.createElement("body");return e.innerHTML=i,e.childNodes[0]}function Ht(i){return i=i.trim(),Bt?Ct(i):It?Wt(i):Lt(i)}function ge(i,e){var t=i.nodeName,n=e.nodeName,r,s;return t===n?!0:(r=t.charCodeAt(0),s=n.charCodeAt(0),r<=90&&s>=97?t===n.toUpperCase():s<=90&&r>=97?n===t.toUpperCase():!1)}function Dt(i,e){return!e||e===Pt?v.createElement(i):v.createElementNS(e,i)}function $t(i,e){for(var t=i.firstChild;t;){var n=t.nextSibling;e.appendChild(t),t=n}return e}function Ae(i,e,t){i[t]!==e[t]&&(i[t]=e[t],i[t]?i.setAttribute(t,""):i.removeAttribute(t))}var _e={OPTION:function(i,e){var t=i.parentNode;if(t){var n=t.nodeName.toUpperCase();n==="OPTGROUP"&&(t=t.parentNode,n=t&&t.nodeName.toUpperCase()),n==="SELECT"&&!t.hasAttribute("multiple")&&(i.hasAttribute("selected")&&!e.selected&&(i.setAttribute("selected","selected"),i.removeAttribute("selected")),t.selectedIndex=-1)}Ae(i,e,"selected")},INPUT:function(i,e){Ae(i,e,"checked"),Ae(i,e,"disabled"),i.value!==e.value&&(i.value=e.value),e.hasAttribute("value")||i.removeAttribute("value")},TEXTAREA:function(i,e){var t=e.value;i.value!==t&&(i.value=t);var n=i.firstChild;if(n){var r=n.nodeValue;if(r==t||!t&&r==i.placeholder)return;n.nodeValue=t}},SELECT:function(i,e){if(!e.hasAttribute("multiple")){for(var t=-1,n=0,r=i.firstChild,s,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")s=r,r=s.firstChild,r||(r=s.nextSibling,s=null);else{if(o==="OPTION"){if(r.hasAttribute("selected")){t=n;break}n++}r=r.nextSibling,!r&&s&&(r=s.nextSibling,s=null)}i.selectedIndex=t}}},ee=1,Ke=11,Oe=3,Ve=8;function I(){}function Rt(i){if(i)return i.getAttribute&&i.getAttribute("id")||i.id}function Nt(i){return function(t,n,r){if(r||(r={}),typeof n=="string")if(t.nodeName==="#document"||t.nodeName==="HTML"||t.nodeName==="BODY"){var s=n;n=v.createElement("html"),n.innerHTML=s}else n=Ht(n);else n.nodeType===Ke&&(n=n.firstElementChild);var o=r.getNodeKey||Rt,a=r.onBeforeNodeAdded||I,l=r.onNodeAdded||I,p=r.onBeforeElUpdated||I,y=r.onElUpdated||I,g=r.onBeforeNodeDiscarded||I,E=r.onNodeDiscarded||I,Y=r.onBeforeElChildrenUpdated||I,b=r.skipFromChildren||I,J=r.addChild||function(d,h){return d.appendChild(h)},H=r.childrenOnly===!0,S=Object.create(null),A=[];function k(d){A.push(d)}function Pe(d,h){if(d.nodeType===ee)for(var m=d.firstChild;m;){var f=void 0;h&&(f=o(m))?k(f):(E(m),m.firstChild&&Pe(m,h)),m=m.nextSibling}}function te(d,h,m){g(d)!==!1&&(h&&h.removeChild(d),E(d),Pe(d,m))}function ye(d){if(d.nodeType===ee||d.nodeType===Ke)for(var h=d.firstChild;h;){var m=o(h);m&&(S[m]=h),ye(h),h=h.nextSibling}}ye(t);function we(d){l(d);for(var h=d.firstChild;h;){var m=h.nextSibling,f=o(h);if(f){var u=S[f];u&&ge(h,u)?(h.parentNode.replaceChild(u,h),ne(u,h)):we(h)}else we(h);h=m}}function Xe(d,h,m){for(;h;){var f=h.nextSibling;(m=o(h))?k(m):te(h,d,!0),h=f}}function ne(d,h,m){var f=o(h);if(f&&delete S[f],!m){var u=p(d,h);if(u===!1||(u instanceof HTMLElement&&(d=u,ye(d)),i(d,h),y(d),Y(d,h)===!1))return}d.nodeName!=="TEXTAREA"?Ge(d,h):_e.TEXTAREA(d,h)}function Ge(d,h){var m=b(d,h),f=h.firstChild,u=d.firstChild,D,U,$,ie,M;e:for(;f;){for(ie=f.nextSibling,D=o(f);!m&&u;){if($=u.nextSibling,f.isSameNode&&f.isSameNode(u)){f=ie,u=$;continue e}U=o(u);var se=u.nodeType,P=void 0;if(se===f.nodeType&&(se===ee?(D?D!==U&&((M=S[D])?$===M?P=!1:(d.insertBefore(M,u),U?k(U):te(u,d,!0),u=M,U=o(u)):P=!1):U&&(P=!1),P=P!==!1&&ge(u,f),P&&ne(u,f)):(se===Oe||se==Ve)&&(P=!0,u.nodeValue!==f.nodeValue&&(u.nodeValue=f.nodeValue))),P){f=ie,u=$;continue e}U?k(U):te(u,d,!0),u=$}if(D&&(M=S[D])&&ge(M,f))m||J(d,M),ne(M,f);else{var be=a(f);be!==!1&&(be&&(f=be),f.actualize&&(f=f.actualize(d.ownerDocument||v)),J(d,f),we(f))}f=ie,u=$}Xe(d,u,U);var Ie=_e[d.nodeName];Ie&&Ie(d,h)}var w=t,re=w.nodeType,Be=n.nodeType;if(!H){if(re===ee)Be===ee?ge(t,n)||(E(t),w=$t(t,Dt(n.nodeName,n.namespaceURI))):w=n;else if(re===Oe||re===Ve){if(Be===re)return w.nodeValue!==n.nodeValue&&(w.nodeValue=n.nodeValue),w;w=n}}if(w===n)E(t);else{if(n.isSameNode&&n.isSameNode(w))return;if(ne(w,n,H),A)for(var xe=0,Ye=A.length;xe<Ye;xe++){var ve=S[A[xe]];ve&&te(ve,ve.parentNode,!1)}}return!H&&w!==t&&t.parentNode&&(w.actualize&&(w=w.actualize(t.ownerDocument||v)),t.parentNode.replaceChild(w,t)),w}}var Ft=Nt(Mt),ke=Ft;var K=class K{constructor(e=!1){this.debug=e}getNodeKey(e){if(e instanceof HTMLElement){for(let t of e.attributes)if(t.name.startsWith("data-on-"))return`${e.tagName}-${t.name}-${t.value}`;if(e.id&&!e.id.startsWith("pywire-uid-"))return e.id;if((e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement)&&e.name)return`${e.tagName}-name-${e.name}`}}getElementSelector(e){if(e.id)return`#${e.id}`;let t=[],n=e;for(;n&&n!==document.body&&t.length<5;){let r=n.tagName.toLowerCase();if(n.id){r=`#${n.id}`,t.unshift(r);break}(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement)&&n.name&&(r+=`[name="${n.name}"]`);for(let s of n.attributes)if(s.name.startsWith("data-on-")){r+=`[${s.name}="${s.value}"]`;break}if(n.parentElement){let o=Array.from(n.parentElement.children).filter(a=>a.tagName===n.tagName);if(o.length>1){let a=o.indexOf(n)+1;r+=`:nth-of-type(${a})`}}t.unshift(r),n=n.parentElement}return t.join(" > ")}captureFocusState(){let e=document.activeElement;if(!e||e===document.body||e===document.documentElement)return null;let t={selector:this.getElementSelector(e),id:e.id||null,tagName:e.tagName,selectionStart:null,selectionEnd:null,scrollTop:0,scrollLeft:0,value:""};return(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(t.selectionStart=e.selectionStart,t.selectionEnd=e.selectionEnd,t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft,t.value=e.value),t}restoreFocusState(e){if(!e)return;let t=null;if(e.id&&(t=document.getElementById(e.id)),!t&&e.selector)try{t=document.querySelector(e.selector)}catch{}if(t&&(t.focus(),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)){if(e.value&&t.value!==e.value&&(t.value=e.value),e.selectionStart!==null&&e.selectionEnd!==null)try{t.setSelectionRange(e.selectionStart,e.selectionEnd)}catch{}t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft}}applyUpdate(e,t){K.isUpdating=!0,this.debug&&console.log("[DOMUpdater] Starting update, isUpdating =",K.isUpdating);try{let n=this.captureFocusState();if(ke){try{ke(e,t,{getNodeKey:r=>this.getNodeKey(r),onBeforeElUpdated:(r,s)=>{if(r instanceof HTMLInputElement&&s instanceof HTMLInputElement)if(r.type==="checkbox"||r.type==="radio")s.checked=r.checked;else{let o=s.value||"",a=r.value||"";(a.startsWith(o)||o.startsWith(a))&&(s.value=a)}if(r instanceof HTMLTextAreaElement&&s instanceof HTMLTextAreaElement){let o=s.value||"",a=r.value||"";(a.startsWith(o)||o.startsWith(a))&&(s.value=a)}return r instanceof HTMLSelectElement&&s instanceof HTMLSelectElement&&(r.value&&Array.from(s.options).some(o=>o.value===r.value)?s.value=r.value:r.selectedIndex>=0&&r.selectedIndex<s.options.length&&(s.selectedIndex=r.selectedIndex)),r.id&&r.id.startsWith("pywire-uid-")&&!s.id&&(s.id=r.id),!0},onBeforeNodeDiscarded:()=>!0})}catch(r){console.error("Morphdom failed:",r),e===document.documentElement&&(document.open(),document.write(t),document.close())}this.restoreFocusState(n)}else e===document.documentElement&&(document.open(),document.write(t),document.close())}finally{setTimeout(()=>{K.isUpdating=!1},0)}}update(e){let t=/<html[\s>]/i.test(e),n=/<body[\s>]/i.test(e);if(!t&&document.body){if(n){this.applyUpdate(document.body,e);return}let r=`<body>${e}</body>`;this.applyUpdate(document.body,r);return}this.applyUpdate(document.documentElement,e)}updateRegion(e,t){let n=document.querySelector(`[data-pw-region="${e}"]`);if(!n){this.debug&&console.warn("[DOMUpdater] Region not found:",e);return}this.applyUpdate(n,t),n.getAttribute("data-pw-region")||n.setAttribute("data-pw-region",e)}};K.isUpdating=!1;var T=K;var me=class{constructor(e){this.debouncers=new Map;this.throttlers=new Map;this.supportedEvents=["click","submit","input","change","keydown","keyup","focus","blur","mouseenter","mouseleave","scroll","contextmenu"];this.suppressDuringUpdate=["focus","blur","mouseenter","mouseleave"];this.app=e}debugLog(...e){this.app.getConfig().debug&&console.log(...e)}init(){this.supportedEvents.forEach(e=>{let t=e==="mouseenter"||e==="mouseleave"||e==="focus"||e==="blur"||e==="scroll"?{capture:!0}:void 0;document.addEventListener(e,n=>this.handleEvent(n),t)})}getHandlers(e,t){let n=`data-on-${t}`,r=e.getAttribute(n);if(!r)return[];if(r.trim().startsWith("["))try{let s=JSON.parse(r);if(Array.isArray(s))return s.flatMap(o=>{if(!o||typeof o!="object")return[];let a="handler"in o&&typeof o.handler=="string"?o.handler:null;if(!a)return[];let l="modifiers"in o&&Array.isArray(o.modifiers)?o.modifiers.filter(y=>typeof y=="string"):[],p="args"in o&&Array.isArray(o.args)?o.args:void 0;return[{name:a,modifiers:l,args:p}]})}catch(s){console.error("Error parsing event handlers:",s)}else{let s=e.getAttribute(`data-modifiers-${t}`),o=s?s.split(" ").filter(a=>a):[];return[{name:r,modifiers:o,args:void 0}]}return[]}async handleEvent(e){let t=e.type;if(T.isUpdating&&this.suppressDuringUpdate.includes(t)){this.debugLog("[Handler] SUPPRESSING event during update:",t,"isUpdating=",T.isUpdating);return}this.debugLog("[Handler] Processing event:",t,"isUpdating=",T.isUpdating);let n=e.composedPath?e.composedPath():[],r=!1;for(let s of n){if(r)break;if(s instanceof HTMLElement){let o=s,a=this.getHandlers(o,t);if(a.length>0){this.debugLog("[handleEvent] Found handlers on",o.tagName,a);for(let l of a)!l.modifiers.includes("window")&&!l.modifiers.includes("outside")&&(this.processEvent(o,t,l.name,l.modifiers,e,l.args),e.cancelBubble&&(r=!0))}}}this.handleGlobalEvent(e)}handleGlobalEvent(e){let t=e.type,n=`[data-modifiers-${t}*="window"]`,r=`[data-modifiers-${t}*="outside"]`;document.querySelectorAll(`${n}, ${r}`).forEach(o=>{if(!(o instanceof HTMLElement))return;let a=this.getHandlers(o,t);for(let l of a)if(l.modifiers.includes("window")&&this.processEvent(o,t,l.name,l.modifiers,e,l.args),l.modifiers.includes("outside")){let p=e.target;p&&!o.contains(p)&&this.processEvent(o,t,l.name,l.modifiers,e,l.args)}})}processEvent(e,t,n,r,s,o){if(this.debugLog("[processEvent]",t,"handler:",n,"modifiers:",r),(r.includes("prevent")||t==="submit")&&(this.debugLog("[processEvent] Calling preventDefault"),s.preventDefault()),r.includes("stop")&&s.stopPropagation(),r.includes("self")&&s.target!==e||r.includes("shift")&&(!("shiftKey"in s)||!s.shiftKey)||r.includes("ctrl")&&(!("ctrlKey"in s)||!s.ctrlKey)||r.includes("alt")&&(!("altKey"in s)||!s.altKey)||r.includes("meta")&&(!("metaKey"in s)||!s.metaKey)||r.includes("cmd")&&(!("metaKey"in s)||!s.metaKey))return;if(s instanceof KeyboardEvent){let g=["enter","escape","space","tab","up","down","left","right"],E=["shift","ctrl","alt","meta","cmd","window","outside","prevent","stop","self","debounce","throttle"],Y=r.filter(b=>E.includes(b)||b.startsWith("debounce")||b.startsWith("throttle")||b.endsWith("ms")?!1:g.includes(b)||b.length===1);if(Y.length>0){let b=s.key.toLowerCase();this.debugLog("[processEvent] Key check. Pressed:",b,"Modifiers:",Y);let J={escape:"escape",esc:"escape",enter:"enter",space:" ",spacebar:" "," ":" ",tab:"tab",up:"arrowup",arrowup:"arrowup",down:"arrowdown",arrowdown:"arrowdown",left:"arrowleft",arrowleft:"arrowleft",right:"arrowright",arrowright:"arrowright"},H=J[b]||b,S=!1;for(let A of Y){let k=J[A]||A;if(this.debugLog("[processEvent] Comparing constraint:",A,"->",k,"vs",H,"code:",s.code),k===H){S=!0;break}if(s.code&&s.code.toLowerCase()===`key${k}`){S=!0;break}}if(!S){this.debugLog("[processEvent] No key match found.");return}}}let a=r.find(g=>g.startsWith("debounce")),l=r.find(g=>g.startsWith("throttle")),y=`${e.id||this.getUniqueId(e)}-${t}-${n}`;if(a){let g=this.parseDuration(r,250);this.debouncers.has(y)&&window.clearTimeout(this.debouncers.get(y));let E=window.setTimeout(()=>{this.debouncers.delete(y),this.dispatchEvent(e,t,n,s,o)},g);this.debouncers.set(y,E);return}if(l){let g=this.parseDuration(r,250);if(this.throttlers.has(y))return;this.throttlers.set(y,Date.now()),this.dispatchEvent(e,t,n,s,o),window.setTimeout(()=>{this.throttlers.delete(y)},g);return}this.dispatchEvent(e,t,n,s,o)}dispatchEvent(e,t,n,r,s){let o={};s&&s.length>0?s.forEach((l,p)=>{o[`arg${p}`]=l}):o=this.getArgs(e);let a={type:t,id:e.id,args:o};if(e instanceof HTMLInputElement?(a.value=e.value,(e.type==="checkbox"||e.type==="radio")&&(a.checked=e.checked)):(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(a.value=e.value),r instanceof KeyboardEvent&&(a.key=r.key,a.keyCode=r.keyCode),t==="submit"&&e instanceof HTMLFormElement){let l=new FormData(e),p={};l.forEach((y,g)=>{y instanceof File||(p[g]=y.toString())}),a.formData=p}this.app.sendEvent(n,a)}parseDuration(e,t){let n=e.findIndex(a=>a.startsWith("debounce")),r=e.findIndex(a=>a.startsWith("throttle")),s=n!==-1?n:r;if(s!==-1&&e[s+1]){let a=e[s+1];if(a.endsWith("ms")){let l=parseInt(a);if(!isNaN(l))return l}}let o=e[s];if(o&&o.includes("-")){let a=o.split("-"),l=parseInt(a[1]);if(!isNaN(l))return l}return t}getUniqueId(e){return e.id||(e.id="pywire-uid-"+Math.random().toString(36).substr(2,9)),e.id}getArgs(e){let t={};if(e instanceof HTMLElement){for(let n in e.dataset)if(n.startsWith("arg"))try{t[n]=JSON.parse(e.dataset[n]||"null")}catch{t[n]=e.dataset[n]}}return t}};var zt={autoInit:!0,enableWebTransport:!0,enableWebSocket:!0,enableHTTP:!0,debug:!1},O=class{constructor(e={}){this.initialized=!1;this.siblingPaths=[];this.pathRegexes=[];this.pjaxEnabled=!1;this.isConnected=!1;this.config={...zt,...e},this.transport=new _(this.config),this.updater=new T(this.config.debug),this.eventHandler=new me(this)}getConfig(){return this.config}async init(){if(!this.initialized){this.initialized=!0,this.transport.onMessage(e=>this.handleMessage(e)),this.transport.onStatusChange(e=>this.handleStatusChange(e));try{await this.transport.connect()}catch(e){console.error("PyWire: Failed to connect:",e)}this.loadSPAMetadata(),this.setupSPANavigation(),this.eventHandler.init(),console.log(`PyWire: Initialized (transport: ${this.transport.getActiveTransport()}, spa_paths: ${this.siblingPaths.length}, pjax: ${this.pjaxEnabled})`)}}handleStatusChange(e){this.isConnected=e}loadSPAMetadata(){let e=document.getElementById("_pywire_spa_meta");if(e)try{let t=JSON.parse(e.textContent||"{}");this.siblingPaths=t.sibling_paths||[],this.pjaxEnabled=!!t.enable_pjax,t.debug!==void 0&&(this.config.debug=!!t.debug),this.pathRegexes=this.siblingPaths.map(n=>this.patternToRegex(n))}catch(t){console.warn("PyWire: Failed to parse SPA metadata",t)}}patternToRegex(e){let t=e.replace(/[.+?^${}()|[\]\\]/g,"\\$&");return t=t.replace(/:(\\w+)(:\\w+)?/g,"([^/]+)"),t=t.replace(/\\{(\\w+)(:\\w+)?\\}/g,"([^/]+)"),new RegExp(`^${t}$`)}isSiblingPath(e){return this.pathRegexes.some(t=>t.test(e))}setupSPANavigation(){window.addEventListener("popstate",()=>{this.sendRelocate(window.location.pathname+window.location.search)}),!(this.siblingPaths.length===0&&!this.pjaxEnabled)&&document.addEventListener("click",e=>{let t=e.target.closest("a[href]");if(!t||t.origin!==window.location.origin||t.hasAttribute("download")||t.target==="_blank")return;let n=!1;(this.pjaxEnabled||this.isSiblingPath(t.pathname))&&(n=!0),n&&(e.preventDefault(),this.navigateTo(t.pathname+t.search))})}navigateTo(e){if(!this.isConnected){console.warn("PyWire: Navigation blocked - Offline");return}history.pushState({},"",e),this.sendRelocate(e)}sendRelocate(e){let t={type:"relocate",path:e};this.transport.send(t)}sendEvent(e,t){let n={type:"event",handler:e,path:window.location.pathname+window.location.search,data:t};this.transport.send(n)}async handleMessage(e){switch(e.type){case"update":e.regions&&e.regions.length>0?e.regions.forEach(t=>{this.updater.updateRegion(t.region,t.html)}):e.html&&this.updater.update(e.html);break;case"reload":console.log("PyWire: Reloading..."),window.location.reload();break;case"error":console.error("PyWire: Server error:",e.error);break;case"error_trace":console.error("PyWire: Error:",e.error);break;case"console":if(e.lines&&e.lines.length>0){let t="PyWire Server:",n=e.lines.join(`
3
+ `);e.level==="error"?console.error(t,n):e.level==="warn"?console.warn(t,n):console.log(t,n)}break;case"init":console.log(`PyWire Client v${Fe} \u2022 Server v${e.version}`);break;default:console.warn("PyWire: Unknown message type",e)}}getTransport(){return this.transport.getActiveTransport()}disconnect(){this.transport.disconnect()}};var V=class{constructor(){this.element=null;this.create()}create(){this.element=document.createElement("div"),this.element.style.cssText=`
4
4
  position: fixed;
5
5
  bottom: 20px;
6
6
  right: 20px;
@@ -17,4 +17,4 @@
17
17
  `,document.body.appendChild(this.element)}update(e){this.element&&(e?this.element.style.display="none":(this.element.textContent="Connection Lost - Reconnecting...",this.element.style.display="block",this.element.style.backgroundColor="rgba(0, 0, 0, 0.8)"))}showNavigationBlocked(){this.element&&(this.element.style.backgroundColor="rgba(200, 0, 0, 0.9)",this.element.textContent="Cannot navigate - Offline",this.element.style.display="block",setTimeout(()=>{this.element&&(this.element.style.backgroundColor="rgba(0, 0, 0, 0.8)")},1500))}};var X=class{constructor(){this.loadedSources=new Set}getVirtualUrl(e){let t=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""),n=e.split(/[/\\]/).pop()||"unknown";return`${window.location.origin}/_pywire/file/${t}/${n}`}async handle(e,t){let n=new Set;for(let o of t)this.loadedSources.has(o.filename)||n.add(o.filename);await Promise.all(Array.from(n).map(async o=>{try{let a=this.getVirtualUrl(o),l=`/_pywire/source?path=${encodeURIComponent(o)}`,p=await fetch(l);if(p.ok){let g=`${await p.text()}
18
18
  //# sourceURL=${a}`;try{(0,eval)(g)}catch{}this.loadedSources.add(o)}this.loadedSources.add(o)}catch(a){console.warn("PyWire: Failed to load source",o,a)}}));let r=new Error(e),s=[`${r.name}: ${r.message}`];for(let o of t){let a=o.name||"<module>",l=this.getVirtualUrl(o.filename),p=o.colno??1;s.push(` at ${a} (${l}:${o.lineno}:${p})`)}r.stack=s.join(`
19
19
  `),console.error(r.stack)}};var G=class extends O{constructor(t={}){super(t);this.overlay=null;this.errorHandler=new X}async init(){this.overlay=new V,await super.init()}handleStatusChange(t){super.handleStatusChange(t),this.overlay&&this.overlay.update(t)}navigateTo(t){if(!this.isConnected){console.warn("PyWire: Navigation blocked - Offline"),this.overlay&&this.overlay.showNavigationBlocked();return}super.navigateTo(t)}async handleMessage(t){switch(t.type){case"error_trace":t.trace&&await this.errorHandler.handle(t.error||"Unknown Error",t.trace);return;case"console":if(t.lines&&t.lines.length>0){let n="PyWire Server:",r=t.lines.join(`
20
- `);t.level==="error"?(console.group(n+" Error"),console.error(r),console.groupEnd()):t.level==="warn"?(console.groupCollapsed(n+" Warning"),console.warn(r),console.groupEnd()):t.lines.length===1?console.log(n,r):(console.groupCollapsed(n+" Log"),console.log(r),console.groupEnd())}return;default:await super.handleMessage(t)}}};var Me=new G;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Me.init()):Me.init();return et(Ft);})();
20
+ `);t.level==="error"?(console.group(n+" Error"),console.error(r),console.groupEnd()):t.level==="warn"?(console.groupCollapsed(n+" Warning"),console.warn(r),console.groupEnd()):t.lines.length===1?console.log(n,r):(console.groupCollapsed(n+" Log"),console.log(r),console.groupEnd())}return;default:await super.handleMessage(t)}}};var Me=new G;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Me.init()):Me.init();return tt(_t);})();
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pywire
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: HTML-over-the-wire Python web framework
5
5
  Author-email: Reece Holmdahl <reece@pywire.dev>
6
6
  License-File: LICENSE
@@ -1,28 +1,29 @@
1
- pywire/__init__.py,sha256=Vnf8jVQs1hz9PGw9qtkvz_5SGhuLpasPeDFAuDixH7w,78
1
+ pywire/__init__.py,sha256=FhTrKeri1KINd1nybHtTg_XJrFpvCTwc3lzjyfIITRc,322
2
+ pywire/_version.py,sha256=rdxBMYpwzYxiWk08QbPLHSAxHoDfeKWwyaJIAM0lSic,704
2
3
  pywire/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
4
  pywire/cli/__init__.py,sha256=SNDCMbWNEM6_UNFDVB666srR-6Ak_HKLAX2Umy2O85I,18
4
5
  pywire/cli/generators.py,sha256=5tgXdhGJua9PhR8FkOxWaK9vHvOuFHdXOf3qamB7f3Q,1009
5
- pywire/cli/main.py,sha256=n3OdvmJB_MUB3obejxqOsBoqSwKt13CetrICsDFoa0U,9082
6
+ pywire/cli/main.py,sha256=Skd7DgQZPFyoXQcD40e41NIc9exMsiFYheR4iS73DHU,9116
6
7
  pywire/cli/tui.py,sha256=USInBXWUUc8BpihqTdtnRrPJtW3U9c7hFBMRup0mkGs,21714
7
8
  pywire/cli/validate.py,sha256=CPUQjFpoPcwpvAx3HvQ8Vq_w_suJ07n3oOhXKmKFwB4,769
8
9
  pywire/client/.prettierignore,sha256=TKRNv7wugFj9ig2T6SdoCZxMi_l9X-ninE8j72JdFzM,87
9
10
  pywire/client/.prettierrc,sha256=NwmnhqxkL9ATCDtQVOrgKBHtpN8L9niFT2j_SYmImzw,107
10
- pywire/client/build.mjs,sha256=DWkD9icyrJYWJR4MkX7lWU9u3-Ywq4raw2hPWVGuNoI,1944
11
+ pywire/client/build.mjs,sha256=5qIEQSonAeYGH-adWGvCyb7izzLGWPCQFu1zoF6XCUE,2081
11
12
  pywire/client/eslint.config.js,sha256=QxkvVaKeMnqSkPGDSjxQFvgfcyPWMbzct0zeMnpzQ4o,992
12
- pywire/client/package.json,sha256=K4pQlex2QKefhkANWbpoBZhpOoveRACp6BkjmWKMPsk,1130
13
+ pywire/client/package.json,sha256=ILTjsoKGwDL42_qTPfQ-S95hlV1timQQl94TqVyMPe8,1130
13
14
  pywire/client/pnpm-lock.yaml,sha256=fPLYdbqVkvTTX6QheVLy0_32RHwWn90M9v6pAfondKw,78073
14
- pywire/client/tsconfig.json,sha256=ZQkpS8rFm9HGjOrklve2YNuELCa4oqPnc5n02GoCuKQ,420
15
+ pywire/client/tsconfig.json,sha256=Eb903jAs8XbfiMJVE-BACg6D6YmPFvMQgl0D2C0R6k8,451
15
16
  pywire/client/vitest.config.ts,sha256=8W1fK9f_o1_8k46oi223IlZlKSSkiyM_EdVHDxmNNRs,393
16
17
  pywire/client/src/pywire.core.ts,sha256=iozCpa5g_N5xa7DNpUxW3M7Ov_NGNfxYnPdgmdisfMc,614
17
18
  pywire/client/src/pywire.dev.ts,sha256=G0FOQOimUY-J8H_cFmYSoc9tSrv6TvwiDKD3EcUA-Q0,674
18
- pywire/client/src/core/app.ts,sha256=WYfxWuSqVkA38VoPr8Cm59xXzW2tC_Bk62rgUopA36k,7401
19
+ pywire/client/src/core/app.ts,sha256=chH5OESOQ6IK8a46upgV9_WgCJ-XnEdsrBfLQxj4ffM,7579
19
20
  pywire/client/src/core/dom-updater.test.ts,sha256=PsiK0EL3P2JYdCpjitZoZpPc2oOi0DJqjV-uOEw8FWo,2571
20
21
  pywire/client/src/core/dom-updater.ts,sha256=rL80LVC__240bgU_PjpJDEnzmxx2wMDG_kqQK9Q6Q7A,9687
21
22
  pywire/client/src/core/index.ts,sha256=tT_R-J_TtM_Fovm103J2w6cB-oiQZc9r1wViZ7wuV3A,215
22
23
  pywire/client/src/core/transport-manager.test.ts,sha256=UbQrYgSXXj1j99mfCeO49rUU5U3grmNglfq28bQapbc,5534
23
24
  pywire/client/src/core/transport-manager.ts,sha256=6_SLITzqnhGnwwvwYG5opd_y-1kVcpQEjMa_pUbAUhg,4433
24
- pywire/client/src/core/transports/base.ts,sha256=fjgIUc1vQqPd3XHtbQ9S8rOKmDP8mrSg9fx4sIc_rqY,2825
25
- pywire/client/src/core/transports/http.ts,sha256=4ySlDl7KXgyJbnWF6wB_yxyuvJRBfXeB16PbFucZ3RY,4070
25
+ pywire/client/src/core/transports/base.ts,sha256=5NmF5J40VeQewFBtEtKD0xFatLP6wcOAv23cDkHc0jg,2920
26
+ pywire/client/src/core/transports/http.ts,sha256=Shrn8Lr1BNsFIGdEpByroUKNzz603ZofRzOSxp5jzjI,4192
26
27
  pywire/client/src/core/transports/index.ts,sha256=CZZPHIOR7bRQmtrbDAvIXXR8O58VI38sEonCVubEkZQ,295
27
28
  pywire/client/src/core/transports/websocket.ts,sha256=hVSykmEv2zCd1nITQfUHe1QhPiuIBOyYcB31iAH-r6c,2615
28
29
  pywire/client/src/core/transports/webtransport.ts,sha256=PCsfC2DKWDPzlssjP4z6QmkfI44Tuuy3PVIeJQSF80M,4077
@@ -49,7 +50,7 @@ pywire/compiler/attributes/form.py,sha256=5NC8PsBP7xfSKvyV5ANLShgSl6Eszq_fHZ5NG-
49
50
  pywire/compiler/attributes/loop.py,sha256=1UL_eBayJOxkDJrO1mhvNnA6UnVs7-riW51XFDqX6Tk,2621
50
51
  pywire/compiler/attributes/reactive.py,sha256=vz0TXRsp_mA9iNh1WcWpiA5g6ZpHNMYiUZB-i9B_tJE,1273
51
52
  pywire/compiler/codegen/__init__.py,sha256=RoW5xrX7mYycSxHPnS0-J46IwWGIiWF9EeJYkx1p4LI,121
52
- pywire/compiler/codegen/generator.py,sha256=dZlXjarfNJ7xL3qvSK9XlnsiU6i-IYjyT1Tttt3uqHw,92851
53
+ pywire/compiler/codegen/generator.py,sha256=VO8ymRK8wLS95MMFpV4o-Y7jr5OHCEcUacmh993OLjM,91592
53
54
  pywire/compiler/codegen/template.py,sha256=jvhmY9zrMymnq44RsDRqjCeifxNz_Z3d91026Hfw3QM,90713
54
55
  pywire/compiler/codegen/attributes/__init__.py,sha256=0wHMipg7PG2bpRjfmLkjIyYWwZTHbSJCevMoZSpmyFs,236
55
56
  pywire/compiler/codegen/attributes/base.py,sha256=pGZHCEZ6d3NTWwQMZ_ZKxofz2aEWDw5Kwm_axL7Gi2g,577
@@ -71,7 +72,7 @@ pywire/compiler/interpolation/jinja.py,sha256=HJEkRE0aB-YEiw7sZ6agS_zRUQlo19uj0b
71
72
  pywire/core/wire.py,sha256=ZgjoALx_B8i4ibt8rdY0XjNLVrfZcHLQh0urWl-iwIE,3899
72
73
  pywire/runtime/__init__.py,sha256=441hDvBWfYni7BtKlVXHEm2FWahK0MR3sIpkPkIE1zk,207
73
74
  pywire/runtime/aioquic_server.py,sha256=n9GuK81xtc6PUT54uMhqMlGXn8NrH-ryZ6Rl9qQWt7M,6685
74
- pywire/runtime/app.py,sha256=ebJ5SDDgJTk95R6AunWtJOi6RI4R4dJKCM31051hGy8,36217
75
+ pywire/runtime/app.py,sha256=vl9A-zXrMIgHpxIKVbmiUmaRAzzASG-Dc4yZFDBKoaA,36252
75
76
  pywire/runtime/compile_error_page.py,sha256=sqPTqG9dv_e2uBgYuAgOcDHx0D3Gwq2liFbBRrz4_iY,8205
76
77
  pywire/runtime/debug.py,sha256=6U-Ot1defe7eDXaAxNip4NtRPQjtjS9LNCUnk_pmmeQ,7416
77
78
  pywire/runtime/dev_server.py,sha256=DUVbktSBAujiwALxXG2iWLTdpjcAe80l44GPDJRdV6w,16018
@@ -81,8 +82,8 @@ pywire/runtime/error_renderer.py,sha256=HNS9seD5gX4jE3L4GPsJsyxvpMTiiNo3E43trUNi
81
82
  pywire/runtime/escape.py,sha256=w-_TcFLG0heyenDaituVx2oir_80WjGBWnnHZe5I8Wk,517
82
83
  pywire/runtime/files.py,sha256=RJjDhCaoKjk_x3B_71rA4EhqVjNLGU_fuwg4Cq894nY,1316
83
84
  pywire/runtime/helpers.py,sha256=jY3bDE7hHjPaVlLmWrGvQPDEtCYFU9Alt8j0dvSZgNQ,3039
84
- pywire/runtime/http_transport.py,sha256=uS3Or4uo581XSVqRB1VsEfa7Mbqr4RK5Rk0pGb-z4p8,9401
85
- pywire/runtime/loader.py,sha256=rKsHYb8dx-WkxBYClHR4Gztoy1N88kLYt5CCnvA0gIg,9664
85
+ pywire/runtime/http_transport.py,sha256=nkJ5Lgh9VQWS0RH2G24AQcueNjgroYTht7ZZkp68G8E,9469
86
+ pywire/runtime/loader.py,sha256=sDapm3yaO7BgkbGpYgQfq_Lf8cW_LqcFzQoZF7HQ19M,9763
86
87
  pywire/runtime/logging.py,sha256=wEdxro6YxvdnjwALwzMr60As2JMj_J4DIsSL8JZScvM,2286
87
88
  pywire/runtime/page.py,sha256=tEKPUfQFQpw3T20sWsjlXLfmDr2TlNmesc_jDwcK748,14288
88
89
  pywire/runtime/pydantic_integration.py,sha256=Fwu45Km5SHS10ZqIxCK-Ps8hBPlVY6rHzkkP7Mh8KEs,1800
@@ -91,16 +92,16 @@ pywire/runtime/server.py,sha256=hzG1NACfjasTmNZd-imORTLNxMCD-JYgkfjIRyQ3GJE,746
91
92
  pywire/runtime/style_collector.py,sha256=H1Crk1DO1wfch2Ed4i4_sHANH5QX_HGGGlaJr7MRiIY,1147
92
93
  pywire/runtime/upload_manager.py,sha256=n7WRwpzHqnW1CZsoshxq7YumNMFrG7Hs5CiEHP-0W4k,2346
93
94
  pywire/runtime/validation.py,sha256=Y1_nI_dFKy3_7aXN-gCubUBhBlzgEtNEkdS1DH81tEI,16199
94
- pywire/runtime/websocket.py,sha256=7sNawtxC0l_eJBEjI80DGnUqei7Ol0RX8Y7Yz3_wNxw,26949
95
+ pywire/runtime/websocket.py,sha256=QBZNRbe4U4MwLhkZpzBkZU2xQKgnzxQ6HTm2VYmtmqs,27123
95
96
  pywire/runtime/webtransport_handler.py,sha256=GZIzTlv5IyEmIq2eumxFTu1XgWaPkiRFujG1vBjQNsE,7841
96
97
  pywire/templates/error/404.html,sha256=cZavWjs-aXoSRpEy-8D0rulP7g5Sn31MsIXmkZUQnnA,256
97
98
  pywire/templates/error/500.html,sha256=545CPh1XyhN-zdSAD8R-6Cuos6hLC--TXJy4EQHrpjM,1282
98
99
  pywire/templates/error/base.html,sha256=nlBlBIg-VFAWtTLWky7c2igNVsFjj9M8Wyw3v3_4KGQ,4863
99
100
  pywire/templates/error/compile_error.html,sha256=FMqU3HXYWMeiXG3eTAysNpAHH-AOPx2Apbz8f_HBvtw,837
100
- pywire/static/pywire.core.min.js,sha256=SGZYyI_NgoUphlWWJ_WM9_S3Ix-2-6JykU3frlhW_6A,47482
101
- pywire/static/pywire.dev.min.js,sha256=v7C7Gkh-0eernYfHGvqzTFdjCqiXLt4EQSvPl2l6-oM,50520
102
- pywire-0.1.3.dist-info/METADATA,sha256=xotwogdm8P9eqUWNFqrPYrsQMUUeFkEVgkLBgerzpAo,2386
103
- pywire-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
104
- pywire-0.1.3.dist-info/entry_points.txt,sha256=L0n4cNLZIocOo6lG05uOoUN1GHgA_uQOHvapDAhULBI,47
105
- pywire-0.1.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
106
- pywire-0.1.3.dist-info/RECORD,,
101
+ pywire/static/pywire.core.min.js,sha256=AwgCJLT-Hsa8lkHtVI_I0waCcW1dn3iVKzID-BetCxs,47642
102
+ pywire/static/pywire.dev.min.js,sha256=NDseJjdPSqR9j_C6Gktb8bzSh9Gnb-5k45A0dZKLg3g,50680
103
+ pywire-0.1.5.dist-info/METADATA,sha256=mqWHpHe734njTopnGbho1vZRb0j9rHRWYPUDJXF1ahU,2386
104
+ pywire-0.1.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
105
+ pywire-0.1.5.dist-info/entry_points.txt,sha256=L0n4cNLZIocOo6lG05uOoUN1GHgA_uQOHvapDAhULBI,47
106
+ pywire-0.1.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
107
+ pywire-0.1.5.dist-info/RECORD,,
File without changes