dsh-codex-subscription 2.4.2 → 2.5.1

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/README.en.md CHANGED
@@ -105,7 +105,7 @@ This plugin supports the latest DeepSeek Harness release recorded in its package
105
105
  2. Paste this package name, with its version, into the **Package name or address** field:
106
106
 
107
107
  ```text
108
- dsh-codex-subscription@2.4.2
108
+ dsh-codex-subscription@2.5.1
109
109
  ```
110
110
 
111
111
  3. Click **Install** and wait for completion. Follow the page instructions; save your work before restarting if requested.
@@ -220,11 +220,15 @@ Here the reference image is attached to the message and the model copies it on t
220
220
 
221
221
  The SVG runs have finer hair highlights, lace trim and lettering, and Sol was almost 9 minutes faster with SVG than stroke by stroke; Astra spent about 3 extra minutes on SVG for clearly richer detail. Neither model got the face shape right (too long and flat) or the small whale motif on the apron, though Sol's whale looks more like a whale.
222
222
 
223
- The full Chinese prompts for all three subjects are in the [Chinese README](README.md#从草图到作品).
223
+ **The same challenge again, with the model checking itself against the reference**
224
224
 
225
- Each example is a single run, not a measure of consistent quality. Sol Xhigh is much slower; Astra or a lower reasoning level is enough for everyday sketches.
225
+ Same prompt and the same way of attaching the image as above; the plugin just gives the model two more things. It can use `reference` to put the image attached in the chat onto the board as a hidden picture layer, and while previewing it can turn on `compare` (the drawing and the reference blended 50/50, so position errors show up as ghosting) and `grid` (a labelled line every 100 pixels). Same Astra Medium on the official desktop app, one run, no image generation: 20 min 57 s, 7 drawing layers and 686 native strokes. The model also generated hair strands and lace with scripts, and checked against the overlay several times while drawing, fixing lettering and lace overlaps.
226
226
 
227
- </details>
227
+ <table>
228
+ <tr><td><img src="docs/assets/sketch-niang-astra-compare.webp" alt="Astra Medium with overlay checks" width="380"><br><sub><b>Astra Medium</b> · 20 min 57 s · 686 strokes</sub></td><td><img src="docs/assets/sketch-niang-astra-overlay.webp" alt="The overlay preview the model saw" width="260"><br><sub>The overlay the model saw: ghosting on the lettering and hair edges is the error</sub></td></tr>
229
+ </table>
230
+
231
+ The face shape, hair flow, lace, hand and speech-bubble lettering are all closer to the reference than the two Astra runs above, at about twice the time of the SVG run. This is a single run; other prompts and references may behave differently.
228
232
 
229
233
  <details>
230
234
  <summary>View Images & sketch settings</summary>
package/README.md CHANGED
@@ -105,7 +105,7 @@
105
105
  2. 在 **包名或地址** 输入框中粘贴下面的包名(已带版本号):
106
106
 
107
107
  ```text
108
- dsh-codex-subscription@2.4.2
108
+ dsh-codex-subscription@2.5.1
109
109
  ```
110
110
 
111
111
  3. 点击 **安装**,等待安装完成;按页面提示操作,需要重启时先保存工作。
@@ -222,6 +222,16 @@ Sol Xhigh 约 28 分钟,Astra Low 约 5 分钟。两者都保留了主峰、
222
222
 
223
223
  SVG 版的发丝高光、蕾丝褶边和手写字更精细,Sol 用 SVG 还比逐笔绘制快了近 9 分钟;Astra 用 SVG 多花约 3 分钟,换来明显更丰富的细节。两个模型都没能画准脸型(偏长偏平)和围裙上的小鲸鱼图案,Sol 的鲸鱼更像鲸。
224
224
 
225
+ **同一题再跑一次:让模型自己叠图对照**
226
+
227
+ 这一次提示词和附件方式都和上面一样,只是插件多了两样东西:模型可以用 `reference` 把聊天里附的参考图放进画板(作为隐藏的图片图层),并且在预览时打开 `compare`(把画作和参考图各占 50% 叠在一起,位置偏差会显示成重影)和 `grid`(每 100 像素一条带数字的网格)。同一题、同一个 Astra Medium,在官方桌面版上跑了一次,没有调用生图,共 20 分 57 秒、7 个绘画图层、686 条原生笔画;模型还用脚本批量生成了发丝和花边,并在画的过程中多次叠图检查、修正文字和蕾丝遮挡。
228
+
229
+ <table>
230
+ <tr><td><img src="docs/assets/sketch-niang-astra-compare.webp" alt="Astra Medium 叠图对照版" width="380"><br><sub><b>Astra Medium</b> · 20 分 57 秒 · 686 笔</sub></td><td><img src="docs/assets/sketch-niang-astra-overlay.webp" alt="模型看到的叠图对照预览" width="260"><br><sub>模型看到的叠图预览:文字和发丝边缘的重影就是偏差</sub></td></tr>
231
+ </table>
232
+
233
+ 脸型、长发走向、蕾丝、手和气泡字都比上面的两个 Astra 版更接近参考图,耗时约是 SVG 版的两倍。这是单次运行,不同提示词和参考图的效果可能不同。
234
+
225
235
  <details>
226
236
  <summary>展开三道题的完整提示词</summary>
227
237
 
package/lib/client.js CHANGED
@@ -3327,11 +3327,22 @@ window.__ModuleLoader__.load({
3327
3327
  }
3328
3328
  if (request.documentId !== current.documentId) throw Error("Document changed; inspect again");
3329
3329
  if (pending || adapter.busy()) throw Error("Sketch is being edited; retry after it settles");
3330
- if (request.action === "preview") return {
3331
- ...current,
3332
- png: await adapter.preview()
3333
- };
3334
- if (!["apply", "save"].includes(request.action)) throw Error("Unknown sketch action");
3330
+ if (request.action === "preview") {
3331
+ for (const key of ["compare", "grid"]) if (request[key] !== void 0 && typeof request[key] !== "boolean") throw Error(`${key} must be true or false`);
3332
+ return {
3333
+ ...current,
3334
+ png: await adapter.preview({
3335
+ compare: request.compare === true,
3336
+ grid: request.grid === true
3337
+ }),
3338
+ ...request.grid ? { gridStep: 100 } : {}
3339
+ };
3340
+ }
3341
+ if (![
3342
+ "apply",
3343
+ "save",
3344
+ "reference"
3345
+ ].includes(request.action)) throw Error("Unknown sketch action");
3335
3346
  if (typeof request.requestId !== "string" || !request.requestId.length || request.requestId.length > 100) throw Error("A unique requestId is required");
3336
3347
  const key = `${current.documentId}:${request.requestId}`, fingerprint = JSON.stringify({
3337
3348
  ...request,
@@ -3361,6 +3372,14 @@ window.__ModuleLoader__.load({
3361
3372
  layer: l.id,
3362
3373
  id: s.id
3363
3374
  })));
3375
+ } else if (request.action === "reference") {
3376
+ if (typeof request.image !== "string" || !/^data:image\/(png|jpeg|webp);base64,/.test(request.image) || request.image.length > 19e5) throw Error("A PNG, JPEG or WebP reference image is required");
3377
+ pending = true;
3378
+ try {
3379
+ await adapter.addReference(request.image, typeof request.name === "string" ? request.name.slice(0, 40) : "reference");
3380
+ } finally {
3381
+ pending = false;
3382
+ }
3364
3383
  } else {
3365
3384
  if (request.name !== void 0 && (typeof request.name !== "string" || request.name.length > 60)) throw Error("Invalid draft name");
3366
3385
  pending = true;
@@ -3645,7 +3664,7 @@ window.__ModuleLoader__.load({
3645
3664
  name: row.name
3646
3665
  });
3647
3666
  };
3648
- const importImage = async (file) => {
3667
+ const importImage = async (file, { visible = true } = {}) => {
3649
3668
  if (file.name?.toLowerCase().endsWith(".psd") || file.name?.toLowerCase().endsWith(".dsh-sketch.json")) {
3650
3669
  if (file.size > 32 * 1024 * 1024) throw Error("File exceeds 32 MB");
3651
3670
  if (file.name.toLowerCase().endsWith(".psd") && !await confirmPsd()) return;
@@ -3663,7 +3682,7 @@ window.__ModuleLoader__.load({
3663
3682
  const layer = {
3664
3683
  id: doc.current.nextId,
3665
3684
  name: file.name?.slice(0, 40) || t("sketchImport"),
3666
- visible: true,
3685
+ visible,
3667
3686
  strokes: [],
3668
3687
  image: {
3669
3688
  src: image.src,
@@ -3678,7 +3697,7 @@ window.__ModuleLoader__.load({
3678
3697
  doc.current = {
3679
3698
  ...doc.current,
3680
3699
  nextId: layer.id + 1,
3681
- active: layer.id,
3700
+ active: visible ? layer.id : doc.current.active,
3682
3701
  layers: [...doc.current.layers, layer]
3683
3702
  };
3684
3703
  schedule();
@@ -3882,6 +3901,60 @@ window.__ModuleLoader__.load({
3882
3901
  }
3883
3902
  }
3884
3903
  //#endregion
3904
+ //#region src/sketch-preview.js
3905
+ const GRID_STEP = 100;
3906
+ function composeSketchPreview({ doc, images, width, height, options = {}, makeSurface, paintLayers }) {
3907
+ const surface = makeSurface(width, height), context = surface.getContext("2d");
3908
+ if (options.compare) {
3909
+ if (!doc.layers.some((layer) => layer.image)) throw Error("compare needs a reference picture layer on the board; ask the user to add the reference with the pictures button");
3910
+ const reference = makeSurface(width, height), drawing = makeSurface(width, height);
3911
+ paintLayers(reference.getContext("2d"), {
3912
+ ...doc,
3913
+ layers: doc.layers.map((layer) => ({
3914
+ ...layer,
3915
+ strokes: [],
3916
+ visible: Boolean(layer.image)
3917
+ }))
3918
+ }, /* @__PURE__ */ new Map(), width, height, void 0, images);
3919
+ paintLayers(drawing.getContext("2d"), {
3920
+ ...doc,
3921
+ layers: doc.layers.map((layer) => ({
3922
+ ...layer,
3923
+ image: void 0
3924
+ }))
3925
+ }, /* @__PURE__ */ new Map(), width, height, void 0, images);
3926
+ context.drawImage(reference, 0, 0);
3927
+ context.globalAlpha = .5;
3928
+ context.drawImage(drawing, 0, 0);
3929
+ context.globalAlpha = 1;
3930
+ } else paintLayers(context, doc, /* @__PURE__ */ new Map(), width, height, void 0, images);
3931
+ if (options.grid) paintGrid(context, width, height);
3932
+ return surface.toDataURL("image/png");
3933
+ }
3934
+ function paintGrid(context, width, height) {
3935
+ context.save();
3936
+ context.lineWidth = 1;
3937
+ context.strokeStyle = "rgba(214,0,120,0.45)";
3938
+ context.fillStyle = "rgba(214,0,120,0.9)";
3939
+ context.font = "12px sans-serif";
3940
+ context.textBaseline = "top";
3941
+ for (let x = GRID_STEP; x < width; x += GRID_STEP) {
3942
+ context.beginPath();
3943
+ context.moveTo(x + .5, 0);
3944
+ context.lineTo(x + .5, height);
3945
+ context.stroke();
3946
+ context.fillText(String(x), x + 3, 2);
3947
+ }
3948
+ for (let y = GRID_STEP; y < height; y += GRID_STEP) {
3949
+ context.beginPath();
3950
+ context.moveTo(0, y + .5);
3951
+ context.lineTo(width, y + .5);
3952
+ context.stroke();
3953
+ context.fillText(String(y), 3, y + 2);
3954
+ }
3955
+ context.restore();
3956
+ }
3957
+ //#endregion
3885
3958
  //#region src/sketch-files.jsx
3886
3959
  function SketchFiles({ save, load, fresh, importImage, download, hasContent, disabled, t, runOperation }) {
3887
3960
  const [open, setOpen] = (0, react.useState)(false), [rows, setRows] = (0, react.useState)([]), [name, setName] = (0, react.useState)(""), [remove, setRemove] = (0, react.useState)(null), [working, setWorking] = (0, react.useState)(false);
@@ -4101,7 +4174,7 @@ window.__ModuleLoader__.load({
4101
4174
  }
4102
4175
  //#endregion
4103
4176
  //#region src/sketch-agent-run.js
4104
- function createSketchAgentRun({ execute, open, changed, busy = () => false, previewEnabled = () => false, idleMs = 18e4 }) {
4177
+ function createSketchAgentRun({ execute, open, changed, busy = () => false, idleMs = 18e4 }) {
4105
4178
  let state = "idle", generation = 0, runNumber = 0, pending = false, runId, timer, completed;
4106
4179
  const update = (next) => {
4107
4180
  state = next;
@@ -4165,15 +4238,10 @@ window.__ModuleLoader__.load({
4165
4238
  ...value,
4166
4239
  runId
4167
4240
  };
4168
- const result = previewEnabled() ? await execute({
4169
- action: "preview",
4170
- documentId: value.documentId
4171
- }) : value;
4172
- if (version !== generation) throw Error("Drawing interrupted");
4173
4241
  completed = {
4174
4242
  key: JSON.stringify(request),
4175
4243
  value: {
4176
- ...result,
4244
+ ...value,
4177
4245
  runId
4178
4246
  }
4179
4247
  };
@@ -4294,7 +4362,7 @@ window.__ModuleLoader__.load({
4294
4362
  }
4295
4363
  //#endregion
4296
4364
  //#region src/sketch-studio.jsx
4297
- function SketchStudio({ open, agentEnabled, agentPreview, onOpen, onClose, attachSketch, enabled, t, incoming, sessionId, rpc, sessionState }) {
4365
+ function SketchStudio({ open, agentEnabled, onOpen, onClose, attachSketch, enabled, t, incoming, sessionId, rpc, sessionState }) {
4298
4366
  const localSession = (0, react.useRef)(null);
4299
4367
  const psdImport = useSketchImportConfirm(t);
4300
4368
  localSession.current ??= sessionState ?? createSketchSessionState();
@@ -4591,7 +4659,6 @@ window.__ModuleLoader__.load({
4591
4659
  setNoticeHidden(false);
4592
4660
  },
4593
4661
  available: () => enabled && agentEnabled,
4594
- previewEnabled: () => agentPreview,
4595
4662
  open: () => onOpen(),
4596
4663
  busy: () => operationGate.current.running || busy || Boolean(active.current) || Boolean(textEdit) || sizeGesture.current,
4597
4664
  document: () => doc.current,
@@ -4625,9 +4692,24 @@ window.__ModuleLoader__.load({
4625
4692
  setError("");
4626
4693
  schedule();
4627
4694
  },
4628
- preview: async () => {
4629
- paint();
4630
- return canvas.current.toDataURL("image/png");
4695
+ preview: async (options) => {
4696
+ const w = doc.current.width ?? 1024, h = doc.current.height ?? 1024;
4697
+ return composeSketchPreview({
4698
+ doc: doc.current,
4699
+ images: images.current,
4700
+ width: w,
4701
+ height: h,
4702
+ options,
4703
+ paintLayers: paintSketchLayers,
4704
+ makeSurface: (width, height) => Object.assign(document.createElement("canvas"), {
4705
+ width,
4706
+ height
4707
+ })
4708
+ });
4709
+ },
4710
+ addReference: async (dataUrl, name) => {
4711
+ const blob = await (await fetch(dataUrl)).blob();
4712
+ await importImage(new File([blob], name, { type: blob.type }), { visible: false });
4631
4713
  },
4632
4714
  save
4633
4715
  });
@@ -4636,8 +4718,7 @@ window.__ModuleLoader__.load({
4636
4718
  execute: (request) => agentSession.current(request),
4637
4719
  open: () => agentAdapter.current.open(),
4638
4720
  changed: (state) => agentAdapter.current.changed?.(state),
4639
- busy: () => agentAdapter.current.busy(),
4640
- previewEnabled: () => agentAdapter.current.previewEnabled()
4721
+ busy: () => agentAdapter.current.busy()
4641
4722
  });
4642
4723
  (0, react.useEffect)(() => {
4643
4724
  if (!enabled || !agentEnabled || !hydrated) return;
@@ -5317,7 +5398,6 @@ window.__ModuleLoader__.load({
5317
5398
  }), [registerOpen]);
5318
5399
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SketchStudio, {
5319
5400
  sessionState,
5320
- agentPreview: settings.imageSketchAgentPreview,
5321
5401
  agentEnabled: settings.imageSketchAgent,
5322
5402
  onOpen: () => {
5323
5403
  opener.current = document.activeElement;
@@ -5713,10 +5793,6 @@ window.__ModuleLoader__.load({
5713
5793
  sketchRun_failed: "绘制失败",
5714
5794
  sketchRunStop: "停止绘制",
5715
5795
  sketchRunResume: "允许继续绘制",
5716
- sketchAgentPreview: "完成后返回预览 · Beta",
5717
- sketchAgentPreviewHint: "默认关闭;完成绘制后向模型返回画布图片,会增加图片输入用量。",
5718
- sketchAgentPreview_on: "开启",
5719
- sketchAgentPreview_off: "关闭",
5720
5796
  sketchAgent_on: "开启",
5721
5797
  sketchAgent_off: "关闭",
5722
5798
  imageSettings: "图片",
@@ -5891,6 +5967,12 @@ window.__ModuleLoader__.load({
5891
5967
  resetAccountChanged: "登录账号已变更,请重新开始。",
5892
5968
  resetUncertain: "服务端返回结果不确定。请再次确认,插件会复用同一个请求,不会另外发起一次重置。",
5893
5969
  creditsNote: "额外 Credits、消费上限、重置次数分别显示。",
5970
+ creditsExpires: "预计 {date} 到期,还剩 {days} 天",
5971
+ creditsExpiredToday: "今天 {date} 到期",
5972
+ creditsExpiryEstimate: "(估计:官方公布的 Pro 200 补偿 Credits 到期日,接口未返回,以 ChatGPT 使用情况页为准)",
5973
+ creditsAfterAllowance: "Credits 要等套餐额度用完后才会开始消耗,官方没有“先用 Credits”的开关。",
5974
+ creditsMessages: "约可发 {local} 条本地消息 / {cloud} 条云端消息",
5975
+ chatPass: "ChatPass 每周额度",
5894
5976
  creditsUsed: "已用 {used} / {limit} credits",
5895
5977
  spendReached: "Credits 月度消费上限已用尽。",
5896
5978
  unavailable: "暂无数据",
@@ -5922,7 +6004,6 @@ window.__ModuleLoader__.load({
5922
6004
  diagnosticsHint: "遇到问题时生成报告,可复制后用于反馈。不含登录凭据和账号标识。",
5923
6005
  sketchCanvasSetting: "画板入口",
5924
6006
  sketchAgentSetting: "Agent 绘图",
5925
- sketchAgentPreviewSetting: "完成后返回预览",
5926
6007
  quotaShowIndicator: "显示额度",
5927
6008
  quotaIndicatorHint: "输入框只显示图标,点击查看详情。关闭时暂停续航采样。",
5928
6009
  quotaForecastOptional: "续航预测 · 实验",
@@ -6279,10 +6360,6 @@ window.__ModuleLoader__.load({
6279
6360
  sketchRun_failed: "Drawing failed",
6280
6361
  sketchRunStop: "Stop drawing",
6281
6362
  sketchRunResume: "Allow drawing again",
6282
- sketchAgentPreview: "Preview on completion · Beta",
6283
- sketchAgentPreviewHint: "Off by default. Returns the canvas to the model on completion, adding image input usage.",
6284
- sketchAgentPreview_on: "On",
6285
- sketchAgentPreview_off: "Off",
6286
6363
  sketchAgent_on: "On",
6287
6364
  sketchAgent_off: "Off",
6288
6365
  imageSettings: "Images",
@@ -6457,6 +6534,12 @@ window.__ModuleLoader__.load({
6457
6534
  resetAccountChanged: "The signed-in account changed. Start again.",
6458
6535
  resetUncertain: "The server result is uncertain. Confirm again to check the same request; the plugin will not start a separate reset.",
6459
6536
  creditsNote: "Extra Credits, spending caps, and resets are separate items.",
6537
+ creditsExpires: "Expires {date} ({days} days left)",
6538
+ creditsExpiredToday: "Expires today ({date})",
6539
+ creditsExpiryEstimate: "(Estimate: the published expiry of the Pro 200 compensation Credits; the API does not report it, so check ChatGPT usage settings)",
6540
+ creditsAfterAllowance: "Credits are only drawn once the plan allowance runs out; there is no official switch to spend them first.",
6541
+ creditsMessages: "Roughly {local} local / {cloud} cloud messages",
6542
+ chatPass: "ChatPass weekly",
6460
6543
  creditsUsed: "{used} / {limit} credits used",
6461
6544
  spendReached: "The monthly Credits spending cap has been reached.",
6462
6545
  unavailable: "No data yet",
@@ -6488,7 +6571,6 @@ window.__ModuleLoader__.load({
6488
6571
  diagnosticsHint: "Generate a report to copy into a support request. Sign-in credentials and account identifiers are excluded.",
6489
6572
  sketchCanvasSetting: "Board entry",
6490
6573
  sketchAgentSetting: "Agent drawing",
6491
- sketchAgentPreviewSetting: "Return preview on completion",
6492
6574
  quotaShowIndicator: "Show quota",
6493
6575
  quotaIndicatorHint: "Show an icon in the composer; click for details. Hiding it pauses forecast sampling.",
6494
6576
  quotaForecastOptional: "Runway forecast · Experimental",
@@ -6700,6 +6782,7 @@ window.__ModuleLoader__.load({
6700
6782
  .codexSubscriptionSearchOptions[open]>summary{margin-bottom:8px}
6701
6783
  .codexSubscriptionCreditSection{display:flex;flex-direction:column;gap:7px}
6702
6784
  .codexSubscriptionCreditNote{font-size:11px;line-height:17px;color:var(--dsw-alias-label-tertiary)}
6785
+ .codexSubscriptionCreditExpiry{display:grid;gap:2px;font-size:11px;line-height:17px;color:var(--dsw-alias-label-tertiary)}.codexSubscriptionCreditExpiry p{margin:0}.codexSubscriptionCreditExpiry[data-soon=true]{color:var(--dsw-alias-label-secondary);font-weight:600}
6703
6786
  .codexSubscriptionCreditRows{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:8px}
6704
6787
  .codexSubscriptionCreditBalance,.codexSubscriptionSpendLimit{min-width:0;border-radius:10px;padding:12px 14px;background:var(--dsw-alias-bg-module-platform)}
6705
6788
  .codexSubscriptionCreditBalance{display:flex;flex-direction:column;gap:6px}
@@ -7796,8 +7879,7 @@ window.__ModuleLoader__.load({
7796
7879
  imageViewer: true,
7797
7880
  imageAnnotations: true,
7798
7881
  imageSketch: false,
7799
- imageSketchAgent: false,
7800
- imageSketchAgentPreview: false
7882
+ imageSketchAgent: false
7801
7883
  });
7802
7884
  function readImageFeatures(value = {}) {
7803
7885
  return Object.fromEntries(Object.entries(IMAGE_FEATURE_DEFAULTS).map(([key, fallback]) => [key, typeof value?.[key] === "boolean" ? value[key] : fallback]));
@@ -8603,7 +8685,7 @@ window.__ModuleLoader__.load({
8603
8685
  }
8604
8686
  //#endregion
8605
8687
  //#region src/version.js
8606
- const PACKAGE_VERSION = "2.4.2";
8688
+ const PACKAGE_VERSION = "2.5.1";
8607
8689
  //#endregion
8608
8690
  //#region src/client-recovery.js
8609
8691
  async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
@@ -9202,7 +9284,6 @@ window.__ModuleLoader__.load({
9202
9284
  imageEntryPoints: ["imageShortcut"],
9203
9285
  sketchCanvas: ["imageSketch"],
9204
9286
  sketchAgent: ["imageSketchAgent"],
9205
- sketchAgentPreview: ["imageSketchAgentPreview"],
9206
9287
  imageBrowsing: ["imageViewer", "imageAnnotations"]
9207
9288
  });
9208
9289
  function imageGroupValue(snapshot, group) {
@@ -11228,8 +11309,38 @@ window.__ModuleLoader__.load({
11228
11309
  ]
11229
11310
  });
11230
11311
  }
11312
+ Object.freeze({
11313
+ credits: 62500,
11314
+ expiresAt: Date.UTC(2026, 11, 31, 12)
11315
+ });
11316
+ const DAY_MS = 864e5;
11317
+ /** Whole days left, and whether the expiry is close enough to call out. */
11318
+ function creditExpiryStatus(expiry, now = Date.now()) {
11319
+ if (expiry === void 0) return void 0;
11320
+ const daysLeft = Math.max(0, Math.ceil((expiry.expiresAt - now) / DAY_MS));
11321
+ return {
11322
+ daysLeft,
11323
+ soon: daysLeft <= 30
11324
+ };
11325
+ }
11231
11326
  //#endregion
11232
11327
  //#region src/client-usage.jsx
11328
+ const count = (value) => Number(value).toLocaleString();
11329
+ function CreditExpiry({ credits, t }) {
11330
+ const date = validDate(credits.expiresAt);
11331
+ if (date === void 0 || credits.unlimited) return null;
11332
+ const status = creditExpiryStatus({ expiresAt: credits.expiresAt });
11333
+ const estimate = credits.expirySource === "estimate";
11334
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11335
+ className: "codexSubscriptionCreditExpiry",
11336
+ "data-soon": status.soon,
11337
+ role: "status",
11338
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", { children: [fill(t(status.daysLeft === 0 ? "creditsExpiredToday" : "creditsExpires"), {
11339
+ date: date.toLocaleDateString(),
11340
+ days: status.daysLeft
11341
+ }), estimate ? ` ${t("creditsExpiryEstimate")}` : ""] })
11342
+ });
11343
+ }
11233
11344
  function ResetTime({ resetsAt, t }) {
11234
11345
  const date = Number.isSafeInteger(resetsAt) ? validDate(resetsAt * 1e3) : void 0;
11235
11346
  if (date === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("resetUnknown") });
@@ -11491,7 +11602,7 @@ window.__ModuleLoader__.load({
11491
11602
  const visibleUsage = signedIn ? usage : void 0;
11492
11603
  const limits = visibleUsage?.rateLimits ?? [];
11493
11604
  const exhausted = limits.some((limit) => limit.id !== "code_review" && limit.windows.some((window) => window.usedPercent >= 100));
11494
- const hasUsageDetails = limits.length > 0 || visibleUsage?.credits !== void 0 || visibleUsage?.individualLimit !== void 0 || visibleUsage?.resetCredits?.availableCount > 0;
11605
+ const hasUsageDetails = limits.length > 0 || visibleUsage?.chatPass !== void 0 || visibleUsage?.credits !== void 0 || visibleUsage?.individualLimit !== void 0 || visibleUsage?.resetCredits?.availableCount > 0;
11495
11606
  const fetchedAt = typeof visibleUsage?.fetchedAt === "number" ? validDate(visibleUsage.fetchedAt) : void 0;
11496
11607
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11497
11608
  className: "codexSubscriptionCard codexSubscriptionUsageCard",
@@ -11574,6 +11685,36 @@ window.__ModuleLoader__.load({
11574
11685
  ]
11575
11686
  }, `${limit.id}-${window.windowSeconds}-${index}`)))
11576
11687
  }),
11688
+ visibleUsage?.chatPass === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
11689
+ className: "codexSubscriptionLimits",
11690
+ children: visibleUsage.chatPass.windows.map((window, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11691
+ className: "codexSubscriptionLimit",
11692
+ children: [
11693
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11694
+ className: "codexSubscriptionLimitTop",
11695
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11696
+ className: "codexSubscriptionLimitLabel",
11697
+ children: t("chatPass")
11698
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("strong", { children: [percent(window.remainingPercent), "%"] })]
11699
+ }),
11700
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("progress", {
11701
+ max: "100",
11702
+ value: window.remainingPercent,
11703
+ "aria-label": `${t("chatPass")} ${fill(t("remaining"), { value: percent(window.remainingPercent) })}`
11704
+ }),
11705
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11706
+ className: "codexSubscriptionLimitMeta",
11707
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11708
+ className: "codexSubscriptionLimitPeriod",
11709
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: windowLabel(window.windowSeconds, t) })
11710
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResetTime, {
11711
+ resetsAt: window.resetsAt,
11712
+ t
11713
+ })]
11714
+ })
11715
+ ]
11716
+ }, `chatpass-${window.windowSeconds}-${index}`))
11717
+ }),
11577
11718
  visibleUsage?.credits === void 0 && visibleUsage?.individualLimit === void 0 && !(visibleUsage?.resetCredits?.availableCount > 0) ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
11578
11719
  className: "codexSubscriptionCreditSection",
11579
11720
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
@@ -11586,6 +11727,21 @@ window.__ModuleLoader__.load({
11586
11727
  className: "codexSubscriptionCreditBalance",
11587
11728
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("creditsBalance") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: visibleUsage.credits.unlimited ? t("unlimited") : `${visibleUsage.credits.balance ?? t("unavailable")} ${t("creditsUnit")}` })]
11588
11729
  }) : null,
11730
+ visibleUsage?.credits ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CreditExpiry, {
11731
+ credits: visibleUsage.credits,
11732
+ t
11733
+ }) : null,
11734
+ visibleUsage?.credits && !visibleUsage.credits.unlimited ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
11735
+ className: "codexSubscriptionCreditNote",
11736
+ children: t("creditsAfterAllowance")
11737
+ }) : null,
11738
+ visibleUsage?.credits?.approxLocalMessages ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
11739
+ className: "codexSubscriptionCreditNote",
11740
+ children: fill(t("creditsMessages"), {
11741
+ local: `${count(visibleUsage.credits.approxLocalMessages[0])}–${count(visibleUsage.credits.approxLocalMessages[1])}`,
11742
+ cloud: visibleUsage.credits.approxCloudMessages ? `${count(visibleUsage.credits.approxCloudMessages[0])}–${count(visibleUsage.credits.approxCloudMessages[1])}` : t("unavailable")
11743
+ })
11744
+ }) : null,
11589
11745
  visibleUsage?.resetCredits?.availableCount > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("details", {
11590
11746
  className: "codexSubscriptionCreditBalance codexSubscriptionResetDisclosure",
11591
11747
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("summary", { children: fill(t("resetCreditsAvailable"), { count: visibleUsage.resetCredits.availableCount }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResetCreditList, {