@houzhen888/groove-grow 0.0.2 → 0.0.3

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 CHANGED
@@ -1,8 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.3 — 2026-10-04
4
+
5
+ - Credit accounts return resource summaries; `listCreditBalances` retrieves grant sources with a stable cursor and bounded database pages.
6
+ - Customer Pages fetch source details independently from the live balance summary.
7
+ - Update the SDK and server together. The former embedded `account.balances` response is rejected; use `account.resources` and the source page API.
8
+
3
9
  ## 0.0.2 — 2026-10-03
4
10
 
5
- - Customer state with permission-checked sections, exact resource totals and grant breakdowns.
11
+ - Customer state with permission-checked sections and exact resource totals.
6
12
  - Customer-aware plan relationships, trial qualification and explicit currency availability.
7
13
  - Credit history filters, complete cursor-paginated pack orders and offer history.
8
14
  - Framework-neutral state subscriptions, shared requests, bounded freshness and identity clearing.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # @houzhen888/groove-grow
2
2
 
3
- Groove Grow 的框架无关 Web / TypeScript SDK。当前 Beta 版本为 `0.0.2`。一个 npm 包提供三个 ESM 入口,无需内部 contracts 包、React、Next.js 或 Supabase。
3
+ Groove Grow 的框架无关 Web / TypeScript SDK。本分支构建版本为 `0.0.3`,包含资源余额摘要与批次分页,须与匹配服务端一同发布。一个 npm 包提供三个 ESM 入口,无需内部 contracts 包、React、Next.js 或 Supabase。
4
4
 
5
5
  ```sh
6
6
  npm install @houzhen888/groove-grow@beta
7
7
  ```
8
8
 
9
- 通过个人测试 scope 分发。正式公司包名将另行公布,迁移时需要更新依赖和导入路径。本地安装可使用 `pnpm test:sdk-package` 生成的 `.local/sdk-package-check/houzhen888-groove-grow-0.0.2.tgz`。
9
+ 通过个人测试 scope 分发。正式公司包名将另行公布,迁移时需要更新依赖和导入路径。本地安装可使用 `pnpm test:sdk-package` 生成的 `.local/sdk-package-check/houzhen888-groove-grow-0.0.3.tgz`。
10
10
 
11
11
  | 入口 | 用途 | 加载行为 |
12
12
  | -------------------------------- | --------------------------------------------- | ---------------------------------------- |
@@ -155,6 +155,28 @@ page.destroy();
155
155
 
156
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
157
 
158
+ Credit reads return resource summaries without embedded grants or rates. Fetch details explicitly with bounded cursor pages:
159
+
160
+ ```ts
161
+ const account = await client.getBalances();
162
+ const resource = Object.values(account.resources)[0];
163
+ if (resource) {
164
+ const first = await client.listCreditBalances({
165
+ resourceKey: resource.resourceKey,
166
+ limit: 50,
167
+ });
168
+ if (first.nextCursor) {
169
+ const next = await client.listCreditBalances({
170
+ resourceKey: resource.resourceKey,
171
+ limit: 50,
172
+ cursor: first.nextCursor,
173
+ });
174
+ }
175
+ }
176
+ ```
177
+
178
+ `scope: "current"` is the default; `scope: "all"` includes retained historical batches. Each page permits 1–100 records. Account responses and customer state reject the old embedded `balances`/`breakdown` format. Decimal totals are exact strings.
179
+
158
180
  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
181
 
160
182
  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.
@@ -0,0 +1,5 @@
1
+ import{z as yt}from"zod";var Fe=yt.enum(["sandbox","live"]),ae=yt.object({projectId:yt.string().min(1),environment:Fe});import{z as Kr}from"zod";var Zr=["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=Kr.enum(Zr);function Ne(e){let t=L.parse(e.toUpperCase());return["JPY","KRW","VND"].includes(t)?0:2}function ta(e,t){let r=Ne(t),n=e.trim().match(/^(\d+)(?:\.(\d+))?$/);if(!n||(n[2]?.length??0)>r)throw new Error("Amount has invalid currency precision");let i=BigInt(n[1])*BigInt(10**r)+BigInt((n[2]??"").padEnd(r,"0")||"0");if(i>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Amount exceeds the supported range");return Number(i)}function na(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Error("Expected a nonnegative integer amount");let r=Ne(t),n=String(e).padStart(r+1,"0");return r?`${n.slice(0,-r)}.${n.slice(-r)}`:n}function en(e,t,r="en",n={}){let i=L.parse(t.toUpperCase());return new Intl.NumberFormat(r,{style:"currency",currency:i,...n}).format(e/10**Ne(i))}import{z as $}from"zod";var Wr=$.object({minAccountAgeDays:$.number().int().min(0).max(3650),paymentStatus:$.enum(["all","unpaid","paid"])}),Gr=$.object({percentOff:$.number().int().min(1).max(100),redemptionWindowHours:$.number().int().min(1).max(2160)}),Yr=$.object({title:$.string().trim().min(1).max(80),description:$.string().trim().min(1).max(240),buttonLabel:$.string().trim().min(1).max(30)}),Jr=$.object({name:$.string().trim().min(1).max(80),audience:Wr,offer:Gr,popup:Yr}),aa=Jr.extend({id:$.string().min(1),projectId:$.string().min(1),environment:Fe,status:$.enum(["draft","active","paused"]),updatedAt:$.iso.datetime()}),sa=ae.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()}),ca=$.object({error:$.object({code:$.string(),message:$.string()})});import{z as S}from"zod";import{z as g}from"zod";var xt=g.string().regex(/^[a-z][a-z0-9_]{0,63}$/),fe=g.number().int().min(0).max(1e4),$e=g.object({key:xt,featureId:g.uuid(),planVersionId:g.uuid(),includedQuantity:fe,maximumQuantity:fe,unitAmountCents:g.number().int().min(0).max(1e8),stripePriceId:g.string().regex(/^price_[A-Za-z0-9]+$/).nullable(),pooledResources:g.array(g.string().regex(/^(?:[a-z][a-z0-9_]{0,63}|pool:[0-9a-f-]{36})$/)).max(100),requireAssignment:g.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"),Qe=g.array(g.object({key:xt,quantity:fe}).strict()).max(20).refine(e=>new Set(e.map(t=>t.key)).size===e.length,"\u5E2D\u4F4D\u6570\u91CF\u4E0D\u80FD\u91CD\u590D"),Qr=g.object({id:g.uuid(),customerId:g.uuid(),externalId:g.string().min(1).max(255),featureId:g.uuid(),name:g.string().max(80),disableSharedBalance:g.boolean(),archivedAt:g.iso.datetime().nullable(),revision:g.number().int().positive(),createdAt:g.iso.datetime()}),Xr=g.object({id:g.uuid(),key:xt,parentHoldingId:g.uuid(),planVersionId:g.uuid(),featureId:g.uuid(),purchased:fe,included:fe,assigned:fe,remaining:fe,active:g.boolean()}),ei=g.object({id:g.uuid(),poolId:g.uuid(),entityId:g.uuid().nullable(),planVersionId:g.uuid(),assignedAt:g.iso.datetime().nullable(),releasedAt:g.iso.datetime().nullable(),ordinal:g.number().int().positive()}),Xe=g.object({customerId:g.uuid(),entities:g.array(Qr),pools:g.array(Xr),assignments:g.array(ei)}),tn=g.object({customerId:g.uuid().optional()}).strict(),Se={customerId:g.uuid(),requestId:g.uuid()},nn=g.discriminatedUnion("action",[g.object({...Se,action:g.literal("create"),externalId:g.string().trim().min(1).max(255),featureId:g.uuid(),name:g.string().trim().max(80),disableSharedBalance:g.boolean()}).strict(),g.object({...Se,action:g.literal("update"),entityId:g.uuid(),revision:g.number().int().positive(),name:g.string().trim().max(80),disableSharedBalance:g.boolean()}).strict(),g.object({...Se,action:g.literal("archive"),entityId:g.uuid(),revision:g.number().int().positive()}).strict()]),rn=g.discriminatedUnion("action",[g.object({...Se,action:g.literal("cancel_change"),poolId:g.uuid()}).strict(),g.object({...Se,action:g.literal("assign"),poolId:g.uuid(),entityId:g.uuid()}).strict(),g.object({...Se,action:g.literal("release"),assignmentId:g.uuid()}).strict(),g.object({...Se,action:g.literal("quantity"),poolId:g.uuid(),quantity:fe,timing:g.enum(["immediate","end_of_cycle"])}).strict()]);import{z as k}from"zod";import{z as V}from"zod";import{z as u}from"zod";var Z=u.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),te=u.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),he=te.refine(e=>/[1-9]/.test(e),"\u6570\u91CF\u5FC5\u987B\u5927\u4E8E 0"),ce=u.string().regex(/^[a-z][a-z0-9_]{0,63}$/),qe=u.union([ce,u.string().regex(/^pool:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)]),ti=u.record(ce,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,r])=>[t,String(r)]))),on=u.record(ce,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"),ve=e=>{let[t,r=""]=e.split(".");return BigInt(t)*BigInt("1000000")+BigInt(r.padEnd(6,"0"))},an=u.array(u.object({upTo:he.nullable(),cost:te}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((t,r)=>t.upTo!==null&&(r===0||ve(t.upTo)>ve(e[r-1].upTo))),"\u9636\u68AF\u4E0A\u9650\u5FC5\u987B\u9012\u589E\uFF0C\u6700\u540E\u4E00\u6863\u4E3A\u65E0\u9650"),ni=u.object({key:ce,match:on,priority:u.number().int().min(-100).max(100).default(0),cost:te.optional(),tiers:an.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"\u7EF4\u5EA6\u9700\u8981\u6307\u5B9A\u5355\u4EF7\u6216\u9636\u68AF"),ri=u.object({key:ce,match:on,factor:te.default("1"),add:te.default("0")}).strict(),sn=u.object({featureKey:ce,units:he.default("1"),cost:te,tiers:an.optional(),dimensions:u.array(ni).max(12).optional(),multipliers:u.array(ri).max(4).optional()}).strict().superRefine((e,t)=>{let r=e.dimensions??[],n=e.multipliers??[];(new Set(r.map(a=>a.key)).size!==r.length||new Set(n.map(a=>a.key)).size!==n.length)&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u548C\u500D\u7387\u7684 ID \u4E0D\u80FD\u91CD\u590D"});for(let a=0;a<r.length;a++)for(let l=a+1;l<r.length;l++){let d=r[a],c=r[l];Object.keys(d.match).length===Object.keys(c.match).length&&d.priority===c.priority&&!Object.keys(d.match).some(h=>c.match[h]!==void 0&&c.match[h]!==d.match[h])&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u53EF\u80FD\u540C\u65F6\u5339\u914D\uFF0C\u8BF7\u8C03\u6574\u4F18\u5148\u7EA7"})}let i=[e.cost,...(e.tiers??[]).map(a=>a.cost),...r.flatMap(a=>[...a.cost===void 0?[]:[a.cost],...(a.tiers??[]).map(l=>l.cost)])],o=ve(e.units);for(let a of i)for(let l=0;l<1<<n.length;l++){let d=ve(a),c=BigInt("1"),h=BigInt("0");for(let _=0;_<n.length;_++)l&1<<_&&(d*=ve(n[_].factor),c*=BigInt("1000000"),h+=ve(n[_].add));let v=(d+h*c)*BigInt("1000000"),T=c*o;(v%T!==BigInt("0")||v/T>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"})}}),St=u.object({dimension:u.string(),cycleStart:u.iso.datetime(),counterKey:u.string(),unitCost:te,units:Z,amount:Z,tier:u.number().int().nullable(),poolVersionId:u.uuid().nullable()}),da=u.object({key:ce,name:u.string().trim().min(1).max(80),rates:u.array(sn).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(),Le=u.object({poolVersionId:u.uuid(),amount:he,reset:u.enum(["month","lifetime"]).default("month"),pooled:u.boolean().optional(),rollover:u.object({cap:he,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"),ii=u.object({id:u.uuid(),entityId:u.uuid().nullable(),resourceKey:u.string(),name:u.string(),source:u.string(),granted:Z,available:Z,reserved:Z,spendable:Z,consumed:Z,forfeited:Z,rolledOver:Z,startsAt:u.iso.datetime(),expiresAt:u.iso.datetime().nullable(),eligible:u.boolean(),rates:u.array(sn)}),oi=u.object({id:u.uuid(),kind:u.string(),featureKey:u.string().nullable(),featureName:u.string().nullable(),quantity:Z,at:u.iso.datetime(),reason:u.string(),referenceId:u.uuid().nullable(),refundableQuantity:Z,allocations:u.array(u.object({balanceId:u.uuid(),amount:Z,pricing:u.array(St).optional()}))}),ai=u.object({id:u.uuid(),featureKey:u.string(),quantity:Z,status:u.enum(["pending","confirmed","released","expired"]),expiresAt:u.iso.datetime({offset:!0})}),ge=u.string().regex(/^(0|[1-9]\d{0,29})(\.\d{1,12})?$/),kt=u.object({resourceKey:u.string(),name:u.string(),granted:ge,available:ge,reserved:ge,spendable:ge,consumedInActiveGrants:ge,ownSpendable:ge,sharedSpendable:ge,sourceCount:u.number().int().nonnegative(),nextExpiry:u.object({at:u.iso.datetime(),spendable:ge}).strict().nullable()}).strict(),cn=u.object({customerId:u.uuid(),entityId:u.uuid().nullable(),evaluatedAt:u.iso.datetime(),resources:u.record(u.string(),kt)}).strict(),ne=u.object({customerId:u.uuid().optional(),entityId:u.uuid().optional()}).strict(),un=u.object({createdAt:u.iso.datetime(),id:u.uuid()}).strict(),ln=u.object({customerId:u.uuid(),entityId:u.uuid().nullable(),evaluatedAt:u.iso.datetime(),balances:u.array(ii).max(100),nextCursor:un.nullable()}).strict(),pn=ne.extend({resourceKey:qe.optional(),cursor:un.optional(),limit:u.number().int().min(1).max(100).default(50),scope:u.enum(["current","all"]).default("current")}).strict(),It=ne.extend({featureKey:ce,quantity:he.default("1"),properties:ti.optional()}).strict(),mn=u.object({allowed:u.boolean(),featureKey:ce,quantity:he,reason:u.enum(["insufficient_balance","feature_unavailable"]).nullable(),allocations:u.array(u.object({balanceId:u.uuid(),amount:Z,units:Z,pricing:u.array(St).optional()}))}),vt=It.extend({customerId:u.uuid(),entityId:u.uuid().optional(),idempotencyKey:u.string().min(1).max(120),reason:u.string().trim().max(240).default("")}).strict(),dn=vt.extend({expiresAt:u.iso.datetime()}).strict(),fn=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:te.optional()}).strict(),gn=u.object({customerId:u.uuid(),entityId:u.uuid().optional(),transactionId:u.uuid(),quantity:he,idempotencyKey:u.string().min(1).max(120),reason:u.string().trim().min(1).max(240)}).strict(),hn=u.object({customerId:u.uuid(),entityId:u.uuid().optional(),poolVersionId:u.uuid(),amount:he,expiresAt:u.iso.datetime().nullable().default(null),idempotencyKey:u.string().min(1).max(120),reason:u.string().trim().min(1).max(240)}).strict(),we=u.object({accepted:u.boolean(),operationId:u.uuid().nullable(),reason:u.string().nullable(),allocations:u.array(u.object({balanceId:u.uuid(),amount:Z,pricing:u.array(St)}).strict())}).strict(),fa=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(),ue=u.object({at:u.iso.datetime(),id:u.uuid()}).strict(),bn=ne.extend({cursor:ue.nullable().optional(),limit:u.number().int().min(1).max(100).default(50),resourceKey:qe.optional(),featureKey:ce.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"),yn=u.object({transactions:u.array(oi),nextCursor:ue.nullable()}),si=u.object({expiresAt:u.iso.datetime({offset:!0}),id:u.uuid()}).strict(),ga=u.object({reservations:u.array(ai),nextCursor:si.nullable()});var Ce=V.object({days:V.number().int().min(1).max(730),cardRequired:V.boolean(),featureAllowances:V.record(V.uuid(),V.number().int().min(0).max(1e9)),creditAmounts:V.record(V.uuid(),te)}).strict(),Ae=V.object({id:V.uuid(),planVersionId:V.uuid(),slot:V.string(),cardRequired:V.boolean(),status:V.enum(["pending","active","converted","canceled","expired","failed"]),startsAt:V.iso.datetime().nullable(),endsAt:V.iso.datetime().nullable(),createdAt:V.iso.datetime()}).strict(),et=V.object({eligible:V.boolean(),reason:V.enum(["eligible","not_configured","already_used","already_subscribed","pending","entity_requires_payer"]),policy:Ce.nullable()}).strict(),xn=V.object({planVersionId:V.uuid(),requestId:V.uuid(),currency:L.optional(),offerId:V.uuid().optional(),promotionCode:V.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 wt=k.object({group:k.string().regex(/^[a-z][a-z0-9_]{0,63}$/).default("main"),kind:k.enum(["main","addon"]).default("main")}).strict(),Ct=k.enum(["immediate","end_of_cycle"]),At=k.enum(["attach","change","cancel","resume","cancel_change"]),_t=k.object({action:At,planVersionId:k.uuid().optional(),holdingId:k.uuid().optional(),timing:Ct.optional(),currency:L.optional(),requestId:k.uuid(),entityId:k.uuid().optional(),licenseQuantities:Qe.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=k.object({action:At,direction:k.enum(["new","upgrade","downgrade","same"]),timing:Ct,group:k.string(),kind:k.enum(["main","addon"]),currentPlanVersionId:k.uuid().nullable(),targetPlanVersionId:k.uuid().nullable(),effectiveAt:k.iso.datetime(),amountDueCents:k.number().int().nullable(),currency:L,requiresCheckout:k.boolean(),estimate:k.boolean(),lineItems:k.array(k.object({description:k.string(),amountCents:k.number().int()})),nextCycle:k.object({startsAt:k.iso.datetime().nullable(),amountCents:k.number().int(),interval:k.enum(["free","month","year"]),estimate:k.boolean()}).nullable()}),Sn=k.object({id:k.uuid(),subscriptionId:k.uuid().nullable(),targetPlanVersionId:k.uuid().nullable(),action:At,timing:Ct,status:k.enum(["preparing","payment_pending","scheduled","completed","canceled","failed"]),effectiveAt:k.iso.datetime().nullable(),createdAt:k.iso.datetime()}),ci=k.object({id:k.uuid(),planVersionId:k.uuid(),planId:k.uuid(),basePlanId:k.uuid().nullable(),name:k.string(),group:k.string(),kind:k.enum(["main","addon"]),source:k.enum(["subscription","assignment","license","apple","google"]),status:k.string(),accessEnabled:k.boolean(),startsAt:k.iso.datetime().nullable(),endsAt:k.iso.datetime().nullable(),cancelAtPeriodEnd:k.boolean(),scheduledChange:Sn.nullable(),trial:Ae.nullable().optional()}),tt=k.object({customerId:k.uuid(),evaluatedAt:k.iso.datetime(),holdings:k.array(ci),changes:k.array(Sn),trials:k.array(Ae).optional()}),Pt=k.object({changeId:k.uuid(),status:k.enum(["payment_pending","scheduled","completed"]),checkout:k.object({checkoutId:k.uuid(),url:k.url()}).nullable(),paymentUrl:k.url().nullable().optional(),effectiveAt:k.iso.datetime().nullable()});var _e=S.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"),Ta=S.record(S.string().min(1).max(80),S.union([S.string().max(500),S.number().finite(),S.boolean(),S.null()])).refine(e=>Object.keys(e).length<=30,"\u6700\u591A 30 \u4E2A\u5C5E\u6027"),kn=S.object({key:_e,name:S.string().trim().min(1).max(80),description:S.string().trim().max(240),type:S.enum(["boolean","metered"]),usageType:S.enum(["consumable","non_consumable"]).optional()}),Da=kn.extend({...ae.shape,id:S.string().min(1),archived:S.boolean(),createdAt:S.iso.datetime()}),je=S.object({amountCents:S.number().int().min(0).max(1e8),currency:L,interval:S.enum(["free","month","year"]),currencyOptions:S.partialRecord(L,S.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 Ea(e,t){if(!t||t===e.currency)return e;let r=e.currencyOptions?.[t];if(r===void 0)throw new Error("Plan has no price for this currency");let n={...e.currencyOptions,[e.currency]:e.amountCents};return delete n[t],{...e,amountCents:r,currency:t,currencyOptions:n}}function Fa(e){return[e.currency,...Object.keys(e.currencyOptions??{}).map(t=>L.parse(t))]}var zt=S.object({featureId:S.string().min(1),allowance:S.number().int().min(0).max(1e9).nullable(),pooled:S.boolean().optional()}),nt=S.object({name:S.string().trim().min(1).max(80),description:S.string().trim().max(240),price:je,membership:wt.optional(),trial:Ce.nullable().optional(),licenses:S.array($e).max(20).optional(),items:S.array(zt).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")}),Na=S.object({key:_e,config:nt}),$a=ae.extend({id:S.string().min(1),key:_e,draft:nt,status:S.enum(["draft","published","archived"]),publishedVersionId:S.string().nullable(),isDefault:S.boolean(),updatedAt:S.iso.datetime()}),ui=kn.pick({key:!0,name:!0,type:!0}).extend({featureId:S.string(),allowance:S.number().int().min(0).max(1e9).nullable(),pooled:S.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"),Ve=ae.extend({id:S.string().min(1),planId:S.string().min(1),variant:S.object({basePlanId:S.uuid(),baseVersionId:S.uuid()}).nullable(),version:S.number().int().positive(),name:S.string(),description:S.string(),price:je,membership:wt.optional(),trial:Ce.nullable().optional(),licenses:S.array($e).optional(),items:S.array(ui),credits:S.array(Le).optional(),publishedAt:S.iso.datetime()}),Ot=S.object({startsAt:S.iso.datetime(),endsAt:S.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"),qa=ae.extend({id:S.string(),customerId:S.string(),planVersionId:S.string(),assignedAt:S.iso.datetime(),source:S.literal("demo"),validity:Ot.nullable().default(null),used:S.record(S.string(),S.number().int().min(0))}),La=ae.extend({id:S.string(),customerId:S.string(),at:S.iso.datetime(),message:S.string()});import{z as Q}from"zod";var rt=nt.extend({credits:Q.array(Le).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 r of Object.keys(e.trial.featureAllowances))(!e.items.some(n=>n.featureId===r&&n.allowance!==null)||e.licenses?.some(n=>n.featureId===r))&&t.addIssue({code:"custom",path:["trial","featureAllowances",r],message:"Trial allowance must reference a plan feature without licensed capacity"});for(let r of Object.keys(e.trial.creditAmounts))e.credits.some(n=>n.poolVersionId===r)||t.addIssue({code:"custom",path:["trial","creditAmounts",r],message:"Trial credit pool must belong to the plan"})}}),In=e=>Q.object({upsert:Q.array(e).max(100),remove:Q.array(Q.uuid()).max(100)}).strict(),it=Q.object({name:Q.string().trim().min(1).max(80).optional(),description:Q.string().trim().max(240).optional(),price:je.optional(),items:In(zt.strict()).optional(),credits:In(Le).optional(),licenses:Q.array($e).max(20).optional(),trial:Ce.nullable().optional()}).strict().superRefine((e,t)=>{for(let r of["items","credits"]){let n=e[r];if(!n)continue;let i=n.upsert.map(o=>"featureId"in o?o.featureId:o.poolVersionId);(new Set(i).size!==i.length||new Set(n.remove).size!==n.remove.length||i.some(o=>n.remove.includes(o)))&&t.addIssue({code:"custom",path:[r],message:"\u53D8\u4F53\u5DEE\u5F02\u4E0D\u80FD\u91CD\u590D\u6216\u540C\u65F6\u79FB\u9664\u4E0E\u8986\u76D6\u540C\u4E00\u9879"})}}),Za=Q.object({key:_e,basePlanId:Q.uuid(),baseVersionId:Q.uuid(),overrides:it}).strict(),Wa=Q.object({key:_e,name:Q.string().trim().min(1).max(80),description:Q.string().trim().max(240)}).strict();function vn(e,t,r){let n=new Map(e.map(i=>[r(i),structuredClone(i)]));for(let i of t?.remove??[])n.delete(i);for(let i of t?.upsert??[])n.set(r(i),structuredClone(i));return[...n.values()]}function Ga(e,t){let r=it.parse(t),n=structuredClone(rt.parse(e));return r.name!==void 0&&(n.name=r.name),r.description!==void 0&&(n.description=r.description),r.price!==void 0&&(n.price=structuredClone(r.price)),r.licenses!==void 0&&(n.licenses=structuredClone(r.licenses)),r.trial!==void 0&&(n.trial=structuredClone(r.trial)),n.items=vn(n.items,r.items,i=>i.featureId),n.credits=vn(n.credits,r.credits,i=>i.poolVersionId),rt.parse(n)}function li(e,t){let r=rt.parse(e),n=rt.parse(t);if(JSON.stringify(r.membership)!==JSON.stringify(n.membership))throw new Error("\u53D8\u4F53\u5FC5\u987B\u7EE7\u627F\u57FA\u7840\u5957\u9910\u7684\u7EC4\u548C\u7C7B\u578B");let i={};JSON.stringify(r.licenses??[])!==JSON.stringify(n.licenses??[])&&(i.licenses=structuredClone(n.licenses??[]));for(let d of["name","description","price","trial"])JSON.stringify(r[d])!==JSON.stringify(n[d])&&Object.assign(i,{[d]:n[d]});let o=(d,c,h)=>{let v=new Map(d.map(_=>[h(_),_])),T=new Set(c.map(h));return{upsert:c.filter(_=>JSON.stringify(v.get(h(_)))!==JSON.stringify(_)),remove:d.map(h).filter(_=>!T.has(_))}},a=o(r.items,n.items,d=>d.featureId),l=o(r.credits,n.credits,d=>d.poolVersionId);return(a.upsert.length||a.remove.length)&&(i.items=a),(l.upsert.length||l.remove.length)&&(i.credits=l),it.parse(i)}function Ya(e,t,r){let n={};for(let a of["name","description","price","trial"])t[a]!==void 0&&JSON.stringify(t[a])===JSON.stringify(r[a])&&Object.assign(n,{[a]:t[a]});let i={...n,...li(e,r)},o=(a,l,d,c)=>{let h=new Map(d.map(_=>[c(_),_])),v=new Map((a?.upsert??[]).filter(_=>JSON.stringify(h.get(c(_)))===JSON.stringify(_)).map(_=>[c(_),_]));for(let _ of l?.upsert??[])v.set(c(_),_);let T=new Set([...(a?.remove??[]).filter(_=>!h.has(_)),...l?.remove??[]]);return v.size||T.size?{upsert:[...v.values()],remove:[...T]}:void 0};return i.items=o(t.items,i.items,r.items,a=>a.featureId),t.licenses!==void 0&&i.licenses===void 0&&(i.licenses=structuredClone(t.licenses)),i.credits=o(t.credits,i.credits,r.credits,a=>a.poolVersionId),it.parse(i)}import{z as be}from"zod";var pi=be.object({name:be.string().trim().min(1,"\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0").max(80),slug:be.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")}),wn=be.object({description:be.string().trim().max(240)}),Xa=be.object({project:pi.extend({id:be.string().min(1)}),environments:be.object({sandbox:wn,live:wn})});import{z as D}from"zod";import{z as A}from"zod";import{z as mi}from"zod";var An=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,X=mi.string().max(16).regex(An,"\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 ke(e){if(typeof e!="string")return null;try{let t=Intl.getCanonicalLocales(e.trim().replaceAll("_","-"))[0];if(!t)return null;let{language:r,script:n,region:i}=new Intl.Locale(t),o=[r,n,i].filter(Boolean).join("-");return An.test(o)?o:null}catch{return null}}var di=new Set(["TW","HK","MO"]);function Cn(e){let[t,r,n]=e.split("-");if(t!=="zh")return`${t}-${new Intl.Locale(e).maximize().script??""}`;let i=r?.length===4?r:void 0,o=r?.length===4?n:r;return i?`zh-${i}`:o&&di.has(o)?"zh-Hant":"zh-Hans"}function ot(e,t,r){let n=t.map(i=>({code:X.parse(i),normalized:i}));for(let i of e){let o=ke(i);if(!o)continue;let a=n.find(c=>c.normalized===o);if(a)return a.code;let l=Cn(o),d=n.filter(c=>Cn(c.normalized)===l);if(d.length>0)return(d.find(c=>!c.normalized.includes("-")||c.normalized===l)??d[0]).code}return r}var fi=[{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 ns(e){return fi.find(t=>t.code===e)?.label??e}var Rt={"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"}},as=["zh-CN","zh-TW","zh-HK","en","ja","ko","es","fr","de","pt-BR","it","ru","vi","th","id","ar"];function Tt(e){let t=ke(e)??"en",r=t.split("-"),n=r[0]==="zh"?r.includes("Hans")?"zh-Hans":r.includes("Hant")||r.some(i=>["TW","HK","MO"].includes(i))?"zh-Hant":"zh-Hans":r[0];return Rt[n]?{locale:t,copy:Rt[n]}:{locale:"en",copy:Rt.en}}function gi(e,t,r="zh-CN"){let n=Ne(t);return en(e,t,Tt(r).locale,{currencyDisplay:"narrowSymbol",minimumFractionDigits:e%10**n===0?0:n,maximumFractionDigits:n})}function hi(e,t="zh-CN"){let r=Tt(t).locale;return e.type==="percent"?new Intl.NumberFormat(r,{style:"percent",maximumFractionDigits:0}).format(e.percentOff/100):gi(e.amountOffCents,e.currency,r)}var _n={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 jn(e,t="zh-CN",r="month"){let n=Tt(t),i=hi(e.discount,n.locale),o=e.duration.type==="repeating"?new Intl.NumberFormat(n.locale).format(e.duration.months):"",a=n.locale.split("-")[0],l=a==="zh"&&/(?:Hant|TW|HK|MO)/.test(n.locale)?"zh-Hant":a,d=e.duration.type==="repeating"&&r!=="month"?_n[l]??_n.en:e.duration.type==="repeating"&&e.duration.months===1?n.copy.repeatingOne??n.copy.repeating:n.copy[e.duration.type],c=e.duration.type==="repeating"?new Intl.NumberFormat(n.locale,{style:"unit",unit:"month",unitDisplay:"long"}).format(e.duration.months):"";return d.replace("{discount}",i).replace("{months}",o).replace("{period}",c)}var ps=A.enum(["draft","active","paused","archived"]),Pn=A.discriminatedUnion("type",[A.object({type:A.literal("percent"),percentOff:A.number().int().min(1).max(100)}).strict(),A.object({type:A.literal("amount"),amountOffCents:A.number().int().min(1).max(1e8),currency:L}).strict()]),zn=A.discriminatedUnion("type",[A.object({type:A.literal("once")}).strict(),A.object({type:A.literal("repeating"),months:A.number().int().min(1).max(36)}).strict(),A.object({type:A.literal("forever")}).strict()]),On=A.discriminatedUnion("type",[A.object({type:A.literal("all")}).strict(),A.object({type:A.literal("plans"),planIds:A.array(A.uuid()).min(1).max(50).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D")}).strict()]),bi=A.string().trim().min(1).max(40).refine(e=>!e.includes(","),"\u6807\u7B7E\u4E0D\u80FD\u5305\u542B\u9017\u53F7"),yi=A.object({firstPurchaseOnly:A.boolean(),requiredTags:A.array(bi).max(20).refine(e=>new Set(e).size===e.length,"\u6807\u7B7E\u4E0D\u80FD\u91CD\u590D")}).strict(),ms=A.object({name:A.string().trim().min(1).max(80),description:A.string().max(500),discount:Pn,duration:zn,appliesTo:On,eligibility:yi,startsAt:A.iso.datetime().nullable(),endsAt:A.iso.datetime().nullable(),totalLimit:A.number().int().min(1).max(1e6).nullable(),perCustomerLimit:A.number().int().min(1).max(10),grantWindowHours:A.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"]}),ds=A.object({code:A.string().trim().transform(e=>e.toUpperCase()).pipe(A.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:A.number().int().min(1).max(1e6).nullable(),expiresAt:A.iso.datetime().nullable(),firstPurchaseOnly:A.boolean(),minimumAmountCents:A.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 fs(){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 Dt=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function gs(e,t,r){if(e==="draft")return[];if(e==="archived")return["\u5DF2\u5F52\u6863\u7684\u4F18\u60E0\u5238\u4E0D\u80FD\u4FEE\u6539"];let n=[];return Dt(t.discount,r.discount)||n.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u6298\u6263"),Dt(t.duration,r.duration)||n.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u6301\u7EED\u65B9\u5F0F"),Dt(t.appliesTo,r.appliesTo)||n.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u9002\u7528\u5957\u9910"),t.startsAt!==r.startsAt&&n.push("\u751F\u6548\u540E\u4E0D\u80FD\u4FEE\u6539\u5F00\u59CB\u65F6\u95F4"),t.endsAt!==r.endsAt&&(r.endsAt===null||t.endsAt!==null&&Date.parse(r.endsAt)>Date.parse(t.endsAt))&&n.push("\u751F\u6548\u540E\u7ED3\u675F\u65F6\u95F4\u53EA\u80FD\u63D0\u524D"),t.totalLimit!==r.totalLimit&&(r.totalLimit===null||t.totalLimit!==null&&r.totalLimit>t.totalLimit)&&n.push("\u751F\u6548\u540E\u603B\u6B21\u6570\u53EA\u80FD\u8C03\u4F4E"),r.perCustomerLimit>t.perCustomerLimit&&n.push("\u751F\u6548\u540E\u6BCF\u4EBA\u6B21\u6570\u53EA\u80FD\u8C03\u4F4E"),n}function hs(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 xi=e=>`$${(e/100).toFixed(e%100===0?0:2)}`;function bs(e,t="zh-CN"){return jn(e,t)}function ys(e){return xi(e)}function xs(e,t){return e.startsAt&&Date.parse(e.startsAt)>t?"scheduled":e.endsAt&&Date.parse(e.endsAt)<=t?"ended":"open"}var Pe=A.object({id:A.uuid(),couponId:A.uuid(),status:A.enum(["issued","redeemed","revoked","expired"]),issuedAt:A.iso.datetime(),expiresAt:A.iso.datetime(),coupon:A.object({name:A.string(),discount:Pn,duration:zn,appliesTo:On})}),Rn=A.enum(["inactive","outside_window","not_targeted","not_first_purchase","limit_reached","sold_out"]);var Si=D.enum(["memberships","entitlements","credits"]),Tn=ne.extend({include:D.array(Si).min(1).max(3).refine(e=>new Set(e).size===e.length,"Duplicate state sections").default(["memberships","entitlements","credits"])}).strict(),ki=kt,Ii=D.object({key:D.string(),name:D.string(),type:D.enum(["boolean","metered"]),allowed:D.boolean(),allowance:D.number().nonnegative().nullable(),used:D.number().nonnegative(),remaining:D.number().nonnegative().nullable()}).strict(),Dn=D.object({customerId:D.uuid(),entityId:D.uuid().nullable(),evaluatedAt:D.iso.datetime(),membership:tt.optional(),features:D.record(D.string(),Ii).optional(),resources:D.record(D.string(),ki).optional()}).strict(),En=ne.extend({currency:L.optional()}).strict(),vi=D.object({status:D.enum(["available","current","scheduled","blocked"]),action:D.enum(["attach","change"]).nullable(),direction:D.enum(["new","upgrade","downgrade","same"]).nullable(),reason:D.enum(["current","scheduled","pending_change","ambiguous_membership","managed_by_store","managed_by_payer","currency_unavailable","available"]),holdingId:D.uuid().nullable(),trial:et.nullable()}).strict(),wi=D.object({plan:Ve,price:je.nullable(),eligibility:vi}).strict(),Fn=D.object({customerId:D.uuid(),entityId:D.uuid().nullable(),evaluatedAt:D.iso.datetime(),plans:D.array(wi)}).strict(),Nn=ne.extend({cursor:ue.nullable().optional(),limit:D.number().int().min(1).max(100).default(50),status:Pe.shape.status.optional(),from:D.iso.datetime().optional(),to:D.iso.datetime().optional()}).strict().refine(e=>!e.from||!e.to||Date.parse(e.from)<=Date.parse(e.to),"Invalid date range"),$n=D.object({offers:D.array(Pe),nextCursor:ue.nullable()}).strict();import{z as j}from"zod";var Ci=["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"],Ln=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(),qn=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(),ye=j.object({nodes:j.record(j.string(),j.object({base:qn,picker:j.string().optional(),byPlan:j.record(j.string(),qn).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 at(e){return[...e.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(t=>t[1].trim())}function st(e){let t=at(e).filter(n=>!Ci.includes(n)),r=e.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(r.includes("{{")||r.includes("}}"))&&t.push("\u65E0\u6548\u53D8\u91CF\u8BED\u6CD5"),[...new Set(t)]}function Rs(e,t,r,n=!1){let i=at(e).filter(o=>!/^(input|params)\.[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(o)&&t[o]===void 0);return i.length&&!n?{value:r,missing:i}:{value:e.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(o,a)=>t[a.trim()]??o),missing:i}}function Ts(e,t,r={}){let n=e?.nodes[t];if(!n)return;let i=n.picker?r[n.picker]??e?.pickers[n.picker]?.selected:void 0;return typeof i=="string"?n.byPlan?.[i]??n.base:n.base}import{z as Ai}from"zod";var ze=Ai.string().regex(/^[a-f0-9]{64}$/);import{z as R}from"zod";var Vn=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:te.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(),Bn=Vn.extend({id:R.uuid(),packId:R.uuid(),version:R.number().int().positive()}),Mn=ne.extend({packVersionId:R.uuid(),requestId:R.uuid()}).strict(),ct=R.object({id:R.uuid(),packVersionId:R.uuid(),name:R.string(),amount:te,amountCents:R.number().int(),currency:R.literal("USD"),status:R.enum(["created","pending","paid","expired","refunded","disputed"]),refundedCents:R.number().int().nonnegative(),shortfall:Z,at:R.iso.datetime(),paidAt:R.iso.datetime().nullable()}),qs=R.object({orders:R.array(ct),nextCursor:ue.nullable()}),Un=ne.extend({cursor:ue.nullable().optional(),limit:R.number().int().min(1).max(100).default(50),status:ct.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"),Ls=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 r=(e.action==="save"?Vn:R.object({}).strict()).safeParse(e.input);return r.success?{...e,input:r.data}:(t.addIssue({code:"custom",message:r.error.issues[0]?.message??"\u8BF7\u68C0\u67E5\u79EF\u5206\u5305"}),R.NEVER)});import{z as m}from"zod";import{z as s}from"zod";import{z as P}from"zod";var _i=["credit_balance","credit_transactions","membership","customer_plans","credit_packs","credit_pack_orders","offer_history"],Hn=P.enum(_i),Kn=P.object({source:Hn,layout:P.enum(["full","compact"]),resourceKey:qe.optional(),pageSize:P.number().int().min(1).max(50),showSources:P.boolean(),allowPurchase:P.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&&!["credit_packs","customer_plans","membership"].includes(e.source)&&t.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u5305\u3001\u5957\u9910\u4E0E\u4F1A\u5458\u7EC4\u4EF6\u53EF\u4EE5\u542F\u7528\u4EA4\u6613\u3002"})}),W=P.string().max(2e3),Zn=P.object({id:P.string().max(100),label:W,detail:P.array(W).max(12),value:W.optional(),status:W.optional(),facts:P.array(P.object({label:W,value:W}).strict()).max(1e3),purchaseId:P.uuid().optional(),membershipActions:P.array(P.object({value:P.string().max(100),label:W}).strict()).max(3).optional()}).strict(),ji=P.object({key:qe,name:W,spendable:W,reserved:W,available:W,expiry:W.nullable(),sources:P.array(Zn).max(50),sourceCount:P.number().int().nonnegative(),sourcePage:P.number().int().positive(),hasNextSources:P.boolean(),hasPreviousSources:P.boolean()}).strict(),Pi=P.object({source:Hn,status:P.enum(["idle","loading","ready","error"]),stale:P.boolean(),preview:P.boolean(),errorCode:P.string().max(80).optional(),errorMessage:W.optional(),resources:P.array(ji).max(500),rows:P.array(Zn).max(50),hasNext:P.boolean(),hasPrevious:P.boolean(),page:P.number().int().positive(),filter:P.string().max(40),updatedAt:P.iso.datetime().optional(),buyingId:P.uuid().optional(),membershipBusy:P.boolean().optional(),membershipReview:P.object({title:W,note:W,facts:P.array(P.object({label:W,value:W}).strict()).max(100)}).strict().optional(),membershipResult:W.optional()}).strict(),Us=P.object({nodes:P.record(P.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Pi)}).strict(),Hs=P.object({nodeId:P.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:P.enum(["refresh","next","previous","filter","buy_pack","membership_preview","membership_confirm","membership_dismiss","sources_next","sources_previous"]),value:P.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 Et(e){let t=st(e).map(r=>`\u672A\u77E5\u53D8\u91CF\uFF1A${r}`);for(let r=0;r<e.length;r++){if(e[r]!=="<"||!/[A-Za-z!/?{]/.test(e[r+1]??""))continue;let n=r;if(e.startsWith("<!--",r)){let i=e.indexOf("-->",r+4);r=i<0?e.length:i+2}else{let i="";for(r++;r<e.length;r++){let o=e[r];if(i)o===i&&(i="");else if(o==='"'||o==="'")i=o;else if(o===">")break}}/\{\{|\}\}/.test(e.slice(n,r+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 Gn(e){return e.replace(/[&<>"']/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[t])}function Ws(e,t,r,n=!1){let i=Et(e);if(i.length)throw new Error(i[0]);let o=[...new Set(at(e).filter(a=>t[a]===void 0))];return o.length&&!n?{value:Gn(r),missing:o}:{value:e.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(a,l)=>t[l.trim()]===void 0?a:Gn(t[l.trim()])),missing:o}}function zi(e){let t=[],r=[];function n(i,o){let a={...o,...i.type==="stack"?i.bind:{}};if(i.type==="plan_picker"&&t.push(i),i.type==="button"&&r.push({nodeId:i.id,actionId:i.action,binding:a}),i.type==="custom_html"){let l=new Set(Object.values(i.html).flatMap(d=>[...d.matchAll(/(?:^|\s)data-grow-action\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+))/gi)].flatMap(c=>{let h=c[1]??c[2]??c[3];return h.includes("&")?e.actions.filter(v=>v.type==="purchase").map(v=>v.id):[h]})));for(let d of l)r.push({nodeId:i.id,actionId:d,binding:a})}i.type==="stack"&&i.children.forEach(l=>n(l,a))}return e.pages.forEach(i=>n(i.root,{})),r.flatMap(i=>{let o=e.actions.find(d=>d.id===i.actionId);if(o?.type!=="purchase")return[];let a=o.plan!=="selected"?o.plan:i.binding.plan,l=a?void 0:o.picker??i.binding.picker??t[0]?.id;return[{...i,planId:a,picker:t.find(d=>d.id===l)}]})}function Yn(e,t){return zi(e).flatMap(r=>{let n=`\u8D2D\u4E70\u6309\u94AE ${r.nodeId}`;if(!r.planId&&!r.picker)return[`${n} \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 i=t.filter(a=>a.interval!=="free");if(r.planId)return i.some(a=>a.id===r.planId)?[]:[`${n} \u5F15\u7528\u7684\u5957\u9910\u4E0D\u53EF\u8D2D\u4E70\uFF0C\u8BF7\u9009\u62E9\u5DF2\u53D1\u5E03\u7684\u4ED8\u8D39\u5957\u9910`];let o=r.picker.planIds??[];return i.some(a=>!o.length||o.includes(a.id))?[]:[`${n} \u7684\u5957\u9910\u9009\u62E9\u6CA1\u6709\u53EF\u8D2D\u4E70\u7684\u5DF2\u53D1\u5E03\u5957\u9910`]})}import{z as I}from"zod";var B=I.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Oi=I.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Jn=I.object({version:I.literal(1),entry:B,questions:I.array(I.object({id:B,source:B,required:I.boolean()}).strict()).max(40),nodes:I.array(I.discriminatedUnion("type",[I.object({id:B,name:I.string().trim().min(1).max(60),type:I.literal("parameter_branch"),parameter:B,cases:I.array(I.object({value:I.string().max(500),target:B}).strict()).min(1).max(50),fallback:B,editorPosition:I.object({x:I.number().finite().min(-1e5).max(1e5),y:I.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),I.object({id:B,name:I.string().trim().min(1).max(60),type:I.literal("branch"),question:B,cases:I.array(I.object({value:I.union([I.string().max(500),I.boolean()]),target:B}).strict()).min(1).max(50),fallback:B,editorPosition:I.object({x:I.number().finite().min(-1e5).max(1e5),y:I.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),I.object({id:B,name:I.string().trim().min(1).max(60),type:I.literal("auth"),success:B,cancel:B,failure:B,editorPosition:I.object({x:I.number().finite().min(-1e5).max(1e5),y:I.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),I.object({id:B,name:I.string().trim().min(1).max(60),type:I.literal("purchase"),planVersionId:I.uuid(),success:B,cancel:B,failure:B,editorPosition:I.object({x:I.number().finite().min(-1e5).max(1e5),y:I.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),I.object({id:B,name:I.string().trim().min(1).max(60),type:I.literal("experiment"),experimentId:I.uuid(),revision:I.number().int().min(1),bucketVersion:I.number().int().min(1).max(1e9),variants:I.array(I.object({id:B,name:I.string().trim().min(1).max(60),weight:I.number().int().min(1).max(1e4),target:B}).strict()).min(2).max(5),editorPosition:I.object({x:I.number().finite().min(-1e5).max(1e5),y:I.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict(),I.object({id:B,name:I.string().trim().min(1).max(60),type:I.literal("complete"),editorPosition:I.object({x:I.number().finite().min(-1e5).max(1e5),y:I.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()])).max(40),routes:I.array(I.object({action:Oi,target:B}).strict()).max(40)}).strict();function Qs(e,t,r={}){let n={status:"running",nodeId:e.entry,pageId:null,answers:Object.create(null),history:[]},i=()=>({...n,answers:Object.fromEntries(Object.entries(n.answers).map(([a,l])=>[a,Array.isArray(l)?[...l]:l])),history:[...n.history]}),o=a=>{let l=new Set;for(;!t.includes(a);){if(l.has(a)){n.status="failed",n.error="\u6761\u4EF6\u5206\u652F\u5F62\u6210\u5FAA\u73AF",n.pageId=null;return}l.add(a);let d=e.nodes.find(h=>h.id===a);if(n.nodeId=a,!d){n.status="failed",n.error="\u6D41\u7A0B\u76EE\u6807\u4E0D\u5B58\u5728",n.pageId=null;return}if(["auth","purchase","experiment"].includes(d.type)){n.status="waiting",n.nodeId=d.id,n.pageId=null;return}if(d.type==="complete"){n.status="completed",n.pageId=null;return}if(d.type==="parameter_branch"){a=d.cases.find(h=>h.value===r[d.parameter])?.target??d.fallback;continue}if(d.type!=="branch")return;let c=Object.hasOwn(n.answers,d.question)?n.answers[d.question]:void 0;a=d.cases.find(h=>Array.isArray(c)?c.includes(String(h.value)):h.value===c)?.target??d.fallback}n.status="running",n.error=void 0,n.nodeId=n.pageId=a};return{start(a=e.entry){return n={status:"running",nodeId:a,pageId:null,answers:Object.create(null),history:[]},o(a),i()},answer(a,l){return n.status==="running"&&e.questions.some(d=>d.id===a)&&(n.answers[a]=Array.isArray(l)?[...l]:l),i()},move(a){return n.status!=="running"||(n.pageId&&a!==n.pageId&&n.history.push(n.pageId),o(a)),i()},back(){if(n.status!=="running")return i();let a=n.history.pop();return a&&o(a),i()},restore(a){if(a.status==="waiting"&&e.nodes.some(l=>l.id===a.nodeId&&["auth","purchase","experiment"].includes(l.type)))return n={...a,pageId:null,answers:{...a.answers},history:a.history.filter(l=>t.includes(l)).slice(-100)},i();if(a.status!=="running"||!a.pageId||!t.includes(a.pageId)||a.nodeId!==a.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"},i();n={status:"running",nodeId:a.pageId,pageId:a.pageId,answers:Object.create(null),history:a.history.filter(l=>t.includes(l)).slice(-100)};for(let l of e.questions)if(Object.hasOwn(a.answers,l.id)){let d=a.answers[l.id];(typeof d=="string"||typeof d=="boolean"||Array.isArray(d)&&d.every(c=>typeof c=="string"))&&(n.answers[l.id]=Array.isArray(d)?[...d]:d)}return i()},resolve(a){if(n.status!=="waiting")return i();let l=e.nodes.find(c=>c.id===n.nodeId);return(l?.type==="experiment"?l.variants.map(c=>c.target):l?.type==="auth"||l?.type==="purchase"?[l.success,l.cancel,l.failure]:[]).includes(a)&&o(a),i()},snapshot:i}}function Nt(e){let t=new Map,r=(n,i,o=!0,a=!1)=>{if(o=o&&!n.hidden,t.set(n.id,{node:n,page:i,visible:o,interactiveParent:a}),n.type==="stack")for(let l of n.children)r(l,i,o,a||!!n.interaction)};for(let n of e.pages)r(n.root,n.id);return t}function $t(e){let t=[],r=[],n=e.funnel;if(!n)return{errors:t,warnings:r};e.surface!=="onboarding"&&t.push("Funnel \u53EA\u7528\u4E8E\u5F15\u5BFC\u6D41\u7A0B");let i=new Set(e.pages.map(f=>f.id));for(let f of n.nodes)(i.has(f.id)||["next","back"].includes(f.id))&&t.push(`\u6D41\u7A0B\u8282\u70B9\u6807\u8BC6\u91CD\u590D\u6216\u4FDD\u7559\uFF1A${f.id}`),i.add(f.id);let o=f=>{i.has(f)||t.push(`\u6D41\u7A0B\u76EE\u6807\u4E0D\u5B58\u5728\uFF1A${f}`)};o(n.entry);let a=Nt(e),l=new Set,d=new Set;for(let f of n.questions){(l.has(f.id)||d.has(f.source))&&t.push(`\u95EE\u9898\u6807\u8BC6\u6216\u7EC4\u4EF6\u91CD\u590D\uFF1A${f.id}`),l.add(f.id),d.add(f.source);let w=a.get(f.source);(!w?.visible||w.node.type!=="stack"||!w.node.interaction||!["select","toggle","input","multiselect"].includes(w.node.interaction.type))&&t.push(`\u95EE\u9898 ${f.id} \u5FC5\u987B\u7ED1\u5B9A\u53EF\u89C1\u7684\u8F93\u5165\u7EC4\u4EF6`),w?.interactiveParent&&t.push(`\u95EE\u9898 ${f.id} \u4E0D\u80FD\u5D4C\u5165\u5176\u4ED6\u4EA4\u4E92\u7EC4\u4EF6\uFF1B\u8BF7\u5C06\u95EE\u9898\u653E\u5728\u72EC\u7ACB\u9875\u9762\u6216\u666E\u901A\u5BB9\u5668\u4E2D`)}let c=(f,w)=>{let q=n.questions.find(K=>K.id===f),x=q&&a.get(q.source)?.node;return x?.type==="stack"&&(x.interaction?.type==="input"?typeof w=="string"&&w.length<=x.interaction.maxLength:x.interaction?.type==="toggle"?typeof w=="boolean":(x.interaction?.type==="select"||x.interaction?.type==="multiselect")&&typeof w=="string"&&x.children.some(K=>K.id===w&&!K.hidden))};for(let f of n.nodes)if(f.type==="branch"){l.has(f.question)||t.push(`\u5206\u652F ${f.name} \u5F15\u7528\u7684\u95EE\u9898\u4E0D\u5B58\u5728`);let w=new Set;for(let q of f.cases){c(f.question,q.value)||t.push(`\u5206\u652F ${f.name} \u7684\u7B54\u6848\u503C\u65E0\u6548`);let x=JSON.stringify(q.value);w.has(x)&&t.push(`\u5206\u652F ${f.name} \u7684\u6761\u4EF6\u91CD\u590D`),w.add(x),o(q.target)}o(f.fallback)}for(let f of n.nodes){for(let w of Ft(f))o(w.target);f.type==="experiment"&&new Set(f.variants.map(w=>w.id)).size!==f.variants.length&&t.push(`\u5B9E\u9A8C ${f.name} \u7684\u53D8\u4F53\u6807\u8BC6\u91CD\u590D`)}for(let f of n.nodes)if(f.type==="parameter_branch"){let w=new Set;for(let q of f.cases)w.has(q.value)&&t.push(`\u53C2\u6570\u5206\u652F ${f.name} \u7684\u6761\u4EF6\u91CD\u590D`),w.add(q.value)}for(let f of a.values())if(f.node.type==="stack"&&f.node.interaction?.type==="multiselect"){let w=f.node.interaction;(w.min>w.max||w.max>f.node.children.filter(q=>!q.hidden).length)&&t.push(`\u591A\u9009\u7EC4\u4EF6 ${f.node.id} \u7684\u9009\u62E9\u6570\u91CF\u8303\u56F4\u65E0\u6548`)}for(let f of Object.values(e.strings.locales))for(let w of Object.values(f))for(let q of w.matchAll(/\{\{\s*input\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\s*\}\}/g))l.has(q[1])||t.push(`\u6587\u6848\u5F15\u7528\u7684\u95EE\u9898\u4E0D\u5B58\u5728\uFF1A${q[1]}`);let h=new Set;for(let f of n.routes)h.has(f.action)&&t.push(`\u6D41\u7A0B\u52A8\u4F5C\u8DEF\u7531\u91CD\u590D\uFF1A${f.action}`),h.add(f.action),e.actions.some(w=>w.id===f.action&&w.type==="navigate")||t.push(`\u6D41\u7A0B\u8DEF\u7531\u5FC5\u987B\u5F15\u7528\u5BFC\u822A\u52A8\u4F5C\uFF1A${f.action}`),f.target!=="back"&&o(f.target);let v=new Map(n.nodes.filter(f=>["branch","parameter_branch","experiment"].includes(f.type)).map(f=>[f.id,f])),T=new Set,_=new Set,J=f=>{if(T.has(f))return!0;if(_.has(f))return!1;let w=v.get(f);if(!w)return!1;T.add(f);let q=Ft(w).some(x=>J(x.target));return T.delete(f),_.add(f),q};return[...v.keys()].some(J)&&t.push("\u6761\u4EF6\u8282\u70B9\u4E4B\u95F4\u4E0D\u80FD\u5F62\u6210\u81EA\u52A8\u8DF3\u8F6C\u5FAA\u73AF"),n.nodes.some(f=>f.type==="complete")||r.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:r}}function Ri(e,t){let r={};if(!t||typeof t!="object"||Array.isArray(t))return r;let n=t,i=Nt(e);for(let o of e.funnel?.questions??[]){let a=i.get(o.source)?.node,l=Object.hasOwn(n,o.id)?n[o.id]:void 0;a?.type==="stack"&&(a.interaction?.type==="input"&&typeof l=="string"&&l.length<=a.interaction.maxLength&&(r[o.id]=l),a.interaction?.type==="multiselect"&&Array.isArray(l)&&l.length<=a.interaction.max&&new Set(l).size===l.length&&l.every(d=>typeof d=="string"&&a.children.some(c=>!c.hidden&&c.id===d))&&(r[o.id]=[...l]),a.interaction?.type==="toggle"&&typeof l=="boolean"&&(r[o.id]=l),a.interaction?.type==="select"&&typeof l=="string"&&a.children.some(d=>!d.hidden&&d.id===l)&&(r[o.id]=l))}return r}function Xs(e,t){if(!e.funnel||!t||!["running","waiting","completed","failed"].includes(t.status))return null;let r=new Set(e.pages.map(i=>i.id)),n=e.funnel.nodes.find(i=>i.id===t.nodeId);return t.status==="running"&&(!r.has(t.nodeId)||t.pageId!==t.nodeId)||t.status==="completed"&&(n?.type!=="complete"||t.pageId!==null)||t.status==="waiting"&&(!n||!["auth","purchase","experiment"].includes(n.type)||t.pageId!==null)||t.status==="failed"&&!n&&!r.has(t.nodeId)?null:{status:t.status,nodeId:t.nodeId,pageId:t.status==="running"?t.pageId:null,answers:Ri(e,t.answers),history:Array.isArray(t.history)?t.history.filter(i=>r.has(i)).slice(-100):[],...typeof t.error=="string"?{error:t.error.slice(0,200)}:{}}}function Qn(e){let t=[],r=[];if(!e.funnel)return{errors:t,warnings:r};let n=e.funnel,i=new Set,o=[n.entry],a=new Map,l=(h,v)=>{a.set(h,[...a.get(h)??[],...v]),o.push(...v)};for(;o.length;){let h=o.shift();if(i.has(h))continue;i.add(h);let v=n.nodes.find(w=>w.id===h);if(v){l(h,Ft(v).map(w=>w.target));continue}let T=e.pages.findIndex(w=>w.id===h),_=e.pages[T];if(!_)continue;let J=new Set,f=w=>{if(!w.hidden){if(w.type==="button"&&J.add(w.action),w.type==="custom_html")for(let q of Object.values(w.html))for(let x of q.matchAll(/data-grow-action\s*=\s*["']([a-zA-Z][a-zA-Z0-9_.-]*)["']/g))J.add(x[1]);w.type==="stack"&&w.children.forEach(f)}};f(_.root);for(let w of e.actions.filter(q=>J.has(q.id))){if(w.type!=="navigate")continue;let x=n.routes.find(K=>K.action===w.id)?.target??(w.target==="next"?e.pages[T+1]?.id:w.target);x&&x!=="back"&&l(h,[x]),x||t.push(`\u9875\u9762 ${_.name} \u7684\u4E0B\u4E00\u9875\u4E0D\u5B58\u5728\uFF0C\u8BF7\u8FDE\u63A5\u5230\u9875\u9762\u6216\u5B8C\u6210\u8282\u70B9`)}}let d=Nt(e),c=(h,v)=>{let T=new Set,_=[h];for(;_.length;){let J=_.pop();if(J===v)return!0;T.has(J)||(T.add(J),_.push(...a.get(J)??[]))}return!1};for(let[h,v]of d){let T=v.node.type==="text"?[v.node.text]:v.node.type==="button"?[v.node.label]:[];for(let _ of Object.values(e.strings.locales))for(let J of T)for(let f of(_[J]??"").matchAll(/\{\{\s*input\.([a-zA-Z][a-zA-Z0-9_-]{0,63})\s*\}\}/g)){let w=n.questions.find(x=>x.id===f[1]),q=w&&d.get(w.source);q&&(q.page===v.page||!c(q.page,v.page))&&t.push(`\u7EC4\u4EF6 ${h} \u53EA\u80FD\u5F15\u7528\u4E0A\u6E38\u9875\u9762\u7684\u95EE\u9898\uFF1A${f[1]}`)}}n.nodes.some(h=>h.type==="complete"&&i.has(h.id))||t.push("Funnel \u81F3\u5C11\u9700\u8981\u4E00\u6761\u53EF\u5230\u8FBE\u5B8C\u6210\u8282\u70B9\u7684\u8DEF\u5F84");for(let h of[...e.pages,...n.nodes])i.has(h.id)||r.push(`\u6D41\u7A0B\u8282\u70B9 ${h.name} \u4ECE\u5165\u53E3\u4E0D\u53EF\u5230\u8FBE`);return{errors:t,warnings:r}}function Ft(e){return e.type==="branch"||e.type==="parameter_branch"?[...e.cases.map((t,r)=>({handle:`case-${r}`,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,r)=>({handle:t,label:["\u6210\u529F","\u53D6\u6D88","\u5931\u8D25"][r],target:e[t]})):[]}var Ti=3,ie={nodes:150,depth:8,children:50,locales:20,actions:40,pages:20,stringLength:2e3,customHtml:32768,customCss:16384,documentBytes:2e5},Be=s.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),M=s.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Di=s.enum(["none","xs","sm","md","lg","xl"]),Ei=s.enum(["none","sm","md","lg","full"]),ut=s.string().regex(/^#[0-9a-fA-F]{6}$/),cc=s.union([s.enum(["primary","text","muted","background","surface"]),ut]),nr=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"),qt=s.union([nr,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}$/)]),Xn=s.object({primary:ut,background:ut,text:ut,radius:Ei,font:s.enum(["system","serif","rounded","mono"])}).strict(),Me=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),er=s.union([s.enum(["fit","fill"]),E(1,1200)]),Fi=s.object({top:E(0,200),right:E(0,200),bottom:E(0,200),left:E(0,200)}).strict(),Ni=s.object({top:E(-100,200),right:E(-100,200),bottom:E(-100,200),left:E(-100,200)}).strict(),rr=s.object({x:E(0,100),y:E(0,100)}).strict(),$i=s.discriminatedUnion("type",[s.object({type:s.literal("color"),color:Me}).strict(),s.object({type:s.literal("linear"),angle:E(0,360),stops:s.array(s.object({color:Me,at:E(0,100)}).strict()).min(2).max(4)}).strict(),s.object({type:s.literal("image"),src:qt,fit:s.enum(["cover","contain"]),position:rr.optional()}).strict()]),qi=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()]),Li=s.object({width:E(0,12),color:Me,style:s.enum(["solid","dashed"])}).strict(),Vi=s.object({x:E(-40,40),y:E(-40,40),blur:E(0,80),spread:E(-20,40),color:Me}).strict(),Bi=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:Me,align:s.enum(["start","center","end"]),italic:s.boolean(),decoration:s.enum(["none","underline","line-through"]),transform:s.enum(["none","uppercase"])}).strict().partial(),Re=s.object({width:er,height:er,padding:Fi,margin:Ni,gap:E(0,120),grow:s.union([s.boolean(),s.number().min(0).max(12)]),background:$i,opacity:s.number().min(0).max(1),clipContent:s.boolean(),shape:qi,border:Li,shadow:Vi,text:Bi}).strict().partial(),oe={id:Be,name:s.string().trim().min(1).max(60).optional(),hidden:s.boolean().optional(),style:Re.optional(),fallback:M.optional()},Mi=s.object({...oe,type:s.literal("text"),text:M,variant:s.enum(["title","heading","body","caption"])}).strict(),Ui=s.object({...oe,type:s.literal("image"),src:qt,localizedSrc:s.record(X,qt).optional(),alt:M,aspect:s.enum(["auto","1:1","4:3","16:9","3:1"]),fit:s.enum(["cover","contain"]),position:rr.optional()}).strict(),Hi=s.object({...oe,type:s.literal("button"),label:M,variant:s.enum(["primary","secondary","link"]),action:M}).strict(),Ki=s.object({...oe,type:s.literal("divider")}).strict(),Zi=s.object({...oe,type:s.literal("customer_data"),title:M,data:Kn}).strict(),Wi=s.object({...oe,type:s.literal("spacer"),size:Di}).strict(),Gi=s.object({...oe,type:s.literal("custom_html"),html:s.record(X,s.string().max(ie.customHtml)),css:s.string().max(ie.customCss)}).strict(),Yi=s.object({...oe,type:s.literal("price"),fallback:M,parts:s.object({current:Re.optional(),original:Re.optional(),period:Re.optional()}).strict().optional()}).strict(),Ji=s.object({...oe,type:s.literal("coupon_code"),label:M,fallback:M}).strict(),Qi=s.object({...oe,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:M,fallback:M}).strict().refine(e=>e.source!=="fixed"||!!e.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),Xi=s.object({...oe,type:s.literal("plan_picker"),label:M,fallback:M,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:Re.optional()}).strict().optional()}).strict(),eo=s.discriminatedUnion("type",[s.object({type:s.literal("input"),label:M,keyboard:s.enum(["text","email","tel","url"]),maxLength:E(1,500)}).strict(),s.object({type:s.literal("multiselect"),label:M,min:E(0,50),max:E(1,50)}).strict(),s.object({type:s.literal("select"),label:M,defaultIndex:E(0,49),purpose:s.enum(["option","package","tier"]).optional(),selectedStyle:Re.optional()}).strict(),s.object({type:s.literal("tabs"),label:M,defaultIndex:E(0,49),purpose:s.literal("tier").optional()}).strict(),s.object({type:s.literal("toggle"),label:M,defaultEnabled:s.boolean()}).strict(),s.object({type:s.literal("carousel"),label:M}).strict()]),ir=s.lazy(()=>s.object({...oe,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(to).max(ie.children),interaction:eo.optional(),bind:Ln.optional()}).strict()),to=s.lazy(()=>s.union([ir,Mi,Ui,Hi,Ki,Wi,Gi,Yi,Ji,Qi,Xi,Zi])),no=s.union([s.string().max(500),s.number().finite(),s.boolean(),s.null()]),Oe={id:M,event:M,properties:s.record(M,no).refine(e=>Object.keys(e).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},ro=s.discriminatedUnion("type",[s.object({...Oe,type:s.literal("purchase"),close:s.literal(!1),plan:s.union([s.literal("selected"),s.uuid()]),picker:Be.optional(),offer:s.enum(["scope","none"]),channel:s.enum(["web","native"])}).strict(),s.object({...Oe,type:s.literal("navigate"),target:Be,close:s.literal(!1)}).strict(),s.object({...Oe,type:s.literal("event"),close:s.boolean()}).strict(),s.object({...Oe,type:s.literal("close"),close:s.literal(!0)}).strict(),s.object({...Oe,type:s.literal("open_url"),close:s.boolean(),url:nr}).strict(),s.object({...Oe,type:s.literal("claim_offer"),close:s.boolean(),couponId:s.uuid()}).strict()]),tr=s.object({defaultLocale:X,locales:s.record(X,s.record(M,s.string().max(ie.stringLength)))}).strict(),Vt=s.enum(["popup","paywall","onboarding","page"]),or={popup:"\u5F39\u7A97",paywall:"\u4ED8\u8D39\u5899",onboarding:"\u8F6C\u5316\u6F0F\u6597",page:"\u9875\u9762"},uc={popup:"/workspace/popups",paywall:"/workspace/paywalls",onboarding:"/workspace/onboarding",page:"/workspace/pages"},io=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()]),lc={sm:360,md:420,lg:560},oo=s.object({kind:s.literal("screen"),schemaVersion:s.literal(Ti),name:s.string().trim().min(1).max(80),surface:Vt,presentation:io,theme:Xn,funnel:Jn.optional(),pages:s.array(s.object({id:Be,name:s.string().trim().min(1).max(60),root:ir,theme:Xn.optional(),source:s.object({campaignId:s.uuid(),versionId:s.uuid(),map:s.record(s.string(),Be),strings:tr.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(ie.pages),strings:tr,actions:s.array(ro).max(ie.actions)}).strict();function le(e,t){for(let r of e.pages)Ue(r.root,t)}function pc(e,t){return{...e,pages:e.pages.map((r,n)=>n===0?{...r,root:t}:r)}}var G=oo.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 r=c=>t.addIssue({code:"custom",message:c});e.pages.some(c=>c.source)&&(e.surface!=="onboarding"||!e.funnel)&&r("\u53EA\u6709 Funnel \u53EF\u4EE5\u5F15\u7528\u5DF2\u53D1\u5E03\u9875\u9762\u3002");for(let c of $t(e).errors)r(c);let n=Object.keys(e.strings.locales);n.includes(e.strings.defaultLocale)||r("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),n.length>ie.locales&&r(`\u6700\u591A ${ie.locales} \u79CD\u8BED\u8A00`);let i=new Set;for(let c of e.actions)i.has(c.id)&&r(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${c.id}`),i.add(c.id);let o=new Set;for(let c of e.pages)["next","back"].includes(c.id)&&r(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${c.id}`),o.has(c.id)&&r(`\u9875\u9762 id \u91CD\u590D\uFF1A${c.id}`),o.add(c.id);for(let c of e.actions)c.type==="navigate"&&!["next","back"].includes(c.target)&&!o.has(c.target)&&r(`\u7FFB\u9875\u76EE\u6807\u4E0D\u5B58\u5728\uFF1A${c.target}`);let a=new Set,l=0,d=!1;le(e,(c,h)=>{if(l++,h>ie.depth&&(d=!0),a.has(c.id)&&r(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${c.id}`),a.add(c.id),c.type==="button"&&!i.has(c.action)&&r(`\u6309\u94AE ${c.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${c.action}`),c.type==="customer_data"&&!["page","onboarding"].includes(e.surface)&&r("\u4E1A\u52A1\u6570\u636E\u7EC4\u4EF6\u53EA\u7528\u4E8E Pages \u6216 Funnel \u9875\u9762\u3002"),c.type==="custom_html")for(let v of Object.keys(c.html))n.includes(v)||r(`\u81EA\u5B9A\u4E49 HTML ${c.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${v}`);if(c.type==="image")for(let v of Object.keys(c.localizedSrc??{}))n.includes(v)||r(`\u56FE\u7247 ${c.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${v}`)}),l>ie.nodes&&r(`\u7EC4\u4EF6\u6700\u591A ${ie.nodes} \u4E2A`),d&&r(`\u5C42\u7EA7\u6700\u591A ${ie.depth} \u5C42`)});function Ue(e,t,r=1,n=null){if(t(e,r,n)!==!1&&e.type==="stack")for(let i of e.children)Ue(i,t,r+1,e)}function Bt(e){let t=[],r=new Set;return le(e,n=>{let i=(o,a,l)=>{r.has(o)||(r.add(o),t.push({key:o,nodeId:n.id,nodeType:n.type,field:a,required:l}))};n.type==="stack"&&n.interaction&&i(n.interaction.label,"label",!0),n.fallback&&i(n.fallback,"text",!0),n.type==="text"&&i(n.text,"text",!0),n.type==="customer_data"&&i(n.title,"title",!0),(n.type==="plan_picker"||n.type==="coupon_code")&&i(n.label,"label",!0),n.type==="countdown"&&i(n.expired,"text",!0),n.type==="button"&&i(n.label,"label",!0),n.type==="image"&&(i(`image:${n.id}`,"src",!1),i(n.alt,"alt",!1)),n.type==="custom_html"&&i(`html:${n.id}`,"html",!0)}),t}function ao(e,t,r){if(t.field==="html"){let n;return le(e,i=>{i.id===t.nodeId&&i.type==="custom_html"&&(n=i.html[r])}),n}if(t.field==="src"){let n=Lt(e,t.nodeId);return n?.type==="image"?n.localizedSrc?.[r]??(r===e.strings.defaultLocale?n.src:void 0):void 0}return e.strings.locales[r]?.[t.key]}function ar(e){let t=Bt(e).filter(n=>n.required);return Object.keys(e.strings.locales).sort((n,i)=>n===e.strings.defaultLocale?-1:i===e.strings.defaultLocale?1:0).map(n=>{let i=t.filter(o=>!ao(e,o,n)?.trim()).map(o=>o.key);return{locale:n,total:t.length,filled:t.length-i.length,missing:i,complete:i.length===0}})}function mc(e){let t=Qn(e),r=[...t.errors,...Yn(e)],n=e.actions.some(c=>typeof c.properties.templateKey=="string"&&c.properties.templateKey.startsWith("popup-coupon-"));n&&(!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-")))&&r.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 i(c,h){let v=c.type==="stack"?c.bind?.coupon??h:h;if(n&&c.type==="text"&&Object.values(e.strings.locales).some(T=>T[c.text]?.includes("{{offer."))&&!v&&r.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 T=e.actions.find(_=>_.id===c.action);T?.type==="claim_offer"&&v&&v!==T.couponId&&r.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(T=>i(T,v))}e.pages.forEach(c=>i(c.root));let o=[...$t(e).warnings,...t.warnings],a=G.safeParse(e);a.success||r.push(...a.error.issues.map(c=>c.message));for(let c of Object.values(e.strings.locales))for(let h of Object.values(c))for(let v of st(e.funnel?h.replace(/\{\{\s*(?:input|params)\.[a-zA-Z][a-zA-Z0-9_-]{0,63}\s*\}\}/g,""):h))r.push(`\u672A\u77E5\u53D8\u91CF\uFF1A${v}`);le(e,c=>{if(c.type==="customer_data"&&Object.values(e.strings.locales).some(v=>/\{\{|\}\}/.test(v[c.title]??""))&&r.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(v=>Object.values(e.strings.locales).some(T=>T[v]?.includes("{{")))&&!c.fallback&&r.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(v=>v[c.fallback]?.includes("{{"))&&r.push(`\u7EC4\u4EF6 ${c.id} \u7684\u5907\u7528\u6587\u6848\u9700\u8981\u4F7F\u7528\u9759\u6001\u6587\u5B57`),c.type==="custom_html"){for(let v of Object.values(c.html))r.push(...Et(v).map(T=>`HTML ${c.id}\uFF1A${T}`));Object.values(c.html).some(v=>v.includes("{{"))&&!c.fallback&&r.push(`HTML ${c.id} \u4F7F\u7528\u53D8\u91CF\uFF0C\u8BF7\u586B\u5199\u5907\u7528\u6587\u6848`),/\{\{|\}\}/.test(c.css)&&r.push(`HTML ${c.id} \u7684 CSS \u4E0D\u652F\u6301\u53D8\u91CF`)}c.type==="stack"&&c.bind?.picker&&Lt(e,c.bind.picker)?.type!=="plan_picker"&&r.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&&Lt(e,c.picker)?.type!=="plan_picker"&&r.push(`\u8D2D\u4E70\u52A8\u4F5C ${c.id} \u5F15\u7528\u7684\u5957\u9910\u9009\u62E9\u4E0D\u5B58\u5728`),c.type==="purchase"&&c.channel==="native"&&r.push("\u539F\u751F\u5E94\u7528\u5185\u8D2D\u4E70\u5C1A\u672A\u63A5\u5165\uFF0C\u8BF7\u4F7F\u7528 Web \u7ED3\u8D26");let l=ar(e);for(let c of l)c.complete||(c.locale===e.strings.defaultLocale?r.push(`\u9ED8\u8BA4\u8BED\u8A00 ${c.locale} \u8FD8\u6709 ${c.missing.length} \u5904\u5185\u5BB9\u6CA1\u586B`):r.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`));Bt(e).length===0&&!e.pages.some(c=>so(c.root))&&r.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(h=>co(h.root,c.id))&&o.push(`\u52A8\u4F5C ${c.id} \u6CA1\u6709\u88AB\u4EFB\u4F55\u6309\u94AE\u4F7F\u7528`);return{errors:r,warnings:o}}function so(e){let t=!1;return Ue(e,r=>{if(r.hidden)return!1;r.type==="image"&&(t=!0)}),t}function co(e,t){let r=!1;return Ue(e,n=>{if(n.type==="custom_html")for(let i of Object.values(n.html))i.includes(`data-grow-action="${t}"`)&&(r=!0)}),r}function uo(e){return ar(e).filter(t=>t.complete||t.locale===e.strings.defaultLocale).map(t=>t.locale)}function dc(e,t){return ot(t,uo(e),e.strings.defaultLocale)}function fc(e,t){let r=e.strings.locales[t]??{},n=e.strings.locales[e.strings.defaultLocale]??{},i={};for(let a of Bt(e)){if(a.field==="html"||a.field==="src")continue;let l=r[a.key]?.trim()?r[a.key]:n[a.key];l!==void 0&&(i[a.key]=l)}let o=a=>{if(a.type==="stack")return{...a,children:a.children.map(o)};if(a.type==="custom_html"){let l=a.html[t]?.trim()?a.html[t]:a.html[e.strings.defaultLocale];return{...a,html:l===void 0?{}:{[t]:l}}}if(a.type==="image"){let{localizedSrc:l,...d}=a;return{...d,src:l?.[t]??l?.[e.strings.defaultLocale]??a.src}}return a};return{...e,pages:e.pages.map(a=>({...a,root:o(a.root)})),strings:{defaultLocale:t,locales:{[t]:i}}}}function lo(e,t){let r=null;return Ue(e,n=>{if(r)return!1;n.id===t&&(r=n)}),r}function Lt(e,t){for(let r of e.pages){let n=lo(r.root,t);if(n)return n}return null}function gc(e){let t=ke(e)?.split("-")[0];return t!==void 0&&["ar","he","fa","ur"].includes(t)}function hc(e,t,r){let n={};if(!t||typeof t!="object"||Array.isArray(t))return n;let i=t;return le(e,o=>{if(o.type==="plan_picker"){let l=i[o.id];typeof l=="string"&&r?.pickers[o.id]?.options.includes(l)&&(n[o.id]=l);return}if(o.type!=="stack"||!o.interaction)return;let a=Object.hasOwn(i,o.id)?i[o.id]:void 0;["select","tabs"].includes(o.interaction.type)&&typeof a=="string"&&o.children.some(l=>l.id===a)&&(n[o.id]=a),o.interaction.type==="toggle"&&typeof a=="boolean"&&(n[o.id]=a)}),n}import{z as b}from"zod";var Te=1,Sc=b.enum(["stripe","apple","google"]),He=b.enum(["membership","credit_pack"]),kc=b.enum(["active","grace","suspended","inactive","revoked"]),po=b.strictObject({projectId:b.uuid(),environment:Fe}),se=b.string().min(1).max(256),sr=b.iso.datetime(),Ic=b.strictObject({currency:b.string().regex(/^[A-Z]{3}$/),micros:b.string().regex(/^(0|[1-9][0-9]{0,29})$/)}),mo=b.discriminatedUnion("provider",[b.strictObject({provider:b.literal("stripe"),priceId:se,productId:se}),b.strictObject({provider:b.literal("apple"),productId:se}),b.strictObject({provider:b.literal("google"),productId:se,basePlanId:se.nullable(),offerId:se.nullable()})]),vc=b.strictObject({id:b.uuid(),deliveryVersionId:b.uuid(),kind:He,binding:mo,purchaseEnabled:b.boolean()}),cr=b.strictObject({protocolVersion:b.literal(Te),bindingId:b.uuid(),idempotencyKey:b.uuid()}),fo=b.discriminatedUnion("provider",[b.strictObject({provider:b.literal("stripe"),checkoutUrl:b.url()}),b.strictObject({provider:b.literal("apple"),productId:se,appAccountToken:b.uuid()}),b.strictObject({provider:b.literal("google"),productId:se,basePlanId:se.nullable(),offerId:se.nullable(),obfuscatedAccountId:b.string().regex(/^[A-Za-z0-9_-]{1,64}$/),obfuscatedProfileId:b.uuid()})]),ur=b.strictObject({protocolVersion:b.literal(Te),id:b.uuid(),scope:po,expiresAt:sr,nextStep:fo,submissionTicket:b.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 r=e.nextStep.provider==="apple"?e.nextStep.appAccountToken:e.nextStep.provider==="google"?e.nextStep.obfuscatedProfileId:null;r!==null&&r.toLowerCase()!==e.id.toLowerCase()&&t.addIssue({code:"custom",message:"Native store context must identify this purchase intent",path:["nextStep"]})}),Mt=b.discriminatedUnion("provider",[b.strictObject({provider:b.literal("apple"),signedTransaction:b.string().min(1).max(32768)}),b.strictObject({provider:b.literal("google"),purchaseToken:b.string().min(1).max(4096)})]),wc=b.strictObject({protocolVersion:b.literal(Te),intentId:b.uuid(),evidence:Mt}),Cc=b.strictObject({protocolVersion:b.literal(Te),intentId:b.uuid(),state:b.enum(["ready","pending","processing","fulfilled","rejected","ownership_conflict"]),purchaseId:b.uuid().nullable(),finishTransactionKeys:b.array(b.string().min(1).max(256)).max(50),retryAt:sr.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"]})}),lr=b.strictObject({protocolVersion:b.literal(Te),evidence:b.array(b.discriminatedUnion("provider",[Mt.options[0],Mt.options[1].extend({productId:se})])).min(1).max(50)}),pr=b.strictObject({protocolVersion:b.literal(Te),results:b.array(b.strictObject({index:b.number().int().nonnegative(),state:b.enum(["restored","processing","pending_claim","ownership_conflict","rejected","unsupported"]),purchaseId:b.uuid().nullable(),finishTransactionKeys:b.array(b.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(n=>n.index)).size!==e.length||e.some(n=>n.index>=e.length))&&t.addIssue({code:"custom",message:"Restoration must cover every input index exactly once"})})});import{z as C}from"zod";var mr=C.union([C.string().max(500),C.number().finite(),C.boolean()]),dr=e=>{let t=C.record(C.string().min(1).max(80),e);return C.custom(r=>r!==null&&typeof r=="object"&&!Array.isArray(r)&&!Object.hasOwn(r,"__proto__"),"\u5C5E\u6027\u952E\u4E0D\u53EF\u7528").pipe(t).refine(r=>Object.keys(r).length<=30,"\u6700\u591A 30 \u4E2A\u5C5E\u6027").refine(r=>new TextEncoder().encode(JSON.stringify(r)).length<=16384,"\u5C5E\u6027\u5185\u5BB9\u8FC7\u5927")},fr=dr(mr),gr=dr(mr.nullable()),Ut=C.array(C.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"),Ht=C.string().trim().max(80),Kt=C.union([C.email().max(254),C.literal("")]),hr=C.object({externalUserId:C.string().trim().min(1).max(255),name:Ht.default(""),email:Kt.default(""),tags:Ut.default([]),metadata:gr.default({})}).strict(),Ke=C.object({id:C.uuid(),externalUserId:C.string().min(1).max(255),name:Ht,email:Kt,metadata:fr,tags:Ut,revision:C.number().int().nonnegative(),createdAt:C.iso.datetime(),updatedAt:C.iso.datetime()}),br=C.object({customer:Ke,changed:C.boolean(),replayed:C.boolean()}),go=C.discriminatedUnion("type",[C.object({type:C.literal("id"),value:C.uuid()}).strict(),C.object({type:C.literal("externalUserId"),value:C.string().trim().min(1).max(255)}).strict()]),ho=C.object({name:Ht.optional(),email:Kt.optional(),tags:Ut.optional(),metadata:gr.optional()}).strict().refine(e=>Object.keys(e).length>0,"\u8BF7\u63D0\u4F9B\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"),Zt=C.object({lookup:go}).strict(),yr=Zt.extend({revision:C.number().int().nonnegative(),requestId:C.uuid(),patch:ho}).strict(),xr=C.object({search:C.string().trim().max(200).default(""),tag:C.string().trim().max(40).default(""),planId:C.union([C.uuid(),C.literal("")]).default(""),versionId:C.union([C.uuid(),C.literal("")]).default(""),holdingStatus:C.enum(["","active","scheduled","expired","unavailable","none"]).default(""),subscriptionStatus:C.enum(["","active","trialing","past_due","unpaid","incomplete","canceled","incomplete_expired","paused"]).default(""),createdFrom:C.union([C.iso.datetime(),C.literal("")]).default(""),createdUntil:C.union([C.iso.datetime(),C.literal("")]).default(""),offset:C.coerce.number().int().min(0).max(1e5).default(0),limit:C.coerce.number().int().min(1).max(100).default(50)}).strict(),Sr=C.object({customers:Ke.array(),hasMore:C.boolean(),total:C.number().int().nonnegative().nullable(),evaluatedAt:C.iso.datetime()});function jc(e,t){let r={...e};for(let[n,i]of Object.entries(t))i===null?delete r[n]:Object.defineProperty(r,n,{value:i,enumerable:!0,writable:!0,configurable:!0});return fr.parse(r)}import{z as F}from"zod";var kr=F.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ec=F.object({enabled:F.boolean(),trigger:kr,tags:F.array(F.string().trim().min(1).max(40).refine(e=>!e.includes(","))).max(20).refine(e=>new Set(e).size===e.length),priority:F.number().int().min(-1e3).max(1e3),cooldownHours:F.number().int().min(0).max(720)}).strict(),bo=F.object({id:F.uuid(),campaignId:F.uuid(),versionId:F.uuid(),popup:G,capabilities:ye.optional(),locale:X,expiresAt:F.iso.datetime()}),Ir=bo.extend({popup:G.nullable(),contentTag:ze,capabilities:ye}),vr=F.object({locale:F.string().max(35).optional(),acceptLanguages:F.array(F.string().max(35)).max(10).optional()}),wr=F.discriminatedUnion("type",[F.object({eventId:F.uuid(),deliveryId:F.uuid(),type:F.literal("shown"),locale:X.optional()}).strict(),F.object({eventId:F.uuid(),deliveryId:F.uuid(),type:F.literal("action"),actionId:kr}).strict(),F.object({eventId:F.uuid(),deliveryId:F.uuid(),type:F.literal("closed"),reason:F.enum(["close_button","escape","action","destroy","timeout"])}).strict()]);var yo=m.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"]),Cr={scope:ae,permissions:m.array(yo),expiresAt:m.iso.datetime().nullable()},nu=m.discriminatedUnion("kind",[m.object({...Cr,kind:m.literal("server"),keyId:m.string().min(1)}),m.object({...Cr,kind:m.literal("customer"),customerId:m.string().min(1),entityId:m.uuid().nullable().optional(),expiresAt:m.iso.datetime()})]),O=m.object({requestId:m.uuid(),scope:ae}),xo=hr.strict(),So=O.extend({customer:Ke,created:m.boolean()}),ko=O.extend({plans:m.array(Ve)}),Io=m.object({customerId:m.string().min(1).max(255).optional(),entityId:m.uuid().optional()}).strict(),vo=m.enum(["unassigned","unknown","scheduled","active","expired"]),wo=m.object({customerId:m.string().min(1),evaluatedAt:m.iso.datetime(),status:vo,validity:Ot.nullable(),planVersion:Ve.nullable(),holdings:m.array(m.object({id:m.uuid(),planVersionId:m.uuid(),source:m.enum(["subscription","assignment","license","license_pool","entity_pool"])})).optional(),entitlements:m.array(m.object({featureId:m.string(),featureKey:m.string(),featureName:m.string(),type:m.enum(["boolean","metered"]),allowance:m.number().int().nonnegative().nullable(),used:m.number().finite().nonnegative(),remaining:m.number().finite().nonnegative().nullable(),allowed:m.boolean(),sources:m.array(m.object({holdingId:m.uuid(),planVersionId:m.uuid(),group:m.string(),kind:m.enum(["main","addon"]),allowance:m.number().nullable()})).optional()}))}),Co=O.extend(wo.shape),Ao=m.enum(["UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","INTERNAL_ERROR"]),ru=m.object({requestId:m.uuid(),error:m.object({code:Ao,message:m.string()})});function Ar(){return O.extend({offer:Pe.nullable(),reason:Rn.nullable()})}var iu={getPage:{method:"POST",path:"pages/get",permission:"popups:resolve",audience:"customer",request:m.object({pageId:m.uuid(),locale:X.optional(),entityId:m.uuid().optional(),cachedContentTag:ze.optional()}).strict(),response:O.extend({pageId:m.uuid(),versionId:m.uuid(),locale:X,document:G.nullable(),contentTag:ze,capabilities:ye})},listOfferHistory:{method:"POST",path:"offers/history",permission:"offers:resolve",audience:"either",request:Nn,response:O.extend($n.shape)},getCustomerState:{method:"POST",path:"customer-state",permission:"entitlements:read",audience:"either",request:Tn,response:O.extend({state:Dn})},listCustomerPlans:{method:"POST",path:"customer-plans",permission:"plans:read",audience:"either",request:En,response:O.extend(Fn.shape)},getTrialEligibility:{method:"POST",path:"memberships/trial/eligibility",permission:"billing:read",audience:"customer",request:m.object({planVersionId:m.uuid()}).strict(),response:O.extend({eligibility:et})},startTrial:{method:"POST",path:"memberships/trial",permission:"billing:write",audience:"customer",request:xn,response:O.extend({trial:Ae,checkout:m.object({checkoutId:m.uuid(),url:m.url()}).nullable(),discount:m.object({couponId:m.uuid(),offerId:m.uuid().nullable(),promotionCode:m.string().nullable()}).nullable().optional()})},restorePurchases:{method:"POST",path:"purchases/restore",permission:"billing:write",audience:"customer",request:lr,response:O.extend(pr.shape)},createPurchaseIntent:{method:"POST",path:"purchases/intents",permission:"billing:write",audience:"customer",request:cr,response:O.extend({intent:ur})},getEntities:{method:"POST",path:"entities/list",permission:"customers:read",audience:"server",request:tn,response:O.extend({state:Xe})},manageEntity:{method:"POST",path:"entities/manage",permission:"customers:write",audience:"server",request:nn,response:O.extend({state:Xe})},manageLicense:{method:"POST",path:"licenses/manage",permission:"billing:write",audience:"server",request:rn,response:O.extend({state:Xe,billing:m.object({status:m.enum(["payment_pending","scheduled","completed"]),paymentUrl:m.url().nullable(),effectiveAt:m.iso.datetime().nullable()}).optional()})},listCreditPacks:{method:"POST",path:"credits/packs",permission:"credits:read",audience:"either",request:ne,response:O.extend({packs:m.array(Bn)})},listCreditPackOrders:{method:"POST",path:"credits/packs/orders",permission:"credits:read",audience:"either",request:Un,response:O.extend({orders:m.array(ct),nextCursor:ue.nullable()})},createCreditPackCheckout:{method:"POST",path:"credits/packs/checkout",permission:"billing:write",audience:"either",request:Mn,response:O.extend({orderId:m.uuid(),url:m.url()})},listCreditTransactions:{method:"POST",path:"credits/transactions",permission:"credits:read",audience:"either",request:bn,response:O.extend(yn.shape)},listCreditBalances:{method:"POST",path:"credits/batches",permission:"credits:read",audience:"either",request:pn,response:O.extend(ln.shape)},getBalances:{method:"POST",path:"credits/balances",permission:"credits:read",audience:"either",request:ne,response:O.extend({account:cn})},checkCredits:{method:"POST",path:"credits/check",permission:"credits:read",audience:"either",request:It,response:O.extend(mn.shape)},consumeCredits:{method:"POST",path:"credits/consume",permission:"credits:consume",audience:"server",request:vt,response:O.extend(we.shape)},reserveCredits:{method:"POST",path:"credits/reserve",permission:"credits:consume",audience:"server",request:dn,response:O.extend(we.shape)},finalizeCredits:{method:"POST",path:"credits/finalize",permission:"credits:consume",audience:"server",request:fn,response:O.extend(we.shape)},refundCredits:{method:"POST",path:"credits/refund",permission:"credits:manage",audience:"server",request:gn,response:O.extend(we.shape)},grantCredits:{method:"POST",path:"credits/grant",permission:"credits:manage",audience:"server",request:hn,response:O.extend(we.shape)},refreshSurface:{method:"POST",path:"surfaces/context",permission:"popups:resolve",audience:"customer",request:m.object({deliveryId:m.uuid(),locale:m.string().max(35).optional(),currency:L.optional()}).strict(),response:O.extend({capabilities:ye})},purchaseSurface:{method:"POST",path:"surfaces/purchase",permission:"billing:write",audience:"customer",request:m.object({deliveryId:m.uuid(),actionId:m.string().min(1).max(64),nodeId:m.string().min(1).max(64),planId:m.uuid().optional(),currency:L.optional(),requestId:m.uuid(),reviewKey:m.string().regex(/^[a-f0-9]{64}$/).optional()}).strict(),response:O.extend({checkoutId:m.uuid().nullable(),url:m.url().nullable(),trial:Ae.optional(),membershipPreview:jt.optional(),reviewKey:m.string().regex(/^[a-f0-9]{64}$/).optional(),membership:Pt.optional(),discount:m.object({couponId:m.uuid(),offerId:m.uuid().nullable(),promotionCode:m.string().nullable()}).nullable()})},createCheckout:{method:"POST",path:"billing/checkout",permission:"billing:write",audience:"customer",request:m.object({planVersionId:m.uuid(),currency:L.optional(),requestId:m.uuid(),licenseQuantities:Qe.optional(),offerId:m.uuid().optional(),promotionCode:m.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:O.extend({checkoutId:m.uuid(),url:m.url(),discount:m.object({couponId:m.uuid(),offerId:m.uuid().nullable(),promotionCode:m.string().nullable()}).nullable()})},getMemberships:{method:"GET",path:"memberships",permission:"billing:read",audience:"customer",request:m.object({entityId:m.uuid().optional()}).strict(),response:O.extend({membership:tt})},previewMembership:{method:"POST",path:"memberships/preview",permission:"billing:read",audience:"customer",request:_t,response:O.extend({preview:jt})},manageMembership:{method:"POST",path:"memberships/manage",permission:"billing:write",audience:"customer",request:_t,response:O.extend(Pt.shape)},listSubscriptions:{method:"GET",path:"billing/subscriptions",permission:"billing:read",audience:"customer",request:m.object({}).strict(),response:O.extend({subscriptions:m.array(m.object({id:m.uuid(),status:m.string(),planVersionId:m.uuid().nullable(),startsAt:m.iso.datetime(),endsAt:m.iso.datetime(),cancelAtPeriodEnd:m.boolean(),accessEnabled:m.boolean()}))})},resolvePopup:{method:"POST",path:"popups/resolve",permission:"popups:resolve",audience:"customer",request:vr.extend({currency:L.optional(),trigger:m.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),requestId:m.uuid(),cachedContentTag:ze.optional()}).strict(),response:O.extend({delivery:Ir.nullable()})},trackPopup:{method:"POST",path:"popups/events",permission:"events:write",audience:"customer",request:wr,response:O.extend({accepted:m.literal(!0)})},createCustomer:{method:"POST",path:"customers",permission:"customers:write",audience:"server",request:xo,response:So},getCustomer:{method:"POST",path:"customers/get",permission:"customers:read",audience:"server",request:Zt,response:O.extend({customer:Ke})},listCustomers:{method:"POST",path:"customers/list",permission:"customers:read",audience:"server",request:xr,response:O.extend(Sr.shape)},updateCustomer:{method:"POST",path:"customers/update",permission:"customers:write",audience:"server",request:yr,response:O.extend(br.shape)},listPlans:{method:"GET",path:"plans",permission:"plans:read",audience:"either",request:m.object({}).strict(),response:ko},getEntitlements:{method:"POST",path:"entitlements",permission:"entitlements:read",audience:"either",request:Io,response:Co},createSession:{method:"POST",path:"customer-sessions",permission:"sessions:create",audience:"server",request:m.object({customerId:m.string().min(1),entityId:m.uuid().optional()}).strict(),response:O.extend({customerToken:m.string().min(1),expiresAt:m.iso.datetime()})},listOffers:{method:"GET",path:"offers",permission:"offers:resolve",audience:"customer",request:m.object({}).strict(),response:O.extend({offers:m.array(Pe)})},claimOffer:{method:"POST",path:"offers/claim",permission:"offers:resolve",audience:"customer",request:m.object({deliveryId:m.uuid(),actionId:m.string().min(1).max(64),couponId:m.uuid(),requestId:m.uuid()}).strict(),response:Ar()},grantOffer:{method:"POST",path:"offers/grant",permission:"offers:grant",audience:"server",request:m.object({customerId:m.string().min(1).max(255),couponId:m.uuid(),requestId:m.uuid()}).strict(),response:Ar()}};var Pr={primary:"#2C3C96",background:"#FFFFFF",text:"#1B1D24",radius:"md",font:"system"},Ze=(e,t,r,n,i)=>({kind:"screen",schemaVersion:3,name:e,surface:"popup",presentation:{type:"modal",size:"md"},theme:{...Pr},pages:[{id:"main",name:"\u4E3B\u9875\u9762",root:t}],strings:{defaultLocale:"zh-CN",locales:{"zh-CN":r,en:n}},actions:i}),De=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}}}),lt={id:"dismiss",type:"close",event:"popup.dismissed",properties:{},close:!0},_r=[{id:"blank",label:"\u7A7A\u767D",description:"\u4E00\u4E2A\u6807\u9898\u548C\u4E00\u4E2A\u6309\u94AE\uFF0C\u4ECE\u96F6\u5F00\u59CB\u642D\u3002",document:Ze("\u672A\u547D\u540D\u5F39\u7A97",De([{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"},[lt])},{id:"announcement",label:"\u516C\u544A",description:"\u65B0\u529F\u80FD\u6216\u91CD\u8981\u901A\u77E5\uFF0C\u4E00\u4E2A\u4E3B\u6309\u94AE\u3002",document:Ze("\u65B0\u529F\u80FD\u516C\u544A",De([{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},lt])},{id:"upgrade",label:"\u5347\u7EA7\u5230 Pro",description:"\u5217\u51FA\u51E0\u9879\u6743\u76CA\uFF0C\u5F15\u5BFC\u5347\u7EA7\u3002",document:Ze("\u5347\u7EA7\u5230 Pro",De([{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},lt])},{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:{...Ze("\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},lt]),theme:{...Pr,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:Ze("\u6EE1\u610F\u5EA6\u8C03\u67E5",De([{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 pt(e="blank"){let t=_r.find(r=>r.id===e)??_r[0];return structuredClone(t.document)}var jr=(e,t,r)=>({type:"stack",id:e,name:"Web \u81EA\u9002\u5E94\u5E03\u5C40",direction:"horizontal",align:"center",justify:"center",children:[{...De(t),id:`${e}_intro`,name:"\u4ECB\u7ECD",style:{width:480,gap:20,padding:{top:0,right:0,bottom:0,left:0}}},{...De(r),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 au(e,t="blank"){let r=pt(t);if(e==="popup"||(r.surface=e,r.presentation={type:"fullscreen"},e==="page"))return r;if(e==="paywall"){let i=pt("upgrade");i.actions=i.actions.map(a=>a.id==="upgrade"&&a.type==="event"?{...a,event:"paywall.upgrade_clicked",properties:{},close:!1}:a),i.strings.locales["zh-CN"].cta="\u4E86\u89E3\u5347\u7EA7\u65B9\u6848",i.strings.locales.en.cta="Explore upgrade options",i.strings.locales["zh-CN"].body="\u4E3A\u4F60\u7684\u5DE5\u4F5C\u533A\u9009\u62E9\u9002\u5408\u7684\u529F\u80FD\u4E0E\u534F\u4F5C\u65B9\u5F0F\u3002",i.strings.locales.en.body="Find the right features and collaboration tools for your workspace.";let o=i.pages[0].root.children;return i.pages[0].root=jr("root",[...o.slice(0,2),{type:"text",id:"body",text:"body",variant:"body",style:{text:{color:"muted"}}}],o.slice(2)),{...i,surface:e,presentation:{type:"fullscreen"},name:"\u9AD8\u7EA7\u529F\u80FD\u4ED8\u8D39\u5899"}}r.name="\u65B0\u7528\u6237\u5F15\u5BFC",r.pages=[],r.actions=[],r.strings.locales={"zh-CN":{},en:{}};let n=[["\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 i=0;i<n.length;i++){let o=`step${i+1}`,[a,l,d,c]=n[i],h=jr(`${o}_root`,[{type:"text",id:`${o}_step`,text:`${o}.step`,variant:"caption",style:{text:{color:"primary",weight:700}}},{type:"text",id:`${o}_title`,text:`${o}.title`,variant:"title"},{type:"text",id:`${o}_body`,text:`${o}.body`,variant:"body",style:{text:{color:"muted"}}}],[{type:"text",id:`${o}_detail_title`,text:`${o}.detail_title`,variant:"heading"},{type:"text",id:`${o}_detail_body`,text:`${o}.detail_body`,variant:"body",style:{text:{color:"muted"}}},{type:"divider",id:`${o}_divider`},{type:"stack",id:`${o}_controls`,name:"\u9875\u9762\u64CD\u4F5C",direction:"horizontal",align:"center",justify:"end",children:[...i?[{type:"button",id:`${o}_back`,label:"back",variant:"secondary",action:"go_back",style:{width:"fit"}}]:[],{type:"button",id:`${o}_cta`,label:`${o}.cta`,variant:"primary",action:`${o}_continue`,style:{width:"fit"}}],style:{gap:8,padding:{top:0,right:0,bottom:0,left:0}}}]);r.pages.push({id:o,name:`\u7B2C ${i+1} \u9875`,root:h}),Object.assign(r.strings.locales["zh-CN"],{[`${o}.title`]:a,[`${o}.body`]:l,[`${o}.cta`]:i===2?"\u5F00\u59CB\u4F7F\u7528":"\u7EE7\u7EED",[`${o}.step`]:`\u7B2C ${i+1} / 3 \u6B65`,[`${o}.detail_title`]:["\u4E86\u89E3\u5DE5\u4F5C\u533A","\u9009\u62E9\u4F7F\u7528\u65B9\u5F0F","\u5F00\u59CB\u4F53\u9A8C"][i],[`${o}.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"][i],back:"\u8FD4\u56DE"}),Object.assign(r.strings.locales.en,{[`${o}.title`]:d,[`${o}.body`]:c,[`${o}.cta`]:i===2?"Get started":"Continue",[`${o}.step`]:`Step ${i+1} of 3`,[`${o}.detail_title`]:["Explore your workspace","Choose how you work","Start exploring"][i],[`${o}.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."][i],back:"Back"}),r.actions.push(i===2?{id:`${o}_continue`,type:"event",event:"onboarding.completed",properties:{},close:!0}:{id:`${o}_continue`,type:"navigate",target:`step${i+2}`,event:"onboarding.next",properties:{},close:!1})}return r.actions.push({id:"go_back",type:"navigate",target:"back",event:"onboarding.back",properties:{},close:!1}),r}function lu(e){let t=pt();return{...t,name:`\u672A\u547D\u540D${or[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 U}from"zod";var fu=U.object({id:U.uuid(),key:U.string().nullable(),label:U.string().min(1).max(80),description:U.string().max(300),category:U.string().min(1).max(40),tags:U.array(U.string().max(30)).max(10),surface:Vt,source:U.enum(["official","private"]),document:G,revision:U.number().int().positive(),archived_at:U.string().nullable(),created_at:U.string()}),gu=U.object({projectId:U.uuid(),environmentId:U.uuid(),label:U.string().trim().min(1).max(80),description:U.string().trim().max(300),category:U.string().trim().min(1).max(40),document:G}),hu=U.object({projectId:U.uuid(),environmentId:U.uuid(),id:U.uuid(),revision:U.number().int().positive()});import{z as p}from"zod";import{z as xe}from"zod";var Wt=xe.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),mt=xe.record(Wt,xe.union([xe.string().max(500),xe.boolean(),xe.array(Wt).max(50)])).refine(e=>Object.keys(e).length<=40,"Too many answers"),We=xe.record(Wt,xe.string().max(500)).refine(e=>Object.keys(e).length<=20,"Too many parameters").refine(e=>Object.entries(e).every(([t,r])=>!/^(?:api_?key|authorization|password|(?:customer|run|visitor)_?token|access_?token)$/i.test(t)&&!/gg_(?:sk|ct|fr|fv)_[A-Za-z0-9_-]{20,}/.test(r)),"Credentials cannot be Funnel parameters");function Su(e){let t=Object.create(null);for(let[r,n]of new URL(e).searchParams)Object.hasOwn(t,r)||(t[r]=n);return We.parse(t)}function ku(e,t,r){let n=new Set,i=e.pages.find(o=>o.id===t);return i&&le({pages:[i]},o=>{if(o.hidden)return!1;n.add(o.id)}),Object.fromEntries((e.funnel?.questions??[]).filter(o=>n.has(o.source)&&Object.hasOwn(r,o.id)).map(o=>[o.id,r[o.id]]))}var zr=p.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),Gt=p.string().regex(/^gg_ct_[A-Za-z0-9_-]{32,128}$/),ju=p.discriminatedUnion("operation",[p.object({operation:p.literal("answers"),requestId:p.uuid(),nodeId:p.string().max(64),revision:p.number().int().nonnegative(),answers:mt,customerToken:Gt.optional()}).strict(),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(),parameters:We.optional()}).strict(),p.object({operation:p.literal("revoke"),runId:p.uuid()}).strict(),p.object({operation:p.literal("get"),customerToken:Gt.optional()}).strict(),p.object({operation:p.literal("link"),runToken:zr}).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(),customerToken:Gt.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()]),_o=p.object({id:p.uuid(),campaignId:p.uuid(),versionId:p.uuid(),document:G,capabilities:ye,locale:p.string(),nodeId:p.string(),history:p.array(p.string()),answers:mt,answersRevision:p.number().int().nonnegative(),parameters:We,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()}))}),Pu=p.object({run:_o.optional(),runToken:zr.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:L,interval:p.enum(["free","month","year"]).nullable()}).optional(),accepted:p.boolean().optional()}),zu=p.object({references:p.array(p.object({id:p.uuid(),name:p.string(),versionId:p.uuid(),version:p.number(),document:G})).default([]),pages:p.array(p.object({id:p.uuid(),name:p.string(),versionId:p.uuid(),version:p.number(),document:G})).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()}))}),Ou=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()}))}),Ru=p.array(p.object({id:p.uuid(),version_id:p.uuid(),locale:p.string(),status:p.enum(["running","completed","closed"]),created_at:p.iso.datetime({offset:!0}),customer_id:p.uuid().nullable(),answers:mt,parameters:We,questions:p.array(p.object({id:p.string(),label:p.string()}))}));var Yt={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 Eu(e,t,r=[]){let n=ke(t)??"en",i=n.split("-")[0],o=i==="zh"&&/(?:Hant|TW|HK|MO)/.test(n)?"zh-Hant":i,a=Yt[o]??Yt.en,l=Yt[o]?n:"en",d=_=>new Intl.NumberFormat(l).format(_),c=_=>new Intl.DateTimeFormat(l,{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(new Date(_))+" UTC",h=[e.appliesTo.type==="all"?a[0]:`${a[1]}${r.length?`: ${r.slice(0,3).join(", ")+(r.length>3?` (+${d(r.length-3)})`:"")}`:""}`,e.eligibility.firstPurchaseOnly?a[3]:a[2],e.eligibility.requiredTags.length?`${a[4]}: ${e.eligibility.requiredTags.join(", ")}`:null].filter(Boolean).join(" \xB7 "),v=[e.startsAt?`${a[5]}: ${c(e.startsAt)}`:null,e.endsAt?`${a[6]}: ${c(e.endsAt)}`:a[7]].filter(Boolean).join(" \xB7 "),T=[h,v,`${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:h,validity:v,terms:T}}var Jt={"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 Or(e){return e.actions.map(t=>t.properties.templateKey).find(t=>typeof t=="string"&&t.startsWith("popup-coupon-"))}function qu(e,t){let r=Or(e);if(!r||!Object.hasOwn(Jt,r))return e;let n=i=>{let o={...i.root.bind,coupon:t};return i.root.bind?.coupon!==t&&delete o.promotionCode,{bind:o}};return{...e,pages:e.pages.map(i=>({...i,root:{...i.root,...n(i)}})),actions:e.actions.map(i=>i.properties.templateKey===r&&i.type!=="navigate"&&i.type!=="close"?{id:i.id,type:"claim_offer",couponId:t,event:"offer.claimed",properties:i.properties,close:i.close}:i)}}function Lu(e){let t=Or(e),r=t?Jt[t]:void 0;return!r||e.actions.some(n=>n.type==="claim_offer")?e:{...e,strings:{...e.strings,locales:Object.fromEntries(Object.entries(e.strings.locales).map(([n,i])=>[n,Object.fromEntries(Object.entries(i).map(([o,a])=>[o,a.replaceAll("{{offer.discount}}",r.discount).replaceAll("{{offer.headline}}",n.startsWith("zh")?r.zh:r.en).replaceAll("{{offer.terms}}",n.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 Mu(e,t,r,n,i){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 o=new Set,a=e.pages.find(x=>x.id===i);if(a&&!a.source)throw new Error("\u9875\u9762\u6807\u8BC6\u5DF2\u5B58\u5728\u3002");let l=x=>{if(Array.isArray(x))x.forEach(l);else if(x&&typeof x=="object"){let K=x;typeof K.id=="string"&&o.add(K.id),Object.values(K).forEach(l)}};l(t.pages),t.actions.forEach(x=>o.add(x.id)),Object.values(t.strings.locales).forEach(x=>Object.keys(x).forEach(K=>o.add(K)));let d=Math.max(-1,...Object.values(a?.source?.map??{}).map(x=>Number(x.match(/_k(\d+)$/)?.[1]??-1)))+1,c=Object.fromEntries([...o].map(x=>[x,a?.source?.map[x]??`${i}_k${d++}`]));c[t.pages[0].id]=i;let h=(x,K="")=>typeof x=="string"?["id","text","title","alt","label","action","fallback","expired","picker","target"].includes(K)&&Object.hasOwn(c,x)?c[x]:x.replace(/\bdata-grow-action\s*=\s*(["'])([a-zA-Z][a-zA-Z0-9_.-]{0,63})\1/gi,(de,Ie,Je)=>Object.hasOwn(c,Je)?`data-grow-action=${Ie}${c[Je]}${Ie}`:de):Array.isArray(x)?x.map(de=>h(de)):x&&typeof x=="object"?Object.fromEntries(Object.entries(x).map(([de,Ie])=>[de,h(Ie,de)])):x,v=h(t.pages[0].root),T=structuredClone(e.strings.locales),_=new Set(Object.values(a?.source?.map??{}));Object.values(T).forEach(x=>_.forEach(K=>delete x[K]));for(let[x,K]of Object.entries(T)){let de=t.strings.locales[x]??t.strings.locales[t.strings.defaultLocale];for(let[Ie,Je]of Object.entries(de))K[c[Ie]]=Je}let J=t.actions.map(x=>({id:c[x.id],type:"navigate",target:i,event:x.event,properties:x.properties,close:!1})),f={id:i,name:t.name.slice(0,60),root:v,theme:t.theme,source:{campaignId:r,versionId:n,map:c,strings:t.strings},...a?.editorPosition?{editorPosition:a.editorPosition}:{}},w=e.actions.filter(x=>!_.has(x.id)),q=new Set([...w,...J].map(x=>x.id));return G.parse({...e,funnel:{...e.funnel,routes:e.funnel.routes.filter(x=>q.has(x.action))},pages:a?e.pages.map(x=>x.id===i?f:x):[...e.pages,f],actions:[...w,...J],strings:{...e.strings,locales:T}})}function Zu(e,t,r=[]){let n={nodes:{}},i=t.startsWith("zh"),o=(l,d)=>i?l:d,a=(l,d,c,h,v=[])=>({id:l,label:d,value:c,status:h,detail:v,facts:[]});return le(e,l=>{if(l.type!=="customer_data")return;let d={...Wn(l.data.source),status:"ready",stale:!1,preview:!0};if(l.data.source==="credit_balance"){let c=l.data.resourceKey??r[0]?.key??"credits";d.resources=[{key:c,name:r.find(h=>h.key===c)?.label??o("\u521B\u4F5C\u79EF\u5206","Creative credits"),spendable:"3,840",available:"4,040",reserved:"200",expiry:o("1,200 \xB7 2026\u5E7411\u67081\u65E5","1,200 \xB7 November 1, 2026"),sources:[a("sample-monthly",o("\u4F1A\u5458\u6708\u5EA6\u79EF\u5206","Monthly membership credits"),"2,640",o("\u53EF\u7528","Available")),a("sample-pack",o("\u8D2D\u4E70\u79EF\u5206\u5305","Purchased credit pack"),"1,200",o("\u53EF\u7528","Available"))],sourceCount:2,sourcePage:1,hasNextSources:!1,hasPreviousSources:!1}]}else l.data.source==="credit_transactions"?(d.rows=[a("sample-usage-1",o("\u56FE\u50CF\u751F\u6210","Image generation"),"",o("\u6D88\u8D39","Usage"),[o("10\u67083\u65E5 09:42","Oct 3, 09:42")]),a("sample-usage-2",o("\u89C6\u9891\u751F\u6210","Video generation"),"",o("\u9884\u6263","Reserved"),[o("10\u67083\u65E5 09:30","Oct 3, 09:30")]),a("sample-usage-3",o("\u56FE\u50CF\u751F\u6210","Image generation"),"",o("\u9000\u56DE","Refund"),[o("10\u67082\u65E5 16:10","Oct 2, 16:10")]),a("sample-usage-4",o("\u89C6\u9891\u751F\u6210","Video generation"),"",o("\u6D88\u8D39","Usage"),[o("10\u67082\u65E5 15:24","Oct 2, 15:24")]),a("sample-usage-5",o("\u56FE\u50CF\u751F\u6210","Image generation"),"",o("\u6D88\u8D39","Usage"),[o("10\u67082\u65E5 14:08","Oct 2, 14:08")])].slice(0,l.data.pageSize),d.rows.forEach((c,h)=>{c.facts=[{label:o("\u521B\u4F5C\u79EF\u5206","Creative credits"),value:["12","180","12","180","24"][h]}]})):l.data.source==="membership"?d.rows=[a("sample-plan",o("\u4E13\u4E1A\u7248 \xB7 \u6708\u4ED8","Pro \xB7 Monthly"),"",o("\u6709\u6548","Active"),[o("\u5F53\u524D\u5468\u671F\u7ED3\u675F \xB7 2026\u5E7411\u67081\u65E5","Current period ends \xB7 November 1, 2026")])]:l.data.source==="customer_plans"?d.rows=[a("sample-free",o("\u57FA\u7840\u7248","Starter"),o("\u514D\u8D39","Free"),o("\u53EF\u9009\u62E9","Available")),a("sample-pro",o("\u4E13\u4E1A\u7248","Pro"),o("$29 / \u6708","$29 / month"),o("\u5F53\u524D\u5957\u9910","Current plan")),a("sample-team",o("\u56E2\u961F\u7248","Team"),o("$79 / \u6708","$79 / month"),o("\u53EF\u9009\u62E9","Available"))].slice(0,l.data.pageSize):l.data.source==="credit_packs"?d.rows=[a("sample-pack-small",o("\u521B\u4F5C\u8865\u5145\u5305","Creative top-up"),"$12","",[o("1,200 \u79EF\u5206 \xB7 90 \u5929\u6709\u6548","1,200 credits \xB7 90 days validity")]),a("sample-pack-large",o("\u521B\u4F5C\u6269\u5C55\u5305","Creative expansion"),"$40","",[o("5,000 \u79EF\u5206 \xB7 180 \u5929\u6709\u6548","5,000 credits \xB7 180 days validity")])].slice(0,l.data.pageSize).map((c,h)=>({...c,...l.data.allowPurchase?{purchaseId:`10000000-0000-4000-8000-${String(h+1).padStart(12,"0")}`}:{}})):l.data.source==="credit_pack_orders"?d.rows=[a("sample-order",o("\u521B\u4F5C\u8865\u5145\u5305","Creative top-up"),"$12",o("\u5DF2\u4ED8\u6B3E","Paid"),["2026-10-01 12:30"])]:d.rows=[a("sample-offer",o("\u4F1A\u5458\u7EED\u8D39\u4F18\u60E0","Membership renewal offer"),"",o("\u53EF\u7528","Available"),[o("2026\u5E7411\u67081\u65E5\u5230\u671F","Expires November 1, 2026")])];n.nodes[l.id]=d}),n}import{z}from"zod";var jo=z.enum(["surface","customer","feature","plan","pool","coupon","audience"]),Po=z.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"]),dt=z.object({baseRevision:z.number().int().nonnegative(),latestRevision:z.number().int().nonnegative(),mode:z.enum(["merge","use_latest"]),decisions:z.array(z.object({field:Po,mine:z.number().int().min(0).max(1e3),latest:z.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),Rr=z.number().int().nonnegative().nullable(),zo=z.object({resource:jo,id:z.uuid(),projectId:z.uuid(),environmentId:z.uuid(),fromRevision:Rr,toRevision:Rr,provenance:z.enum(["recorded","historical"]),changes:z.array(z.object({field:z.string(),redacted:z.boolean(),before:z.union([z.string(),z.number(),z.boolean(),z.null()]),after:z.union([z.string(),z.number(),z.boolean(),z.null()])})),merge:dt.safeExtend({source:z.literal("client")}).nullable()}),Oo=z.object({createdAt:z.iso.datetime({offset:!0}),id:z.uuid()}).strict(),Yu=z.object({events:z.array(z.object({id:z.uuid(),action:z.string(),actorId:z.uuid().nullable(),actorEmail:z.email().nullable(),createdAt:z.iso.datetime({offset:!0}),object:zo})),nextCursor:Oo.nullable()});import{z as y}from"zod";var Qt=y.array(y.string().trim().min(1).max(40)).max(20).refine(e=>new Set(e).size===e.length),Tr=y.iso.datetime({offset:!0}).nullable(),Ro=y.object({enabled:y.boolean(),tagsAll:Qt,tagsAny:Qt,tagsNone:Qt,countries:y.array(y.string().regex(/^[A-Z]{2}$/)).max(40).refine(e=>new Set(e).size===e.length),subscription:y.enum(["any","none","active","trialing","ended"]),ageMinDays:y.number().int().min(0).max(36500).nullable(),ageMaxDays:y.number().int().min(0).max(36500).nullable(),attributes:y.array(y.object({key:y.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,49}$/),value:y.union([y.string().max(200),y.number().finite(),y.boolean()])}).strict()).max(10).refine(e=>new Set(e.map(t=>t.key)).size===e.length),startsAt:Tr,endsAt:Tr}).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(r=>e.tagsAll.includes(r))&&t.addIssue({code:"custom",path:["tagsNone"],message:"Required tag is excluded"}),e.tagsAny.length>0&&e.tagsAny.every(r=>e.tagsNone.includes(r))&&t.addIssue({code:"custom",path:["tagsAny"],message:"Every alternative tag is excluded"})}),el={enabled:!1,tagsAll:[],tagsAny:[],tagsNone:[],countries:[],subscription:"any",ageMinDays:null,ageMaxDays:null,attributes:[],startsAt:null,endsAt:null},tl=y.object({campaign_id:y.uuid(),revision:y.number().int().min(0),audience_id:y.uuid().nullable(),enabled:y.boolean()}),nl=y.object({matches:y.boolean(),revision:y.number().int().nullable(),reasons:y.array(y.enum(["before_start","after_end","customer_required","tags_all","tags_any","tags_none","country","subscription","age","attributes","audience_unavailable"])),audienceId:y.uuid().nullable().optional(),audienceRevision:y.number().int().nullable().optional()}),rl=y.object({campaignId:y.uuid(),revision:y.number().int().min(0),audienceId:y.uuid().nullable(),enabled:y.boolean()}).strict().refine(e=>!e.enabled||e.audienceId!==null),Dr=Ro.refine(e=>e.enabled,"Audience conditions must remain enabled"),il=y.object({id:y.uuid(),name:y.string().min(1).max(80),description:y.string().max(500),config:Dr,revision:y.number().int().min(1),status:y.enum(["active","archived"]),created_at:y.iso.datetime({offset:!0}),updated_at:y.iso.datetime({offset:!0})}),ol=y.discriminatedUnion("action",[y.object({action:y.literal("save"),id:y.uuid().nullable(),audit:dt.nullable().optional(),revision:y.number().int().min(0),name:y.string().trim().min(1).max(80),description:y.string().trim().max(500),config:Dr}).strict(),y.object({action:y.literal("archive"),id:y.uuid(),audit:dt.nullable().optional(),revision:y.number().int().min(1)}).strict()]),To=y.object({id:y.uuid(),name:y.string().nullable(),external_user_id:y.string(),tags:y.string().array(),created_at:y.iso.datetime({offset:!0})}),al=y.object({customers:To.array(),hasMore:y.boolean(),offset:y.number().int().min(0),limit:y.number().int().min(1),evaluatedAt:y.iso.datetime({offset:!0}),revision:y.number().int().min(1)}),sl=y.object({campaignId:y.uuid(),experimentId:y.uuid(),revision:y.number().int().min(1),variantId:y.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/)}).strict();import{z as Ge}from"zod";var pl=Ge.object({defaultLocale:X,locales:Ge.record(X,Ge.object({name:Ge.string().max(80),description:Ge.string().max(500)}).strict())}).strict().superRefine((e,t)=>{let r=Object.keys(e.locales);(!r.length||r.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 ml(e,t){let r=e.displayCopy;if(!r)return{name:e.name,description:""};let n=Object.keys(r.locales).filter(l=>r.locales[l].name.trim()),i=ot([t],n,r.defaultLocale),o=r.locales[i],a=r.locales[r.defaultLocale];return{name:o?.name.trim()?o.name:a?.name.trim()?a.name:e.name,description:o?.description.trim()?o.description:a?.description.trim()?a.description:""}}import{z as N}from"zod";var Ee=N.string().min(1).max(255).regex(/^[^\s\p{Cc}]+$/u),Er=N.strictObject({projectId:N.uuid(),environmentId:N.uuid()}),Do=N.strictObject({kind:He,deliveryVersionId:N.uuid(),productId:Ee,basePlanId:Ee.nullable(),offerId:Ee.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"})}),hl=Er.extend({connectionId:N.uuid(),binding:Do}),bl=Er.extend({bindingId:N.uuid()}),yl=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:He,name:N.string(),version:N.number().int().positive()})),bindings:N.array(N.strictObject({id:N.uuid(),connectionId:N.uuid(),kind:He,deliveryVersionId:N.uuid(),productId:Ee,basePlanId:Ee.nullable(),offerId:Ee.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"])}))});var Fr="#172033",ft="#667085",Eo="#E2E6EE",Fo="#2C3C96",ee=e=>({top:e,right:e,bottom:e,left:e}),Y=e=>({type:"color",color:e}),re=class{constructor(t,r={}){this.name=t;this.design=r}name;design;zh={};en={};text(t,r,n,i=13,o=ft,a={}){return this.zh[t]=r,this.en[t]=n,{id:t,type:"text",text:t,variant:i>=30?"title":"body",style:{text:{size:i,color:o,weight:i>=30?600:400,lineHeight:1.35,...i>=30?{letterSpacing:-1.2}:{}},...a}}}stack(t,r,n={},i=!1){return{id:t,type:"stack",direction:i?"horizontal":"vertical",align:"stretch",justify:"start",children:r,style:{gap:i?40:24,...n}}}widget(t,r,n,i,o=!1,a={}){let l=t+"_title";return this.zh[l]=n,this.en[l]=i,{id:t,type:"customer_data",title:l,data:{source:r,layout:o?"compact":"full",pageSize:r==="credit_transactions"?5:4,showSources:r==="credit_balance"&&!o,allowPurchase:r==="credit_packs"},style:a}}rule(t,r=Eo){return{id:t,type:"divider",style:{background:Y(r),height:1}}}header(t,r,n,i,o,a=!1){return this.stack("account_header",[this.stack("intro",[this.text("eyebrow","\u5DE5\u4F5C\u7A7A\u95F4 / \u8D26\u6237","WORKSPACE / ACCOUNT",11,a?"#A9B4CB":ft,{text:{size:11,color:a?"#A9B4CB":ft,letterSpacing:1.4,weight:600}}),this.text("heading",t,r,28,a?"#FFFFFF":Fr),this.text("description",n,i,14,a?"#A9B4CB":ft)],{gap:12,width:660,grow:!0}),...o?[o]:[]],{gap:32},!0)}document(t,r=!1){return G.parse({kind:"screen",schemaVersion:3,name:this.name,surface:"page",presentation:{type:"fullscreen"},theme:{primary:Fo,background:r?"#101A30":"#F5F6FA",text:Fr,radius:"md",font:"system",...this.design.theme},pages:[{id:"account_page",name:this.name,root:{...this.stack("root",[this.stack("content",t,{width:this.design.width??1200,gap:this.design.gap??32})],{padding:this.design.padding??{top:40,right:24,bottom:36,left:24}}),align:"center"}}],strings:{defaultLocale:"zh-CN",locales:{"zh-CN":this.zh,en:this.en}},actions:[]})}};var ht="#19202E",No="#667080",Xt="#2C3C96",Nr="#DDE2E9",$r="#F0F3FA",$o=(e=72,t=ht)=>({text:{size:e,color:t,weight:600,font:"system"}}),gt=(e,t=1)=>({width:e,grow:t}),qo={background:Y("#FFFFFF"),shape:{type:"rect",radius:10}};function Lo(e){return new re(e,{theme:{background:"#FFFFFF",text:ht,primary:Xt},width:1184,gap:32,padding:{top:24,right:24,bottom:40,left:24}})}function Vo(e,t,r,n,i){let o=e.text("wordmark","GROW / \u8D26\u6237","GROW / ACCOUNT",13,Xt,{text:{size:13,color:Xt,weight:700,letterSpacing:.8}});return e.stack("page_header",[o,e.text("heading",t,r,40,ht,{text:{size:40,color:ht,weight:700,lineHeight:1.18,letterSpacing:-1.4}}),e.text("description",n,i,14,No)],{gap:12,padding:{top:8,right:0,bottom:8,left:0}})}function qr(){let e="#FAF7F0",t="#302923",r="#A63C25",n="#73665A",i=new re("\u8D26\u6237\u4E00\u89C8",{theme:{background:e,text:t,primary:r,radius:"none"},width:1120,gap:36,padding:{top:32,right:24,bottom:48,left:24}}),o=(a,l,d)=>i.text(a,l,d,12,r,{text:{size:12,color:r,font:"mono",weight:500,letterSpacing:1.1}});return i.document([i.stack("journal_masthead",[i.stack("journal_identity",[i.text("wordmark","GROW","GROW",22,t,{text:{size:22,color:t,weight:700,letterSpacing:-1}}),o("edition","\u8D26\u6237 / ACCOUNT","ACCOUNT / JOURNAL")],{gap:16},!0),i.rule("masthead_rule",t),i.stack("journal_intro",[i.text("heading","\u8D26\u6237\u4E00\u89C8","Your account.",64,t,{width:720,grow:2,text:{size:64,color:t,font:"serif",weight:400,lineHeight:1.12,letterSpacing:-2}}),i.stack("intro_note",[o("intro_index","\u4E3A\u4F60\u7684\u4E0B\u4E00\u6B21\u521B\u4F5C","FOR YOUR NEXT CHAPTER"),i.text("description",`\u4F60\u7684\u4F1A\u5458\u3001\u79EF\u5206\u4E0E\u8D2D\u4E70\u8BB0\u5F55\uFF0C
2
+ \u5728\u4E00\u5904\u4ECE\u5BB9\u638C\u63E1\u3002`,`Membership, credits and purchases.
3
+ A little clarity for what's next.`,14,n)],{width:300,grow:1,gap:12,padding:{top:8,right:0,bottom:0,left:0}})],{gap:40},!0)],{gap:24}),i.stack("account_summary",[i.stack("member_column",[o("member_index","01 / \u4F1A\u5458","01 / MEMBERSHIP"),i.widget("membership","membership","\u5F53\u524D\u4F1A\u5458","Current membership",!1,{text:{color:t,font:"serif",size:40,weight:400}})],{width:660,grow:2,gap:16}),i.stack("balance_column",[o("balance_index","02 / \u79EF\u5206","02 / CREDITS"),i.widget("balance","credit_balance","\u53EF\u7528\u79EF\u5206","Available credits",!0,{text:{color:t,font:"serif",size:64,weight:400}})],{width:340,grow:1,gap:16})],{gap:48,padding:{top:12,right:0,bottom:12,left:0}},!0),i.rule("records_rule","#D9CFC1"),i.stack("account_records",[i.stack("purchase_column",[o("purchase_index","03 / \u8D2D\u4E70\u8BB0\u5F55","03 / PURCHASES"),i.widget("orders","credit_pack_orders","\u6BCF\u4E00\u7B14\u8D2D\u4E70","Your purchases",!1,{text:{color:t}})],{width:660,grow:2,gap:16}),i.stack("offer_column",[o("offer_index","04 / \u4E13\u5C5E\u4F18\u60E0","04 / YOUR OFFERS"),i.widget("offers","offer_history","\u53EF\u7528\u4F18\u60E0","Available offers",!0,{text:{color:t}})],{width:340,grow:1,gap:16})],{gap:48},!0),i.rule("catalog_rule","#D9CFC1"),i.stack("account_catalog",[o("catalog_index","05 / \u65B9\u6848","05 / PLANS"),i.widget("plans","customer_plans","\u63A2\u7D22\u9002\u5408\u4F60\u7684\u65B9\u6848","Find your next plan",!0,{text:{color:t}})],{gap:16}),i.text("journal_footer","GROW / \u8BA9\u521B\u4F5C\u7EE7\u7EED","GROW / KEEP CREATING",11,n,{text:{size:11,color:n,font:"mono",letterSpacing:1}})])}function Lr(){let e="#182C4A",t="#596B83",r="#CCD6E4",n=new re("\u79EF\u5206\u5DE5\u4F5C\u53F0",{theme:{background:"#EDF1F7",text:e,primary:"#244F9E",radius:"sm"},width:1200,gap:24,padding:{top:24,right:24,bottom:40,left:24}}),i=(o,a,l)=>n.text(o,a,l,11,t,{text:{size:11,color:t,font:"mono",weight:500,letterSpacing:1}});return n.document([n.stack("terminal_header",[i("wordmark","GROW / \u79EF\u5206\u5DE5\u4F5C\u53F0","GROW / CREDIT WORKSPACE"),n.stack("terminal_intro",[n.text("heading","\u79EF\u5206\u4E0E\u7528\u91CF","Credits & usage",36,e,{width:780,grow:2,text:{size:36,color:e,weight:600,letterSpacing:-1.2,lineHeight:1.15}}),n.text("description","\u4F59\u989D\u3001\u5230\u671F\u6765\u6E90\u4E0E\u6BCF\u4E00\u7B14\u4F7F\u7528\u3002","Balance, expiry and every transaction.",13,t,{width:340,grow:1})],{gap:32},!0)],{gap:16,padding:{top:8,right:0,bottom:8,left:0}}),n.stack("terminal_workspace",[n.stack("ledger_workspace",[n.stack("credit_summary",[i("balance_index","01 / \u8D26\u6237\u4F59\u989D","01 / BALANCE"),n.widget("balance","credit_balance","\u53EF\u7528\u79EF\u5206","Available credits",!1,{text:{size:80,color:e,font:"mono",weight:500}})],{gap:16,padding:ee(28),background:Y("#E0E8F4")}),n.stack("ledger_panel",[i("activity_index","02 / \u8D26\u76EE\u660E\u7EC6","02 / ACTIVITY"),n.widget("activity","credit_transactions","\u79EF\u5206\u6D41\u6C34","Credit history",!1,{text:{color:e}})],{gap:16,padding:ee(28),background:Y("#FFFFFF")})],{width:820,grow:2,gap:2}),n.stack("purchase_rail",[n.stack("plan_context",[i("membership_index","\u8D26\u6237 / \u65B9\u6848","ACCOUNT / PLAN"),n.widget("membership","membership","\u5F53\u524D\u65B9\u6848","Current plan",!0,{text:{color:e}})],{gap:16,padding:ee(24),background:Y("#FFFFFF")}),n.stack("purchase_panel",[i("purchase_index","03 / \u8865\u5145\u79EF\u5206","03 / TOP UP"),n.widget("packs","credit_packs","\u8D2D\u4E70\u79EF\u5206","Buy credits",!0,{text:{color:e}}),n.text("purchase_note","\u8D2D\u4E70\u524D\u67E5\u770B\u79EF\u5206\u6570\u91CF\u4E0E\u6709\u6548\u671F\u3002","Check the credit amount and validity before purchase.",12,t)],{gap:16,padding:ee(24),background:Y("#FFFFFF")}),n.stack("orders_panel",[i("orders_index","04 / \u8D2D\u4E70\u8BB0\u5F55","04 / PURCHASES"),n.widget("orders","credit_pack_orders","\u6700\u8FD1\u8D2D\u4E70","Recent purchases",!0,{text:{color:e}})],{gap:16,padding:ee(24),background:Y("#FFFFFF")})],{width:348,grow:1,gap:2})],{gap:24},!0),n.rule("terminal_rule",r),i("terminal_footer","GROW / \u6309\u8D44\u6E90\u67E5\u770B\u4F59\u989D \xB7 \u6309\u8BB0\u5F55\u6838\u5BF9\u4F7F\u7528","GROW / RESOURCE BALANCES \xB7 TRANSACTION RECORDS")])}function Vr(){let e="#253F34",t="#F5F3EC",r="#5C6A60",n="#DBE8B8",i=new re("\u4F1A\u5458\u4FF1\u4E50\u90E8",{theme:{background:t,text:e,primary:e,radius:"none"},width:1160,gap:32,padding:{top:28,right:24,bottom:48,left:24}}),o=(a,l,d,c=r)=>i.text(a,l,d,12,c,{text:{size:12,color:c,font:"mono",letterSpacing:1,weight:500}});return i.document([i.stack("club_masthead",[i.stack("club_identity",[i.text("wordmark","GROW CLUB","GROW CLUB",22,e,{text:{size:22,color:e,weight:700,letterSpacing:-.6}}),o("club_edition","\u4F1A\u5458 / MEMBERSHIP","MEMBERSHIP / YOUR SPACE")],{gap:20},!0),i.rule("club_rule",e),i.stack("club_intro",[i.text("heading","\u4F1A\u5458\u4E0E\u65B9\u6848","Room to grow.",64,e,{width:752,grow:2,text:{size:64,color:e,font:"serif",weight:400,lineHeight:1.1,letterSpacing:-2}}),i.stack("club_description",[o("club_intro_label","\u4E3A\u6301\u7EED\u7684\u521B\u9020\u529B","FOR WHAT COMES NEXT"),i.text("description",`\u67E5\u770B\u4F60\u7684\u4F1A\u5458\u72B6\u6001\uFF0C
4
+ \u627E\u5230\u9002\u5408\u4E0B\u4E00\u6B65\u7684\u65B9\u6848\u3002`,`Your membership, at a glance.
5
+ A plan for what comes next.`,14,r)],{width:320,grow:1,gap:12,padding:{top:10,right:0,bottom:0,left:0}})],{gap:40},!0)],{gap:24}),i.stack("membership_summary",[i.stack("member_spread",[o("member_index","01 / \u4F60\u7684\u4F1A\u5458","01 / YOUR MEMBERSHIP","#CCD9CA"),i.widget("membership","membership","\u5F53\u524D\u4F1A\u5458","Current membership",!1,{text:{color:"#FFFFFF",font:"serif",size:52,weight:400}})],{width:744,grow:2,gap:20,padding:ee(32),background:Y(e)}),i.stack("balance_inset",[o("balance_index","02 / \u521B\u4F5C\u4F59\u989D","02 / CREDIT BALANCE",e),i.widget("balance","credit_balance","\u53EF\u7528\u79EF\u5206","Available credits",!0,{text:{color:e,size:60,weight:500}})],{width:376,grow:1,gap:20,padding:ee(28),background:Y(n)})],{gap:0},!0),i.stack("plan_comparison",[o("plans_index","03 / \u9009\u62E9\u4F60\u7684\u4E0B\u4E00\u6B65","03 / YOUR NEXT STEP"),i.widget("plans","customer_plans","\u627E\u5230\u9002\u5408\u4F60\u7684\u65B9\u6848","A plan to make it yours",!1,{text:{color:e,font:"serif"}})],{gap:16,padding:{top:8,right:0,bottom:8,left:0}}),i.rule("benefits_rule","#C8CEC2"),i.stack("benefit_records",[i.stack("member_offers",[o("offers_index","04 / \u4F60\u7684\u4F18\u60E0","04 / YOUR OFFERS"),i.widget("offers","offer_history","\u4F1A\u5458\u4F18\u60E0","Member offers",!1,{text:{color:e}})],{width:556,grow:1,gap:16}),i.stack("member_purchases",[o("orders_index","05 / \u8D2D\u4E70\u8BB0\u5F55","05 / PURCHASES"),i.widget("orders","credit_pack_orders","\u8D2D\u4E70\u4E0E\u8BB0\u5F55","Purchases & records",!1,{text:{color:e}})],{width:556,grow:1,gap:16})],{gap:48},!0),i.rule("footer_rule","#C8CEC2"),o("club_footer","GROW CLUB / \u7559\u51FA\u521B\u9020\u7684\u7A7A\u95F4","GROW CLUB / ROOM FOR WHAT'S NEXT")])}function Br(){let e=Lo("\u521B\u4F5C\u5DE5\u4F5C\u533A");return e.document([Vo(e,"\u521B\u4F5C\u5DE5\u4F5C\u533A","Your workspace","\u79EF\u5206\u3001\u4F1A\u5458\u548C\u4F7F\u7528\u8BB0\u5F55\uFF0C\u90FD\u5728\u8FD9\u91CC\u3002","Your credits, membership and activity."),e.stack("studio_summary",[e.widget("balance","credit_balance","\u53EF\u7528\u79EF\u5206","Available credits",!1,{...gt(784,2),...$o(80)}),e.widget("membership","membership","\u5F53\u524D\u4F1A\u5458","Membership",!1,{...gt(328),background:Y($r),padding:ee(24),shape:{type:"rect",radius:10}})],{gap:48,padding:{top:12,right:0,bottom:8,left:0}},!0),e.rule("workspace_rule",Nr),e.stack("studio_workspace",[e.widget("transactions","credit_transactions","\u6700\u8FD1\u4F7F\u7528","Recent activity",!1,gt(784,2)),e.stack("credit_shop",[e.widget("packs","credit_packs","\u8865\u5145\u79EF\u5206","Add credits",!0),e.rule("shop_rule",Nr),e.widget("orders","credit_pack_orders","\u6700\u8FD1\u8D2D\u4E70","Recent purchases",!0)],{...gt(328),...qo,padding:ee(24),gap:24,background:Y($r)})],{gap:48},!0)])}function Mr(){return Br()}var pe=(e,t=1)=>({width:e,grow:t}),bt=(e=16)=>({shape:{type:"rect",radius:e}}),H=(e,t,r="system")=>({text:{color:e,...t?{size:t,font:r,weight:500}:{}}}),me=(e,t,r=e)=>({top:e,right:t,bottom:r,left:t});function Bo(e,t,r,n,i="system"){return e.text("heading",t,r,28,n,{text:{size:28,font:i,weight:600,color:n,lineHeight:1.2,letterSpacing:-.8}})}function Mo(e,t,r,n,i){return e.text(t,r,n,11,i,{text:{size:11,font:"system",weight:500,color:i,letterSpacing:.6}})}function Ye(e,t,r,n,i,o="system"){let a=e.stack("masthead",[Bo(e,t,r,n,o),Mo(e,"scope","\u4E2A\u4EBA\u8D26\u6237","PERSONAL ACCOUNT",i)],{gap:20},!0);return a.justify="between",a.align="center",a}function Ur(e,t,r=!1,n=5){let i=e.widget("activity","credit_transactions","\u6700\u8FD1\u4F7F\u7528","Recent activity",r,H(t));return i.data.pageSize=n,i}function Uo(){let e="#171D1A",t="#F2F5ED",r="#9EADA2",n="#D5E7B0",i=new re("\u6697\u7EFF\u79EF\u5206\u53F0",{theme:{background:e,text:t,primary:e},width:1120,gap:32,padding:me(32,24,48)});return i.document([Ye(i,"\u79EF\u5206\u8D26\u6237","Credits",t,r),i.rule("header_rule","#354039"),i.stack("wallet_workspace",[i.stack("wallet_primary",[i.widget("balance","credit_balance","\u53EF\u7528\u79EF\u5206","Available credits",!1,H(t,96)),i.widget("membership","membership","\u5F53\u524D\u4F1A\u5458","Membership",!0,H(t))],{...pe(680,2),gap:32,padding:me(20,0,12)}),i.stack("purchase_sheet",[i.widget("packs","credit_packs","\u8865\u5145\u79EF\u5206","Add credits",!1,H(e))],{...pe(328),background:Y(n),padding:ee(24),...bt(20)})],{gap:72},!0),i.rule("activity_rule","#354039"),Ur(i,t,!1,4)])}function Ho(){let e="#302C26",t="#7D766B",r="#D8D1C5",n=new re("\u8D26\u6237\u6863\u6848",{theme:{background:"#F7F3EB",text:e,primary:"#84503B"},width:1080,gap:32,padding:me(40,24,48)});return n.document([Ye(n,"\u8D26\u6237\u6863\u6848","Account journal",e,t,"serif"),n.rule("header_rule",e),n.stack("statement",[n.stack("balance_column",[n.widget("balance","credit_balance","\u53EF\u7528\u79EF\u5206","Available credits",!1,H(e,96,"serif"))],{...pe(628,2),padding:me(12,0),gap:24}),n.stack("membership_column",[n.widget("membership","membership","\u4F1A\u5458\u72B6\u6001","Membership",!1,H(e)),n.widget("offers","offer_history","\u8D26\u6237\u4F18\u60E0","Your offers",!0,H(e))],{...pe(356),gap:20,padding:me(12,0)})],{gap:96},!0),n.rule("orders_rule",r),n.widget("orders","credit_pack_orders","\u8D2D\u4E70\u8BB0\u5F55","Purchases",!1,H(e))])}function Ko(){let e="#223E33",t="#687C70",r="#254A3B",n="#F7F9F5",i=new re("\u4F1A\u5458\u7A7A\u95F4",{theme:{background:n,text:e,primary:r},width:1120,gap:32,padding:me(32,24,48)});return i.document([Ye(i,"\u4F1A\u5458\u4E2D\u5FC3","Membership",e,t),i.stack("current_membership",[i.stack("member_credential",[i.widget("membership","membership","\u5F53\u524D\u4F1A\u5458","Current membership",!1,H("#F4F7F0"))],{...pe(640,2),gap:24,background:Y(r),padding:ee(32),...bt(20)}),i.stack("credit_context",[i.widget("balance","credit_balance","\u8D26\u6237\u79EF\u5206","Account credits",!0,H(e,64))],{...pe(400),background:Y("#E9EFE5"),padding:ee(28),...bt(20)})],{gap:24},!0),i.widget("plans","customer_plans","\u65B9\u6848\u4E0E\u4EF7\u683C","Plans & pricing",!1,H(e)),i.rule("offer_rule","#D5DFD3"),i.widget("offers","offer_history","\u6211\u7684\u4F18\u60E0","Your offers",!0,H(e))])}function Zo(){let e="#23262B",t="#797E87",r="#DFE2E7",n=new re("\u7528\u91CF\u8D26\u518C",{theme:{background:"#FFFFFF",text:e,primary:e},width:1160,gap:28,padding:me(32,24,48)});return n.document([Ye(n,"\u7528\u91CF\u4E0E\u8BB0\u5F55","Usage & history",e,t),n.rule("header_rule",e),n.stack("account_context",[n.widget("balance","credit_balance","\u53EF\u7528\u79EF\u5206","Available credits",!0,{...pe(688,2),...H(e,56,"mono")}),n.widget("membership","membership","\u5F53\u524D\u4F1A\u5458","Membership",!0,{...pe(372),...H(e)})],{gap:72,padding:me(4,0,8)},!0),n.rule("activity_rule",r),Ur(n,e),n.rule("order_rule",r),n.widget("orders","credit_pack_orders","\u79EF\u5206\u8D2D\u4E70","Credit purchases",!0,H(e))])}function Wo(){let e="#3F3029",t="#8B766A",r="#A34525",n=new re("\u79EF\u5206\u8865\u7ED9",{theme:{background:"#FEFAF5",text:e,primary:r},width:1160,gap:32,padding:me(32,24,48)});return n.document([Ye(n,"\u8865\u5145\u79EF\u5206","Add credits",e,t),n.rule("header_rule","#E8DDD3"),n.stack("purchase_workspace",[n.stack("account_context",[n.widget("balance","credit_balance","\u73B0\u6709\u79EF\u5206","Current credits",!0,H(e,56)),n.rule("context_rule","#DBC5B5"),n.widget("membership","membership","\u5F53\u524D\u4F1A\u5458","Membership",!0,H(e))],{...pe(304),gap:28,padding:ee(24),background:Y("#F1E5D9"),...bt(16)}),n.stack("purchase_catalog",[n.widget("packs","credit_packs","\u53EF\u8D2D\u4E70\u7684\u79EF\u5206\u5305","Available credit packs",!1,H(e))],{...pe(800,2),gap:24})],{gap:32},!0),n.rule("orders_rule","#E8DDD3"),n.widget("orders","credit_pack_orders","\u8D2D\u4E70\u8BB0\u5F55","Recent purchases",!1,H(e))])}function Hr(){return[{key:"page-credits-midnight",label:"\u6697\u7EFF\u79EF\u5206\u53F0 \xB7 \u591C\u95F4\u6A21\u5F0F",description:"\u4EE5\u5B9E\u65F6\u4F59\u989D\u4E3A\u4E3B\u89C6\u89C9\uFF0C\u6D45\u7EFF\u8D2D\u4E70\u533A\u4E0E\u5B8C\u6574\u6D41\u6C34\u5F62\u6210\u660E\u786E\u64CD\u4F5C\u987A\u5E8F\u3002",category:"\u79EF\u5206\u4E0E\u7528\u91CF",tags:["\u6697\u8272","\u79EF\u5206","\u8D2D\u4E70","\u684C\u9762"],create:Uo},{key:"page-account-journal",label:"\u8D26\u6237\u6863\u6848 \xB7 \u7EB8\u611F\u6392\u7248",description:"\u7EB8\u611F\u8D26\u76EE\u3001\u886C\u7EBF\u4F59\u989D\u3001\u8FB9\u680F\u4F1A\u5458\u4E0E\u4F18\u60E0\uFF0C\u4FDD\u7559\u6E05\u6670\u7684\u8D2D\u4E70\u8BB0\u5F55\u3002",category:"\u8D26\u6237\u7A7A\u95F4",tags:["\u7EB8\u611F","\u886C\u7EBF","\u8D26\u6237","\u8BB0\u5F55"],create:Ho},{key:"page-membership-sage",label:"\u4F1A\u5458\u7A7A\u95F4 \xB7 \u677E\u7EFF",description:"\u677E\u7EFF\u4F1A\u5458\u51ED\u8BC1\u4E0E\u4F59\u989D\u5E76\u6392\uFF0C\u4E0B\u65B9\u5C55\u793A\u5F53\u524D\u5BA2\u6237\u53EF\u89C1\u7684\u65B9\u6848\u4E0E\u4EF7\u683C\u3002",category:"\u4F1A\u5458\u4E0E\u65B9\u6848",tags:["\u677E\u7EFF","\u4F1A\u5458","\u65B9\u6848","\u684C\u9762"],create:Ko},{key:"page-wallet-violet",label:"\u521B\u4F5C\u5DE5\u4F5C\u533A \xB7 \u79EF\u5206\u4E0E\u8BB0\u5F55",description:"\u8D26\u6237\u72B6\u6001\u3001\u5B8C\u6574\u4F7F\u7528\u8BB0\u5F55\u548C\u4FA7\u680F\u79EF\u5206\u8D2D\u4E70\uFF0C\u96C6\u4E2D\u5728\u6E05\u6670\u7684\u5DE5\u4F5C\u533A\u3002",category:"\u79EF\u5206\u4E0E\u7528\u91CF",tags:["\u5DE5\u4F5C\u533A","\u521B\u4F5C","\u79EF\u5206","\u8BB0\u5F55"],create:Mr},{key:"page-usage-ledger",label:"\u7528\u91CF\u8D26\u518C \xB7 \u9ED1\u767D",description:"\u7D27\u51D1\u8D26\u6237\u72B6\u6001\u3001\u5BBD\u5E45\u6D41\u6C34\u4E0E\u8D2D\u4E70\u8BB0\u5F55\uFF0C\u9002\u5408\u7528\u91CF\u5BC6\u96C6\u7684\u4EA7\u54C1\u3002",category:"\u79EF\u5206\u4E0E\u7528\u91CF",tags:["\u9ED1\u767D","\u7B49\u5BBD","\u6D41\u6C34","\u684C\u9762"],create:Zo},{key:"page-topup-orange",label:"\u79EF\u5206\u8865\u7ED9 \xB7 \u6696\u6A59",description:"\u5546\u54C1\u4EF7\u683C\u4E0E\u8D2D\u4E70\u5165\u53E3\u5E76\u6392\u5448\u73B0\uFF0C\u65C1\u8FB9\u4FDD\u7559\u5B9E\u65F6\u4F59\u989D\u548C\u4F1A\u5458\u72B6\u6001\u3002",category:"\u79EF\u5206\u4E0E\u7528\u91CF",tags:["\u6696\u6A59","\u8D2D\u4E70","\u79EF\u5206\u5305","\u8BA2\u5355"],create:Wo}].map(({create:e,...t})=>({...t,document:e()}))}function Go(){return Lr()}function Yo(){return qr()}function Jo(){return Vr()}function Ol(){return[...Hr(),{key:"page-credit-center-wallet",label:"\u79EF\u5206\u5DE5\u4F5C\u53F0 \xB7 Terminal",description:"\u84DD\u7070\u8D26\u76EE\u5DE5\u4F5C\u53F0\uFF1A\u7CBE\u786E\u4F59\u989D\u4E0E\u5B8C\u6574\u6D41\u6C34\u4E3A\u4E3B\uFF0C\u65B9\u6848\u3001\u79EF\u5206\u8D2D\u4E70\u4E0E\u8BA2\u5355\u7F6E\u4E8E\u72EC\u7ACB\u64CD\u4F5C\u680F\u3002",category:"\u8D26\u6237\u4E0E\u79EF\u5206",tags:["\u79EF\u5206","\u6D41\u6C34","\u771F\u5B9E\u6570\u636E","\u684C\u9762"],document:Go()},{key:"page-account-overview",label:"\u8D26\u6237\u4E00\u89C8 \xB7 Journal",description:"\u6696\u7EB8\u8272\u4E0E\u886C\u7EBF\u5B57\u4F53\u7684\u6742\u5FD7\u5F0F\u8D26\u6237\u9875\uFF1A\u4F1A\u5458\u4E0E\u79EF\u5206\u5C55\u5F00\u5448\u73B0\uFF0C\u8D2D\u4E70\u3001\u4F18\u60E0\u548C\u65B9\u6848\u5206\u533A\u9605\u8BFB\u3002",category:"\u8D26\u6237\u4E0E\u79EF\u5206",tags:["\u8D26\u6237","\u4F1A\u5458","\u4F18\u60E0","\u771F\u5B9E\u6570\u636E"],document:Yo()},{key:"page-membership-catalog",label:"\u4F1A\u5458\u4FF1\u4E50\u90E8 \xB7 Club",description:"\u68EE\u6797\u7EFF\u4E0E\u8C61\u7259\u767D\u7684\u54C1\u724C\u4F1A\u5458\u9875\uFF1A\u5F3A\u5B57\u4F53\u3001\u5BF9\u6BD4\u8272\u4F1A\u5458\u533A\u3001\u5F00\u653E\u5F0F\u65B9\u6848\u6BD4\u8F83\u4E0E\u5B8C\u6574\u8D26\u6237\u8BB0\u5F55\u3002",category:"\u8D26\u6237\u4E0E\u79EF\u5206",tags:["\u4F1A\u5458","\u5957\u9910","\u8D44\u683C","\u771F\u5B9E\u6570\u636E"],document:Jo()}]}export{Fe as a,ae as b,Zr as c,L as d,Ne as e,ta as f,na as g,en as h,Wr as i,Gr as j,Yr as k,Jr as l,aa as m,sa as n,ca as o,$e as p,Qe as q,Qr as r,Xr as s,ei as t,Xe as u,tn as v,nn as w,rn as x,Z as y,te as z,qe as A,ti as B,an as C,ni as D,ri as E,sn as F,St as G,da as H,Le as I,ii as J,oi as K,ai as L,kt as M,cn as N,ne as O,un as P,ln as Q,pn as R,It as S,mn as T,vt as U,dn as V,fn as W,gn as X,hn as Y,we as Z,fa as _,ue as $,bn as aa,yn as ba,si as ca,ga as da,Ce as ea,Ae as fa,et as ga,xn as ha,wt as ia,Ct as ja,At as ka,_t as la,jt as ma,Sn as na,ci as oa,tt as pa,Pt as qa,_e as ra,Ta as sa,kn as ta,Da as ua,je as va,Ea as wa,Fa as xa,zt as ya,nt as za,Na as Aa,$a as Ba,ui as Ca,Ve as Da,Ot as Ea,qa as Fa,La as Ga,rt as Ha,it as Ia,Za as Ja,Wa as Ka,Ga as La,li as Ma,Ya as Na,pi as Oa,wn as Pa,Xa as Qa,X as Ra,ke as Sa,ot as Ta,fi as Ua,ns as Va,as as Wa,gi as Xa,hi as Ya,jn as Za,ps as _a,Pn as $a,zn as ab,On as bb,yi as cb,ms as db,ds as eb,fs as fb,gs as gb,hs as hb,bs as ib,ys as jb,xs as kb,Pe as lb,Rn as mb,Si as nb,Tn as ob,ki as pb,Ii as qb,Dn as rb,En as sb,vi as tb,wi as ub,Fn as vb,Nn as wb,$n as xb,Ci as yb,Ln as zb,qn as Ab,ye as Bb,at as Cb,st as Db,Rs as Eb,Ts as Fb,ze as Gb,Vn as Hb,Bn as Ib,Mn as Jb,ct as Kb,qs as Lb,Un as Mb,Ls as Nb,_i as Ob,Hn as Pb,Kn as Qb,Pi as Rb,Us as Sb,Hs as Tb,Wn as Ub,Et as Vb,Gn as Wb,Ws as Xb,zi as Yb,Yn as Zb,Jn as _b,Qs as $b,$t as ac,Ri as bc,Xs as cc,Qn as dc,Ft as ec,Ti as fc,ie as gc,Be as hc,M as ic,Di as jc,Ei as kc,cc as lc,qt as mc,Xn as nc,Me as oc,er as pc,Fi as qc,Ni as rc,rr as sc,$i as tc,qi as uc,Li as vc,Vi as wc,Bi as xc,Re as yc,Mi as zc,Ui as Ac,Hi as Bc,Ki as Cc,Zi as Dc,Wi as Ec,Gi as Fc,Yi as Gc,Ji as Hc,Qi as Ic,Xi as Jc,eo as Kc,ir as Lc,to as Mc,ro as Nc,tr as Oc,Vt as Pc,or as Qc,uc as Rc,io as Sc,lc as Tc,le as Uc,pc as Vc,G as Wc,Ue as Xc,Bt as Yc,ao as Zc,ar as _c,mc as $c,uo as ad,dc as bd,fc as cd,lo as dd,Lt as ed,gc as fd,hc as gd,Te as hd,Sc as id,He as jd,kc as kd,po as ld,Ic as md,mo as nd,vc as od,cr as pd,fo as qd,ur as rd,Mt as sd,wc as td,Cc as ud,lr as vd,pr as wd,fr as xd,gr as yd,Ut as zd,hr as Ad,Ke as Bd,br as Cd,go as Dd,ho as Ed,Zt as Fd,yr as Gd,xr as Hd,Sr as Id,jc as Jd,Ec as Kd,bo as Ld,Ir as Md,vr as Nd,wr as Od,yo as Pd,nu as Qd,O as Rd,xo as Sd,So as Td,ko as Ud,Io as Vd,vo as Wd,wo as Xd,Co as Yd,Ao as Zd,ru as _d,iu as $d,Pr as ae,_r as be,pt as ce,au as de,lu as ee,fu as fe,gu as ge,hu as he,mt as ie,We as je,Su as ke,ku as le,ju as me,_o as ne,Pu as oe,zu as pe,Ou as qe,Ru as re,Eu as se,Or as te,qu as ue,Lu as ve,Mu as we,Zu as xe,jo as ye,Po as ze,dt as Ae,zo as Be,Oo as Ce,Yu as De,Ro as Ee,el as Fe,tl as Ge,nl as He,rl as Ie,Dr as Je,il as Ke,ol as Le,To as Me,al as Ne,sl as Oe,pl as Pe,ml as Qe,Er as Re,Do as Se,hl as Te,bl as Ue,yl as Ve,Go as We,Yo as Xe,Jo as Ye,Ol as Ze};
@@ -0,0 +1 @@
1
+ import{a as _}from"./chunk-O5ZKLGES.js";import{Rb as ae,Sb as ee,Tb as ne,Ub as K,h as Q}from"./chunk-B5O7FDKE.js";function fe(b,...v){try{Promise.resolve(b?.(...v)).catch(()=>{})}catch{}}function te(b){return JSON.stringify({...b,effectiveAt:b.timing==="immediate"?null:b.effectiveAt})}function Y(b,v){let P=v.startsWith("zh"),a=(p,h)=>P?p:h,R=p=>Q(p,b.currency??"USD",v),C=p=>new Intl.DateTimeFormat(v,{dateStyle:"medium",timeStyle:"short"}).format(new Date(p)),l={attach:a("\u8D2D\u4E70\u5957\u9910","Purchase plan"),change:a("\u53D8\u66F4\u5957\u9910","Change plan"),cancel:a("\u53D6\u6D88\u7EED\u8D39","Cancel renewal"),resume:a("\u6062\u590D\u7EED\u8D39","Resume renewal"),cancel_change:a("\u64A4\u9500\u9884\u7EA6\u53D8\u66F4","Cancel scheduled change")},S=[{label:a("\u672C\u6B21\u5E94\u4ED8","Due now"),value:b.amountDueCents===null?a("\u7ED3\u8D26\u65F6\u786E\u5B9A","Calculated at checkout"):R(b.amountDueCents)},{label:a("\u751F\u6548\u65F6\u95F4","Effective"),value:b.timing==="immediate"?a("\u7ACB\u5373","Immediately"):b.effectiveAt?C(b.effectiveAt):a("\u5F53\u524D\u5468\u671F\u7ED3\u675F","End of current cycle")}];for(let p of b.lineItems)S.push({label:p.description,value:R(p.amountCents)});return b.nextCycle&&S.push({label:a("\u4E0B\u4E00\u5468\u671F","Next cycle"),value:`${R(b.nextCycle.amountCents)} / ${b.nextCycle.interval==="year"?a("\u5E74","year"):b.nextCycle.interval==="month"?a("\u6708","month"):a("\u514D\u8D39","free")}${b.nextCycle.startsAt?` \xB7 ${C(b.nextCycle.startsAt)}`:""}`}),{title:l[b.action],facts:S,note:b.estimate||b.nextCycle?.estimate?a("\u91D1\u989D\u4E3A\u9884\u4F30\uFF0C\u4EE5\u652F\u4ED8\u6E20\u9053\u6700\u7EC8\u8D26\u5355\u4E3A\u51C6\u3002","Amounts are estimates; the payment provider determines the final invoice."):a("\u8BF7\u5BA1\u9605\u8D39\u7528\u548C\u751F\u6548\u65F6\u95F4\u540E\u786E\u8BA4\u3002","Review the amount and effective date before confirming.")}}function be(b,v,P){if(P?.aborted)return Promise.resolve(!1);let a=document.activeElement;for(;a?.shadowRoot?.activeElement;)a=a.shadowRoot.activeElement;let R=Y(b,v),C=v.startsWith("zh"),l=a;return new Promise(S=>{let p=document.createElement("dialog");p.setAttribute("aria-label",R.title),p.style.cssText="box-sizing:border-box;width:560px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;padding:24px;border:1px solid #d8dde5;border-radius:10px;background:#fff;color:#1e2530;font:14px/1.5 system-ui;z-index:2147483647";let h=document.createElement("h2");h.textContent=R.title,h.style.cssText="margin:0 0 16px;font-size:20px",p.append(h);let z=document.createElement("dl");z.style.cssText="margin:0";for(let t of R.facts){let I=document.createElement("div");I.style.cssText="display:flex;flex-wrap:wrap;justify-content:space-between;gap:12px;border-bottom:1px solid #e2e6ec;padding:12px 0";let A=document.createElement("dt"),U=document.createElement("dd");A.textContent=t.label,U.textContent=t.value,U.style.cssText="margin:0;font-variant-numeric:tabular-nums",I.append(A,U),z.append(I)}p.append(z);let M=document.createElement("p");M.textContent=R.note,p.append(M);let O=document.createElement("div");O.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:12px;margin-top:20px";function D(t){P?.removeEventListener("abort",J),p.close(),p.remove(),l instanceof HTMLElement&&l.isConnected&&l.focus(),S(t)}let J=()=>D(!1);P?.addEventListener("abort",J,{once:!0}),p.addEventListener("cancel",t=>{t.preventDefault(),D(!1)});for(let[t,I]of[[C?"\u8FD4\u56DE":"Back",!1],[C?"\u786E\u8BA4":"Confirm",!0]]){let A=document.createElement("button");A.type="button",A.textContent=t,A.style.cssText=`min-height:44px;padding:10px 20px;border:1px solid #ccd2dc;border-radius:6px;font:inherit;cursor:pointer;background:${I?"#2C3C96":"#fff"};color:${I?"#fff":"#1e2530"}`,A.addEventListener("click",()=>D(I)),O.append(A)}p.append(O),document.body.append(p),p.showModal()})}function pe(b,v){if(!/^(0|[1-9]\d*)(\.\d{1,12})?$/.test(b))throw new _("INVALID_RESPONSE","Invalid credit amount");let[P,a]=b.split("."),R=new Intl.NumberFormat(v),C=R.formatToParts(1.1).find(S=>S.type==="decimal")?.value??".",l=Array.from({length:10},(S,p)=>new Intl.NumberFormat(v,{useGrouping:!1}).format(p));return R.format(BigInt(P))+(a?C+a.replace(/\d/g,S=>l[Number(S)]):"")}function Pe(b,v,P){let a=new Map,R=r=>{r.hidden||(r.type==="customer_data"&&a.set(r.id,r),r.type==="stack"&&r.children.forEach(R))};b.pages.forEach(r=>R(r.root));let C=!1,l=0,S=!1,p=null,h={nodes:Object.fromEntries([...a].map(([r,o])=>[r,K(o.data.source)]))},z=new Map;for(let r of a.keys())z.set(r,{sequence:0,cursors:[void 0],localPage:0,sources:new Map});let M=new Map,O=new Set,D=new Map,J=P.locale.startsWith("zh"),t=(r,o)=>J?r:o,I=r=>pe(r,P.locale),A=r=>new Intl.DateTimeFormat(P.locale,{dateStyle:"medium",timeStyle:"short"}).format(new Date(r)),U=(r,o)=>Q(r,o,P.locale),L=(r,o,e=[],s={})=>({id:r,label:o,detail:e,facts:[],...s});function k(){if(C)return;let r=ee.parse(h);try{P.onData(r)}catch(o){H(o)}}function H(r){try{P.onError?.(r)}catch{}}function X(r){h.nodes[r]={...h.nodes[r],status:"loading",stale:!0,errorCode:void 0,errorMessage:void 0}}function Z(r){S=!0,l++,p=null,M.clear(),D.clear(),O.clear(),q.clear();for(let[o,e]of a){let s=G(o);s.sequence++,s.pending=void 0,s.cursors=[void 0],s.localPage=0,s.next=void 0,s.sources.clear(),h.nodes[o]={...K(e.data.source),status:"error",errorCode:r.code,errorMessage:r.message}}k(),H(r)}let F=[...a.values()].some(r=>["credit_balance","credit_transactions"].includes(r.data.source))?v.createCustomerStateStore({include:["credits"]}):null,W=[...a.values()].some(r=>r.data.source==="membership")?v.createCustomerStateStore({include:["memberships"]}):null,re=[F,W].filter(r=>!!r);async function ie(r,o,e){if(!p?.resources)throw new _("INVALID_RESPONSE","Requested credit resources are missing");let s=r.data.resourceKey?[p.resources[r.data.resourceKey]]:Object.values(p.resources);if(r.data.resourceKey&&!s[0])throw new _("RESOURCE_UNAVAILABLE",t("\u7ED1\u5B9A\u7684\u79EF\u5206\u8D44\u6E90\u5F53\u524D\u4E0D\u53EF\u7528\u3002","The bound credit resource is unavailable."));return Promise.all(s.map(async n=>{let u=o.sources.get(n.resourceKey);u||(u={page:0,cursors:[void 0],next:null},o.sources.set(n.resourceKey,u));let x=r.data.showSources&&n.sourceCount>0?await V(JSON.stringify([l,"balance-sources",n.resourceKey,r.data.pageSize,u.cursors[u.page]]),()=>v.listCreditBalances({resourceKey:n.resourceKey,limit:r.data.pageSize,cursor:u.cursors[u.page]})):null;e()&&x&&(u.next=x.nextCursor);let E=x?.balances??[];return{key:n.resourceKey,name:n.name,spendable:I(n.spendable),available:I(n.available),reserved:I(n.reserved),expiry:n.nextExpiry?`${I(n.nextExpiry.spendable)} \xB7 ${A(n.nextExpiry.at)}`:null,sources:E.map(g=>L(g.id,g.name,[ce[g.source]??t("\u8D26\u6237\u79EF\u5206","Account credits"),...g.expiresAt?[A(g.expiresAt)]:[]],{value:I(g.spendable),status:g.eligible?t("\u53EF\u7528","Available"):t("\u5F53\u524D\u4E0D\u53EF\u7528","Unavailable"),facts:[{label:t("\u51BB\u7ED3","Reserved"),value:I(g.reserved)}]})),sourceCount:r.data.showSources?n.sourceCount:0,sourcePage:u.page+1,hasNextSources:x?.nextCursor!=null,hasPreviousSources:u.page>0}}))}function G(r){return z.get(r)}function oe(r){return t("\u79EF\u5206\u6765\u6E90","Credit source")}let j={manual:t("\u8D60\u9001","Granted"),revoke:t("\u64A4\u56DE","Revoked"),reset:t("\u91CD\u7F6E","Reset"),expire:t("\u5230\u671F","Expired"),rollover:t("\u7ED3\u8F6C","Rollover"),consume:t("\u6D88\u8D39","Usage"),reserve:t("\u9884\u6263","Reserved"),confirm:t("\u786E\u8BA4\u6263\u8D39","Confirmed usage"),release:t("\u91CA\u653E\u9884\u6263","Released"),refund:t("\u9000\u56DE","Refund"),created:t("\u5DF2\u521B\u5EFA","Created"),pending:t("\u7B49\u5F85\u4ED8\u6B3E","Pending payment"),paid:t("\u5DF2\u4ED8\u6B3E","Paid"),expired:t("\u5DF2\u5230\u671F","Expired"),refunded:t("\u5DF2\u9000\u6B3E","Refunded"),disputed:t("\u4E89\u8BAE\u4E2D","Disputed"),issued:t("\u53EF\u7528","Available"),redeemed:t("\u5DF2\u4F7F\u7528","Redeemed"),revoked:t("\u5DF2\u64A4\u9500","Revoked"),active:t("\u6709\u6548","Active"),current:t("\u5F53\u524D\u5957\u9910","Current plan"),scheduled:t("\u9884\u7EA6\u53D8\u66F4","Scheduled"),available:t("\u53EF\u9009\u62E9","Available"),blocked:t("\u5F53\u524D\u4E0D\u53EF\u9009\u62E9","Unavailable"),pending_change:t("\u5DF2\u6709\u5F85\u5904\u7406\u53D8\u66F4","A change is pending"),managed_by_store:t("\u8BF7\u5728\u8D2D\u4E70\u5546\u5E97\u7BA1\u7406","Manage in the purchase store"),managed_by_payer:t("\u8BF7\u7531\u4ED8\u6B3E\u4EBA\u7BA1\u7406","Managed by the payer"),currency_unavailable:t("\u5F53\u524D\u5E01\u79CD\u4E0D\u53EF\u7528","Currency unavailable"),ambiguous_membership:t("\u9700\u8981\u6838\u5BF9\u4F1A\u5458\u72B6\u6001","Membership requires review")},ce={manual:t("\u8D60\u9001\u79EF\u5206","Granted credits"),pack:t("\u8D2D\u4E70\u79EF\u5206\u5305","Purchased pack"),assignment:t("\u4F1A\u5458\u79EF\u5206","Membership credits"),subscription:t("\u8BA2\u9605\u79EF\u5206","Subscription credits"),trial:t("\u8BD5\u7528\u79EF\u5206","Trial credits"),rollover:t("\u5468\u671F\u7ED3\u8F6C","Cycle rollover")},q=new Map;function V(r,o){let e=q.get(r);if(e)return e;let s=o().finally(()=>{q.get(r)===s&&q.delete(r)});return q.set(r,s),s}async function $(r,o=!1){if(C)return;let e=a.get(r),s=G(r);if(s.pending&&!o)return s.pending;o&&s.sources.clear();let n=++s.sequence,u=l,x=()=>!C&&l===u&&s.sequence===n,E=h.nodes[r];X(r),k();let g=(async()=>{try{let d={...K(e.data.source),filter:E.filter,page:s.localPage+1,status:"ready",stale:!1,...E.membershipReview?{membershipReview:E.membershipReview}:{},...E.membershipBusy?{membershipBusy:!0}:{},...E.membershipResult?{membershipResult:E.membershipResult}:{}},m=e.data.pageSize,w=s.cursors[s.localPage],c={limit:m,cursor:w},N=null,T=e.data.source==="membership"?W:F,B=null;if(["credit_balance","credit_transactions","membership"].includes(e.data.source)){if(B=await(S?T.refresh():T.load()),!x())return;S=!1,e.data.source!=="membership"&&(p=B)}if(e.data.source==="credit_balance"){if(d.resources=await ie(e,s,x),!x())return;d.updatedAt=p.evaluatedAt}else if(e.data.source==="membership"){if(!B?.membership)throw new _("INVALID_RESPONSE","Membership state is missing");N=B.membership.holdings.map(f=>L(f.id,f.name,[f.kind==="addon"?t("\u9644\u52A0\u5305","Add-on"):t("\u4E3B\u5957\u9910","Main plan"),...f.endsAt?[`${t("\u5F53\u524D\u5468\u671F\u7ED3\u675F","Current period ends")} \xB7 ${A(f.endsAt)}`]:[],...f.scheduledChange?.effectiveAt?[`${t("\u9884\u7EA6\u53D8\u66F4","Scheduled change")} \xB7 ${A(f.scheduledChange.effectiveAt)}`]:[]],{...e.data.allowPurchase&&["subscription","assignment"].includes(f.source)&&f.accessEnabled?{membershipActions:[{value:`${f.cancelAtPeriodEnd?"resume":"cancel"}:${f.id}`,label:f.cancelAtPeriodEnd?t("\u6062\u590D\u7EED\u8D39","Resume renewal"):f.source==="assignment"?t("\u53D6\u6D88\u4F1A\u5458","Cancel membership"):t("\u53D6\u6D88\u7EED\u8D39","Cancel renewal")},...f.scheduledChange?[{value:`cancel_change:${f.id}`,label:t("\u64A4\u9500\u9884\u7EA6\u53D8\u66F4","Cancel scheduled change")}]:[]]}:{},status:f.accessEnabled?t("\u6709\u6548","Active"):t("\u5F53\u524D\u65E0\u8BBF\u95EE\u6743\u9650","Access unavailable")})),d.updatedAt=B.membership.evaluatedAt}else if(e.data.source==="credit_transactions"){let f={...c,resourceKey:e.data.resourceKey,...E.filter!=="all"?{kind:E.filter}:{}},i=await V(JSON.stringify([l,e.data.source,f]),()=>v.listCreditTransactions(f));if(!x())return;s.next=i.nextCursor,d.rows=i.transactions.map(y=>L(y.id,y.featureName??j[y.kind]??t("\u79EF\u5206\u8C03\u6574","Credit adjustment"),[A(y.at),...y.reason?[y.reason]:[],`${t("\u4E1A\u52A1\u6570\u91CF","Quantity")} \xB7 ${I(y.quantity)}`],{status:j[y.kind]??t("\u79EF\u5206\u53D8\u52A8","Credit change"),facts:y.allocations.map(se=>({label:oe(se.balanceId),value:I(se.amount)}))})),d.hasNext=i.nextCursor!==null,d.hasPrevious=s.localPage>0}else if(e.data.source==="credit_pack_orders"){let f={...c,...E.filter!=="all"?{status:E.filter}:{}},i=await V(JSON.stringify([l,e.data.source,f]),()=>v.listCreditPackOrders(f));if(!x())return;s.next=i.nextCursor,d.rows=i.orders.map(y=>L(y.id,y.name,[A(y.at),`${I(y.amount)} ${t("\u79EF\u5206","credits")}`],{value:U(y.amountCents,y.currency),status:j[y.status]??y.status,facts:y.refundedCents?[{label:t("\u5DF2\u9000\u6B3E","Refunded"),value:U(y.refundedCents,y.currency)}]:[]})),d.hasNext=i.nextCursor!==null,d.hasPrevious=s.localPage>0}else if(e.data.source==="offer_history"){let f={...c,...E.filter!=="all"?{status:E.filter}:{}},i=await V(JSON.stringify([l,e.data.source,f]),()=>v.listOfferHistory(f));if(!x())return;s.next=i.nextCursor,d.rows=i.offers.map(y=>L(y.id,y.coupon.name,[A(y.issuedAt),...y.expiresAt?[A(y.expiresAt)]:[]],{status:j[y.status]??y.status})),d.hasNext=i.nextCursor!==null,d.hasPrevious=s.localPage>0}else if(e.data.source==="customer_plans"){let f=await V(`plans:${l}`,()=>v.listCustomerPlans());if(!x())return;N=f.plans.map(i=>L(i.plan.id,i.plan.name,[j[i.eligibility.reason]??i.eligibility.reason,...i.eligibility.trial?.eligible?[t("\u7B26\u5408\u8BD5\u7528\u8D44\u683C","Eligible for trial")]:[]],{...e.data.allowPurchase&&i.eligibility.status==="available"&&i.eligibility.action&&i.price?{membershipActions:[{value:`${i.eligibility.action}:${i.plan.id}`,label:i.eligibility.action==="attach"?t("\u8D2D\u4E70\u5957\u9910","Purchase plan"):i.eligibility.direction==="downgrade"?t("\u964D\u7EA7\u5957\u9910","Downgrade plan"):t("\u53D8\u66F4\u5957\u9910","Change plan")}]}:{},status:j[i.eligibility.status],value:i.price?i.price.interval==="free"?t("\u514D\u8D39","Free"):`${U(i.price.amountCents,i.price.currency)} / ${i.price.interval==="year"?t("\u5E74","year"):t("\u6708","month")}`:t("\u5F53\u524D\u5E01\u79CD\u65E0\u4EF7\u683C","No price for this currency")})),d.updatedAt=f.evaluatedAt}else if(e.data.source==="credit_packs"){let f=await V(`packs:${l}`,()=>v.listCreditPacks());if(!x())return;N=f.packs.map(i=>L(i.id,i.name,[`${I(i.amount)} ${t("\u79EF\u5206","credits")}`,...i.expiresDays?[`${i.expiresDays} ${t("\u5929\u6709\u6548","days validity")}`]:[t("\u65E0\u56FA\u5B9A\u5230\u671F\u65F6\u95F4","No fixed expiry")]],{value:U(i.amountCents,i.currency),...e.data.allowPurchase?{purchaseId:i.id}:{}}))}if(N){let f=Math.max(0,Math.ceil(N.length/m)-1);s.localPage=Math.min(s.localPage,f),d.page=s.localPage+1,d.rows=N.slice(s.localPage*m,(s.localPage+1)*m),d.hasNext=(s.localPage+1)*m<N.length,d.hasPrevious=s.localPage>0}!C&&l===u&&s.sequence===n&&(h.nodes[r]=ae.parse(d),k())}catch(d){if(!C&&l===u&&s.sequence===n){let m=d instanceof _?d:new _("INVALID_RESPONSE",t("\u9875\u9762\u6570\u636E\u6682\u65F6\u4E0D\u53EF\u7528\u3002","Page data is unavailable."));if(["UNAUTHENTICATED","NOT_IDENTIFIED"].includes(m.code)){Z(m);return}let w=["FORBIDDEN","SCOPE_MISMATCH","IDENTITY_CHANGED"].includes(m.code);h.nodes[r]={...w?K(e.data.source):h.nodes[r],status:"error",stale:!0,errorCode:m.code,errorMessage:m.message},k(),H(m)}}})().finally(()=>{s.pending===g&&(s.pending=void 0)});return s.pending=g,g}let de=re.map(r=>{let o=null;return r.subscribe(()=>{let e=r.getSnapshot();if(e.status==="ready"&&e.data!==o){o=e.data,r===F&&(p=e.data);for(let[s,n]of a)(r===F?n.data.source==="credit_balance":n.data.source==="membership")&&$(s,!0)}if(e.status==="error"&&!e.data){if(e.error&&["UNAUTHENTICATED","NOT_IDENTIFIED"].includes(e.error.code)){Z(e.error);return}r===F&&(p=null);for(let[s,n]of a)if(r===F?["credit_balance","credit_transactions"].includes(n.data.source):n.data.source==="membership"){let u=G(s);u.sequence++,u.pending=void 0,h.nodes[s]={...K(n.data.source),status:"error",errorCode:e.error?.code,errorMessage:e.error?.message}}k()}})}),ue=v.subscribeIdentity(r=>{l++,S=!1,p=null,q.clear(),M.clear(),D.clear(),O.clear();for(let[o,e]of a){let s=G(o);s.sequence++,s.pending=void 0,s.cursors=[void 0],s.localPage=0,s.next=void 0,s.sources.clear(),h.nodes[o]=K(e.data.source)}k(),r&&Promise.all([...a.keys()].map(o=>$(o)))});async function le(r){let o=ne.safeParse(r);if(!o.success||C||!a.has(o.data.nodeId))return;let e=o.data,s=a.get(e.nodeId),n=G(e.nodeId),u=h.nodes[e.nodeId];if(e.action==="refresh"){if(u.status==="loading")return n.pending;let g=l;X(e.nodeId),k();let d=s.data.source==="membership"?W:["credit_balance","credit_transactions"].includes(s.data.source)?F:null;if(d)try{await d.refresh()}catch{}if(C||l!==g)return;await $(e.nodeId,!0);return}if(e.action.startsWith("membership_")){let g=`${l}:${e.nodeId}`;if(O.has(g)||!s.data.allowPurchase||!["membership","customer_plans"].includes(s.data.source)||u.membershipBusy||u.status!=="ready")return;let d=l,m=()=>!C&&d===l,w=D.get(e.nodeId);if(e.action==="membership_dismiss"){if(w?.submitted)return;D.delete(e.nodeId),delete u.membershipReview,k();return}if(e.action==="membership_preview"&&(!u.rows.some(c=>c.membershipActions?.some(N=>N.value===e.value))||w?.submitted))return;O.add(g),u.membershipBusy=!0,delete u.errorMessage,delete u.membershipResult,k();try{if(e.action==="membership_preview"){let[c,N]=e.value.split(":"),T=c==="attach"||c==="change"?{action:c,planVersionId:N,requestId:crypto.randomUUID()}:{action:c,holdingId:N,requestId:crypto.randomUUID()},B=await v.previewMembership(T);if(!m())return;D.set(e.nodeId,{input:T,preview:B,submitted:!1}),h.nodes[e.nodeId].membershipReview=Y(B,P.locale)}else if(e.action==="membership_confirm"&&w){if(!w.submitted){let T=await v.previewMembership(w.input);if(!m())return;if(te(T)!==te(w.preview))throw w.preview=T,h.nodes[e.nodeId].membershipReview=Y(T,P.locale),new _("CONFLICT",t("\u8D39\u7528\u6216\u751F\u6548\u6761\u6B3E\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u5BA1\u9605\u5E76\u786E\u8BA4\u3002","The quote changed. Review the updated terms and confirm again."));if(T.requiresCheckout&&!P.onCheckout)throw new _("NOT_CONFIGURED",t("\u8D2D\u4E70\u6D41\u7A0B\u5C1A\u672A\u63A5\u5165\u3002","The purchase flow is not connected."))}w.submitted=!0;let c=await v.manageMembership(w.input);if(!m())return;let N=c.checkout?.url??c.paymentUrl;if(N){if(new URL(N).protocol!=="https:")throw new _("INVALID_RESPONSE","Invalid payment URL");if(!P.onCheckout)throw new _("NOT_CONFIGURED","Payment navigation unavailable");await P.onCheckout({url:N})}if(!m())return;D.delete(e.nodeId),q.clear();try{await W?.refresh()}catch{}if(!m())return;await $(e.nodeId,!0),delete h.nodes[e.nodeId].membershipReview,h.nodes[e.nodeId].membershipResult=c.status==="scheduled"?t("\u53D8\u66F4\u5DF2\u9884\u7EA6\uFF0C\u5C06\u5728\u663E\u793A\u7684\u751F\u6548\u65F6\u95F4\u6267\u884C\u3002","Change scheduled for the reviewed effective date."):c.status==="payment_pending"?t("\u7B49\u5F85\u4ED8\u6B3E\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u5237\u65B0\u67E5\u770B\u6743\u76CA\u3002","Payment is pending. Refresh after payment to check access."):t("\u4F1A\u5458\u5DF2\u66F4\u65B0\u3002","Membership updated.")}}catch(c){if(c instanceof _&&["UNAUTHENTICATED","NOT_IDENTIFIED"].includes(c.code)&&m()){Z(c);return}m()&&(w&&c instanceof _&&["INVALID_REQUEST","FORBIDDEN","NOT_FOUND","CONFLICT","NOT_CONFIGURED"].includes(c.code)&&(w.submitted=!1),h.nodes[e.nodeId].errorMessage=c instanceof Error?c.message:t("\u4F1A\u5458\u64CD\u4F5C\u6682\u4E0D\u53EF\u7528\u3002","Membership operation unavailable."),H(c))}finally{O.delete(g),m()&&(h.nodes[e.nodeId].membershipBusy=!1,k())}return}if(e.action==="buy_pack"){if(!s.data.allowPurchase||s.data.source!=="credit_packs"||u.status!=="ready"||!u.rows.some(c=>c.purchaseId===e.value))return;if(!P.onCheckout){let c=new _("NOT_CONFIGURED",t("\u8D2D\u4E70\u6D41\u7A0B\u5C1A\u672A\u63A5\u5165\uFF0C\u8BF7\u8054\u7CFB\u670D\u52A1\u63D0\u4F9B\u65B9\u3002","The purchase flow is not connected. Contact the provider."));h.nodes[e.nodeId]={...u,errorCode:c.code,errorMessage:c.message},k(),H(c);return}let g=e.value,d=M.get(g);if(d?.pending)return d.pending;d||(d={requestId:crypto.randomUUID()},M.set(g,d));let m=l;u.buyingId=g,k();let w=d;return w.pending=(async()=>{try{let c=await v.createCreditPackCheckout({packVersionId:g,requestId:w.requestId});if(new URL(c.url).protocol!=="https:")throw new _("INVALID_RESPONSE","Invalid checkout URL");!C&&m===l&&(await P.onCheckout(c),M.delete(g))}catch(c){!C&&m===l&&(h.nodes[e.nodeId]={...h.nodes[e.nodeId],errorMessage:c instanceof Error?c.message:t("\u8D2D\u4E70\u6682\u4E0D\u53EF\u7528\u3002","Purchase is unavailable.")},H(c))}finally{!C&&m===l&&(delete h.nodes[e.nodeId].buyingId,k()),w.pending=void 0}})(),w.pending}if(e.action==="filter"){if(!{credit_transactions:["all","consume","reserve","confirm","release","refund"],credit_pack_orders:["all","created","pending","paid","expired","refunded","disputed"],offer_history:["all","issued","redeemed","expired","revoked"]}[s.data.source]?.includes(e.value??""))return;h.nodes[e.nodeId]={...u,filter:e.value,rows:[],page:1,hasNext:!1,hasPrevious:!1},n.localPage=0,n.cursors=[void 0],n.next=void 0,await $(e.nodeId,!0);return}if(u.status!=="ready")return;if(e.action.startsWith("sources_")){let g=u.resources.find(w=>w.key===e.value);if(!g)return;let d=e.action==="sources_next";if(d?!g.hasNextSources:!g.hasPreviousSources)return;let m=n.sources.get(g.key);if(!m)return;if(d){if(!m.next)return;m.cursors[m.page+1]=m.next,m.page++}else m.page--;n.sources.set(g.key,m),await $(e.nodeId);return}let x=n.localPage,E=l;if(e.action==="next"&&u.hasNext)n.localPage++,n.cursors[n.localPage]=n.next;else if(e.action==="previous"&&u.hasPrevious)n.localPage--;else return;await $(e.nodeId),!C&&l===E&&h.nodes[e.nodeId].status==="error"&&(n.localPage=x)}let me={snapshot:()=>ee.parse(h),intent:le,async refresh(){if(C)return;let r=l;for(let o of a.keys())X(o);k(),await Promise.all(re.map(o=>o.refresh().catch(()=>{}))),!(C||l!==r)&&await Promise.all([...a.keys()].map(o=>$(o,!0)))},destroy(){C=!0,l++,de.forEach(r=>r()),ue(),q.clear(),M.clear(),D.clear(),O.clear()}};return k(),Promise.all([...a.keys()].map(r=>$(r))),me}export{fe as a,be as b,pe as c,Pe as d};