palbase 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +2 -2
- package/dist/backend/engine.js +2 -2
- package/dist/backend/env.js +1 -1
- package/dist/backend/index.js +3 -3
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/{KHHJRNAO.js → 23G5YVSL.js} +1 -1
- package/dist/chunks/{73R33XMD.js → 3X7CRIHE.js} +1 -1
- package/dist/chunks/5UXVSEM2.js +2 -0
- package/dist/chunks/6YCANJ7U.js +2 -0
- package/dist/chunks/{RYI2OB52.js → 7HMBZG2R.js} +2 -2
- package/dist/chunks/{MAYLG7WE.js → 7OZCS3BA.js} +2 -2
- package/dist/chunks/FFWT3RBE.js +13 -0
- package/dist/chunks/{7XVI5JLP.js → GGKL7UV2.js} +2 -2
- package/dist/chunks/HGQXQMYU.js +95 -0
- package/dist/chunks/{ZSKMWUIQ.js → I45DYZZL.js} +2 -2
- package/dist/chunks/{5RTSNQ4X.js → KSU226RI.js} +2 -2
- package/dist/chunks/MEIN5GAG.js +22 -0
- package/dist/chunks/{NSQAN2ME.js → OEZLXSQN.js} +2 -2
- package/dist/chunks/{6RXVXPHC.js → OGREZP5F.js} +1 -1
- package/dist/chunks/{T2Q5CKLL.js → ONP77MHF.js} +2 -2
- package/dist/chunks/{CA4VJGGG.js → QR4Z3ORW.js} +1 -1
- package/dist/chunks/{M4XLAPDF.js → R5NCHIW3.js} +2 -2
- package/dist/chunks/{KYJJJUEU.js → RV35QG7V.js} +2 -2
- package/dist/chunks/{RZ525VLP.js → YOTK5642.js} +2 -2
- package/dist/chunks/{KJWHR5BP.js → Z7VRCVKE.js} +2 -2
- package/dist/cli.js +129 -127
- package/dist/refuse/ai.js +1 -1
- package/dist/refuse/backend.js +1 -1
- package/dist/refuse/server.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/testing.js +2 -2
- package/dist/web/index.js +2 -2
- package/dist/web/message.js +2 -0
- package/dist/web/palbe.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/push-sw.js +2 -0
- package/dist/web/ssr.js +2 -2
- package/dist/web/vite.js +2 -2
- package/package.json +7 -2
- package/types/backend/src/services.d.ts +2 -2
- package/types/internal/src/modules/ai.d.ts +1 -1
- package/types/internal/src/modules/analytics.d.ts +618 -1
- package/types/internal/src/modules/auth.d.ts +409 -90
- package/types/internal/src/modules/events.d.ts +7 -3
- package/types/internal/src/modules/flags.d.ts +380 -14
- package/types/internal/src/modules/notify.d.ts +2270 -99
- package/types/internal/src/modules/purchases.d.ts +672 -9
- package/types/server/src/webhooks.d.ts +1 -1
- package/types/web/src/analytics.d.ts +56 -5
- package/types/web/src/client.d.ts +26 -4
- package/types/web/src/consent.d.ts +218 -0
- package/types/web/src/flags.d.ts +75 -0
- package/types/web/src/inapp.d.ts +129 -0
- package/types/web/src/inbox.d.ts +59 -0
- package/types/web/src/index.d.ts +9 -3
- package/types/web/src/installation.d.ts +16 -0
- package/types/web/src/message/index.d.ts +5 -0
- package/types/web/src/message/present.d.ts +20 -0
- package/types/web/src/notify.d.ts +67 -0
- package/types/web/src/paywall/index.d.ts +4 -4
- package/types/web/src/paywall/placement.d.ts +11 -12
- package/types/web/src/paywall/prices.d.ts +7 -2
- package/types/web/src/purchases.d.ts +32 -0
- package/types/web/src/{paywall → screen}/assets.d.ts +6 -6
- package/types/web/src/screen/render.d.ts +186 -0
- package/types/web/src/{paywall → screen}/resolve.d.ts +56 -8
- package/dist/chunks/5M3HV3X4.js +0 -2
- package/dist/chunks/Q4XTWEAW.js +0 -92
- package/dist/chunks/Y6AQWQBE.js +0 -2
- package/types/web/src/paywall/render.d.ts +0 -93
- /package/types/web/src/{paywall → screen}/icons.d.ts +0 -0
package/dist/chunks/5M3HV3X4.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! palbase 0.8.1 — Palbase SDK License (see LICENSE) */
|
|
2
|
-
import{e as B,g as G,h as H}from"./5RTSNQ4X.js";import{u as J}from"./Q4XTWEAW.js";import{b as N,c as b,h as F}from"./Y6AQWQBE.js";import{a as $,b as k}from"./RYI2OB52.js";import{b as y,d as S}from"./KYJJJUEU.js";function oe(n){let e=n,t=e?.body,s=t&&typeof t=="object"?t.reason:void 0;return s==="user_deleted"?"userDeleted":s==="user_banned"?"userBanned":e?.code==="session_expired"||e?.code==="token_expired"?"expired":"revoked"}var w=class extends Error{code="session_changed";constructor(e){super(e),this.name="SessionChangedError"}};function V(){let n=null;return{load:()=>n,save:e=>{n=e},clear:()=>{n=null},shared:!1}}function W(n){let e=null,t=!0,s=()=>{try{return globalThis.localStorage}catch{return}};return{shared:!0,load(){try{let i=s()?.getItem(n);return i==null?t?null:e:JSON.parse(i)}catch{return e}},save(i){e=i;try{let r=s();if(!r)throw new Error("no storage");r.setItem(n,JSON.stringify(i)),t=!0}catch{t=!1}},clear(){e=null,t=!0;try{s()?.removeItem(n)}catch{}},watch(i){let r=globalThis;if(typeof r.addEventListener!="function")return()=>{};let a=o=>{(o.key===n||o.key===null)&&i()};return r.addEventListener("storage",a),()=>r.removeEventListener?.("storage",a)}}}function ae(n){try{let e=n.split(".")[1]??"",t=atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"=")),s=JSON.parse(t).sub;return typeof s=="string"?s:""}catch{return""}}var ce=6e4,le=15e3;function ue(n,e,t){let s=n?globalThis.navigator?.locks:void 0;return s?s.request(e,t):t()}var T=class{current=null;loaded;inflight=null;endReason=null;listeners=new Set;store;refresher;isRejected;now;lockName;refreshTimeoutMs;mode;constructor(e,t,s,i={}){this.store=e,this.refresher=t,this.isRejected=s,this.now=i.now??Date.now,this.lockName=i.lockName??"palbase.session.refresh",this.refreshTimeoutMs=i.refreshTimeoutMs??le,this.mode=i.refresh??"behind",this.loaded=Promise.resolve(e.load()).then(r=>{this.current=r}),e.watch?.(()=>{this.reconcile()})}async session(){return await this.loaded,this.current}snapshot(){return this.current}onChange(e){return this.listeners.add(e),()=>this.listeners.delete(e)}async set(e,t,s){await this.loaded;let i=t==="TOKEN_REFRESHED"?this.current:null,r={accessToken:e.access_token,refreshToken:e.refresh_token,expiresAt:this.now()+e.expires_in*1e3,userId:s?.id??i?.userId??ae(e.access_token),user:s??i?.user};return this.current=r,await this.store.save(r),this.emit(t,r),r}async setUser(e,t){await this.loaded,!(!this.current||!t||this.current.userId!==t.userId)&&(this.current={...this.current,user:e},await this.store.save(this.current),this.emit("USER_UPDATED",this.current))}async clear(e,t){await this.loaded;let s=this.current;this.current=null,this.inflight=null;let i=await this.store.load();(!i||!s||i.userId===s.userId)&&await this.store.clear(),s&&(e==="SESSION_EXPIRED"&&(this.endReason=t??"revoked"),this.emit(e,null))}async accessToken(){await this.loaded;let e=this.current;if(!e)return;let t=e.expiresAt-this.now();if(t>ce)return e.accessToken;if(this.mode==="never")return t>0?e.accessToken:void 0;if(t>0&&this.mode==="behind")return this.refresh().catch(()=>{}),e.accessToken;if(t>0)try{return(await this.refresh()).accessToken}catch(s){if(this.current===e)return e.accessToken;throw s}return(await this.refresh()).accessToken}refresh(){if(this.mode==="never")return Promise.reject(new Error("this client does not renew its session (refresh: 'never'): where the session cannot be written back, the request's middleware renews it"));if(this.inflight)return this.inflight;let e=ue(this.store.shared===!0,this.lockName,async()=>{await this.loaded;let t=this.current;if(!t)throw new w("no session to refresh");let s=await this.adoptStored(t);if(s)return s;try{let i=await this.withTimeout(this.refresher(t.refreshToken));if(this.current?.refreshToken!==t.refreshToken)throw new w("the session changed while it was refreshed");return await this.set(i,"TOKEN_REFRESHED")}catch(i){throw this.isRejected(i)&&this.current?.refreshToken===t.refreshToken&&await this.clear("SESSION_EXPIRED",oe(i)),i}});return this.inflight=e,e.finally(()=>{this.inflight===e&&(this.inflight=null)}).catch(()=>{}),e}async adoptStored(e){let t=await this.store.load();if(!t)throw this.current=null,this.emit("SIGNED_OUT",null),new w("signed out in another tab");if(t.userId!==e.userId)throw this.current=t,this.emit("SIGNED_OUT",null),this.emit("SIGNED_IN",t),new w("another user signed in in another tab");if(t.refreshToken!==e.refreshToken&&t.expiresAt>=e.expiresAt)return this.current=t,this.emit("TOKEN_REFRESHED",t),t}async reconcile(){await this.loaded;let e=this.current,t=await this.store.load();if(!e){t&&(this.current=t,this.emit("SIGNED_IN",t));return}await this.adoptStored(e).catch(()=>{})}withTimeout(e){let t,s=new Promise((i,r)=>{t=setTimeout(()=>r(new Error(`the refresh did not answer within ${this.refreshTimeoutMs/1e3} s`)),this.refreshTimeoutMs)});return Promise.race([e,s]).finally(()=>clearTimeout(t))}emit(e,t){(e==="SIGNED_IN"||e==="SIGNED_OUT")&&(this.endReason=null);for(let s of this.listeners)try{s(e,t)}catch{}}};var M=class{state="closed";refusal;logSeq;joinRef=null;listeners=new Map;closers=new Set;joinWaiters=[];name;socket;constructor(e,t,s={}){this.name=e,this.socket=t,this.logSeq=s.after}get topic(){return`realtime:${this.name}`}join(){if(this.state==="joined")return Promise.resolve();let e=new Promise((t,s)=>this.joinWaiters.push({resolve:t,reject:s}));return this.state!=="joining"&&this.socket.join(this),e}leave(){this.socket.leave(this)}push(e,t){return this.socket.request(this,e,t)}on(e,t){let s=this.listeners.get(e);return s||this.listeners.set(e,s=new Set),s.add(t),()=>s.delete(t)}onClosed(e){return this.closers.add(e),()=>this.closers.delete(e)}deliver(e,t){e==="broadcast"&&typeof t.seq=="number"&&(this.logSeq=t.seq);for(let s of this.listeners.get(e)??[])try{s(t)}catch{}}settled(e,t){e&&typeof t.log_seq=="number"&&(this.logSeq=t.log_seq),this.state=e?"joined":"refused",this.refusal=e?void 0:t;let s=this.joinWaiters.splice(0);for(let i of s)e?i.resolve():i.reject(new Error(`join ${this.name} refused: ${JSON.stringify(t)}`))}closed(e){this.state="closed",this.joinRef=null;let t=this.joinWaiters.splice(0);for(let s of t)s.reject(new Error(`join ${this.name}: ${e}`));for(let s of[...this.closers])try{s()}catch{}}},P=class{ws=null;opening=null;ref=0;channels=new Map;replies=new Map;heartbeat=null;heartbeatRef=null;reconnectTimer=null;attempts=0;closedByUs=!1;reconnects=0;opts;constructor(e){this.opts=e}channel(e,t){let s=this.channels.get(e);return s||this.channels.set(e,s=new M(e,this,t)),s}disconnect(){this.closedByUs=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.stopHeartbeat();let e=this.ws;this.ws=null,this.opening=null,e?.close(1e3);for(let[,t]of this.replies)t("error",{reason:"socket closed"});this.replies.clear();for(let t of this.channels.values())t.closed("the socket was closed")}async tokenChanged(){if(!this.ws||this.ws.readyState!==1)return;let e=await this.opts.accessToken();if(e)for(let t of this.channels.values())t.state==="joined"&&this.push(t.joinRef,t.topic,"access_token",{access_token:e})}join(e){e.state="joining",this.open().then(()=>this.sendJoin(e)).catch(t=>e.settled(!1,{reason:t instanceof Error?t.message:String(t)}))}leave(e){e.state==="joined"&&this.ws?.readyState===1&&this.push(e.joinRef,e.topic,"phx_leave",{}),e.state="closed",this.channels.delete(e.name)}async request(e,t,s){let i=this.ws;if(this.channels.get(e.name)!==e||e.state!=="joined"||i?.readyState!==1)return{status:"error",response:{reason:"not joined"}};let r=this.nextRef(),a=JSON.stringify([e.joinRef,r,e.topic,t,s]),o=this.awaitReply(r);return i.send(a),o}open(){if(this.ws?.readyState===1)return Promise.resolve();if(this.opening)return this.opening;this.closedByUs=!1;let e=this.opts.webSocket??globalThis.WebSocket,t=`${this.opts.baseUrl.replace(/^http/,"ws")}/realtime/v1/websocket?vsn=2.0.0&apikey=${encodeURIComponent(this.opts.publishableKey)}`,s=new Promise((i,r)=>{let a=new e(t);this.ws=a,a.onopen=()=>{this.attempts=0,this.startHeartbeat(),i()},a.onmessage=o=>this.receive(String(o.data)),a.onerror=()=>r(new Error("the realtime socket could not be opened")),a.onclose=()=>this.dropped(a)});return this.opening=s,s.finally(()=>{this.opening===s&&(this.opening=null)}).catch(()=>{}),s}dropped(e){if(this.ws!==e)return;this.ws=null,this.stopHeartbeat();for(let[,i]of this.replies)i("error",{reason:"socket closed"});this.replies.clear();for(let i of this.channels.values())i.state==="joined"&&(i.state="joining");if(this.closedByUs||![...this.channels.values()].some(i=>i.state==="joining"))return;let t=this.opts.backoff??[500,1e3,2e3,5e3,1e4,3e4],s=t[Math.min(this.attempts,t.length-1)]*(.8+Math.random()*.4);this.attempts++,this.reconnectTimer=R(setTimeout(()=>{this.reconnectTimer=null,this.reconnects++;let i=[...this.channels.values()].filter(r=>r.state==="joining");this.open().then(()=>Promise.all(i.map(r=>this.sendJoin(r)))).catch(()=>{})},s))}async sendJoin(e){let t=await this.opts.accessToken(),s=this.nextRef();e.joinRef=s;let i=this.awaitReply(s),r={broadcast:{self:!1}};e.logSeq!==void 0&&(r.log={after:e.logSeq}),this.push(s,e.topic,"phx_join",{access_token:t,config:r},s);let{status:a,response:o}=await i;if(this.channels.get(e.name)!==e||e.state!=="joining"){a==="ok"&&this.ws?.readyState===1&&this.push(s,e.topic,"phx_leave",{});return}e.settled(a==="ok",o)}awaitReply(e){return new Promise(t=>{let s=R(setTimeout(()=>{this.replies.delete(e),t({status:"timeout",response:{reason:"no reply"}})},this.opts.replyTimeoutMs??1e4));this.replies.set(e,(i,r)=>{clearTimeout(s),this.replies.delete(e),t({status:i,response:r})})})}receive(e){let t;try{t=JSON.parse(e)}catch{return}if(!Array.isArray(t)||t.length!==5||typeof t[2]!="string"||typeof t[3]!="string")return;let[,s,i,r,a]=t,o=typeof a=="object"&&a!==null?a:{};if(r==="phx_reply"&&typeof s=="string"){if(s===this.heartbeatRef){this.heartbeatRef=null;return}this.replies.get(s)?.(String(o.status),o.response??{});return}let l=[...this.channels.values()].find(c=>c.topic===i);if(l){if(r==="phx_close"){l.state="closed";return}if(r==="phx_error"){l.state="joining",R(setTimeout(()=>this.channels.get(l.name)===l&&l.state==="joining"&&this.ws?.readyState===1&&void this.sendJoin(l),1e3));return}l.deliver(r,o)}}push(e,t,s,i,r=this.nextRef()){this.ws?.send(JSON.stringify([e,r,t,s,i]))}nextRef(){return String(++this.ref)}startHeartbeat(){this.stopHeartbeat(),this.heartbeat=R(setInterval(()=>{if(this.heartbeatRef!==null){this.heartbeatRef=null,this.ws?.close(4e3);return}this.heartbeatRef=this.nextRef(),this.push(null,"phoenix","heartbeat",{},this.heartbeatRef)},this.opts.heartbeatMs??25e3))}stopHeartbeat(){this.heartbeat&&clearInterval(this.heartbeat),this.heartbeat=null,this.heartbeatRef=null}};function R(n){return n.unref?.(),n}var de=30*6e4,X=1e3,fe=100,pe=60*1024,I=()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;function _(){try{return globalThis.localStorage}catch{return}}var C=class{api;closingApi;flushMs;flushAt;now;anonKey;sessionKey;events=[];samples=[];timer;memoryAnon;memorySession;appVersion;stopAuto;session;identifyPending=!1;constructor(e,t,s,i={}){this.session=t,this.api=N.client(e),this.closingApi=N.client({send:r=>e.send({...r,keepalive:!0})}),this.flushMs=i.flushMs??5e3,this.flushAt=i.flushAt??20,this.now=i.now??Date.now,this.anonKey=`palbase.analytics.anonymous.${s}`,this.sessionKey=`palbase.analytics.session.${s}`,t.onChange(r=>{r==="SIGNED_IN"?(this.identifyPending=!0,this.soon()):r==="SIGNED_OUT"&&(this.identifyPending=!1,this.reset())})}capture(e,t){let s=this.now();this.hold({event:e,distinct_id:this.distinctId(),properties:t,timestamp:s,session_id:this.sessionId(s),...this.appVersion?{app_version:this.appVersion}:{}})}page(e={}){let t=globalThis.location,s=globalThis.document,i=e.url??(t?`${t.origin}${t.pathname}`:"");if(!i)return;let r=e.referrer??ve(s?.referrer);this.capture("$pageview",{...e.properties,url:i,...e.title??s?.title?{title:e.title??s?.title}:{},...r?{referrer:r}:{}})}async identify(e){this.identifyPending=!1;let t=this.session.snapshot()?.userId;t&&(await this.flush(),await this.sendIdentify(this.api,t,e))}async sendIdentify(e,t,s){try{await e.identify({body:{distinct_id:t,anonymous_id:this.anonymousId(),traits:s,timestamp:this.now(),sent_at:this.now()}})}catch{}}reset(){this.memoryAnon=void 0,this.memorySession=void 0;try{_()?.removeItem(this.anonKey),_()?.removeItem(this.sessionKey)}catch{}}async flush(e=!1){this.timer&&clearTimeout(this.timer),this.timer=void 0;let t=e?this.closingApi:this.api,s=this.now(),i=this.session.snapshot()?.userId;for(this.identifyPending&&i&&(this.identifyPending=!1,await this.sendIdentify(t,i));this.events.length>0;){let r=this.take(this.events,e);try{await t.batch({body:{events:r.map(a=>({...a,sent_at:s}))}})}catch{}}for(;this.samples.length>0;){let r=this.take(this.samples,e);try{await t.sendPerf({body:{items:r}})}catch{}}}start(e={}){this.stopAuto?.(),this.appVersion=e.appVersion;let t=globalThis;if(typeof t.addEventListener!="function"||typeof globalThis.document>"u")return()=>{};let s=[];e.pageViews!==!1&&s.push(this.watchPages(t)),e.webVitals!==!1&&s.push(ye((a,o)=>this.sample("web_vital",a,o))),e.network!==!1&&s.push(this.watchFetch(t));let i=()=>{document.visibilityState==="hidden"&&this.flush(!0)},r=()=>{this.flush(!0)};return document.addEventListener("visibilitychange",i),t.addEventListener("pagehide",r),s.push(()=>{document.removeEventListener("visibilitychange",i),t.removeEventListener("pagehide",r)}),this.stopAuto=()=>{for(let a of s.splice(0))a();this.stopAuto=void 0},this.stopAuto}hold(e){this.events.length>=X&&this.events.shift(),this.events.push(e),this.soon()}sample(e,t,s,i={}){this.samples.length>=X&&this.samples.shift(),this.samples.push({row_id:I(),trace_type:e,name:t,value:Math.max(0,s),timestamp:this.now(),distinct_id:this.distinctId(),...i}),this.soon()}soon(){if(this.events.length+this.samples.length>=this.flushAt){this.flush();return}this.timer||(this.timer=setTimeout(()=>{this.flush()},this.flushMs),this.timer.unref?.())}take(e,t){let s=e.splice(0,fe);if(!t)return s;for(;s.length>1&&JSON.stringify(s).length>pe;)e.unshift(s.pop());return s}distinctId(){return this.session.snapshot()?.userId??this.anonymousId()}anonymousId(){let e=_();try{let t=e?.getItem(this.anonKey);if(t)return t;let s=`anon_${I()}`;if(e?.setItem(this.anonKey,s),e?.getItem(this.anonKey)===s)return s}catch{}return this.memoryAnon??=`anon_${I()}`,this.memoryAnon}sessionId(e){let t=_(),s=this.memorySession;try{let r=t?.getItem(this.sessionKey);r&&(s=JSON.parse(r))}catch{}let i=s&&e-s.last<de?{id:s.id,last:e}:{id:`ses_${I()}`,last:e};this.memorySession=i;try{t?.setItem(this.sessionKey,JSON.stringify(i))}catch{}return i.id}watchPages(e){let t="",s=()=>{let o=`${e.location.origin}${e.location.pathname}`;o!==t&&(t=o,setTimeout(()=>this.page({url:o}),0))},i=e.history,r=i.pushState.bind(i),a=i.replaceState.bind(i);return i.pushState=(...o)=>{r(...o),s()},i.replaceState=(...o)=>{a(...o),s()},e.addEventListener("popstate",s),s(),()=>{i.pushState=r,i.replaceState=a,e.removeEventListener("popstate",s)}}watchFetch(e){let t=e.fetch;if(typeof t!="function")return()=>{};let s=async(i,r)=>{let a=performance.now(),o=i instanceof Request?i:void 0,l=(r?.method??o?.method??"GET").toUpperCase(),c;try{c=new URL(o?.url??String(i),e.location.href)}catch{c=void 0}let h=!!c&&c.pathname.startsWith("/analytics/")||we(r?.headers??o?.headers);try{let d=await t(i,r);return c&&!h&&this.sample("network",`${l} ${c.origin}${c.pathname}`,performance.now()-a,{attrs:{status:String(d.status)},...d.headers.get("x-request-id")?{request_id:d.headers.get("x-request-id")}:{}}),d}catch(d){throw c&&!h&&this.sample("network",`${l} ${c.origin}${c.pathname}`,performance.now()-a,{attrs:{status:"0"}}),d}};return e.fetch=s,()=>{e.fetch===s&&(e.fetch=t)}}},ge=n=>n.entryType==="layout-shift"&&"value"in n&&"hadRecentInput"in n,me=n=>n.entryType==="event"||n.entryType==="first-input";function E(n,e){if(!(typeof PerformanceObserver>"u"))try{let t=new PerformanceObserver(s=>e(s.getEntries()));return t.observe({type:n,buffered:!0}),t}catch{return}}function ye(n){if(typeof document>"u"||typeof performance>"u"||typeof performance.getEntriesByType!="function")return()=>{};let e=0,t=0,s=0,i=[E("largest-contentful-paint",c=>{for(let h of c)e=Math.max(e,h.startTime)}),E("layout-shift",c=>{for(let h of c)ge(h)&&!h.hadRecentInput&&(t+=h.value)}),E("event",c=>{for(let h of c)me(h)&&(s=Math.max(s,h.duration))}),E("paint",c=>{for(let h of c)h.name==="first-contentful-paint"&&n("FCP",h.startTime)})],r=performance.getEntriesByType("navigation")[0];r&&r.responseStart>0&&n("TTFB",r.responseStart);let a=!1,o=()=>{a||(a=!0,e>0&&n("LCP",e),n("CLS",t),s>0&&n("INP",s))},l=()=>{document.visibilityState==="hidden"&&o()};return document.addEventListener("visibilitychange",l),()=>{o(),document.removeEventListener("visibilitychange",l);for(let c of i)c?.disconnect()}}function we(n){if(!n)return!1;try{return new Headers(n).has("next-router-prefetch")}catch{return!1}}function ve(n){if(!n)return"";try{let e=new URL(n);return`${e.origin}${e.pathname}`}catch{return n.split(/[?#]/,1)[0]??""}}var A=class{api;session;socket;ref;fetch;appVersion;app;listeners=new Set;watch;following;last;constructor(e,t,s,i,r,a,o){this.api=F.client(e),this.session=t,this.socket=s,this.ref=i,this.fetch=r,this.appVersion=a,this.app=o}async me(){let e=this.session.snapshot()?.userId,t=(await this.api.getMyCustomerInfo()).data;return this.watch&&this.watch.userId===e&&this.offer(this.watch,t),t}async offerings(e="web"){return(await this.api.getOfferings({query:{channel:e}})).data}async paywall(e,t={}){return J(this.api,this.ref,e,s=>this.checkout(s),{signal:t.signal,fetch:this.fetch,attributes:t.attributes,locale:t.locale,appVersion:this.appVersion,app:this.app})}async checkout(e){let t={product:e.product,plan:e.plan,success_url:e.successUrl,cancel_url:e.cancelUrl,source:e.source},s=(await this.api.createCheckout({body:t})).data;return s.redemption_key&&Se(this.keyName(s.session_id),s.redemption_key),s.url}async redemptionLink(e,t={}){let s=t.key??ke(this.keyName(e));if(!s)throw new y({op:"CreateCheckoutRedemption",status:0,code:"redemption_key_missing",message:"no redemption key for this checkout in this tab: the link was sent to the buyer's email"});let i=Date.now()+(t.waitSeconds??20)*1e3;for(;;)try{return(await this.api.createCheckoutRedemption({body:{session_id:e,key:s},signal:t.signal})).data}catch(r){let a=(r instanceof y&&r.code==="checkout_not_paid"?r.retryAfter??2:-1)*1e3;if(a<0||Date.now()+a>i)throw r;await Te(a,t.signal)}}async redeem(e){let t=be(e);if(!t)throw new y({op:"RedeemPurchase",status:0,code:"invalid_redemption_link",message:"not a redemption link: <scheme>://palbase/redeem?token=\u2026 or \u2026/purchases/redeem?token=\u2026"});let s=this.session.snapshot()?.userId,i=(await this.api.redeemPurchase({body:{token:t}})).data;return this.watch&&this.watch.userId===s&&this.offer(this.watch,i),i}async portal(e){return(await this.api.createPortalSession({body:{return_url:e}})).data.url}async mergeGrant(){return(await this.api.createMergeGrant()).data}async merge(e){let t=this.session.snapshot()?.userId,s=(await this.api.mergeGuest({body:{grant:typeof e=="string"?e:e.grant}})).data;return this.watch&&this.watch.userId===t&&this.offer(this.watch,s),s}keyName(e){return`palbase:${this.ref}:redemption:${e}`}onCustomerInfo(e){if(this.listeners.add(e),this.listeners.size===1)this.start();else if(this.last!==void 0){let t=this.last;queueMicrotask(()=>this.listeners.has(e)&&z(e,t))}return()=>{this.listeners.delete(e)&&this.listeners.size===0&&this.stop()}}start(){this.following=this.session.onChange((e,t)=>{(e==="SIGNED_IN"||e==="SIGNED_OUT"||e==="SESSION_EXPIRED")&&this.follow(t)}),this.session.session().then(e=>{this.following&&!this.watch&&this.last===void 0&&this.follow(e)})}stop(){this.following?.(),this.following=void 0,this.unfollow(),this.last=void 0}follow(e){if(this.unfollow(),!e){this.tell(null);return}let t=this.socket.channel(`purchases:${this.ref}:${e.userId}`),s={userId:e.userId,channel:t,off:()=>{},revision:-1,reading:!1,wanted:Number.NEGATIVE_INFINITY},i=[t.on("broadcast",r=>{r.event==="changed"&&this.changed(s,L(r.payload))}),t.on("state_snapshot",r=>this.held(s,L(Y(r.entries)))),t.on("state_diff",r=>this.held(s,L(Y(r.set))))];s.off=()=>i.forEach(r=>r()),this.watch=s,t.join().catch(()=>{}),this.read(s)}unfollow(){let e=this.watch;e&&(this.watch=void 0,e.off(),e.channel.leave())}changed(e,t){this.watch!==e||t!==void 0&&t<=e.revision||(e.reading?e.wanted=Math.max(e.wanted,t??Number.POSITIVE_INFINITY):this.read(e))}held(e,t){t!==void 0&&this.changed(e,t)}async read(e){e.reading=!0;try{for(;;){e.wanted=Number.NEGATIVE_INFINITY;try{let t=(await this.api.getMyCustomerInfo()).data;if(this.watch!==e)return;this.offer(e,t)}catch{}if(this.watch!==e||e.wanted<=e.revision)return}}finally{e.reading=!1}}offer(e,t){this.watch!==e||t.revision<=e.revision||(e.revision=t.revision,this.tell(t))}tell(e){if(!(this.last===null&&e===null)){this.last=e;for(let t of[...this.listeners])z(t,e)}}};function z(n,e){try{n(e)}catch{}}function Y(n){let e=typeof n=="object"&&n!==null?n.revision:void 0;return typeof e=="object"&&e!==null?e.v:void 0}function L(n){let e=typeof n=="object"&&n!==null?n.revision:void 0;return typeof e=="number"&&Number.isFinite(e)?e:void 0}var Z=/^[A-Za-z0-9_-]{43}$/;function be(n){let e=n.trim();if(Z.test(e))return e;let t;try{t=new URL(e)}catch{return}let s=t.host==="palbase"&&t.pathname==="/redeem",i=(t.protocol==="https:"||t.protocol==="http:")&&t.pathname==="/purchases/redeem",r=t.searchParams.get("token");return(s||i)&&r!==null&&Z.test(r)?r:void 0}function Se(n,e){try{globalThis.sessionStorage?.setItem(n,e)}catch{}}function ke(n){try{return globalThis.sessionStorage?.getItem(n)??void 0}catch{return}}function Te(n,e){return new Promise((t,s)=>{if(e?.aborted)return s(e.reason);let i=setTimeout(()=>{e?.removeEventListener("abort",r),t()},n),r=()=>{clearTimeout(i),s(e?.reason)};e?.addEventListener("abort",r,{once:!0})})}var x=class{api;open;session;credentials;mfa;passkey;magicLink;phone;password;email;sessions;constructor(e,t,s,i){this.api=b.client(e),this.open=b.client(t),this.session=s,this.credentials=i;let r=this.api,a=this.open;this.mfa={challenge:async(o,l,c)=>this.signedIn((await a.mfaChallenge({body:{mfa_token:o,type:l,code:c}})).data),recovery:async(o,l)=>this.signedIn((await a.mfaRecovery({body:{mfa_token:o,code:l}})).data),sendSmsCode:async o=>{await a.mfaSmsChallenge({body:{mfa_token:o}})},sendEmailCode:async o=>{await a.mfaEmailChallenge({body:{mfa_token:o}})},enrollTotp:async()=>{let o=(await r.mfaEnroll({body:{type:"totp"}})).data;return{enrollmentId:o.enrollment_id,secret:o.secret,otpUrl:o.otp_url,qrCode:o.qr_code,recoveryCodes:o.recovery_codes}},verifyTotp:async o=>{await r.mfaVerifyEnrollment({body:{code:o}})},enrollSms:async o=>(await r.mfaSmsEnroll({body:{phone:o}})).data,verifySms:async o=>{await r.mfaSmsVerifyEnrollment({body:{code:o}})},enrollEmail:async()=>{await r.mfaEmailEnroll()},factors:async()=>(await r.mfaListFactors()).data,removeFactor:async(o,l)=>{await r.mfaRemoveFactor({path:{id:o},body:{current_password:l}})},regenerateRecoveryCodes:async()=>(await r.mfaRegenerateRecoveryCodes()).data},this.passkey={register:async o=>{let l=(await r.webauthnRegisterBegin({body:{name:o}})).data,c=await this.authenticator().create({publicKey:Q(l.options.publicKey)});return(await r.webauthnRegisterFinish({body:te(c)})).data},signIn:async(o={})=>{let l=(await a.webauthnLoginBegin({body:o.userId?{user_id:o.userId}:{}})).data,c=await this.authenticator().get({publicKey:ee(l.options.publicKey)}),h=await a.webauthnLoginFinish({query:o.userId?{user_id:o.userId}:void 0,body:se(c)});return this.signedIn(h.data)},signUp:async(o,l)=>{let c=(await a.webauthnSignupBegin({body:{identifier:o,user_name:l}})).data,h=await this.authenticator().create({publicKey:Q(c.options.publicKey)});await a.webauthnSignupFinish({query:{user_id:c.user_id},body:te(h)});let d=(await a.webauthnLoginBegin({body:{user_id:c.user_id}})).data,m=await this.authenticator().get({publicKey:ee(d.options.publicKey)});return this.signedIn((await a.webauthnLoginFinish({query:{user_id:c.user_id},body:se(m)})).data)},list:async()=>(await r.webauthnListCredentials()).data,remove:async o=>{await r.webauthnDeleteCredential({path:{id:o}})}},this.magicLink={send:async(o,l={})=>{await a.magicLinkRequest({body:{email:o,...l.redirectTo?{redirect_to:l.redirectTo}:{}}})},verify:async o=>this.signedIn((await a.magicLinkVerify({body:{token:o}})).data)},this.phone={sendCode:async o=>(await a.requestPhoneOtp({body:{phone:o,channel:"sms"}})).data,verifyCode:async(o,l)=>this.signInResult((await a.verifyPhoneOtp({body:{phone:o,token:l}})).data)},this.password={requestReset:async(o,l={})=>{await a.passwordResetRequest({body:{email:o,...l.redirectTo?{redirect_to:l.redirectTo}:{}}})},confirmReset:async(o,l)=>{await a.passwordResetConfirm({body:{token:o,new_password:l}})},change:async o=>(await r.passwordChange({body:o})).data,set:async o=>(await r.setPassword({body:o})).data},this.email={verify:async o=>{await a.verifyEmail({body:o})},resendVerification:async o=>(await a.resendVerification({body:{email:o}})).data},this.sessions={list:async()=>(await r.listSessions()).data,revoke:async o=>{await r.revokeSession({path:{id:o}})},revokeAll:async()=>{await r.revokeAllSessions()}}}onAuthStateChange(e){return this.session.onChange(e)}currentSession(){return this.session.session()}get sessionEndReason(){return this.session.endReason}async signUp(e){let t=(await this.open.signup({body:e})).data;return t.access_token&&t.refresh_token&&t.expires_in!==void 0&&await this.session.set({access_token:t.access_token,refresh_token:t.refresh_token,expires_in:t.expires_in},"SIGNED_IN",t.user),t}async signIn(e,t){return this.signInResult((await this.open.login({body:{email:e,password:t}})).data)}async signOut(){try{await this.session.session()&&await this.api.logout()}finally{await this.session.clear("SIGNED_OUT")}}async getUser(){let e=this.session.snapshot(),t=(await this.api.getMe()).data;return await this.session.setUser(t,e),t}async refreshSession(){return this.session.refresh()}async deleteAccount(e){await this.api.deleteAccount(e===void 0?void 0:{body:{password:e}}),await this.session.clear("SIGNED_OUT")}async signInResult(e){return"mfa_required"in e&&e.mfa_required?{mfaRequired:{mfaToken:e.mfa_token,factors:e.factors}}:{user:await this.signedIn(e)}}async setSession(e){return this.signedIn(e)}async signedIn(e){let t=await this.session.set({access_token:e.access_token,refresh_token:e.refresh_token,expires_in:e.expires_in},"SIGNED_IN",e.user);if(e.user)return e.user;let s=(await this.api.verifyTokenUser()).data;return await this.session.setUser(s,t),s}authenticator(){if(!this.credentials)throw new Error("passkeys need navigator.credentials (or createClient({ webauthn }))");return this.credentials}},O=n=>{let e=atob(n.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(n.length/4)*4,"=")),t=new Uint8Array(e.length);for(let s=0;s<e.length;s++)t[s]=e.charCodeAt(s);return t.buffer},g=n=>{if(!n)return;let e=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength),t="";for(let s of e)t+=String.fromCharCode(s);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},ne=n=>Array.isArray(n)?n.map(e=>({...e,id:O(String(e.id))})):void 0;function Q(n){let e=n.user;return{...n,challenge:O(String(n.challenge)),user:{...e,id:O(String(e.id))},excludeCredentials:ne(n.excludeCredentials)}}function ee(n){return{...n,challenge:O(String(n.challenge)),allowCredentials:ne(n.allowCredentials)}}function te(n){let e=n,t=e.response;return{id:e.id,rawId:g(e.rawId),type:"public-key",authenticatorAttachment:e.authenticatorAttachment??void 0,clientExtensionResults:e.getClientExtensionResults?.()??{},response:{clientDataJSON:g(t.clientDataJSON),attestationObject:g(t.attestationObject),transports:t.getTransports?.()}}}function se(n){let e=n,t=e.response;return{id:e.id,rawId:g(e.rawId),type:"public-key",authenticatorAttachment:e.authenticatorAttachment??void 0,clientExtensionResults:e.getClientExtensionResults?.()??{},response:{clientDataJSON:g(t.clientDataJSON),authenticatorData:g(t.authenticatorData),signature:g(t.signature),userHandle:g(t.userHandle)}}}var Re=/^pb_[a-z0-9]+_s/,Pe=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Ie=new Set(["invalid_token","token_expired","session_expired","session_revoked","missing_token"]),_e=new Set(["invalid_token","token_reuse","token_expired","session_revoked","session_expired","session_device_changed"]);function Ee(n){return n.status===400&&n.code==="invalid_request"}function Xe(n){if(Re.test(n.publishableKey)||"secretKey"in n)throw new TypeError("a secret key never goes into a client app: palbase/web takes the publishable key (pb_<ref>_c\u2026); servers use palbase/server");let e=/^pb_([a-z0-9]+)_c/.exec(n.publishableKey)?.[1];if(e===void 0)throw new TypeError("publishableKey is the project publishable key (pb_<ref>_c\u2026)");if(n.appId!==void 0&&!Pe.test(n.appId))throw new TypeError("appId is the registered app's id, a UUID (settings.appId of palbase apps:sync), not its slug");let t=ie(n.language),s=(u,f)=>{let p=n.fetch??globalThis.fetch;if(t===void 0)return p(u,f);let v=new Headers(f?.headers);return v.has("accept-language")||v.set("accept-language",t),p(u,{...f,headers:v})},i=new URL(n.url).origin,r=n.storage??(Ae()?W(`palbase.session.${i}`):V()),a=n.retry??$,o=k(S({baseUrl:n.url,credentials:{publishableKey:n.publishableKey},fetch:s}),a),l=b.client(o),c=new T(r,async u=>(await l.refreshToken({body:{refresh_token:u}})).data,u=>u instanceof y&&(u.status===401&&_e.has(u.code)||Ee(u)),{lockName:`palbase.session.refresh.${i}`,refresh:n.refresh}),h=S({baseUrl:n.url,credentials:{publishableKey:n.publishableKey,accessToken:()=>c.accessToken()},fetch:s,xmlHttpRequest:n.xmlHttpRequest??(n.fetch===void 0?globalThis.XMLHttpRequest:void 0)}),d=k(U(h,c),a),m=new P({baseUrl:n.url,publishableKey:n.publishableKey,accessToken:()=>c.accessToken(),webSocket:n.webSocket});c.onChange(u=>{u==="SIGNED_OUT"||u==="SESSION_EXPIRED"||u==="SIGNED_IN"?m.disconnect():u==="TOKEN_REFRESHED"&&m.tokenChanged()});let q=new C(U(h,c),c,i);n.analytics&&q.start(n.analytics===!0?{}:n.analytics);let j=new Map,re=u=>{let f=new URL(u).origin,p=j.get(f);return p||(p=k(U(S({baseUrl:f,credentials:{accessToken:()=>c.accessToken()},fetch:s}),c),a),j.set(f,p)),p},D=B(d),K=Object.assign(Object.create(G),{auth:new x(d,o,c,n.webauthn??globalThis.navigator?.credentials),socket:m,transport:d,analytics:q,purchases:new A(d,c,m,e,s,n.appVersion,n.appId),setLanguage(u){t=ie(u??void 0)},chatToolCall:(u,f,p={})=>D.toolCall(u,f,p.signal),chatWorkspaceFile:(u,f,p,v={})=>D.workspaceFile(u,f,p,v.signal)});return H(K,i,re,d,m,()=>c.snapshot()?.userId),K}var Ce=/^[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*$/;function ie(n){if(n===void 0)return;let e=typeof n=="string"?[n]:[...n];if(e.length!==0){for(let t of e)if(!Ce.test(t))throw new TypeError(`language ${JSON.stringify(t)} is a BCP 47 tag ("tr", "pt-BR")`);return e.map((t,s)=>s===0?t:`${t};q=${Math.max(.1,1-s/10).toFixed(1)}`).join(", ")}}function Ae(){try{return typeof globalThis.localStorage<"u"}catch{return!1}}function U(n,e){return{async send(t){let s=await e.session();try{return await n.send(t)}catch(i){let r=t.auth.some(a=>a.includes("userJWT"));if(!(i instanceof y)||i.status!==401||!Ie.has(i.code)||!r||!s)throw i;try{e.snapshot()?.refreshToken===s.refreshToken&&await e.refresh()}catch{throw i}if(e.snapshot()?.userId!==s.userId)throw i;return n.send(t)}}}}export{w as a,V as b,W as c,M as d,P as e,C as f,A as g,be as h,Xe as i};
|
package/dist/chunks/Q4XTWEAW.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/*! palbase 0.8.1 — Palbase SDK License (see LICENSE) */
|
|
2
|
-
import{b as oe}from"./KYJJJUEU.js";var Jt=s=>[...new Uint8Array(s)].map(t=>t.toString(16).padStart(2,"0")).join(""),Ut=s=>`pw-font-${s}`;function ie(s){return(typeof s=="string"?/^asset:([0-9a-f-]{36})$/.exec(s):null)?.[1]}async function Ge(s,t={}){let n={},i=t.fetch??((p,l)=>globalThis.fetch(p,l));return await Promise.all(s.map(async p=>{try{if(!/^https:\/\//.test(p.url))return;let l=await i(p.url,{signal:t.signal,credentials:"omit"});if(!l.ok)return;let f=await l.arrayBuffer();if(f.byteLength!==p.bytes&&p.bytes>0||Jt(await globalThis.crypto.subtle.digest("SHA-256",f))!==p.sha256.toLowerCase())return;let g=Vt(p.kind,new Uint8Array(f));if(g===void 0)return;let h=await Bt(p,f,g,t);h&&(n[p.id]=h)}catch{}})),n}var F=(s,t,n=0)=>s.length>=n+t.length&&t.every((i,p)=>s[n+p]===i),q=s=>[...s].map(t=>t.charCodeAt(0));function Vt(s,t){switch(s){case"image":return F(t,[137,80,78,71,13,10,26,10])?"image/png":F(t,[255,216,255])?"image/jpeg":F(t,q("RIFF"))&&F(t,q("WEBP"),8)?"image/webp":void 0;case"video":return F(t,q("ftyp"),4)?F(t,q("qt "),8)?"video/quicktime":"video/mp4":F(t,[26,69,223,163])?"video/webm":void 0;case"font":return F(t,q("wOF2"))?"font/woff2":F(t,q("wOFF"))?"font/woff":F(t,q("OTTO"))?"font/otf":F(t,[0,1,0,0])||F(t,q("true"))?"font/ttf":void 0;case"html":return F(t,[80,75,3,4])||F(t,[80,75,5,6])?"application/zip":void 0;default:return}}async function Bt(s,t,n,i){switch(s.kind){case"image":case"video":return{kind:s.kind,url:URL.createObjectURL(new Blob([t],{type:n}))};case"font":{let p=Ut(s.id),l=globalThis.FontFace,f=i.fonts??globalThis.document?.fonts;if(!l||!f)return;let y=new l(p,t,{display:"block"});return await y.load(),f.add(y),{kind:"font",url:"",family:p}}case"html":{let p=await qt(new Uint8Array(t)),l=Yt(p);return l===void 0?void 0:{kind:"html",url:"",html:l}}}}async function qt(s){let t=new DataView(s.buffer,s.byteOffset,s.byteLength),n=-1;for(let y=s.length-22;y>=Math.max(0,s.length-22-65535);y--)if(t.getUint32(y,!0)===101010256){n=y;break}if(n<0)throw new Error("not a zip");let i=t.getUint16(n+10,!0),p=t.getUint32(n+16,!0),l=new Map,f=0;for(let y=0;y<i;y++){if(t.getUint32(p,!0)!==33639248)throw new Error("a broken zip");let g=t.getUint16(p+10,!0),h=t.getUint32(p+20,!0),w=t.getUint32(p+24,!0),v=t.getUint16(p+28,!0),A=t.getUint16(p+30,!0),x=t.getUint16(p+32,!0),R=t.getUint32(p+42,!0),b=new TextDecoder().decode(s.subarray(p+46,p+46+v));if(p+=46+v+A+x,b.endsWith("/"))continue;if(b.startsWith("/")||b.split("/").includes(".."))throw new Error("a path leaving the zip");if(f+=w,l.size>=200||f>20971520)throw new Error("a zip too large");let T=R+30+t.getUint16(R+26,!0)+t.getUint16(R+28,!0),C=s.subarray(T,T+h);if(g===0)l.set(b,C);else if(g===8)l.set(b,await Wt(C));else throw new Error("a zip entry compressed another way")}return l}async function Wt(s){let t=new Response(new Uint8Array(s)).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(t).arrayBuffer())}var Kt={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 Ye(s,t){let n=Kt[s.split(".").pop()?.toLowerCase()??""]??"application/octet-stream",i="";for(let p=0;p<t.length;p+=32768)i+=String.fromCharCode(...t.subarray(p,p+32768));return`data:${n};base64,${btoa(i)}`}var Xt="default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:";function Yt(s){let t=s.get("index.html");if(!t)return;let n=new TextDecoder().decode(t),i=h=>new TextDecoder().decode(s.get(h)),p=h=>{let w=h.replace(/^\.\//,"").split(/[?#]/)[0];return s.has(w)?w:void 0},l=h=>h.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(w,v,A)=>{let x=p(A);return x?`url("${Ye(x,s.get(x))}")`:w}),f=globalThis.DOMParser;if(!f)return;let y=new f().parseFromString(n,"text/html");for(let h of[...y.querySelectorAll('link[rel~="stylesheet"][href]')]){let w=p(h.getAttribute("href")),v=y.createElement("style");v.textContent=w?l(i(w)):"",h.replaceWith(v)}for(let h of[...y.querySelectorAll("style")])h.textContent=l(h.textContent??"");for(let h of[...y.querySelectorAll("[src], [href], [poster]")])for(let w of["src","href","poster"]){let v=h.getAttribute(w);if(v===null)continue;let A=p(v);A?h.setAttribute(w,Ye(A,s.get(A))):/^(https?:)?\/\//i.test(v)&&h.removeAttribute(w)}for(let h of[...y.querySelectorAll("[style]")])h.setAttribute("style",l(h.getAttribute("style")??""));let g=y.createElement("meta");return g.setAttribute("http-equiv","Content-Security-Policy"),g.setAttribute("content",Xt),y.head.prepend(g),`<!doctype html>${y.documentElement.outerHTML}`}var Ze=20,Qe=2048,et=256,Gt=/^[A-Za-z][A-Za-z0-9_.-]{0,39}$/,Q=s=>new oe({op:"GetPlacementPaywall",status:0,code:"invalid_attributes",message:s});function Zt(s){let t='"';for(let n=0;n<s.length;n++){let i=s.charCodeAt(n);i===34?t+='\\"':i===92?t+="\\\\":i>=32&&i<=126?t+=s[n]:t+=`\\u${i.toString(16).padStart(4,"0")}`}return`${t}"`}function tt(s){let t=Object.keys(s??{}).sort((p,l)=>p<l?-1:p>l?1:0);if(t.length===0)return;if(t.length>Ze)throw Q(`${t.length} attributes: at most ${Ze}`);let n=[];for(let p of t){if(!Gt.test(p))throw Q(`the attribute ${JSON.stringify(p)}: a key is a letter, then letters, digits and _ . -, at most 40`);let l=s[p],f;if(typeof l=="string"){if(new TextEncoder().encode(l).length>et)throw Q(`the attribute ${JSON.stringify(p)} is over ${et} bytes`);f=Zt(l)}else if(typeof l=="number"){if(!Number.isFinite(l))throw Q(`the attribute ${JSON.stringify(p)} is no number`);f=String(Object.is(l,-0)?0:l)}else if(typeof l=="boolean")f=l?"true":"false";else throw Q(`the attribute ${JSON.stringify(p)}: a value is a text, a number or a boolean`);n.push(`"${p}":${f}`)}let i=`{${n.join(",")}}`;if(i.length>Qe)throw Q(`the attributes are ${i.length} bytes: at most ${Qe}`);return i}function _e(s){let t=/^P(\d+)([DWMY])$/.exec(s??"");if(!t)return null;let n=Number(t[1]);if(!Number.isSafeInteger(n)||n<1)return null;switch(t[2]){case"D":return{count:n,unit:"day",months:n*12/365};case"W":return{count:n,unit:"week",months:n*12/52};case"M":return{count:n,unit:"month",months:n};default:return{count:n,unit:"year",months:n*12}}}function nt(s){try{return new Intl.NumberFormat("en",{style:"currency",currency:s}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function st(s,t,n){let i=s/10**nt(t);try{return new Intl.NumberFormat(n,{style:"currency",currency:t}).format(i)}catch{return`${i.toFixed(nt(t))} ${t}`}}function Qt(s,t){try{let n=new Intl.NumberFormat(t,{style:"unit",unit:s.unit,unitDisplay:"long"});return s.count>1?n.format(s.count):n.formatToParts(1).filter(p=>p.type==="unit").map(p=>p.value).join("").trim()||n.format(1)}catch{return s.count>1?`${s.count} ${s.unit}s`:s.unit}}var en={en:s=>`${s} free`,tr:s=>`${s} \xFCcretsiz`,de:s=>`${s} kostenlos`,es:s=>`${s} gratis`,it:s=>`${s} gratis`,nl:s=>`${s} gratis`,pt:s=>`${s} gr\xE1tis`,sv:s=>`${s} gratis`,da:s=>`${s} gratis`,nb:s=>`${s} gratis`};function tn(s,t){let n;try{n=new Intl.NumberFormat(t,{style:"unit",unit:s.unit,unitDisplay:"long"}).format(s.count)}catch{n=`${s.count} ${s.unit}${s.count>1?"s":""}`}let i=en[t.split("-")[0].toLowerCase()];return i?i(n):n}function nn(s,t){try{return new Intl.NumberFormat(t,{style:"percent",maximumFractionDigits:0}).format(s)}catch{return`${Math.round(s*100)}%`}}function rt(s,t){let n=new Map,i=new Map;for(let l of s){let f=_e(l.period);if(!f)continue;let y=l.price.amount/f.months;n.set(l.key,y),i.set(l.price.currency,Math.max(i.get(l.price.currency)??0,y))}let p={};for(let l of s){let f={product_name:l.productName,price:st(l.price.amount,l.price.currency,t)},y=_e(l.period);if(y){f.period=Qt(y,t),f.price_per_month=st(Math.round(n.get(l.key)),l.price.currency,t);let h=i.get(l.price.currency)??0,w=h>0?Math.floor((1-n.get(l.key)/h)*100)/100:0;w>=.01&&(f.savings=nn(w,t))}let g=l.intro?.mode==="free_trial"?_e(l.intro.duration):null;g&&(f.trial=tn(g,t)),p[l.key]=f}return p}var W=(s,t,n)=>`M${s-n} ${t}a${n} ${n} 0 1 0 ${2*n} 0a${n} ${n} 0 1 0 ${-2*n} 0`,ue={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:[W(12,12,9),"M8 12l3 3 5-6"],clock:[W(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:[W(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",W(6,18,3),W(17,16,3)],people:[W(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:[W(12,8,4),"M4 21a8 8 0 0 1 16 0"],photo:["M3 5h18v14H3z",W(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 ot="http://www.w3.org/2000/svg";function fe(s,t,n){let i=s.createElementNS(ot,"svg");i.setAttribute("viewBox","0 0 24 24"),i.setAttribute("width",String(n)),i.setAttribute("height",String(n)),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("aria-hidden","true"),i.setAttribute("focusable","false");for(let p of t){let l=s.createElementNS(ot,"path");l.setAttribute("d",p),i.append(l)}return i}var he=2,m=(s,t=!1)=>({kind:"value",value:"plain",def:s,required:t}),N=s=>({kind:"value",value:"color",def:s}),it=s=>({kind:"value",value:"spacing",def:s}),sn=s=>({kind:"value",value:"radius",def:s}),Y=(s=!1)=>({kind:"text",required:s}),Ee=(s,t=!1)=>({kind:"list",item:s,required:t}),ae=(s,t=!1)=>({kind:"object",item:s,required:t}),at=(s=!1)=>({kind:"component",required:s}),Le={kind:"components"},lt={stack:{axis:m("vertical"),spacing:it(0),align:m("center"),distribution:m("start"),scroll:m(!1),children:Le},text:{text:Y(),spans:Ee("span"),font:m(),size:m(),weight:m(),line_height:m(),letter_spacing:m(),color:{kind:"value",value:"textColor",def:"text"},align:m("center"),max_lines:m(),uppercase:m(!1)},image:{src:m(void 0,!0),fit:m("fit"),aspect:m(),mask:ae("mask"),overlay:{kind:"value",value:"textColor"},alt:Y(),decorative:m(!1)},icon:{name:m(void 0,!0),color:N("accent"),size:m(24)},video:{src:m(void 0,!0),poster:m(),autoplay:m(!0),loop:m(!0),mute:m(!0),controls:m(!1),fit:m("fill"),aspect:m(),alt:Y()},button:{action:ae("action",!0),content:at(!0)},purchase_button:{content:at(!0),package:m()},package:{product:m(void 0,!0),plan:m(void 0,!0),selected:m(!1),children:Le},tabs:{},switch:{},carousel:{pages:Le,peek:m(0),spacing:m(8),loop:m(!1),auto_advance_ms:m(),indicator:ae("indicator"),height:m("")},countdown:{},timeline:{items:Ee("timeline_item",!0),line_color:N("accent"),line_width:m(2),icon_color:N("on_accent"),color:N("text"),spacing:m(16)},features:{items:Ee("feature",!0),icon_color:N("accent"),color:N("text"),spacing:m(12)},spacer:{size:it()},divider:{color:N("muted"),thickness:m(1)},custom_html:{src:m(void 0,!0),height:m("",!0)}},ee={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:m(""),height:m(""),max_width:m(),background:{kind:"fill"},border:ae("border"),corners:{kind:"corners"},shadow:ae("shadow"),opacity:m(1)},border:{width:m(),color:N("")},shadow:{color:N(""),radius:m(0),x:m(0),y:m(0)},linear:{type:m(""),angle:m(180),stops:m()},radial:{type:m(""),center_x:m(.5),center_y:m(.5),radius:m(.5),stops:m()},image_fill:{type:m(""),src:m(),fit:m("fill")},video_fill:{type:m(""),src:m(),poster:m(),loop:m(!0)},animation:{type:m(""),duration_ms:m(300),delay_ms:m(0),easing:m("ease_out")},action:{type:m(""),url:m(),sheet:m(),package:m()},mask:{shape:m(""),radius:sn(0),depth:m(16)},span:{text:Y(!0),bold:m(!1),italic:m(!1),underline:m(!1),strikethrough:m(!1),color:N(""),link:m()},timeline_item:{icon:m(void 0,!0),title:Y(!0),text:Y(),color:N("")},feature:{icon:m(void 0,!0),text:Y(!0)},indicator:{style:m("dots"),color:N("muted"),active_color:N("accent"),size:m(8),spacing:m(6)},typography:{font:m("system"),size:m(),weight:m(400),line_height:m(),letter_spacing:m(0),text_style:m("body")}},rn={linear:"linear",radial:"radial",image:"image_fill",video:"video_fill"},on=["top","bottom","leading","trailing"],an=["top_leading","top_trailing","bottom_leading","bottom_trailing"],Fn=Object.keys(lt),ln=/\{\{\s*([^{}]*?)\s*\}\}/g,te=(s,t)=>typeof s=="object"&&s!==null&&Object.hasOwn(s,t),S=s=>typeof s=="object"&&s!==null&&!Array.isArray(s)?s:{},J=s=>Array.isArray(s)?s:[],X=(s,t)=>s??t;function cn(s){let t=Math.floor(s/86400),n=Math.floor(s%86400/3600),i=Math.floor(s%3600/60),p=s%60,l=y=>String(y).padStart(2,"0");return{countdown:t>0?`${t}d ${l(n)}:${l(i)}:${l(p)}`:n>0?`${n}:${l(i)}:${l(p)}`:`${l(i)}:${l(p)}`,days:String(t),hours:l(n),minutes:l(i),seconds:l(p)}}function ct(s){let t=[],n=p=>{if(Array.isArray(p))return p.forEach(n);if(typeof p!="object"||p===null)return;let l=p;if(l.type==="package"&&typeof l.product=="string"&&typeof l.plan=="string"){let f=`${l.product}.${l.plan}`;t.includes(f)||t.push(f)}for(let f of Object.keys(l).sort())n(l[f])},i=s;for(let p of["header","root","footer"])n(i[p]);for(let p of Object.keys(S(i.sheets)).sort())n(S(S(i.sheets)[p]).root);return t}function Cn(s,t){return new ge(s,t).resolve().tree}function dt(s,t){return new ge(s,t).resolve()}var ge=class{d;opts;lang;texts={};palette;typography={};radii;spacing;packages;selected="";tab="";paths=new WeakMap;tabsShown={};switchesOn={};countdowns={};constructor(t,n){this.d=t,this.opts=n,this.packages=n.packages;let i=S(this.d.locales),p=String(this.d.default_locale??""),l=n.locale;te(i,l)||(l=l.split("-")[0]??"",te(i,l)||(l=p)),this.lang=l;for(let y of[p,l])for(let[g,h]of Object.entries(S(i[y])))typeof h=="string"&&(this.texts[g]=h);let f=S(this.d.theme);this.palette=S(S(f.colors)[n.appearance]);for(let[y,g]of Object.entries(S(f.typography))){let h={};for(let[w,v]of Object.entries(ee.typography)){let A=X(S(g)[w],v.def);A!=null&&(h[w]=A)}this.typography[y]=h}this.radii=S(f.radii),this.spacing=S(f.spacing)}resolve(){let[t,n]=this.initialState();this.tab=t,this.selected=n;let i={selected:n,theme:{colors:this.palette,typography:this.typography,radii:this.radii,spacing:this.spacing}};for(let l of["header","root","footer"]){let f=this.d[l];if(typeof f=="object"&&f!==null){let y=this.component(S(f),l,"",!1);y&&(i[l]=y)}}let p={};if(typeof this.d.sheets=="object"&&this.d.sheets!==null){let l={};for(let[f,y]of Object.entries(S(this.d.sheets))){let g=this.component(S(S(y).root),`sheets.${f}.root`,"",!1);g&&(l[f]=g);let h=this.text(S(y).title,this.packages[this.selected]);h!==null&&(p[f]=h)}i.sheets=l}return{tree:i,pathOf:l=>this.paths.get(l),tabs:this.tabsShown,switches:this.switchesOn,sheetTitles:p,countdowns:this.countdowns,language:this.lang}}switchOn(t,n){return this.opts.switches&&Object.hasOwn(this.opts.switches,n)?this.opts.switches[n]:this.opts.switch?this.opts.switch==="on":t.default===!0}tabShown(t,n){let p=J(t.tabs).map(S).map(f=>String(f.id)),l=this.opts.tabs?.[n];return l!==void 0&&p.includes(l)?l:this.opts.tab?this.opts.tab:typeof t.default=="string"&&t.default!==""?t.default:p[0]??""}initialState(){let t="",n="",i="",p="",l=(y,g)=>{if(Array.isArray(y)){y.forEach((w,v)=>l(w,`${g}[${v}]`));return}if(typeof y!="object"||y===null)return;let h=y;switch(h.type){case"package":{let w=`${h.product}.${h.plan}`;i===""&&(i=w),h.selected===!0&&n===""&&(n=w);break}case"switch":{let w=this.switchOn(h,g),v=w?h.on_package:h.off_package;typeof v=="string"&&p===""&&(p=v),l(w?h.on:h.off,`${g}.${w?"on":"off"}`);return}case"tabs":{let w=this.tabShown(h,g);t===""&&(t=w),J(h.tabs).forEach((v,A)=>{let x=S(v);x.id===w&&(typeof x.package=="string"&&p===""&&(p=x.package),l(x.content,`${g}.tabs[${A}].content`))});return}}for(let w of Object.keys(h).sort())w!=="sheets"&&l(h[w],g===""?w:`${g}.${w}`)};for(let y of["header","root","footer"])l(this.d[y],y);let f=this.opts.selected||p||n||i;return[t,f]}holds(t,n){let i=n||this.selected;for(let[p,l]of Object.entries(t))switch(p){case"selected_package":if(!J(l).includes(this.selected))return!1;break;case"intro_eligible":if((this.opts.eligible??[]).includes(i)!==l)return!1;break;case"platform":if(!J(l).includes(this.opts.platform))return!1;break;case"locale":if(!J(l).includes(this.opts.locale)&&!J(l).includes(this.lang))return!1;break;case"appearance":if(l!==this.opts.appearance)return!1;break;case"tab":if(l!==this.tab)return!1;break}return!0}component(t,n,i,p){if(typeof t.visible=="object"&&t.visible!==null&&!this.holds(S(t.visible),i))return null;let l=String(t.type),f=i,y=p;l==="package"&&(f=`${t.product}.${t.plan}`,y=f===this.selected);let g={type:l};this.paths.set(g,n),te(t,"id")&&(g.id=t.id);let h={...S(t.style)};y&&Object.assign(h,S(S(t.states).selected)),Object.keys(h).length>0&&(g.style=this.style(h)),typeof t.animation=="object"&&t.animation!==null&&(g.animation=this.defaults(S(t.animation),ee.animation));let w=this.packages[f||this.selected];switch(l){case"tabs":return this.tabs(t,g,n,f);case"switch":return this.switchOf(t,g,n,f,y);case"countdown":return this.countdown(t,g,n,f,y);case"purchase_button":{let v=typeof t.package=="string"?t.package:this.selected;g.package=v;let A=this.component(S(t.content),`${n}.content`,v,y);return A?(g.content=A,g):null}case"package":g.product=t.product,g.plan=t.plan,g.selected=y}for(let[v,A]of Object.entries(lt[l]??{})){if(l==="package"&&(v==="product"||v==="plan"||v==="selected"))continue;let x=t[v],R=te(t,v);switch(A.kind){case"component":{if(!R)continue;let b=this.component(S(x),`${n}.${v}`,f,y);if(!b&&A.required)return null;b&&(g[v]=b);break}case"components":{let b=[];J(x).forEach((T,C)=>{let K=this.component(S(T),`${n}.${v}[${C}]`,f,y);K&&b.push(K)}),g[v]=b;break}case"text":{let b=this.text(x,w);if(b!==null)g[v]=b;else if(A.required||l==="text"&&v==="text"&&R)return null;break}case"list":{let b=[];for(let T of J(x)){let C=this.item(A.item,S(T),w);C&&b.push(C)}if(l==="text"&&b.length===0&&R)return null;R&&(g[v]=b);break}case"object":{R?g[v]=this.object(S(x),A.item,w):v==="indicator"&&(g[v]=this.object({},A.item,w));break}case"value":{let b=this.value(X(x,A.def),A);b!=null&&b!==""&&(g[v]=b);break}}}return l==="text"&&this.typeStyle(g),g}typeStyle(t){if(typeof t.size!="string"){t.size!==void 0&&t.size!==null&&(t.text_style="body");return}let n=this.typography[t.size];for(let i of["font","weight","line_height","letter_spacing","text_style"])!te(t,i)&&n?.[i]!==void 0&&n?.[i]!==null&&(t[i]=n[i]);t.size=n?.size??null}tabs(t,n,i,p){let l=this.tabShown(t,i);this.tabsShown[i]=l;let f=[];return J(t.tabs).forEach((y,g)=>{let h=S(y),w=h.id===l,v=this.component(S(h.label),`${i}.tabs[${g}].label`,p,w);if(f.push({id:h.id,selected:w,label:v}),w){let A=this.component(S(h.content),`${i}.tabs[${g}].content`,p,!1);A&&(n.content=A)}}),n.tabs=f,typeof t.bar=="object"&&t.bar!==null&&(n.bar=this.style(S(t.bar))),n}switchOf(t,n,i,p,l){let f=this.switchOn(t,i);this.switchesOn[i]=f,n.on=f;let y=this.text(t.label,this.packages[p||this.selected]);y!==null&&(n.label=y),n.tint=this.color(String(X(t.tint,"accent")));let g=f?"on":"off",h=this.component(S(t[g]),`${i}.${g}`,p,l);return h&&(n.content=h),n}countdown(t,n,i,p,l){let f=S(t.target),y=this.opts.now??Date.now(),g;if(typeof f.after_open_seconds=="number"?g=Math.trunc(f.after_open_seconds)-(this.opts.openedSecondsAgo??0):g=Math.trunc((Date.parse(String(f.at))-y)/1e3),g>0){n.state="counting",n.remaining_seconds=g,this.countdowns[i]=g;let h=this.packages,w={};for(let[A,x]of Object.entries(h))w[A]={...x,...cn(g)};this.packages=w;let v=this.component(S(t.counting),`${i}.counting`,p,l);return v&&(n.content=v),this.packages=h,n}if(n.state="ended",n.remaining_seconds=0,typeof t.ended=="object"&&t.ended!==null){let h=this.component(S(t.ended),`${i}.ended`,p,l);h&&(n.content=h)}return n}item(t,n,i){let p={};for(let[l,f]of Object.entries(ee[t]??{})){let y=n[l];if(f.kind==="text"){let g=this.text(y,i);if(g!==null)p[l]=g;else if(f.required)return null}else{let g=f.def,h=this.value(X(y,g),f);h!=null&&(te(n,l)||g!=null&&g!=="")&&(p[l]=h)}}return p}object(t,n,i){return n==="style"?this.style(t):this.item(n,t,i)??{}}defaults(t,n){let i={};for(let[p,l]of Object.entries(n)){let f=X(t[p],l.def);f!=null&&f!==""&&(i[p]=f)}return i}style(t){let n={};for(let[i,p]of Object.entries(t)){let l=ee.style[i];if(!l){n[i]=p;continue}switch(l.kind){case"edges":n[i]=this.sides(p,on,this.spacing);break;case"corners":n[i]=this.sides(p,an,this.radii);break;case"fill":n[i]=this.fill(p);break;case"object":{let f=S(p),y={};for(let[g,h]of Object.entries(ee[l.item]??{})){let w=X(f[g],h.def);w!=null&&w!==""&&(y[g]=this.value(w,h))}n[i]=y;break}default:n[i]=p}}return n}sides(t,n,i){let p={};for(let l of n){let f=typeof t=="object"&&t!==null?X(S(t)[l],0):t;p[l]=$e(f,i)}return p}fill(t){if(typeof t=="string")return{type:"color",color:this.color(t)};let n=S(t),i=this.defaults(n,ee[rn[String(n.type)]??""]??{});return Array.isArray(n.stops)&&(i.stops=n.stops.map(p=>({color:this.color(String(S(p).color)),at:S(p).at}))),i}value(t,n){if(n.kind!=="value")return t;switch(n.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 $e(t,this.spacing);case"radius":return $e(t,this.radii);default:return t}}color(t){let n=Object.hasOwn(this.palette,t)?this.palette[t]:void 0;return typeof n=="string"?n:t}text(t,n){let i;if(typeof t=="string")i=t;else if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let l=t.t;i=typeof l=="string"&&Object.hasOwn(this.texts,l)?this.texts[l]:""}else return null;let p=!1;return i=i.replace(ln,(l,f)=>{let y=n&&Object.hasOwn(n,f)?n[f]:void 0;return typeof y!="string"||y===""?(p=!0,""):y}),p||i.trim()===""?null:i}};function $e(s,t){return typeof s=="string"?Object.hasOwn(t,s)?t[s]:null:s}var dn={packages:"Choose a plan",close:"Close",restore:"Restore purchases",page:(s,t)=>`${s} of ${t}`},ne={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'},pn=1.35,pt=20,un=new Set(["button","purchase_button","package","text"]),fn=new Set(["ar","he","fa","ur","ps","yi","dv","ug","ku","sd"]),ut={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)"},gn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},hn={start:"flex-start",center:"center",end:"flex-end",space_between:"space-between",space_around:"space-around",space_evenly:"space-evenly"},yn={stack:["children"],package:["children"],button:["content"],purchase_button:["content"],tabs:["tabs","content"],switch:["content"],carousel:["pages"],countdown:["content"]},mn={package:["selected"],purchase_button:["package"],switch:["on"],countdown:["state","remaining_seconds"]},wn=`
|
|
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:${ne.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{padding-left:env(safe-area-inset-left,0px);padding-right:env(safe-area-inset-right,0px)}
|
|
14
|
-
.pw2-head,.pw2-body.pw2-top{padding-top:env(safe-area-inset-top,0px)}
|
|
15
|
-
.pw2-foot,.pw2-body.pw2-bottom{padding-bottom:env(safe-area-inset-bottom,0px)}
|
|
16
|
-
.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}
|
|
17
|
-
.pw2-body::-webkit-scrollbar{display:none}
|
|
18
|
-
.pw2-body>.pw-c{flex:1 0 auto}
|
|
19
|
-
.pw-c{position:relative;min-width:0}
|
|
20
|
-
.pw-c[style*="--pw-bw"]{isolation:isolate}
|
|
21
|
-
.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}
|
|
22
|
-
.pw-stack{display:flex;flex-direction:column}
|
|
23
|
-
.pw-stack.h{flex-direction:row}
|
|
24
|
-
.pw-stack.z{display:grid}
|
|
25
|
-
.pw-stack.z>.pw-c{grid-area:1/1}
|
|
26
|
-
.pw-stack.scroll{overflow-y:auto;scrollbar-width:none}
|
|
27
|
-
.pw-stack.h.scroll{overflow-x:auto;overflow-y:hidden}
|
|
28
|
-
.pw-stack.scroll>.pw-c{flex-shrink:0}
|
|
29
|
-
.pw-text{margin:0;overflow-wrap:break-word;white-space:pre-line}
|
|
30
|
-
/* A text beside others wraps between its words, never inside one: a price stays whole, what is beside it wraps. */
|
|
31
|
-
.pw-stack.h>.pw-text{min-width:min-content}
|
|
32
|
-
.pw-text a{color:inherit}
|
|
33
|
-
.pw-clamp{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}
|
|
34
|
-
.pw-grad{-webkit-background-clip:text;background-clip:text;color:transparent!important;-webkit-text-fill-color:transparent}
|
|
35
|
-
.pw-icon{display:inline-flex;flex:none}
|
|
36
|
-
.pw-icon svg{display:block}
|
|
37
|
-
.pw-img{overflow:hidden;flex:none}
|
|
38
|
-
.pw-img img,.pw-img video{display:block;width:100%;height:100%}
|
|
39
|
-
.pw-img.natural img{height:auto}
|
|
40
|
-
.pw-overlay{position:absolute;inset:0;pointer-events:none}
|
|
41
|
-
.pw-bgvideo{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:-1;pointer-events:none}
|
|
42
|
-
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}
|
|
43
|
-
button.pw-c:active{transform:scale(.98)}
|
|
44
|
-
button.pw-c:disabled{cursor:default;opacity:.5}
|
|
45
|
-
.pw-pkg{cursor:pointer;display:flex;flex-direction:column;transition:background-color .2s ease,border-color .2s ease,box-shadow .2s ease}
|
|
46
|
-
.pw-pkg[aria-disabled=true]{cursor:default;opacity:.55}
|
|
47
|
-
:focus-visible{outline:2px solid currentColor;outline-offset:2px}
|
|
48
|
-
.pw-features{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
|
|
49
|
-
.pw-feature{display:flex;align-items:center;gap:12px;text-align:start}
|
|
50
|
-
.pw-timeline{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
|
|
51
|
-
.pw-step{display:grid;grid-template-columns:auto 1fr;column-gap:14px;position:relative;text-align:start}
|
|
52
|
-
.pw-dot{width:32px;height:32px;border-radius:50%;display:grid;place-items:center;position:relative;z-index:1}
|
|
53
|
-
.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))}
|
|
54
|
-
.pw-step:last-child .pw-line{display:none}
|
|
55
|
-
.pw-step-title{font-weight:600}
|
|
56
|
-
.pw-step-text{opacity:.72;font-size:.9375rem;margin-top:2px}
|
|
57
|
-
.pw-tabs{display:flex;flex-direction:column;gap:12px}
|
|
58
|
-
.pw-tablist{display:flex}
|
|
59
|
-
.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}
|
|
60
|
-
.pw-tab>.pw-c{flex:1 1 auto}
|
|
61
|
-
.pw-switch{display:flex;flex-direction:column;gap:12px}
|
|
62
|
-
.pw-switchcontent{display:flex;flex-direction:column}
|
|
63
|
-
.pw-switchrow{display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:start}
|
|
64
|
-
.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}
|
|
65
|
-
.pw-toggle[aria-checked=true]{background:var(--pw-tint)}
|
|
66
|
-
.pw-toggle i{display:block;width:27px;height:27px;border-radius:50%;background:#fff;box-shadow:0 2px 4px #0003;transition:transform .2s ease}
|
|
67
|
-
.pw-toggle[aria-checked=true] i{transform:translateX(20px)}
|
|
68
|
-
.pw-carousel{display:flex;flex-direction:column;gap:12px;min-width:0}
|
|
69
|
-
.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)}
|
|
70
|
-
.pw-track::-webkit-scrollbar{display:none}
|
|
71
|
-
.pw-track>.pw-c{flex:none;width:100%;scroll-snap-align:center}
|
|
72
|
-
.pw-dots{display:flex;justify-content:center;gap:var(--pw-dot-gap)}
|
|
73
|
-
.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}
|
|
74
|
-
.pw-dots.bars button{width:calc(var(--pw-dot) * 3)}
|
|
75
|
-
.pw-dots button[aria-current=true]{background:var(--pw-dot-on)}
|
|
76
|
-
.pw-dots.dots button[aria-current=true]{width:calc(var(--pw-dot) * 2.5)}
|
|
77
|
-
.pw-html{display:block;width:100%;border:0;pointer-events:none;background:transparent}
|
|
78
|
-
.pw-spacer{flex:1 1 0}
|
|
79
|
-
.pw-stack:not(.h):not(.z)>.greedy-h,.pw-pkg>.greedy-h,button.pw-c>.greedy-h{align-self:stretch}
|
|
80
|
-
.pw-stack.h>.greedy-h{flex:1 1 0}
|
|
81
|
-
.pw-stack.z>.greedy-h{justify-self:stretch}
|
|
82
|
-
.pw-stack:not(.h):not(.z)>.greedy-v,.pw-pkg>.greedy-v{flex:1 1 auto}
|
|
83
|
-
.pw-stack.h>.greedy-v,.pw-stack.z>.greedy-v{align-self:stretch}
|
|
84
|
-
.pw-layer{position:absolute;inset:0;z-index:5;display:flex;flex-direction:column;justify-content:flex-end;background:#0007}
|
|
85
|
-
.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)}
|
|
86
|
-
.pw-sheet>.pw-c{flex:1 0 auto}
|
|
87
|
-
.pw-grab{width:36px;height:5px;border-radius:3px;background:currentColor;opacity:.25;margin:8px auto 0;flex:none}
|
|
88
|
-
[data-pw-highlight]{outline:2px solid #2E7CF6!important;outline-offset:-1px}
|
|
89
|
-
[data-pw-hover]:not([data-pw-highlight]){outline:1px dashed #2E7CF6aa!important;outline-offset:-1px}
|
|
90
|
-
.pw-editing button,.pw-editing .pw-pkg,.pw-editing a{cursor:default}
|
|
91
|
-
@media (prefers-reduced-motion:reduce){.pw2 *{transition:none!important;scroll-behavior:auto!important}}
|
|
92
|
-
`,ye=s=>{if(typeof s!="string"||s.length>2048)return!1;try{let t=new URL(s);return t.protocol==="https:"&&t.hostname!==""&&t.username===""&&t.password===""}catch{return!1}},bn=s=>`${String(s.product)}.${String(s.plan)}`,Te=s=>{let[t,n]=s.split(".");return{product:t??"",plan:n??""}},_=s=>`${Number(s)||0}px`,ft=s=>`${s/16}rem`,vn=0;function gt(s,t,n){let i=s.ownerDocument,p=i.defaultView,l=`pw${++vn}`,f=i.createElement("div");f.setAttribute("data-palbase-paywall",""),f.style.display="block",f.style.height="100%";let y=f.attachShadow({mode:"open"});kn(i,y,wn);let g=i.createElement("div");g.className="pw2";let h=i.createElement("div");h.className="pw2-head";let w=i.createElement("div");w.className="pw2-body";let v=i.createElement("div");v.className="pw2-foot";let A=i.createElement("div");g.append(h,w,v),y.append(g),s.replaceChildren(f);let x={...t},R={openedAt:Date.now(),...t.state},b,T=new Map,C=new Map,K=!1,be=null,ve,Oe=!1,Fe=i.defaultView?.ResizeObserver,Ce=typeof Fe=="function"?new Fe(()=>{g.classList.toggle("pw2-large",Ne()>=pt),xe()}):null;Ce?.observe(g);let He=()=>xe();i.fonts?.addEventListener?.("loadingdone",He);let je=null,ke=p?.matchMedia?.("(prefers-reduced-motion: reduce)"),re=()=>x.reduceMotion??ke?.matches??!1,H=()=>!!n.editor,le={...dn,...n.labels};function G(){let e=R.now??Date.now();b=dt(x.definition,{locale:x.locale,appearance:x.appearance,platform:x.platform??"web",packages:x.packages,eligible:x.eligible??[],...R.selected?{selected:R.selected}:{},tabs:R.tabs??{},switches:R.switches??{},openedSecondsAgo:Math.max(0,Math.floor((e-(R.openedAt??e))/1e3)),now:e});let c=b.tree.theme.colors;g.style.background=c.background??"",g.style.color=c.text??"",g.classList.toggle("pw-editing",H()),g.classList.toggle("pw2-large",Ne()>=pt),g.lang=b.language,g.dir=fn.has(b.language.split("-")[0]??"")?"rtl":"ltr",C=new Map,Pe(h,b.tree.header,"vertical"),Pe(w,b.tree.root,"vertical"),Pe(v,b.tree.footer,"vertical"),h.hidden=!b.tree.header,v.hidden=!b.tree.footer,w.classList.toggle("pw2-top",!b.tree.header),w.classList.toggle("pw2-bottom",!b.tree.footer),Nt();for(let[o,r]of T)C.has(o)||r.cleanup.forEach(a=>a());T=C,be&&We(be);for(let o of T.values())o.type==="custom_html"&&qe(o.el);xe(),clearTimeout(ve),Oe||=f.isConnected,R.now===void 0&&Object.keys(b.countdowns).length>0&&(ve=setTimeout(()=>{Oe&&!f.isConnected||G()},1e3-Date.now()%1e3+5))}function Ne(){let e=i.documentElement,c=e&&p?parseFloat(p.getComputedStyle(e).fontSize):NaN;return Number.isFinite(c)?c:16}function xe(){let e=[];for(let o of T.values()){if(o.type!=="text")continue;let r=o.el,a=r.dataset.pwFit??r.style.fontSize;if(!a||(r.style.fontSize=a,delete r.dataset.pwFit,!/^\S+$/.test(r.textContent??"")))continue;let d=r.parentElement,u=d&&p?p.getComputedStyle(d):null,k=d&&u?d.clientWidth-parseFloat(u.paddingLeft||"0")-parseFloat(u.paddingRight||"0"):1/0,M=Math.min(r.clientWidth,k);e.push({e:r,base:a,k:M<=0||r.scrollWidth<=M+.5?1:Math.max(.6,M/r.scrollWidth)})}let c=o=>o.closest(".pw-stack.h");for(let o of e){let r=Math.min(o.k,...e.filter(a=>a!==o&&a.base===o.base&&c(a.e)&&c(a.e)===c(o.e)).map(a=>a.k));r>=1||(o.e.dataset.pwFit=o.base,o.e.style.fontSize=`calc(${o.base} * ${r.toFixed(3)})`)}}function Pe(e,c,o){let r=c?U(c,o,{inControl:!1,inSheet:!1,inFooter:e===v}):null;V(e,r?[r]:[])}function U(e,c,o){let r=b.pathOf(e)??"",a=vt(e),d=T.get(r),u;if(d&&d.type===e.type&&d.key===a&&d.axis===c&&!C.has(r))u=d;else{let M=xt(e,r,c,o);if(!M)return null;u={el:M.el,type:e.type,key:a,styleKey:"",axis:c,slots:M.slots,cleanup:M.cleanup??[]},u.el.classList.add("pw-c"),u.el.dataset.pwPath=r,u.el.dataset.pwType=e.type,e.id&&(u.el.dataset.pwId=e.id),d&&d.cleanup.forEach(L=>L()),Ot(u.el,e)}let k=`${JSON.stringify(e.style??null)}|${c}`;return u.styleKey!==k&&(De(u.el,e,c),u.styleKey=k),C.set(r,u),$t(u,e),Tt(u,e,o),u.el}function vt(e){let c=new Set(["style",...yn[e.type]??[],...mn[e.type]??[]]),o={};for(let[r,a]of Object.entries(e))c.has(r)||(o[r]=a);return e.type==="tabs"&&(o.tabs=e.tabs.map(r=>r.id)),e.type==="carousel"&&(o.pages=e.pages.length),e.type==="stack"&&(o.greedy=e.children.some(r=>r.type==="spacer"&&typeof r.size!="number")),(e.type==="image"||e.type==="video"||e.type==="custom_html")&&(o.asset=kt(e)),JSON.stringify(o)}function kt(e){let c=ie(e.src);return c?(x.assets?.[c]?.url??x.assets?.[c]?.html?.length??"none").toString():""}function P(e,c){let o=i.createElement(e);return c&&(o.className=c),o}function xt(e,c,o,r){let a=e;switch(e.type){case"stack":{let d=P("div",`pw-stack${a.axis==="horizontal"?" h":a.axis==="z"?" z":""}${a.scroll?" scroll":""}`);return a.axis!=="z"&&a.children.some(u=>u.type==="spacer"&&typeof u.size!="number")&&d.classList.add(a.axis==="horizontal"?"greedy-h":"greedy-v"),d.style.gap=_(a.spacing),a.axis==="z"?d.style.placeItems=a.align==="stretch"?"stretch":String(a.align??"center"):(d.style.alignItems=gn[String(a.align)]??"center",d.style.justifyContent=hn[String(a.distribution)]??"flex-start"),{el:d,slots:{children:d}}}case"text":return{el:Pt(a,r),slots:{}};case"icon":{let d=ue[String(a.name)];if(!d)return null;let u=P("span","pw-icon");return u.style.color=String(a.color??""),u.append(fe(i,d,Number(a.size)||24)),u.setAttribute("aria-hidden","true"),{el:u,slots:{}}}case"image":return Mt(a);case"video":return St(a);case"features":{let d=P("ul","pw-features");d.style.gap=_(a.spacing);for(let u of a.items??[]){let k=P("li","pw-feature"),M=ue[u.icon];if(M){let z=fe(i,M,22);z.style.color=String(a.icon_color),z.style.flex="none",k.append(z)}let L=P("span");L.textContent=u.text,L.style.color=String(a.color),k.append(L),d.append(k)}return{el:d,slots:{}}}case"timeline":{let d=P("ol","pw-timeline");d.style.gap=_(a.spacing),d.style.setProperty("--pw-gap",_(a.spacing)),d.style.setProperty("--pw-line-w",_(a.line_width));for(let u of a.items??[]){let k=P("li","pw-step"),M=P("span","pw-dot");M.style.background=u.color??String(a.line_color),M.style.color=String(a.icon_color);let L=ue[u.icon];L&&M.append(fe(i,L,18)),M.setAttribute("aria-hidden","true");let z=P("span","pw-line");z.style.background=String(a.line_color),z.setAttribute("aria-hidden","true");let D=P("span");D.style.color=String(a.color);let B=P("span","pw-step-title");if(B.textContent=u.title,D.append(B),u.text){let $=P("span","pw-step-text");$.style.display="block",$.textContent=u.text,D.append($)}k.append(M,D,z),d.append(k)}return{el:d,slots:{}}}case"spacer":{let d=P("div","pw-spacer");return d.setAttribute("aria-hidden","true"),typeof a.size=="number"&&(d.style.flex="none",o==="horizontal"?d.style.width=_(a.size):d.style.height=_(a.size)),{el:d,slots:{}}}case"divider":{let d=P("div","pw-divider");return d.setAttribute("role","separator"),d.style.background=String(a.color),d.style.alignSelf="stretch",d.style.flex="none",o==="horizontal"?(d.setAttribute("aria-orientation","vertical"),d.style.width=_(a.thickness)):d.style.height=_(a.thickness),{el:d,slots:{}}}case"button":return Rt(a,r);case"purchase_button":{let d=P("button","pw-buy");return d.type="button",d.addEventListener("click",()=>{Ve(d,()=>jt(d.dataset.package??""))}),{el:d,slots:{content:d}}}case"package":{let d=P("div","pw-pkg");return d.setAttribute("role","radio"),d.addEventListener("click",()=>Re(d)),d.addEventListener("keydown",u=>Ft(u,d)),{el:d,slots:{children:d}}}case"tabs":return _t(a,c);case"switch":return Et(a,c);case"carousel":return Lt(a);case"countdown":{let d=P("div","pw-countdown");return d.setAttribute("role","timer"),d.setAttribute("aria-live","off"),{el:d,slots:{content:d}}}case"custom_html":{let d=x.assets?.[ie(a.src)??""];if(!d?.html)return null;let u=P("iframe","pw-html");return u.setAttribute("sandbox","allow-scripts"),u.setAttribute("aria-hidden","true"),u.setAttribute("title",""),u.tabIndex=-1,u.srcdoc=d.html,typeof a.height=="number"?u.style.height=_(a.height):typeof a.height=="string"&&a.height.endsWith("%")?u.style.height=a.height:a.height==="fill"&&(u.style.flex="1 1 0"),u.addEventListener("load",()=>qe(u)),{el:u,slots:{}}}default:return null}}function Pt(e,c){let o=String(e.text_style??"body"),r=c.inControl?"span":o==="large_title"?"h1":o==="title"||o==="title2"?"h2":o==="title3"?"h3":"p",a=P(r,"pw-text");c.inControl&&(a.style.display="block"),a.style.fontFamily=At(e.font);let d=typeof e.size=="number"?e.size:16;if(c.inFooter?(a.style.setProperty("--pw-fs",ft(d)),a.style.setProperty("--pw-fs-max",`${Number((d*pn).toFixed(2))}px`)):a.style.fontSize=ft(d),typeof e.weight=="number"&&(a.style.fontWeight=String(e.weight)),typeof e.line_height=="number"&&(a.style.lineHeight=String(e.line_height)),typeof e.letter_spacing=="number"&&e.letter_spacing!==0&&(a.style.letterSpacing=_(e.letter_spacing)),a.style.textAlign=String(e.align??"center"),e.uppercase===!0&&(a.style.textTransform="uppercase"),typeof e.max_lines=="number"&&(a.classList.add("pw-clamp"),a.style.setProperty("-webkit-line-clamp",String(e.max_lines))),typeof e.color=="string"?a.style.color=e.color:e.color&&typeof e.color=="object"&&(a.classList.add("pw-grad"),a.style.backgroundImage=Me(e.color)??""),Array.isArray(e.spans))for(let u of e.spans){let k=u.link==="terms"?x.links?.terms:u.link==="privacy"?x.links?.privacy:u.link,M=ye(k)&&!c.inControl,L=P(M?"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),M&&ye(k)&&(L.href=k,L.target="_blank",L.rel="noopener noreferrer",L.addEventListener("click",D=>{H()||!n.onLink||(D.preventDefault(),n.onLink(k))})),a.append(L)}else a.textContent=String(e.text??"");return a}function At(e){if(typeof e!="string")return ne.system;let c=ie(e);if(c){let o=x.assets?.[c]?.family;return o?`"${o}", ${ne.system}`:ne.system}return ne[e]??ne.system}function Z(e){let c=ie(e);return c?x.assets?.[c]?.url||void 0:ye(e)?e:void 0}function Mt(e){let c=P("div","pw-img");typeof e.aspect=="number"&&(c.style.aspectRatio=String(e.aspect));let o=Z(e.src),r=e.mask;if(r?.shape==="circle")c.style.borderRadius="50%";else if(r?.shape==="rect"&&r.radius)c.style.borderRadius=_(r.radius);else if(r?.shape==="convex")c.style.setProperty("border-end-start-radius",`50% ${_(r.depth)}`),c.style.setProperty("border-end-end-radius",`50% ${_(r.depth)}`);else if(r?.shape==="concave"){let a=`radial-gradient(ellipse 50% ${_(r.depth)} at 50% 100%, transparent 98%, #000 100%)`;c.style.setProperty("-webkit-mask-image",a),c.style.setProperty("mask-image",a)}if(o){let a=P("img");a.src=o,a.decoding="async",a.style.objectFit=e.fit==="fill"?"cover":"contain",e.decorative===!0?(a.alt="",c.setAttribute("aria-hidden","true")):a.alt=String(e.alt??""),a.addEventListener("error",()=>a.style.visibility="hidden"),c.append(a)}if(e.overlay&&typeof e.overlay=="object"){let a=P("div","pw-overlay");a.style.backgroundImage=Me(e.overlay)??"",c.append(a)}return{el:c,slots:{}}}function St(e){let c=P("div","pw-img");typeof e.aspect=="number"&&(c.style.aspectRatio=String(e.aspect));let o=Z(e.src);if(o){let r=P("video");r.src=o;let a=Z(e.poster);a&&(r.poster=a),r.muted=e.mute!==!1,r.loop=e.loop!==!1,r.playsInline=!0,r.controls=e.controls===!0,r.preload="auto",r.style.objectFit=e.fit==="fit"?"contain":"cover",r.autoplay=e.autoplay!==!1&&!re()&&!H(),typeof e.alt=="string"?r.setAttribute("aria-label",e.alt):r.setAttribute("aria-hidden","true"),c.append(r)}return{el:c,slots:{}}}function Rt(e,c){let o=e.action??{},r,a=o.type==="restore"||o.type==="offer_code";switch(o.type){case"close":c.inSheet?r=()=>pe(null):n.onClose&&(r=()=>n.onClose());break;case"restore":n.onRestore&&(r=()=>n.onRestore());break;case"offer_code":n.onOfferCode&&(x.platform??"web")!=="web"&&(r=()=>n.onOfferCode());break;case"open_url":case"terms":case"privacy":{let u=o.type==="open_url"?o.url:o.type==="terms"?x.links?.terms:x.links?.privacy;ye(u)&&(r=()=>n.onLink?n.onLink(u):void p?.open(u,"_blank","noopener,noreferrer"));break}case"sheet":o.sheet&&(r=()=>pe(o.sheet));break;case"select_package":o.package&&(r=()=>Se(o.package));break}if(!r&&!H())return null;let d=P("button");return d.type="button",o.type==="close"&&d.setAttribute("aria-label",le.close),d.addEventListener("click",()=>{!r||H()||(a?Ve(d,r):r())}),{el:d,slots:{content:d}}}function _t(e,c){let o=P("div","pw-tabs"),r=P("div","pw-tablist");r.setAttribute("role","tablist");let a=P("div","pw-tabpanel");a.setAttribute("role","tabpanel"),a.id=`${l}-${c}-panel`;let d={content:a},u=e.tabs.map(k=>k.id);return u.forEach((k,M)=>{let L=P("button","pw-tab");L.type="button",L.setAttribute("role","tab"),L.id=`${l}-${c}-tab-${M}`,L.setAttribute("aria-controls",a.id),L.dataset.tab=k,L.addEventListener("click",()=>Je(c,k)),L.addEventListener("keydown",z=>{let D=z.key==="ArrowRight"?M+1:z.key==="ArrowLeft"?M-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(c,B),r.querySelector(`[data-tab="${B}"]`)?.focus()}),r.append(L),d[`label:${k}`]=L}),o.append(r,a),d.bar=r,{el:o,slots:d}}function Et(e,c){let o=P("div","pw-switch"),r=P("div","pw-switchrow"),a=P("span","pw-switchlabel");a.id=`${l}-${c}-label`;let d=P("button","pw-toggle");d.type="button",d.setAttribute("role","switch"),d.setAttribute("aria-labelledby",a.id),d.append(P("i")),d.addEventListener("click",()=>Ht(c,d.getAttribute("aria-checked")!=="true")),r.append(a,d);let u=P("div","pw-switchcontent");return o.append(r,u),{el:o,slots:{content:u,label:a,toggle:d}}}function Lt(e){let c=P("div","pw-carousel");c.setAttribute("role","region"),c.setAttribute("aria-roledescription","carousel");let o=P("div","pw-track");o.tabIndex=0,o.style.setProperty("--pw-peek",_(e.peek)),o.style.setProperty("--pw-gap",_(e.spacing)),typeof e.height=="number"&&(o.style.minHeight=_(e.height));let r=e.indicator??{},a=P("div",`pw-dots ${r.style??"dots"}`);a.style.setProperty("--pw-dot",_(r.size??8)),a.style.setProperty("--pw-dot-gap",_(r.spacing??6)),a.style.setProperty("--pw-dot-c",r.color??"#8888"),a.style.setProperty("--pw-dot-on",r.active_color??"currentColor"),r.style==="none"&&(a.hidden=!0),c.append(o,a);let d=()=>[...o.children].filter($=>$ instanceof(p?.HTMLElement??HTMLElement)),u=()=>{let $=d(),j=o.scrollLeft+o.clientWidth/2,O=0;return $.forEach((I,It)=>{Math.abs(I.offsetLeft+I.offsetWidth/2-j)<Math.abs(($[O]?.offsetLeft??0)+($[O]?.offsetWidth??0)/2-j)&&(O=It)}),O},k=$=>{let j=d();if(j.length===0)return;let O=e.loop?($+j.length)%j.length:Math.max(0,Math.min(j.length-1,$)),I=j[O];o.scrollTo?.({left:I.offsetLeft-(o.clientWidth-I.offsetWidth)/2,behavior:re()?"auto":"smooth"}),M(O)},M=$=>{[...a.children].forEach((j,O)=>j.setAttribute("aria-current",String(O===$)))};o.addEventListener("scroll",()=>M(u()),{passive:!0}),o.addEventListener("keydown",$=>{$.key!=="ArrowRight"&&$.key!=="ArrowLeft"||($.preventDefault(),k(u()+($.key==="ArrowRight"?1:-1)))});let L=!1,z=()=>L=!0,D=()=>L=!1;c.addEventListener("pointerenter",z),c.addEventListener("pointerleave",D),c.addEventListener("focusin",z),c.addEventListener("focusout",D);let B=[];if(typeof e.auto_advance_ms=="number"){let $=setInterval(()=>{if(L||re()||H())return;let j=d(),O=u();!e.loop&&O>=j.length-1||k(O+1)},e.auto_advance_ms);B.push(()=>clearInterval($))}return c.pwDots=$=>{a.children.length!==$&&(a.replaceChildren(...Array.from({length:$},(j,O)=>{let I=P("button");return I.type="button",I.setAttribute("aria-label",le.page(O+1,$)),I.addEventListener("click",()=>k(O)),I})),M(u()))},{el:c,slots:{pages:o},cleanup:B}}function $t(e,c){let o=c;switch(c.type){case"package":{let r=bn(o),d=!!x.packages[r]?.price;e.el.dataset.package=r,e.el.setAttribute("aria-checked",String(o.selected===!0)),e.el.setAttribute("aria-disabled",String(!d));break}case"purchase_button":{let r=String(o.package);e.el.dataset.package=r,e.el.disabled=K||!x.packages[r]?.price;break}case"switch":{let r=e.slots.toggle;r.setAttribute("aria-checked",String(o.on===!0)),r.style.setProperty("--pw-tint",String(o.tint??"")),r.style.setProperty("--pw-off",`color-mix(in srgb, ${b.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 r of o.tabs){let a=e.slots[`label:${r.id}`];a.setAttribute("aria-selected",String(r.selected)),a.tabIndex=r.selected?0:-1,r.selected&&e.slots.content.setAttribute("aria-labelledby",a.id)}o.bar&&De(e.slots.bar,{type:"stack",style:o.bar},"vertical");break}}}function Tt(e,c,o){let r=c,a={...o,inControl:o.inControl||c.type==="button"||c.type==="purchase_button"||c.type==="package"};switch(c.type){case"stack":case"package":{let d=c.type==="stack"?String(r.axis??"vertical"):"vertical",u=r.children.map(M=>[M,U(M,d,a)]).filter(M=>M[1]!==null),k=u.map(M=>M[1]);V(e.slots.children,k),zt(d,u),c.type==="stack"&&ce(e.el,k);break}case"button":case"purchase_button":{let d=r.content?U(r.content,"vertical",a):null;V(e.slots.content,d?[d]:[]);break}case"countdown":case"switch":{let d=r.content?U(r.content,"vertical",a):null;V(e.slots.content,d?[d]:[]),ce(e.slots.content,d?[d]:[]);break}case"tabs":{for(let u of r.tabs){let k=u.label?U(u.label,"vertical",{...a,inControl:!0}):null;V(e.slots[`label:${u.id}`],k?[k]:[])}let d=r.content?U(r.content,"vertical",a):null;V(e.slots.content,d?[d]:[]),ce(e.slots.content,d?[d]:[]);break}case"carousel":{let d=r.pages.map(u=>U(u,"page",a)).filter(Boolean);d.forEach((u,k)=>{u.setAttribute("role","group"),u.setAttribute("aria-roledescription","slide"),u.setAttribute("aria-label",le.page(k+1,d.length))}),V(e.slots.pages,d),ce(e.slots.pages,d),e.el.pwDots?.(d.length);break}}}function zt(e,c){let o=e==="horizontal"?"width":e==="vertical"?"height":null;if(!o)return;let r=u=>u?o==="width"?u.leading+u.trailing:u.top+u.bottom:0,a=c.filter(([u])=>u.style?.[o]==="fill"),d=Math.max(0,...a.map(([u])=>r(u.style?.padding)+r(u.style?.margin)));for(let[u,k]of a)k.style.flexBasis=_(d-r(u.style?.margin))}function ce(e,c){let o=c.filter(a=>a.dataset.pwType==="package");if(o.length===0){e.getAttribute("role")==="radiogroup"&&e.removeAttribute("role");return}e.setAttribute("role","radiogroup"),e.setAttribute("aria-label",le.packages);let r=o.find(a=>a.getAttribute("aria-checked")==="true")??o[0];for(let a of o)a.tabIndex=a===r?0:-1}function V(e,c){let o=()=>[...e.children].filter(a=>a.dataset?.pwPath!==void 0),r=o();for(let a of r)c.includes(a)||a.remove();r=o(),c.forEach((a,d)=>{r[d]!==a&&(e.insertBefore(a,r[d]??null),r=o())})}let Ae=new WeakMap;function E(e,c,o){e.style.setProperty(c,o),Ae.get(e).push(c)}function De(e,c,o){for(let u of Ae.get(e)??[])e.style.removeProperty(u);Ae.set(e,[]);for(let u of[...e.children])u.classList.contains("pw-bgvideo")&&u.remove();let r=c.style;if(c.type==="image"&&e.classList.toggle("natural",typeof c.aspect!="number"&&(r?.height===void 0||r.height==="fit")),!r)return;let a=(u,k)=>{k&&(E(e,`${u}-block-start`,_(k.top)),E(e,`${u}-block-end`,_(k.bottom)),E(e,`${u}-inline-start`,_(k.leading)),E(e,`${u}-inline-end`,_(k.trailing)))};a("padding",r.padding),a("margin",r.margin),Ie(e,"width",r.width,o),typeof r.height=="number"&&un.has(c.type)?(E(e,"min-height",_(r.height)),o==="vertical"&&E(e,"flex","none")):Ie(e,"height",r.height,o),typeof r.max_width=="number"&&E(e,"max-width",_(r.max_width));let d=r.background;if(d){if(d.type==="color")E(e,"background-color",d.color);else if(d.type==="linear"||d.type==="radial")E(e,"background-image",Me(d)??"");else if(d.type==="image"){let u=Z(d.src);u&&(E(e,"background-image",`url("${u.replace(/"/g,"%22")}")`),E(e,"background-size",d.fit==="fit"?"contain":"cover"),E(e,"background-position","center"),E(e,"background-repeat","no-repeat"))}else if(d.type==="video"){let u=Z(d.src);if(u){let k=P("video","pw-bgvideo");k.src=u;let M=Z(d.poster);M&&(k.poster=M),k.muted=!0,k.loop=d.loop!==!1,k.playsInline=!0,k.autoplay=!re()&&!H(),k.setAttribute("aria-hidden","true"),E(e,"isolation","isolate"),e.prepend(k)}}}if(r.border&&c.type==="custom_html"?E(e,"border",`${_(r.border.width)} solid ${r.border.color??"transparent"}`):r.border&&(E(e,"--pw-bw",_(r.border.width)),E(e,"--pw-bc",r.border.color??"transparent")),r.corners){let u=r.corners;E(e,"border-start-start-radius",_(u.top_leading)),E(e,"border-start-end-radius",_(u.top_trailing)),E(e,"border-end-start-radius",_(u.bottom_leading)),E(e,"border-end-end-radius",_(u.bottom_trailing)),(c.type==="image"||c.type==="video"||d?.type==="image"||d?.type==="video")&&E(e,"overflow","hidden")}r.shadow&&E(e,"box-shadow",`${_(r.shadow.x)} ${_(r.shadow.y)} ${_(r.shadow.radius)} ${r.shadow.color}`),typeof r.opacity=="number"&&r.opacity!==1&&E(e,"opacity",String(r.opacity))}function Ie(e,c,o,r){if(o==null||o==="")return;if(r==="page"){c==="height"&&E(e,"height",o==="fill"?"100%":typeof o=="number"?_(o):o==="fit"?"fit-content":String(o));return}let a=r==="horizontal"?"width":r==="vertical"?"height":null;o==="fill"?c===a?(E(e,"flex","1 1 0"),E(e,`min-${c}`,"0")):r==="z"?E(e,c,"100%"):(E(e,"align-self","stretch"),E(e,c,"auto")):o==="fit"?(c===a&&E(e,"flex","0 0 auto"),E(e,c,"fit-content")):(E(e,c,typeof o=="number"?_(o):String(o)),c===a&&E(e,"flex","none"))}function Me(e){let c=o=>o.map(r=>`${r.color} ${(r.at*100).toFixed(2)}%`).join(", ");if(e.type==="linear")return`linear-gradient(${e.angle}deg, ${c(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)}%, ${c(e.stops)})`}}function Ot(e,c){let o=c.animation;if(!o||x.animate===!1||re()||typeof e.animate!="function")return;let r=24,d={fade:{opacity:0},slide_up:{opacity:0,transform:`translateY(${r}px)`},slide_down:{opacity:0,transform:`translateY(-${r}px)`},slide_leading:{opacity:0,transform:`translateX(-${r}px)`},slide_trailing:{opacity:0,transform:`translateX(${r}px)`},scale:{opacity:0,transform:"scale(0.92)"}}[o.type];d&&e.animate([d,{opacity:1,transform:"none"}],{duration:o.duration_ms,delay:o.delay_ms,easing:ut[o.easing]??ut.ease_out,fill:"backwards"})}function de(){n.onState?.({...R}),G()}function Se(e){R.selected===e&&b.tree.selected===e||(R.selected=e,de(),n.onSelect?.(Te(e)))}function Re(e){H()||e.getAttribute("aria-disabled")==="true"||Se(e.dataset.package??"")}function Ft(e,c){if(e.key===" "||e.key==="Enter"){e.preventDefault(),Re(c);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 r=c.closest("[role=radiogroup]"),d=(r?[...r.children].filter(M=>M.dataset.pwType==="package"):[c]).filter(M=>M.getAttribute("aria-disabled")!=="true"),u=d.indexOf(c),k=d[(u+o+d.length)%d.length];k&&(Re(k),(T.get(k.dataset.pwPath??"")?.el??k).focus())}function Je(e,c){if(H())return;R.tabs={...R.tabs,[e]:c};let o=Ct(e,c);o&&(R.selected=o),de()}function Ct(e,c){return Ue(e)?.tabs?.find(r=>r.id===c)?.package}function Ht(e,c){if(H())return;R.switches={...R.switches,[e]:c};let o=Ue(e),r=c?o?.on_package:o?.off_package;r&&(R.selected=r),de()}function Ue(e){let c=x.definition;for(let o of e.match(/[^.[\]]+/g)??[])c=c?.[/^\d+$/.test(o)?Number(o):o];return c}async function Ve(e,c){if(!(H()||K)){K=!0,e.disabled=!0,e.setAttribute("aria-busy","true");try{await c()}finally{K=!1,e.removeAttribute("aria-busy"),e.disabled=!1;for(let o of T.values())o.type==="purchase_button"&&(o.el.disabled=!x.packages[o.el.dataset.package??""]?.price)}}}async function jt(e){x.packages[e]?.price&&await n.onPurchase(Te(e))}function pe(e){H()&&e!==null&&R.sheet===e||(e&&!R.sheet&&(je=y.activeElement??null),R.sheet=e,de(),e||je?.focus())}function Nt(){let e=R.sheet,c=e?b.tree.sheets?.[e]:void 0;if(!c){A.remove();return}A.className="pw-layer";let o=A.firstElementChild;if(!o){o=P("div","pw-sheet"),o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.tabIndex=-1;let a=P("div","pw-grab");a.setAttribute("aria-hidden","true"),o.append(a),A.append(o),A.addEventListener("click",d=>{d.target===A&&!H()&&pe(null)}),o.addEventListener("keydown",d=>Dt(d,o))}o.style.background=b.tree.theme.colors.background??"",o.setAttribute("aria-label",b.sheetTitles[e]??"");let r=U(c,"vertical",{inControl:!1,inSheet:!0});V(o,r?[r]:[]),A.isConnected||(g.append(A),queueMicrotask(()=>(Be(o)[0]??o).focus()))}function Be(e){return[...e.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')].filter(c=>!c.hidden)}function Dt(e,c){if(e.key==="Escape"){e.preventDefault(),pe(null);return}if(e.key!=="Tab")return;let o=Be(c);if(o.length===0){e.preventDefault();return}let r=o[0],a=o[o.length-1],d=y.activeElement;e.shiftKey&&d===r?(e.preventDefault(),a.focus()):!e.shiftKey&&d===a&&(e.preventDefault(),r.focus())}function qe(e){try{e.contentWindow?.postMessage({type:"palbase.paywall",package:b.tree.selected,locale:b.language,appearance:x.appearance},"*")}catch{}}function We(e){for(let c of y.querySelectorAll("[data-pw-highlight]"))c.removeAttribute("data-pw-highlight");be=e,e&&T.get(e)?.el.setAttribute("data-pw-highlight","")}let Ke=e=>e.composedPath().find(c=>c instanceof(p?.HTMLElement??HTMLElement)&&c.dataset.pwPath!==void 0);g.addEventListener("click",e=>{if(!n.editor)return;let c=Ke(e);c&&(e.preventDefault(),e.stopPropagation(),n.editor.onPick(c.dataset.pwPath))},!0),g.addEventListener("pointerover",e=>{if(n.editor){for(let c of y.querySelectorAll("[data-pw-hover]"))c.removeAttribute("data-pw-hover");Ke(e)?.setAttribute("data-pw-hover","")}}),g.addEventListener("pointerleave",()=>{for(let e of y.querySelectorAll("[data-pw-hover]"))e.removeAttribute("data-pw-hover")});let Xe=()=>G();return ke?.addEventListener?.("change",Xe),G(),{get selected(){return Te(b.tree.selected)},get state(){return{...R}},select(e){Se(e)},update(e){x={...x,...e},e.state&&Object.assign(R,e.state),G()},highlight(e){We(e)},replay(){for(let e of T.values())e.cleanup.forEach(c=>c());T=new Map;for(let e of[h,w,v])e.replaceChildren();G()},destroy(){clearTimeout(ve),Ce?.disconnect(),i.fonts?.removeEventListener?.("loadingdone",He),ke?.removeEventListener?.("change",Xe);for(let e of T.values())e.cleanup.forEach(c=>c());f.remove()}}}function kn(s,t,n){let i=s.defaultView;try{if(i&&"adoptedStyleSheets"in t&&typeof i.CSSStyleSheet=="function"){let l=new i.CSSStyleSheet;l.replaceSync(n),t.adoptedStyleSheets=[l];return}}catch{}let p=s.createElement("style");p.textContent=n,t.append(p)}var ht={version:"0.8.1"};var yt=`palbase-js/${ht.version}`;var we=class{placement;source;definition;assets;offerings;shown;deps;exposed=!1;constructor(t,n,i,p,l,f,y={}){this.placement=t,this.source=n,this.definition=i,this.assets=y,this.offerings=p,this.shown=l,this.deps=f}packages(t){return rt(Mn(this.offerings,ct(this.definition),t),t)}render(t,n){let i=n.locale??globalThis.navigator?.language??this.definition.default_locale,p=n.appearance===void 0?Pn():void 0,l=this.packages(i),f=gt(t,{definition:this.definition,locale:i,appearance:n.appearance??(p?.matches?"dark":"light"),platform:"web",packages:l,eligible:Object.entries(l).filter(([,h])=>h.trial).map(([h])=>h),links:n.links,assets:this.assets},{onPurchase:async h=>{try{let w=await this.deps.checkout({product:h.product,plan:h.plan,successUrl:n.successUrl,cancelUrl:n.cancelUrl});n.onCheckout?n.onCheckout(w,h):globalThis.location.assign(w)}catch(w){if(!n.onError)throw w;n.onError(w,h)}},onClose:n.onClose,onLink:n.onLink,labels:n.labels}),y=h=>f.update({appearance:h.matches?"dark":"light"});p?.addEventListener?.("change",y),!this.exposed&&this.shown&&(this.exposed=!0,this.deps.expose(this));let g=f.destroy.bind(f);return f.destroy=()=>{p?.removeEventListener?.("change",y),g()},f}};function Pn(){try{return globalThis.matchMedia?.("(prefers-color-scheme: dark)")}catch{return}}function An(s,t){if(!s)return;let n=t.split("-")[0];return s[t]?.name??s[n]?.name??Object.values(s).find(i=>i.name)?.name}function Mn(s,t,n){let i=[];for(let p of t){let[l,f]=p.split("."),y=s.products.find(w=>w.key===l),g=y?.channels.web,h=g?.plans.find(w=>w.key===f);!y||!g||!h||i.push({key:p,productName:An(g.locales,n)??y.key,price:{amount:h.price.amount,currency:h.price.currency},period:h.period,intro:h.intro})}return i}var Sn={en:{cta:"Continue",terms:"Terms",privacy:"Privacy"},tr:{cta:"Devam et",terms:"Ko\u015Fullar",privacy:"Gizlilik"},de:{cta:"Weiter",terms:"Bedingungen",privacy:"Datenschutz"},es:{cta:"Continuar",terms:"T\xE9rminos",privacy:"Privacidad"},fr:{cta:"Continuer",terms:"Conditions",privacy:"Confidentialit\xE9"},it:{cta:"Continua",terms:"Termini",privacy:"Privacy"},pt:{cta:"Continuar",terms:"Termos",privacy:"Privacidade"},nl:{cta:"Doorgaan",terms:"Voorwaarden",privacy:"Privacy"},ja:{cta:"\u7D9A\u3051\u308B",terms:"\u5229\u7528\u898F\u7D04",privacy:"\u30D7\u30E9\u30A4\u30D0\u30B7\u30FC"}},mt=s=>({type:"button",action:{type:s},content:{type:"text",text:{t:s},size:"caption",color:"muted"}});function Rn(s){let t=s.products.flatMap(n=>(n.channels.web?.plans??[]).map(i=>({product:n.key,plan:i.key}))).slice(0,6);return t.length===0?null:{schema:2,name:"Default",default_locale:"en",locales:Sn,theme:{colors:{light:{background:"#FFFFFF",surface:"#F2F2F7",text:"#111114",muted:"#6B6B70",accent:"#111114",on_accent:"#FFFFFF",stroke:"#E5E5EA"},dark:{background:"#000000",surface:"#1C1C1E",text:"#F5F5F7",muted:"#9A9AA0",accent:"#F5F5F7",on_accent:"#000000",stroke:"#2C2C2E"}},typography:{headline:{size:17,weight:600,text_style:"headline"},caption:{size:13,weight:400,text_style:"footnote"}},radii:{card:14},spacing:{sm:8,md:16,lg:24}},root:{type:"stack",spacing:"md",align:"stretch",style:{padding:"lg"},children:[{type:"stack",axis:"horizontal",children:[{type:"spacer"},{type:"button",action:{type:"close"},content:{type:"icon",name:"close",color:"muted",size:22}}]},{type:"spacer"},{type:"stack",spacing:"sm",align:"stretch",children:t.map(({product:n,plan:i})=>({type:"package",product:n,plan:i,style:{padding:"md",corners:"card",background:"surface",border:{width:1,color:"stroke"}},states:{selected:{border:{width:2,color:"accent"}}},children:[{type:"stack",axis:"horizontal",spacing:"sm",children:[{type:"stack",align:"start",spacing:2,children:[{type:"text",text:"{{product_name}}",size:"headline",align:"start"},{type:"text",text:"{{period}}",size:"caption",color:"muted",align:"start"}]},{type:"spacer"},{type:"text",text:"{{price}}",size:"headline"}]}]}))},{type:"purchase_button",style:{padding:"md",corners:"card",background:"accent"},content:{type:"text",text:{t:"cta"},size:"headline",color:"on_accent"}},{type:"stack",axis:"horizontal",spacing:"md",distribution:"center",children:[mt("terms"),mt("privacy")]}]}}}function se(){try{return globalThis.localStorage}catch{return}}function _n(s){try{let t=se()?.getItem(s);if(!t)return;let n=JSON.parse(t),i=n?.answer;return typeof i!="object"||i===null||typeof i.paywall_id!="string"||typeof i.version!="number"||typeof i.definition!="object"||i.definition===null||typeof i.offerings!="object"||i.definition.schema!==2?void 0:{etag:typeof n.etag=="string"?n.etag:void 0,answer:i}}catch{return}}function me(s,t){try{t?se()?.setItem(s,JSON.stringify(t)):se()?.removeItem(s)}catch{}}var wt=()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,bt;function En(s){let t=`palbase.installation.${s}`;try{let n=se()?.getItem(t);if(n&&/^[A-Za-z0-9._:-]{1,128}$/.test(n))return n;let i=wt();if(se()?.setItem(t,i),se()?.getItem(t)===i)return i}catch{}return bt??=wt(),bt}async function Zn(s,t,n,i,p={}){let{signal:l,fetch:f}=p,y=tt(p.attributes),g=`palbase.paywall.${t}.${n}`,h=En(t),v={checkout:i,expose:async b=>{if(b.shown)try{let T={paywall_id:b.shown.paywallId,version:b.shown.version,...b.shown.variant!==void 0?{variant:b.shown.variant}:{},...b.shown.ruleId!==void 0?{rule_id:b.shown.ruleId}:{}};await s.recordPaywallExposure({path:{placement:n},headers:{"X-Palbase-Installation":h},body:T})}catch{}}},A=async(b,T)=>new we(n,T,b.definition,b.offerings,{paywallId:b.paywall_id,version:b.version,...b.variant!==void 0?{variant:b.variant}:{},...b.rule_id!==void 0?{ruleId:b.rule_id}:{}},v,await Ge(b.assets??[],{signal:l,...f?{fetch:f}:{}})),x=_n(g),R;try{R=await s.getPlacementPaywall({path:{placement:n},query:{channel:"web"},headers:{"X-Palbase-Paywall-Schema":2,"X-Palbase-Installation":h,"X-Platform":"web","X-Palbase-SDK":yt,...p.appVersion?{"X-Palbase-Client-Version":p.appVersion}:{},...p.app?{"X-Palbase-App":p.app}:{},...p.locale?{"Accept-Language":p.locale}:{},...y!==void 0?{"X-Palbase-Attributes":y}:{},...x?.etag?{"If-None-Match":x.etag}:{}},signal:l})}catch(b){if(b instanceof oe&&b.status===404||b instanceof oe&&b.status===400&&b.code.startsWith("invalid_"))return me(g,void 0),ze(s,n,v,l);if(x&&!l?.aborted)return A(x.answer,"cache");throw b}return R.status===200?(me(g,{etag:R.headers.get("etag")??void 0,answer:R.data}),A(R.data,"server")):R.status===304&&x?A(x.answer,"server"):(me(g,void 0),ze(s,n,v,l))}async function ze(s,t,n,i){let p=(await s.getOfferings({query:{channel:"web"},signal:i})).data,l=Rn(p);return l?new we(t,"default",l,p,void 0,n):null}export{Ut as a,ie as b,Ge as c,qt as d,Yt as e,tt as f,_e as g,st as h,Qt as i,rt as j,ue as k,he as l,Fn as m,cn as n,ct as o,Cn as p,dt as q,gt as r,we as s,Rn as t,Zn as u};
|