@tinkerlandai/longplay-sdk 0.10.73 → 0.10.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/check-response-LYK2HZFK.js +1 -0
  3. package/dist/{chunk-XOX4O4A7.js → chunk-3ZYWGEBY.js} +1 -1
  4. package/dist/{chunk-TY4PJ2AG.js → chunk-464CINQK.js} +1 -1
  5. package/dist/{chunk-NPDRXDI7.js → chunk-4G52SO64.js} +1 -1
  6. package/dist/{chunk-WX55MS2F.js → chunk-52GS4CLH.js} +1 -1
  7. package/dist/{chunk-GNRFL6KF.js → chunk-5SNUVXZ7.js} +1 -1
  8. package/dist/{chunk-SOUVNTG4.js → chunk-62MMCXIA.js} +1 -1
  9. package/dist/{chunk-4DMVOAXB.js → chunk-66SRWQES.js} +1 -1
  10. package/dist/{chunk-PLXNTIX4.js → chunk-B7CFFTJI.js} +1 -1
  11. package/dist/{chunk-CN2INQIX.js → chunk-BB6PDBS4.js} +1 -1
  12. package/dist/chunk-CIVRE5G5.js +1 -0
  13. package/dist/{chunk-E3DRXDDQ.js → chunk-CJJ4R645.js} +1 -1
  14. package/dist/{chunk-ZZ4X4DMO.js → chunk-CLV4ROBM.js} +1 -1
  15. package/dist/{chunk-XJTEGBPR.js → chunk-CWBL2S3A.js} +1 -1
  16. package/dist/{chunk-SUAUY6IF.js → chunk-DIFM44US.js} +1 -1
  17. package/dist/{chunk-2XTBFJN4.js → chunk-DMMD4TMS.js} +1 -1
  18. package/dist/{chunk-V53RJR3S.js → chunk-DRCBHEC6.js} +1 -1
  19. package/dist/{chunk-HLK7L2RV.js → chunk-E4B7243C.js} +1 -1
  20. package/dist/{chunk-DCPRELJA.js → chunk-EQJIC52H.js} +1 -1
  21. package/dist/{chunk-4ZIA22MI.js → chunk-EU7KLHEE.js} +1 -1
  22. package/dist/{chunk-WG2DKREQ.js → chunk-FINCNJBH.js} +1 -1
  23. package/dist/{chunk-MSRPJSCY.js → chunk-FMDLTDLK.js} +1 -1
  24. package/dist/{chunk-KLPRVDHS.js → chunk-H3LBNH34.js} +1 -1
  25. package/dist/{chunk-MQ3543DO.js → chunk-HQ6MQWFY.js} +1 -1
  26. package/dist/{chunk-UG5RBIWP.js → chunk-IEYSWIRA.js} +1 -1
  27. package/dist/{chunk-T3JVQBQT.js → chunk-KCRL2BDG.js} +1 -1
  28. package/dist/{chunk-7XQKSA4R.js → chunk-KRJ7D25I.js} +1 -1
  29. package/dist/{chunk-H4RDA4MD.js → chunk-KSRJEMYQ.js} +1 -1
  30. package/dist/{chunk-DKEQCWIR.js → chunk-L33UXXE4.js} +2 -2
  31. package/dist/{chunk-Y4MFO2FU.js → chunk-LYTPUZOW.js} +1 -1
  32. package/dist/{chunk-PHUD42K4.js → chunk-M3E3ZAHR.js} +1 -1
  33. package/dist/{chunk-OHPNHCQS.js → chunk-MWTSCBSY.js} +1 -1
  34. package/dist/{chunk-MCFHMWLX.js → chunk-NUIKM2BY.js} +1 -1
  35. package/dist/{chunk-QLUP7E5M.js → chunk-PZPONSBE.js} +1 -1
  36. package/dist/{chunk-SZPHTRYE.js → chunk-Q6SK6G7T.js} +1 -1
  37. package/dist/{chunk-NE64O6U6.js → chunk-QJLVJLVX.js} +1 -1
  38. package/dist/{chunk-O273JQ7U.js → chunk-QLMQI6SX.js} +1 -1
  39. package/dist/{chunk-AVXJB4O6.js → chunk-RM6RSLKI.js} +1 -1
  40. package/dist/{chunk-JFQBHUUN.js → chunk-SHJUMRYM.js} +1 -1
  41. package/dist/{chunk-GWREHUOB.js → chunk-STASMAS7.js} +1 -1
  42. package/dist/{chunk-HQWZWHHM.js → chunk-SUUBL2WC.js} +1 -1
  43. package/dist/{chunk-EK5U2JOM.js → chunk-TQKNQGWV.js} +1 -1
  44. package/dist/{chunk-SSVSXSYE.js → chunk-TZTWXL53.js} +1 -1
  45. package/dist/chunk-WAPQ6BX4.js +1 -0
  46. package/dist/{chunk-724YT3J5.js → chunk-WPPT4PS7.js} +1 -1
  47. package/dist/{chunk-7KQWJBFQ.js → chunk-X6ZYJHX4.js} +1 -1
  48. package/dist/{chunk-VVZLNTWC.js → chunk-XSEYXS4X.js} +1 -1
  49. package/dist/{chunk-KWOB5LYC.js → chunk-YMTCZWZG.js} +1 -1
  50. package/dist/{chunk-LM6TMEMB.js → chunk-ZLRQ6X3A.js} +1 -1
  51. package/dist/{content-RJTGQ5OG.js → content-PFD22VB5.js} +1 -1
  52. package/dist/funnel-host-purchase-A7RIV3VL.js +1 -0
  53. package/dist/funnel-host-recovery-paywall-QWUEMOMW.js +1 -0
  54. package/dist/{funnel-paywall-copies-E7GHHCVL.js → funnel-paywall-copies-43CVL4UQ.js} +1 -1
  55. package/dist/funnel-paywall-prerender-LFK2J34G.js +1 -0
  56. package/dist/funnel-route-prediction-DXMYNMCA.js +1 -0
  57. package/dist/funnel-route-source-2OGRCZKX.js +1 -0
  58. package/dist/funnel-runtime-host-BMOLGYXZ.js +1 -0
  59. package/dist/index.d.ts +13 -1
  60. package/dist/index.js +1 -1
  61. package/dist/merchant-bridge-contracts-MEMS65CV.js +1 -0
  62. package/dist/openrouter.js +1 -1
  63. package/dist/operation-contracts-L3CZMIL6.js +1 -0
  64. package/dist/page.js +1 -1
  65. package/dist/paywall-ZP5X27ZZ.js +1 -0
  66. package/dist/paywall-content-5SVZLU5S.js +1 -0
  67. package/dist/paywall-session-NKWC4TGU.js +1 -0
  68. package/dist/popup.js +1 -1
  69. package/dist/react-native.js +1 -1
  70. package/dist/screen-renderer-IKROGLA7.js +1 -0
  71. package/dist/server.js +1 -1
  72. package/dist/visual.js +1 -1
  73. package/package.json +9 -10
  74. package/dist/check-response-2VZGH33N.js +0 -1
  75. package/dist/chunk-VWVLWUBX.js +0 -1
  76. package/dist/chunk-ZUBDANL4.js +0 -1
  77. package/dist/funnel-host-purchase-HBKEI5SU.js +0 -1
  78. package/dist/funnel-host-recovery-paywall-FVRMHF6K.js +0 -1
  79. package/dist/funnel-paywall-prerender-BU4VSPDB.js +0 -1
  80. package/dist/funnel-route-prediction-6IXHGQYB.js +0 -1
  81. package/dist/funnel-route-source-CALCHIZL.js +0 -1
  82. package/dist/funnel-runtime-host-GF6XCCO3.js +0 -1
  83. package/dist/merchant-bridge-contracts-2TYLNFKF.js +0 -1
  84. package/dist/operation-contracts-KYYM2PJO.js +0 -1
  85. package/dist/paywall-KGICSTDM.js +0 -1
  86. package/dist/paywall-content-7NCG5I7S.js +0 -1
  87. package/dist/paywall-session-AEDGMP7W.js +0 -1
  88. package/dist/screen-renderer-AVHPHFXT.js +0 -1
  89. /package/dist/{chunk-35JZDDF3.js → chunk-7RUOZL6C.js} +0 -0
  90. /package/dist/{chunk-DKEQCWIR.js.LEGAL.txt → chunk-L33UXXE4.js.LEGAL.txt} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.75
4
+
5
+ - With `whenPurchasePending: "recover"`, a pre-render that finds an unfinished purchase and no kept Paywall now keeps the Paywall it has just read, under the Funnel of its Start or of the purchase left pending in storage, and holds it for that purchase's recovery. Before, only a copy kept from an earlier presentation was held, and an earlier SDK forgot that copy as soon as a purchase became pending, so a Customer who already had an unpaid Checkout never got the Paywall at the click. A refused Start with no pending purchase in storage still gives the copy up
6
+
7
+ ## 0.10.74
8
+
9
+ - `prerenderFunnelPurchase` accepts `whenPurchasePending: "recover"`. By default a purchase this Customer left unfinished makes the pre-rendered copy unavailable and forgets the kept one, so the next click shows nothing until that purchase has been read. With the option the Paywall the device kept stays: a click reveals it at once, display only, and `showFunnelPurchase`, given that copy with or without a Start, recovers the purchase behind it and replaces the copy in the same open dialog once the purchase's own Paywall has painted, with no loading state in between. A copy that must be read first, and a purchase Longplay cannot attribute to one original, behave as before
10
+
3
11
  ## 0.10.73
4
12
 
5
13
  - A purchase presentation whose Run has ended while its original Checkout is still unpaid no longer limits the Paywall to Continue checkout when it was opened with a Start and sells new purchases. Choosing another plan closes the original Checkout first, reads it back closed and unpaid, and only then quotes that plan with a new Run of the same Start (a fresh request) in the same rendered Paywall. A paid or settling original is shown instead. A recovery without a Start, or with `allowNewPurchase: false`, still offers only the original Checkout
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-B7CFFTJI.js";import"./chunk-CWBL2S3A.js";import"./chunk-X6ZYJHX4.js";import"./chunk-E4B7243C.js";import"./chunk-5SNUVXZ7.js";import"./chunk-7RUOZL6C.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as validateEntitlementCheck,b as validateResourceCheck};
@@ -1 +1 @@
1
- import{b as e}from"./chunk-35JZDDF3.js";var r=e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),m=e.enum(["unknown","denied","provisional","granted"]),d=e.enum(["ios","android"]),i=e.strictObject({installationId:e.uuid(),publicKey:e.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:e.iso.datetime({offset:!0}),signature:e.string().regex(/^[A-Za-z0-9_-]{86}$/)}),a=e.string().regex(/^[a-f0-9]{64}$/),p=i.extend({sequence:r,platform:d,credentialDigest:a}),f=i.extend({credentialDigest:a}),x=i.extend({sequence:r,platform:d}),l=i.extend({sequence:r,credentialDigest:a,connectionId:e.uuid().nullable(),kind:e.enum(["fcm_token","apns_token"]).nullable(),token:e.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:m}),g=l,b=l.extend({challenge:e.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),S=e.strictObject({requested:e.literal(!0),expiresAt:e.iso.datetime({offset:!0})}),A=e.strictObject({installationId:e.uuid(),bound:e.boolean(),identitySeq:r,bindingGeneration:r,addressSeq:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:e.uuid().nullable(),addressStatus:e.enum(["active","invalid"]).nullable(),permission:m}),I=e.strictObject({channel:e.enum(["email","sms","voice","push"]),state:e.enum(["unknown","allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}),P=e.strictObject({state:e.enum(["allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function y(s,c,t){let n=["indiana_push_v1",s,c.projectId,c.environment,t.installationId,t.publicKey,t.issuedAt];s==="bind"?n.push(t.sequence,t.platform,t.credentialDigest):s==="detach"?n.push(t.sequence,t.platform):s==="read"?n.push(t.credentialDigest):n.push(t.sequence,t.credentialDigest,t.connectionId,t.kind,t.token,t.permission),s==="recovery_confirm"&&n.push(t.challenge);let u=JSON.stringify(n);if([...u].some(o=>o.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(u,o=>o.charCodeAt(0))}export{p as a,f as b,x as c,l as d,g as e,b as f,S as g,A as h,I as i,y as j};
1
+ import{b as e}from"./chunk-7RUOZL6C.js";var r=e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),m=e.enum(["unknown","denied","provisional","granted"]),d=e.enum(["ios","android"]),i=e.strictObject({installationId:e.uuid(),publicKey:e.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:e.iso.datetime({offset:!0}),signature:e.string().regex(/^[A-Za-z0-9_-]{86}$/)}),a=e.string().regex(/^[a-f0-9]{64}$/),p=i.extend({sequence:r,platform:d,credentialDigest:a}),f=i.extend({credentialDigest:a}),x=i.extend({sequence:r,platform:d}),l=i.extend({sequence:r,credentialDigest:a,connectionId:e.uuid().nullable(),kind:e.enum(["fcm_token","apns_token"]).nullable(),token:e.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:m}),g=l,b=l.extend({challenge:e.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),S=e.strictObject({requested:e.literal(!0),expiresAt:e.iso.datetime({offset:!0})}),A=e.strictObject({installationId:e.uuid(),bound:e.boolean(),identitySeq:r,bindingGeneration:r,addressSeq:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:e.uuid().nullable(),addressStatus:e.enum(["active","invalid"]).nullable(),permission:m}),I=e.strictObject({channel:e.enum(["email","sms","voice","push"]),state:e.enum(["unknown","allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}),P=e.strictObject({state:e.enum(["allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function y(s,c,t){let n=["indiana_push_v1",s,c.projectId,c.environment,t.installationId,t.publicKey,t.issuedAt];s==="bind"?n.push(t.sequence,t.platform,t.credentialDigest):s==="detach"?n.push(t.sequence,t.platform):s==="read"?n.push(t.credentialDigest):n.push(t.sequence,t.credentialDigest,t.connectionId,t.kind,t.token,t.permission),s==="recovery_confirm"&&n.push(t.challenge);let u=JSON.stringify(n);if([...u].some(o=>o.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(u,o=>o.charCodeAt(0))}export{p as a,f as b,x as c,l as d,g as e,b as f,S as g,A as h,I as i,y as j};
@@ -1 +1 @@
1
- import{C as d,D as u}from"./chunk-KLPRVDHS.js";function f(r){let{quote:o,operation:e,requestId:s}=r,a={type:"recover",operationId:e?.operationId??o?.operationId??null,requestId:s};if(r.destroyed||r.pending)return a;if(!e)return o?{type:"cancel",operationId:o.operationId}:a;let t=e.merchantExecution;if(d(e)){if(t&&t.type!=="subscription_change")return a;if(t?.type==="subscription_change"){if(["applied","scheduled"].includes(t.status))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&u(e)&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&!e.problem&&!t.problem&&t.nextAction?.type==="redirect"&&(!e.checkoutUrl||t.nextAction.url===e.checkoutUrl)&&Date.parse(t.nextAction.expiresAt)>Date.now()&&t.status==="pending")return{type:"checkout",operationId:e.operationId,checkoutUrl:t.nextAction.url}}if(!e.problem&&!t?.problem&&u(e)&&e.executor!=="merchant")return{type:"complete",operationId:e.operationId};if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let n=p=>!p||p.phase==="execution"&&p.reason==="STATE_CHANGED";return r.canReselect===!0&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&n(e.problem)&&n(t?.problem)&&(!t||t.status==="failed"&&t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable")?{type:"native",operationId:e.operationId}:["prepared","quoted"].includes(e.status)&&!e.confirmedAt&&!t&&!e.checkoutUrl&&!e.problem?{type:"cancel",operationId:e.operationId}:a}if(t?.type==="purchase"){if(["succeeded","not_required"].includes(t.paymentStatus))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&e.status==="complete"&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&e.checkoutUrl&&!e.problem&&!t.problem&&t.checkoutUrl===e.checkoutUrl&&t.checkoutExpiresAt&&Date.parse(t.checkoutExpiresAt)>Date.now()&&["not_started","pending"].includes(t.paymentStatus))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl}}if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&!e.nativePurchase&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let c=[e.problem,t?.problem],i=c.every(n=>!n||n.phase==="execution"&&n.reason!=="RESULT_UNKNOWN"),y=e.status==="cancelled"&&!c.some(Boolean)&&t?.type==="purchase"&&["pending","not_started","expired"].includes(t.paymentStatus)&&["not_started","not_applicable"].includes(t.fulfillmentStatus);return r.canReselect===!0&&i&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"||!t||t.type==="purchase"&&!["succeeded","not_required"].includes(t.paymentStatus)&&(y||t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable"))?{type:"native",operationId:e.operationId}:!c.some(Boolean)&&e.status==="complete"&&e.executor!=="merchant"?{type:"complete",operationId:e.operationId}:i&&r.canReselect!==!1&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"?!e.confirmedAt&&(e.status==="cancelled"||!e.quoteFinalized):!t&&!e.quoteFinalized||t?.type==="purchase"&&["failed","expired"].includes(t.paymentStatus)&&t.fulfillmentStatus==="not_applicable"&&t.recordingStatus==="accepted")?{type:"native",operationId:e.operationId}:e.status==="pending"&&i&&!e.quoteFinalized&&!t&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase?{type:"cancel",operationId:e.operationId}:a}function h(r,o=!0){if(!r)return!1;let e=f({quote:r.quote??null,operation:r,requestId:null,pending:!1,destroyed:!1,canReselect:o});return e.type==="complete"||e.type==="native"}function l(r){return r.recovery??{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}}function b(r){return!!(r?.operationId&&(r.type==="checkout"||r.type==="recover"||r.type==="fulfillment"||r.type==="recording"))}async function g(r){let o=l(r);if(o.type==="recover"&&r.quote)try{await r.read(),o=l(r)}catch{return o}if(o.type!=="cancel"&&!(o.type==="recover"&&r.pendingCancellation))return o;try{await r.cancel();let e=l(r);return e.type==="cancel"?{type:"recover",operationId:o.operationId,requestId:null}:e}catch{let e=l(r);return e.type==="recover"?e:{type:"recover",operationId:o.operationId,requestId:null}}}export{f as a,h as b,l as c,b as d,g as e};
1
+ import{C as d,D as u}from"./chunk-H3LBNH34.js";function f(r){let{quote:o,operation:e,requestId:s}=r,a={type:"recover",operationId:e?.operationId??o?.operationId??null,requestId:s};if(r.destroyed||r.pending)return a;if(!e)return o?{type:"cancel",operationId:o.operationId}:a;let t=e.merchantExecution;if(d(e)){if(t&&t.type!=="subscription_change")return a;if(t?.type==="subscription_change"){if(["applied","scheduled"].includes(t.status))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&u(e)&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&!e.problem&&!t.problem&&t.nextAction?.type==="redirect"&&(!e.checkoutUrl||t.nextAction.url===e.checkoutUrl)&&Date.parse(t.nextAction.expiresAt)>Date.now()&&t.status==="pending")return{type:"checkout",operationId:e.operationId,checkoutUrl:t.nextAction.url}}if(!e.problem&&!t?.problem&&u(e)&&e.executor!=="merchant")return{type:"complete",operationId:e.operationId};if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let n=p=>!p||p.phase==="execution"&&p.reason==="STATE_CHANGED";return r.canReselect===!0&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&n(e.problem)&&n(t?.problem)&&(!t||t.status==="failed"&&t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable")?{type:"native",operationId:e.operationId}:["prepared","quoted"].includes(e.status)&&!e.confirmedAt&&!t&&!e.checkoutUrl&&!e.problem?{type:"cancel",operationId:e.operationId}:a}if(t?.type==="purchase"){if(["succeeded","not_required"].includes(t.paymentStatus))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&e.status==="complete"&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&e.checkoutUrl&&!e.problem&&!t.problem&&t.checkoutUrl===e.checkoutUrl&&t.checkoutExpiresAt&&Date.parse(t.checkoutExpiresAt)>Date.now()&&["not_started","pending"].includes(t.paymentStatus))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl}}if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&!e.nativePurchase&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let c=[e.problem,t?.problem],i=c.every(n=>!n||n.phase==="execution"&&n.reason!=="RESULT_UNKNOWN"),y=e.status==="cancelled"&&!c.some(Boolean)&&t?.type==="purchase"&&["pending","not_started","expired"].includes(t.paymentStatus)&&["not_started","not_applicable"].includes(t.fulfillmentStatus);return r.canReselect===!0&&i&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"||!t||t.type==="purchase"&&!["succeeded","not_required"].includes(t.paymentStatus)&&(y||t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable"))?{type:"native",operationId:e.operationId}:!c.some(Boolean)&&e.status==="complete"&&e.executor!=="merchant"?{type:"complete",operationId:e.operationId}:i&&r.canReselect!==!1&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"?!e.confirmedAt&&(e.status==="cancelled"||!e.quoteFinalized):!t&&!e.quoteFinalized||t?.type==="purchase"&&["failed","expired"].includes(t.paymentStatus)&&t.fulfillmentStatus==="not_applicable"&&t.recordingStatus==="accepted")?{type:"native",operationId:e.operationId}:e.status==="pending"&&i&&!e.quoteFinalized&&!t&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase?{type:"cancel",operationId:e.operationId}:a}function h(r,o=!0){if(!r)return!1;let e=f({quote:r.quote??null,operation:r,requestId:null,pending:!1,destroyed:!1,canReselect:o});return e.type==="complete"||e.type==="native"}function l(r){return r.recovery??{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}}function b(r){return!!(r?.operationId&&(r.type==="checkout"||r.type==="recover"||r.type==="fulfillment"||r.type==="recording"))}async function g(r){let o=l(r);if(o.type==="recover"&&r.quote)try{await r.read(),o=l(r)}catch{return o}if(o.type!=="cancel"&&!(o.type==="recover"&&r.pendingCancellation))return o;try{await r.cancel();let e=l(r);return e.type==="cancel"?{type:"recover",operationId:o.operationId,requestId:null}:e}catch{let e=l(r);return e.type==="recover"?e:{type:"recover",operationId:o.operationId,requestId:null}}}export{f as a,h as b,l as c,b as d,g as e};
@@ -1 +1 @@
1
- import{a as C,j as J}from"./chunk-XJTEGBPR.js";import{b as X}from"./chunk-WG2DKREQ.js";import{j as K,l as E}from"./chunk-GNRFL6KF.js";import{b as e}from"./chunk-35JZDDF3.js";var Y=e.number().int().min(0).max(1e8),V=e.strictObject({kind:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().min(1).max(1e4).nullable(),unitAmountMinor:Y,flatAmountMinor:Y.optional()})).min(1).max(12)}).refine(t=>t.tiers.at(-1)?.upTo===null&&t.tiers.slice(0,-1).every((n,i)=>{let r=t.tiers[i-1]?.upTo;return n.upTo!==null&&(i===0||r!=null&&n.upTo>r)}),"Tier ceilings must increase and end unbounded").refine(t=>!t.tiers.some(n=>(n.flatAmountMinor??0)>0)||t.kind==="volume"&&t.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers");function M(t,n){if(!Number.isInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased pack quantity");let i=t.pricing?V.parse(t.pricing):void 0;if(n===0)return 0;let r=0n,o=0;if(!i)r=BigInt(t.amountMinor)*BigInt(n);else for(let a of i.tiers){let s=a.upTo??1e4;if(i.kind==="volume"){if(n<=s){r=BigInt(n)*BigInt(a.unitAmountMinor)+BigInt(a.flatAmountMinor??0);break}}else n>o&&(r+=BigInt(Math.min(n,s)-o)*BigInt(a.unitAmountMinor));o=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function wt(t){return M({amountMinor:t.unitAmountMinor,...t.pricing?{pricing:t.pricing}:{}},t.quantity)}var ve=K.refine(t=>/[1-9]/.test(t)),te=e.strictObject({units:ve,prices:e.array(e.strictObject({currency:C,amountMinor:e.number().int().min(0).max(1e8),pricing:V.optional()})).min(1).max(20).refine(t=>new Set(t.map(n=>n.currency)).size===t.length,"Currencies must be unique").refine(t=>t.every(n=>!n.pricing||n.amountMinor===0),"Tiered prices specify their rates in tiers"),minimumQuantity:e.number().int().min(0).max(1e4),maximumQuantity:e.number().int().min(0).max(1e4)}).refine(t=>t.maximumQuantity>=t.minimumQuantity,"Purchased quantity must fit its published bounds").refine(t=>{try{for(let n of t.prices)for(let i of[t.maximumQuantity,...n.pricing?.tiers.flatMap(r=>r.upTo===null?[]:[r.upTo,r.upTo+1])??[]])i<=t.maximumQuantity&&M({amountMinor:n.amountMinor,...n.pricing===void 0?{}:{pricing:n.pricing}},i);return!0}catch{return!1}},"Every purchasable quantity must fit the payment amount limit");function ee(t){if(!/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/.test(t))throw new Error("Invalid quantity");let[n,i=""]=t.split(".");if(n===void 0||n==="")throw new Error("Invalid decimal value");return BigInt(n)*1000000n+BigInt(i.padEnd(6,"0"))}function Ot(t,n,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=ee(t)+ee(n)*BigInt(i);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let o=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(o?"."+o:"")}var ne=e.strictObject({internalFeatureId:e.uuid(),name:e.string().min(1).max(120),includedAmount:e.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),reset:e.enum(["hour","day","week","month","year","lifetime"]),resetCount:e.number().int().min(1).max(100),terms:te});var _e=["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","paywall.feature","paywall.message","paywall.action"],T=e.object({plan:e.string().min(1).max(200).optional(),coupon:e.uuid().optional(),promotionCode:e.uuid().optional(),picker:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),re=e.object({text:e.string().optional(),label:e.string().optional(),alt:e.string().optional(),html:e.string().max(32768).optional(),price:e.object({current:e.string(),original:e.string().nullable(),period:e.string()}).optional(),code:e.string().optional(),countdownAt:e.iso.datetime().optional(),planId:e.string().min(1).max(200).optional(),planVersionId:e.string().min(1).max(200).optional(),currency:C.optional(),couponId:e.uuid().optional(),offerId:e.uuid().optional(),unavailable:e.boolean().optional(),unavailableReason:e.string().optional(),missing:e.array(e.string()).optional()}).strict(),Et=e.object({paywall:J.optional(),nodes:e.record(e.string(),e.object({base:re,picker:e.string().optional(),byPlan:e.record(e.string(),re).optional()}).strict()),plans:e.record(e.string(),e.object({id:e.string().min(1).max(200),versionId:e.string().min(1).max(200),available:e.boolean(),name:e.string(),price:e.string(),period:e.string(),currency:C.optional(),amountMinor:e.number().int().nonnegative().optional(),interval:e.enum(["free","week","month","year","one_time"]).optional(),intervalCount:e.number().int().positive().optional(),prepaid:e.array(ne).max(100).optional()}).strict()),pickers:e.record(e.string(),e.object({options:e.array(e.string().min(1).max(200)).max(20),selected:e.string().min(1).max(200).nullable()}).strict()),quantities:e.record(e.string(),e.strictObject({minimum:e.number().int().nonnegative(),maximum:e.number().int().nonnegative(),step:e.number().int().positive(),value:e.number().int().nonnegative(),label:e.string(),available:e.boolean()})).optional(),diagnostics:e.array(e.object({nodeId:e.string(),message:e.string()}).strict())}).strict();function ie(t){return[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(n=>n[1]===void 0?[]:[n[1].trim()])}function Z(t){let n=ie(t).filter(r=>!_e.includes(r)&&!/^variables\.[A-Za-z0-9_][A-Za-z0-9_.:-]*$/.test(r)),i=t.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(i.includes("{{")||i.includes("}}"))&&n.push("无效变量语法"),[...new Set(n)]}function Vt(t,n,i={}){let r=t?.nodes[n];if(!r)return;let o=r.picker?i[r.picker]??t?.pickers[r.picker]?.selected:void 0;return typeof o=="string"?r.byPlan?.[o]??r.base:r.base}var Ne=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],oe=e.enum(Ne),ae=e.object({source:oe,layout:e.enum(["full","compact"]),resourceKey:E.optional(),pageSize:e.number().int().min(1).max(50),showSources:e.boolean(),allowPurchase:e.boolean(),outputs:e.object({billing_adjustment:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_authorization:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),buy_pack:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_portal:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),cancel_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),resume_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional()}).strict().optional()}).strict().superRefine((t,n)=>{(t.outputs?.billing_authorization||t.outputs?.billing_adjustment)&&t.source!=="billing_controls"&&n.addIssue({code:"custom",message:"Payment authorization routes belong to the billing controls component."}),t.resourceKey&&!["credit_balance","credit_transactions"].includes(t.source)&&n.addIssue({code:"custom",message:"这个数据源不能绑定积分资源。"}),t.showSources&&t.source!=="credit_balance"&&n.addIssue({code:"custom",message:"只有积分余额可以展开来源。"}),t.allowPurchase&&!["credit_packs","customer_plans","membership"].includes(t.source)&&n.addIssue({code:"custom",message:"只有积分包、套餐与会员组件可以启用交易。"})}),x=e.string().max(2e3),se=e.object({id:e.string().max(100),label:x,detail:e.array(x).max(12),value:x.optional(),status:x.optional(),facts:e.array(e.object({label:x,value:x}).strict()).max(1e3),purchaseId:e.uuid().optional(),invoiceUrl:e.url().max(2048).refine(t=>{let n=new URL(t);return n.protocol==="https:"&&!n.username&&!n.password}).optional(),billingActions:e.array(e.strictObject({action:e.literal("invoice_open"),label:x})).max(1).optional(),membershipActions:e.array(e.object({value:e.string().max(100),label:x}).strict()).max(3).optional()}).strict(),Pe=e.object({key:E,name:x,spendable:x,reserved:x,available:x,expiry:x.nullable(),sources:e.array(se).max(50),sourceCount:e.number().int().nonnegative(),sourcePage:e.number().int().positive(),hasNextSources:e.boolean(),hasPreviousSources:e.boolean()}).strict(),Oe=e.object({source:oe,status:e.enum(["idle","loading","ready","error"]),stale:e.boolean(),preview:e.boolean(),errorCode:e.string().max(80).optional(),errorMessage:x.optional(),resources:e.array(Pe).max(500),rows:e.array(se).max(50),hasNext:e.boolean(),hasPrevious:e.boolean(),page:e.number().int().positive(),filter:e.string().max(40),updatedAt:e.iso.datetime().optional(),buyingId:e.uuid().optional(),membershipBusy:e.boolean().optional(),billingBusy:e.boolean().optional(),membershipReview:e.object({title:x,note:x,facts:e.array(e.object({label:x,value:x}).strict()).max(100)}).strict().optional(),membershipResult:x.optional()}).strict(),Qt=e.object({nodes:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Oe)}).strict(),Ft=e.object({nodeId:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:e.enum(["refresh","next","previous","filter","buy_pack","billing_portal","billing_authorization","billing_adjustment","invoice_open","membership_preview","membership_confirm","membership_dismiss","sources_next","sources_previous"]),value:e.string().max(100).optional()}).strict();function ce(t){return t.type==="stack"&&t.interaction?.type==="select"&&t.interaction.purpose==="product"&&!!t.interaction.pickerId}function le(t){let n={};function i(r){if(ce(r)){let o=n[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let l=s.type==="stack"?s.bind?.plan:void 0;l&&!o.ids.includes(l)&&o.ids.push(l)}let a=r.children[r.interaction.defaultIndex];!o.defaultId&&a?.type==="stack"&&(o.defaultId=a.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return t.pages.forEach(r=>i(r.root)),n}function pe(t,n,i){let r={};function o(u){if(u.hidden)return;if(u.type==="plan_picker"){let b=i.pickers[u.id];r[u.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(u.type!=="stack")return;let y=u.children.filter(b=>!b.hidden),c=u.interaction;if(ce(u)){let b=r[u.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},k=i.pickers[u.interaction.pickerId]?.options??[];for(let p of y){let d=p.type==="stack"?p.bind?.plan:void 0;d&&k.includes(d)&&!b.ids.includes(d)&&b.ids.push(d),d&&p.id===n[u.id]&&b.remembered.push(d)}let m=u.children[u.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&b.defaults.push(m.bind.plan)}if(c?.type==="tabs"){let b=y.find(k=>k.id===n[u.id])??u.children[c.defaultIndex];b&&o(b)}else if(c?.type==="toggle"){let b=typeof n[u.id]=="boolean"?n[u.id]:c.defaultEnabled,k=u.children[b?0:1];k&&o(k)}else y.forEach(o)}let a=typeof n.__page=="string"?n.__page:t.initialPageId??t.pages[0]?.id,s=t.pages.find(u=>u.id===a);s&&o(s.root);let l={};for(let[u,y]of Object.entries(r)){let c=n[u],b=y.remembered[0]??(y.ids.includes(i.pickers[u]?.selected??"")?i.pickers[u]?.selected:y.defaults[0]);l[u]=typeof c=="string"?y.ids.includes(c)?c:"":b&&y.ids.includes(b)?b:""}for(let u of Object.keys(le(t)))l[u]??="";return l}var ue=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),me=e.strictObject({tiers:e.array(e.strictObject({id:ue,name:e.string().trim().min(1).max(80)})).min(1).max(8),assignments:e.array(e.strictObject({productVersionId:e.string().min(1).max(200),tierId:ue,period:e.enum(["month","year"])})).max(20)}).superRefine((t,n)=>{let i=t.tiers.map(r=>r.id);(new Set(i).size!==i.length||new Set(t.assignments.map(r=>r.productVersionId)).size!==t.assignments.length||new Set(t.assignments.map(r=>`${r.tierId}:${r.period}`)).size!==t.assignments.length||t.assignments.some(r=>!i.includes(r.tierId)))&&n.addIssue({code:"custom",message:"Each product and tier/period cell must have one unambiguous assignment"})});function fe(t,n){return t.assignments.length===n.length&&t.assignments.every(i=>n.includes(i.productVersionId))}function Jt(t){let n=Z(t).map(i=>`未知变量:${i}`);for(let i=0;i<t.length;i++){if(t[i]!=="<"||!/[A-Za-z!/?{]/.test(t[i+1]??""))continue;let r=i;if(t.startsWith("<!--",i)){let o=t.indexOf("-->",i+4);i=o<0?t.length:o+2}else{let o="";for(i++;i<t.length;i++){let a=t[i];if(o)a===o&&(o="");else if(a==='"'||a==="'")o=a;else if(a===">")break}}/\{\{|\}\}/.test(t.slice(r,i+1))&&n.push("变量只能放在 HTML 文字中,不能放入标签、属性或注释")}return[...new Set(n)]}var h={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},ge=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),S=e.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(t=>!ge.has(t),"Reserved UI identifier"),B=e.union([e.string().max(2e3),e.number().finite(),e.boolean(),e.null()]),Ae=e.discriminatedUnion("type",[e.strictObject({type:e.literal("enum"),values:e.array(B).min(1).max(h.enumValues),default:B}),e.strictObject({type:e.literal("number"),min:e.number().finite(),max:e.number().finite(),step:e.number().finite().positive(),default:e.number().finite()}),e.strictObject({type:e.literal("text"),maxLength:e.number().int().min(0).max(2e3),default:e.string().max(2e3).nullable()}),e.strictObject({type:e.literal("boolean"),default:e.boolean()})]);function D(t,n){if(t.type==="enum")return t.values.some(r=>r===n);if(t.type==="boolean")return typeof n=="boolean";if(t.type==="text")return n===null||typeof n=="string"&&n.length<=t.maxLength;if(typeof n!="number"||!Number.isFinite(n)||n<t.min||n>t.max)return!1;let i=(n-t.min)/t.step;return Number.isFinite(i)&&Math.abs(i-Math.round(i))<=Math.min(1e-7,Math.max(1,Math.abs(i))*Number.EPSILON*8)}var Ce=Ae.superRefine((t,n)=>{t.type==="enum"&&new Set(t.values).size!==t.values.length&&n.addIssue({code:"custom",path:["values"],message:"UI enum values must be unique"}),t.type==="number"&&t.min>t.max&&n.addIssue({code:"custom",path:["max"],message:"UI number range is reversed"}),D(t,t.default)||n.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),$e=["add","sub","mul","div","min","max","round","floor","eq","ne","gt","gte","lt","lte","and","or","not","if","concat","number","parse_number","money","lookup","now","duration"];function Ue(t,n){return t==="now"?n===0:t==="concat"?!0:t==="lookup"?n>=4&&n%2===0:t==="if"?n===3:["sub","div","eq","ne","gt","gte","lt","lte"].includes(t)?n===2:["round","floor","not","number","parse_number","money","duration"].includes(t)?n===1:n>=1}var N=e.lazy(()=>e.union([B,e.strictObject({ref:S}),e.strictObject({op:e.enum($e),args:e.array(N).max(h.expressionNodes)}).superRefine((t,n)=>{Ue(t.op,t.args.length)||n.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function j(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function _(t,n,i){if(!t||typeof t!="object")return!0;if(!j(t))return n.addIssue({code:"custom",path:i,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(t)){if(ge.has(r))return n.addIssue({code:"custom",path:[...i,r],message:"Reserved UI object key"}),!1;let o=Object.getOwnPropertyDescriptor(t,r);if(o&&!Object.hasOwn(o,"value"))return n.addIssue({code:"custom",path:[...i,r],message:"UI objects cannot contain accessors"}),!1}return!0}function O(t,n,i,r){let o=[{value:t,depth:1,path:i}];for(;o.length;){let a=o.pop();if(++r.nodes>h.expressionNodes||a.depth>h.depth){n.addIssue({code:"custom",path:a.path,message:"UI expression budget exceeded"});return}if(!_(a.value,n,a.path))return;if(j(a.value)&&Array.isArray(a.value.args)){if(a.value.args.length>h.expressionNodes){n.addIssue({code:"custom",path:[...a.path,"args"],message:"UI expression budget exceeded"});return}for(let s=a.value.args.length-1;s>=0;s--)o.push({value:a.value.args[s],depth:a.depth+1,path:[...a.path,"args",s]})}}}var en=e.unknown().superRefine((t,n)=>{O(t,n,[],{nodes:0})}).pipe(N),Q=e.record(S,N).refine(t=>Object.keys(t).length>0&&Object.keys(t).length<=h.state,"UI assignments need 1–32 state keys"),Le=e.strictObject({target:S,property:e.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:N,className:S.optional()}).superRefine((t,n)=>{t.property==="class"!=(t.className!==void 0)&&n.addIssue({code:"custom",path:["className"],message:"Only class bindings require a safe className"})}),Te=e.discriminatedUnion("type",[e.strictObject({type:e.literal("scroll_latch"),target:S,state:S}),e.strictObject({type:e.literal("input"),target:S,state:S,set:Q.optional()}),e.strictObject({type:e.literal("action"),target:S,set:Q}),e.strictObject({type:e.literal("carousel"),target:S,state:S,initialIndex:e.number().int().nonnegative().optional(),maxWidth:e.number().int().min(1).max(1e4).optional(),previousTarget:S.optional(),nextTarget:S.optional(),inactiveTargets:e.array(S).max(20).optional(),inactiveMaxWidth:e.number().int().min(1).max(1e4).optional()})]),De=e.strictObject({afterMs:e.number().int().min(0).max(6e4),set:Q}),Re=e.strictObject({type:e.literal("mosaic_waves"),target:S,color:e.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:e.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:N.optional(),speed:e.number().min(0).max(4).optional(),pitch:e.number().min(.05).max(4).optional(),fill:e.number().min(.05).max(1).optional(),feather:e.number().min(0).max(1).optional(),warp:e.number().min(0).max(4).optional(),warpScale:e.number().min(0).max(32).optional(),detailScale:e.number().min(0).max(32).optional(),waveScale:e.number().min(0).max(32).optional(),falloff:e.number().min(.1).max(32).optional(),brightness:e.number().min(0).max(32).optional(),ambient:e.number().min(0).max(1).optional(),gamma:e.number().min(.05).max(8).optional(),vignette:e.number().min(0).max(1).optional(),opacity:e.number().min(0).max(1).optional()}),Ee=e.strictObject({type:e.literal("number_counter"),target:S,value:N,prefix:e.string().max(20).optional(),format:e.enum(["number","short"]).optional()}),Ve=e.strictObject({state:e.record(S,Ce).refine(t=>Object.keys(t).length<=h.state,"Too many UI state keys").optional(),derived:e.record(S,N).refine(t=>Object.keys(t).length<=h.derived,"Too many UI derived keys").optional(),bindings:e.array(Le).max(h.bindings).optional(),controls:e.array(Te).max(h.controls).optional(),timers:e.array(De).max(h.timers).optional(),effects:e.array(e.discriminatedUnion("type",[Re,Ee])).max(h.effects).optional(),clock:e.boolean().optional()});function Me(t,n){if(!_(t,n,[])||!j(t))return;for(let[r,o]of[["state",h.state],["derived",h.derived]]){let a=t[r];if(!_(a,n,[r]))return;if(j(a)&&Object.keys(a).length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,o]of[["bindings",h.bindings],["controls",h.controls],["timers",h.timers],["effects",h.effects]])if(Array.isArray(t[r])&&t[r].length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(t.effects)){for(let[r,o]of t.effects.entries())if(!_(o,n,["effects",r]))return}if(j(t.state))for(let[r,o]of Object.entries(t.state)){if(!_(o,n,["state",r]))return;if(j(o)&&Array.isArray(o.values)&&o.values.length>h.enumValues){n.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let i={nodes:0};if(j(t.derived))for(let[r,o]of Object.entries(t.derived))O(o,n,["derived",r],i);for(let r of["bindings","controls","timers"]){let o=t[r];if(Array.isArray(o)){for(let[a,s]of o.entries())if(!(!_(s,n,[r,a])||!j(s))){if(r==="bindings")O(s.expression,n,[r,a,"expression"],i);else if(_(s.set,n,[r,a,"set"])&&j(s.set)){if(Object.keys(s.set).length>h.state){n.addIssue({code:"custom",path:[r,a,"set"],message:"Too many UI assignments"});return}for(let[l,u]of Object.entries(s.set))O(u,n,[r,a,"set",l],i)}if(i.nodes>h.expressionNodes)return}}}if(Array.isArray(t.effects))for(let[r,o]of t.effects.entries())j(o)&&o.type==="number_counter"?O(o.value,n,["effects",r,"value"],i):j(o)&&o.enabled!==void 0&&O(o.enabled,n,["effects",r,"enabled"],i)}function de(t){let n=[],i=[t];for(;i.length;){let r=i.pop();!r||typeof r!="object"||("ref"in r?n.push(r.ref):i.push(...r.args))}return n}var be=e.unknown().superRefine(Me).pipe(Ve).superRefine((t,n)=>{let i=t.state??{},r=t.derived??{},o=new Set([...Object.keys(i),...Object.keys(r)]),a=(m,p)=>{for(let d of de(m))o.has(d)||n.addIssue({code:"custom",path:p,message:`Unknown UI reference: ${d}`})};for(let[m,p]of Object.entries(t.derived??{}))Object.hasOwn(i,m)&&n.addIssue({code:"custom",path:["derived",m],message:"UI state and derived identifiers must be distinct"}),a(p,["derived",m]);let s=new Set,l=new Set,u=m=>{if(s.has(m))return!1;if(l.has(m))return!0;s.add(m);for(let p of de(r[m]))if(Object.hasOwn(r,p)&&!u(p))return!1;return s.delete(m),l.add(m),!0};for(let m of Object.keys(r))if(!u(m)){n.addIssue({code:"custom",path:["derived",m],message:"Cyclic UI derived references"});break}for(let[m,p]of(t.bindings??[]).entries())a(p.expression,["bindings",m,"expression"]);let y=new Set;for(let[m,p]of(t.effects??[]).entries())y.has(p.target)&&n.addIssue({code:"custom",path:["effects",m,"target"],message:"Effect targets must be unique"}),y.add(p.target),p.type==="number_counter"?(a(p.value,["effects",m,"value"]),typeof p.value=="number"&&Math.abs(p.value)>1e12&&n.addIssue({code:"custom",path:["effects",m,"value"],message:"Counter values must be within the display bound"})):p.enabled!==void 0&&a(p.enabled,["effects",m,"enabled"]);let c=(m,p)=>{for(let[d,v]of Object.entries(m))Object.hasOwn(i,d)||n.addIssue({code:"custom",path:[...p,d],message:"UI assignments can only update declared state"}),a(v,[...p,d])},b=new Set,k=new Set;for(let[m,p]of(t.controls??[]).entries()){if(p.type==="carousel"&&p.inactiveMaxWidth!==void 0&&p.inactiveTargets===void 0&&n.addIssue({code:"custom",path:["controls",m,"inactiveMaxWidth"],message:"Inactive width requires inactive article targets"}),p.type==="carousel")for(let d of p.inactiveTargets??[])(d===p.target||k.has(d))&&n.addIssue({code:"custom",path:["controls",m,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),k.add(d);if(p.type==="carousel")for(let d of["previousTarget","nextTarget"]){let v=p[d];v!==void 0&&((v===p.target||b.has(v)||(t.controls??[]).some(ze=>ze.target===v))&&n.addIssue({code:"custom",path:["controls",m,d],message:"Carousel navigation needs a distinct, exclusive button target"}),b.add(v))}if(p.type!=="action"){let d=Object.hasOwn(i,p.state)?i[p.state]:void 0;(!d||p.type==="input"&&d.type==="enum"&&d.values.some(v=>typeof v!="string"))&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Control needs a supported declared UI state"}),p.type==="carousel"&&(d?.type!=="number"||!Number.isInteger(d.min)||d.min<0||!Number.isInteger(d.max)||d.step!==1||p.initialIndex!==void 0&&!D(d,p.initialIndex))&&n.addIssue({code:"custom",path:["controls",m],message:"Carousel needs bounded nonnegative integer index state"}),p.type==="scroll_latch"&&d?.type!=="boolean"&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Scroll latches require boolean UI state"})}(p.type==="input"||p.type==="action")&&p.set&&c(p.set,["controls",m,"set"])}for(let[m,p]of(t.timers??[]).entries())c(p.set,["timers",m,"set"])});var he=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,A=e.string().max(16).regex(he,"语言代码格式不正确,例如 zh-CN、en").refine(t=>{try{return Intl.getCanonicalLocales(t)[0]===t}catch{return!1}},"持久化语言代码必须使用规范写法");function F(t){if(typeof t!="string")return null;try{let n=Intl.getCanonicalLocales(t.trim().replaceAll("_","-"))[0];if(!n)return null;let{language:i,script:r,region:o}=new Intl.Locale(n),a=[i,r,o].filter(Boolean).join("-");return he.test(a)?a:null}catch{return null}}var Ze=new Set(["TW","HK","MO"]);function ye(t){let[n,i,r]=t.split("-");if(n!=="zh")return`${n}-${new Intl.Locale(t).maximize().script??""}`;let o=i?.length===4?i:void 0,a=i?.length===4?r:i;return o?`zh-${o}`:a&&Ze.has(a)?"zh-Hant":"zh-Hans"}function xe(t,n,i){let r=n.map(o=>({code:A.parse(o),normalized:o}));for(let o of t){let a=F(o);if(!a)continue;let s=r.find(c=>c.normalized===a);if(s)return s.code;let l=ye(a),u=r.filter(c=>ye(c.normalized)===l),y=u.find(c=>!c.normalized.includes("-")||c.normalized===l)??u[0];if(y)return y.code}return i}var Be=4,z={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},U=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),g=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Qe=e.enum(["none","xs","sm","md","lg","xl"]),Fe=e.enum(["none","sm","md","lg","full"]),H=e.string().regex(/^#[0-9a-fA-F]{6}$/),G=e.string().max(2048).refine(t=>{try{let n=new URL(t);return n.protocol==="https:"&&n.hostname.length>0}catch{return!1}},"只支持 https 链接"),q=e.union([G,e.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),Se=e.object({primary:H,background:H,text:H,radius:Fe,font:e.enum(["system","serif","rounded","mono"]),fontAssets:e.object({family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/),faces:e.array(e.object({url:G,weight:e.number().int().min(100).max(900).multipleOf(100),family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/).optional()}).strict()).min(1).max(4)}).strict().optional()}).strict(),L=e.union([e.enum(["primary","text","muted","background","surface"]),e.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),f=(t,n)=>e.number().int().min(t).max(n),ke=e.union([e.enum(["fit","fill"]),f(1,1200)]),He=e.object({top:f(0,200),right:f(0,200),bottom:f(0,200),left:f(0,200)}).strict(),qe=e.object({top:f(-100,200),right:f(-100,200),bottom:f(-100,200),left:f(-100,200)}).strict(),Ie=e.object({x:f(0,100),y:f(0,100)}).strict(),Ge=e.discriminatedUnion("type",[e.object({type:e.literal("color"),color:L}).strict(),e.object({type:e.literal("linear"),angle:f(0,360),stops:e.array(e.object({color:L,at:f(0,100)}).strict()).min(2).max(4)}).strict(),e.object({type:e.literal("image"),src:q,fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict()]),We=e.discriminatedUnion("type",[e.object({type:e.literal("rect"),radius:e.union([f(0,200),e.object({topLeft:f(0,200),topRight:f(0,200),bottomRight:f(0,200),bottomLeft:f(0,200)}).strict()])}).strict(),e.object({type:e.literal("pill")}).strict()]),Ke=e.object({width:f(0,12),color:L,style:e.enum(["solid","dashed"])}).strict(),Je=e.object({x:f(-40,40),y:f(-40,40),blur:f(0,80),spread:f(-20,40),color:L}).strict(),Xe=e.object({font:e.enum(["system","serif","rounded","mono"]),size:f(8,96),weight:e.number().int().min(100).max(900).multipleOf(100),lineHeight:e.number().min(.8).max(3),letterSpacing:e.number().min(-5).max(20),color:L,align:e.enum(["start","center","end"]),italic:e.boolean(),decoration:e.enum(["none","underline","line-through"]),transform:e.enum(["none","uppercase"])}).strict().partial(),P=e.object({width:ke,height:ke,padding:He,margin:qe,gap:f(0,120),grow:e.union([e.boolean(),e.number().min(0).max(12)]),background:Ge,opacity:e.number().min(0).max(1),clipContent:e.boolean(),shape:We,border:Ke,shadow:Je,text:Xe}).strict().partial(),I={id:U,name:e.string().trim().min(1).max(60).optional(),hidden:e.boolean().optional(),style:P.optional(),fallback:g.optional()},Ye=e.object({...I,type:e.literal("text"),productField:e.enum(["name","price","trial","period"]).optional(),feature:e.object({id:e.uuid(),field:e.enum(["name","allowance"])}).strict().optional(),text:g,variant:e.enum(["title","heading","body","caption"])}).strict(),et=e.object({...I,type:e.literal("image"),src:q,localizedSrc:e.record(A,q).optional(),alt:g,aspect:e.enum(["auto","1:1","4:3","16:9","3:1"]),fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict(),tt=e.object({...I,type:e.literal("button"),label:g,variant:e.enum(["primary","secondary","link"]),action:g,purpose:e.enum(["purchase","navigation","close"]).optional(),bind:T.optional()}).strict(),nt=e.object({...I,type:e.literal("divider")}).strict(),rt=e.object({...I,type:e.literal("customer_data"),title:g,data:ae}).strict(),it=e.object({...I,type:e.literal("spacer"),size:Qe}).strict(),ot=e.object({...I,type:e.literal("custom_html"),html:e.record(A,e.string().max(z.customHtml)),css:e.string().max(z.customCss),ui:be.optional()}).strict(),at=e.object({...I,type:e.literal("price"),fallback:g,parts:e.object({current:P.optional(),original:P.optional(),period:P.optional()}).strict().optional()}).strict(),st=e.object({...I,type:e.literal("coupon_code"),label:g,fallback:g}).strict(),ct=e.object({...I,type:e.literal("countdown"),source:e.enum(["offer.ends_at","offer.expires_at","fixed"]),at:e.iso.datetime().optional(),granularity:e.enum(["day","hour","minute","second"]),expired:g,fallback:g}).strict().refine(t=>t.source!=="fixed"||!!t.at,"固定倒计时需要结束时间"),lt=e.object({...I,type:e.literal("plan_picker"),label:g,fallback:g,planIds:e.array(e.string().min(1).max(200)).min(1).max(20).refine(t=>new Set(t).size===t.length,"套餐不能重复").optional(),defaultPlan:e.string().min(1).max(200).optional(),grouping:me.safeExtend({monthLabel:g,yearLabel:g,unavailableLabel:g}).optional(),states:e.object({selected:P.optional()}).strict().optional()}).strict().superRefine((t,n)=>{t.grouping&&(!t.planIds||!fe(t.grouping,t.planIds))&&n.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),pt=e.object({...I,type:e.literal("quantity_picker"),bind:T.optional(),label:g,fallback:g,internalFeatureId:e.uuid(),minimumQuantity:f(0,1e4),maximumQuantity:f(0,1e4),defaultQuantity:f(0,1e4),step:f(1,1e4)}).strict().refine(t=>t.minimumQuantity<=t.defaultQuantity&&t.defaultQuantity<=t.maximumQuantity&&(t.defaultQuantity-t.minimumQuantity)%t.step===0,"Quantity controls require a Product binding and valid bounds"),ut=e.discriminatedUnion("type",[e.object({type:e.literal("input"),label:g,keyboard:e.enum(["text","email","tel","url"]),maxLength:f(1,500)}).strict(),e.object({type:e.literal("multiselect"),label:g,min:f(0,50),max:f(1,50)}).strict(),e.object({type:e.literal("select"),label:g,defaultIndex:f(0,49),purpose:e.enum(["option","product","tier"]).optional(),pickerId:U.optional(),selectedStyle:P.optional()}).strict(),e.object({type:e.literal("tabs"),label:g,defaultIndex:f(0,49),purpose:e.literal("tier").optional()}).strict(),e.object({type:e.literal("toggle"),label:g,defaultEnabled:e.boolean()}).strict(),e.object({type:e.literal("carousel"),label:g}).strict()]),w={...I,type:e.literal("stack"),direction:e.enum(["vertical","horizontal","overlay"]),align:e.enum(["start","center","end","stretch"]),justify:e.enum(["start","center","end","between"]),productSlot:e.object({index:f(0,19),period:e.enum(["month","year"]).optional(),requireBinding:e.boolean().optional()}).strict().optional(),interaction:ut.optional(),states:e.object({selected:P.optional()}).strict().optional(),purpose:e.literal("benefits").optional(),purchaseAction:g.optional(),buttonVariant:e.enum(["primary","secondary","link"]).optional(),bind:T.optional()},je=e.lazy(()=>e.object({...I,type:w.type,direction:w.direction,align:w.align,justify:w.justify,children:e.array(mt).max(z.children),productSlot:w.productSlot,interaction:w.interaction,states:w.states,purpose:w.purpose,purchaseAction:w.purchaseAction,buttonVariant:w.buttonVariant,bind:w.bind}).strict()),mt=e.lazy(()=>e.union([je,Ye,et,tt,nt,it,ot,at,st,ct,lt,pt,rt])),ft=e.union([e.string().max(500),e.number().finite(),e.boolean(),e.null()]),$={id:g,event:g,properties:e.record(g,ft).refine(t=>Object.keys(t).length<=20,"最多 20 个参数")},dt=e.discriminatedUnion("type",[e.object({...$,type:e.literal("navigate"),close:e.literal(!1),pageId:U}).strict(),e.object({...$,type:e.literal("event"),close:e.boolean()}).strict(),e.object({...$,type:e.literal("close"),close:e.literal(!0)}).strict(),e.object({...$,type:e.literal("open_url"),close:e.boolean(),url:G}).strict(),e.object({...$,type:e.literal("claim_offer"),close:e.boolean(),couponId:e.uuid()}).strict()]),gt=e.object({defaultLocale:A,locales:e.record(A,e.record(g,e.string().max(z.stringLength)))}).strict(),bt=e.enum(["popup","paywall","onboarding","page","banner"]);var yt=e.object({kind:e.literal("screen"),schemaVersion:e.literal(Be),name:e.string().trim().min(1).max(80),surface:bt,initialPageId:U.optional(),presentation:X,theme:Se,pages:e.array(e.object({id:U,name:e.string().trim().min(1).max(60),root:je,theme:Se.optional(),editorPosition:e.object({x:e.number().finite().min(-1e5).max(1e5),y:e.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(z.pages),strings:gt,actions:e.array(dt).max(z.actions)}).strict();function R(t,n){for(let i of t.pages)W(i.root,n)}var dn=yt.superRefine((t,n)=>{let i=z;t.surface!=="paywall"&&t.pages.length!==1&&n.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),t.initialPageId&&!t.pages.some(c=>c.id===t.initialPageId)&&n.addIssue({code:"custom",message:"Initial screen does not exist"});for(let c of t.actions)c.type==="navigate"&&(t.surface!=="paywall"||!t.pages.some(b=>b.id===c.pageId))&&n.addIssue({code:"custom",message:"Navigation screen does not exist"});t.pages.length>i.pages&&n.addIssue({code:"custom",message:`页面最多 ${i.pages} 个`}),t.actions.length>i.actions&&n.addIssue({code:"custom",message:`动作最多 ${i.actions} 个`});let r=c=>n.addIssue({code:"custom",message:c}),o=Object.keys(t.strings.locales);o.includes(t.strings.defaultLocale)||r("默认语言必须在语言列表里"),o.length>z.locales&&r(`最多 ${z.locales} 种语言`);let a=new Set;for(let c of t.actions)a.has(c.id)&&r(`动作标识重复:${c.id}`),a.add(c.id);let s=new Set;for(let c of t.pages)["next","back"].includes(c.id)&&r(`页面 id 不能使用保留名称:${c.id}`),s.has(c.id)&&r(`页面 id 重复:${c.id}`),s.add(c.id);let l=new Set,u=0,y=!1;R(t,(c,b)=>{if(u++,b>z.depth&&(y=!0),l.has(c.id)&&r(`组件 id 重复:${c.id}`),l.add(c.id),c.type==="button"&&!a.has(c.action)&&r(`按钮 ${c.id} 引用的动作不存在:${c.action}`),c.type==="custom_html")for(let k of Object.keys(c.html))o.includes(k)||r(`自定义 HTML ${c.id} 含有未启用的语言:${k}`);if(c.type==="image")for(let k of Object.keys(c.localizedSrc??{}))o.includes(k)||r(`图片 ${c.id} 含有未启用的语言:${k}`)}),u>i.nodes&&r(`组件最多 ${i.nodes} 个`),y&&r(`层级最多 ${z.depth} 层`)});function W(t,n,i=1,r=null){if(n(t,i,r)!==!1&&t.type==="stack")for(let o of t.children)W(o,n,i+1,t)}function we(t){let n=[],i=new Set;return R(t,r=>{let o=(a,s,l)=>{i.has(a)||(i.add(a),n.push({key:a,nodeId:r.id,nodeType:r.type,field:s,required:l}))};r.type==="stack"&&r.interaction&&o(r.interaction.label,"label",!0),r.fallback&&o(r.fallback,"text",!0),r.type==="text"&&o(r.text,"text",!0),r.type==="customer_data"&&o(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&o(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(o(r.grouping.monthLabel,"label",!0),o(r.grouping.yearLabel,"label",!0),o(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&o(r.expired,"text",!0),r.type==="button"&&o(r.label,"label",!0),r.type==="image"&&(o(`image:${r.id}`,"src",!1),o(r.alt,"alt",!1)),r.type==="custom_html"&&o(`html:${r.id}`,"html",!0)}),n}function ht(t,n,i){if(n.field==="html"){let r;return R(t,o=>{o.id===n.nodeId&&o.type==="custom_html"&&(r=o.html[i])}),r}if(n.field==="src"){let r=It(t,n.nodeId);return r?.type==="image"?r.localizedSrc?.[i]??(i===t.strings.defaultLocale?r.src:void 0):void 0}return t.strings.locales[i]?.[n.key]}function xt(t){let n=we(t).filter(r=>r.required);return Object.keys(t.strings.locales).sort((r,o)=>r===t.strings.defaultLocale?-1:o===t.strings.defaultLocale?1:0).map(r=>{let o=n.filter(a=>!ht(t,a,r)?.trim()).map(a=>a.key);return{locale:r,total:n.length,filled:n.length-o.length,missing:o,complete:o.length===0}})}function St(t){return xt(t).filter(n=>n.complete||n.locale===t.strings.defaultLocale).map(n=>n.locale)}function gn(t,n){return xe(n,St(t),t.strings.defaultLocale)}function bn(t,n){let i=t.strings.locales[n]??{},r=t.strings.locales[t.strings.defaultLocale]??{},o={};for(let s of we(t)){if(s.field==="html"||s.field==="src")continue;let l=i[s.key]?.trim()?i[s.key]:r[s.key];l!==void 0&&(o[s.key]=l)}let a=s=>{if(s.type==="stack")return{...s,children:s.children.map(a)};if(s.type==="custom_html"){let l=s.html[n]?.trim()?s.html[n]:s.html[t.strings.defaultLocale];return{...s,html:l===void 0?{}:{[n]:l}}}if(s.type==="image"){let{localizedSrc:l,...u}=s;return{...u,src:l?.[n]??l?.[t.strings.defaultLocale]??s.src}}return s};return{...t,pages:t.pages.map(s=>({...s,root:a(s.root)})),strings:{defaultLocale:n,locales:{[n]:o}}}}function kt(t,n){let i=null;return W(t,r=>{if(i)return!1;r.id===n&&(i=r)}),i}function It(t,n){for(let i of t.pages){let r=kt(i.root,n);if(r)return r}return null}function yn(t){let n=F(t)?.split("-")[0];return n!==void 0&&["ar","he","fa","ur"].includes(n)}function hn(t,n,i){let r={};if(!n||typeof n!="object"||Array.isArray(n))return r;let o=n;if(R(t,a=>{if(a.type==="quantity_picker"){let l=o[a.id];typeof l=="number"&&Number.isSafeInteger(l)&&l>=a.minimumQuantity&&l<=a.maximumQuantity&&(l-a.minimumQuantity)%a.step===0&&(r[a.id]=l);return}if(a.type==="plan_picker"){let l=o[a.id];typeof l=="string"&&(r[a.id]=i?.pickers[a.id]?.options.includes(l)?l:"");return}if(a.type==="custom_html"&&a.ui)for(let[l,u]of Object.entries(a.ui.state??{})){let y=`${a.id}.${l}`,c=o[y];c!==null&&D(u,c)&&(r[y]=c)}if(a.type!=="stack"||!a.interaction)return;let s=Object.hasOwn(o,a.id)?o[a.id]:void 0;["select","tabs"].includes(a.interaction.type)&&typeof s=="string"&&a.children.some(l=>l.id===s)&&(r[a.id]=s),a.interaction.type==="toggle"&&typeof s=="boolean"&&(r[a.id]=s)}),t.surface==="paywall"&&typeof o.__page=="string"&&t.pages.some(a=>a.id===o.__page)&&(r.__page=o.__page),i){let a={...r};for(let[s,l]of Object.entries(o))(typeof l=="string"||typeof l=="boolean")&&(a[s]=l);Object.assign(r,pe(t,a,i))}return r}export{V as a,wt as b,te as c,Ot as d,ne as e,re as f,Et as g,ie as h,Vt as i,le as j,me as k,fe as l,Qt as m,Ft as n,Jt as o,A as p,F as q,z as r,U as s,g as t,q as u,R as v,dn as w,W as x,we as y,xt as z,gn as A,bn as B,It as C,yn as D,hn as E};
1
+ import{a as C,j as J}from"./chunk-CWBL2S3A.js";import{b as X}from"./chunk-FINCNJBH.js";import{j as K,l as E}from"./chunk-5SNUVXZ7.js";import{b as e}from"./chunk-7RUOZL6C.js";var Y=e.number().int().min(0).max(1e8),V=e.strictObject({kind:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().min(1).max(1e4).nullable(),unitAmountMinor:Y,flatAmountMinor:Y.optional()})).min(1).max(12)}).refine(t=>t.tiers.at(-1)?.upTo===null&&t.tiers.slice(0,-1).every((n,i)=>{let r=t.tiers[i-1]?.upTo;return n.upTo!==null&&(i===0||r!=null&&n.upTo>r)}),"Tier ceilings must increase and end unbounded").refine(t=>!t.tiers.some(n=>(n.flatAmountMinor??0)>0)||t.kind==="volume"&&t.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers");function M(t,n){if(!Number.isInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased pack quantity");let i=t.pricing?V.parse(t.pricing):void 0;if(n===0)return 0;let r=0n,o=0;if(!i)r=BigInt(t.amountMinor)*BigInt(n);else for(let a of i.tiers){let s=a.upTo??1e4;if(i.kind==="volume"){if(n<=s){r=BigInt(n)*BigInt(a.unitAmountMinor)+BigInt(a.flatAmountMinor??0);break}}else n>o&&(r+=BigInt(Math.min(n,s)-o)*BigInt(a.unitAmountMinor));o=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function wt(t){return M({amountMinor:t.unitAmountMinor,...t.pricing?{pricing:t.pricing}:{}},t.quantity)}var ve=K.refine(t=>/[1-9]/.test(t)),te=e.strictObject({units:ve,prices:e.array(e.strictObject({currency:C,amountMinor:e.number().int().min(0).max(1e8),pricing:V.optional()})).min(1).max(20).refine(t=>new Set(t.map(n=>n.currency)).size===t.length,"Currencies must be unique").refine(t=>t.every(n=>!n.pricing||n.amountMinor===0),"Tiered prices specify their rates in tiers"),minimumQuantity:e.number().int().min(0).max(1e4),maximumQuantity:e.number().int().min(0).max(1e4)}).refine(t=>t.maximumQuantity>=t.minimumQuantity,"Purchased quantity must fit its published bounds").refine(t=>{try{for(let n of t.prices)for(let i of[t.maximumQuantity,...n.pricing?.tiers.flatMap(r=>r.upTo===null?[]:[r.upTo,r.upTo+1])??[]])i<=t.maximumQuantity&&M({amountMinor:n.amountMinor,...n.pricing===void 0?{}:{pricing:n.pricing}},i);return!0}catch{return!1}},"Every purchasable quantity must fit the payment amount limit");function ee(t){if(!/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/.test(t))throw new Error("Invalid quantity");let[n,i=""]=t.split(".");if(n===void 0||n==="")throw new Error("Invalid decimal value");return BigInt(n)*1000000n+BigInt(i.padEnd(6,"0"))}function Ot(t,n,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=ee(t)+ee(n)*BigInt(i);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let o=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(o?"."+o:"")}var ne=e.strictObject({internalFeatureId:e.uuid(),name:e.string().min(1).max(120),includedAmount:e.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),reset:e.enum(["hour","day","week","month","year","lifetime"]),resetCount:e.number().int().min(1).max(100),terms:te});var _e=["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","paywall.feature","paywall.message","paywall.action"],T=e.object({plan:e.string().min(1).max(200).optional(),coupon:e.uuid().optional(),promotionCode:e.uuid().optional(),picker:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),re=e.object({text:e.string().optional(),label:e.string().optional(),alt:e.string().optional(),html:e.string().max(32768).optional(),price:e.object({current:e.string(),original:e.string().nullable(),period:e.string()}).optional(),code:e.string().optional(),countdownAt:e.iso.datetime().optional(),planId:e.string().min(1).max(200).optional(),planVersionId:e.string().min(1).max(200).optional(),currency:C.optional(),couponId:e.uuid().optional(),offerId:e.uuid().optional(),unavailable:e.boolean().optional(),unavailableReason:e.string().optional(),missing:e.array(e.string()).optional()}).strict(),Et=e.object({paywall:J.optional(),nodes:e.record(e.string(),e.object({base:re,picker:e.string().optional(),byPlan:e.record(e.string(),re).optional()}).strict()),plans:e.record(e.string(),e.object({id:e.string().min(1).max(200),versionId:e.string().min(1).max(200),available:e.boolean(),name:e.string(),price:e.string(),period:e.string(),currency:C.optional(),amountMinor:e.number().int().nonnegative().optional(),interval:e.enum(["free","week","month","year","one_time"]).optional(),intervalCount:e.number().int().positive().optional(),prepaid:e.array(ne).max(100).optional()}).strict()),pickers:e.record(e.string(),e.object({options:e.array(e.string().min(1).max(200)).max(20),selected:e.string().min(1).max(200).nullable()}).strict()),quantities:e.record(e.string(),e.strictObject({minimum:e.number().int().nonnegative(),maximum:e.number().int().nonnegative(),step:e.number().int().positive(),value:e.number().int().nonnegative(),label:e.string(),available:e.boolean()})).optional(),diagnostics:e.array(e.object({nodeId:e.string(),message:e.string()}).strict())}).strict();function ie(t){return[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(n=>n[1]===void 0?[]:[n[1].trim()])}function Z(t){let n=ie(t).filter(r=>!_e.includes(r)&&!/^variables\.[A-Za-z0-9_][A-Za-z0-9_.:-]*$/.test(r)),i=t.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(i.includes("{{")||i.includes("}}"))&&n.push("无效变量语法"),[...new Set(n)]}function Vt(t,n,i={}){let r=t?.nodes[n];if(!r)return;let o=r.picker?i[r.picker]??t?.pickers[r.picker]?.selected:void 0;return typeof o=="string"?r.byPlan?.[o]??r.base:r.base}var Ne=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],oe=e.enum(Ne),ae=e.object({source:oe,layout:e.enum(["full","compact"]),resourceKey:E.optional(),pageSize:e.number().int().min(1).max(50),showSources:e.boolean(),allowPurchase:e.boolean(),outputs:e.object({billing_adjustment:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_authorization:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),buy_pack:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_portal:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),cancel_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),resume_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional()}).strict().optional()}).strict().superRefine((t,n)=>{(t.outputs?.billing_authorization||t.outputs?.billing_adjustment)&&t.source!=="billing_controls"&&n.addIssue({code:"custom",message:"Payment authorization routes belong to the billing controls component."}),t.resourceKey&&!["credit_balance","credit_transactions"].includes(t.source)&&n.addIssue({code:"custom",message:"这个数据源不能绑定积分资源。"}),t.showSources&&t.source!=="credit_balance"&&n.addIssue({code:"custom",message:"只有积分余额可以展开来源。"}),t.allowPurchase&&!["credit_packs","customer_plans","membership"].includes(t.source)&&n.addIssue({code:"custom",message:"只有积分包、套餐与会员组件可以启用交易。"})}),x=e.string().max(2e3),se=e.object({id:e.string().max(100),label:x,detail:e.array(x).max(12),value:x.optional(),status:x.optional(),facts:e.array(e.object({label:x,value:x}).strict()).max(1e3),purchaseId:e.uuid().optional(),invoiceUrl:e.url().max(2048).refine(t=>{let n=new URL(t);return n.protocol==="https:"&&!n.username&&!n.password}).optional(),billingActions:e.array(e.strictObject({action:e.literal("invoice_open"),label:x})).max(1).optional(),membershipActions:e.array(e.object({value:e.string().max(100),label:x}).strict()).max(3).optional()}).strict(),Pe=e.object({key:E,name:x,spendable:x,reserved:x,available:x,expiry:x.nullable(),sources:e.array(se).max(50),sourceCount:e.number().int().nonnegative(),sourcePage:e.number().int().positive(),hasNextSources:e.boolean(),hasPreviousSources:e.boolean()}).strict(),Oe=e.object({source:oe,status:e.enum(["idle","loading","ready","error"]),stale:e.boolean(),preview:e.boolean(),errorCode:e.string().max(80).optional(),errorMessage:x.optional(),resources:e.array(Pe).max(500),rows:e.array(se).max(50),hasNext:e.boolean(),hasPrevious:e.boolean(),page:e.number().int().positive(),filter:e.string().max(40),updatedAt:e.iso.datetime().optional(),buyingId:e.uuid().optional(),membershipBusy:e.boolean().optional(),billingBusy:e.boolean().optional(),membershipReview:e.object({title:x,note:x,facts:e.array(e.object({label:x,value:x}).strict()).max(100)}).strict().optional(),membershipResult:x.optional()}).strict(),Qt=e.object({nodes:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Oe)}).strict(),Ft=e.object({nodeId:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:e.enum(["refresh","next","previous","filter","buy_pack","billing_portal","billing_authorization","billing_adjustment","invoice_open","membership_preview","membership_confirm","membership_dismiss","sources_next","sources_previous"]),value:e.string().max(100).optional()}).strict();function ce(t){return t.type==="stack"&&t.interaction?.type==="select"&&t.interaction.purpose==="product"&&!!t.interaction.pickerId}function le(t){let n={};function i(r){if(ce(r)){let o=n[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let l=s.type==="stack"?s.bind?.plan:void 0;l&&!o.ids.includes(l)&&o.ids.push(l)}let a=r.children[r.interaction.defaultIndex];!o.defaultId&&a?.type==="stack"&&(o.defaultId=a.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return t.pages.forEach(r=>i(r.root)),n}function pe(t,n,i){let r={};function o(u){if(u.hidden)return;if(u.type==="plan_picker"){let b=i.pickers[u.id];r[u.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(u.type!=="stack")return;let y=u.children.filter(b=>!b.hidden),c=u.interaction;if(ce(u)){let b=r[u.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},k=i.pickers[u.interaction.pickerId]?.options??[];for(let p of y){let d=p.type==="stack"?p.bind?.plan:void 0;d&&k.includes(d)&&!b.ids.includes(d)&&b.ids.push(d),d&&p.id===n[u.id]&&b.remembered.push(d)}let m=u.children[u.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&b.defaults.push(m.bind.plan)}if(c?.type==="tabs"){let b=y.find(k=>k.id===n[u.id])??u.children[c.defaultIndex];b&&o(b)}else if(c?.type==="toggle"){let b=typeof n[u.id]=="boolean"?n[u.id]:c.defaultEnabled,k=u.children[b?0:1];k&&o(k)}else y.forEach(o)}let a=typeof n.__page=="string"?n.__page:t.initialPageId??t.pages[0]?.id,s=t.pages.find(u=>u.id===a);s&&o(s.root);let l={};for(let[u,y]of Object.entries(r)){let c=n[u],b=y.remembered[0]??(y.ids.includes(i.pickers[u]?.selected??"")?i.pickers[u]?.selected:y.defaults[0]);l[u]=typeof c=="string"?y.ids.includes(c)?c:"":b&&y.ids.includes(b)?b:""}for(let u of Object.keys(le(t)))l[u]??="";return l}var ue=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),me=e.strictObject({tiers:e.array(e.strictObject({id:ue,name:e.string().trim().min(1).max(80)})).min(1).max(8),assignments:e.array(e.strictObject({productVersionId:e.string().min(1).max(200),tierId:ue,period:e.enum(["month","year"])})).max(20)}).superRefine((t,n)=>{let i=t.tiers.map(r=>r.id);(new Set(i).size!==i.length||new Set(t.assignments.map(r=>r.productVersionId)).size!==t.assignments.length||new Set(t.assignments.map(r=>`${r.tierId}:${r.period}`)).size!==t.assignments.length||t.assignments.some(r=>!i.includes(r.tierId)))&&n.addIssue({code:"custom",message:"Each product and tier/period cell must have one unambiguous assignment"})});function fe(t,n){return t.assignments.length===n.length&&t.assignments.every(i=>n.includes(i.productVersionId))}function Jt(t){let n=Z(t).map(i=>`未知变量:${i}`);for(let i=0;i<t.length;i++){if(t[i]!=="<"||!/[A-Za-z!/?{]/.test(t[i+1]??""))continue;let r=i;if(t.startsWith("<!--",i)){let o=t.indexOf("-->",i+4);i=o<0?t.length:o+2}else{let o="";for(i++;i<t.length;i++){let a=t[i];if(o)a===o&&(o="");else if(a==='"'||a==="'")o=a;else if(a===">")break}}/\{\{|\}\}/.test(t.slice(r,i+1))&&n.push("变量只能放在 HTML 文字中,不能放入标签、属性或注释")}return[...new Set(n)]}var h={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},ge=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),S=e.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(t=>!ge.has(t),"Reserved UI identifier"),B=e.union([e.string().max(2e3),e.number().finite(),e.boolean(),e.null()]),Ae=e.discriminatedUnion("type",[e.strictObject({type:e.literal("enum"),values:e.array(B).min(1).max(h.enumValues),default:B}),e.strictObject({type:e.literal("number"),min:e.number().finite(),max:e.number().finite(),step:e.number().finite().positive(),default:e.number().finite()}),e.strictObject({type:e.literal("text"),maxLength:e.number().int().min(0).max(2e3),default:e.string().max(2e3).nullable()}),e.strictObject({type:e.literal("boolean"),default:e.boolean()})]);function D(t,n){if(t.type==="enum")return t.values.some(r=>r===n);if(t.type==="boolean")return typeof n=="boolean";if(t.type==="text")return n===null||typeof n=="string"&&n.length<=t.maxLength;if(typeof n!="number"||!Number.isFinite(n)||n<t.min||n>t.max)return!1;let i=(n-t.min)/t.step;return Number.isFinite(i)&&Math.abs(i-Math.round(i))<=Math.min(1e-7,Math.max(1,Math.abs(i))*Number.EPSILON*8)}var Ce=Ae.superRefine((t,n)=>{t.type==="enum"&&new Set(t.values).size!==t.values.length&&n.addIssue({code:"custom",path:["values"],message:"UI enum values must be unique"}),t.type==="number"&&t.min>t.max&&n.addIssue({code:"custom",path:["max"],message:"UI number range is reversed"}),D(t,t.default)||n.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),$e=["add","sub","mul","div","min","max","round","floor","eq","ne","gt","gte","lt","lte","and","or","not","if","concat","number","parse_number","money","lookup","now","duration"];function Ue(t,n){return t==="now"?n===0:t==="concat"?!0:t==="lookup"?n>=4&&n%2===0:t==="if"?n===3:["sub","div","eq","ne","gt","gte","lt","lte"].includes(t)?n===2:["round","floor","not","number","parse_number","money","duration"].includes(t)?n===1:n>=1}var N=e.lazy(()=>e.union([B,e.strictObject({ref:S}),e.strictObject({op:e.enum($e),args:e.array(N).max(h.expressionNodes)}).superRefine((t,n)=>{Ue(t.op,t.args.length)||n.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function j(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function _(t,n,i){if(!t||typeof t!="object")return!0;if(!j(t))return n.addIssue({code:"custom",path:i,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(t)){if(ge.has(r))return n.addIssue({code:"custom",path:[...i,r],message:"Reserved UI object key"}),!1;let o=Object.getOwnPropertyDescriptor(t,r);if(o&&!Object.hasOwn(o,"value"))return n.addIssue({code:"custom",path:[...i,r],message:"UI objects cannot contain accessors"}),!1}return!0}function O(t,n,i,r){let o=[{value:t,depth:1,path:i}];for(;o.length;){let a=o.pop();if(++r.nodes>h.expressionNodes||a.depth>h.depth){n.addIssue({code:"custom",path:a.path,message:"UI expression budget exceeded"});return}if(!_(a.value,n,a.path))return;if(j(a.value)&&Array.isArray(a.value.args)){if(a.value.args.length>h.expressionNodes){n.addIssue({code:"custom",path:[...a.path,"args"],message:"UI expression budget exceeded"});return}for(let s=a.value.args.length-1;s>=0;s--)o.push({value:a.value.args[s],depth:a.depth+1,path:[...a.path,"args",s]})}}}var en=e.unknown().superRefine((t,n)=>{O(t,n,[],{nodes:0})}).pipe(N),Q=e.record(S,N).refine(t=>Object.keys(t).length>0&&Object.keys(t).length<=h.state,"UI assignments need 1–32 state keys"),Le=e.strictObject({target:S,property:e.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:N,className:S.optional()}).superRefine((t,n)=>{t.property==="class"!=(t.className!==void 0)&&n.addIssue({code:"custom",path:["className"],message:"Only class bindings require a safe className"})}),Te=e.discriminatedUnion("type",[e.strictObject({type:e.literal("scroll_latch"),target:S,state:S}),e.strictObject({type:e.literal("input"),target:S,state:S,set:Q.optional()}),e.strictObject({type:e.literal("action"),target:S,set:Q}),e.strictObject({type:e.literal("carousel"),target:S,state:S,initialIndex:e.number().int().nonnegative().optional(),maxWidth:e.number().int().min(1).max(1e4).optional(),previousTarget:S.optional(),nextTarget:S.optional(),inactiveTargets:e.array(S).max(20).optional(),inactiveMaxWidth:e.number().int().min(1).max(1e4).optional()})]),De=e.strictObject({afterMs:e.number().int().min(0).max(6e4),set:Q}),Re=e.strictObject({type:e.literal("mosaic_waves"),target:S,color:e.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:e.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:N.optional(),speed:e.number().min(0).max(4).optional(),pitch:e.number().min(.05).max(4).optional(),fill:e.number().min(.05).max(1).optional(),feather:e.number().min(0).max(1).optional(),warp:e.number().min(0).max(4).optional(),warpScale:e.number().min(0).max(32).optional(),detailScale:e.number().min(0).max(32).optional(),waveScale:e.number().min(0).max(32).optional(),falloff:e.number().min(.1).max(32).optional(),brightness:e.number().min(0).max(32).optional(),ambient:e.number().min(0).max(1).optional(),gamma:e.number().min(.05).max(8).optional(),vignette:e.number().min(0).max(1).optional(),opacity:e.number().min(0).max(1).optional()}),Ee=e.strictObject({type:e.literal("number_counter"),target:S,value:N,prefix:e.string().max(20).optional(),format:e.enum(["number","short"]).optional()}),Ve=e.strictObject({state:e.record(S,Ce).refine(t=>Object.keys(t).length<=h.state,"Too many UI state keys").optional(),derived:e.record(S,N).refine(t=>Object.keys(t).length<=h.derived,"Too many UI derived keys").optional(),bindings:e.array(Le).max(h.bindings).optional(),controls:e.array(Te).max(h.controls).optional(),timers:e.array(De).max(h.timers).optional(),effects:e.array(e.discriminatedUnion("type",[Re,Ee])).max(h.effects).optional(),clock:e.boolean().optional()});function Me(t,n){if(!_(t,n,[])||!j(t))return;for(let[r,o]of[["state",h.state],["derived",h.derived]]){let a=t[r];if(!_(a,n,[r]))return;if(j(a)&&Object.keys(a).length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,o]of[["bindings",h.bindings],["controls",h.controls],["timers",h.timers],["effects",h.effects]])if(Array.isArray(t[r])&&t[r].length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(t.effects)){for(let[r,o]of t.effects.entries())if(!_(o,n,["effects",r]))return}if(j(t.state))for(let[r,o]of Object.entries(t.state)){if(!_(o,n,["state",r]))return;if(j(o)&&Array.isArray(o.values)&&o.values.length>h.enumValues){n.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let i={nodes:0};if(j(t.derived))for(let[r,o]of Object.entries(t.derived))O(o,n,["derived",r],i);for(let r of["bindings","controls","timers"]){let o=t[r];if(Array.isArray(o)){for(let[a,s]of o.entries())if(!(!_(s,n,[r,a])||!j(s))){if(r==="bindings")O(s.expression,n,[r,a,"expression"],i);else if(_(s.set,n,[r,a,"set"])&&j(s.set)){if(Object.keys(s.set).length>h.state){n.addIssue({code:"custom",path:[r,a,"set"],message:"Too many UI assignments"});return}for(let[l,u]of Object.entries(s.set))O(u,n,[r,a,"set",l],i)}if(i.nodes>h.expressionNodes)return}}}if(Array.isArray(t.effects))for(let[r,o]of t.effects.entries())j(o)&&o.type==="number_counter"?O(o.value,n,["effects",r,"value"],i):j(o)&&o.enabled!==void 0&&O(o.enabled,n,["effects",r,"enabled"],i)}function de(t){let n=[],i=[t];for(;i.length;){let r=i.pop();!r||typeof r!="object"||("ref"in r?n.push(r.ref):i.push(...r.args))}return n}var be=e.unknown().superRefine(Me).pipe(Ve).superRefine((t,n)=>{let i=t.state??{},r=t.derived??{},o=new Set([...Object.keys(i),...Object.keys(r)]),a=(m,p)=>{for(let d of de(m))o.has(d)||n.addIssue({code:"custom",path:p,message:`Unknown UI reference: ${d}`})};for(let[m,p]of Object.entries(t.derived??{}))Object.hasOwn(i,m)&&n.addIssue({code:"custom",path:["derived",m],message:"UI state and derived identifiers must be distinct"}),a(p,["derived",m]);let s=new Set,l=new Set,u=m=>{if(s.has(m))return!1;if(l.has(m))return!0;s.add(m);for(let p of de(r[m]))if(Object.hasOwn(r,p)&&!u(p))return!1;return s.delete(m),l.add(m),!0};for(let m of Object.keys(r))if(!u(m)){n.addIssue({code:"custom",path:["derived",m],message:"Cyclic UI derived references"});break}for(let[m,p]of(t.bindings??[]).entries())a(p.expression,["bindings",m,"expression"]);let y=new Set;for(let[m,p]of(t.effects??[]).entries())y.has(p.target)&&n.addIssue({code:"custom",path:["effects",m,"target"],message:"Effect targets must be unique"}),y.add(p.target),p.type==="number_counter"?(a(p.value,["effects",m,"value"]),typeof p.value=="number"&&Math.abs(p.value)>1e12&&n.addIssue({code:"custom",path:["effects",m,"value"],message:"Counter values must be within the display bound"})):p.enabled!==void 0&&a(p.enabled,["effects",m,"enabled"]);let c=(m,p)=>{for(let[d,v]of Object.entries(m))Object.hasOwn(i,d)||n.addIssue({code:"custom",path:[...p,d],message:"UI assignments can only update declared state"}),a(v,[...p,d])},b=new Set,k=new Set;for(let[m,p]of(t.controls??[]).entries()){if(p.type==="carousel"&&p.inactiveMaxWidth!==void 0&&p.inactiveTargets===void 0&&n.addIssue({code:"custom",path:["controls",m,"inactiveMaxWidth"],message:"Inactive width requires inactive article targets"}),p.type==="carousel")for(let d of p.inactiveTargets??[])(d===p.target||k.has(d))&&n.addIssue({code:"custom",path:["controls",m,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),k.add(d);if(p.type==="carousel")for(let d of["previousTarget","nextTarget"]){let v=p[d];v!==void 0&&((v===p.target||b.has(v)||(t.controls??[]).some(ze=>ze.target===v))&&n.addIssue({code:"custom",path:["controls",m,d],message:"Carousel navigation needs a distinct, exclusive button target"}),b.add(v))}if(p.type!=="action"){let d=Object.hasOwn(i,p.state)?i[p.state]:void 0;(!d||p.type==="input"&&d.type==="enum"&&d.values.some(v=>typeof v!="string"))&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Control needs a supported declared UI state"}),p.type==="carousel"&&(d?.type!=="number"||!Number.isInteger(d.min)||d.min<0||!Number.isInteger(d.max)||d.step!==1||p.initialIndex!==void 0&&!D(d,p.initialIndex))&&n.addIssue({code:"custom",path:["controls",m],message:"Carousel needs bounded nonnegative integer index state"}),p.type==="scroll_latch"&&d?.type!=="boolean"&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Scroll latches require boolean UI state"})}(p.type==="input"||p.type==="action")&&p.set&&c(p.set,["controls",m,"set"])}for(let[m,p]of(t.timers??[]).entries())c(p.set,["timers",m,"set"])});var he=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,A=e.string().max(16).regex(he,"语言代码格式不正确,例如 zh-CN、en").refine(t=>{try{return Intl.getCanonicalLocales(t)[0]===t}catch{return!1}},"持久化语言代码必须使用规范写法");function F(t){if(typeof t!="string")return null;try{let n=Intl.getCanonicalLocales(t.trim().replaceAll("_","-"))[0];if(!n)return null;let{language:i,script:r,region:o}=new Intl.Locale(n),a=[i,r,o].filter(Boolean).join("-");return he.test(a)?a:null}catch{return null}}var Ze=new Set(["TW","HK","MO"]);function ye(t){let[n,i,r]=t.split("-");if(n!=="zh")return`${n}-${new Intl.Locale(t).maximize().script??""}`;let o=i?.length===4?i:void 0,a=i?.length===4?r:i;return o?`zh-${o}`:a&&Ze.has(a)?"zh-Hant":"zh-Hans"}function xe(t,n,i){let r=n.map(o=>({code:A.parse(o),normalized:o}));for(let o of t){let a=F(o);if(!a)continue;let s=r.find(c=>c.normalized===a);if(s)return s.code;let l=ye(a),u=r.filter(c=>ye(c.normalized)===l),y=u.find(c=>!c.normalized.includes("-")||c.normalized===l)??u[0];if(y)return y.code}return i}var Be=4,z={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},U=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),g=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Qe=e.enum(["none","xs","sm","md","lg","xl"]),Fe=e.enum(["none","sm","md","lg","full"]),H=e.string().regex(/^#[0-9a-fA-F]{6}$/),G=e.string().max(2048).refine(t=>{try{let n=new URL(t);return n.protocol==="https:"&&n.hostname.length>0}catch{return!1}},"只支持 https 链接"),q=e.union([G,e.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),Se=e.object({primary:H,background:H,text:H,radius:Fe,font:e.enum(["system","serif","rounded","mono"]),fontAssets:e.object({family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/),faces:e.array(e.object({url:G,weight:e.number().int().min(100).max(900).multipleOf(100),family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/).optional()}).strict()).min(1).max(4)}).strict().optional()}).strict(),L=e.union([e.enum(["primary","text","muted","background","surface"]),e.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),f=(t,n)=>e.number().int().min(t).max(n),ke=e.union([e.enum(["fit","fill"]),f(1,1200)]),He=e.object({top:f(0,200),right:f(0,200),bottom:f(0,200),left:f(0,200)}).strict(),qe=e.object({top:f(-100,200),right:f(-100,200),bottom:f(-100,200),left:f(-100,200)}).strict(),Ie=e.object({x:f(0,100),y:f(0,100)}).strict(),Ge=e.discriminatedUnion("type",[e.object({type:e.literal("color"),color:L}).strict(),e.object({type:e.literal("linear"),angle:f(0,360),stops:e.array(e.object({color:L,at:f(0,100)}).strict()).min(2).max(4)}).strict(),e.object({type:e.literal("image"),src:q,fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict()]),We=e.discriminatedUnion("type",[e.object({type:e.literal("rect"),radius:e.union([f(0,200),e.object({topLeft:f(0,200),topRight:f(0,200),bottomRight:f(0,200),bottomLeft:f(0,200)}).strict()])}).strict(),e.object({type:e.literal("pill")}).strict()]),Ke=e.object({width:f(0,12),color:L,style:e.enum(["solid","dashed"])}).strict(),Je=e.object({x:f(-40,40),y:f(-40,40),blur:f(0,80),spread:f(-20,40),color:L}).strict(),Xe=e.object({font:e.enum(["system","serif","rounded","mono"]),size:f(8,96),weight:e.number().int().min(100).max(900).multipleOf(100),lineHeight:e.number().min(.8).max(3),letterSpacing:e.number().min(-5).max(20),color:L,align:e.enum(["start","center","end"]),italic:e.boolean(),decoration:e.enum(["none","underline","line-through"]),transform:e.enum(["none","uppercase"])}).strict().partial(),P=e.object({width:ke,height:ke,padding:He,margin:qe,gap:f(0,120),grow:e.union([e.boolean(),e.number().min(0).max(12)]),background:Ge,opacity:e.number().min(0).max(1),clipContent:e.boolean(),shape:We,border:Ke,shadow:Je,text:Xe}).strict().partial(),I={id:U,name:e.string().trim().min(1).max(60).optional(),hidden:e.boolean().optional(),style:P.optional(),fallback:g.optional()},Ye=e.object({...I,type:e.literal("text"),productField:e.enum(["name","price","trial","period"]).optional(),feature:e.object({id:e.uuid(),field:e.enum(["name","allowance"])}).strict().optional(),text:g,variant:e.enum(["title","heading","body","caption"])}).strict(),et=e.object({...I,type:e.literal("image"),src:q,localizedSrc:e.record(A,q).optional(),alt:g,aspect:e.enum(["auto","1:1","4:3","16:9","3:1"]),fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict(),tt=e.object({...I,type:e.literal("button"),label:g,variant:e.enum(["primary","secondary","link"]),action:g,purpose:e.enum(["purchase","navigation","close"]).optional(),bind:T.optional()}).strict(),nt=e.object({...I,type:e.literal("divider")}).strict(),rt=e.object({...I,type:e.literal("customer_data"),title:g,data:ae}).strict(),it=e.object({...I,type:e.literal("spacer"),size:Qe}).strict(),ot=e.object({...I,type:e.literal("custom_html"),html:e.record(A,e.string().max(z.customHtml)),css:e.string().max(z.customCss),ui:be.optional()}).strict(),at=e.object({...I,type:e.literal("price"),fallback:g,parts:e.object({current:P.optional(),original:P.optional(),period:P.optional()}).strict().optional()}).strict(),st=e.object({...I,type:e.literal("coupon_code"),label:g,fallback:g}).strict(),ct=e.object({...I,type:e.literal("countdown"),source:e.enum(["offer.ends_at","offer.expires_at","fixed"]),at:e.iso.datetime().optional(),granularity:e.enum(["day","hour","minute","second"]),expired:g,fallback:g}).strict().refine(t=>t.source!=="fixed"||!!t.at,"固定倒计时需要结束时间"),lt=e.object({...I,type:e.literal("plan_picker"),label:g,fallback:g,planIds:e.array(e.string().min(1).max(200)).min(1).max(20).refine(t=>new Set(t).size===t.length,"套餐不能重复").optional(),defaultPlan:e.string().min(1).max(200).optional(),grouping:me.safeExtend({monthLabel:g,yearLabel:g,unavailableLabel:g}).optional(),states:e.object({selected:P.optional()}).strict().optional()}).strict().superRefine((t,n)=>{t.grouping&&(!t.planIds||!fe(t.grouping,t.planIds))&&n.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),pt=e.object({...I,type:e.literal("quantity_picker"),bind:T.optional(),label:g,fallback:g,internalFeatureId:e.uuid(),minimumQuantity:f(0,1e4),maximumQuantity:f(0,1e4),defaultQuantity:f(0,1e4),step:f(1,1e4)}).strict().refine(t=>t.minimumQuantity<=t.defaultQuantity&&t.defaultQuantity<=t.maximumQuantity&&(t.defaultQuantity-t.minimumQuantity)%t.step===0,"Quantity controls require a Product binding and valid bounds"),ut=e.discriminatedUnion("type",[e.object({type:e.literal("input"),label:g,keyboard:e.enum(["text","email","tel","url"]),maxLength:f(1,500)}).strict(),e.object({type:e.literal("multiselect"),label:g,min:f(0,50),max:f(1,50)}).strict(),e.object({type:e.literal("select"),label:g,defaultIndex:f(0,49),purpose:e.enum(["option","product","tier"]).optional(),pickerId:U.optional(),selectedStyle:P.optional()}).strict(),e.object({type:e.literal("tabs"),label:g,defaultIndex:f(0,49),purpose:e.literal("tier").optional()}).strict(),e.object({type:e.literal("toggle"),label:g,defaultEnabled:e.boolean()}).strict(),e.object({type:e.literal("carousel"),label:g}).strict()]),w={...I,type:e.literal("stack"),direction:e.enum(["vertical","horizontal","overlay"]),align:e.enum(["start","center","end","stretch"]),justify:e.enum(["start","center","end","between"]),productSlot:e.object({index:f(0,19),period:e.enum(["month","year"]).optional(),requireBinding:e.boolean().optional()}).strict().optional(),interaction:ut.optional(),states:e.object({selected:P.optional()}).strict().optional(),purpose:e.literal("benefits").optional(),purchaseAction:g.optional(),buttonVariant:e.enum(["primary","secondary","link"]).optional(),bind:T.optional()},je=e.lazy(()=>e.object({...I,type:w.type,direction:w.direction,align:w.align,justify:w.justify,children:e.array(mt).max(z.children),productSlot:w.productSlot,interaction:w.interaction,states:w.states,purpose:w.purpose,purchaseAction:w.purchaseAction,buttonVariant:w.buttonVariant,bind:w.bind}).strict()),mt=e.lazy(()=>e.union([je,Ye,et,tt,nt,it,ot,at,st,ct,lt,pt,rt])),ft=e.union([e.string().max(500),e.number().finite(),e.boolean(),e.null()]),$={id:g,event:g,properties:e.record(g,ft).refine(t=>Object.keys(t).length<=20,"最多 20 个参数")},dt=e.discriminatedUnion("type",[e.object({...$,type:e.literal("navigate"),close:e.literal(!1),pageId:U}).strict(),e.object({...$,type:e.literal("event"),close:e.boolean()}).strict(),e.object({...$,type:e.literal("close"),close:e.literal(!0)}).strict(),e.object({...$,type:e.literal("open_url"),close:e.boolean(),url:G}).strict(),e.object({...$,type:e.literal("claim_offer"),close:e.boolean(),couponId:e.uuid()}).strict()]),gt=e.object({defaultLocale:A,locales:e.record(A,e.record(g,e.string().max(z.stringLength)))}).strict(),bt=e.enum(["popup","paywall","onboarding","page","banner"]);var yt=e.object({kind:e.literal("screen"),schemaVersion:e.literal(Be),name:e.string().trim().min(1).max(80),surface:bt,initialPageId:U.optional(),presentation:X,theme:Se,pages:e.array(e.object({id:U,name:e.string().trim().min(1).max(60),root:je,theme:Se.optional(),editorPosition:e.object({x:e.number().finite().min(-1e5).max(1e5),y:e.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(z.pages),strings:gt,actions:e.array(dt).max(z.actions)}).strict();function R(t,n){for(let i of t.pages)W(i.root,n)}var dn=yt.superRefine((t,n)=>{let i=z;t.surface!=="paywall"&&t.pages.length!==1&&n.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),t.initialPageId&&!t.pages.some(c=>c.id===t.initialPageId)&&n.addIssue({code:"custom",message:"Initial screen does not exist"});for(let c of t.actions)c.type==="navigate"&&(t.surface!=="paywall"||!t.pages.some(b=>b.id===c.pageId))&&n.addIssue({code:"custom",message:"Navigation screen does not exist"});t.pages.length>i.pages&&n.addIssue({code:"custom",message:`页面最多 ${i.pages} 个`}),t.actions.length>i.actions&&n.addIssue({code:"custom",message:`动作最多 ${i.actions} 个`});let r=c=>n.addIssue({code:"custom",message:c}),o=Object.keys(t.strings.locales);o.includes(t.strings.defaultLocale)||r("默认语言必须在语言列表里"),o.length>z.locales&&r(`最多 ${z.locales} 种语言`);let a=new Set;for(let c of t.actions)a.has(c.id)&&r(`动作标识重复:${c.id}`),a.add(c.id);let s=new Set;for(let c of t.pages)["next","back"].includes(c.id)&&r(`页面 id 不能使用保留名称:${c.id}`),s.has(c.id)&&r(`页面 id 重复:${c.id}`),s.add(c.id);let l=new Set,u=0,y=!1;R(t,(c,b)=>{if(u++,b>z.depth&&(y=!0),l.has(c.id)&&r(`组件 id 重复:${c.id}`),l.add(c.id),c.type==="button"&&!a.has(c.action)&&r(`按钮 ${c.id} 引用的动作不存在:${c.action}`),c.type==="custom_html")for(let k of Object.keys(c.html))o.includes(k)||r(`自定义 HTML ${c.id} 含有未启用的语言:${k}`);if(c.type==="image")for(let k of Object.keys(c.localizedSrc??{}))o.includes(k)||r(`图片 ${c.id} 含有未启用的语言:${k}`)}),u>i.nodes&&r(`组件最多 ${i.nodes} 个`),y&&r(`层级最多 ${z.depth} 层`)});function W(t,n,i=1,r=null){if(n(t,i,r)!==!1&&t.type==="stack")for(let o of t.children)W(o,n,i+1,t)}function we(t){let n=[],i=new Set;return R(t,r=>{let o=(a,s,l)=>{i.has(a)||(i.add(a),n.push({key:a,nodeId:r.id,nodeType:r.type,field:s,required:l}))};r.type==="stack"&&r.interaction&&o(r.interaction.label,"label",!0),r.fallback&&o(r.fallback,"text",!0),r.type==="text"&&o(r.text,"text",!0),r.type==="customer_data"&&o(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&o(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(o(r.grouping.monthLabel,"label",!0),o(r.grouping.yearLabel,"label",!0),o(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&o(r.expired,"text",!0),r.type==="button"&&o(r.label,"label",!0),r.type==="image"&&(o(`image:${r.id}`,"src",!1),o(r.alt,"alt",!1)),r.type==="custom_html"&&o(`html:${r.id}`,"html",!0)}),n}function ht(t,n,i){if(n.field==="html"){let r;return R(t,o=>{o.id===n.nodeId&&o.type==="custom_html"&&(r=o.html[i])}),r}if(n.field==="src"){let r=It(t,n.nodeId);return r?.type==="image"?r.localizedSrc?.[i]??(i===t.strings.defaultLocale?r.src:void 0):void 0}return t.strings.locales[i]?.[n.key]}function xt(t){let n=we(t).filter(r=>r.required);return Object.keys(t.strings.locales).sort((r,o)=>r===t.strings.defaultLocale?-1:o===t.strings.defaultLocale?1:0).map(r=>{let o=n.filter(a=>!ht(t,a,r)?.trim()).map(a=>a.key);return{locale:r,total:n.length,filled:n.length-o.length,missing:o,complete:o.length===0}})}function St(t){return xt(t).filter(n=>n.complete||n.locale===t.strings.defaultLocale).map(n=>n.locale)}function gn(t,n){return xe(n,St(t),t.strings.defaultLocale)}function bn(t,n){let i=t.strings.locales[n]??{},r=t.strings.locales[t.strings.defaultLocale]??{},o={};for(let s of we(t)){if(s.field==="html"||s.field==="src")continue;let l=i[s.key]?.trim()?i[s.key]:r[s.key];l!==void 0&&(o[s.key]=l)}let a=s=>{if(s.type==="stack")return{...s,children:s.children.map(a)};if(s.type==="custom_html"){let l=s.html[n]?.trim()?s.html[n]:s.html[t.strings.defaultLocale];return{...s,html:l===void 0?{}:{[n]:l}}}if(s.type==="image"){let{localizedSrc:l,...u}=s;return{...u,src:l?.[n]??l?.[t.strings.defaultLocale]??s.src}}return s};return{...t,pages:t.pages.map(s=>({...s,root:a(s.root)})),strings:{defaultLocale:n,locales:{[n]:o}}}}function kt(t,n){let i=null;return W(t,r=>{if(i)return!1;r.id===n&&(i=r)}),i}function It(t,n){for(let i of t.pages){let r=kt(i.root,n);if(r)return r}return null}function yn(t){let n=F(t)?.split("-")[0];return n!==void 0&&["ar","he","fa","ur"].includes(n)}function hn(t,n,i){let r={};if(!n||typeof n!="object"||Array.isArray(n))return r;let o=n;if(R(t,a=>{if(a.type==="quantity_picker"){let l=o[a.id];typeof l=="number"&&Number.isSafeInteger(l)&&l>=a.minimumQuantity&&l<=a.maximumQuantity&&(l-a.minimumQuantity)%a.step===0&&(r[a.id]=l);return}if(a.type==="plan_picker"){let l=o[a.id];typeof l=="string"&&(r[a.id]=i?.pickers[a.id]?.options.includes(l)?l:"");return}if(a.type==="custom_html"&&a.ui)for(let[l,u]of Object.entries(a.ui.state??{})){let y=`${a.id}.${l}`,c=o[y];c!==null&&D(u,c)&&(r[y]=c)}if(a.type!=="stack"||!a.interaction)return;let s=Object.hasOwn(o,a.id)?o[a.id]:void 0;["select","tabs"].includes(a.interaction.type)&&typeof s=="string"&&a.children.some(l=>l.id===s)&&(r[a.id]=s),a.interaction.type==="toggle"&&typeof s=="boolean"&&(r[a.id]=s)}),t.surface==="paywall"&&typeof o.__page=="string"&&t.pages.some(a=>a.id===o.__page)&&(r.__page=o.__page),i){let a={...r};for(let[s,l]of Object.entries(o))(typeof l=="string"||typeof l=="boolean")&&(a[s]=l);Object.assign(r,pe(t,a,i))}return r}export{V as a,wt as b,te as c,Ot as d,ne as e,re as f,Et as g,ie as h,Vt as i,le as j,me as k,fe as l,Qt as m,Ft as n,Jt as o,A as p,F as q,z as r,U as s,g as t,q as u,R as v,dn as w,W as x,we as y,xt as z,gn as A,bn as B,It as C,yn as D,hn as E};
@@ -1 +1 @@
1
- import{a as kn,c as Rn,d as Ut,f as Lt,g as An,k as Sn}from"./chunk-UG5RBIWP.js";import{a as wn,b as Ye}from"./chunk-W32FI2A2.js";import{e as bn,f as Cn,g as Pn,h as vn,j as _t,k as ot,l as In,m as En,n as xn}from"./chunk-VVZLNTWC.js";import{a as hn,c as Ot,d as mn,e as yn}from"./chunk-TY4PJ2AG.js";import{a as at,b as oe,d as Nt,f as Dt,j as gn}from"./chunk-DCPRELJA.js";import{b as Ee}from"./chunk-SSVSXSYE.js";import{B as _,C as it,D as Ge,E as _e,y as fn}from"./chunk-KLPRVDHS.js";import{r as Ue,t as Le}from"./chunk-HQWZWHHM.js";import{i as pn}from"./chunk-NPDRXDI7.js";import{c as be,j as We}from"./chunk-XJTEGBPR.js";import{c as Tt}from"./chunk-7KQWJBFQ.js";import{a as k}from"./chunk-HLK7L2RV.js";import{a as z}from"./chunk-DSPLGTQI.js";async function Tn(H,a,x){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let T=H?We.parse(H):null;if(await x.onComplete?.(a),!T||!x.check)return;let F=We.parse(await x.check());if(F.internal_feature_id!==T.internal_feature_id||F.quantity!==T.quantity||T.observation!==void 0&&(F.observation===void 0||F.observation.requirementDigest!==T.observation.requirementDigest||F.observation.authority!==T.observation.authority||Tt(F.observation.subject)!==Tt(T.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");F.allowed&&await x.onAccessGranted?.(F)}function On(H){return Object.entries(H.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!Ee(a.product,{},H.capabilities)).map(([a])=>a)}function Nn(H,a){let x=_(a)?void 0:a.lines[0];if(!_(a)&&(a.lines.length!==1||!x))return;let T=_(a)?a.productVersionId:x.productVersionId,{screen:F,buttons:se}=H.document,M=new Map(_(a)?Object.entries(a.featureQuantities??{}):(x?.prepaid??[]).map(b=>[b.internal_feature_id,b.quantity]));function le(b,u){if(b.hidden)return!1;if(b.type==="plan_picker"&&H.capabilities.pickers[b.id]?.options.includes(T))return u[b.id]=T,!0;if(b.type==="quantity_picker"){let ne=M.get(b.internalFeatureId);return ne!==void 0&&(!b.bind?.plan||b.bind.plan===T)&&(u[b.id]=ne),!1}if(b.type==="button"&&b.action){let ne=se[b.action];return ne?.type==="checkout"&&ne.product.type==="fixed"&&ne.product.productVersionId===T}if(b.type!=="stack")return!1;let te=b.interaction,i=b.bind?.plan===T;for(let[ne,p]of b.children.entries()){let Z={},U=le(p,Z);if(te?.type==="toggle"||te?.type==="tabs"){if(!U)continue;return u[b.id]=te.type==="toggle"?ne===0:p.id,Object.assign(u,Z),!0}Object.assign(u,Z),U&&(i=!0,te?.type==="select"&&te.purpose==="product"&&te.pickerId&&p.type==="stack"&&p.bind?.plan===T&&(u[b.id]=p.id,u[te.pickerId]=T))}return i}for(let b of F.pages){let u={__page:b.id};if(le(b.root,u))return u}}var Bn="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0";async function Pr(H,a,x){let T=a.focusAtReveal?()=>{}:_t(H.ownerDocument),F=()=>{M.finish("dismissed"),T()},se=()=>F(),M=In(H,a,"paywall",()=>{F(),z(a.onDismiss)},kn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",se,{once:!0});let le=null,b,u,te;try{if(M.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),M.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(le=a.check?We.parse(await M.wait(a.check(),ot)):null,le?.allowed)return M.finish("skipped"),a.signal?.removeEventListener("abort",se),T(),await a.onAccessGranted?.(le),{check:le,host:null};let[e,t]=await Promise.allSettled([M.wait(import("./screen-renderer-AVHPHFXT.js")),M.wait(a.start().then(r=>(M.cancelled&&r.destroy(),r)),ot)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;te=e.value,b=t.value,a.signal?.throwIfAborted(),b.signal?.throwIfAborted(),b.signal?.addEventListener("abort",se,{once:!0});let n=b.view??await M.wait(b.refresh(),ot);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");b.signal?.throwIfAborted(),u=n}catch(e){throw M.finish("error",e),x?.retainedDialog?.release(),a.signal?.removeEventListener("abort",se),b?.signal?.removeEventListener("abort",se),b?.destroy(),T(),e}let i=b,{mountScreenPreview:ne}=te,p=H.ownerDocument,Z=new AbortController,U=p.createElement("section"),pe=p.createElement("div"),W=p.createElement("div"),st=a.mountControls,ee=st?p.createElement("div"):void 0,d=p.createElement("p"),y=p.createElement("button"),ce=p.createElement("button"),N=p.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&x?.hostPaywallTarget&&!x.retainedDialog&&u.document.presentation.type==="modal"&&(x.retainedDialog=vn(x.hostPaywallTarget));let ue=x?.retainedDialog,A=ue?.dialog??p.createElement("dialog"),Me=ue&&u.document.presentation.type==="inline"?{type:"modal",size:"md"}:u.document.presentation,re=Me.type==="inline"?W:p.createElement("div"),lt=i.locale||u.document.screen.strings.defaultLocale,o=lt.toLowerCase().startsWith("zh"),Dn=o?"正在处理…":"Processing…",_n=o?"正在准备报价…":"Preparing your price…",D=Rn(u.document.screen.theme);U.dataset.indianaPaywall="",U.setAttribute("aria-label",u.document.name),U.style.cssText=D.root,W.style.cssText=D.controls,d.style.cssText=D.message,d.setAttribute("role","status"),N.style.cssText=D.link,N.textContent=o?"关闭":"Close",y.style.cssText=D.secondary,y.textContent=o?"重试":"Retry",y.hidden=!0,ce.type="button",ce.style.cssText=D.primary,ce.textContent=o?"继续付款":"Continue payment",ce.hidden=!0,re.append(d,ce,y),W.append(N),ee&&(ee.style.cssText="flex:1 0 100%;min-width:0",ee.hidden=!0,W.prepend(ee)),re!==W&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",U.append(re)),U.append(pe,W);let ct=()=>{let e=Mn();d.style.cssText=e?`${D.message};${Bn}`:D.message,zt();let t=c=>!c.hidden&&(c!==d||!!d.textContent&&!e);if(re!==W&&(re.style.cssText=!ie&&[...re.children].some(t)?`${D.controls};padding:12px 64px 12px 20px;flex-shrink:0`:e?"padding:0":"display:none;padding:0"),ee){let c=!ee.childElementCount&&!ee.textContent?.trim();ee.hidden!==c&&(ee.hidden=c)}let n=me??W,r=![...n.children].some(t),s=[...n.children].some(c=>c!==N&&t(c));n.style.cssText=r?D.controls.replace(/padding:[^;]+/,"padding:0"):s?`${D.controls};${D.pinned}`:D.controls,dt()},Mt=typeof MutationObserver>"u"?void 0:new MutationObserver(ct);Mt?.observe(U,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Un=Object.entries(u.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),O,Vt,Ve=!1,$t=JSON.stringify(u.capabilities),Q;function Ce(e){let t=On(e);if(Q||fe&&!ae||B&&(C||!Pe()||ge))return Ae(e).map(({actionId:r})=>r);if(bt()||!C&&Pe())return t;let n=C?wt(e):Ct(e);return[...new Set([...t,...Ae(e).map(({actionId:r})=>r).filter(r=>!n.includes(r))])]}function $e(e){if(w)return;let t=u.id!==e.id;u=e;let n=JSON.stringify(e.capabilities);if(t||n!==$t){let r=!v&&!i.quote&&!i.operation?at(e,K,Bt):K;t||JSON.stringify(r)!==JSON.stringify(K)?(K=r,O?.update(e.document.screen,lt,{capabilities:oe(e),unavailableActions:Ce(e),serverInput:{bindings:[],answers:{}},selection:K})):O?.updateCapabilities(oe(e),Ce(e)),$t=n}Vn(e),ve(),Xe()}let L,ut=0;function Ht(){return(me??W).getBoundingClientRect().height+(re===W?0:re.getBoundingClientRect().height)}function dt(){let e=p.defaultView;if(!L?.responsive||!e)return;let t=me??W,n=e.innerHeight-(L.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",ut=Math.max(1,n-Ht()),O?.resizeViewport?.(ut,e.innerWidth)}let w=!1,fe=!1,v=null,pt,ze=!1,Qt=!1,he=!1,ft,ht=!1,ie,me;function Ln(){return fe||w||ie||ht?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Ot(i)}let I=()=>!w&&!ze&&!ie&&a.canInteract?.()!==!1,J,xe=!1,Re=!1,mt,f=null,de=null,Ke="",ye=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),K={},Bt=new Set,ae,C;function yt(e){return!!e&&_(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let gt=o?"正在确认付款…":"Confirming payment…",B=null,ge,Je,jt=!1,Pe=()=>a.allowNewPurchase!==!1||jt;function qt(){return JSON.stringify([u.id,u.capabilities])}function Ft(){let e=mt;return e&&e.read===a.prepareSubscriptionChange&&e.basis===qt()?e:void 0}function Xe(){let e=a.prepareSubscriptionChange;if(!e||!he||!I()||!Pe()||a.onPurchaseIntent||p.visibilityState==="hidden"||v||i.quote||i.operation||!Ae(u).length||Ft())return;let t=Z.signal,n=new Promise(r=>{let s=()=>r(void 0);t.addEventListener("abort",s,{once:!0}),Promise.resolve().then(()=>(t.throwIfAborted(),e(t))).then(c=>r(t.aborted?void 0:c),s).finally(()=>t.removeEventListener("abort",s))});mt={read:e,basis:qt(),result:n}}let Wt=()=>{p.visibilityState==="hidden"?mt=void 0:Xe()};p.addEventListener("visibilitychange",Wt);function Ae(e){return Object.entries(e.document.buttons).flatMap(([t,n])=>n.type==="checkout"?[{actionId:t,policy:n}]:[])}function Gt(e){let t=C?.quote;return t?Ae(e).filter(({actionId:n,policy:r})=>Se(t,e,n,r.product,K)).map(({actionId:n})=>n):[]}function wt(e){return C?.phase==="payment"?Gt(e):[]}function bt(){return(C?C.phase==="payment":!Pe())&&(Pe()||!!a.prepareUpgradeReplacement)&&ye()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&R(i.operation).type==="checkout"}function Ct(e){let t=i.quote;return!ye()||B||!t||!i.operation||R(i.operation).type!=="checkout"?[]:Ae(e).filter(({actionId:n,policy:r})=>Se(t,e,n,r.product,K)).map(({actionId:n})=>n)}function ve(){let e=Q?[]:C?wt(u):Ct(u),t=a.allowNewPurchase===!1&&!!i.operation&&R(i.operation).type==="checkout";ce.hidden=!!Q||(C?C.phase!=="payment":!t)||e.length>0,zt(e)}function Yt(){if(!(ae===void 0||Q))return d.textContent?d.textContent:C?.phase==="checking"?gt:void 0}function Mn(){return!!O?.updateCheckoutControls&&!!d.textContent&&Yt()!==void 0}let Ze;function zt(e=Q?[]:C?wt(u):Ct(u)){if(!O?.updateCheckoutControls)return;let t=Yt(),n=ye()||!!C;if(!t&&!n&&Ze?.on!==O)return;let r={actions:Ae(u).map(({actionId:c})=>c),resume:t?[ae]:n?e:[],resumeLabel:t??(o?"继续付款":C?"Continue payment":"Continue checkout"),busy:ae},s=JSON.stringify(r);Ze?.on===O&&Ze.key===s||(Ze={on:O,key:s},O.updateCheckoutControls(r))}function Kt(){de?.remove(),de=null}async function et(){if(B)return;if(a.resumeCheckout&&i.operation){let t=i.operation.operationId;try{await a.resumeCheckout(t)}catch(n){if(!(n instanceof k&&n.code==="PURCHASE_PENDING"))throw n;let r=await i.read();if(!I())return;if(r.operationId!==t||R(r).type==="checkout")throw n;await V(r,!1)}return}let e=await i.read();if(R(e).type!=="checkout")return V(e,!1);I()&&(He.delete(e.operationId),await Qe(e))}function Pt(){ge?.destroy(),ge=void 0,Je=void 0}function Jt(){let e=B;if(!e||ge)return;let t=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",n=Date.now()+6e5,r=wn({document:p,delay:()=>Date.now()<n?5e3:void 0,async run(){if(!I())return;let s=await i.read();if(ge!==r||!I())return;if(s.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let c=R(s);c.type==="native"?(Pt(),d.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",y.textContent=o?"继续更换套餐":"Continue changing plans",f=()=>tt(),y.hidden=!1):(c.type==="complete"||c.type==="fulfillment"||c.type==="recording")&&(Pt(),B=null,y.hidden=!0,await V(s,!1))}});ge=r,Je=async()=>{try{await r.refresh()}finally{ge===r&&(d.textContent=t,y.hidden=!1)}},f=Je,y.textContent=o?"查询结果":"Check result",y.hidden=!1,d.textContent=t,r.schedule()}async function tt(e=!1){let t=B;if(!t)return;f=()=>tt(),C&&(y.textContent=o?"查询状态":"Check status"),y.hidden=!0;let n=Date.now()+2e4;for(;I();){let r=await i.read();if(r.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!I())break;let s=R(r);if(s.type==="native"){if(!Pe()&&a.prepareUpgradeReplacement){let c=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!I())return;jt=!0,$e(c)}B=null,C&&Te(C.quote),Kt(),v=t.selection,J=t.coupon,xe=!1,Re=!1,await qe();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){B=null,C?await ke(C.quote,r):await V(r,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(c){z(a.onError,c)}}if(Date.now()>=n){C&&s.type==="checkout"&&(B=null,await ke(C.quote,r));break}await Ye(1e3,p,Z.signal)}!B||w||(C?(d.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",y.hidden=!1):Jt())}async function Xt(e,t,n,r){if(f=()=>Xt(e,t,n,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!I())return;let s=i.operation;if(s?.operationId!==e||R(s).type!=="checkout"){f=null,s&&await V(s,!1);return}B={operationId:e,selection:t,coupon:n,intent:r},C&&(d.textContent=o?"正在切换套餐…":"Changing plan…",y.hidden=!0);let c=!1;try{await a.terminateCheckout(e)}catch(l){if(l instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(l.code)){B=null,C&&(f=It,y.textContent=o?"查询状态":"Check status",y.hidden=!1),d.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",z(a.onError,l);return}c=l instanceof k&&(l.status??0)>=500,z(a.onError,l)}I()&&await tt(c)}function vt(e,t,n,r,s){let c=oe(e).checkoutCoupons?.[t],l=c?c.products[n]:a.claimCoupon&&s?pn(e.capabilities,s,r):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Vn(e){fe||v||i.quote||i.operation||Ke&&d.textContent===Ke||(d.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,nt=!1;function Se(e,t,n,r,s,c){let l=_(e),m=!l&&e.lines.length===1?e.lines[0]:void 0,h=Ee(r,s,t.capabilities);if(!h||h!==(l?e.productVersionId:m?.productVersionId))return!1;let E=vt(t,n,h,s,c),q;try{q=Le(t.document.screen,h,s,t.capabilities)}catch{return!1}if(l){let X=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(q).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(q).every(([De,St])=>e.featureQuantities?.[De]===St)&&(!E||X?.couponId===E.id&&(!E.offerId||X.grantId===E.offerId))}if((E||oe(t).checkoutCoupons?.[n])&&(E?.id??null)!==(e.discount?.couponId??null))return!1;let G=Object.fromEntries((m?.prepaid??[]).map(X=>[X.internal_feature_id,X.quantity]));return[...new Set([...Object.keys(q),...Object.keys(G)])].every(X=>(q[X]??0)===(G[X]??0))}let R=e=>hn({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Qe(e){let t=e.merchantExecution,n=R(e),r=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!I()||!r||it(e)&&n.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):p.defaultView?.location.assign(r)}catch(s){throw He.delete(e.operationId),s}}}let we=(e,t=!1)=>{if(e instanceof Nt)f=null,d.textContent=e.customerMessage(o);else if(An(e))f=null,d.textContent=t?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Lt(e,o);else if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(f=null,d.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!v?d.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":n==="COMMAND_PENDING"?d.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":d.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else d.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Lt(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";y.hidden=f===null,Ke=d.textContent,t&&ae===void 0&&!L?.responsive&&d.scrollIntoView?.({block:"nearest"}),z(t&&x?.quoteError?x.quoteError:a.onError,e)},Be=new WeakMap;function je(e){fe=e,y.disabled=e,ce.disabled=e,O?.updateCapabilities?.(oe(u),Ce(u));for(let t of de?.querySelectorAll("button")??[])e?(Be.has(t)||Be.set(t,t.disabled),t.disabled=!0):Be.has(t)&&(t.disabled=Be.get(t),Be.delete(t)),Ut(t)}function Zt(){Q&&(d.textContent=Q.message,y.textContent=o?"重试":"Retry",y.disabled=!1,y.hidden=!Q.retry,ce.disabled=!0)}function kt(){d.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}async function $n(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof Nt?(v=null,xe=!1,Re=!1,f=null):f=e,t}}async function j(e,t){if(fe||w||Q)return;if(!I()){kt();return}let n=e===qe,r=n?_n:Dn;ae=t!==void 0&&O?.updateCheckoutControls?t:void 0,d.textContent=r,je(!0),ve(),y.hidden=!0;try{if(e!==on&&e!==It&&e!==Et&&e!==Je&&(e!==et||!a.resumeCheckout)&&await $n(e),w||Q)return;if(!I()){f=e,y.hidden=!1,kt();return}await e()}catch(s){w||we(s,n)}finally{ae=void 0,je(!1),ve(),Q?Zt():d.textContent===r&&(d.textContent="")}}async function en(e){await Tn(le,e,a)}function Te(e,t){C=t?{quote:e,phase:t}:void 0,t==="checking"?(ae??=v?.actionId??Gt(u)[0],d.textContent=gt,f=It,y.textContent=o?"查询状态":"Check status",y.hidden=!0):ae=void 0,O?.updateCapabilities(oe(u),Ce(u)),ve()}function tn(e){return e instanceof k&&(e.code==="COMMAND_PENDING"||e.reason==="RESULT_UNKNOWN"||e.code==="NETWORK_ERROR"||e.code==="TIMEOUT"||e.status===429||(e.status??0)>=500)}function nn(e,t){Dt(e,{...t,featureQuantities:t.featureQuantities??{}},"Purchase operation changed")}async function It(){C&&await ke(C.quote)}async function ke(e,t){Te(e,"checking"),Ke="";let n=1e3;Ve=!0,z(a.onObservationChange,!0);try{for(let r=t;I();r=void 0){if(!r){try{r=await i.read()}catch(s){if(!tn(s))throw s}if(!I())return}if(r){nn(r,e);let s=R(r);if(s.type==="checkout"){Te(e,"payment"),d.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",y.hidden=!1;return}if(s.type==="complete"){Te(e,"complete"),f=null;let c=u.capabilities.plans[e.productVersionId]?.name,l=e.merchantTerms?.subscriptionTerms?.items,m=l?.length===1?l[0].interval:void 0,h=m==="year"?o?"年付":"annual billing":m==="month"?o?"月付":"monthly billing":null;d.textContent=c?o?`已升级到 ${c}${h?" "+h:""}。`:`Upgraded to ${c}${h?" ("+h+")":""}.`:o?"已成功升级。":"Plan upgraded.",await en(r);return}if(s.type==="native"&&!_e(r)){Te(e),v=null,f=null,d.textContent=o?"付款没有成功,套餐未变更。请检查付款方式后重新选择套餐。":"Your payment didn’t go through, so your plan is unchanged. Check your payment method, then choose a plan again.",y.textContent=o?"重试":"Retry";return}if(r.problem&&!["RESULT_UNKNOWN","STATE_CHANGED"].includes(r.problem.reason??""))throw new k(r.problem.code,o?"暂时无法完成升级。":"The upgrade needs attention.",void 0,void 0,r.problem)}await Ye(n,p,Z.signal),n=Math.min(n*1.5,15e3)}}finally{Ve=!1,z(a.onObservationChange,!1)}}async function Et(){let e=C?.quote;if(!e)return;let t=await i.read();if(nn(t,e),R(t).type!=="checkout")return ke(e,t);if(a.resumeCheckout){await a.resumeCheckout(t.operationId);return}He.delete(t.operationId),await Qe(t)}function rn(e){return Ot(i).type==="recording"||R(e).type==="recording"}function an(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],r=t?t.totalMinor:_(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),s=t?n.length===1&&n[0]?.amountMinor===r&&n[0]:!_(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],c=r===null?be(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):be(r,e.currency)+(s?Ue(s.interval,o?"zh-CN":"en",s.intervalCount??1):""),l=_(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(m=>m.productName).join(", ");return{label:l?`${l} · ${c}`:c,recurring:s}}async function V(e,t=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!I()){f=async()=>V(await i.read()),y.hidden=!1;return}let n=e.quote??i.quote;if(yt(n)&&(e.confirmedAt||e.merchantExecution))return ke(n,e);if(d.textContent=Sn(e.status,o),rn(e)){let h=e.merchantExecution?.recordingStatus==="failed";d.textContent=h?o?"付款和商户处理已完成,但交易记录失败。请联系商户修复,勿重复购买。":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"付款和商户处理已完成,正在确认交易记录。请勿重复购买。":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=o?"查询记录":"Check recording",f=async()=>V(await i.read()),y.hidden=!1;return}if(e.problem&&R(e).type!=="native"){let h=e.problem;f=Oe,y.textContent=o?"检查并恢复原操作":"Check and recover original purchase",we(new k(h.code,h.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":h.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":h.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":h.code==="NOT_CONFIGURED"?o?"付款服务连接需要处理,请联系商户后恢复原操作。":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"原购买操作需要处理,请查询或恢复此操作。":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,h));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(d.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&R(e).type==="complete"){f=null,await en(e);return}if(!_e(e)&&R(e).type!=="fulfillment"){if(i.canReselect===!1){d.textContent=o?"正在核对原购买结果":"Checking the original purchase result",y.textContent=o?"查询结果":"Check result",f=async()=>V(await i.read()),y.hidden=!1;return}e.status==="cancelled"?d.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(d.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),y.textContent=o?"重试":"Retry",f=null,v=null;return}if(!t&&R(e).type==="checkout"){if(B){Jt();return}if(ye()){d.textContent="",nt=!1,f=null,y.hidden=!0,O?.updateCapabilities?.(oe(u),Ce(u)),ve();return}let h=i.quote,E=h?.operationId===e.operationId?an(h).label:"";d.textContent=nt?E?o?`${E} 尚未付款。再次选择该方案即可继续付款。`:`${E} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",nt=!1,f=null;return}await Qe(e);let r=Date.now(),s=r+6e5,c=2e3,l=R(e).type!=="checkout",m=()=>l&&Date.now()-r<15e3;Ve=!0,z(a.onObservationChange,!0);try{for(;!w&&Date.now()<s;){if(await Ye(m()?700:c,p,Z.signal),w)return;if(!I()){f=async()=>V(await i.read()),y.hidden=!1;return}let h=await i.read();if(R(h).type==="checkout"&&(l=!1),!t&&R(h).type==="checkout"){await V(h,!1);return}if(!h.problem&&_e(h)&&await Qe(h),!_e(h)||h.problem||rn(h)){await V(h);return}m()||(c=Math.min(c*1.5,3e4))}}finally{Ve=!1,z(a.onObservationChange,!1)}f=async()=>V(await i.read()),y.hidden=!1}async function xt(e=!1){let t=await i.read();if(w)return;if(!I()){f=()=>xt(e),y.hidden=!1;return}let n=i.quote;if(n&&Dt(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(it(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(it(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await Oe():f=null;return}setTimeout(sn,0,n);return}await V(t,e||void 0)}async function on(){await xt()}async function Hn(e){d.textContent=gt;let t=Date.now()+12e3;for(;!w&&Date.now()<t&&(await Ye(1500,p,Z.signal),!(w||!I()));){let n;try{n=await i.read()}catch{break}if(n.problem?.reason!=="RESULT_UNKNOWN")return n}return e}async function Oe(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Kt();let e=i.quote;if(yt(e)){Te(e,"checking");let n;try{n=await i.confirm()}catch(r){if(!tn(r))throw r;return ke(e)}return ke(e,n)}f=Oe;let t=await i.confirm();if(!I()){f=Oe,y.hidden=!1;return}if(t.problem?.reason==="RESULT_UNKNOWN"&&(t=await Hn(t)),t.problem){await V(t);return}if(_e(t)){if(R(t).type==="checkout")await Qe(t);else if(t.execution&&t.execution.provider!=="merchant"||"nativePurchase"in t&&t.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:t,signal:Z.signal})}}f=async()=>V(await i.read()),await V(t,!0)}function sn(e){if(w)return;de?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());d.textContent=t?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),r=p.createElement("button"),s=p.createElement("button"),c=p.createElement("div"),l=p.createElement("p"),m=e.merchantTerms,h=o?"zh-CN":"en",E=m?.subscriptionTerms?.items??[],q=m?m.subscriptionTerms?.trial?.days:_(e)?void 0:e.lines.find(g=>g.trial)?.trial?.days,G=_(e)?m?m.totalMinor:e.totalMinor:q===void 0?null:m?m.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(g=>g.trial)?0:null,Ne=(g,P)=>o?`${P} 天试用结束后 ${g}`:`Then ${g} after the ${P}-day trial`,{label:X,recurring:De}=an(e),St=_(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(g=>g.productName).join(", "),un=G===null?"":`${o?"今天应付":"Due today"} ${be(G,e.currency)}`;l.textContent=un?[St,un].filter(Boolean).join(" · "):X,r.textContent=_(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=t,s.textContent=o?"取消":"Cancel",n.style.cssText=D.panel,l.style.cssText=D.summary,c.style.cssText=D.actions,r.style.cssText=D.primary,s.style.cssText=D.secondary,Ut(r),r.onclick=()=>{j(Oe)};let dn=async()=>{let g=await i.cancel();w||(n.remove(),de=null,await V(g))};s.onclick=()=>{f=dn,j(dn)};let Y=p.createElement("div");if(Y.style.cssText=D.terms,_(e)){for(let[P,S]of Object.entries(e.featureQuantities??{})){let $=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(Qn=>Qn.internalFeatureId===P),rt=p.createElement("p");rt.textContent=`${$?.name??P} · ${S} ${o?"份":"packs"}${$?` × ${$.terms.units}`:""}`,Y.append(rt)}for(let[P,S]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",m?.discountMinor??e.discountMinor],[o?"税费":"Tax",m?m.taxMinor:e.taxMinor]]){let $=p.createElement("p");$.textContent=`${P}: ${S===null?o?"结账时确认":"Confirmed at checkout":be(S,e.currency)}`,Y.append($)}let g=p.createElement("p");g.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,Y.append(g)}if(m){for(let P of E){if(G===null&&P===De)continue;let S=p.createElement("p"),$=be(P.amountMinor,e.currency)+Ue(P.interval,h,P.intervalCount);S.textContent=G!==null&&q!==void 0?Ne($,q):$,P.amountAfterOfferMinor!==void 0&&(S.textContent+=` · ${o?"优惠结束后":"After the offer"} ${be(P.amountAfterOfferMinor,e.currency)}${Ue(P.interval,h,P.intervalCount)}`),Y.append(S)}let g=m.subscriptionTerms?.trial;if(g){let P=p.createElement("p");P.textContent=o?`试用 ${g.days} 天;${g.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.days}; ${g.cardRequired?"a payment method is required":"no payment method is required"}`,Y.append(P)}for(let P of[...m.expectedEffects.map(S=>S.description),...m.requiredConsents.map(S=>S.summary)]){let S=p.createElement("p");S.textContent=P,Y.append(S)}}else if(!_(e)){for(let g of e.lines){if(G!==null||g!==De){let P=p.createElement("p"),S=`${be(g.catalogAmountMinor,e.currency)}${Ue(g.interval,h,g.intervalCount??1)}`;P.textContent=G!==null&&g.trial?(e.lines.length>1?`${g.productName} · `:"")+Ne(S,g.trial.days):`${g.productName} · ${S}`,Y.append(P)}for(let P of g.prepaid??[]){let S=p.createElement("p"),$=i.view?.capabilities.plans[g.productVersionId]?.prepaid?.find(rt=>rt.internalFeatureId===P.internal_feature_id);S.textContent=`${$?.name??P.internal_feature_id} · ${P.quantity} ${o?"份":"packs"} × ${P.terms.units}`,$&&(S.textContent+=Ue($.reset==="week"||$.reset==="month"||$.reset==="year"?$.reset:"one_time",h,$.resetCount)),Y.append(S)}if(g.trial){let P=p.createElement("p");P.textContent=o?`试用 ${g.trial.days} 天;${g.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.trial.days}; ${g.trial.cardRequired?"a payment method is required":"no payment method is required"}`,Y.append(P)}}if(!e.charge){let g=p.createElement("p");g.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",Y.append(g)}}for(let g of Y.children)g.style.margin="0";c.append(r,s),n.append(l,...Y.childElementCount?[Y]:[],c),W.prepend(n),L?.responsive||n.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),de=n,fe&&je(!0),f=null}async function qe(){if(!v)return;if(f=qe,!xe){let n=i.view,r=n?.document.buttons[v.actionId],s=n&&r?.type==="checkout"?Ee(r.product,v.selection,n.capabilities):null;if(!n||!s)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!Re){let l=Ft(),m=l?await l.result:void 0;if(w)return;let h=a.resolveSubscriptionChange;if(h||m){let E={actionId:v.actionId,productVersionId:s,featureQuantities:Le(n.document.screen,s,v.selection,n.capabilities)},q=m?[async()=>m(E)]:[],G=h?await h(E,...q):await q[0]?.();if(w)return;G!==void 0&&(v.subscriptionChange=fn.parse(G))}Re=!0}let c=J?.offerId;if(J&&!c){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await a.claimCoupon(J.id,v.requestId);if(w)return;if(!l||l.couponId!==J.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw v=null,J=void 0,f=async()=>{$e(await i.refresh()),f=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");c=l.id}if(!J&&!n.document.screen.actions.some(l=>l.id===v?.actionId&&typeof l.properties.couponBinding=="string")&&(c=await a.resolveOfferId?.({actionId:v.actionId,productVersionId:s,featureQuantities:Le(n.document.screen,s,v.selection,n.capabilities)})),w)return;c!==void 0&&(v.offerId=c),xe=!0}if(!I()){y.hidden=!1;return}let e;try{e=await i.preview(v)}catch(n){throw i.canReselect===!0&&(v=null,xe=!1,Re=!1,J=void 0,f=null),n}if(J&&(_(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==J.id||n.grantId!==v.offerId})():e.discount?.couponId!==J.id||e.discount.offerId!==v.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let t=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&I()&&!_(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!I()){y.hidden=!1;return}if(!(Date.parse(e.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");let n=ae?"":o?"正在打开收银台…":"Opening checkout…";d.textContent=n;try{await Oe()}catch(r){w||we(r)}finally{d.textContent===n&&(d.textContent="")}return}sn(e)}function Ie(e="destroy",t=!1){if(w)return;w=!0;let n=pt;pt=void 0,z(n),a.signal?.removeEventListener("abort",se),i.signal?.removeEventListener("abort",se),M.finish("dismissed"),Vt?.(),Pt(),p.removeEventListener("visibilitychange",Wt),Z.abort(),Mt?.disconnect(),O?.destroy(),i.destroy(),A.removeEventListener("cancel",cn),N.remove(),U.remove(),t||ln(),e==="dismiss"&&z(a.onDismiss)}function ln(){if(L?.destroy(),ue){ue.release();return}A.open&&A.close(),A.remove(),T()}F=Ie;async function Fe(){if(!he||w||ze||ie==="closing"||!ie&&!I())return;if(!x){Ie("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=p.createElement("div"),me.style.cssText=W.style.cssText,W.replaceWith(me),pe.inert=!0),N.hidden=!1,me.replaceChildren(e,N),ie="closing",N.setAttribute("aria-disabled","true"),N.focus({preventScroll:!0});try{await x.dismiss()}catch(t){w||z(a.onError,t)}w||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",N.textContent=o?"重试关闭":"Retry closing",N.removeAttribute("aria-label"),N.removeAttribute("aria-disabled"))}N.onclick=()=>{Fe()};function cn(e){e.preventDefault(),Fe()}A.addEventListener("cancel",cn),ce.onclick=()=>{j(C?Et:et)},y.onclick=()=>{if(Q){Q.retry?.();return}f&&j(f)};function Rt(e){M.finish("error",e),Ie()}function At(){if(!(!Qt||he||w||ze||L&&!I()))try{let e=t=>{a.focusAtReveal&&(T=_t(p)),a.settleMotionAtReveal?O?.setHidden?.(!1,!0):O?.setHidden?.(!1),ft?.(),L&&(A.open||A.showModal(),L.responsive&&A.focus({preventScroll:!0}),!t&&a.loading!=="host"&&Cn(A,L.type,L.responsive)),t&&a.loading!=="host"&&typeof pe.animate=="function"&&!p.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),he=!0,Xe()};x?x.present(t=>M.present(n=>e(t??n))):M.present(e)}catch(e){Rt(e),we(e)}}try{if(Me.type==="inline"?(ct(),ft=xn(U,H),H.append(U)):(A.setAttribute("aria-label",u.document.name),N.textContent="×",N.setAttribute("aria-label",o?"关闭":"Close"),Pn(N,u.document.screen.theme),N.hidden=gn(u.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ue?.content?ue.content.append(N,U):A.replaceChildren(N,U),ue||H.append(A),L=bn(A,{...u.document.screen,presentation:Me},dt),L.latch(),L.responsive&&(U.style.display="flex",U.style.flexDirection="column",U.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ue||(ft=En(A))),st&&ee){let n=st(ee);if(typeof n=="function"&&(w?z(n):pt=n),w)throw new DOMException("Presentation cancelled","AbortError");ct()}O=ne(pe,{mode:"live",rendererUrl:"bundled",title:u.document.name,closeActions:Un,onAuthoredClose(n){ie||w||(N.hidden=n)},hostPresentation:()=>L?.type??Me.type,reportContentHeight:L?.responsive,onResize:n=>{if(!L?.responsive)return;let r=Math.min(n,ut);pe.style.height=`${r}px`,L.setContentHeight(r+Ht())},onSelection(n){for(let[r,s]of Object.entries(n))typeof s=="number"&&typeof K[r]=="number"&&K[r]!==s&&Bt.add(r);K=n,ve(),Xe()},onAction(n,r={},s,c){if(!he||w||ie)return;let l=i.view,m=l?.document.buttons[n];if(!m)return;if(Q){m.type==="close"&&Fe();return}if(m.type==="close"&&x&&a.resumeCheckout&&i.operation&&mn(R(i.operation))){Fe();return}if(fe)return;if(!I()){kt();return}if(m.type==="close"){j(async()=>{x?.closeAction?await x.closeAction(n):await a.onAction?.(n),Ie(a.onAction?"action":"dismiss")});return}if(m.type==="action"){f=async()=>{if(m.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(m.action.event)}else a.onOpenUrl?await a.onOpenUrl(m.action.url):p.defaultView?.location.assign(m.action.url);await a.onAction?.(n),f=null},j(f);return}if(ye()&&B){!ge&&B.selection.actionId===n&&j(()=>tt(!0),n);return}if(C){if(C.phase==="payment"&&l&&Se(C.quote,l,n,m.product,r,c)){j(Et,n);return}if(!bt())return}if(!Pe()&&!bt()){ye()&&l&&i.quote&&i.operation&&R(i.operation).type==="checkout"&&Se(i.quote,l,n,m.product,r,c)?j(et,n):d.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(de&&i.canReselect===!1){d.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",L?.responsive||de.scrollIntoView?.({block:"nearest"}),de.querySelector("button")?.focus({preventScroll:!0});return}if(ye()&&a.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&R(i.operation).type==="checkout"){if(Se(i.quote,l,n,m.product,r,c)){j(et,n);return}let E=Ee(m.product,r,l.capabilities),q;try{if(!E)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");q=Le(l.document.screen,E,r,l.capabilities)}catch(De){we(De);return}let G=i.operation.operationId,Ne={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(r)},X=vt(l,n,E,r,c);j(()=>Xt(G,Ne,X,{actionId:n,productVersionId:E,selection:Ne.selection,featureQuantities:q}),n);return}if((i.quote||v)&&i.canReselect===!1){let E=!!l&&!!i.quote&&Se(i.quote,l,n,m.product,r,c);nt=!!i.quote&&!E,f=i.quote?()=>xt(E):qe,j(f,n);return}let h=l&&Ee(m.product,r,l.capabilities);if(!l||!h){we(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){f=null,j(async()=>{let E={actionId:n,productVersionId:h,selection:structuredClone(r),featureQuantities:Le(l.document.screen,h,r,l.capabilities)};ht=!0,await a.onPurchaseIntent(E)},n);return}if(v&&v.actionId!==n){we(new k("COMMAND_PENDING","Finish the current purchase"));return}v||(J=vt(l,n,h,r,c),v={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(r)},xe=!1,Re=!1),j(qe,n)},onEscape:()=>{Fe()},onError:n=>{let r=new Error(n);!he&&!w&&Rt(r),we(r)},onRendered:n=>{n&&A.setAttribute("aria-label",n),Qt=!0,At()}}),O.setHidden?.(!0),dt();let e=ye()&&!!i.quote&&!!i.operation&&R(i.operation).type==="checkout";K=i.quote?Nn(u,i.quote)??at(u,{}):at(u,{}),O.update(u.document.screen,lt,{capabilities:oe(u),unavailableActions:Ce(u),serverInput:{bindings:[],answers:{}},...Object.keys(K).length?{selection:K}:{}}),Vt=i.subscribe?.($e),$e(i.view??u),await M.wait(O.ready);let t=i.operation;(!e||yt(i.quote))&&(i.quote||t&&(t.confirmedAt||t.checkoutUrl||Ge(t)))&&(f=on,j(f))}catch(e){throw Rt(e),e}return{check:le,host:{get currentResolution(){return u},setPurchaseRecovery(e,t){Q={message:e,retry:t},O?.updateCapabilities?.(oe(u),Ce(u)),ve(),Zt()},get subscriptionUpgradeActive(){return C!==void 0},get observing(){return Ve},get recovery(){return Ln()},async prepareFallback(){if(fe||w||ie||ht)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await yn(i);return e.type==="native"&&Ie(),e}finally{je(!1)}},setSuspended(e){ze=e,U.hidden=e,e&&A.open?A.close():!e&&!he?At():!e&&!w&&he&&Me.type!=="inline"&&!A.open&&A.showModal()},destroy:Ie,retainPurchaseDialog(){if(!(w||!A.open||!A.isConnected))return Ie("destroy",!0),{dialog:A,content:ue?.content,release:ln}},refresh:async()=>{if(!I()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return $e(e),At(),e}}}}export{Pr as a};
1
+ import{a as kn,c as Rn,d as Ut,f as Lt,g as An,k as Sn}from"./chunk-IEYSWIRA.js";import{a as wn,b as Ye}from"./chunk-W32FI2A2.js";import{e as bn,f as Cn,g as Pn,h as vn,j as _t,k as ot,l as In,m as En,n as xn}from"./chunk-XSEYXS4X.js";import{a as hn,c as Ot,d as mn,e as yn}from"./chunk-464CINQK.js";import{a as at,b as oe,d as Nt,f as Dt,j as gn}from"./chunk-EQJIC52H.js";import{b as Ee}from"./chunk-TZTWXL53.js";import{B as _,C as it,D as Ge,E as _e,y as fn}from"./chunk-H3LBNH34.js";import{r as Ue,t as Le}from"./chunk-SUUBL2WC.js";import{i as pn}from"./chunk-4G52SO64.js";import{c as be,j as We}from"./chunk-CWBL2S3A.js";import{c as Tt}from"./chunk-X6ZYJHX4.js";import{a as k}from"./chunk-E4B7243C.js";import{a as z}from"./chunk-DSPLGTQI.js";async function Tn(H,a,x){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let T=H?We.parse(H):null;if(await x.onComplete?.(a),!T||!x.check)return;let F=We.parse(await x.check());if(F.internal_feature_id!==T.internal_feature_id||F.quantity!==T.quantity||T.observation!==void 0&&(F.observation===void 0||F.observation.requirementDigest!==T.observation.requirementDigest||F.observation.authority!==T.observation.authority||Tt(F.observation.subject)!==Tt(T.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");F.allowed&&await x.onAccessGranted?.(F)}function On(H){return Object.entries(H.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!Ee(a.product,{},H.capabilities)).map(([a])=>a)}function Nn(H,a){let x=_(a)?void 0:a.lines[0];if(!_(a)&&(a.lines.length!==1||!x))return;let T=_(a)?a.productVersionId:x.productVersionId,{screen:F,buttons:se}=H.document,M=new Map(_(a)?Object.entries(a.featureQuantities??{}):(x?.prepaid??[]).map(b=>[b.internal_feature_id,b.quantity]));function le(b,u){if(b.hidden)return!1;if(b.type==="plan_picker"&&H.capabilities.pickers[b.id]?.options.includes(T))return u[b.id]=T,!0;if(b.type==="quantity_picker"){let ne=M.get(b.internalFeatureId);return ne!==void 0&&(!b.bind?.plan||b.bind.plan===T)&&(u[b.id]=ne),!1}if(b.type==="button"&&b.action){let ne=se[b.action];return ne?.type==="checkout"&&ne.product.type==="fixed"&&ne.product.productVersionId===T}if(b.type!=="stack")return!1;let te=b.interaction,i=b.bind?.plan===T;for(let[ne,p]of b.children.entries()){let Z={},U=le(p,Z);if(te?.type==="toggle"||te?.type==="tabs"){if(!U)continue;return u[b.id]=te.type==="toggle"?ne===0:p.id,Object.assign(u,Z),!0}Object.assign(u,Z),U&&(i=!0,te?.type==="select"&&te.purpose==="product"&&te.pickerId&&p.type==="stack"&&p.bind?.plan===T&&(u[b.id]=p.id,u[te.pickerId]=T))}return i}for(let b of F.pages){let u={__page:b.id};if(le(b.root,u))return u}}var Bn="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0";async function Pr(H,a,x){let T=a.focusAtReveal?()=>{}:_t(H.ownerDocument),F=()=>{M.finish("dismissed"),T()},se=()=>F(),M=In(H,a,"paywall",()=>{F(),z(a.onDismiss)},kn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",se,{once:!0});let le=null,b,u,te;try{if(M.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),M.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(le=a.check?We.parse(await M.wait(a.check(),ot)):null,le?.allowed)return M.finish("skipped"),a.signal?.removeEventListener("abort",se),T(),await a.onAccessGranted?.(le),{check:le,host:null};let[e,t]=await Promise.allSettled([M.wait(import("./screen-renderer-IKROGLA7.js")),M.wait(a.start().then(r=>(M.cancelled&&r.destroy(),r)),ot)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;te=e.value,b=t.value,a.signal?.throwIfAborted(),b.signal?.throwIfAborted(),b.signal?.addEventListener("abort",se,{once:!0});let n=b.view??await M.wait(b.refresh(),ot);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");b.signal?.throwIfAborted(),u=n}catch(e){throw M.finish("error",e),x?.retainedDialog?.release(),a.signal?.removeEventListener("abort",se),b?.signal?.removeEventListener("abort",se),b?.destroy(),T(),e}let i=b,{mountScreenPreview:ne}=te,p=H.ownerDocument,Z=new AbortController,U=p.createElement("section"),pe=p.createElement("div"),W=p.createElement("div"),st=a.mountControls,ee=st?p.createElement("div"):void 0,d=p.createElement("p"),y=p.createElement("button"),ce=p.createElement("button"),N=p.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&x?.hostPaywallTarget&&!x.retainedDialog&&u.document.presentation.type==="modal"&&(x.retainedDialog=vn(x.hostPaywallTarget));let ue=x?.retainedDialog,A=ue?.dialog??p.createElement("dialog"),Me=ue&&u.document.presentation.type==="inline"?{type:"modal",size:"md"}:u.document.presentation,re=Me.type==="inline"?W:p.createElement("div"),lt=i.locale||u.document.screen.strings.defaultLocale,o=lt.toLowerCase().startsWith("zh"),Dn=o?"正在处理…":"Processing…",_n=o?"正在准备报价…":"Preparing your price…",D=Rn(u.document.screen.theme);U.dataset.indianaPaywall="",U.setAttribute("aria-label",u.document.name),U.style.cssText=D.root,W.style.cssText=D.controls,d.style.cssText=D.message,d.setAttribute("role","status"),N.style.cssText=D.link,N.textContent=o?"关闭":"Close",y.style.cssText=D.secondary,y.textContent=o?"重试":"Retry",y.hidden=!0,ce.type="button",ce.style.cssText=D.primary,ce.textContent=o?"继续付款":"Continue payment",ce.hidden=!0,re.append(d,ce,y),W.append(N),ee&&(ee.style.cssText="flex:1 0 100%;min-width:0",ee.hidden=!0,W.prepend(ee)),re!==W&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",U.append(re)),U.append(pe,W);let ct=()=>{let e=Mn();d.style.cssText=e?`${D.message};${Bn}`:D.message,zt();let t=c=>!c.hidden&&(c!==d||!!d.textContent&&!e);if(re!==W&&(re.style.cssText=!ie&&[...re.children].some(t)?`${D.controls};padding:12px 64px 12px 20px;flex-shrink:0`:e?"padding:0":"display:none;padding:0"),ee){let c=!ee.childElementCount&&!ee.textContent?.trim();ee.hidden!==c&&(ee.hidden=c)}let n=me??W,r=![...n.children].some(t),s=[...n.children].some(c=>c!==N&&t(c));n.style.cssText=r?D.controls.replace(/padding:[^;]+/,"padding:0"):s?`${D.controls};${D.pinned}`:D.controls,dt()},Mt=typeof MutationObserver>"u"?void 0:new MutationObserver(ct);Mt?.observe(U,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Un=Object.entries(u.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),O,Vt,Ve=!1,$t=JSON.stringify(u.capabilities),Q;function Ce(e){let t=On(e);if(Q||fe&&!ae||B&&(C||!Pe()||ge))return Ae(e).map(({actionId:r})=>r);if(bt()||!C&&Pe())return t;let n=C?wt(e):Ct(e);return[...new Set([...t,...Ae(e).map(({actionId:r})=>r).filter(r=>!n.includes(r))])]}function $e(e){if(w)return;let t=u.id!==e.id;u=e;let n=JSON.stringify(e.capabilities);if(t||n!==$t){let r=!v&&!i.quote&&!i.operation?at(e,K,Bt):K;t||JSON.stringify(r)!==JSON.stringify(K)?(K=r,O?.update(e.document.screen,lt,{capabilities:oe(e),unavailableActions:Ce(e),serverInput:{bindings:[],answers:{}},selection:K})):O?.updateCapabilities(oe(e),Ce(e)),$t=n}Vn(e),ve(),Xe()}let L,ut=0;function Ht(){return(me??W).getBoundingClientRect().height+(re===W?0:re.getBoundingClientRect().height)}function dt(){let e=p.defaultView;if(!L?.responsive||!e)return;let t=me??W,n=e.innerHeight-(L.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",ut=Math.max(1,n-Ht()),O?.resizeViewport?.(ut,e.innerWidth)}let w=!1,fe=!1,v=null,pt,ze=!1,Qt=!1,he=!1,ft,ht=!1,ie,me;function Ln(){return fe||w||ie||ht?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Ot(i)}let I=()=>!w&&!ze&&!ie&&a.canInteract?.()!==!1,J,xe=!1,Re=!1,mt,f=null,de=null,Ke="",ye=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),K={},Bt=new Set,ae,C;function yt(e){return!!e&&_(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let gt=o?"正在确认付款…":"Confirming payment…",B=null,ge,Je,jt=!1,Pe=()=>a.allowNewPurchase!==!1||jt;function qt(){return JSON.stringify([u.id,u.capabilities])}function Ft(){let e=mt;return e&&e.read===a.prepareSubscriptionChange&&e.basis===qt()?e:void 0}function Xe(){let e=a.prepareSubscriptionChange;if(!e||!he||!I()||!Pe()||a.onPurchaseIntent||p.visibilityState==="hidden"||v||i.quote||i.operation||!Ae(u).length||Ft())return;let t=Z.signal,n=new Promise(r=>{let s=()=>r(void 0);t.addEventListener("abort",s,{once:!0}),Promise.resolve().then(()=>(t.throwIfAborted(),e(t))).then(c=>r(t.aborted?void 0:c),s).finally(()=>t.removeEventListener("abort",s))});mt={read:e,basis:qt(),result:n}}let Wt=()=>{p.visibilityState==="hidden"?mt=void 0:Xe()};p.addEventListener("visibilitychange",Wt);function Ae(e){return Object.entries(e.document.buttons).flatMap(([t,n])=>n.type==="checkout"?[{actionId:t,policy:n}]:[])}function Gt(e){let t=C?.quote;return t?Ae(e).filter(({actionId:n,policy:r})=>Se(t,e,n,r.product,K)).map(({actionId:n})=>n):[]}function wt(e){return C?.phase==="payment"?Gt(e):[]}function bt(){return(C?C.phase==="payment":!Pe())&&(Pe()||!!a.prepareUpgradeReplacement)&&ye()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&R(i.operation).type==="checkout"}function Ct(e){let t=i.quote;return!ye()||B||!t||!i.operation||R(i.operation).type!=="checkout"?[]:Ae(e).filter(({actionId:n,policy:r})=>Se(t,e,n,r.product,K)).map(({actionId:n})=>n)}function ve(){let e=Q?[]:C?wt(u):Ct(u),t=a.allowNewPurchase===!1&&!!i.operation&&R(i.operation).type==="checkout";ce.hidden=!!Q||(C?C.phase!=="payment":!t)||e.length>0,zt(e)}function Yt(){if(!(ae===void 0||Q))return d.textContent?d.textContent:C?.phase==="checking"?gt:void 0}function Mn(){return!!O?.updateCheckoutControls&&!!d.textContent&&Yt()!==void 0}let Ze;function zt(e=Q?[]:C?wt(u):Ct(u)){if(!O?.updateCheckoutControls)return;let t=Yt(),n=ye()||!!C;if(!t&&!n&&Ze?.on!==O)return;let r={actions:Ae(u).map(({actionId:c})=>c),resume:t?[ae]:n?e:[],resumeLabel:t??(o?"继续付款":C?"Continue payment":"Continue checkout"),busy:ae},s=JSON.stringify(r);Ze?.on===O&&Ze.key===s||(Ze={on:O,key:s},O.updateCheckoutControls(r))}function Kt(){de?.remove(),de=null}async function et(){if(B)return;if(a.resumeCheckout&&i.operation){let t=i.operation.operationId;try{await a.resumeCheckout(t)}catch(n){if(!(n instanceof k&&n.code==="PURCHASE_PENDING"))throw n;let r=await i.read();if(!I())return;if(r.operationId!==t||R(r).type==="checkout")throw n;await V(r,!1)}return}let e=await i.read();if(R(e).type!=="checkout")return V(e,!1);I()&&(He.delete(e.operationId),await Qe(e))}function Pt(){ge?.destroy(),ge=void 0,Je=void 0}function Jt(){let e=B;if(!e||ge)return;let t=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",n=Date.now()+6e5,r=wn({document:p,delay:()=>Date.now()<n?5e3:void 0,async run(){if(!I())return;let s=await i.read();if(ge!==r||!I())return;if(s.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let c=R(s);c.type==="native"?(Pt(),d.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",y.textContent=o?"继续更换套餐":"Continue changing plans",f=()=>tt(),y.hidden=!1):(c.type==="complete"||c.type==="fulfillment"||c.type==="recording")&&(Pt(),B=null,y.hidden=!0,await V(s,!1))}});ge=r,Je=async()=>{try{await r.refresh()}finally{ge===r&&(d.textContent=t,y.hidden=!1)}},f=Je,y.textContent=o?"查询结果":"Check result",y.hidden=!1,d.textContent=t,r.schedule()}async function tt(e=!1){let t=B;if(!t)return;f=()=>tt(),C&&(y.textContent=o?"查询状态":"Check status"),y.hidden=!0;let n=Date.now()+2e4;for(;I();){let r=await i.read();if(r.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!I())break;let s=R(r);if(s.type==="native"){if(!Pe()&&a.prepareUpgradeReplacement){let c=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!I())return;jt=!0,$e(c)}B=null,C&&Te(C.quote),Kt(),v=t.selection,J=t.coupon,xe=!1,Re=!1,await qe();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){B=null,C?await ke(C.quote,r):await V(r,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(c){z(a.onError,c)}}if(Date.now()>=n){C&&s.type==="checkout"&&(B=null,await ke(C.quote,r));break}await Ye(1e3,p,Z.signal)}!B||w||(C?(d.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",y.hidden=!1):Jt())}async function Xt(e,t,n,r){if(f=()=>Xt(e,t,n,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!I())return;let s=i.operation;if(s?.operationId!==e||R(s).type!=="checkout"){f=null,s&&await V(s,!1);return}B={operationId:e,selection:t,coupon:n,intent:r},C&&(d.textContent=o?"正在切换套餐…":"Changing plan…",y.hidden=!0);let c=!1;try{await a.terminateCheckout(e)}catch(l){if(l instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(l.code)){B=null,C&&(f=It,y.textContent=o?"查询状态":"Check status",y.hidden=!1),d.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",z(a.onError,l);return}c=l instanceof k&&(l.status??0)>=500,z(a.onError,l)}I()&&await tt(c)}function vt(e,t,n,r,s){let c=oe(e).checkoutCoupons?.[t],l=c?c.products[n]:a.claimCoupon&&s?pn(e.capabilities,s,r):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Vn(e){fe||v||i.quote||i.operation||Ke&&d.textContent===Ke||(d.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,nt=!1;function Se(e,t,n,r,s,c){let l=_(e),m=!l&&e.lines.length===1?e.lines[0]:void 0,h=Ee(r,s,t.capabilities);if(!h||h!==(l?e.productVersionId:m?.productVersionId))return!1;let E=vt(t,n,h,s,c),q;try{q=Le(t.document.screen,h,s,t.capabilities)}catch{return!1}if(l){let X=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(q).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(q).every(([De,St])=>e.featureQuantities?.[De]===St)&&(!E||X?.couponId===E.id&&(!E.offerId||X.grantId===E.offerId))}if((E||oe(t).checkoutCoupons?.[n])&&(E?.id??null)!==(e.discount?.couponId??null))return!1;let G=Object.fromEntries((m?.prepaid??[]).map(X=>[X.internal_feature_id,X.quantity]));return[...new Set([...Object.keys(q),...Object.keys(G)])].every(X=>(q[X]??0)===(G[X]??0))}let R=e=>hn({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Qe(e){let t=e.merchantExecution,n=R(e),r=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!I()||!r||it(e)&&n.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):p.defaultView?.location.assign(r)}catch(s){throw He.delete(e.operationId),s}}}let we=(e,t=!1)=>{if(e instanceof Nt)f=null,d.textContent=e.customerMessage(o);else if(An(e))f=null,d.textContent=t?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Lt(e,o);else if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(f=null,d.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!v?d.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":n==="COMMAND_PENDING"?d.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":d.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else d.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Lt(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";y.hidden=f===null,Ke=d.textContent,t&&ae===void 0&&!L?.responsive&&d.scrollIntoView?.({block:"nearest"}),z(t&&x?.quoteError?x.quoteError:a.onError,e)},Be=new WeakMap;function je(e){fe=e,y.disabled=e,ce.disabled=e,O?.updateCapabilities?.(oe(u),Ce(u));for(let t of de?.querySelectorAll("button")??[])e?(Be.has(t)||Be.set(t,t.disabled),t.disabled=!0):Be.has(t)&&(t.disabled=Be.get(t),Be.delete(t)),Ut(t)}function Zt(){Q&&(d.textContent=Q.message,y.textContent=o?"重试":"Retry",y.disabled=!1,y.hidden=!Q.retry,ce.disabled=!0)}function kt(){d.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}async function $n(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof Nt?(v=null,xe=!1,Re=!1,f=null):f=e,t}}async function j(e,t){if(fe||w||Q)return;if(!I()){kt();return}let n=e===qe,r=n?_n:Dn;ae=t!==void 0&&O?.updateCheckoutControls?t:void 0,d.textContent=r,je(!0),ve(),y.hidden=!0;try{if(e!==on&&e!==It&&e!==Et&&e!==Je&&(e!==et||!a.resumeCheckout)&&await $n(e),w||Q)return;if(!I()){f=e,y.hidden=!1,kt();return}await e()}catch(s){w||we(s,n)}finally{ae=void 0,je(!1),ve(),Q?Zt():d.textContent===r&&(d.textContent="")}}async function en(e){await Tn(le,e,a)}function Te(e,t){C=t?{quote:e,phase:t}:void 0,t==="checking"?(ae??=v?.actionId??Gt(u)[0],d.textContent=gt,f=It,y.textContent=o?"查询状态":"Check status",y.hidden=!0):ae=void 0,O?.updateCapabilities(oe(u),Ce(u)),ve()}function tn(e){return e instanceof k&&(e.code==="COMMAND_PENDING"||e.reason==="RESULT_UNKNOWN"||e.code==="NETWORK_ERROR"||e.code==="TIMEOUT"||e.status===429||(e.status??0)>=500)}function nn(e,t){Dt(e,{...t,featureQuantities:t.featureQuantities??{}},"Purchase operation changed")}async function It(){C&&await ke(C.quote)}async function ke(e,t){Te(e,"checking"),Ke="";let n=1e3;Ve=!0,z(a.onObservationChange,!0);try{for(let r=t;I();r=void 0){if(!r){try{r=await i.read()}catch(s){if(!tn(s))throw s}if(!I())return}if(r){nn(r,e);let s=R(r);if(s.type==="checkout"){Te(e,"payment"),d.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",y.hidden=!1;return}if(s.type==="complete"){Te(e,"complete"),f=null;let c=u.capabilities.plans[e.productVersionId]?.name,l=e.merchantTerms?.subscriptionTerms?.items,m=l?.length===1?l[0].interval:void 0,h=m==="year"?o?"年付":"annual billing":m==="month"?o?"月付":"monthly billing":null;d.textContent=c?o?`已升级到 ${c}${h?" "+h:""}。`:`Upgraded to ${c}${h?" ("+h+")":""}.`:o?"已成功升级。":"Plan upgraded.",await en(r);return}if(s.type==="native"&&!_e(r)){Te(e),v=null,f=null,d.textContent=o?"付款没有成功,套餐未变更。请检查付款方式后重新选择套餐。":"Your payment didn’t go through, so your plan is unchanged. Check your payment method, then choose a plan again.",y.textContent=o?"重试":"Retry";return}if(r.problem&&!["RESULT_UNKNOWN","STATE_CHANGED"].includes(r.problem.reason??""))throw new k(r.problem.code,o?"暂时无法完成升级。":"The upgrade needs attention.",void 0,void 0,r.problem)}await Ye(n,p,Z.signal),n=Math.min(n*1.5,15e3)}}finally{Ve=!1,z(a.onObservationChange,!1)}}async function Et(){let e=C?.quote;if(!e)return;let t=await i.read();if(nn(t,e),R(t).type!=="checkout")return ke(e,t);if(a.resumeCheckout){await a.resumeCheckout(t.operationId);return}He.delete(t.operationId),await Qe(t)}function rn(e){return Ot(i).type==="recording"||R(e).type==="recording"}function an(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],r=t?t.totalMinor:_(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),s=t?n.length===1&&n[0]?.amountMinor===r&&n[0]:!_(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],c=r===null?be(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):be(r,e.currency)+(s?Ue(s.interval,o?"zh-CN":"en",s.intervalCount??1):""),l=_(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(m=>m.productName).join(", ");return{label:l?`${l} · ${c}`:c,recurring:s}}async function V(e,t=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!I()){f=async()=>V(await i.read()),y.hidden=!1;return}let n=e.quote??i.quote;if(yt(n)&&(e.confirmedAt||e.merchantExecution))return ke(n,e);if(d.textContent=Sn(e.status,o),rn(e)){let h=e.merchantExecution?.recordingStatus==="failed";d.textContent=h?o?"付款和商户处理已完成,但交易记录失败。请联系商户修复,勿重复购买。":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"付款和商户处理已完成,正在确认交易记录。请勿重复购买。":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=o?"查询记录":"Check recording",f=async()=>V(await i.read()),y.hidden=!1;return}if(e.problem&&R(e).type!=="native"){let h=e.problem;f=Oe,y.textContent=o?"检查并恢复原操作":"Check and recover original purchase",we(new k(h.code,h.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":h.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":h.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":h.code==="NOT_CONFIGURED"?o?"付款服务连接需要处理,请联系商户后恢复原操作。":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"原购买操作需要处理,请查询或恢复此操作。":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,h));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(d.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&R(e).type==="complete"){f=null,await en(e);return}if(!_e(e)&&R(e).type!=="fulfillment"){if(i.canReselect===!1){d.textContent=o?"正在核对原购买结果":"Checking the original purchase result",y.textContent=o?"查询结果":"Check result",f=async()=>V(await i.read()),y.hidden=!1;return}e.status==="cancelled"?d.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(d.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),y.textContent=o?"重试":"Retry",f=null,v=null;return}if(!t&&R(e).type==="checkout"){if(B){Jt();return}if(ye()){d.textContent="",nt=!1,f=null,y.hidden=!0,O?.updateCapabilities?.(oe(u),Ce(u)),ve();return}let h=i.quote,E=h?.operationId===e.operationId?an(h).label:"";d.textContent=nt?E?o?`${E} 尚未付款。再次选择该方案即可继续付款。`:`${E} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",nt=!1,f=null;return}await Qe(e);let r=Date.now(),s=r+6e5,c=2e3,l=R(e).type!=="checkout",m=()=>l&&Date.now()-r<15e3;Ve=!0,z(a.onObservationChange,!0);try{for(;!w&&Date.now()<s;){if(await Ye(m()?700:c,p,Z.signal),w)return;if(!I()){f=async()=>V(await i.read()),y.hidden=!1;return}let h=await i.read();if(R(h).type==="checkout"&&(l=!1),!t&&R(h).type==="checkout"){await V(h,!1);return}if(!h.problem&&_e(h)&&await Qe(h),!_e(h)||h.problem||rn(h)){await V(h);return}m()||(c=Math.min(c*1.5,3e4))}}finally{Ve=!1,z(a.onObservationChange,!1)}f=async()=>V(await i.read()),y.hidden=!1}async function xt(e=!1){let t=await i.read();if(w)return;if(!I()){f=()=>xt(e),y.hidden=!1;return}let n=i.quote;if(n&&Dt(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(it(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(it(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await Oe():f=null;return}setTimeout(sn,0,n);return}await V(t,e||void 0)}async function on(){await xt()}async function Hn(e){d.textContent=gt;let t=Date.now()+12e3;for(;!w&&Date.now()<t&&(await Ye(1500,p,Z.signal),!(w||!I()));){let n;try{n=await i.read()}catch{break}if(n.problem?.reason!=="RESULT_UNKNOWN")return n}return e}async function Oe(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Kt();let e=i.quote;if(yt(e)){Te(e,"checking");let n;try{n=await i.confirm()}catch(r){if(!tn(r))throw r;return ke(e)}return ke(e,n)}f=Oe;let t=await i.confirm();if(!I()){f=Oe,y.hidden=!1;return}if(t.problem?.reason==="RESULT_UNKNOWN"&&(t=await Hn(t)),t.problem){await V(t);return}if(_e(t)){if(R(t).type==="checkout")await Qe(t);else if(t.execution&&t.execution.provider!=="merchant"||"nativePurchase"in t&&t.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:t,signal:Z.signal})}}f=async()=>V(await i.read()),await V(t,!0)}function sn(e){if(w)return;de?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());d.textContent=t?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),r=p.createElement("button"),s=p.createElement("button"),c=p.createElement("div"),l=p.createElement("p"),m=e.merchantTerms,h=o?"zh-CN":"en",E=m?.subscriptionTerms?.items??[],q=m?m.subscriptionTerms?.trial?.days:_(e)?void 0:e.lines.find(g=>g.trial)?.trial?.days,G=_(e)?m?m.totalMinor:e.totalMinor:q===void 0?null:m?m.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(g=>g.trial)?0:null,Ne=(g,P)=>o?`${P} 天试用结束后 ${g}`:`Then ${g} after the ${P}-day trial`,{label:X,recurring:De}=an(e),St=_(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(g=>g.productName).join(", "),un=G===null?"":`${o?"今天应付":"Due today"} ${be(G,e.currency)}`;l.textContent=un?[St,un].filter(Boolean).join(" · "):X,r.textContent=_(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=t,s.textContent=o?"取消":"Cancel",n.style.cssText=D.panel,l.style.cssText=D.summary,c.style.cssText=D.actions,r.style.cssText=D.primary,s.style.cssText=D.secondary,Ut(r),r.onclick=()=>{j(Oe)};let dn=async()=>{let g=await i.cancel();w||(n.remove(),de=null,await V(g))};s.onclick=()=>{f=dn,j(dn)};let Y=p.createElement("div");if(Y.style.cssText=D.terms,_(e)){for(let[P,S]of Object.entries(e.featureQuantities??{})){let $=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(Qn=>Qn.internalFeatureId===P),rt=p.createElement("p");rt.textContent=`${$?.name??P} · ${S} ${o?"份":"packs"}${$?` × ${$.terms.units}`:""}`,Y.append(rt)}for(let[P,S]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",m?.discountMinor??e.discountMinor],[o?"税费":"Tax",m?m.taxMinor:e.taxMinor]]){let $=p.createElement("p");$.textContent=`${P}: ${S===null?o?"结账时确认":"Confirmed at checkout":be(S,e.currency)}`,Y.append($)}let g=p.createElement("p");g.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,Y.append(g)}if(m){for(let P of E){if(G===null&&P===De)continue;let S=p.createElement("p"),$=be(P.amountMinor,e.currency)+Ue(P.interval,h,P.intervalCount);S.textContent=G!==null&&q!==void 0?Ne($,q):$,P.amountAfterOfferMinor!==void 0&&(S.textContent+=` · ${o?"优惠结束后":"After the offer"} ${be(P.amountAfterOfferMinor,e.currency)}${Ue(P.interval,h,P.intervalCount)}`),Y.append(S)}let g=m.subscriptionTerms?.trial;if(g){let P=p.createElement("p");P.textContent=o?`试用 ${g.days} 天;${g.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.days}; ${g.cardRequired?"a payment method is required":"no payment method is required"}`,Y.append(P)}for(let P of[...m.expectedEffects.map(S=>S.description),...m.requiredConsents.map(S=>S.summary)]){let S=p.createElement("p");S.textContent=P,Y.append(S)}}else if(!_(e)){for(let g of e.lines){if(G!==null||g!==De){let P=p.createElement("p"),S=`${be(g.catalogAmountMinor,e.currency)}${Ue(g.interval,h,g.intervalCount??1)}`;P.textContent=G!==null&&g.trial?(e.lines.length>1?`${g.productName} · `:"")+Ne(S,g.trial.days):`${g.productName} · ${S}`,Y.append(P)}for(let P of g.prepaid??[]){let S=p.createElement("p"),$=i.view?.capabilities.plans[g.productVersionId]?.prepaid?.find(rt=>rt.internalFeatureId===P.internal_feature_id);S.textContent=`${$?.name??P.internal_feature_id} · ${P.quantity} ${o?"份":"packs"} × ${P.terms.units}`,$&&(S.textContent+=Ue($.reset==="week"||$.reset==="month"||$.reset==="year"?$.reset:"one_time",h,$.resetCount)),Y.append(S)}if(g.trial){let P=p.createElement("p");P.textContent=o?`试用 ${g.trial.days} 天;${g.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.trial.days}; ${g.trial.cardRequired?"a payment method is required":"no payment method is required"}`,Y.append(P)}}if(!e.charge){let g=p.createElement("p");g.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",Y.append(g)}}for(let g of Y.children)g.style.margin="0";c.append(r,s),n.append(l,...Y.childElementCount?[Y]:[],c),W.prepend(n),L?.responsive||n.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),de=n,fe&&je(!0),f=null}async function qe(){if(!v)return;if(f=qe,!xe){let n=i.view,r=n?.document.buttons[v.actionId],s=n&&r?.type==="checkout"?Ee(r.product,v.selection,n.capabilities):null;if(!n||!s)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!Re){let l=Ft(),m=l?await l.result:void 0;if(w)return;let h=a.resolveSubscriptionChange;if(h||m){let E={actionId:v.actionId,productVersionId:s,featureQuantities:Le(n.document.screen,s,v.selection,n.capabilities)},q=m?[async()=>m(E)]:[],G=h?await h(E,...q):await q[0]?.();if(w)return;G!==void 0&&(v.subscriptionChange=fn.parse(G))}Re=!0}let c=J?.offerId;if(J&&!c){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await a.claimCoupon(J.id,v.requestId);if(w)return;if(!l||l.couponId!==J.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw v=null,J=void 0,f=async()=>{$e(await i.refresh()),f=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");c=l.id}if(!J&&!n.document.screen.actions.some(l=>l.id===v?.actionId&&typeof l.properties.couponBinding=="string")&&(c=await a.resolveOfferId?.({actionId:v.actionId,productVersionId:s,featureQuantities:Le(n.document.screen,s,v.selection,n.capabilities)})),w)return;c!==void 0&&(v.offerId=c),xe=!0}if(!I()){y.hidden=!1;return}let e;try{e=await i.preview(v)}catch(n){throw i.canReselect===!0&&(v=null,xe=!1,Re=!1,J=void 0,f=null),n}if(J&&(_(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==J.id||n.grantId!==v.offerId})():e.discount?.couponId!==J.id||e.discount.offerId!==v.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let t=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&I()&&!_(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!I()){y.hidden=!1;return}if(!(Date.parse(e.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");let n=ae?"":o?"正在打开收银台…":"Opening checkout…";d.textContent=n;try{await Oe()}catch(r){w||we(r)}finally{d.textContent===n&&(d.textContent="")}return}sn(e)}function Ie(e="destroy",t=!1){if(w)return;w=!0;let n=pt;pt=void 0,z(n),a.signal?.removeEventListener("abort",se),i.signal?.removeEventListener("abort",se),M.finish("dismissed"),Vt?.(),Pt(),p.removeEventListener("visibilitychange",Wt),Z.abort(),Mt?.disconnect(),O?.destroy(),i.destroy(),A.removeEventListener("cancel",cn),N.remove(),U.remove(),t||ln(),e==="dismiss"&&z(a.onDismiss)}function ln(){if(L?.destroy(),ue){ue.release();return}A.open&&A.close(),A.remove(),T()}F=Ie;async function Fe(){if(!he||w||ze||ie==="closing"||!ie&&!I())return;if(!x){Ie("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=p.createElement("div"),me.style.cssText=W.style.cssText,W.replaceWith(me),pe.inert=!0),N.hidden=!1,me.replaceChildren(e,N),ie="closing",N.setAttribute("aria-disabled","true"),N.focus({preventScroll:!0});try{await x.dismiss()}catch(t){w||z(a.onError,t)}w||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",N.textContent=o?"重试关闭":"Retry closing",N.removeAttribute("aria-label"),N.removeAttribute("aria-disabled"))}N.onclick=()=>{Fe()};function cn(e){e.preventDefault(),Fe()}A.addEventListener("cancel",cn),ce.onclick=()=>{j(C?Et:et)},y.onclick=()=>{if(Q){Q.retry?.();return}f&&j(f)};function Rt(e){M.finish("error",e),Ie()}function At(){if(!(!Qt||he||w||ze||L&&!I()))try{let e=t=>{a.focusAtReveal&&(T=_t(p)),a.settleMotionAtReveal?O?.setHidden?.(!1,!0):O?.setHidden?.(!1),ft?.(),L&&(A.open||A.showModal(),L.responsive&&A.focus({preventScroll:!0}),!t&&a.loading!=="host"&&Cn(A,L.type,L.responsive)),t&&a.loading!=="host"&&typeof pe.animate=="function"&&!p.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),he=!0,Xe()};x?x.present(t=>M.present(n=>e(t??n))):M.present(e)}catch(e){Rt(e),we(e)}}try{if(Me.type==="inline"?(ct(),ft=xn(U,H),H.append(U)):(A.setAttribute("aria-label",u.document.name),N.textContent="×",N.setAttribute("aria-label",o?"关闭":"Close"),Pn(N,u.document.screen.theme),N.hidden=gn(u.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ue?.content?ue.content.append(N,U):A.replaceChildren(N,U),ue||H.append(A),L=bn(A,{...u.document.screen,presentation:Me},dt),L.latch(),L.responsive&&(U.style.display="flex",U.style.flexDirection="column",U.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ue||(ft=En(A))),st&&ee){let n=st(ee);if(typeof n=="function"&&(w?z(n):pt=n),w)throw new DOMException("Presentation cancelled","AbortError");ct()}O=ne(pe,{mode:"live",rendererUrl:"bundled",title:u.document.name,closeActions:Un,onAuthoredClose(n){ie||w||(N.hidden=n)},hostPresentation:()=>L?.type??Me.type,reportContentHeight:L?.responsive,onResize:n=>{if(!L?.responsive)return;let r=Math.min(n,ut);pe.style.height=`${r}px`,L.setContentHeight(r+Ht())},onSelection(n){for(let[r,s]of Object.entries(n))typeof s=="number"&&typeof K[r]=="number"&&K[r]!==s&&Bt.add(r);K=n,ve(),Xe()},onAction(n,r={},s,c){if(!he||w||ie)return;let l=i.view,m=l?.document.buttons[n];if(!m)return;if(Q){m.type==="close"&&Fe();return}if(m.type==="close"&&x&&a.resumeCheckout&&i.operation&&mn(R(i.operation))){Fe();return}if(fe)return;if(!I()){kt();return}if(m.type==="close"){j(async()=>{x?.closeAction?await x.closeAction(n):await a.onAction?.(n),Ie(a.onAction?"action":"dismiss")});return}if(m.type==="action"){f=async()=>{if(m.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(m.action.event)}else a.onOpenUrl?await a.onOpenUrl(m.action.url):p.defaultView?.location.assign(m.action.url);await a.onAction?.(n),f=null},j(f);return}if(ye()&&B){!ge&&B.selection.actionId===n&&j(()=>tt(!0),n);return}if(C){if(C.phase==="payment"&&l&&Se(C.quote,l,n,m.product,r,c)){j(Et,n);return}if(!bt())return}if(!Pe()&&!bt()){ye()&&l&&i.quote&&i.operation&&R(i.operation).type==="checkout"&&Se(i.quote,l,n,m.product,r,c)?j(et,n):d.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(de&&i.canReselect===!1){d.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",L?.responsive||de.scrollIntoView?.({block:"nearest"}),de.querySelector("button")?.focus({preventScroll:!0});return}if(ye()&&a.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&R(i.operation).type==="checkout"){if(Se(i.quote,l,n,m.product,r,c)){j(et,n);return}let E=Ee(m.product,r,l.capabilities),q;try{if(!E)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");q=Le(l.document.screen,E,r,l.capabilities)}catch(De){we(De);return}let G=i.operation.operationId,Ne={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(r)},X=vt(l,n,E,r,c);j(()=>Xt(G,Ne,X,{actionId:n,productVersionId:E,selection:Ne.selection,featureQuantities:q}),n);return}if((i.quote||v)&&i.canReselect===!1){let E=!!l&&!!i.quote&&Se(i.quote,l,n,m.product,r,c);nt=!!i.quote&&!E,f=i.quote?()=>xt(E):qe,j(f,n);return}let h=l&&Ee(m.product,r,l.capabilities);if(!l||!h){we(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){f=null,j(async()=>{let E={actionId:n,productVersionId:h,selection:structuredClone(r),featureQuantities:Le(l.document.screen,h,r,l.capabilities)};ht=!0,await a.onPurchaseIntent(E)},n);return}if(v&&v.actionId!==n){we(new k("COMMAND_PENDING","Finish the current purchase"));return}v||(J=vt(l,n,h,r,c),v={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(r)},xe=!1,Re=!1),j(qe,n)},onEscape:()=>{Fe()},onError:n=>{let r=new Error(n);!he&&!w&&Rt(r),we(r)},onRendered:n=>{n&&A.setAttribute("aria-label",n),Qt=!0,At()}}),O.setHidden?.(!0),dt();let e=ye()&&!!i.quote&&!!i.operation&&R(i.operation).type==="checkout";K=i.quote?Nn(u,i.quote)??at(u,{}):at(u,{}),O.update(u.document.screen,lt,{capabilities:oe(u),unavailableActions:Ce(u),serverInput:{bindings:[],answers:{}},...Object.keys(K).length?{selection:K}:{}}),Vt=i.subscribe?.($e),$e(i.view??u),await M.wait(O.ready);let t=i.operation;(!e||yt(i.quote))&&(i.quote||t&&(t.confirmedAt||t.checkoutUrl||Ge(t)))&&(f=on,j(f))}catch(e){throw Rt(e),e}return{check:le,host:{get currentResolution(){return u},setPurchaseRecovery(e,t){Q={message:e,retry:t},O?.updateCapabilities?.(oe(u),Ce(u)),ve(),Zt()},get subscriptionUpgradeActive(){return C!==void 0},get observing(){return Ve},get recovery(){return Ln()},async prepareFallback(){if(fe||w||ie||ht)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await yn(i);return e.type==="native"&&Ie(),e}finally{je(!1)}},setSuspended(e){ze=e,U.hidden=e,e&&A.open?A.close():!e&&!he?At():!e&&!w&&he&&Me.type!=="inline"&&!A.open&&A.showModal()},destroy:Ie,retainPurchaseDialog(){if(!(w||!A.open||!A.isConnected))return Ie("destroy",!0),{dialog:A,content:ue?.content,release:ln}},refresh:async()=>{if(!I()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return $e(e),At(),e}}}}export{Pr as a};
@@ -1 +1 @@
1
- import{b as r}from"./chunk-35JZDDF3.js";var R=r.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),H=r.enum([...R.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED","SENSITIVE_OUTPUT_REQUIRED"]),j=r.enum([...R.options,"stale_revision"]),v=r.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),x=r.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED","FUNNEL_PAUSED"]),L={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var S={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",CUSTOMER_SESSION_REQUIRED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",PURCHASE_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",PURCHASE_STORAGE_CONFLICT:"resolve_conflict",PURCHASE_STORAGE_INVALID:"recover_operation",EXECUTION_POLICY_REFUSED:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",ROUTE_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",COUPON_UNAVAILABLE:"reload_state",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function g(e,o){if(e==="CONFLICT"&&o===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&o===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION"||e==="SENSITIVE_OUTPUT_REQUIRED")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(S,e)){let n=S[e];return{retryable:n==="retry_same_request",recovery:n}}let t=R.safeParse(e);return t.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:L[t.data].recovery}:{retryable:!1,recovery:"contact_support"}}function Q(e,o){let t=R.safeParse(e);if(t.success)return e==="CONFLICT"?[409,412,425].includes(o):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(o):e==="INVALID_REQUEST"?[400,405,415,422].includes(o):e==="NOT_CONFIGURED"?[501,503].includes(o):L[t.data].status===o;let n={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],SENSITIVE_OUTPUT_REQUIRED:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(n,e)&&(n[e]?.includes(o)??!1)}function P(e,o=Date.now()){if(e===null)return;let t=e.trim();if(/^\d+$/.test(t)){let s=Number(t);return Number.isSafeInteger(s)?s:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(t))return;let n=Date.parse(t);return Number.isFinite(n)?Math.max(0,Math.ceil((n-o)/1e3)):void 0}var y=r.object({retryable:r.boolean(),recovery:v,reason:x.optional(),retryAfterSeconds:r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),b=r.object({requestId:r.uuid().optional(),error:r.object({code:r.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:r.string(),...y.partial().shape})}),z=r.object({error:b.shape.error.extend({requestId:r.uuid().optional()})}),Y=r.object({error:r.string(),code:r.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:r.uuid(),...y.shape});function $(e,o,t={}){let n=g(e,o),s=t.reason==="RESULT_UNKNOWN"?"recover_operation":t.recovery??n.recovery,A=n.retryable&&t.retryable!==!1&&s!=="recover_operation",i=A?P(t.retryAfter??null):void 0;return{...n,retryable:A,recovery:s,...i===void 0?{}:{retryAfterSeconds:i},...t.reason?{reason:t.reason}:{}}}var V=r.enum(["sandbox","live"]),W=r.object({projectId:r.string().min(1),environment:V}).strict();var J=r.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),u=r.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),M=r.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let o=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return o==="-0"?"0":o}),p=u.refine(e=>/[1-9]/.test(e),"数量必须大于 0"),D=r.string().min(1).max(64),B=r.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),C=r.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),ee=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()])).refine(e=>Object.keys(e).length<=16,"最多 16 个计价属性").transform(e=>Object.fromEntries(Object.entries(e).map(([o,t])=>[o,String(t)]))),U=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"匹配条件最多 8 个属性"),I=e=>{let o=e.startsWith("-");o&&(e=e.slice(1));let[t,n=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");let s=BigInt(t)*BigInt("1000000")+BigInt(n.padEnd(6,"0"));return o?-s:s},h=r.array(r.object({upTo:p.nullable(),cost:u}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((o,t)=>{let n=e[t-1]?.upTo;return o.upTo!==null&&(t===0||n!=null&&I(o.upTo)>I(n))}),"阶梯上限必须递增,最后一档为无限"),G=r.object({key:C,match:U,priority:r.number().int().default(0),cost:u.optional(),tiers:h.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"维度需要指定单价或阶梯"),F=r.object({key:C,match:U,factor:p.optional(),add:M.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),k=r.object({units:p.default("1"),cost:u,tiers:h.optional(),dimensions:r.array(G).max(12).optional(),multipliers:r.array(F).max(4).optional()}).strict().superRefine((e,o)=>{let t=e.dimensions??[],n=e.multipliers??[];(new Set(t.map(i=>i.key)).size!==t.length||new Set(n.map(i=>i.key)).size!==n.length)&&o.addIssue({code:"custom",message:"维度和倍率的 ID 不能重复"});for(let[i,a]of t.entries())for(let c of t.slice(i+1))Object.keys(a.match).length===Object.keys(c.match).length&&a.priority===c.priority&&!Object.keys(a.match).some(E=>c.match[E]!==void 0&&c.match[E]!==a.match[E])&&o.addIssue({code:"custom",message:"维度可能同时匹配,请调整优先级"});let s=[e.cost,...(e.tiers??[]).map(i=>i.cost),...t.flatMap(i=>[...i.cost===void 0?[]:[i.cost],...(i.tiers??[]).map(a=>a.cost)])],A=I(e.units);for(let i of s)for(let a=0;a<1<<n.length;a++){let c=n.filter((N,_)=>a&1<<_);if(c.some((N,_)=>c.slice(_+1).some(d=>Object.keys(N.match).some(l=>d.match[l]!==void 0&&d.match[l]!==N.match[l]))))continue;let E=I(i),O=BigInt("1"),f=BigInt("0");for(let[N,_]of n.entries())a&1<<N&&(E*=I(_.factor??"1"),O*=BigInt("1000000"),f+=I(_.add??"0"));let T=(E+f*O)*BigInt("1000000"),m=O*A;(T<BigInt("0")||T%m!==BigInt("0")||T/m>BigInt("999999999999999999"))&&o.addIssue({code:"custom",message:"每个业务单位的最终单价必须非负、在范围内且能精确表示为最多 6 位小数"})}}),re=k.safeExtend({featureKey:B});export{R as a,v as b,x as c,Q as d,b as e,$ as f,V as g,W as h,J as i,u as j,M as k,B as l,ee as m};
1
+ import{b as r}from"./chunk-7RUOZL6C.js";var R=r.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),H=r.enum([...R.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED","SENSITIVE_OUTPUT_REQUIRED"]),j=r.enum([...R.options,"stale_revision"]),v=r.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),x=r.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED","FUNNEL_PAUSED"]),L={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var S={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",CUSTOMER_SESSION_REQUIRED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",PURCHASE_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",PURCHASE_STORAGE_CONFLICT:"resolve_conflict",PURCHASE_STORAGE_INVALID:"recover_operation",EXECUTION_POLICY_REFUSED:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",ROUTE_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",COUPON_UNAVAILABLE:"reload_state",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function g(e,o){if(e==="CONFLICT"&&o===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&o===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION"||e==="SENSITIVE_OUTPUT_REQUIRED")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(S,e)){let n=S[e];return{retryable:n==="retry_same_request",recovery:n}}let t=R.safeParse(e);return t.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:L[t.data].recovery}:{retryable:!1,recovery:"contact_support"}}function Q(e,o){let t=R.safeParse(e);if(t.success)return e==="CONFLICT"?[409,412,425].includes(o):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(o):e==="INVALID_REQUEST"?[400,405,415,422].includes(o):e==="NOT_CONFIGURED"?[501,503].includes(o):L[t.data].status===o;let n={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],SENSITIVE_OUTPUT_REQUIRED:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(n,e)&&(n[e]?.includes(o)??!1)}function P(e,o=Date.now()){if(e===null)return;let t=e.trim();if(/^\d+$/.test(t)){let s=Number(t);return Number.isSafeInteger(s)?s:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(t))return;let n=Date.parse(t);return Number.isFinite(n)?Math.max(0,Math.ceil((n-o)/1e3)):void 0}var y=r.object({retryable:r.boolean(),recovery:v,reason:x.optional(),retryAfterSeconds:r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),b=r.object({requestId:r.uuid().optional(),error:r.object({code:r.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:r.string(),...y.partial().shape})}),z=r.object({error:b.shape.error.extend({requestId:r.uuid().optional()})}),Y=r.object({error:r.string(),code:r.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:r.uuid(),...y.shape});function $(e,o,t={}){let n=g(e,o),s=t.reason==="RESULT_UNKNOWN"?"recover_operation":t.recovery??n.recovery,A=n.retryable&&t.retryable!==!1&&s!=="recover_operation",i=A?P(t.retryAfter??null):void 0;return{...n,retryable:A,recovery:s,...i===void 0?{}:{retryAfterSeconds:i},...t.reason?{reason:t.reason}:{}}}var V=r.enum(["sandbox","live"]),W=r.object({projectId:r.string().min(1),environment:V}).strict();var J=r.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),u=r.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),M=r.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let o=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return o==="-0"?"0":o}),p=u.refine(e=>/[1-9]/.test(e),"数量必须大于 0"),D=r.string().min(1).max(64),B=r.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),C=r.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),ee=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()])).refine(e=>Object.keys(e).length<=16,"最多 16 个计价属性").transform(e=>Object.fromEntries(Object.entries(e).map(([o,t])=>[o,String(t)]))),U=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"匹配条件最多 8 个属性"),I=e=>{let o=e.startsWith("-");o&&(e=e.slice(1));let[t,n=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");let s=BigInt(t)*BigInt("1000000")+BigInt(n.padEnd(6,"0"));return o?-s:s},h=r.array(r.object({upTo:p.nullable(),cost:u}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((o,t)=>{let n=e[t-1]?.upTo;return o.upTo!==null&&(t===0||n!=null&&I(o.upTo)>I(n))}),"阶梯上限必须递增,最后一档为无限"),G=r.object({key:C,match:U,priority:r.number().int().default(0),cost:u.optional(),tiers:h.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"维度需要指定单价或阶梯"),F=r.object({key:C,match:U,factor:p.optional(),add:M.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),k=r.object({units:p.default("1"),cost:u,tiers:h.optional(),dimensions:r.array(G).max(12).optional(),multipliers:r.array(F).max(4).optional()}).strict().superRefine((e,o)=>{let t=e.dimensions??[],n=e.multipliers??[];(new Set(t.map(i=>i.key)).size!==t.length||new Set(n.map(i=>i.key)).size!==n.length)&&o.addIssue({code:"custom",message:"维度和倍率的 ID 不能重复"});for(let[i,a]of t.entries())for(let c of t.slice(i+1))Object.keys(a.match).length===Object.keys(c.match).length&&a.priority===c.priority&&!Object.keys(a.match).some(E=>c.match[E]!==void 0&&c.match[E]!==a.match[E])&&o.addIssue({code:"custom",message:"维度可能同时匹配,请调整优先级"});let s=[e.cost,...(e.tiers??[]).map(i=>i.cost),...t.flatMap(i=>[...i.cost===void 0?[]:[i.cost],...(i.tiers??[]).map(a=>a.cost)])],A=I(e.units);for(let i of s)for(let a=0;a<1<<n.length;a++){let c=n.filter((N,_)=>a&1<<_);if(c.some((N,_)=>c.slice(_+1).some(d=>Object.keys(N.match).some(l=>d.match[l]!==void 0&&d.match[l]!==N.match[l]))))continue;let E=I(i),O=BigInt("1"),f=BigInt("0");for(let[N,_]of n.entries())a&1<<N&&(E*=I(_.factor??"1"),O*=BigInt("1000000"),f+=I(_.add??"0"));let T=(E+f*O)*BigInt("1000000"),m=O*A;(T<BigInt("0")||T%m!==BigInt("0")||T/m>BigInt("999999999999999999"))&&o.addIssue({code:"custom",message:"每个业务单位的最终单价必须非负、在范围内且能精确表示为最多 6 位小数"})}}),re=k.safeExtend({featureKey:B});export{R as a,v as b,x as c,Q as d,b as e,$ as f,V as g,W as h,J as i,u as j,M as k,B as l,ee as m};
@@ -1 +1 @@
1
- import{d as t}from"./chunk-O273JQ7U.js";async function u(e,n){try{let{route:r}=await e.funnelRoute(n.funnelId),a=t(r,{customerId:n.customerId,parameters:n.parameters??{}});return{funnelId:n.funnelId,...a}}catch(r){return{funnelId:n.funnelId,type:"unavailable",reason:r?.code?.toLowerCase()??"error",path:[]}}}function l(e){switch(e.type){case"paywall":return null;case"screen":return`first_screen_${e.surface}`;case"external_page":return"first_screen_external_page";case"end":return`route_end_${e.outcome}`;case"unknown":return`route_unknown_${e.reason}`;case"unavailable":return e.reason.startsWith("route_")?e.reason:`route_${e.reason}`}}async function s(e,n){if(n.type!=="paywall")return null;try{let{document:r}=await e.paywall(n.paywallId,n.paywallVersionId);return{presentation:r.presentation,screen:r.screen,buttons:r.buttons}}catch{return null}}export{u as a,l as b,s as c};
1
+ import{d as t}from"./chunk-QLMQI6SX.js";async function u(e,n){try{let{route:r}=await e.funnelRoute(n.funnelId),a=t(r,{customerId:n.customerId,parameters:n.parameters??{}});return{funnelId:n.funnelId,...a}}catch(r){return{funnelId:n.funnelId,type:"unavailable",reason:r?.code?.toLowerCase()??"error",path:[]}}}function l(e){switch(e.type){case"paywall":return null;case"screen":return`first_screen_${e.surface}`;case"external_page":return"first_screen_external_page";case"end":return`route_end_${e.outcome}`;case"unknown":return`route_unknown_${e.reason}`;case"unavailable":return e.reason.startsWith("route_")?e.reason:`route_${e.reason}`}}async function s(e,n){if(n.type!=="paywall")return null;try{let{document:r}=await e.paywall(n.paywallId,n.paywallVersionId);return{presentation:r.presentation,screen:r.screen,buttons:r.buttons}}catch{return null}}export{u as a,l as b,s as c};
@@ -1 +1 @@
1
- import{b as e}from"./chunk-35JZDDF3.js";var s=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,o=e.object({customerId:e.uuid(),sessionId:e.uuid(),accessToken:e.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:e.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:e.iso.datetime(),refreshExpiresAt:e.iso.datetime()});export{s as a,o as b};
1
+ import{b as e}from"./chunk-7RUOZL6C.js";var s=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,o=e.object({customerId:e.uuid(),sessionId:e.uuid(),accessToken:e.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:e.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:e.iso.datetime(),refreshExpiresAt:e.iso.datetime()});export{s as a,o as b};
@@ -1 +1 @@
1
- import{m as o}from"./chunk-XJTEGBPR.js";import{a as i}from"./chunk-HLK7L2RV.js";function m(t,e,n,r){if(!o(t,e)||n!==void 0&&e.observation&&e.observation.subject.customerId!==n||r!==void 0&&e.observation!==void 0&&(e.observation.subject.scope.projectId!==r.projectId||e.observation.subject.scope.environment!==r.environment))throw new i("INVALID_RESPONSE","The access requirement or Customer changed");return e}function d(t,e,n){if(t.requirement){if(!e)throw new i("INVALID_RESPONSE","The requested access check is missing");m(t.requirement,e,t.customerId,n)}}export{m as a,d as b};
1
+ import{m as o}from"./chunk-CWBL2S3A.js";import{a as i}from"./chunk-E4B7243C.js";function m(t,e,n,r){if(!o(t,e)||n!==void 0&&e.observation&&e.observation.subject.customerId!==n||r!==void 0&&e.observation!==void 0&&(e.observation.subject.scope.projectId!==r.projectId||e.observation.subject.scope.environment!==r.environment))throw new i("INVALID_RESPONSE","The access requirement or Customer changed");return e}function d(t,e,n){if(t.requirement){if(!e)throw new i("INVALID_RESPONSE","The requested access check is missing");m(t.requirement,e,t.customerId,n)}}export{m as a,d as b};