@goodwidget/ai-credits-widget 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/element.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AiCreditsWidget
3
- } from "./chunk-635NKGPL.js";
3
+ } from "./chunk-3QY3YZDH.js";
4
4
 
5
5
  // src/element.ts
6
6
  import { createMiniAppElement } from "@goodwidget/embed";
package/dist/index.cjs CHANGED
@@ -3596,22 +3596,29 @@ function useCopyFeedback() {
3596
3596
 
3597
3597
  // src/components/buy/GenerateSignerKeyPanel.tsx
3598
3598
  var import_jsx_runtime3 = require("react/jsx-runtime");
3599
- function NumberedStep({ index, title }) {
3600
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
3601
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3602
- import_ui5.YStack,
3603
- {
3604
- width: 24,
3605
- height: 24,
3606
- borderRadius: "$full",
3607
- backgroundColor: "$backgroundSurface",
3608
- alignItems: "center",
3609
- justifyContent: "center",
3610
- flexShrink: 0,
3611
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$1", fontWeight: "700", children: index })
3612
- }
3613
- ),
3614
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$3", fontWeight: "700", children: title })
3599
+ function NumberedStep({
3600
+ index,
3601
+ title,
3602
+ note
3603
+ }) {
3604
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.YStack, { gap: "$1", children: [
3605
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
3606
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3607
+ import_ui5.YStack,
3608
+ {
3609
+ width: 24,
3610
+ height: 24,
3611
+ borderRadius: "$full",
3612
+ backgroundColor: "$backgroundSurface",
3613
+ alignItems: "center",
3614
+ justifyContent: "center",
3615
+ flexShrink: 0,
3616
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$1", fontWeight: "700", children: index })
3617
+ }
3618
+ ),
3619
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$3", fontWeight: "700", children: title })
3620
+ ] }),
3621
+ note && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { marginLeft: 32, fontSize: "$2", color: "$warning", fontStyle: "italic", lineHeight: "$3", children: note })
3615
3622
  ] });
3616
3623
  }
3617
3624
  function GenerateSignerKeyPanel({
@@ -3645,11 +3652,18 @@ function GenerateSignerKeyPanel({
3645
3652
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.YStack, { gap: "$2", children: [
3646
3653
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 1, title: "Open Antseed Desktop" }),
3647
3654
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 2, title: "Go to Profile \u2192 Signer" }),
3648
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 3, title: "Tap \u2191, paste your Signer Private Key, and save" })
3655
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3656
+ NumberedStep,
3657
+ {
3658
+ index: 3,
3659
+ title: "Back up your existing Signer Key",
3660
+ note: "\u26A0\uFE0F Tap \u2193 to back up your existing signer key. Importing a new signer key will replace it."
3661
+ }
3662
+ ),
3663
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NumberedStep, { index: 4, title: "Tap \u2191 to paste your Signer Key, then save." })
3649
3664
  ] }),
3650
3665
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AntseedSignerRow, { mode: "generate", showCaption: false }),
3651
3666
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AiCreditsStatusNotice, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { fontSize: "$2", tone: "soft", lineHeight: "$3", children: "The address you see when you paste your private key is the public address used for your AI credits." }) }),
3652
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AiCreditsStatusNotice, { borderColor: "$warning", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Text, { color: "$warning", fontSize: "$2", lineHeight: "$3", children: "Back up any existing AntSeed signer key before importing this one. Importing replaces the signer used by your AntSeed account." }) }),
3653
3667
  onOpenApiSetup && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.XStack, { gap: "$2", alignItems: "center", children: [
3654
3668
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_ui5.Icon, { name: "settings", size: "xs", color: "muted" }),
3655
3669
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_ui5.Text, { fontSize: "$2", tone: "soft", flex: 1, lineHeight: "$3", children: [
@@ -4198,14 +4212,43 @@ var WITHDRAW_TOOLTIP = "Withdraws principal to your payer wallet (not bonus). Re
4198
4212
 
4199
4213
  // src/components/manage/CreditsManagementCard.tsx
4200
4214
  var import_jsx_runtime7 = require("react/jsx-runtime");
4201
- function StatCell({ label, children }) {
4202
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { raised: true, borderWidth: 0, flexGrow: 1, flexBasis: 0, children: [
4203
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: label }),
4204
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.YStack, { justifyContent: "center", children })
4205
- ] });
4215
+ function StatCell({
4216
+ label,
4217
+ icon: Glyph,
4218
+ children
4219
+ }) {
4220
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4221
+ import_ui9.Card,
4222
+ {
4223
+ raised: true,
4224
+ borderWidth: 0,
4225
+ flexGrow: 1,
4226
+ flexBasis: 0,
4227
+ padding: "$3",
4228
+ gap: "$1",
4229
+ children: [
4230
+ Glyph ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4231
+ import_ui9.XStack,
4232
+ {
4233
+ width: 28,
4234
+ height: 28,
4235
+ borderRadius: "$2",
4236
+ backgroundColor: "$background",
4237
+ alignItems: "center",
4238
+ justifyContent: "center",
4239
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Glyph, { size: 16, color: "$colorSoft" })
4240
+ }
4241
+ ) : null,
4242
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { children: [
4243
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: label }),
4244
+ children
4245
+ ] })
4246
+ ]
4247
+ }
4248
+ );
4206
4249
  }
4207
4250
  function StatRow({ children }) {
4208
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$2", width: "100%", alignItems: "stretch", children });
4251
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.XStack, { gap: "$1", width: "100%", alignItems: "stretch", children });
4209
4252
  }
4210
4253
  function StatValueText({
4211
4254
  children,
@@ -4214,12 +4257,30 @@ function StatValueText({
4214
4257
  }) {
4215
4258
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize, fontWeight: "700", color, children });
4216
4259
  }
4260
+ function StatValue({
4261
+ value,
4262
+ unit,
4263
+ unitPosition,
4264
+ fontSize = "$2",
4265
+ unitFontSize = "$1",
4266
+ color
4267
+ }) {
4268
+ const hoistMarker = unitPosition === "prefix" && value.startsWith("<");
4269
+ const unitLabel = hoistMarker ? `<${unit}` : unit;
4270
+ const digits = hoistMarker ? value.slice(1) : value;
4271
+ const unitText = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: unitFontSize, fontWeight: "700", tone: "soft", children: unitLabel });
4272
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { alignItems: "baseline", gap: "$1", children: [
4273
+ unitPosition === "prefix" ? unitText : null,
4274
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize, color, children: digits }),
4275
+ unitPosition === "suffix" ? unitText : null
4276
+ ] });
4277
+ }
4217
4278
  function CompactGStatValue({ amount }) {
4218
4279
  const [open, setOpen] = (0, import_react8.useState)(false);
4219
4280
  const display = formatGValue(amount);
4220
4281
  const exact = formatExactGAmount(amount);
4221
4282
  if (!isGValueCompacted(amount)) {
4222
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: display });
4283
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" });
4223
4284
  }
4224
4285
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4225
4286
  import_ui9.XStack,
@@ -4235,7 +4296,7 @@ function CompactGStatValue({ amount }) {
4235
4296
  onBlur: () => setOpen(false),
4236
4297
  onPress: () => setOpen((prev) => !prev),
4237
4298
  children: [
4238
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: display }),
4299
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: display, unit: "G$", unitPosition: "suffix" }),
4239
4300
  open && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4240
4301
  import_ui9.YStack,
4241
4302
  {
@@ -4260,6 +4321,43 @@ function CompactGStatValue({ amount }) {
4260
4321
  function formatUsdAmount2(usdMicro) {
4261
4322
  return formatUsdMicroValue(usdMicro);
4262
4323
  }
4324
+ function CreditBalanceCard({
4325
+ balance,
4326
+ monthlyCredit
4327
+ }) {
4328
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { raised: true, borderWidth: 0, width: "100%", gap: "$2", children: [
4329
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Text, { fontSize: "$1", tone: "soft", children: "Credit balance" }),
4330
+ balance !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4331
+ StatValue,
4332
+ {
4333
+ value: balance,
4334
+ unit: "US$",
4335
+ unitPosition: "prefix",
4336
+ fontSize: "$8",
4337
+ unitFontSize: "$5"
4338
+ }
4339
+ ) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }),
4340
+ monthlyCredit ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
4341
+ import_ui9.XStack,
4342
+ {
4343
+ alignSelf: "flex-start",
4344
+ alignItems: "center",
4345
+ gap: "$1",
4346
+ paddingHorizontal: "$2",
4347
+ paddingVertical: "$1",
4348
+ borderRadius: "$full",
4349
+ backgroundColor: "$infoMuted",
4350
+ children: [
4351
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.TrendingUp, { size: 14, color: "$primary" }),
4352
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Text, { fontSize: "$1", fontWeight: "700", color: "$primary", children: [
4353
+ monthlyCredit.startsWith("<") ? monthlyCredit : `~${monthlyCredit}`,
4354
+ " / month"
4355
+ ] })
4356
+ ]
4357
+ }
4358
+ ) : null
4359
+ ] });
4360
+ }
4263
4361
  function CreditsManagementCard({ state, actions }) {
4264
4362
  const [isClosing, setIsClosing] = (0, import_react8.useState)(false);
4265
4363
  const [isWithdrawing, setIsWithdrawing] = (0, import_react8.useState)(false);
@@ -4284,7 +4382,7 @@ function CreditsManagementCard({ state, actions }) {
4284
4382
  streamBonusPercent: state.streamBonusPercent
4285
4383
  });
4286
4384
  if (usdMicro <= 0n) return null;
4287
- return formatUsdAmount2(usdMicro.toString());
4385
+ return formatUsdMicroAmount(usdMicro.toString());
4288
4386
  }, [
4289
4387
  monthlyStreamG,
4290
4388
  gdUsdPerToken,
@@ -4300,20 +4398,16 @@ function CreditsManagementCard({ state, actions }) {
4300
4398
  const canWithdraw = Boolean(signerPrvKey) && hasWithdrawableBalance && Boolean(withdrawAmount.trim()) && !isWithdrawing;
4301
4399
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.Card, { children: [
4302
4400
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Heading, { level: 6, children: "AI Credits" }),
4303
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4304
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Total Credit (US$)", children: totalCreditDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize: "$5", children: totalCreditDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) }),
4305
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Monthly Credit (US$)", children: monthlyStreamUsdDisplay ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatValueText, { fontSize: "$5", color: "$primary", children: [
4306
- "~",
4307
- monthlyStreamUsdDisplay
4308
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { fontSize: "$5", children: "\u2014" }) })
4309
- ] }),
4310
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4311
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Total Deposited (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: totalGdDepositedG ?? "0.00" }) }),
4312
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Monthly Stream (G$)", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: monthlyStreamG ?? "0.00" }) })
4313
- ] }),
4314
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4315
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Bonus Earned (US$)", children: totalBonusDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: totalBonusDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) }),
4316
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Withdrawable (US$)", children: withdrawableDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValueText, { children: withdrawableDisplay }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) })
4401
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$2", width: "100%", children: [
4402
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CreditBalanceCard, { balance: totalCreditDisplay, monthlyCredit: monthlyStreamUsdDisplay }),
4403
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4404
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Deposited", icon: import_ui9.Coins, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: totalGdDepositedG ?? "0.00" }) }),
4405
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Monthly Streaming", icon: import_ui9.Repeat, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CompactGStatValue, { amount: monthlyStreamG ?? "0.00" }) })
4406
+ ] }),
4407
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(StatRow, { children: [
4408
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Bonus", icon: import_ui9.Gift, children: totalBonusDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: totalBonusDisplay, unit: "US$", unitPosition: "prefix" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) }),
4409
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatCell, { label: "Withdrawable", icon: import_ui9.Wallet, children: withdrawableDisplay !== null ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StatValue, { value: withdrawableDisplay, unit: "US$", unitPosition: "prefix" }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_ui9.Spinner, { size: "sm" }) })
4410
+ ] })
4317
4411
  ] }),
4318
4412
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.YStack, { gap: "$1", width: "100%", children: [
4319
4413
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_ui9.XStack, { gap: "$1", alignItems: "center", children: [