@tinkerlandai/longplay-sdk 0.10.23 → 0.10.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/README.md +79 -0
- package/README.zh-CN.md +31 -0
- package/dist/{ai-usage-WFwbPTiq.d.ts → ai-usage-B6RepnmH.d.ts} +1 -1
- package/dist/{api-rZ_QoNQi.d.ts → api-C9P338XT.d.ts} +1547 -6
- package/dist/{chunk-5SHVM4AF.js → chunk-2KI63SPJ.js} +2 -2
- package/dist/{chunk-7MF2YMN4.js → chunk-2ZJ5CS5Q.js} +1 -1
- package/dist/chunk-34I23EKZ.js +1 -0
- package/dist/{chunk-XFO4FBFG.js → chunk-5HJMAZ7A.js} +1 -1
- package/dist/chunk-7AXCG6NU.js +1 -0
- package/dist/chunk-BB5P5HPS.js +1 -0
- package/dist/chunk-C2BODHNY.js +1 -0
- package/dist/chunk-EIYWDWXP.js +1 -0
- package/dist/chunk-LFFBNGXP.js +1 -0
- package/dist/{chunk-HDVLCRC6.js → chunk-MHEYMXGZ.js} +2 -2
- package/dist/{chunk-EZLLTGV3.js → chunk-ML3BIPM6.js} +1 -1
- package/dist/{chunk-KZ63ANBP.js → chunk-O3LZPMS4.js} +1 -1
- package/dist/chunk-O4535GJR.js +6 -0
- package/dist/{chunk-PKLLZXNM.js → chunk-OEH47Y2L.js} +1 -1
- package/dist/chunk-RKREEPCT.js +1 -0
- package/dist/{chunk-QVGTHPWT.js → chunk-SJNF6JDJ.js} +1 -1
- package/dist/chunk-THGLNE4K.js +1 -0
- package/dist/chunk-TUYBXAAK.js +1 -0
- package/dist/chunk-ZX2RWS3T.js +1 -0
- package/dist/content-FD2Q6XD6.js +1 -0
- package/dist/{coupon-Btz_KFKp.d.ts → coupon-DyKA-BRG.d.ts} +8 -0
- package/dist/funnel-host-purchase-XW7IF52Y.js +1 -0
- package/dist/{funnel-local-client-BYdKGnMb.d.ts → funnel-local-client-CSA9XoC4.d.ts} +3270 -32
- package/dist/{funnel-node-evaluation-eLMEZIFz.d.ts → funnel-node-evaluation-Cg-4tcAs.d.ts} +88 -0
- package/dist/funnel-process-client-RXgS2i-R.d.ts +23184 -0
- package/dist/funnel-runtime-host-I6PJXVRC.js +1 -0
- package/dist/index.d.ts +1219 -31
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +2 -2
- package/dist/openrouter.js +1 -1
- package/dist/page.js +1 -1
- package/dist/paywall-CGBFHFRU.js +1 -0
- package/dist/popup.d.ts +3 -3
- package/dist/popup.js +1 -1
- package/dist/{presentation-loading-Ctk1djAi.d.ts → presentation-loading-D0A9G_kT.d.ts} +16 -2
- package/dist/react-native.d.ts +6 -6
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-WOMWOEYL.js +1 -0
- package/dist/server.d.ts +2402 -17
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3J24TUO7.js +0 -1
- package/dist/chunk-6DTGBDYG.js +0 -1
- package/dist/chunk-DUZ2E7BK.js +0 -1
- package/dist/chunk-IIYIIXNB.js +0 -1
- package/dist/chunk-KRQESEG2.js +0 -6
- package/dist/chunk-WMIDEJTZ.js +0 -1
- package/dist/chunk-YAVWELIV.js +0 -1
- package/dist/content-FM52HLRX.js +0 -1
- package/dist/funnel-process-client-C87pmLC9.d.ts +0 -64499
- package/dist/funnel-runtime-host-MZKLVLC4.js +0 -1
- package/dist/paywall-JL4SXFXT.js +0 -1
- package/dist/screen-renderer-TEVGVUT5.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{pb as d}from"./chunk-O4535GJR.js";import{a as u}from"./chunk-DSPLGTQI.js";function m(e){if(!/^[A-Za-z0-9_-]{1,64}$/.test(e))throw new Error("Invalid device cookie name");let t="";for(let i of document.cookie.split(";"))if(i.trim().startsWith(`${e}=`))try{t=decodeURIComponent(i.trim().slice(e.length+1))}catch{}return/^[A-Za-z0-9_-]{8,128}$/.test(t)||(t=crypto.randomUUID(),document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${400*24*3600}; SameSite=Lax`),t}function y(){try{let e=sessionStorage.getItem("indiana_sid");return e||(e=crypto.randomUUID(),sessionStorage.setItem("indiana_sid",e)),e}catch{return}}function g(e=d){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(t.hostname))||t.username||t.password||t.search||t.hash)throw new Error("baseUrl must be an https origin without credentials");return t.origin}var o=new Set,s;function S(e){let t=()=>e();if(o.add(t),!s){let i=!0,a=history.pushState,p=history.replaceState,r=()=>{if(i)for(let n of[...o])o.has(n)&&u(n)},c=function(...n){a.apply(this,n),r()},h=function(...n){p.apply(this,n),r()};history.pushState=c,history.replaceState=h,addEventListener("popstate",r),addEventListener("hashchange",r),s=()=>{i=!1,history.pushState===c&&(history.pushState=a),history.replaceState===h&&(history.replaceState=p),removeEventListener("popstate",r),removeEventListener("hashchange",r)}}return()=>{o.delete(t)&&(o.size||(s?.(),s=void 0))}}export{m as a,y as b,g as c,S as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"./chunk-SJNF6JDJ.js";function d(t){let{quote:r,operation:e,requestId:i}=t,o={type:"recover",operationId:e?.operationId??r?.operationId??null,requestId:i};if(t.destroyed||t.pending)return o;if(!e)return r?{type:"cancel",operationId:r.operationId}:o;let n=e.merchantExecution;if(n?.type==="purchase"){if(["succeeded","not_required"].includes(n.paymentStatus))return!["applied","not_applicable"].includes(n.fulfillmentStatus)||e.problem?.phase==="fulfillment"||n.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:n.recordingStatus==="accepted"&&e.status==="complete"&&!e.problem&&!n.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&e.checkoutUrl&&n.checkoutUrl===e.checkoutUrl&&n.checkoutExpiresAt&&Date.parse(n.checkoutExpiresAt)>Date.now()&&["not_started","pending"].includes(n.paymentStatus))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl}}if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&!e.nativePurchase&&(!r||Date.parse(r.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let p=[e.problem,n?.problem],s=p.every(l=>!l||l.phase==="execution"&&l.reason!=="RESULT_UNKNOWN");return!p.some(Boolean)&&e.status==="complete"&&e.executor!=="merchant"?{type:"complete",operationId:e.operationId}:s&&t.canReselect!==!1&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"?!e.confirmedAt&&(e.status==="cancelled"||!e.quoteFinalized):!n&&!e.quoteFinalized||n?.type==="purchase"&&["failed","expired"].includes(n.paymentStatus)&&n.fulfillmentStatus==="not_applicable"&&n.recordingStatus==="accepted")?{type:"native",operationId:e.operationId}:e.status==="pending"&&s&&!e.quoteFinalized&&!n&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase?{type:"cancel",operationId:e.operationId}:o}function f(t,r=!0){if(!t)return!1;let e=d({quote:t.quote??null,operation:t,requestId:null,pending:!1,destroyed:!1,canReselect:r});return e.type==="complete"||e.type==="native"}function u(t){return t.recovery??{type:"recover",operationId:t.operation?.operationId??t.quote?.operationId??null,requestId:null}}async function y(t){let r=u(t);if(r.type==="recover"&&t.quote)try{await t.read(),r=u(t)}catch{return r}if(r.type!=="cancel"&&!(r.type==="recover"&&t.pendingCancellation))return r;try{await t.cancel();let e=u(t);return e.type==="cancel"?{type:"recover",operationId:r.operationId,requestId:null}:e}catch{let e=u(t);return e.type==="recover"?e:{type:"recover",operationId:r.operationId,requestId:null}}}function m(t,r){let e=structuredClone(t);for(let[i,a]of Object.entries(e.plans)){let o=r.plans[i];!o||o.versionId!==a.versionId||(o.amountMinor!==void 0&&(a.amountMinor=o.amountMinor),o.interval!==void 0&&(a.interval=o.interval),o.intervalCount!==void 0&&(a.intervalCount=o.intervalCount),o.prepaid!==void 0&&(a.prepaid=structuredClone(o.prepaid)))}return e}function b(t,r){let e=i=>"document"in i?i.offering.id:i.content.offeringVersionId;return t.id===r.id&&e(t)===e(r)&&t.content?.artifact.sha256===r.content?.artifact.sha256}function S(t,r,e){if(t.operationId!==r.operationId||r.currency!==void 0&&t.currency!==r.currency)throw new c("INVALID_RESPONSE",e)}function v(t,r,e){let i=Object.fromEntries((t.lines[0]?.prepaid??[]).map(a=>[a.internal_feature_id,a.quantity]));if(r.featureQuantities&&(Object.keys(i).length!==Object.keys(r.featureQuantities).length||Object.entries(r.featureQuantities).some(([a,o])=>i[a]!==o)))throw new c("INVALID_RESPONSE","The purchase quote changed its selected quantities");if(t.lines.length!==1||t.lines[0].productVersionId!==r.productVersionId||r.currency!==void 0&&t.currency!==r.currency||r.provider!==void 0&&t.provider!==r.provider&&!(r.provider==="stripe"&&t.provider==="merchant"&&t.execution?.provider==="merchant"))throw new c("INVALID_RESPONSE",e)}function g(t,r,e=!1){if(!t||t.operationId!==r?.operationId)return r;let i=t.merchantExecution,a=r.merchantExecution;return i&&(!a||Date.parse(a.updatedAt)<Date.parse(i.updatedAt))||t.status==="complete"&&r.status!=="complete"||t.status!=="pending"&&(r.status==="pending"||e&&r.status!=="complete")?t:r}export{d as a,f as b,u as c,y as d,m as e,b as f,S as g,v as h,g as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as o}from"./chunk-
|
|
1
|
+
import{g as o}from"./chunk-MHEYMXGZ.js";var n=class extends Error{constructor(t,s,y,i,r){super(s);this.code=t;this.status=y;this.requestId=i;this.name="IndianaError",this.reason=r?.reason;let e=o(t,y??0,{...r,retryAfter:r?.retryAfterSeconds===void 0?void 0:String(r.retryAfterSeconds)});this.retryable=e.retryable,this.recovery=e.recovery,this.retryAfterSeconds=e.retryAfterSeconds}code;status;requestId;commandRequestId;retryable;recovery;retryAfterSeconds;reason};export{n as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-LFFBNGXP.js";import{a}from"./chunk-SJNF6JDJ.js";import{Da as o}from"./chunk-O4535GJR.js";function p(r){if(r!==null&&typeof r=="object"&&"customerId"in r)throw new a("INVALID_REQUEST","Customer requests use the verified session identity")}function m(r){return{async previewUpdate(t){p(t);let e=o.previewUpdate;return i(r,e,t)},async update(t){p(t);let e=o.update;return i(r,e,t)},async readSubscriptionUpdate(t){p(t);let e=o.readSubscriptionUpdate;return i(r,e,t)},async restoreNativePurchase(t){p(t);let e=o.restoreNativePurchase;return i(r,e,t)},async previewAttach(t){p(t);let e=o.previewAttach;return i(r,e,t)},async attach(t){p(t);let e=o.attach;return i(r,e,t)},async readSubscriptionOperation(t){p(t);let e=o.readSubscriptionOperation;return i(r,e,t)}}}export{p as a,m as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ge,b as Je,c as He,l as Ke,m as we,q as $e}from"./chunk-LFFBNGXP.js";import{a as Qe,f as Ye,g as We,h as Xe,i as Ze}from"./chunk-RKREEPCT.js";import{a as ye,b as he}from"./chunk-5HJMAZ7A.js";import{a as w}from"./chunk-SJNF6JDJ.js";import{b as je,c as ze}from"./chunk-2ZJ5CS5Q.js";import{$ as Ne,Da as Z,Z as Re,aa as Fe,ba as Te,ca as De,cb as Ge,ib as qe,ma as Le,na as _e,o as Se,oa as z,pa as Ve,pb as Be,q as me,qa as Ie,ra as M,ta as Ue,ua as Me,va as ke}from"./chunk-O4535GJR.js";import{a as et}from"./chunk-DSPLGTQI.js";import{C as Ee,J as Oe,M as Pe,Na as xe,P as pe}from"./chunk-MHEYMXGZ.js";function ft(n){let e=null,u=null,I=0,d=0,C=new Set,f=null,p=null,s=new Set,v=()=>{for(let o of s)try{o()}catch{}},l={attributes:pe.parse(n.attributes??{}),onFeatureUsage:n.onFeatureUsage?(o,h)=>{!C.has(o)&&e&&(!("analyticsConfig"in e)||e.analyticsConfig.featureUsageEnabled)&&n.onFeatureUsage(o,structuredClone(h),structuredClone(l.attributes),e.generation)}:void 0,onExperimentViewed:n.onExperimentViewed?(o,h)=>e&&(!("analyticsConfig"in e)||e.analyticsConfig.experimentViewsEnabled)&&n.onExperimentViewed(structuredClone(o),structuredClone(h),structuredClone(l.attributes),e.generation):void 0,stickyBucketAssignmentDocs:structuredClone(n.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:n.saveStickyBucketAssignmentDoc?o=>n.saveStickyBucketAssignmentDoc(structuredClone(o)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},S=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function m(o,h=new Set){return C.has(o)?!f||!f.features[o]||["unknownFeature","cyclicPrerequisite"].includes(f.features[o].source):h.has(o)?!1:(h.add(o),(e?.features[o]?.rules??[]).some(P=>[...P.parentConditions??[],...(P.tracks??[]).flatMap(E=>E.experiment.parentConditions??[])].some(E=>m(E.id,h))))}let y=o=>{if(n.assertUsable?.(e?.generation),!e)throw new Error("Initialize the Feature client before evaluation");if(e.expiresAt&&Date.parse(e.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return f?.expiresAt&&Date.parse(f.expiresAt)<=Date.now()&&(f=null,l.features=e.features),C.has(o)?!f||f.expiresAt&&Date.parse(f.expiresAt)<=Date.now()?S():structuredClone(f.features[o]??S()):n.evaluateRemote&&(l.attributes?.merchandise||l.attributes?.merchandiseId)&&!f||m(o)?S():structuredClone(Pe(o,l))};async function _(){if(!e||!C.size&&!l.attributes?.merchandise&&!l.attributes?.merchandiseId)return;if(!n.evaluateRemote){if(C.size)throw new Error("Remote Feature evaluation requires a server loader");return}let o=d;if(p?.revision===o)return p.loading;let h=I,P=e,E=[...C],N=(async()=>{let A=De.parse(await n.evaluateRemote({attributes:structuredClone(l.attributes),features:E}));if(!(h!==I||o!==d||P!==e)){if(n.assertUsable?.(P.generation),A.generation!==P.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(E.some(D=>!Object.hasOwn(A.features,D))||Object.keys(A.features).some(D=>!C.has(D)))throw new Error("Invalid remote Feature results");if(l.attributes?.merchandise||l.attributes?.merchandiseId){if(!A.merchandiseContext)throw new Error("Server did not resolve merchandise context");l.attributes=pe.parse({...l.attributes,...A.merchandiseContext})}f=structuredClone(A),l.features={...P.features,...Object.fromEntries(Object.entries(f.features).map(([D,q])=>[D,{defaultValue:q.value}]))},v()}})();p={revision:o,loading:N};try{await N}finally{p?.loading===N&&(p=null)}}function T(){_().catch(o=>{try{n.onError?.(o)}catch{}})}async function G(){if(u)return u;let o=I,h=(async()=>{let P=await n.load(),E="remoteFeatures"in P?Fe.parse(P):null,N=E??Ne.parse(P);if(N.scope.projectId!==n.scope.projectId||N.scope.environment!==n.scope.environment)throw new Error("Feature payload scope changed");if(o!==I)throw new Error("Feature client was reset");if(n.assertUsable&&e?.generation===N.generation){let{evaluatedAt:D,expiresAt:q,...te}=e,{evaluatedAt:g,expiresAt:L,...F}=N;if(M(te)!==M(F))throw new Error("Immutable Feature generation changed content");return e.evaluatedAt=N.evaluatedAt,e.expiresAt=N.expiresAt,v(),(!f||f.expiresAt&&Date.parse(f.expiresAt)<=Date.now())&&T(),structuredClone(e)}let A=new Set(E?.remoteFeatures??[]);if([...A].some(D=>Object.hasOwn(N.features,D)))throw new Error("Remote Feature definitions must not be delivered locally");return e&&"analyticsConfig"in e&&"analyticsConfig"in N&&!e.analyticsConfig.experimentViewsEnabled&&E?.analyticsConfig.experimentViewsEnabled&&l.trackedExperiments?.clear(),e=structuredClone(N),C=A,f=null,p=null,d++,l.features=e.features,l.savedGroups=Oe(e.savedGroups),l.trackedFeatureUsage={},v(),T(),structuredClone(e)})();u=h;try{return await h}finally{u===h&&(u=null)}}return{init:G,refresh:G,refreshRemote:_,get generation(){return e?.generation??null},get expiresAt(){return e?.expiresAt??null},subscribe(o){return s.add(o),()=>{s.delete(o)}},setAttributes(o){let h=pe.parse(o);(l.attributes?.merchandise||l.attributes?.merchandiseId||o.merchandise||o.merchandiseId)&&l.trackedExperiments?.clear(),l.attributes=h,d++,f=null,p=null,l.features=e?.features??{},l.trackedFeatureUsage={},v(),T()},evalFeature:y,isOn(o){return y(o).on},isOff(o){return y(o).off},getFeatureValue(o,h){let P=y(o).value;return structuredClone(P===null?h:P)},reset(){I++,d++,u=null,p=null,e=null,f=null,C.clear(),l.features={},l.savedGroups={},l.stickyBucketAssignmentDocs={},l.attributes={},l.trackedFeatureUsage={},l.trackedExperiments?.clear(),v()}}}function at(n,e,u,I){if(!Ee(n,e)||u!==void 0&&e.observation&&e.observation.subject.customerId!==u||I!==void 0&&e.observation!==void 0&&(e.observation.subject.scope.projectId!==I.projectId||e.observation.subject.scope.environment!==I.environment))throw new w("INVALID_RESPONSE","The access requirement or Customer changed");return e}function tt(n,e,u){if(n.requirement){if(!e)throw new w("INVALID_RESPONSE","The requested access check is missing");at(n.requirement,e,n.customerId,u)}}async function Et(n,e){if(!me.test(e.customerToken))throw new w("INVALID_TOKEN","A verified Customer credential is required");if(n.session&&n.session.peek()!==e.customerToken)throw new w("SCOPE_MISMATCH","Paywall credential does not match the shared session");let u=Z.resolvePaywall.request.parse({funnelId:e.funnelId,funnelVersionId:e.funnelVersionId,selector:e.paywallVersionId?{type:"version",versionId:e.paywallVersionId}:{type:"paywall",paywallId:e.paywallId},commerce:e.commerce,locale:e.locale,...e.requirement?{requirement:e.requirement}:{}}),I=he(n);n.session||I.identify(e.customerToken);let d=null,C=!1,f=new AbortController,p=null,s=null,v=null,l=null,S=null,m=null,y=null,_=0,T=null,G="",o=0,h=new Map,P=new Set;function E(){if(C)throw new w("IDENTITY_CHANGED","Paywall is closed")}function N(){let g=JSON.stringify([_,y!==null]);if(!T||g!==G){G=g;let L=A(++o);T=L;let F=()=>{T===L&&(T=null)};L.then(F,F)}return T.then(L=>structuredClone(L))}async function A(g){E();let L=Z.resolvePaywall,F=await ge(I.request,L,{...u,selector:d?{type:"version",versionId:d.id}:u.selector});tt(u,F.paywall.check,F.scope);let x=await He(n,F.paywall);if(E(),e.paywallVersionId?x.id!==e.paywallVersionId:x.paywallId!==e.paywallId)throw new w("INVALID_RESPONSE","The requested Paywall changed");if(d&&(!Ye(x,d)||x.paywallId!==d.paywallId))throw new w("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");if(g!==o)return structuredClone(d??x);d=x;for(let H of P)et(H,structuredClone(d));return structuredClone(d)}async function D(g){if(E(),l&&g!=="read")throw new w("COMMAND_PENDING","Wait for the original quote");if(!p)throw new w("INVALID_REQUEST","A quoted purchase is required");let L=p;if(g!=="read"){if(y){if(m===g)return y;throw new w("COMMAND_PENDING","Wait for the original purchase command")}if(m&&m!==g)throw new w("COMMAND_PENDING","Read the original purchase before changing an uncertain command");m=g,_++,o++}let F=m,x=_,H=g==="read"&&y===null,B=JSON.stringify([L.operationId,x,y!==null]);if(g==="read"&&h.has(B))return h.get(B).then(V=>structuredClone(V));let $=g==="read"?Z.readSubscriptionOperation:Z.attach,J=(async()=>{let V=await ge(I.request,$,{operationId:L.operationId,...g==="read"?{}:{intent:g},...g==="confirm"&&L.merchantTerms?{merchantConfirmation:Se(L.merchantTerms)}:{}});return We(V.operation,{operationId:L.operationId,currency:u.commerce.currency},"The purchase operation changed"),E(),p?.operationId!==L.operationId?structuredClone(V.operation):(s=Ze(s,V.operation),(g!=="read"||H&&y===null)&&_===x&&m===F&&(m=null),structuredClone(s))})();if(g!=="read"){y=J;let V=()=>{y===J&&(y=null)};J.then(V,V)}else{h.set(B,J);let V=()=>{h.get(B)===J&&h.delete(B)};J.then(V,V)}return J.then(V=>structuredClone(V))}let q={signal:f.signal,get view(){return d?structuredClone(d):null},get quote(){return p?structuredClone(p):null},get operation(){return s?structuredClone(s):null},get webViewUrl(){return"bundled"},get recovery(){return Qe({quote:p,operation:s,requestId:S,pending:l!==null||m!==null,destroyed:C})},get pendingCancellation(){return!C&&m==="cancel"},refresh:N,subscribe(g){return C?()=>{}:(P.add(g),()=>P.delete(g))},async preview(g){if(E(),!d)throw new w("INVALID_REQUEST","Load the Paywall first");let L=d.document.buttons[g.actionId];if(L?.type!=="checkout")throw new w("INVALID_REQUEST","Choose an authored purchase action");let F=Re(L.product,g.selection,d.capabilities);if(!F)throw new w("PRODUCT_UNAVAILABLE","Choose an available Product");let x=xe(d.document.screen,F,g.selection,d.capabilities),H=Z.previewAttach.request.parse({funnelId:u.funnelId,funnelVersionId:u.funnelVersionId,requestId:g.requestId,plans:[{productVersionId:F,...Object.keys(x).length?{featureQuantities:x}:{}}],provider:u.commerce.provider,currency:u.commerce.currency,...g.offerId?{offerId:g.offerId}:{},...g.nativeOffer?{nativeOffer:g.nativeOffer}:{}}),B=JSON.stringify(H);if(v&&v!==B&&(l||m||!s||s.status==="pending"))throw new w("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(v===B){if(l)return l;if(p)return structuredClone(p)}v!==B&&(p=null,s=null),v=B,S=H.requestId;let $=(async()=>{let J=Z.previewAttach,V=await ge(I.request,J,H);return E(),Xe(V.quote,{productVersionId:F,featureQuantities:x,currency:u.commerce.currency,provider:u.commerce.provider},"The purchase quote changed its selected Product or presentment"),p=V.quote,s=null,structuredClone(p)})();l=$;try{return await $}finally{l===$&&(l=null)}},confirm:()=>D("confirm"),cancel:()=>D("cancel"),read:()=>D("read"),destroy(){C||(C=!0,f.abort(),P.clear(),h.clear(),te?.(),I.dispose(),d=null,p=null,s=null,v=null,S=null)}},te=n.session?.subscribeIdentity(q.destroy);try{return await N(),q}catch(g){throw q.destroy(),g}}import{z as ct}from"zod";import{z as le}from"zod";var st=le.record(le.string().regex(/^[a-f0-9]{64}$/),le.strictObject({at:le.number(),text:le.string()})),ee=2*1048576,ut=100;function lt(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function nt(n,e){let u=e===void 0?lt():e,I=new Map,d=0,C=!1,f=!1,p,s;async function v(S){if(!u)return null;let m;try{let y=await Promise.race([Promise.resolve().then(()=>u.getItem(S)),new Promise(_=>{m=setTimeout(()=>_(null),ut)})]);return typeof y=="string"&&y.length<=ee&&new TextEncoder().encode(y).byteLength<=ee?y:null}catch{return null}finally{clearTimeout(m)}}function l(){if(s)return s;let S=(async()=>{try{let m=await v(`${n}:artifacts`);if(m)return st.parse(JSON.parse(m))}catch{}return{}})();return s=S,S.finally(()=>{s===S&&(s=void 0)}),S}return{async readManifest(){return v(n)},writeManifest(S){!u||S.length>ee||new TextEncoder().encode(S).byteLength>ee||(p=S,!f&&(f=!0,Promise.resolve().then(async()=>{try{for(;p!==void 0;){let m=p;try{await u.setItem(n,m)}catch{}p===m&&(p=void 0)}}finally{f=!1}})))},async readArtifact(S){let m=(await l())[S],y=Date.now();return m&&y>=m.at&&y-m.at<=z.retentionMs?m.text:void 0},writeArtifact(S,m){if(!u||m.length>ee)return;let y=I.get(S);if(y?.text===m||!y&&I.size>=128)return;let _=new TextEncoder().encode(m).byteLength;d-(y?.byteLength??0)+_>ee||(I.set(S,{text:m,byteLength:_}),d+=_-(y?.byteLength??0),!C&&(C=!0,Promise.resolve().then(async()=>{try{for(;I.size;){let T=new Map(I);try{let G={...await l()},o=Date.now();for(let[N,A]of T)G[N]={at:o,text:A.text};let h={},P=2,E=0;for(let[N,A]of Object.entries(G).sort(([,D],[,q])=>q.at-D.at)){if(A.at>o||o-A.at>z.retentionMs)continue;let D=new TextEncoder().encode(JSON.stringify({[N]:A})).byteLength;P+D>ee||E>=128||(h[N]=A,P+=D,E++)}await u.setItem(`${n}:artifacts`,JSON.stringify(h))}catch{}finally{for(let[G,o]of T)I.get(G)===o&&(I.delete(G),d-=o.byteLength)}}}finally{C=!1}})))}}}var c=(n,e)=>new w(n,e),Y=()=>performance.now(),rt=n=>{typeof n=="object"&&"unref"in n&&n.unref()};function Ut(n){let e=Ve.parse(n.scope),u=new ye(n.origin??Be);if(u.username||u.password||u.search||u.hash||u.pathname!=="/"||u.protocol!=="https:"&&!(u.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(u.hostname)))throw c("INVALID_URL","Configuration requires a trusted HTTPS origin");let I=new Set([u.origin,...(n.assetOrigins??[]).map(r=>{let t=new ye(r);if(t.protocol!=="https:"||t.username||t.password||t.search||t.hash||t.pathname!=="/")throw c("INVALID_URL","Invalid configuration asset origin");return t.origin})]),d=n.fetch??globalThis.fetch.bind(globalThis),C=`/api/v1/configuration/${e.environmentId}`,f=`indiana:configuration:1:${u.origin}:${M(e)}`,p=nt(f,n.storage),s,v=0,l=0,S=!1,m=!1,y=0,_=0,T,G,o,h,P=0,E=new Set,N=new Set,A=new Map,D=new Map,q=0,te=!1;function g(){for(let r of E)try{r()}catch{}}function L(r){try{n.onError?.(r)}catch{}}let F=()=>!m&&!S&&!!s&&Y()<v&&Date.now()<l;function x(){if(!F())throw c("CONFIGURATION_EXPIRED","Refresh configuration before using it")}function H(r,t,i){if(!A.has(r)){for(;A.size&&(A.size>=128||q+i>z.maxCacheBytes);){let a=A.entries().next().value;q-=a[1].byteLength,A.delete(a[0])}A.set(r,{text:t,byteLength:i}),q+=i}}function B(r,t,i){return je(r,t,{signal:i,error:a=>c("INVALID_RESPONSE",a==="missing"?"Configuration body is missing":"Configuration exceeds its byte limit")})}function $(r){let t=new ye(r,u);if(!I.has(t.origin)||t.username||t.password||t.hash||t.search)throw c("INVALID_URL","Configuration artifact origin is not trusted");return t.href}async function J(r,t,i=!1){let a=await d($(r),{method:"GET",credentials:"omit",redirect:"error",cache:i?"default":"no-cache",signal:t,headers:{}});if(a.status===429){let O=a.headers.get("retry-after")??"";P=/^\d+$/.test(O)?Number(O)*1e3:Math.max(0,Date.parse(O)-Date.now())||15e3}if(!a.ok&&a.status!==304)throw c(`CONFIGURATION_HTTP_${a.status}`,"Configuration synchronization failed");return a}function V(r,t,i){let a=Date.parse(r.headers.get("x-indiana-config-validated-at")??""),O=Date.parse(r.headers.get("x-indiana-config-valid-until")??""),R=Date.parse(r.headers.get("date")??""),b=r.headers.get("age"),j=b!==null&&/^\d+(\.\d+)?$/.test(b)?Number(b)*1e3:NaN;if(![a,O,R,j].every(Number.isFinite)||O<=a||O-a>z.maxControlAgeMs||a>R+1e3)throw c("INVALID_RESPONSE","Configuration freshness evidence is invalid");let U=Math.min(O-a,i.maxControlAgeSeconds*1e3,z.maxControlAgeMs)-Math.max(j,R-a,0)-(Y()-t);if(U<=0)throw c("CONFIGURATION_EXPIRED","Configuration validation expired in transit");return Y()+U}function ce(){if(clearTimeout(o),clearTimeout(h),m||!E.size||(F()&&(h=setTimeout(()=>{F()?ce():g()},Math.max(1,v-Y())),rt(h)),typeof document<"u"&&document.visibilityState==="hidden"))return;let r=_?Math.min(15e3,1e3*2**Math.min(_-1,4)):Math.min(15e3,(s?.policy.refreshIntervalSeconds??15)*1e3);o=setTimeout(()=>{ne().catch(L)},Math.max(P,r*(.8+Math.random()*.2))),rt(o)}async function ne(){if(m)throw c("CONFIGURATION_DISPOSED","Configuration manager was destroyed");if(T)return T;let r=y,t=new AbortController;G=t;let i=(async()=>{if(!te){te=!0;try{let fe=await p.readManifest();if(fe&&!s){let Q=Ie.parse(JSON.parse(fe));M(Q.scope)===M(e)&&(s=Q)}}catch{}}t.signal.throwIfAborted();let b=s,j=Y(),k=await J(C,t.signal);k.status===304&&(!b||!k.headers.has("x-indiana-config-validated-at")||!k.headers.has("x-indiana-config-valid-until")||!k.headers.has("age"))&&(k=await J(C,t.signal));let U=k.status===304?b:Ie.parse(JSON.parse(await B(k,z.maxManifestBytes,t.signal))),{generation:ae,...se}=U,K=k.headers.get("etag");if(M(U.scope)!==M(e)||Ue(se)!==ae||K!==`"${ae}"`&&K!==`W/"${ae}"`)throw c("INVALID_RESPONSE","Configuration scope or content identity changed");if(b&&(U.revision<b.revision||U.revision===b.revision&&U.generation!==b.generation))throw c("INVALID_RESPONSE","Configuration revision moved backwards or changed identity");for(let[fe,Q]of Object.entries(b?.funnels??{})){let X=U.funnels[fe];if(X&&(X.controlRevision<Q.controlRevision||X.evaluationRevision<Q.evaluationRevision||X.controlRevision===Q.controlRevision&&X.state!==Q.state||X.evaluationRevision===Q.evaluationRevision&&X.evaluationMode!==Q.evaluationMode))throw c("INVALID_RESPONSE","Funnel control revision changed identity")}let W=V(k,j,U.policy);if(t.signal.throwIfAborted(),r!==y)throw c("CONFIGURATION_DISPOSED","Configuration scope changed");return s=U,v=W,l=Date.now()+Math.max(0,W-Y()),S=!1,_=0,P=0,p.writeManifest(M(U)),g(),structuredClone(U)})(),a=setTimeout(()=>t.abort(c("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),z.initializationMs),O=new Promise((b,j)=>t.signal.addEventListener("abort",()=>j(t.signal.reason),{once:!0})),R=Promise.race([i,O]).catch(b=>{throw _++,(b instanceof ct.ZodError||b instanceof SyntaxError||b instanceof w&&["CONFIGURATION_HTTP_404","CONFIGURATION_HTTP_410","INVALID_RESPONSE"].includes(b.code))&&(v=0,S=!0,g()),b}).finally(()=>{clearTimeout(a),T===R&&(T=void 0),ce()});return T=R,R}async function de(r){let t=r.sha256,i=se=>ze(se,r);$(r.url);let a=A.get(t);if(a){if(a.byteLength!==r.byteLength)throw c("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return A.delete(t),A.set(t,a),a.text}let O=D.get(t);if(O){if(O.byteLength!==r.byteLength)throw c("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return O.promise}let R=new AbortController;N.add(R);let b=y,j=(async()=>{try{let W=await p.readArtifact(t);if(W&&i(W)){if(R.signal.throwIfAborted(),m||b!==y)throw c("CONFIGURATION_DISPOSED","Configuration scope changed");return H(t,W,r.byteLength),W}}catch{}R.signal.throwIfAborted();let se=await J(r.url,R.signal,!0),K=await B(se,r.byteLength,R.signal);if(!i(K))throw c("INVALID_RESPONSE","Configuration artifact digest or size mismatch");if(m||b!==y)throw c("CONFIGURATION_DISPOSED","Configuration scope changed");return H(t,K,r.byteLength),p.writeArtifact(t,K),K})(),k=setTimeout(()=>R.abort(c("CONFIGURATION_UNAVAILABLE","Configuration artifact timed out")),z.initializationMs),U=new Promise((se,K)=>R.signal.addEventListener("abort",()=>K(R.signal.reason),{once:!0})),ae=Promise.race([j,U]).finally(()=>{clearTimeout(k),N.delete(R),D.delete(t)});return D.set(t,{promise:ae,byteLength:r.byteLength}),ae}async function ue(){return F()||await ne(),x(),s}async function re(r){let t,i=new Promise((a,O)=>{t=setTimeout(()=>O(c("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),z.initializationMs)});try{return await Promise.race([r(),i])}finally{clearTimeout(t)}}function oe(r,t){if(x(),s?.generation!==r.generation)throw c("CONFIGURATION_CHANGED","Configuration changed while preparing a snapshot");if(t&&s.funnels[t]?.state!=="active")throw c("FUNNEL_STOPPED","Funnel is paused or unavailable")}async function ve(r){let t=r.gb.features;if(!t)throw c("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");let i=r.artifacts[t];if(i.formatVersion!==1)throw c("UNSUPPORTED_SCHEMA","Unsupported public GB configuration format");let a=Te.parse(JSON.parse(await de(i)));if(M(a.scope)!==M({projectId:e.projectId,environment:e.environment})||a.generation!==i.generation||a.remoteFeatures.some(O=>Object.hasOwn(a.features,O)))throw c("INVALID_RESPONSE","Public GB configuration scope or generation is invalid");return oe(r),{...a,evaluatedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+Math.max(0,v-Y())).toISOString()}}async function be(r,t){let i=await ue(),a=i.funnels[r];t&&(!a||a.evaluationMode==="local"&&!a.versions[t])&&(T&&await T,i=await ne()),oe(i,r);let O=i.funnels[r];if(O.evaluationMode!=="local")throw c("EVALUATION_MODE","This Funnel executes at Longplay; public graph loading is disabled");let R=t??O.currentVersionId,b=O.versions[R];if(!b)throw c("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable");if(i.artifacts[b.artifact].formatVersion!==3)throw c("UNSUPPORTED_SCHEMA","Unsupported public Funnel format");let[j,k]=await Promise.all([de(i.artifacts[b.artifact]).then(U=>ke(JSON.parse(U))),O.evaluationMode==="local"?ve(i):void 0]);if(k&&M(Me(j,k))!==M(b.dependencies))throw c("INVALID_RESPONSE","Funnel and GB dependency contract do not match");return oe(i,r),{document:j,growth:k,versionId:R,control:structuredClone(O),manifest:structuredClone(i)}}async function Ce(r,t){try{return await be(r,t)}catch(i){if(!(i instanceof w)||!(i.code==="CONFIGURATION_CHANGED"||i.code==="CONFIGURATION_HTTP_404"&&F()))throw i;let a=s?.generation;if(T&&await T,await ne(),i.code!=="CONFIGURATION_CHANGED"&&s?.generation===a)throw i;return be(r,t)}}function ie(){if(F()||g(),typeof document<"u"&&document.visibilityState==="hidden"){ce();return}ne().catch(L)}function it(r){if(m)throw c("CONFIGURATION_DISPOSED","Configuration manager was destroyed");return E.add(r),E.size===1&&(typeof window<"u"&&(window.addEventListener("online",ie),window.addEventListener("focus",ie),document.addEventListener("visibilitychange",ie)),ce()),()=>{E.delete(r),E.size||(clearTimeout(o),clearTimeout(h),Ae())}}function Ae(){typeof window<"u"&&(window.removeEventListener("online",ie),window.removeEventListener("focus",ie),document.removeEventListener("visibilitychange",ie))}return{scope:Object.freeze({...e}),refresh:ne,subscribe:it,assertFresh:x,assertFeatures(r){x();let t=s.gb.features;if(!t)throw c("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");if(r!==void 0&&s.artifacts[t].generation!==r)throw c("CONFIGURATION_CHANGED","Refresh changed Feature configuration before evaluation")},get fresh(){return F()},get snapshot(){return s?structuredClone(s):null},get remainingMs(){return F()?Math.max(0,v-Y()):0},async features(){return re(async()=>ve(await ue()))},pageExperiments:()=>re(async()=>{let r=await ue(),t=r.gb.pageExperiments;if(!t)throw c("CONFIGURATION_UNAVAILABLE","Public page experiments are disabled");let i=r.artifacts[t];if(i.formatVersion!==1)throw c("UNSUPPORTED_SCHEMA","Unsupported page experiment format");let a=qe.parse(JSON.parse(await de(i)));if(a.environmentId!==e.environmentId||a.generation!==i.generation)throw c("INVALID_RESPONSE","Page experiment scope or generation changed");return oe(r),a}),funnel:(r,t)=>re(()=>Ce(r,t)),funnelControl:r=>re(async()=>{let t=await ue();return oe(t,r),structuredClone(t.funnels[r])}),paywall:(r,t)=>re(async()=>{let i=await ue(),a=i.paywalls?.[r];if(!a||!t&&a.state!=="published")throw c("PAYWALL_UNAVAILABLE","Published Paywall is unavailable");let O=t??a.currentVersionId,R=a.versions[O],b=R&&i.artifacts[R.artifact];if(!b||b.kind!=="paywall"||b.formatVersion!==1)throw c("UNSUPPORTED_SCHEMA","Public Paywall format is unavailable");let j=_e.parse(JSON.parse(await de(b)));return oe(i),{document:j,versionId:O,version:R.version,control:structuredClone(a),manifest:structuredClone(i)}}),async localFunnel(r,t){let i=await re(()=>Ce(r,t));if(!i.growth)throw c("EVALUATION_MODE","This Funnel requires remote execution");let{analyticsConfig:a,remoteFeatures:O,...R}=i.growth;return Ge({scope:{projectId:e.projectId,environment:e.environment},funnelId:r,versionId:i.versionId,evaluationMode:"local",evaluationRevision:i.control.evaluationRevision,document:i.document,payload:R})},assertFunnel(r,t,i){x();let a=s.funnels[r];if(!a||a.state!=="active")throw c("FUNNEL_STOPPED","Funnel is paused or unavailable");if(a.evaluationMode!=="local")throw c("EVALUATION_MODE","This Funnel now executes at Longplay");if(t!==void 0&&a.controlRevision!==t)throw c("RUN_RECONCILIATION_REQUIRED","Reconcile the original Run after a control change");if(i!==void 0&&!a.versions[i])throw c("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable")},destroy(){if(!m){m=!0,y++,v=0,G?.abort(c("CONFIGURATION_DISPOSED","Configuration manager was destroyed")),clearTimeout(o),clearTimeout(h),Ae(),g(),E.clear();for(let r of N)r.abort(c("CONFIGURATION_DISPOSED","Configuration manager was destroyed"));A.clear(),q=0}}}}function ot(n){let e=me.test(n.apiKey);if(typeof window<"u"&&!e)throw new w("SERVER_ONLY","Funnel starts are issued by your backend");if(!e&&!we.test(n.apiKey))throw new w("INVALID_TOKEN","A customer credential or server API key is required");return{async start(u){let I=Le.safeParse({...u,operation:"start"});if(!I.success||I.data.operation!=="start"||(e?I.data.customer!==void 0:I.data.customer===void 0))throw new w("INVALID_REQUEST","Invalid current Funnel start");let d=I.data,C=he({...n,timeoutMs:n.timeoutMs??35e3});try{n.session||C.identify(n.apiKey);let f=Je(n,await C.request("funnels",d));if(!f.runToken)throw new w("INVALID_RESPONSE","Funnel start credentials are missing");if(f.run.source.id!==d.funnelId||f.run.locale!==(d.locale??"en")||!Ke(f.run.parameters,d.parameters??{})||(d.customer?!f.customerId||d.customer.type==="id"&&f.customerId!==d.customer.value:f.customerId!==void 0))throw new w("INVALID_RESPONSE","Funnel start contract changed");return{...f,runToken:f.runToken}}finally{C.dispose()}}}}async function Yt(n){n={...n};let e=n.configuration;if(!e)throw new w("CONFIGURATION_UNAVAILABLE","Local conditions require public configuration");let u={projectId:e.scope.projectId,environment:e.scope.environment};if(n.scope&&M(u)!==M(n.scope))throw new w("SCOPE_MISMATCH","Configuration and transport scopes differ");if((await e.funnelControl(n.funnelId)).evaluationMode!=="local")throw new w("EVALUATION_MODE","This Funnel uses Remote evaluation");let d=we.test(n.credential);if(d?!n.customerId:n.customerId!==void 0)throw new w("INVALID_REQUEST","Only Server-Key starts name their Customer");let C=ot({...n,scope:u,apiKey:n.credential}),f=(p,s)=>{let v=$e({...n,scope:u,runToken:p,initialResponse:s,...d?{serverKey:n.credential}:{}});return d||v.identify(n.credential),v};return{async start(p){let s=await C.start({...p,funnelId:n.funnelId,...d?{customer:{type:"id",value:n.customerId}}:{}}),v=f(s.runToken,s),l=await v.get();return{...s,...l,controller:v}},async restore(p){let s=f(p),v=await s.get();if(v.run.source.id!==n.funnelId)throw s.reset(),new w("SCOPE_MISMATCH","Run belongs to another Funnel");return{...v,runToken:p,controller:s}}}}export{at as a,tt as b,ft as c,Et as d,Ut as e,ot as f,Yt as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as P}from"./chunk-DSPLGTQI.js";import{sa as S}from"./chunk-MHEYMXGZ.js";var D=767;function ne(e,r,o=()=>!0,l="Close"){let n=e.ownerDocument.defaultView,i=e.ownerDocument.createElement("button");i.type="button",i.setAttribute("aria-label",l),i.style.cssText="position:absolute;inset:0 48px auto;z-index:2;height:24px;border:0;padding:0;background:transparent;touch-action:none;cursor:grab";let a=e.ownerDocument.createElement("span");a.style.cssText="display:block;width:36px;height:4px;border-radius:4px;margin:8px auto 12px;background:currentColor;opacity:.22;pointer-events:none",i.append(a),e.prepend(i);let p,s=0,c=!1,h=()=>{i.hidden=e.dataset.presentation!=="sheet",i.setAttribute("aria-disabled",String(!o()))},b=t=>{h(),!(i.hidden||!o()||t.button!==0)&&(p={y:t.clientY,time:Date.now(),id:t.pointerId},s=0,c=!1,i.setPointerCapture?.(t.pointerId))},x=t=>{!p||t.pointerId!==p.id||(s=Math.max(0,t.clientY-p.y),e.style.transform=`translateY(${s}px)`)},d=t=>{if(!p||t.pointerId!==p.id)return;let m=Math.max(1,Date.now()-p.time),y=t.type!=="pointercancel"&&o()&&(s>120||s>40&&s/m>.5);c=s>6,p=void 0,i.releasePointerCapture?.(t.pointerId),e.style.transform="",y?r():s&&typeof e.animate=="function"&&!n?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&e.animate([{transform:`translateY(${s}px)`},{transform:"none"}],{duration:200,easing:"cubic-bezier(.2,.8,.2,1)"}),s=0},u=()=>{if(c){c=!1;return}!p&&s===0&&o()&&r()};i.addEventListener("pointerdown",b),i.addEventListener("pointermove",x),i.addEventListener("pointerup",d),i.addEventListener("pointercancel",d),i.addEventListener("click",u);let f=typeof MutationObserver=="function"?new MutationObserver(h):void 0;return f?.observe(e,{attributes:!0,attributeFilter:["data-presentation"]}),n?.addEventListener("resize",h),h(),()=>{f?.disconnect(),n?.removeEventListener("resize",h),i.remove(),e.style.transform=""}}function I(e,r,o=!1){return(e.type==="modal"||e.type==="sheet")&&e.mobile&&o&&r<=D?e.mobile:e.type}function re(e,r,o){let l=e.ownerDocument.defaultView,n=r.presentation,i;if((n.type==="modal"||n.type==="sheet")&&n.backdrop){let t=`lp-backdrop-${crypto.randomUUID()}`,m={none:"transparent",scrim:"#f2f2f2cc",dim:"#0006","strong-dim":"#000000bf",blur:"#0006"};e.dataset.indianaBackdrop=t,i=e.ownerDocument.createElement("style"),i.textContent=`dialog[data-indiana-backdrop="${t}"]::backdrop{background:${m[n.backdrop]};backdrop-filter:${n.backdrop==="blur"?"blur(16px)":"none"}}`,e.append(i)}let a=r.pages?.[0]?.root.style?.shape,p=a?.type==="pill"?"9999px":a?.type==="rect"?typeof a.radius=="number"?`${a.radius}px`:[a.radius.topLeft,a.radius.topRight,a.radius.bottomRight,a.radius.bottomLeft].map(t=>`${t}px`).join(" "):void 0,s=(n.type==="modal"||n.type==="sheet")&&(n.desktopWidth!==void 0||n.mobile!==void 0),c=n.type,h,b,x=!1,d=t=>{x||!Number.isFinite(t)||t<0||(b=t,c!=="fullscreen"&&c!=="inline"&&(e.style.height=`min(${Math.max(t,40)}px, calc(100dvh - ${c==="sheet"?0:32}px))`))},u=()=>{if(!x&&(c=h??I(n,l?.innerWidth??1024,l?.matchMedia?.("(pointer: coarse)").matches===!0),e.dataset.presentation=c,!(!s||n.type!=="modal"&&n.type!=="sheet"))){if(e.style.boxSizing="border-box",e.style.padding="0",e.style.border="0",e.style.overflow="hidden",e.style.outline="none",e.tabIndex=-1,e.style.background=r.theme.background,e.style.color=r.theme.text,c==="fullscreen")e.style.width="100vw",e.style.height="100dvh",e.style.maxWidth="100vw",e.style.maxHeight="100dvh",e.style.margin="0",e.style.borderRadius="0";else{let t=n.mobile==="sheet"&&c==="sheet",m=n.desktopWidth,y=l?.innerWidth??1024;e.style.width=t?`${y}px`:m?`${Math.min(m.max,Math.max(y*m.viewport/100,m.min))}px`:`${S[n.size]}px`,e.style.maxWidth=`${Math.max(0,y-(c==="sheet"?0:32))}px`,e.style.maxHeight=c==="sheet"?"100dvh":"calc(100dvh - 32px)",e.style.margin=c==="sheet"?"auto auto 0":"auto",e.style.borderRadius=p??(c==="sheet"?"16px 16px 0 0":"24px"),e.style.height="",b!==void 0&&d(b)}o?.(c)}},f=s?[l?.matchMedia?.(`(max-width: ${D}px)`),l?.matchMedia?.("(pointer: coarse)")].filter(t=>t!==void 0):[];if(s){l?.addEventListener("resize",u);for(let t of f)t.addEventListener?t.addEventListener("change",u):t.addListener?.(u)}return u(),{responsive:s,get type(){return c},latch(){x||h!==void 0||(u(),h=c)},setContentHeight:d,destroy(){if(!x){x=!0,i?.remove(),delete e.dataset.indianaBackdrop,l?.removeEventListener("resize",u);for(let t of f)t.removeEventListener?t.removeEventListener("change",u):t.removeListener?.(u)}}}}function oe(e,r,o=!1){let l=e.ownerDocument.defaultView;if(typeof e.animate!="function"||l?.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let n=o?{duration:300,easing:"cubic-bezier(0.23, 1, 0.32, 1)"}:{duration:240,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)"};e.animate(r==="sheet"?[{transform:"translateY(100%)"},{transform:"none"}]:r==="modal"?[{opacity:0,transform:o?"translateY(12px) scale(0.96)":"translateY(8px) scale(0.98)"},{opacity:1,transform:"none"}]:[{opacity:0},{opacity:1}],n);try{e.animate([{opacity:0},{opacity:1}],{...n,pseudoElement:"::backdrop"})}catch{}}function T(e,r){e.style.cssText=["position:absolute","z-index:1","top:calc(4px + env(safe-area-inset-top, 0px))","inset-inline-end:calc(4px + env(safe-area-inset-right, 0px))","width:44px","height:44px","padding:0","border:0",`background:radial-gradient(circle, ${r.background} 0 15px, color-mix(in srgb, ${r.text} 22%, ${r.background}) 15px 16px, transparent 16.5px)`,`color:${r.text}`,"font:400 20px/1 system-ui,sans-serif","cursor:pointer","touch-action:manipulation"].join(";")}var ce=15e3;function de(e,r,o,l){let n=e.ownerDocument,i=new AbortController,a=!1,p=!1,s;function c(){s?.tagName==="DIALOG"&&s.close?.(),s?.remove(),s=void 0}function h(d,u){p||(p=!0,c(),(d==="dismissed"||d==="error")&&i.abort(u??new DOMException("Presentation cancelled","AbortError")),!(!a&&d!=="ready")&&P(r.onPresentationState,d==="error"?{surface:o,state:d,error:u}:{surface:o,state:d}))}let b=l,x=()=>{p||b()};return{setDismissHandler(d){b=d},get active(){return a&&!p},get cancelled(){return i.signal.aborted},start(d,u){if(!(a||p)){if(a=!0,r.loading!=="host"){let f=(u??n.documentElement.lang)||"en",t=n.createElement(d?"dialog":"div");s=t,t.dataset.longplayLoading=o;let m=f.startsWith("zh")?"\u6B63\u5728\u52A0\u8F7D":"Loading";t.setAttribute("aria-label",m),t.style.cssText="position:relative;box-sizing:border-box;background:Canvas;color:CanvasText;padding:24px 48px 24px 24px;"+(d?"position:fixed;width:min(480px,calc(100% - 32px));border:0;border-radius:16px;max-height:calc(100dvh - 32px)":"width:100%");let y=n.createElement("div");y.setAttribute("role","status"),y.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",y.textContent=m;let v=n.createElement("div");v.setAttribute("aria-hidden","true"),v.style.cssText="display:grid;gap:12px";let E=o==="banner"?[["72%",12],["44%",10]]:[["46%",20],["84%",12],["65%",12],["100%",o==="paywall"?96:64]];for(let[g,M]of E){let k=n.createElement("div");k.style.cssText=`width:${g};height:${M}px;background:currentColor;opacity:.11;border-radius:6px`,v.append(k)}let w=n.createElement("button");w.type="button",w.textContent="\xD7",w.setAttribute("aria-label",f.startsWith("zh")?"\u53D6\u6D88\u52A0\u8F7D":"Cancel loading"),T(w,{background:"Canvas",text:"CanvasText"}),w.addEventListener("click",x),t.addEventListener("cancel",g=>{g.preventDefault(),x()}),t.append(y,v,w),e.append(t),t instanceof n.defaultView.HTMLDialogElement&&(t.showModal?t.showModal():t.open=!0,w.focus({preventScroll:!0}))}P(r.onPresentationState,{surface:o,state:"loading",dismiss:x})}},present(d){if(p)return;let u=!!s;c(),d(u),h("ready")},dismiss:x,finish:h,async wait(d,u){let f=i.signal,t,m,y=new Promise((v,E)=>{m=()=>E(f.reason),f.aborted?m():f.addEventListener("abort",m,{once:!0}),u!==void 0&&(t=setTimeout(()=>E(new Error("Presentation data timed out")),u))});try{let v=await Promise.race([y,d]);return f.throwIfAborted(),v}finally{f.removeEventListener("abort",m),clearTimeout(t)}}}}function C(e){let r={display:"block",position:"fixed",top:"0",left:"0",opacity:"0",pointerEvents:"none",zIndex:"-1"},o=Object.keys(r).map(i=>{let a=i,p=e.style[a];return e.style[a]=r[a],[a,p]}),l=e.inert??!1,n=e.getAttribute("aria-hidden");return e.inert=!0,e.setAttribute("aria-hidden","true"),()=>{for(let[i,a]of o)e.style[i]=a;e.inert=l,n===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}}function ue(e,r){let o=e.style.width;e.style.width=`${r.getBoundingClientRect().width||r.ownerDocument.defaultView?.innerWidth||800}px`;let l=C(e);return()=>{l(),e.style.width=o}}var L=new WeakMap;function me(e,r){return L.set(e,r),()=>L.delete(e)}function fe(e){let r=e.defaultView?.HTMLElement,o=e.activeElement;for(let n=0;n<16&&o?.shadowRoot?.activeElement;n++)o=o.shadowRoot.activeElement;let l=o?L.get(o)?.():void 0;return()=>{!o?.isConnected||!r||!(o instanceof r)||(o.focus({preventScroll:!0}),l?.())}}export{ne as a,I as b,re as c,oe as d,T as e,ce as f,de as g,C as h,ue as i,me as j,fe as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as ie}from"./chunk-2KI63SPJ.js";import{a as Z,c as ee,d as te,e as ne,g as re,h as oe,i as se,k as N}from"./chunk-ZX2RWS3T.js";import"./chunk-5HJMAZ7A.js";import{a as d}from"./chunk-SJNF6JDJ.js";import{Y as X,ra as V}from"./chunk-O4535GJR.js";import{a as h}from"./chunk-DSPLGTQI.js";import{Ba as G,Ia as Y,Ja as K,O as R,sa as $}from"./chunk-MHEYMXGZ.js";import{z as p}from"zod";var z=new WeakMap;function ce(s){let t={string:p.string(),number:p.number().finite(),boolean:p.boolean(),strings:p.array(p.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=p.record(p.string(),R).parse(s);if(Object.keys(f).length>40)throw new d("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new d("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new d("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ce(s,t){return le(s,t,!1)}async function Ee(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new d("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new d("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(p.array(p.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new d("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new d("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),u=s.ownerDocument,ue=s.clientHeight||u.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?u.createElement("dialog"):null,c=u.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(u.defaultView?.innerHeight||800,u.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...u.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=u.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new d("CONFLICT","Content host has been destroyed");E||!S||(P??=N(u),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new d("CONFLICT","Content host has been destroyed");let o=p.record(p.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new d("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(u),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?u.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:u.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ce as mountContent,Ee as prepareContent};
|
|
@@ -53,6 +53,10 @@ declare const couponInputSchema: z.ZodObject<{
|
|
|
53
53
|
}, z.core.$strict>, z.ZodObject<{
|
|
54
54
|
type: z.ZodLiteral<"forever">;
|
|
55
55
|
}, z.core.$strict>], "type">;
|
|
56
|
+
nativeDiscountPolicy: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
replace: "replace";
|
|
58
|
+
stack_native: "stack_native";
|
|
59
|
+
}>>;
|
|
56
60
|
appliesTo: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
57
61
|
type: z.ZodLiteral<"all">;
|
|
58
62
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -150,6 +154,10 @@ declare const offerSchema: z.ZodObject<{
|
|
|
150
154
|
}, z.core.$strict>, z.ZodObject<{
|
|
151
155
|
type: z.ZodLiteral<"forever">;
|
|
152
156
|
}, z.core.$strict>], "type">;
|
|
157
|
+
nativeDiscountPolicy: z.ZodOptional<z.ZodEnum<{
|
|
158
|
+
replace: "replace";
|
|
159
|
+
stack_native: "stack_native";
|
|
160
|
+
}>>;
|
|
153
161
|
appliesTo: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
154
162
|
type: z.ZodLiteral<"all">;
|
|
155
163
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as y}from"./chunk-7AXCG6NU.js";import{c as A}from"./chunk-EIYWDWXP.js";import"./chunk-JGG4R75K.js";import{f as g,g as I}from"./chunk-ZX2RWS3T.js";import"./chunk-THGLNE4K.js";import"./chunk-34I23EKZ.js";import"./chunk-LFFBNGXP.js";import"./chunk-RKREEPCT.js";import"./chunk-5HJMAZ7A.js";import{a as c}from"./chunk-SJNF6JDJ.js";import"./chunk-SLUA7ABW.js";import"./chunk-OEH47Y2L.js";import"./chunk-2ZJ5CS5Q.js";import"./chunk-O4535GJR.js";import{a as i}from"./chunk-DSPLGTQI.js";import"./chunk-MHEYMXGZ.js";var d=new WeakMap;function T(h,e){let P=d.get(e.client);if(P)return P;let m=Promise.resolve().then(async()=>{let n=!1,s,w,E=!1,v=()=>{},r=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,u=()=>{d.get(e.client)===m&&d.delete(e.client),r.removeEventListener("abort",f),v()},o=I(h,e,"funnel",f);function f(){n||(n=!0,o.finish("dismissed"),s?s.destroy():(u(),i(e.onDismiss,null)))}r.addEventListener("abort",f,{once:!0});try{let b=function(){!n&&!r.aborted&&!E&&w&&e.client.recovery.status==="complete"&&(E=!0,i(e.onComplete,structuredClone(w)))};var C=b;r.throwIfAborted(),o.start(!0,e.start?.locale);let l=await o.wait(e.start?e.client.start(e.start):e.client.refresh(),g);r.throwIfAborted();let O=e.client.controller;return l.mode!=="run"||l.status==="blocked"||!O?(o.finish("skipped"),u(),null):(r.removeEventListener("abort",f),v=e.client.subscribe(b),s=await A(h,{...e,client:O,signal:r,checkoutNavigation:"after_confirmation",onCheckoutUrl(t){if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(y(e.client.recovery)!==t)throw new c("PURCHASE_PENDING","Checkout differs from the original recovery proof");return e.onCheckoutUrl?e.onCheckoutUrl(t):h.ownerDocument.defaultView?.location.assign(t)},async resolveOfferId(t){if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let a=e.client.attempt;if(!a)throw new c("PURCHASE_PENDING","Read the original Start before selecting an offer");let F=await e.resolveOfferId?.(t,a);if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==a.requestId)throw new c("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return F},onComplete(t){w=t,b()},onError(t){i(e.onError,t),t instanceof c&&t.status===401&&!r.aborted&&e.client.refresh().catch(a=>i(e.onError,a))},onDismiss(t){n=!0,u(),i(e.onDismiss,t)}},o),n||r.aborted?(s.destroy(),null):s)}catch(l){if(n)return null;throw o.finish("error",l),u(),i(e.onError,l),l}});return d.set(e.client,m),m}export{T as showFunnelPurchase};
|