@aixnn/aixautots 0.6.12 → 0.6.17

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 (51) hide show
  1. package/dist/{automation-queue-CvrWEOw2.d.ts → automation-queue-DO8fOG6l.d.ts} +2 -2
  2. package/dist/{chunk-PUEKOYSH.js → chunk-2KPZSPV6.js} +131 -3
  3. package/dist/{chunk-D7J4EQTA.js → chunk-3OBCSW2J.js} +1 -1
  4. package/dist/{chunk-UH5OYPXE.js → chunk-7BJPVSEZ.js} +205 -18
  5. package/dist/{chunk-SKTL6ACT.js → chunk-7RQTSTR6.js} +3 -3
  6. package/dist/{chunk-LO3XD4T5.js → chunk-FJPIY4YI.js} +124 -8
  7. package/dist/{chunk-SL6M6CC6.js → chunk-KASSYUGM.js} +3 -3
  8. package/dist/chunk-LOKPZ677.js +422 -0
  9. package/dist/{chunk-E7WMHM63.js → chunk-MBBVYSPD.js} +7 -0
  10. package/dist/{chunk-ROOOAG3E.js → chunk-NIEGPH3E.js} +51 -418
  11. package/dist/{chunk-7IXBWJHB.js → chunk-QEK25NUA.js} +5 -5
  12. package/dist/{chunk-QZLUQSLA.js → chunk-TJ2QIP5M.js} +352 -423
  13. package/dist/{chunk-LR5LJJNM.js → chunk-WOPEKCVC.js} +4 -4
  14. package/dist/chunk-ZCTAYVPK.js +1 -0
  15. package/dist/{chunk-XCYGBYFC.js → chunk-ZDCTHR7D.js} +215 -126
  16. package/dist/{config-BUH2EYHO.d.ts → config-CBUhr4Gl.d.ts} +173 -2
  17. package/dist/core/index.d.ts +29 -11
  18. package/dist/core/index.js +2 -2
  19. package/dist/{device-normalize-DzuVemCy.d.ts → device-normalize-Vl5JYbAI.d.ts} +7 -4
  20. package/dist/device-session-3XK2SZDF.js +1 -0
  21. package/dist/i18n/index.js +1 -1
  22. package/dist/{mirror-session-D2YY9mKf.d.ts → mirror-session-Y1InpkUY.d.ts} +14 -4
  23. package/dist/react/index.d.ts +9 -9
  24. package/dist/react/index.js +3 -3
  25. package/dist/{script-debugger-Csm4CrfY.d.ts → script-debugger-DoT02din.d.ts} +1 -1
  26. package/dist/{task-agent-runner-C4WfT77g.d.ts → task-agent-runner-Cl2ickJ1.d.ts} +3 -3
  27. package/dist/{types-BfIeUpsU.d.ts → types-Cp1ohbTb.d.ts} +35 -3
  28. package/dist/ui/billing.d.ts +2 -2
  29. package/dist/ui/billing.js +14 -8
  30. package/dist/ui/device-create.d.ts +5 -2
  31. package/dist/ui/device-create.js +8 -7
  32. package/dist/ui/device-mirror.js +7 -7
  33. package/dist/ui/devices.d.ts +5 -5
  34. package/dist/ui/devices.js +12 -11
  35. package/dist/ui/editor.d.ts +2 -2
  36. package/dist/ui/editor.js +7 -7
  37. package/dist/ui/index.d.ts +5 -4
  38. package/dist/ui/index.js +9 -7
  39. package/dist/ui/inspector.js +5 -5
  40. package/dist/ui/ip-commerce.d.ts +28 -0
  41. package/dist/ui/ip-commerce.js +8 -0
  42. package/dist/ui/market.js +4 -4
  43. package/dist/ui/mirror.d.ts +5 -4
  44. package/dist/ui/mirror.js +1 -1
  45. package/dist/ui/primitives/index.js +1 -1
  46. package/dist/ui/script-studio.js +6 -6
  47. package/dist/ui/scripts.d.ts +1 -1
  48. package/dist/ui/scripts.js +5 -5
  49. package/dist/ui/tasks.js +12 -11
  50. package/package.json +6 -2
  51. package/dist/device-session-7MKEJTIA.js +0 -1
@@ -0,0 +1,422 @@
1
+ import { useAixLang } from './chunk-FJPIY4YI.js';
2
+ import { Button } from './chunk-7RQTSTR6.js';
3
+ import { useClient } from './chunk-QEK25NUA.js';
4
+ import { useState, useRef, useEffect } from 'react';
5
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+
7
+ var usd = (cents) => `USD ${(cents / 100).toFixed(2)}`;
8
+ function offerUnit(offer, zh) {
9
+ if (offer.billing_mode === "term") return zh ? "IP / \u5929" : "IP / day";
10
+ return `${offer.unit_bytes ?? "\u2014"} bytes`;
11
+ }
12
+ function chooseRegionOffer(offers) {
13
+ const billing = (offer) => offer.billing_mode === "term" ? 0 : offer.billing_mode === "prepaid" ? 1 : 2;
14
+ return [...offers].sort((a, b) => (a.available === false ? 1 : 0) - (b.available === false ? 1 : 0) || billing(a) - billing(b) || (a.kind === b.kind ? 0 : a.kind === "static" ? -1 : 1) || (a.unit_price_cents ?? Number.MAX_SAFE_INTEGER) - (b.unit_price_cents ?? Number.MAX_SAFE_INTEGER) || a.tier_rank - b.tier_rank || a.name.localeCompare(b.name))[0];
15
+ }
16
+ var clientIds = /* @__PURE__ */ new WeakMap();
17
+ var nextClientId = 0;
18
+ function IpCommercePanel(props) {
19
+ return props.client ? /* @__PURE__ */ jsx(BoundPanel, { ...props, client: props.client }) : /* @__PURE__ */ jsx(ConnectedPanel, { ...props });
20
+ }
21
+ function ConnectedPanel(props) {
22
+ const client = useClient();
23
+ return /* @__PURE__ */ jsx(BoundPanel, { ...props, client });
24
+ }
25
+ function BoundPanel(props) {
26
+ const { client } = props;
27
+ if (!clientIds.has(client)) clientIds.set(client, ++nextClientId);
28
+ return /* @__PURE__ */ jsx(IpCommerceSession, { ...props }, `${clientIds.get(client)}:${props.deviceId ?? (props.creationSpec ? "creation" : "standalone")}`);
29
+ }
30
+ function IpCommerceSession(props) {
31
+ const { client } = props;
32
+ const standalone = !props.deviceId && !props.creationSpec;
33
+ const supported = props.supported ?? standalone;
34
+ const regionOnly = props.regionOnly === true;
35
+ const lang = useAixLang();
36
+ const zh = lang === "zh";
37
+ const msg = (cn, en) => zh ? cn : en;
38
+ const [catalog, setCatalog] = useState(null);
39
+ const [orders, setOrders] = useState([]);
40
+ const [resources, setResources] = useState([]);
41
+ const [kind, setKind] = useState("static");
42
+ const [country, setCountry] = useState("");
43
+ const [tier, setTier] = useState("");
44
+ const [mode, setMode] = useState("");
45
+ const [ceiling, setCeiling] = useState("");
46
+ const [selected, setSelected] = useState("");
47
+ const [duration, setDuration] = useState("");
48
+ const [traffic, setTraffic] = useState("");
49
+ const [limit, setLimit] = useState("");
50
+ const [quote, setQuote] = useState(null);
51
+ const [pending, setPending] = useState(null);
52
+ const [storage, setStorage] = useState(null);
53
+ const storageRef = useRef(null);
54
+ const [busy, setBusy] = useState(false);
55
+ const [loading, setLoading] = useState(true);
56
+ const [error, setError] = useState("");
57
+ const [notice, setNotice] = useState("");
58
+ const [, setClock] = useState(0);
59
+ const alive = useRef(true);
60
+ const lock = useRef(false);
61
+ const latest = useRef(props);
62
+ latest.current = props;
63
+ const quoteScope = useRef("");
64
+ const currentScope = JSON.stringify([props.deviceId, props.creationSpec]);
65
+ const filters = catalog?.offers.filter((o) => o.kind === kind) ?? [];
66
+ const offers = filters.filter((o) => (!country || o.region === country) && (!tier || o.tier === tier) && (!mode || o.billing_mode === mode) && (!ceiling || o.unit_price_cents !== null && o.unit_price_cents <= Number(ceiling)));
67
+ const listed = regionOnly ? catalog?.offers.filter((o) => !!country && o.region === country) ?? [] : offers;
68
+ const offer = regionOnly ? chooseRegionOffer(listed) : listed.find((o) => o.offer_id === selected) ?? listed[0];
69
+ const regions = [...new Set((regionOnly ? catalog?.offers ?? [] : filters).flatMap((o) => o.region ? [o.region] : []))];
70
+ const frozen = busy || !!pending;
71
+ const active = orders.find((o) => o.id === pending);
72
+ const issue = (e) => e instanceof Error ? e.message : String(e);
73
+ const remember = (id) => {
74
+ if (!storage) throw new Error(msg("\u7528\u6237\u4E0A\u4E0B\u6587\u5C1A\u672A\u5C31\u7EEA", "User context is not ready"));
75
+ if (id) localStorage.setItem(storage, id);
76
+ else localStorage.removeItem(storage);
77
+ setPending(id);
78
+ };
79
+ const run = async (action) => {
80
+ if (lock.current) return;
81
+ lock.current = true;
82
+ setBusy(true);
83
+ setError("");
84
+ setNotice("");
85
+ try {
86
+ await action();
87
+ } catch (e) {
88
+ if (alive.current) setError(issue(e));
89
+ } finally {
90
+ lock.current = false;
91
+ if (alive.current) setBusy(false);
92
+ }
93
+ };
94
+ const refresh = async () => {
95
+ const [rows, usage] = await Promise.all([client.ipCommerce.orders(props.deviceId ?? ""), client.ipCommerce.resources()]);
96
+ if (!alive.current) return;
97
+ setOrders((old) => [...rows, ...old.filter((o) => !rows.some((r) => r.id === o.id))]);
98
+ setResources(usage.items);
99
+ const unresolved = rows.find((o) => o.status === "pending");
100
+ if (unresolved && storageRef.current) {
101
+ localStorage.setItem(storageRef.current, unresolved.id);
102
+ setPending(unresolved.id);
103
+ }
104
+ };
105
+ useEffect(() => {
106
+ alive.current = true;
107
+ const controller = new AbortController();
108
+ void (async () => {
109
+ try {
110
+ const context = await client.ipCommerce.capabilities({ signal: controller.signal });
111
+ if (!alive.current) return;
112
+ const key = JSON.stringify(["aixips-commerce", client.cfg.baseUrl, context.owner_user_id, context.project_id, props.deviceId ?? (standalone ? "standalone" : "creation")]);
113
+ storageRef.current = key;
114
+ setStorage(key);
115
+ const saved = localStorage.getItem(key);
116
+ if (saved) {
117
+ setPending(saved);
118
+ const row = await client.ipCommerce.order(saved, { signal: controller.signal });
119
+ if (!alive.current) return;
120
+ setOrders([row]);
121
+ if (row.status === "quoted") setQuote(row.quote);
122
+ }
123
+ await refresh();
124
+ const result = await client.ipCommerce.catalog({}, { signal: controller.signal });
125
+ if (alive.current) setCatalog(result);
126
+ } catch (e) {
127
+ if (alive.current) setError(issue(e));
128
+ } finally {
129
+ if (alive.current) setLoading(false);
130
+ }
131
+ })();
132
+ return () => {
133
+ alive.current = false;
134
+ controller.abort();
135
+ };
136
+ }, [client, props.deviceId]);
137
+ useEffect(() => {
138
+ if (!loading) latest.current.onPendingChange?.(!!pending);
139
+ }, [pending, loading]);
140
+ useEffect(() => {
141
+ const timer = setInterval(() => {
142
+ setClock((n) => n + 1);
143
+ if (!pending || lock.current) return;
144
+ void client.ipCommerce.order(pending).then((row) => {
145
+ if (!alive.current) return;
146
+ setOrders((old) => [row, ...old.filter((o) => o.id !== row.id)]);
147
+ if (row.status === "fulfilled") void client.ipCommerce.resources().then((r) => {
148
+ if (alive.current) setResources(r.items);
149
+ }).catch(() => {
150
+ });
151
+ }).catch((e) => {
152
+ if (alive.current) setError(issue(e));
153
+ });
154
+ }, 5e3);
155
+ return () => clearInterval(timer);
156
+ }, [client, pending]);
157
+ useEffect(() => {
158
+ if (!pending) setQuote(null);
159
+ }, [currentScope, selected, kind, country, tier, mode, ceiling, duration, traffic, limit, pending]);
160
+ const preferredRegion = regionOnly && catalog ? regions.find((region) => catalog.offers.some((o) => o.region === region && o.available && o.billing_mode !== "payg")) ?? regions.find((region) => catalog.offers.some((o) => o.region === region && o.available)) ?? regions[0] : "";
161
+ if (regionOnly && preferredRegion && !regions.includes(country)) setCountry(preferredRegion);
162
+ const selectClass = "min-h-11 w-full rounded border border-border bg-background px-2 text-sm disabled:opacity-50";
163
+ const getQuote = () => run(async () => {
164
+ if (!offer || !offer.available) return;
165
+ quoteScope.current = currentScope;
166
+ const q = await client.ipCommerce.quote({
167
+ request_id: crypto.randomUUID(),
168
+ ...props.deviceId ? { device_id: props.deviceId } : { creation_spec: props.creationSpec },
169
+ offer_id: offer.offer_id,
170
+ quantity: 1,
171
+ ...offer.billing_mode === "term" ? { duration_days: Number(duration || offer.duration_days_options[0]) } : {},
172
+ ...offer.billing_mode === "prepaid" ? { traffic_gb: Number(traffic || offer.traffic_gb_options[0]) } : {},
173
+ ...offer.billing_mode === "payg" ? { spend_limit_cents: Number(limit) } : {}
174
+ });
175
+ if (alive.current) setQuote(q);
176
+ });
177
+ const buy = (chosen = quote) => run(async () => {
178
+ const quote2 = chosen;
179
+ if (!quote2 || !quote2.retail_configured || Date.parse(quote2.expires_at) <= Date.now()) return;
180
+ if (!pending && quoteScope.current !== currentScope) throw new Error(msg("\u8BBE\u5907\u914D\u7F6E\u5DF2\u6539\u53D8\uFF0C\u8BF7\u91CD\u65B0\u62A5\u4EF7", "Device settings changed; request a new quote"));
181
+ remember(quote2.id);
182
+ const row = await client.ipCommerce.purchase({ quote_id: quote2.id, max_total_cents: quote2.total_cents, confirm: true });
183
+ if (alive.current) {
184
+ setOrders((old) => [row, ...old.filter((o) => o.id !== row.id)]);
185
+ setQuote(null);
186
+ }
187
+ });
188
+ const selectResource = (resource, row) => run(async () => {
189
+ if (props.onConnectionSelected) {
190
+ const connection = await client.ipCommerce.resourceConnection(resource.id);
191
+ if (!alive.current) return;
192
+ await latest.current.onConnectionSelected?.(connection, resource, row);
193
+ }
194
+ if (alive.current) latest.current.onResourceSelected?.(resource, row);
195
+ });
196
+ const apply = (row, resourceId) => run(async () => {
197
+ if (props.deviceId) {
198
+ const r = await client.ipCommerce.apply(row.id, resourceId);
199
+ if (!alive.current) return;
200
+ setNotice(`${msg("\u4EE3\u7406\u914D\u7F6E\u72B6\u6001", "Proxy configuration status")}: ${r.status}`);
201
+ latest.current.onChanged?.();
202
+ if (r.status === "applied" && pending === row.id) remember(null);
203
+ } else if (props.creationSpec) {
204
+ const result = await client.ipCommerce.createDevice(row.id);
205
+ if (!alive.current) return;
206
+ remember(null);
207
+ latest.current.onCreated?.(result.device_id);
208
+ }
209
+ });
210
+ return /* @__PURE__ */ jsxs("section", { hidden: props.visible === false, "aria-busy": loading || busy, className: "space-y-3 text-sm", children: [
211
+ standalone && /* @__PURE__ */ jsx("p", { children: msg("\u8D2D\u4E70\u7684 IP \u5F52\u5C5E\u5F53\u524D\u7528\u6237\u548C\u9879\u76EE\uFF0C\u8D39\u7528\u4EE5 USD \u7ED3\u7B97\u3002\u9009\u62E9 IP \u4E0D\u989D\u5916\u6536\u8D39\uFF0C\u4F7F\u7528\u6D41\u91CF\u4ECD\u6309\u5546\u54C1\u89C4\u5219\u8BA1\u8D39\u3002", "IPs belong to the current user and project. Charges are in USD. Selection has no additional fee; traffic remains subject to product pricing.") }),
212
+ /* @__PURE__ */ jsxs("p", { className: "font-medium", children: [
213
+ "AIxIPs \xB7 ",
214
+ msg("\u5730\u533A\u4E0E\u5546\u54C1", "Regions and products")
215
+ ] }),
216
+ loading && /* @__PURE__ */ jsx("p", { role: "status", children: msg("\u6B63\u5728\u67E5\u8BE2\u771F\u5B9E\u5E93\u5B58\u4E0E\u4EF7\u683C\uFF0C\u7EBF\u8DEF\u68C0\u67E5\u53EF\u80FD\u9700\u8981 45 \u79D2\u2026", "Checking live inventory and prices; line checks may take 45 seconds\u2026") }),
217
+ error && /* @__PURE__ */ jsx("p", { role: "alert", className: "break-words text-destructive", children: error }),
218
+ notice && /* @__PURE__ */ jsx("p", { role: "status", children: notice }),
219
+ !supported && !standalone && /* @__PURE__ */ jsx("p", { children: msg("\u5F53\u524D\u8282\u70B9\u4E0D\u652F\u6301\u8BBE\u5907\u4EE3\u7406\uFF0C\u8BF7\u9009\u62E9\u652F\u6301\u4EE3\u7406\u7684 Redroid \u8282\u70B9\u3002", "Choose a Redroid node with per-device proxy support.") }),
220
+ pending && /* @__PURE__ */ jsxs("div", { className: "rounded border border-border p-3 space-y-2", children: [
221
+ /* @__PURE__ */ jsxs("p", { className: "break-all", children: [
222
+ msg("\u539F\u8BA2\u5355", "Original order"),
223
+ ": ",
224
+ pending
225
+ ] }),
226
+ /* @__PURE__ */ jsx("p", { role: "status", children: active?.status ?? msg("\u6B63\u5728\u6062\u590D\u7ED3\u679C", "Recovering outcome") }),
227
+ active?.failure_reason && /* @__PURE__ */ jsx("p", { role: "alert", children: active.failure_reason }),
228
+ (!active || active.status === "pending") && /* @__PURE__ */ jsx("p", { children: msg("\u6B63\u5728\u6838\u5BF9\u91C7\u8D2D\u7ED3\u679C\u3002\u8BF7\u52FF\u91CD\u65B0\u4E0B\u5355\uFF1B\u8D85\u65F6\u4E0D\u4EE3\u8868\u672A\u6210\u4EA4\u3002", "Reconciling purchase. Do not place another order; a timeout does not mean the purchase failed.") }),
229
+ active?.status === "rejected" && /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => {
230
+ remember(null);
231
+ setQuote(null);
232
+ }, children: msg("\u5173\u95ED\u5DF2\u53D6\u6D88\u62A5\u4EF7", "Close cancelled quote") }),
233
+ active?.status === "quoted" && /* @__PURE__ */ jsxs(Fragment, { children: [
234
+ /* @__PURE__ */ jsx(Button, { disabled: busy || Date.parse(active.quote.expires_at) <= Date.now() || !active.quote.retail_configured, onClick: () => void buy(active.quote), children: msg("\u786E\u8BA4\u539F\u62A5\u4EF7\u5E76\u91C7\u8D2D", "Confirm original quote and purchase") }),
235
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", disabled: busy, onClick: () => void run(async () => {
236
+ const row = await client.ipCommerce.cancelQuote(active.id);
237
+ if (!alive.current) return;
238
+ if (row.status === "rejected") {
239
+ remember(null);
240
+ setQuote(null);
241
+ } else setOrders((old) => [row, ...old.filter((o) => o.id !== row.id)]);
242
+ }), children: msg("\u53D6\u6D88\u672A\u63D0\u4EA4\u62A5\u4EF7", "Cancel unsubmitted quote") })
243
+ ] })
244
+ ] }),
245
+ !pending && catalog && /* @__PURE__ */ jsxs(Fragment, { children: [
246
+ regionOnly ? /* @__PURE__ */ jsxs("label", { children: [
247
+ msg("\u56FD\u5BB6\uFF0F\u5730\u533A", "Country / region"),
248
+ /* @__PURE__ */ jsx("select", { className: selectClass, disabled: frozen, value: country, onChange: (e) => setCountry(e.target.value), children: regions.map((r) => /* @__PURE__ */ jsx("option", { value: r, children: r.toUpperCase() }, r)) })
249
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
250
+ /* @__PURE__ */ jsxs("label", { children: [
251
+ msg("\u7C7B\u578B", "Type"),
252
+ /* @__PURE__ */ jsxs("select", { className: selectClass, disabled: frozen, value: kind, onChange: (e) => {
253
+ setKind(e.target.value);
254
+ setSelected("");
255
+ setCountry("");
256
+ setTier("");
257
+ setMode("");
258
+ }, children: [
259
+ /* @__PURE__ */ jsx("option", { value: "static", children: msg("\u9759\u6001", "Static") }),
260
+ /* @__PURE__ */ jsx("option", { value: "dynamic", children: msg("\u52A8\u6001", "Dynamic") })
261
+ ] })
262
+ ] }),
263
+ /* @__PURE__ */ jsxs("label", { children: [
264
+ msg("\u56FD\u5BB6\uFF0F\u5730\u533A", "Country / region"),
265
+ /* @__PURE__ */ jsxs("select", { className: selectClass, disabled: frozen, value: country, onChange: (e) => setCountry(e.target.value), children: [
266
+ /* @__PURE__ */ jsx("option", { value: "", children: msg("\u5168\u90E8", "All") }),
267
+ regions.map((r) => /* @__PURE__ */ jsx("option", { value: r, children: r.toUpperCase() }, r))
268
+ ] })
269
+ ] }),
270
+ /* @__PURE__ */ jsxs("label", { children: [
271
+ msg("\u5546\u54C1\u5206\u7C7B", "Product tier"),
272
+ /* @__PURE__ */ jsxs("select", { className: selectClass, disabled: frozen, value: tier, onChange: (e) => setTier(e.target.value), children: [
273
+ /* @__PURE__ */ jsx("option", { value: "", children: msg("\u5168\u90E8", "All") }),
274
+ [...new Set(filters.map((o) => o.tier))].map((r) => /* @__PURE__ */ jsx("option", { children: r }, r))
275
+ ] })
276
+ ] }),
277
+ /* @__PURE__ */ jsxs("label", { children: [
278
+ msg("\u8BA1\u8D39\u65B9\u5F0F", "Billing mode"),
279
+ /* @__PURE__ */ jsxs("select", { className: selectClass, disabled: frozen, value: mode, onChange: (e) => setMode(e.target.value), children: [
280
+ /* @__PURE__ */ jsx("option", { value: "", children: msg("\u5168\u90E8", "All") }),
281
+ [...new Set(filters.map((o) => o.billing_mode))].map((r) => /* @__PURE__ */ jsx("option", { children: r }, r))
282
+ ] })
283
+ ] }),
284
+ /* @__PURE__ */ jsxs("label", { children: [
285
+ msg("\u6700\u9AD8\u5355\u4EF7\uFF08USD cents\uFF0C\u987B\u6BD4\u8F83\u76F8\u540C\u8BA1\u8D39\u5355\u4F4D\uFF09", "Maximum unit price (USD cents; compare matching units)"),
286
+ /* @__PURE__ */ jsx("input", { className: selectClass, type: "number", min: "0", step: "1", value: ceiling, disabled: frozen, onChange: (e) => setCeiling(e.target.value) })
287
+ ] })
288
+ ] }),
289
+ !regionOnly && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: msg("\u5546\u54C1\u5206\u7C7B\u4E0D\u4EE3\u8868\u72EC\u7ACB\u8D28\u91CF\u8BA4\u8BC1\uFF1B\u56FA\u5B9A\u7EBF\u8DEF\u4E0D\u4FDD\u8BC1\u51FA\u53E3 IP \u6C38\u4E45\u4E0D\u53D8\u3002", "Tiers are product classifications, not quality certification. A fixed line does not guarantee a permanently fixed exit IP.") }),
290
+ !listed.length ? /* @__PURE__ */ jsx("p", { role: "status", children: regionOnly ? msg("\u8BE5\u5730\u533A\u6682\u65E0\u53EF\u8D2D\u4E70\u7EBF\u8DEF\u3002", "No purchasable line is available for this region.") : kind === "dynamic" ? msg("\u5F53\u524D\u6682\u65E0\u7B26\u5408\u6761\u4EF6\u7684\u52A8\u6001 IP \u5546\u54C1\u3002", "No matching dynamic IP products are currently available.") : msg("\u6682\u65E0\u7B26\u5408\u6761\u4EF6\u7684\u5546\u54C1\u3002", "No matching products.") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
291
+ !regionOnly && /* @__PURE__ */ jsxs("label", { className: "block", children: [
292
+ msg("\u5546\u54C1", "Product"),
293
+ /* @__PURE__ */ jsx("select", { className: selectClass, value: offer?.offer_id ?? "", disabled: frozen, onChange: (e) => {
294
+ setSelected(e.target.value);
295
+ setDuration("");
296
+ setTraffic("");
297
+ }, children: listed.map((o) => /* @__PURE__ */ jsxs("option", { value: o.offer_id, children: [
298
+ o.name,
299
+ " \xB7 ",
300
+ o.unit_price_cents === null ? msg("\u672A\u5B9A\u4EF7", "Unpriced") : `${usd(o.unit_price_cents)} / ${offerUnit(o, zh)}`,
301
+ " \xB7 ",
302
+ o.available ? msg("\u53EF\u62A5\u4EF7", "Quote available") : msg("\u4E0D\u53EF\u552E", "Unavailable")
303
+ ] }, o.offer_id)) })
304
+ ] }),
305
+ offer && /* @__PURE__ */ jsxs("div", { className: "rounded border border-border p-3 space-y-2", children: [
306
+ regionOnly && /* @__PURE__ */ jsxs("p", { className: "font-medium", children: [
307
+ offer.name,
308
+ " \xB7 ",
309
+ offer.unit_price_cents === null ? msg("\u672A\u5B9A\u4EF7", "Unpriced") : `${usd(offer.unit_price_cents)} / ${offerUnit(offer, zh)}`
310
+ ] }),
311
+ /* @__PURE__ */ jsxs("p", { children: [
312
+ msg("\u51FA\u53E3\u7A33\u5B9A\u6027", "Exit stability"),
313
+ ": ",
314
+ offer.ip_stability
315
+ ] }),
316
+ !offer.available && /* @__PURE__ */ jsxs("p", { role: "status", children: [
317
+ msg("\u4E0D\u53EF\u552E\u539F\u56E0", "Unavailable reason"),
318
+ ": ",
319
+ offer.unavailable_reason ?? "unavailable"
320
+ ] }),
321
+ !regionOnly && offer.billing_mode === "term" && /* @__PURE__ */ jsxs("label", { className: "block", children: [
322
+ msg("\u671F\u9650\uFF08\u5929\uFF09", "Duration (days)"),
323
+ /* @__PURE__ */ jsx("select", { className: selectClass, value: duration || String(offer.duration_days_options[0] ?? ""), disabled: frozen, onChange: (e) => setDuration(e.target.value), children: offer.duration_days_options.map((n) => /* @__PURE__ */ jsx("option", { children: n }, n)) })
324
+ ] }),
325
+ !regionOnly && offer.billing_mode === "prepaid" && /* @__PURE__ */ jsxs("label", { className: "block", children: [
326
+ msg("\u6D41\u91CF\u5305\uFF08GiB\uFF09", "Traffic package (GiB)"),
327
+ /* @__PURE__ */ jsx("select", { className: selectClass, value: traffic || String(offer.traffic_gb_options[0] ?? ""), disabled: frozen, onChange: (e) => setTraffic(e.target.value), children: offer.traffic_gb_options.map((n) => /* @__PURE__ */ jsx("option", { children: n }, n)) })
328
+ ] }),
329
+ offer.billing_mode === "payg" && /* @__PURE__ */ jsxs("label", { className: "block", children: [
330
+ msg("\u7528\u91CF\u8D39\u7528\u4E0A\u9650\uFF08USD cents\uFF09", "Usage spending cap (USD cents)"),
331
+ /* @__PURE__ */ jsx("input", { className: selectClass, type: "number", min: "1", max: "100000000", step: "1", value: limit, disabled: frozen, onChange: (e) => setLimit(e.target.value) })
332
+ ] }),
333
+ /* @__PURE__ */ jsx(Button, { disabled: busy || !supported || !offer.available || !catalog.purchases_enabled || offer.billing_mode === "payg" && !(Number(limit) > 0), onClick: () => void getQuote(), children: msg("\u83B7\u53D6\u62A5\u4EF7", "Get quote") })
334
+ ] })
335
+ ] }),
336
+ !catalog.retail_policy?.configured && /* @__PURE__ */ jsx("p", { role: "status", children: msg("\u7528\u6237\u94B1\u5305\u5E01\u79CD\u53CA\u6536\u8D39\u89C4\u5219\u5C1A\u672A\u914D\u7F6E\uFF0C\u5F53\u524D\u4E0D\u80FD\u91C7\u8D2D\u3002", "Retail wallet currency and pricing policy are not configured; purchasing is unavailable.") })
337
+ ] }),
338
+ quote && !pending && /* @__PURE__ */ jsxs("div", { className: "rounded border border-primary/40 p-3 space-y-2", children: [
339
+ /* @__PURE__ */ jsxs("p", { className: "font-semibold", children: [
340
+ msg("IP \u9996\u6B21\u8D39\u7528", "Upfront IP cost"),
341
+ ": ",
342
+ usd(quote.total_cents)
343
+ ] }),
344
+ /* @__PURE__ */ jsxs("p", { children: [
345
+ msg("\u7528\u6237\u8D39\u7528", "Retail charge"),
346
+ ": ",
347
+ quote.retail_currency ?? "\u2014",
348
+ " ",
349
+ quote.retail_total ?? "\u2014"
350
+ ] }),
351
+ /* @__PURE__ */ jsxs("p", { children: [
352
+ msg("\u53E6\u9884\u7559\u7528\u91CF\u989D\u5EA6", "Additional reserved usage budget"),
353
+ ": ",
354
+ quote.retail_currency ?? "\u2014",
355
+ " ",
356
+ quote.retail_usage_limit ?? "\u2014"
357
+ ] }),
358
+ /* @__PURE__ */ jsxs("p", { children: [
359
+ msg("\u540E\u7EED\u8D39\u7387", "Ongoing rate"),
360
+ ": ",
361
+ quote.offer.unit_price_cents === null ? "\u2014" : usd(quote.offer.unit_price_cents),
362
+ " / ",
363
+ offerUnit(quote.offer, zh),
364
+ " \xB7 ",
365
+ quote.offer.billing_mode
366
+ ] }),
367
+ quote.offer.billing_mode === "payg" && /* @__PURE__ */ jsx("p", { children: msg("\u96F6\u9996\u4ED8\u4E0D\u4EE3\u8868\u514D\u8D39\u3002\u4F7F\u7528\u8D39\u7528\u6309\u5B9E\u9645\u7D2F\u8BA1\u6D88\u8017\u5DEE\u989D\u7ED3\u7B97\u3002", "Zero upfront is not free. Usage is settled from cumulative charge differences.") }),
368
+ quote.device_billing && /* @__PURE__ */ jsxs("p", { children: [
369
+ msg("\u8BBE\u5907\u8FD0\u884C\u8D39\u7528", "Device running cost"),
370
+ ": ",
371
+ quote.device_billing.kind === "personal_free" ? msg("\u4E2A\u4EBA\u8282\u70B9\u514D\u8D39", "Personal node: free") : `${quote.device_billing.currency} ${quote.device_billing.rate_per_hour} / h`
372
+ ] }),
373
+ /* @__PURE__ */ jsxs("p", { children: [
374
+ msg("\u62A5\u4EF7\u6709\u6548\u81F3", "Quote expires"),
375
+ ": ",
376
+ new Date(quote.expires_at).toLocaleString()
377
+ ] }),
378
+ /* @__PURE__ */ jsx(Button, { disabled: busy || !quote.retail_configured || Date.parse(quote.expires_at) <= Date.now(), onClick: () => void buy(), children: msg("\u786E\u8BA4\u8D39\u7528\u5E76\u91C7\u8D2D", "Confirm charges and purchase") })
379
+ ] }),
380
+ orders.filter((o) => o.status === "fulfilled").map((row) => /* @__PURE__ */ jsxs("div", { className: "rounded border border-border p-3 space-y-2", children: [
381
+ /* @__PURE__ */ jsxs("p", { children: [
382
+ msg("\u5DF2\u8D2D IP", "Purchased IP"),
383
+ " \xB7 ",
384
+ row.quote.offer.name,
385
+ " \xB7 ",
386
+ usd(row.charged_cents ?? 0)
387
+ ] }),
388
+ row.entitlement_ids.map((id) => {
389
+ const r = resources.find((item) => item.id === id);
390
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
391
+ r && /* @__PURE__ */ jsxs("p", { children: [
392
+ r.status,
393
+ " \xB7 ",
394
+ msg("\u5DF2\u7528", "Used"),
395
+ " ",
396
+ r.used_bytes,
397
+ " bytes \xB7 ",
398
+ msg("\u7D2F\u8BA1\u7528\u91CF\u8D39\u7528", "Cumulative usage cost"),
399
+ " ",
400
+ usd(r.usage_charged_cents)
401
+ ] }),
402
+ standalone ? /* @__PURE__ */ jsxs(Fragment, { children: [
403
+ (props.onResourceSelected || props.onConnectionSelected) && /* @__PURE__ */ jsx(Button, { disabled: busy || !r || r.status !== "active", onClick: () => {
404
+ if (r) void selectResource(r, row);
405
+ }, children: msg("\u9009\u62E9\u6B64 IP", "Select this IP") }),
406
+ pending === row.id && /* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: () => {
407
+ remember(null);
408
+ setQuote(null);
409
+ }, children: msg("\u5B8C\u6210", "Done") })
410
+ ] }) : /* @__PURE__ */ jsx(Button, { disabled: busy || !supported || !r || r.status !== "active", onClick: () => void apply(row, id), children: props.deviceId ? msg("\u5E94\u7528\u5230\u8BBE\u5907", "Apply to device") : msg("\u4F7F\u7528\u5DF2\u8D2D IP \u521B\u5EFA\u8BBE\u5907", "Create device with purchased IP") })
411
+ ] }, id);
412
+ })
413
+ ] }, row.id)),
414
+ !loading && /* @__PURE__ */ jsx(Button, { variant: "ghost", disabled: busy, onClick: () => void run(async () => {
415
+ const c = await client.ipCommerce.catalog();
416
+ if (alive.current) setCatalog(c);
417
+ await refresh();
418
+ }), children: msg("\u5237\u65B0\u5E93\u5B58\u4E0E\u8BA2\u5355", "Refresh inventory and orders") })
419
+ ] });
420
+ }
421
+
422
+ export { IpCommercePanel };
@@ -5,6 +5,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
5
5
  var TOUCH_MOVE_THROTTLE_MS = 30;
6
6
  function MirrorView({
7
7
  stream,
8
+ permission = "control",
8
9
  deviceSize,
9
10
  onInput,
10
11
  keyboard = true,
@@ -15,6 +16,12 @@ function MirrorView({
15
16
  volume = 0,
16
17
  className
17
18
  }) {
19
+ if (permission === "video_only") {
20
+ onInput = void 0;
21
+ keyboard = false;
22
+ autoFocus = false;
23
+ volume = 0;
24
+ }
18
25
  const videoRef = useRef(null);
19
26
  const downRef = useRef(null);
20
27
  const gestureActiveRef = useRef(false);