@lobehub/cli 0.0.1-canary.3 → 0.0.1-canary.4

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.
Files changed (2) hide show
  1. package/dist/index.js +2214 -6
  2. package/package.json +13 -12
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import path4 from "path";
12
12
  import { randomUUID } from "crypto";
13
13
  import { EventEmitter } from "events";
14
14
  import os from "os";
15
- import WebSocket from "ws";
15
+ import WebSocket2 from "ws";
16
16
  var DEFAULT_GATEWAY_URL = "https://device-gateway.lobehub.com";
17
17
  var HEARTBEAT_INTERVAL = 3e4;
18
18
  var INITIAL_RECONNECT_DELAY = 1e3;
@@ -93,7 +93,7 @@ var GatewayClient = class extends EventEmitter {
93
93
  try {
94
94
  const wsUrl = this.buildWsUrl();
95
95
  this.logger.debug(`Connecting to: ${wsUrl}`);
96
- const ws = new WebSocket(wsUrl);
96
+ const ws = new WebSocket2(wsUrl);
97
97
  ws.on("open", this.handleOpen);
98
98
  ws.on("message", this.handleMessage);
99
99
  ws.on("close", this.handleClose);
@@ -229,14 +229,14 @@ var GatewayClient = class extends EventEmitter {
229
229
  }
230
230
  // ─── Helpers ───
231
231
  sendMessage(data) {
232
- if (this.ws?.readyState === WebSocket.OPEN) {
232
+ if (this.ws?.readyState === WebSocket2.OPEN) {
233
233
  this.ws.send(JSON.stringify(data));
234
234
  }
235
235
  }
236
236
  closeWebSocket() {
237
237
  if (this.ws) {
238
238
  this.ws.removeAllListeners();
239
- if (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING) {
239
+ if (this.ws.readyState === WebSocket2.OPEN || this.ws.readyState === WebSocket2.CONNECTING) {
240
240
  this.ws.close(1e3, "Client disconnect");
241
241
  }
242
242
  this.ws = null;
@@ -1249,6 +1249,2208 @@ function collectSystemInfo() {
1249
1249
  };
1250
1250
  }
1251
1251
 
1252
+ // src/commands/doc.ts
1253
+ import fs4 from "fs";
1254
+ import readline from "readline";
1255
+ import pc2 from "picocolors";
1256
+
1257
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/objectSpread2-BvkFp-_Y.mjs
1258
+ var __create = Object.create;
1259
+ var __defProp = Object.defineProperty;
1260
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1261
+ var __getOwnPropNames = Object.getOwnPropertyNames;
1262
+ var __getProtoOf = Object.getPrototypeOf;
1263
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1264
+ var __commonJS = (cb, mod) => function() {
1265
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
1266
+ };
1267
+ var __copyProps = (to, from, except, desc) => {
1268
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
1269
+ key = keys[i];
1270
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
1271
+ get: ((k) => from[k]).bind(null, key),
1272
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
1273
+ });
1274
+ }
1275
+ return to;
1276
+ };
1277
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
1278
+ value: mod,
1279
+ enumerable: true
1280
+ }) : target, mod));
1281
+ var require_typeof = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
1282
+ function _typeof$2(o) {
1283
+ "@babel/helpers - typeof";
1284
+ return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
1285
+ return typeof o$1;
1286
+ } : function(o$1) {
1287
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
1288
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
1289
+ }
1290
+ module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
1291
+ } });
1292
+ var require_toPrimitive = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
1293
+ var _typeof$1 = require_typeof()["default"];
1294
+ function toPrimitive$1(t, r) {
1295
+ if ("object" != _typeof$1(t) || !t) return t;
1296
+ var e = t[Symbol.toPrimitive];
1297
+ if (void 0 !== e) {
1298
+ var i = e.call(t, r || "default");
1299
+ if ("object" != _typeof$1(i)) return i;
1300
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1301
+ }
1302
+ return ("string" === r ? String : Number)(t);
1303
+ }
1304
+ module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
1305
+ } });
1306
+ var require_toPropertyKey = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
1307
+ var _typeof = require_typeof()["default"];
1308
+ var toPrimitive = require_toPrimitive();
1309
+ function toPropertyKey$1(t) {
1310
+ var i = toPrimitive(t, "string");
1311
+ return "symbol" == _typeof(i) ? i : i + "";
1312
+ }
1313
+ module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
1314
+ } });
1315
+ var require_defineProperty = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
1316
+ var toPropertyKey = require_toPropertyKey();
1317
+ function _defineProperty(e, r, t) {
1318
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1319
+ value: t,
1320
+ enumerable: true,
1321
+ configurable: true,
1322
+ writable: true
1323
+ }) : e[r] = t, e;
1324
+ }
1325
+ module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
1326
+ } });
1327
+ var require_objectSpread2 = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
1328
+ var defineProperty = require_defineProperty();
1329
+ function ownKeys(e, r) {
1330
+ var t = Object.keys(e);
1331
+ if (Object.getOwnPropertySymbols) {
1332
+ var o = Object.getOwnPropertySymbols(e);
1333
+ r && (o = o.filter(function(r$1) {
1334
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
1335
+ })), t.push.apply(t, o);
1336
+ }
1337
+ return t;
1338
+ }
1339
+ function _objectSpread2(e) {
1340
+ for (var r = 1; r < arguments.length; r++) {
1341
+ var t = null != arguments[r] ? arguments[r] : {};
1342
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r$1) {
1343
+ defineProperty(e, r$1, t[r$1]);
1344
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
1345
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
1346
+ });
1347
+ }
1348
+ return e;
1349
+ }
1350
+ module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
1351
+ } });
1352
+
1353
+ // node_modules/.pnpm/@trpc+server@11.12.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-UMO3vUa_.mjs
1354
+ function observable(subscribe) {
1355
+ const self = {
1356
+ subscribe(observer) {
1357
+ let teardownRef = null;
1358
+ let isDone = false;
1359
+ let unsubscribed = false;
1360
+ let teardownImmediately = false;
1361
+ function unsubscribe() {
1362
+ if (teardownRef === null) {
1363
+ teardownImmediately = true;
1364
+ return;
1365
+ }
1366
+ if (unsubscribed) return;
1367
+ unsubscribed = true;
1368
+ if (typeof teardownRef === "function") teardownRef();
1369
+ else if (teardownRef) teardownRef.unsubscribe();
1370
+ }
1371
+ teardownRef = subscribe({
1372
+ next(value) {
1373
+ var _observer$next;
1374
+ if (isDone) return;
1375
+ (_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value);
1376
+ },
1377
+ error(err) {
1378
+ var _observer$error;
1379
+ if (isDone) return;
1380
+ isDone = true;
1381
+ (_observer$error = observer.error) === null || _observer$error === void 0 || _observer$error.call(observer, err);
1382
+ unsubscribe();
1383
+ },
1384
+ complete() {
1385
+ var _observer$complete;
1386
+ if (isDone) return;
1387
+ isDone = true;
1388
+ (_observer$complete = observer.complete) === null || _observer$complete === void 0 || _observer$complete.call(observer);
1389
+ unsubscribe();
1390
+ }
1391
+ });
1392
+ if (teardownImmediately) unsubscribe();
1393
+ return { unsubscribe };
1394
+ },
1395
+ pipe(...operations) {
1396
+ return operations.reduce(pipeReducer, self);
1397
+ }
1398
+ };
1399
+ return self;
1400
+ }
1401
+ function pipeReducer(prev, fn) {
1402
+ return fn(prev);
1403
+ }
1404
+ function observableToPromise(observable$1) {
1405
+ const ac = new AbortController();
1406
+ const promise = new Promise((resolve, reject) => {
1407
+ let isDone = false;
1408
+ function onDone() {
1409
+ if (isDone) return;
1410
+ isDone = true;
1411
+ obs$.unsubscribe();
1412
+ }
1413
+ ac.signal.addEventListener("abort", () => {
1414
+ reject(ac.signal.reason);
1415
+ });
1416
+ const obs$ = observable$1.subscribe({
1417
+ next(data) {
1418
+ isDone = true;
1419
+ resolve(data);
1420
+ onDone();
1421
+ },
1422
+ error(data) {
1423
+ reject(data);
1424
+ },
1425
+ complete() {
1426
+ ac.abort();
1427
+ onDone();
1428
+ }
1429
+ });
1430
+ });
1431
+ return promise;
1432
+ }
1433
+
1434
+ // node_modules/.pnpm/@trpc+server@11.12.0_typescript@5.9.3/node_modules/@trpc/server/dist/observable-CUiPknO-.mjs
1435
+ function share(_opts) {
1436
+ return (source) => {
1437
+ let refCount = 0;
1438
+ let subscription = null;
1439
+ const observers = [];
1440
+ function startIfNeeded() {
1441
+ if (subscription) return;
1442
+ subscription = source.subscribe({
1443
+ next(value) {
1444
+ for (const observer of observers) {
1445
+ var _observer$next;
1446
+ (_observer$next = observer.next) === null || _observer$next === void 0 || _observer$next.call(observer, value);
1447
+ }
1448
+ },
1449
+ error(error) {
1450
+ for (const observer of observers) {
1451
+ var _observer$error;
1452
+ (_observer$error = observer.error) === null || _observer$error === void 0 || _observer$error.call(observer, error);
1453
+ }
1454
+ },
1455
+ complete() {
1456
+ for (const observer of observers) {
1457
+ var _observer$complete;
1458
+ (_observer$complete = observer.complete) === null || _observer$complete === void 0 || _observer$complete.call(observer);
1459
+ }
1460
+ }
1461
+ });
1462
+ }
1463
+ function resetIfNeeded() {
1464
+ if (refCount === 0 && subscription) {
1465
+ const _sub = subscription;
1466
+ subscription = null;
1467
+ _sub.unsubscribe();
1468
+ }
1469
+ }
1470
+ return observable((subscriber) => {
1471
+ refCount++;
1472
+ observers.push(subscriber);
1473
+ startIfNeeded();
1474
+ return { unsubscribe() {
1475
+ refCount--;
1476
+ resetIfNeeded();
1477
+ const index = observers.findIndex((v) => v === subscriber);
1478
+ if (index > -1) observers.splice(index, 1);
1479
+ } };
1480
+ });
1481
+ };
1482
+ }
1483
+ function behaviorSubject(initialValue) {
1484
+ let value = initialValue;
1485
+ const observerList = [];
1486
+ const addObserver = (observer) => {
1487
+ if (value !== void 0) observer.next(value);
1488
+ observerList.push(observer);
1489
+ };
1490
+ const removeObserver = (observer) => {
1491
+ observerList.splice(observerList.indexOf(observer), 1);
1492
+ };
1493
+ const obs = observable((observer) => {
1494
+ addObserver(observer);
1495
+ return () => {
1496
+ removeObserver(observer);
1497
+ };
1498
+ });
1499
+ obs.next = (nextValue) => {
1500
+ if (value === nextValue) return;
1501
+ value = nextValue;
1502
+ for (const observer of observerList) observer.next(nextValue);
1503
+ };
1504
+ obs.get = () => value;
1505
+ return obs;
1506
+ }
1507
+
1508
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/splitLink-B7Cuf2c_.mjs
1509
+ function createChain(opts) {
1510
+ return observable((observer) => {
1511
+ function execute(index = 0, op = opts.op) {
1512
+ const next = opts.links[index];
1513
+ if (!next) throw new Error("No more links to execute - did you forget to add an ending link?");
1514
+ const subscription = next({
1515
+ op,
1516
+ next(nextOp) {
1517
+ const nextObserver = execute(index + 1, nextOp);
1518
+ return nextObserver;
1519
+ }
1520
+ });
1521
+ return subscription;
1522
+ }
1523
+ const obs$ = execute();
1524
+ return obs$.subscribe(observer);
1525
+ });
1526
+ }
1527
+
1528
+ // node_modules/.pnpm/@trpc+server@11.12.0_typescript@5.9.3/node_modules/@trpc/server/dist/codes-DagpWZLc.mjs
1529
+ function isObject(value) {
1530
+ return !!value && !Array.isArray(value) && typeof value === "object";
1531
+ }
1532
+ function emptyObject() {
1533
+ return /* @__PURE__ */ Object.create(null);
1534
+ }
1535
+ var TRPC_ERROR_CODES_BY_KEY = {
1536
+ PARSE_ERROR: -32700,
1537
+ BAD_REQUEST: -32600,
1538
+ INTERNAL_SERVER_ERROR: -32603,
1539
+ NOT_IMPLEMENTED: -32603,
1540
+ BAD_GATEWAY: -32603,
1541
+ SERVICE_UNAVAILABLE: -32603,
1542
+ GATEWAY_TIMEOUT: -32603,
1543
+ UNAUTHORIZED: -32001,
1544
+ PAYMENT_REQUIRED: -32002,
1545
+ FORBIDDEN: -32003,
1546
+ NOT_FOUND: -32004,
1547
+ METHOD_NOT_SUPPORTED: -32005,
1548
+ TIMEOUT: -32008,
1549
+ CONFLICT: -32009,
1550
+ PRECONDITION_FAILED: -32012,
1551
+ PAYLOAD_TOO_LARGE: -32013,
1552
+ UNSUPPORTED_MEDIA_TYPE: -32015,
1553
+ UNPROCESSABLE_CONTENT: -32022,
1554
+ PRECONDITION_REQUIRED: -32028,
1555
+ TOO_MANY_REQUESTS: -32029,
1556
+ CLIENT_CLOSED_REQUEST: -32099
1557
+ };
1558
+ var retryableRpcCodes = [
1559
+ TRPC_ERROR_CODES_BY_KEY.BAD_GATEWAY,
1560
+ TRPC_ERROR_CODES_BY_KEY.SERVICE_UNAVAILABLE,
1561
+ TRPC_ERROR_CODES_BY_KEY.GATEWAY_TIMEOUT,
1562
+ TRPC_ERROR_CODES_BY_KEY.INTERNAL_SERVER_ERROR
1563
+ ];
1564
+
1565
+ // node_modules/.pnpm/@trpc+server@11.12.0_typescript@5.9.3/node_modules/@trpc/server/dist/getErrorShape-vC8mUXJD.mjs
1566
+ var __create2 = Object.create;
1567
+ var __defProp2 = Object.defineProperty;
1568
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
1569
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
1570
+ var __getProtoOf2 = Object.getPrototypeOf;
1571
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
1572
+ var __commonJS2 = (cb, mod) => function() {
1573
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
1574
+ };
1575
+ var __copyProps2 = (to, from, except, desc) => {
1576
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames2(from), i = 0, n = keys.length, key; i < n; i++) {
1577
+ key = keys[i];
1578
+ if (!__hasOwnProp2.call(to, key) && key !== except) __defProp2(to, key, {
1579
+ get: ((k) => from[k]).bind(null, key),
1580
+ enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
1581
+ });
1582
+ }
1583
+ return to;
1584
+ };
1585
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", {
1586
+ value: mod,
1587
+ enumerable: true
1588
+ }) : target, mod));
1589
+ var noop = () => {
1590
+ };
1591
+ var freezeIfAvailable = (obj) => {
1592
+ if (Object.freeze) Object.freeze(obj);
1593
+ };
1594
+ function createInnerProxy(callback, path5, memo) {
1595
+ var _memo$cacheKey;
1596
+ const cacheKey = path5.join(".");
1597
+ (_memo$cacheKey = memo[cacheKey]) !== null && _memo$cacheKey !== void 0 || (memo[cacheKey] = new Proxy(noop, {
1598
+ get(_obj, key) {
1599
+ if (typeof key !== "string" || key === "then") return void 0;
1600
+ return createInnerProxy(callback, [...path5, key], memo);
1601
+ },
1602
+ apply(_1, _2, args) {
1603
+ const lastOfPath = path5[path5.length - 1];
1604
+ let opts = {
1605
+ args,
1606
+ path: path5
1607
+ };
1608
+ if (lastOfPath === "call") opts = {
1609
+ args: args.length >= 2 ? [args[1]] : [],
1610
+ path: path5.slice(0, -1)
1611
+ };
1612
+ else if (lastOfPath === "apply") opts = {
1613
+ args: args.length >= 2 ? args[1] : [],
1614
+ path: path5.slice(0, -1)
1615
+ };
1616
+ freezeIfAvailable(opts.args);
1617
+ freezeIfAvailable(opts.path);
1618
+ return callback(opts);
1619
+ }
1620
+ }));
1621
+ return memo[cacheKey];
1622
+ }
1623
+ var createRecursiveProxy = (callback) => createInnerProxy(callback, [], emptyObject());
1624
+ var createFlatProxy = (callback) => {
1625
+ return new Proxy(noop, { get(_obj, name) {
1626
+ if (name === "then") return void 0;
1627
+ return callback(name);
1628
+ } });
1629
+ };
1630
+ var require_typeof2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(exports, module) {
1631
+ function _typeof$2(o) {
1632
+ "@babel/helpers - typeof";
1633
+ return module.exports = _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
1634
+ return typeof o$1;
1635
+ } : function(o$1) {
1636
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
1637
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof$2(o);
1638
+ }
1639
+ module.exports = _typeof$2, module.exports.__esModule = true, module.exports["default"] = module.exports;
1640
+ } });
1641
+ var require_toPrimitive2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(exports, module) {
1642
+ var _typeof$1 = require_typeof2()["default"];
1643
+ function toPrimitive$1(t, r) {
1644
+ if ("object" != _typeof$1(t) || !t) return t;
1645
+ var e = t[Symbol.toPrimitive];
1646
+ if (void 0 !== e) {
1647
+ var i = e.call(t, r || "default");
1648
+ if ("object" != _typeof$1(i)) return i;
1649
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1650
+ }
1651
+ return ("string" === r ? String : Number)(t);
1652
+ }
1653
+ module.exports = toPrimitive$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
1654
+ } });
1655
+ var require_toPropertyKey2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(exports, module) {
1656
+ var _typeof = require_typeof2()["default"];
1657
+ var toPrimitive = require_toPrimitive2();
1658
+ function toPropertyKey$1(t) {
1659
+ var i = toPrimitive(t, "string");
1660
+ return "symbol" == _typeof(i) ? i : i + "";
1661
+ }
1662
+ module.exports = toPropertyKey$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
1663
+ } });
1664
+ var require_defineProperty2 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(exports, module) {
1665
+ var toPropertyKey = require_toPropertyKey2();
1666
+ function _defineProperty(e, r, t) {
1667
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1668
+ value: t,
1669
+ enumerable: true,
1670
+ configurable: true,
1671
+ writable: true
1672
+ }) : e[r] = t, e;
1673
+ }
1674
+ module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
1675
+ } });
1676
+ var require_objectSpread22 = __commonJS2({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(exports, module) {
1677
+ var defineProperty = require_defineProperty2();
1678
+ function ownKeys(e, r) {
1679
+ var t = Object.keys(e);
1680
+ if (Object.getOwnPropertySymbols) {
1681
+ var o = Object.getOwnPropertySymbols(e);
1682
+ r && (o = o.filter(function(r$1) {
1683
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
1684
+ })), t.push.apply(t, o);
1685
+ }
1686
+ return t;
1687
+ }
1688
+ function _objectSpread2(e) {
1689
+ for (var r = 1; r < arguments.length; r++) {
1690
+ var t = null != arguments[r] ? arguments[r] : {};
1691
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r$1) {
1692
+ defineProperty(e, r$1, t[r$1]);
1693
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
1694
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
1695
+ });
1696
+ }
1697
+ return e;
1698
+ }
1699
+ module.exports = _objectSpread2, module.exports.__esModule = true, module.exports["default"] = module.exports;
1700
+ } });
1701
+ var import_objectSpread2 = __toESM2(require_objectSpread22(), 1);
1702
+
1703
+ // node_modules/.pnpm/@trpc+server@11.12.0_typescript@5.9.3/node_modules/@trpc/server/dist/tracked-Bjtgv3wJ.mjs
1704
+ var import_defineProperty = __toESM2(require_defineProperty2(), 1);
1705
+ var import_objectSpread2$1 = __toESM2(require_objectSpread22(), 1);
1706
+ function transformResultInner(response, transformer) {
1707
+ if ("error" in response) {
1708
+ const error = transformer.deserialize(response.error);
1709
+ return {
1710
+ ok: false,
1711
+ error: (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, response), {}, { error })
1712
+ };
1713
+ }
1714
+ const result = (0, import_objectSpread2$1.default)((0, import_objectSpread2$1.default)({}, response.result), (!response.result.type || response.result.type === "data") && {
1715
+ type: "data",
1716
+ data: transformer.deserialize(response.result.data)
1717
+ });
1718
+ return {
1719
+ ok: true,
1720
+ result
1721
+ };
1722
+ }
1723
+ var TransformResultError = class extends Error {
1724
+ constructor() {
1725
+ super("Unable to transform response from server");
1726
+ }
1727
+ };
1728
+ function transformResult(response, transformer) {
1729
+ let result;
1730
+ try {
1731
+ result = transformResultInner(response, transformer);
1732
+ } catch (_unused) {
1733
+ throw new TransformResultError();
1734
+ }
1735
+ if (!result.ok && (!isObject(result.error.error) || typeof result.error.error["code"] !== "number")) throw new TransformResultError();
1736
+ if (result.ok && !isObject(result.result)) throw new TransformResultError();
1737
+ return result;
1738
+ }
1739
+ var import_objectSpread22 = __toESM2(require_objectSpread22(), 1);
1740
+
1741
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/TRPCClientError-apv8gw59.mjs
1742
+ var import_defineProperty2 = __toESM(require_defineProperty(), 1);
1743
+ var import_objectSpread23 = __toESM(require_objectSpread2(), 1);
1744
+ function isTRPCClientError(cause) {
1745
+ return cause instanceof TRPCClientError;
1746
+ }
1747
+ function isTRPCErrorResponse(obj) {
1748
+ return isObject(obj) && isObject(obj["error"]) && typeof obj["error"]["code"] === "number" && typeof obj["error"]["message"] === "string";
1749
+ }
1750
+ function getMessageFromUnknownError(err, fallback) {
1751
+ if (typeof err === "string") return err;
1752
+ if (isObject(err) && typeof err["message"] === "string") return err["message"];
1753
+ return fallback;
1754
+ }
1755
+ var TRPCClientError = class TRPCClientError2 extends Error {
1756
+ constructor(message, opts) {
1757
+ var _opts$result, _opts$result2;
1758
+ const cause = opts === null || opts === void 0 ? void 0 : opts.cause;
1759
+ super(message, { cause });
1760
+ (0, import_defineProperty2.default)(this, "cause", void 0);
1761
+ (0, import_defineProperty2.default)(this, "shape", void 0);
1762
+ (0, import_defineProperty2.default)(this, "data", void 0);
1763
+ (0, import_defineProperty2.default)(this, "meta", void 0);
1764
+ this.meta = opts === null || opts === void 0 ? void 0 : opts.meta;
1765
+ this.cause = cause;
1766
+ this.shape = opts === null || opts === void 0 || (_opts$result = opts.result) === null || _opts$result === void 0 ? void 0 : _opts$result.error;
1767
+ this.data = opts === null || opts === void 0 || (_opts$result2 = opts.result) === null || _opts$result2 === void 0 ? void 0 : _opts$result2.error.data;
1768
+ this.name = "TRPCClientError";
1769
+ Object.setPrototypeOf(this, TRPCClientError2.prototype);
1770
+ }
1771
+ static from(_cause, opts = {}) {
1772
+ const cause = _cause;
1773
+ if (isTRPCClientError(cause)) {
1774
+ if (opts.meta) cause.meta = (0, import_objectSpread23.default)((0, import_objectSpread23.default)({}, cause.meta), opts.meta);
1775
+ return cause;
1776
+ }
1777
+ if (isTRPCErrorResponse(cause)) return new TRPCClientError2(cause.error.message, (0, import_objectSpread23.default)((0, import_objectSpread23.default)({}, opts), {}, {
1778
+ result: cause,
1779
+ cause: opts.cause
1780
+ }));
1781
+ return new TRPCClientError2(getMessageFromUnknownError(cause, "Unknown error"), (0, import_objectSpread23.default)((0, import_objectSpread23.default)({}, opts), {}, { cause }));
1782
+ }
1783
+ };
1784
+
1785
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/unstable-internals-Bg7n9BBj.mjs
1786
+ function getTransformer(transformer) {
1787
+ const _transformer = transformer;
1788
+ if (!_transformer) return {
1789
+ input: {
1790
+ serialize: (data) => data,
1791
+ deserialize: (data) => data
1792
+ },
1793
+ output: {
1794
+ serialize: (data) => data,
1795
+ deserialize: (data) => data
1796
+ }
1797
+ };
1798
+ if ("input" in _transformer) return _transformer;
1799
+ return {
1800
+ input: _transformer,
1801
+ output: _transformer
1802
+ };
1803
+ }
1804
+
1805
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpUtils-Dv57hbOd.mjs
1806
+ var isFunction2 = (fn) => typeof fn === "function";
1807
+ function getFetch(customFetchImpl) {
1808
+ if (customFetchImpl) return customFetchImpl;
1809
+ if (typeof window !== "undefined" && isFunction2(window.fetch)) return window.fetch;
1810
+ if (typeof globalThis !== "undefined" && isFunction2(globalThis.fetch)) return globalThis.fetch;
1811
+ throw new Error("No fetch implementation found");
1812
+ }
1813
+ var import_objectSpread24 = __toESM(require_objectSpread2(), 1);
1814
+ function resolveHTTPLinkOptions(opts) {
1815
+ return {
1816
+ url: opts.url.toString(),
1817
+ fetch: opts.fetch,
1818
+ transformer: getTransformer(opts.transformer),
1819
+ methodOverride: opts.methodOverride
1820
+ };
1821
+ }
1822
+ function arrayToDict(array) {
1823
+ const dict = {};
1824
+ for (let index = 0; index < array.length; index++) {
1825
+ const element = array[index];
1826
+ dict[index] = element;
1827
+ }
1828
+ return dict;
1829
+ }
1830
+ var METHOD = {
1831
+ query: "GET",
1832
+ mutation: "POST",
1833
+ subscription: "PATCH"
1834
+ };
1835
+ function getInput(opts) {
1836
+ return "input" in opts ? opts.transformer.input.serialize(opts.input) : arrayToDict(opts.inputs.map((_input) => opts.transformer.input.serialize(_input)));
1837
+ }
1838
+ var getUrl = (opts) => {
1839
+ const parts = opts.url.split("?");
1840
+ const base = parts[0].replace(/\/$/, "");
1841
+ let url = base + "/" + opts.path;
1842
+ const queryParts = [];
1843
+ if (parts[1]) queryParts.push(parts[1]);
1844
+ if ("inputs" in opts) queryParts.push("batch=1");
1845
+ if (opts.type === "query" || opts.type === "subscription") {
1846
+ const input = getInput(opts);
1847
+ if (input !== void 0 && opts.methodOverride !== "POST") queryParts.push(`input=${encodeURIComponent(JSON.stringify(input))}`);
1848
+ }
1849
+ if (queryParts.length) url += "?" + queryParts.join("&");
1850
+ return url;
1851
+ };
1852
+ var getBody = (opts) => {
1853
+ if (opts.type === "query" && opts.methodOverride !== "POST") return void 0;
1854
+ const input = getInput(opts);
1855
+ return input !== void 0 ? JSON.stringify(input) : void 0;
1856
+ };
1857
+ var jsonHttpRequester = (opts) => {
1858
+ return httpRequest((0, import_objectSpread24.default)((0, import_objectSpread24.default)({}, opts), {}, {
1859
+ contentTypeHeader: "application/json",
1860
+ getUrl,
1861
+ getBody
1862
+ }));
1863
+ };
1864
+ var AbortError = class extends Error {
1865
+ constructor() {
1866
+ const name = "AbortError";
1867
+ super(name);
1868
+ this.name = name;
1869
+ this.message = name;
1870
+ }
1871
+ };
1872
+ var throwIfAborted = (signal) => {
1873
+ var _signal$throwIfAborte;
1874
+ if (!(signal === null || signal === void 0 ? void 0 : signal.aborted)) return;
1875
+ (_signal$throwIfAborte = signal.throwIfAborted) === null || _signal$throwIfAborte === void 0 || _signal$throwIfAborte.call(signal);
1876
+ if (typeof DOMException !== "undefined") throw new DOMException("AbortError", "AbortError");
1877
+ throw new AbortError();
1878
+ };
1879
+ async function fetchHTTPResponse(opts) {
1880
+ var _opts$methodOverride;
1881
+ throwIfAborted(opts.signal);
1882
+ const url = opts.getUrl(opts);
1883
+ const body = opts.getBody(opts);
1884
+ const method = (_opts$methodOverride = opts.methodOverride) !== null && _opts$methodOverride !== void 0 ? _opts$methodOverride : METHOD[opts.type];
1885
+ const resolvedHeaders = await (async () => {
1886
+ const heads = await opts.headers();
1887
+ if (Symbol.iterator in heads) return Object.fromEntries(heads);
1888
+ return heads;
1889
+ })();
1890
+ const headers = (0, import_objectSpread24.default)((0, import_objectSpread24.default)((0, import_objectSpread24.default)({}, opts.contentTypeHeader && method !== "GET" ? { "content-type": opts.contentTypeHeader } : {}), opts.trpcAcceptHeader ? { "trpc-accept": opts.trpcAcceptHeader } : void 0), resolvedHeaders);
1891
+ return getFetch(opts.fetch)(url, {
1892
+ method,
1893
+ signal: opts.signal,
1894
+ body,
1895
+ headers
1896
+ });
1897
+ }
1898
+ async function httpRequest(opts) {
1899
+ const meta = {};
1900
+ const res = await fetchHTTPResponse(opts);
1901
+ meta.response = res;
1902
+ const json = await res.json();
1903
+ meta.responseJSON = json;
1904
+ return {
1905
+ json,
1906
+ meta
1907
+ };
1908
+ }
1909
+
1910
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpLink-Cz9h1Qgh.mjs
1911
+ function isOctetType(input) {
1912
+ return input instanceof Uint8Array || input instanceof Blob;
1913
+ }
1914
+ function isFormData(input) {
1915
+ return input instanceof FormData;
1916
+ }
1917
+ var import_objectSpread25 = __toESM(require_objectSpread2(), 1);
1918
+ var universalRequester = (opts) => {
1919
+ if ("input" in opts) {
1920
+ const { input } = opts;
1921
+ if (isFormData(input)) {
1922
+ if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("FormData is only supported for mutations");
1923
+ return httpRequest((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, opts), {}, {
1924
+ contentTypeHeader: void 0,
1925
+ getUrl,
1926
+ getBody: () => input
1927
+ }));
1928
+ }
1929
+ if (isOctetType(input)) {
1930
+ if (opts.type !== "mutation" && opts.methodOverride !== "POST") throw new Error("Octet type input is only supported for mutations");
1931
+ return httpRequest((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, opts), {}, {
1932
+ contentTypeHeader: "application/octet-stream",
1933
+ getUrl,
1934
+ getBody: () => input
1935
+ }));
1936
+ }
1937
+ }
1938
+ return jsonHttpRequester(opts);
1939
+ };
1940
+ function httpLink(opts) {
1941
+ const resolvedOpts = resolveHTTPLinkOptions(opts);
1942
+ return () => {
1943
+ return (operationOpts) => {
1944
+ const { op } = operationOpts;
1945
+ return observable((observer) => {
1946
+ const { path: path5, input, type } = op;
1947
+ if (type === "subscription") throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");
1948
+ const request = universalRequester((0, import_objectSpread25.default)((0, import_objectSpread25.default)({}, resolvedOpts), {}, {
1949
+ type,
1950
+ path: path5,
1951
+ input,
1952
+ signal: op.signal,
1953
+ headers() {
1954
+ if (!opts.headers) return {};
1955
+ if (typeof opts.headers === "function") return opts.headers({ op });
1956
+ return opts.headers;
1957
+ }
1958
+ }));
1959
+ let meta = void 0;
1960
+ request.then((res) => {
1961
+ meta = res.meta;
1962
+ const transformed = transformResult(res.json, resolvedOpts.transformer.output);
1963
+ if (!transformed.ok) {
1964
+ observer.error(TRPCClientError.from(transformed.error, { meta }));
1965
+ return;
1966
+ }
1967
+ observer.next({
1968
+ context: res.meta,
1969
+ result: transformed.result
1970
+ });
1971
+ observer.complete();
1972
+ }).catch((cause) => {
1973
+ observer.error(TRPCClientError.from(cause, { meta }));
1974
+ });
1975
+ return () => {
1976
+ };
1977
+ });
1978
+ };
1979
+ };
1980
+ }
1981
+
1982
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/httpBatchLink-fQ1NAi-e.mjs
1983
+ var import_objectSpread26 = __toESM(require_objectSpread2(), 1);
1984
+
1985
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/loggerLink-ineCN1PO.mjs
1986
+ var import_objectSpread27 = __toESM(require_objectSpread2(), 1);
1987
+
1988
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/wsLink-DSf4KOdW.mjs
1989
+ var resultOf = (value, ...args) => {
1990
+ return typeof value === "function" ? value(...args) : value;
1991
+ };
1992
+ var import_defineProperty$3 = __toESM(require_defineProperty(), 1);
1993
+ function withResolvers() {
1994
+ let resolve;
1995
+ let reject;
1996
+ const promise = new Promise((res, rej) => {
1997
+ resolve = res;
1998
+ reject = rej;
1999
+ });
2000
+ return {
2001
+ promise,
2002
+ resolve,
2003
+ reject
2004
+ };
2005
+ }
2006
+ async function prepareUrl(urlOptions) {
2007
+ const url = await resultOf(urlOptions.url);
2008
+ if (!urlOptions.connectionParams) return url;
2009
+ const prefix = url.includes("?") ? "&" : "?";
2010
+ const connectionParams = `${prefix}connectionParams=1`;
2011
+ return url + connectionParams;
2012
+ }
2013
+ async function buildConnectionMessage(connectionParams, encoder) {
2014
+ const message = {
2015
+ method: "connectionParams",
2016
+ data: await resultOf(connectionParams)
2017
+ };
2018
+ return encoder.encode(message);
2019
+ }
2020
+ var import_defineProperty$2 = __toESM(require_defineProperty(), 1);
2021
+ var import_defineProperty$1 = __toESM(require_defineProperty(), 1);
2022
+ function asyncWsOpen(ws) {
2023
+ const { promise, resolve, reject } = withResolvers();
2024
+ ws.addEventListener("open", () => {
2025
+ ws.removeEventListener("error", reject);
2026
+ resolve();
2027
+ });
2028
+ ws.addEventListener("error", reject);
2029
+ return promise;
2030
+ }
2031
+ function setupPingInterval(ws, { intervalMs, pongTimeoutMs }) {
2032
+ let pingTimeout;
2033
+ let pongTimeout;
2034
+ function start() {
2035
+ pingTimeout = setTimeout(() => {
2036
+ ws.send("PING");
2037
+ pongTimeout = setTimeout(() => {
2038
+ ws.close();
2039
+ }, pongTimeoutMs);
2040
+ }, intervalMs);
2041
+ }
2042
+ function reset() {
2043
+ clearTimeout(pingTimeout);
2044
+ start();
2045
+ }
2046
+ function pong() {
2047
+ clearTimeout(pongTimeout);
2048
+ reset();
2049
+ }
2050
+ ws.addEventListener("open", start);
2051
+ ws.addEventListener("message", ({ data }) => {
2052
+ clearTimeout(pingTimeout);
2053
+ start();
2054
+ if (data === "PONG") pong();
2055
+ });
2056
+ ws.addEventListener("close", () => {
2057
+ clearTimeout(pingTimeout);
2058
+ clearTimeout(pongTimeout);
2059
+ });
2060
+ }
2061
+ var WsConnection = class WsConnection2 {
2062
+ constructor(opts) {
2063
+ var _opts$WebSocketPonyfi;
2064
+ (0, import_defineProperty$1.default)(this, "id", ++WsConnection2.connectCount);
2065
+ (0, import_defineProperty$1.default)(this, "WebSocketPonyfill", void 0);
2066
+ (0, import_defineProperty$1.default)(this, "urlOptions", void 0);
2067
+ (0, import_defineProperty$1.default)(this, "keepAliveOpts", void 0);
2068
+ (0, import_defineProperty$1.default)(this, "encoder", void 0);
2069
+ (0, import_defineProperty$1.default)(this, "wsObservable", behaviorSubject(null));
2070
+ (0, import_defineProperty$1.default)(this, "openPromise", null);
2071
+ this.WebSocketPonyfill = (_opts$WebSocketPonyfi = opts.WebSocketPonyfill) !== null && _opts$WebSocketPonyfi !== void 0 ? _opts$WebSocketPonyfi : WebSocket;
2072
+ if (!this.WebSocketPonyfill) throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");
2073
+ this.urlOptions = opts.urlOptions;
2074
+ this.keepAliveOpts = opts.keepAlive;
2075
+ this.encoder = opts.encoder;
2076
+ }
2077
+ get ws() {
2078
+ return this.wsObservable.get();
2079
+ }
2080
+ set ws(ws) {
2081
+ this.wsObservable.next(ws);
2082
+ }
2083
+ /**
2084
+ * Checks if the WebSocket connection is open and ready to communicate.
2085
+ */
2086
+ isOpen() {
2087
+ return !!this.ws && this.ws.readyState === this.WebSocketPonyfill.OPEN && !this.openPromise;
2088
+ }
2089
+ /**
2090
+ * Checks if the WebSocket connection is closed or in the process of closing.
2091
+ */
2092
+ isClosed() {
2093
+ return !!this.ws && (this.ws.readyState === this.WebSocketPonyfill.CLOSING || this.ws.readyState === this.WebSocketPonyfill.CLOSED);
2094
+ }
2095
+ async open() {
2096
+ var _this = this;
2097
+ if (_this.openPromise) return _this.openPromise;
2098
+ _this.id = ++WsConnection2.connectCount;
2099
+ const wsPromise = prepareUrl(_this.urlOptions).then((url) => new _this.WebSocketPonyfill(url));
2100
+ _this.openPromise = wsPromise.then(async (ws) => {
2101
+ _this.ws = ws;
2102
+ ws.binaryType = "arraybuffer";
2103
+ ws.addEventListener("message", function({ data }) {
2104
+ if (data === "PING") this.send("PONG");
2105
+ });
2106
+ if (_this.keepAliveOpts.enabled) setupPingInterval(ws, _this.keepAliveOpts);
2107
+ ws.addEventListener("close", () => {
2108
+ if (_this.ws === ws) _this.ws = null;
2109
+ });
2110
+ await asyncWsOpen(ws);
2111
+ if (_this.urlOptions.connectionParams) ws.send(await buildConnectionMessage(_this.urlOptions.connectionParams, _this.encoder));
2112
+ });
2113
+ try {
2114
+ await _this.openPromise;
2115
+ } finally {
2116
+ _this.openPromise = null;
2117
+ }
2118
+ }
2119
+ /**
2120
+ * Closes the WebSocket connection gracefully.
2121
+ * Waits for any ongoing open operation to complete before closing.
2122
+ */
2123
+ async close() {
2124
+ var _this2 = this;
2125
+ try {
2126
+ await _this2.openPromise;
2127
+ } finally {
2128
+ var _this$ws;
2129
+ (_this$ws = _this2.ws) === null || _this$ws === void 0 || _this$ws.close();
2130
+ }
2131
+ }
2132
+ };
2133
+ (0, import_defineProperty$1.default)(WsConnection, "connectCount", 0);
2134
+ var import_defineProperty3 = __toESM(require_defineProperty(), 1);
2135
+ var import_objectSpread28 = __toESM(require_objectSpread2(), 1);
2136
+
2137
+ // node_modules/.pnpm/@trpc+client@11.12.0_@trpc+server@11.12.0_typescript@5.9.3__typescript@5.9.3/node_modules/@trpc/client/dist/index.mjs
2138
+ var import_defineProperty4 = __toESM(require_defineProperty(), 1);
2139
+ var import_objectSpread2$4 = __toESM(require_objectSpread2(), 1);
2140
+ var TRPCUntypedClient = class {
2141
+ constructor(opts) {
2142
+ (0, import_defineProperty4.default)(this, "links", void 0);
2143
+ (0, import_defineProperty4.default)(this, "runtime", void 0);
2144
+ (0, import_defineProperty4.default)(this, "requestId", void 0);
2145
+ this.requestId = 0;
2146
+ this.runtime = {};
2147
+ this.links = opts.links.map((link) => link(this.runtime));
2148
+ }
2149
+ $request(opts) {
2150
+ var _opts$context;
2151
+ const chain$ = createChain({
2152
+ links: this.links,
2153
+ op: (0, import_objectSpread2$4.default)((0, import_objectSpread2$4.default)({}, opts), {}, {
2154
+ context: (_opts$context = opts.context) !== null && _opts$context !== void 0 ? _opts$context : {},
2155
+ id: ++this.requestId
2156
+ })
2157
+ });
2158
+ return chain$.pipe(share());
2159
+ }
2160
+ async requestAsPromise(opts) {
2161
+ var _this = this;
2162
+ try {
2163
+ const req$ = _this.$request(opts);
2164
+ const envelope = await observableToPromise(req$);
2165
+ const data = envelope.result.data;
2166
+ return data;
2167
+ } catch (err) {
2168
+ throw TRPCClientError.from(err);
2169
+ }
2170
+ }
2171
+ query(path5, input, opts) {
2172
+ return this.requestAsPromise({
2173
+ type: "query",
2174
+ path: path5,
2175
+ input,
2176
+ context: opts === null || opts === void 0 ? void 0 : opts.context,
2177
+ signal: opts === null || opts === void 0 ? void 0 : opts.signal
2178
+ });
2179
+ }
2180
+ mutation(path5, input, opts) {
2181
+ return this.requestAsPromise({
2182
+ type: "mutation",
2183
+ path: path5,
2184
+ input,
2185
+ context: opts === null || opts === void 0 ? void 0 : opts.context,
2186
+ signal: opts === null || opts === void 0 ? void 0 : opts.signal
2187
+ });
2188
+ }
2189
+ subscription(path5, input, opts) {
2190
+ const observable$ = this.$request({
2191
+ type: "subscription",
2192
+ path: path5,
2193
+ input,
2194
+ context: opts.context,
2195
+ signal: opts.signal
2196
+ });
2197
+ return observable$.subscribe({
2198
+ next(envelope) {
2199
+ switch (envelope.result.type) {
2200
+ case "state": {
2201
+ var _opts$onConnectionSta;
2202
+ (_opts$onConnectionSta = opts.onConnectionStateChange) === null || _opts$onConnectionSta === void 0 || _opts$onConnectionSta.call(opts, envelope.result);
2203
+ break;
2204
+ }
2205
+ case "started": {
2206
+ var _opts$onStarted;
2207
+ (_opts$onStarted = opts.onStarted) === null || _opts$onStarted === void 0 || _opts$onStarted.call(opts, { context: envelope.context });
2208
+ break;
2209
+ }
2210
+ case "stopped": {
2211
+ var _opts$onStopped;
2212
+ (_opts$onStopped = opts.onStopped) === null || _opts$onStopped === void 0 || _opts$onStopped.call(opts);
2213
+ break;
2214
+ }
2215
+ case "data":
2216
+ case void 0: {
2217
+ var _opts$onData;
2218
+ (_opts$onData = opts.onData) === null || _opts$onData === void 0 || _opts$onData.call(opts, envelope.result.data);
2219
+ break;
2220
+ }
2221
+ }
2222
+ },
2223
+ error(err) {
2224
+ var _opts$onError;
2225
+ (_opts$onError = opts.onError) === null || _opts$onError === void 0 || _opts$onError.call(opts, err);
2226
+ },
2227
+ complete() {
2228
+ var _opts$onComplete;
2229
+ (_opts$onComplete = opts.onComplete) === null || _opts$onComplete === void 0 || _opts$onComplete.call(opts);
2230
+ }
2231
+ });
2232
+ }
2233
+ };
2234
+ var untypedClientSymbol = /* @__PURE__ */ Symbol.for("trpc_untypedClient");
2235
+ var clientCallTypeMap = {
2236
+ query: "query",
2237
+ mutate: "mutation",
2238
+ subscribe: "subscription"
2239
+ };
2240
+ var clientCallTypeToProcedureType = (clientCallType) => {
2241
+ return clientCallTypeMap[clientCallType];
2242
+ };
2243
+ function createTRPCClientProxy(client) {
2244
+ const proxy = createRecursiveProxy(({ path: path5, args }) => {
2245
+ const pathCopy = [...path5];
2246
+ const procedureType = clientCallTypeToProcedureType(pathCopy.pop());
2247
+ const fullPath = pathCopy.join(".");
2248
+ return client[procedureType](fullPath, ...args);
2249
+ });
2250
+ return createFlatProxy((key) => {
2251
+ if (key === untypedClientSymbol) return client;
2252
+ return proxy[key];
2253
+ });
2254
+ }
2255
+ function createTRPCClient(opts) {
2256
+ const client = new TRPCUntypedClient(opts);
2257
+ const proxy = createTRPCClientProxy(client);
2258
+ return proxy;
2259
+ }
2260
+ var import_objectSpread2$3 = __toESM(require_objectSpread2(), 1);
2261
+ var import_objectSpread2$2 = __toESM(require_objectSpread2(), 1);
2262
+ var require_asyncIterator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(exports, module) {
2263
+ function _asyncIterator$1(r) {
2264
+ var n, t, o, e = 2;
2265
+ for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--; ) {
2266
+ if (t && null != (n = r[t])) return n.call(r);
2267
+ if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r));
2268
+ t = "@@asyncIterator", o = "@@iterator";
2269
+ }
2270
+ throw new TypeError("Object is not async iterable");
2271
+ }
2272
+ function AsyncFromSyncIterator(r) {
2273
+ function AsyncFromSyncIteratorContinuation(r$1) {
2274
+ if (Object(r$1) !== r$1) return Promise.reject(new TypeError(r$1 + " is not an object."));
2275
+ var n = r$1.done;
2276
+ return Promise.resolve(r$1.value).then(function(r$2) {
2277
+ return {
2278
+ value: r$2,
2279
+ done: n
2280
+ };
2281
+ });
2282
+ }
2283
+ return AsyncFromSyncIterator = function AsyncFromSyncIterator$1(r$1) {
2284
+ this.s = r$1, this.n = r$1.next;
2285
+ }, AsyncFromSyncIterator.prototype = {
2286
+ s: null,
2287
+ n: null,
2288
+ next: function next() {
2289
+ return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
2290
+ },
2291
+ "return": function _return(r$1) {
2292
+ var n = this.s["return"];
2293
+ return void 0 === n ? Promise.resolve({
2294
+ value: r$1,
2295
+ done: true
2296
+ }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
2297
+ },
2298
+ "throw": function _throw(r$1) {
2299
+ var n = this.s["return"];
2300
+ return void 0 === n ? Promise.reject(r$1) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments));
2301
+ }
2302
+ }, new AsyncFromSyncIterator(r);
2303
+ }
2304
+ module.exports = _asyncIterator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
2305
+ } });
2306
+ var import_asyncIterator = __toESM(require_asyncIterator(), 1);
2307
+ var import_objectSpread2$12 = __toESM(require_objectSpread2(), 1);
2308
+ var require_usingCtx = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(exports, module) {
2309
+ function _usingCtx() {
2310
+ var r = "function" == typeof SuppressedError ? SuppressedError : function(r$1, e$1) {
2311
+ var n$1 = Error();
2312
+ return n$1.name = "SuppressedError", n$1.error = r$1, n$1.suppressed = e$1, n$1;
2313
+ }, e = {}, n = [];
2314
+ function using(r$1, e$1) {
2315
+ if (null != e$1) {
2316
+ if (Object(e$1) !== e$1) throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
2317
+ if (r$1) var o = e$1[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
2318
+ if (void 0 === o && (o = e$1[Symbol.dispose || Symbol["for"]("Symbol.dispose")], r$1)) var t = o;
2319
+ if ("function" != typeof o) throw new TypeError("Object is not disposable.");
2320
+ t && (o = function o$1() {
2321
+ try {
2322
+ t.call(e$1);
2323
+ } catch (r$2) {
2324
+ return Promise.reject(r$2);
2325
+ }
2326
+ }), n.push({
2327
+ v: e$1,
2328
+ d: o,
2329
+ a: r$1
2330
+ });
2331
+ } else r$1 && n.push({
2332
+ d: e$1,
2333
+ a: r$1
2334
+ });
2335
+ return e$1;
2336
+ }
2337
+ return {
2338
+ e,
2339
+ u: using.bind(null, false),
2340
+ a: using.bind(null, true),
2341
+ d: function d() {
2342
+ var o, t = this.e, s = 0;
2343
+ function next() {
2344
+ for (; o = n.pop(); ) try {
2345
+ if (!o.a && 1 === s) return s = 0, n.push(o), Promise.resolve().then(next);
2346
+ if (o.d) {
2347
+ var r$1 = o.d.call(o.v);
2348
+ if (o.a) return s |= 2, Promise.resolve(r$1).then(next, err);
2349
+ } else s |= 1;
2350
+ } catch (r$2) {
2351
+ return err(r$2);
2352
+ }
2353
+ if (1 === s) return t !== e ? Promise.reject(t) : Promise.resolve();
2354
+ if (t !== e) throw t;
2355
+ }
2356
+ function err(n$1) {
2357
+ return t = t !== e ? new r(n$1, t) : n$1, next();
2358
+ }
2359
+ return next();
2360
+ }
2361
+ };
2362
+ }
2363
+ module.exports = _usingCtx, module.exports.__esModule = true, module.exports["default"] = module.exports;
2364
+ } });
2365
+ var require_OverloadYield = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(exports, module) {
2366
+ function _OverloadYield(e, d) {
2367
+ this.v = e, this.k = d;
2368
+ }
2369
+ module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
2370
+ } });
2371
+ var require_awaitAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(exports, module) {
2372
+ var OverloadYield$1 = require_OverloadYield();
2373
+ function _awaitAsyncGenerator$1(e) {
2374
+ return new OverloadYield$1(e, 0);
2375
+ }
2376
+ module.exports = _awaitAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
2377
+ } });
2378
+ var require_wrapAsyncGenerator = __commonJS({ "../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(exports, module) {
2379
+ var OverloadYield = require_OverloadYield();
2380
+ function _wrapAsyncGenerator$1(e) {
2381
+ return function() {
2382
+ return new AsyncGenerator(e.apply(this, arguments));
2383
+ };
2384
+ }
2385
+ function AsyncGenerator(e) {
2386
+ var r, t;
2387
+ function resume(r$1, t$1) {
2388
+ try {
2389
+ var n = e[r$1](t$1), o = n.value, u = o instanceof OverloadYield;
2390
+ Promise.resolve(u ? o.v : o).then(function(t$2) {
2391
+ if (u) {
2392
+ var i = "return" === r$1 ? "return" : "next";
2393
+ if (!o.k || t$2.done) return resume(i, t$2);
2394
+ t$2 = e[i](t$2).value;
2395
+ }
2396
+ settle(n.done ? "return" : "normal", t$2);
2397
+ }, function(e$1) {
2398
+ resume("throw", e$1);
2399
+ });
2400
+ } catch (e$1) {
2401
+ settle("throw", e$1);
2402
+ }
2403
+ }
2404
+ function settle(e$1, n) {
2405
+ switch (e$1) {
2406
+ case "return":
2407
+ r.resolve({
2408
+ value: n,
2409
+ done: true
2410
+ });
2411
+ break;
2412
+ case "throw":
2413
+ r.reject(n);
2414
+ break;
2415
+ default:
2416
+ r.resolve({
2417
+ value: n,
2418
+ done: false
2419
+ });
2420
+ }
2421
+ (r = r.next) ? resume(r.key, r.arg) : t = null;
2422
+ }
2423
+ this._invoke = function(e$1, n) {
2424
+ return new Promise(function(o, u) {
2425
+ var i = {
2426
+ key: e$1,
2427
+ arg: n,
2428
+ resolve: o,
2429
+ reject: u,
2430
+ next: null
2431
+ };
2432
+ t ? t = t.next = i : (r = t = i, resume(e$1, n));
2433
+ });
2434
+ }, "function" != typeof e["return"] && (this["return"] = void 0);
2435
+ }
2436
+ AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
2437
+ return this;
2438
+ }, AsyncGenerator.prototype.next = function(e) {
2439
+ return this._invoke("next", e);
2440
+ }, AsyncGenerator.prototype["throw"] = function(e) {
2441
+ return this._invoke("throw", e);
2442
+ }, AsyncGenerator.prototype["return"] = function(e) {
2443
+ return this._invoke("return", e);
2444
+ };
2445
+ module.exports = _wrapAsyncGenerator$1, module.exports.__esModule = true, module.exports["default"] = module.exports;
2446
+ } });
2447
+ var import_usingCtx = __toESM(require_usingCtx(), 1);
2448
+ var import_awaitAsyncGenerator = __toESM(require_awaitAsyncGenerator(), 1);
2449
+ var import_wrapAsyncGenerator = __toESM(require_wrapAsyncGenerator(), 1);
2450
+ var import_objectSpread29 = __toESM(require_objectSpread2(), 1);
2451
+
2452
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/double-indexed-kv.js
2453
+ var DoubleIndexedKV = class {
2454
+ constructor() {
2455
+ this.keyToValue = /* @__PURE__ */ new Map();
2456
+ this.valueToKey = /* @__PURE__ */ new Map();
2457
+ }
2458
+ set(key, value) {
2459
+ this.keyToValue.set(key, value);
2460
+ this.valueToKey.set(value, key);
2461
+ }
2462
+ getByKey(key) {
2463
+ return this.keyToValue.get(key);
2464
+ }
2465
+ getByValue(value) {
2466
+ return this.valueToKey.get(value);
2467
+ }
2468
+ clear() {
2469
+ this.keyToValue.clear();
2470
+ this.valueToKey.clear();
2471
+ }
2472
+ };
2473
+
2474
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/registry.js
2475
+ var Registry = class {
2476
+ constructor(generateIdentifier) {
2477
+ this.generateIdentifier = generateIdentifier;
2478
+ this.kv = new DoubleIndexedKV();
2479
+ }
2480
+ register(value, identifier) {
2481
+ if (this.kv.getByValue(value)) {
2482
+ return;
2483
+ }
2484
+ if (!identifier) {
2485
+ identifier = this.generateIdentifier(value);
2486
+ }
2487
+ this.kv.set(identifier, value);
2488
+ }
2489
+ clear() {
2490
+ this.kv.clear();
2491
+ }
2492
+ getIdentifier(value) {
2493
+ return this.kv.getByValue(value);
2494
+ }
2495
+ getValue(identifier) {
2496
+ return this.kv.getByKey(identifier);
2497
+ }
2498
+ };
2499
+
2500
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/class-registry.js
2501
+ var ClassRegistry = class extends Registry {
2502
+ constructor() {
2503
+ super((c) => c.name);
2504
+ this.classToAllowedProps = /* @__PURE__ */ new Map();
2505
+ }
2506
+ register(value, options) {
2507
+ if (typeof options === "object") {
2508
+ if (options.allowProps) {
2509
+ this.classToAllowedProps.set(value, options.allowProps);
2510
+ }
2511
+ super.register(value, options.identifier);
2512
+ } else {
2513
+ super.register(value, options);
2514
+ }
2515
+ }
2516
+ getAllowedProps(value) {
2517
+ return this.classToAllowedProps.get(value);
2518
+ }
2519
+ };
2520
+
2521
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/util.js
2522
+ function valuesOfObj(record) {
2523
+ if ("values" in Object) {
2524
+ return Object.values(record);
2525
+ }
2526
+ const values = [];
2527
+ for (const key in record) {
2528
+ if (record.hasOwnProperty(key)) {
2529
+ values.push(record[key]);
2530
+ }
2531
+ }
2532
+ return values;
2533
+ }
2534
+ function find(record, predicate) {
2535
+ const values = valuesOfObj(record);
2536
+ if ("find" in values) {
2537
+ return values.find(predicate);
2538
+ }
2539
+ const valuesNotNever = values;
2540
+ for (let i = 0; i < valuesNotNever.length; i++) {
2541
+ const value = valuesNotNever[i];
2542
+ if (predicate(value)) {
2543
+ return value;
2544
+ }
2545
+ }
2546
+ return void 0;
2547
+ }
2548
+ function forEach(record, run2) {
2549
+ Object.entries(record).forEach(([key, value]) => run2(value, key));
2550
+ }
2551
+ function includes(arr, value) {
2552
+ return arr.indexOf(value) !== -1;
2553
+ }
2554
+ function findArr(record, predicate) {
2555
+ for (let i = 0; i < record.length; i++) {
2556
+ const value = record[i];
2557
+ if (predicate(value)) {
2558
+ return value;
2559
+ }
2560
+ }
2561
+ return void 0;
2562
+ }
2563
+
2564
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/custom-transformer-registry.js
2565
+ var CustomTransformerRegistry = class {
2566
+ constructor() {
2567
+ this.transfomers = {};
2568
+ }
2569
+ register(transformer) {
2570
+ this.transfomers[transformer.name] = transformer;
2571
+ }
2572
+ findApplicable(v) {
2573
+ return find(this.transfomers, (transformer) => transformer.isApplicable(v));
2574
+ }
2575
+ findByName(name) {
2576
+ return this.transfomers[name];
2577
+ }
2578
+ };
2579
+
2580
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/is.js
2581
+ var getType = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
2582
+ var isUndefined = (payload) => typeof payload === "undefined";
2583
+ var isNull = (payload) => payload === null;
2584
+ var isPlainObject = (payload) => {
2585
+ if (typeof payload !== "object" || payload === null)
2586
+ return false;
2587
+ if (payload === Object.prototype)
2588
+ return false;
2589
+ if (Object.getPrototypeOf(payload) === null)
2590
+ return true;
2591
+ return Object.getPrototypeOf(payload) === Object.prototype;
2592
+ };
2593
+ var isEmptyObject = (payload) => isPlainObject(payload) && Object.keys(payload).length === 0;
2594
+ var isArray = (payload) => Array.isArray(payload);
2595
+ var isString = (payload) => typeof payload === "string";
2596
+ var isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
2597
+ var isBoolean = (payload) => typeof payload === "boolean";
2598
+ var isRegExp = (payload) => payload instanceof RegExp;
2599
+ var isMap = (payload) => payload instanceof Map;
2600
+ var isSet = (payload) => payload instanceof Set;
2601
+ var isSymbol = (payload) => getType(payload) === "Symbol";
2602
+ var isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
2603
+ var isError = (payload) => payload instanceof Error;
2604
+ var isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
2605
+ var isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
2606
+ var isBigint = (payload) => typeof payload === "bigint";
2607
+ var isInfinite = (payload) => payload === Infinity || payload === -Infinity;
2608
+ var isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
2609
+ var isURL = (payload) => payload instanceof URL;
2610
+
2611
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/pathstringifier.js
2612
+ var escapeKey = (key) => key.replace(/\\/g, "\\\\").replace(/\./g, "\\.");
2613
+ var stringifyPath = (path5) => path5.map(String).map(escapeKey).join(".");
2614
+ var parsePath = (string, legacyPaths) => {
2615
+ const result = [];
2616
+ let segment = "";
2617
+ for (let i = 0; i < string.length; i++) {
2618
+ let char = string.charAt(i);
2619
+ if (!legacyPaths && char === "\\") {
2620
+ const escaped = string.charAt(i + 1);
2621
+ if (escaped === "\\") {
2622
+ segment += "\\";
2623
+ i++;
2624
+ continue;
2625
+ } else if (escaped !== ".") {
2626
+ throw Error("invalid path");
2627
+ }
2628
+ }
2629
+ const isEscapedDot = char === "\\" && string.charAt(i + 1) === ".";
2630
+ if (isEscapedDot) {
2631
+ segment += ".";
2632
+ i++;
2633
+ continue;
2634
+ }
2635
+ const isEndOfSegment = char === ".";
2636
+ if (isEndOfSegment) {
2637
+ result.push(segment);
2638
+ segment = "";
2639
+ continue;
2640
+ }
2641
+ segment += char;
2642
+ }
2643
+ const lastSegment = segment;
2644
+ result.push(lastSegment);
2645
+ return result;
2646
+ };
2647
+
2648
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/transformer.js
2649
+ function simpleTransformation(isApplicable, annotation, transform, untransform) {
2650
+ return {
2651
+ isApplicable,
2652
+ annotation,
2653
+ transform,
2654
+ untransform
2655
+ };
2656
+ }
2657
+ var simpleRules = [
2658
+ simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
2659
+ simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
2660
+ if (typeof BigInt !== "undefined") {
2661
+ return BigInt(v);
2662
+ }
2663
+ console.error("Please add a BigInt polyfill.");
2664
+ return v;
2665
+ }),
2666
+ simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
2667
+ simpleTransformation(isError, "Error", (v, superJson) => {
2668
+ const baseError = {
2669
+ name: v.name,
2670
+ message: v.message
2671
+ };
2672
+ if ("cause" in v) {
2673
+ baseError.cause = v.cause;
2674
+ }
2675
+ superJson.allowedErrorProps.forEach((prop) => {
2676
+ baseError[prop] = v[prop];
2677
+ });
2678
+ return baseError;
2679
+ }, (v, superJson) => {
2680
+ const e = new Error(v.message, { cause: v.cause });
2681
+ e.name = v.name;
2682
+ e.stack = v.stack;
2683
+ superJson.allowedErrorProps.forEach((prop) => {
2684
+ e[prop] = v[prop];
2685
+ });
2686
+ return e;
2687
+ }),
2688
+ simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
2689
+ const body = regex.slice(1, regex.lastIndexOf("/"));
2690
+ const flags = regex.slice(regex.lastIndexOf("/") + 1);
2691
+ return new RegExp(body, flags);
2692
+ }),
2693
+ simpleTransformation(
2694
+ isSet,
2695
+ "set",
2696
+ // (sets only exist in es6+)
2697
+ // eslint-disable-next-line es5/no-es6-methods
2698
+ (v) => [...v.values()],
2699
+ (v) => new Set(v)
2700
+ ),
2701
+ simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
2702
+ simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
2703
+ if (isNaNValue(v)) {
2704
+ return "NaN";
2705
+ }
2706
+ if (v > 0) {
2707
+ return "Infinity";
2708
+ } else {
2709
+ return "-Infinity";
2710
+ }
2711
+ }, Number),
2712
+ simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
2713
+ return "-0";
2714
+ }, Number),
2715
+ simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
2716
+ ];
2717
+ function compositeTransformation(isApplicable, annotation, transform, untransform) {
2718
+ return {
2719
+ isApplicable,
2720
+ annotation,
2721
+ transform,
2722
+ untransform
2723
+ };
2724
+ }
2725
+ var symbolRule = compositeTransformation((s, superJson) => {
2726
+ if (isSymbol(s)) {
2727
+ const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
2728
+ return isRegistered;
2729
+ }
2730
+ return false;
2731
+ }, (s, superJson) => {
2732
+ const identifier = superJson.symbolRegistry.getIdentifier(s);
2733
+ return ["symbol", identifier];
2734
+ }, (v) => v.description, (_, a, superJson) => {
2735
+ const value = superJson.symbolRegistry.getValue(a[1]);
2736
+ if (!value) {
2737
+ throw new Error("Trying to deserialize unknown symbol");
2738
+ }
2739
+ return value;
2740
+ });
2741
+ var constructorToName = [
2742
+ Int8Array,
2743
+ Uint8Array,
2744
+ Int16Array,
2745
+ Uint16Array,
2746
+ Int32Array,
2747
+ Uint32Array,
2748
+ Float32Array,
2749
+ Float64Array,
2750
+ Uint8ClampedArray
2751
+ ].reduce((obj, ctor) => {
2752
+ obj[ctor.name] = ctor;
2753
+ return obj;
2754
+ }, {});
2755
+ var typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
2756
+ const ctor = constructorToName[a[1]];
2757
+ if (!ctor) {
2758
+ throw new Error("Trying to deserialize unknown typed array");
2759
+ }
2760
+ return new ctor(v);
2761
+ });
2762
+ function isInstanceOfRegisteredClass(potentialClass, superJson) {
2763
+ if (potentialClass?.constructor) {
2764
+ const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
2765
+ return isRegistered;
2766
+ }
2767
+ return false;
2768
+ }
2769
+ var classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
2770
+ const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
2771
+ return ["class", identifier];
2772
+ }, (clazz, superJson) => {
2773
+ const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
2774
+ if (!allowedProps) {
2775
+ return { ...clazz };
2776
+ }
2777
+ const result = {};
2778
+ allowedProps.forEach((prop) => {
2779
+ result[prop] = clazz[prop];
2780
+ });
2781
+ return result;
2782
+ }, (v, a, superJson) => {
2783
+ const clazz = superJson.classRegistry.getValue(a[1]);
2784
+ if (!clazz) {
2785
+ throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
2786
+ }
2787
+ return Object.assign(Object.create(clazz.prototype), v);
2788
+ });
2789
+ var customRule = compositeTransformation((value, superJson) => {
2790
+ return !!superJson.customTransformerRegistry.findApplicable(value);
2791
+ }, (value, superJson) => {
2792
+ const transformer = superJson.customTransformerRegistry.findApplicable(value);
2793
+ return ["custom", transformer.name];
2794
+ }, (value, superJson) => {
2795
+ const transformer = superJson.customTransformerRegistry.findApplicable(value);
2796
+ return transformer.serialize(value);
2797
+ }, (v, a, superJson) => {
2798
+ const transformer = superJson.customTransformerRegistry.findByName(a[1]);
2799
+ if (!transformer) {
2800
+ throw new Error("Trying to deserialize unknown custom value");
2801
+ }
2802
+ return transformer.deserialize(v);
2803
+ });
2804
+ var compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
2805
+ var transformValue = (value, superJson) => {
2806
+ const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
2807
+ if (applicableCompositeRule) {
2808
+ return {
2809
+ value: applicableCompositeRule.transform(value, superJson),
2810
+ type: applicableCompositeRule.annotation(value, superJson)
2811
+ };
2812
+ }
2813
+ const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
2814
+ if (applicableSimpleRule) {
2815
+ return {
2816
+ value: applicableSimpleRule.transform(value, superJson),
2817
+ type: applicableSimpleRule.annotation
2818
+ };
2819
+ }
2820
+ return void 0;
2821
+ };
2822
+ var simpleRulesByAnnotation = {};
2823
+ simpleRules.forEach((rule) => {
2824
+ simpleRulesByAnnotation[rule.annotation] = rule;
2825
+ });
2826
+ var untransformValue = (json, type, superJson) => {
2827
+ if (isArray(type)) {
2828
+ switch (type[0]) {
2829
+ case "symbol":
2830
+ return symbolRule.untransform(json, type, superJson);
2831
+ case "class":
2832
+ return classRule.untransform(json, type, superJson);
2833
+ case "custom":
2834
+ return customRule.untransform(json, type, superJson);
2835
+ case "typed-array":
2836
+ return typedArrayRule.untransform(json, type, superJson);
2837
+ default:
2838
+ throw new Error("Unknown transformation: " + type);
2839
+ }
2840
+ } else {
2841
+ const transformation = simpleRulesByAnnotation[type];
2842
+ if (!transformation) {
2843
+ throw new Error("Unknown transformation: " + type);
2844
+ }
2845
+ return transformation.untransform(json, superJson);
2846
+ }
2847
+ };
2848
+
2849
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/accessDeep.js
2850
+ var getNthKey = (value, n) => {
2851
+ if (n > value.size)
2852
+ throw new Error("index out of bounds");
2853
+ const keys = value.keys();
2854
+ while (n > 0) {
2855
+ keys.next();
2856
+ n--;
2857
+ }
2858
+ return keys.next().value;
2859
+ };
2860
+ function validatePath(path5) {
2861
+ if (includes(path5, "__proto__")) {
2862
+ throw new Error("__proto__ is not allowed as a property");
2863
+ }
2864
+ if (includes(path5, "prototype")) {
2865
+ throw new Error("prototype is not allowed as a property");
2866
+ }
2867
+ if (includes(path5, "constructor")) {
2868
+ throw new Error("constructor is not allowed as a property");
2869
+ }
2870
+ }
2871
+ var getDeep = (object, path5) => {
2872
+ validatePath(path5);
2873
+ for (let i = 0; i < path5.length; i++) {
2874
+ const key = path5[i];
2875
+ if (isSet(object)) {
2876
+ object = getNthKey(object, +key);
2877
+ } else if (isMap(object)) {
2878
+ const row = +key;
2879
+ const type = +path5[++i] === 0 ? "key" : "value";
2880
+ const keyOfRow = getNthKey(object, row);
2881
+ switch (type) {
2882
+ case "key":
2883
+ object = keyOfRow;
2884
+ break;
2885
+ case "value":
2886
+ object = object.get(keyOfRow);
2887
+ break;
2888
+ }
2889
+ } else {
2890
+ object = object[key];
2891
+ }
2892
+ }
2893
+ return object;
2894
+ };
2895
+ var setDeep = (object, path5, mapper) => {
2896
+ validatePath(path5);
2897
+ if (path5.length === 0) {
2898
+ return mapper(object);
2899
+ }
2900
+ let parent = object;
2901
+ for (let i = 0; i < path5.length - 1; i++) {
2902
+ const key = path5[i];
2903
+ if (isArray(parent)) {
2904
+ const index = +key;
2905
+ parent = parent[index];
2906
+ } else if (isPlainObject(parent)) {
2907
+ parent = parent[key];
2908
+ } else if (isSet(parent)) {
2909
+ const row = +key;
2910
+ parent = getNthKey(parent, row);
2911
+ } else if (isMap(parent)) {
2912
+ const isEnd = i === path5.length - 2;
2913
+ if (isEnd) {
2914
+ break;
2915
+ }
2916
+ const row = +key;
2917
+ const type = +path5[++i] === 0 ? "key" : "value";
2918
+ const keyOfRow = getNthKey(parent, row);
2919
+ switch (type) {
2920
+ case "key":
2921
+ parent = keyOfRow;
2922
+ break;
2923
+ case "value":
2924
+ parent = parent.get(keyOfRow);
2925
+ break;
2926
+ }
2927
+ }
2928
+ }
2929
+ const lastKey = path5[path5.length - 1];
2930
+ if (isArray(parent)) {
2931
+ parent[+lastKey] = mapper(parent[+lastKey]);
2932
+ } else if (isPlainObject(parent)) {
2933
+ parent[lastKey] = mapper(parent[lastKey]);
2934
+ }
2935
+ if (isSet(parent)) {
2936
+ const oldValue = getNthKey(parent, +lastKey);
2937
+ const newValue = mapper(oldValue);
2938
+ if (oldValue !== newValue) {
2939
+ parent.delete(oldValue);
2940
+ parent.add(newValue);
2941
+ }
2942
+ }
2943
+ if (isMap(parent)) {
2944
+ const row = +path5[path5.length - 2];
2945
+ const keyToRow = getNthKey(parent, row);
2946
+ const type = +lastKey === 0 ? "key" : "value";
2947
+ switch (type) {
2948
+ case "key": {
2949
+ const newKey = mapper(keyToRow);
2950
+ parent.set(newKey, parent.get(keyToRow));
2951
+ if (newKey !== keyToRow) {
2952
+ parent.delete(keyToRow);
2953
+ }
2954
+ break;
2955
+ }
2956
+ case "value": {
2957
+ parent.set(keyToRow, mapper(parent.get(keyToRow)));
2958
+ break;
2959
+ }
2960
+ }
2961
+ }
2962
+ return object;
2963
+ };
2964
+
2965
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/plainer.js
2966
+ var enableLegacyPaths = (version) => version < 1;
2967
+ function traverse(tree, walker2, version, origin = []) {
2968
+ if (!tree) {
2969
+ return;
2970
+ }
2971
+ const legacyPaths = enableLegacyPaths(version);
2972
+ if (!isArray(tree)) {
2973
+ forEach(tree, (subtree, key) => traverse(subtree, walker2, version, [
2974
+ ...origin,
2975
+ ...parsePath(key, legacyPaths)
2976
+ ]));
2977
+ return;
2978
+ }
2979
+ const [nodeValue, children] = tree;
2980
+ if (children) {
2981
+ forEach(children, (child, key) => {
2982
+ traverse(child, walker2, version, [
2983
+ ...origin,
2984
+ ...parsePath(key, legacyPaths)
2985
+ ]);
2986
+ });
2987
+ }
2988
+ walker2(nodeValue, origin);
2989
+ }
2990
+ function applyValueAnnotations(plain, annotations, version, superJson) {
2991
+ traverse(annotations, (type, path5) => {
2992
+ plain = setDeep(plain, path5, (v) => untransformValue(v, type, superJson));
2993
+ }, version);
2994
+ return plain;
2995
+ }
2996
+ function applyReferentialEqualityAnnotations(plain, annotations, version) {
2997
+ const legacyPaths = enableLegacyPaths(version);
2998
+ function apply(identicalPaths, path5) {
2999
+ const object = getDeep(plain, parsePath(path5, legacyPaths));
3000
+ identicalPaths.map((path6) => parsePath(path6, legacyPaths)).forEach((identicalObjectPath) => {
3001
+ plain = setDeep(plain, identicalObjectPath, () => object);
3002
+ });
3003
+ }
3004
+ if (isArray(annotations)) {
3005
+ const [root, other] = annotations;
3006
+ root.forEach((identicalPath) => {
3007
+ plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
3008
+ });
3009
+ if (other) {
3010
+ forEach(other, apply);
3011
+ }
3012
+ } else {
3013
+ forEach(annotations, apply);
3014
+ }
3015
+ return plain;
3016
+ }
3017
+ var isDeep = (object, superJson) => isPlainObject(object) || isArray(object) || isMap(object) || isSet(object) || isError(object) || isInstanceOfRegisteredClass(object, superJson);
3018
+ function addIdentity(object, path5, identities) {
3019
+ const existingSet = identities.get(object);
3020
+ if (existingSet) {
3021
+ existingSet.push(path5);
3022
+ } else {
3023
+ identities.set(object, [path5]);
3024
+ }
3025
+ }
3026
+ function generateReferentialEqualityAnnotations(identitites, dedupe) {
3027
+ const result = {};
3028
+ let rootEqualityPaths = void 0;
3029
+ identitites.forEach((paths) => {
3030
+ if (paths.length <= 1) {
3031
+ return;
3032
+ }
3033
+ if (!dedupe) {
3034
+ paths = paths.map((path5) => path5.map(String)).sort((a, b) => a.length - b.length);
3035
+ }
3036
+ const [representativePath, ...identicalPaths] = paths;
3037
+ if (representativePath.length === 0) {
3038
+ rootEqualityPaths = identicalPaths.map(stringifyPath);
3039
+ } else {
3040
+ result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
3041
+ }
3042
+ });
3043
+ if (rootEqualityPaths) {
3044
+ if (isEmptyObject(result)) {
3045
+ return [rootEqualityPaths];
3046
+ } else {
3047
+ return [rootEqualityPaths, result];
3048
+ }
3049
+ } else {
3050
+ return isEmptyObject(result) ? void 0 : result;
3051
+ }
3052
+ }
3053
+ var walker = (object, identities, superJson, dedupe, path5 = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
3054
+ const primitive = isPrimitive(object);
3055
+ if (!primitive) {
3056
+ addIdentity(object, path5, identities);
3057
+ const seen = seenObjects.get(object);
3058
+ if (seen) {
3059
+ return dedupe ? {
3060
+ transformedValue: null
3061
+ } : seen;
3062
+ }
3063
+ }
3064
+ if (!isDeep(object, superJson)) {
3065
+ const transformed2 = transformValue(object, superJson);
3066
+ const result2 = transformed2 ? {
3067
+ transformedValue: transformed2.value,
3068
+ annotations: [transformed2.type]
3069
+ } : {
3070
+ transformedValue: object
3071
+ };
3072
+ if (!primitive) {
3073
+ seenObjects.set(object, result2);
3074
+ }
3075
+ return result2;
3076
+ }
3077
+ if (includes(objectsInThisPath, object)) {
3078
+ return {
3079
+ transformedValue: null
3080
+ };
3081
+ }
3082
+ const transformationResult = transformValue(object, superJson);
3083
+ const transformed = transformationResult?.value ?? object;
3084
+ const transformedValue = isArray(transformed) ? [] : {};
3085
+ const innerAnnotations = {};
3086
+ forEach(transformed, (value, index) => {
3087
+ if (index === "__proto__" || index === "constructor" || index === "prototype") {
3088
+ throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
3089
+ }
3090
+ const recursiveResult = walker(value, identities, superJson, dedupe, [...path5, index], [...objectsInThisPath, object], seenObjects);
3091
+ transformedValue[index] = recursiveResult.transformedValue;
3092
+ if (isArray(recursiveResult.annotations)) {
3093
+ innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
3094
+ } else if (isPlainObject(recursiveResult.annotations)) {
3095
+ forEach(recursiveResult.annotations, (tree, key) => {
3096
+ innerAnnotations[escapeKey(index) + "." + key] = tree;
3097
+ });
3098
+ }
3099
+ });
3100
+ const result = isEmptyObject(innerAnnotations) ? {
3101
+ transformedValue,
3102
+ annotations: !!transformationResult ? [transformationResult.type] : void 0
3103
+ } : {
3104
+ transformedValue,
3105
+ annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
3106
+ };
3107
+ if (!primitive) {
3108
+ seenObjects.set(object, result);
3109
+ }
3110
+ return result;
3111
+ };
3112
+
3113
+ // node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/getType.js
3114
+ function getType2(payload) {
3115
+ return Object.prototype.toString.call(payload).slice(8, -1);
3116
+ }
3117
+
3118
+ // node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isArray.js
3119
+ function isArray2(payload) {
3120
+ return getType2(payload) === "Array";
3121
+ }
3122
+
3123
+ // node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isPlainObject.js
3124
+ function isPlainObject2(payload) {
3125
+ if (getType2(payload) !== "Object")
3126
+ return false;
3127
+ const prototype = Object.getPrototypeOf(payload);
3128
+ return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
3129
+ }
3130
+
3131
+ // node_modules/.pnpm/copy-anything@4.0.5/node_modules/copy-anything/dist/index.js
3132
+ function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
3133
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
3134
+ if (propType === "enumerable")
3135
+ carry[key] = newVal;
3136
+ if (includeNonenumerable && propType === "nonenumerable") {
3137
+ Object.defineProperty(carry, key, {
3138
+ value: newVal,
3139
+ enumerable: false,
3140
+ writable: true,
3141
+ configurable: true
3142
+ });
3143
+ }
3144
+ }
3145
+ function copy(target, options = {}) {
3146
+ if (isArray2(target)) {
3147
+ return target.map((item) => copy(item, options));
3148
+ }
3149
+ if (!isPlainObject2(target)) {
3150
+ return target;
3151
+ }
3152
+ const props = Object.getOwnPropertyNames(target);
3153
+ const symbols = Object.getOwnPropertySymbols(target);
3154
+ return [...props, ...symbols].reduce((carry, key) => {
3155
+ if (key === "__proto__")
3156
+ return carry;
3157
+ if (isArray2(options.props) && !options.props.includes(key)) {
3158
+ return carry;
3159
+ }
3160
+ const val = target[key];
3161
+ const newVal = copy(val, options);
3162
+ assignProp(carry, key, newVal, target, options.nonenumerable);
3163
+ return carry;
3164
+ }, {});
3165
+ }
3166
+
3167
+ // node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/index.js
3168
+ var SuperJSON = class {
3169
+ /**
3170
+ * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
3171
+ */
3172
+ constructor({ dedupe = false } = {}) {
3173
+ this.classRegistry = new ClassRegistry();
3174
+ this.symbolRegistry = new Registry((s) => s.description ?? "");
3175
+ this.customTransformerRegistry = new CustomTransformerRegistry();
3176
+ this.allowedErrorProps = [];
3177
+ this.dedupe = dedupe;
3178
+ }
3179
+ serialize(object) {
3180
+ const identities = /* @__PURE__ */ new Map();
3181
+ const output = walker(object, identities, this, this.dedupe);
3182
+ const res = {
3183
+ json: output.transformedValue
3184
+ };
3185
+ if (output.annotations) {
3186
+ res.meta = {
3187
+ ...res.meta,
3188
+ values: output.annotations
3189
+ };
3190
+ }
3191
+ const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
3192
+ if (equalityAnnotations) {
3193
+ res.meta = {
3194
+ ...res.meta,
3195
+ referentialEqualities: equalityAnnotations
3196
+ };
3197
+ }
3198
+ if (res.meta)
3199
+ res.meta.v = 1;
3200
+ return res;
3201
+ }
3202
+ deserialize(payload, options) {
3203
+ const { json, meta } = payload;
3204
+ let result = options?.inPlace ? json : copy(json);
3205
+ if (meta?.values) {
3206
+ result = applyValueAnnotations(result, meta.values, meta.v ?? 0, this);
3207
+ }
3208
+ if (meta?.referentialEqualities) {
3209
+ result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities, meta.v ?? 0);
3210
+ }
3211
+ return result;
3212
+ }
3213
+ stringify(object) {
3214
+ return JSON.stringify(this.serialize(object));
3215
+ }
3216
+ parse(string) {
3217
+ return this.deserialize(JSON.parse(string), { inPlace: true });
3218
+ }
3219
+ registerClass(v, options) {
3220
+ this.classRegistry.register(v, options);
3221
+ }
3222
+ registerSymbol(v, identifier) {
3223
+ this.symbolRegistry.register(v, identifier);
3224
+ }
3225
+ registerCustom(transformer, name) {
3226
+ this.customTransformerRegistry.register({
3227
+ name,
3228
+ ...transformer
3229
+ });
3230
+ }
3231
+ allowErrorProps(...props) {
3232
+ this.allowedErrorProps.push(...props);
3233
+ }
3234
+ };
3235
+ SuperJSON.defaultInstance = new SuperJSON();
3236
+ SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
3237
+ SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
3238
+ SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
3239
+ SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
3240
+ SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
3241
+ SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
3242
+ SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
3243
+ SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
3244
+ var dist_default = SuperJSON;
3245
+ var serialize = SuperJSON.serialize;
3246
+ var deserialize = SuperJSON.deserialize;
3247
+ var stringify = SuperJSON.stringify;
3248
+ var parse = SuperJSON.parse;
3249
+ var registerClass = SuperJSON.registerClass;
3250
+ var registerCustom = SuperJSON.registerCustom;
3251
+ var registerSymbol = SuperJSON.registerSymbol;
3252
+ var allowErrorProps = SuperJSON.allowErrorProps;
3253
+
3254
+ // src/api/client.ts
3255
+ var _client;
3256
+ async function getTrpcClient() {
3257
+ if (_client) return _client;
3258
+ const result = await getValidToken();
3259
+ if (!result) {
3260
+ log.error("No authentication found. Run 'lh login' first.");
3261
+ process.exit(1);
3262
+ }
3263
+ const { serverUrl, accessToken } = result.credentials;
3264
+ _client = createTRPCClient({
3265
+ links: [
3266
+ httpLink({
3267
+ headers: {
3268
+ "Oidc-Auth": accessToken
3269
+ },
3270
+ transformer: dist_default,
3271
+ url: `${serverUrl.replace(/\/$/, "")}/trpc/lambda`
3272
+ })
3273
+ ]
3274
+ });
3275
+ return _client;
3276
+ }
3277
+
3278
+ // src/commands/doc.ts
3279
+ function timeAgo(date) {
3280
+ const diff = Date.now() - new Date(date).getTime();
3281
+ const seconds = Math.floor(diff / 1e3);
3282
+ const minutes = Math.floor(seconds / 60);
3283
+ const hours = Math.floor(minutes / 60);
3284
+ const days = Math.floor(hours / 24);
3285
+ if (days > 0) return `${days}d ago`;
3286
+ if (hours > 0) return `${hours}h ago`;
3287
+ if (minutes > 0) return `${minutes}m ago`;
3288
+ return `${seconds}s ago`;
3289
+ }
3290
+ function truncate(str, len) {
3291
+ if (str.length <= len) return str;
3292
+ return str.slice(0, len - 1) + "\u2026";
3293
+ }
3294
+ function printTable(rows, header) {
3295
+ const allRows = [header, ...rows];
3296
+ const colWidths = header.map((_, i) => Math.max(...allRows.map((r) => (r[i] || "").length)));
3297
+ const headerLine = header.map((h, i) => h.padEnd(colWidths[i])).join(" ");
3298
+ console.log(pc2.bold(headerLine));
3299
+ for (const row of rows) {
3300
+ const line = row.map((cell, i) => (cell || "").padEnd(colWidths[i])).join(" ");
3301
+ console.log(line);
3302
+ }
3303
+ }
3304
+ function pickFields(obj, fields) {
3305
+ const result = {};
3306
+ for (const f of fields) {
3307
+ if (f in obj) result[f] = obj[f];
3308
+ }
3309
+ return result;
3310
+ }
3311
+ function outputJson(data, fields) {
3312
+ if (fields) {
3313
+ const fieldList = fields.split(",").map((f) => f.trim());
3314
+ if (Array.isArray(data)) {
3315
+ console.log(
3316
+ JSON.stringify(
3317
+ data.map((item) => pickFields(item, fieldList)),
3318
+ null,
3319
+ 2
3320
+ )
3321
+ );
3322
+ } else if (data && typeof data === "object") {
3323
+ console.log(JSON.stringify(pickFields(data, fieldList), null, 2));
3324
+ }
3325
+ } else {
3326
+ console.log(JSON.stringify(data, null, 2));
3327
+ }
3328
+ }
3329
+ function readBodyContent(options) {
3330
+ if (options.bodyFile) {
3331
+ if (!fs4.existsSync(options.bodyFile)) {
3332
+ log.error(`File not found: ${options.bodyFile}`);
3333
+ process.exit(1);
3334
+ }
3335
+ return fs4.readFileSync(options.bodyFile, "utf8");
3336
+ }
3337
+ return options.body;
3338
+ }
3339
+ async function confirm(message) {
3340
+ const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
3341
+ return new Promise((resolve) => {
3342
+ rl.question(`${message} (y/N) `, (answer) => {
3343
+ rl.close();
3344
+ resolve(answer.toLowerCase() === "y");
3345
+ });
3346
+ });
3347
+ }
3348
+ function registerDocCommand(program2) {
3349
+ const doc = program2.command("doc").description("Manage documents");
3350
+ doc.command("list").description("List documents").option("-L, --limit <n>", "Maximum number of items to fetch", "30").option("--file-type <type>", "Filter by file type").option("--json [fields]", "Output JSON, optionally specify fields (comma-separated)").action(async (options) => {
3351
+ const client = await getTrpcClient();
3352
+ const pageSize = Number.parseInt(options.limit || "30", 10);
3353
+ const query = { pageSize };
3354
+ if (options.fileType) query.fileTypes = [options.fileType];
3355
+ const result = await client.document.queryDocuments.query(query);
3356
+ const docs = Array.isArray(result) ? result : result.items ?? [];
3357
+ if (options.json !== void 0) {
3358
+ const fields = typeof options.json === "string" ? options.json : void 0;
3359
+ outputJson(docs, fields);
3360
+ return;
3361
+ }
3362
+ if (docs.length === 0) {
3363
+ console.log("No documents found.");
3364
+ return;
3365
+ }
3366
+ const rows = docs.map((d) => [
3367
+ d.id,
3368
+ truncate(d.title || d.filename || "Untitled", 120),
3369
+ d.fileType || "",
3370
+ d.updatedAt ? timeAgo(d.updatedAt) : ""
3371
+ ]);
3372
+ printTable(rows, ["ID", "TITLE", "TYPE", "UPDATED"]);
3373
+ });
3374
+ doc.command("view <id>").description("View a document").option("--json [fields]", "Output JSON, optionally specify fields (comma-separated)").action(async (id, options) => {
3375
+ const client = await getTrpcClient();
3376
+ const document = await client.document.getDocumentById.query({ id });
3377
+ if (!document) {
3378
+ log.error(`Document not found: ${id}`);
3379
+ process.exit(1);
3380
+ return;
3381
+ }
3382
+ if (options.json !== void 0) {
3383
+ const fields = typeof options.json === "string" ? options.json : void 0;
3384
+ outputJson(document, fields);
3385
+ return;
3386
+ }
3387
+ console.log(pc2.bold(document.title || "Untitled"));
3388
+ const meta = [];
3389
+ if (document.fileType) meta.push(document.fileType);
3390
+ if (document.updatedAt) meta.push(`Updated ${timeAgo(document.updatedAt)}`);
3391
+ if (meta.length > 0) console.log(pc2.dim(meta.join(" \xB7 ")));
3392
+ console.log();
3393
+ if (document.content) {
3394
+ console.log(document.content);
3395
+ } else {
3396
+ console.log(pc2.dim("(no content)"));
3397
+ }
3398
+ });
3399
+ doc.command("create").description("Create a new document").requiredOption("-t, --title <title>", "Document title").option("-b, --body <content>", "Document content").option("-F, --body-file <path>", "Read content from file").option("--parent <id>", "Parent document or folder ID").option("--slug <slug>", "Custom slug").action(
3400
+ async (options) => {
3401
+ const content = readBodyContent(options);
3402
+ const client = await getTrpcClient();
3403
+ const result = await client.document.createDocument.mutate({
3404
+ content,
3405
+ editorData: JSON.stringify({ content: content || "", type: "doc" }),
3406
+ parentId: options.parent,
3407
+ slug: options.slug,
3408
+ title: options.title
3409
+ });
3410
+ console.log(`${pc2.green("\u2713")} Created document ${pc2.bold(result.id)}`);
3411
+ }
3412
+ );
3413
+ doc.command("edit <id>").description("Edit a document").option("-t, --title <title>", "New title").option("-b, --body <content>", "New content").option("-F, --body-file <path>", "Read new content from file").option("--parent <id>", "Move to parent document (empty string for root)").action(
3414
+ async (id, options) => {
3415
+ const content = readBodyContent(options);
3416
+ if (!options.title && !content && options.parent === void 0) {
3417
+ log.error("No changes specified. Use --title, --body, --body-file, or --parent.");
3418
+ process.exit(1);
3419
+ }
3420
+ const client = await getTrpcClient();
3421
+ const params = { id };
3422
+ if (options.title) params.title = options.title;
3423
+ if (content !== void 0) {
3424
+ params.content = content;
3425
+ params.editorData = JSON.stringify({ content, type: "doc" });
3426
+ }
3427
+ if (options.parent !== void 0) {
3428
+ params.parentId = options.parent || null;
3429
+ }
3430
+ await client.document.updateDocument.mutate(params);
3431
+ console.log(`${pc2.green("\u2713")} Updated document ${pc2.bold(id)}`);
3432
+ }
3433
+ );
3434
+ doc.command("delete <ids...>").description("Delete one or more documents").option("--yes", "Skip confirmation prompt").action(async (ids, options) => {
3435
+ if (!options.yes) {
3436
+ const confirmed = await confirm(
3437
+ `Are you sure you want to delete ${ids.length} document(s)?`
3438
+ );
3439
+ if (!confirmed) {
3440
+ console.log("Cancelled.");
3441
+ return;
3442
+ }
3443
+ }
3444
+ const client = await getTrpcClient();
3445
+ if (ids.length === 1) {
3446
+ await client.document.deleteDocument.mutate({ id: ids[0] });
3447
+ } else {
3448
+ await client.document.deleteDocuments.mutate({ ids });
3449
+ }
3450
+ console.log(`${pc2.green("\u2713")} Deleted ${ids.length} document(s)`);
3451
+ });
3452
+ }
3453
+
1252
3454
  // src/commands/login.ts
1253
3455
  import { execFile } from "child_process";
1254
3456
  var CLIENT_ID2 = "lobehub-cli";
@@ -1292,7 +3494,7 @@ function registerLoginCommand(program2) {
1292
3494
  const expiresAt = Date.now() + deviceAuth.expires_in * 1e3;
1293
3495
  let pollInterval = interval;
1294
3496
  while (Date.now() < expiresAt) {
1295
- await sleep(pollInterval);
3497
+ await sleep2(pollInterval);
1296
3498
  try {
1297
3499
  const res = await fetch(`${serverUrl}/oidc/token`, {
1298
3500
  body: new URLSearchParams({
@@ -1345,7 +3547,7 @@ function registerLoginCommand(program2) {
1345
3547
  process.exit(1);
1346
3548
  });
1347
3549
  }
1348
- function sleep(ms) {
3550
+ function sleep2(ms) {
1349
3551
  return new Promise((resolve) => setTimeout(resolve, ms));
1350
3552
  }
1351
3553
  function openBrowser(url) {
@@ -1431,4 +3633,10 @@ registerLoginCommand(program);
1431
3633
  registerLogoutCommand(program);
1432
3634
  registerConnectCommand(program);
1433
3635
  registerStatusCommand(program);
3636
+ registerDocCommand(program);
1434
3637
  program.parse();
3638
+ /*! Bundled license information:
3639
+
3640
+ @trpc/client/dist/httpLink-Cz9h1Qgh.mjs:
3641
+ (* istanbul ignore if -- @preserve *)
3642
+ */