@tinkerlandai/indiana-sdk 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/README.md +17 -11
- package/README.zh-CN.md +21 -16
- package/dist/{chunk-OK2Q6IJD.js → chunk-ET4NANGB.js} +1 -1
- package/dist/{chunk-5WY3AXSS.js → chunk-J7M7UH74.js} +1 -1
- package/dist/{chunk-PCVQHHEE.js → chunk-M3DG6ZCT.js} +1 -1
- package/dist/chunk-N6UIDDAX.js +4 -0
- package/dist/chunk-VMLGV5OS.js +11 -0
- package/dist/funnel-runtime-host-3STQUS6F.js +1 -0
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +2 -1
- package/dist/page.js +1 -1
- package/dist/{paywall-TCE5DE5T.js → paywall-LBDMGVWZ.js} +1 -1
- package/dist/popup.d.ts +10 -6
- package/dist/popup.js +176 -6
- package/dist/server.js +1 -1
- package/dist/src-X6KT6WIH.js +1 -0
- package/dist/visual.js +1 -1
- package/package.json +10 -9
- package/dist/chunk-4JBIKJMU.js +0 -4
- package/dist/chunk-HU2HIDVT.js +0 -11
- package/dist/funnel-runtime-host-L3WILUHK.js +0 -1
- package/dist/src-VGIVVM27.js +0 -1
package/dist/server.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as j,b,c as pe,d as le,e as Se,f as de,g as me,j as fe,k as Ee,l as qe,m as Ae}from"./chunk-5WY3AXSS.js";import{a as Ce,b as Re,c as Fe,d as Le}from"./chunk-PCVQHHEE.js";import{a as q}from"./chunk-OK2Q6IJD.js";import{a as s}from"./chunk-5TEZEOHX.js";import"./chunk-S5TVMQRC.js";import{Bi as B,Ci as se,Ei as _,Fi as oe,Ig as U,Lg as X,Mj as ie,Ng as Z,Nj as ce,Rh as M,Sk as ue,Tg as te,Vf as o,ch as V,dh as ne,fh as re,qh as N,rh as R,sh as ae}from"./chunk-HU2HIDVT.js";import{Rb as ee}from"./chunk-RMJJOSVZ.js";import{b as Y,h as W}from"./chunk-OHDY27EI.js";import{B as $,b as H,m as J}from"./chunk-S2MSIA57.js";function p(n,r){try{return n.parse(r)}catch{throw new s("INVALID_RESPONSE","Invalid gateway response")}}function we(n){let r=le(n),t=i=>{throw new s("INVALID_RESPONSE",i)};r.nodes.size!==n.topology.nodes.length&&t("Duplicate local node identity"),r.nodes.get(n.topology.entry)?.type!=="entry"&&t("A local Funnel must start at Entry");let e=new Set(["entry","condition","feature","split","end","output"]);for(let i of r.nodes.values()){if(!e.has(i.type))throw new s("SERVER_REQUIRED","This Funnel requires authoritative server execution");if(i.type==="entry"&&i.id!==n.topology.entry&&t("Unexpected Entry node"),["entry","feature"].includes(i.type)&&!i.outputs.next&&t("Local next exit is unavailable"),i.type==="feature"){let c=i.resources.featureKey;(!c||!Object.hasOwn(n.evaluation.variables,i.writes.value)||!Object.hasOwn(r.features,c))&&t("Local Feature definition or declaration is unavailable")}if(i.type==="condition"){let c=n.conditions[i.id];(!c||!i.outputs.default||c.some((f,m)=>f.port!==`case:${m}`||!i.outputs[f.port]))&&t("Local Condition exits are unavailable")}if(i.type==="split"&&(!i.resources.experimentId||!Object.hasOwn(n.growth.experiments,i.resources.experimentId)||!i.outputs.notParticipating)&&t("Local Experiment definition or exit is unavailable"),i.type==="end"||i.type==="output"){let c=n.evaluation.terminals[i.id];if(!c)throw new s("SERVER_REQUIRED","Terminal resource delivery requires the server");Object.keys(i.outputs).length&&t("A terminal cannot have outgoing edges"),c.output?.type==="feature"&&!Object.hasOwn(r.features,c.output.featureKey)&&t("Terminal Feature definition is unavailable")}for(let c of Object.values(i.outputs))r.nodes.has(c)||t("Local target is unavailable")}let a=new Set,u=new Set;function l(i){if(u.has(i)&&t("Local graph contains a cycle"),!a.has(i)){u.add(i);for(let c of Object.values(r.nodes.get(i).outputs))l(c);u.delete(i),a.add(i)}}return l(n.topology.entry),a.size!==r.nodes.size&&t("Local graph contains unreachable nodes"),{evaluate(i){let c={},f=i.context;f.features=r.features,f.savedGroups=r.savedGroups;let m=()=>{f.attributes=Z({declarations:n.evaluation.variables,attributes:i.attributes,parameters:i.parameters,answers:{},results:c,savedGroups:r.savedGroups})};m();let I=n.topology.entry,d=0;for(;;){let w=r.nodes.get(I);if(w.type==="end"||w.type==="output"){let y=n.evaluation.terminals[I],h=y.output,v=h?.type==="feature"?r.feature(h.featureKey,f):h?.type==="variable"?te({source:"variable",key:h.key,...h.path?{path:h.path}:{}},{declarations:n.evaluation.variables,answers:{},results:c,parameters:i.parameters,attributes:i.attributes,savedGroups:r.savedGroups}):h?.value??null;return U(n.evaluation.outputSchema,v)||t("Local output does not match its declaration"),{outcome:y.outcome,value:v}}if(d++>=n.evaluation.maxTransitions)throw new s("TRANSITION_LIMIT","Local Funnel transition budget exceeded");if(w.type==="entry")I=w.outputs.next;else{let y=r.evaluate(I,f);if(w.type==="feature"){let h=w.writes.value,v=y.value??null;U(n.evaluation.variables[h],v)||t("Local Feature value does not match its declaration"),X(n.evaluation.variables,{writes:w.writes},{[h]:v}),c[h]=v,m()}I=y.target}}}}}import{z as ye}from"zod";function Ie(n,r,t){let e=J.parse(n.attributes);if(["parameters","answers","results"].some(S=>Object.hasOwn(e,S)))throw new s("INVALID_REQUEST","Flow namespaces cannot be caller attributes");let a=ee.parse(n.parameters??{}),u=ye.record(ye.string(),$).parse(n.stickyBucketAssignmentDocs??{});for(let[S,g]of Object.entries(u))if(S!==`${g.attributeName}||${g.attributeValue}`||!Object.hasOwn(e,g.attributeName)||H(e[g.attributeName])!==g.attributeValue)throw new s("INVALID_REQUEST","Sticky document identity does not match this session");let l=n.saveStickyBucketAssignmentDoc,i=n.onFeatureUsage,c=n.onExperimentViewed,f=n.onError,m=new Map,I=new Set,d={},w=Promise.resolve();function y(S){let g=w.then(()=>(t(),S()));return w=g.catch(()=>{}),g}function h(S){try{f?.(S)}catch{}}function v(S){try{let g=S();g&&typeof g.catch=="function"&&g.catch(h)}catch(g){h(g)}}async function L(){for(let[S,g]of m){if(t(),l)try{await l(structuredClone(g))}catch{throw new s("STICKY_SAVE_FAILED","Persist the pending Sticky assignment before using this evaluation")}t(),m.delete(S)}}return{evaluate(S={}){let g=S.track===!0;return y(async()=>{let D=await r();t(D);let K=new Set(I),z={...d},Q=new Map,T=[],he={stickyBucketAssignmentDocs:structuredClone(u),saveStickyBucketAssignmentDoc(E){Q.set(`${E.attributeName}||${E.attributeValue}`,structuredClone(E))},...g?{trackedExperiments:K,trackedFeatureUsage:z,onExperimentViewed(E,C){let P=structuredClone(E),ve=structuredClone(C);c&&T.push(()=>c(structuredClone(P),structuredClone(ve)))},onFeatureUsage(E,C){let P=structuredClone(C);i&&T.push(()=>i(E,structuredClone(P)))}}:{}},ge=D.program.evaluate({attributes:e,parameters:a,context:he});t(D);for(let[E,C]of Q)u[E]=C,m.set(E,C);await L(),t(D),g&&(I=K,d=z);for(let E of T)v(E);let O=D.configuration;return structuredClone({evaluationMode:"local",scope:O.scope,funnelId:O.funnelId,versionId:O.versionId,evaluationRevision:O.evaluationRevision,generation:O.growth.generation,...ge})})},flush:()=>y(L),get stickyBucketAssignmentDocs(){return t(),structuredClone(u)}}}var De=6e4;function x(n){if(typeof window<"u")throw new s("SERVER_ONLY","Local Funnel sessions run on your backend");let r=Y.parse(n.scope),t=n.funnelId,e=n.load,a,u,l,i=0,c=I=>Date.now()>=I.expiresAt;async function f(){if(u)return u;let I=i;a=void 0;let d=(async()=>{let w=await e();if(I!==i)throw new s("IDENTITY_CHANGED","Local evaluator was reset");if(w&&typeof w=="object"&&"evaluationMode"in w&&w.evaluationMode==="remote")throw p(_,w),new s("EVALUATION_MODE","This Funnel requires remote decide");let y=p(oe,w);if(I!==i)throw new s("IDENTITY_CHANGED","Local evaluator was reset");if(y.scope.projectId!==r.projectId||y.scope.environment!==r.environment||y.funnelId!==t)throw new s("SCOPE_MISMATCH","Local configuration scope changed");if(y.growth.scope.projectId!==r.projectId||y.growth.scope.environment!==r.environment||y.growth.expiresAt!==y.expiresAt)throw new s("INVALID_RESPONSE","GB configuration scope or expiry changed");let h=Math.min(Date.now()+De,y.expiresAt?Date.parse(y.expiresAt):1/0);if(Date.now()>=h)throw new s("CONFIGURATION_EXPIRED","Refresh expired local rules");let v=JSON.stringify([r.projectId,r.environment,t,y.versionId,y.evaluationRevision,y.growth.generation]),L=[y.topology,y.conditions,y.evaluation,y.growth.features,y.growth.experiments,y.growth.savedGroups];if(l?.key===v&&!pe(l.body,L))throw new s("INVALID_RESPONSE","Immutable local configuration identity changed");return l?.key!==v&&(l={key:v,body:L,program:we(y)}),a={key:v,configuration:y,expiresAt:h,program:l.program},a})();u=d;try{return await d}finally{u===d&&(u=void 0)}}function m(){return u??(a&&!c(a)?Promise.resolve(a):f())}return{session(I){let d=i;return Ie(I,m,w=>{if(n.assertUsable?.(),d!==i)throw new s("IDENTITY_CHANGED","Local evaluator was reset");if(w&&(c(w)||a?.key!==w.key))throw new s("CONFIGURATION_EXPIRED","Refresh local rules before using this result")})},async refresh(){return structuredClone((await f()).configuration)},reset(){i++,a=void 0,u=void 0,l=void 0}}}function Oe(n,r){let t=n.snapshot?.generation,e=x({scope:{projectId:n.scope.projectId,environment:n.scope.environment},funnelId:r,load:()=>n.localFunnel(r),assertUsable:()=>n.assertFunnel(r)}),a=n.subscribe(()=>{let l=n.snapshot?.generation;n.fresh&&l!==t&&(t=l,e.refresh().catch(()=>{}))}),u=e.session;return Object.assign(e,{session(l){let i=u(l),c=i.evaluate;return Object.assign(i,{async evaluate(...f){return n.fresh||await n.refresh(),c(...f)}})},destroy(){a(),e.reset()}})}function _e(n){if(typeof window<"u")throw new s("SERVER_ONLY","Secret API keys must stay on the backend");return{start:r=>fe(n,r)}}var F=class extends s{constructor(t,e){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,e);this.decisionId=t;this.decisionRequestId=e}decisionId;decisionRequestId};async function k(n,r,t,e){let{decisionId:a,requestId:u}=n,l=n,i=250;for(;;){if(l.decisionId!==a||l.requestId!==u||l.decision&&!b(l.decision,r))throw new s("INVALID_RESPONSE","Decision request or customer changed");if(l.decision)return l.decision;if(l.status==="failed")throw new s("DECISION_FAILED","Decision execution failed",503,u);if(Date.now()>=t)throw new F(a,u);if(await new Promise(c=>setTimeout(c,Math.min(i,t-Date.now()))),Date.now()>=t)throw new F(a,u);i=Math.min(1e3,i*2);try{l=await e(a,t)}catch(c){if(c instanceof s&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(c.code))continue;throw c}}}function G(n){if("remoteEval"in n)throw new s("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new s("SERVER_ONLY","Funnel decisions are requested by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A server API key is required");let r,t,e=new Map;async function a(c,f){let m=c;m.status!=="pending"&&e.delete(m.decisionId);for(let I=0;I<32&&m.evaluation;I++){let d=m.evaluation;if(d.runId!==m.decisionId)throw new s("INVALID_RESPONSE","Local evaluation Run changed");let w=e.get(m.decisionId);if(!w&&d.type==="evaluate_segment"){let h=ue.parse(await u({operation:"segment_configuration",funnelId:n.funnelId,versionId:d.versionId},f));if(h.configuration.scope.projectId!==n.scope.projectId||h.configuration.scope.environment!==n.scope.environment||h.configuration.funnelId!==n.funnelId||h.configuration.versionId!==d.versionId||h.configuration.evaluationRevision!==d.policyRevision)throw new s("SCOPE_MISMATCH","Original decision segment configuration changed");if(e.size>=128)throw new s("COMMAND_PENDING","Reconcile outstanding decisions first");w={operation:"commit_decision_segment",decisionId:m.decisionId,requestId:M(m.decisionId,d.visit,`segment:${d.revision}`),nodeId:d.nodeId,visit:d.visit,revision:d.revision,policyRevision:d.policyRevision,generation:h.configuration.growth.generation,...me(h.configuration,h.document,d)},e.set(m.decisionId,w)}if(!w){if(d.type!=="evaluate")throw new s("INVALID_RESPONSE","Unknown decision instruction");if((!t||t.versionId!==d.versionId||t.evaluationRevision!==d.policyRevision||t.expiresAt&&Date.parse(t.expiresAt)<=Date.now())&&(t=_.parse(await u({operation:"configuration",funnelId:n.funnelId,versionId:d.versionId},f))),t.scope.projectId!==n.scope.projectId||t.scope.environment!==n.scope.environment||t.funnelId!==n.funnelId)throw new s("SCOPE_MISMATCH","Local evaluation configuration scope changed");if(t.evaluationMode!=="local"||t.versionId!==d.versionId||t.evaluationRevision!==d.policyRevision)throw new s("EVALUATION_MODE","Original Local evaluation policy is unavailable");if(e.size>=128)throw new s("COMMAND_PENDING","Reconcile outstanding Local decisions first");w={operation:"evaluate_decision",decisionId:m.decisionId,requestId:M(m.decisionId,d.visit,"evaluation"),nodeId:d.nodeId,visit:d.visit,revision:d.revision,receiptId:d.receiptId,policyRevision:d.policyRevision,generation:t.growth.generation,result:de(t,d.nodeId,d)},e.set(m.decisionId,w)}let y=R.parse(await u(w,f));if(y.decisionId!==c.decisionId||y.requestId!==c.requestId)throw new s("INVALID_RESPONSE","Decision identity changed during local evaluation");e.delete(m.decisionId),m=y}return m}async function u(c,f,m=!1){let I=q({...n,fetch:(d,w)=>{let y=new Headers(w?.headers);return y.set("Accept-Encoding","identity"),m&&y.set("Prefer","respond-async"),(n.fetch??globalThis.fetch)(d,{...w,headers:y})},timeoutMs:Math.min(n.timeoutMs??1e4,f?Math.max(1,f-Date.now()):12e4)});return I.identify(n.apiKey),I.request("funnels",c)}async function l(c,f){let m=R.parse(await u(N.parse({operation:"read_decision",decisionId:c}),f));if(m.decisionId!==c)throw new s("INVALID_RESPONSE","Decision identity changed");return a(m,f)}async function i(c,f,m=!1){let I=N.options[0].parse({...c,operation:"decide",funnelId:n.funnelId}),d;try{d=R.parse(await u(I,f,m))}catch(w){throw w instanceof s&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(w.code)?new s("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",w.status,c.requestId):w}if(d.requestId!==c.requestId||d.decision&&!b(d.decision,I.customer))throw new s("INVALID_RESPONSE","Decision request or customer changed");return{response:await a(d,f),customer:I.customer}}return{local(){return r??=x({scope:n.scope,funnelId:n.funnelId,load:()=>u({operation:"local_configuration",funnelId:n.funnelId})})},async configuration(){let c=_.parse(await u({operation:"configuration",funnelId:n.funnelId}));if(c.scope.projectId!==n.scope.projectId||c.scope.environment!==n.scope.environment||c.funnelId!==n.funnelId)throw new s("SCOPE_MISMATCH","Configuration scope changed");return c},features(c={}){return j({...c,scope:n.scope,load:async()=>W.parse(await u({operation:"feature_config",funnelId:n.funnelId}))})},read:c=>l(c),async submit(c){return(await i(c,void 0,!0)).response},async decide(c){let f=Date.now()+3e4,m=await i(c,f);return k(m.response,m.customer,f,l)},async reportUsed(c){let f=ae.parse(await u(N.parse({...c,operation:"report_used"})));if(f.decisionId!==c.decisionId||f.eventId!==c.eventId)throw new s("INVALID_RESPONSE","Usage receipt identity changed");return f}}}function Ne(n){if(typeof window<"u")throw new s("SERVER_ONLY","Native receipts are verified by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","Server API key required");let r=q({...n,timeoutMs:n.timeoutMs??35e3});return r.identify(n.apiKey),{async recover(t){let e=ie.parse(t);if(e.orderId!==e.receiptId)throw new s("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let a=e.nativeEvidence,u={requestId:e.requestId,customerToken:e.customerToken,purchaseIntentId:e.orderId,...a===null?{intent:"read"}:a.provider==="apple"?{provider:"apple",signedTransaction:a.signedTransaction}:{provider:"google",purchaseToken:a.purchaseToken}},l=o.restoreNativePurchase.response.parse(await r.request(o.restoreNativePurchase.path,u));if(l.operation.requestId!==e.requestId)throw new s("INVALID_RESPONSE","Native receipt request identity changed");let i=ce.parse({scope:l.scope,requestId:e.requestId,orderId:l.operation.orderId,receiptId:l.operation.orderId,orderStatus:l.operation.status,refunded:l.operation.refunded,...l.operation.completion===null?{}:{nativeCompletion:{orderId:l.operation.orderId,receiptId:l.operation.orderId,...l.operation.completion}}});if(i.requestId!==e.requestId||i.orderId!==e.orderId||i.receiptId!==e.receiptId||i.scope.projectId!==n.scope.projectId||i.scope.environment!==n.scope.environment)throw new s("INVALID_RESPONSE","Current order receipt scope changed");return i}}}import{z as be}from"zod";var A=be.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function xe(n,r){let t=A.parse(n.inputTokens.total),e=A.parse(n.outputTokens.total),a=A.parse(n.inputTokens.cacheRead??0),u=A.parse(n.inputTokens.cacheWrite??0),l=A.parse(n.outputTokens.reasoning??0);if(a+u>t||l>e||n.inputTokens.noCache!==void 0&&A.parse(n.inputTokens.noCache)!==t-a-u||n.outputTokens.text!==void 0&&A.parse(n.outputTokens.text)!==e-l)throw new s("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:t-a-u,cache_read:a,cache_write:u,output:r==="output"?e:e-l,reasoning:r==="separate"?l:0,input_audio:0,output_audio:0}}function ke(n){if(typeof window<"u")throw new s("SERVER_ONLY","AI usage belongs on the trusted backend");if(!n.modelId||!["output","separate"].includes(n.reasoning))throw new s("INVALID_REQUEST","Model ID and reasoning pricing are required");async function r(e){await n.persist({context:e,modelId:n.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function t(e,a){let u={context:e,modelId:n.modelId,usage:a,tokens:null,quote:null,receipt:null,phase:"captured"};await n.persist(u);let l=n.mapTokens?n.mapTokens(a):xe(a,n.reasoning),i=await n.pricing.quoteTokens({modelId:n.modelId,tokens:l});await n.persist({...u,tokens:l,quote:i,phase:"quoted"});let c=await n.pricing.trackTokens(n.client,{...e,quote:i});if(!c.receipt.accepted)throw new s("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await n.persist({...u,tokens:l,quote:i,receipt:c,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:e}){let a=await n.context(),u;try{u=await e()}catch(l){throw await r(a),l}return await t(a,u.usage),u},async wrapStream({doStream:e}){let a=await n.context(),u;try{u=await e()}catch(m){throw await r(a),m}let l=!1,i=!1,c=u.stream.getReader();async function f(){l||i||(i=!0,await r(a))}return{...u,stream:new ReadableStream({async pull(m){try{let{value:I,done:d}=await c.read();if(d){if(!l)throw await f(),new s("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");m.close();return}if(I.type==="finish"){if(l)throw new s("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");l=!0,await t(a,I.usage)}m.enqueue(I)}catch(I){try{await f()}finally{m.error(I),await c.cancel(I)}}},async cancel(m){try{await f()}finally{await c.cancel(m)}}})}}}}function Te(n){if(typeof window<"u")throw new s("SERVER_ONLY","Funnel receipts are sent by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A server API key is required");let r=q(n);return r.identify(n.apiKey),{async signal(t){let e=V.parse({...t,operation:"signal"}),a=ne.parse(await r.request("funnels",e));if(a.runId!==t.runId||a.eventId!==t.eventId||a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new s("INVALID_RESPONSE","Receipt identity changed");return a},async readResults(t){let e=V.parse({operation:"read_results",runId:t}),a=re.parse(await r.request("funnels",e));if(a.runId!==t||a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new s("INVALID_RESPONSE","Result identity changed");return a}}}function Pe(n){if("remoteEval"in n)throw new s("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new s("SERVER_ONLY","Campaign entry requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A server API key is required");let r=q({...n,timeoutMs:n.timeoutMs??35e3});return r.identify(n.apiKey),{async decide(t){let e=Date.now()+(n.timeoutMs??3e4),a=B.parse({...t,funnelId:n.funnelId,operation:"campaign_decide"}),u=q({...n,timeoutMs:Math.min(n.timeoutMs??35e3,Math.max(1,e-Date.now()))});u.identify(n.apiKey);let l=R.parse(await u.request("funnels",a));if(l.scope.projectId!==n.scope.projectId||l.scope.environment!==n.scope.environment)throw new s("SCOPE_MISMATCH","Campaign scope changed");return k(l,a.customer,e,(i,c)=>G({...n,timeoutMs:Math.min(n.timeoutMs??1e4,Math.max(1,c-Date.now()))}).read(i))},async start(t){let e=B.parse({...t,funnelId:n.funnelId,operation:"campaign_start"}),a=se.parse(await r.request("funnels",e));if(a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new s("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in a)&&(a.run.source.id!==n.funnelId||!a.customerId||e.customer.type==="id"&&a.customerId!==e.customer.value))throw new s("INVALID_RESPONSE","Campaign Funnel or Customer changed");return a}}}function xt(){if(typeof window<"u")throw new s("SERVER_ONLY","Guest identity is issued by your backend");let n=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...n)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function kt(n){if(typeof window<"u")throw new s("SERVER_ONLY","Secret API keys must stay on your backend");let r=q(n);return r.identify(n.apiKey),{async listInvoiceTemplates(t={}){let e=o.listInvoiceTemplates;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewInvoice(t){let e=o.previewInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async createInvoice(t){let e=o.createInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageInvoice(t){let e=o.manageInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readInvoiceOperation(t){let e=o.readInvoiceOperation;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listInvoices(t){let e=o.listInvoices;return p(e.response,await r.request(e.path,e.request.parse(t)))},async getInvoice(t){let e=o.getInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async recordCouponRedemption(t){let e=o.recordCouponRedemption,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid Coupon redemption facts");return p(e.response,await r.request(e.path,a.data))},async getFeatures(t={}){let e=o.getFeatures;return p(e.response,await r.request(e.path,e.request.parse(t),e.method))},async evaluateFeatures(t){let e=o.evaluateFeatures;return p(e.response,await r.request(e.path,e.request.parse(t),e.method))},async trackEvents(t){let e=o.trackEvents;return p(e.response,await r.request(e.path,e.request.parse(t),e.method))},async resolvePaywall(t){let e=o.resolvePaywall;return p(e.response,await r.request(e.path,e.request.parse(t)))},async resolveOffering(t){let e=o.resolveOffering;return p(e.response,await r.request(e.path,e.request.parse(t)))},async checkEntitlement(t){let e=o.checkEntitlement;return p(e.response,await r.request(e.path,e.request.parse(t)))},async setupPayment(t){let e=o.setupPayment;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readPaymentSetup(t){let e=o.readPaymentSetup;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewSubscriptionBatch(t){let e=o.previewSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async confirmSubscriptionBatch(t){let e=o.confirmSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionBatch(t){let e=o.readSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async abandonSubscriptionBatch(t){let e=o.abandonSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageSubscriptionTrial(t){let e=o.manageSubscriptionTrial;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionTrial(t){let e=o.readSubscriptionTrial;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptions(t){let e=o.listSubscriptions;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listPurchases(t){let e=o.listPurchases;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptionConflicts(t){let e=o.listSubscriptionConflicts;return p(e.response,await r.request(e.path,e.request.parse(t)))},async retrySubscriptionConflict(t){let e=o.retrySubscriptionConflict;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewRefund(t){let e=o.previewRefund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async refund(t){let e=o.refund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readRefund(t){let e=o.readRefund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewUpdate(t){let e=o.previewUpdate;return p(e.response,await r.request(e.path,e.request.parse(t)))},async update(t){let e=o.update;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){let e=o.readSubscriptionUpdate;return p(e.response,await r.request(e.path,e.request.parse(t)))},async restoreNativePurchase(t){let e=o.restoreNativePurchase;return p(e.response,await r.request(e.path,e.request.parse(t)))},async verifySubscriptions(t){let e=o.verifySubscriptions;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewAttach(t){let e=o.previewAttach;return p(e.response,await r.request(e.path,e.request.parse(t)))},async attach(t){let e=o.attach;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){let e=o.readSubscriptionOperation;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readAiPricing(t){let e=o.readAiPricing;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsage(t){let e=o.readUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async setUsage(t){let e=o.setUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageBalanceGrant(t){let e=o.manageBalanceGrant;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readBalanceSource(t){let e=o.readBalanceSource;return p(e.response,await r.request(e.path,e.request.parse(t)))},async adjustBalance(t){let e=o.adjustBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listBalanceGrants(t){let e=o.listBalanceGrants;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageBillingLimits(t){let e=o.manageBillingLimits;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSeats(t){let e=o.readSeats;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageSeat(t){let e=o.manageSeat;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageUsageEntity(t){let e=o.manageUsageEntity;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageAnalytics(t){let e=o.readUsageAnalytics;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditAnalytics(t){let e=o.readCreditAnalytics;return p(e.response,await r.request(e.path,e.request.parse(t)))},async submitUsageBatch(t){let e=o.submitUsageBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageBatch(t){let e=o.readUsageBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readHoldings(t){let e=o.readHoldings;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readLedger(t){let e=o.readLedger;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readBillingInvoice(t){let e=o.readBillingInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditStatement(t){let e=o.readCreditStatement;return p(e.response,await r.request(e.path,e.request.parse(t)))},async quoteBalance(t){let e=o.quoteBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async trackUsage(t){let e=o.trackUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async mutateBalance(t){let e=o.mutateBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async getCustomer(t){let e=o.getCustomer,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid customer lookup");let u=e.response.safeParse(await r.request(e.path,a.data));if(!u.success)throw new s("INVALID_RESPONSE","Invalid customer response");return u.data},async listCustomers(t={}){let e=o.listCustomers,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid customer filters");let u=e.response.safeParse(await r.request(e.path,a.data));if(!u.success)throw new s("INVALID_RESPONSE","Invalid customer response");return u.data},async updateCustomer(t){let e=o.updateCustomer,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid customer patch");let u=e.response.safeParse(await r.request(e.path,a.data));if(!u.success)throw new s("INVALID_RESPONSE","Invalid customer response");return u.data},async createGuestCustomer(t){let e=o.createGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async resumeGuestSession(t){let e=o.resumeGuestSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async claimGuestCustomer(t){let e=o.claimGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async renewCustomerSession(t){let e=o.renewSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async revokeCustomerSessions(t){let e=o.revokeSessions;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async createCustomerSession(t){let e=o.createSession.request.safeParse({customerId:t});if(!e.success)throw new s("INVALID_REQUEST","A customer ID is required");let a=o.createSession.response.safeParse(await r.request("customer-sessions",e.data));if(!a.success)throw new s("INVALID_RESPONSE","Invalid customer session response");return a.data},async getOrCreateCustomer(t){let e=o.createCustomer.request.safeParse(t);if(!e.success)throw new s("INVALID_REQUEST","Invalid customer input");let a=o.createCustomer.response.safeParse(await r.request("customers",e.data));if(!a.success)throw new s("INVALID_RESPONSE","Invalid customer response");return a.data},async grantOffer(t){let e=o.grantOffer.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!e.success||!e.data.customerId)throw new s("INVALID_REQUEST","Invalid offer grant");let a=o.grantOffer.response.safeParse(await r.request("offers/grant",e.data));if(!a.success)throw new s("INVALID_RESPONSE","Invalid offer response");return a.data}}}async function Tt(n,r){if(typeof window<"u")throw new s("SERVER_ONLY","Renewal requires your backend");let{funnelCredentialCommandSchema:t,funnelCredentialResponseSchema:e}=await import("./src-VGIVVM27.js"),a=q(n);return a.identify(n.apiKey),e.parse(await a.request("funnels",t.parse({...r,operation:"renew_run"})))}export{F as FunnelDecisionTimeoutError,s as IndianaError,Ce as aiPriceSnapshotSchema,Re as aiTokenQuoteSchema,Fe as createAiPricing,ke as createAiUsageMiddleware,Ee as createConfigurationSync,Le as createConfiguredAiPricing,j as createFeatureClient,Pe as createFunnelCampaignClient,G as createFunnelDecisionClient,x as createFunnelLocalEvaluator,Te as createFunnelOrchestrationClient,qe as createFunnelStartClient,xt as createGuestToken,kt as createIndianaServer,Ae as createLocalFunnelClient,Ne as createNativeReceiptClient,_e as createPaywallStartClient,Oe as createSynchronizedFunnelLocalEvaluator,Se as evaluateFunnelNode,Tt as renewFunnelRun};
|
|
1
|
+
import{a as j,b,c as pe,d as le,e as Se,f as de,g as me,j as fe,k as Ee,l as qe,m as Ae}from"./chunk-J7M7UH74.js";import{a as Ce,b as Re,c as Fe,d as Le}from"./chunk-M3DG6ZCT.js";import{a as q}from"./chunk-ET4NANGB.js";import{a as s}from"./chunk-5TEZEOHX.js";import"./chunk-S5TVMQRC.js";import{Fi as B,Gi as se,Ig as U,Ii as _,Ji as oe,Lg as X,Ng as Z,Qj as ie,Rh as M,Rj as ce,Tg as te,Vf as o,Wk as ue,ch as V,dh as ne,fh as re,qh as N,rh as R,sh as ae}from"./chunk-VMLGV5OS.js";import{Rb as ee}from"./chunk-RMJJOSVZ.js";import{b as Y,h as W}from"./chunk-OHDY27EI.js";import{B as $,b as H,m as J}from"./chunk-S2MSIA57.js";function p(n,r){try{return n.parse(r)}catch{throw new s("INVALID_RESPONSE","Invalid gateway response")}}function we(n){let r=le(n),t=i=>{throw new s("INVALID_RESPONSE",i)};r.nodes.size!==n.topology.nodes.length&&t("Duplicate local node identity"),r.nodes.get(n.topology.entry)?.type!=="entry"&&t("A local Funnel must start at Entry");let e=new Set(["entry","condition","feature","split","end","output"]);for(let i of r.nodes.values()){if(!e.has(i.type))throw new s("SERVER_REQUIRED","This Funnel requires authoritative server execution");if(i.type==="entry"&&i.id!==n.topology.entry&&t("Unexpected Entry node"),["entry","feature"].includes(i.type)&&!i.outputs.next&&t("Local next exit is unavailable"),i.type==="feature"){let c=i.resources.featureKey;(!c||!Object.hasOwn(n.evaluation.variables,i.writes.value)||!Object.hasOwn(r.features,c))&&t("Local Feature definition or declaration is unavailable")}if(i.type==="condition"){let c=n.conditions[i.id];(!c||!i.outputs.default||c.some((f,m)=>f.port!==`case:${m}`||!i.outputs[f.port]))&&t("Local Condition exits are unavailable")}if(i.type==="split"&&(!i.resources.experimentId||!Object.hasOwn(n.growth.experiments,i.resources.experimentId)||!i.outputs.notParticipating)&&t("Local Experiment definition or exit is unavailable"),i.type==="end"||i.type==="output"){let c=n.evaluation.terminals[i.id];if(!c)throw new s("SERVER_REQUIRED","Terminal resource delivery requires the server");Object.keys(i.outputs).length&&t("A terminal cannot have outgoing edges"),c.output?.type==="feature"&&!Object.hasOwn(r.features,c.output.featureKey)&&t("Terminal Feature definition is unavailable")}for(let c of Object.values(i.outputs))r.nodes.has(c)||t("Local target is unavailable")}let a=new Set,u=new Set;function l(i){if(u.has(i)&&t("Local graph contains a cycle"),!a.has(i)){u.add(i);for(let c of Object.values(r.nodes.get(i).outputs))l(c);u.delete(i),a.add(i)}}return l(n.topology.entry),a.size!==r.nodes.size&&t("Local graph contains unreachable nodes"),{evaluate(i){let c={},f=i.context;f.features=r.features,f.savedGroups=r.savedGroups;let m=()=>{f.attributes=Z({declarations:n.evaluation.variables,attributes:i.attributes,parameters:i.parameters,answers:{},results:c,savedGroups:r.savedGroups})};m();let I=n.topology.entry,d=0;for(;;){let w=r.nodes.get(I);if(w.type==="end"||w.type==="output"){let y=n.evaluation.terminals[I],h=y.output,v=h?.type==="feature"?r.feature(h.featureKey,f):h?.type==="variable"?te({source:"variable",key:h.key,...h.path?{path:h.path}:{}},{declarations:n.evaluation.variables,answers:{},results:c,parameters:i.parameters,attributes:i.attributes,savedGroups:r.savedGroups}):h?.value??null;return U(n.evaluation.outputSchema,v)||t("Local output does not match its declaration"),{outcome:y.outcome,value:v}}if(d++>=n.evaluation.maxTransitions)throw new s("TRANSITION_LIMIT","Local Funnel transition budget exceeded");if(w.type==="entry")I=w.outputs.next;else{let y=r.evaluate(I,f);if(w.type==="feature"){let h=w.writes.value,v=y.value??null;U(n.evaluation.variables[h],v)||t("Local Feature value does not match its declaration"),X(n.evaluation.variables,{writes:w.writes},{[h]:v}),c[h]=v,m()}I=y.target}}}}}import{z as ye}from"zod";function Ie(n,r,t){let e=J.parse(n.attributes);if(["parameters","answers","results"].some(S=>Object.hasOwn(e,S)))throw new s("INVALID_REQUEST","Flow namespaces cannot be caller attributes");let a=ee.parse(n.parameters??{}),u=ye.record(ye.string(),$).parse(n.stickyBucketAssignmentDocs??{});for(let[S,g]of Object.entries(u))if(S!==`${g.attributeName}||${g.attributeValue}`||!Object.hasOwn(e,g.attributeName)||H(e[g.attributeName])!==g.attributeValue)throw new s("INVALID_REQUEST","Sticky document identity does not match this session");let l=n.saveStickyBucketAssignmentDoc,i=n.onFeatureUsage,c=n.onExperimentViewed,f=n.onError,m=new Map,I=new Set,d={},w=Promise.resolve();function y(S){let g=w.then(()=>(t(),S()));return w=g.catch(()=>{}),g}function h(S){try{f?.(S)}catch{}}function v(S){try{let g=S();g&&typeof g.catch=="function"&&g.catch(h)}catch(g){h(g)}}async function L(){for(let[S,g]of m){if(t(),l)try{await l(structuredClone(g))}catch{throw new s("STICKY_SAVE_FAILED","Persist the pending Sticky assignment before using this evaluation")}t(),m.delete(S)}}return{evaluate(S={}){let g=S.track===!0;return y(async()=>{let D=await r();t(D);let K=new Set(I),z={...d},Q=new Map,T=[],he={stickyBucketAssignmentDocs:structuredClone(u),saveStickyBucketAssignmentDoc(E){Q.set(`${E.attributeName}||${E.attributeValue}`,structuredClone(E))},...g?{trackedExperiments:K,trackedFeatureUsage:z,onExperimentViewed(E,C){let P=structuredClone(E),ve=structuredClone(C);c&&T.push(()=>c(structuredClone(P),structuredClone(ve)))},onFeatureUsage(E,C){let P=structuredClone(C);i&&T.push(()=>i(E,structuredClone(P)))}}:{}},ge=D.program.evaluate({attributes:e,parameters:a,context:he});t(D);for(let[E,C]of Q)u[E]=C,m.set(E,C);await L(),t(D),g&&(I=K,d=z);for(let E of T)v(E);let O=D.configuration;return structuredClone({evaluationMode:"local",scope:O.scope,funnelId:O.funnelId,versionId:O.versionId,evaluationRevision:O.evaluationRevision,generation:O.growth.generation,...ge})})},flush:()=>y(L),get stickyBucketAssignmentDocs(){return t(),structuredClone(u)}}}var De=6e4;function x(n){if(typeof window<"u")throw new s("SERVER_ONLY","Local Funnel sessions run on your backend");let r=Y.parse(n.scope),t=n.funnelId,e=n.load,a,u,l,i=0,c=I=>Date.now()>=I.expiresAt;async function f(){if(u)return u;let I=i;a=void 0;let d=(async()=>{let w=await e();if(I!==i)throw new s("IDENTITY_CHANGED","Local evaluator was reset");if(w&&typeof w=="object"&&"evaluationMode"in w&&w.evaluationMode==="remote")throw p(_,w),new s("EVALUATION_MODE","This Funnel requires remote decide");let y=p(oe,w);if(I!==i)throw new s("IDENTITY_CHANGED","Local evaluator was reset");if(y.scope.projectId!==r.projectId||y.scope.environment!==r.environment||y.funnelId!==t)throw new s("SCOPE_MISMATCH","Local configuration scope changed");if(y.growth.scope.projectId!==r.projectId||y.growth.scope.environment!==r.environment||y.growth.expiresAt!==y.expiresAt)throw new s("INVALID_RESPONSE","GB configuration scope or expiry changed");let h=Math.min(Date.now()+De,y.expiresAt?Date.parse(y.expiresAt):1/0);if(Date.now()>=h)throw new s("CONFIGURATION_EXPIRED","Refresh expired local rules");let v=JSON.stringify([r.projectId,r.environment,t,y.versionId,y.evaluationRevision,y.growth.generation]),L=[y.topology,y.conditions,y.evaluation,y.growth.features,y.growth.experiments,y.growth.savedGroups];if(l?.key===v&&!pe(l.body,L))throw new s("INVALID_RESPONSE","Immutable local configuration identity changed");return l?.key!==v&&(l={key:v,body:L,program:we(y)}),a={key:v,configuration:y,expiresAt:h,program:l.program},a})();u=d;try{return await d}finally{u===d&&(u=void 0)}}function m(){return u??(a&&!c(a)?Promise.resolve(a):f())}return{session(I){let d=i;return Ie(I,m,w=>{if(n.assertUsable?.(),d!==i)throw new s("IDENTITY_CHANGED","Local evaluator was reset");if(w&&(c(w)||a?.key!==w.key))throw new s("CONFIGURATION_EXPIRED","Refresh local rules before using this result")})},async refresh(){return structuredClone((await f()).configuration)},reset(){i++,a=void 0,u=void 0,l=void 0}}}function Oe(n,r){let t=n.snapshot?.generation,e=x({scope:{projectId:n.scope.projectId,environment:n.scope.environment},funnelId:r,load:()=>n.localFunnel(r),assertUsable:()=>n.assertFunnel(r)}),a=n.subscribe(()=>{let l=n.snapshot?.generation;n.fresh&&l!==t&&(t=l,e.refresh().catch(()=>{}))}),u=e.session;return Object.assign(e,{session(l){let i=u(l),c=i.evaluate;return Object.assign(i,{async evaluate(...f){return n.fresh||await n.refresh(),c(...f)}})},destroy(){a(),e.reset()}})}function _e(n){if(typeof window<"u")throw new s("SERVER_ONLY","Secret API keys must stay on the backend");return{start:r=>fe(n,r)}}var F=class extends s{constructor(t,e){super("DECISION_PENDING","Decision is still pending; read this decision ID or retry the original request ID",202,e);this.decisionId=t;this.decisionRequestId=e}decisionId;decisionRequestId};async function k(n,r,t,e){let{decisionId:a,requestId:u}=n,l=n,i=250;for(;;){if(l.decisionId!==a||l.requestId!==u||l.decision&&!b(l.decision,r))throw new s("INVALID_RESPONSE","Decision request or customer changed");if(l.decision)return l.decision;if(l.status==="failed")throw new s("DECISION_FAILED","Decision execution failed",503,u);if(Date.now()>=t)throw new F(a,u);if(await new Promise(c=>setTimeout(c,Math.min(i,t-Date.now()))),Date.now()>=t)throw new F(a,u);i=Math.min(1e3,i*2);try{l=await e(a,t)}catch(c){if(c instanceof s&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE","RATE_LIMITED"].includes(c.code))continue;throw c}}}function G(n){if("remoteEval"in n)throw new s("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new s("SERVER_ONLY","Funnel decisions are requested by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A server API key is required");let r,t,e=new Map;async function a(c,f){let m=c;m.status!=="pending"&&e.delete(m.decisionId);for(let I=0;I<32&&m.evaluation;I++){let d=m.evaluation;if(d.runId!==m.decisionId)throw new s("INVALID_RESPONSE","Local evaluation Run changed");let w=e.get(m.decisionId);if(!w&&d.type==="evaluate_segment"){let h=ue.parse(await u({operation:"segment_configuration",funnelId:n.funnelId,versionId:d.versionId},f));if(h.configuration.scope.projectId!==n.scope.projectId||h.configuration.scope.environment!==n.scope.environment||h.configuration.funnelId!==n.funnelId||h.configuration.versionId!==d.versionId||h.configuration.evaluationRevision!==d.policyRevision)throw new s("SCOPE_MISMATCH","Original decision segment configuration changed");if(e.size>=128)throw new s("COMMAND_PENDING","Reconcile outstanding decisions first");w={operation:"commit_decision_segment",decisionId:m.decisionId,requestId:M(m.decisionId,d.visit,`segment:${d.revision}`),nodeId:d.nodeId,visit:d.visit,revision:d.revision,policyRevision:d.policyRevision,generation:h.configuration.growth.generation,...me(h.configuration,h.document,d)},e.set(m.decisionId,w)}if(!w){if(d.type!=="evaluate")throw new s("INVALID_RESPONSE","Unknown decision instruction");if((!t||t.versionId!==d.versionId||t.evaluationRevision!==d.policyRevision||t.expiresAt&&Date.parse(t.expiresAt)<=Date.now())&&(t=_.parse(await u({operation:"configuration",funnelId:n.funnelId,versionId:d.versionId},f))),t.scope.projectId!==n.scope.projectId||t.scope.environment!==n.scope.environment||t.funnelId!==n.funnelId)throw new s("SCOPE_MISMATCH","Local evaluation configuration scope changed");if(t.evaluationMode!=="local"||t.versionId!==d.versionId||t.evaluationRevision!==d.policyRevision)throw new s("EVALUATION_MODE","Original Local evaluation policy is unavailable");if(e.size>=128)throw new s("COMMAND_PENDING","Reconcile outstanding Local decisions first");w={operation:"evaluate_decision",decisionId:m.decisionId,requestId:M(m.decisionId,d.visit,"evaluation"),nodeId:d.nodeId,visit:d.visit,revision:d.revision,receiptId:d.receiptId,policyRevision:d.policyRevision,generation:t.growth.generation,result:de(t,d.nodeId,d)},e.set(m.decisionId,w)}let y=R.parse(await u(w,f));if(y.decisionId!==c.decisionId||y.requestId!==c.requestId)throw new s("INVALID_RESPONSE","Decision identity changed during local evaluation");e.delete(m.decisionId),m=y}return m}async function u(c,f,m=!1){let I=q({...n,fetch:(d,w)=>{let y=new Headers(w?.headers);return y.set("Accept-Encoding","identity"),m&&y.set("Prefer","respond-async"),(n.fetch??globalThis.fetch)(d,{...w,headers:y})},timeoutMs:Math.min(n.timeoutMs??1e4,f?Math.max(1,f-Date.now()):12e4)});return I.identify(n.apiKey),I.request("funnels",c)}async function l(c,f){let m=R.parse(await u(N.parse({operation:"read_decision",decisionId:c}),f));if(m.decisionId!==c)throw new s("INVALID_RESPONSE","Decision identity changed");return a(m,f)}async function i(c,f,m=!1){let I=N.options[0].parse({...c,operation:"decide",funnelId:n.funnelId}),d;try{d=R.parse(await u(I,f,m))}catch(w){throw w instanceof s&&["TIMEOUT","NETWORK_ERROR","SERVICE_UNAVAILABLE"].includes(w.code)?new s("DECISION_ACCEPTANCE_UNKNOWN","Decision acceptance is unknown; retry the original request ID and input",w.status,c.requestId):w}if(d.requestId!==c.requestId||d.decision&&!b(d.decision,I.customer))throw new s("INVALID_RESPONSE","Decision request or customer changed");return{response:await a(d,f),customer:I.customer}}return{local(){return r??=x({scope:n.scope,funnelId:n.funnelId,load:()=>u({operation:"local_configuration",funnelId:n.funnelId})})},async configuration(){let c=_.parse(await u({operation:"configuration",funnelId:n.funnelId}));if(c.scope.projectId!==n.scope.projectId||c.scope.environment!==n.scope.environment||c.funnelId!==n.funnelId)throw new s("SCOPE_MISMATCH","Configuration scope changed");return c},features(c={}){return j({...c,scope:n.scope,load:async()=>W.parse(await u({operation:"feature_config",funnelId:n.funnelId}))})},read:c=>l(c),async submit(c){return(await i(c,void 0,!0)).response},async decide(c){let f=Date.now()+3e4,m=await i(c,f);return k(m.response,m.customer,f,l)},async reportUsed(c){let f=ae.parse(await u(N.parse({...c,operation:"report_used"})));if(f.decisionId!==c.decisionId||f.eventId!==c.eventId)throw new s("INVALID_RESPONSE","Usage receipt identity changed");return f}}}function Ne(n){if(typeof window<"u")throw new s("SERVER_ONLY","Native receipts are verified by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","Server API key required");let r=q({...n,timeoutMs:n.timeoutMs??35e3});return r.identify(n.apiKey),{async recover(t){let e=ie.parse(t);if(e.orderId!==e.receiptId)throw new s("INVALID_REQUEST","Native recovery requires the accepted commercial intent");let a=e.nativeEvidence,u={requestId:e.requestId,customerToken:e.customerToken,purchaseIntentId:e.orderId,...a===null?{intent:"read"}:a.provider==="apple"?{provider:"apple",signedTransaction:a.signedTransaction}:{provider:"google",purchaseToken:a.purchaseToken}},l=o.restoreNativePurchase.response.parse(await r.request(o.restoreNativePurchase.path,u));if(l.operation.requestId!==e.requestId)throw new s("INVALID_RESPONSE","Native receipt request identity changed");let i=ce.parse({scope:l.scope,requestId:e.requestId,orderId:l.operation.orderId,receiptId:l.operation.orderId,orderStatus:l.operation.status,refunded:l.operation.refunded,...l.operation.completion===null?{}:{nativeCompletion:{orderId:l.operation.orderId,receiptId:l.operation.orderId,...l.operation.completion}}});if(i.requestId!==e.requestId||i.orderId!==e.orderId||i.receiptId!==e.receiptId||i.scope.projectId!==n.scope.projectId||i.scope.environment!==n.scope.environment)throw new s("INVALID_RESPONSE","Current order receipt scope changed");return i}}}import{z as be}from"zod";var A=be.number().int().min(0).max(Number.MAX_SAFE_INTEGER);function xe(n,r){let t=A.parse(n.inputTokens.total),e=A.parse(n.outputTokens.total),a=A.parse(n.inputTokens.cacheRead??0),u=A.parse(n.inputTokens.cacheWrite??0),l=A.parse(n.outputTokens.reasoning??0);if(a+u>t||l>e||n.inputTokens.noCache!==void 0&&A.parse(n.inputTokens.noCache)!==t-a-u||n.outputTokens.text!==void 0&&A.parse(n.outputTokens.text)!==e-l)throw new s("AI_USAGE_UNAVAILABLE","Provider token counts do not conserve total usage");return{input:t-a-u,cache_read:a,cache_write:u,output:r==="output"?e:e-l,reasoning:r==="separate"?l:0,input_audio:0,output_audio:0}}function ke(n){if(typeof window<"u")throw new s("SERVER_ONLY","AI usage belongs on the trusted backend");if(!n.modelId||!["output","separate"].includes(n.reasoning))throw new s("INVALID_REQUEST","Model ID and reasoning pricing are required");async function r(e){await n.persist({context:e,modelId:n.modelId,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"})}async function t(e,a){let u={context:e,modelId:n.modelId,usage:a,tokens:null,quote:null,receipt:null,phase:"captured"};await n.persist(u);let l=n.mapTokens?n.mapTokens(a):xe(a,n.reasoning),i=await n.pricing.quoteTokens({modelId:n.modelId,tokens:l});await n.persist({...u,tokens:l,quote:i,phase:"quoted"});let c=await n.pricing.trackTokens(n.client,{...e,quote:i});if(!c.receipt.accepted)throw new s("AI_BALANCE_REJECTED","AI usage was captured but the balance operation was rejected");await n.persist({...u,tokens:l,quote:i,receipt:c,phase:"settled"})}return{specificationVersion:"v4",async wrapGenerate({doGenerate:e}){let a=await n.context(),u;try{u=await e()}catch(l){throw await r(a),l}return await t(a,u.usage),u},async wrapStream({doStream:e}){let a=await n.context(),u;try{u=await e()}catch(m){throw await r(a),m}let l=!1,i=!1,c=u.stream.getReader();async function f(){l||i||(i=!0,await r(a))}return{...u,stream:new ReadableStream({async pull(m){try{let{value:I,done:d}=await c.read();if(d){if(!l)throw await f(),new s("AI_USAGE_UNAVAILABLE","Stream ended without final usage; no amount was invented");m.close();return}if(I.type==="finish"){if(l)throw new s("AI_USAGE_UNAVAILABLE","Provider sent more than one final usage record");l=!0,await t(a,I.usage)}m.enqueue(I)}catch(I){try{await f()}finally{m.error(I),await c.cancel(I)}}},async cancel(m){try{await f()}finally{await c.cancel(m)}}})}}}}function Te(n){if(typeof window<"u")throw new s("SERVER_ONLY","Funnel receipts are sent by your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A server API key is required");let r=q(n);return r.identify(n.apiKey),{async signal(t){let e=V.parse({...t,operation:"signal"}),a=ne.parse(await r.request("funnels",e));if(a.runId!==t.runId||a.eventId!==t.eventId||a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new s("INVALID_RESPONSE","Receipt identity changed");return a},async readResults(t){let e=V.parse({operation:"read_results",runId:t}),a=re.parse(await r.request("funnels",e));if(a.runId!==t||a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new s("INVALID_RESPONSE","Result identity changed");return a}}}function Pe(n){if("remoteEval"in n)throw new s("INVALID_REQUEST","Configure evaluation mode on the Funnel; remoteEval is not supported");if(typeof window<"u")throw new s("SERVER_ONLY","Campaign entry requires your backend");if(!/^gg_sk_[A-Za-z0-9_-]{32,128}$/.test(n.apiKey))throw new s("INVALID_TOKEN","A server API key is required");let r=q({...n,timeoutMs:n.timeoutMs??35e3});return r.identify(n.apiKey),{async decide(t){let e=Date.now()+(n.timeoutMs??3e4),a=B.parse({...t,funnelId:n.funnelId,operation:"campaign_decide"}),u=q({...n,timeoutMs:Math.min(n.timeoutMs??35e3,Math.max(1,e-Date.now()))});u.identify(n.apiKey);let l=R.parse(await u.request("funnels",a));if(l.scope.projectId!==n.scope.projectId||l.scope.environment!==n.scope.environment)throw new s("SCOPE_MISMATCH","Campaign scope changed");return k(l,a.customer,e,(i,c)=>G({...n,timeoutMs:Math.min(n.timeoutMs??1e4,Math.max(1,c-Date.now()))}).read(i))},async start(t){let e=B.parse({...t,funnelId:n.funnelId,operation:"campaign_start"}),a=se.parse(await r.request("funnels",e));if(a.scope.projectId!==n.scope.projectId||a.scope.environment!==n.scope.environment)throw new s("SCOPE_MISMATCH","Campaign scope changed");if(!("suppressed"in a)&&(a.run.source.id!==n.funnelId||!a.customerId||e.customer.type==="id"&&a.customerId!==e.customer.value))throw new s("INVALID_RESPONSE","Campaign Funnel or Customer changed");return a}}}function xt(){if(typeof window<"u")throw new s("SERVER_ONLY","Guest identity is issued by your backend");let n=crypto.getRandomValues(new Uint8Array(32));return"gg_gc_"+btoa(String.fromCharCode(...n)).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function kt(n){if(typeof window<"u")throw new s("SERVER_ONLY","Secret API keys must stay on your backend");let r=q(n);return r.identify(n.apiKey),{async listInvoiceTemplates(t={}){let e=o.listInvoiceTemplates;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewInvoice(t){let e=o.previewInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async createInvoice(t){let e=o.createInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageInvoice(t){let e=o.manageInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readInvoiceOperation(t){let e=o.readInvoiceOperation;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listInvoices(t){let e=o.listInvoices;return p(e.response,await r.request(e.path,e.request.parse(t)))},async getInvoice(t){let e=o.getInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async recordCouponRedemption(t){let e=o.recordCouponRedemption,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid Coupon redemption facts");return p(e.response,await r.request(e.path,a.data))},async getFeatures(t={}){let e=o.getFeatures;return p(e.response,await r.request(e.path,e.request.parse(t),e.method))},async evaluateFeatures(t){let e=o.evaluateFeatures;return p(e.response,await r.request(e.path,e.request.parse(t),e.method))},async trackEvents(t){let e=o.trackEvents;return p(e.response,await r.request(e.path,e.request.parse(t),e.method))},async resolvePaywall(t){let e=o.resolvePaywall;return p(e.response,await r.request(e.path,e.request.parse(t)))},async resolveOffering(t){let e=o.resolveOffering;return p(e.response,await r.request(e.path,e.request.parse(t)))},async checkEntitlement(t){let e=o.checkEntitlement;return p(e.response,await r.request(e.path,e.request.parse(t)))},async setupPayment(t){let e=o.setupPayment;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readPaymentSetup(t){let e=o.readPaymentSetup;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewSubscriptionBatch(t){let e=o.previewSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async confirmSubscriptionBatch(t){let e=o.confirmSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionBatch(t){let e=o.readSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async abandonSubscriptionBatch(t){let e=o.abandonSubscriptionBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageSubscriptionTrial(t){let e=o.manageSubscriptionTrial;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionTrial(t){let e=o.readSubscriptionTrial;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptions(t){let e=o.listSubscriptions;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listPurchases(t){let e=o.listPurchases;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listSubscriptionConflicts(t){let e=o.listSubscriptionConflicts;return p(e.response,await r.request(e.path,e.request.parse(t)))},async retrySubscriptionConflict(t){let e=o.retrySubscriptionConflict;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewRefund(t){let e=o.previewRefund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async refund(t){let e=o.refund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readRefund(t){let e=o.readRefund;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewUpdate(t){let e=o.previewUpdate;return p(e.response,await r.request(e.path,e.request.parse(t)))},async update(t){let e=o.update;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionUpdate(t){let e=o.readSubscriptionUpdate;return p(e.response,await r.request(e.path,e.request.parse(t)))},async restoreNativePurchase(t){let e=o.restoreNativePurchase;return p(e.response,await r.request(e.path,e.request.parse(t)))},async verifySubscriptions(t){let e=o.verifySubscriptions;return p(e.response,await r.request(e.path,e.request.parse(t)))},async previewAttach(t){let e=o.previewAttach;return p(e.response,await r.request(e.path,e.request.parse(t)))},async attach(t){let e=o.attach;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSubscriptionOperation(t){let e=o.readSubscriptionOperation;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readAiPricing(t){let e=o.readAiPricing;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsage(t){let e=o.readUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async setUsage(t){let e=o.setUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageBalanceGrant(t){let e=o.manageBalanceGrant;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readBalanceSource(t){let e=o.readBalanceSource;return p(e.response,await r.request(e.path,e.request.parse(t)))},async adjustBalance(t){let e=o.adjustBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async listBalanceGrants(t){let e=o.listBalanceGrants;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageBillingLimits(t){let e=o.manageBillingLimits;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readSeats(t){let e=o.readSeats;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageSeat(t){let e=o.manageSeat;return p(e.response,await r.request(e.path,e.request.parse(t)))},async manageUsageEntity(t){let e=o.manageUsageEntity;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageAnalytics(t){let e=o.readUsageAnalytics;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditAnalytics(t){let e=o.readCreditAnalytics;return p(e.response,await r.request(e.path,e.request.parse(t)))},async submitUsageBatch(t){let e=o.submitUsageBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readUsageBatch(t){let e=o.readUsageBatch;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readHoldings(t){let e=o.readHoldings;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readLedger(t){let e=o.readLedger;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readBillingInvoice(t){let e=o.readBillingInvoice;return p(e.response,await r.request(e.path,e.request.parse(t)))},async readCreditStatement(t){let e=o.readCreditStatement;return p(e.response,await r.request(e.path,e.request.parse(t)))},async quoteBalance(t){let e=o.quoteBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async trackUsage(t){let e=o.trackUsage;return p(e.response,await r.request(e.path,e.request.parse(t)))},async mutateBalance(t){let e=o.mutateBalance;return p(e.response,await r.request(e.path,e.request.parse(t)))},async getCustomer(t){let e=o.getCustomer,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid customer lookup");let u=e.response.safeParse(await r.request(e.path,a.data));if(!u.success)throw new s("INVALID_RESPONSE","Invalid customer response");return u.data},async listCustomers(t={}){let e=o.listCustomers,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid customer filters");let u=e.response.safeParse(await r.request(e.path,a.data));if(!u.success)throw new s("INVALID_RESPONSE","Invalid customer response");return u.data},async updateCustomer(t){let e=o.updateCustomer,a=e.request.safeParse(t);if(!a.success)throw new s("INVALID_REQUEST","Invalid customer patch");let u=e.response.safeParse(await r.request(e.path,a.data));if(!u.success)throw new s("INVALID_RESPONSE","Invalid customer response");return u.data},async createGuestCustomer(t){let e=o.createGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async resumeGuestSession(t){let e=o.resumeGuestSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async claimGuestCustomer(t){let e=o.claimGuestCustomer;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async renewCustomerSession(t){let e=o.renewSession;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async revokeCustomerSessions(t){let e=o.revokeSessions;return e.response.parse(await r.request(e.path,e.request.parse(t)))},async createCustomerSession(t){let e=o.createSession.request.safeParse({customerId:t});if(!e.success)throw new s("INVALID_REQUEST","A customer ID is required");let a=o.createSession.response.safeParse(await r.request("customer-sessions",e.data));if(!a.success)throw new s("INVALID_RESPONSE","Invalid customer session response");return a.data},async getOrCreateCustomer(t){let e=o.createCustomer.request.safeParse(t);if(!e.success)throw new s("INVALID_REQUEST","Invalid customer input");let a=o.createCustomer.response.safeParse(await r.request("customers",e.data));if(!a.success)throw new s("INVALID_RESPONSE","Invalid customer response");return a.data},async grantOffer(t){let e=o.grantOffer.request.safeParse({...t,requestId:t.requestId??crypto.randomUUID()});if(!e.success||!e.data.customerId)throw new s("INVALID_REQUEST","Invalid offer grant");let a=o.grantOffer.response.safeParse(await r.request("offers/grant",e.data));if(!a.success)throw new s("INVALID_RESPONSE","Invalid offer response");return a.data}}}async function Tt(n,r){if(typeof window<"u")throw new s("SERVER_ONLY","Renewal requires your backend");let{funnelCredentialCommandSchema:t,funnelCredentialResponseSchema:e}=await import("./src-X6KT6WIH.js"),a=q(n);return a.identify(n.apiKey),e.parse(await a.request("funnels",t.parse({...r,operation:"renew_run"})))}export{F as FunnelDecisionTimeoutError,s as IndianaError,Ce as aiPriceSnapshotSchema,Re as aiTokenQuoteSchema,Fe as createAiPricing,ke as createAiUsageMiddleware,Ee as createConfigurationSync,Le as createConfiguredAiPricing,j as createFeatureClient,Pe as createFunnelCampaignClient,G as createFunnelDecisionClient,x as createFunnelLocalEvaluator,Te as createFunnelOrchestrationClient,qe as createFunnelStartClient,xt as createGuestToken,kt as createIndianaServer,Ae as createLocalFunnelClient,Ne as createNativeReceiptClient,_e as createPaywallStartClient,Oe as createSynchronizedFunnelLocalEvaluator,Se as evaluateFunnelNode,Tt as renewFunnelRun};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as Xa,$a as Xb,$b as Cd,$c as Ge,$d as kh,$e as ki,$f as wj,$g as Ck,$h as Cl,$i as Cm,$j as Dn,A as Q,Aa as wb,Ab as Lc,Ac as fe,Ad as nf,Ae as Lh,Af as Ri,Ag as Xj,Ah as bl,Ai as bm,Aj as bn,Ak as co,B as R,Ba as xb,Bb as Mc,Bc as ge,Bd as of,Be as Mh,Bf as Si,Bg as Yj,Bh as cl,Bi as cm,Bj as cn,Bk as lo,C as S,Ca as yb,Cb as Nc,Cc as he,Cd as pf,Ce as Nh,Cf as Ti,Cg as Zj,Ch as dl,Ci as dm,Cj as dn,Ck as mo,D as T,Da as zb,Db as Oc,Dc as ie,Dd as qf,De as Oh,Df as Ui,Dg as _j,Dh as el,Di as em,Dj as en,Dk as no,E as U,Ea as Ab,Eb as Pc,Ec as je,Ed as rf,Ee as Ph,Ef as Vi,Eg as $j,Eh as fl,Ei as fm,Ej as fn,Ek as oo,F as V,Fa as Bb,Fb as Qc,Fc as ke,Fd as uf,Fe as Qh,Ff as Wi,Fg as ak,Fh as gl,Fi as gm,Fj as gn,Fk as po,G as W,Ga as Cb,Gb as Rc,Gc as le,Gd as vf,Ge as Rh,Gf as Xi,Gg as bk,Gh as hl,Gi as hm,Gj as hn,Gk as qo,H as Z,Ha as Db,Hb as Sc,Hc as me,Hd as Sg,He as Sh,Hf as Yi,Hg as ck,Hh as il,Hi as im,Hj as jn,Hk as ro,I as _,Ia as Eb,Ib as Tc,Ic as ne,Id as Tg,Ie as Th,If as Zi,Ig as dk,Ih as jl,Ii as jm,Ij as kn,Ik as so,J as $,Ja as Fb,Jb as ad,Jc as oe,Jd as Ug,Je as Uh,Jf as _i,Jg as ek,Jh as kl,Ji as km,Jj as ln,Jk as to,K as aa,Ka as Gb,Kb as bd,Kc as pe,Kd as Vg,Ke as Vh,Kf as $i,Kg as fk,Kh as ll,Ki as lm,Kj as mn,Kk as uo,L as ba,La as Hb,Lb as cd,Lc as qe,Ld as Wg,Le as Wh,Lf as aj,Lg as gk,Lh as ml,Li as mm,Lj as nn,Lk as vo,M as ca,Ma as Ib,Mb as dd,Mc as re,Md as Xg,Me as Xh,Mf as bj,Mg as hk,Mh as nl,Mi as nm,Mj as on,Mk as wo,N as da,Na as Jb,Nb as ed,Nc as se,Nd as Yg,Ne as Yh,Nf as cj,Ng as ik,Nh as ol,Ni as om,Nj as pn,Nk as xo,O as ea,Oa as Kb,Ob as fd,Oc as te,Od as Zg,Oe as Zh,Of as dj,Og as jk,Oh as pl,Oi as pm,Oj as qn,Ok as yo,P as fa,Pa as Lb,Pb as gd,Pc as ue,Pd as _g,Pe as _h,Pf as ej,Pg as kk,Ph as ql,Pi as qm,Pj as rn,Pk as zo,Q as ga,Qa as Mb,Qb as hd,Qc as ve,Qd as $g,Qe as $h,Qf as fj,Qg as rk,Qh as rl,Qi as rm,Qj as sn,Qk as Ao,R as ha,Ra as Nb,Rb as id,Rc as we,Rd as ah,Re as ai,Rf as gj,Rg as sk,Rh as sl,Ri as sm,Rj as tn,Rk as Bo,S as ia,Sa as Ob,Sb as jd,Sc as xe,Sd as bh,Se as bi,Sf as hj,Sg as tk,Sh as tl,Si as tm,Sj as un,Sk as Co,T as ja,Ta as Pb,Tb as kd,Tc as ye,Td as ch,Te as ci,Tf as ij,Tg as uk,Th as ul,Ti as um,Tj as vn,Tk as Do,U as ka,Ua as Qb,Ub as ld,Uc as ze,Ud as dh,Ue as di,Uf as jj,Ug as vk,Uh as vl,Ui as vm,Uj as wn,Uk as Eo,V as Ra,Va as Rb,Vb as md,Vc as Ae,Vd as eh,Ve as ei,Vf as kj,Vg as wk,Vh as wl,Vi as wm,Vj as xn,Vk as Fo,W as Sa,Wa as Sb,Wb as nd,Wc as Be,Wd as fh,We as fi,Wf as lj,Wg as xk,Wh as xl,Wi as xm,Wj as yn,Wk as Go,X as Ta,Xa as Tb,Xb as yd,Xc as Ce,Xd as gh,Xe as gi,Xf as sj,Xg as yk,Xh as yl,Xi as ym,Xj as zn,Xk as Ho,Y as Ua,Ya as Ub,Yb as zd,Yc as De,Yd as hh,Ye as hi,Yf as tj,Yg as zk,Yh as zl,Yi as zm,Yj as An,Yk as Io,Z as Va,Za as Vb,Zb as Ad,Zc as Ee,Zd as ih,Ze as ii,Zf as uj,Zg as Ak,Zh as Al,Zi as Am,Zj as Bn,_ as Wa,_a as Wb,_b as Bd,_c as Fe,_d as jh,_e as ji,_f as vj,_g as Bk,_h as Bl,_i as Bm,_j as Cn,a,aa as Ya,ab as Yb,ac as Dd,ad as He,ae as lh,af as li,ag as xj,ah as Dk,ai as Dl,aj as Dm,ak as En,b,ba as Za,bb as Zb,bc as Id,bd as Ie,be as mh,bf as mi,bg as yj,bh as Ek,bi as El,bj as Em,bk as Fn,c,ca as _a,cb as _b,cc as Jd,cd as Je,ce as nh,cf as ni,cg as zj,ch as Fk,ci as Fl,cj as Fm,ck as Gn,d,da as $a,db as $b,dc as Kd,dd as Ke,de as oh,df as oi,dg as Aj,dh as Gk,di as Gl,dj as Gm,dk as Hn,e,ea as ab,eb as ac,ec as Ld,ed as Le,ee as ph,ef as pi,eg as Bj,eh as Hk,ei as Hl,ej as Hm,ek as In,f,fa as bb,fb as bc,fc as Md,fd as Me,fe as qh,ff as qi,fg as Cj,fh as Ik,fi as Il,fj as Im,fk as Jn,g,ga as cb,gb as cc,gc as Nd,gd as Ne,ge as rh,gf as ri,gg as Dj,gh as Jk,gi as Jl,gj as Jm,gk as Kn,h,ha as db,hb as dc,hc as Od,hd as Oe,he as sh,hf as si,hg as Ej,hh as Kk,hi as Kl,hj as Km,hk as Ln,i,ia as eb,ib as ec,ic as Pd,id as Pe,ie as th,if as ti,ig as Fj,ih as Lk,ii as Ll,ij as Lm,ik as Mn,j,ja as fb,jb as fc,jc as Qd,jd as Xe,je as uh,jf as ui,jg as Gj,jh as Mk,ji as Ml,jj as Mm,jk as Nn,k,ka as gb,kb as vc,kc as Rd,kd as Ye,ke as vh,kf as vi,kg as Hj,kh as Nk,ki as Nl,kj as Nm,kk as On,l,la as hb,lb as wc,lc as Sd,ld as Ze,le as wh,lf as wi,lg as Ij,lh as Ok,li as Ol,lj as Om,lk as Pn,m,ma as ib,mb as xc,mc as Td,md as _e,me as xh,mf as xi,mg as Jj,mh as Pk,mi as Pl,mj as Pm,mk as Qn,n,na as jb,nb as yc,nc as Ud,nd as $e,ne as yh,nf as yi,ng as Kj,nh as Qk,ni as Ql,nj as Qm,nk as Rn,o,oa as kb,ob as zc,oc as Vd,od as af,oe as zh,of as zi,og as Lj,oh as Rk,oi as Rl,oj as Rm,ok as Sn,p,pa as lb,pb as Ac,pc as Wd,pd as bf,pe as Ah,pf as Ai,pg as Mj,ph as Sk,pi as Sl,pj as Sm,pk as Tn,q,qa as mb,qb as Bc,qc as Xd,qd as cf,qe as Bh,qf as Bi,qg as Nj,qh as Tk,qi as Tl,qj as Tm,qk as Un,r,ra as nb,rb as Cc,rc as Yd,rd as df,re as Ch,rf as Ci,rg as Oj,rh as Uk,ri as Ul,rj as Um,rk as Vn,s,sa as ob,sb as Dc,sc as Zd,sd as ef,se as Dh,sf as Di,sg as Pj,sh as Vk,si as Vl,sj as Vm,sk as Wn,t as z,ta as pb,tb as Ec,tc as _d,td as ff,te as Eh,tf as Ei,tg as Qj,th as Wk,ti as Wl,tj as Wm,tk as Xn,u as A,ua as qb,ub as Fc,uc as $d,ud as gf,ue as Fh,uf as Fi,ug as Rj,uh as Xk,ui as Xl,uj as Xm,uk as Yn,v as B,va as rb,vb as Gc,vc as ae,vd as hf,ve as Gh,vf as Gi,vg as Sj,vh as Yk,vi as Yl,vj as Ym,vk as Zn,w as C,wa as sb,wb as Hc,wc as be,wd as jf,we as Hh,wf as Hi,wg as Tj,wh as Zk,wi as Zl,wj as Zm,wk as _n,x as D,xa as tb,xb as Ic,xc as ce,xd as kf,xe as Ih,xf as Oi,xg as Uj,xh as _k,xi as _l,xj as _m,xk as $n,y as E,ya as ub,yb as Jc,yc as de,yd as lf,ye as Jh,yf as Pi,yg as Vj,yh as $k,yi as $l,yj as $m,yk as ao,z as P,za as vb,zb as Kc,zc as ee,zd as mf,ze as Kh,zf as Qi,zg as Wj,zh as al,zi as am,zj as an,zk as bo}from"./chunk-VMLGV5OS.js";import{$ as xd,$a as ig,A as lc,Aa as Jf,Ab as Jg,B as mc,Ba as Kf,Bb as Kg,C as nc,Ca as Lf,Cb as Lg,D as oc,Da as Mf,Db as Mg,E as pc,Ea as Nf,Eb as Ng,F as qc,Fa as Of,Fb as Og,G as rc,Ga as Pf,Gb as Pg,H as sc,Ha as Qf,Hb as Qg,I as tc,Ia as Rf,Ib as Rg,J as uc,Ja as Sf,Jb as mj,K as Uc,Ka as Tf,Kb as nj,L as Vc,La as Uf,Lb as oj,M as Wc,Ma as Vf,Mb as pj,N as Xc,Na as Wf,Nb as qj,O as Yc,Oa as Xf,Ob as rj,P as Zc,Pa as Yf,Pb as lk,Q as _c,Qa as Zf,Qb as mk,R as $c,Ra as _f,Rb as nk,S as od,Sa as $f,Sb as ok,T as pd,Ta as ag,Tb as pk,U as qd,Ua as bg,Ub as qk,V as rd,Va as cg,W as sd,Wa as dg,X as td,Xa as eg,Y as ud,Ya as fg,Z as vd,Za as gg,_ as wd,_a as hg,a as t,aa as Ed,ab as jg,b as u,ba as Fd,bb as kg,c as v,ca as Gd,cb as lg,d as w,da as Hd,db as mg,e as x,ea as Qe,eb as ng,f as y,fa as Re,fb as og,g as F,ga as Se,gb as pg,h as G,ha as Te,hb as qg,i as H,ia as Ue,ib as rg,j as I,ja as Ve,jb as sg,k as J,ka as We,kb as tg,l as K,la as sf,lb as ug,m as L,ma as tf,mb as vg,n as M,na as wf,nb as wg,o as N,oa as xf,ob as xg,p as O,pa as yf,pb as yg,q as Ma,qa as zf,qb as zg,r as Na,ra as Af,rb as Ag,s as Oa,sa as Bf,sb as Bg,t as Pa,ta as Cf,tb as Cg,u as Qa,ua as Df,ub as Dg,v as gc,va as Ef,vb as Eg,w as hc,wa as Ff,wb as Fg,x as ic,xa as Gf,xb as Gg,y as jc,ya as Hf,yb as Hg,z as kc,za as If,zb as Ig}from"./chunk-RMJJOSVZ.js";import{a as X,b as Y,c as Ii,d as Ji,e as Ki,f as Li,g as Mi,h as Ni,i as eo,j as fo,k as go,l as ho,m as io,n as jo,o as ko}from"./chunk-OHDY27EI.js";import{A as Ia,B as Ja,C as Ka,D as La,a as la,b as ma,c as na,f as oa,g as pa,h as qa,i as ra,j as sa,l as ta,m as ua,n as va,o as wa,p as xa,q as ya,r as za,s as Aa,t as Ba,u as Ca,v as Da,w as Ea,x as Fa,y as Ga,z as Ha}from"./chunk-S2MSIA57.js";export{Yh as CODE_REFERENCE_LIMITS,Pa as COMMON_LOCALES,lo as CONFIGURATION_POLICY,Ra as COUPON_TERM_LOCALES,Hf as CUSTOMER_DATA_SOURCES,Td as CreateInvoiceParamsSchema,Sd as CreateInvoicePreviewSchema,Vm as DEFAULT_AUDIENCE_GROUP,Bk as DEFAULT_FUNNEL_EXECUTION_POLICY,dl as FUNNEL_API_CAPABILITIES,uj as FUNNEL_EXECUTION_LIMITS,sj as FUNNEL_LIMITS,om as FUNNEL_PREVIEW_LIMITS,Ho as FUNNEL_READ_ONLY_OPERATIONS,vj as FUNNEL_RECORDING_LIMITS,xo as FUNNEL_SEGMENT_BYTES,wo as FUNNEL_SEGMENT_LIMIT,dm as FUNNEL_SERVER_KEY_HEADER,ql as FunnelCalculationError,Qd as InvoiceModeParamsSchema,Rd as InvoiceTemplateSchema,Ze as OFFERING_MAX_DEPTH,$e as OFFERING_MAX_ITEMS,_e as OFFERING_MAX_PRODUCTS,Bg as POPUP_WIDTHS,Pd as ReissueInvoiceParamsSchema,Sf as SCREEN_LIMITS,mj as SCREEN_RENDER_PATH,Rf as SCREEN_SCHEMA_VERSION,zj as SCREEN_TEMPLATES,vc as SDK_PROTOCOL_HEADER,xc as SDK_SUPPORT_HEADER,yc as SDK_SUPPORT_POLICY,wc as SDK_VERSION_HEADER,zg as SURFACE_PATHS,zf as SURFACE_VARIABLES,Ec as SdkProtocolError,tj as UNBOUND_PRODUCT_VERSION_ID,jo as VISUAL_EDITOR_PARAM,Cc as addSupportMonths,j as aiCreditSystemConfigSchema,lh as aiMarkupSchema,kh as aiModelIdSchema,mh as aiModelRatesSchema,nh as aiPricingConfigurationSchema,jh as aiTokenPools,w as amountToMinor,Fi as analyticsConfigSchema,Hi as analyticsEventEnabled,lc as apiErrorCatalog,mc as apiErrorCodeForStatus,gc as apiErrorCodeSchema,kj as apiOperations,dj as apiPermissionSchema,on as appResultsSchema,nn as appRevenueSchema,xn as appendScreenTemplate,Vn as applyGrowthReleasePlan,_j as archiveSurfaceTemplateSchema,Ym as audienceCustomerSchema,fn as audienceFunnelUsageSchema,gn as audienceFunnelUsagesSchema,Zm as audienceMembersSchema,Hc as audienceSchema,Xm as audienceWriteSchema,Qm as auditFieldSchema,Tm as auditHistoryCursorSchema,Um as auditHistorySchema,Pm as auditResourceSchema,qb as autoTopupPurchaseLimitSchema,Cb as autoTopupStateSchema,ao as autumnAmountToMinor,Em as autumnCustomerAutoTopupSchema,Jm as autumnCustomerControlsSchema,Lm as autumnCustomerMetadataSchema,Im as autumnCustomerOverageAllowedSchema,Nm as autumnCustomerProductSummarySchema,Mm as autumnCustomerProfileRecordSchema,Fm as autumnCustomerSpendLimitSchema,Hm as autumnCustomerUsageAlertSchema,Gm as autumnCustomerUsageLimitSchema,Km as autumnEntityControlsSchema,bo as autumnMinorToAmount,co as autumnUsageUnitAmountDecimal,eh as balanceAdjustmentCommandSchema,fh as balanceAdjustmentStateSchema,Yc as balanceAllocationSchema,Vc as balanceCommandSchema,bd as balanceGrantCommandSchema,ad as balanceGrantCreateSchema,ed as balanceGrantPageSchema,dd as balanceGrantReadSchema,cd as balanceGrantSchema,$c as balanceOperationSchema,Wc as balancePricingSegmentSchema,_c as balanceQuoteSchema,Xc as balanceReceiptUnitsSchema,Zc as balanceRejectionReasonSchema,Dn as balanceSourceReasonSchema,gh as balanceSourceStateSchema,En as balanceSourceStatusSchema,Gn as balanceSourcesPageSchema,Fn as balanceSourcesQuerySchema,jb as billingAccruedMinorSchema,ib as billingAmountMinorSchema,tb as billingAuthorizationSchema,sb as billingAuthorizationTermsSchema,kb as billingBudgetMinorSchema,Db as billingControlInputSchema,Eb as billingControlsSchema,Mb as billingCouponsSchema,z as billingCurrencies,Fb as billingInvoiceLineSchema,Gb as billingInvoiceSchema,Jb as billingInvoicesSchema,xb as billingLimitSchema,Wj as billingPortalInputSchema,Xj as billingPortalSchema,D as billingSettingsMutationSchema,B as billingSettingsSchema,C as billingSettingsScopeSchema,Bb as billingUsageWindowSchema,eg as borderSchema,kg as buttonNodeSchema,rl as calculateFunnelNode,Kc as campaignInputSchema,Ic as campaignOfferSchema,Lc as campaignSchema,Na as canonicalLocale,Af as capabilityBindingSchema,ob as cashPriceSchema,mb as cashPricingSchema,lb as cashPricingTiersSchema,hb as cashUnitAmountMinorSchema,Oh as claimRewardProductRequestSchema,$h as codeReferenceBranchSchema,fi as codeReferenceConfigRequestSchema,ei as codeReferenceConfigureSchema,li as codeReferenceFeatureSummarySchema,Zh as codeReferenceKeySchema,ai as codeReferencePathSchema,ii as codeReferenceReceiptSchema,_h as codeReferenceRepoSchema,hi as codeReferenceReportSchema,ci as codeReferenceRepositoryInputSchema,di as codeReferenceRepositorySchema,gi as codeReferenceScanConfigSchema,ji as codeReferenceScanSchema,ki as codeReferenceSettingsSchema,mi as codeReferenceSummarySchema,Gd as commerceAccessSchema,Qe as commerceContextSchema,De as commerceCursorSchema,Ee as commerceListQuerySchema,Hd as commerceMoneySchema,zn as commerceProductKind,Fd as commerceProductKindSchema,Ed as commerceProviderSchema,Ea as compileGrowthFeatures,oo as configurationArtifactSchema,uo as configurationDependencies,no as configurationDependenciesSchema,so as configurationDigest,po as configurationFunnelSchema,to as configurationGeneration,ro as configurationJson,mo as configurationScopeSchema,Hb as confirmBillingAdjustmentInputSchema,vb as confirmBillingAuthorizationInputSchema,ic as consoleErrorCodeSchema,tc as consoleErrorResponseSchema,Zn as consoleHasPermission,ne as consoleRefundRequestSchema,Xn as consoleResources,Yn as consoleRolePermissions,Wn as consoleRoleSchema,rg as countdownNodeSchema,Ya as couponAppliesToSchema,bb as couponChangeErrors,qg as couponCodeNodeSchema,tl as couponContentDigestSchema,Wa as couponDiscountSchema,_m as couponDisplaySchema,Ej as couponDistributionBatchSchema,Gj as couponDistributionDetailSchema,Dj as couponDistributionPreviewSchema,Fj as couponDistributionRecipientSchema,Hj as couponDistributionWriteSchema,Xa as couponDurationSchema,Za as couponEligibilitySchema,_a as couponInputSchema,Di as couponRedemptionCommandSchema,Ei as couponRedemptionReceiptSchema,Va as couponStatusSchema,Dm as couponTemplateExample,Bm as couponTemplateKey,eb as couponWindow,bn as createAccountOverviewPage,an as createCreditCenterPage,dn as createCustomerPageTemplates,gj as createCustomerRequestSchema,hj as createCustomerResponseSchema,cn as createMembershipPage,Qh as createReferralCodeRequestSchema,F as creditAmountSchema,qh as creditAnalyticsFilterSchema,sh as creditAnalyticsPageSchema,rh as creditAnalyticsQuerySchema,oh as creditAnalyticsRangeSchema,ph as creditAnalyticsTimezoneSchema,L as creditDimensionSchema,M as creditMultiplierSchema,H as creditPriceAdjustmentSchema,N as creditPricingSchema,J as creditPropertiesSchema,G as creditQuantitySchema,O as creditRateSchema,Ob as creditResetCountSchema,Nb as creditResetSchema,I as creditResourceKeySchema,Pb as creditRolloverSchema,c as creditSchemaItemSchema,id as creditStatementInputSchema,jd as creditStatementSchema,i as creditSystemConfigSchema,K as creditTiersSchema,t as currencies,A as currencyAmountOptionsSchema,v as currencyDecimals,u as currencySchema,lj as currentApiOperations,kd as currentNotificationEventTypeSchema,og as customHtmlNodeSchema,ka as customerActivitySchema,oi as customerAttributesSchema,Wm as customerAudienceSchema,Jf as customerDataConfigSchema,Mf as customerDataIntentSchema,mg as customerDataNodeSchema,ui as customerDataReferenceMessage,ti as customerDataReferenced,si as customerDataSchema,If as customerDataSourceSchema,jj as customerEntitlementsSchema,Bi as customerFiltersSchema,pi as customerFingerprintSchema,pn as customerFunnelDecisionsSchema,zi as customerGetSchema,sd as customerHoldingsSchema,qi as customerInputSchema,wd as customerLedgerEntrySchema,xd as customerLedgerPageSchema,vd as customerLedgerQuerySchema,xi as customerLookupSchema,wi as customerMutationSchema,Lf as customerPageDataSchema,Kf as customerPageNodeStateSchema,Om as customerPageSampleData,Ci as customerPageSchema,yi as customerPatchSchema,ec as customerPlanCreateSchema,fc as customerPlanCreatedSchema,ja as customerPlanSchema,vi as customerProfileSchema,ri as customerReferenceSchema,Vj as customerScheduledChangeCancelSchema,Tj as customerScheduledChangeSchema,Uj as customerScheduledChangesSchema,Mc as customerSchema,ni as customerTagsSchema,Ai as customerUpdateRequestSchema,bi as defaultCodeReferenceMethods,yj as defaultScreenTheme,cb as describeCoupon,_b as diffProductVariant,lg as dividerNodeSchema,Nf as emptyCustomerPageNode,Se as entitlementCheckInputSchema,Te as entitlementCheckReasonSchema,Ve as entitlementCheckResultSchema,Re as entitlementRequirementSchema,ga as entitlementSnapshotSchema,ij as entitlementStatusSchema,X as environmentSchema,Cd as environmentSettingsSchema,oc as errorCodeMatchesStatus,uc as errorMetadata,qc as errorMetadataSchema,nc as errorPolicy,kc as errorReasonSchema,jc as errorRecoverySchema,rc as errorResponseSchema,Pf as escapeHtmlText,pa as evalCondition,sa as evalFeature,Qi as evaluateFeaturesRequestSchema,Si as evaluateFeaturesResultSchema,am as executionSourceSchema,Fo as expandFunnelSegment,Da as experimentConfigurationSchema,Ca as experimentPhaseSchema,Ha as experimentSnapshotSchema,n as featureCollectionSchema,g as featureConfigOverrideSchema,k as featureDefinitionSchema,Oi as featureDeliveryPayloadSchema,a as featureIdSchema,$ as featureInputSchema,f as featureMarkupsOverrideSchema,o as featureOptionsSchema,Ni as featurePayloadSchema,m as featureRecordSchema,aa as featureSchema,_n as featureTypes,$n as featureUpdateBlockers,l as featureUpdateRulesSchema,od as featureUsageReadSchema,pd as featureUsageSetSchema,qd as featureUsageStateSchema,b as featureUsageTypeSchema,p as featureWriteSchema,Hg as fieldValue,cg as fillSchema,rd as financialAmountSchema,ud as financialCursorSchema,td as financialEntryTypeSchema,Pg as findDocumentNode,Og as findNode,Am as formatCouponConditions,Ta as formatCouponDiscount,Sa as formatCouponMoney,Ua as formatCouponTerms,y as formatCurrencyMinor,Cn as formatProductBillingPeriod,db as formatUsd,el as funnelApiBindingSchema,bl as funnelApiProjectionSchema,Wk as funnelBundleDefinitionSchema,_k as funnelBundleLiterals,Zk as funnelBundleResultSchema,Xk as funnelBundleSelectionSchema,gm as funnelCampaignCommandSchema,hm as funnelCampaignStartResponseSchema,fl as funnelCapabilitySchema,Xl as funnelCollectionSchema,Ul as funnelCommandSchema,jm as funnelConfigurationSchema,Cl as funnelConsumedVariables,Eo as funnelContextDelta,em as funnelCredentialCommandSchema,fm as funnelCredentialResponseSchema,Tl as funnelDataQueriesSchema,Sk as funnelDecideShape,Tk as funnelDecisionCommandSchema,Mk as funnelDecisionEvaluationSchema,Qk as funnelDecisionOutputSchema,Uk as funnelDecisionResponseSchema,Rk as funnelDecisionSchema,Pk as funnelDecisionSegmentEvaluationSchema,Vk as funnelDecisionUsedResponseSchema,Ll as funnelDocumentDraftSchema,Pl as funnelDocumentSchema,ik as funnelEvaluationAttributes,Lk as funnelEvaluationInstructionSchema,Jk as funnelEvaluationModeSchema,Kk as funnelEvaluationResultSchema,Ak as funnelExecutionPolicySchema,Il as funnelExecutionStateSchema,hl as funnelExternalPageUrlSchema,zk as funnelExternalTaskSchema,kl as funnelGraphDraftSchema,jl as funnelGraphNodeSchema,ll as funnelGraphSchema,ml as funnelGraphTargets,en as funnelGroupReferenceSchema,$l as funnelInstructionSchema,sl as funnelInvocationId,km as funnelLocalConfigurationSchema,vl as funnelLocalScreenCommandSchema,wl as funnelLocalScreenResponseSchema,Ok as funnelLocalSegmentStepSchema,Io as funnelNodeAcceptsEffect,Gl as funnelNodeInputSchema,El as funnelNodeKindSchema,fk as funnelNodeProjections,Hl as funnelNodeResultSchema,ck as funnelNodeWritesSchema,il as funnelOpenInSchema,Fk as funnelOrchestrationCommandSchema,ok as funnelParametersFromUrl,Sl as funnelPresentationSubmissionSchema,pm as funnelPreviewCommandSchema,sm as funnelPreviewDependencySchema,tm as funnelPreviewJournalSchema,qm as funnelPreviewOutcomeSchema,vm as funnelPreviewRequestSchema,wm as funnelPreviewResponseSchema,rm as funnelPreviewScenarioSchema,ym as funnelPreviewShareWriteSchema,xm as funnelPreviewSnapshotSchema,um as funnelPreviewSourceSchema,$k as funnelProjectionFilterValueSchema,al as funnelProjectionWhereSchema,Rl as funnelPublicationDraftSchema,Nl as funnelPublicationRules,Ql as funnelPublicationSchema,Ol as funnelPublishableDraftSchema,yo as funnelPureNode,Wl as funnelRecordSchema,Fl as funnelResourceReferenceSchema,hn as funnelResultsCursorSchema,jn as funnelResultsQuerySchema,Ik as funnelResultsResponseSchema,kn as funnelResultsSchema,bm as funnelRunViewSchema,cm as funnelRuntimeResponseSchema,_l as funnelRuntimeStatusSchema,zl as funnelScreenReads,yl as funnelScreenTokens,Al as funnelScreenValues,Go as funnelSegmentConfigurationSchema,Nk as funnelSegmentEvaluationInstructionSchema,Do as funnelSegmentHasDynamicHash,zo as funnelSegmentPositionSchema,Bo as funnelSegmentSchema,Ao as funnelSegmentStepSchema,Gk as funnelSignalResponseSchema,zm as funnelStatisticsSchema,Co as funnelStepId,yk as funnelTaskBindingSchema,wk as funnelTaskDataSchema,xk as funnelTaskOutputsSchema,Ck as funnelTaskResponseSchema,Hk as funnelTaskResultsSchema,wn as funnelTemplateDraft,un as funnelTemplateSchema,lm as funnelTopology,im as funnelTopologySchema,Jl as funnelTraceEventSchema,sk as funnelValueBindingSchema,$j as funnelValueDeclarationSchema,dk as funnelValueMatches,rk as funnelValuePathSchema,hk as funnelValueSchema,ak as funnelVariableDeclarationSchema,bk as funnelVariableDeclarationsSchema,xl as funnelVariableRead,ek as funnelVariableValues,wj as funnelVisitAllowed,Dl as funnelWaitKindSchema,Yl as funnelWriteSchema,Ji as gbRuntimeExperimentResultSchema,Ii as gbRuntimeExperimentSchema,Ki as gbRuntimeFeatureRuleSchema,Li as gbRuntimeFeatureSchema,Mi as gbRuntimeSavedGroupsSchema,la as getQueryStringOverride,Un as getRecommendedRolloutData,qa as getStickyBucketAttributes,Mn as growthAttributeSchema,ua as growthAttributesSchema,On as growthCatalogSchema,xa as growthConditionGroupIds,kk as growthConditionPaths,va as growthConditionSchema,Qn as growthDryRunSchema,Rn as growthExperimentInspectionSchema,Fa as growthExperimentStop,Ga as growthFeatureExpiry,za as growthFeatureRuleSchema,Aa as growthFeatureSchema,Ba as growthFeaturesSchema,Sn as growthGroupReferenceCursorSchema,Tn as growthGroupReferencesSchema,wa as growthGroupSchema,Nn as growthNamespaceSchema,Pn as growthResourceWriteSchema,Ka as growthRuleContextSchema,ya as growthSavedGroupsSchema,Ia as growthSnapshotSchema,La as growthSplitResultSchema,Of as htmlVariableErrors,Uf as identifierSchema,jg as imageNodeSchema,bg as imagePositionSchema,$f as insetsSchema,Zi as invoiceCommandSchema,fd as invoiceDetailInputSchema,hd as invoiceDetailSchema,aj as invoiceOperationSchema,gd as invoiceProductItemSchema,me as invoiceRefundsSchema,Yi as invoiceTemplateCommandSchema,Xi as invoiceTemplatePageSchema,Vi as invoiceTemplateValuesSchema,pb as isInvoiceCreditPrice,wf as isProductGroup,yn as isRecurringMembership,Qg as isRtlLocale,Bc as isStableSdkProtocol,na as isURLTargeted,nb as itemBillingCycleSchema,xj as jsonStorageBytes,ta as jsonValueSchema,E as licenseOfferSchema,Ib as listBillingInvoicesInputSchema,Qa as localeLabel,Ma as localeSchema,Ig as localeStatuses,Ng as localizeScreen,zb as manageBillingLimitsInputSchema,yb as manageOveragePolicyInputSchema,$i as managedInvoiceDetailSchema,bj as managedInvoicePageSchema,_i as managedInvoiceSchema,Wi as managedInvoiceTemplateSchema,hc as managementErrorCodeSchema,sc as managementErrorResponseSchema,ag as marginSchema,Oa as matchLocale,jk as matchesGrowthCondition,T as membershipActionSchema,An as membershipBillingCount,U as membershipChangeSchema,V as membershipHoldingSchema,R as membershipRulesSchema,W as membershipStateSchema,S as membershipTimingSchema,Rm as mergeAuditSchema,_ as metadataSchema,h as meteredConfigSchema,x as minorToAmount,e as modelMarkupsSchema,rn as nativeCompletionSchema,Id as nativeCouponStoreOfferLinkWriteSchema,Jd as nativeCouponStoreOfferLinksSchema,Rc as nativeProductBindingSchema,Tc as nativeProductBindingWriteSchema,Sc as nativeProductBindingsPageSchema,qn as nativeProofSchema,Od as nativePurchaseInstructionSchema,sn as nativeReceiptCommandSchema,tn as nativeReceiptResponseSchema,Oe as nativeRestoreCommandSchema,Pe as nativeRestoreResultSchema,Md as nativeStoreOfferForProduct,Kd as nativeStoreOfferSelectionSchema,Ld as nativeStoreOfferSelectionsSchema,Nd as nativeStoreSelectionMatches,ee as nativeSubscriptionUpdatePreviewSchema,fe as nativeSubscriptionUpdateResultSchema,Cj as newBlankSurface,ab as newCouponInput,Gi as newEnvironmentAnalyticsConfig,Zl as newFunnelDocument,Aj as newScreenFromTemplate,Bj as newSurfaceFromTemplate,Tf as nodeIdSchema,Sm as objectAuditSchema,Ml as offerCopyUnscoped,ln as offerFlowInputSchema,mn as offerFlowResultSchema,fb as offerSchema,gb as offerUnavailableReasonSchema,ff as offeringAuthorSchema,kf as offeringCollectionSchema,ef as offeringDocumentSchema,af as offeringItemSchema,bf as offeringItemsSchema,Ye as offeringMetadataSchema,gf as offeringProductEvidenceSchema,Xe as offeringProductIdSchema,cf as offeringProductIds,of as offeringProductOptionSchema,df as offeringProductPaths,qf as offeringPublicationIssues,hf as offeringRecordSchema,nf as offeringSelectorSchema,rf as offeringValueSchema,jf as offeringVersionSchema,pf as offeringWorkspaceSchema,mf as offeringWriteResultSchema,lf as offeringWriteSchema,Uc as overageBehaviorSchema,Ab as overagePolicySchema,Kl as ownedFunnelScreenSchema,Jn as pageExperimentEventSchema,Kn as pageExperimentEventsRequestSchema,Ln as pageExperimentEventsResponseSchema,In as pageExperimentPayloadSchema,Hn as pageExperimentSchema,Zf as paintColorSchema,vo as parsePublicFunnel,pc as parseRetryAfter,qj as parseScreenRenderPath,xe as paymentSetupCommandSchema,ye as paymentSetupReadSchema,Ae as paymentSetupSchema,Ue as paywallCandidateSchema,Ug as paywallClientActionSchema,_g as paywallCollectionSchema,Vg as paywallDocumentDraftSchema,Wg as paywallDocumentSchema,Yg as paywallFlowIssues,bh as paywallLibrarySchema,Xg as paywallProductIssues,uf as paywallProductsSchema,Zg as paywallRecordSchema,We as paywallRequestSchema,dh as paywallResolutionSchema,ch as paywallResolveInputSchema,$g as paywallSummarySchema,ah as paywallWriteSchema,da as planConfigSchema,ea as planInputSchema,ca as planItemSchema,sg as planPickerNodeSchema,fa as planSchema,ha as planVersionSchema,Jc as popupSchema,dc as prepaidAllowanceAmount,r as prepaidPriceAmount,s as prepaidQuantityAmount,Nc as prepaidQuantitySchema,q as prepaidTierPricingSchema,rb as prepareBillingAuthorizationInputSchema,Cm as prepareCouponTemplate,oa as prepareSavedGroups,ub as preparedBillingAuthorizationSchema,Ag as presentationSchema,pg as priceNodeSchema,ba as priceSchema,Sb as productAllowanceSchema,Oc as productBindingSchema,Qc as productBindingWriteSchema,Pc as productBindingsPageSchema,bc as productCollectionSchema,Vb as productConfigurationSchema,Yb as productDefinitionSchema,cc as productEditorOptionsSchema,tf as productGroupingMatches,sf as productGroupingSchema,Ub as productLicenseSchema,Ij as productMigrationBlockReasonSchema,Pj as productMigrationDetailSchema,Jj as productMigrationErrorCodeSchema,Oj as productMigrationItemSchema,Mj as productMigrationItemStatusSchema,Qj as productMigrationListSchema,Kj as productMigrationPreviewSchema,Sj as productMigrationQuerySchema,Lj as productMigrationRunStatusSchema,Nj as productMigrationSchema,Rj as productMigrationWriteSchema,$b as productOptionsSchema,Rb as productPrepaidPriceSchema,Qb as productPricesSchema,ac as productRecordSchema,Sg as productSelectionSchema,Tb as productTrialSchema,Wb as productVariantOverridesSchema,Xb as productVariantSchema,cl as projectFunnelApiOutputs,mm as projectFunnelConfiguration,nm as projectFunnelLocalConfiguration,Bd as projectSettingsSchema,$a as promotionCodeInputSchema,Ac as protocolForSdkVersion,d as providerMarkupsSchema,ul as publicCouponScreenDataSchema,Pi as publicFeatureConfigurationSchema,Jg as publishChecks,Ge as purchaseListItemSchema,Me as purchaseListPageSchema,Wf as radiusSchema,tk as readFunnelValuePath,Nh as redeemRewardRequestSchema,Rh as referralCodeSchema,Th as referralProgramCollectionSchema,Gh as referralProgramInputSchema,Ih as referralProgramRecordSchema,Lh as referralProgramWriteSchema,Ri as remoteFeatureResultSchema,Bl as renameFunnelScreenVariable,Dg as replaceFirstPageRoot,$m as resolveCouponDisplay,Yk as resolveFunnelBundle,gl as resolveFunnelCapabilityInputs,Ek as resolveFunnelTaskInputs,uk as resolveFunnelValueBinding,vk as resolveFunnelValueBindings,Zb as resolveProductVariant,Mg as resolveScreenLocale,Fc as resolveSdkProtocol,fj as responseMetaSchema,wb as revokeBillingAuthorizationInputSchema,Vh as rewardActivityRedemptionSchema,Wh as rewardActivitySchema,Fh as rewardCodeInputSchema,Uh as rewardCodeSchema,Xh as rewardCodeWriteSchema,Sh as rewardCollectionSchema,Ch as rewardConfigurationSchema,Ah as rewardGrantExpirySchema,Bh as rewardGrantSchema,Eh as rewardInputSchema,Dh as rewardKeySchema,Jh as rewardOptionSchema,Ph as rewardProductCheckoutSchema,Hh as rewardRecordSchema,Mh as rewardRedemptionSchema,zh as rewardStatusSchema,yh as rewardTypeSchema,Kh as rewardWriteSchema,ra as runExperiment,Bn as sameMembershipBillingCycle,Zj as saveSurfaceTemplateSchema,Y as scopeSchema,wg as screenActionSchema,mk as screenAnswersSchema,lk as screenDataCursorSchema,Eg as screenDocumentSchema,Xf as screenImageSourceSchema,pk as screenInputBindingsSchema,vg as screenNodeSchema,nk as screenParametersSchema,Tg as screenPresentationSchema,xf as screenProductScopes,yf as screenProductSelections,pj as screenRenderPath,nj as screenRenderPathSchema,rj as screenRenderTags,oj as screenRenderUrlSchema,qk as screenRendererInputSchema,Rg as screenSelections,xg as screenStringsSchema,qo as sdkConfigurationManifestSchema,zc as sdkProtocolRegistry,Gc as sdkProtocolResponseHeaders,zd as seatCommandSchema,yd as seatReadSchema,Ad as seatsStateSchema,ol as selectFunnelCondition,vf as selectedPaywallProduct,Gf as selectedSurfaceValue,Lg as servableLocales,Lb as setBillingCouponsInputSchema,fg as shadowSchema,dg as shapeSchema,_f as sizeSchema,Vf as spaceSchema,ng as spacerNodeSchema,Z as stableKeySchema,tg as stackInteractionSchema,ug as stackNodeSchema,Ja as stickyAssignmentDocumentSchema,Xd as stripeAppendContextSchema,Wd as stripeCouponTermsSchema,Yd as stripePurchaseExecutionSchema,je as stripeRefundExecutionSchema,ze as stripeSetupExecutionSchema,be as stripeSubscriptionUpdateExecutionSchema,ce as stripeSubscriptionUpdatePreviewSchema,de as stripeSubscriptionUpdateResultSchema,ue as stripeTrialExecutionSchema,hg as styleSchema,Ud as subscriptionAttachCommandSchema,Zd as subscriptionAttachQuoteSchema,oe as subscriptionBatchCommandSchema,qe as subscriptionBatchGroupSchema,pe as subscriptionBatchReadSchema,re as subscriptionBatchSchema,$d as subscriptionCarryOptionsSchema,Ne as subscriptionConflictPageSchema,Ie as subscriptionConflictQuerySchema,Ke as subscriptionConflictRetryResultSchema,Je as subscriptionConflictRetrySchema,He as subscriptionConflictSchema,Kb as subscriptionCouponExecutionSchema,cj as subscriptionInvoiceModeSchema,Fe as subscriptionListItemSchema,Le as subscriptionListPageSchema,Vd as subscriptionOperationInputSchema,_d as subscriptionOperationSchema,ie as subscriptionRefundCommandSchema,ke as subscriptionRefundPreviewSchema,le as subscriptionRefundResultSchema,se as subscriptionTrialCommandSchema,we as subscriptionTrialPolicySchema,te as subscriptionTrialReadSchema,ve as subscriptionTrialResultSchema,ae as subscriptionUpdateCommandSchema,ge as subscriptionUpdatePreviewSchema,he as subscriptionUpdateResultSchema,Be as subscriptionVerificationInputSchema,Ce as subscriptionVerificationSchema,Qf as substituteHtmlVariables,Ff as substituteSurfaceVariables,Cf as surfaceDataSchema,yg as surfaceSchema,Yj as surfaceTemplateSchema,Bf as surfaceValueSchema,Df as surfaceVariableNames,Kg as templateChecks,vn as templateScreen,ig as textNodeSchema,gg as textStyleSchema,Yf as themeSchema,ma as toAttributeString,Ti as trackEventsRequestSchema,Ui as trackEventsResultSchema,pl as transitionFunnelGraph,Gg as translatableFields,P as trialPolicySchema,Q as trialRecordSchema,Ef as unknownSurfaceVariables,md as usageAlertNotificationDataSchema,nd as usageAllowanceNotificationDataSchema,uh as usageAnalyticsPageSchema,th as usageAnalyticsQuerySchema,xh as usageBatchPageSchema,wh as usageBatchReadSchema,vh as usageBatchSubmitSchema,hh as usageEntityCommandSchema,ih as usageEntitySchema,ld as usageLimitNotificationDataSchema,nl as validateFunnelGraph,gk as validateFunnelProjections,Dk as validateFunnelTaskData,Vl as validateScreenAnswers,Dc as validateSdkProtocolRegistry,ia as validitySchema,ej as verifiedPrincipalSchema,fo as visualChangeSchema,io as visualExperimentPayloadSchema,ho as visualExperimentSchema,eo as visualMutationSchema,ko as visualSelectedElementSchema,go as visualVariationSchema,Cg as walkDocument,Fg as walkScreen,Dd as workspaceSettingsSchema};
|
package/dist/visual.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as _,c as
|
|
1
|
+
import{b as _,c as q}from"./chunk-BIFEEVQO.js";import{a as $,b as j,c as P,d as G,e as K,f as N,g as H,i as Q}from"./chunk-N6UIDDAX.js";import"./chunk-S5TVMQRC.js";import"./chunk-OHDY27EI.js";import{f as L,i as O,k as d}from"./chunk-S2MSIA57.js";function re(e){let h=P(e.baseUrl);if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let x=e.fetch??globalThis.fetch.bind(globalThis),E=`${h}/api/v1/visual-experiments/${e.environmentId}`,V=$(e.deviceIdCookie??"indiana_did"),b=j(),c=null,o=!1,I=!1,g="",w={...e.attributes??{}},k,p,v=0,s=new Map,S=new Map,T=new Set,J=K({endpoint:`${E}/events`,fetch:x,log:e.log,label:"Visual exposure"}),y=J.flush,R,u;function m(){clearTimeout(R),u?.remove(),u=void 0}function C(t,i){let l=d(t,i);T.has(l)||e.trackExposures===!1||c?.trackExposures===!1||o||(T.add(l),J.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:V,...b?{sessionId:b}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:t.key,variationKey:i.key}))}function f(){if(!c||o)return;let t=new Set,i={onExperimentViewed:(n,a)=>{t.add(d(n,a))},url:location.href,attributes:{...Q(V,location),...w},savedGroups:L(c.savedGroups),log:e.log},l=new Set;for(let n of c.experiments){let a=n;try{let r=O(a,i);if(S.set(n.changeId,r),!r.inExperiment)continue;l.add(n.changeId);let A=JSON.stringify([r.key,r.value]),D=s.get(n.changeId);if(D?.signature===A){D.applied()&&t.has(d(a,r))&&C(a,r);continue}s.get(n.changeId)?.revert(),s.delete(n.changeId);let F=q(r.value,{allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{t.has(d(a,r))&&C(a,r)},onError:B=>e.log?.("Visual experiment stopped",{experiment:n.key,error:String(B)})});s.set(n.changeId,{signature:A,revert:F.revert,applied:()=>F.applied})}catch(r){e.log?.("Skipping visual experiment",{experiment:n.key,error:String(r)})}}for(let[n,a]of s)l.has(n)||(a.revert(),s.delete(n));m()}async function M(){let t=++v,i=await x(E,{cache:"no-cache",credentials:"omit"});if(!i.ok)throw new Error(`Visual experiments unavailable (${i.status})`);let l=_(await i.json());if(l.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");!o&&t===v&&(c=l)}let z=()=>{g!==location.href&&(g=location.href,f())},U=()=>{y()};return{async start(){if(I||o)return;I=!0;let t=N(h,e.environmentId);if(t){H();let i=await import("./visual-editor-agent-WW65CMKW.js");o||(p=i.startVisualEditorAgent(t,{allowJs:e.disableJsInjection===!1,nonce:e.nonce}));return}e.antiFlicker&&(u=document.createElement("style"),e.nonce&&(u.nonce=e.nonce),u.textContent="body { visibility: hidden !important }",document.head.append(u),R=setTimeout(m,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(await M(),o)return;k=G(z),addEventListener("pagehide",U),g=location.href,f()}finally{m()}},async refresh(){o||p||(await M(),f())},setAttributes(t){w={...t},p||f()},flush:y,getResults(){return new Map(S)},get generation(){return c?.generation??null},destroy(){o=!0,v++,k?.(),p?.(),removeEventListener("pagehide",U),m();for(let t of s.values())t.revert();s.clear(),y()}}}export{re as createVisualExperiments};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinkerlandai/indiana-sdk",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Framework-independent Indiana SDK for customer identity, entitlements, credits, offers and growth surfaces.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -54,6 +54,12 @@
|
|
|
54
54
|
"import": "./dist/visual.js"
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsup",
|
|
59
|
+
"prepack": "pnpm run build",
|
|
60
|
+
"typecheck": "tsc --noEmit",
|
|
61
|
+
"lint": "node ../../scripts/lint.mjs --workspace packages/sdk"
|
|
62
|
+
},
|
|
57
63
|
"dependencies": {
|
|
58
64
|
"@ai-sdk/provider": "4.0.26",
|
|
59
65
|
"@types/json-schema": "7.0.15",
|
|
@@ -63,12 +69,12 @@
|
|
|
63
69
|
"zod": "4.6.5"
|
|
64
70
|
},
|
|
65
71
|
"devDependencies": {
|
|
72
|
+
"@indiana/contracts": "workspace:*",
|
|
66
73
|
"@openrouter/sdk": "^1.4.25",
|
|
67
74
|
"@types/css-tree": "^3.2.0",
|
|
68
75
|
"ai": "7.0.136",
|
|
69
76
|
"tsup": "^8.5.1",
|
|
70
|
-
"typescript": "^5.9.3"
|
|
71
|
-
"@indiana/contracts": "0.1.0"
|
|
77
|
+
"typescript": "^5.9.3"
|
|
72
78
|
},
|
|
73
79
|
"peerDependencies": {
|
|
74
80
|
"@openrouter/sdk": "^1.4.25"
|
|
@@ -77,10 +83,5 @@
|
|
|
77
83
|
"@openrouter/sdk": {
|
|
78
84
|
"optional": true
|
|
79
85
|
}
|
|
80
|
-
},
|
|
81
|
-
"scripts": {
|
|
82
|
-
"build": "tsup",
|
|
83
|
-
"typecheck": "tsc --noEmit",
|
|
84
|
-
"lint": "node ../../scripts/lint.mjs --workspace packages/sdk"
|
|
85
86
|
}
|
|
86
|
-
}
|
|
87
|
+
}
|
package/dist/chunk-4JBIKJMU.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as V}from"./chunk-S5TVMQRC.js";import{c as L,f as A,i as T}from"./chunk-S2MSIA57.js";function C(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 D(){try{let e=sessionStorage.getItem("indiana_sid");return e||(e=crypto.randomUUID(),sessionStorage.setItem("indiana_sid",e)),e}catch{return}}function $(e=V){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 x=new Set,E;function _(e){if(x.add(e),!E){let t=history.pushState,i=history.replaceState,r=()=>{for(let s of x)s()},o=function(...s){t.apply(this,s),r()},c=function(...s){i.apply(this,s),r()};history.pushState=o,history.replaceState=c,addEventListener("popstate",r),addEventListener("hashchange",r),E=()=>{history.pushState===o&&(history.pushState=t),history.replaceState===c&&(history.replaceState=i),removeEventListener("popstate",r),removeEventListener("hashchange",r)}}return()=>{x.delete(e),x.size||(E?.(),E=void 0)}}var O="__indiana_visual_editor",l;function W(e,t){if(l&&l.origin===e&&l.environmentId===t&&l.expiresAt>Date.now())return l;try{let i=new URL(location.href).searchParams.get(O);if(!i||i.length>2048)return null;let r=JSON.parse(i);return r.origin!==e||r.environmentId!==t||!/^[a-f0-9-]{36}$/i.test(r.nonce)||r.expiresAt<=Date.now()||r.expiresAt>Date.now()+900*1e3?null:(l=r,r)}catch{return null}}function G(e,t){return!!W(e,t)}function Y(){let e=new URL(location.href);e.searchParams.delete(O),history.replaceState(history.state,"",e.href)}/*!
|
|
2
|
-
Portions ported from GrowthBook sdk-js @ ed29827 (GrowthBook.ts auto experiments, util.ts mergeQueryStrings,
|
|
3
|
-
plugins/auto-attributes.ts). Copyright (c) GrowthBook, Inc. MIT License.
|
|
4
|
-
*/function B(e,t){let i,r;try{i=new URL(e),r=new URL(t)}catch{return t}return i.searchParams.forEach((o,c)=>{r.searchParams.has(c)||r.searchParams.set(c,o)}),r.toString()}function K(e,t){let i=navigator.userAgent,r=new URLSearchParams(t.search),o={};for(let c of["source","medium","campaign","term","content"]){let s=r.get(`utm_${c}`);s!==null&&(o[`utm${c[0].toUpperCase()}${c.slice(1)}`]=s)}return{id:e,deviceId:e,url:t.href,path:t.pathname,host:t.host,query:t.search,pageTitle:typeof document>"u"?"":document.title,browser:/Edg/.test(i)?"edge":/Chrome/.test(i)?"chrome":/Firefox/.test(i)?"firefox":/Safari/.test(i)?"safari":"unknown",deviceType:/Mobi/.test(i)?"mobile":"desktop",...o}}function Q(e){let t=e;if(!(!!t&&typeof t=="object"&&typeof t.environmentId=="string"&&typeof t.trackExposures=="boolean"&&/^[a-f0-9]{64}$/.test(t.generation??"")&&Array.isArray(t.experiments)&&t.experiments.length<=100&&t.experiments.every(r=>!!r&&!["namespace","status","url","groups"].some(o=>Object.hasOwn(r,o))&&(r.hashVersion===void 0||r.hashVersion===2)&&typeof r.key=="string"&&Array.isArray(r.variations)&&r.variations.length>=2&&r.variations.every(o=>!!o&&typeof o.urlRedirect=="string")&&(r.urlPatterns===void 0||Array.isArray(r.urlPatterns)))&&!!t.savedGroups&&typeof t.savedGroups=="object"&&!Array.isArray(t.savedGroups)))throw new Error("Invalid page experiment payload");return t}function ie(e){if(e.configuration&&e.configuration.scope.environmentId!==e.environmentId)throw new Error("Page configuration belongs to another App environment");let t=$(e.baseUrl);if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("environmentId must be the App environment ID");let i=e.fetch??globalThis.fetch.bind(globalThis),r=`${t}/api/v1/page-experiments/${e.environmentId}`,o=C(e.deviceIdCookie??"indiana_did"),c=D(),s=null,R={...e.attributes??{}},f="",m=!1,I=new Map,P=[],h;function N(n){return n.length?i(`${r}/events`,{method:"POST",body:JSON.stringify({events:n}),headers:{"Content-Type":"text/plain"},keepalive:!0,credentials:"omit"}).then(()=>{}).catch(a=>e.log?.("Exposure not sent",{error:a})):Promise.resolve()}function v(){return clearTimeout(h),h=void 0,N(P.splice(0,20))}let d={trackedExperiments:new Set,log:e.log,onExperimentViewed:(n,a)=>{e.trackExposures===!1||s?.trackExposures===!1||(P.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:o,...c?{sessionId:c}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:n.key,variationKey:a.key}),h||(h=setTimeout(()=>{v()},1e3)))}},J=()=>{d.url=location.href,d.attributes={...K(o,location),...R}};function H(n){if(!e.disableCrossOriginUrlRedirects)return!1;try{let a=new URL(location.href);return n.variations.some(u=>{if(!u.urlRedirect)return!1;let y=new URL(u.urlRedirect);return y.protocol!==a.protocol||y.host!==a.host})}catch{return!0}}function j(n,a){let u=e.configuration?.snapshot?.generation;f=n;let y=e.navigate??(g=>location.replace(g)),z=e.navigateDelay??(e.navigate?0:100),F=e.maxNavigateDelay??1e3;Promise.all([Promise.race([a,new Promise(g=>setTimeout(g,F))]),new Promise(g=>setTimeout(g,z))]).then(()=>{!m&&(!e.configuration||e.configuration.fresh&&e.configuration.snapshot?.generation===u)&&y(n)})}function p(){if(!(!s||m||e.configuration&&!e.configuration.fresh||G(t,e.environmentId))){J();for(let n of s.experiments){if(H(n)){e.log?.("Auto experiment blocked",{id:n.key});continue}let a;try{a=T(n,d)}catch(u){e.log?.("Skipping page experiment",{id:n.key,error:String(u)});continue}if(I.set(n.key,a),!!a.inExperiment){if(a.value.urlRedirect){let u=n.persistQueryString?B(location.href,a.value.urlRedirect):a.value.urlRedirect;L(u,n.urlPatterns??[])?e.log?.("Skipping redirect because original URL matches redirect URL",{id:n.key}):u!==f&&j(u,v())}break}}}}let w="",q=()=>{location.href!==w&&(w=location.href,f="",p())},S,k;function M(){S??=_(q),addEventListener("pagehide",U)}let U=()=>{v()};async function b(){let n=e.configuration?null:await i(r,{cache:"no-cache",credentials:"omit"});if(n&&!n.ok)throw new Error(`Page experiments unavailable (${n.status})`);let a=Q(e.configuration?await e.configuration.pageExperiments():await n.json());if(a.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Page experiment payload scope changed");s?.trackExposures===!1&&a.trackExposures&&d.trackedExperiments?.clear(),s=a,d.savedGroups=A(a.savedGroups)}return{async start(){await b(),k??=e.configuration?.subscribe(()=>{!m&&e.configuration?.fresh&&b().then(p).catch(n=>e.log?.("Page configuration unavailable",{error:String(n)}))}),M(),w=location.href,p()},async refresh(){await b(),f="",p()},setAttributes(n){R={...n},p()},getResults(){return new Map(I)},get generation(){return s?.generation??null},destroy(){m=!0,k?.(),S?.(),removeEventListener("pagehide",U),v()}}}export{C as a,D as b,$ as c,_ as d,W as e,Y as f,B as g,K as h,Q as i,ie as j};
|