termbridge 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js ADDED
@@ -0,0 +1,2819 @@
1
+ #!/usr/bin/env node
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+
28
+ // ../node_modules/react/cjs/react-jsx-runtime.production.js
29
+ var require_react_jsx_runtime_production = __commonJS({
30
+ "../node_modules/react/cjs/react-jsx-runtime.production.js"(exports) {
31
+ "use strict";
32
+ var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element");
33
+ var REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
34
+ function jsxProd(type, config, maybeKey) {
35
+ var key = null;
36
+ void 0 !== maybeKey && (key = "" + maybeKey);
37
+ void 0 !== config.key && (key = "" + config.key);
38
+ if ("key" in config) {
39
+ maybeKey = {};
40
+ for (var propName in config)
41
+ "key" !== propName && (maybeKey[propName] = config[propName]);
42
+ } else maybeKey = config;
43
+ config = maybeKey.ref;
44
+ return {
45
+ $$typeof: REACT_ELEMENT_TYPE,
46
+ type,
47
+ key,
48
+ ref: void 0 !== config ? config : null,
49
+ props: maybeKey
50
+ };
51
+ }
52
+ exports.Fragment = REACT_FRAGMENT_TYPE;
53
+ exports.jsx = jsxProd;
54
+ exports.jsxs = jsxProd;
55
+ }
56
+ });
57
+
58
+ // ../node_modules/react/cjs/react.production.js
59
+ var require_react_production = __commonJS({
60
+ "../node_modules/react/cjs/react.production.js"(exports) {
61
+ "use strict";
62
+ var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element");
63
+ var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
64
+ var REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
65
+ var REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode");
66
+ var REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler");
67
+ var REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer");
68
+ var REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context");
69
+ var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
70
+ var REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
71
+ var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
72
+ var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
73
+ var REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity");
74
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
75
+ function getIteratorFn(maybeIterable) {
76
+ if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
77
+ maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
78
+ return "function" === typeof maybeIterable ? maybeIterable : null;
79
+ }
80
+ var ReactNoopUpdateQueue = {
81
+ isMounted: function() {
82
+ return false;
83
+ },
84
+ enqueueForceUpdate: function() {
85
+ },
86
+ enqueueReplaceState: function() {
87
+ },
88
+ enqueueSetState: function() {
89
+ }
90
+ };
91
+ var assign = Object.assign;
92
+ var emptyObject = {};
93
+ function Component(props, context, updater) {
94
+ this.props = props;
95
+ this.context = context;
96
+ this.refs = emptyObject;
97
+ this.updater = updater || ReactNoopUpdateQueue;
98
+ }
99
+ Component.prototype.isReactComponent = {};
100
+ Component.prototype.setState = function(partialState, callback) {
101
+ if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
102
+ throw Error(
103
+ "takes an object of state variables to update or a function which returns an object of state variables."
104
+ );
105
+ this.updater.enqueueSetState(this, partialState, callback, "setState");
106
+ };
107
+ Component.prototype.forceUpdate = function(callback) {
108
+ this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
109
+ };
110
+ function ComponentDummy() {
111
+ }
112
+ ComponentDummy.prototype = Component.prototype;
113
+ function PureComponent(props, context, updater) {
114
+ this.props = props;
115
+ this.context = context;
116
+ this.refs = emptyObject;
117
+ this.updater = updater || ReactNoopUpdateQueue;
118
+ }
119
+ var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
120
+ pureComponentPrototype.constructor = PureComponent;
121
+ assign(pureComponentPrototype, Component.prototype);
122
+ pureComponentPrototype.isPureReactComponent = true;
123
+ var isArrayImpl = Array.isArray;
124
+ function noop() {
125
+ }
126
+ var ReactSharedInternals = { H: null, A: null, T: null, S: null };
127
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
128
+ function ReactElement(type, key, props) {
129
+ var refProp = props.ref;
130
+ return {
131
+ $$typeof: REACT_ELEMENT_TYPE,
132
+ type,
133
+ key,
134
+ ref: void 0 !== refProp ? refProp : null,
135
+ props
136
+ };
137
+ }
138
+ function cloneAndReplaceKey(oldElement, newKey) {
139
+ return ReactElement(oldElement.type, newKey, oldElement.props);
140
+ }
141
+ function isValidElement(object) {
142
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
143
+ }
144
+ function escape(key) {
145
+ var escaperLookup = { "=": "=0", ":": "=2" };
146
+ return "$" + key.replace(/[=:]/g, function(match) {
147
+ return escaperLookup[match];
148
+ });
149
+ }
150
+ var userProvidedKeyEscapeRegex = /\/+/g;
151
+ function getElementKey(element, index) {
152
+ return "object" === typeof element && null !== element && null != element.key ? escape("" + element.key) : index.toString(36);
153
+ }
154
+ function resolveThenable(thenable) {
155
+ switch (thenable.status) {
156
+ case "fulfilled":
157
+ return thenable.value;
158
+ case "rejected":
159
+ throw thenable.reason;
160
+ default:
161
+ switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
162
+ function(fulfilledValue) {
163
+ "pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
164
+ },
165
+ function(error) {
166
+ "pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
167
+ }
168
+ )), thenable.status) {
169
+ case "fulfilled":
170
+ return thenable.value;
171
+ case "rejected":
172
+ throw thenable.reason;
173
+ }
174
+ }
175
+ throw thenable;
176
+ }
177
+ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
178
+ var type = typeof children;
179
+ if ("undefined" === type || "boolean" === type) children = null;
180
+ var invokeCallback = false;
181
+ if (null === children) invokeCallback = true;
182
+ else
183
+ switch (type) {
184
+ case "bigint":
185
+ case "string":
186
+ case "number":
187
+ invokeCallback = true;
188
+ break;
189
+ case "object":
190
+ switch (children.$$typeof) {
191
+ case REACT_ELEMENT_TYPE:
192
+ case REACT_PORTAL_TYPE:
193
+ invokeCallback = true;
194
+ break;
195
+ case REACT_LAZY_TYPE:
196
+ return invokeCallback = children._init, mapIntoArray(
197
+ invokeCallback(children._payload),
198
+ array,
199
+ escapedPrefix,
200
+ nameSoFar,
201
+ callback
202
+ );
203
+ }
204
+ }
205
+ if (invokeCallback)
206
+ return callback = callback(children), invokeCallback = "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar, isArrayImpl(callback) ? (escapedPrefix = "", null != invokeCallback && (escapedPrefix = invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
207
+ return c;
208
+ })) : null != callback && (isValidElement(callback) && (callback = cloneAndReplaceKey(
209
+ callback,
210
+ escapedPrefix + (null == callback.key || children && children.key === callback.key ? "" : ("" + callback.key).replace(
211
+ userProvidedKeyEscapeRegex,
212
+ "$&/"
213
+ ) + "/") + invokeCallback
214
+ )), array.push(callback)), 1;
215
+ invokeCallback = 0;
216
+ var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
217
+ if (isArrayImpl(children))
218
+ for (var i = 0; i < children.length; i++)
219
+ nameSoFar = children[i], type = nextNamePrefix + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
220
+ nameSoFar,
221
+ array,
222
+ escapedPrefix,
223
+ type,
224
+ callback
225
+ );
226
+ else if (i = getIteratorFn(children), "function" === typeof i)
227
+ for (children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
228
+ nameSoFar = nameSoFar.value, type = nextNamePrefix + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
229
+ nameSoFar,
230
+ array,
231
+ escapedPrefix,
232
+ type,
233
+ callback
234
+ );
235
+ else if ("object" === type) {
236
+ if ("function" === typeof children.then)
237
+ return mapIntoArray(
238
+ resolveThenable(children),
239
+ array,
240
+ escapedPrefix,
241
+ nameSoFar,
242
+ callback
243
+ );
244
+ array = String(children);
245
+ throw Error(
246
+ "Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
247
+ );
248
+ }
249
+ return invokeCallback;
250
+ }
251
+ function mapChildren(children, func, context) {
252
+ if (null == children) return children;
253
+ var result = [], count = 0;
254
+ mapIntoArray(children, result, "", "", function(child) {
255
+ return func.call(context, child, count++);
256
+ });
257
+ return result;
258
+ }
259
+ function lazyInitializer(payload) {
260
+ if (-1 === payload._status) {
261
+ var ctor = payload._result;
262
+ ctor = ctor();
263
+ ctor.then(
264
+ function(moduleObject) {
265
+ if (0 === payload._status || -1 === payload._status)
266
+ payload._status = 1, payload._result = moduleObject;
267
+ },
268
+ function(error) {
269
+ if (0 === payload._status || -1 === payload._status)
270
+ payload._status = 2, payload._result = error;
271
+ }
272
+ );
273
+ -1 === payload._status && (payload._status = 0, payload._result = ctor);
274
+ }
275
+ if (1 === payload._status) return payload._result.default;
276
+ throw payload._result;
277
+ }
278
+ var reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
279
+ if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
280
+ var event = new window.ErrorEvent("error", {
281
+ bubbles: true,
282
+ cancelable: true,
283
+ message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
284
+ error
285
+ });
286
+ if (!window.dispatchEvent(event)) return;
287
+ } else if ("object" === typeof process && "function" === typeof process.emit) {
288
+ process.emit("uncaughtException", error);
289
+ return;
290
+ }
291
+ console.error(error);
292
+ };
293
+ var Children = {
294
+ map: mapChildren,
295
+ forEach: function(children, forEachFunc, forEachContext) {
296
+ mapChildren(
297
+ children,
298
+ function() {
299
+ forEachFunc.apply(this, arguments);
300
+ },
301
+ forEachContext
302
+ );
303
+ },
304
+ count: function(children) {
305
+ var n = 0;
306
+ mapChildren(children, function() {
307
+ n++;
308
+ });
309
+ return n;
310
+ },
311
+ toArray: function(children) {
312
+ return mapChildren(children, function(child) {
313
+ return child;
314
+ }) || [];
315
+ },
316
+ only: function(children) {
317
+ if (!isValidElement(children))
318
+ throw Error(
319
+ "React.Children.only expected to receive a single React element child."
320
+ );
321
+ return children;
322
+ }
323
+ };
324
+ exports.Activity = REACT_ACTIVITY_TYPE;
325
+ exports.Children = Children;
326
+ exports.Component = Component;
327
+ exports.Fragment = REACT_FRAGMENT_TYPE;
328
+ exports.Profiler = REACT_PROFILER_TYPE;
329
+ exports.PureComponent = PureComponent;
330
+ exports.StrictMode = REACT_STRICT_MODE_TYPE;
331
+ exports.Suspense = REACT_SUSPENSE_TYPE;
332
+ exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
333
+ exports.__COMPILER_RUNTIME = {
334
+ __proto__: null,
335
+ c: function(size) {
336
+ return ReactSharedInternals.H.useMemoCache(size);
337
+ }
338
+ };
339
+ exports.cache = function(fn) {
340
+ return function() {
341
+ return fn.apply(null, arguments);
342
+ };
343
+ };
344
+ exports.cacheSignal = function() {
345
+ return null;
346
+ };
347
+ exports.cloneElement = function(element, config, children) {
348
+ if (null === element || void 0 === element)
349
+ throw Error(
350
+ "The argument must be a React element, but you passed " + element + "."
351
+ );
352
+ var props = assign({}, element.props), key = element.key;
353
+ if (null != config)
354
+ for (propName in void 0 !== config.key && (key = "" + config.key), config)
355
+ !hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
356
+ var propName = arguments.length - 2;
357
+ if (1 === propName) props.children = children;
358
+ else if (1 < propName) {
359
+ for (var childArray = Array(propName), i = 0; i < propName; i++)
360
+ childArray[i] = arguments[i + 2];
361
+ props.children = childArray;
362
+ }
363
+ return ReactElement(element.type, key, props);
364
+ };
365
+ exports.createContext = function(defaultValue) {
366
+ defaultValue = {
367
+ $$typeof: REACT_CONTEXT_TYPE,
368
+ _currentValue: defaultValue,
369
+ _currentValue2: defaultValue,
370
+ _threadCount: 0,
371
+ Provider: null,
372
+ Consumer: null
373
+ };
374
+ defaultValue.Provider = defaultValue;
375
+ defaultValue.Consumer = {
376
+ $$typeof: REACT_CONSUMER_TYPE,
377
+ _context: defaultValue
378
+ };
379
+ return defaultValue;
380
+ };
381
+ exports.createElement = function(type, config, children) {
382
+ var propName, props = {}, key = null;
383
+ if (null != config)
384
+ for (propName in void 0 !== config.key && (key = "" + config.key), config)
385
+ hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (props[propName] = config[propName]);
386
+ var childrenLength = arguments.length - 2;
387
+ if (1 === childrenLength) props.children = children;
388
+ else if (1 < childrenLength) {
389
+ for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
390
+ childArray[i] = arguments[i + 2];
391
+ props.children = childArray;
392
+ }
393
+ if (type && type.defaultProps)
394
+ for (propName in childrenLength = type.defaultProps, childrenLength)
395
+ void 0 === props[propName] && (props[propName] = childrenLength[propName]);
396
+ return ReactElement(type, key, props);
397
+ };
398
+ exports.createRef = function() {
399
+ return { current: null };
400
+ };
401
+ exports.forwardRef = function(render2) {
402
+ return { $$typeof: REACT_FORWARD_REF_TYPE, render: render2 };
403
+ };
404
+ exports.isValidElement = isValidElement;
405
+ exports.lazy = function(ctor) {
406
+ return {
407
+ $$typeof: REACT_LAZY_TYPE,
408
+ _payload: { _status: -1, _result: ctor },
409
+ _init: lazyInitializer
410
+ };
411
+ };
412
+ exports.memo = function(type, compare) {
413
+ return {
414
+ $$typeof: REACT_MEMO_TYPE,
415
+ type,
416
+ compare: void 0 === compare ? null : compare
417
+ };
418
+ };
419
+ exports.startTransition = function(scope) {
420
+ var prevTransition = ReactSharedInternals.T, currentTransition = {};
421
+ ReactSharedInternals.T = currentTransition;
422
+ try {
423
+ var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
424
+ null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
425
+ "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop, reportGlobalError);
426
+ } catch (error) {
427
+ reportGlobalError(error);
428
+ } finally {
429
+ null !== prevTransition && null !== currentTransition.types && (prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
430
+ }
431
+ };
432
+ exports.unstable_useCacheRefresh = function() {
433
+ return ReactSharedInternals.H.useCacheRefresh();
434
+ };
435
+ exports.use = function(usable) {
436
+ return ReactSharedInternals.H.use(usable);
437
+ };
438
+ exports.useActionState = function(action, initialState, permalink) {
439
+ return ReactSharedInternals.H.useActionState(action, initialState, permalink);
440
+ };
441
+ exports.useCallback = function(callback, deps) {
442
+ return ReactSharedInternals.H.useCallback(callback, deps);
443
+ };
444
+ exports.useContext = function(Context) {
445
+ return ReactSharedInternals.H.useContext(Context);
446
+ };
447
+ exports.useDebugValue = function() {
448
+ };
449
+ exports.useDeferredValue = function(value, initialValue) {
450
+ return ReactSharedInternals.H.useDeferredValue(value, initialValue);
451
+ };
452
+ exports.useEffect = function(create, deps) {
453
+ return ReactSharedInternals.H.useEffect(create, deps);
454
+ };
455
+ exports.useEffectEvent = function(callback) {
456
+ return ReactSharedInternals.H.useEffectEvent(callback);
457
+ };
458
+ exports.useId = function() {
459
+ return ReactSharedInternals.H.useId();
460
+ };
461
+ exports.useImperativeHandle = function(ref, create, deps) {
462
+ return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
463
+ };
464
+ exports.useInsertionEffect = function(create, deps) {
465
+ return ReactSharedInternals.H.useInsertionEffect(create, deps);
466
+ };
467
+ exports.useLayoutEffect = function(create, deps) {
468
+ return ReactSharedInternals.H.useLayoutEffect(create, deps);
469
+ };
470
+ exports.useMemo = function(create, deps) {
471
+ return ReactSharedInternals.H.useMemo(create, deps);
472
+ };
473
+ exports.useOptimistic = function(passthrough, reducer) {
474
+ return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
475
+ };
476
+ exports.useReducer = function(reducer, initialArg, init) {
477
+ return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
478
+ };
479
+ exports.useRef = function(initialValue) {
480
+ return ReactSharedInternals.H.useRef(initialValue);
481
+ };
482
+ exports.useState = function(initialState) {
483
+ return ReactSharedInternals.H.useState(initialState);
484
+ };
485
+ exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
486
+ return ReactSharedInternals.H.useSyncExternalStore(
487
+ subscribe,
488
+ getSnapshot,
489
+ getServerSnapshot
490
+ );
491
+ };
492
+ exports.useTransition = function() {
493
+ return ReactSharedInternals.H.useTransition();
494
+ };
495
+ exports.version = "19.2.3";
496
+ }
497
+ });
498
+
499
+ // ../node_modules/react/cjs/react.development.js
500
+ var require_react_development = __commonJS({
501
+ "../node_modules/react/cjs/react.development.js"(exports, module) {
502
+ "use strict";
503
+ "production" !== process.env.NODE_ENV && (function() {
504
+ function defineDeprecationWarning(methodName, info) {
505
+ Object.defineProperty(Component.prototype, methodName, {
506
+ get: function() {
507
+ console.warn(
508
+ "%s(...) is deprecated in plain JavaScript React classes. %s",
509
+ info[0],
510
+ info[1]
511
+ );
512
+ }
513
+ });
514
+ }
515
+ function getIteratorFn(maybeIterable) {
516
+ if (null === maybeIterable || "object" !== typeof maybeIterable)
517
+ return null;
518
+ maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
519
+ return "function" === typeof maybeIterable ? maybeIterable : null;
520
+ }
521
+ function warnNoop(publicInstance, callerName) {
522
+ publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
523
+ var warningKey = publicInstance + "." + callerName;
524
+ didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error(
525
+ "Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
526
+ callerName,
527
+ publicInstance
528
+ ), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
529
+ }
530
+ function Component(props, context, updater) {
531
+ this.props = props;
532
+ this.context = context;
533
+ this.refs = emptyObject;
534
+ this.updater = updater || ReactNoopUpdateQueue;
535
+ }
536
+ function ComponentDummy() {
537
+ }
538
+ function PureComponent(props, context, updater) {
539
+ this.props = props;
540
+ this.context = context;
541
+ this.refs = emptyObject;
542
+ this.updater = updater || ReactNoopUpdateQueue;
543
+ }
544
+ function noop() {
545
+ }
546
+ function testStringCoercion(value) {
547
+ return "" + value;
548
+ }
549
+ function checkKeyStringCoercion(value) {
550
+ try {
551
+ testStringCoercion(value);
552
+ var JSCompiler_inline_result = false;
553
+ } catch (e) {
554
+ JSCompiler_inline_result = true;
555
+ }
556
+ if (JSCompiler_inline_result) {
557
+ JSCompiler_inline_result = console;
558
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
559
+ var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
560
+ JSCompiler_temp_const.call(
561
+ JSCompiler_inline_result,
562
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
563
+ JSCompiler_inline_result$jscomp$0
564
+ );
565
+ return testStringCoercion(value);
566
+ }
567
+ }
568
+ function getComponentNameFromType(type) {
569
+ if (null == type) return null;
570
+ if ("function" === typeof type)
571
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
572
+ if ("string" === typeof type) return type;
573
+ switch (type) {
574
+ case REACT_FRAGMENT_TYPE:
575
+ return "Fragment";
576
+ case REACT_PROFILER_TYPE:
577
+ return "Profiler";
578
+ case REACT_STRICT_MODE_TYPE:
579
+ return "StrictMode";
580
+ case REACT_SUSPENSE_TYPE:
581
+ return "Suspense";
582
+ case REACT_SUSPENSE_LIST_TYPE:
583
+ return "SuspenseList";
584
+ case REACT_ACTIVITY_TYPE:
585
+ return "Activity";
586
+ }
587
+ if ("object" === typeof type)
588
+ switch ("number" === typeof type.tag && console.error(
589
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
590
+ ), type.$$typeof) {
591
+ case REACT_PORTAL_TYPE:
592
+ return "Portal";
593
+ case REACT_CONTEXT_TYPE:
594
+ return type.displayName || "Context";
595
+ case REACT_CONSUMER_TYPE:
596
+ return (type._context.displayName || "Context") + ".Consumer";
597
+ case REACT_FORWARD_REF_TYPE:
598
+ var innerType = type.render;
599
+ type = type.displayName;
600
+ type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
601
+ return type;
602
+ case REACT_MEMO_TYPE:
603
+ return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
604
+ case REACT_LAZY_TYPE:
605
+ innerType = type._payload;
606
+ type = type._init;
607
+ try {
608
+ return getComponentNameFromType(type(innerType));
609
+ } catch (x) {
610
+ }
611
+ }
612
+ return null;
613
+ }
614
+ function getTaskName(type) {
615
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
616
+ if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
617
+ return "<...>";
618
+ try {
619
+ var name = getComponentNameFromType(type);
620
+ return name ? "<" + name + ">" : "<...>";
621
+ } catch (x) {
622
+ return "<...>";
623
+ }
624
+ }
625
+ function getOwner() {
626
+ var dispatcher = ReactSharedInternals.A;
627
+ return null === dispatcher ? null : dispatcher.getOwner();
628
+ }
629
+ function UnknownOwner() {
630
+ return Error("react-stack-top-frame");
631
+ }
632
+ function hasValidKey(config) {
633
+ if (hasOwnProperty.call(config, "key")) {
634
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
635
+ if (getter && getter.isReactWarning) return false;
636
+ }
637
+ return void 0 !== config.key;
638
+ }
639
+ function defineKeyPropWarningGetter(props, displayName) {
640
+ function warnAboutAccessingKey() {
641
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
642
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
643
+ displayName
644
+ ));
645
+ }
646
+ warnAboutAccessingKey.isReactWarning = true;
647
+ Object.defineProperty(props, "key", {
648
+ get: warnAboutAccessingKey,
649
+ configurable: true
650
+ });
651
+ }
652
+ function elementRefGetterWithDeprecationWarning() {
653
+ var componentName = getComponentNameFromType(this.type);
654
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
655
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
656
+ ));
657
+ componentName = this.props.ref;
658
+ return void 0 !== componentName ? componentName : null;
659
+ }
660
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
661
+ var refProp = props.ref;
662
+ type = {
663
+ $$typeof: REACT_ELEMENT_TYPE,
664
+ type,
665
+ key,
666
+ props,
667
+ _owner: owner
668
+ };
669
+ null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
670
+ enumerable: false,
671
+ get: elementRefGetterWithDeprecationWarning
672
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
673
+ type._store = {};
674
+ Object.defineProperty(type._store, "validated", {
675
+ configurable: false,
676
+ enumerable: false,
677
+ writable: true,
678
+ value: 0
679
+ });
680
+ Object.defineProperty(type, "_debugInfo", {
681
+ configurable: false,
682
+ enumerable: false,
683
+ writable: true,
684
+ value: null
685
+ });
686
+ Object.defineProperty(type, "_debugStack", {
687
+ configurable: false,
688
+ enumerable: false,
689
+ writable: true,
690
+ value: debugStack
691
+ });
692
+ Object.defineProperty(type, "_debugTask", {
693
+ configurable: false,
694
+ enumerable: false,
695
+ writable: true,
696
+ value: debugTask
697
+ });
698
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
699
+ return type;
700
+ }
701
+ function cloneAndReplaceKey(oldElement, newKey) {
702
+ newKey = ReactElement(
703
+ oldElement.type,
704
+ newKey,
705
+ oldElement.props,
706
+ oldElement._owner,
707
+ oldElement._debugStack,
708
+ oldElement._debugTask
709
+ );
710
+ oldElement._store && (newKey._store.validated = oldElement._store.validated);
711
+ return newKey;
712
+ }
713
+ function validateChildKeys(node) {
714
+ isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
715
+ }
716
+ function isValidElement(object) {
717
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
718
+ }
719
+ function escape(key) {
720
+ var escaperLookup = { "=": "=0", ":": "=2" };
721
+ return "$" + key.replace(/[=:]/g, function(match) {
722
+ return escaperLookup[match];
723
+ });
724
+ }
725
+ function getElementKey(element, index) {
726
+ return "object" === typeof element && null !== element && null != element.key ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
727
+ }
728
+ function resolveThenable(thenable) {
729
+ switch (thenable.status) {
730
+ case "fulfilled":
731
+ return thenable.value;
732
+ case "rejected":
733
+ throw thenable.reason;
734
+ default:
735
+ switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
736
+ function(fulfilledValue) {
737
+ "pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
738
+ },
739
+ function(error) {
740
+ "pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
741
+ }
742
+ )), thenable.status) {
743
+ case "fulfilled":
744
+ return thenable.value;
745
+ case "rejected":
746
+ throw thenable.reason;
747
+ }
748
+ }
749
+ throw thenable;
750
+ }
751
+ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
752
+ var type = typeof children;
753
+ if ("undefined" === type || "boolean" === type) children = null;
754
+ var invokeCallback = false;
755
+ if (null === children) invokeCallback = true;
756
+ else
757
+ switch (type) {
758
+ case "bigint":
759
+ case "string":
760
+ case "number":
761
+ invokeCallback = true;
762
+ break;
763
+ case "object":
764
+ switch (children.$$typeof) {
765
+ case REACT_ELEMENT_TYPE:
766
+ case REACT_PORTAL_TYPE:
767
+ invokeCallback = true;
768
+ break;
769
+ case REACT_LAZY_TYPE:
770
+ return invokeCallback = children._init, mapIntoArray(
771
+ invokeCallback(children._payload),
772
+ array,
773
+ escapedPrefix,
774
+ nameSoFar,
775
+ callback
776
+ );
777
+ }
778
+ }
779
+ if (invokeCallback) {
780
+ invokeCallback = children;
781
+ callback = callback(invokeCallback);
782
+ var childKey = "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
783
+ isArrayImpl(callback) ? (escapedPrefix = "", null != childKey && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
784
+ return c;
785
+ })) : null != callback && (isValidElement(callback) && (null != callback.key && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(
786
+ callback,
787
+ escapedPrefix + (null == callback.key || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(
788
+ userProvidedKeyEscapeRegex,
789
+ "$&/"
790
+ ) + "/") + childKey
791
+ ), "" !== nameSoFar && null != invokeCallback && isValidElement(invokeCallback) && null == invokeCallback.key && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
792
+ return 1;
793
+ }
794
+ invokeCallback = 0;
795
+ childKey = "" === nameSoFar ? "." : nameSoFar + ":";
796
+ if (isArrayImpl(children))
797
+ for (var i = 0; i < children.length; i++)
798
+ nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
799
+ nameSoFar,
800
+ array,
801
+ escapedPrefix,
802
+ type,
803
+ callback
804
+ );
805
+ else if (i = getIteratorFn(children), "function" === typeof i)
806
+ for (i === children.entries && (didWarnAboutMaps || console.warn(
807
+ "Using Maps as children is not supported. Use an array of keyed ReactElements instead."
808
+ ), didWarnAboutMaps = true), children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
809
+ nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
810
+ nameSoFar,
811
+ array,
812
+ escapedPrefix,
813
+ type,
814
+ callback
815
+ );
816
+ else if ("object" === type) {
817
+ if ("function" === typeof children.then)
818
+ return mapIntoArray(
819
+ resolveThenable(children),
820
+ array,
821
+ escapedPrefix,
822
+ nameSoFar,
823
+ callback
824
+ );
825
+ array = String(children);
826
+ throw Error(
827
+ "Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
828
+ );
829
+ }
830
+ return invokeCallback;
831
+ }
832
+ function mapChildren(children, func, context) {
833
+ if (null == children) return children;
834
+ var result = [], count = 0;
835
+ mapIntoArray(children, result, "", "", function(child) {
836
+ return func.call(context, child, count++);
837
+ });
838
+ return result;
839
+ }
840
+ function lazyInitializer(payload) {
841
+ if (-1 === payload._status) {
842
+ var ioInfo = payload._ioInfo;
843
+ null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
844
+ ioInfo = payload._result;
845
+ var thenable = ioInfo();
846
+ thenable.then(
847
+ function(moduleObject) {
848
+ if (0 === payload._status || -1 === payload._status) {
849
+ payload._status = 1;
850
+ payload._result = moduleObject;
851
+ var _ioInfo = payload._ioInfo;
852
+ null != _ioInfo && (_ioInfo.end = performance.now());
853
+ void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
854
+ }
855
+ },
856
+ function(error) {
857
+ if (0 === payload._status || -1 === payload._status) {
858
+ payload._status = 2;
859
+ payload._result = error;
860
+ var _ioInfo2 = payload._ioInfo;
861
+ null != _ioInfo2 && (_ioInfo2.end = performance.now());
862
+ void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
863
+ }
864
+ }
865
+ );
866
+ ioInfo = payload._ioInfo;
867
+ if (null != ioInfo) {
868
+ ioInfo.value = thenable;
869
+ var displayName = thenable.displayName;
870
+ "string" === typeof displayName && (ioInfo.name = displayName);
871
+ }
872
+ -1 === payload._status && (payload._status = 0, payload._result = thenable);
873
+ }
874
+ if (1 === payload._status)
875
+ return ioInfo = payload._result, void 0 === ioInfo && console.error(
876
+ "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
877
+ ioInfo
878
+ ), "default" in ioInfo || console.error(
879
+ "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
880
+ ioInfo
881
+ ), ioInfo.default;
882
+ throw payload._result;
883
+ }
884
+ function resolveDispatcher() {
885
+ var dispatcher = ReactSharedInternals.H;
886
+ null === dispatcher && console.error(
887
+ "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
888
+ );
889
+ return dispatcher;
890
+ }
891
+ function releaseAsyncTransition() {
892
+ ReactSharedInternals.asyncTransitions--;
893
+ }
894
+ function enqueueTask(task) {
895
+ if (null === enqueueTaskImpl)
896
+ try {
897
+ var requireString = ("require" + Math.random()).slice(0, 7);
898
+ enqueueTaskImpl = (module && module[requireString]).call(
899
+ module,
900
+ "timers"
901
+ ).setImmediate;
902
+ } catch (_err) {
903
+ enqueueTaskImpl = function(callback) {
904
+ false === didWarnAboutMessageChannel && (didWarnAboutMessageChannel = true, "undefined" === typeof MessageChannel && console.error(
905
+ "This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
906
+ ));
907
+ var channel = new MessageChannel();
908
+ channel.port1.onmessage = callback;
909
+ channel.port2.postMessage(void 0);
910
+ };
911
+ }
912
+ return enqueueTaskImpl(task);
913
+ }
914
+ function aggregateErrors(errors) {
915
+ return 1 < errors.length && "function" === typeof AggregateError ? new AggregateError(errors) : errors[0];
916
+ }
917
+ function popActScope(prevActQueue, prevActScopeDepth) {
918
+ prevActScopeDepth !== actScopeDepth - 1 && console.error(
919
+ "You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
920
+ );
921
+ actScopeDepth = prevActScopeDepth;
922
+ }
923
+ function recursivelyFlushAsyncActWork(returnValue, resolve4, reject) {
924
+ var queue = ReactSharedInternals.actQueue;
925
+ if (null !== queue)
926
+ if (0 !== queue.length)
927
+ try {
928
+ flushActQueue(queue);
929
+ enqueueTask(function() {
930
+ return recursivelyFlushAsyncActWork(returnValue, resolve4, reject);
931
+ });
932
+ return;
933
+ } catch (error) {
934
+ ReactSharedInternals.thrownErrors.push(error);
935
+ }
936
+ else ReactSharedInternals.actQueue = null;
937
+ 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve4(returnValue);
938
+ }
939
+ function flushActQueue(queue) {
940
+ if (!isFlushing) {
941
+ isFlushing = true;
942
+ var i = 0;
943
+ try {
944
+ for (; i < queue.length; i++) {
945
+ var callback = queue[i];
946
+ do {
947
+ ReactSharedInternals.didUsePromise = false;
948
+ var continuation = callback(false);
949
+ if (null !== continuation) {
950
+ if (ReactSharedInternals.didUsePromise) {
951
+ queue[i] = callback;
952
+ queue.splice(0, i);
953
+ return;
954
+ }
955
+ callback = continuation;
956
+ } else break;
957
+ } while (1);
958
+ }
959
+ queue.length = 0;
960
+ } catch (error) {
961
+ queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
962
+ } finally {
963
+ isFlushing = false;
964
+ }
965
+ }
966
+ }
967
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
968
+ var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
969
+ isMounted: function() {
970
+ return false;
971
+ },
972
+ enqueueForceUpdate: function(publicInstance) {
973
+ warnNoop(publicInstance, "forceUpdate");
974
+ },
975
+ enqueueReplaceState: function(publicInstance) {
976
+ warnNoop(publicInstance, "replaceState");
977
+ },
978
+ enqueueSetState: function(publicInstance) {
979
+ warnNoop(publicInstance, "setState");
980
+ }
981
+ }, assign = Object.assign, emptyObject = {};
982
+ Object.freeze(emptyObject);
983
+ Component.prototype.isReactComponent = {};
984
+ Component.prototype.setState = function(partialState, callback) {
985
+ if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
986
+ throw Error(
987
+ "takes an object of state variables to update or a function which returns an object of state variables."
988
+ );
989
+ this.updater.enqueueSetState(this, partialState, callback, "setState");
990
+ };
991
+ Component.prototype.forceUpdate = function(callback) {
992
+ this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
993
+ };
994
+ var deprecatedAPIs = {
995
+ isMounted: [
996
+ "isMounted",
997
+ "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
998
+ ],
999
+ replaceState: [
1000
+ "replaceState",
1001
+ "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
1002
+ ]
1003
+ };
1004
+ for (fnName in deprecatedAPIs)
1005
+ deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
1006
+ ComponentDummy.prototype = Component.prototype;
1007
+ deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
1008
+ deprecatedAPIs.constructor = PureComponent;
1009
+ assign(deprecatedAPIs, Component.prototype);
1010
+ deprecatedAPIs.isPureReactComponent = true;
1011
+ var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference"), ReactSharedInternals = {
1012
+ H: null,
1013
+ A: null,
1014
+ T: null,
1015
+ S: null,
1016
+ actQueue: null,
1017
+ asyncTransitions: 0,
1018
+ isBatchingLegacy: false,
1019
+ didScheduleLegacyUpdate: false,
1020
+ didUsePromise: false,
1021
+ thrownErrors: [],
1022
+ getCurrentStack: null,
1023
+ recentlyCreatedOwnerStacks: 0
1024
+ }, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
1025
+ return null;
1026
+ };
1027
+ deprecatedAPIs = {
1028
+ react_stack_bottom_frame: function(callStackForError) {
1029
+ return callStackForError();
1030
+ }
1031
+ };
1032
+ var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
1033
+ var didWarnAboutElementRef = {};
1034
+ var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
1035
+ deprecatedAPIs,
1036
+ UnknownOwner
1037
+ )();
1038
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
1039
+ var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
1040
+ if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
1041
+ var event = new window.ErrorEvent("error", {
1042
+ bubbles: true,
1043
+ cancelable: true,
1044
+ message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
1045
+ error
1046
+ });
1047
+ if (!window.dispatchEvent(event)) return;
1048
+ } else if ("object" === typeof process && "function" === typeof process.emit) {
1049
+ process.emit("uncaughtException", error);
1050
+ return;
1051
+ }
1052
+ console.error(error);
1053
+ }, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = "function" === typeof queueMicrotask ? function(callback) {
1054
+ queueMicrotask(function() {
1055
+ return queueMicrotask(callback);
1056
+ });
1057
+ } : enqueueTask;
1058
+ deprecatedAPIs = Object.freeze({
1059
+ __proto__: null,
1060
+ c: function(size) {
1061
+ return resolveDispatcher().useMemoCache(size);
1062
+ }
1063
+ });
1064
+ var fnName = {
1065
+ map: mapChildren,
1066
+ forEach: function(children, forEachFunc, forEachContext) {
1067
+ mapChildren(
1068
+ children,
1069
+ function() {
1070
+ forEachFunc.apply(this, arguments);
1071
+ },
1072
+ forEachContext
1073
+ );
1074
+ },
1075
+ count: function(children) {
1076
+ var n = 0;
1077
+ mapChildren(children, function() {
1078
+ n++;
1079
+ });
1080
+ return n;
1081
+ },
1082
+ toArray: function(children) {
1083
+ return mapChildren(children, function(child) {
1084
+ return child;
1085
+ }) || [];
1086
+ },
1087
+ only: function(children) {
1088
+ if (!isValidElement(children))
1089
+ throw Error(
1090
+ "React.Children.only expected to receive a single React element child."
1091
+ );
1092
+ return children;
1093
+ }
1094
+ };
1095
+ exports.Activity = REACT_ACTIVITY_TYPE;
1096
+ exports.Children = fnName;
1097
+ exports.Component = Component;
1098
+ exports.Fragment = REACT_FRAGMENT_TYPE;
1099
+ exports.Profiler = REACT_PROFILER_TYPE;
1100
+ exports.PureComponent = PureComponent;
1101
+ exports.StrictMode = REACT_STRICT_MODE_TYPE;
1102
+ exports.Suspense = REACT_SUSPENSE_TYPE;
1103
+ exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
1104
+ exports.__COMPILER_RUNTIME = deprecatedAPIs;
1105
+ exports.act = function(callback) {
1106
+ var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
1107
+ actScopeDepth++;
1108
+ var queue = ReactSharedInternals.actQueue = null !== prevActQueue ? prevActQueue : [], didAwaitActCall = false;
1109
+ try {
1110
+ var result = callback();
1111
+ } catch (error) {
1112
+ ReactSharedInternals.thrownErrors.push(error);
1113
+ }
1114
+ if (0 < ReactSharedInternals.thrownErrors.length)
1115
+ throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
1116
+ if (null !== result && "object" === typeof result && "function" === typeof result.then) {
1117
+ var thenable = result;
1118
+ queueSeveralMicrotasks(function() {
1119
+ didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
1120
+ "You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
1121
+ ));
1122
+ });
1123
+ return {
1124
+ then: function(resolve4, reject) {
1125
+ didAwaitActCall = true;
1126
+ thenable.then(
1127
+ function(returnValue) {
1128
+ popActScope(prevActQueue, prevActScopeDepth);
1129
+ if (0 === prevActScopeDepth) {
1130
+ try {
1131
+ flushActQueue(queue), enqueueTask(function() {
1132
+ return recursivelyFlushAsyncActWork(
1133
+ returnValue,
1134
+ resolve4,
1135
+ reject
1136
+ );
1137
+ });
1138
+ } catch (error$0) {
1139
+ ReactSharedInternals.thrownErrors.push(error$0);
1140
+ }
1141
+ if (0 < ReactSharedInternals.thrownErrors.length) {
1142
+ var _thrownError = aggregateErrors(
1143
+ ReactSharedInternals.thrownErrors
1144
+ );
1145
+ ReactSharedInternals.thrownErrors.length = 0;
1146
+ reject(_thrownError);
1147
+ }
1148
+ } else resolve4(returnValue);
1149
+ },
1150
+ function(error) {
1151
+ popActScope(prevActQueue, prevActScopeDepth);
1152
+ 0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(
1153
+ ReactSharedInternals.thrownErrors
1154
+ ), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
1155
+ }
1156
+ );
1157
+ }
1158
+ };
1159
+ }
1160
+ var returnValue$jscomp$0 = result;
1161
+ popActScope(prevActQueue, prevActScopeDepth);
1162
+ 0 === prevActScopeDepth && (flushActQueue(queue), 0 !== queue.length && queueSeveralMicrotasks(function() {
1163
+ didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
1164
+ "A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
1165
+ ));
1166
+ }), ReactSharedInternals.actQueue = null);
1167
+ if (0 < ReactSharedInternals.thrownErrors.length)
1168
+ throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
1169
+ return {
1170
+ then: function(resolve4, reject) {
1171
+ didAwaitActCall = true;
1172
+ 0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
1173
+ return recursivelyFlushAsyncActWork(
1174
+ returnValue$jscomp$0,
1175
+ resolve4,
1176
+ reject
1177
+ );
1178
+ })) : resolve4(returnValue$jscomp$0);
1179
+ }
1180
+ };
1181
+ };
1182
+ exports.cache = function(fn) {
1183
+ return function() {
1184
+ return fn.apply(null, arguments);
1185
+ };
1186
+ };
1187
+ exports.cacheSignal = function() {
1188
+ return null;
1189
+ };
1190
+ exports.captureOwnerStack = function() {
1191
+ var getCurrentStack = ReactSharedInternals.getCurrentStack;
1192
+ return null === getCurrentStack ? null : getCurrentStack();
1193
+ };
1194
+ exports.cloneElement = function(element, config, children) {
1195
+ if (null === element || void 0 === element)
1196
+ throw Error(
1197
+ "The argument must be a React element, but you passed " + element + "."
1198
+ );
1199
+ var props = assign({}, element.props), key = element.key, owner = element._owner;
1200
+ if (null != config) {
1201
+ var JSCompiler_inline_result;
1202
+ a: {
1203
+ if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
1204
+ config,
1205
+ "ref"
1206
+ ).get) && JSCompiler_inline_result.isReactWarning) {
1207
+ JSCompiler_inline_result = false;
1208
+ break a;
1209
+ }
1210
+ JSCompiler_inline_result = void 0 !== config.ref;
1211
+ }
1212
+ JSCompiler_inline_result && (owner = getOwner());
1213
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
1214
+ for (propName in config)
1215
+ !hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
1216
+ }
1217
+ var propName = arguments.length - 2;
1218
+ if (1 === propName) props.children = children;
1219
+ else if (1 < propName) {
1220
+ JSCompiler_inline_result = Array(propName);
1221
+ for (var i = 0; i < propName; i++)
1222
+ JSCompiler_inline_result[i] = arguments[i + 2];
1223
+ props.children = JSCompiler_inline_result;
1224
+ }
1225
+ props = ReactElement(
1226
+ element.type,
1227
+ key,
1228
+ props,
1229
+ owner,
1230
+ element._debugStack,
1231
+ element._debugTask
1232
+ );
1233
+ for (key = 2; key < arguments.length; key++)
1234
+ validateChildKeys(arguments[key]);
1235
+ return props;
1236
+ };
1237
+ exports.createContext = function(defaultValue) {
1238
+ defaultValue = {
1239
+ $$typeof: REACT_CONTEXT_TYPE,
1240
+ _currentValue: defaultValue,
1241
+ _currentValue2: defaultValue,
1242
+ _threadCount: 0,
1243
+ Provider: null,
1244
+ Consumer: null
1245
+ };
1246
+ defaultValue.Provider = defaultValue;
1247
+ defaultValue.Consumer = {
1248
+ $$typeof: REACT_CONSUMER_TYPE,
1249
+ _context: defaultValue
1250
+ };
1251
+ defaultValue._currentRenderer = null;
1252
+ defaultValue._currentRenderer2 = null;
1253
+ return defaultValue;
1254
+ };
1255
+ exports.createElement = function(type, config, children) {
1256
+ for (var i = 2; i < arguments.length; i++)
1257
+ validateChildKeys(arguments[i]);
1258
+ i = {};
1259
+ var key = null;
1260
+ if (null != config)
1261
+ for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn(
1262
+ "Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
1263
+ )), hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key), config)
1264
+ hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (i[propName] = config[propName]);
1265
+ var childrenLength = arguments.length - 2;
1266
+ if (1 === childrenLength) i.children = children;
1267
+ else if (1 < childrenLength) {
1268
+ for (var childArray = Array(childrenLength), _i = 0; _i < childrenLength; _i++)
1269
+ childArray[_i] = arguments[_i + 2];
1270
+ Object.freeze && Object.freeze(childArray);
1271
+ i.children = childArray;
1272
+ }
1273
+ if (type && type.defaultProps)
1274
+ for (propName in childrenLength = type.defaultProps, childrenLength)
1275
+ void 0 === i[propName] && (i[propName] = childrenLength[propName]);
1276
+ key && defineKeyPropWarningGetter(
1277
+ i,
1278
+ "function" === typeof type ? type.displayName || type.name || "Unknown" : type
1279
+ );
1280
+ var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
1281
+ return ReactElement(
1282
+ type,
1283
+ key,
1284
+ i,
1285
+ getOwner(),
1286
+ propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
1287
+ propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
1288
+ );
1289
+ };
1290
+ exports.createRef = function() {
1291
+ var refObject = { current: null };
1292
+ Object.seal(refObject);
1293
+ return refObject;
1294
+ };
1295
+ exports.forwardRef = function(render2) {
1296
+ null != render2 && render2.$$typeof === REACT_MEMO_TYPE ? console.error(
1297
+ "forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
1298
+ ) : "function" !== typeof render2 ? console.error(
1299
+ "forwardRef requires a render function but was given %s.",
1300
+ null === render2 ? "null" : typeof render2
1301
+ ) : 0 !== render2.length && 2 !== render2.length && console.error(
1302
+ "forwardRef render functions accept exactly two parameters: props and ref. %s",
1303
+ 1 === render2.length ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
1304
+ );
1305
+ null != render2 && null != render2.defaultProps && console.error(
1306
+ "forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
1307
+ );
1308
+ var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render: render2 }, ownName;
1309
+ Object.defineProperty(elementType, "displayName", {
1310
+ enumerable: false,
1311
+ configurable: true,
1312
+ get: function() {
1313
+ return ownName;
1314
+ },
1315
+ set: function(name) {
1316
+ ownName = name;
1317
+ render2.name || render2.displayName || (Object.defineProperty(render2, "name", { value: name }), render2.displayName = name);
1318
+ }
1319
+ });
1320
+ return elementType;
1321
+ };
1322
+ exports.isValidElement = isValidElement;
1323
+ exports.lazy = function(ctor) {
1324
+ ctor = { _status: -1, _result: ctor };
1325
+ var lazyType = {
1326
+ $$typeof: REACT_LAZY_TYPE,
1327
+ _payload: ctor,
1328
+ _init: lazyInitializer
1329
+ }, ioInfo = {
1330
+ name: "lazy",
1331
+ start: -1,
1332
+ end: -1,
1333
+ value: null,
1334
+ owner: null,
1335
+ debugStack: Error("react-stack-top-frame"),
1336
+ debugTask: console.createTask ? console.createTask("lazy()") : null
1337
+ };
1338
+ ctor._ioInfo = ioInfo;
1339
+ lazyType._debugInfo = [{ awaited: ioInfo }];
1340
+ return lazyType;
1341
+ };
1342
+ exports.memo = function(type, compare) {
1343
+ null == type && console.error(
1344
+ "memo: The first argument must be a component. Instead received: %s",
1345
+ null === type ? "null" : typeof type
1346
+ );
1347
+ compare = {
1348
+ $$typeof: REACT_MEMO_TYPE,
1349
+ type,
1350
+ compare: void 0 === compare ? null : compare
1351
+ };
1352
+ var ownName;
1353
+ Object.defineProperty(compare, "displayName", {
1354
+ enumerable: false,
1355
+ configurable: true,
1356
+ get: function() {
1357
+ return ownName;
1358
+ },
1359
+ set: function(name) {
1360
+ ownName = name;
1361
+ type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
1362
+ }
1363
+ });
1364
+ return compare;
1365
+ };
1366
+ exports.startTransition = function(scope) {
1367
+ var prevTransition = ReactSharedInternals.T, currentTransition = {};
1368
+ currentTransition._updatedFibers = /* @__PURE__ */ new Set();
1369
+ ReactSharedInternals.T = currentTransition;
1370
+ try {
1371
+ var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
1372
+ null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
1373
+ "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
1374
+ } catch (error) {
1375
+ reportGlobalError(error);
1376
+ } finally {
1377
+ null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
1378
+ "Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
1379
+ )), null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
1380
+ "We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
1381
+ ), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
1382
+ }
1383
+ };
1384
+ exports.unstable_useCacheRefresh = function() {
1385
+ return resolveDispatcher().useCacheRefresh();
1386
+ };
1387
+ exports.use = function(usable) {
1388
+ return resolveDispatcher().use(usable);
1389
+ };
1390
+ exports.useActionState = function(action, initialState, permalink) {
1391
+ return resolveDispatcher().useActionState(
1392
+ action,
1393
+ initialState,
1394
+ permalink
1395
+ );
1396
+ };
1397
+ exports.useCallback = function(callback, deps) {
1398
+ return resolveDispatcher().useCallback(callback, deps);
1399
+ };
1400
+ exports.useContext = function(Context) {
1401
+ var dispatcher = resolveDispatcher();
1402
+ Context.$$typeof === REACT_CONSUMER_TYPE && console.error(
1403
+ "Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
1404
+ );
1405
+ return dispatcher.useContext(Context);
1406
+ };
1407
+ exports.useDebugValue = function(value, formatterFn) {
1408
+ return resolveDispatcher().useDebugValue(value, formatterFn);
1409
+ };
1410
+ exports.useDeferredValue = function(value, initialValue) {
1411
+ return resolveDispatcher().useDeferredValue(value, initialValue);
1412
+ };
1413
+ exports.useEffect = function(create, deps) {
1414
+ null == create && console.warn(
1415
+ "React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1416
+ );
1417
+ return resolveDispatcher().useEffect(create, deps);
1418
+ };
1419
+ exports.useEffectEvent = function(callback) {
1420
+ return resolveDispatcher().useEffectEvent(callback);
1421
+ };
1422
+ exports.useId = function() {
1423
+ return resolveDispatcher().useId();
1424
+ };
1425
+ exports.useImperativeHandle = function(ref, create, deps) {
1426
+ return resolveDispatcher().useImperativeHandle(ref, create, deps);
1427
+ };
1428
+ exports.useInsertionEffect = function(create, deps) {
1429
+ null == create && console.warn(
1430
+ "React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1431
+ );
1432
+ return resolveDispatcher().useInsertionEffect(create, deps);
1433
+ };
1434
+ exports.useLayoutEffect = function(create, deps) {
1435
+ null == create && console.warn(
1436
+ "React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1437
+ );
1438
+ return resolveDispatcher().useLayoutEffect(create, deps);
1439
+ };
1440
+ exports.useMemo = function(create, deps) {
1441
+ return resolveDispatcher().useMemo(create, deps);
1442
+ };
1443
+ exports.useOptimistic = function(passthrough, reducer) {
1444
+ return resolveDispatcher().useOptimistic(passthrough, reducer);
1445
+ };
1446
+ exports.useReducer = function(reducer, initialArg, init) {
1447
+ return resolveDispatcher().useReducer(reducer, initialArg, init);
1448
+ };
1449
+ exports.useRef = function(initialValue) {
1450
+ return resolveDispatcher().useRef(initialValue);
1451
+ };
1452
+ exports.useState = function(initialState) {
1453
+ return resolveDispatcher().useState(initialState);
1454
+ };
1455
+ exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
1456
+ return resolveDispatcher().useSyncExternalStore(
1457
+ subscribe,
1458
+ getSnapshot,
1459
+ getServerSnapshot
1460
+ );
1461
+ };
1462
+ exports.useTransition = function() {
1463
+ return resolveDispatcher().useTransition();
1464
+ };
1465
+ exports.version = "19.2.3";
1466
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1467
+ })();
1468
+ }
1469
+ });
1470
+
1471
+ // ../node_modules/react/index.js
1472
+ var require_react = __commonJS({
1473
+ "../node_modules/react/index.js"(exports, module) {
1474
+ "use strict";
1475
+ if (process.env.NODE_ENV === "production") {
1476
+ module.exports = require_react_production();
1477
+ } else {
1478
+ module.exports = require_react_development();
1479
+ }
1480
+ }
1481
+ });
1482
+
1483
+ // ../node_modules/react/cjs/react-jsx-runtime.development.js
1484
+ var require_react_jsx_runtime_development = __commonJS({
1485
+ "../node_modules/react/cjs/react-jsx-runtime.development.js"(exports) {
1486
+ "use strict";
1487
+ "production" !== process.env.NODE_ENV && (function() {
1488
+ function getComponentNameFromType(type) {
1489
+ if (null == type) return null;
1490
+ if ("function" === typeof type)
1491
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
1492
+ if ("string" === typeof type) return type;
1493
+ switch (type) {
1494
+ case REACT_FRAGMENT_TYPE:
1495
+ return "Fragment";
1496
+ case REACT_PROFILER_TYPE:
1497
+ return "Profiler";
1498
+ case REACT_STRICT_MODE_TYPE:
1499
+ return "StrictMode";
1500
+ case REACT_SUSPENSE_TYPE:
1501
+ return "Suspense";
1502
+ case REACT_SUSPENSE_LIST_TYPE:
1503
+ return "SuspenseList";
1504
+ case REACT_ACTIVITY_TYPE:
1505
+ return "Activity";
1506
+ }
1507
+ if ("object" === typeof type)
1508
+ switch ("number" === typeof type.tag && console.error(
1509
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
1510
+ ), type.$$typeof) {
1511
+ case REACT_PORTAL_TYPE:
1512
+ return "Portal";
1513
+ case REACT_CONTEXT_TYPE:
1514
+ return type.displayName || "Context";
1515
+ case REACT_CONSUMER_TYPE:
1516
+ return (type._context.displayName || "Context") + ".Consumer";
1517
+ case REACT_FORWARD_REF_TYPE:
1518
+ var innerType = type.render;
1519
+ type = type.displayName;
1520
+ type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
1521
+ return type;
1522
+ case REACT_MEMO_TYPE:
1523
+ return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
1524
+ case REACT_LAZY_TYPE:
1525
+ innerType = type._payload;
1526
+ type = type._init;
1527
+ try {
1528
+ return getComponentNameFromType(type(innerType));
1529
+ } catch (x) {
1530
+ }
1531
+ }
1532
+ return null;
1533
+ }
1534
+ function testStringCoercion(value) {
1535
+ return "" + value;
1536
+ }
1537
+ function checkKeyStringCoercion(value) {
1538
+ try {
1539
+ testStringCoercion(value);
1540
+ var JSCompiler_inline_result = false;
1541
+ } catch (e) {
1542
+ JSCompiler_inline_result = true;
1543
+ }
1544
+ if (JSCompiler_inline_result) {
1545
+ JSCompiler_inline_result = console;
1546
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
1547
+ var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
1548
+ JSCompiler_temp_const.call(
1549
+ JSCompiler_inline_result,
1550
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
1551
+ JSCompiler_inline_result$jscomp$0
1552
+ );
1553
+ return testStringCoercion(value);
1554
+ }
1555
+ }
1556
+ function getTaskName(type) {
1557
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
1558
+ if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
1559
+ return "<...>";
1560
+ try {
1561
+ var name = getComponentNameFromType(type);
1562
+ return name ? "<" + name + ">" : "<...>";
1563
+ } catch (x) {
1564
+ return "<...>";
1565
+ }
1566
+ }
1567
+ function getOwner() {
1568
+ var dispatcher = ReactSharedInternals.A;
1569
+ return null === dispatcher ? null : dispatcher.getOwner();
1570
+ }
1571
+ function UnknownOwner() {
1572
+ return Error("react-stack-top-frame");
1573
+ }
1574
+ function hasValidKey(config) {
1575
+ if (hasOwnProperty.call(config, "key")) {
1576
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
1577
+ if (getter && getter.isReactWarning) return false;
1578
+ }
1579
+ return void 0 !== config.key;
1580
+ }
1581
+ function defineKeyPropWarningGetter(props, displayName) {
1582
+ function warnAboutAccessingKey() {
1583
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
1584
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
1585
+ displayName
1586
+ ));
1587
+ }
1588
+ warnAboutAccessingKey.isReactWarning = true;
1589
+ Object.defineProperty(props, "key", {
1590
+ get: warnAboutAccessingKey,
1591
+ configurable: true
1592
+ });
1593
+ }
1594
+ function elementRefGetterWithDeprecationWarning() {
1595
+ var componentName = getComponentNameFromType(this.type);
1596
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
1597
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
1598
+ ));
1599
+ componentName = this.props.ref;
1600
+ return void 0 !== componentName ? componentName : null;
1601
+ }
1602
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
1603
+ var refProp = props.ref;
1604
+ type = {
1605
+ $$typeof: REACT_ELEMENT_TYPE,
1606
+ type,
1607
+ key,
1608
+ props,
1609
+ _owner: owner
1610
+ };
1611
+ null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
1612
+ enumerable: false,
1613
+ get: elementRefGetterWithDeprecationWarning
1614
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
1615
+ type._store = {};
1616
+ Object.defineProperty(type._store, "validated", {
1617
+ configurable: false,
1618
+ enumerable: false,
1619
+ writable: true,
1620
+ value: 0
1621
+ });
1622
+ Object.defineProperty(type, "_debugInfo", {
1623
+ configurable: false,
1624
+ enumerable: false,
1625
+ writable: true,
1626
+ value: null
1627
+ });
1628
+ Object.defineProperty(type, "_debugStack", {
1629
+ configurable: false,
1630
+ enumerable: false,
1631
+ writable: true,
1632
+ value: debugStack
1633
+ });
1634
+ Object.defineProperty(type, "_debugTask", {
1635
+ configurable: false,
1636
+ enumerable: false,
1637
+ writable: true,
1638
+ value: debugTask
1639
+ });
1640
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
1641
+ return type;
1642
+ }
1643
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
1644
+ var children = config.children;
1645
+ if (void 0 !== children)
1646
+ if (isStaticChildren)
1647
+ if (isArrayImpl(children)) {
1648
+ for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++)
1649
+ validateChildKeys(children[isStaticChildren]);
1650
+ Object.freeze && Object.freeze(children);
1651
+ } else
1652
+ console.error(
1653
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
1654
+ );
1655
+ else validateChildKeys(children);
1656
+ if (hasOwnProperty.call(config, "key")) {
1657
+ children = getComponentNameFromType(type);
1658
+ var keys = Object.keys(config).filter(function(k) {
1659
+ return "key" !== k;
1660
+ });
1661
+ isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
1662
+ didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(
1663
+ 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
1664
+ isStaticChildren,
1665
+ children,
1666
+ keys,
1667
+ children
1668
+ ), didWarnAboutKeySpread[children + isStaticChildren] = true);
1669
+ }
1670
+ children = null;
1671
+ void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
1672
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
1673
+ if ("key" in config) {
1674
+ maybeKey = {};
1675
+ for (var propName in config)
1676
+ "key" !== propName && (maybeKey[propName] = config[propName]);
1677
+ } else maybeKey = config;
1678
+ children && defineKeyPropWarningGetter(
1679
+ maybeKey,
1680
+ "function" === typeof type ? type.displayName || type.name || "Unknown" : type
1681
+ );
1682
+ return ReactElement(
1683
+ type,
1684
+ children,
1685
+ maybeKey,
1686
+ getOwner(),
1687
+ debugStack,
1688
+ debugTask
1689
+ );
1690
+ }
1691
+ function validateChildKeys(node) {
1692
+ isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
1693
+ }
1694
+ function isValidElement(object) {
1695
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
1696
+ }
1697
+ var React = require_react(), REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference"), ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
1698
+ return null;
1699
+ };
1700
+ React = {
1701
+ react_stack_bottom_frame: function(callStackForError) {
1702
+ return callStackForError();
1703
+ }
1704
+ };
1705
+ var specialPropKeyWarningShown;
1706
+ var didWarnAboutElementRef = {};
1707
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
1708
+ React,
1709
+ UnknownOwner
1710
+ )();
1711
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
1712
+ var didWarnAboutKeySpread = {};
1713
+ exports.Fragment = REACT_FRAGMENT_TYPE;
1714
+ exports.jsx = function(type, config, maybeKey) {
1715
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
1716
+ return jsxDEVImpl(
1717
+ type,
1718
+ config,
1719
+ maybeKey,
1720
+ false,
1721
+ trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
1722
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
1723
+ );
1724
+ };
1725
+ exports.jsxs = function(type, config, maybeKey) {
1726
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
1727
+ return jsxDEVImpl(
1728
+ type,
1729
+ config,
1730
+ maybeKey,
1731
+ true,
1732
+ trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
1733
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
1734
+ );
1735
+ };
1736
+ })();
1737
+ }
1738
+ });
1739
+
1740
+ // ../node_modules/react/jsx-runtime.js
1741
+ var require_jsx_runtime = __commonJS({
1742
+ "../node_modules/react/jsx-runtime.js"(exports, module) {
1743
+ "use strict";
1744
+ if (process.env.NODE_ENV === "production") {
1745
+ module.exports = require_react_jsx_runtime_production();
1746
+ } else {
1747
+ module.exports = require_react_jsx_runtime_development();
1748
+ }
1749
+ }
1750
+ });
1751
+
1752
+ // src/cli/run.ts
1753
+ import qrcode2 from "qrcode-terminal";
1754
+
1755
+ // src/cli/args.ts
1756
+ var parseNumber = (value) => {
1757
+ if (!value) {
1758
+ return null;
1759
+ }
1760
+ const parsed = Number.parseInt(value, 10);
1761
+ return Number.isNaN(parsed) ? null : parsed;
1762
+ };
1763
+ var parseArgs = (argv) => {
1764
+ const args = [...argv];
1765
+ let command = "start";
1766
+ if (args[0] && !args[0].startsWith("-")) {
1767
+ command = args.shift() === "help" ? "help" : "start";
1768
+ }
1769
+ const options = {
1770
+ killOnExit: false,
1771
+ noQr: false,
1772
+ tunnel: "cloudflare"
1773
+ };
1774
+ while (args.length > 0) {
1775
+ const current = args.shift();
1776
+ if (!current) {
1777
+ continue;
1778
+ }
1779
+ if (current === "--help" || current === "-h") {
1780
+ command = "help";
1781
+ continue;
1782
+ }
1783
+ if (current === "--port") {
1784
+ const port = parseNumber(args.shift());
1785
+ if (!port || port <= 0) {
1786
+ throw new Error("invalid port");
1787
+ }
1788
+ options.port = port;
1789
+ continue;
1790
+ }
1791
+ if (current === "--session") {
1792
+ const session = args.shift();
1793
+ if (!session) {
1794
+ throw new Error("missing session name");
1795
+ }
1796
+ options.session = session;
1797
+ continue;
1798
+ }
1799
+ if (current === "--kill-on-exit") {
1800
+ options.killOnExit = true;
1801
+ continue;
1802
+ }
1803
+ if (current === "--no-qr") {
1804
+ options.noQr = true;
1805
+ continue;
1806
+ }
1807
+ if (current === "--tunnel") {
1808
+ const tunnel = args.shift();
1809
+ if (tunnel !== "cloudflare") {
1810
+ throw new Error("unsupported tunnel provider");
1811
+ }
1812
+ options.tunnel = "cloudflare";
1813
+ continue;
1814
+ }
1815
+ throw new Error(`unknown option: ${current}`);
1816
+ }
1817
+ return { command, options };
1818
+ };
1819
+
1820
+ // src/cli/help.ts
1821
+ var helpText = `termbridge
1822
+
1823
+ Usage:
1824
+ termbridge [start]
1825
+
1826
+ Options:
1827
+ --port <port> Bind the local server to a fixed port
1828
+ --session <name> Use a specific tmux session name
1829
+ --kill-on-exit Kill the tmux session when the CLI exits
1830
+ --no-qr Disable QR code output
1831
+ --tunnel <provider> Tunnel provider (cloudflare)
1832
+ -h, --help Show this help message
1833
+ `;
1834
+
1835
+ // src/cli/ink.tsx
1836
+ import { Box, Text, render } from "ink";
1837
+ import qrcode from "qrcode-terminal";
1838
+
1839
+ // src/cli/start.ts
1840
+ import { resolve as resolve3, dirname as dirname2 } from "path";
1841
+ import { existsSync } from "fs";
1842
+ import { fileURLToPath } from "url";
1843
+
1844
+ // ../packages/terminal/src/index.ts
1845
+ import { EventEmitter } from "events";
1846
+ import { execFile as execFileCallback } from "child_process";
1847
+ import { promisify } from "util";
1848
+ import { accessSync, chmodSync, constants as fsConstants } from "fs";
1849
+ import { dirname, resolve } from "path";
1850
+ import { createRequire } from "module";
1851
+ import * as pty from "node-pty";
1852
+ var execFile = promisify(execFileCallback);
1853
+ var requireFromHere = createRequire(import.meta.url);
1854
+ var spawnHelperChecked = false;
1855
+ var controlKeyMap = {
1856
+ ctrl_c: "",
1857
+ esc: "\x1B",
1858
+ tab: " ",
1859
+ up: "\x1B[A",
1860
+ down: "\x1B[B",
1861
+ left: "\x1B[D",
1862
+ right: "\x1B[C"
1863
+ };
1864
+ var defaultDeps = {
1865
+ execFile: async (file, args) => execFile(file, args),
1866
+ spawnPty: pty.spawn,
1867
+ env: process.env,
1868
+ defaultCols: 80,
1869
+ defaultRows: 24
1870
+ };
1871
+ var ensureSpawnHelperExecutable = () => {
1872
+ if (spawnHelperChecked || process.platform === "win32") {
1873
+ return;
1874
+ }
1875
+ spawnHelperChecked = true;
1876
+ try {
1877
+ const { loadNativeModule } = requireFromHere("node-pty/lib/utils");
1878
+ const native = loadNativeModule("pty");
1879
+ const unixTerminalPath = requireFromHere.resolve("node-pty/lib/unixTerminal");
1880
+ const helperPath = resolve(dirname(unixTerminalPath), `${native.dir}/spawn-helper`);
1881
+ try {
1882
+ accessSync(helperPath, fsConstants.X_OK);
1883
+ } catch {
1884
+ chmodSync(helperPath, 493);
1885
+ }
1886
+ } catch (error) {
1887
+ const message = error instanceof Error ? error.message : String(error);
1888
+ throw new Error(`node-pty spawn-helper unavailable: ${message}`);
1889
+ }
1890
+ };
1891
+ var createTmuxBackend = (deps = {}) => {
1892
+ const runtime = { ...defaultDeps, ...deps };
1893
+ const sessions = /* @__PURE__ */ new Map();
1894
+ const runTmux = async (args) => runtime.execFile("tmux", args);
1895
+ const createSession = async (name) => {
1896
+ const existing = sessions.get(name);
1897
+ if (existing) {
1898
+ return existing.session;
1899
+ }
1900
+ try {
1901
+ await runTmux(["new-session", "-d", "-s", name]);
1902
+ } catch (error) {
1903
+ try {
1904
+ await runTmux(["has-session", "-t", name]);
1905
+ } catch {
1906
+ throw error;
1907
+ }
1908
+ }
1909
+ try {
1910
+ await runTmux(["set-option", "-t", name, "status", "off"]);
1911
+ } catch {
1912
+ }
1913
+ const session = { name, createdAt: /* @__PURE__ */ new Date() };
1914
+ sessions.set(name, {
1915
+ session,
1916
+ pty: null,
1917
+ subscribers: /* @__PURE__ */ new Set(),
1918
+ cols: runtime.defaultCols,
1919
+ rows: runtime.defaultRows,
1920
+ disposables: []
1921
+ });
1922
+ return session;
1923
+ };
1924
+ const disposePty = (entry, kill) => {
1925
+ const current = entry.pty;
1926
+ entry.pty = null;
1927
+ for (const disposable of entry.disposables) {
1928
+ disposable.dispose();
1929
+ }
1930
+ entry.disposables = [];
1931
+ if (kill && current) {
1932
+ try {
1933
+ current.kill();
1934
+ } catch {
1935
+ }
1936
+ }
1937
+ };
1938
+ const ensurePty = (entry) => {
1939
+ if (entry.pty) {
1940
+ return entry.pty;
1941
+ }
1942
+ ensureSpawnHelperExecutable();
1943
+ const ptyInstance = runtime.spawnPty("tmux", ["attach-session", "-t", entry.session.name], {
1944
+ name: "xterm-256color",
1945
+ cols: entry.cols,
1946
+ rows: entry.rows,
1947
+ env: {
1948
+ ...runtime.env,
1949
+ TERM: "xterm-256color",
1950
+ COLORTERM: "truecolor"
1951
+ }
1952
+ });
1953
+ entry.pty = ptyInstance;
1954
+ const dataDisposable = ptyInstance.onData((data) => {
1955
+ for (const subscriber of entry.subscribers) {
1956
+ subscriber(data);
1957
+ }
1958
+ });
1959
+ const exitDisposable = ptyInstance.onExit(() => {
1960
+ disposePty(entry, false);
1961
+ });
1962
+ entry.disposables = [dataDisposable, exitDisposable];
1963
+ return ptyInstance;
1964
+ };
1965
+ const write = async (sessionName, data) => {
1966
+ if (data.length === 0) {
1967
+ return;
1968
+ }
1969
+ const entry = sessions.get(sessionName);
1970
+ if (!entry) {
1971
+ return;
1972
+ }
1973
+ ensurePty(entry).write(data);
1974
+ };
1975
+ const sendControl = async (sessionName, key) => {
1976
+ const entry = sessions.get(sessionName);
1977
+ if (!entry) {
1978
+ return;
1979
+ }
1980
+ const controlSequence = controlKeyMap[key];
1981
+ ensurePty(entry).write(controlSequence);
1982
+ };
1983
+ const resize = async (sessionName, cols, rows) => {
1984
+ const entry = sessions.get(sessionName);
1985
+ if (!entry) {
1986
+ return;
1987
+ }
1988
+ entry.cols = cols;
1989
+ entry.rows = rows;
1990
+ if (entry.pty) {
1991
+ entry.pty.resize(cols, rows);
1992
+ }
1993
+ };
1994
+ const onOutput = (sessionName, callback) => {
1995
+ const entry = sessions.get(sessionName);
1996
+ if (!entry) {
1997
+ return () => void 0;
1998
+ }
1999
+ entry.subscribers.add(callback);
2000
+ ensurePty(entry);
2001
+ return () => {
2002
+ entry.subscribers.delete(callback);
2003
+ if (entry.subscribers.size === 0) {
2004
+ disposePty(entry, true);
2005
+ }
2006
+ };
2007
+ };
2008
+ const closeSession = async (sessionName) => {
2009
+ const entry = sessions.get(sessionName);
2010
+ if (entry) {
2011
+ disposePty(entry, true);
2012
+ sessions.delete(sessionName);
2013
+ }
2014
+ try {
2015
+ await runTmux(["kill-session", "-t", sessionName]);
2016
+ } catch {
2017
+ return;
2018
+ }
2019
+ };
2020
+ return {
2021
+ createSession,
2022
+ write,
2023
+ resize,
2024
+ sendControl,
2025
+ onOutput,
2026
+ closeSession
2027
+ };
2028
+ };
2029
+
2030
+ // ../packages/tunnel/src/index.ts
2031
+ import { spawn as spawnCallback } from "child_process";
2032
+ var parseCloudflaredUrl = (line) => {
2033
+ const match = line.match(/https:\/\/[^\s]+trycloudflare\.com/);
2034
+ return match?.[0] ?? null;
2035
+ };
2036
+ var readLines = (data, carry, onLine) => {
2037
+ const combined = carry + data;
2038
+ const lines = combined.split("\n");
2039
+ const remainder = lines.pop();
2040
+ for (const line of lines) {
2041
+ onLine(line);
2042
+ }
2043
+ return remainder;
2044
+ };
2045
+ var createCloudflaredProvider = (deps = {}) => {
2046
+ const spawn2 = deps.spawn ?? spawnCallback;
2047
+ let child = null;
2048
+ const start = (localUrl) => {
2049
+ if (child) {
2050
+ return Promise.reject(new Error("cloudflared already running"));
2051
+ }
2052
+ child = spawn2("cloudflared", ["tunnel", "--url", localUrl]);
2053
+ let stdoutCarry = "";
2054
+ let stderrCarry = "";
2055
+ return new Promise((resolve4, reject) => {
2056
+ const handleLine = (line) => {
2057
+ const url = parseCloudflaredUrl(line);
2058
+ if (url) {
2059
+ resolve4({ publicUrl: url });
2060
+ }
2061
+ };
2062
+ const handleOutput = (data, isStdout) => {
2063
+ if (isStdout) {
2064
+ stdoutCarry = readLines(data.toString(), stdoutCarry, handleLine);
2065
+ } else {
2066
+ stderrCarry = readLines(data.toString(), stderrCarry, handleLine);
2067
+ }
2068
+ };
2069
+ child?.stdout.on("data", (data) => handleOutput(data, true));
2070
+ child?.stderr.on("data", (data) => handleOutput(data, false));
2071
+ child?.once("error", (error) => reject(error));
2072
+ child?.once("exit", (code) => {
2073
+ reject(new Error(`cloudflared exited (${code ?? "unknown"})`));
2074
+ });
2075
+ });
2076
+ };
2077
+ const stop = async () => {
2078
+ if (!child) {
2079
+ return;
2080
+ }
2081
+ child.kill("SIGTERM");
2082
+ child = null;
2083
+ };
2084
+ return { start, stop };
2085
+ };
2086
+
2087
+ // src/server/auth.ts
2088
+ import { randomBytes, createHash } from "crypto";
2089
+ var SESSION_COOKIE_NAME = "termbridge_session";
2090
+ var hashToken = (token) => createHash("sha256").update(token).digest("hex");
2091
+ var createSessionId = () => randomBytes(18).toString("base64url");
2092
+ var parseCookies = (cookieHeader) => {
2093
+ const cookies = {};
2094
+ if (!cookieHeader) {
2095
+ return cookies;
2096
+ }
2097
+ for (const part of cookieHeader.split(";")) {
2098
+ const [name, ...rest] = part.trim().split("=");
2099
+ if (!name) {
2100
+ continue;
2101
+ }
2102
+ cookies[name] = rest.join("=");
2103
+ }
2104
+ return cookies;
2105
+ };
2106
+ var createAuth = ({
2107
+ tokenTtlMs,
2108
+ sessionIdleMs,
2109
+ sessionMaxMs,
2110
+ redeemLimiter,
2111
+ cookieSecure,
2112
+ now
2113
+ }) => {
2114
+ const clock = now ?? (() => Date.now());
2115
+ const secureCookie = cookieSecure ?? true;
2116
+ const tokens = /* @__PURE__ */ new Map();
2117
+ const sessions = /* @__PURE__ */ new Map();
2118
+ const issueToken = () => {
2119
+ const token = randomBytes(16).toString("base64url");
2120
+ const record = {
2121
+ hash: hashToken(token),
2122
+ expiresAt: clock() + tokenTtlMs,
2123
+ consumed: false
2124
+ };
2125
+ tokens.set(record.hash, record);
2126
+ return { token };
2127
+ };
2128
+ const redeemToken = (token, ip) => {
2129
+ if (redeemLimiter && !redeemLimiter.allow(ip)) {
2130
+ return null;
2131
+ }
2132
+ const record = tokens.get(hashToken(token));
2133
+ if (!record || record.consumed || record.expiresAt <= clock()) {
2134
+ return null;
2135
+ }
2136
+ record.consumed = true;
2137
+ const session = {
2138
+ id: createSessionId(),
2139
+ createdAt: clock(),
2140
+ lastSeen: clock()
2141
+ };
2142
+ sessions.set(session.id, session);
2143
+ return session;
2144
+ };
2145
+ const getSession = (sessionId) => {
2146
+ const session = sessions.get(sessionId);
2147
+ if (!session) {
2148
+ return null;
2149
+ }
2150
+ const nowMs = clock();
2151
+ if (nowMs - session.createdAt > sessionMaxMs) {
2152
+ sessions.delete(sessionId);
2153
+ return null;
2154
+ }
2155
+ if (nowMs - session.lastSeen > sessionIdleMs) {
2156
+ sessions.delete(sessionId);
2157
+ return null;
2158
+ }
2159
+ session.lastSeen = nowMs;
2160
+ return session;
2161
+ };
2162
+ const getSessionFromRequest = (request) => {
2163
+ const cookies = parseCookies(request.headers.cookie);
2164
+ const sessionId = cookies[SESSION_COOKIE_NAME];
2165
+ if (!sessionId) {
2166
+ return null;
2167
+ }
2168
+ return getSession(sessionId);
2169
+ };
2170
+ const createSessionCookie = (sessionId) => {
2171
+ const parts = [
2172
+ `${SESSION_COOKIE_NAME}=${sessionId}`,
2173
+ "Path=/",
2174
+ "HttpOnly",
2175
+ "SameSite=Lax"
2176
+ ];
2177
+ if (secureCookie) {
2178
+ parts.splice(3, 0, "Secure");
2179
+ }
2180
+ return parts.join("; ");
2181
+ };
2182
+ return {
2183
+ issueToken,
2184
+ redeemToken,
2185
+ getSession,
2186
+ getSessionFromRequest,
2187
+ createSessionCookie
2188
+ };
2189
+ };
2190
+
2191
+ // src/server/rate-limit.ts
2192
+ var createRateLimiter = ({ limit, windowMs, now }) => {
2193
+ const clock = now ?? (() => Date.now());
2194
+ const buckets = /* @__PURE__ */ new Map();
2195
+ const allow = (key) => {
2196
+ const current = clock();
2197
+ const bucket = buckets.get(key);
2198
+ if (!bucket || current >= bucket.resetAt) {
2199
+ buckets.set(key, { count: 1, resetAt: current + windowMs });
2200
+ return true;
2201
+ }
2202
+ if (bucket.count >= limit) {
2203
+ return false;
2204
+ }
2205
+ bucket.count += 1;
2206
+ return true;
2207
+ };
2208
+ return { allow };
2209
+ };
2210
+
2211
+ // src/server/terminal-registry.ts
2212
+ import { randomBytes as randomBytes2 } from "crypto";
2213
+ var createTerminalId = () => randomBytes2(8).toString("hex");
2214
+ var createTerminalRegistry = () => {
2215
+ const terminals = /* @__PURE__ */ new Map();
2216
+ const add = (sessionName, label, source) => {
2217
+ const id = createTerminalId();
2218
+ const record = {
2219
+ id,
2220
+ label,
2221
+ status: "running",
2222
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2223
+ source,
2224
+ sessionName
2225
+ };
2226
+ terminals.set(id, record);
2227
+ return record;
2228
+ };
2229
+ const list = () => Array.from(terminals.values()).map(({ sessionName: _sessionName, ...rest }) => rest);
2230
+ const get = (id) => terminals.get(id) ?? null;
2231
+ const remove = (id) => {
2232
+ terminals.delete(id);
2233
+ };
2234
+ const getSessionNames = () => Array.from(terminals.values()).map((record) => record.sessionName);
2235
+ return { add, list, get, remove, getSessionNames };
2236
+ };
2237
+
2238
+ // src/server/server.ts
2239
+ import { createServer as createHttpServer } from "http";
2240
+ import { randomBytes as randomBytes3 } from "crypto";
2241
+ import { WebSocketServer } from "ws";
2242
+
2243
+ // ../packages/shared/src/index.ts
2244
+ var TERMINAL_CONTROL_KEYS = [
2245
+ "ctrl_c",
2246
+ "esc",
2247
+ "tab",
2248
+ "up",
2249
+ "down",
2250
+ "left",
2251
+ "right"
2252
+ ];
2253
+
2254
+ // src/server/static.ts
2255
+ import { readFile } from "fs/promises";
2256
+ import { extname, resolve as resolve2 } from "path";
2257
+ var contentTypes = {
2258
+ ".html": "text/html",
2259
+ ".js": "text/javascript",
2260
+ ".css": "text/css",
2261
+ ".json": "application/json",
2262
+ ".svg": "image/svg+xml",
2263
+ ".png": "image/png",
2264
+ ".ico": "image/x-icon"
2265
+ };
2266
+ var getContentType = (filePath) => contentTypes[extname(filePath)] ?? "text/plain";
2267
+ var createStaticHandler = (uiDistPath, basePath) => {
2268
+ const normalizedBase = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
2269
+ return async (request, response) => {
2270
+ const rawPath = request.url ?? "/";
2271
+ const url = new URL(rawPath, `http://${request.headers.host ?? "localhost"}`);
2272
+ if (rawPath.includes("..")) {
2273
+ response.statusCode = 403;
2274
+ response.end("forbidden");
2275
+ return true;
2276
+ }
2277
+ if (!url.pathname.startsWith(normalizedBase)) {
2278
+ return false;
2279
+ }
2280
+ const relative = url.pathname.slice(normalizedBase.length) || "/";
2281
+ const filePath = relative === "/" ? "/index.html" : relative;
2282
+ const absolutePath = resolve2(uiDistPath, `.${filePath}`);
2283
+ try {
2284
+ const payload = await readFile(absolutePath);
2285
+ response.statusCode = 200;
2286
+ response.setHeader("Content-Type", getContentType(absolutePath));
2287
+ response.end(payload);
2288
+ return true;
2289
+ } catch {
2290
+ try {
2291
+ const fallback = await readFile(resolve2(uiDistPath, "index.html"));
2292
+ response.statusCode = 200;
2293
+ response.setHeader("Content-Type", "text/html");
2294
+ response.end(fallback);
2295
+ return true;
2296
+ } catch {
2297
+ response.statusCode = 404;
2298
+ response.end("not found");
2299
+ return true;
2300
+ }
2301
+ }
2302
+ };
2303
+ };
2304
+
2305
+ // src/server/server.ts
2306
+ var jsonResponse = (response, status, payload) => {
2307
+ const body = JSON.stringify(payload);
2308
+ response.statusCode = status;
2309
+ response.setHeader("Content-Type", "application/json");
2310
+ response.setHeader("Content-Length", Buffer.byteLength(body));
2311
+ response.end(body);
2312
+ };
2313
+ var readJsonBody = async (request) => {
2314
+ const chunks = [];
2315
+ for await (const chunk of request) {
2316
+ chunks.push(chunk);
2317
+ }
2318
+ const body = Buffer.concat(chunks).toString("utf8").trim();
2319
+ if (!body) {
2320
+ return null;
2321
+ }
2322
+ try {
2323
+ return JSON.parse(body);
2324
+ } catch {
2325
+ return null;
2326
+ }
2327
+ };
2328
+ var getIp = (request) => String(request.socket.remoteAddress);
2329
+ var isAllowedOrigin = (origin, host) => {
2330
+ if (!origin || !host) {
2331
+ return true;
2332
+ }
2333
+ try {
2334
+ return new URL(origin).host === host;
2335
+ } catch {
2336
+ return false;
2337
+ }
2338
+ };
2339
+ var allowedControlKeys = new Set(TERMINAL_CONTROL_KEYS);
2340
+ var parseClientMessage = (payload) => {
2341
+ const text = typeof payload === "string" ? payload : payload.toString();
2342
+ try {
2343
+ const parsed = JSON.parse(text);
2344
+ if (parsed.type === "input" && typeof parsed.data === "string") {
2345
+ return parsed;
2346
+ }
2347
+ if (parsed.type === "resize" && typeof parsed.cols === "number" && typeof parsed.rows === "number") {
2348
+ return parsed;
2349
+ }
2350
+ if (parsed.type === "control" && allowedControlKeys.has(parsed.key)) {
2351
+ return parsed;
2352
+ }
2353
+ return null;
2354
+ } catch {
2355
+ return null;
2356
+ }
2357
+ };
2358
+ var sendWsMessage = (socket, message) => {
2359
+ socket.send(JSON.stringify(message));
2360
+ };
2361
+ var createSessionName = () => `termbridge-${randomBytes3(4).toString("hex")}`;
2362
+ var createAppServer = (deps) => {
2363
+ const staticHandler = createStaticHandler(deps.uiDistPath, "/app");
2364
+ const wss = new WebSocketServer({ noServer: true });
2365
+ const connectionInfo = /* @__PURE__ */ new WeakMap();
2366
+ const server = createHttpServer(async (request, response) => {
2367
+ const url = new URL(request.url, `http://${request.headers.host}`);
2368
+ if (request.method === "GET" && url.pathname === "/healthz") {
2369
+ response.statusCode = 200;
2370
+ response.end("ok");
2371
+ return;
2372
+ }
2373
+ if (request.method === "GET" && url.pathname === "/") {
2374
+ response.statusCode = 302;
2375
+ response.setHeader("Location", "/app");
2376
+ response.end();
2377
+ return;
2378
+ }
2379
+ if (request.method === "GET" && url.pathname.startsWith("/s/")) {
2380
+ const token = url.pathname.slice(3);
2381
+ const ip = getIp(request);
2382
+ if (!deps.redemptionLimiter.allow(ip)) {
2383
+ response.statusCode = 429;
2384
+ response.end("rate limited");
2385
+ return;
2386
+ }
2387
+ const session = deps.auth.redeemToken(token, ip);
2388
+ if (!session) {
2389
+ response.statusCode = 401;
2390
+ response.end("invalid token");
2391
+ return;
2392
+ }
2393
+ response.statusCode = 302;
2394
+ response.setHeader("Set-Cookie", deps.auth.createSessionCookie(session.id));
2395
+ response.setHeader("Location", "/app");
2396
+ response.end();
2397
+ return;
2398
+ }
2399
+ if (url.pathname === "/api/terminals") {
2400
+ const session = deps.auth.getSessionFromRequest(request);
2401
+ if (!session) {
2402
+ response.statusCode = 401;
2403
+ response.end("unauthorized");
2404
+ return;
2405
+ }
2406
+ if (request.method === "GET") {
2407
+ const payload = { terminals: deps.terminalRegistry.list() };
2408
+ jsonResponse(response, 200, payload);
2409
+ return;
2410
+ }
2411
+ if (request.method === "POST") {
2412
+ const body = await readJsonBody(request);
2413
+ if (body && typeof body !== "object") {
2414
+ response.statusCode = 400;
2415
+ response.end("invalid body");
2416
+ return;
2417
+ }
2418
+ const name = body && typeof body.name === "string" ? body.name : createSessionName();
2419
+ const created = await deps.terminalBackend.createSession(name);
2420
+ const record = deps.terminalRegistry.add(created.name, created.name, "tmux");
2421
+ jsonResponse(response, 201, record);
2422
+ return;
2423
+ }
2424
+ }
2425
+ const handled = await staticHandler(request, response);
2426
+ if (!handled) {
2427
+ response.statusCode = 404;
2428
+ response.end("not found");
2429
+ }
2430
+ });
2431
+ server.on("upgrade", (request, socket, head) => {
2432
+ const url = new URL(request.url, `http://${request.headers.host}`);
2433
+ if (!url.pathname.startsWith("/ws/terminal/")) {
2434
+ socket.destroy();
2435
+ return;
2436
+ }
2437
+ if (!isAllowedOrigin(request.headers.origin, request.headers.host)) {
2438
+ socket.destroy();
2439
+ return;
2440
+ }
2441
+ const terminalId = url.pathname.split("/").pop();
2442
+ if (!terminalId) {
2443
+ socket.destroy();
2444
+ return;
2445
+ }
2446
+ const ip = getIp(request);
2447
+ if (!deps.wsLimiter.allow(ip)) {
2448
+ socket.destroy();
2449
+ return;
2450
+ }
2451
+ const session = deps.auth.getSessionFromRequest(request);
2452
+ if (!session) {
2453
+ socket.destroy();
2454
+ return;
2455
+ }
2456
+ const record = deps.terminalRegistry.get(terminalId);
2457
+ if (!record) {
2458
+ socket.destroy();
2459
+ return;
2460
+ }
2461
+ wss.handleUpgrade(request, socket, head, (ws) => {
2462
+ connectionInfo.set(ws, { sessionName: record.sessionName });
2463
+ wss.emit("connection", ws, request);
2464
+ });
2465
+ });
2466
+ wss.on("connection", (socket) => {
2467
+ const info = connectionInfo.get(socket);
2468
+ sendWsMessage(socket, { type: "status", state: "connected" });
2469
+ const unsubscribe = deps.terminalBackend.onOutput(info.sessionName, (data) => {
2470
+ sendWsMessage(socket, { type: "output", data });
2471
+ });
2472
+ socket.on("message", (payload) => {
2473
+ const message = parseClientMessage(payload);
2474
+ if (!message) {
2475
+ sendWsMessage(socket, {
2476
+ type: "status",
2477
+ state: "error",
2478
+ message: "invalid payload"
2479
+ });
2480
+ return;
2481
+ }
2482
+ if (message.type === "input") {
2483
+ void deps.terminalBackend.write(info.sessionName, message.data);
2484
+ return;
2485
+ }
2486
+ if (message.type === "resize") {
2487
+ void deps.terminalBackend.resize(info.sessionName, message.cols, message.rows);
2488
+ return;
2489
+ }
2490
+ void deps.terminalBackend.sendControl(info.sessionName, message.key);
2491
+ });
2492
+ socket.on("close", () => {
2493
+ unsubscribe();
2494
+ });
2495
+ });
2496
+ const listen = (port) => new Promise((resolve4, _reject) => {
2497
+ server.listen(port, "127.0.0.1", () => {
2498
+ const address = server.address();
2499
+ resolve4({
2500
+ port: address.port,
2501
+ close: async () => {
2502
+ await new Promise((closeResolve) => server.close(() => closeResolve()));
2503
+ wss.close();
2504
+ }
2505
+ });
2506
+ });
2507
+ });
2508
+ return { listen };
2509
+ };
2510
+
2511
+ // src/cli/start.ts
2512
+ var resolveUiDistPath = () => {
2513
+ const currentDir = dirname2(fileURLToPath(import.meta.url));
2514
+ const candidates = [
2515
+ resolve3(currentDir, "../../ui/dist"),
2516
+ resolve3(currentDir, "../ui/dist"),
2517
+ resolve3(process.cwd(), "ui/dist"),
2518
+ resolve3(process.cwd(), "cli/ui/dist")
2519
+ ];
2520
+ for (const candidate of candidates) {
2521
+ if (existsSync(candidate)) {
2522
+ return candidate;
2523
+ }
2524
+ }
2525
+ return candidates[0];
2526
+ };
2527
+ var createDefaultLogger = () => ({
2528
+ info: (message) => console.log(message),
2529
+ warn: (message) => console.warn(message),
2530
+ error: (message) => console.error(message)
2531
+ });
2532
+ var parseSessionCount = (value) => {
2533
+ if (!value) {
2534
+ return 1;
2535
+ }
2536
+ const parsed = Number.parseInt(value, 10);
2537
+ if (!Number.isFinite(parsed) || parsed < 1) {
2538
+ return 1;
2539
+ }
2540
+ return parsed;
2541
+ };
2542
+ var startCommand = async (options, deps = {}) => {
2543
+ const logger = deps.logger ?? createDefaultLogger();
2544
+ const processRef = deps.process ?? process;
2545
+ const env = processRef.env ?? {};
2546
+ const insecureCookie = env.TERMBRIDGE_INSECURE_COOKIE === "1" || env.TERMBRIDGE_INSECURE_COOKIE === "true";
2547
+ const auth = (deps.createAuth ?? (() => createAuth({
2548
+ tokenTtlMs: 9e4,
2549
+ sessionIdleMs: 30 * 6e4,
2550
+ sessionMaxMs: 8 * 60 * 6e4,
2551
+ cookieSecure: !insecureCookie
2552
+ })))();
2553
+ const terminalBackend = (deps.createTerminalBackend ?? (() => createTmuxBackend()))();
2554
+ const terminalRegistry = (deps.createTerminalRegistry ?? (() => createTerminalRegistry()))();
2555
+ const tunnelProvider = (deps.createTunnelProvider ?? (() => createCloudflaredProvider()))();
2556
+ const wsLimiter = createRateLimiter({ limit: 30, windowMs: 6e4 });
2557
+ const serverFactory = deps.createServer ?? ((serverDeps) => createAppServer({
2558
+ ...serverDeps,
2559
+ redemptionLimiter: createRateLimiter({ limit: 5, windowMs: 6e4 }),
2560
+ wsLimiter,
2561
+ logger
2562
+ }));
2563
+ const server = serverFactory({
2564
+ uiDistPath: resolveUiDistPath(),
2565
+ auth,
2566
+ terminalRegistry,
2567
+ terminalBackend
2568
+ });
2569
+ const started = await server.listen(options.port ?? 0);
2570
+ const localUrl = `http://127.0.0.1:${started.port}`;
2571
+ const sessionName = options.session ?? `termbridge-${started.port}`;
2572
+ const sessionCount = parseSessionCount(env.TERMBRIDGE_SESSIONS);
2573
+ const createdSessions = [];
2574
+ for (let index = 0; index < sessionCount; index += 1) {
2575
+ const suffix = index === 0 ? "" : `-${index + 1}`;
2576
+ const nextName = `${sessionName}${suffix}`;
2577
+ const session = await terminalBackend.createSession(nextName);
2578
+ terminalRegistry.add(session.name, session.name, "tmux");
2579
+ createdSessions.push(session.name);
2580
+ }
2581
+ const { token } = auth.issueToken();
2582
+ let publicUrl = "";
2583
+ try {
2584
+ const result = await tunnelProvider.start(localUrl);
2585
+ publicUrl = result.publicUrl;
2586
+ } catch (error) {
2587
+ const message = error instanceof Error ? error.message : "unknown error";
2588
+ logger.error(`Tunnel failed: ${message}`);
2589
+ await started.close();
2590
+ throw error;
2591
+ }
2592
+ const redeemUrl = `${publicUrl}/s/${token}`;
2593
+ logger.info(`Local server: ${localUrl}`);
2594
+ logger.info(`Tunnel URL: ${redeemUrl}`);
2595
+ if (!options.noQr && deps.qr) {
2596
+ deps.qr.generate(redeemUrl, { small: true });
2597
+ } else if (!options.noQr) {
2598
+ logger.warn("QR output unavailable");
2599
+ }
2600
+ const stop = async () => {
2601
+ await tunnelProvider.stop();
2602
+ await started.close();
2603
+ if (options.killOnExit) {
2604
+ for (const name of createdSessions) {
2605
+ await terminalBackend.closeSession(name);
2606
+ }
2607
+ }
2608
+ };
2609
+ const shutdown = () => {
2610
+ void stop();
2611
+ };
2612
+ processRef.on("SIGINT", shutdown);
2613
+ processRef.on("SIGTERM", shutdown);
2614
+ return { localUrl, publicUrl, token, stop };
2615
+ };
2616
+
2617
+ // src/cli/ink.tsx
2618
+ var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2619
+ var InfoRow = ({ label, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { children: [
2620
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "gray", bold: true, children: label.padEnd(8) }),
2621
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: value })
2622
+ ] });
2623
+ var InkCliView = ({
2624
+ state,
2625
+ options,
2626
+ localUrl,
2627
+ publicUrl,
2628
+ redeemUrl,
2629
+ sessionName,
2630
+ qr
2631
+ }) => {
2632
+ const statusText = state === "starting" ? "Starting\u2026" : "Running";
2633
+ const statusColor = state === "starting" ? "yellow" : "green";
2634
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { flexDirection: "column", padding: 1, children: [
2635
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
2636
+ Box,
2637
+ {
2638
+ flexDirection: "column",
2639
+ borderStyle: "round",
2640
+ borderColor: "cyan",
2641
+ paddingX: 2,
2642
+ paddingY: 1,
2643
+ children: [
2644
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "cyanBright", bold: true, children: "Termbridge" }),
2645
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: statusColor, children: statusText }),
2646
+ state === "running" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box, { flexDirection: "column", marginTop: 1, gap: 1, children: [
2647
+ localUrl ? InfoRow({ label: "Local:", value: localUrl }) : null,
2648
+ publicUrl ? InfoRow({ label: "Public:", value: publicUrl }) : null,
2649
+ redeemUrl ? InfoRow({ label: "Share:", value: redeemUrl }) : null,
2650
+ sessionName ? InfoRow({ label: "Session:", value: sessionName }) : null,
2651
+ InfoRow({ label: "Tunnel:", value: options.tunnel })
2652
+ ] }) : null
2653
+ ]
2654
+ }
2655
+ ),
2656
+ state === "running" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, { flexDirection: "column", marginTop: 1, children: options.noQr ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "gray", children: "QR disabled (--no-qr)" }) : qr ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { children: qr.trimEnd() }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "gray", children: "Generating QR\u2026" }) }) : null,
2657
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { color: "gray", children: "Press Ctrl+C to stop." }) })
2658
+ ] });
2659
+ };
2660
+ var createSilentLogger = (externalLogger) => ({
2661
+ info: (message) => externalLogger?.info(message),
2662
+ warn: (message) => externalLogger?.warn(message),
2663
+ error: (message) => externalLogger?.error(message)
2664
+ });
2665
+ var buildSessionName = (options, localUrl) => {
2666
+ if (options.session) {
2667
+ return options.session;
2668
+ }
2669
+ try {
2670
+ const url = new URL(localUrl);
2671
+ return `termbridge-${url.port}`;
2672
+ } catch {
2673
+ return "termbridge";
2674
+ }
2675
+ };
2676
+ var buildRedeemUrl = (result) => `${result.publicUrl}/s/${result.token}`;
2677
+ var generateQr = async (text) => new Promise((resolve4) => {
2678
+ qrcode.generate(text, { small: true }, (output) => resolve4(output));
2679
+ });
2680
+ var runInkCli = async (options, deps = {}) => {
2681
+ const processRef = deps.process ?? process;
2682
+ const stderr = processRef.stderr;
2683
+ const renderImpl = deps.render ?? render;
2684
+ const start = deps.startCommand ?? startCommand;
2685
+ const logger = createSilentLogger(deps.logger);
2686
+ const instance = renderImpl(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(InkCliView, { state: "starting", options }));
2687
+ try {
2688
+ const result = await start(options, {
2689
+ ...deps,
2690
+ process: processRef,
2691
+ logger,
2692
+ qr: { generate: () => void 0 }
2693
+ });
2694
+ const redeemUrl = buildRedeemUrl(result);
2695
+ const sessionName = buildSessionName(options, result.localUrl);
2696
+ const qr = options.noQr ? null : await generateQr(redeemUrl);
2697
+ instance.rerender(
2698
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
2699
+ InkCliView,
2700
+ {
2701
+ state: "running",
2702
+ options,
2703
+ localUrl: result.localUrl,
2704
+ publicUrl: result.publicUrl,
2705
+ redeemUrl,
2706
+ sessionName,
2707
+ qr
2708
+ }
2709
+ )
2710
+ );
2711
+ return 0;
2712
+ } catch (error) {
2713
+ const message = error instanceof Error ? error.message : "unknown error";
2714
+ stderr.write(`${message}
2715
+ `);
2716
+ instance.unmount();
2717
+ return 1;
2718
+ }
2719
+ };
2720
+
2721
+ // src/cli/run.ts
2722
+ var createLogger = (stdout, stderr) => ({
2723
+ info: (message) => stdout.write(`${message}
2724
+ `),
2725
+ warn: (message) => stderr.write(`${message}
2726
+ `),
2727
+ error: (message) => stderr.write(`${message}
2728
+ `)
2729
+ });
2730
+ var shouldUseInk = (stdout) => Boolean(stdout && "isTTY" in stdout && stdout.isTTY);
2731
+ var runCli = async (argv, deps = {}) => {
2732
+ const stdout = deps.stdout ?? process.stdout;
2733
+ const stderr = deps.stderr ?? process.stderr;
2734
+ const processRef = deps.process ?? process;
2735
+ try {
2736
+ const parsed = parseArgs(argv);
2737
+ if (parsed.command === "help") {
2738
+ stdout.write(helpText);
2739
+ return 0;
2740
+ }
2741
+ if (shouldUseInk(stdout)) {
2742
+ return await runInkCli(parsed.options, {
2743
+ process: processRef
2744
+ });
2745
+ }
2746
+ await startCommand(parsed.options, {
2747
+ process: processRef,
2748
+ logger: createLogger(stdout, stderr),
2749
+ qr: {
2750
+ generate: (text, options) => qrcode2.generate(text, options)
2751
+ }
2752
+ });
2753
+ return 0;
2754
+ } catch (error) {
2755
+ const message = error instanceof Error ? error.message : "unknown error";
2756
+ stderr.write(`${message}
2757
+ `);
2758
+ return 1;
2759
+ }
2760
+ };
2761
+
2762
+ // src/bin.ts
2763
+ var main = async (argv = process.argv.slice(2), proc = process) => {
2764
+ const exitCode = await runCli(argv, { process: proc, stdout: proc.stdout, stderr: proc.stderr });
2765
+ proc.exitCode = exitCode;
2766
+ };
2767
+ if (process.env.NODE_ENV !== "test") {
2768
+ void main();
2769
+ }
2770
+ export {
2771
+ main
2772
+ };
2773
+ /*! Bundled license information:
2774
+
2775
+ react/cjs/react-jsx-runtime.production.js:
2776
+ (**
2777
+ * @license React
2778
+ * react-jsx-runtime.production.js
2779
+ *
2780
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2781
+ *
2782
+ * This source code is licensed under the MIT license found in the
2783
+ * LICENSE file in the root directory of this source tree.
2784
+ *)
2785
+
2786
+ react/cjs/react.production.js:
2787
+ (**
2788
+ * @license React
2789
+ * react.production.js
2790
+ *
2791
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2792
+ *
2793
+ * This source code is licensed under the MIT license found in the
2794
+ * LICENSE file in the root directory of this source tree.
2795
+ *)
2796
+
2797
+ react/cjs/react.development.js:
2798
+ (**
2799
+ * @license React
2800
+ * react.development.js
2801
+ *
2802
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2803
+ *
2804
+ * This source code is licensed under the MIT license found in the
2805
+ * LICENSE file in the root directory of this source tree.
2806
+ *)
2807
+
2808
+ react/cjs/react-jsx-runtime.development.js:
2809
+ (**
2810
+ * @license React
2811
+ * react-jsx-runtime.development.js
2812
+ *
2813
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2814
+ *
2815
+ * This source code is licensed under the MIT license found in the
2816
+ * LICENSE file in the root directory of this source tree.
2817
+ *)
2818
+ */
2819
+ //# sourceMappingURL=bin.js.map