palbase 0.72.0 → 0.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +1 -1
  2. package/dist/ai/index.js +2 -2
  3. package/dist/ai-sdk/index.js +2 -2
  4. package/dist/backend/engine.js +2 -2
  5. package/dist/backend/env.js +1 -1
  6. package/dist/backend/index.js +11 -11
  7. package/dist/backend/stack.js +1 -1
  8. package/dist/backend/test.js +2 -2
  9. package/dist/chunks/2TKZTIMD.js +19 -0
  10. package/dist/chunks/{3MF6NROQ.js → 3KCV4F4F.js} +2 -2
  11. package/dist/chunks/{QDPRR5PE.js → 4E4ABCSD.js} +2 -2
  12. package/dist/chunks/{Y7ZJ3M5F.js → 5N5GHLUU.js} +2 -2
  13. package/dist/chunks/{JMNQRIEG.js → 5N6QKGPA.js} +2 -2
  14. package/dist/chunks/{7TZJLWWX.js → AXANFT2A.js} +2 -2
  15. package/dist/chunks/{E2MNCFOU.js → DNSLYLU6.js} +1 -1
  16. package/dist/chunks/{S3N7N6UD.js → GTKPHG5F.js} +2 -2
  17. package/dist/chunks/{OY2MT7N5.js → GWWU2FJ7.js} +2 -2
  18. package/dist/chunks/{LDFOUUBT.js → HRWVZ4PC.js} +2 -2
  19. package/dist/chunks/{I4SH2RTD.js → HYPCFC4K.js} +1 -1
  20. package/dist/chunks/{F4LE2YZX.js → IVJOWYRE.js} +2 -2
  21. package/dist/chunks/{DE7BWXBF.js → MB7MHOQO.js} +1 -1
  22. package/dist/chunks/{D5I74USX.js → MFSC4OJV.js} +2 -2
  23. package/dist/chunks/SEICTPQP.js +2 -0
  24. package/dist/chunks/{MVVULWTH.js → SQNAPFXW.js} +2 -2
  25. package/dist/chunks/SS2RVI27.js +95 -0
  26. package/dist/chunks/TR2IPX2A.js +23 -0
  27. package/dist/chunks/{JXIKBG4D.js → U3H6HER3.js} +1 -1
  28. package/dist/chunks/UOJVMV42.js +13 -0
  29. package/dist/chunks/UXHNXE3J.js +2 -0
  30. package/dist/chunks/{O6JNTYC5.js → VCL3SAQL.js} +2 -2
  31. package/dist/chunks/{WWXBXZUO.js → W2KD2I4Q.js} +1 -1
  32. package/dist/chunks/{QROXSSPQ.js → YU3GFTZV.js} +1 -1
  33. package/dist/cli.js +259 -259
  34. package/dist/cloud/index.js +2 -2
  35. package/dist/refuse/ai-sdk.js +1 -1
  36. package/dist/refuse/ai.js +1 -1
  37. package/dist/refuse/backend.js +1 -1
  38. package/dist/refuse/cloud.js +1 -1
  39. package/dist/refuse/server.js +1 -1
  40. package/dist/server/index.js +2 -2
  41. package/dist/server/testing.js +2 -2
  42. package/dist/web/index.js +2 -2
  43. package/dist/web/message.js +2 -2
  44. package/dist/web/palbe.js +2 -2
  45. package/dist/web/payments-ui.js +2 -2
  46. package/dist/web/paywall.js +2 -2
  47. package/dist/web/push-sw.js +1 -1
  48. package/dist/web/ssr.js +2 -2
  49. package/dist/web/vite.js +2 -2
  50. package/package.json +2 -2
  51. package/types/backend/src/index.d.ts +1 -1
  52. package/types/backend/src/services.d.ts +31 -0
  53. package/types/cloud/src/generated/project.d.ts +2 -1
  54. package/types/internal/src/modules/analytics.d.ts +58 -4
  55. package/types/internal/src/modules/campaigns.d.ts +616 -0
  56. package/types/internal/src/modules/events.d.ts +4 -3
  57. package/types/internal/src/modules/index.d.ts +1 -0
  58. package/types/internal/src/modules/journeys.d.ts +145 -0
  59. package/types/internal/src/modules/notify.d.ts +7 -6
  60. package/types/server/src/campaigns.d.ts +31 -0
  61. package/types/server/src/index.d.ts +1 -0
  62. package/types/server/src/server.d.ts +4 -0
  63. package/types/web/src/campaigns.d.ts +59 -0
  64. package/types/web/src/client.d.ts +3 -0
  65. package/types/web/src/inapp.d.ts +4 -0
  66. package/types/web/src/index.d.ts +1 -0
  67. package/types/web/src/screen/render.d.ts +6 -1
  68. package/types/web/src/screen/resolve.d.ts +10 -0
  69. package/dist/chunks/CYS75YV4.js +0 -2
  70. package/dist/chunks/JP55FW66.js +0 -13
  71. package/dist/chunks/MB6ITBD2.js +0 -95
  72. package/dist/chunks/UXU6RXU3.js +0 -23
  73. package/dist/chunks/XUYC354U.js +0 -2
  74. package/dist/chunks/ZHSM4NCV.js +0 -13
@@ -1,2 +0,0 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
2
- import{b as C}from"./DE7BWXBF.js";import{a as le}from"./JXIKBG4D.js";import{a as K,b as U,c as L,d as I,e as N,f as $,g as D,h as B,j as F,k as q,l as V,m as J,n as z,o as Y,p as G,q as X,r as Z}from"./XUYC354U.js";import{a as w,c as te,d as ne,e as re,f as oe,h as se,i as ie,j as R,k as ae,l as ce,o as A}from"./QROXSSPQ.js";import{a as Q,b as ee}from"./3MF6NROQ.js";import{b as x,d as v}from"./LDFOUUBT.js";var f=class extends Error{status=400;code;data;constructor(e,t,r={}){super(t),this.name="TransitRefusal",this.code=e,this.data=r}},Me=6e4,Oe=1e3;function M(n){return/^t[1-9][0-9]{0,5}$/.test(n)?Number(n.slice(1)):0}var k=class{keys=new Map;retired=new Set;order=[];project;timer;fetchedAt=0;heldFrom=0;fetching;opts;now;sleep;constructor(e){this.opts=e,this.now=e.now??Date.now,this.sleep=e.sleep??(t=>new Promise(r=>setTimeout(r,t)))}get loaded(){return this.project!==void 0}get projectId(){if(this.project===void 0)throw new Error("the project's transit keys are not loaded: await palbase.transit.load() at startup");return this.project}current(){return this.order[0]}async load(e){await this.refresh(e),this.timer===void 0&&(this.timer=setInterval(()=>{this.refresh().catch(()=>{})},Me),this.timer.unref?.())}close(){clearInterval(this.timer),this.timer=void 0}refresh(e){return this.fetching??=(async()=>{let t=this.now();try{let r=await this.opts.fetch(e),o=new Map;for(let s of r.keys){let i=ne(s.key);o.set(s.id,{privateKey:i,publicKey:this.keys.get(s.id)?.publicKey??await re(i)})}this.keys=o,this.order=r.keys.map(s=>s.id),this.retired=new Set(r.retired),this.project=r.project,this.fetchedAt=this.now(),this.heldFrom=t}finally{this.fetching=void 0}})(),this.fetching}newest(){return Math.max(0,...this.order.map(M),...[...this.retired].map(M))}async key(e){let t=this.now();for(;M(e)>this.newest()&&this.heldFrom<t;){let s=this.fetchedAt+Oe-this.now();if(s>0){await this.sleep(s);continue}await this.refresh()}let r=this.keys.get(e),o=this.current();if(this.retired.has(e))throw new f("encryption_key_retired",`the request is sealed to ${e}, retired: fetch the project's keys again`,{current:o});if(r===void 0)throw new f("encryption_key_unknown",`the request is sealed to ${e}, which the project has not made`,{current:o});return r}async request(e){if(e.header===void 0||e.header===null||e.header==="")throw new f("encryption_required",`this route carries encrypted fields: the request names its key in ${w}`,{field:w,current:this.current()});let t;try{t=se(e.header).kid}catch{throw new f("encryption_unopenable",`${w} is not one`,{field:w})}let r=await this.key(t),o;try{o=oe(this.projectId,e.method,e.path,e.params??[])}catch{throw new f("encryption_unopenable","the request's path holds a value no key is sealed for",{field:w})}try{return new E(t,await ie(e.header,r.privateKey,r.publicKey,o))}catch(s){throw s instanceof te?new f("encryption_unopenable","the request's key does not open: sealed for another project, route or path, or changed",{field:w}):s}}},E=class{kid;key;constructor(e,t){this.kid=e,this.key=t}async open(e,t,r){return A(e,t,r,async(o,s)=>{if(!ae(s))throw new f("encryption_required",`${o} is an encrypted field: it came plain`,{field:o});try{return await ce(this.key,o,s)}catch{throw new f("encryption_unopenable",`${o} does not open: changed, moved from another field, or another request's`,{field:o})}})}async seal(e,t){return A(e,"/response",t,(r,o)=>R(this.key,r,o))}sealField(e,t){return R(this.key,e,t)}};var He=/^pb_[a-z0-9]+_s/;function O(n){if(le())throw new TypeError("palbase/server runs on a server: its secret key never goes into a browser or a mobile app \u2014 apps use palbase/web (or the native SDKs) with the publishable key");if(typeof n.secretKey!="string"||!He.test(n.secretKey))throw new TypeError("secretKey is the project secret key (pb_<ref>_s\u2026); a publishable key belongs in palbase/web");let e=ee(v({baseUrl:n.url,credentials:{secretKey:n.secretKey},fetch:n.fetch,solveProofOfWork:n.solveProofOfWork??!1}),n.retry??Q),t=Y.client(e);return{ai:K.client(e),analytics:U.client(e),auth:L.client(e),cache:I.client(e),calls:N.client(e),fields:new C({fetch:async r=>(await t.getFieldKeys({signal:r})).data}),flags:D.client(e),iap:B.client(e),machines:F.client(e),messaging:q.client(e),notify:V.client(e),payments:J.client(e),commerce:$.client(e),realtime:z.client(e),secrets:t,storage:G.client(e),stores:X.client(e),workspaces:Z.client(e),transit:new k({fetch:async r=>(await t.getTransitKeys({signal:r})).data}),transport:e,url:new URL(n.url).origin}}var p=class extends Error{code;constructor(e,t){super(t),this.name="WebhookSignatureError",this.code=e}},je=300,Ke=/^[0-9]{1,12}$/,Ue=/^[0-9a-f]{64}$/,de=8,Le=/^whsec_[0-9A-Za-z]{32,}$/,Ie=1024*1024;async function ue(n){if(typeof n.secret!="string"||!Le.test(n.secret))throw new TypeError("secret is the webhook endpoint secret (whsec_\u2026), not an API key");await pe(n);let e;try{e=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(he(n.body)))}catch{throw new p("invalid_body","the signed body is not JSON")}if(!qe(e))throw new p("invalid_body","the signed body is not a Palbase event (id, type, project_id, created_at, data)");return e}async function pe(n){if(typeof n.secret!="string"||n.secret==="")throw new TypeError("secret is the key the request was signed with");let e=he(n.body),{t,v1:r}=ye(n),o=await crypto.subtle.importKey("raw",new TextEncoder().encode(n.secret),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),s=new Uint8Array(await crypto.subtle.sign("HMAC",o,Fe(new TextEncoder().encode(`${t}.`),e))),i=!1;for(let l of r)Be(s,De(l))&&(i=!0);if(!i)throw new p("signature_mismatch","no v1 in Palbase-Signature is this body signed with this secret")}function ye(n){let e=n.toleranceSeconds??je;if(!Number.isFinite(e)||e<0)throw new TypeError(`toleranceSeconds is a number of seconds, 0 or more (got ${String(n.toleranceSeconds)})`);let t=(n.now??Date.now)();if(!Number.isFinite(t))throw new TypeError(`now() returns epoch milliseconds (got ${String(t)})`);let r=n.signature;if(typeof r!="string"||r.trim()==="")throw new p("missing_signature","the request carries no Palbase-Signature header");let o,s=[];for(let i of r.split(",")){let l=i.indexOf("=");if(l<=0)throw new p("malformed_signature","Palbase-Signature is t=<seconds>,v1=<hex>");let c=i.slice(0,l).trim(),a=i.slice(l+1).trim();if(c==="t"){if(o!==void 0||!Ke.test(a))throw new p("malformed_signature","Palbase-Signature carries one t, in unix seconds");o=a}else if(c==="v1"){if(!Ue.test(a))throw new p("malformed_signature","a v1 is 64 lowercase hex characters");if(s.length===de)throw new p("malformed_signature",`Palbase-Signature carries at most ${de} v1`);s.push(a)}}if(o===void 0||s.length===0)throw new p("malformed_signature","Palbase-Signature is t=<seconds>,v1=<hex>");if(Math.abs(t/1e3-Number(o))>e)throw new p("stale_timestamp",`the signature's time is more than ${e} s from now: an old delivery sent again is not taken`);return{t:o,v1:s}}async function Ne(n,e,t={}){let r=await $e(n,t.maxBytes??Ie);return ue({toleranceSeconds:t.toleranceSeconds,now:t.now,secret:e,signature:n.headers.get("palbase-signature"),body:r})}async function $e(n,e){let t=()=>new p("body_too_large",`the body is larger than ${e} bytes`),r=Number(n.headers.get("content-length")??"NaN");if(Number.isFinite(r)&&r>e)throw t();if(!n.body)return new Uint8Array(0);let o=n.body.getReader(),s=[],i=0;for(;;){let{done:a,value:d}=await o.read();if(a)break;if(i+=d.byteLength,i>e)throw await o.cancel().catch(()=>{}),t();s.push(d)}let l=new Uint8Array(i),c=0;for(let a of s)l.set(a,c),c+=a.byteLength;return l}function he(n){if(typeof n=="string")return new TextEncoder().encode(n);if(n instanceof Uint8Array)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);throw new TypeError("body is the raw request body (string or bytes): a parsed object is not what was signed \u2014 read the body before any JSON middleware")}function De(n){let e=new Uint8Array(n.length/2);for(let t=0;t<e.length;t++)e[t]=parseInt(n.slice(t*2,t*2+2),16);return e}function Be(n,e){if(n.byteLength!==e.byteLength)return!1;let t=0;for(let r=0;r<n.byteLength;r++)t|=n[r]^e[r];return t===0}function Fe(n,e){let t=new Uint8Array(n.byteLength+e.byteLength);return t.set(n,0),t.set(e,n.byteLength),t}function qe(n){if(typeof n!="object"||n===null)return!1;let e=n;return typeof e.id=="string"&&typeof e.type=="string"&&typeof e.project_id=="string"&&typeof e.created_at=="string"&&"data"in e}var fe=60,Ve=60,Je=8*1024,ze=1e5;function H(n){let e=n instanceof Uint8Array?n:new Uint8Array(n),t="";for(let r of e)t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function we(n){let e=n.replace(/[\s=]+/g,"");if(!/^[A-Za-z0-9+/_-]*$/.test(e)||e.length%4===1)return;let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"=")),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function me(n){let e=we(n);if(e)try{let t=JSON.parse(new TextDecoder().decode(e));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}catch{return}}var _=class{byKey=new Map;held=0;sweptAt=Number.NEGATIVE_INFINITY;max;constructor(e=ze){this.max=e}spend(e,t){if(t>=e.until)throw new u("proof","the DPoP proof is not taken: it was checked too long ago");let r=this.byKey.get(e.jkt);if(r){this.forgetOld(e.jkt,r,t);let o=r.get(e.jti);if(o!==void 0&&o>t)throw new u("proof","the DPoP proof is not taken: it was used before");o!==void 0&&r.delete(e.jti)&&this.held--}this.held>=this.max&&this.makeRoom(t),r=this.byKey.get(e.jkt),r||(r=new Map,this.byKey.set(e.jkt,r)),r.set(e.jti,e.until),this.held++}forgetOld(e,t,r){for(let[o,s]of t){if(s>r)break;t.delete(o),this.held--}t.size===0&&this.byKey.delete(e)}makeRoom(e){if(e-this.sweptAt>=1e3){this.sweptAt=e;for(let[r,o]of this.byKey){for(let[s,i]of o)i>e||(o.delete(s),this.held--);o.size===0&&this.byKey.delete(r)}this.held=0;for(let r of this.byKey.values())this.held+=r.size}if(this.held<this.max)return;let t=[...this.byKey].sort((r,o)=>o[1].size-r[1].size);for(let[r,o]of t){if(this.held<=this.max*.9)break;this.byKey.delete(r),this.held-=o.size}}};async function Ye(n,e){let t=`{"crv":"P-256","kty":"EC","x":"${n}","y":"${e}"}`;return H(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t)))}function ge(n){try{let e=new URL(n);return e.username!==""||e.password!==""?void 0:`${e.protocol}//${e.host}${e.pathname}`}catch{return}}async function be(n,e,t,r){let o=Ce=>{throw new u("proof",`the DPoP proof is not taken: ${Ce}`)},s=t.proof;if(!s)return o("there is none (a DPoP-bound token comes with a DPoP header)");if(s.length>Je)return o("it is too long");let i=s.split(".");if(i.length!==3)return o("it is not a JWS of three parts");let l=me(i[0]),c=me(i[1]);if(!l||!c)return o("its header or claims are not base64url JSON");if(l.typ!=="dpop+jwt")return o("its typ is not dpop+jwt");if(l.alg!=="ES256")return o(`it is signed with ${String(l.alg)}; only ES256 is taken`);let a=l.jwk;if(!a||typeof a!="object"||a.kty!=="EC"||a.crv!=="P-256"||typeof a.x!="string"||typeof a.y!="string")return o("its header carries no P-256 public key");if("d"in a)return o("its header carries a private key");if(await Ye(a.x,a.y)!==e)return o("it is signed by a key the token does not name");let d;try{d=await crypto.subtle.importKey("jwk",{kty:"EC",crv:"P-256",x:a.x,y:a.y,ext:!0},{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])}catch{return o("its key is not a P-256 point")}let y=we(i[2]);if(!y||!await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},d,y,new TextEncoder().encode(`${i[0]}.${i[1]}`)).catch(()=>!1))return o("its signature does not verify");if(typeof c.htm!="string"||c.htm.toUpperCase()!==t.method.toUpperCase())return o(`it is for ${String(c.htm)}, not ${t.method}`);let h=typeof c.htu=="string"?ge(c.htu):void 0,m=ge(t.url);if(!h||!m||h!==m)return o(`it is for ${String(c.htu)}, not ${m??t.url}`);let S=r/1e3;if(typeof c.iat!="number"||Math.abs(c.iat-S)>fe)return o("it was not made within a minute of now");let Re=H(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n)));if(c.ath!==Re)return o("it is not for this token (ath)");if(typeof c.jti!="string"||c.jti===""||c.jti.length>256)return o("it has no jti (or one longer than 256)");let Ae=H(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(c.jti)));return{jkt:e,jti:Ae,until:(c.iat+fe+Ve)*1e3+1}}var u=class extends Error{reason;constructor(e,t){super(t),this.name="TokenError",this.reason=e}},b=class extends Error{constructor(e,t){super(e,t),this.name="AuthUnavailable"}},Ge=new Set(["invalid_api_key","missing_api_key","secret_key_in_browser"]);function Xe(n){return async e=>{let t=v({baseUrl:n.url,credentials:{secretKey:n.secretKey,accessToken:()=>e},fetch:n.fetch});try{return await t.send({op:"SessionStanding",method:"GET",path:"/auth/session/standing",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"}}),!0}catch(r){if(r instanceof x&&r.status===401&&!Ge.has(r.code))return!1;throw new b("a session's standing could not be told",{cause:r})}}}var W={ES256:{kty:"EC",import:{name:"ECDSA",namedCurve:"P-256"},verify:{name:"ECDSA",hash:"SHA-256"}},PS256:{kty:"RSA",import:{name:"RSA-PSS",hash:"SHA-256"},verify:{name:"RSA-PSS",saltLength:32}}},ke=60,Ze=16*1024,Qe=10*6e4,et=5e4,Se=n=>typeof n=="string"&&Object.hasOwn(W,n),j=class{issuer;projectId;fetchImpl;now;maxKeyAgeMs;refetchIntervalMs;fetchTimeoutMs;standing;standingTtlMs;standingStaleMs;standings=new Map;asking=new Map;keys=new Map;keysUntil=0;lastFetch=Number.NEGATIVE_INFINITY;lastFailure=void 0;inflight=null;seenProofs=new _;constructor(e){let t=new URL(e.issuer);if(t.origin!==e.issuer.replace(/\/$/,""))throw new TypeError(`issuer is the project's origin (https://<ref>.<domain>), not ${e.issuer}`);if(typeof e.projectId!="string"||e.projectId==="")throw new TypeError("projectId is the project id the tokens carry");if(this.issuer=t.origin,this.projectId=e.projectId,this.fetchImpl=e.fetch??globalThis.fetch,this.now=e.now??Date.now,this.maxKeyAgeMs=e.maxKeyAgeMs??60*6e4,this.refetchIntervalMs=e.refetchIntervalMs??3e4,this.fetchTimeoutMs=e.fetchTimeoutMs??5e3,typeof e.standing!="function")throw new TypeError("standing is how the verifier asks whether a token's session stands");this.standing=e.standing,this.standingTtlMs=e.standingTtlMs??1e3,this.standingStaleMs=e.standingStaleMs??15e3}async verify(e,t){if(typeof e!="string"||e.length===0||e.length>Ze)throw new u("malformed","the token is not a JWT");let r=e.split(".");if(r.length!==3)throw new u("malformed","the token is not a JWS of three parts");let o=ve(r[0]),s=ve(r[1]);if(!o||!s)throw new u("malformed","the token header or claims are not base64url JSON");let i=o.alg;if(!Se(i))throw new u("algorithm",`the token is signed with ${String(i)}; only ES256 and PS256 are taken`);let l=o.kid;if(typeof l!="string"||l==="")throw new u("malformed","the token header names no kid");let c=await this.key(l);if(!c)throw new u("unknown_key",`no key ${l} in the project's key set`);if(c.alg!==i)throw new u("algorithm",`key ${l} is ${c.alg}, the token says ${i}`);let a=_e(r[2]);if(!a)throw new u("malformed","the signature is not base64url");let d=new TextEncoder().encode(`${r[0]}.${r[1]}`);if(!await crypto.subtle.verify(W[c.alg].verify,c.key,a,d).catch(()=>!1))throw new u("signature","the signature does not verify");let g=this.check(s),h=s.cnf,m;if(h!==void 0){if(!t)throw new u("bound","the token is bound to a key (DPoP): it comes with the DPoP scheme and a proof, not as a Bearer");if(typeof h!="object"||h===null||typeof h.jkt!="string"||h.jkt==="")throw new u("bound","the token is bound to a key it does not name (cnf.jkt)");m=await be(e,h.jkt,t,this.now())}else if(t)throw new u("not_bound","the DPoP scheme came with a token bound to no key");if(!await this.stands(e,g.sessionId))throw new u("session_ended","the token's session has ended (signed out, revoked, or its user banned)");return m&&this.seenProofs.spend(m,this.now()),g}async verifyRequest(e){let t=e.headers instanceof Headers?e.headers:nt(e.headers),r=t.get("authorization")??"";if(r==="")return null;let o=/^(bearer|dpop)\s+(\S+)$/i.exec(r);if(!o)throw new u("malformed","the Authorization header is not a Bearer or DPoP token");let s=o[1].toLowerCase()==="dpop",i=new URL(e.url,`http://${t.get("host")??"localhost"}`);return this.verify(o[2],s?{proof:t.get("dpop"),method:e.method,url:Ee(t,i)}:void 0)}async stands(e,t){let r=this.now(),o=this.standings.get(t);if(o&&r<o.until)return o.live;let s=this.asking.get(t);s||(s=this.standing(e,t).finally(()=>this.asking.delete(t)),this.asking.set(t,s));let i;try{i=await s}catch(c){let a=this.standings.get(t),d=this.now();if(a&&d<a.at+this.standingStaleMs)return a.until=Math.min(d+this.standingTtlMs,a.at+this.standingStaleMs),a.live;throw new b("a session's standing cannot be read now",{cause:c})}let l=this.now();return this.standings.delete(t),this.standings.set(t,{live:i,at:l,until:l+this.standingTtlMs}),this.standings.size>et&&this.standings.delete(this.standings.keys().next().value),i}check(e){if(e.iss!==this.issuer)throw new u("issuer",`the token was issued by ${String(e.iss)}, not this project`);if(!(Array.isArray(e.aud)?e.aud:[e.aud]).includes(this.issuer))throw new u("audience","the token is not meant for this project");if(e.project_id!==this.projectId)throw new u("project","the token names another project");let r=this.now()/1e3;if(typeof e.exp!="number"||e.exp+ke<=r)throw new u("expired","the token has expired");if(e.nbf!==void 0&&(typeof e.nbf!="number"||e.nbf-ke>r))throw new u("not_yet_valid","the token is not valid yet");if(typeof e.sub!="string"||e.sub===""||typeof e.auth_time!="number")throw new u("not_a_user","the token is not a user's");if(typeof e.session_id!="string"||e.session_id==="")throw new u("not_a_session","the token is no session's");let o=e.custom_claims;if(o!==void 0&&(typeof o!="object"||o===null||o.type!==void 0))throw new u("not_a_session","the token is a custom one (an exchange or an approval), not a session's");return{id:e.sub,email:typeof e.email=="string"?e.email:null,emailVerified:e.email_verified===!0,role:typeof e.role=="string"?e.role:null,sessionId:typeof e.session_id=="string"?e.session_id:null,claims:Object.freeze({...e})}}async key(e){let t=this.now();if(t>=this.keysUntil){let o=this.keys.size>0&&t<this.keysUntil+Qe;if(this.lastFailure!==void 0&&t-this.lastFetch<this.refetchIntervalMs){if(!o)throw new b("the project's key set cannot be read now",{cause:this.lastFailure})}else try{await this.refresh()}catch(s){if(!o)throw s}}let r=this.keys.get(e);return!r&&t-this.lastFetch>=this.refetchIntervalMs&&(await this.refresh(),r=this.keys.get(e)),r}refresh(){if(this.inflight)return this.inflight;let e=this.load().finally(()=>{this.inflight=null});return this.inflight=e,e}async load(){this.lastFetch=this.now();let e,t;try{if(t=await this.fetchImpl(`${this.issuer}/.well-known/jwks.json`,{redirect:"error",headers:{accept:"application/json"},signal:AbortSignal.timeout(this.fetchTimeoutMs)}),!t.ok)throw new Error(`the project's key set answered ${t.status}`);e=await t.json()}catch(s){throw this.lastFailure=s,new b("the project's key set cannot be read now",{cause:s})}this.lastFailure=void 0;let r=new Map;for(let s of Array.isArray(e.keys)?e.keys:[]){let i=s.alg;if(typeof s.kid!="string"||!Se(i))continue;let l=W[i];if(s.kty!==l.kty||s.use!==void 0&&s.use!=="sig")continue;let{d:c,...a}=s;try{r.set(s.kid,{alg:i,key:await crypto.subtle.importKey("jwk",a,l.import,!1,["verify"])})}catch{}}this.keys=r;let o=rt(t.headers.get("cache-control"))??this.maxKeyAgeMs;this.keysUntil=this.now()+Math.min(Math.max(o,this.refetchIntervalMs),this.maxKeyAgeMs)}};function Ee(n,e){let t=n.get("x-forwarded-proto")?.split(",")[0]?.trim().toLowerCase(),r=t==="https"||t==="http"?t:e.protocol.slice(0,-1),o=n.get("host")??e.host;return tt.test(o)?`${r}://${o}${e.pathname}`:""}var tt=/^(?:[a-z0-9-]+(?:\.[a-z0-9-]+)*|\[[0-9a-f:.]+\])(?::[0-9]{1,5})?$/i;function nt(n){let e=new Headers;for(let[t,r]of Object.entries(n))if(r!==void 0)for(let o of Array.isArray(r)?r:[r])e.append(t,o);return e}function rt(n){let e=/(?:^|,)\s*max-age=(\d+)/i.exec(n??"");return e?Number(e[1])*1e3:void 0}function _e(n){if(!/^[A-Za-z0-9_-]*$/.test(n)||n.length%4===1)return null;let e=atob(n.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(n.length/4)*4,"=")),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function ve(n){let e=_e(n);if(!e)return null;try{let t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function ot(n,e,t=Date.now()){let r=Object.hasOwn(n.entitlements,e)?n.entitlements[e]:void 0;return r?.active?r.expires_at===null?!0:Date.parse(r.expires_at)>(typeof t=="number"?t:t.getTime()):!1}var T=class extends Error{receipt;constructor(e){super(`the reservation ${JSON.stringify(e.idempotency_key)} is ${e.status} already: its job is not run again (a new one is a new Idempotency-Key)`),this.name="ReservationSettled",this.receipt=e}};async function st(n,e,t,r){let{idempotencyKey:o,amount:s,ttlSeconds:i,metadata:l}=t;if(typeof o!="string"||o==="")throw new TypeError("idempotencyKey names the reservation for good: a retry with it is the same hold, never a second");let c={amount:s,...t.credits!==void 0?{credits:t.credits}:{limit:t.limit},...i!==void 0?{ttl_seconds:i}:{},...l!==void 0?{metadata:l}:{}},a=(await n.iap.holdSpend({path:{customer_id:e},headers:{"Idempotency-Key":o},body:c})).data;if(a.status!=="held")throw new T(a);let d={customer_id:a.customer,spend_id:a.id},y;try{y=await r(a)}catch(g){throw await n.iap.releaseSpend({path:d}).catch(()=>{}),g}return await n.iap.commitSpend({path:d}),y}var it=new Set(["provider_unavailable","authentication_required","three_ds_failed"]);function at(n){return n!==void 0&&it.has(n)}function ct(n,e){return{[Te]:!0,commitAmount:n,value:e}}var Te=Symbol("palbase.payments.settleWalletHold");function lt(n){return typeof n=="object"&&n!==null&&Te in n}var P=class extends Error{hold;constructor(e){super(`wallet hold ${JSON.stringify(e.id)} is already ${e.status}: the work is not run again (use a new Idempotency-Key for a new hold)`),this.name="WalletHoldSettled",this.hold=e}};async function dt(n,e,t){let{idempotencyKey:r,walletKey:o,amount:s,ttlSeconds:i,reference:l,metadata:c}=e;if(typeof r!="string"||r.trim()==="")throw new TypeError("idempotencyKey is required for withWalletHold so retries never reserve funds twice");if(!Number.isInteger(s)||s<=0)throw new TypeError("amount must be a positive integer in minor units");let a={wallet_key:o,amount:s,...e.customerId!==void 0?{customer_id:e.customerId}:{spend_token:e.spendToken},...i!==void 0?{ttl_seconds:i}:{},...l!==void 0?{reference:l}:{},...c!==void 0?{metadata:c}:{}},d=(await n.payments.createWalletHold({headers:{"Idempotency-Key":r},body:a})).data;if(d.status!=="held")throw new P(d);let y;try{y=await t(d)}catch(g){throw await n.payments.releaseWalletHold({path:{hold_id:d.id}}).catch(()=>{}),g}return lt(y)?(y.commitAmount<=0?await n.payments.releaseWalletHold({path:{hold_id:d.id}}):await n.payments.commitWalletHold({path:{hold_id:d.id},body:{amount:y.commitAmount}}),y.value):(await n.payments.commitWalletHold({path:{hold_id:d.id}}),y)}function ut(n){return n.type.startsWith("payments.")}function pt(n){return n.type.startsWith("commerce.")}function yt(n){return n.type.startsWith("promotions.")}var ht=300,ft=/^[0-9]{1,12}$/;function mt(n){return typeof n=="string"?new TextEncoder().encode(n):n instanceof ArrayBuffer?new Uint8Array(n):n}function gt(n){if(n.startsWith("whsec_")){let e=n.slice(6);try{let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}catch{}}return new TextEncoder().encode(n)}function wt(n,e){if(n.length!==e.length)return!1;let t=0;for(let r=0;r<n.length;r++)t|=n[r]^e[r];return t===0}function bt(n){try{let e=atob(n),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}catch{return null}}async function Pe(n){if(typeof n.secret!="string"||n.secret==="")throw new TypeError("secret is the commerce hook signing secret (whsec_\u2026)");let e=n.webhookId?.trim()??"",t=n.webhookTimestamp?.trim()??"",r=n.webhookSignature?.trim()??"";if(!e||!t||!r)throw new p("missing_signature","webhook-id, webhook-timestamp, and webhook-signature headers are required");if(!ft.test(t))throw new p("malformed_signature","webhook-timestamp must be unix seconds");let o=n.toleranceSeconds??ht,s=Math.floor((n.now?.()??Date.now())/1e3);if(Math.abs(s-Number(t))>o)throw new p("stale_timestamp",`webhook-timestamp ${t} is outside tolerance (${o}s)`);let i=mt(n.body),l=new TextEncoder().encode(`${e}.${t}.`),c=new Uint8Array(l.length+i.length);c.set(l,0),c.set(i,l.length);let a=gt(n.secret),d=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),y=await crypto.subtle.importKey("raw",d,{name:"HMAC",hash:"SHA-256"},!1,["sign"]),g=new Uint8Array(await crypto.subtle.sign("HMAC",y,c)),h=!1;for(let m of r.split(/\s+/)){if(!m.startsWith("v1,"))continue;let S=bt(m.slice(3));if(S&&wt(g,S)){h=!0;break}}if(!h)throw new p("signature_mismatch","no v1 signature in webhook-signature matches the payload")}function kt(n){return async e=>{let t=new Uint8Array(await e.arrayBuffer()),r=e.headers.get("webhook-id")??"";try{await Pe({secret:n.secret,webhookId:r,webhookTimestamp:e.headers.get("webhook-timestamp"),webhookSignature:e.headers.get("webhook-signature"),body:t,toleranceSeconds:n.toleranceSeconds,now:n.now})}catch(i){let l=i instanceof p?i.code:"signature_mismatch",c=i instanceof Error?i.message:"invalid hook signature";return new Response(JSON.stringify({error:l,error_description:c}),{status:401,headers:{"content-type":"application/json"}})}let o;try{o=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(t))}catch{return new Response(JSON.stringify({error:"invalid_body",error_description:"hook body is not valid JSON"}),{status:400,headers:{"content-type":"application/json"}})}let s=await n.handle({hookPoint:e.headers.get("x-palbase-hook-point")??"",webhookId:r,payload:o,request:e});return new Response(JSON.stringify(s),{status:200,headers:{"content-type":"application/json"}})}}async function*St(n){let e,t=new Set;do{let r=(await n(e)).data;yield r;let o=r.next_cursor??void 0;if(o!==void 0&&t.has(o))throw new Error(`the listing answered a cursor it had answered before (${o})`);o!==void 0&&t.add(o),e=o}while(e)}var vt=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/,Et=/^(PALBASE_|NODE_|BUN_|NPM_|LD_|DYLD_|GIT_|SSH_)|^(PATH|HOME|SHELL|USER|TMPDIR|TMP|TEMP|PWD|IFS|ENV|BASH_ENV|SSL_CERT_FILE|SSL_CERT_DIR|CURL_CA_BUNDLE|REQUESTS_CA_BUNDLE|NO_PROXY|ALL_PROXY|HTTP_PROXY|HTTPS_PROXY|PG\w*)$/i;function xe(n){return!vt.test(n)||Et.test(n)||/_PROXY$/i.test(n)}var _t=/^(PORT|PALBASE_(URL|PROJECT_ID|MACHINE|REPLICAS|SECRET_KEY|WEBHOOK_SECRET|PLATFORM_SECRET|CONTRACT_OUT|CONTRACT_ENTRY|WEB_ORIGINS|SECRETS|DB_[A-Z0-9_]+))$/;function Tt(n){return _t.test(n)}async function Pt(n={}){let e=n.env??process.env,t=e.PALBASE_SECRETS;if(t===void 0||t==="")return;if(t==="production")throw new TypeError("PALBASE_SECRETS=production: a production secret's value is never read back \u2014 only the machines that start with it are given it. Run here with PALBASE_SECRETS=development (palbase env:pull writes it), and set a value for this computer with palbase secrets:set NAME --dev");if(t!=="development")throw new TypeError(`PALBASE_SECRETS is development, not ${t}`);let r=n.url??e.PALBASE_URL??"",o=n.secretKey??e.PALBASE_SECRET_KEY??"";if(r===""||o==="")throw new TypeError("PALBASE_SECRETS reads the project's Secrets with PALBASE_URL and PALBASE_SECRET_KEY: give both (palbase env:pull writes them)");let s=O({url:new URL(r).origin,secretKey:o,fetch:n.fetch}),{data:i}=await s.secrets.getEnvironmentValues({path:{environment:t}}),l=[],c=[],a=[];for(let[d,y]of Object.entries(i.values)){if(xe(d)){a.push(d);continue}if(e[d]!==void 0&&e[d]!==""){c.push(d);continue}e[d]=y,l.push(d)}return{set:t,loaded:l.sort(),kept:c.sort(),refused:a.sort()}}export{f as a,k as b,E as c,O as d,p as e,ue as f,pe as g,ye as h,Ne as i,u as j,b as k,Xe as l,j as m,Ee as n,ot as o,T as p,st as q,at as r,ct as s,P as t,dt as u,ut as v,pt as w,yt as x,Pe as y,kt as z,St as A,xe as B,Tt as C,Pt as D};
@@ -1,13 +0,0 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
2
- import{p as R,t as k,u as H}from"./MB6ITBD2.js";var N=40,V=`
3
- :host{display:contents}
4
- .pm-modal,.pm-full{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;border:0;background:transparent;color:inherit;overflow:hidden;display:flex;flex-direction:column}
5
- .pm-modal::backdrop,.pm-full::backdrop{background:transparent}
6
- .pm-modal{align-items:center;justify-content:center;box-sizing:border-box;padding:max(16px,env(safe-area-inset-top,0px)) max(16px,env(safe-area-inset-right,0px)) max(16px,env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-left,0px))}
7
- .pm-full{padding:0}
8
- .pm-panel{display:flex;flex-direction:column;min-height:0;width:100%;max-height:100%;outline:none}
9
- .pm-full>.pm-panel{flex:1 1 auto;height:100%}
10
- .pm-banner{position:fixed;z-index:2147483000;left:50%;transform:translateX(-50%);width:min(640px,calc(100% - 16px - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)));display:flex;flex-direction:column;touch-action:none;outline:none}
11
- .pm-banner.top{top:calc(8px + env(safe-area-inset-top,0px))}
12
- .pm-banner.bottom{bottom:calc(8px + env(safe-area-inset-bottom,0px))}
13
- `;function I(r,y={},Y={}){let g=Y.root??globalThis.document?.body;if(!g)throw new Error("presentMessage needs a page");let l=g.ownerDocument,A=l.defaultView,t=R(r.definition,{locale:r.locale,appearance:r.appearance,platform:r.platform??"web",variables:r.variables??{}}).presentation;if(t.type==="card")throw new Error("a card is drawn in its inbox (renderMessage), not shown over the page");let m=l.createElement("div");m.setAttribute("data-palbase-message-layer","");let b=m.attachShadow({mode:"open"});H(l,b,V);let d=t.type==="banner",e=l.createElement(d?"div":"dialog"),f=d?e:l.createElement("div");d?(e.className=`pm-banner ${t.position}`,e.setAttribute("role","dialog"),e.setAttribute("aria-modal","false")):(e.className=t.type==="modal"?"pm-modal":"pm-full",t.type==="modal"&&(e.style.background=t.backdrop),f.className="pm-panel",e.append(f));let u=l.createElement("div");u.style.cssText="display:flex;flex-direction:column;min-height:0;flex:1 1 auto",f.append(u),b.append(e),g.append(m);let x=t.type!=="fullscreen"&&t.dismissible,h=()=>r.reduceMotion??A?.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,v=!1,w="button",M,D=new Promise(n=>M=n),E=[],L=k(u,r,{...y,onAction(n){w=n.type==="close"?"button":"action",y.onAction?.(n)},onClose:()=>p(w)}),T=u.querySelector("[data-palbase-message]")?.shadowRoot?.querySelector("h1,h2,h3,.pw-text")?.textContent?.trim();if(T&&e.setAttribute("aria-label",T),d){let n=t.auto_dismiss_seconds;if(n!==void 0){let o=n*1e3,a=Date.now(),c,s=0,i=()=>{a=Date.now(),c=setTimeout(()=>p("timeout"),o)},C=()=>{s++===0&&(clearTimeout(c),o-=Date.now()-a)},P=()=>{--s===0&&i()};e.addEventListener("pointerenter",C),e.addEventListener("pointerleave",P),e.addEventListener("focusin",C),e.addEventListener("focusout",P),i(),E.push(()=>clearTimeout(c))}if(x){let o=t.position==="top",a=null;e.addEventListener("pointerdown",s=>{a=s.clientY}),e.addEventListener("pointermove",s=>{if(a===null)return;let i=Math.max(0,o?a-s.clientY:s.clientY-a);e.style.transform=`translateX(-50%) translateY(${o?-i:i}px)`,e.style.opacity=String(Math.max(.3,1-i/120))});let c=s=>{if(a===null)return;let i=o?a-s.clientY:s.clientY-a;a=null,i>N?p("swipe"):(e.style.transform="",e.style.opacity="")};e.addEventListener("pointerup",c),e.addEventListener("pointercancel",c)}}else{let n=e;n.addEventListener("cancel",o=>{o.preventDefault(),x&&p("escape")}),t.type==="modal"&&n.addEventListener("click",o=>{o.target===n&&x&&p("outside")}),n.showModal()}S();function S(){if(h()||typeof e.animate!="function")return;let n=t.type==="banner"?t.position==="top"?-24:24:0,o=t.type==="modal"?[{opacity:0,transform:"scale(0.96)"},{opacity:1,transform:"none"}]:t.type==="banner"?[{opacity:0,transform:`translateX(-50%) translateY(${n}px)`},{opacity:1,transform:"translateX(-50%)"}]:[{opacity:0,transform:"translateY(24px)"},{opacity:1,transform:"none"}];(t.type==="banner"?e:f).animate(o,{duration:220,easing:"cubic-bezier(0.16, 1, 0.3, 1)"}),t.type==="modal"&&e.animate([{opacity:0},{opacity:1}],{duration:180,easing:"ease-out"})}function p(n){if(v)return;v=!0,E.forEach(a=>a());let o=()=>{d||e.close(),L.destroy(),m.remove()};h()||typeof e.animate!="function"?o():e.animate([{opacity:Number(e.style.opacity||1)},{opacity:0}],{duration:160,easing:"ease-in",fill:"forwards"}).finished.then(o,o),M(n),y.onClose?.(n)}return{view:L,closed:D,close:()=>p("app")}}export{I as a};
@@ -1,95 +0,0 @@
1
- /*! palbase 0.72.0 — Palbase SDK License (see LICENSE) */
2
- var Rt=d=>[...new Uint8Array(d)].map(t=>t.toString(16).padStart(2,"0")).join(""),At=d=>`pw-font-${d}`;function ne(d){return(typeof d=="string"?/^asset:([0-9a-f-]{36})$/.exec(d):null)?.[1]}async function an(d,t={}){let a={},l=t.fetch??((c,p)=>globalThis.fetch(c,p));return await Promise.all(d.map(async c=>{try{if(!/^https:\/\//.test(c.url))return;let p=await l(c.url,{signal:t.signal,credentials:"omit"});if(!p.ok)return;let g=await p.arrayBuffer();if(g.byteLength!==c.bytes&&c.bytes>0||Rt(await globalThis.crypto.subtle.digest("SHA-256",g))!==c.sha256.toLowerCase())return;let w=_t(c.kind,new Uint8Array(g));if(w===void 0)return;let y=await Et(c,g,w,t);y&&(a[c.id]=y)}catch{}})),a}var C=(d,t,a=0)=>d.length>=a+t.length&&t.every((l,c)=>d[a+c]===l),W=d=>[...d].map(t=>t.charCodeAt(0));function _t(d,t){switch(d){case"image":return C(t,[137,80,78,71,13,10,26,10])?"image/png":C(t,[255,216,255])?"image/jpeg":C(t,W("RIFF"))&&C(t,W("WEBP"),8)?"image/webp":void 0;case"video":return C(t,W("ftyp"),4)?C(t,W("qt "),8)?"video/quicktime":"video/mp4":C(t,[26,69,223,163])?"video/webm":void 0;case"font":return C(t,W("wOF2"))?"font/woff2":C(t,W("wOFF"))?"font/woff":C(t,W("OTTO"))?"font/otf":C(t,[0,1,0,0])||C(t,W("true"))?"font/ttf":void 0;case"html":return C(t,[80,75,3,4])||C(t,[80,75,5,6])?"application/zip":void 0;default:return}}async function Et(d,t,a,l){switch(d.kind){case"image":case"video":return{kind:d.kind,url:URL.createObjectURL(new Blob([t],{type:a}))};case"font":{let c=At(d.id),p=globalThis.FontFace,g=l.fonts??globalThis.document?.fonts;if(!p||!g)return;let h=new p(c,t,{display:"block"});return await h.load(),g.add(h),{kind:"font",url:"",family:c}}case"html":{let c=await Lt(new Uint8Array(t)),p=Ot(c);return p===void 0?void 0:{kind:"html",url:"",html:p}}}}async function Lt(d){let t=new DataView(d.buffer,d.byteOffset,d.byteLength),a=-1;for(let h=d.length-22;h>=Math.max(0,d.length-22-65535);h--)if(t.getUint32(h,!0)===101010256){a=h;break}if(a<0)throw new Error("not a zip");let l=t.getUint16(a+10,!0),c=t.getUint32(a+16,!0),p=new Map,g=0;for(let h=0;h<l;h++){if(t.getUint32(c,!0)!==33639248)throw new Error("a broken zip");let w=t.getUint16(c+10,!0),y=t.getUint32(c+20,!0),m=t.getUint32(c+24,!0),v=t.getUint16(c+28,!0),_=t.getUint16(c+30,!0),P=t.getUint16(c+32,!0),R=t.getUint32(c+42,!0),x=new TextDecoder().decode(d.subarray(c+46,c+46+v));if(c+=46+v+_+P,x.endsWith("/"))continue;if(x.startsWith("/")||x.split("/").includes(".."))throw new Error("a path leaving the zip");if(g+=m,p.size>=200||g>20971520)throw new Error("a zip too large");let T=R+30+t.getUint16(R+26,!0)+t.getUint16(R+28,!0),O=d.subarray(T,T+y);if(w===0)p.set(x,O);else if(w===8)p.set(x,await Pt(O));else throw new Error("a zip entry compressed another way")}return p}async function Pt(d){let t=new Response(new Uint8Array(d)).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(t).arrayBuffer())}var Tt={html:"text/html",css:"text/css",js:"text/javascript",mjs:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",woff2:"font/woff2",woff:"font/woff",ttf:"font/ttf",otf:"font/otf"};function qe(d,t){let a=Tt[d.split(".").pop()?.toLowerCase()??""]??"application/octet-stream",l="";for(let c=0;c<t.length;c+=32768)l+=String.fromCharCode(...t.subarray(c,c+32768));return`data:${a};base64,${btoa(l)}`}var $t="default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:";function Ot(d){let t=d.get("index.html");if(!t)return;let a=new TextDecoder().decode(t),l=y=>new TextDecoder().decode(d.get(y)),c=y=>{let m=y.replace(/^\.\//,"").split(/[?#]/)[0];return d.has(m)?m:void 0},p=y=>y.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(m,v,_)=>{let P=c(_);return P?`url("${qe(P,d.get(P))}")`:m}),g=globalThis.DOMParser;if(!g)return;let h=new g().parseFromString(a,"text/html");for(let y of[...h.querySelectorAll('link[rel~="stylesheet"][href]')]){let m=c(y.getAttribute("href")),v=h.createElement("style");v.textContent=m?p(l(m)):"",y.replaceWith(v)}for(let y of[...h.querySelectorAll("style")])y.textContent=p(y.textContent??"");for(let y of[...h.querySelectorAll("[src], [href], [poster]")])for(let m of["src","href","poster"]){let v=y.getAttribute(m);if(v===null)continue;let _=c(v);_?y.setAttribute(m,qe(_,d.get(_))):/^(https?:)?\/\//i.test(v)&&y.removeAttribute(m)}for(let y of[...h.querySelectorAll("[style]")])y.setAttribute("style",p(y.getAttribute("style")??""));let w=h.createElement("meta");return w.setAttribute("http-equiv","Content-Security-Policy"),w.setAttribute("content",$t),h.head.prepend(w),`<!doctype html>${h.documentElement.outerHTML}`}var K=(d,t,a)=>`M${d-a} ${t}a${a} ${a} 0 1 0 ${2*a} 0a${a} ${a} 0 1 0 ${-2*a} 0`,de={ad_free:["M3 7h18v10H3z","M4 4l16 16"],bell:["M6 16v-5a6 6 0 0 1 12 0v5l2 2H4z","M10 21a2 2 0 0 0 4 0"],bolt:["M13 2L4 14h7l-1 8 9-12h-7z"],book:["M5 4h11a3 3 0 0 1 3 3v13H8a3 3 0 0 1-3-3z","M5 17a3 3 0 0 1 3-3h11"],chart:["M3 20h18","M6 20v-8","M11 20V5","M16 20v-6","M21 20V9"],chat:["M4 5h16v11H9l-5 4z"],check:["M5 12l5 5 9-10"],check_circle:[K(12,12,9),"M8 12l3 3 5-6"],clock:[K(12,12,9),"M12 7v5l3 2"],cloud:["M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9a4.5 4.5 0 0 1-.5 9z"],crown:["M3 8l4 4 5-7 5 7 4-4-2 11H5z"],download:["M12 4v11","M7 10l5 5 5-5","M4 20h16"],gift:["M3 9h18v4H3z","M5 13v8h14v-8","M12 9v12","M12 9C10 5 6 5 6 7.5S12 9 12 9zm0 0c2-4 6-4 6-1.5S12 9 12 9z"],globe:[K(12,12,9),"M3 12h18","M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18z"],heart:["M12 20s-7-4.5-9-9a4.5 4.5 0 0 1 9-3 4.5 4.5 0 0 1 9 3c-2 4.5-9 9-9 9z"],infinity:["M7 9a3 3 0 1 0 0 6c3 0 7-6 10-6a3 3 0 1 1 0 6c-3 0-7-6-10-6z"],lock_open:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 7.5-2"],music:["M9 18V5l11-2v13",K(6,18,3),K(17,16,3)],people:[K(9,8,3.5),"M2 20a7 7 0 0 1 14 0","M16 4.5a3.5 3.5 0 0 1 0 7","M18 14a6 6 0 0 1 4 6"],person:[K(12,8,4),"M4 21a8 8 0 0 1 16 0"],photo:["M3 5h18v14H3z",K(8.5,9.5,1.5),"M3 17l5-5 4 4 3-3 6 6"],shield:["M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z"],sparkles:["M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z","M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z"],star:["M12 3l2.8 5.7 6.2.9-4.5 4.4 1 6.2L12 17.3l-5.5 2.9 1-6.2L3 9.6l6.2-.9z"],video:["M3 6h12v12H3z","M15 10l6-3v10l-6-3z"],arrow_right:["M4 12h15","M13 6l6 6-6 6"],calendar:["M4 6h16v15H4z","M4 10h16","M8 3v5","M16 3v5"],close:["M6 6l12 12","M18 6L6 18"],lock:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 8 0v4"],play:["M7 4l13 8-13 8z"],quote:["M5 17c3 0 4-2 4-5V7H4v5h3","M15 17c3 0 4-2 4-5V7h-5v5h3"],trophy:["M7 4h10v5a5 5 0 0 1-10 0z","M7 6H4v2a3 3 0 0 0 3 3","M17 6h3v2a3 3 0 0 1-3 3","M12 14v4","M8 21h8","M9 18h6v3H9z"]};var Be="http://www.w3.org/2000/svg";function pe(d,t,a){let l=d.createElementNS(Be,"svg");l.setAttribute("viewBox","0 0 24 24"),l.setAttribute("width",String(a)),l.setAttribute("height",String(a)),l.setAttribute("fill","none"),l.setAttribute("stroke","currentColor"),l.setAttribute("stroke-width","2"),l.setAttribute("stroke-linecap","round"),l.setAttribute("stroke-linejoin","round"),l.setAttribute("aria-hidden","true"),l.setAttribute("focusable","false");for(let c of t){let p=d.createElementNS(Be,"path");p.setAttribute("d",c),l.append(p)}return l}var dn=2,pn=2,f=(d,t=!1)=>({kind:"value",value:"plain",def:d,required:t}),j=d=>({kind:"value",value:"color",def:d}),We=d=>({kind:"value",value:"spacing",def:d}),zt=d=>({kind:"value",value:"radius",def:d}),X=(d=!1)=>({kind:"text",required:d}),Me=(d,t=!1)=>({kind:"list",item:d,required:t}),se=(d,t=!1)=>({kind:"object",item:d,required:t}),Ke=(d=!1)=>({kind:"component",required:d}),Re={kind:"components"},Ge={stack:{axis:f("vertical"),spacing:We(0),align:f("center"),distribution:f("start"),scroll:f(!1),children:Re},text:{text:X(),spans:Me("span"),font:f(),size:f(),weight:f(),line_height:f(),letter_spacing:f(),color:{kind:"value",value:"textColor",def:"text"},align:f("center"),max_lines:f(),uppercase:f(!1)},image:{src:f(void 0,!0),fit:f("fit"),aspect:f(),mask:se("mask"),overlay:{kind:"value",value:"textColor"},alt:X(),decorative:f(!1)},icon:{name:f(void 0,!0),color:j("accent"),size:f(24)},video:{src:f(void 0,!0),poster:f(),autoplay:f(!0),loop:f(!0),mute:f(!0),controls:f(!1),fit:f("fill"),aspect:f(),alt:X()},button:{action:se("action",!0),content:Ke(!0)},purchase_button:{content:Ke(!0),package:f()},package:{product:f(void 0,!0),plan:f(void 0,!0),selected:f(!1),offer:f(),children:Re},tabs:{},switch:{},carousel:{pages:Re,peek:f(0),spacing:f(8),loop:f(!1),auto_advance_ms:f(),indicator:se("indicator"),height:f("")},countdown:{},timeline:{items:Me("timeline_item",!0),line_color:j("accent"),line_width:f(2),icon_color:j("on_accent"),color:j("text"),spacing:f(16)},features:{items:Me("feature",!0),icon_color:j("accent"),color:j("text"),spacing:f(12)},spacer:{size:We()},divider:{color:j("muted"),thickness:f(1)},custom_html:{src:f(void 0,!0),height:f("",!0)}},Ht={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:f(""),height:f(""),max_width:f(),background:{kind:"fill"},border:se("border"),corners:{kind:"corners"},shadow:se("shadow"),opacity:f(1)},border:{width:f(),color:j("")},shadow:{color:j(""),radius:f(0),x:f(0),y:f(0)},linear:{type:f(""),angle:f(180),stops:f()},radial:{type:f(""),center_x:f(.5),center_y:f(.5),radius:f(.5),stops:f()},image_fill:{type:f(""),src:f(),fit:f("fill")},video_fill:{type:f(""),src:f(),poster:f(),loop:f(!0)},animation:{type:f(""),duration_ms:f(300),delay_ms:f(0),easing:f("ease_out")},action:{type:f(""),url:f(),sheet:f(),package:f()},mask:{shape:f(""),radius:zt(0),depth:f(16)},span:{text:X(!0),bold:f(!1),italic:f(!1),underline:f(!1),strikethrough:f(!1),color:j(""),link:f()},timeline_item:{icon:f(void 0,!0),title:X(!0),text:X(),color:j("")},feature:{icon:f(void 0,!0),text:X(!0)},indicator:{style:f("dots"),color:j("muted"),active_color:j("accent"),size:f(8),spacing:f(6)},typography:{font:f("system"),size:f(),weight:f(400),line_height:f(),letter_spacing:f(0),text_style:f("body")}},Xe=new Set(["package","purchase_button"]),Ct={action:{type:f(""),url:f(),link:f(),sheet:f(),placement:f(),name:f(),value:f(),offer:f(),dismiss:f(!0)},presentation:{type:f(""),position:f("bottom"),auto_dismiss_seconds:f(),dismissible:f(!0),backdrop:j("#00000080")}},jt={modal:["type","dismissible","backdrop"],fullscreen:["type"],banner:["type","position","auto_dismiss_seconds","dismissible"],card:["type"]},Ft={linear:"linear",radial:"radial",image:"image_fill",video:"video_fill"},Nt=["top","bottom","leading","trailing"],Dt=["top_leading","top_trailing","bottom_leading","bottom_trailing"],Jt=Object.keys(Ge),un=Jt.filter(d=>!Xe.has(d)),Ye=/\{\{\s*([^{}]*?)\s*\}\}/g,Q=(d,t)=>typeof d=="object"&&d!==null&&Object.hasOwn(d,t),M=d=>typeof d=="object"&&d!==null&&!Array.isArray(d)?d:{},I=d=>Array.isArray(d)?d:[],G=(d,t)=>d??t;function It(d){let t="";for(let a of new TextEncoder().encode(d)){let l=String.fromCharCode(a);t+=/^[A-Za-z0-9._~-]$/.test(l)?l:`%${a.toString(16).toUpperCase().padStart(2,"0")}`}return t}function Vt(d){let t=Math.floor(d/86400),a=Math.floor(d%86400/3600),l=Math.floor(d%3600/60),c=d%60,p=h=>String(h).padStart(2,"0");return{countdown:t>0?`${t}d ${p(a)}:${p(l)}:${p(c)}`:a>0?`${a}:${p(l)}:${p(c)}`:`${p(l)}:${p(c)}`,days:String(t),hours:p(a),minutes:p(l),seconds:p(c)}}function fn(d){let t=[],a=c=>{if(Array.isArray(c))return c.forEach(a);if(typeof c!="object"||c===null)return;let p=c;if(p.type==="package"&&typeof p.product=="string"&&typeof p.plan=="string"){let g=`${p.product}.${p.plan}`;t.includes(g)||t.push(g)}for(let g of Object.keys(p).sort())a(p[g])},l=d;for(let c of["header","root","footer"])a(l[c]);for(let c of Object.keys(M(l.sheets)).sort())a(M(M(l.sheets)[c]).root);return t}function Ut(d){let t=new Map,a=c=>{if(Array.isArray(c))return c.forEach(a);if(typeof c!="object"||c===null)return;let p=c;if(p.type==="package"&&typeof p.offer=="string"){let g=`${p.product}.${p.plan}`;t.has(g)||t.set(g,p.offer)}for(let g of Object.keys(p).sort())a(p[g])},l=d;for(let c of["header","root","footer","sheets"])a(l[c]);return t}function gn(d,t){return _e(d,t).tree}function _e(d,t){return new ue("paywall",d,t).resolve()}function hn(d,t){return Ee(d,t).tree}function Ee(d,t){let{variables:a,...l}=t;return new ue("message",d,{...l,packages:{"":{...a}}}).resolve()}var ue=class{kind;d;opts;lang;texts={};palette;typography={};radii;spacing;packages;offers;selected="";tab="";paths=new WeakMap;tabsShown={};switchesOn={};countdowns={};constructor(t,a,l){this.kind=t,this.d=a,this.opts=l,this.offers=Ut(a);let c={};for(let[y,m]of Object.entries(l.packages??{})){let v={...m};this.open(y)||(m.price!==void 0?v.offer_price=m.price:delete v.offer_price),c[y]=v}this.packages=c;let p=M(this.d.locales),g=String(this.d.default_locale??""),h=l.locale;Q(p,h)||(h=h.split("-")[0]??"",Q(p,h)||(h=g)),this.lang=h;for(let y of[g,h])for(let[m,v]of Object.entries(M(p[y])))typeof v=="string"&&(this.texts[m]=v);let w=M(this.d.theme);this.palette=M(M(w.colors)[l.appearance]);for(let[y,m]of Object.entries(M(w.typography))){let v={};for(let[_,P]of Object.entries(this.objectFields("typography"))){let R=G(M(m)[_],P.def);R!=null&&(v[_]=R)}this.typography[y]=v}this.radii=M(w.radii),this.spacing=M(w.spacing)}open(t){let a=this.offers.get(t);return a!==void 0&&(this.opts.offers??[]).includes(a)}fields(t){if(!(this.kind==="message"&&Xe.has(t)))return Ge[t]}objectFields(t){return(this.kind==="message"?Ct[t]:void 0)??Ht[t]??{}}resolve(){let[t,a]=this.initialState();this.tab=t,this.selected=this.kind==="paywall"?a:"";let l={theme:{colors:this.palette,typography:this.typography,radii:this.radii,spacing:this.spacing}};this.kind==="paywall"&&(l.selected=a);let c=this.d.presentation;if(typeof c=="object"&&c!==null){let g=this.item("presentation",M(c),void 0)??{},h=jt[String(M(c).type)]??[];for(let w of Object.keys(g))h.includes(w)||delete g[w];l.presentation=g}for(let g of["header","root","footer"]){let h=this.d[g];if(typeof h=="object"&&h!==null){let w=this.component(M(h),g,"",!1);w&&(l[g]=w)}}let p={};if(typeof this.d.sheets=="object"&&this.d.sheets!==null){let g={};for(let[h,w]of Object.entries(M(this.d.sheets))){let y=this.component(M(M(w).root),`sheets.${h}.root`,"",!1);y&&(g[h]=y);let m=this.text(M(w).title,this.packages[this.selected]);m!==null&&(p[h]=m)}l.sheets=g}return{tree:l,pathOf:g=>this.paths.get(g),tabs:this.tabsShown,switches:this.switchesOn,sheetTitles:p,countdowns:this.countdowns,language:this.lang}}switchOn(t,a){return this.opts.switches&&Object.hasOwn(this.opts.switches,a)?this.opts.switches[a]:this.opts.switch?this.opts.switch==="on":t.default===!0}tabShown(t,a){let c=I(t.tabs).map(M).map(g=>String(g.id)),p=this.opts.tabs?.[a];return p!==void 0&&c.includes(p)?p:this.opts.tab?this.opts.tab:typeof t.default=="string"&&t.default!==""?t.default:c[0]??""}initialState(){let t="",a="",l="",c="",p=(h,w)=>{if(Array.isArray(h)){h.forEach((m,v)=>p(m,`${w}[${v}]`));return}if(typeof h!="object"||h===null)return;let y=h;switch(y.type){case"package":{let m=`${y.product}.${y.plan}`;l===""&&(l=m),y.selected===!0&&a===""&&(a=m);break}case"switch":{let m=this.switchOn(y,w),v=m?y.on_package:y.off_package;typeof v=="string"&&c===""&&(c=v),p(m?y.on:y.off,`${w}.${m?"on":"off"}`);return}case"tabs":{let m=this.tabShown(y,w);t===""&&(t=m),I(y.tabs).forEach((v,_)=>{let P=M(v);P.id===m&&(typeof P.package=="string"&&c===""&&(c=P.package),p(P.content,`${w}.tabs[${_}].content`))});return}}for(let m of Object.keys(y).sort())m!=="sheets"&&p(y[m],w===""?m:`${w}.${m}`)};for(let h of["header","root","footer"])p(this.d[h],h);let g=this.opts.selected||c||a||l;return[t,g]}holds(t,a){let l=a||this.selected;for(let[c,p]of Object.entries(t))switch(c){case"selected_package":if(!I(p).includes(this.selected))return!1;break;case"intro_eligible":if((this.opts.eligible??[]).includes(l)!==p)return!1;break;case"offer_open":if(this.open(l)!==p)return!1;break;case"platform":if(!I(p).includes(this.opts.platform))return!1;break;case"locale":if(!I(p).includes(this.opts.locale)&&!I(p).includes(this.lang))return!1;break;case"appearance":if(p!==this.opts.appearance)return!1;break;case"tab":if(p!==this.tab)return!1;break}return!0}component(t,a,l,c){if(typeof t.visible=="object"&&t.visible!==null&&!this.holds(M(t.visible),l))return null;let p=String(t.type),g=l,h=c;p==="package"&&(g=`${t.product}.${t.plan}`,h=g===this.selected);let w={type:p};this.paths.set(w,a),Q(t,"id")&&(w.id=t.id);let y={...M(t.style)};h&&Object.assign(y,M(M(t.states).selected)),Object.keys(y).length>0&&(w.style=this.style(y)),typeof t.animation=="object"&&t.animation!==null&&(w.animation=this.defaults(M(t.animation),this.objectFields("animation")));let m=this.packages[g||this.selected];switch(p){case"tabs":return this.tabs(t,w,a,g);case"switch":return this.switchOf(t,w,a,g,h);case"countdown":return this.countdown(t,w,a,g,h);case"purchase_button":{let v=typeof t.package=="string"?t.package:this.selected;w.package=v,this.open(v)&&(w.offer=this.offers.get(v));let _=this.component(M(t.content),`${a}.content`,v,h);return _?(w.content=_,w):null}case"package":w.product=t.product,w.plan=t.plan,w.selected=h,typeof t.offer=="string"&&(this.opts.offers??[]).includes(t.offer)&&(w.offer=t.offer)}for(let[v,_]of Object.entries(this.fields(p)??{})){if(p==="package"&&(v==="product"||v==="plan"||v==="selected"||v==="offer"))continue;let P=t[v],R=Q(t,v);switch(_.kind){case"component":{if(!R)continue;let x=this.component(M(P),`${a}.${v}`,g,h);if(!x&&_.required)return null;x&&(w[v]=x);break}case"components":{let x=[];I(P).forEach((T,O)=>{let V=this.component(M(T),`${a}.${v}[${O}]`,g,h);V&&x.push(V)}),w[v]=x;break}case"text":{let x=this.text(P,m);if(x!==null)w[v]=x;else if(_.required||p==="text"&&v==="text"&&R)return null;break}case"list":{let x=[];for(let T of I(P)){let O=this.item(_.item,M(T),m);O&&x.push(O)}if(p==="text"&&x.length===0&&R)return null;R&&(w[v]=x);break}case"object":{if(R){let x=this.object(M(P),_.item,m);if(x===null&&_.required)return null;w[v]=x}else v==="indicator"&&(w[v]=this.object({},_.item,m));break}case"value":{let x=this.value(G(P,_.def),_);x!=null&&x!==""&&(w[v]=x);break}}}return p==="text"&&this.typeStyle(w),w}typeStyle(t){if(typeof t.size!="string"){t.size!==void 0&&t.size!==null&&(t.text_style="body");return}let a=this.typography[t.size];for(let l of["font","weight","line_height","letter_spacing","text_style"])!Q(t,l)&&a?.[l]!==void 0&&a?.[l]!==null&&(t[l]=a[l]);t.size=a?.size??null}tabs(t,a,l,c){let p=this.tabShown(t,l);this.tabsShown[l]=p;let g=[];return I(t.tabs).forEach((h,w)=>{let y=M(h),m=y.id===p,v=this.component(M(y.label),`${l}.tabs[${w}].label`,c,m);if(g.push({id:y.id,selected:m,label:v}),m){let _=this.component(M(y.content),`${l}.tabs[${w}].content`,c,!1);_&&(a.content=_)}}),a.tabs=g,typeof t.bar=="object"&&t.bar!==null&&(a.bar=this.style(M(t.bar))),a}switchOf(t,a,l,c,p){let g=this.switchOn(t,l);this.switchesOn[l]=g,a.on=g;let h=this.text(t.label,this.packages[c||this.selected]);h!==null&&(a.label=h),a.tint=this.color(String(G(t.tint,"accent")));let w=g?"on":"off",y=this.component(M(t[w]),`${l}.${w}`,c,p);return y&&(a.content=y),a}countdown(t,a,l,c,p){let g=M(t.target),h=this.opts.now??Date.now(),w;if(typeof g.after_open_seconds=="number"?w=Math.trunc(g.after_open_seconds)-(this.opts.openedSecondsAgo??0):w=Math.trunc((Date.parse(String(g.at))-h)/1e3),w>0){a.state="counting",a.remaining_seconds=w,this.countdowns[l]=w;let y=this.packages,m={};for(let[_,P]of Object.entries(y))m[_]={...P,...Vt(w)};this.packages=m;let v=this.component(M(t.counting),`${l}.counting`,c,p);return v&&(a.content=v),this.packages=y,a}if(a.state="ended",a.remaining_seconds=0,typeof t.ended=="object"&&t.ended!==null){let y=this.component(M(t.ended),`${l}.ended`,c,p);y&&(a.content=y)}return a}item(t,a,l){let c={};for(let[p,g]of Object.entries(this.objectFields(t))){let h=a[p];if(g.kind==="text"){let w=this.text(h,l);if(w!==null)c[p]=w;else if(g.required)return null}else{let w=g.def,y=this.value(G(h,w),g);y!=null&&(Q(a,p)||w!=null&&w!=="")&&(c[p]=y)}}return c}object(t,a,l){if(a==="style")return this.style(t);let c=this.item(a,t,l)??{};if(a==="action")for(let p of["url","link"]){if(typeof c[p]!="string")continue;let g=qt(c[p],l);if(g===null)return null;c[p]=g}return c}defaults(t,a){let l={};for(let[c,p]of Object.entries(a)){let g=G(t[c],p.def);g!=null&&g!==""&&(l[c]=g)}return l}style(t){let a={};for(let[l,c]of Object.entries(t)){let p=this.objectFields("style")[l];if(!p){a[l]=c;continue}switch(p.kind){case"edges":a[l]=this.sides(c,Nt,this.spacing);break;case"corners":a[l]=this.sides(c,Dt,this.radii);break;case"fill":a[l]=this.fill(c);break;case"object":{let g=M(c),h={};for(let[w,y]of Object.entries(this.objectFields(p.item))){let m=G(g[w],y.def);m!=null&&m!==""&&(h[w]=this.value(m,y))}a[l]=h;break}default:a[l]=c}}return a}sides(t,a,l){let c={};for(let p of a){let g=typeof t=="object"&&t!==null?G(M(t)[p],0):t;c[p]=Ae(g,l)}return c}fill(t){if(typeof t=="string")return{type:"color",color:this.color(t)};let a=M(t),l=this.defaults(a,this.objectFields(Ft[String(a.type)]??""));return Array.isArray(a.stops)&&(l.stops=a.stops.map(c=>({color:this.color(String(M(c).color)),at:M(c).at}))),l}value(t,a){if(a.kind!=="value")return t;switch(a.value){case"color":return typeof t=="string"&&t!==""?this.color(t):t;case"textColor":return typeof t=="string"?this.color(t):t==null?t:this.fill(t);case"spacing":return Ae(t,this.spacing);case"radius":return Ae(t,this.radii);default:return t}}color(t){let a=Object.hasOwn(this.palette,t)?this.palette[t]:void 0;return typeof a=="string"?a:t}text(t,a){let l;if(typeof t=="string")l=t;else if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let p=t.t;l=typeof p=="string"&&Object.hasOwn(this.texts,p)?this.texts[p]:""}else return null;let c=!1;return l=l.replace(Ye,(p,g)=>{let h=a&&Object.hasOwn(a,g)?a[g]:void 0;return typeof h!="string"||h===""?(c=!0,""):h}),c||l.trim()===""?null:l}};function qt(d,t){let a=!1,l=d.replace(Ye,(c,p)=>{let g=t&&Object.hasOwn(t,p)?t[p]:void 0;return typeof g!="string"||g===""?(a=!0,""):It(g)});return a?null:l}function Ae(d,t){return typeof d=="string"?Object.hasOwn(t,d)?t[d]:null:d}var Bt={packages:"Choose a plan",close:"Close",restore:"Restore purchases",page:(d,t)=>`${d} of ${t}`},ee={system:'-apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',rounded:'ui-rounded, "SF Pro Rounded", Nunito, "Varela Round", system-ui, -apple-system, sans-serif',serif:'ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif',mono:'ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace'},Wt=1.35,Ze=20,Kt=new Set(["button","purchase_button","package","text"]),Gt=new Set(["ar","he","fa","ur","ps","yi","dv","ug","ku","sd"]),Qe={ease_out:"cubic-bezier(0.16, 1, 0.3, 1)",ease_in_out:"cubic-bezier(0.65, 0, 0.35, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"},Xt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},Yt={start:"flex-start",center:"center",end:"flex-end",space_between:"space-between",space_around:"space-around",space_evenly:"space-evenly"},Zt={stack:["children"],package:["children"],button:["content"],purchase_button:["content"],tabs:["tabs","content"],switch:["content"],carousel:["pages"],countdown:["content"]},Qt={package:["selected"],purchase_button:["package"],switch:["on"],countdown:["state","remaining_seconds"]},en=`
3
- :host{display:block;height:100%}
4
- .pw2{position:relative;box-sizing:border-box;display:flex;flex-direction:column;height:100%;overflow:hidden;font-family:${ee.system};font-size:1rem;line-height:1.3;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;text-rendering:optimizeLegibility}
5
- .pw2 *,.pw2 *::before,.pw2 *::after{box-sizing:border-box}
6
- .pw2-head,.pw2-foot{flex:none;display:flex;flex-direction:column;position:relative;z-index:1}
7
- .pw2-head[hidden],.pw2-foot[hidden]{display:none}
8
- .pw2-foot{max-height:30%;overflow-y:auto;scrollbar-width:none}
9
- .pw2-foot .pw-text{font-size:min(var(--pw-fs,1rem),var(--pw-fs-max,21.6px))}
10
- .pw2.pw2-large{overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none}
11
- .pw2.pw2-large>.pw2-body{flex:1 0 auto;overflow:visible;min-height:auto}
12
- .pw2.pw2-large>.pw2-foot{position:sticky;bottom:0}
13
- .pw2:not(.pw2-fit){padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)}
14
- .pw2:not(.pw2-fit)>.pw2-head,.pw2:not(.pw2-fit)>.pw2-body.pw2-top{padding-top:env(safe-area-inset-top,0px)}
15
- .pw2:not(.pw2-fit)>.pw2-foot,.pw2:not(.pw2-fit)>.pw2-body.pw2-bottom{padding-bottom:env(safe-area-inset-bottom,0px)}
16
- .pw2.pw2-fit{height:auto;flex:0 1 auto;min-height:0}
17
- .pw2-body{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;display:flex;flex-direction:column;overscroll-behavior:contain;scrollbar-width:none}
18
- .pw2-body::-webkit-scrollbar{display:none}
19
- .pw2-body>.pw-c{flex:1 0 auto}
20
- /* A part as wide as its place \u2014 narrower when it says how wide it is at most, then in the middle, as SwiftUI's stacks place it. */
21
- .pw2-head>.pw-c,.pw2-body>.pw-c,.pw2-foot>.pw-c{align-self:center;width:100%}
22
- .pw-c{position:relative;min-width:0}
23
- .pw-c[style*="--pw-bw"]{isolation:isolate}
24
- .pw-c[style*="--pw-bw"]::after{content:"";position:absolute;inset:0;border:var(--pw-bw) solid var(--pw-bc);border-radius:inherit;pointer-events:none;z-index:2}
25
- .pw-stack{display:flex;flex-direction:column}
26
- .pw-stack.h{flex-direction:row}
27
- .pw-stack.z{display:grid}
28
- .pw-stack.z>.pw-c{grid-area:1/1}
29
- .pw-stack.scroll{overflow-y:auto;scrollbar-width:none}
30
- .pw-stack.h.scroll{overflow-x:auto;overflow-y:hidden}
31
- .pw-stack.scroll>.pw-c{flex-shrink:0}
32
- .pw-text{margin:0;overflow-wrap:break-word;white-space:pre-line}
33
- /* A text beside others wraps between its words, never inside one: a price stays whole, what is beside it wraps. */
34
- .pw-stack.h>.pw-text{min-width:min-content}
35
- .pw-text a{color:inherit}
36
- .pw-clamp{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}
37
- .pw-grad{-webkit-background-clip:text;background-clip:text;color:transparent!important;-webkit-text-fill-color:transparent}
38
- .pw-icon{display:inline-flex;flex:none}
39
- .pw-icon svg{display:block}
40
- .pw-img{overflow:hidden;flex:none}
41
- .pw-img img,.pw-img video{display:block;width:100%;height:100%}
42
- .pw-img.natural img{height:auto}
43
- .pw-overlay{position:absolute;inset:0;pointer-events:none}
44
- .pw-bgvideo{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:-1;pointer-events:none}
45
- button.pw-c{font:inherit;color:inherit;background:none;border:0;margin:0;padding:0;cursor:pointer;text-align:inherit;display:flex;flex-direction:column;align-items:stretch;justify-content:center;-webkit-tap-highlight-color:transparent;transition:opacity .15s ease,transform .15s ease}
46
- button.pw-c:active{transform:scale(.98)}
47
- button.pw-c:disabled{cursor:default;opacity:.5}
48
- .pw-pkg{cursor:pointer;display:flex;flex-direction:column;transition:background-color .2s ease,border-color .2s ease,box-shadow .2s ease}
49
- .pw-pkg[aria-disabled=true]{cursor:default;opacity:.55}
50
- :focus-visible{outline:2px solid currentColor;outline-offset:2px}
51
- .pw-features{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
52
- .pw-feature{display:flex;align-items:center;gap:12px;text-align:start}
53
- .pw-timeline{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
54
- .pw-step{display:grid;grid-template-columns:auto 1fr;column-gap:14px;position:relative;text-align:start}
55
- .pw-dot{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;position:relative;z-index:1}
56
- .pw-line{position:absolute;left:calc(16px - var(--pw-line-w)/2);top:32px;width:var(--pw-line-w);bottom:calc(-1 * var(--pw-gap))}
57
- .pw-step:last-child .pw-line{display:none}
58
- .pw-step-title{font-weight:600}
59
- .pw-step-text{opacity:.72;font-size:.9375rem;margin-top:2px}
60
- .pw-tabs{display:flex;flex-direction:column;gap:12px}
61
- .pw-tablist{display:flex}
62
- .pw-tab{flex:1 1 0;min-width:0;font:inherit;color:inherit;background:none;border:0;margin:0;padding:0;cursor:pointer;display:flex}
63
- .pw-tab>.pw-c{flex:1 1 auto}
64
- .pw-switch{display:flex;flex-direction:column;gap:12px}
65
- .pw-switchcontent{display:flex;flex-direction:column}
66
- .pw-switchrow{display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:start}
67
- .pw-toggle{flex:none;width:51px;height:31px;border-radius:999px;border:0;padding:2px;cursor:pointer;background:var(--pw-off);transition:background-color .2s ease}
68
- .pw-toggle[aria-checked=true]{background:var(--pw-tint)}
69
- .pw-toggle i{display:block;width:27px;height:27px;border-radius:50%;background:#fff;box-shadow:0 2px 4px #0003;transition:transform .2s ease}
70
- .pw-toggle[aria-checked=true] i{transform:translateX(20px)}
71
- .pw-carousel{display:flex;flex-direction:column;gap:12px;min-width:0}
72
- .pw-track{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none;scroll-behavior:smooth;padding-inline:var(--pw-peek);scroll-padding-inline:var(--pw-peek);gap:var(--pw-gap)}
73
- .pw-track::-webkit-scrollbar{display:none}
74
- .pw-track>.pw-c{flex:none;width:100%;scroll-snap-align:center}
75
- .pw-dots{display:flex;justify-content:center;gap:var(--pw-dot-gap)}
76
- .pw-dots button{border:0;padding:0;cursor:pointer;width:var(--pw-dot);height:var(--pw-dot);border-radius:999px;background:var(--pw-dot-c);transition:width .25s ease,background-color .25s ease}
77
- .pw-dots.bars button{width:calc(var(--pw-dot) * 3)}
78
- .pw-dots button[aria-current=true]{background:var(--pw-dot-on)}
79
- .pw-dots.dots button[aria-current=true]{width:calc(var(--pw-dot) * 2.5)}
80
- .pw-html{display:block;width:100%;border:0;pointer-events:none;background:transparent}
81
- .pw-spacer{flex:1 1 0}
82
- .pw-stack:not(.h):not(.z)>.greedy-h,.pw-pkg>.greedy-h,button.pw-c>.greedy-h{align-self:stretch}
83
- .pw-stack.h>.greedy-h{flex:1 1 0}
84
- .pw-stack.z>.greedy-h{justify-self:stretch}
85
- .pw-stack:not(.h):not(.z)>.greedy-v,.pw-pkg>.greedy-v{flex:1 1 auto}
86
- .pw-stack.h>.greedy-v,.pw-stack.z>.greedy-v{align-self:stretch}
87
- .pw-layer{position:absolute;inset:0;z-index:5;display:flex;flex-direction:column;justify-content:flex-end;background:#0007}
88
- .pw-sheet{max-height:92%;overflow-y:auto;border-radius:16px 16px 0 0;display:flex;flex-direction:column;outline:none;padding-bottom:env(safe-area-inset-bottom,0px)}
89
- .pw-sheet>.pw-c{flex:1 0 auto}
90
- .pw-grab{width:36px;height:5px;border-radius:3px;background:currentColor;opacity:.25;margin:8px auto 0;flex:none}
91
- [data-pw-highlight]{outline:2px solid #2E7CF6!important;outline-offset:-1px}
92
- [data-pw-hover]:not([data-pw-highlight]){outline:1px dashed #2E7CF6aa!important;outline-offset:-1px}
93
- .pw-editing button,.pw-editing .pw-pkg,.pw-editing a{cursor:default}
94
- @media (prefers-reduced-motion:reduce){.pw2 *{transition:none!important;scroll-behavior:auto!important}}
95
- `,oe=d=>{if(typeof d!="string"||d.length>2048)return!1;try{let t=new URL(d);return t.protocol==="https:"&&t.hostname!==""&&t.username===""&&t.password===""}catch{return!1}},tn=d=>{if(typeof d!="string"||d.length>2048||/[\s\u0000-\u001f\u007f]/.test(d))return!1;if(oe(d))return!0;let t=/^([a-z][a-z0-9+.-]{1,31}):(.+)$/.exec(d)?.[1];if(!t||nn.has(t))return!1;try{let a=new URL(d);return a.username===""&&a.password===""}catch{return!1}},nn=new Set(["https","http","javascript","data","file","vbscript","about","blob","content","intent"]),sn=d=>`${String(d.product)}.${String(d.plan)}`,fe=d=>{let[t,a]=d.split(".");return{product:t??"",plan:a??""}},A=d=>`${Number(d)||0}px`,et=d=>`${d/16}rem`,on=0;function vn(d,t,a){return tt("paywall",d,t,a)}function kn(d,t,a){return tt("message",d,t,a)}function tt(d,t,a,l){let c=t.ownerDocument,p=c.defaultView,g=`pw${++on}`,h=c.createElement("div");h.setAttribute(d==="paywall"?"data-palbase-paywall":"data-palbase-message",""),h.style.display="block",h.style.height="100%";let w=h.attachShadow({mode:"open"});rn(c,w,en);let y=c.createElement("div");y.className="pw2";let m=c.createElement("div");m.className="pw2-head";let v=c.createElement("div");v.className="pw2-body";let _=c.createElement("div");_.className="pw2-foot";let P=c.createElement("div");y.append(m,v,_),w.append(y),t.replaceChildren(h);let R={...a},x={openedAt:Date.now(),...a.state},T,O=new Map,V=new Map,ie=!1,ge=null,he,Le=!1,Pe=c.defaultView?.ResizeObserver,Te=typeof Pe=="function"?new Pe(()=>{y.classList.toggle("pw2-large",ze()>=Ze),be()}):null;Te?.observe(y);let $e=()=>be();c.fonts?.addEventListener?.("loadingdone",$e);let Oe=null,ye=p?.matchMedia?.("(prefers-reduced-motion: reduce)"),te=()=>R.reduceMotion??ye?.matches??!1,F=()=>!!l.editor,re={...Bt,...l.labels},we=()=>T.tree.selected??"";function Y(){let e=x.now??Date.now(),i={locale:R.locale,appearance:R.appearance,platform:R.platform??"web",tabs:x.tabs??{},switches:x.switches??{},openedSecondsAgo:Math.max(0,Math.floor((e-(x.openedAt??e))/1e3)),now:e};T=d==="paywall"?_e(R.definition,{...i,packages:R.packages??{},eligible:R.eligible??[],offers:R.offers??[],...x.selected?{selected:x.selected}:{}}):Ee(R.definition,{...i,variables:R.variables??{}});let o=T.tree.theme.colors,n=T.tree.presentation?.type,s=d==="message"&&n!==void 0&&n!=="fullscreen";y.classList.toggle("pw2-fit",s),h.style.display=s?"flex":"block",h.style.flexDirection=s?"column":"",h.style.minHeight=s?"0":"",h.style.flex=s?"0 1 auto":"",h.style.height=s?"auto":"100%",y.style.background=s?"":o.background??"",y.style.color=o.text??"",y.classList.toggle("pw-editing",F()),y.classList.toggle("pw2-large",ze()>=Ze),y.lang=T.language,y.dir=Gt.has(T.language.split("-")[0]??"")?"rtl":"ltr",V=new Map,me(m,T.tree.header,"vertical"),me(v,T.tree.root,"vertical"),me(_,T.tree.footer,"vertical"),m.hidden=!T.tree.header,_.hidden=!T.tree.footer,v.classList.toggle("pw2-top",!T.tree.header),v.classList.toggle("pw2-bottom",!T.tree.footer),xt();for(let[r,u]of O)V.has(r)||u.cleanup.forEach(b=>b());O=V,ge&&Ie(ge);for(let r of O.values())r.type==="custom_html"&&Je(r.el);be(),clearTimeout(he),Le||=h.isConnected,x.now===void 0&&Object.keys(T.countdowns).length>0&&(he=setTimeout(()=>{Le&&!h.isConnected||Y()},1e3-Date.now()%1e3+5))}function ze(){let e=c.documentElement,i=e&&p?parseFloat(p.getComputedStyle(e).fontSize):NaN;return Number.isFinite(i)?i:16}function be(){let e=[];for(let o of O.values()){if(o.type!=="text")continue;let n=o.el,s=n.dataset.pwFit??n.style.fontSize;if(!s||(n.style.fontSize=s,delete n.dataset.pwFit,!/^\S+$/.test(n.textContent??"")))continue;let r=n.parentElement,u=r&&p?p.getComputedStyle(r):null,b=r&&u?r.clientWidth-parseFloat(u.paddingLeft||"0")-parseFloat(u.paddingRight||"0"):1/0,k=Math.min(n.clientWidth,b);e.push({e:n,base:s,k:k<=0||n.scrollWidth<=k+.5?1:Math.max(.6,k/n.scrollWidth)})}let i=o=>o.closest(".pw-stack.h");for(let o of e){let n=Math.min(o.k,...e.filter(s=>s!==o&&s.base===o.base&&i(s.e)&&i(s.e)===i(o.e)).map(s=>s.k));n>=1||(o.e.dataset.pwFit=o.base,o.e.style.fontSize=`calc(${o.base} * ${n.toFixed(3)})`)}}function me(e,i,o){let n=i?U(i,o,{inControl:!1,inSheet:!1,inFooter:e===_}):null;q(e,n?[n]:[])}function U(e,i,o){let n=T.pathOf(e)??"",s=nt(e),r=O.get(n),u;if(r&&r.type===e.type&&r.key===s&&r.axis===i&&!V.has(n))u=r;else{let k=ot(e,n,i,o);if(!k)return null;u={el:k.el,type:e.type,key:s,styleKey:"",axis:i,slots:k.slots,cleanup:k.cleanup??[]},u.el.classList.add("pw-c"),u.el.dataset.pwPath=n,u.el.dataset.pwType=e.type,e.id&&(u.el.dataset.pwId=e.id),r&&r.cleanup.forEach(L=>L()),wt(u.el,e)}let b=`${JSON.stringify(e.style??null)}|${i}`;return u.styleKey!==b&&(He(u.el,e,i),u.styleKey=b),V.set(n,u),gt(u,e),ht(u,e,o),u.el}function nt(e){let i=new Set(["style",...Zt[e.type]??[],...Qt[e.type]??[]]),o={};for(let[n,s]of Object.entries(e))i.has(n)||(o[n]=s);return e.type==="tabs"&&(o.tabs=e.tabs.map(n=>n.id)),e.type==="carousel"&&(o.pages=e.pages.length),e.type==="stack"&&(o.greedy=e.children.some(n=>n.type==="spacer"&&typeof n.size!="number")),(e.type==="image"||e.type==="video"||e.type==="custom_html")&&(o.asset=st(e)),JSON.stringify(o)}function st(e){let i=ne(e.src);return i?(R.assets?.[i]?.url??R.assets?.[i]?.html?.length??"none").toString():""}function S(e,i){let o=c.createElement(e);return i&&(o.className=i),o}function ot(e,i,o,n){let s=e;switch(e.type){case"stack":{let r=S("div",`pw-stack${s.axis==="horizontal"?" h":s.axis==="z"?" z":""}${s.scroll?" scroll":""}`);return s.axis!=="z"&&s.children.some(u=>u.type==="spacer"&&typeof u.size!="number")&&r.classList.add(s.axis==="horizontal"?"greedy-h":"greedy-v"),r.style.gap=A(s.spacing),s.axis==="z"?r.style.placeItems=s.align==="stretch"?"stretch":String(s.align??"center"):(r.style.alignItems=Xt[String(s.align)]??"center",r.style.justifyContent=Yt[String(s.distribution)]??"flex-start"),{el:r,slots:{children:r}}}case"text":return{el:it(s,n),slots:{}};case"icon":{let r=de[String(s.name)];if(!r)return null;let u=S("span","pw-icon");return u.style.color=String(s.color??""),u.append(pe(c,r,Number(s.size)||24)),u.setAttribute("aria-hidden","true"),{el:u,slots:{}}}case"image":return at(s);case"video":return lt(s);case"features":{let r=S("ul","pw-features");r.style.gap=A(s.spacing);for(let u of s.items??[]){let b=S("li","pw-feature"),k=de[u.icon];if(k){let z=pe(c,k,22);z.style.color=String(s.icon_color),z.style.flex="none",b.append(z)}let L=S("span");L.textContent=u.text,L.style.color=String(s.color),b.append(L),r.append(b)}return{el:r,slots:{}}}case"timeline":{let r=S("ol","pw-timeline");r.style.gap=A(s.spacing),r.style.setProperty("--pw-gap",A(s.spacing)),r.style.setProperty("--pw-line-w",A(s.line_width));for(let u of s.items??[]){let b=S("li","pw-step"),k=S("span","pw-dot");k.style.background=u.color??String(s.line_color),k.style.color=String(s.icon_color);let L=de[u.icon];L&&k.append(pe(c,L,18)),k.setAttribute("aria-hidden","true");let z=S("span","pw-line");z.style.background=String(s.line_color),z.setAttribute("aria-hidden","true");let D=S("span");D.style.color=String(s.color);let B=S("span","pw-step-title");if(B.textContent=u.title,D.append(B),u.text){let $=S("span","pw-step-text");$.style.display="block",$.textContent=u.text,D.append($)}b.append(k,D,z),r.append(b)}return{el:r,slots:{}}}case"spacer":{let r=S("div","pw-spacer");return r.setAttribute("aria-hidden","true"),typeof s.size=="number"&&(r.style.flex="none",o==="horizontal"?r.style.width=A(s.size):r.style.height=A(s.size)),{el:r,slots:{}}}case"divider":{let r=S("div","pw-divider");return r.setAttribute("role","separator"),r.style.background=String(s.color),r.style.alignSelf="stretch",r.style.flex="none",o==="horizontal"?(r.setAttribute("aria-orientation","vertical"),r.style.width=A(s.thickness)):r.style.height=A(s.thickness),{el:r,slots:{}}}case"button":return ct(s,n,i);case"purchase_button":{let r=S("button","pw-buy");return r.type="button",r.addEventListener("click",()=>{Ne(r,()=>kt(r.dataset.package??"",r.dataset.offer))}),{el:r,slots:{content:r}}}case"package":{let r=S("div","pw-pkg");return r.setAttribute("role","radio"),r.addEventListener("click",()=>Se(r)),r.addEventListener("keydown",u=>bt(u,r)),{el:r,slots:{children:r}}}case"tabs":return pt(s,i);case"switch":return ut(s,i);case"carousel":return ft(s);case"countdown":{let r=S("div","pw-countdown");return r.setAttribute("role","timer"),r.setAttribute("aria-live","off"),{el:r,slots:{content:r}}}case"custom_html":{let r=R.assets?.[ne(s.src)??""];if(!r?.html)return null;let u=S("iframe","pw-html");return u.setAttribute("sandbox","allow-scripts"),u.setAttribute("aria-hidden","true"),u.setAttribute("title",""),u.tabIndex=-1,u.srcdoc=r.html,typeof s.height=="number"?u.style.height=A(s.height):typeof s.height=="string"&&s.height.endsWith("%")?u.style.height=s.height:s.height==="fill"&&(u.style.flex="1 1 0"),u.addEventListener("load",()=>Je(u)),{el:u,slots:{}}}default:return null}}function it(e,i){let o=String(e.text_style??"body"),n=i.inControl?"span":o==="large_title"?"h1":o==="title"||o==="title2"?"h2":o==="title3"?"h3":"p",s=S(n,"pw-text");i.inControl&&(s.style.display="block"),s.style.fontFamily=rt(e.font);let r=typeof e.size=="number"?e.size:16;if(i.inFooter?(s.style.setProperty("--pw-fs",et(r)),s.style.setProperty("--pw-fs-max",`${Number((r*Wt).toFixed(2))}px`)):s.style.fontSize=et(r),typeof e.weight=="number"&&(s.style.fontWeight=String(e.weight)),typeof e.line_height=="number"&&(s.style.lineHeight=String(e.line_height)),typeof e.letter_spacing=="number"&&e.letter_spacing!==0&&(s.style.letterSpacing=A(e.letter_spacing)),s.style.textAlign=String(e.align??"center"),e.uppercase===!0&&(s.style.textTransform="uppercase"),typeof e.max_lines=="number"&&(s.classList.add("pw-clamp"),s.style.setProperty("-webkit-line-clamp",String(e.max_lines))),typeof e.color=="string"?s.style.color=e.color:e.color&&typeof e.color=="object"&&(s.classList.add("pw-grad"),s.style.backgroundImage=ke(e.color)??""),Array.isArray(e.spans))for(let u of e.spans){let b=u.link==="terms"?R.links?.terms:u.link==="privacy"?R.links?.privacy:u.link,k=oe(b)&&!i.inControl,L=S(k?"a":"span");L.textContent=String(u.text),u.bold&&(L.style.fontWeight="700"),u.italic&&(L.style.fontStyle="italic");let z=[u.underline?"underline":"",u.strikethrough?"line-through":""].filter(Boolean).join(" ");z&&(L.style.textDecoration=z),typeof u.color=="string"&&u.color!==""&&(L.style.color=u.color),k&&oe(b)&&(L.href=b,L.target="_blank",L.rel="noopener noreferrer",L.addEventListener("click",D=>{F()||!l.onLink||(D.preventDefault(),l.onLink(b))})),s.append(L)}else s.textContent=String(e.text??"");return s}function rt(e){if(typeof e!="string")return ee.system;let i=ne(e);if(i){let o=R.assets?.[i]?.family;return o?`"${o}", ${ee.system}`:ee.system}return ee[e]??ee.system}function Z(e){let i=ne(e);return i?R.assets?.[i]?.url||void 0:oe(e)?e:void 0}function at(e){let i=S("div","pw-img");typeof e.aspect=="number"&&(i.style.aspectRatio=String(e.aspect));let o=Z(e.src),n=e.mask;if(n?.shape==="circle")i.style.borderRadius="50%";else if(n?.shape==="rect"&&n.radius)i.style.borderRadius=A(n.radius);else if(n?.shape==="convex")i.style.setProperty("border-end-start-radius",`50% ${A(n.depth)}`),i.style.setProperty("border-end-end-radius",`50% ${A(n.depth)}`);else if(n?.shape==="concave"){let s=`radial-gradient(ellipse 50% ${A(n.depth)} at 50% 100%, transparent 98%, #000 100%)`;i.style.setProperty("-webkit-mask-image",s),i.style.setProperty("mask-image",s)}if(o){let s=S("img");s.src=o,s.decoding="async",s.style.objectFit=e.fit==="fill"?"cover":"contain",e.decorative===!0?(s.alt="",i.setAttribute("aria-hidden","true")):s.alt=String(e.alt??""),s.addEventListener("error",()=>s.style.visibility="hidden"),i.append(s)}if(e.overlay&&typeof e.overlay=="object"){let s=S("div","pw-overlay");s.style.backgroundImage=ke(e.overlay)??"",i.append(s)}return{el:i,slots:{}}}function lt(e){let i=S("div","pw-img");typeof e.aspect=="number"&&(i.style.aspectRatio=String(e.aspect));let o=Z(e.src);if(o){let n=S("video");n.src=o;let s=Z(e.poster);s&&(n.poster=s),n.muted=e.mute!==!1,n.loop=e.loop!==!1,n.playsInline=!0,n.controls=e.controls===!0,n.preload="auto",n.style.objectFit=e.fit==="fit"?"contain":"cover",n.autoplay=e.autoplay!==!1&&!te()&&!F(),typeof e.alt=="string"?n.setAttribute("aria-label",e.alt):n.setAttribute("aria-hidden","true"),i.append(n)}return{el:i,slots:{}}}function ct(e,i,o){let n=e.action??{},s,r=n.type==="restore"||n.type==="offer_code"||n.type==="request_push"||n.type==="show_paywall"||n.type==="offer",u=d==="message"&&n.type!=="close"&&n.type!=="sheet"&&n.dismiss!==!1;switch(n.type){case"close":i.inSheet?s=()=>ce(null):l.onClose&&(s=()=>l.onClose());break;case"restore":l.onRestore&&(s=()=>l.onRestore());break;case"offer_code":l.onOfferCode&&(R.platform??"web")!=="web"&&(s=()=>l.onOfferCode());break;case"open_url":case"terms":case"privacy":{let k=n.type==="open_url"?n.url:n.type==="terms"?R.links?.terms:R.links?.privacy;oe(k)&&(s=()=>l.onLink?l.onLink(k):void p?.open(k,"_blank","noopener,noreferrer"));break}case"sheet":n.sheet&&(s=()=>ce(n.sheet));break;case"select_package":n.package&&(s=()=>xe(n.package));break;case"deep_link":{let k=n.link;tn(k)&&(s=()=>l.onDeepLink?l.onDeepLink(k):p?.location.assign(k));break}case"request_push":l.onRequestPush&&(s=()=>l.onRequestPush());break;case"show_paywall":n.placement&&l.onShowPaywall&&(s=()=>l.onShowPaywall(n.placement));break;case"custom":n.name&&l.onCustom&&(s=()=>l.onCustom(n.name,n.value));break;case"offer":n.offer&&l.onOffer&&(s=()=>l.onOffer(n.offer));break}if(!s&&!F())return null;let b=S("button");return b.type="button",n.type==="close"&&b.setAttribute("aria-label",re.close),b.addEventListener("click",()=>{if(!s||F())return;d==="message"&&l.onAction?.(dt(n,o,e.id));let k=u?()=>l.onClose?.():void 0;r?Ne(b,async()=>{await s(),k?.()}):(s(),k?.())}),{el:b,slots:{content:b}}}function dt(e,i,o){let n={type:e.type,dismiss:e.type==="sheet"?!1:e.type==="close"||e.dismiss!==!1,path:i};for(let s of["url","link","placement","name","value","sheet","offer"])typeof e[s]=="string"&&(n[s]=e[s]);return typeof o=="string"&&(n.id=o),n}function pt(e,i){let o=S("div","pw-tabs"),n=S("div","pw-tablist");n.setAttribute("role","tablist");let s=S("div","pw-tabpanel");s.setAttribute("role","tabpanel"),s.id=`${g}-${i}-panel`;let r={content:s},u=e.tabs.map(b=>b.id);return u.forEach((b,k)=>{let L=S("button","pw-tab");L.type="button",L.setAttribute("role","tab"),L.id=`${g}-${i}-tab-${k}`,L.setAttribute("aria-controls",s.id),L.dataset.tab=b,L.addEventListener("click",()=>je(i,b)),L.addEventListener("keydown",z=>{let D=z.key==="ArrowRight"?k+1:z.key==="ArrowLeft"?k-1:z.key==="Home"?0:z.key==="End"?u.length-1:-2;if(D===-2)return;z.preventDefault();let B=u[(D+u.length)%u.length];je(i,B),n.querySelector(`[data-tab="${B}"]`)?.focus()}),n.append(L),r[`label:${b}`]=L}),o.append(n,s),r.bar=n,{el:o,slots:r}}function ut(e,i){let o=S("div","pw-switch"),n=S("div","pw-switchrow"),s=S("span","pw-switchlabel");s.id=`${g}-${i}-label`;let r=S("button","pw-toggle");r.type="button",r.setAttribute("role","switch"),r.setAttribute("aria-labelledby",s.id),r.append(S("i")),r.addEventListener("click",()=>vt(i,r.getAttribute("aria-checked")!=="true")),n.append(s,r);let u=S("div","pw-switchcontent");return o.append(n,u),{el:o,slots:{content:u,label:s,toggle:r}}}function ft(e){let i=S("div","pw-carousel");i.setAttribute("role","region"),i.setAttribute("aria-roledescription","carousel");let o=S("div","pw-track");o.tabIndex=0,o.style.setProperty("--pw-peek",A(e.peek)),o.style.setProperty("--pw-gap",A(e.spacing)),typeof e.height=="number"&&(o.style.minHeight=A(e.height));let n=e.indicator??{},s=S("div",`pw-dots ${n.style??"dots"}`);s.style.setProperty("--pw-dot",A(n.size??8)),s.style.setProperty("--pw-dot-gap",A(n.spacing??6)),s.style.setProperty("--pw-dot-c",n.color??"#8888"),s.style.setProperty("--pw-dot-on",n.active_color??"currentColor"),n.style==="none"&&(s.hidden=!0),i.append(o,s);let r=()=>[...o.children].filter($=>$ instanceof(p?.HTMLElement??HTMLElement)),u=()=>{let $=r(),N=o.scrollLeft+o.clientWidth/2,H=0;return $.forEach((J,Mt)=>{Math.abs(J.offsetLeft+J.offsetWidth/2-N)<Math.abs(($[H]?.offsetLeft??0)+($[H]?.offsetWidth??0)/2-N)&&(H=Mt)}),H},b=$=>{let N=r();if(N.length===0)return;let H=e.loop?($+N.length)%N.length:Math.max(0,Math.min(N.length-1,$)),J=N[H];o.scrollTo?.({left:J.offsetLeft-(o.clientWidth-J.offsetWidth)/2,behavior:te()?"auto":"smooth"}),k(H)},k=$=>{[...s.children].forEach((N,H)=>N.setAttribute("aria-current",String(H===$)))};o.addEventListener("scroll",()=>k(u()),{passive:!0}),o.addEventListener("keydown",$=>{$.key!=="ArrowRight"&&$.key!=="ArrowLeft"||($.preventDefault(),b(u()+($.key==="ArrowRight"?1:-1)))});let L=!1,z=()=>L=!0,D=()=>L=!1;i.addEventListener("pointerenter",z),i.addEventListener("pointerleave",D),i.addEventListener("focusin",z),i.addEventListener("focusout",D);let B=[];if(typeof e.auto_advance_ms=="number"){let $=setInterval(()=>{if(L||te()||F())return;let N=r(),H=u();!e.loop&&H>=N.length-1||b(H+1)},e.auto_advance_ms);B.push(()=>clearInterval($))}return i.pwDots=$=>{s.children.length!==$&&(s.replaceChildren(...Array.from({length:$},(N,H)=>{let J=S("button");return J.type="button",J.setAttribute("aria-label",re.page(H+1,$)),J.addEventListener("click",()=>b(H)),J})),k(u()))},{el:i,slots:{pages:o},cleanup:B}}function gt(e,i){let o=i;switch(i.type){case"package":{let n=sn(o),r=!!R.packages?.[n]?.price;e.el.dataset.package=n,e.el.setAttribute("aria-checked",String(o.selected===!0)),e.el.setAttribute("aria-disabled",String(!r));break}case"purchase_button":{let n=String(o.package);e.el.dataset.package=n,typeof o.offer=="string"?e.el.dataset.offer=o.offer:delete e.el.dataset.offer,e.el.disabled=ie||!R.packages?.[n]?.price;break}case"switch":{let n=e.slots.toggle;n.setAttribute("aria-checked",String(o.on===!0)),n.style.setProperty("--pw-tint",String(o.tint??"")),n.style.setProperty("--pw-off",`color-mix(in srgb, ${T.tree.theme.colors.muted??"#888888"} 45%, transparent)`),e.slots.label.textContent=String(o.label??""),e.slots.label.hidden=o.label===void 0;break}case"tabs":{for(let n of o.tabs){let s=e.slots[`label:${n.id}`];s.setAttribute("aria-selected",String(n.selected)),s.tabIndex=n.selected?0:-1,n.selected&&e.slots.content.setAttribute("aria-labelledby",s.id)}o.bar&&He(e.slots.bar,{type:"stack",style:o.bar},"vertical");break}}}function ht(e,i,o){let n=i,s={...o,inControl:o.inControl||i.type==="button"||i.type==="purchase_button"||i.type==="package"};switch(i.type){case"stack":case"package":{let r=i.type==="stack"?String(n.axis??"vertical"):"vertical",u=n.children.map(k=>[k,U(k,r,s)]).filter(k=>k[1]!==null),b=u.map(k=>k[1]);q(e.slots.children,b),yt(r,u),i.type==="stack"&&ae(e.el,b);break}case"button":case"purchase_button":{let r=n.content?U(n.content,"vertical",s):null;q(e.slots.content,r?[r]:[]);break}case"countdown":case"switch":{let r=n.content?U(n.content,"vertical",s):null;q(e.slots.content,r?[r]:[]),ae(e.slots.content,r?[r]:[]);break}case"tabs":{for(let u of n.tabs){let b=u.label?U(u.label,"vertical",{...s,inControl:!0}):null;q(e.slots[`label:${u.id}`],b?[b]:[])}let r=n.content?U(n.content,"vertical",s):null;q(e.slots.content,r?[r]:[]),ae(e.slots.content,r?[r]:[]);break}case"carousel":{let r=n.pages.map(u=>U(u,"page",s)).filter(Boolean);r.forEach((u,b)=>{u.setAttribute("role","group"),u.setAttribute("aria-roledescription","slide"),u.setAttribute("aria-label",re.page(b+1,r.length))}),q(e.slots.pages,r),ae(e.slots.pages,r),e.el.pwDots?.(r.length);break}}}function yt(e,i){let o=e==="horizontal"?"width":e==="vertical"?"height":null;if(!o)return;let n=u=>u?o==="width"?u.leading+u.trailing:u.top+u.bottom:0,s=i.filter(([u])=>u.style?.[o]==="fill"),r=Math.max(0,...s.map(([u])=>n(u.style?.padding)+n(u.style?.margin)));for(let[u,b]of s)b.style.flexBasis=A(r-n(u.style?.margin))}function ae(e,i){let o=i.filter(s=>s.dataset.pwType==="package");if(o.length===0){e.getAttribute("role")==="radiogroup"&&e.removeAttribute("role");return}e.setAttribute("role","radiogroup"),e.setAttribute("aria-label",re.packages);let n=o.find(s=>s.getAttribute("aria-checked")==="true")??o[0];for(let s of o)s.tabIndex=s===n?0:-1}function q(e,i){let o=()=>[...e.children].filter(s=>s.dataset?.pwPath!==void 0),n=o();for(let s of n)i.includes(s)||s.remove();n=o(),i.forEach((s,r)=>{n[r]!==s&&(e.insertBefore(s,n[r]??null),n=o())})}let ve=new WeakMap;function E(e,i,o){e.style.setProperty(i,o),ve.get(e).push(i)}function He(e,i,o){for(let u of ve.get(e)??[])e.style.removeProperty(u);ve.set(e,[]);for(let u of[...e.children])u.classList.contains("pw-bgvideo")&&u.remove();let n=i.style;if(i.type==="image"&&e.classList.toggle("natural",typeof i.aspect!="number"&&(n?.height===void 0||n.height==="fit")),!n)return;let s=(u,b)=>{b&&(E(e,`${u}-block-start`,A(b.top)),E(e,`${u}-block-end`,A(b.bottom)),E(e,`${u}-inline-start`,A(b.leading)),E(e,`${u}-inline-end`,A(b.trailing)))};s("padding",n.padding),s("margin",n.margin),Ce(e,"width",n.width,o),typeof n.height=="number"&&Kt.has(i.type)?(E(e,"min-height",A(n.height)),o==="vertical"&&E(e,"flex","none")):Ce(e,"height",n.height,o),typeof n.max_width=="number"&&E(e,"max-width",A(n.max_width));let r=n.background;if(r){if(r.type==="color")E(e,"background-color",r.color);else if(r.type==="linear"||r.type==="radial")E(e,"background-image",ke(r)??"");else if(r.type==="image"){let u=Z(r.src);u&&(E(e,"background-image",`url("${u.replace(/"/g,"%22")}")`),E(e,"background-size",r.fit==="fit"?"contain":"cover"),E(e,"background-position","center"),E(e,"background-repeat","no-repeat"))}else if(r.type==="video"){let u=Z(r.src);if(u){let b=S("video","pw-bgvideo");b.src=u;let k=Z(r.poster);k&&(b.poster=k),b.muted=!0,b.loop=r.loop!==!1,b.playsInline=!0,b.autoplay=!te()&&!F(),b.setAttribute("aria-hidden","true"),E(e,"isolation","isolate"),e.prepend(b)}}}if(n.border&&i.type==="custom_html"?E(e,"border",`${A(n.border.width)} solid ${n.border.color??"transparent"}`):n.border&&(E(e,"--pw-bw",A(n.border.width)),E(e,"--pw-bc",n.border.color??"transparent")),n.corners){let u=n.corners;E(e,"border-start-start-radius",A(u.top_leading)),E(e,"border-start-end-radius",A(u.top_trailing)),E(e,"border-end-start-radius",A(u.bottom_leading)),E(e,"border-end-end-radius",A(u.bottom_trailing)),(i.type==="image"||i.type==="video"||r?.type==="image"||r?.type==="video")&&E(e,"overflow","hidden")}n.shadow&&E(e,"box-shadow",`${A(n.shadow.x)} ${A(n.shadow.y)} ${A(n.shadow.radius)} ${n.shadow.color}`),typeof n.opacity=="number"&&n.opacity!==1&&E(e,"opacity",String(n.opacity))}function Ce(e,i,o,n){if(o==null||o==="")return;if(n==="page"){i==="height"&&E(e,"height",o==="fill"?"100%":typeof o=="number"?A(o):o==="fit"?"fit-content":String(o));return}let s=n==="horizontal"?"width":n==="vertical"?"height":null;o==="fill"?i===s?(E(e,"flex","1 1 0"),E(e,`min-${i}`,"0")):n==="z"?E(e,i,"100%"):(E(e,"align-self","stretch"),E(e,i,"auto")):o==="fit"?(i===s&&E(e,"flex","0 0 auto"),E(e,i,"fit-content")):(E(e,i,typeof o=="number"?A(o):String(o)),i===s&&E(e,"flex","none"))}function ke(e){let i=o=>o.map(n=>`${n.color} ${(n.at*100).toFixed(2)}%`).join(", ");if(e.type==="linear")return`linear-gradient(${e.angle}deg, ${i(e.stops)})`;if(e.type==="radial"){let o=`${(e.radius*100).toFixed(2)}%`;return`radial-gradient(ellipse ${o} ${o} at ${(e.center_x*100).toFixed(2)}% ${(e.center_y*100).toFixed(2)}%, ${i(e.stops)})`}}function wt(e,i){let o=i.animation;if(!o||R.animate===!1||te()||typeof e.animate!="function")return;let n=24,r={fade:{opacity:0},slide_up:{opacity:0,transform:`translateY(${n}px)`},slide_down:{opacity:0,transform:`translateY(-${n}px)`},slide_leading:{opacity:0,transform:`translateX(-${n}px)`},slide_trailing:{opacity:0,transform:`translateX(${n}px)`},scale:{opacity:0,transform:"scale(0.92)"}}[o.type];r&&e.animate([r,{opacity:1,transform:"none"}],{duration:o.duration_ms,delay:o.delay_ms,easing:Qe[o.easing]??Qe.ease_out,fill:"backwards"})}function le(){l.onState?.({...x}),Y()}function xe(e){x.selected===e&&we()===e||(x.selected=e,le(),l.onSelect?.(fe(e)))}function Se(e){F()||e.getAttribute("aria-disabled")==="true"||xe(e.dataset.package??"")}function bt(e,i){if(e.key===" "||e.key==="Enter"){e.preventDefault(),Se(i);return}let o=e.key==="ArrowDown"||e.key==="ArrowRight"?1:e.key==="ArrowUp"||e.key==="ArrowLeft"?-1:0;if(o===0)return;e.preventDefault();let n=i.closest("[role=radiogroup]"),r=(n?[...n.children].filter(k=>k.dataset.pwType==="package"):[i]).filter(k=>k.getAttribute("aria-disabled")!=="true"),u=r.indexOf(i),b=r[(u+o+r.length)%r.length];b&&(Se(b),(O.get(b.dataset.pwPath??"")?.el??b).focus())}function je(e,i){if(F())return;x.tabs={...x.tabs,[e]:i};let o=mt(e,i);o&&(x.selected=o),le()}function mt(e,i){return Fe(e)?.tabs?.find(n=>n.id===i)?.package}function vt(e,i){if(F())return;x.switches={...x.switches,[e]:i};let o=Fe(e),n=i?o?.on_package:o?.off_package;n&&(x.selected=n),le()}function Fe(e){let i=R.definition;for(let o of e.match(/[^.[\]]+/g)??[])i=i?.[/^\d+$/.test(o)?Number(o):o];return i}async function Ne(e,i){if(!(F()||ie)){ie=!0,e.disabled=!0,e.setAttribute("aria-busy","true");try{await i()}finally{ie=!1,e.removeAttribute("aria-busy"),e.disabled=!1;for(let o of O.values())o.type==="purchase_button"&&(o.el.disabled=!R.packages?.[o.el.dataset.package??""]?.price)}}}async function kt(e,i){!R.packages?.[e]?.price||!l.onPurchase||await l.onPurchase(i!==void 0?{...fe(e),offer:i}:fe(e))}function ce(e){F()&&e!==null&&x.sheet===e||(e&&!x.sheet&&(Oe=w.activeElement??null),x.sheet=e,le(),e||Oe?.focus())}function xt(){let e=x.sheet,i=e?T.tree.sheets?.[e]:void 0;if(!i){P.remove();return}P.className="pw-layer";let o=P.firstElementChild;if(!o){o=S("div","pw-sheet"),o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.tabIndex=-1;let s=S("div","pw-grab");s.setAttribute("aria-hidden","true"),o.append(s),P.append(o),P.addEventListener("click",r=>{r.target===P&&!F()&&ce(null)}),o.addEventListener("keydown",r=>St(r,o))}o.style.background=T.tree.theme.colors.background??"",o.setAttribute("aria-label",T.sheetTitles[e]??"");let n=U(i,"vertical",{inControl:!1,inSheet:!0});q(o,n?[n]:[]),P.isConnected||(y.append(P),queueMicrotask(()=>(De(o)[0]??o).focus()))}function De(e){return[...e.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')].filter(i=>!i.hidden)}function St(e,i){if(e.key==="Escape"){e.preventDefault(),ce(null);return}if(e.key!=="Tab")return;let o=De(i);if(o.length===0){e.preventDefault();return}let n=o[0],s=o[o.length-1],r=w.activeElement;e.shiftKey&&r===n?(e.preventDefault(),s.focus()):!e.shiftKey&&r===s&&(e.preventDefault(),n.focus())}function Je(e){try{let i=d==="paywall"?{type:"palbase.paywall",package:we()}:{type:"palbase.message"};e.contentWindow?.postMessage({...i,locale:T.language,appearance:R.appearance},"*")}catch{}}function Ie(e){for(let i of w.querySelectorAll("[data-pw-highlight]"))i.removeAttribute("data-pw-highlight");ge=e,e&&O.get(e)?.el.setAttribute("data-pw-highlight","")}let Ve=e=>e.composedPath().find(i=>i instanceof(p?.HTMLElement??HTMLElement)&&i.dataset.pwPath!==void 0);y.addEventListener("click",e=>{if(!l.editor)return;let i=Ve(e);i&&(e.preventDefault(),e.stopPropagation(),l.editor.onPick(i.dataset.pwPath))},!0),y.addEventListener("pointerover",e=>{if(l.editor){for(let i of w.querySelectorAll("[data-pw-hover]"))i.removeAttribute("data-pw-hover");Ve(e)?.setAttribute("data-pw-hover","")}}),y.addEventListener("pointerleave",()=>{for(let e of w.querySelectorAll("[data-pw-hover]"))e.removeAttribute("data-pw-hover")});let Ue=()=>Y();return ye?.addEventListener?.("change",Ue),Y(),{get selected(){let e=we();return e?fe(e):null},get state(){return{...x}},select(e){xe(e)},update(e){R={...R,...e},e.state&&Object.assign(x,e.state),Y()},highlight(e){Ie(e)},replay(){for(let e of O.values())e.cleanup.forEach(i=>i());O=new Map;for(let e of[m,v,_])e.replaceChildren();Y()},destroy(){clearTimeout(he),Te?.disconnect(),c.fonts?.removeEventListener?.("loadingdone",$e),ye?.removeEventListener?.("change",Ue);for(let e of O.values())e.cleanup.forEach(i=>i());h.remove()}}}function rn(d,t,a){let l=d.defaultView;try{if(l&&"adoptedStyleSheets"in t&&typeof l.CSSStyleSheet=="function"){let p=new l.CSSStyleSheet;p.replaceSync(a),t.adoptedStyleSheets=[p];return}}catch{}let c=d.createElement("style");c.textContent=a,t.append(c)}export{At as a,ne as b,an as c,Lt as d,Ot as e,de as f,dn as g,pn as h,Jt as i,un as j,Vt as k,fn as l,Ut as m,gn as n,_e as o,hn as p,Ee as q,tn as r,vn as s,kn as t,rn as u};