@houzhen888/groove-grow 0.0.0-stage → 0.0.2
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/CHANGELOG.md +32 -0
- package/README.md +169 -2
- package/dist/chunk-D5TMAVB3.js +1 -0
- package/dist/chunk-ORSJMBMZ.js +1 -0
- package/dist/chunk-ZPYBAV5Z.js +1 -0
- package/dist/index-VzF48VxI.d.ts +3188 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/popup.d.ts +167 -0
- package/dist/popup.js +137 -0
- package/dist/server.d.ts +434 -0
- package/dist/server.js +1 -0
- package/dist/src-QOPY5YKS.js +1 -0
- package/dist/transport-DrW-__2k.d.ts +7383 -0
- package/package.json +51 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.0.2 — 2026-10-03
|
|
4
|
+
|
|
5
|
+
- Customer state with permission-checked sections, exact resource totals and grant breakdowns.
|
|
6
|
+
- Customer-aware plan relationships, trial qualification and explicit currency availability.
|
|
7
|
+
- Credit history filters, complete cursor-paginated pack orders and offer history.
|
|
8
|
+
- Framework-neutral state subscriptions, shared requests, bounded freshness and identity clearing.
|
|
9
|
+
- Published customer Pages with live balances, grant sources, filtered usage and pagination.
|
|
10
|
+
- Hosted ISR Web View shells for remote Popup, Page and Funnel rendering, with per-frame channels and CSP script hashes.
|
|
11
|
+
- Versioned pure-design caches and delivery hints; identity, permission, publication and business state remain live.
|
|
12
|
+
- Explicit `webView: "embedded"` for offline or mocked gateways; hosted startup failures reject and clean up the frame.
|
|
13
|
+
- Update cached renderer shells through content-addressed URLs without retaining customer data in public caches.
|
|
14
|
+
|
|
15
|
+
Upgrade: deploy the matching server before upgrading the SDK. Remote surfaces now default to hosted rendering and require the `X-Grow-Web-View` response header. Custom gateways must provide and expose that header, or explicitly select embedded rendering. The HTTP delivery format includes `contentTag`; direct HTTP callers sending `cachedContentTag` must retain the matching design document. Existing browser SDK methods continue returning complete documents.
|
|
16
|
+
|
|
17
|
+
## 0.0.1
|
|
18
|
+
|
|
19
|
+
First Web SDK Beta release, distributed as one package with core, server and popup ESM entries.
|
|
20
|
+
|
|
21
|
+
- Customer sessions, catalog, entitlements, offers, credits, membership and billing API adapters.
|
|
22
|
+
- Distribute the test release as `@houzhen888/groove-grow` with the `beta` tag.
|
|
23
|
+
- Exclude placeholder generic events and the legacy subscription management endpoint; use popup/Funnel events and membership management.
|
|
24
|
+
- Isolated popup / paywall / page rendering and server-driven Funnel lifecycle.
|
|
25
|
+
- Load the Funnel renderer only when presenting a flow.
|
|
26
|
+
- Invalidate pending Funnel authentication and node requests on identity changes.
|
|
27
|
+
- Normalize Funnel validation failures to GrooveError.
|
|
28
|
+
- Remove Funnel UI immediately on close, including telemetry failure and early close.
|
|
29
|
+
- Isolate synchronous and asynchronous host notification failures.
|
|
30
|
+
- Build before packing and verify installed artifacts outside the workspace.
|
|
31
|
+
|
|
32
|
+
Beta limits: ESM only; no automatic session refresh, retry, offline queue or generic events API. Billing needs explicit per-App Stripe Sandbox configuration. A later company scope requires updating package imports.
|
package/README.md
CHANGED
|
@@ -1,3 +1,170 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @houzhen888/groove-grow
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Groove Grow 的框架无关 Web / TypeScript SDK。当前 Beta 版本为 `0.0.2`。一个 npm 包提供三个 ESM 入口,无需内部 contracts 包、React、Next.js 或 Supabase。
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @houzhen888/groove-grow@beta
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
通过个人测试 scope 分发。正式公司包名将另行公布,迁移时需要更新依赖和导入路径。本地安装可使用 `pnpm test:sdk-package` 生成的 `.local/sdk-package-check/houzhen888-groove-grow-0.0.2.tgz`。
|
|
10
|
+
|
|
11
|
+
| 入口 | 用途 | 加载行为 |
|
|
12
|
+
| -------------------------------- | --------------------------------------------- | ---------------------------------------- |
|
|
13
|
+
| `@houzhen888/groove-grow` | 客户 API、Funnel 客户端与 `showFunnel` | 被动导入;展示 Funnel 时才加载渲染器 |
|
|
14
|
+
| `@houzhen888/groove-grow/server` | 客户管理、Session 签发、积分写入、Funnel 启动 | 被动导入;禁止在浏览器创建 Secret 客户端 |
|
|
15
|
+
| `@houzhen888/groove-grow/popup` | 远程投放、离线渲染、编辑预览 | 调用展示方法时挂载 UI |
|
|
16
|
+
|
|
17
|
+
支持现代浏览器及 Node.js 22+ ESM,暂不提供 CommonJS 或原生移动端 SDK。
|
|
18
|
+
|
|
19
|
+
## 可信后端:绑定自己的登录用户
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { createGrooveServer } from "@houzhen888/groove-grow/server";
|
|
23
|
+
const server = createGrooveServer({
|
|
24
|
+
baseUrl: "https://groove-grow.vercel.app",
|
|
25
|
+
apiKey: process.env.GROOVE_SECRET_KEY!,
|
|
26
|
+
scope: { projectId: "your-app-uuid", environment: "sandbox" },
|
|
27
|
+
});
|
|
28
|
+
// verifiedUser 必须来自应用自己的可信登录会话。
|
|
29
|
+
const { customer } = await server.getOrCreateCustomer({
|
|
30
|
+
externalUserId: verifiedUser.id,
|
|
31
|
+
name: verifiedUser.name,
|
|
32
|
+
});
|
|
33
|
+
const { customerToken } = await server.createCustomerSession(customer.id);
|
|
34
|
+
// 仅向已验证的当前用户返回 customerToken。
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
浏览器提供的 customerId 不能作为登录证明。Secret Key 不得出现在客户端代码、HTML 或日志中。每个 App / 环境单独配置 Key、权限与 allowed_origins。
|
|
38
|
+
|
|
39
|
+
## 浏览器:读取权益并显式展示
|
|
40
|
+
|
|
41
|
+
`0.0.2` 的客户展示入口见 [客户展示数据](https://github.com/tinkerlandai/groove-grow/blob/main/docs/sdk-customer-state.md):`getCustomerState`、`listCustomerPlans`、`listOfferHistory` 与 `createCustomerStateStore`。这些接口和托管 Web View 需要匹配当前服务端;升级时应同时使用已经部署的服务端与新版 SDK。`0.0.1` 不包含这些新增入口。
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { createGroove } from "@houzhen888/groove-grow";
|
|
45
|
+
import { showRemotePopup } from "@houzhen888/groove-grow/popup";
|
|
46
|
+
const grow = createGroove({
|
|
47
|
+
baseUrl: "https://groove-grow.vercel.app",
|
|
48
|
+
scope: { projectId: "your-app-uuid", environment: "sandbox" },
|
|
49
|
+
locale: "en",
|
|
50
|
+
});
|
|
51
|
+
grow.identify(customerToken);
|
|
52
|
+
const plans = await grow.listPlans();
|
|
53
|
+
const rights = await grow.getEntitlements();
|
|
54
|
+
const popup = await showRemotePopup(grow, "upgrade", {
|
|
55
|
+
onEvent(event) {
|
|
56
|
+
console.log(event.type);
|
|
57
|
+
},
|
|
58
|
+
onError(error) {
|
|
59
|
+
/* 向应用自己的监控报告 */
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
// 退出登录或切换账号时,先销毁展示,再清除身份。
|
|
63
|
+
popup?.destroy();
|
|
64
|
+
grow.reset();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
客户 Token 仅在内存保存。浏览器方法绑定当前客户,不接受任意其他客户 ID。`reset()` / `identify()` 取消旧请求并丢弃迟到响应,不能撤回服务器已执行的操作。宿主负责销毁当前展示并刷新过期 Token。
|
|
68
|
+
|
|
69
|
+
## 首版能力
|
|
70
|
+
|
|
71
|
+
| 能力 | 浏览器 | 可信后端 |
|
|
72
|
+
| ---------- | ------------------------------------------------------ | -------------------------------------------------- |
|
|
73
|
+
| 客户与权益 | 身份、套餐目录、权益 | 创建 / 查询 / 更新客户、签发 Session、查询客户权益 |
|
|
74
|
+
| 优惠 | 查询、通过投放凭证领取 | 定向发放 |
|
|
75
|
+
| 积分 | 余额、检查、流水、积分包 / 订单、积分包结账 | 另有原子消费、预扣、结算、退款、授予 |
|
|
76
|
+
| 会员与订阅 | 持有情况、变更预览、会员管理、订阅查询、托管结账 | 配置与实际状态由后端及验证后的支付通知管理 |
|
|
77
|
+
| 界面 | 弹窗、付费墙、独立页面、多页流程、语言、按钮导航与分支 | 控制台配置发布版本与投放规则 |
|
|
78
|
+
| Funnel | 读取、专用事件、认证链接、业务节点确认 / 取消 | 匿名启动 / 撤销 |
|
|
79
|
+
|
|
80
|
+
支付方法要求对应 App 显式配置 Stripe Sandbox 账户、测试凭据、价格映射和 Key 权限。SDK 提供方法不代表托管环境已完成支付配置;点击、回跳与客户端事件不能证明付款成功。积分数量传十进制字符串,写入复用稳定幂等键。浏览器不提供积分消费或管理权限。
|
|
81
|
+
|
|
82
|
+
## 展示与 Funnel 生命周期
|
|
83
|
+
|
|
84
|
+
服务端 `createFunnelServer().start()` 返回 24 小时 `runToken` 和 180 天 `visitorToken` / `visitorExpiresAt`。宿主后端自行保存访客凭证(建议 HttpOnly cookie),下一次 start 传回以保持匿名 subject;SDK 不自动写 cookie。访客凭证不登录客户,也不能用于浏览器 Funnel 操作。签发 key / App / 环境必须相同,清凭证或换设备无法自动恢复匿名身份。详见仓库接入协议 `docs/growth-integration.md`。
|
|
85
|
+
|
|
86
|
+
`showRemotePopup` 获取投放、展示并上报专用事件;失败返回 `null` 或通知 `onError`。优惠领取与购买动作调用对应业务 API。`getPopup` / `trackPopup` 供宿主控制交付和重试。离线 `showPopup(document, options)` 只渲染,不自动持久化或执行远程业务操作。
|
|
87
|
+
|
|
88
|
+
`getPopup()` 和 `getPage()` 在客户端内存中复用纯设计。每次调用仍请求服务端,重新验证身份、当前可展示版本和实时 capabilities。SDK 自动携带内容指纹;命中后服务端可省略设计正文,SDK 还原完整公开返回值。发布版本、实际语言或设计内容改变时自动取新文档,`identify()` / `reset()` 清空设计缓存。缓存有大小与时间上限,不使用浏览器持久化存储,也不在网络失败时展示缓存版本。
|
|
89
|
+
|
|
90
|
+
内容在 sandbox iframe 内渲染,弹窗外层使用 Shadow DOM。同页最多一个弹窗;销毁清理节点、监听器、计时器并恢复焦点。预览也使用同一渲染器。宿主通知回调的同步异常与 Promise 拒绝被隔离;`onAuthenticate` 是需要等待结果的业务回调。
|
|
91
|
+
|
|
92
|
+
纯设计的 HTML/CSS 准备结果按内容、解析器 Window 隔离复用,严格文档校验每次执行;动态 HTML 每次重新清洗。每次 iframe 挂载生成新的 channel 和 CSP nonce。该优化也覆盖 Page、Funnel 和控制台预览。服务端私有响应继续 `no-store`,这项能力属于版本化内容缓存,不依赖 Next.js ISR。
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { createFunnelClient, showFunnel } from "@houzhen888/groove-grow";
|
|
96
|
+
const flow = createFunnelClient({
|
|
97
|
+
baseUrl: "https://groove-grow.vercel.app",
|
|
98
|
+
runToken, // 自己的后端调用 createFunnelServer().start() 得到。
|
|
99
|
+
scope: { projectId: "your-app-uuid", environment: "sandbox" },
|
|
100
|
+
});
|
|
101
|
+
const handle = await showFunnel(container, {
|
|
102
|
+
client: flow,
|
|
103
|
+
onAuthenticate: async () => obtainCurrentUserCustomerToken(),
|
|
104
|
+
onCheckout(checkout) {
|
|
105
|
+
window.location.assign(checkout.url);
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
// 立即移除 UI;Promise 表示关闭事件是否提交成功。重复 close 不重复提交。
|
|
109
|
+
await handle.close().catch(reportError);
|
|
110
|
+
flow.reset();
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
`destroy()` 只清理本地 UI,不记录服务端关闭。切换账号时销毁旧展示,为新用户创建或识别客户端。
|
|
114
|
+
|
|
115
|
+
## 错误与 Beta 边界
|
|
116
|
+
|
|
117
|
+
API 使用 `GrooveError`,包括 `INVALID_REQUEST`、`INVALID_RESPONSE`、`NOT_IDENTIFIED`、`IDENTITY_CHANGED`、`TIMEOUT`、`NETWORK_ERROR`、`SCOPE_MISMATCH` 和服务端业务码。HTTPS 或 localhost HTTP;默认超时 10 秒覆盖响应体读取;禁用重定向、Cookie 凭据与响应缓存。
|
|
118
|
+
|
|
119
|
+
没有自动网络重试、离线队列或 Session 刷新。重试写入时复用 requestId / eventId / 幂等键;页面退出不保证遥测送达。使用 `trackPopup` / Funnel 专用事件,首版不提供通用 `track()`。订阅操作使用 `manageMembership()`,首版不提供旧 `manageSubscription()`。统一 `present(trigger)`、原生恢复购买和跨平台购买尚未提供。
|
|
120
|
+
|
|
121
|
+
## 仓库验证
|
|
122
|
+
|
|
123
|
+
`pnpm test:sdk-package` 在仓库外安装实际 tarball,检查 NodeNext / Bundler 严格 TypeScript、三个 ESM 入口、被动导入、后端运行限制、模拟 API 和消费者 bundle。`prepack` 自动重新构建,避免发布旧 dist。Zod 是公开依赖,DOMPurify / CSS Tree 用于渲染器;基础 API 导入不加载它们。
|
|
124
|
+
|
|
125
|
+
详细接入见仓库 `docs/growth-integration.md`、`docs/credits-integration.md` 和 `docs/sdk-audit-2026-10-02.md`。当前标记 `UNLICENSED`,本次发布不新增开源许可证。
|
|
126
|
+
|
|
127
|
+
### Customer data Pages
|
|
128
|
+
|
|
129
|
+
Publish a Page in the console, then embed its immutable design with live customer data:
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { createGroove } from "@houzhen888/groove-grow";
|
|
133
|
+
import { mountCustomerPage } from "@houzhen888/groove-grow/popup";
|
|
134
|
+
|
|
135
|
+
const client = createGroove({
|
|
136
|
+
baseUrl: "https://your-grow-api.example",
|
|
137
|
+
locale: "en",
|
|
138
|
+
});
|
|
139
|
+
client.identify(customerToken); // issued by your backend for the verified customer
|
|
140
|
+
const page = await mountCustomerPage(
|
|
141
|
+
document.querySelector<HTMLElement>("#account")!,
|
|
142
|
+
{
|
|
143
|
+
client,
|
|
144
|
+
pageId: "your-published-page-uuid",
|
|
145
|
+
onCheckout: ({ url }) => window.location.assign(url),
|
|
146
|
+
onError: (error) => console.error(error),
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
// After a confirmed purchase or when returning to the account route:
|
|
150
|
+
await page.refresh();
|
|
151
|
+
// On logout, clear the client's identity before removing the page:
|
|
152
|
+
client.reset();
|
|
153
|
+
page.destroy();
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`getPage()` requires `popups:resolve`. Widgets independently require the existing scopes: credits and activity use `credits:read`; membership uses `billing:read`; customer plans use both `plans:read` and `billing:read`; credit packs and purchase history use `credits:read`; offer history uses `offers:resolve`. Credit pack checkout additionally requires `billing:write` and an `onCheckout` handler. Entity sessions retain existing payer restrictions and use their verified shared-credit scope.
|
|
157
|
+
|
|
158
|
+
The seven native sources are credit balance, credit activity, membership, customer plans, credit packs, purchase history and offer history. The Page stores titles, layout, resource binding and page size. Customer IDs, tokens, API URLs, results and cursors are never saved in its document. Filters and cursors are controlled by the host SDK; the sandboxed renderer receives display data and sends allowlisted intents. Different credit resources remain separate and decimals are preserved exactly. Authorization failures clear sensitive sections; identity reset clears every widget synchronously.
|
|
159
|
+
|
|
160
|
+
Console and template previews explicitly show sample data and disable purchases. Real pages use the current verified customer. Checkout starts payment; credit balances change only after provider confirmation and a refresh. `onAction` handles authored static actions; membership changes continue through the existing preview, confirmation and execution APIs. A directly mounted Page has no popup delivery receipt and must not call `purchaseSurface()` with a fabricated delivery ID.
|
|
161
|
+
|
|
162
|
+
For a Funnel containing referenced data Pages, pass the same configured browser SDK as `showFunnel({ customerClient: client, ... })`. The Funnel verifies its customer link before connecting the data host, preserves the pinned Page design and clears widgets when its identity resets. Credit pack checkout uses `onCreditPackCheckout`; the existing `onCheckout` callback remains the Funnel's membership checkout callback.
|
|
163
|
+
|
|
164
|
+
### Published Web View delivery
|
|
165
|
+
|
|
166
|
+
`showRemotePopup`, `mountCustomerPage` and `showFunnel` use the gateway's hosted renderer by default. Successful surface HTTP replies expose `X-Grow-Web-View`, a same-origin path addressed by the entire shell HTML's SHA-256. Proxies must preserve this header and its CORS exposure. The SDK rejects malformed metadata; a missing header is an integration error, never permission to render cached customer content.
|
|
167
|
+
|
|
168
|
+
The public HTML shell is a Next.js ISR route. It contains only executable renderer code, no tenant design, customer token or business result. Browser cache is one year with `immutable`, and ISR revalidation is one hour. Changed HTML or CSP gets a changed URL. Fresh message channels are carried in fragments, which are not sent to the server. Frames retain `sandbox="allow-scripts"` without `allow-same-origin`; the shell CSP authorizes the immutable script by hash and blocks network access. Customer documents and values arrive only through the authorized host bridge.
|
|
169
|
+
|
|
170
|
+
The first hosted mount downloads the shell; later mounts can reuse the browser cache. Customer API replies remain `no-store`. This is not a static customer account page or a public URL exposing its balances. Console previews and explicit exported-document `showPopup` calls remain embedded. For a deliberate offline or mocked gateway, set `webView: "embedded"` on `createGroove` / `createFunnelClient`; there is no automatic network-error fallback. A Page or Funnel mount rejects if its renderer cannot start, and removes the failed iframe. Destroying a pending mount cancels startup.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as rt}from"zod";var Pe=rt.enum(["sandbox","live"]),te=rt.object({projectId:rt.string().min(1),environment:Pe});import{z as hr}from"zod";var br=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],L=hr.enum(br);function Oe(e){let t=L.parse(e.toUpperCase());return["JPY","KRW","VND"].includes(t)?0:2}function ao(e,t){let n=Oe(t),r=e.trim().match(/^(\d+)(?:\.(\d+))?$/);if(!r||(r[2]?.length??0)>n)throw new Error("Amount has invalid currency precision");let o=BigInt(r[1])*BigInt(10**n)+BigInt((r[2]??"").padEnd(n,"0")||"0");if(o>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Amount exceeds the supported range");return Number(o)}function so(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Error("Expected a nonnegative integer amount");let n=Oe(t),r=String(e).padStart(n+1,"0");return n?`${r.slice(0,-n)}.${r.slice(-n)}`:r}function Dt(e,t,n="en",r={}){let o=L.parse(t.toUpperCase());return new Intl.NumberFormat(n,{style:"currency",currency:o,...r}).format(e/10**Oe(o))}import{z as $}from"zod";var yr=$.object({minAccountAgeDays:$.number().int().min(0).max(3650),paymentStatus:$.enum(["all","unpaid","paid"])}),xr=$.object({percentOff:$.number().int().min(1).max(100),redemptionWindowHours:$.number().int().min(1).max(2160)}),Sr=$.object({title:$.string().trim().min(1).max(80),description:$.string().trim().min(1).max(240),buttonLabel:$.string().trim().min(1).max(30)}),Ir=$.object({name:$.string().trim().min(1).max(80),audience:yr,offer:xr,popup:Sr}),po=Ir.extend({id:$.string().min(1),projectId:$.string().min(1),environment:Pe,status:$.enum(["draft","active","paused"]),updatedAt:$.iso.datetime()}),mo=te.extend({id:$.string().min(1),externalUserId:$.string().min(1),name:$.string().min(1),email:$.union([$.email(),$.literal("")]),createdAt:$.iso.datetime(),paymentStatus:$.enum(["unpaid","paid"]),stripeCustomerId:$.string().nullable()}),fo=$.object({error:$.object({code:$.string(),message:$.string()})});import{z as b}from"zod";import{z as f}from"zod";var it=f.string().regex(/^[a-z][a-z0-9_]{0,63}$/),se=f.number().int().min(0).max(1e4),_e=f.object({key:it,featureId:f.uuid(),planVersionId:f.uuid(),includedQuantity:se,maximumQuantity:se,unitAmountCents:f.number().int().min(0).max(1e8),stripePriceId:f.string().regex(/^price_[A-Za-z0-9]+$/).nullable(),pooledResources:f.array(f.string().regex(/^(?:[a-z][a-z0-9_]{0,63}|pool:[0-9a-f-]{36})$/)).max(100),requireAssignment:f.boolean()}).strict().refine(e=>e.maximumQuantity>=e.includedQuantity,"\u6700\u5927\u5E2D\u4F4D\u6570\u4E0D\u80FD\u5C0F\u4E8E\u5305\u542B\u5E2D\u4F4D\u6570").refine(e=>new Set(e.pooledResources).size===e.pooledResources.length,"\u5171\u4EAB\u6765\u6E90\u4E0D\u80FD\u91CD\u590D"),Me=f.array(f.object({key:it,quantity:se}).strict()).max(20).refine(e=>new Set(e.map(t=>t.key)).size===e.length,"\u5E2D\u4F4D\u6570\u91CF\u4E0D\u80FD\u91CD\u590D"),vr=f.object({id:f.uuid(),customerId:f.uuid(),externalId:f.string().min(1).max(255),featureId:f.uuid(),name:f.string().max(80),disableSharedBalance:f.boolean(),archivedAt:f.iso.datetime().nullable(),revision:f.number().int().positive(),createdAt:f.iso.datetime()}),kr=f.object({id:f.uuid(),key:it,parentHoldingId:f.uuid(),planVersionId:f.uuid(),featureId:f.uuid(),purchased:se,included:se,assigned:se,remaining:se,active:f.boolean()}),Cr=f.object({id:f.uuid(),poolId:f.uuid(),entityId:f.uuid().nullable(),planVersionId:f.uuid(),assignedAt:f.iso.datetime().nullable(),releasedAt:f.iso.datetime().nullable(),ordinal:f.number().int().positive()}),Ue=f.object({customerId:f.uuid(),entities:f.array(vr),pools:f.array(kr),assignments:f.array(Cr)}),Nt=f.object({customerId:f.uuid().optional()}).strict(),pe={customerId:f.uuid(),requestId:f.uuid()},$t=f.discriminatedUnion("action",[f.object({...pe,action:f.literal("create"),externalId:f.string().trim().min(1).max(255),featureId:f.uuid(),name:f.string().trim().max(80),disableSharedBalance:f.boolean()}).strict(),f.object({...pe,action:f.literal("update"),entityId:f.uuid(),revision:f.number().int().positive(),name:f.string().trim().max(80),disableSharedBalance:f.boolean()}).strict(),f.object({...pe,action:f.literal("archive"),entityId:f.uuid(),revision:f.number().int().positive()}).strict()]),Et=f.discriminatedUnion("action",[f.object({...pe,action:f.literal("cancel_change"),poolId:f.uuid()}).strict(),f.object({...pe,action:f.literal("assign"),poolId:f.uuid(),entityId:f.uuid()}).strict(),f.object({...pe,action:f.literal("release"),assignmentId:f.uuid()}).strict(),f.object({...pe,action:f.literal("quantity"),poolId:f.uuid(),quantity:se,timing:f.enum(["immediate","end_of_cycle"])}).strict()]);import{z as y}from"zod";import{z as q}from"zod";import{z as u}from"zod";var H=u.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),W=u.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),ce=W.refine(e=>/[1-9]/.test(e),"\u6570\u91CF\u5FC5\u987B\u5927\u4E8E 0"),ie=u.string().regex(/^[a-z][a-z0-9_]{0,63}$/),He=u.union([ie,u.string().regex(/^pool:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)]),jr=u.record(ie,u.union([u.string().max(120),u.number().finite(),u.boolean()])).refine(e=>Object.keys(e).length<=16,"\u6700\u591A 16 \u4E2A\u8BA1\u4EF7\u5C5E\u6027").transform(e=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,String(n)]))),qt=u.record(ie,u.string().min(1).max(120)).refine(e=>Object.keys(e).length>=1&&Object.keys(e).length<=8,"\u5339\u914D\u6761\u4EF6\u9700\u8981 1\u20138 \u4E2A\u5C5E\u6027"),fe=e=>{let[t,n=""]=e.split(".");return BigInt(t)*BigInt("1000000")+BigInt(n.padEnd(6,"0"))},Ft=u.array(u.object({upTo:ce.nullable(),cost:W}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((t,n)=>t.upTo!==null&&(n===0||fe(t.upTo)>fe(e[n-1].upTo))),"\u9636\u68AF\u4E0A\u9650\u5FC5\u987B\u9012\u589E\uFF0C\u6700\u540E\u4E00\u6863\u4E3A\u65E0\u9650"),Ar=u.object({key:ie,match:qt,priority:u.number().int().min(-100).max(100).default(0),cost:W.optional(),tiers:Ft.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"\u7EF4\u5EA6\u9700\u8981\u6307\u5B9A\u5355\u4EF7\u6216\u9636\u68AF"),wr=u.object({key:ie,match:qt,factor:W.default("1"),add:W.default("0")}).strict(),Lt=u.object({featureKey:ie,units:ce.default("1"),cost:W,tiers:Ft.optional(),dimensions:u.array(Ar).max(12).optional(),multipliers:u.array(wr).max(4).optional()}).strict().superRefine((e,t)=>{let n=e.dimensions??[],r=e.multipliers??[];(new Set(n.map(a=>a.key)).size!==n.length||new Set(r.map(a=>a.key)).size!==r.length)&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u548C\u500D\u7387\u7684 ID \u4E0D\u80FD\u91CD\u590D"});for(let a=0;a<n.length;a++)for(let m=a+1;m<n.length;m++){let d=n[a],c=n[m];Object.keys(d.match).length===Object.keys(c.match).length&&d.priority===c.priority&&!Object.keys(d.match).some(k=>c.match[k]!==void 0&&c.match[k]!==d.match[k])&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u53EF\u80FD\u540C\u65F6\u5339\u914D\uFF0C\u8BF7\u8C03\u6574\u4F18\u5148\u7EA7"})}let o=[e.cost,...(e.tiers??[]).map(a=>a.cost),...n.flatMap(a=>[...a.cost===void 0?[]:[a.cost],...(a.tiers??[]).map(m=>m.cost)])],i=fe(e.units);for(let a of o)for(let m=0;m<1<<r.length;m++){let d=fe(a),c=BigInt("1"),k=BigInt("0");for(let z=0;z<r.length;z++)m&1<<z&&(d*=fe(r[z].factor),c*=BigInt("1000000"),k+=fe(r[z].add));let A=(d+k*c)*BigInt("1000000"),w=c*i;(A%w!==BigInt("0")||A/w>BigInt("999999999999999999"))&&t.addIssue({code:"custom",message:"\u6BCF\u4E2A\u4E1A\u52A1\u5355\u4F4D\u7684\u6700\u7EC8\u5355\u4EF7\u5FC5\u987B\u5728\u8303\u56F4\u5185\u4E14\u80FD\u7CBE\u786E\u8868\u793A\u4E3A\u6700\u591A 6 \u4F4D\u5C0F\u6570"})}}),ot=u.object({dimension:u.string(),cycleStart:u.iso.datetime(),counterKey:u.string(),unitCost:W,units:H,amount:H,tier:u.number().int().nullable(),poolVersionId:u.uuid().nullable()}),xo=u.object({key:ie,name:u.string().trim().min(1).max(80),rates:u.array(Lt).min(1).max(100).refine(e=>new Set(e.map(t=>t.featureKey)).size===e.length,"\u6BCF\u4E2A\u529F\u80FD\u53EA\u80FD\u914D\u7F6E\u4E00\u6761\u57FA\u7840\u8D39\u7387")}).strict(),Te=u.object({poolVersionId:u.uuid(),amount:ce,reset:u.enum(["month","lifetime"]).default("month"),pooled:u.boolean().optional(),rollover:u.object({cap:ce,cycles:u.number().int().min(1).max(12)}).strict().optional()}).strict().refine(e=>!e.rollover||e.reset==="month","\u7ED3\u8F6C\u53EA\u9002\u7528\u4E8E\u6708\u5EA6\u79EF\u5206"),at=u.object({id:u.uuid(),entityId:u.uuid().nullable(),resourceKey:u.string(),name:u.string(),source:u.string(),granted:H,available:H,reserved:H,spendable:H,consumed:H,forfeited:H,rolledOver:H,startsAt:u.iso.datetime(),expiresAt:u.iso.datetime().nullable(),eligible:u.boolean(),rates:u.array(Lt)}),zr=u.object({id:u.uuid(),kind:u.string(),featureKey:u.string().nullable(),featureName:u.string().nullable(),quantity:H,at:u.iso.datetime(),reason:u.string(),referenceId:u.uuid().nullable(),refundableQuantity:H,allocations:u.array(u.object({balanceId:u.uuid(),amount:H,pricing:u.array(ot).optional()}))}),Pr=u.object({id:u.uuid(),featureKey:u.string(),quantity:H,status:u.enum(["pending","confirmed","released","expired"]),expiresAt:u.iso.datetime({offset:!0})}),Vt=u.object({customerId:u.uuid(),entityId:u.uuid().nullable(),evaluatedAt:u.iso.datetime(),balances:u.array(at)}).strict(),Q=u.object({customerId:u.uuid().optional(),entityId:u.uuid().optional()}).strict(),st=Q.extend({featureKey:ie,quantity:ce.default("1"),properties:jr.optional()}).strict(),Mt=u.object({allowed:u.boolean(),featureKey:ie,quantity:ce,reason:u.enum(["insufficient_balance","feature_unavailable"]).nullable(),allocations:u.array(u.object({balanceId:u.uuid(),amount:H,units:H,pricing:u.array(ot).optional()}))}),ct=st.extend({customerId:u.uuid(),entityId:u.uuid().optional(),idempotencyKey:u.string().min(1).max(120),reason:u.string().trim().max(240).default("")}).strict(),Ut=ct.extend({expiresAt:u.iso.datetime()}).strict(),Ht=u.object({customerId:u.uuid(),entityId:u.uuid().optional(),reservationId:u.uuid(),idempotencyKey:u.string().min(1).max(120),action:u.enum(["confirm","release"]),quantity:W.optional()}).strict(),Bt=u.object({customerId:u.uuid(),entityId:u.uuid().optional(),transactionId:u.uuid(),quantity:ce,idempotencyKey:u.string().min(1).max(120),reason:u.string().trim().min(1).max(240)}).strict(),Kt=u.object({customerId:u.uuid(),entityId:u.uuid().optional(),poolVersionId:u.uuid(),amount:ce,expiresAt:u.iso.datetime().nullable().default(null),idempotencyKey:u.string().min(1).max(120),reason:u.string().trim().min(1).max(240)}).strict(),ge=u.object({accepted:u.boolean(),operationId:u.uuid().nullable(),reason:u.string().nullable(),allocations:u.array(u.object({balanceId:u.uuid(),amount:H,pricing:u.array(ot)}).strict())}).strict(),So=u.object({projectId:u.uuid(),environmentId:u.uuid(),action:u.enum(["pool_save","pool_publish","pool_archive","grant","refund","revoke"]),id:u.uuid().nullable().default(null),revision:u.number().int().nonnegative().default(0),input:u.unknown()}).strict(),oe=u.object({at:u.iso.datetime(),id:u.uuid()}).strict(),Zt=Q.extend({cursor:oe.nullable().optional(),limit:u.number().int().min(1).max(100).default(50),resourceKey:He.optional(),featureKey:ie.optional(),kind:u.enum(["consume","reserve","confirm","release","refund","manual","revoke","reset","expire","rollover"]).optional(),from:u.iso.datetime().optional(),to:u.iso.datetime().optional()}).strict().refine(e=>!e.from||!e.to||Date.parse(e.from)<=Date.parse(e.to),"Invalid date range"),Gt=u.object({transactions:u.array(zr),nextCursor:oe.nullable()}),Or=u.object({expiresAt:u.iso.datetime({offset:!0}),id:u.uuid()}).strict(),Io=u.object({reservations:u.array(Pr),nextCursor:Or.nullable()});var he=q.object({days:q.number().int().min(1).max(730),cardRequired:q.boolean(),featureAllowances:q.record(q.uuid(),q.number().int().min(0).max(1e9)),creditAmounts:q.record(q.uuid(),W)}).strict(),be=q.object({id:q.uuid(),planVersionId:q.uuid(),slot:q.string(),cardRequired:q.boolean(),status:q.enum(["pending","active","converted","canceled","expired","failed"]),startsAt:q.iso.datetime().nullable(),endsAt:q.iso.datetime().nullable(),createdAt:q.iso.datetime()}).strict(),Be=q.object({eligible:q.boolean(),reason:q.enum(["eligible","not_configured","already_used","already_subscribed","pending","entity_requires_payer"]),policy:he.nullable()}).strict(),Wt=q.object({planVersionId:q.uuid(),requestId:q.uuid(),currency:L.optional(),offerId:q.uuid().optional(),promotionCode:q.string().trim().min(3).max(32).transform(e=>e.toUpperCase()).optional()}).strict().refine(e=>!(e.offerId&&e.promotionCode),"Use either an offer or a promotion code");var ut=y.object({group:y.string().regex(/^[a-z][a-z0-9_]{0,63}$/).default("main"),kind:y.enum(["main","addon"]).default("main")}).strict(),lt=y.enum(["immediate","end_of_cycle"]),pt=y.enum(["attach","change","cancel","resume","cancel_change"]),mt=y.object({action:pt,planVersionId:y.uuid().optional(),holdingId:y.uuid().optional(),timing:lt.optional(),currency:L.optional(),requestId:y.uuid(),entityId:y.uuid().optional(),licenseQuantities:Me.optional()}).strict().superRefine((e,t)=>{["attach","change"].includes(e.action)&&!e.planVersionId&&t.addIssue({code:"custom",path:["planVersionId"],message:"Target plan version required"}),!["attach","change"].includes(e.action)&&(e.planVersionId||e.timing||e.currency)&&t.addIssue({code:"custom",message:"Only plan changes accept a target and timing"})}),Jt=y.object({action:pt,direction:y.enum(["new","upgrade","downgrade","same"]),timing:lt,group:y.string(),kind:y.enum(["main","addon"]),currentPlanVersionId:y.uuid().nullable(),targetPlanVersionId:y.uuid().nullable(),effectiveAt:y.iso.datetime(),amountDueCents:y.number().int().nullable(),currency:L,requiresCheckout:y.boolean(),estimate:y.boolean(),lineItems:y.array(y.object({description:y.string(),amountCents:y.number().int()})),nextCycle:y.object({startsAt:y.iso.datetime().nullable(),amountCents:y.number().int(),interval:y.enum(["free","month","year"]),estimate:y.boolean()}).nullable()}),Qt=y.object({id:y.uuid(),subscriptionId:y.uuid().nullable(),targetPlanVersionId:y.uuid().nullable(),action:pt,timing:lt,status:y.enum(["preparing","payment_pending","scheduled","completed","canceled","failed"]),effectiveAt:y.iso.datetime().nullable(),createdAt:y.iso.datetime()}),_r=y.object({id:y.uuid(),planVersionId:y.uuid(),planId:y.uuid(),basePlanId:y.uuid().nullable(),name:y.string(),group:y.string(),kind:y.enum(["main","addon"]),source:y.enum(["subscription","assignment","license","apple","google"]),status:y.string(),accessEnabled:y.boolean(),startsAt:y.iso.datetime().nullable(),endsAt:y.iso.datetime().nullable(),cancelAtPeriodEnd:y.boolean(),scheduledChange:Qt.nullable(),trial:be.nullable().optional()}),Ke=y.object({customerId:y.uuid(),evaluatedAt:y.iso.datetime(),holdings:y.array(_r),changes:y.array(Qt),trials:y.array(be).optional()}),Yt=y.object({changeId:y.uuid(),status:y.enum(["payment_pending","scheduled","completed"]),checkout:y.object({checkoutId:y.uuid(),url:y.url()}).nullable(),paymentUrl:y.url().nullable().optional(),effectiveAt:y.iso.datetime().nullable()});var ye=b.string().trim().min(1).max(64).regex(/^[a-z][a-z0-9_]*$/,"ID \u4F7F\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u4E0B\u5212\u7EBF\uFF0C\u5E76\u4EE5\u5B57\u6BCD\u5F00\u5934"),Fo=b.record(b.string().min(1).max(80),b.union([b.string().max(500),b.number().finite(),b.boolean(),b.null()])).refine(e=>Object.keys(e).length<=30,"\u6700\u591A 30 \u4E2A\u5C5E\u6027"),Xt=b.object({key:ye,name:b.string().trim().min(1).max(80),description:b.string().trim().max(240),type:b.enum(["boolean","metered"]),usageType:b.enum(["consumable","non_consumable"]).optional()}),Lo=Xt.extend({...te.shape,id:b.string().min(1),archived:b.boolean(),createdAt:b.iso.datetime()}),xe=b.object({amountCents:b.number().int().min(0).max(1e8),currency:L,interval:b.enum(["free","month","year"]),currencyOptions:b.partialRecord(L,b.number().int().min(1).max(1e8)).optional()}).refine(e=>e.interval==="free"?e.amountCents===0:e.amountCents>0,"\u514D\u8D39\u5957\u9910\u91D1\u989D\u5FC5\u987B\u4E3A 0\uFF0C\u4ED8\u8D39\u91D1\u989D\u5FC5\u987B\u5927\u4E8E 0").refine(e=>!e.currencyOptions||!Object.hasOwn(e.currencyOptions,e.currency)&&(e.interval!=="free"||Object.keys(e.currencyOptions).length===0),"\u9644\u52A0\u5E01\u79CD\u4E0D\u80FD\u91CD\u590D\u9ED8\u8BA4\u5E01\u79CD\uFF1B\u514D\u8D39\u5957\u9910\u4E0D\u8BBE\u7F6E\u9644\u52A0\u4EF7\u683C");function Vo(e,t){if(!t||t===e.currency)return e;let n=e.currencyOptions?.[t];if(n===void 0)throw new Error("Plan has no price for this currency");let r={...e.currencyOptions,[e.currency]:e.amountCents};return delete r[t],{...e,amountCents:n,currency:t,currencyOptions:r}}function Mo(e){return[e.currency,...Object.keys(e.currencyOptions??{}).map(t=>L.parse(t))]}var dt=b.object({featureId:b.string().min(1),allowance:b.number().int().min(0).max(1e9).nullable(),pooled:b.boolean().optional()}),Ze=b.object({name:b.string().trim().min(1).max(80),description:b.string().trim().max(240),price:xe,membership:ut.optional(),trial:he.nullable().optional(),licenses:b.array(_e).max(20).optional(),items:b.array(dt).max(100).refine(e=>new Set(e.map(t=>t.featureId)).size===e.length,"\u540C\u4E00\u529F\u80FD\u4E0D\u80FD\u91CD\u590D\u52A0\u5165\u5957\u9910")}),Uo=b.object({key:ye,config:Ze}),Ho=te.extend({id:b.string().min(1),key:ye,draft:Ze,status:b.enum(["draft","published","archived"]),publishedVersionId:b.string().nullable(),isDefault:b.boolean(),updatedAt:b.iso.datetime()}),Tr=Xt.pick({key:!0,name:!0,type:!0}).extend({featureId:b.string(),allowance:b.number().int().min(0).max(1e9).nullable(),pooled:b.boolean().optional()}).refine(e=>e.type==="boolean"?e.allowance===null:e.allowance!==null,"\u5F00\u5173\u578B\u65E0\u6570\u91CF\uFF0C\u8BA1\u91CF\u578B\u5FC5\u987B\u6307\u5B9A\u989D\u5EA6"),Re=te.extend({id:b.string().min(1),planId:b.string().min(1),variant:b.object({basePlanId:b.uuid(),baseVersionId:b.uuid()}).nullable(),version:b.number().int().positive(),name:b.string(),description:b.string(),price:xe,membership:ut.optional(),trial:he.nullable().optional(),licenses:b.array(_e).optional(),items:b.array(Tr),credits:b.array(Te).optional(),publishedAt:b.iso.datetime()}),ft=b.object({startsAt:b.iso.datetime(),endsAt:b.iso.datetime().nullable()}).refine(e=>e.endsAt===null||Date.parse(e.endsAt)>Date.parse(e.startsAt),"\u5230\u671F\u65F6\u95F4\u5FC5\u987B\u665A\u4E8E\u751F\u6548\u65F6\u95F4"),Bo=te.extend({id:b.string(),customerId:b.string(),planVersionId:b.string(),assignedAt:b.iso.datetime(),source:b.literal("demo"),validity:ft.nullable().default(null),used:b.record(b.string(),b.number().int().min(0))}),Ko=te.extend({id:b.string(),customerId:b.string(),at:b.iso.datetime(),message:b.string()});import{z as Z}from"zod";var Ge=Ze.extend({credits:Z.array(Te).max(100).default([])}).strict().superRefine((e,t)=>{if(e.trial){e.price.interval==="free"&&t.addIssue({code:"custom",path:["trial"],message:"Trials require a paid subscription plan"});for(let n of Object.keys(e.trial.featureAllowances))(!e.items.some(r=>r.featureId===n&&r.allowance!==null)||e.licenses?.some(r=>r.featureId===n))&&t.addIssue({code:"custom",path:["trial","featureAllowances",n],message:"Trial allowance must reference a plan feature without licensed capacity"});for(let n of Object.keys(e.trial.creditAmounts))e.credits.some(r=>r.poolVersionId===n)||t.addIssue({code:"custom",path:["trial","creditAmounts",n],message:"Trial credit pool must belong to the plan"})}}),en=e=>Z.object({upsert:Z.array(e).max(100),remove:Z.array(Z.uuid()).max(100)}).strict(),We=Z.object({name:Z.string().trim().min(1).max(80).optional(),description:Z.string().trim().max(240).optional(),price:xe.optional(),items:en(dt.strict()).optional(),credits:en(Te).optional(),licenses:Z.array(_e).max(20).optional(),trial:he.nullable().optional()}).strict().superRefine((e,t)=>{for(let n of["items","credits"]){let r=e[n];if(!r)continue;let o=r.upsert.map(i=>"featureId"in i?i.featureId:i.poolVersionId);(new Set(o).size!==o.length||new Set(r.remove).size!==r.remove.length||o.some(i=>r.remove.includes(i)))&&t.addIssue({code:"custom",path:[n],message:"\u53D8\u4F53\u5DEE\u5F02\u4E0D\u80FD\u91CD\u590D\u6216\u540C\u65F6\u79FB\u9664\u4E0E\u8986\u76D6\u540C\u4E00\u9879"})}}),Xo=Z.object({key:ye,basePlanId:Z.uuid(),baseVersionId:Z.uuid(),overrides:We}).strict(),ea=Z.object({key:ye,name:Z.string().trim().min(1).max(80),description:Z.string().trim().max(240)}).strict();function tn(e,t,n){let r=new Map(e.map(o=>[n(o),structuredClone(o)]));for(let o of t?.remove??[])r.delete(o);for(let o of t?.upsert??[])r.set(n(o),structuredClone(o));return[...r.values()]}function ta(e,t){let n=We.parse(t),r=structuredClone(Ge.parse(e));return n.name!==void 0&&(r.name=n.name),n.description!==void 0&&(r.description=n.description),n.price!==void 0&&(r.price=structuredClone(n.price)),n.licenses!==void 0&&(r.licenses=structuredClone(n.licenses)),n.trial!==void 0&&(r.trial=structuredClone(n.trial)),r.items=tn(r.items,n.items,o=>o.featureId),r.credits=tn(r.credits,n.credits,o=>o.poolVersionId),Ge.parse(r)}function Rr(e,t){let n=Ge.parse(e),r=Ge.parse(t);if(JSON.stringify(n.membership)!==JSON.stringify(r.membership))throw new Error("\u53D8\u4F53\u5FC5\u987B\u7EE7\u627F\u57FA\u7840\u5957\u9910\u7684\u7EC4\u548C\u7C7B\u578B");let o={};JSON.stringify(n.licenses??[])!==JSON.stringify(r.licenses??[])&&(o.licenses=structuredClone(r.licenses??[]));for(let d of["name","description","price","trial"])JSON.stringify(n[d])!==JSON.stringify(r[d])&&Object.assign(o,{[d]:r[d]});let i=(d,c,k)=>{let A=new Map(d.map(z=>[k(z),z])),w=new Set(c.map(k));return{upsert:c.filter(z=>JSON.stringify(A.get(k(z)))!==JSON.stringify(z)),remove:d.map(k).filter(z=>!w.has(z))}},a=i(n.items,r.items,d=>d.featureId),m=i(n.credits,r.credits,d=>d.poolVersionId);return(a.upsert.length||a.remove.length)&&(o.items=a),(m.upsert.length||m.remove.length)&&(o.credits=m),We.parse(o)}function na(e,t,n){let r={};for(let a of["name","description","price","trial"])t[a]!==void 0&&JSON.stringify(t[a])===JSON.stringify(n[a])&&Object.assign(r,{[a]:t[a]});let o={...r,...Rr(e,n)},i=(a,m,d,c)=>{let k=new Map(d.map(z=>[c(z),z])),A=new Map((a?.upsert??[]).filter(z=>JSON.stringify(k.get(c(z)))===JSON.stringify(z)).map(z=>[c(z),z]));for(let z of m?.upsert??[])A.set(c(z),z);let w=new Set([...(a?.remove??[]).filter(z=>!k.has(z)),...m?.remove??[]]);return A.size||w.size?{upsert:[...A.values()],remove:[...w]}:void 0};return o.items=i(t.items,o.items,n.items,a=>a.featureId),t.licenses!==void 0&&o.licenses===void 0&&(o.licenses=structuredClone(t.licenses)),o.credits=i(t.credits,o.credits,n.credits,a=>a.poolVersionId),We.parse(o)}import{z as ue}from"zod";var Dr=ue.object({name:ue.string().trim().min(1,"\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0").max(80),slug:ue.string().trim().max(63).regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"\u9879\u76EE\u6807\u8BC6\u4F7F\u7528\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26")}),nn=ue.object({description:ue.string().trim().max(240)}),oa=ue.object({project:Dr.extend({id:ue.string().min(1)}),environments:ue.object({sandbox:nn,live:nn})});import{z as P}from"zod";import{z as C}from"zod";import{z as Nr}from"zod";var on=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,G=Nr.string().max(16).regex(on,"\u8BED\u8A00\u4EE3\u7801\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4F8B\u5982 zh-CN\u3001en").refine(e=>{try{return Intl.getCanonicalLocales(e)[0]===e}catch{return!1}},"\u6301\u4E45\u5316\u8BED\u8A00\u4EE3\u7801\u5FC5\u987B\u4F7F\u7528\u89C4\u8303\u5199\u6CD5");function me(e){if(typeof e!="string")return null;try{let t=Intl.getCanonicalLocales(e.trim().replaceAll("_","-"))[0];if(!t)return null;let{language:n,script:r,region:o}=new Intl.Locale(t),i=[n,r,o].filter(Boolean).join("-");return on.test(i)?i:null}catch{return null}}var $r=new Set(["TW","HK","MO"]);function rn(e){let[t,n,r]=e.split("-");if(t!=="zh")return`${t}-${new Intl.Locale(e).maximize().script??""}`;let o=n?.length===4?n:void 0,i=n?.length===4?r:n;return o?`zh-${o}`:i&&$r.has(i)?"zh-Hant":"zh-Hans"}function Je(e,t,n){let r=t.map(o=>({code:G.parse(o),normalized:o}));for(let o of e){let i=me(o);if(!i)continue;let a=r.find(c=>c.normalized===i);if(a)return a.code;let m=rn(i),d=r.filter(c=>rn(c.normalized)===m);if(d.length>0)return(d.find(c=>!c.normalized.includes("-")||c.normalized===m)??d[0]).code}return n}var Er=[{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587\uFF08\u53F0\u7063\uFF09"},{code:"zh-HK",label:"\u7E41\u9AD4\u4E2D\u6587\uFF08\u9999\u6E2F\uFF09"},{code:"en",label:"English"},{code:"ja",label:"\u65E5\u672C\u8A9E"},{code:"ko",label:"\uD55C\uAD6D\uC5B4"},{code:"es",label:"Espa\xF1ol"},{code:"fr",label:"Fran\xE7ais"},{code:"de",label:"Deutsch"},{code:"pt-BR",label:"Portugu\xEAs (Brasil)"},{code:"it",label:"Italiano"},{code:"ru",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"vi",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"th",label:"\u0E44\u0E17\u0E22"},{code:"id",label:"Bahasa Indonesia"},{code:"ar",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629"}];function ca(e){return Er.find(t=>t.code===e)?.label??e}var gt={"zh-Hans":{once:"\u9996\u671F\u51CF {discount}",repeating:"\u524D {months} \u4E2A\u6708\u6BCF\u6708\u51CF {discount}",forever:"\u6BCF\u671F\u51CF {discount}"},"zh-Hant":{once:"\u9996\u671F\u6E1B {discount}",repeating:"\u524D {months} \u500B\u6708\u6BCF\u6708\u6E1B {discount}",forever:"\u6BCF\u671F\u6E1B {discount}"},en:{once:"{discount} off your first payment",repeating:"{discount} off each month for the first {months} months",repeatingOne:"{discount} off the first month",forever:"{discount} off every payment"},ja:{once:"\u521D\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15",repeating:"\u6700\u521D\u306E {months} \u304B\u6708\u9593\u3001\u6BCE\u6708 {discount} \u5272\u5F15",forever:"\u6BCE\u56DE\u306E\u304A\u652F\u6255\u3044\u304C {discount} \u5272\u5F15"},ko:{once:"\uCCAB \uACB0\uC81C {discount} \uD560\uC778",repeating:"\uCCAB {months}\uAC1C\uC6D4 \uB3D9\uC548 \uB9E4\uC6D4 {discount} \uD560\uC778",forever:"\uB9E4 \uACB0\uC81C {discount} \uD560\uC778"},es:{once:"{discount} de descuento en el primer pago",repeating:"{discount} de descuento cada mes durante los primeros {months} meses",forever:"{discount} de descuento en cada pago",repeatingOne:"{discount} de descuento durante el primer mes"},fr:{once:"{discount} de r\xE9duction sur le premier paiement",repeating:"{discount} de r\xE9duction par mois pendant les {months} premiers mois",forever:"{discount} de r\xE9duction sur chaque paiement",repeatingOne:"{discount} de r\xE9duction pendant le premier mois"},de:{once:"{discount} Rabatt auf die erste Zahlung",repeating:"{discount} Rabatt pro Monat f\xFCr die ersten {months} Monate",forever:"{discount} Rabatt auf jede Zahlung",repeatingOne:"{discount} Rabatt im ersten Monat"},pt:{once:"{discount} de desconto no primeiro pagamento",repeating:"{discount} de desconto por m\xEAs nos primeiros {months} meses",forever:"{discount} de desconto em cada pagamento",repeatingOne:"{discount} de desconto no primeiro m\xEAs"},it:{once:"{discount} di sconto sul primo pagamento",repeating:"{discount} di sconto al mese per i primi {months} mesi",forever:"{discount} di sconto su ogni pagamento",repeatingOne:"{discount} di sconto per il primo mese"},ru:{once:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043F\u0435\u0440\u0432\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436",repeating:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043A\u0430\u0436\u0434\u044B\u0439 \u043C\u0435\u0441\u044F\u0446 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",repeatingOne:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u0432 \u043F\u0435\u0440\u0432\u044B\u0439 \u043C\u0435\u0441\u044F\u0446",forever:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u043A\u0430\u0436\u0434\u044B\u0439 \u043F\u043B\u0430\u0442\u0451\u0436"},vi:{once:"Gi\u1EA3m {discount} cho l\u1EA7n thanh to\xE1n \u0111\u1EA7u ti\xEAn",repeating:"Gi\u1EA3m {discount} m\u1ED7i th\xE1ng trong {months} th\xE1ng \u0111\u1EA7u",forever:"Gi\u1EA3m {discount} cho m\u1ED7i l\u1EA7n thanh to\xE1n"},th:{once:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E04\u0E23\u0E31\u0E49\u0E07\u0E41\u0E23\u0E01",repeating:"\u0E25\u0E14 {discount} \u0E15\u0E48\u0E2D\u0E40\u0E14\u0E37\u0E2D\u0E19\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",forever:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E01\u0E32\u0E23\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19\u0E17\u0E38\u0E01\u0E04\u0E23\u0E31\u0E49\u0E07"},id:{once:"Diskon {discount} untuk pembayaran pertama",repeating:"Diskon {discount} setiap bulan selama {months} bulan pertama",forever:"Diskon {discount} untuk setiap pembayaran"},ar:{once:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u062F\u0641\u0639\u0629 \u0627\u0644\u0623\u0648\u0644\u0649",repeating:"\u062E\u0635\u0645 {discount} \u0634\u0647\u0631\u064A\u064B\u0627 \u0644\u0645\u062F\u0629 {period}",forever:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0643\u0644 \u062F\u0641\u0639\u0629"}},ma=["zh-CN","zh-TW","zh-HK","en","ja","ko","es","fr","de","pt-BR","it","ru","vi","th","id","ar"];function ht(e){let t=me(e)??"en",n=t.split("-"),r=n[0]==="zh"?n.includes("Hans")?"zh-Hans":n.includes("Hant")||n.some(o=>["TW","HK","MO"].includes(o))?"zh-Hant":"zh-Hans":n[0];return gt[r]?{locale:t,copy:gt[r]}:{locale:"en",copy:gt.en}}function qr(e,t,n="zh-CN"){let r=Oe(t);return Dt(e,t,ht(n).locale,{currencyDisplay:"narrowSymbol",minimumFractionDigits:e%10**r===0?0:r,maximumFractionDigits:r})}function Fr(e,t="zh-CN"){let n=ht(t).locale;return e.type==="percent"?new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:0}).format(e.percentOff/100):qr(e.amountOffCents,e.currency,n)}var an={zh:"\u524D {months} \u4E2A\u6708\u5185\u5F00\u51FA\u7684\u8D26\u5355\u51CF {discount}","zh-Hant":"\u524D {months} \u500B\u6708\u5167\u958B\u51FA\u7684\u5E33\u55AE\u6E1B {discount}",en:"{discount} off invoices issued within the first {months} months",ja:"\u6700\u521D\u306E {months} \u304B\u6708\u4EE5\u5185\u306E\u8ACB\u6C42\u304C {discount} \u5272\u5F15",ko:"\uCCAB {months}\uAC1C\uC6D4 \uB0B4 \uCCAD\uAD6C\uC11C {discount} \uD560\uC778",es:"{discount} de descuento en facturas emitidas durante los primeros {months} meses",fr:"{discount} de r\xE9duction sur les factures \xE9mises pendant les {months} premiers mois",de:"{discount} Rabatt auf Rechnungen innerhalb der ersten {months} Monate",pt:"{discount} de desconto nas faturas emitidas nos primeiros {months} meses",it:"{discount} di sconto sulle fatture emesse nei primi {months} mesi",ru:"\u0421\u043A\u0438\u0434\u043A\u0430 {discount} \u043D\u0430 \u0441\u0447\u0435\u0442\u0430 \u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435 \u043F\u0435\u0440\u0432\u044B\u0445 {months} \u043C\u0435\u0441.",vi:"Gi\u1EA3m {discount} cho h\xF3a \u0111\u01A1n trong {months} th\xE1ng \u0111\u1EA7u",th:"\u0E25\u0E14 {discount} \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A\u0E43\u0E1A\u0E41\u0E08\u0E49\u0E07\u0E2B\u0E19\u0E35\u0E49\u0E43\u0E19\u0E0A\u0E48\u0E27\u0E07 {months} \u0E40\u0E14\u0E37\u0E2D\u0E19\u0E41\u0E23\u0E01",id:"Diskon {discount} untuk tagihan dalam {months} bulan pertama",ar:"\u062E\u0635\u0645 {discount} \u0639\u0644\u0649 \u0627\u0644\u0641\u0648\u0627\u062A\u064A\u0631 \u0627\u0644\u0635\u0627\u062F\u0631\u0629 \u062E\u0644\u0627\u0644 \u0623\u0648\u0644 {period}"};function sn(e,t="zh-CN",n="month"){let r=ht(t),o=Fr(e.discount,r.locale),i=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale).format(e.duration.months):"",a=r.locale.split("-")[0],m=a==="zh"&&/(?:Hant|TW|HK|MO)/.test(r.locale)?"zh-Hant":a,d=e.duration.type==="repeating"&&n!=="month"?an[m]??an.en:e.duration.type==="repeating"&&e.duration.months===1?r.copy.repeatingOne??r.copy.repeating:r.copy[e.duration.type],c=e.duration.type==="repeating"?new Intl.NumberFormat(r.locale,{style:"unit",unit:"month",unitDisplay:"long"}).format(e.duration.months):"";return d.replace("{discount}",o).replace("{months}",i).replace("{period}",c)}var ba=C.enum(["draft","active","paused","archived"]),cn=C.discriminatedUnion("type",[C.object({type:C.literal("percent"),percentOff:C.number().int().min(1).max(100)}).strict(),C.object({type:C.literal("amount"),amountOffCents:C.number().int().min(1).max(1e8),currency:L}).strict()]),un=C.discriminatedUnion("type",[C.object({type:C.literal("once")}).strict(),C.object({type:C.literal("repeating"),months:C.number().int().min(1).max(36)}).strict(),C.object({type:C.literal("forever")}).strict()]),ln=C.discriminatedUnion("type",[C.object({type:C.literal("all")}).strict(),C.object({type:C.literal("plans"),planIds:C.array(C.uuid()).min(1).max(50).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D")}).strict()]),Lr=C.string().trim().min(1).max(40).refine(e=>!e.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7"),Vr=C.object({firstPurchaseOnly:C.boolean(),requiredTags:C.array(Lr).max(20).refine(e=>new Set(e).size===e.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D")}).strict(),ya=C.object({name:C.string().trim().min(1).max(80),description:C.string().max(500),discount:cn,duration:un,appliesTo:ln,eligibility:Vr,startsAt:C.iso.datetime().nullable(),endsAt:C.iso.datetime().nullable(),totalLimit:C.number().int().min(1).max(1e6).nullable(),perCustomerLimit:C.number().int().min(1).max(10),grantWindowHours:C.number().int().min(1).max(2160)}).strict().refine(e=>!e.startsAt||!e.endsAt||Date.parse(e.endsAt)>Date.parse(e.startsAt),{message:"\u7ED3\u675F\u65F6\u95F4\u5FC5\u987B\u665A\u4E8E\u5F00\u59CB\u65F6\u95F4",path:["endsAt"]}),xa=C.object({code:C.string().trim().transform(e=>e.toUpperCase()).pipe(C.string().regex(/^[A-Z0-9][A-Z0-9_-]{2,31}$/,"\u4F18\u60E0\u7801\u53EA\u80FD\u7528 3\u201332 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934")),maxRedemptions:C.number().int().min(1).max(1e6).nullable(),expiresAt:C.iso.datetime().nullable(),firstPurchaseOnly:C.boolean(),minimumAmountCents:C.number().int().min(1).max(1e8).nullable(),minimumAmountCurrency:L.nullable()}).strict().refine(e=>e.minimumAmountCents===null==(e.minimumAmountCurrency===null),"Minimum amount requires its currency");function Sa(){return{name:"\u65B0\u4F18\u60E0\u5238",description:"",discount:{type:"percent",percentOff:20},duration:{type:"once"},appliesTo:{type:"all"},eligibility:{firstPurchaseOnly:!1,requiredTags:[]},startsAt:null,endsAt:null,totalLimit:null,perCustomerLimit:1,grantWindowHours:72}}var bt=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function Ia(e,t,n){if(e==="draft")return[];if(e==="archived")return["\u5DF2\u5F52\u6863\u7684\u4F18\u60E0\u5238\u4E0D\u80FD\u4FEE\u6539"];let r=[];return bt(t.discount,n.discount)||r.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u6298\u6263"),bt(t.duration,n.duration)||r.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u6301\u7EED\u65B9\u5F0F"),bt(t.appliesTo,n.appliesTo)||r.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u9002\u7528\u5957\u9910"),t.startsAt!==n.startsAt&&r.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u5F00\u59CB\u65F6\u95F4"),t.endsAt!==n.endsAt&&(n.endsAt===null||t.endsAt!==null&&Date.parse(n.endsAt)>Date.parse(t.endsAt))&&r.push("\u751F\u6548\u540E\u7ED3\u675F\u65F6\u95F4\u53EA\u80FD\u63D0\u524D"),t.totalLimit!==n.totalLimit&&(n.totalLimit===null||t.totalLimit!==null&&n.totalLimit>t.totalLimit)&&r.push("\u751F\u6548\u540E\u603B\u6B21\u6570\u53EA\u80FD\u8C03\u4F4E"),n.perCustomerLimit>t.perCustomerLimit&&r.push("\u751F\u6548\u540E\u6BCF\u4EBA\u6B21\u6570\u53EA\u80FD\u8C03\u4F4E"),r}function va(e,t){return t==="activate"&&e==="draft"||t==="delete"&&e==="draft"||t==="pause"&&e==="active"||t==="resume"&&e==="paused"||t==="archive"&&(e==="active"||e==="paused")}var Mr=e=>`$${(e/100).toFixed(e%100===0?0:2)}`;function ka(e,t="zh-CN"){return sn(e,t)}function Ca(e){return Mr(e)}function ja(e,t){return e.startsAt&&Date.parse(e.startsAt)>t?"scheduled":e.endsAt&&Date.parse(e.endsAt)<=t?"ended":"open"}var Se=C.object({id:C.uuid(),couponId:C.uuid(),status:C.enum(["issued","redeemed","revoked","expired"]),issuedAt:C.iso.datetime(),expiresAt:C.iso.datetime(),coupon:C.object({name:C.string(),discount:cn,duration:un,appliesTo:ln})}),pn=C.enum(["inactive","outside_window","not_targeted","not_first_purchase","limit_reached","sold_out"]);var Ur=P.enum(["memberships","entitlements","credits"]),mn=Q.extend({include:P.array(Ur).min(1).max(3).refine(e=>new Set(e).size===e.length,"Duplicate state sections").default(["memberships","entitlements","credits"])}).strict(),Ie=P.string().regex(/^(0|[1-9]\d{0,29})(\.\d{1,12})?$/),Hr=P.object({resourceKey:P.string(),name:P.string(),granted:Ie,available:Ie,reserved:Ie,spendable:Ie,consumedInActiveGrants:Ie,nextExpiry:P.object({at:P.iso.datetime(),spendable:Ie}).nullable(),breakdown:P.array(at)}).strict(),Br=P.object({key:P.string(),name:P.string(),type:P.enum(["boolean","metered"]),allowed:P.boolean(),allowance:P.number().nonnegative().nullable(),used:P.number().nonnegative(),remaining:P.number().nonnegative().nullable()}).strict(),dn=P.object({customerId:P.uuid(),entityId:P.uuid().nullable(),evaluatedAt:P.iso.datetime(),membership:Ke.optional(),features:P.record(P.string(),Br).optional(),resources:P.record(P.string(),Hr).optional()}).strict(),fn=Q.extend({currency:L.optional()}).strict(),Kr=P.object({status:P.enum(["available","current","scheduled","blocked"]),action:P.enum(["attach","change"]).nullable(),direction:P.enum(["new","upgrade","downgrade","same"]).nullable(),reason:P.enum(["current","scheduled","pending_change","ambiguous_membership","managed_by_store","managed_by_payer","currency_unavailable","available"]),holdingId:P.uuid().nullable(),trial:Be.nullable()}).strict(),Zr=P.object({plan:Re,price:xe.nullable(),eligibility:Kr}).strict(),gn=P.object({customerId:P.uuid(),entityId:P.uuid().nullable(),evaluatedAt:P.iso.datetime(),plans:P.array(Zr)}).strict(),hn=Q.extend({cursor:oe.nullable().optional(),limit:P.number().int().min(1).max(100).default(50),status:Se.shape.status.optional(),from:P.iso.datetime().optional(),to:P.iso.datetime().optional()}).strict().refine(e=>!e.from||!e.to||Date.parse(e.from)<=Date.parse(e.to),"Invalid date range"),bn=P.object({offers:P.array(Se),nextCursor:oe.nullable()}).strict();import{z as j}from"zod";var Gr=["plan.name","plan.price","plan.period","plan.price_per_month","trial.headline","trial.terms","offer.headline","offer.name","offer.description","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.price","offer.original_price","offer.months","offer.code","offer.ends_at","offer.expires_at"],xn=j.object({plan:j.uuid().optional(),coupon:j.uuid().optional(),promotionCode:j.uuid().optional(),picker:j.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),yn=j.object({text:j.string().optional(),label:j.string().optional(),alt:j.string().optional(),html:j.string().max(32768).optional(),price:j.object({current:j.string(),original:j.string().nullable(),period:j.string()}).optional(),code:j.string().optional(),countdownAt:j.iso.datetime().optional(),planId:j.uuid().optional(),planVersionId:j.uuid().optional(),currency:L.optional(),couponId:j.uuid().optional(),offerId:j.uuid().optional(),unavailable:j.boolean().optional(),unavailableReason:j.string().optional(),missing:j.array(j.string()).optional()}).strict(),ve=j.object({nodes:j.record(j.string(),j.object({base:yn,picker:j.string().optional(),byPlan:j.record(j.string(),yn).optional()}).strict()),plans:j.record(j.string(),j.object({id:j.uuid(),versionId:j.uuid(),name:j.string(),price:j.string(),period:j.string(),currency:L.optional()}).strict()),pickers:j.record(j.string(),j.object({options:j.array(j.uuid()).max(20),selected:j.uuid().nullable()}).strict()),diagnostics:j.array(j.object({nodeId:j.string(),message:j.string()}).strict())}).strict();function Qe(e){return[...e.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(t=>t[1].trim())}function Ye(e){let t=Qe(e).filter(r=>!Gr.includes(r)),n=e.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(n.includes("{{")||n.includes("}}"))&&t.push("\u65E0\u6548\u53D8\u91CF\u8BED\u6CD5"),[...new Set(t)]}function qa(e,t,n,r=!1){let o=Qe(e).filter(i=>t[i]===void 0);return o.length&&!r?{value:n,missing:o}:{value:e.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(i,a)=>t[a.trim()]??i),missing:o}}function Fa(e,t,n={}){let r=e?.nodes[t];if(!r)return;let o=r.picker?n[r.picker]??e?.pickers[r.picker]?.selected:void 0;return typeof o=="string"?r.byPlan?.[o]??r.base:r.base}import{z as Wr}from"zod";var ke=Wr.string().regex(/^[a-f0-9]{64}$/);import{z as R}from"zod";var Sn=R.object({key:R.string().regex(/^[a-z][a-z0-9_]{0,63}$/),name:R.string().trim().min(1).max(80),poolVersionId:R.uuid(),amount:W.refine(e=>/[1-9]/.test(e)),amountCents:R.number().int().min(50).max(99999999),currency:R.literal("USD").default("USD"),expiresDays:R.number().int().min(1).max(3660).nullable().default(null),stripePriceId:R.string().regex(/^price_[A-Za-z0-9]+$/)}).strict(),In=Sn.extend({id:R.uuid(),packId:R.uuid(),version:R.number().int().positive()}),vn=Q.extend({packVersionId:R.uuid(),requestId:R.uuid()}).strict(),yt=R.object({id:R.uuid(),packVersionId:R.uuid(),name:R.string(),amount:W,amountCents:R.number().int(),currency:R.literal("USD"),status:R.enum(["created","pending","paid","expired","refunded","disputed"]),refundedCents:R.number().int().nonnegative(),shortfall:H,at:R.iso.datetime(),paidAt:R.iso.datetime().nullable()}),kn=Q.extend({cursor:oe.nullable().optional(),limit:R.number().int().min(1).max(100).default(50),status:yt.shape.status.optional(),from:R.iso.datetime().optional(),to:R.iso.datetime().optional()}).strict().refine(e=>!e.from||!e.to||Date.parse(e.from)<=Date.parse(e.to),"Invalid date range"),Ba=R.object({projectId:R.uuid(),environmentId:R.uuid(),action:R.enum(["save","publish","archive"]),id:R.uuid().nullable().default(null),revision:R.number().int().nonnegative(),input:R.unknown()}).strict().transform((e,t)=>{let n=(e.action==="save"?Sn:R.object({}).strict()).safeParse(e.input);return n.success?{...e,input:n.data}:(t.addIssue({code:"custom",message:n.error.issues[0]?.message??"\u8BF7\u68C0\u67E5\u79EF\u5206\u5305"}),R.NEVER)});import{z as l}from"zod";import{z as s}from"zod";import{z as T}from"zod";var Jr=["credit_balance","credit_transactions","membership","customer_plans","credit_packs","credit_pack_orders","offer_history"],Cn=T.enum(Jr),jn=T.object({source:Cn,layout:T.enum(["full","compact"]),resourceKey:He.optional(),pageSize:T.number().int().min(1).max(50),showSources:T.boolean(),allowPurchase:T.boolean()}).strict().superRefine((e,t)=>{e.resourceKey&&!["credit_balance","credit_transactions"].includes(e.source)&&t.addIssue({code:"custom",message:"\u8FD9\u4E2A\u6570\u636E\u6E90\u4E0D\u80FD\u7ED1\u5B9A\u79EF\u5206\u8D44\u6E90\u3002"}),e.showSources&&e.source!=="credit_balance"&&t.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u4F59\u989D\u53EF\u4EE5\u5C55\u5F00\u6765\u6E90\u3002"}),e.allowPurchase&&e.source!=="credit_packs"&&t.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u5305\u7EC4\u4EF6\u53EF\u4EE5\u542F\u7528\u8D2D\u4E70\u3002"})}),Y=T.string().max(2e3),An=T.object({id:T.string().max(100),label:Y,detail:T.array(Y).max(12),value:Y.optional(),status:Y.optional(),facts:T.array(T.object({label:Y,value:Y}).strict()).max(1e3),purchaseId:T.uuid().optional()}).strict(),Qr=T.object({key:He,name:Y,spendable:Y,reserved:Y,available:Y,expiry:Y.nullable(),sources:T.array(An).max(50),sourceCount:T.number().int().nonnegative(),sourcePage:T.number().int().positive(),hasNextSources:T.boolean(),hasPreviousSources:T.boolean()}).strict(),Yr=T.object({source:Cn,status:T.enum(["idle","loading","ready","error"]),stale:T.boolean(),preview:T.boolean(),errorCode:T.string().max(80).optional(),errorMessage:Y.optional(),resources:T.array(Qr).max(500),rows:T.array(An).max(50),hasNext:T.boolean(),hasPrevious:T.boolean(),page:T.number().int().positive(),filter:T.string().max(40),updatedAt:T.iso.datetime().optional(),buyingId:T.uuid().optional()}).strict(),Wa=T.object({nodes:T.record(T.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Yr)}).strict(),Ja=T.object({nodeId:T.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:T.enum(["refresh","next","previous","filter","buy_pack","sources_next","sources_previous"]),value:T.string().max(100).optional()}).strict();function wn(e){return{source:e,status:"idle",stale:!0,preview:!1,resources:[],rows:[],hasNext:!1,hasPrevious:!1,page:1,filter:"all"}}function xt(e){let t=Ye(e).map(n=>`\u672A\u77E5\u53D8\u91CF\uFF1A${n}`);for(let n=0;n<e.length;n++){if(e[n]!=="<"||!/[A-Za-z!/?{]/.test(e[n+1]??""))continue;let r=n;if(e.startsWith("<!--",n)){let o=e.indexOf("-->",n+4);n=o<0?e.length:o+2}else{let o="";for(n++;n<e.length;n++){let i=e[n];if(o)i===o&&(o="");else if(i==='"'||i==="'")o=i;else if(i===">")break}}/\{\{|\}\}/.test(e.slice(r,n+1))&&t.push("\u53D8\u91CF\u53EA\u80FD\u653E\u5728 HTML \u6587\u5B57\u4E2D\uFF0C\u4E0D\u80FD\u653E\u5165\u6807\u7B7E\u3001\u5C5E\u6027\u6216\u6CE8\u91CA")}return[...new Set(t)]}function zn(e){return e.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t])}function Xa(e,t,n,r=!1){let o=xt(e);if(o.length)throw new Error(o[0]);let i=[...new Set(Qe(e).filter(a=>t[a]===void 0))];return i.length&&!r?{value:zn(n),missing:i}:{value:e.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(a,m)=>t[m.trim()]===void 0?a:zn(t[m.trim()])),missing:i}}function Xr(e){let t=[],n=[];function r(o,i){let a={...i,...o.type==="stack"?o.bind:{}};if(o.type==="plan_picker"&&t.push(o),o.type==="button"&&n.push({nodeId:o.id,actionId:o.action,binding:a}),o.type==="custom_html"){let m=new Set(Object.values(o.html).flatMap(d=>[...d.matchAll(/(?:^|\s)data-grow-action\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+))/gi)].flatMap(c=>{let k=c[1]??c[2]??c[3];return k.includes("&")?e.actions.filter(A=>A.type==="purchase").map(A=>A.id):[k]})));for(let d of m)n.push({nodeId:o.id,actionId:d,binding:a})}o.type==="stack"&&o.children.forEach(m=>r(m,a))}return e.pages.forEach(o=>r(o.root,{})),n.flatMap(o=>{let i=e.actions.find(d=>d.id===o.actionId);if(i?.type!=="purchase")return[];let a=i.plan!=="selected"?i.plan:o.binding.plan,m=a?void 0:i.picker??o.binding.picker??t[0]?.id;return[{...o,planId:a,picker:t.find(d=>d.id===m)}]})}function Pn(e,t){return Xr(e).flatMap(n=>{let r=`\u8D2D\u4E70\u6309\u94AE ${n.nodeId}`;if(!n.planId&&!n.picker)return[`${r} \u6CA1\u6709\u771F\u5B9E\u5957\u9910\u6765\u6E90\uFF0C\u8BF7\u7ED1\u5B9A\u5957\u9910\u6216\u6DFB\u52A0\u771F\u5B9E\u5957\u9910\u9009\u62E9`];if(!t)return[];let o=t.filter(a=>a.interval!=="free");if(n.planId)return o.some(a=>a.id===n.planId)?[]:[`${r} \u5F15\u7528\u7684\u5957\u9910\u4E0D\u53EF\u8D2D\u4E70\uFF0C\u8BF7\u9009\u62E9\u5DF2\u53D1\u5E03\u7684\u4ED8\u8D39\u5957\u9910`];let i=n.picker.planIds??[];return o.some(a=>!i.length||i.includes(a.id))?[]:[`${r} \u7684\u5957\u9910\u9009\u62E9\u6CA1\u6709\u53EF\u8D2D\u4E70\u7684\u5DF2\u53D1\u5E03\u5957\u9910`]})}import{z as v}from"zod";var M=v.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),ei=v.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),On=v.object({version:v.literal(1),entry:M,questions:v.array(v.object({id:M,source:M,required:v.boolean()}).strict()).max(40),nodes:v.array(v.discriminatedUnion("type",[v.object({id:M,name:v.string().trim().min(1).max(60),type:v.literal("branch"),question:M,cases:v.array(v.object({value:v.union([M,v.boolean()]),target:M}).strict()).min(1).max(50),fallback:M,editorPosition:v.object({x:v.number().finite().min(-1e5).max(1e5),y:v.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),v.object({id:M,name:v.string().trim().min(1).max(60),type:v.literal("auth"),success:M,cancel:M,failure:M,editorPosition:v.object({x:v.number().finite().min(-1e5).max(1e5),y:v.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),v.object({id:M,name:v.string().trim().min(1).max(60),type:v.literal("purchase"),planVersionId:v.uuid(),success:M,cancel:M,failure:M,editorPosition:v.object({x:v.number().finite().min(-1e5).max(1e5),y:v.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),v.object({id:M,name:v.string().trim().min(1).max(60),type:v.literal("experiment"),experimentId:v.uuid(),revision:v.number().int().min(1),bucketVersion:v.number().int().min(1).max(1e9),variants:v.array(v.object({id:M,name:v.string().trim().min(1).max(60),weight:v.number().int().min(1).max(1e4),target:M}).strict()).min(2).max(5),editorPosition:v.object({x:v.number().finite().min(-1e5).max(1e5),y:v.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),v.object({id:M,name:v.string().trim().min(1).max(60),type:v.literal("complete"),editorPosition:v.object({x:v.number().finite().min(-1e5).max(1e5),y:v.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()])).max(40),routes:v.array(v.object({action:ei,target:M}).strict()).max(40)}).strict();function rs(e,t){let n={status:"running",nodeId:e.entry,pageId:null,answers:Object.create(null),history:[]},r=()=>({...n,answers:{...n.answers},history:[...n.history]}),o=i=>{let a=new Set;for(;!t.includes(i);){if(a.has(i)){n.status="failed",n.error="\u6761\u4EF6\u5206\u652F\u5F62\u6210\u5FAA\u73AF",n.pageId=null;return}a.add(i);let m=e.nodes.find(c=>c.id===i);if(n.nodeId=i,!m){n.status="failed",n.error="\u6D41\u7A0B\u76EE\u6807\u4E0D\u5B58\u5728",n.pageId=null;return}if(["auth","purchase","experiment"].includes(m.type)){n.status="waiting",n.nodeId=m.id,n.pageId=null;return}if(m.type==="complete"){n.status="completed",n.pageId=null;return}if(m.type!=="branch")return;let d=Object.hasOwn(n.answers,m.question)?n.answers[m.question]:void 0;i=m.cases.find(c=>c.value===d)?.target??m.fallback}n.status="running",n.error=void 0,n.nodeId=n.pageId=i};return{start(i=e.entry){return n={status:"running",nodeId:i,pageId:null,answers:Object.create(null),history:[]},o(i),r()},answer(i,a){return n.status==="running"&&e.questions.some(m=>m.id===i)&&(n.answers[i]=a),r()},move(i){return n.status!=="running"||(n.pageId&&i!==n.pageId&&n.history.push(n.pageId),o(i)),r()},back(){if(n.status!=="running")return r();let i=n.history.pop();return i&&o(i),r()},restore(i){if(i.status==="waiting"&&e.nodes.some(a=>a.id===i.nodeId&&["auth","purchase","experiment"].includes(a.type)))return n={...i,pageId:null,answers:{...i.answers},history:i.history.filter(a=>t.includes(a)).slice(-100)},r();if(i.status!=="running"||!i.pageId||!t.includes(i.pageId)||i.nodeId!==i.pageId)return n={status:"failed",nodeId:e.entry,pageId:null,answers:Object.create(null),history:[],error:"\u6062\u590D\u7684\u6D41\u7A0B\u72B6\u6001\u65E0\u6548"},r();n={status:"running",nodeId:i.pageId,pageId:i.pageId,answers:Object.create(null),history:i.history.filter(a=>t.includes(a)).slice(-100)};for(let a of e.questions)if(Object.hasOwn(i.answers,a.id)){let m=i.answers[a.id];(typeof m=="string"||typeof m=="boolean")&&(n.answers[a.id]=m)}return r()},resolve(i){if(n.status!=="waiting")return r();let a=e.nodes.find(d=>d.id===n.nodeId);return(a?.type==="experiment"?a.variants.map(d=>d.target):a?.type==="auth"||a?.type==="purchase"?[a.success,a.cancel,a.failure]:[]).includes(i)&&o(i),r()},snapshot:r}}function _n(e){let t=new Map,n=(r,o,i=!0)=>{if(i=i&&!r.hidden,t.set(r.id,{node:r,page:o,visible:i}),r.type==="stack")for(let a of r.children)n(a,o,i)};for(let r of e.pages)n(r.root,r.id);return t}function It(e){let t=[],n=[],r=e.funnel;if(!r)return{errors:t,warnings:n};e.surface!=="onboarding"&&t.push("Funnel \u53EA\u7528\u4E8E\u5F15\u5BFC\u6D41\u7A0B");let o=new Set(e.pages.map(x=>x.id));for(let x of r.nodes)(o.has(x.id)||["next","back"].includes(x.id))&&t.push(`\u6D41\u7A0B\u8282\u70B9\u6807\u8BC6\u91CD\u590D\u6216\u4FDD\u7559\uFF1A${x.id}`),o.add(x.id);let i=x=>{o.has(x)||t.push(`\u6D41\u7A0B\u76EE\u6807\u4E0D\u5B58\u5728\uFF1A${x}`)};i(r.entry);let a=_n(e),m=new Set,d=new Set;for(let x of r.questions){(m.has(x.id)||d.has(x.source))&&t.push(`\u95EE\u9898\u6807\u8BC6\u6216\u7EC4\u4EF6\u91CD\u590D\uFF1A${x.id}`),m.add(x.id),d.add(x.source);let F=a.get(x.source);(!F?.visible||F.node.type!=="stack"||!F.node.interaction||!["select","toggle"].includes(F.node.interaction.type))&&t.push(`\u95EE\u9898 ${x.id} \u5FC5\u987B\u7ED1\u5B9A\u53EF\u89C1\u7684\u5355\u9009\u6216\u5F00\u5173\u7EC4\u4EF6`)}let c=(x,F)=>{let re=r.questions.find(K=>K.id===x),I=re&&a.get(re.source)?.node;return I?.type==="stack"&&(I.interaction?.type==="toggle"?typeof F=="boolean":I.interaction?.type==="select"&&typeof F=="string"&&I.children.some(K=>K.id===F&&!K.hidden))};for(let x of r.nodes)if(x.type==="branch"){m.has(x.question)||t.push(`\u5206\u652F ${x.name} \u5F15\u7528\u7684\u95EE\u9898\u4E0D\u5B58\u5728`);let F=new Set;for(let re of x.cases){c(x.question,re.value)||t.push(`\u5206\u652F ${x.name} \u7684\u7B54\u6848\u503C\u65E0\u6548`);let I=JSON.stringify(re.value);F.has(I)&&t.push(`\u5206\u652F ${x.name} \u7684\u6761\u4EF6\u91CD\u590D`),F.add(I),i(re.target)}i(x.fallback)}for(let x of r.nodes){for(let F of St(x))i(F.target);x.type==="experiment"&&new Set(x.variants.map(F=>F.id)).size!==x.variants.length&&t.push(`\u5B9E\u9A8C ${x.name} \u7684\u53D8\u4F53\u6807\u8BC6\u91CD\u590D`)}let k=new Set;for(let x of r.routes)k.has(x.action)&&t.push(`\u6D41\u7A0B\u52A8\u4F5C\u8DEF\u7531\u91CD\u590D\uFF1A${x.action}`),k.add(x.action),e.actions.some(F=>F.id===x.action&&F.type==="navigate")||t.push(`\u6D41\u7A0B\u8DEF\u7531\u5FC5\u987B\u5F15\u7528\u5BFC\u822A\u52A8\u4F5C\uFF1A${x.action}`),x.target!=="back"&&i(x.target);let A=new Map(r.nodes.filter(x=>x.type==="branch"||x.type==="experiment").map(x=>[x.id,x])),w=new Set,z=new Set,J=x=>{if(w.has(x))return!0;if(z.has(x))return!1;let F=A.get(x);if(!F)return!1;w.add(x);let re=St(F).some(I=>J(I.target));return w.delete(x),z.add(x),re};return[...A.keys()].some(J)&&t.push("\u6761\u4EF6\u8282\u70B9\u4E4B\u95F4\u4E0D\u80FD\u5F62\u6210\u81EA\u52A8\u8DF3\u8F6C\u5FAA\u73AF"),r.nodes.some(x=>x.type==="complete")||n.push("\u6D41\u7A0B\u5C1A\u672A\u8BBE\u7F6E\u5B8C\u6210\u8282\u70B9\uFF1B\u5173\u95ED\u9875\u9762\u4E0D\u4EE3\u8868\u5B8C\u6210\u6D41\u7A0B"),{errors:[...new Set(t)],warnings:n}}function ti(e,t){let n={};if(!t||typeof t!="object"||Array.isArray(t))return n;let r=t,o=_n(e);for(let i of e.funnel?.questions??[]){let a=o.get(i.source)?.node,m=Object.hasOwn(r,i.id)?r[i.id]:void 0;a?.type==="stack"&&(a.interaction?.type==="toggle"&&typeof m=="boolean"&&(n[i.id]=m),a.interaction?.type==="select"&&typeof m=="string"&&a.children.some(d=>!d.hidden&&d.id===m)&&(n[i.id]=m))}return n}function is(e,t){if(!e.funnel||!t||!["running","waiting","completed","failed"].includes(t.status))return null;let n=new Set(e.pages.map(o=>o.id)),r=e.funnel.nodes.find(o=>o.id===t.nodeId);return t.status==="running"&&(!n.has(t.nodeId)||t.pageId!==t.nodeId)||t.status==="completed"&&(r?.type!=="complete"||t.pageId!==null)||t.status==="waiting"&&(!r||!["auth","purchase","experiment"].includes(r.type)||t.pageId!==null)||t.status==="failed"&&!r&&!n.has(t.nodeId)?null:{status:t.status,nodeId:t.nodeId,pageId:t.status==="running"?t.pageId:null,answers:ti(e,t.answers),history:Array.isArray(t.history)?t.history.filter(o=>n.has(o)).slice(-100):[],...typeof t.error=="string"?{error:t.error.slice(0,200)}:{}}}function Tn(e){let t=[],n=[];if(!e.funnel)return{errors:t,warnings:n};let r=e.funnel,o=new Set,i=[r.entry];for(;i.length;){let a=i.shift();if(o.has(a))continue;o.add(a);let m=r.nodes.find(w=>w.id===a);if(m){i.push(...St(m).map(w=>w.target));continue}let d=e.pages.findIndex(w=>w.id===a),c=e.pages[d];if(!c)continue;let k=new Set,A=w=>{if(!w.hidden){if(w.type==="button"&&k.add(w.action),w.type==="custom_html")for(let z of Object.values(w.html))for(let J of z.matchAll(/data-grow-action\s*=\s*["']([a-zA-Z][a-zA-Z0-9_.-]*)["']/g))k.add(J[1]);w.type==="stack"&&w.children.forEach(A)}};A(c.root);for(let w of e.actions.filter(z=>k.has(z.id))){if(w.type!=="navigate")continue;let J=r.routes.find(x=>x.action===w.id)?.target??(w.target==="next"?e.pages[d+1]?.id:w.target);J&&J!=="back"&&i.push(J),J||t.push(`\u9875\u9762 ${c.name} \u7684\u4E0B\u4E00\u9875\u4E0D\u5B58\u5728\uFF0C\u8BF7\u8FDE\u63A5\u5230\u9875\u9762\u6216\u5B8C\u6210\u8282\u70B9`)}}r.nodes.some(a=>a.type==="complete"&&o.has(a.id))||t.push("Funnel \u81F3\u5C11\u9700\u8981\u4E00\u6761\u53EF\u5230\u8FBE\u5B8C\u6210\u8282\u70B9\u7684\u8DEF\u5F84");for(let a of[...e.pages,...r.nodes])o.has(a.id)||n.push(`\u6D41\u7A0B\u8282\u70B9 ${a.name} \u4ECE\u5165\u53E3\u4E0D\u53EF\u5230\u8FBE`);return{errors:t,warnings:n}}function St(e){return e.type==="branch"?[...e.cases.map((t,n)=>({handle:`case-${n}`,label:String(t.value),target:t.target})),{handle:"fallback",label:"\u5176\u4ED6\u60C5\u51B5",target:e.fallback}]:e.type==="experiment"?e.variants.map(t=>({handle:t.id,label:`${t.name} \xB7 ${t.weight}`,target:t.target})):e.type==="auth"||e.type==="purchase"?["success","cancel","failure"].map((t,n)=>({handle:t,label:["\u6210\u529F","\u53D6\u6D88","\u5931\u8D25"][n],target:e[t]})):[]}var ni=3,X={nodes:150,depth:8,children:50,locales:20,actions:40,pages:20,stringLength:2e3,customHtml:32768,customCss:16384,documentBytes:2e5},De=s.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),U=s.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),ri=s.enum(["none","xs","sm","md","lg","xl"]),ii=s.enum(["none","sm","md","lg","full"]),Xe=s.string().regex(/^#[0-9a-fA-F]{6}$/),ds=s.union([s.enum(["primary","text","muted","background","surface"]),Xe]),$n=s.string().max(2048).refine(e=>{try{let t=new URL(e);return t.protocol==="https:"&&t.hostname.length>0}catch{return!1}},"\u53EA\u652F\u6301 https \u94FE\u63A5"),vt=s.union([$n,s.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),s.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),s.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),Rn=s.object({primary:Xe,background:Xe,text:Xe,radius:ii,font:s.enum(["system","serif","rounded","mono"])}).strict(),Ne=s.union([s.enum(["primary","text","muted","background","surface"]),s.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),E=(e,t)=>s.number().int().min(e).max(t),Dn=s.union([s.enum(["fit","fill"]),E(1,1200)]),oi=s.object({top:E(0,200),right:E(0,200),bottom:E(0,200),left:E(0,200)}).strict(),ai=s.object({top:E(-100,200),right:E(-100,200),bottom:E(-100,200),left:E(-100,200)}).strict(),En=s.object({x:E(0,100),y:E(0,100)}).strict(),si=s.discriminatedUnion("type",[s.object({type:s.literal("color"),color:Ne}).strict(),s.object({type:s.literal("linear"),angle:E(0,360),stops:s.array(s.object({color:Ne,at:E(0,100)}).strict()).min(2).max(4)}).strict(),s.object({type:s.literal("image"),src:vt,fit:s.enum(["cover","contain"]),position:En.optional()}).strict()]),ci=s.discriminatedUnion("type",[s.object({type:s.literal("rect"),radius:s.union([E(0,200),s.object({topLeft:E(0,200),topRight:E(0,200),bottomRight:E(0,200),bottomLeft:E(0,200)}).strict()])}).strict(),s.object({type:s.literal("pill")}).strict()]),ui=s.object({width:E(0,12),color:Ne,style:s.enum(["solid","dashed"])}).strict(),li=s.object({x:E(-40,40),y:E(-40,40),blur:E(0,80),spread:E(-20,40),color:Ne}).strict(),pi=s.object({font:s.enum(["system","serif","rounded","mono"]),size:E(8,96),weight:s.number().int().min(100).max(900).multipleOf(100),lineHeight:s.number().min(.8).max(3),letterSpacing:s.number().min(-5).max(20),color:Ne,align:s.enum(["start","center","end"]),italic:s.boolean(),decoration:s.enum(["none","underline","line-through"]),transform:s.enum(["none","uppercase"])}).strict().partial(),je=s.object({width:Dn,height:Dn,padding:oi,margin:ai,gap:E(0,120),grow:s.union([s.boolean(),s.number().min(0).max(12)]),background:si,opacity:s.number().min(0).max(1),clipContent:s.boolean(),shape:ci,border:ui,shadow:li,text:pi}).strict().partial(),ee={id:De,name:s.string().trim().min(1).max(60).optional(),hidden:s.boolean().optional(),style:je.optional(),fallback:U.optional()},mi=s.object({...ee,type:s.literal("text"),text:U,variant:s.enum(["title","heading","body","caption"])}).strict(),di=s.object({...ee,type:s.literal("image"),src:vt,localizedSrc:s.record(G,vt).optional(),alt:U,aspect:s.enum(["auto","1:1","4:3","16:9","3:1"]),fit:s.enum(["cover","contain"]),position:En.optional()}).strict(),fi=s.object({...ee,type:s.literal("button"),label:U,variant:s.enum(["primary","secondary","link"]),action:U}).strict(),gi=s.object({...ee,type:s.literal("divider")}).strict(),hi=s.object({...ee,type:s.literal("customer_data"),title:U,data:jn}).strict(),bi=s.object({...ee,type:s.literal("spacer"),size:ri}).strict(),yi=s.object({...ee,type:s.literal("custom_html"),html:s.record(G,s.string().max(X.customHtml)),css:s.string().max(X.customCss)}).strict(),xi=s.object({...ee,type:s.literal("price"),fallback:U,parts:s.object({current:je.optional(),original:je.optional(),period:je.optional()}).strict().optional()}).strict(),Si=s.object({...ee,type:s.literal("coupon_code"),label:U,fallback:U}).strict(),Ii=s.object({...ee,type:s.literal("countdown"),source:s.enum(["offer.ends_at","offer.expires_at","fixed"]),at:s.iso.datetime().optional(),granularity:s.enum(["day","hour","minute","second"]),expired:U,fallback:U}).strict().refine(e=>e.source!=="fixed"||!!e.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),vi=s.object({...ee,type:s.literal("plan_picker"),label:U,fallback:U,planIds:s.array(s.uuid()).min(1).max(20).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D").optional(),defaultPlan:s.uuid().optional(),states:s.object({selected:je.optional()}).strict().optional()}).strict(),ki=s.discriminatedUnion("type",[s.object({type:s.literal("select"),label:U,defaultIndex:E(0,49),purpose:s.enum(["option","package","tier"]).optional(),selectedStyle:je.optional()}).strict(),s.object({type:s.literal("tabs"),label:U,defaultIndex:E(0,49),purpose:s.literal("tier").optional()}).strict(),s.object({type:s.literal("toggle"),label:U,defaultEnabled:s.boolean()}).strict(),s.object({type:s.literal("carousel"),label:U}).strict()]),qn=s.lazy(()=>s.object({...ee,type:s.literal("stack"),direction:s.enum(["vertical","horizontal","overlay"]),align:s.enum(["start","center","end","stretch"]),justify:s.enum(["start","center","end","between"]),children:s.array(Ci).max(X.children),interaction:ki.optional(),bind:xn.optional()}).strict()),Ci=s.lazy(()=>s.union([qn,mi,di,fi,gi,bi,yi,xi,Si,Ii,vi,hi])),ji=s.union([s.string().max(500),s.number().finite(),s.boolean(),s.null()]),Ce={id:U,event:U,properties:s.record(U,ji).refine(e=>Object.keys(e).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},Ai=s.discriminatedUnion("type",[s.object({...Ce,type:s.literal("purchase"),close:s.literal(!1),plan:s.union([s.literal("selected"),s.uuid()]),picker:De.optional(),offer:s.enum(["scope","none"]),channel:s.enum(["web","native"])}).strict(),s.object({...Ce,type:s.literal("navigate"),target:De,close:s.literal(!1)}).strict(),s.object({...Ce,type:s.literal("event"),close:s.boolean()}).strict(),s.object({...Ce,type:s.literal("close"),close:s.literal(!0)}).strict(),s.object({...Ce,type:s.literal("open_url"),close:s.boolean(),url:$n}).strict(),s.object({...Ce,type:s.literal("claim_offer"),close:s.boolean(),couponId:s.uuid()}).strict()]),Nn=s.object({defaultLocale:G,locales:s.record(G,s.record(U,s.string().max(X.stringLength)))}).strict(),Ct=s.enum(["popup","paywall","onboarding","page"]),Fn={popup:"\u5F39\u7A97",paywall:"\u4ED8\u8D39\u5899",onboarding:"\u8F6C\u5316\u6F0F\u6597",page:"\u9875\u9762"},fs={popup:"/workspace/popups",paywall:"/workspace/paywalls",onboarding:"/workspace/onboarding",page:"/workspace/pages"},wi=s.discriminatedUnion("type",[s.object({type:s.literal("modal"),size:s.enum(["sm","md","lg"])}).strict(),s.object({type:s.literal("sheet"),size:s.enum(["sm","md","lg"])}).strict(),s.object({type:s.literal("fullscreen")}).strict()]),gs={sm:360,md:420,lg:560},zi=s.object({kind:s.literal("screen"),schemaVersion:s.literal(ni),name:s.string().trim().min(1).max(80),surface:Ct,presentation:wi,theme:Rn,funnel:On.optional(),pages:s.array(s.object({id:De,name:s.string().trim().min(1).max(60),root:qn,theme:Rn.optional(),source:s.object({campaignId:s.uuid(),versionId:s.uuid(),map:s.record(s.string(),De),strings:Nn.optional()}).strict().optional(),editorPosition:s.object({x:s.number().finite().min(-1e5).max(1e5),y:s.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(X.pages),strings:Nn,actions:s.array(Ai).max(X.actions)}).strict();function le(e,t){for(let n of e.pages)$e(n.root,t)}function hs(e,t){return{...e,pages:e.pages.map((n,r)=>r===0?{...n,root:t}:n)}}var B=zi.superRefine((e,t)=>{e.surface==="page"&&(e.pages.length!==1||e.funnel||e.pages[0].source)&&t.addIssue({code:"custom",message:"\u72EC\u7ACB\u9875\u9762\u53EA\u80FD\u5305\u542B\u4E00\u4E2A\u9875\u9762\uFF0C\u4E0D\u80FD\u5305\u542B\u6D41\u7A0B\u6216\u5F15\u7528\u5176\u4ED6\u9875\u9762\u3002"});let n=c=>t.addIssue({code:"custom",message:c});e.pages.some(c=>c.source)&&(e.surface!=="onboarding"||!e.funnel)&&n("\u53EA\u6709 Funnel \u53EF\u4EE5\u5F15\u7528\u5DF2\u53D1\u5E03\u9875\u9762\u3002");for(let c of It(e).errors)n(c);let r=Object.keys(e.strings.locales);r.includes(e.strings.defaultLocale)||n("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),r.length>X.locales&&n(`\u6700\u591A ${X.locales} \u79CD\u8BED\u8A00`);let o=new Set;for(let c of e.actions)o.has(c.id)&&n(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${c.id}`),o.add(c.id);let i=new Set;for(let c of e.pages)["next","back"].includes(c.id)&&n(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${c.id}`),i.has(c.id)&&n(`\u9875\u9762 id \u91CD\u590D\uFF1A${c.id}`),i.add(c.id);for(let c of e.actions)c.type==="navigate"&&!["next","back"].includes(c.target)&&!i.has(c.target)&&n(`\u7FFB\u9875\u76EE\u6807\u4E0D\u5B58\u5728\uFF1A${c.target}`);let a=new Set,m=0,d=!1;le(e,(c,k)=>{if(m++,k>X.depth&&(d=!0),a.has(c.id)&&n(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${c.id}`),a.add(c.id),c.type==="button"&&!o.has(c.action)&&n(`\u6309\u94AE ${c.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${c.action}`),c.type==="customer_data"&&!["page","onboarding"].includes(e.surface)&&n("\u4E1A\u52A1\u6570\u636E\u7EC4\u4EF6\u53EA\u7528\u4E8E Pages \u6216 Funnel \u9875\u9762\u3002"),c.type==="custom_html")for(let A of Object.keys(c.html))r.includes(A)||n(`\u81EA\u5B9A\u4E49 HTML ${c.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${A}`);if(c.type==="image")for(let A of Object.keys(c.localizedSrc??{}))r.includes(A)||n(`\u56FE\u7247 ${c.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${A}`)}),m>X.nodes&&n(`\u7EC4\u4EF6\u6700\u591A ${X.nodes} \u4E2A`),d&&n(`\u5C42\u7EA7\u6700\u591A ${X.depth} \u5C42`)});function $e(e,t,n=1,r=null){if(t(e,n,r)!==!1&&e.type==="stack")for(let o of e.children)$e(o,t,n+1,e)}function jt(e){let t=[],n=new Set;return le(e,r=>{let o=(i,a,m)=>{n.has(i)||(n.add(i),t.push({key:i,nodeId:r.id,nodeType:r.type,field:a,required:m}))};r.type==="stack"&&r.interaction&&o(r.interaction.label,"label",!0),r.fallback&&o(r.fallback,"text",!0),r.type==="text"&&o(r.text,"text",!0),r.type==="customer_data"&&o(r.title,"title",!0),(r.type==="plan_picker"||r.type==="coupon_code")&&o(r.label,"label",!0),r.type==="countdown"&&o(r.expired,"text",!0),r.type==="button"&&o(r.label,"label",!0),r.type==="image"&&(o(`image:${r.id}`,"src",!1),o(r.alt,"alt",!1)),r.type==="custom_html"&&o(`html:${r.id}`,"html",!0)}),t}function Pi(e,t,n){if(t.field==="html"){let r;return le(e,o=>{o.id===t.nodeId&&o.type==="custom_html"&&(r=o.html[n])}),r}if(t.field==="src"){let r=kt(e,t.nodeId);return r?.type==="image"?r.localizedSrc?.[n]??(n===e.strings.defaultLocale?r.src:void 0):void 0}return e.strings.locales[n]?.[t.key]}function Ln(e){let t=jt(e).filter(r=>r.required);return Object.keys(e.strings.locales).sort((r,o)=>r===e.strings.defaultLocale?-1:o===e.strings.defaultLocale?1:0).map(r=>{let o=t.filter(i=>!Pi(e,i,r)?.trim()).map(i=>i.key);return{locale:r,total:t.length,filled:t.length-o.length,missing:o,complete:o.length===0}})}function bs(e){let t=Tn(e),n=[...t.errors,...Pn(e)],r=e.actions.some(c=>typeof c.properties.templateKey=="string"&&c.properties.templateKey.startsWith("popup-coupon-"));r&&(!e.actions.some(c=>c.type==="claim_offer")||e.actions.some(c=>c.type==="event"&&typeof c.properties.templateKey=="string"&&c.properties.templateKey.startsWith("popup-coupon-")))&&n.push("\u4F18\u60E0\u5238\u6A21\u677F\u5C1A\u672A\u7ED1\u5B9A\u771F\u5B9E\u4F18\u60E0\u5238\uFF1A\u8BF7\u5C06\u9886\u53D6\u6309\u94AE\u8BBE\u4E3A\u300C\u9886\u53D6\u4F18\u60E0\u300D\u5E76\u9009\u62E9\u751F\u6548\u4E2D\u7684\u5238");function o(c,k){let A=c.type==="stack"?c.bind?.coupon??k:k;if(r&&c.type==="text"&&Object.values(e.strings.locales).some(w=>w[c.text]?.includes("{{offer."))&&!A&&n.push("\u4F18\u60E0\u5238\u6A21\u677F\u5C1A\u672A\u7ED1\u5B9A\u771F\u5B9E\u4F18\u60E0\u5238\uFF1A\u52A8\u6001\u6587\u6848\u9700\u8981\u7EE7\u627F\u4F18\u60E0\u5238\u7ED1\u5B9A"),c.type==="button"){let w=e.actions.find(z=>z.id===c.action);w?.type==="claim_offer"&&A&&A!==w.couponId&&n.push(`\u9886\u53D6\u6309\u94AE ${c.id} \u4E0E\u5C55\u793A\u5185\u5BB9\u7ED1\u5B9A\u4E86\u4E0D\u540C\u7684\u4F18\u60E0\u5238`)}c.type==="stack"&&c.children.forEach(w=>o(w,A))}e.pages.forEach(c=>o(c.root));let i=[...It(e).warnings,...t.warnings],a=B.safeParse(e);a.success||n.push(...a.error.issues.map(c=>c.message));for(let c of Object.values(e.strings.locales))for(let k of Object.values(c))for(let A of Ye(k))n.push(`\u672A\u77E5\u53D8\u91CF\uFF1A${A}`);le(e,c=>{if(c.type==="customer_data"&&Object.values(e.strings.locales).some(A=>/\{\{|\}\}/.test(A[c.title]??""))&&n.push(`\u6570\u636E\u7EC4\u4EF6 ${c.id} \u7684\u6807\u9898\u9700\u8981\u4F7F\u7528\u9759\u6001\u6587\u5B57`),(c.type==="text"?[c.text]:c.type==="button"?[c.label]:[]).some(A=>Object.values(e.strings.locales).some(w=>w[A]?.includes("{{")))&&!c.fallback&&n.push(`\u7EC4\u4EF6 ${c.id} \u4F7F\u7528\u53D8\u91CF\uFF0C\u8BF7\u586B\u5199\u5907\u7528\u6587\u6848`),c.fallback&&Object.values(e.strings.locales).some(A=>A[c.fallback]?.includes("{{"))&&n.push(`\u7EC4\u4EF6 ${c.id} \u7684\u5907\u7528\u6587\u6848\u9700\u8981\u4F7F\u7528\u9759\u6001\u6587\u5B57`),c.type==="custom_html"){for(let A of Object.values(c.html))n.push(...xt(A).map(w=>`HTML ${c.id}\uFF1A${w}`));Object.values(c.html).some(A=>A.includes("{{"))&&!c.fallback&&n.push(`HTML ${c.id} \u4F7F\u7528\u53D8\u91CF\uFF0C\u8BF7\u586B\u5199\u5907\u7528\u6587\u6848`),/\{\{|\}\}/.test(c.css)&&n.push(`HTML ${c.id} \u7684 CSS \u4E0D\u652F\u6301\u53D8\u91CF`)}c.type==="stack"&&c.bind?.picker&&kt(e,c.bind.picker)?.type!=="plan_picker"&&n.push(`\u5BB9\u5668 ${c.id} \u5F15\u7528\u7684\u5957\u9910\u9009\u62E9\u4E0D\u5B58\u5728`)});for(let c of e.actions)c.type==="purchase"&&c.picker&&kt(e,c.picker)?.type!=="plan_picker"&&n.push(`\u8D2D\u4E70\u52A8\u4F5C ${c.id} \u5F15\u7528\u7684\u5957\u9910\u9009\u62E9\u4E0D\u5B58\u5728`),c.type==="purchase"&&c.channel==="native"&&n.push("\u539F\u751F\u5E94\u7528\u5185\u8D2D\u4E70\u5C1A\u672A\u63A5\u5165\uFF0C\u8BF7\u4F7F\u7528 Web \u7ED3\u8D26");let m=Ln(e);for(let c of m)c.complete||(c.locale===e.strings.defaultLocale?n.push(`\u9ED8\u8BA4\u8BED\u8A00 ${c.locale} \u8FD8\u6709 ${c.missing.length} \u5904\u5185\u5BB9\u6CA1\u586B`):n.push(`${c.locale} \u8FD8\u6709 ${c.missing.length} \u5904\u6CA1\u7FFB\u8BD1\uFF0C\u8BF7\u8865\u9F50\u6216\u5220\u9664\u8FD9\u79CD\u8BED\u8A00\u540E\u53D1\u5E03`));jt(e).length===0&&!e.pages.some(c=>Oi(c.root))&&n.push("\u5F39\u7A97\u91CC\u8FD8\u6CA1\u6709\u53EF\u663E\u793A\u7684\u5185\u5BB9");let d=new Set;le(e,c=>{c.type==="button"&&d.add(c.action)});for(let c of e.actions)!d.has(c.id)&&!e.pages.some(k=>_i(k.root,c.id))&&i.push(`\u52A8\u4F5C ${c.id} \u6CA1\u6709\u88AB\u4EFB\u4F55\u6309\u94AE\u4F7F\u7528`);return{errors:n,warnings:i}}function Oi(e){let t=!1;return $e(e,n=>{if(n.hidden)return!1;n.type==="image"&&(t=!0)}),t}function _i(e,t){let n=!1;return $e(e,r=>{if(r.type==="custom_html")for(let o of Object.values(r.html))o.includes(`data-grow-action="${t}"`)&&(n=!0)}),n}function Ti(e){return Ln(e).filter(t=>t.complete||t.locale===e.strings.defaultLocale).map(t=>t.locale)}function ys(e,t){return Je(t,Ti(e),e.strings.defaultLocale)}function xs(e,t){let n=e.strings.locales[t]??{},r=e.strings.locales[e.strings.defaultLocale]??{},o={};for(let a of jt(e)){if(a.field==="html"||a.field==="src")continue;let m=n[a.key]?.trim()?n[a.key]:r[a.key];m!==void 0&&(o[a.key]=m)}let i=a=>{if(a.type==="stack")return{...a,children:a.children.map(i)};if(a.type==="custom_html"){let m=a.html[t]?.trim()?a.html[t]:a.html[e.strings.defaultLocale];return{...a,html:m===void 0?{}:{[t]:m}}}if(a.type==="image"){let{localizedSrc:m,...d}=a;return{...d,src:m?.[t]??m?.[e.strings.defaultLocale]??a.src}}return a};return{...e,pages:e.pages.map(a=>({...a,root:i(a.root)})),strings:{defaultLocale:t,locales:{[t]:o}}}}function Ri(e,t){let n=null;return $e(e,r=>{if(n)return!1;r.id===t&&(n=r)}),n}function kt(e,t){for(let n of e.pages){let r=Ri(n.root,t);if(r)return r}return null}function Ss(e){let t=me(e)?.split("-")[0];return t!==void 0&&["ar","he","fa","ur"].includes(t)}function Is(e,t,n){let r={};if(!t||typeof t!="object"||Array.isArray(t))return r;let o=t;return le(e,i=>{if(i.type==="plan_picker"){let m=o[i.id];typeof m=="string"&&n?.pickers[i.id]?.options.includes(m)&&(r[i.id]=m);return}if(i.type!=="stack"||!i.interaction)return;let a=Object.hasOwn(o,i.id)?o[i.id]:void 0;["select","tabs"].includes(i.interaction.type)&&typeof a=="string"&&i.children.some(m=>m.id===a)&&(r[i.id]=a),i.interaction.type==="toggle"&&typeof a=="boolean"&&(r[i.id]=a)}),r}import{z as g}from"zod";var Ae=1,js=g.enum(["stripe","apple","google"]),Ee=g.enum(["membership","credit_pack"]),As=g.enum(["active","grace","suspended","inactive","revoked"]),Di=g.strictObject({projectId:g.uuid(),environment:Pe}),ne=g.string().min(1).max(256),Vn=g.iso.datetime(),ws=g.strictObject({currency:g.string().regex(/^[A-Z]{3}$/),micros:g.string().regex(/^(0|[1-9][0-9]{0,29})$/)}),Ni=g.discriminatedUnion("provider",[g.strictObject({provider:g.literal("stripe"),priceId:ne,productId:ne}),g.strictObject({provider:g.literal("apple"),productId:ne}),g.strictObject({provider:g.literal("google"),productId:ne,basePlanId:ne.nullable(),offerId:ne.nullable()})]),zs=g.strictObject({id:g.uuid(),deliveryVersionId:g.uuid(),kind:Ee,binding:Ni,purchaseEnabled:g.boolean()}),Mn=g.strictObject({protocolVersion:g.literal(Ae),bindingId:g.uuid(),idempotencyKey:g.uuid()}),$i=g.discriminatedUnion("provider",[g.strictObject({provider:g.literal("stripe"),checkoutUrl:g.url()}),g.strictObject({provider:g.literal("apple"),productId:ne,appAccountToken:g.uuid()}),g.strictObject({provider:g.literal("google"),productId:ne,basePlanId:ne.nullable(),offerId:ne.nullable(),obfuscatedAccountId:g.string().regex(/^[A-Za-z0-9_-]{1,64}$/),obfuscatedProfileId:g.uuid()})]),Un=g.strictObject({protocolVersion:g.literal(Ae),id:g.uuid(),scope:Di,expiresAt:Vn,nextStep:$i,submissionTicket:g.string().regex(/^gg_pt_[A-Za-z0-9_-]{43}$/).nullable()}).superRefine((e,t)=>{e.nextStep.provider!=="stripe"&&e.submissionTicket===null&&t.addIssue({code:"custom",message:"Native purchase intent requires its original submission capability",path:["submissionTicket"]});let n=e.nextStep.provider==="apple"?e.nextStep.appAccountToken:e.nextStep.provider==="google"?e.nextStep.obfuscatedProfileId:null;n!==null&&n.toLowerCase()!==e.id.toLowerCase()&&t.addIssue({code:"custom",message:"Native store context must identify this purchase intent",path:["nextStep"]})}),At=g.discriminatedUnion("provider",[g.strictObject({provider:g.literal("apple"),signedTransaction:g.string().min(1).max(32768)}),g.strictObject({provider:g.literal("google"),purchaseToken:g.string().min(1).max(4096)})]),Ps=g.strictObject({protocolVersion:g.literal(Ae),intentId:g.uuid(),evidence:At}),Os=g.strictObject({protocolVersion:g.literal(Ae),intentId:g.uuid(),state:g.enum(["ready","pending","processing","fulfilled","rejected","ownership_conflict"]),purchaseId:g.uuid().nullable(),finishTransactionKeys:g.array(g.string().min(1).max(256)).max(50),retryAt:Vn.nullable()}).superRefine((e,t)=>{e.state!=="fulfilled"&&e.finishTransactionKeys.length>0&&t.addIssue({code:"custom",message:"Only durable fulfillment can finish transactions",path:["finishTransactionKeys"]}),e.state==="fulfilled"&&e.purchaseId===null&&t.addIssue({code:"custom",message:"Fulfillment requires a purchase record",path:["purchaseId"]}),e.state==="ownership_conflict"&&e.purchaseId!==null&&t.addIssue({code:"custom",message:"Ownership conflicts cannot disclose another purchase",path:["purchaseId"]})}),Hn=g.strictObject({protocolVersion:g.literal(Ae),evidence:g.array(g.discriminatedUnion("provider",[At.options[0],At.options[1].extend({productId:ne})])).min(1).max(50)}),Bn=g.strictObject({protocolVersion:g.literal(Ae),results:g.array(g.strictObject({index:g.number().int().nonnegative(),state:g.enum(["restored","processing","pending_claim","ownership_conflict","rejected","unsupported"]),purchaseId:g.uuid().nullable(),finishTransactionKeys:g.array(g.string().min(1).max(256)).max(50)}).superRefine((e,t)=>{e.state!=="restored"&&e.finishTransactionKeys.length>0&&t.addIssue({code:"custom",message:"Only restored purchases can finish transactions",path:["finishTransactionKeys"]}),e.state==="restored"&&e.purchaseId===null&&t.addIssue({code:"custom",message:"Restoration requires a purchase record",path:["purchaseId"]}),["ownership_conflict","pending_claim"].includes(e.state)&&e.purchaseId!==null&&t.addIssue({code:"custom",message:"Unowned purchases cannot disclose a purchase record",path:["purchaseId"]})})).min(1).max(50).superRefine((e,t)=>{(new Set(e.map(r=>r.index)).size!==e.length||e.some(r=>r.index>=e.length))&&t.addIssue({code:"custom",message:"Restoration must cover every input index exactly once"})})});import{z as S}from"zod";var Kn=S.union([S.string().max(500),S.number().finite(),S.boolean()]),Zn=e=>{let t=S.record(S.string().min(1).max(80),e);return S.custom(n=>n!==null&&typeof n=="object"&&!Array.isArray(n)&&!Object.hasOwn(n,"__proto__"),"\u5C5E\u6027\u952E\u4E0D\u53EF\u7528").pipe(t).refine(n=>Object.keys(n).length<=30,"\u6700\u591A 30 \u4E2A\u5C5E\u6027").refine(n=>new TextEncoder().encode(JSON.stringify(n)).length<=16384,"\u5C5E\u6027\u5185\u5BB9\u8FC7\u5927")},Gn=Zn(Kn),Wn=Zn(Kn.nullable()),wt=S.array(S.string().trim().min(1).max(40).refine(e=>!e.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7")).max(20).refine(e=>new Set(e).size===e.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D"),zt=S.string().trim().max(80),Pt=S.union([S.email().max(254),S.literal("")]),Jn=S.object({externalUserId:S.string().trim().min(1).max(255),name:zt.default(""),email:Pt.default(""),tags:wt.default([]),metadata:Wn.default({})}).strict(),qe=S.object({id:S.uuid(),externalUserId:S.string().min(1).max(255),name:zt,email:Pt,metadata:Gn,tags:wt,revision:S.number().int().nonnegative(),createdAt:S.iso.datetime(),updatedAt:S.iso.datetime()}),Qn=S.object({customer:qe,changed:S.boolean(),replayed:S.boolean()}),Ei=S.discriminatedUnion("type",[S.object({type:S.literal("id"),value:S.uuid()}).strict(),S.object({type:S.literal("externalUserId"),value:S.string().trim().min(1).max(255)}).strict()]),qi=S.object({name:zt.optional(),email:Pt.optional(),tags:wt.optional(),metadata:Wn.optional()}).strict().refine(e=>Object.keys(e).length>0,"\u8BF7\u63D0\u4F9B\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"),Ot=S.object({lookup:Ei}).strict(),Yn=Ot.extend({revision:S.number().int().nonnegative(),requestId:S.uuid(),patch:qi}).strict(),Xn=S.object({search:S.string().trim().max(200).default(""),tag:S.string().trim().max(40).default(""),planId:S.union([S.uuid(),S.literal("")]).default(""),versionId:S.union([S.uuid(),S.literal("")]).default(""),holdingStatus:S.enum(["","active","scheduled","expired","unavailable","none"]).default(""),subscriptionStatus:S.enum(["","active","trialing","past_due","unpaid","incomplete","canceled","incomplete_expired","paused"]).default(""),createdFrom:S.union([S.iso.datetime(),S.literal("")]).default(""),createdUntil:S.union([S.iso.datetime(),S.literal("")]).default(""),offset:S.coerce.number().int().min(0).max(1e5).default(0),limit:S.coerce.number().int().min(1).max(100).default(50)}).strict(),er=S.object({customers:qe.array(),hasMore:S.boolean(),total:S.number().int().nonnegative().nullable(),evaluatedAt:S.iso.datetime()});function Rs(e,t){let n={...e};for(let[r,o]of Object.entries(t))o===null?delete n[r]:Object.defineProperty(n,r,{value:o,enumerable:!0,writable:!0,configurable:!0});return Gn.parse(n)}import{z as D}from"zod";var tr=D.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ls=D.object({enabled:D.boolean(),trigger:tr,tags:D.array(D.string().trim().min(1).max(40).refine(e=>!e.includes(","))).max(20).refine(e=>new Set(e).size===e.length),priority:D.number().int().min(-1e3).max(1e3),cooldownHours:D.number().int().min(0).max(720)}).strict(),Fi=D.object({id:D.uuid(),campaignId:D.uuid(),versionId:D.uuid(),popup:B,capabilities:ve.optional(),locale:G,expiresAt:D.iso.datetime()}),nr=Fi.extend({popup:B.nullable(),contentTag:ke,capabilities:ve}),rr=D.object({locale:D.string().max(35).optional(),acceptLanguages:D.array(D.string().max(35)).max(10).optional()}),ir=D.discriminatedUnion("type",[D.object({eventId:D.uuid(),deliveryId:D.uuid(),type:D.literal("shown"),locale:G.optional()}).strict(),D.object({eventId:D.uuid(),deliveryId:D.uuid(),type:D.literal("action"),actionId:tr}).strict(),D.object({eventId:D.uuid(),deliveryId:D.uuid(),type:D.literal("closed"),reason:D.enum(["close_button","escape","action","destroy","timeout"])}).strict()]);var Li=l.enum(["customers:read","customers:write","plans:read","entitlements:read","sessions:create","offers:resolve","offers:grant","popups:resolve","billing:read","billing:write","events:write","credits:read","credits:consume","credits:manage"]),or={scope:te,permissions:l.array(Li),expiresAt:l.iso.datetime().nullable()},sc=l.discriminatedUnion("kind",[l.object({...or,kind:l.literal("server"),keyId:l.string().min(1)}),l.object({...or,kind:l.literal("customer"),customerId:l.string().min(1),entityId:l.uuid().nullable().optional(),expiresAt:l.iso.datetime()})]),_=l.object({requestId:l.uuid(),scope:te}),Vi=Jn.strict(),Mi=_.extend({customer:qe,created:l.boolean()}),Ui=_.extend({plans:l.array(Re)}),Hi=l.object({customerId:l.string().min(1).max(255).optional(),entityId:l.uuid().optional()}).strict(),Bi=l.enum(["unassigned","unknown","scheduled","active","expired"]),Ki=l.object({customerId:l.string().min(1),evaluatedAt:l.iso.datetime(),status:Bi,validity:ft.nullable(),planVersion:Re.nullable(),holdings:l.array(l.object({id:l.uuid(),planVersionId:l.uuid(),source:l.enum(["subscription","assignment","license","license_pool","entity_pool"])})).optional(),entitlements:l.array(l.object({featureId:l.string(),featureKey:l.string(),featureName:l.string(),type:l.enum(["boolean","metered"]),allowance:l.number().int().nonnegative().nullable(),used:l.number().finite().nonnegative(),remaining:l.number().finite().nonnegative().nullable(),allowed:l.boolean(),sources:l.array(l.object({holdingId:l.uuid(),planVersionId:l.uuid(),group:l.string(),kind:l.enum(["main","addon"]),allowance:l.number().nullable()})).optional()}))}),Zi=_.extend(Ki.shape),Gi=l.enum(["UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","INTERNAL_ERROR"]),cc=l.object({requestId:l.uuid(),error:l.object({code:Gi,message:l.string()})});function ar(){return _.extend({offer:Se.nullable(),reason:pn.nullable()})}var uc={getPage:{method:"POST",path:"pages/get",permission:"popups:resolve",audience:"customer",request:l.object({pageId:l.uuid(),locale:G.optional(),entityId:l.uuid().optional(),cachedContentTag:ke.optional()}).strict(),response:_.extend({pageId:l.uuid(),versionId:l.uuid(),locale:G,document:B.nullable(),contentTag:ke,capabilities:ve})},listOfferHistory:{method:"POST",path:"offers/history",permission:"offers:resolve",audience:"either",request:hn,response:_.extend(bn.shape)},getCustomerState:{method:"POST",path:"customer-state",permission:"entitlements:read",audience:"either",request:mn,response:_.extend({state:dn})},listCustomerPlans:{method:"POST",path:"customer-plans",permission:"plans:read",audience:"either",request:fn,response:_.extend(gn.shape)},getTrialEligibility:{method:"POST",path:"memberships/trial/eligibility",permission:"billing:read",audience:"customer",request:l.object({planVersionId:l.uuid()}).strict(),response:_.extend({eligibility:Be})},startTrial:{method:"POST",path:"memberships/trial",permission:"billing:write",audience:"customer",request:Wt,response:_.extend({trial:be,checkout:l.object({checkoutId:l.uuid(),url:l.url()}).nullable(),discount:l.object({couponId:l.uuid(),offerId:l.uuid().nullable(),promotionCode:l.string().nullable()}).nullable().optional()})},restorePurchases:{method:"POST",path:"purchases/restore",permission:"billing:write",audience:"customer",request:Hn,response:_.extend(Bn.shape)},createPurchaseIntent:{method:"POST",path:"purchases/intents",permission:"billing:write",audience:"customer",request:Mn,response:_.extend({intent:Un})},getEntities:{method:"POST",path:"entities/list",permission:"customers:read",audience:"server",request:Nt,response:_.extend({state:Ue})},manageEntity:{method:"POST",path:"entities/manage",permission:"customers:write",audience:"server",request:$t,response:_.extend({state:Ue})},manageLicense:{method:"POST",path:"licenses/manage",permission:"billing:write",audience:"server",request:Et,response:_.extend({state:Ue,billing:l.object({status:l.enum(["payment_pending","scheduled","completed"]),paymentUrl:l.url().nullable(),effectiveAt:l.iso.datetime().nullable()}).optional()})},listCreditPacks:{method:"POST",path:"credits/packs",permission:"credits:read",audience:"either",request:Q,response:_.extend({packs:l.array(In)})},listCreditPackOrders:{method:"POST",path:"credits/packs/orders",permission:"credits:read",audience:"either",request:kn,response:_.extend({orders:l.array(yt),nextCursor:oe.nullable()})},createCreditPackCheckout:{method:"POST",path:"credits/packs/checkout",permission:"billing:write",audience:"either",request:vn,response:_.extend({orderId:l.uuid(),url:l.url()})},listCreditTransactions:{method:"POST",path:"credits/transactions",permission:"credits:read",audience:"either",request:Zt,response:_.extend(Gt.shape)},getBalances:{method:"POST",path:"credits/balances",permission:"credits:read",audience:"either",request:Q,response:_.extend({account:Vt})},checkCredits:{method:"POST",path:"credits/check",permission:"credits:read",audience:"either",request:st,response:_.extend(Mt.shape)},consumeCredits:{method:"POST",path:"credits/consume",permission:"credits:consume",audience:"server",request:ct,response:_.extend(ge.shape)},reserveCredits:{method:"POST",path:"credits/reserve",permission:"credits:consume",audience:"server",request:Ut,response:_.extend(ge.shape)},finalizeCredits:{method:"POST",path:"credits/finalize",permission:"credits:consume",audience:"server",request:Ht,response:_.extend(ge.shape)},refundCredits:{method:"POST",path:"credits/refund",permission:"credits:manage",audience:"server",request:Bt,response:_.extend(ge.shape)},grantCredits:{method:"POST",path:"credits/grant",permission:"credits:manage",audience:"server",request:Kt,response:_.extend(ge.shape)},refreshSurface:{method:"POST",path:"surfaces/context",permission:"popups:resolve",audience:"customer",request:l.object({deliveryId:l.uuid(),locale:l.string().max(35).optional(),currency:L.optional()}).strict(),response:_.extend({capabilities:ve})},purchaseSurface:{method:"POST",path:"surfaces/purchase",permission:"billing:write",audience:"customer",request:l.object({deliveryId:l.uuid(),actionId:l.string().min(1).max(64),nodeId:l.string().min(1).max(64),planId:l.uuid().optional(),currency:L.optional(),requestId:l.uuid()}).strict(),response:_.extend({checkoutId:l.uuid().nullable(),url:l.url().nullable(),trial:be.optional(),discount:l.object({couponId:l.uuid(),offerId:l.uuid().nullable(),promotionCode:l.string().nullable()}).nullable()})},createCheckout:{method:"POST",path:"billing/checkout",permission:"billing:write",audience:"customer",request:l.object({planVersionId:l.uuid(),currency:L.optional(),requestId:l.uuid(),licenseQuantities:Me.optional(),offerId:l.uuid().optional(),promotionCode:l.string().trim().min(3).max(32).transform(e=>e.toUpperCase()).optional()}).strict().refine(e=>!(e.offerId&&e.promotionCode),{message:"Use either offerId or promotionCode"}),response:_.extend({checkoutId:l.uuid(),url:l.url(),discount:l.object({couponId:l.uuid(),offerId:l.uuid().nullable(),promotionCode:l.string().nullable()}).nullable()})},getMemberships:{method:"GET",path:"memberships",permission:"billing:read",audience:"customer",request:l.object({entityId:l.uuid().optional()}).strict(),response:_.extend({membership:Ke})},previewMembership:{method:"POST",path:"memberships/preview",permission:"billing:read",audience:"customer",request:mt,response:_.extend({preview:Jt})},manageMembership:{method:"POST",path:"memberships/manage",permission:"billing:write",audience:"customer",request:mt,response:_.extend(Yt.shape)},listSubscriptions:{method:"GET",path:"billing/subscriptions",permission:"billing:read",audience:"customer",request:l.object({}).strict(),response:_.extend({subscriptions:l.array(l.object({id:l.uuid(),status:l.string(),planVersionId:l.uuid().nullable(),startsAt:l.iso.datetime(),endsAt:l.iso.datetime(),cancelAtPeriodEnd:l.boolean(),accessEnabled:l.boolean()}))})},resolvePopup:{method:"POST",path:"popups/resolve",permission:"popups:resolve",audience:"customer",request:rr.extend({currency:L.optional(),trigger:l.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),requestId:l.uuid(),cachedContentTag:ke.optional()}).strict(),response:_.extend({delivery:nr.nullable()})},trackPopup:{method:"POST",path:"popups/events",permission:"events:write",audience:"customer",request:ir,response:_.extend({accepted:l.literal(!0)})},createCustomer:{method:"POST",path:"customers",permission:"customers:write",audience:"server",request:Vi,response:Mi},getCustomer:{method:"POST",path:"customers/get",permission:"customers:read",audience:"server",request:Ot,response:_.extend({customer:qe})},listCustomers:{method:"POST",path:"customers/list",permission:"customers:read",audience:"server",request:Xn,response:_.extend(er.shape)},updateCustomer:{method:"POST",path:"customers/update",permission:"customers:write",audience:"server",request:Yn,response:_.extend(Qn.shape)},listPlans:{method:"GET",path:"plans",permission:"plans:read",audience:"either",request:l.object({}).strict(),response:Ui},getEntitlements:{method:"POST",path:"entitlements",permission:"entitlements:read",audience:"either",request:Hi,response:Zi},createSession:{method:"POST",path:"customer-sessions",permission:"sessions:create",audience:"server",request:l.object({customerId:l.string().min(1),entityId:l.uuid().optional()}).strict(),response:_.extend({customerToken:l.string().min(1),expiresAt:l.iso.datetime()})},listOffers:{method:"GET",path:"offers",permission:"offers:resolve",audience:"customer",request:l.object({}).strict(),response:_.extend({offers:l.array(Se)})},claimOffer:{method:"POST",path:"offers/claim",permission:"offers:resolve",audience:"customer",request:l.object({deliveryId:l.uuid(),actionId:l.string().min(1).max(64),couponId:l.uuid(),requestId:l.uuid()}).strict(),response:ar()},grantOffer:{method:"POST",path:"offers/grant",permission:"offers:grant",audience:"server",request:l.object({customerId:l.string().min(1).max(255),couponId:l.uuid(),requestId:l.uuid()}).strict(),response:ar()}};var ur={primary:"#2C3C96",background:"#FFFFFF",text:"#1B1D24",radius:"md",font:"system"},Fe=(e,t,n,r,o)=>({kind:"screen",schemaVersion:3,name:e,surface:"popup",presentation:{type:"modal",size:"md"},theme:{...ur},pages:[{id:"main",name:"\u4E3B\u9875\u9762",root:t}],strings:{defaultLocale:"zh-CN",locales:{"zh-CN":n,en:r}},actions:o}),we=e=>({type:"stack",id:"root",direction:"vertical",align:"stretch",justify:"start",children:e,style:{gap:12,padding:{top:24,right:24,bottom:24,left:24}}}),et={id:"dismiss",type:"close",event:"popup.dismissed",properties:{},close:!0},sr=[{id:"blank",label:"\u7A7A\u767D",description:"\u4E00\u4E2A\u6807\u9898\u548C\u4E00\u4E2A\u6309\u94AE\uFF0C\u4ECE\u96F6\u5F00\u59CB\u642D\u3002",document:Fe("\u672A\u547D\u540D\u5F39\u7A97",we([{type:"text",id:"title",text:"title",variant:"heading"},{type:"button",id:"cta",label:"cta",variant:"primary",action:"dismiss",style:{width:"fill"}}]),{title:"\u6807\u9898",cta:"\u77E5\u9053\u4E86"},{title:"Title",cta:"Got it"},[et])},{id:"announcement",label:"\u516C\u544A",description:"\u65B0\u529F\u80FD\u6216\u91CD\u8981\u901A\u77E5\uFF0C\u4E00\u4E2A\u4E3B\u6309\u94AE\u3002",document:Fe("\u65B0\u529F\u80FD\u516C\u544A",we([{type:"text",id:"eyebrow",text:"eyebrow",variant:"caption",style:{text:{color:"primary",weight:700}}},{type:"text",id:"title",text:"title",variant:"heading"},{type:"text",id:"body",text:"body",variant:"body",style:{text:{color:"muted"}}},{type:"button",id:"cta",label:"cta",variant:"primary",action:"learn_more",style:{width:"fill"}},{type:"button",id:"later",label:"later",variant:"link",action:"dismiss",style:{width:"fill"}}]),{eyebrow:"\u65B0\u529F\u80FD",title:"\u73B0\u5728\u53EF\u4EE5\u4E00\u952E\u5BFC\u51FA\u62A5\u8868",body:"\u5728\u4EFB\u610F\u6570\u636E\u9875\u70B9\u51FB\u53F3\u4E0A\u89D2\u300C\u5BFC\u51FA\u300D\uFF0C\u5373\u53EF\u4E0B\u8F7D CSV \u6216 PDF\u3002",cta:"\u53BB\u770B\u770B",later:"\u4EE5\u540E\u518D\u8BF4"},{eyebrow:"NEW",title:"Export reports in one click",body:"Click Export on any data page to download a CSV or PDF.",cta:"Take a look",later:"Not now"},[{id:"learn_more",type:"event",event:"announcement_clicked",properties:{},close:!0},et])},{id:"upgrade",label:"\u5347\u7EA7\u5230 Pro",description:"\u5217\u51FA\u51E0\u9879\u6743\u76CA\uFF0C\u5F15\u5BFC\u5347\u7EA7\u3002",document:Fe("\u5347\u7EA7\u5230 Pro",we([{type:"text",id:"eyebrow",text:"eyebrow",variant:"caption",style:{text:{color:"primary",weight:700}}},{type:"text",id:"title",text:"title",variant:"heading"},{type:"stack",id:"benefits",name:"\u6743\u76CA\u5217\u8868",direction:"vertical",align:"stretch",justify:"start",children:[{type:"text",id:"benefit1",text:"benefit1",variant:"body"},{type:"text",id:"benefit2",text:"benefit2",variant:"body"},{type:"text",id:"benefit3",text:"benefit3",variant:"body"}],style:{background:{type:"color",color:"surface"},shape:{type:"rect",radius:8},gap:4,padding:{top:16,right:16,bottom:16,left:16}}},{type:"button",id:"cta",label:"cta",variant:"primary",action:"upgrade",style:{width:"fill"}},{type:"button",id:"later",label:"later",variant:"link",action:"dismiss",style:{width:"fill"}}]),{eyebrow:"PRO",title:"\u89E3\u9501\u5168\u90E8\u9AD8\u7EA7\u529F\u80FD",benefit1:"\u2713 \u65E0\u9650\u9879\u76EE\u4E0E\u6210\u5458",benefit2:"\u2713 \u9AD8\u7EA7\u6570\u636E\u5206\u6790",benefit3:"\u2713 \u4F18\u5148\u5BA2\u670D\u652F\u6301",cta:"\u67E5\u770B Pro \u65B9\u6848",later:"\u7EE7\u7EED\u4F7F\u7528\u514D\u8D39\u7248"},{eyebrow:"PRO",title:"Unlock every advanced feature",benefit1:"\u2713 Unlimited projects and members",benefit2:"\u2713 Advanced analytics",benefit3:"\u2713 Priority support",cta:"See Pro plans",later:"Stay on Free"},[{id:"upgrade",type:"event",event:"checkout_requested",properties:{planId:"pro"},close:!0},et])},{id:"offer",label:"\u9650\u65F6\u4F18\u60E0",description:"\u6E10\u53D8\u5934\u56FE + \u89D2\u6807 + \u539F\u4EF7\u5212\u7EBF\u7684\u4F18\u60E0\u4EF7\uFF0C\u9002\u5408\u9886\u5238\u5F39\u7A97\u3002",document:{...Fe("\u9650\u65F6\u4F18\u60E0",{type:"stack",id:"root",direction:"vertical",align:"stretch",justify:"start",children:[{type:"stack",id:"hero",name:"\u5934\u56FE",direction:"overlay",align:"start",justify:"start",children:[{type:"stack",id:"heroContent",name:"\u5934\u56FE\u5185\u5BB9",direction:"vertical",align:"center",justify:"center",children:[{type:"text",id:"eyebrow",text:"eyebrow",variant:"caption",style:{width:"fit",padding:{top:3,right:10,bottom:3,left:10},background:{type:"color",color:"#FFFFFF2E"},shape:{type:"pill"},text:{color:"#FFFFFF",weight:700,letterSpacing:1,align:"center"}}},{type:"text",id:"title",text:"title",variant:"title",style:{text:{size:40,weight:900,color:"#FFFFFF",align:"center",lineHeight:1.1}}},{type:"text",id:"subtitle",text:"subtitle",variant:"body",style:{text:{size:14,color:"#FFFFFFD9",align:"center"}}}],style:{width:"fill",padding:{top:32,right:24,bottom:28,left:24},gap:6}},{type:"text",id:"badge",name:"\u89D2\u6807",text:"badge",variant:"caption",style:{width:"fit",margin:{top:14,right:0,bottom:0,left:14},padding:{top:4,right:10,bottom:4,left:10},background:{type:"color",color:"#FFD84D"},shape:{type:"pill"},shadow:{x:0,y:4,blur:10,spread:0,color:"#00000026"},text:{color:"#3A1D00",weight:800,size:13}}}],style:{gap:0,padding:{top:0,right:0,bottom:0,left:0},background:{type:"linear",angle:135,stops:[{color:"#FF7A45",at:0},{color:"#E8336D",at:100}]}}},{type:"stack",id:"body",name:"\u4EF7\u683C\u4E0E\u6309\u94AE",direction:"vertical",align:"stretch",justify:"start",children:[{type:"stack",id:"price",name:"\u4EF7\u683C",direction:"horizontal",align:"end",justify:"center",children:[{type:"text",id:"newPrice",text:"newPrice",variant:"title",style:{text:{size:34,weight:800,color:"#E8336D",lineHeight:1}}},{type:"text",id:"period",text:"period",variant:"body",style:{text:{color:"muted",size:14,lineHeight:1.6}}},{type:"text",id:"oldPrice",text:"oldPrice",variant:"body",style:{text:{color:"muted",size:15,decoration:"line-through",lineHeight:1.6}}}],style:{gap:8,padding:{top:0,right:0,bottom:0,left:0}}},{type:"text",id:"then",text:"then",variant:"caption",style:{text:{color:"muted",align:"center"}}},{type:"button",id:"cta",label:"cta",variant:"primary",action:"claim",style:{width:"fill",height:52,background:{type:"linear",angle:90,stops:[{color:"#FF7A45",at:0},{color:"#E8336D",at:100}]},shape:{type:"pill"},shadow:{x:0,y:10,blur:24,spread:-6,color:"#E8336D66"},text:{size:17,weight:800,color:"#FFFFFF"}}},{type:"button",id:"later",label:"later",variant:"link",action:"dismiss",style:{width:"fill"}}],style:{gap:14,padding:{top:22,right:24,bottom:22,left:24}}}],style:{gap:0,padding:{top:0,right:0,bottom:0,left:0}}},{eyebrow:"\u9650\u65F6 48 \u5C0F\u65F6",title:"\u9996\u6708 7 \u6298",subtitle:"\u65B0\u7528\u6237\u4E13\u4EAB \xB7 \u9886\u53D6\u540E 3 \u5929\u5185\u6709\u6548",badge:"-30%",newPrice:"$20.30",period:"/\u9996\u6708",oldPrice:"$29",then:"\u4E4B\u540E\u6BCF\u6708 $29\uFF0C\u53EF\u968F\u65F6\u53D6\u6D88",cta:"\u7ACB\u5373\u9886\u53D6",later:"\u6682\u4E0D\u9700\u8981"},{eyebrow:"48 HOURS ONLY",title:"30% off",subtitle:"For new members \xB7 valid 3 days after claiming",badge:"-30%",newPrice:"$20.30",period:"/first month",oldPrice:"$29",then:"Then $29/month. Cancel anytime.",cta:"Claim offer",later:"Not now"},[{id:"claim",type:"event",event:"offer_claimed",properties:{discount:30},close:!0},et]),theme:{...ur,primary:"#E8336D",radius:"lg"}}},{id:"feedback",label:"\u6536\u96C6\u53CD\u9988",description:"\u4E24\u4E2A\u9009\u9879\u6309\u94AE\uFF0C\u8BB0\u5F55\u7528\u6237\u7684\u9009\u62E9\u3002",document:Fe("\u6EE1\u610F\u5EA6\u8C03\u67E5",we([{type:"text",id:"title",text:"title",variant:"heading",style:{text:{align:"center"}}},{type:"text",id:"body",text:"body",variant:"body",style:{text:{align:"center",color:"muted"}}},{type:"stack",id:"choices",name:"\u9009\u9879",direction:"horizontal",align:"stretch",justify:"center",children:[{type:"button",id:"yes",label:"yes",variant:"secondary",action:"positive",style:{width:"fill"}},{type:"button",id:"no",label:"no",variant:"secondary",action:"negative",style:{width:"fill"}}],style:{gap:8,padding:{top:0,right:0,bottom:0,left:0}}}]),{title:"\u8FD9\u4E2A\u529F\u80FD\u5BF9\u4F60\u6709\u5E2E\u52A9\u5417\uFF1F",body:"\u4F60\u7684\u53CD\u9988\u4F1A\u76F4\u63A5\u5F71\u54CD\u6211\u4EEC\u4E0B\u4E00\u6B65\u505A\u4EC0\u4E48\u3002",yes:"\u6709\u5E2E\u52A9",no:"\u6CA1\u5E2E\u52A9"},{title:"Was this feature helpful?",body:"Your answer shapes what we build next.",yes:"Yes",no:"No"},[{id:"positive",type:"event",event:"feedback_submitted",properties:{helpful:!0},close:!0},{id:"negative",type:"event",event:"feedback_submitted",properties:{helpful:!1},close:!0}])}];function tt(e="blank"){let t=sr.find(n=>n.id===e)??sr[0];return structuredClone(t.document)}var cr=(e,t,n)=>({type:"stack",id:e,name:"Web \u81EA\u9002\u5E94\u5E03\u5C40",direction:"horizontal",align:"center",justify:"center",children:[{...we(t),id:`${e}_intro`,name:"\u4ECB\u7ECD",style:{width:480,gap:20,padding:{top:0,right:0,bottom:0,left:0}}},{...we(n),id:`${e}_detail`,name:"\u5185\u5BB9\u4E0E\u64CD\u4F5C",style:{width:400,gap:20,padding:{top:24,right:24,bottom:24,left:24},background:{type:"color",color:"surface"},shape:{type:"rect",radius:8}}}],style:{gap:40,padding:{top:40,right:24,bottom:40,left:24}}});function pc(e,t="blank"){let n=tt(t);if(e==="popup"||(n.surface=e,n.presentation={type:"fullscreen"},e==="page"))return n;if(e==="paywall"){let o=tt("upgrade");o.actions=o.actions.map(a=>a.id==="upgrade"&&a.type==="event"?{...a,event:"paywall.upgrade_clicked",properties:{},close:!1}:a),o.strings.locales["zh-CN"].cta="\u4E86\u89E3\u5347\u7EA7\u65B9\u6848",o.strings.locales.en.cta="Explore upgrade options",o.strings.locales["zh-CN"].body="\u4E3A\u4F60\u7684\u5DE5\u4F5C\u533A\u9009\u62E9\u9002\u5408\u7684\u529F\u80FD\u4E0E\u534F\u4F5C\u65B9\u5F0F\u3002",o.strings.locales.en.body="Find the right features and collaboration tools for your workspace.";let i=o.pages[0].root.children;return o.pages[0].root=cr("root",[...i.slice(0,2),{type:"text",id:"body",text:"body",variant:"body",style:{text:{color:"muted"}}}],i.slice(2)),{...o,surface:e,presentation:{type:"fullscreen"},name:"\u9AD8\u7EA7\u529F\u80FD\u4ED8\u8D39\u5899"}}n.name="\u65B0\u7528\u6237\u5F15\u5BFC",n.pages=[],n.actions=[],n.strings.locales={"zh-CN":{},en:{}};let r=[["\u6B22\u8FCE\u4F7F\u7528","\u4ECE\u8FD9\u91CC\u5F00\u59CB\uFF0C\u4E86\u89E3\u4F60\u53EF\u4EE5\u5B8C\u6210\u4EC0\u4E48\u3002","Welcome","Discover what you can do here."],["\u627E\u5230\u9002\u5408\u4F60\u7684\u65B9\u5F0F","\u6309\u81EA\u5DF1\u7684\u8282\u594F\u63A2\u7D22\uFF0C\u968F\u65F6\u8C03\u6574\u3002","Make it yours","Explore at your own pace."],["\u4E00\u5207\u51C6\u5907\u5C31\u7EEA","\u5F00\u59CB\u4F60\u7684\u7B2C\u4E00\u6B21\u4F53\u9A8C\u3002","You're ready","Start your first experience."]];for(let o=0;o<r.length;o++){let i=`step${o+1}`,[a,m,d,c]=r[o],k=cr(`${i}_root`,[{type:"text",id:`${i}_step`,text:`${i}.step`,variant:"caption",style:{text:{color:"primary",weight:700}}},{type:"text",id:`${i}_title`,text:`${i}.title`,variant:"title"},{type:"text",id:`${i}_body`,text:`${i}.body`,variant:"body",style:{text:{color:"muted"}}}],[{type:"text",id:`${i}_detail_title`,text:`${i}.detail_title`,variant:"heading"},{type:"text",id:`${i}_detail_body`,text:`${i}.detail_body`,variant:"body",style:{text:{color:"muted"}}},{type:"divider",id:`${i}_divider`},{type:"stack",id:`${i}_controls`,name:"\u9875\u9762\u64CD\u4F5C",direction:"horizontal",align:"center",justify:"end",children:[...o?[{type:"button",id:`${i}_back`,label:"back",variant:"secondary",action:"go_back",style:{width:"fit"}}]:[],{type:"button",id:`${i}_cta`,label:`${i}.cta`,variant:"primary",action:`${i}_continue`,style:{width:"fit"}}],style:{gap:8,padding:{top:0,right:0,bottom:0,left:0}}}]);n.pages.push({id:i,name:`\u7B2C ${o+1} \u9875`,root:k}),Object.assign(n.strings.locales["zh-CN"],{[`${i}.title`]:a,[`${i}.body`]:m,[`${i}.cta`]:o===2?"\u5F00\u59CB\u4F7F\u7528":"\u7EE7\u7EED",[`${i}.step`]:`\u7B2C ${o+1} / 3 \u6B65`,[`${i}.detail_title`]:["\u4E86\u89E3\u5DE5\u4F5C\u533A","\u9009\u62E9\u4F7F\u7528\u65B9\u5F0F","\u5F00\u59CB\u4F53\u9A8C"][o],[`${i}.detail_body`]:["\u5148\u719F\u6089\u529F\u80FD\u4E0E\u5E38\u7528\u64CD\u4F5C\uFF0C\u518D\u8FDB\u5165\u4E0B\u4E00\u6B65\u3002","\u6839\u636E\u81EA\u5DF1\u7684\u5DE5\u4F5C\u4E60\u60EF\u8BBE\u7F6E\uFF0C\u4E4B\u540E\u4E5F\u53EF\u4EE5\u8C03\u6574\u3002","\u5F15\u5BFC\u5DF2\u5B8C\u6210\uFF0C\u70B9\u51FB\u4E0B\u65B9\u6309\u94AE\u8FDB\u5165\u5DE5\u4F5C\u533A\u3002"][o],back:"\u8FD4\u56DE"}),Object.assign(n.strings.locales.en,{[`${i}.title`]:d,[`${i}.body`]:c,[`${i}.cta`]:o===2?"Get started":"Continue",[`${i}.step`]:`Step ${o+1} of 3`,[`${i}.detail_title`]:["Explore your workspace","Choose how you work","Start exploring"][o],[`${i}.detail_body`]:["Learn the features and common actions before moving on.","Set up your workflow. You can adjust it later.","You're all set. Use the button below to enter your workspace."][o],back:"Back"}),n.actions.push(o===2?{id:`${i}_continue`,type:"event",event:"onboarding.completed",properties:{},close:!0}:{id:`${i}_continue`,type:"navigate",target:`step${o+2}`,event:"onboarding.next",properties:{},close:!1})}return n.actions.push({id:"go_back",type:"navigate",target:"back",event:"onboarding.back",properties:{},close:!1}),n}function gc(e){let t=tt();return{...t,name:`\u672A\u547D\u540D${Fn[e]}`,surface:e,presentation:e==="popup"?{type:"modal",size:"md"}:{type:"fullscreen"},pages:[{id:"main",name:e==="onboarding"?"\u5F00\u59CB":"\u4E3B\u9875\u9762",root:{...t.pages[0].root,name:"\u753B\u5E03",style:e==="popup"?{height:280}:{},children:[]}}],strings:{defaultLocale:"zh-CN",locales:{"zh-CN":{},en:{}}},actions:[]}}import{z as V}from"zod";var xc=V.object({id:V.uuid(),key:V.string().nullable(),label:V.string().min(1).max(80),description:V.string().max(300),category:V.string().min(1).max(40),tags:V.array(V.string().max(30)).max(10),surface:Ct,source:V.enum(["official","private"]),document:B,revision:V.number().int().positive(),archived_at:V.string().nullable(),created_at:V.string()}),Sc=V.object({projectId:V.uuid(),environmentId:V.uuid(),label:V.string().trim().min(1).max(80),description:V.string().trim().max(300),category:V.string().trim().min(1).max(40),document:B}),Ic=V.object({projectId:V.uuid(),environmentId:V.uuid(),id:V.uuid(),revision:V.number().int().positive()});import{z as p}from"zod";var lr=p.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),jc=p.discriminatedUnion("operation",[p.object({operation:p.literal("start"),campaignId:p.uuid(),requestId:p.uuid(),visitorToken:p.string().regex(/^gg_fv_[A-Za-z0-9_-]{43}$/).optional(),customerToken:p.string().regex(/^gg_ct_[A-Za-z0-9_-]{32,128}$/).optional(),locale:p.string().max(35).optional()}).strict(),p.object({operation:p.literal("revoke"),runId:p.uuid()}).strict(),p.object({operation:p.literal("get")}).strict(),p.object({operation:p.literal("link"),runToken:lr}).strict(),p.object({operation:p.literal("event"),eventId:p.uuid(),nodeId:p.string().max(64),type:p.enum(["enter","complete","close"]),back:p.boolean().optional()}).strict(),p.object({operation:p.literal("node"),nodeId:p.string().max(64),requestId:p.uuid(),outcome:p.enum(["begin","cancel","failure","confirm"]),customerToken:p.string().regex(/^gg_ct_[A-Za-z0-9_-]{32,128}$/).optional()}).strict()]),Wi=p.object({id:p.uuid(),campaignId:p.uuid(),versionId:p.uuid(),document:B,locale:p.string(),nodeId:p.string(),history:p.array(p.string()),status:p.enum(["running","completed","closed"]),customerId:p.uuid().nullable(),expiresAt:p.iso.datetime({offset:!0}),assignments:p.array(p.object({nodeId:p.string(),variantId:p.string(),target:p.string(),experimentId:p.uuid(),revision:p.number(),bucketVersion:p.number().int().positive(),excluded:p.boolean()}))}),Ac=p.object({run:Wi.optional(),runToken:lr.optional(),visitorToken:p.string().regex(/^gg_fv_[A-Za-z0-9_-]{43}$/).optional(),visitorExpiresAt:p.iso.datetime({offset:!0}).optional(),target:p.string().optional(),pending:p.boolean().optional(),trialTerms:p.string().min(1).max(2e3).optional(),checkout:p.object({checkoutId:p.uuid(),url:p.url()}).nullable().optional(),price:p.object({amountCents:p.number().int(),currency:p.string(),interval:p.string().nullable()}).optional(),accepted:p.boolean().optional()}),wc=p.object({references:p.array(p.object({id:p.uuid(),name:p.string(),versionId:p.uuid(),version:p.number(),document:B})).default([]),pages:p.array(p.object({id:p.uuid(),name:p.string(),versionId:p.uuid(),version:p.number(),document:B})).default([]),plans:p.array(p.object({id:p.uuid(),name:p.string(),amount_cents:p.number(),currency:p.string(),price_interval:p.string()})),experiments:p.array(p.object({id:p.uuid(),revision:p.number(),node_id:p.string(),bucket_version:p.number().int().positive(),status:p.enum(["draft","running","paused","ended"]),winner_variant_id:p.string().nullable().optional()}))}),zc=p.object({overall:p.object({entered:p.number(),completed:p.number(),authenticated:p.number(),authReached:p.number(),paid:p.number(),free:p.number()}),steps:p.array(p.object({node_id:p.string(),visitors:p.number()})),edges:p.array(p.object({node_id:p.string(),target:p.string(),visitors:p.number()})),currencies:p.array(p.object({currency:p.string(),grossCents:p.number(),refundCents:p.number()})),variants:p.array(p.object({experimentId:p.uuid(),revision:p.number(),variantId:p.string(),exposed:p.number(),completed:p.number(),paid:p.number(),exposedRuns:p.number().optional(),completedRuns:p.number().optional(),paidRuns:p.number().optional()}))});var _t={zh:["\u5168\u90E8\u4ED8\u8D39\u5957\u9910","\u6307\u5B9A\u5957\u9910","\u6240\u6709\u5BA2\u6237","\u4EC5\u9996\u8D2D","\u9700\u8981\u6807\u7B7E","\u5F00\u59CB","\u622A\u6B62","\u65E0\u622A\u6B62\u65E5\u671F","\u9886\u53D6\u540E\u6709\u6548","\u5C0F\u65F6","\u6BCF\u4EBA\u6B21\u6570","\u603B\u540D\u989D"],"zh-Hant":["\u5168\u90E8\u4ED8\u8CBB\u65B9\u6848","\u6307\u5B9A\u65B9\u6848","\u6240\u6709\u5BA2\u6236","\u50C5\u9996\u8CFC","\u9700\u8981\u6A19\u7C64","\u958B\u59CB","\u622A\u6B62","\u7121\u622A\u6B62\u65E5\u671F","\u9818\u53D6\u5F8C\u6709\u6548","\u5C0F\u6642","\u6BCF\u4EBA\u6B21\u6578","\u7E3D\u540D\u984D"],en:["All paid plans","Selected plans","All customers","First purchase only","Required tags","Starts","Ends","No end date","Valid after claim","hours","Uses per customer","Total limit"],ja:["\u5168\u6709\u6599\u30D7\u30E9\u30F3","\u5BFE\u8C61\u30D7\u30E9\u30F3","\u3059\u3079\u3066\u306E\u304A\u5BA2\u69D8","\u521D\u56DE\u8CFC\u5165\u9650\u5B9A","\u5FC5\u8981\u306A\u30BF\u30B0","\u958B\u59CB","\u7D42\u4E86","\u7D42\u4E86\u65E5\u306A\u3057","\u53D7\u53D6\u5F8C\u306E\u6709\u52B9\u671F\u9593","\u6642\u9593","\u9867\u5BA2\u3054\u3068\u306E\u5229\u7528\u56DE\u6570","\u5229\u7528\u4E0A\u9650"],ko:["\uBAA8\uB4E0 \uC720\uB8CC \uC694\uAE08\uC81C","\uC9C0\uC815 \uC694\uAE08\uC81C","\uBAA8\uB4E0 \uACE0\uAC1D","\uCCAB \uAD6C\uB9E4\uB9CC","\uD544\uC218 \uD0DC\uADF8","\uC2DC\uC791","\uC885\uB8CC","\uC885\uB8CC\uC77C \uC5C6\uC74C","\uC218\uB839 \uD6C4 \uC720\uD6A8 \uAE30\uAC04","\uC2DC\uAC04","\uACE0\uAC1D\uBCC4 \uC0AC\uC6A9 \uD69F\uC218","\uCD1D \uD55C\uB3C4"],es:["Todos los planes de pago","Planes seleccionados","Todos los clientes","Solo primera compra","Etiquetas requeridas","Inicio","Fin","Sin fecha de fin","Validez tras reclamar","horas","Usos por cliente","L\xEDmite total"],fr:["Tous les forfaits payants","Forfaits s\xE9lectionn\xE9s","Tous les clients","Premier achat uniquement","\xC9tiquettes requises","D\xE9but","Fin","Sans date de fin","Validit\xE9 apr\xE8s obtention","heures","Utilisations par client","Limite totale"],de:["Alle kostenpflichtigen Tarife","Ausgew\xE4hlte Tarife","Alle Kunden","Nur erster Kauf","Erforderliche Tags","Beginn","Ende","Kein Enddatum","G\xFCltigkeit nach Erhalt","Stunden","Nutzungen pro Kunde","Gesamtlimit"],pt:["Todos os planos pagos","Planos selecionados","Todos os clientes","Apenas primeira compra","Etiquetas necess\xE1rias","In\xEDcio","Fim","Sem data final","Validade ap\xF3s resgate","horas","Usos por cliente","Limite total"],it:["Tutti i piani a pagamento","Piani selezionati","Tutti i clienti","Solo primo acquisto","Tag richiesti","Inizio","Fine","Senza data finale","Validit\xE0 dopo il ritiro","ore","Utilizzi per cliente","Limite totale"],ru:["\u0412\u0441\u0435 \u043F\u043B\u0430\u0442\u043D\u044B\u0435 \u043F\u043B\u0430\u043D\u044B","\u0412\u044B\u0431\u0440\u0430\u043D\u043D\u044B\u0435 \u043F\u043B\u0430\u043D\u044B","\u0412\u0441\u0435 \u043A\u043B\u0438\u0435\u043D\u0442\u044B","\u0422\u043E\u043B\u044C\u043A\u043E \u043F\u0435\u0440\u0432\u0430\u044F \u043F\u043E\u043A\u0443\u043F\u043A\u0430","\u041D\u0435\u043E\u0431\u0445\u043E\u0434\u0438\u043C\u044B\u0435 \u0442\u0435\u0433\u0438","\u041D\u0430\u0447\u0430\u043B\u043E","\u041E\u043A\u043E\u043D\u0447\u0430\u043D\u0438\u0435","\u0411\u0435\u0437 \u0434\u0430\u0442\u044B \u043E\u043A\u043E\u043D\u0447\u0430\u043D\u0438\u044F","\u0421\u0440\u043E\u043A \u043F\u043E\u0441\u043B\u0435 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u044F","\u0447\u0430\u0441\u043E\u0432","\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0439 \u043D\u0430 \u043A\u043B\u0438\u0435\u043D\u0442\u0430","\u041E\u0431\u0449\u0438\u0439 \u043B\u0438\u043C\u0438\u0442"],vi:["M\u1ECDi g\xF3i tr\u1EA3 ph\xED","G\xF3i \u0111\u01B0\u1EE3c ch\u1ECDn","M\u1ECDi kh\xE1ch h\xE0ng","Ch\u1EC9 l\u1EA7n mua \u0111\u1EA7u","Th\u1EBB b\u1EAFt bu\u1ED9c","B\u1EAFt \u0111\u1EA7u","K\u1EBFt th\xFAc","Kh\xF4ng c\xF3 ng\xE0y k\u1EBFt th\xFAc","Hi\u1EC7u l\u1EF1c sau khi nh\u1EADn","gi\u1EDD","L\u01B0\u1EE3t m\u1ED7i kh\xE1ch","T\u1ED5ng gi\u1EDBi h\u1EA1n"],th:["\u0E17\u0E38\u0E01\u0E41\u0E1E\u0E47\u0E01\u0E40\u0E01\u0E08\u0E41\u0E1A\u0E1A\u0E0A\u0E33\u0E23\u0E30\u0E40\u0E07\u0E34\u0E19","\u0E41\u0E1E\u0E47\u0E01\u0E40\u0E01\u0E08\u0E17\u0E35\u0E48\u0E40\u0E25\u0E37\u0E2D\u0E01","\u0E25\u0E39\u0E01\u0E04\u0E49\u0E32\u0E17\u0E38\u0E01\u0E04\u0E19","\u0E40\u0E09\u0E1E\u0E32\u0E30\u0E01\u0E32\u0E23\u0E0B\u0E37\u0E49\u0E2D\u0E04\u0E23\u0E31\u0E49\u0E07\u0E41\u0E23\u0E01","\u0E41\u0E17\u0E47\u0E01\u0E17\u0E35\u0E48\u0E08\u0E33\u0E40\u0E1B\u0E47\u0E19","\u0E40\u0E23\u0E34\u0E48\u0E21","\u0E2A\u0E34\u0E49\u0E19\u0E2A\u0E38\u0E14","\u0E44\u0E21\u0E48\u0E21\u0E35\u0E27\u0E31\u0E19\u0E2A\u0E34\u0E49\u0E19\u0E2A\u0E38\u0E14","\u0E2D\u0E32\u0E22\u0E38\u0E2B\u0E25\u0E31\u0E07\u0E23\u0E31\u0E1A\u0E2A\u0E34\u0E17\u0E18\u0E34\u0E4C","\u0E0A\u0E31\u0E48\u0E27\u0E42\u0E21\u0E07","\u0E04\u0E23\u0E31\u0E49\u0E07\u0E15\u0E48\u0E2D\u0E25\u0E39\u0E01\u0E04\u0E49\u0E32","\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E31\u0E49\u0E07\u0E2B\u0E21\u0E14"],id:["Semua paket berbayar","Paket terpilih","Semua pelanggan","Hanya pembelian pertama","Tag wajib","Mulai","Berakhir","Tanpa tanggal akhir","Masa berlaku setelah klaim","jam","Penggunaan per pelanggan","Batas total"],ar:["\u062C\u0645\u064A\u0639 \u0627\u0644\u062E\u0637\u0637 \u0627\u0644\u0645\u062F\u0641\u0648\u0639\u0629","\u0627\u0644\u062E\u0637\u0637 \u0627\u0644\u0645\u062D\u062F\u062F\u0629","\u062C\u0645\u064A\u0639 \u0627\u0644\u0639\u0645\u0644\u0627\u0621","\u0627\u0644\u0634\u0631\u0627\u0621 \u0627\u0644\u0623\u0648\u0644 \u0641\u0642\u0637","\u0627\u0644\u0648\u0633\u0648\u0645 \u0627\u0644\u0645\u0637\u0644\u0648\u0628\u0629","\u062A\u0628\u062F\u0623","\u062A\u0646\u062A\u0647\u064A","\u0628\u0644\u0627 \u062A\u0627\u0631\u064A\u062E \u0627\u0646\u062A\u0647\u0627\u0621","\u0627\u0644\u0635\u0644\u0627\u062D\u064A\u0629 \u0628\u0639\u062F \u0627\u0644\u0645\u0637\u0627\u0644\u0628\u0629","\u0633\u0627\u0639\u0627\u062A","\u0627\u0644\u0627\u0633\u062A\u062E\u062F\u0627\u0645\u0627\u062A \u0644\u0643\u0644 \u0639\u0645\u064A\u0644","\u0627\u0644\u062D\u062F \u0627\u0644\u0625\u062C\u0645\u0627\u0644\u064A"]};function _c(e,t,n=[]){let r=me(t)??"en",o=r.split("-")[0],i=o==="zh"&&/(?:Hant|TW|HK|MO)/.test(r)?"zh-Hant":o,a=_t[i]??_t.en,m=_t[i]?r:"en",d=z=>new Intl.NumberFormat(m).format(z),c=z=>new Intl.DateTimeFormat(m,{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(new Date(z))+" UTC",k=[e.appliesTo.type==="all"?a[0]:`${a[1]}${n.length?`: ${n.slice(0,3).join(", ")+(n.length>3?` (+${d(n.length-3)})`:"")}`:""}`,e.eligibility.firstPurchaseOnly?a[3]:a[2],e.eligibility.requiredTags.length?`${a[4]}: ${e.eligibility.requiredTags.join(", ")}`:null].filter(Boolean).join(" \xB7 "),A=[e.startsAt?`${a[5]}: ${c(e.startsAt)}`:null,e.endsAt?`${a[6]}: ${c(e.endsAt)}`:a[7]].filter(Boolean).join(" \xB7 "),w=[k,A,`${a[8]}: ${d(e.grantWindowHours)} ${a[9]}`,`${a[10]}: ${d(e.perCustomerLimit)}`,e.totalLimit===null?null:`${a[11]}: ${d(e.totalLimit)}`].filter(Boolean).join(" \xB7 ");return{eligibility:k,validity:A,terms:w}}var Tt={"popup-coupon-welcome-ticket":{discount:"20%",zh:"\u9996\u671F\u8BA2\u9605\u4F18\u60E0",en:"Off your first subscription payment"},"popup-coupon-return-ticket":{discount:"$5",zh:"\u56DE\u6765\u7EE7\u7EED\u4F60\u7684\u8BA1\u5212",en:"Pick up where you left off"},"popup-coupon-launch-poster":{discount:"30%",zh:"\u65B0\u7248\u672C\u4E0A\u7EBF\u4F18\u60E0",en:"A special offer for our new release"},"popup-coupon-friday-poster":{discount:"40%",zh:"\u6D3B\u52A8\u671F\u8BA2\u9605\u4F18\u60E0",en:"A subscription offer for the campaign"},"popup-coupon-studio-split":{discount:"25%",zh:"\u4E3A\u521B\u4F5C\u8005\u51C6\u5907\u7684\u8BA2\u9605\u793C\u9047",en:"A subscription offer for creators"},"popup-coupon-team-split":{discount:"$10",zh:"\u56E2\u961F\u65B9\u6848\u9996\u671F\u51CF\u514D",en:"Off the first payment on a team plan"},"popup-coupon-member-letter":{discount:"20%",zh:"\u4E00\u4EFD\u4E13\u5C5E\u7684\u4F1A\u5458\u793C\u9047",en:"A membership offer just for you"},"popup-coupon-founder-letter":{discount:"30%",zh:"\u7ED9\u65E9\u671F\u652F\u6301\u8005\u7684\u8BA2\u9605\u4F18\u60E0",en:"A subscription offer for early supporters"},"popup-coupon-gift-box":{discount:"$5",zh:"\u4F60\u7684\u4E0B\u4E00\u6B21\u8BA2\u9605\u4F18\u60E0",en:"An offer for your next subscription"},"popup-coupon-birthday-box":{discount:"25%",zh:"\u751F\u65E5\u4E3B\u9898\u4F1A\u5458\u4F18\u60E0",en:"A birthday-themed membership offer"},"popup-coupon-first-receipt":{discount:"20%",zh:"\u9996\u671F\u4ED8\u6B3E\u6298\u6263",en:"A discount on the first payment"},"popup-coupon-loyalty-receipt":{discount:"$8",zh:"\u8001\u5BA2\u6237\u8BA2\u9605\u793C\u9047",en:"A subscription offer for returning customers"},"popup-coupon-upgrade-sheet":{discount:"20%",zh:"\u4E86\u89E3\u8BA2\u9605\u4F18\u60E0",en:"Explore a subscription offer"},"popup-coupon-return-sheet":{discount:"$5",zh:"\u56DE\u5F52\u8BA2\u9605\u4F18\u60E0",en:"A returning subscriber offer"},"popup-coupon-minimal-number":{discount:"20%",zh:"\u9996\u671F\u8BA2\u9605\u51CF\u514D",en:"Off the first subscription payment"},"popup-coupon-bold-number":{discount:"50%",zh:"\u6D3B\u52A8\u8BA2\u9605\u6298\u6263",en:"A campaign subscription discount"},"popup-coupon-studio-editorial":{discount:"25%",zh:"\u4E13\u4E1A\u8BA2\u9605\u65B9\u6848\u4F18\u60E0",en:"An offer on a professional subscription"},"popup-coupon-autumn-editorial":{discount:"30%",zh:"\u79CB\u5B63\u8BA2\u9605\u6D3B\u52A8",en:"An autumn subscription campaign"},"popup-coupon-vip-pass":{discount:"20%",zh:"\u4F1A\u5458\u8BA2\u9605\u793C\u9047",en:"A membership subscription offer"},"popup-coupon-beta-pass":{discount:"35%",zh:"\u65E9\u671F\u4F53\u9A8C\u8005\u4F18\u60E0",en:"An offer for early adopters"},"popup-coupon-welcome-stamp":{discount:"20%",zh:"\u9996\u6B21\u8BA2\u9605\u793C\u9047",en:"A first subscription offer"},"popup-coupon-milestone-stamp":{discount:"$5",zh:"\u7EE7\u7EED\u524D\u884C\u7684\u8BA2\u9605\u4F18\u60E0",en:"A subscription offer for your next step"},"popup-coupon-quiet-frame":{discount:"15%",zh:"\u4E13\u6CE8\u5DE5\u4F5C\u6D41\u8BA2\u9605\u4F18\u60E0",en:"An offer for a focused workflow"},"popup-coupon-premium-frame":{discount:"25%",zh:"\u7CBE\u9009\u4F1A\u5458\u65B9\u6848\u793C\u9047",en:"An offer on selected membership plans"},"popup-coupon-starter-steps":{discount:"20%",zh:"\u4E86\u89E3\u4F18\u60E0\uFF0C\u9886\u53D6\u540E\u9009\u5957\u9910",en:"Explore the offer, then choose your plan"},"popup-coupon-comeback-steps":{discount:"$5",zh:"\u4E3A\u56DE\u5F52\u51C6\u5907\u7684\u8BA2\u9605\u4F18\u60E0",en:"A subscription offer for your return"},"popup-coupon-spring-banner":{discount:"20%",zh:"\u6625\u5B63\u8BA2\u9605\u793C\u9047",en:"A spring subscription offer"},"popup-coupon-year-banner":{discount:"30%",zh:"\u65B0\u5E74\u4F1A\u5458\u8BA2\u9605\u4F18\u60E0",en:"A new-year membership offer"},"popup-coupon-mono-card":{discount:"20%",zh:"\u4E13\u4E1A\u5DE5\u5177\u8BA2\u9605\u4F18\u60E0",en:"An offer on professional tools"},"popup-coupon-night-card":{discount:"$5",zh:"\u521B\u4F5C\u5DE5\u5177\u8BA2\u9605\u4F18\u60E0",en:"An offer on creative tools"},"popup-coupon-spotlight-panel":{discount:"30%",zh:"\u4E13\u4E1A\u7248\u8BA2\u9605\u6D3B\u52A8",en:"A professional subscription campaign"},"popup-coupon-summer-panel":{discount:"25%",zh:"\u590F\u5B63\u8BA2\u9605\u4F18\u60E0",en:"A summer subscription offer"}};function pr(e){return e.actions.map(t=>t.properties.templateKey).find(t=>typeof t=="string"&&t.startsWith("popup-coupon-"))}function Nc(e,t){let n=pr(e);if(!n||!Object.hasOwn(Tt,n))return e;let r=o=>{let i={...o.root.bind,coupon:t};return o.root.bind?.coupon!==t&&delete i.promotionCode,{bind:i}};return{...e,pages:e.pages.map(o=>({...o,root:{...o.root,...r(o)}})),actions:e.actions.map(o=>o.properties.templateKey===n&&o.type!=="navigate"&&o.type!=="close"?{id:o.id,type:"claim_offer",couponId:t,event:"offer.claimed",properties:o.properties,close:o.close}:o)}}function $c(e){let t=pr(e),n=t?Tt[t]:void 0;return!n||e.actions.some(r=>r.type==="claim_offer")?e:{...e,strings:{...e.strings,locales:Object.fromEntries(Object.entries(e.strings.locales).map(([r,o])=>[r,Object.fromEntries(Object.entries(o).map(([i,a])=>[i,a.replaceAll("{{offer.discount}}",n.discount).replaceAll("{{offer.headline}}",r.startsWith("zh")?n.zh:n.en).replaceAll("{{offer.terms}}",r.startsWith("zh")?"\u6F14\u793A\u91D1\u989D \xB7 \u7ED1\u5B9A\u4F18\u60E0\u5238\u540E\u81EA\u52A8\u663E\u793A\u771F\u5B9E\u6761\u6B3E":"Demo amount \xB7 Bind a coupon to show actual terms")]))]))}}}function Fc(e,t,n,r,o){if(!e.funnel||t.pages.length!==1||t.funnel||!["page","paywall"].includes(t.surface))throw new Error("\u8BF7\u9009\u62E9\u5DF2\u53D1\u5E03\u7684\u72EC\u7ACB\u9875\u9762\u6216\u5355\u9875\u4ED8\u8D39\u5899\u3002");let i=new Set,a=e.pages.find(I=>I.id===o);if(a&&!a.source)throw new Error("\u9875\u9762\u6807\u8BC6\u5DF2\u5B58\u5728\u3002");let m=I=>{if(Array.isArray(I))I.forEach(m);else if(I&&typeof I=="object"){let K=I;typeof K.id=="string"&&i.add(K.id),Object.values(K).forEach(m)}};m(t.pages),t.actions.forEach(I=>i.add(I.id)),Object.values(t.strings.locales).forEach(I=>Object.keys(I).forEach(K=>i.add(K)));let d=Math.max(-1,...Object.values(a?.source?.map??{}).map(I=>Number(I.match(/_k(\d+)$/)?.[1]??-1)))+1,c=Object.fromEntries([...i].map(I=>[I,a?.source?.map[I]??`${o}_k${d++}`]));c[t.pages[0].id]=o;let k=(I,K="")=>typeof I=="string"?["id","text","title","alt","label","action","fallback","expired","picker","target"].includes(K)&&Object.hasOwn(c,I)?c[I]:I.replace(/\bdata-grow-action\s*=\s*(["'])([a-zA-Z][a-zA-Z0-9_.-]{0,63})\1/gi,(ae,de,Ve)=>Object.hasOwn(c,Ve)?`data-grow-action=${de}${c[Ve]}${de}`:ae):Array.isArray(I)?I.map(ae=>k(ae)):I&&typeof I=="object"?Object.fromEntries(Object.entries(I).map(([ae,de])=>[ae,k(de,ae)])):I,A=k(t.pages[0].root),w=structuredClone(e.strings.locales),z=new Set(Object.values(a?.source?.map??{}));Object.values(w).forEach(I=>z.forEach(K=>delete I[K]));for(let[I,K]of Object.entries(w)){let ae=t.strings.locales[I]??t.strings.locales[t.strings.defaultLocale];for(let[de,Ve]of Object.entries(ae))K[c[de]]=Ve}let J=t.actions.map(I=>({id:c[I.id],type:"navigate",target:o,event:I.event,properties:I.properties,close:!1})),x={id:o,name:t.name.slice(0,60),root:A,theme:t.theme,source:{campaignId:n,versionId:r,map:c,strings:t.strings},...a?.editorPosition?{editorPosition:a.editorPosition}:{}},F=e.actions.filter(I=>!z.has(I.id)),re=new Set([...F,...J].map(I=>I.id));return B.parse({...e,funnel:{...e.funnel,routes:e.funnel.routes.filter(I=>re.has(I.action))},pages:a?e.pages.map(I=>I.id===o?x:I):[...e.pages,x],actions:[...F,...J],strings:{...e.strings,locales:w}})}function Uc(e,t,n=[]){let r={nodes:{}},o=t.startsWith("zh"),i=(m,d)=>o?m:d,a=(m,d,c,k,A=[])=>({id:m,label:d,value:c,status:k,detail:A,facts:[]});return le(e,m=>{if(m.type!=="customer_data")return;let d={...wn(m.data.source),status:"ready",stale:!1,preview:!0};if(m.data.source==="credit_balance"){let c=m.data.resourceKey??n[0]?.key??"credits";d.resources=[{key:c,name:n.find(k=>k.key===c)?.label??i("\u521B\u4F5C\u79EF\u5206","Creative credits"),spendable:"3,840",available:"4,040",reserved:"200",expiry:i("1,200 \xB7 2026\u5E7411\u67081\u65E5","1,200 \xB7 November 1, 2026"),sources:[a("sample-monthly",i("\u4F1A\u5458\u6708\u5EA6\u79EF\u5206","Monthly membership credits"),"2,640",i("\u53EF\u7528","Available")),a("sample-pack",i("\u8D2D\u4E70\u79EF\u5206\u5305","Purchased credit pack"),"1,200",i("\u53EF\u7528","Available"))],sourceCount:2,sourcePage:1,hasNextSources:!1,hasPreviousSources:!1}]}else m.data.source==="credit_transactions"?(d.rows=[a("sample-usage-1",i("\u56FE\u50CF\u751F\u6210","Image generation"),"",i("\u6D88\u8D39","Usage"),[i("10\u67083\u65E5 09:42","Oct 3, 09:42")]),a("sample-usage-2",i("\u89C6\u9891\u751F\u6210","Video generation"),"",i("\u9884\u6263","Reserved"),[i("10\u67083\u65E5 09:30","Oct 3, 09:30")]),a("sample-usage-3",i("\u56FE\u50CF\u751F\u6210","Image generation"),"",i("\u9000\u56DE","Refund"),[i("10\u67082\u65E5 16:10","Oct 2, 16:10")]),a("sample-usage-4",i("\u89C6\u9891\u751F\u6210","Video generation"),"",i("\u6D88\u8D39","Usage"),[i("10\u67082\u65E5 15:24","Oct 2, 15:24")]),a("sample-usage-5",i("\u56FE\u50CF\u751F\u6210","Image generation"),"",i("\u6D88\u8D39","Usage"),[i("10\u67082\u65E5 14:08","Oct 2, 14:08")])].slice(0,m.data.pageSize),d.rows.forEach((c,k)=>{c.facts=[{label:i("\u521B\u4F5C\u79EF\u5206","Creative credits"),value:["12","180","12","180","24"][k]}]})):m.data.source==="membership"?d.rows=[a("sample-plan",i("\u4E13\u4E1A\u7248 \xB7 \u6708\u4ED8","Pro \xB7 Monthly"),"",i("\u6709\u6548","Active"),[i("\u5F53\u524D\u5468\u671F\u7ED3\u675F \xB7 2026\u5E7411\u67081\u65E5","Current period ends \xB7 November 1, 2026")])]:m.data.source==="customer_plans"?d.rows=[a("sample-free",i("\u57FA\u7840\u7248","Starter"),i("\u514D\u8D39","Free"),i("\u53EF\u9009\u62E9","Available")),a("sample-pro",i("\u4E13\u4E1A\u7248","Pro"),"$29 / month",i("\u5F53\u524D\u5957\u9910","Current plan")),a("sample-team",i("\u56E2\u961F\u7248","Team"),"$79 / month",i("\u53EF\u9009\u62E9","Available"))].slice(0,m.data.pageSize):m.data.source==="credit_packs"?d.rows=[a("sample-pack-small",i("\u521B\u4F5C\u8865\u5145\u5305","Creative top-up"),"$12","",[i("1,200 \u79EF\u5206 \xB7 90 \u5929\u6709\u6548","1,200 credits \xB7 90 days validity")]),a("sample-pack-large",i("\u521B\u4F5C\u6269\u5C55\u5305","Creative expansion"),"$40","",[i("5,000 \u79EF\u5206 \xB7 180 \u5929\u6709\u6548","5,000 credits \xB7 180 days validity")])].slice(0,m.data.pageSize).map((c,k)=>({...c,...m.data.allowPurchase?{purchaseId:`10000000-0000-4000-8000-${String(k+1).padStart(12,"0")}`}:{}})):m.data.source==="credit_pack_orders"?d.rows=[a("sample-order",i("\u521B\u4F5C\u8865\u5145\u5305","Creative top-up"),"$12",i("\u5DF2\u4ED8\u6B3E","Paid"),["2026-10-01 12:30"])]:d.rows=[a("sample-offer",i("\u4F1A\u5458\u7EED\u8D39\u4F18\u60E0","Membership renewal offer"),"",i("\u53EF\u7528","Available"),[i("2026\u5E7411\u67081\u65E5\u5230\u671F","Expires November 1, 2026")])];r.nodes[m.id]=d}),r}import{z as O}from"zod";var Ji=O.enum(["surface","customer","feature","plan","pool","coupon","audience"]),Qi=O.enum(["name","description","email","metadata","tags","pages","strings","actions","theme","presentation","funnel","config","variant","price","items","credits","rates","status","key","type","usageType","archived","surface","distribution","terms","codes","content"]),nt=O.object({baseRevision:O.number().int().nonnegative(),latestRevision:O.number().int().nonnegative(),mode:O.enum(["merge","use_latest"]),decisions:O.array(O.object({field:Qi,mine:O.number().int().min(0).max(1e3),latest:O.number().int().min(0).max(1e3)}).strict().refine(e=>e.mine+e.latest>0)).max(28)}).strict().refine(e=>e.latestRevision>e.baseRevision).refine(e=>new Set(e.decisions.map(t=>t.field)).size===e.decisions.length).refine(e=>e.mode!=="use_latest"||e.decisions.length===0),mr=O.number().int().nonnegative().nullable(),Yi=O.object({resource:Ji,id:O.uuid(),projectId:O.uuid(),environmentId:O.uuid(),fromRevision:mr,toRevision:mr,provenance:O.enum(["recorded","historical"]),changes:O.array(O.object({field:O.string(),redacted:O.boolean(),before:O.union([O.string(),O.number(),O.boolean(),O.null()]),after:O.union([O.string(),O.number(),O.boolean(),O.null()])})),merge:nt.safeExtend({source:O.literal("client")}).nullable()}),Xi=O.object({createdAt:O.iso.datetime({offset:!0}),id:O.uuid()}).strict(),Kc=O.object({events:O.array(O.object({id:O.uuid(),action:O.string(),actorId:O.uuid().nullable(),actorEmail:O.email().nullable(),createdAt:O.iso.datetime({offset:!0}),object:Yi})),nextCursor:Xi.nullable()});import{z as h}from"zod";var Rt=h.array(h.string().trim().min(1).max(40)).max(20).refine(e=>new Set(e).size===e.length),dr=h.iso.datetime({offset:!0}).nullable(),eo=h.object({enabled:h.boolean(),tagsAll:Rt,tagsAny:Rt,tagsNone:Rt,countries:h.array(h.string().regex(/^[A-Z]{2}$/)).max(40).refine(e=>new Set(e).size===e.length),subscription:h.enum(["any","none","active","trialing","ended"]),ageMinDays:h.number().int().min(0).max(36500).nullable(),ageMaxDays:h.number().int().min(0).max(36500).nullable(),attributes:h.array(h.object({key:h.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,49}$/),value:h.union([h.string().max(200),h.number().finite(),h.boolean()])}).strict()).max(10).refine(e=>new Set(e.map(t=>t.key)).size===e.length),startsAt:dr,endsAt:dr}).strict().superRefine((e,t)=>{e.ageMinDays!==null&&e.ageMaxDays!==null&&e.ageMinDays>e.ageMaxDays&&t.addIssue({code:"custom",path:["ageMaxDays"],message:"Minimum age exceeds maximum age"}),e.startsAt&&e.endsAt&&Date.parse(e.startsAt)>=Date.parse(e.endsAt)&&t.addIssue({code:"custom",path:["endsAt"],message:"Start must precede end"}),e.tagsNone.some(n=>e.tagsAll.includes(n))&&t.addIssue({code:"custom",path:["tagsNone"],message:"Required tag is excluded"}),e.tagsAny.length>0&&e.tagsAny.every(n=>e.tagsNone.includes(n))&&t.addIssue({code:"custom",path:["tagsAny"],message:"Every alternative tag is excluded"})}),Jc={enabled:!1,tagsAll:[],tagsAny:[],tagsNone:[],countries:[],subscription:"any",ageMinDays:null,ageMaxDays:null,attributes:[],startsAt:null,endsAt:null},Qc=h.object({campaign_id:h.uuid(),revision:h.number().int().min(0),audience_id:h.uuid().nullable(),enabled:h.boolean()}),Yc=h.object({matches:h.boolean(),revision:h.number().int().nullable(),reasons:h.array(h.enum(["before_start","after_end","customer_required","tags_all","tags_any","tags_none","country","subscription","age","attributes","audience_unavailable"])),audienceId:h.uuid().nullable().optional(),audienceRevision:h.number().int().nullable().optional()}),Xc=h.object({campaignId:h.uuid(),revision:h.number().int().min(0),audienceId:h.uuid().nullable(),enabled:h.boolean()}).strict().refine(e=>!e.enabled||e.audienceId!==null),fr=eo.refine(e=>e.enabled,"Audience conditions must remain enabled"),eu=h.object({id:h.uuid(),name:h.string().min(1).max(80),description:h.string().max(500),config:fr,revision:h.number().int().min(1),status:h.enum(["active","archived"]),created_at:h.iso.datetime({offset:!0}),updated_at:h.iso.datetime({offset:!0})}),tu=h.discriminatedUnion("action",[h.object({action:h.literal("save"),id:h.uuid().nullable(),audit:nt.nullable().optional(),revision:h.number().int().min(0),name:h.string().trim().min(1).max(80),description:h.string().trim().max(500),config:fr}).strict(),h.object({action:h.literal("archive"),id:h.uuid(),audit:nt.nullable().optional(),revision:h.number().int().min(1)}).strict()]),to=h.object({id:h.uuid(),name:h.string().nullable(),external_user_id:h.string(),tags:h.string().array(),created_at:h.iso.datetime({offset:!0})}),nu=h.object({customers:to.array(),hasMore:h.boolean(),offset:h.number().int().min(0),limit:h.number().int().min(1),evaluatedAt:h.iso.datetime({offset:!0}),revision:h.number().int().min(1)}),ru=h.object({campaignId:h.uuid(),experimentId:h.uuid(),revision:h.number().int().min(1),variantId:h.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/)}).strict();import{z as Le}from"zod";var su=Le.object({defaultLocale:G,locales:Le.record(G,Le.object({name:Le.string().max(80),description:Le.string().max(500)}).strict())}).strict().superRefine((e,t)=>{let n=Object.keys(e.locales);(!n.length||n.length>20||!e.locales[e.defaultLocale])&&t.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(e)).length>5e4&&t.addIssue({code:"custom",message:"Content exceeds 50 KB"})});function cu(e,t){let n=e.displayCopy;if(!n)return{name:e.name,description:""};let r=Object.keys(n.locales).filter(m=>n.locales[m].name.trim()),o=Je([t],r,n.defaultLocale),i=n.locales[o],a=n.locales[n.defaultLocale];return{name:i?.name.trim()?i.name:a?.name.trim()?a.name:e.name,description:i?.description.trim()?i.description:a?.description.trim()?a.description:""}}import{z as N}from"zod";var ze=N.string().min(1).max(255).regex(/^[^\s\p{Cc}]+$/u),gr=N.strictObject({projectId:N.uuid(),environmentId:N.uuid()}),no=N.strictObject({kind:Ee,deliveryVersionId:N.uuid(),productId:ze,basePlanId:ze.nullable(),offerId:ze.nullable(),accessPriority:N.number().int().min(0).max(1e5)}).superRefine((e,t)=>{e.kind==="credit_pack"&&(e.basePlanId!==null||e.offerId!==null||e.accessPriority!==0)&&t.addIssue({code:"custom",message:"Credit packs have no subscription terms or access priority"})}),mu=gr.extend({connectionId:N.uuid(),binding:no}),du=gr.extend({bindingId:N.uuid()}),fu=N.strictObject({environment:N.enum(["sandbox","live"]),truncated:N.boolean(),connections:N.array(N.strictObject({id:N.uuid(),provider:N.enum(["apple","google"]),applicationId:N.string()})),deliveries:N.array(N.strictObject({id:N.uuid(),kind:Ee,name:N.string(),version:N.number().int().positive()})),bindings:N.array(N.strictObject({id:N.uuid(),connectionId:N.uuid(),kind:Ee,deliveryVersionId:N.uuid(),productId:ze,basePlanId:ze.nullable(),offerId:ze.nullable(),accessPriority:N.number().int().min(0).max(1e5),archivedAt:N.iso.datetime().nullable(),verification:N.enum(["archived","credential_required","paused","verification_required","verification_expired","verified"])}))});function bu(){let e=(o,i,a,m=!1)=>({id:o,type:"customer_data",title:a,data:{source:i,layout:m?"compact":"full",pageSize:i==="credit_transactions"?5:10,showSources:i==="credit_balance",allowPurchase:i==="credit_packs"}}),t=(o,i,a)=>({id:o,type:"stack",direction:"vertical",align:"stretch",justify:"start",children:i,style:{gap:24,...a?{width:a,grow:!0}:{}}}),n=e("balance","credit_balance","balance_title");n.style={background:{type:"color",color:"primary"},text:{color:"#FFFFFF"},padding:{top:28,right:32,bottom:24,left:32},shape:{type:"rect",radius:16}};let r=e("membership","membership","membership_title",!0);return r.style={width:300},B.parse({kind:"screen",schemaVersion:3,name:"\u79EF\u5206\u4E2D\u5FC3",surface:"page",presentation:{type:"fullscreen"},theme:{primary:"#2C3C96",background:"#F5F6FA",text:"#172033",radius:"md",font:"system"},pages:[{id:"credit_center",name:"\u79EF\u5206\u4E2D\u5FC3",root:{...t("root",[{...t("content",[{id:"account_header",type:"stack",direction:"horizontal",align:"center",justify:"between",style:{gap:24},children:[{...t("intro",[{id:"eyebrow",type:"text",text:"eyebrow",variant:"caption",style:{text:{size:11,weight:600,color:"muted",letterSpacing:1}}},{id:"heading",type:"text",text:"heading",variant:"title",style:{text:{size:30,weight:600,lineHeight:1.2,letterSpacing:-.8}}}]),style:{gap:8,width:420,grow:!0}},r]},n,{id:"workspace",type:"stack",direction:"horizontal",align:"start",justify:"start",style:{gap:40,padding:{top:28,right:28,bottom:28,left:28},background:{type:"color",color:"#FFFFFF"},shape:{type:"rect",radius:16},border:{width:1,color:"#E5E8F0",style:"solid"}},children:[t("activity_column",[e("activity","credit_transactions","activity_title")],636),{...t("account_column",[{...t("topup",[e("packs","credit_packs","packs_title"),{id:"pack_note",type:"text",text:"pack_note",variant:"caption",style:{text:{size:11,color:"muted",lineHeight:1.6}}}]),style:{gap:12,padding:{top:20,right:20,bottom:20,left:20},background:{type:"color",color:"#F6F7FB"},shape:{type:"rect",radius:12}}},e("orders","credit_pack_orders","orders_title",!0)],280),style:{width:280,grow:!0,gap:32}}]},{id:"footer",type:"text",text:"footer",variant:"caption",style:{text:{size:11,color:"muted",align:"center"}}}]),style:{width:1120,gap:28}}]),align:"center",style:{padding:{top:36,right:24,bottom:28,left:24}}}}],strings:{defaultLocale:"zh-CN",locales:{"zh-CN":{eyebrow:"\u8D26\u6237 / \u79EF\u5206",heading:"\u79EF\u5206\u4E2D\u5FC3",balance_title:"\u53EF\u7528\u79EF\u5206",activity_title:"\u4F7F\u7528\u8BB0\u5F55",membership_title:"\u5F53\u524D\u65B9\u6848",packs_title:"\u8865\u5145\u79EF\u5206",orders_title:"\u6700\u8FD1\u8D2D\u4E70",pack_note:"\u79EF\u5206\u5305\u4E3A\u4E00\u6B21\u6027\u8D2D\u4E70\uFF0C\u65E0\u9700\u8BA2\u9605\u3002",footer:"\u4F59\u989D\u968F\u5B9E\u9645\u5230\u8D26\u4E0E\u4F7F\u7528\u66F4\u65B0\u3002"},en:{eyebrow:"ACCOUNT / CREDITS",heading:"Credit center",balance_title:"Available credits",activity_title:"Activity",membership_title:"Current plan",packs_title:"Add credits",orders_title:"Recent purchases",pack_note:"One-time credit packs. No subscription required.",footer:"Your balance updates as credits are added and used."}}},actions:[]})}export{Pe as a,te as b,br as c,L as d,Oe as e,ao as f,so as g,Dt as h,yr as i,xr as j,Sr as k,Ir as l,po as m,mo as n,fo as o,_e as p,Me as q,vr as r,kr as s,Cr as t,Ue as u,Nt as v,$t as w,Et as x,H as y,W as z,He as A,jr as B,Ft as C,Ar as D,wr as E,Lt as F,ot as G,xo as H,Te as I,at as J,zr as K,Pr as L,Vt as M,Q as N,st as O,Mt as P,ct as Q,Ut as R,Ht as S,Bt as T,Kt as U,ge as V,So as W,oe as X,Zt as Y,Gt as Z,Or as _,Io as $,he as aa,be as ba,Be as ca,Wt as da,ut as ea,lt as fa,pt as ga,mt as ha,Jt as ia,Qt as ja,_r as ka,Ke as la,Yt as ma,ye as na,Fo as oa,Xt as pa,Lo as qa,xe as ra,Vo as sa,Mo as ta,dt as ua,Ze as va,Uo as wa,Ho as xa,Tr as ya,Re as za,ft as Aa,Bo as Ba,Ko as Ca,Ge as Da,We as Ea,Xo as Fa,ea as Ga,ta as Ha,Rr as Ia,na as Ja,Dr as Ka,nn as La,oa as Ma,G as Na,me as Oa,Je as Pa,Er as Qa,ca as Ra,ma as Sa,qr as Ta,Fr as Ua,sn as Va,ba as Wa,cn as Xa,un as Ya,ln as Za,Vr as _a,ya as $a,xa as ab,Sa as bb,Ia as cb,va as db,ka as eb,Ca as fb,ja as gb,Se as hb,pn as ib,Ur as jb,mn as kb,Hr as lb,Br as mb,dn as nb,fn as ob,Kr as pb,Zr as qb,gn as rb,hn as sb,bn as tb,Gr as ub,xn as vb,yn as wb,ve as xb,Qe as yb,Ye as zb,qa as Ab,Fa as Bb,ke as Cb,Sn as Db,In as Eb,vn as Fb,yt as Gb,kn as Hb,Ba as Ib,Jr as Jb,Cn as Kb,jn as Lb,Yr as Mb,Wa as Nb,Ja as Ob,wn as Pb,xt as Qb,zn as Rb,Xa as Sb,Xr as Tb,Pn as Ub,On as Vb,rs as Wb,It as Xb,ti as Yb,is as Zb,Tn as _b,St as $b,ni as ac,X as bc,De as cc,U as dc,ri as ec,ii as fc,ds as gc,vt as hc,Rn as ic,Ne as jc,Dn as kc,oi as lc,ai as mc,En as nc,si as oc,ci as pc,ui as qc,li as rc,pi as sc,je as tc,mi as uc,di as vc,fi as wc,gi as xc,hi as yc,bi as zc,yi as Ac,xi as Bc,Si as Cc,Ii as Dc,vi as Ec,ki as Fc,qn as Gc,Ci as Hc,Ai as Ic,Nn as Jc,Ct as Kc,Fn as Lc,fs as Mc,wi as Nc,gs as Oc,le as Pc,hs as Qc,B as Rc,$e as Sc,jt as Tc,Pi as Uc,Ln as Vc,bs as Wc,Ti as Xc,ys as Yc,xs as Zc,Ri as _c,kt as $c,Ss as ad,Is as bd,Ae as cd,js as dd,Ee as ed,As as fd,Di as gd,ws as hd,Ni as id,zs as jd,Mn as kd,$i as ld,Un as md,At as nd,Ps as od,Os as pd,Hn as qd,Bn as rd,Gn as sd,Wn as td,wt as ud,Jn as vd,qe as wd,Qn as xd,Ei as yd,qi as zd,Ot as Ad,Yn as Bd,Xn as Cd,er as Dd,Rs as Ed,Ls as Fd,Fi as Gd,nr as Hd,rr as Id,ir as Jd,Li as Kd,sc as Ld,_ as Md,Vi as Nd,Mi as Od,Ui as Pd,Hi as Qd,Bi as Rd,Ki as Sd,Zi as Td,Gi as Ud,cc as Vd,uc as Wd,ur as Xd,sr as Yd,tt as Zd,pc as _d,gc as $d,xc as ae,Sc as be,Ic as ce,jc as de,Wi as ee,Ac as fe,wc as ge,zc as he,_c as ie,pr as je,Nc as ke,$c as le,Fc as me,Uc as ne,Ji as oe,Qi as pe,nt as qe,Yi as re,Xi as se,Kc as te,eo as ue,Jc as ve,Qc as we,Yc as xe,Xc as ye,fr as ze,eu as Ae,tu as Be,to as Ce,nu as De,ru as Ee,su as Fe,cu as Ge,gr as He,no as Ie,mu as Je,du as Ke,fu as Le,bu as Me};
|