@tinkerlandai/longplay-sdk 0.10.26 → 0.10.27

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 (65) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/{chunk-PWQ5BHBJ.js → chunk-26YREQNF.js} +1 -1
  3. package/dist/{chunk-MYUYN7ZG.js → chunk-2GMWNOOE.js} +1 -1
  4. package/dist/{chunk-ECMWY3G2.js → chunk-2TQEJ6GM.js} +1 -1
  5. package/dist/{chunk-JAKOBECD.js → chunk-2ZPCWVFU.js} +1 -1
  6. package/dist/{chunk-GIV4FOOW.js → chunk-5M536ISX.js} +1 -1
  7. package/dist/{chunk-O4KXODTJ.js → chunk-5OJVM7Q4.js} +1 -1
  8. package/dist/{chunk-CZ3H2X7D.js → chunk-67JOPO63.js} +1 -1
  9. package/dist/{chunk-DCIGO3NJ.js → chunk-7CFSTOTX.js} +1 -1
  10. package/dist/{chunk-SMIO7OG5.js → chunk-AEERSTTW.js} +1 -1
  11. package/dist/{chunk-HMRIMJ5W.js → chunk-ANZB6OLR.js} +1 -1
  12. package/dist/{chunk-T4GTAH43.js → chunk-COMWJEMO.js} +1 -1
  13. package/dist/{chunk-UHI7SPHK.js → chunk-D4CDG535.js} +1 -1
  14. package/dist/{chunk-2MTTK3BT.js → chunk-DC7UHEC6.js} +1 -1
  15. package/dist/{chunk-G7NSECIG.js → chunk-EBXWLW4D.js} +1 -1
  16. package/dist/{chunk-C6JRUYKW.js → chunk-FB7X4MFC.js} +1 -1
  17. package/dist/{chunk-DOJE7VUR.js → chunk-G2QO6ZWP.js} +1 -1
  18. package/dist/{chunk-2KOQBV3Y.js → chunk-HWQVZL7I.js} +1 -1
  19. package/dist/{chunk-LPDUK7HT.js → chunk-LHOSUSTZ.js} +1 -1
  20. package/dist/{chunk-KRTX4QEH.js → chunk-LHXRT32T.js} +1 -1
  21. package/dist/{chunk-BZSKOOMM.js → chunk-LI4B43FT.js} +1 -1
  22. package/dist/{chunk-NMKZ724L.js → chunk-MBLWCMAI.js} +1 -1
  23. package/dist/{chunk-MWDR5FEU.js → chunk-MTKM26F7.js} +1 -1
  24. package/dist/{chunk-X7G7JMZ3.js → chunk-S4X6YX5D.js} +1 -1
  25. package/dist/{chunk-UBKD6VMS.js → chunk-S67P7ZQ6.js} +1 -1
  26. package/dist/{chunk-B5JHPPR4.js → chunk-SYQMGS6O.js} +1 -1
  27. package/dist/{chunk-5RXU57I5.js → chunk-TJMODHSS.js} +1 -1
  28. package/dist/{chunk-MRFBMFNK.js → chunk-VRCN5YLM.js} +1 -1
  29. package/dist/{chunk-6VY4PZZ6.js → chunk-VTZHKUZO.js} +1 -1
  30. package/dist/{chunk-3FPYCF7Z.js → chunk-WCKOWAIL.js} +1 -1
  31. package/dist/{chunk-CNIBGSVO.js → chunk-WKH23DZE.js} +1 -1
  32. package/dist/chunk-WPLSGFYT.js +1 -0
  33. package/dist/{chunk-DCCM7FYR.js → chunk-WU4SDY27.js} +1 -1
  34. package/dist/chunk-XBVJHXSP.js +1 -0
  35. package/dist/{chunk-PMCGTXGH.js → chunk-XZMM34BS.js} +1 -1
  36. package/dist/{chunk-YSNMXK4R.js → chunk-Z6RZQ5KJ.js} +1 -1
  37. package/dist/{content-UDP5VQS4.js → content-4V7YBP3O.js} +1 -1
  38. package/dist/{funnel-host-purchase-5NLPYJRK.js → funnel-host-purchase-LJYQF6AX.js} +1 -1
  39. package/dist/funnel-runtime-host-XWXG4SIU.js +1 -0
  40. package/dist/index.d.ts +3 -0
  41. package/dist/index.js +1 -1
  42. package/dist/merchant-bridge-contracts-OL3ME2AL.js +1 -0
  43. package/dist/openrouter.js +1 -1
  44. package/dist/operation-contracts-NJPUHGUM.js +1 -0
  45. package/dist/page.js +1 -1
  46. package/dist/paywall-INF4ZZ7J.js +1 -0
  47. package/dist/paywall-session-3JV2JMUI.js +1 -0
  48. package/dist/popup.js +1 -1
  49. package/dist/react-native.js +1 -1
  50. package/dist/screen-renderer-ZRSVFBLQ.js +1 -0
  51. package/dist/server.js +1 -1
  52. package/dist/{visual-dom-5LUN4AHO.js → visual-dom-CAOVBSVC.js} +1 -1
  53. package/dist/visual.js +1 -1
  54. package/package.json +9 -10
  55. package/dist/chunk-7CFF6SWH.js +0 -1
  56. package/dist/chunk-ORPOCB2J.js +0 -1
  57. package/dist/funnel-runtime-host-ZWUAGDBU.js +0 -1
  58. package/dist/merchant-bridge-contracts-N3Q4W6ZU.js +0 -1
  59. package/dist/operation-contracts-VURXKAFX.js +0 -1
  60. package/dist/paywall-QQ2MC4KO.js +0 -1
  61. package/dist/paywall-session-WC2WFWBQ.js +0 -1
  62. package/dist/screen-renderer-G2EWN3WB.js +0 -1
  63. /package/dist/{chunk-OJM6ORHE.js → chunk-D6SDVDXZ.js} +0 -0
  64. /package/dist/{chunk-CILM5XMH.js → chunk-QENDBHBQ.js} +0 -0
  65. /package/dist/{chunk-WM27UTWT.js → chunk-ZGBSTK22.js} +0 -0
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as pn}from"./chunk-ORPOCB2J.js";import{a as I}from"./chunk-ECMWY3G2.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-T4GTAH43.js";import{a as xt}from"./chunk-CZ3H2X7D.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-6VY4PZZ6.js";import"./chunk-2KOQBV3Y.js";import{a as Te,b as oe,c as yt,d as It,e as wt,f as xe,g as vt,h as _e,i as dn,j as ln,k as mn}from"./chunk-2MTTK3BT.js";import{a as Et,b as Me}from"./chunk-BZSKOOMM.js";import"./chunk-LPDUK7HT.js";import{A as Tt,C as V,D as N,a as Oe,e as ft,f as ht,l as gt,m as j,n as St,q as Ct,r as Rt,s as bt,t as At,u as Ot,z as pe}from"./chunk-UHI7SPHK.js";import{c as f}from"./chunk-G7NSECIG.js";import"./chunk-GIV4FOOW.js";import{e as at}from"./chunk-MYUYN7ZG.js";import{A as tt,B as Se,C as ae,E as ie,F as Ce,K as se,M as ce,N as nt,P as Ee,Q as rt,R as ot,d as Ge,e as je,h as we,p as ze,q as Ke,s as an,t as sn,w as cn,x as Q,y as J,z as re}from"./chunk-C6JRUYKW.js";import{A as Re,B as st,C as ct,H as ut,I as dt,J as be,K as Ae,S as pt,T as de,U as Y,V as lt,_ as mt,d as ve,f as Ze,g as et,u as q,z as it}from"./chunk-PMCGTXGH.js";import"./chunk-7CFF6SWH.js";import"./chunk-PWQ5BHBJ.js";import"./chunk-HMRIMJ5W.js";import"./chunk-NMKZ724L.js";import"./chunk-MWDR5FEU.js";import{a as Ne,b as Le}from"./chunk-UBKD6VMS.js";import{V as Xe,Y as We,la as ue,n as un,p as $e,q as Qe,r as Je}from"./chunk-5RXU57I5.js";import{c as Ie}from"./chunk-DOJE7VUR.js";import{a as c}from"./chunk-X7G7JMZ3.js";import{h as $}from"./chunk-JAKOBECD.js";import"./chunk-3VUPVXAV.js";import"./chunk-SMIO7OG5.js";import{b as u}from"./chunk-WM27UTWT.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var Mt=4,_t=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results"],In=u.enum(_t),X=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...ie.shape,bridgeVersion:u.literal(Mt),capabilities:X(In,_t.length),checkKinds:X(u.enum(["access","metered","credit"]),3),preparationActions:X(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:X(u.enum(["auto_topup"]),1),nextActionTypes:X(u.enum(["redirect","authenticate"]),2),resultEvents:X(u.enum(["benefit.claimed","authorization.updated"]),2)}).superRefine((e,n)=>{e.capabilities.includes("catalog")!==(e.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(e.capabilities.includes("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare unique supported billing events"});let t=r=>e.capabilities.includes(r),o=(r,a)=>n.addIssue({code:"custom",path:[r],message:a});t("requirement_checks")!==e.checkKinds.length>0&&o("checkKinds","Declare the supported Check kinds"),t("preparations")!==e.preparationActions.length>0&&o("preparationActions","Declare the supported preparation actions"),t("authorizations")!==e.authorizationKinds.length>0&&o("authorizationKinds","Declare the supported authorization kinds"),t("business_results")!==e.resultEvents.length>0&&o("resultEvents","Declare the supported non-financial results");for(let[r,a,s]of[["purchases","purchase","purchase.completed"],["subscription_changes","subscription_change","subscription.change.completed"],["refunds","refund","refund.updated"]])t(r)&&(!t("operation_status")||!t("billing_records")||!t("preparations")||!e.preparationActions.includes(a)||!e.billingEvents.includes(s))&&o("capabilities",`${r} requires preparation, original lookup and its billing result`);t("purchases")&&!e.billingEvents.includes("purchase.closed")&&o("billingEvents","Purchase execution requires its terminal closure result"),t("subscription_changes")&&!e.billingEvents.includes("subscription.change.closed")&&o("billingEvents","Subscription change execution requires its terminal closure result");for(let[r,a]of[["benefit_claims","benefit.claimed"],["authorizations","authorization.updated"]])t(r)&&(!t("operation_status")||!t("business_results")||!e.resultEvents.includes(a))&&o("capabilities",`${r} requires original lookup and its non-financial result`)}),W={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He},Hn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read"]);function Z(e,n){return u.strictObject({bridgeVersion:u.literal(Mt),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[Z("bridge.ping",W["bridge.ping"]),Z("bridge.describe",W["bridge.describe"]),Z("requirement.check",W["requirement.check"]),Z("operation.prepare",W["operation.prepare"]),Z("benefit.claim",W["benefit.claim"]),Z("operation.read",W["operation.read"])]),Be=u.strictObject({code:u.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:u.string().min(1).max(500),retryable:u.boolean(),recovery:u.string().min(1).max(80),effect:u.enum(["none","unknown"])}).refine(e=>e.effect!=="unknown"||!e.retryable&&e.recovery==="recover_operation","Unknown effects require original-operation recovery");function Bt(e){let n={bridgeVersion:u.literal(4),requestId:u.uuid(),scope:Ce,command:u.literal(e)};return u.union([u.strictObject({...n,data:wn[e]}),u.strictObject({...n,error:Be})])}var Pt="X-Indiana-Bridge-Signature",z="X-Indiana-Bridge-Key-Id";function vn(e){return new TextEncoder().encode(e)}function Dt(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),n=>n.charCodeAt(0))}function Ft(e,n,t,o){return vn(`indiana-merchant-bridge:${o}
1
+ import{a as pn}from"./chunk-WPLSGFYT.js";import{a as I}from"./chunk-2TQEJ6GM.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-COMWJEMO.js";import{a as xt}from"./chunk-67JOPO63.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-VTZHKUZO.js";import"./chunk-HWQVZL7I.js";import{a as Te,b as oe,c as yt,d as It,e as wt,f as xe,g as vt,h as _e,i as dn,j as ln,k as mn}from"./chunk-DC7UHEC6.js";import{a as Et,b as Me}from"./chunk-LI4B43FT.js";import"./chunk-LHOSUSTZ.js";import{A as Tt,C as V,D as N,a as Oe,e as ft,f as ht,l as gt,m as j,n as St,q as Ct,r as Rt,s as bt,t as At,u as Ot,z as pe}from"./chunk-D4CDG535.js";import{c as f}from"./chunk-EBXWLW4D.js";import"./chunk-5M536ISX.js";import{e as at}from"./chunk-2GMWNOOE.js";import{A as tt,B as Se,C as ae,E as ie,F as Ce,K as se,M as ce,N as nt,P as Ee,Q as rt,R as ot,d as Ge,e as je,h as we,p as ze,q as Ke,s as an,t as sn,w as cn,x as Q,y as J,z as re}from"./chunk-FB7X4MFC.js";import{A as Re,B as st,C as ct,H as ut,I as dt,J as be,K as Ae,S as pt,T as de,U as Y,V as lt,_ as mt,d as ve,f as Ze,g as et,u as q,z as it}from"./chunk-XZMM34BS.js";import"./chunk-XBVJHXSP.js";import"./chunk-26YREQNF.js";import"./chunk-ANZB6OLR.js";import"./chunk-MBLWCMAI.js";import"./chunk-MTKM26F7.js";import{a as Ne,b as Le}from"./chunk-S67P7ZQ6.js";import{V as Xe,Y as We,la as ue,n as un,p as $e,q as Qe,r as Je}from"./chunk-TJMODHSS.js";import{c as Ie}from"./chunk-G2QO6ZWP.js";import{a as c}from"./chunk-S4X6YX5D.js";import{h as $}from"./chunk-2ZPCWVFU.js";import"./chunk-3VUPVXAV.js";import"./chunk-AEERSTTW.js";import{b as u}from"./chunk-ZGBSTK22.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-5OJVM7Q4.js";import"./chunk-QENDBHBQ.js";import"./chunk-WOT6VMZA.js";var Mt=4,_t=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results"],In=u.enum(_t),X=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...ie.shape,bridgeVersion:u.literal(Mt),capabilities:X(In,_t.length),checkKinds:X(u.enum(["access","metered","credit"]),3),preparationActions:X(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:X(u.enum(["auto_topup"]),1),nextActionTypes:X(u.enum(["redirect","authenticate"]),2),resultEvents:X(u.enum(["benefit.claimed","authorization.updated"]),2)}).superRefine((e,n)=>{e.capabilities.includes("catalog")!==(e.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(e.capabilities.includes("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare unique supported billing events"});let t=r=>e.capabilities.includes(r),o=(r,a)=>n.addIssue({code:"custom",path:[r],message:a});t("requirement_checks")!==e.checkKinds.length>0&&o("checkKinds","Declare the supported Check kinds"),t("preparations")!==e.preparationActions.length>0&&o("preparationActions","Declare the supported preparation actions"),t("authorizations")!==e.authorizationKinds.length>0&&o("authorizationKinds","Declare the supported authorization kinds"),t("business_results")!==e.resultEvents.length>0&&o("resultEvents","Declare the supported non-financial results");for(let[r,a,s]of[["purchases","purchase","purchase.completed"],["subscription_changes","subscription_change","subscription.change.completed"],["refunds","refund","refund.updated"]])t(r)&&(!t("operation_status")||!t("billing_records")||!t("preparations")||!e.preparationActions.includes(a)||!e.billingEvents.includes(s))&&o("capabilities",`${r} requires preparation, original lookup and its billing result`);t("purchases")&&!e.billingEvents.includes("purchase.closed")&&o("billingEvents","Purchase execution requires its terminal closure result"),t("subscription_changes")&&!e.billingEvents.includes("subscription.change.closed")&&o("billingEvents","Subscription change execution requires its terminal closure result");for(let[r,a]of[["benefit_claims","benefit.claimed"],["authorizations","authorization.updated"]])t(r)&&(!t("operation_status")||!t("business_results")||!e.resultEvents.includes(a))&&o("capabilities",`${r} requires original lookup and its non-financial result`)}),W={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He},Hn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read"]);function Z(e,n){return u.strictObject({bridgeVersion:u.literal(Mt),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[Z("bridge.ping",W["bridge.ping"]),Z("bridge.describe",W["bridge.describe"]),Z("requirement.check",W["requirement.check"]),Z("operation.prepare",W["operation.prepare"]),Z("benefit.claim",W["benefit.claim"]),Z("operation.read",W["operation.read"])]),Be=u.strictObject({code:u.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:u.string().min(1).max(500),retryable:u.boolean(),recovery:u.string().min(1).max(80),effect:u.enum(["none","unknown"])}).refine(e=>e.effect!=="unknown"||!e.retryable&&e.recovery==="recover_operation","Unknown effects require original-operation recovery");function Bt(e){let n={bridgeVersion:u.literal(4),requestId:u.uuid(),scope:Ce,command:u.literal(e)};return u.union([u.strictObject({...n,data:wn[e]}),u.strictObject({...n,error:Be})])}var Pt="X-Indiana-Bridge-Signature",z="X-Indiana-Bridge-Key-Id";function vn(e){return new TextEncoder().encode(e)}function Dt(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),n=>n.charCodeAt(0))}function Ft(e,n,t,o){return vn(`indiana-merchant-bridge:${o}
2
2
  ${n}
3
3
  POST
4
4
  ${J}
@@ -1 +1 @@
1
- import{b as a,c as b}from"./chunk-OJM6ORHE.js";import"./chunk-J6KIN4RH.js";import"./chunk-WOT6VMZA.js";export{b as applyVisualVariation,a as safeVisualMutation};
1
+ import{b as a,c as b}from"./chunk-D6SDVDXZ.js";import"./chunk-J6KIN4RH.js";import"./chunk-WOT6VMZA.js";export{b as applyVisualVariation,a as safeVisualMutation};
package/dist/visual.js CHANGED
@@ -1 +1 @@
1
- import{a as pe,c as fe}from"./chunk-OJM6ORHE.js";import{b as ue}from"./chunk-J6KIN4RH.js";import{a as Ve,b as re,c as ce,d as de}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-KRTX4QEH.js";import{a as ae,b as se,c as oe,d as le}from"./chunk-DCIGO3NJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-SMIO7OG5.js";import{b as o}from"./chunk-WM27UTWT.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var K="indiana-visual-diagnostics-v1",Ae=o.strictObject({environmentId:o.string().uuid(),release:o.string().regex(/^[a-f0-9]{64}$/).nullable(),generation:o.string().regex(/^[a-f0-9]{64}$/).nullable(),publishedGeneration:o.string().regex(/^[a-f0-9]{64}$/).nullable(),checkedAt:o.string().datetime(),origin:o.string().url(),pathname:o.string().max(2048),urlMatches:o.boolean(),stopped:o.boolean(),rows:o.array(o.strictObject({changeId:o.string().regex(/^[a-f0-9]{64}$/),experimentKey:o.string().max(256),variationKey:o.string().max(256),inExperiment:o.boolean(),fingerprint:o.string().regex(/^[a-f0-9]{64}$/),status:o.enum(["inactive","waiting","partial","applied","mismatch","no_changes","unavailable","error"]),total:o.number().int().min(0).max(600),applied:o.number().int().min(0).max(600)})).max(100)});function ye(e){let l=n=>Array.isArray(n)?"["+n.map(l).join(",")+"]":n&&typeof n=="object"?"{"+Object.entries(n).filter(([,c])=>c!==void 0).sort(([c],[y])=>c.localeCompare(y)).map(([c,y])=>JSON.stringify(c)+":"+l(y)).join(",")+"}":JSON.stringify(n);return l({css:e.css,js:e.js,domMutations:e.domMutations,...e.renderGuard?{renderGuard:e.renderGuard}:{}})}function he(e){let l=new URL(e.baseUrl),n=l.origin==="https://api.longplayai.com"||l.origin==="https://api.dev.longplayai.com"?l.hostname.slice(4):void 0,c=e.origins??(n?[`https://console.${n}`]:[]),y=new Set(c.filter(t=>{try{let i=new URL(t);return i.origin===t&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}})),v=!1,I=!1,k=0,T=async t=>{if(v||I||!t.source||!y.has(t.origin)||!t.data||typeof t.data!="object")return;let i=t.data;if(!(i.channel!==K||i.type!=="inspect"||i.environmentId!==e.environmentId||typeof i.nonce!="string"||!/^[a-f0-9-]{36}$/i.test(i.nonce)||typeof i.changeId!="string"||!/^[a-f0-9]{64}$/.test(i.changeId)||typeof i.url!="string"||i.url.length>2048||Date.now()-k<250)){try{if(new URL(i.url).origin!==location.origin)return}catch{return}I=!0,k=Date.now();try{let x=await e.inspect(i.changeId,i.url);!v&&x.rows.some(S=>S.changeId===i.changeId)&&t.source.postMessage({channel:K,type:"result",nonce:i.nonce,snapshot:x},t.origin)}finally{I=!1}}},u=t=>{T(t).catch(()=>{})};return window.addEventListener("message",u),()=>{v=!0,window.removeEventListener("message",u)}}var R=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=(e,l)=>typeof e=="string"&&e.length<=l,Ee=e=>typeof e=="string"&&(["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e));function ke(e){if(!R(e)||!E(e.css??"",1e5)||!E(e.js??"",1e5)||!Array.isArray(e.domMutations??[])||Array.isArray(e.domMutations)&&e.domMutations.length>200)throw new Error("Invalid visual variation");let l=e.domMutations??[];for(let n of l)if(!R(n)||!E(n.selector,2048)||!n.selector||!Ee(n.attribute)||!["set","append","remove"].includes(String(n.action))||n.value!==void 0&&!E(n.value,5e4)||n.parentSelector!==void 0&&!E(n.parentSelector,2048)||n.insertBeforeSelector!==void 0&&!E(n.insertBeforeSelector,2048))throw new Error("Invalid visual mutation");return{css:e.css??"",js:e.js??"",domMutations:l,...e.renderGuard===void 0?{}:{renderGuard:ue(e.renderGuard)}}}function q(e){if(!R(e)||typeof e.environmentId!="string"||typeof e.trackExposures!="boolean"||!/^[-a-f0-9]{36}$/i.test(e.environmentId)||typeof e.generation!="string"||!/^[a-f0-9]{64}$/.test(e.generation)||!Array.isArray(e.experiments)||e.experiments.length>100||!R(e.savedGroups))throw new Error("Invalid visual experiment payload");let l=e.experiments.map(n=>{if(!R(n)||!["key","changeId"].every(c=>typeof n[c]=="string"&&n[c])||!/^[a-f0-9]{64}$/.test(String(n.changeId))||["namespace","status","groups","url"].some(c=>Object.hasOwn(n,c))||n.hashVersion!==void 0&&n.hashVersion!==2||!Array.isArray(n.variations)||n.variations.length<2||n.variations.length>20||n.urlPatterns!==void 0&&!Array.isArray(n.urlPatterns))throw new Error("Invalid visual experiment");return{...n,variations:n.variations.map(ke)}});return{...e,experiments:l}}var ve=6e4;function qe(e){let l=oe(e.baseUrl);if(e.appManifestRelease!==void 0&&!/^[a-f0-9]{64}$/.test(e.appManifestRelease))throw new Error("Invalid IAM manifest digest");if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let n=e.fetch??globalThis.fetch.bind(globalThis),c=F(n),y=F(n),v=`${l}/api/v1/visual-experiments/${e.environmentId}`,I=e.appManifestRelease?`${v}?iam=${e.appManifestRelease}`:v,k=ae(e.deviceIdCookie??"indiana_did"),T=se(),u=null,t=!1,i=!1,x="",S={...e.attributes??{}},G,B,D=0,H=-1/0,$,m=new Map,O=new Map,C=new Set,z=ge({endpoint:`${v}/events`,fetch:n,log:e.log,label:"Visual exposure"}),P=z.flush,W,b;function j(){clearTimeout(W),b?.remove(),b=void 0}function Y(s,d){let f=M(s,d);C.has(f)||e.trackExposures===!1||u?.trackExposures===!1||t||(C.add(f),z.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:k,...T?{sessionId:T}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:s.key,variationKey:d.key}))}function we(s){if(!u||t)return;let d=new Set,f={onExperimentViewed:(r,p)=>{d.add(M(r,p))},url:location.href,attributes:{...me(k,location),...S,indianaAppManifestRelease:e.appManifestRelease??null},savedGroups:te(u.savedGroups),log:e.log},h=new Set;for(let r of u.experiments){if(ce(`${e.environmentId}:${r.key}`))continue;let p=r;try{let a=ie(p,f);if(O.set(r.changeId,a),!a.inExperiment)continue;h.add(r.changeId);let w=JSON.stringify([a.key,a.value]),U=m.get(r.changeId);if(U?.signature===w){d.has(M(p,a))&&s.push(()=>{U.applied()&&Y(p,a)});continue}m.get(r.changeId)?.revert(),m.delete(r.changeId);let A=fe(a.value,{requireUniqueTargets:!!e.appManifestRelease&&Array.isArray(r.condition?.$and)&&r.condition.$and.some(g=>g!==null&&typeof g=="object"&&!Array.isArray(g)&&g.indianaAppManifestRelease===e.appManifestRelease),boundVariations:r.variations,allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{d.has(M(p,a))&&Y(p,a)},onError:g=>e.log?.("Visual experiment stopped",{experiment:r.key,changeId:r.changeId,variation:a.key,error:String(g)}),onTargetStatus:e.log?g=>e.log?.("Visual target status changed",{experiment:r.key,changeId:r.changeId,variation:a.key,...g}):void 0});m.set(r.changeId,{signature:w,revert:A.revert,applied:()=>A.applied,inspect:()=>A.inspect()})}catch(a){e.log?.("Skipping visual experiment",{experiment:r.key,error:String(a)})}}for(let[r,p]of m)h.has(r)||(p.revert(),m.delete(r));j()}let V=()=>{let s=[];pe(()=>we(s));for(let d of s)d()};async function _(){let s=++D,d;try{d=await c.read(I,J)}catch(h){if(t||s!==D)return!1;throw h}let f=q(d);if(f.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");return t||s!==D?!1:(u=f,H=performance.now(),!0)}async function Q(){!await _()||t||(N(),V())}function L(){clearTimeout($),$=setTimeout(()=>{if(document.visibilityState==="hidden")return L();Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()})},ve)}let X=()=>{t||document.visibilityState==="hidden"||performance.now()-H<ve||(clearTimeout($),Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()}))},Ie=()=>{x!==location.href&&(x=location.href,V())},Z=()=>{P(!0)},N=()=>{G||t||(G=le(Ie),addEventListener("pagehide",Z),x=location.href)};async function ee(s,d){let f=location.href,h=u,r=[],p=null;if(!t)try{let a=q(await y.read(I,J));a.environmentId===e.environmentId&&(p=a.generation)}catch{}for(let a of h?.experiments??[]){if(s&&a.changeId!==s)continue;let w=O.get(a.changeId);if(!w)continue;let U=new TextEncoder().encode(ye(w.value)),A=[...new Uint8Array(await crypto.subtle.digest("SHA-256",U))].map(be=>be.toString(16).padStart(2,"0")).join(""),g=m.get(a.changeId)?.inspect()??{status:"inactive",total:0,applied:0};r.push({changeId:a.changeId,experimentKey:a.key,variationKey:w.key,inExperiment:w.inExperiment,fingerprint:A,...g})}return{environmentId:e.environmentId,release:e.appManifestRelease??null,generation:h?.generation??null,publishedGeneration:p,checkedAt:new Date().toISOString(),origin:location.origin,pathname:location.pathname,urlMatches:location.href===f&&(!d||d===f)&&h===u,stopped:t,rows:r}}let ne,xe=de(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=re(e.appManifestRelease)),e.antiFlicker&&(b=document.createElement("style"),e.nonce&&(b.nonce=e.nonce),b.textContent="body { visibility: hidden !important }",document.head.append(b),W=setTimeout(j,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(!await _()||t)return;N(),V()}finally{j(),t||(L(),document.addEventListener("visibilitychange",X),ne=he({environmentId:e.environmentId,baseUrl:l,origins:e.diagnosticsOrigins,inspect:ee}))}}},async refresh(){t||await _()&&(i&&N(),V())},setAttributes(s){S={...s},V()},flush:()=>P(),getDiagnostics:ee,getResults(){return new Map(O)},get generation(){return u?.generation??null},destroy(){t=!0,clearTimeout($),document.removeEventListener("visibilitychange",X),xe(),ne?.(),D++,c.destroy(),y.destroy(),G?.(),B?.destroy(),removeEventListener("pagehide",Z),j();for(let s of m.values())s.revert();m.clear(),P(!0),u=null,O.clear(),C.clear(),S={}}}}export{qe as createVisualExperiments,Ve as loadAppManifestRelease};
1
+ import{a as pe,c as fe}from"./chunk-D6SDVDXZ.js";import{b as ue}from"./chunk-J6KIN4RH.js";import{a as Ve,b as re,c as ce,d as de}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-LHXRT32T.js";import{a as ae,b as se,c as oe,d as le}from"./chunk-7CFSTOTX.js";import"./chunk-3VUPVXAV.js";import"./chunk-AEERSTTW.js";import{b as o}from"./chunk-ZGBSTK22.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-5OJVM7Q4.js";import"./chunk-QENDBHBQ.js";import"./chunk-WOT6VMZA.js";var K="indiana-visual-diagnostics-v1",Ae=o.strictObject({environmentId:o.string().uuid(),release:o.string().regex(/^[a-f0-9]{64}$/).nullable(),generation:o.string().regex(/^[a-f0-9]{64}$/).nullable(),publishedGeneration:o.string().regex(/^[a-f0-9]{64}$/).nullable(),checkedAt:o.string().datetime(),origin:o.string().url(),pathname:o.string().max(2048),urlMatches:o.boolean(),stopped:o.boolean(),rows:o.array(o.strictObject({changeId:o.string().regex(/^[a-f0-9]{64}$/),experimentKey:o.string().max(256),variationKey:o.string().max(256),inExperiment:o.boolean(),fingerprint:o.string().regex(/^[a-f0-9]{64}$/),status:o.enum(["inactive","waiting","partial","applied","mismatch","no_changes","unavailable","error"]),total:o.number().int().min(0).max(600),applied:o.number().int().min(0).max(600)})).max(100)});function ye(e){let l=n=>Array.isArray(n)?"["+n.map(l).join(",")+"]":n&&typeof n=="object"?"{"+Object.entries(n).filter(([,c])=>c!==void 0).sort(([c],[y])=>c.localeCompare(y)).map(([c,y])=>JSON.stringify(c)+":"+l(y)).join(",")+"}":JSON.stringify(n);return l({css:e.css,js:e.js,domMutations:e.domMutations,...e.renderGuard?{renderGuard:e.renderGuard}:{}})}function he(e){let l=new URL(e.baseUrl),n=l.origin==="https://api.longplayai.com"||l.origin==="https://api.dev.longplayai.com"?l.hostname.slice(4):void 0,c=e.origins??(n?[`https://console.${n}`]:[]),y=new Set(c.filter(t=>{try{let i=new URL(t);return i.origin===t&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}})),v=!1,I=!1,k=0,T=async t=>{if(v||I||!t.source||!y.has(t.origin)||!t.data||typeof t.data!="object")return;let i=t.data;if(!(i.channel!==K||i.type!=="inspect"||i.environmentId!==e.environmentId||typeof i.nonce!="string"||!/^[a-f0-9-]{36}$/i.test(i.nonce)||typeof i.changeId!="string"||!/^[a-f0-9]{64}$/.test(i.changeId)||typeof i.url!="string"||i.url.length>2048||Date.now()-k<250)){try{if(new URL(i.url).origin!==location.origin)return}catch{return}I=!0,k=Date.now();try{let x=await e.inspect(i.changeId,i.url);!v&&x.rows.some(S=>S.changeId===i.changeId)&&t.source.postMessage({channel:K,type:"result",nonce:i.nonce,snapshot:x},t.origin)}finally{I=!1}}},u=t=>{T(t).catch(()=>{})};return window.addEventListener("message",u),()=>{v=!0,window.removeEventListener("message",u)}}var R=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=(e,l)=>typeof e=="string"&&e.length<=l,Ee=e=>typeof e=="string"&&(["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e));function ke(e){if(!R(e)||!E(e.css??"",1e5)||!E(e.js??"",1e5)||!Array.isArray(e.domMutations??[])||Array.isArray(e.domMutations)&&e.domMutations.length>200)throw new Error("Invalid visual variation");let l=e.domMutations??[];for(let n of l)if(!R(n)||!E(n.selector,2048)||!n.selector||!Ee(n.attribute)||!["set","append","remove"].includes(String(n.action))||n.value!==void 0&&!E(n.value,5e4)||n.parentSelector!==void 0&&!E(n.parentSelector,2048)||n.insertBeforeSelector!==void 0&&!E(n.insertBeforeSelector,2048))throw new Error("Invalid visual mutation");return{css:e.css??"",js:e.js??"",domMutations:l,...e.renderGuard===void 0?{}:{renderGuard:ue(e.renderGuard)}}}function q(e){if(!R(e)||typeof e.environmentId!="string"||typeof e.trackExposures!="boolean"||!/^[-a-f0-9]{36}$/i.test(e.environmentId)||typeof e.generation!="string"||!/^[a-f0-9]{64}$/.test(e.generation)||!Array.isArray(e.experiments)||e.experiments.length>100||!R(e.savedGroups))throw new Error("Invalid visual experiment payload");let l=e.experiments.map(n=>{if(!R(n)||!["key","changeId"].every(c=>typeof n[c]=="string"&&n[c])||!/^[a-f0-9]{64}$/.test(String(n.changeId))||["namespace","status","groups","url"].some(c=>Object.hasOwn(n,c))||n.hashVersion!==void 0&&n.hashVersion!==2||!Array.isArray(n.variations)||n.variations.length<2||n.variations.length>20||n.urlPatterns!==void 0&&!Array.isArray(n.urlPatterns))throw new Error("Invalid visual experiment");return{...n,variations:n.variations.map(ke)}});return{...e,experiments:l}}var ve=6e4;function qe(e){let l=oe(e.baseUrl);if(e.appManifestRelease!==void 0&&!/^[a-f0-9]{64}$/.test(e.appManifestRelease))throw new Error("Invalid IAM manifest digest");if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let n=e.fetch??globalThis.fetch.bind(globalThis),c=F(n),y=F(n),v=`${l}/api/v1/visual-experiments/${e.environmentId}`,I=e.appManifestRelease?`${v}?iam=${e.appManifestRelease}`:v,k=ae(e.deviceIdCookie??"indiana_did"),T=se(),u=null,t=!1,i=!1,x="",S={...e.attributes??{}},G,B,D=0,H=-1/0,$,m=new Map,O=new Map,C=new Set,z=ge({endpoint:`${v}/events`,fetch:n,log:e.log,label:"Visual exposure"}),P=z.flush,W,b;function j(){clearTimeout(W),b?.remove(),b=void 0}function Y(s,d){let f=M(s,d);C.has(f)||e.trackExposures===!1||u?.trackExposures===!1||t||(C.add(f),z.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:k,...T?{sessionId:T}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:s.key,variationKey:d.key}))}function we(s){if(!u||t)return;let d=new Set,f={onExperimentViewed:(r,p)=>{d.add(M(r,p))},url:location.href,attributes:{...me(k,location),...S,indianaAppManifestRelease:e.appManifestRelease??null},savedGroups:te(u.savedGroups),log:e.log},h=new Set;for(let r of u.experiments){if(ce(`${e.environmentId}:${r.key}`))continue;let p=r;try{let a=ie(p,f);if(O.set(r.changeId,a),!a.inExperiment)continue;h.add(r.changeId);let w=JSON.stringify([a.key,a.value]),U=m.get(r.changeId);if(U?.signature===w){d.has(M(p,a))&&s.push(()=>{U.applied()&&Y(p,a)});continue}m.get(r.changeId)?.revert(),m.delete(r.changeId);let A=fe(a.value,{requireUniqueTargets:!!e.appManifestRelease&&Array.isArray(r.condition?.$and)&&r.condition.$and.some(g=>g!==null&&typeof g=="object"&&!Array.isArray(g)&&g.indianaAppManifestRelease===e.appManifestRelease),boundVariations:r.variations,allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{d.has(M(p,a))&&Y(p,a)},onError:g=>e.log?.("Visual experiment stopped",{experiment:r.key,changeId:r.changeId,variation:a.key,error:String(g)}),onTargetStatus:e.log?g=>e.log?.("Visual target status changed",{experiment:r.key,changeId:r.changeId,variation:a.key,...g}):void 0});m.set(r.changeId,{signature:w,revert:A.revert,applied:()=>A.applied,inspect:()=>A.inspect()})}catch(a){e.log?.("Skipping visual experiment",{experiment:r.key,error:String(a)})}}for(let[r,p]of m)h.has(r)||(p.revert(),m.delete(r));j()}let V=()=>{let s=[];pe(()=>we(s));for(let d of s)d()};async function _(){let s=++D,d;try{d=await c.read(I,J)}catch(h){if(t||s!==D)return!1;throw h}let f=q(d);if(f.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");return t||s!==D?!1:(u=f,H=performance.now(),!0)}async function Q(){!await _()||t||(N(),V())}function L(){clearTimeout($),$=setTimeout(()=>{if(document.visibilityState==="hidden")return L();Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()})},ve)}let X=()=>{t||document.visibilityState==="hidden"||performance.now()-H<ve||(clearTimeout($),Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()}))},Ie=()=>{x!==location.href&&(x=location.href,V())},Z=()=>{P(!0)},N=()=>{G||t||(G=le(Ie),addEventListener("pagehide",Z),x=location.href)};async function ee(s,d){let f=location.href,h=u,r=[],p=null;if(!t)try{let a=q(await y.read(I,J));a.environmentId===e.environmentId&&(p=a.generation)}catch{}for(let a of h?.experiments??[]){if(s&&a.changeId!==s)continue;let w=O.get(a.changeId);if(!w)continue;let U=new TextEncoder().encode(ye(w.value)),A=[...new Uint8Array(await crypto.subtle.digest("SHA-256",U))].map(be=>be.toString(16).padStart(2,"0")).join(""),g=m.get(a.changeId)?.inspect()??{status:"inactive",total:0,applied:0};r.push({changeId:a.changeId,experimentKey:a.key,variationKey:w.key,inExperiment:w.inExperiment,fingerprint:A,...g})}return{environmentId:e.environmentId,release:e.appManifestRelease??null,generation:h?.generation??null,publishedGeneration:p,checkedAt:new Date().toISOString(),origin:location.origin,pathname:location.pathname,urlMatches:location.href===f&&(!d||d===f)&&h===u,stopped:t,rows:r}}let ne,xe=de(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=re(e.appManifestRelease)),e.antiFlicker&&(b=document.createElement("style"),e.nonce&&(b.nonce=e.nonce),b.textContent="body { visibility: hidden !important }",document.head.append(b),W=setTimeout(j,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(!await _()||t)return;N(),V()}finally{j(),t||(L(),document.addEventListener("visibilitychange",X),ne=he({environmentId:e.environmentId,baseUrl:l,origins:e.diagnosticsOrigins,inspect:ee}))}}},async refresh(){t||await _()&&(i&&N(),V())},setAttributes(s){S={...s},V()},flush:()=>P(),getDiagnostics:ee,getResults(){return new Map(O)},get generation(){return u?.generation??null},destroy(){t=!0,clearTimeout($),document.removeEventListener("visibilitychange",X),xe(),ne?.(),D++,c.destroy(),y.destroy(),G?.(),B?.destroy(),removeEventListener("pagehide",Z),j();for(let s of m.values())s.revert();m.clear(),P(!0),u=null,O.clear(),C.clear(),S={}}}}export{qe as createVisualExperiments,Ve as loadAppManifestRelease};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinkerlandai/longplay-sdk",
3
- "version": "0.10.26",
3
+ "version": "0.10.27",
4
4
  "description": "Framework-independent Longplay SDK for customer identity, entitlements, credits, offers and growth surfaces.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -60,12 +60,6 @@
60
60
  "import": "./dist/visual.js"
61
61
  }
62
62
  },
63
- "scripts": {
64
- "build": "tsup",
65
- "prepack": "pnpm run build",
66
- "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
67
- "lint": "node ../../scripts/ci/lint.mjs --workspace packages/sdk"
68
- },
69
63
  "dependencies": {
70
64
  "@ai-sdk/provider": "4.0.26",
71
65
  "@types/json-schema": "7.0.15",
@@ -75,13 +69,13 @@
75
69
  "zod": "4.6.6"
76
70
  },
77
71
  "devDependencies": {
78
- "@indiana/contracts": "workspace:*",
79
72
  "@openrouter/sdk": "^1.4.25",
80
73
  "@types/css-tree": "^3.2.0",
81
74
  "ai": "7.0.136",
82
75
  "tsup": "^8.5.1",
83
76
  "typescript": "^5.9.3",
84
- "whatwg-url-minimum": "0.2.0"
77
+ "whatwg-url-minimum": "0.2.0",
78
+ "@indiana/contracts": "0.1.0"
85
79
  },
86
80
  "peerDependencies": {
87
81
  "@openrouter/sdk": "^1.4.25"
@@ -90,5 +84,10 @@
90
84
  "@openrouter/sdk": {
91
85
  "optional": true
92
86
  }
87
+ },
88
+ "scripts": {
89
+ "build": "tsup",
90
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
91
+ "lint": "node ../../scripts/ci/lint.mjs --workspace packages/sdk"
93
92
  }
94
- }
93
+ }
@@ -1 +0,0 @@
1
- import{b as e}from"./chunk-WM27UTWT.js";var c=e.enum(["replace","stack_native"]);export{c as a};
@@ -1 +0,0 @@
1
- import{p as n,s as t}from"./chunk-UHI7SPHK.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
@@ -1 +0,0 @@
1
- import{c as a,d as b}from"./chunk-YSNMXK4R.js";import"./chunk-JGG4R75K.js";import"./chunk-CNIBGSVO.js";import"./chunk-PMCGTXGH.js";import"./chunk-7CFF6SWH.js";import"./chunk-PWQ5BHBJ.js";import"./chunk-HMRIMJ5W.js";import"./chunk-MWDR5FEU.js";import"./chunk-UBKD6VMS.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-SLUA7ABW.js";import"./chunk-DCIGO3NJ.js";import"./chunk-SMIO7OG5.js";import"./chunk-WM27UTWT.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
@@ -1 +0,0 @@
1
- import{N as r,O as m,h as e}from"./chunk-C6JRUYKW.js";import"./chunk-7CFF6SWH.js";import"./chunk-UBKD6VMS.js";import"./chunk-DOJE7VUR.js";import"./chunk-JAKOBECD.js";import"./chunk-WM27UTWT.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
@@ -1 +0,0 @@
1
- import{e as o}from"./chunk-6VY4PZZ6.js";import"./chunk-2KOQBV3Y.js";import"./chunk-LPDUK7HT.js";import"./chunk-GIV4FOOW.js";import"./chunk-MYUYN7ZG.js";import"./chunk-C6JRUYKW.js";import"./chunk-PMCGTXGH.js";import"./chunk-7CFF6SWH.js";import"./chunk-HMRIMJ5W.js";import"./chunk-NMKZ724L.js";import"./chunk-UBKD6VMS.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import"./chunk-JAKOBECD.js";import"./chunk-WM27UTWT.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
@@ -1 +0,0 @@
1
- import{b as Ye,c as Je}from"./chunk-JGG4R75K.js";import{c as ze,d as He,e as Be,f as de,g as Qe,h as Ge,i as je,k as We}from"./chunk-CNIBGSVO.js";import{a as qe,c as Ae,d as Ve,g as Fe}from"./chunk-PWQ5BHBJ.js";import{b as ee}from"./chunk-HMRIMJ5W.js";import"./chunk-MWDR5FEU.js";import"./chunk-UBKD6VMS.js";import{c as Y,o as Z,oa as te,qa as Me}from"./chunk-5RXU57I5.js";import{c as Ie}from"./chunk-DOJE7VUR.js";import{a as A}from"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-SMIO7OG5.js";import"./chunk-WM27UTWT.js";import{a as z}from"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";async function Ke(s,n,v){if(n.status!=="complete")throw new A("INVALID_RESPONSE","A verified completed purchase is required");let g=s?Z.parse(s):null;if(await v.onComplete?.(n),!g||!v.check)return;let y=Z.parse(await v.check());if(y.internal_feature_id!==g.internal_feature_id||y.quantity!==g.quantity||g.observation!==void 0&&(y.observation===void 0||y.observation.requirementDigest!==g.observation.requirementDigest||y.observation.authority!==g.observation.authority||Ie(y.observation.subject)!==Ie(g.observation.subject)))throw new A("INVALID_RESPONSE","The access requirement changed");y.allowed&&await v.onAccessGranted?.(y)}var st={none:0,sm:4,md:8,lg:14,full:9999},ct={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"};function lt(s){let[n,v,g]=[1,3,5].map(y=>{let x=Number.parseInt(s.slice(y,y+2),16)/255;return x<=.03928?x/12.92:((x+.055)/1.055)**2.4});return .2126*n+.7152*v+.0722*g}function Xe(s){let n=lt(s.primary),v=(n+.05)/.05>1.05/(n+.05)?"#111318":"#FFFFFF",g=`color-mix(in srgb, ${s.text} 22%, ${s.background})`,y=`${st[s.radius]}px`,x=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${y};font:inherit;font-size:15px;font-weight:600;line-height:1.25;cursor:pointer;touch-action:manipulation`;return{root:`width:100%;box-sizing:border-box;background:${s.background};color:${s.text};font:14px/1.5 ${ct[s.font]}`,controls:"display:flex;gap:12px;padding:0 20px 12px;align-items:center;flex-wrap:wrap",message:"flex:1 1 200px;min-width:0;margin:0;font-size:13px",panel:`flex:1 0 100%;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:16px;border:1px solid ${g};border-radius:${y}`,summary:"margin:0;font-size:15px;font-weight:600",terms:"display:flex;flex-direction:column;gap:4px;font-size:13px;opacity:.72",actions:"display:flex;gap:8px;flex-wrap:wrap;margin-top:4px",primary:`${x};background:${s.primary};color:${v}`,secondary:`${x};background:transparent;color:${s.text};box-shadow:inset 0 0 0 1px ${g}`,link:`${x};background:transparent;color:${s.text};opacity:.72;font-weight:500`}}function Re(s){s.style.opacity=s.disabled?".55":"",s.style.cursor=s.disabled?"not-allowed":"pointer"}function Se(s){return Object.entries(s.document.buttons).filter(([,n])=>n.type==="checkout"&&n.product.type==="fixed"&&!ee(n.product,{},s.capabilities)).map(([n])=>n)}async function Nt(s,n,v){let g=We(s.ownerDocument),y=()=>{C.finish("dismissed"),g()},x=()=>y(),C=Qe(s,n,"paywall",()=>{y(),z(n.onDismiss)});n.signal?.throwIfAborted(),n.signal?.addEventListener("abort",x,{once:!0});let H=null,N,b,Te;try{if(C.start(!0),C.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(H=n.check?Z.parse(await C.wait(n.check(),de)):null,H?.allowed)return C.finish("skipped"),n.signal?.removeEventListener("abort",x),g(),await n.onAccessGranted?.(H),{check:H,host:null};let[e,t]=await Promise.allSettled([C.wait(import("./screen-renderer-G2EWN3WB.js")),C.wait(n.start().then(d=>(C.cancelled&&d.destroy(),d)),de)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Te=e.value,N=t.value,n.signal?.throwIfAborted(),N.signal?.throwIfAborted(),N.signal?.addEventListener("abort",x,{once:!0});let a=N.view??await C.wait(N.refresh(),de);if(!a)throw new A("INVALID_RESPONSE","Paywall presentation is missing");N.signal?.throwIfAborted(),b=a}catch(e){throw C.finish("error",e),n.signal?.removeEventListener("abort",x),N?.signal?.removeEventListener("abort",x),N?.destroy(),g(),e}let r=N,{mountScreenPreview:Ze}=Te,u=s.ownerDocument,pe=new AbortController,L=u.createElement("section"),fe=u.createElement("div"),M=u.createElement("div"),m=u.createElement("p"),f=u.createElement("button"),P=u.createElement("button"),w=u.createElement("dialog"),i=b.document.screen.strings.defaultLocale.startsWith("zh"),et=i?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",tt=i?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",O=Xe(b.document.screen.theme);L.dataset.indianaPaywall="",L.setAttribute("aria-label",b.document.name),L.style.cssText=O.root,M.style.cssText=O.controls,m.style.cssText=O.message,m.setAttribute("role","status"),P.style.cssText=O.link,P.textContent=i?"\u5173\u95ED":"Close",f.style.cssText=O.secondary,f.textContent=i?"\u91CD\u8BD5":"Retry",f.hidden=!0,M.append(m,f,P),L.append(fe,M);let B=b.document.presentation,Q,Oe,me=!1,De=JSON.stringify(b.capabilities);function he(e){if(p)return;b=e;let t=JSON.stringify(e.capabilities);t!==De&&(Q?.updateCapabilities(e.capabilities,Se(e)),De=t),rt(e)}let R;function Ne(){let e=u.defaultView;R?.responsive&&e&&Q?.resizeViewport?.(e.innerHeight,e.innerWidth)}let p=!1,J=!1,E=null,ne=!1,Le=!1,q=!1,ye,we=!1,$,G;function nt(){return J||p||$||we?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:Ae(r)}let S=()=>!p&&!ne&&!$&&n.canInteract?.()!==!1,ge=!1,c=null,U=null;function rt(e){J||E||r.quote||r.operation||(m.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":i?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let be=new Map,re=e=>qe({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:r.canReselect});async function ve(e){let t=e.merchantExecution;if(!(!S()||!e.checkoutUrl||n.checkoutNavigation==="after_confirmation"&&re(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||be.get(e.operationId)===e.checkoutUrl)){be.set(e.operationId,e.checkoutUrl);try{n.onCheckoutUrl?await n.onCheckoutUrl(e.checkoutUrl):u.defaultView?.location.assign(e.checkoutUrl)}catch(a){throw be.delete(e.operationId),a}}}let j=(e,t=!1)=>{if(t){let a=e instanceof A?e.code:void 0;a==="CAPABILITY_UNAVAILABLE"||a==="NOT_CONFIGURED"?(c=null,m.textContent=i?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):a==="COMMAND_PENDING"?m.textContent=i?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":m.textContent=i?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else m.textContent=e instanceof Error?e.message:i?"\u8BF7\u6C42\u5931\u8D25":"Request failed";f.hidden=c===null,t&&m.scrollIntoView?.({block:"nearest"}),z(t&&v?.quoteError?v.quoteError:n.onError,e)},ie=new WeakMap;function oe(e){J=e;for(let t of U?.querySelectorAll("button")??[])e?(ie.set(t,t.disabled),t.disabled=!0):ie.has(t)&&(t.disabled=ie.get(t),ie.delete(t)),Re(t)}function xe(){m.textContent=i?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function it(e){if(n.beforeAction)try{await n.beforeAction()}catch(t){throw c=e,t}}async function _(e){if(J||p)return;if(!S()){xe();return}let t=e===se,a=t?tt:et;oe(!0),f.hidden=!0,m.textContent=a,t&&m.scrollIntoView?.({block:"nearest"});try{if(await it(e),p)return;if(!S()){c=e,f.hidden=!1,xe();return}await e()}catch(d){p||j(d,t)}finally{oe(!1),m.textContent===a&&(m.textContent="")}}async function ot(e){await Ke(H,e,n)}function Ue(e){return Ae(r).type==="recording"||re(e).type==="recording"}async function k(e,t=n.checkoutNavigation!=="after_confirmation"){if(p)return;if(!S()){c=async()=>k(await r.read()),f.hidden=!1;return}if(m.textContent=Je(e.status,i),Ue(e)){let o=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";m.textContent=o?i?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":i?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",f.textContent=i?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",c=async()=>k(await r.read()),f.hidden=!1;return}if(e.problem){let o=e.problem;c=ae,f.textContent=i?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",j(new A(o.code,o.reason==="RESULT_UNKNOWN"?i?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":o.phase==="fulfillment"?i?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":o.code==="CAPABILITY_UNAVAILABLE"?i?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":o.code==="NOT_CONFIGURED"?i?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":i?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,o));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(m.textContent=i?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){c=null,await ot(e);return}if(e.status!=="pending"){if(r.canReselect===!1){m.textContent=i?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",f.textContent=i?"\u67E5\u8BE2\u7ED3\u679C":"Check result",c=async()=>k(await r.read()),f.hidden=!1;return}f.textContent=i?"\u91CD\u8BD5":"Retry",c=null,E=null;return}if(!t&&re(e).type==="checkout"){m.textContent=i?"\u539F\u4ED8\u6B3E\u5C1A\u672A\u5B8C\u6210\uFF0C\u53EF\u7EE7\u7EED\u539F\u6536\u94F6\u53F0\u3002":"Payment is unfinished. Continue the original checkout.",f.textContent=i?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",c=async()=>k(await r.read(),!0),f.hidden=!1;return}await ve(e);let a=Date.now()+6e5,d=2e3;me=!0,z(n.onObservationChange,!0);try{for(;!p&&Date.now()<a;){if(await Ye(d,u,pe.signal),p)return;if(!S()){c=async()=>k(await r.read()),f.hidden=!1;return}let o=await r.read();if(!t&&re(o).type==="checkout"){await k(o,!1);return}if(!o.problem&&o.status==="pending"&&await ve(o),o.status!=="pending"||o.problem||Ue(o)){await k(o);return}d=Math.min(d*1.5,3e4)}}finally{me=!1,z(n.onObservationChange,!1)}c=async()=>k(await r.read()),f.hidden=!1}async function Ce(){let e=await r.read();if(p)return;if(!S()){c=Ce,f.hidden=!1;return}let t=r.quote;if(t&&Fe(e,{operationId:t.operationId,currency:t.currency},"The original purchase operation changed"),t&&e.status==="pending"&&e.quoteFinalized===!1&&!e.confirmedAt&&!e.checkoutUrl&&!e.nativePurchase&&!e.merchantExecution&&!e.problem&&!r.pendingCancellation){_e(t);return}await k(e)}async function ae(){U?.remove(),U=null,c=ae;let e=await r.confirm();if(!S()){c=ae,f.hidden=!1;return}if(e.problem){await k(e);return}if(e.status==="pending"){if(e.checkoutUrl)await ve(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!n.onPurchase)throw new A("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await n.onPurchase({operation:e,signal:pe.signal})}}c=async()=>k(await r.read()),await k(e,!0)}function _e(e){U?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());m.textContent=t?i?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let a=u.createElement("div"),d=u.createElement("button"),o=u.createElement("button"),V=u.createElement("div"),K=u.createElement("p"),T=e.merchantTerms,ce=T?T.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),le=i?"zh-CN":"en",ue=T?.subscriptionTerms?.items??[],X=T?ue.length===1&&ue[0]?.amountMinor===ce&&ue[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===ce&&e.lines[0];K.textContent=e.lines.map(l=>l.productName).join(", ")+" \xB7 "+(ce===null?i?`${Y(T.subtotalMinor-T.discountMinor,e.currency)} + \u5F85\u786E\u8BA4\u7A0E\u8D39`:`${Y(T.subtotalMinor-T.discountMinor,e.currency)} + tax confirmed at checkout`:Y(ce,e.currency)+(X?te(X.interval,le,X.intervalCount??1):"")),d.textContent=i?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",d.disabled=t,o.textContent=i?"\u53D6\u6D88":"Cancel",a.style.cssText=O.panel,K.style.cssText=O.summary,V.style.cssText=O.actions,d.style.cssText=O.primary,o.style.cssText=O.secondary,Re(d),d.onclick=()=>{_(ae)};let $e=async()=>{let l=await r.cancel();p||(a.remove(),U=null,await k(l))};o.onclick=()=>{c=$e,_($e)};let D=u.createElement("div");if(D.style.cssText=O.terms,T){for(let h of ue){if(h===X)continue;let I=u.createElement("p");I.textContent=Y(h.amountMinor,e.currency)+te(h.interval,le,h.intervalCount),D.append(I)}let l=T.subscriptionTerms?.trial;if(l){let h=u.createElement("p");h.textContent=i?`\u8BD5\u7528 ${l.days} \u5929\uFF1B${l.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${l.days}; ${l.cardRequired?"a payment method is required":"no payment method is required"}`,D.append(h)}for(let h of[...T.expectedEffects.map(I=>I.description),...T.requiredConsents.map(I=>I.summary)]){let I=u.createElement("p");I.textContent=h,D.append(I)}}else{for(let l of e.lines){if(l!==X){let h=u.createElement("p");h.textContent=`${l.productName} \xB7 ${Y(l.catalogAmountMinor,e.currency)}${te(l.interval,le,l.intervalCount??1)}`,D.append(h)}for(let h of l.prepaid??[]){let I=u.createElement("p"),F=r.view?.capabilities.plans[l.productVersionId]?.prepaid?.find(at=>at.internalFeatureId===h.internal_feature_id);I.textContent=`${F?.name??h.internal_feature_id} \xB7 ${h.quantity} ${i?"\u4EFD":"packs"} \xD7 ${h.terms.units}`,F&&(I.textContent+=te(F.reset==="week"||F.reset==="month"||F.reset==="year"?F.reset:"one_time",le,F.resetCount)),D.append(I)}if(l.trial){let h=u.createElement("p");h.textContent=i?`\u8BD5\u7528 ${l.trial.days} \u5929\uFF1B${l.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${l.trial.days}; ${l.trial.cardRequired?"a payment method is required":"no payment method is required"}`,D.append(h)}}if(!e.charge){let l=u.createElement("p");l.textContent=i?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",D.append(l)}}for(let l of D.children)l.style.margin="0";V.append(d,o),a.append(K,...D.childElementCount?[D]:[],V),M.prepend(a),a.scrollIntoView?.({block:"nearest"}),d.focus({preventScroll:!0}),U=a,c=null}async function se(){if(!E)return;if(c=se,!ge){let t=r.view,a=t?.document.buttons[E.actionId],d=t&&a?.type==="checkout"?ee(a.product,E.selection,t.capabilities):null;if(!d)throw new A("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let o=await n.resolveOfferId?.({actionId:E.actionId,productVersionId:d});if(p)return;o!==void 0&&(E.offerId=o),ge=!0}if(!S()){f.hidden=!1;return}let e=await r.preview(E);p||_e(e)}function W(e="destroy"){p||(p=!0,n.signal?.removeEventListener("abort",x),r.signal?.removeEventListener("abort",x),C.finish("dismissed"),Oe?.(),pe.abort(),R?.destroy(),Q?.destroy(),r.destroy(),w.open&&w.close(),w.remove(),L.remove(),g(),e==="dismiss"&&z(n.onDismiss))}y=W;async function Pe(){if(!q||p||ne||$==="closing"||!$&&!S())return;if(!v){W("dismiss");return}let e=u.createElement("p");e.setAttribute("role","status"),e.textContent=i?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",G||(G=u.createElement("div"),G.style.cssText=M.style.cssText,M.replaceWith(G),fe.inert=!0),G.replaceChildren(e,P),$="closing",P.setAttribute("aria-disabled","true"),P.focus({preventScroll:!0});try{await v.dismiss()}catch(t){p||z(n.onError,t)}p||($="retry",e.textContent=i?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",P.textContent=i?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",P.removeAttribute("aria-label"),P.removeAttribute("aria-disabled"))}P.onclick=()=>{Pe()},w.addEventListener("cancel",e=>{e.preventDefault(),Pe()}),f.onclick=()=>{c&&_(c)};function Ee(e){C.finish("error",e),W()}function ke(){if(!(!Le||q||p||ne||R&&!S()))try{let e=t=>{ye?.(),R&&(w.showModal(),R.responsive&&w.focus({preventScroll:!0}),!t&&n.loading!=="host"&&He(w,R.type,R.responsive)),q=!0};v?v.present(()=>C.present(()=>e(!0))):C.present(e)}catch(e){Ee(e),j(e)}}try{if(B.type==="inline")ye=je(L,s),s.append(L);else{let t={sm:420,md:640,lg:900};w.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in B?t[B.size]+"px":"100vw"}`,w.setAttribute("aria-label",b.document.name),P.textContent="\xD7",P.setAttribute("aria-label",i?"\u5173\u95ED":"Close"),Be(P,b.document.screen.theme),w.append(P,L),s.append(w),R=ze(w,{...b.document.screen,presentation:B},Ne),R.latch(),ye=Ge(w)}Q=Ze(fe,{mode:"live",rendererUrl:r.webViewUrl,title:b.document.name,hostPresentation:()=>R?.type??B.type,onResize:t=>{R?.responsive&&R.setContentHeight(t+(G??M).getBoundingClientRect().height)},onAction(t,a={}){if(!q||p||$)return;if(!S()){xe();return}let d=r.view,o=d?.document.buttons[t];if(!o)return;if(o.type==="close"){_(async()=>{await n.onAction?.(t),W(n.onAction?"action":"dismiss")});return}if(o.type==="action"){c=async()=>{if(o.action.type==="event"){if(!n.onEvent)throw new A("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(o.action.event)}else n.onOpenUrl?await n.onOpenUrl(o.action.url):u.defaultView?.location.assign(o.action.url);await n.onAction?.(t),c=null},_(c);return}if(U&&r.canReselect===!1){m.textContent=i?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",U.scrollIntoView?.({block:"nearest"}),U.querySelector("button")?.focus({preventScroll:!0});return}if((r.quote||E)&&r.canReselect===!1){c=r.quote?Ce:se,_(c);return}let V=d&&ee(o.product,a,d.capabilities);if(!d||!V){j(new A("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(n.onPurchaseIntent){c=null,_(async()=>{let K={actionId:t,productVersionId:V,selection:structuredClone(a),featureQuantities:Me(d.document.screen,V,a,d.capabilities)};we=!0,await n.onPurchaseIntent(K)});return}if(E&&E.actionId!==t){j(new A("COMMAND_PENDING","Finish the current purchase"));return}E||(E={requestId:crypto.randomUUID(),actionId:t,selection:a},ge=!1),_(se)},onEscape:()=>{Pe()},onError:t=>{let a=new Error(t);!q&&!p&&Ee(a),j(a)},onRendered:t=>{t&&w.setAttribute("aria-label",t),Le=!0,ke()}}),Ne(),Q.update(b.document.screen,b.document.screen.strings.defaultLocale,{capabilities:b.capabilities,unavailableActions:Se(b),serverInput:{bindings:[],answers:{}}}),Oe=r.subscribe?.(he),he(r.view??b),await C.wait(Q.ready);let e=r.operation;(r.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(c=Ce,_(c))}catch(e){throw Ee(e),e}return{check:H,host:{get observing(){return me},get recovery(){return nt()},async prepareFallback(){if(J||p||$||we)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};oe(!0);try{let e=await Ve(r);return e.type==="native"&&W(),e}finally{oe(!1)}},setSuspended(e){ne=e,L.hidden=e,e&&w.open?w.close():!e&&!q?ke():!e&&!p&&q&&B.type!=="inline"&&!w.open&&w.showModal()},destroy:W,refresh:async()=>{if(!S()){if(r.view)return r.view;throw new A("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return he(e),ke(),e}}}}export{Nt as showPaywall};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-CZ3H2X7D.js";import"./chunk-6VY4PZZ6.js";import"./chunk-2KOQBV3Y.js";import"./chunk-BZSKOOMM.js";import"./chunk-LPDUK7HT.js";import"./chunk-G7NSECIG.js";import"./chunk-GIV4FOOW.js";import"./chunk-MYUYN7ZG.js";import"./chunk-C6JRUYKW.js";import"./chunk-PMCGTXGH.js";import"./chunk-7CFF6SWH.js";import"./chunk-PWQ5BHBJ.js";import"./chunk-HMRIMJ5W.js";import"./chunk-NMKZ724L.js";import"./chunk-MWDR5FEU.js";import"./chunk-UBKD6VMS.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-3VUPVXAV.js";import"./chunk-SMIO7OG5.js";import"./chunk-WM27UTWT.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk-B5JHPPR4.js";import"./chunk-CNIBGSVO.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-WM27UTWT.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
File without changes
File without changes
File without changes