palbase 0.7.0 → 0.8.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 +9 -9
- package/dist/backend/stack.js +1 -1
- package/dist/backend/test.js +2 -2
- package/dist/chunks/5VTGMNPL.js +20 -0
- package/dist/chunks/{ZBOJEH7K.js → BO5KR2EQ.js} +2 -2
- package/dist/chunks/{PJVWGUIT.js → BRBCWPR3.js} +1 -1
- package/dist/chunks/DB3SIBKB.js +2 -0
- package/dist/chunks/EGNEXFTZ.js +2 -0
- package/dist/chunks/{HEXIIGWS.js → FZ3MQOVA.js} +2 -2
- package/dist/chunks/{SU7BP6VF.js → JSJVV43D.js} +1 -1
- package/dist/chunks/K6RRNI23.js +4 -0
- package/dist/chunks/{KDSWK3XW.js → KDWDPSL2.js} +1 -1
- package/dist/chunks/P4Z5E6ZI.js +2 -0
- package/dist/chunks/PDOHT46N.js +2 -0
- package/dist/chunks/PGPQGKH2.js +18 -0
- package/dist/chunks/{G3BK7L3J.js → RBA6V3UO.js} +2 -2
- package/dist/chunks/{X3MTLJRV.js → RO5Y5YU4.js} +1 -1
- package/dist/chunks/{BKVU4I5R.js → TUGRIOFX.js} +2 -2
- package/dist/chunks/WEI32SAJ.js +13 -0
- package/dist/chunks/{5ZJCEQV5.js → WINBISC2.js} +3 -3
- package/dist/chunks/Z5JVQNAZ.js +2 -0
- package/dist/cli.js +121 -120
- 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/palbe.js +2 -2
- package/dist/web/paywall.js +2 -2
- package/dist/web/ssr.js +2 -2
- package/dist/web/vite.js +2 -2
- package/package.json +2 -2
- package/types/ai/src/ai.d.ts +44 -15
- package/types/ai/src/chats.d.ts +442 -12
- package/types/ai/src/index.d.ts +4 -4
- package/types/ai/src/tools.d.ts +158 -21
- package/types/backend/src/bootstrap.d.ts +8 -0
- package/types/backend/src/container.d.ts +9 -0
- package/types/backend/src/database.d.ts +17 -2
- package/types/backend/src/engine.d.ts +2 -0
- package/types/backend/src/gateways.d.ts +19 -0
- package/types/backend/src/index.d.ts +1 -0
- package/types/backend/src/runtime.d.ts +12 -0
- package/types/backend/src/testing/unit.d.ts +3 -1
- package/types/internal/src/chat.d.ts +168 -3
- package/types/internal/src/modules/ai.d.ts +1305 -57
- package/types/internal/src/modules/auth.d.ts +14 -2
- package/types/internal/src/modules/events.d.ts +2 -2
- package/types/internal/src/modules/machines.d.ts +57 -1
- package/types/internal/src/modules/notify.d.ts +6 -6
- package/types/internal/src/modules/purchases.d.ts +357 -13
- package/types/internal/src/modules/realtime.d.ts +36 -0
- package/types/internal/src/modules/stores.d.ts +259 -22
- package/types/internal/src/transport.d.ts +5 -0
- package/types/server/src/auth/jwt.d.ts +1 -6
- package/types/web/src/auth.d.ts +15 -4
- package/types/web/src/backends.d.ts +1 -1
- package/types/web/src/chat.d.ts +215 -4
- package/types/web/src/client.d.ts +28 -0
- package/types/web/src/gateways.d.ts +4 -3
- package/types/web/src/index.d.ts +3 -2
- package/types/web/src/session.d.ts +11 -1
- package/types/web/src/voice.d.ts +36 -0
- package/dist/chunks/3ALGILOX.js +0 -2
- package/dist/chunks/AIIKXCWN.js +0 -2
- package/dist/chunks/ELEE7XO2.js +0 -18
- package/dist/chunks/G7E26S3Y.js +0 -13
- package/dist/chunks/H2EPK74V.js +0 -20
- package/dist/chunks/JS3TTUHS.js +0 -2
- package/dist/chunks/L3NTI4AZ.js +0 -2
- package/dist/chunks/LEBVOSG6.js +0 -4
- package/dist/chunks/OIA7KLRW.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! palbase 0.
|
|
2
|
-
import{b as oe}from"./JS3TTUHS.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=`
|
|
1
|
+
/*! palbase 0.8.0 — Palbase SDK License (see LICENSE) */
|
|
2
|
+
import{b as oe}from"./PDOHT46N.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
3
|
:host{display:block;height:100%}
|
|
4
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
5
|
.pw2 *,.pw2 *::before,.pw2 *::after{box-sizing:border-box}
|
|
@@ -89,4 +89,4 @@ button.pw-c:disabled{cursor:default;opacity:.5}
|
|
|
89
89
|
[data-pw-hover]:not([data-pw-highlight]){outline:1px dashed #2E7CF6aa!important;outline-offset:-1px}
|
|
90
90
|
.pw-editing button,.pw-editing .pw-pkg,.pw-editing a{cursor:default}
|
|
91
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.7.0"};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};
|
|
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.0"};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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! palbase 0.8.0 — Palbase SDK License (see LICENSE) */
|
|
2
|
+
import{a as D}from"./KDWDPSL2.js";import{a as A,b as P,c as R,d as x,e as O,f as j,g as M,h as C,i as L,j as U,k as K,l as N}from"./EGNEXFTZ.js";import{a as $,b as I}from"./BO5KR2EQ.js";import{b as S,d as w}from"./PDOHT46N.js";var ae=/^pb_[a-z0-9]+_s/;function v(n){if(D())throw new TypeError("palbase/server runs on a server: its secret key never goes into a browser or a mobile app \u2014 apps use palbase/web (or the native SDKs) with the publishable key");if(typeof n.secretKey!="string"||!ae.test(n.secretKey))throw new TypeError("secretKey is the project secret key (pb_<ref>_s\u2026); a publishable key belongs in palbase/web");let e=I(w({baseUrl:n.url,credentials:{secretKey:n.secretKey},fetch:n.fetch,solveProofOfWork:n.solveProofOfWork??!1}),n.retry??$);return{ai:A.client(e),analytics:P.client(e),auth:R.client(e),cache:x.client(e),flags:O.client(e),machines:j.client(e),notify:M.client(e),purchases:C.client(e),realtime:L.client(e),secrets:U.client(e),storage:K.client(e),stores:N.client(e),transport:e,url:new URL(n.url).origin}}var f=class extends Error{code;constructor(e,t){super(t),this.name="WebhookSignatureError",this.code=e}},ue=300,de=/^[0-9]{1,12}$/,le=/^[0-9a-f]{64}$/,W=8,fe=/^whsec_[0-9A-Za-z]{32,}$/,he=1024*1024;async function B(n){if(typeof n.secret!="string"||!fe.test(n.secret))throw new TypeError("secret is the webhook endpoint secret (whsec_\u2026), not an API key");await F(n);let e;try{e=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(z(n.body)))}catch{throw new f("invalid_body","the signed body is not JSON")}if(!be(e))throw new f("invalid_body","the signed body is not a Palbase event (id, type, project_id, created_at, data)");return e}async function F(n){if(typeof n.secret!="string"||n.secret==="")throw new TypeError("secret is the key the request was signed with");let e=z(n.body),{t,v1:r}=H(n),s=await crypto.subtle.importKey("raw",new TextEncoder().encode(n.secret),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),o=new Uint8Array(await crypto.subtle.sign("HMAC",s,we(new TextEncoder().encode(`${t}.`),e))),a=!1;for(let u of r)me(o,ge(u))&&(a=!0);if(!a)throw new f("signature_mismatch","no v1 in Palbase-Signature is this body signed with this secret")}function H(n){let e=n.toleranceSeconds??ue;if(!Number.isFinite(e)||e<0)throw new TypeError(`toleranceSeconds is a number of seconds, 0 or more (got ${String(n.toleranceSeconds)})`);let t=(n.now??Date.now)();if(!Number.isFinite(t))throw new TypeError(`now() returns epoch milliseconds (got ${String(t)})`);let r=n.signature;if(typeof r!="string"||r.trim()==="")throw new f("missing_signature","the request carries no Palbase-Signature header");let s,o=[];for(let a of r.split(",")){let u=a.indexOf("=");if(u<=0)throw new f("malformed_signature","Palbase-Signature is t=<seconds>,v1=<hex>");let c=a.slice(0,u).trim(),i=a.slice(u+1).trim();if(c==="t"){if(s!==void 0||!de.test(i))throw new f("malformed_signature","Palbase-Signature carries one t, in unix seconds");s=i}else if(c==="v1"){if(!le.test(i))throw new f("malformed_signature","a v1 is 64 lowercase hex characters");if(o.length===W)throw new f("malformed_signature",`Palbase-Signature carries at most ${W} v1`);o.push(i)}}if(s===void 0||o.length===0)throw new f("malformed_signature","Palbase-Signature is t=<seconds>,v1=<hex>");if(Math.abs(t/1e3-Number(s))>e)throw new f("stale_timestamp",`the signature's time is more than ${e} s from now: an old delivery sent again is not taken`);return{t:s,v1:o}}async function pe(n,e,t={}){let r=await ye(n,t.maxBytes??he);return B({toleranceSeconds:t.toleranceSeconds,now:t.now,secret:e,signature:n.headers.get("palbase-signature"),body:r})}async function ye(n,e){let t=()=>new f("body_too_large",`the body is larger than ${e} bytes`),r=Number(n.headers.get("content-length")??"NaN");if(Number.isFinite(r)&&r>e)throw t();if(!n.body)return new Uint8Array(0);let s=n.body.getReader(),o=[],a=0;for(;;){let{done:i,value:l}=await s.read();if(i)break;if(a+=l.byteLength,a>e)throw await s.cancel().catch(()=>{}),t();o.push(l)}let u=new Uint8Array(a),c=0;for(let i of o)u.set(i,c),c+=i.byteLength;return u}function z(n){if(typeof n=="string")return new TextEncoder().encode(n);if(n instanceof Uint8Array)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);throw new TypeError("body is the raw request body (string or bytes): a parsed object is not what was signed \u2014 read the body before any JSON middleware")}function ge(n){let e=new Uint8Array(n.length/2);for(let t=0;t<e.length;t++)e[t]=parseInt(n.slice(t*2,t*2+2),16);return e}function me(n,e){if(n.byteLength!==e.byteLength)return!1;let t=0;for(let r=0;r<n.byteLength;r++)t|=n[r]^e[r];return t===0}function we(n,e){let t=new Uint8Array(n.byteLength+e.byteLength);return t.set(n,0),t.set(e,n.byteLength),t}function be(n){if(typeof n!="object"||n===null)return!1;let e=n;return typeof e.id=="string"&&typeof e.type=="string"&&typeof e.project_id=="string"&&typeof e.created_at=="string"&&"data"in e}var V=60,ke=60,Se=8*1024,ve=1e5;function E(n){let e=n instanceof Uint8Array?n:new Uint8Array(n),t="";for(let r of e)t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Y(n){let e=n.replace(/[\s=]+/g,"");if(!/^[A-Za-z0-9+/_-]*$/.test(e)||e.length%4===1)return;let t=atob(e.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(e.length/4)*4,"=")),r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}function J(n){let e=Y(n);if(e)try{let t=JSON.parse(new TextDecoder().decode(e));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:void 0}catch{return}}var b=class{byKey=new Map;held=0;sweptAt=Number.NEGATIVE_INFINITY;max;constructor(e=ve){this.max=e}spend(e,t){if(t>=e.until)throw new d("proof","the DPoP proof is not taken: it was checked too long ago");let r=this.byKey.get(e.jkt);if(r){this.forgetOld(e.jkt,r,t);let s=r.get(e.jti);if(s!==void 0&&s>t)throw new d("proof","the DPoP proof is not taken: it was used before");s!==void 0&&r.delete(e.jti)&&this.held--}this.held>=this.max&&this.makeRoom(t),r=this.byKey.get(e.jkt),r||(r=new Map,this.byKey.set(e.jkt,r)),r.set(e.jti,e.until),this.held++}forgetOld(e,t,r){for(let[s,o]of t){if(o>r)break;t.delete(s),this.held--}t.size===0&&this.byKey.delete(e)}makeRoom(e){if(e-this.sweptAt>=1e3){this.sweptAt=e;for(let[r,s]of this.byKey){for(let[o,a]of s)a>e||(s.delete(o),this.held--);s.size===0&&this.byKey.delete(r)}this.held=0;for(let r of this.byKey.values())this.held+=r.size}if(this.held<this.max)return;let t=[...this.byKey].sort((r,s)=>s[1].size-r[1].size);for(let[r,s]of t){if(this.held<=this.max*.9)break;this.byKey.delete(r),this.held-=s.size}}};async function Ee(n,e){let t=`{"crv":"P-256","kty":"EC","x":"${n}","y":"${e}"}`;return E(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t)))}function q(n){try{let e=new URL(n);return e.username!==""||e.password!==""?void 0:`${e.protocol}//${e.host}${e.pathname}`}catch{return}}async function G(n,e,t,r){let s=ie=>{throw new d("proof",`the DPoP proof is not taken: ${ie}`)},o=t.proof;if(!o)return s("there is none (a DPoP-bound token comes with a DPoP header)");if(o.length>Se)return s("it is too long");let a=o.split(".");if(a.length!==3)return s("it is not a JWS of three parts");let u=J(a[0]),c=J(a[1]);if(!u||!c)return s("its header or claims are not base64url JSON");if(u.typ!=="dpop+jwt")return s("its typ is not dpop+jwt");if(u.alg!=="ES256")return s(`it is signed with ${String(u.alg)}; only ES256 is taken`);let i=u.jwk;if(!i||typeof i!="object"||i.kty!=="EC"||i.crv!=="P-256"||typeof i.x!="string"||typeof i.y!="string")return s("its header carries no P-256 public key");if("d"in i)return s("its header carries a private key");if(await Ee(i.x,i.y)!==e)return s("it is signed by a key the token does not name");let l;try{l=await crypto.subtle.importKey("jwk",{kty:"EC",crv:"P-256",x:i.x,y:i.y,ext:!0},{name:"ECDSA",namedCurve:"P-256"},!1,["verify"])}catch{return s("its key is not a P-256 point")}let p=Y(a[2]);if(!p||!await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},l,p,new TextEncoder().encode(`${a[0]}.${a[1]}`)).catch(()=>!1))return s("its signature does not verify");if(typeof c.htm!="string"||c.htm.toUpperCase()!==t.method.toUpperCase())return s(`it is for ${String(c.htm)}, not ${t.method}`);let h=typeof c.htu=="string"?q(c.htu):void 0,y=q(t.url);if(!h||!y||h!==y)return s(`it is for ${String(c.htu)}, not ${y??t.url}`);let re=r/1e3;if(typeof c.iat!="number"||Math.abs(c.iat-re)>V)return s("it was not made within a minute of now");let se=E(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(n)));if(c.ath!==se)return s("it is not for this token (ath)");if(typeof c.jti!="string"||c.jti===""||c.jti.length>256)return s("it has no jti (or one longer than 256)");let oe=E(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(c.jti)));return{jkt:e,jti:oe,until:(c.iat+V+ke)*1e3+1}}var d=class extends Error{reason;constructor(e,t){super(t),this.name="TokenError",this.reason=e}},g=class extends Error{constructor(e,t){super(e,t),this.name="AuthUnavailable"}},_e=new Set(["invalid_api_key","missing_api_key","secret_key_in_browser"]);function Te(n){return async e=>{let t=w({baseUrl:n.url,credentials:{secretKey:n.secretKey,accessToken:()=>e},fetch:n.fetch});try{return await t.send({op:"SessionStanding",method:"GET",path:"/auth/session/standing",auth:[["ApiKeyAuth","userJWT"]],answers:{204:"empty"}}),!0}catch(r){if(r instanceof S&&r.status===401&&!_e.has(r.code))return!1;throw new g("a session's standing could not be told",{cause:r})}}}var _={ES256:{kty:"EC",import:{name:"ECDSA",namedCurve:"P-256"},verify:{name:"ECDSA",hash:"SHA-256"}},PS256:{kty:"RSA",import:{name:"RSA-PSS",hash:"SHA-256"},verify:{name:"RSA-PSS",saltLength:32}}},X=60,Ae=16*1024,Pe=10*6e4,Re=5e4,Z=n=>typeof n=="string"&&Object.hasOwn(_,n),T=class{issuer;projectId;fetchImpl;now;maxKeyAgeMs;refetchIntervalMs;fetchTimeoutMs;standing;standingTtlMs;standingStaleMs;standings=new Map;asking=new Map;keys=new Map;keysUntil=0;lastFetch=Number.NEGATIVE_INFINITY;lastFailure=void 0;inflight=null;seenProofs=new b;constructor(e){let t=new URL(e.issuer);if(t.origin!==e.issuer.replace(/\/$/,""))throw new TypeError(`issuer is the project's origin (https://<ref>.<domain>), not ${e.issuer}`);if(typeof e.projectId!="string"||e.projectId==="")throw new TypeError("projectId is the project id the tokens carry");if(this.issuer=t.origin,this.projectId=e.projectId,this.fetchImpl=e.fetch??globalThis.fetch,this.now=e.now??Date.now,this.maxKeyAgeMs=e.maxKeyAgeMs??60*6e4,this.refetchIntervalMs=e.refetchIntervalMs??3e4,this.fetchTimeoutMs=e.fetchTimeoutMs??5e3,typeof e.standing!="function")throw new TypeError("standing is how the verifier asks whether a token's session stands");this.standing=e.standing,this.standingTtlMs=e.standingTtlMs??1e3,this.standingStaleMs=e.standingStaleMs??15e3}async verify(e,t){if(typeof e!="string"||e.length===0||e.length>Ae)throw new d("malformed","the token is not a JWT");let r=e.split(".");if(r.length!==3)throw new d("malformed","the token is not a JWS of three parts");let s=Q(r[0]),o=Q(r[1]);if(!s||!o)throw new d("malformed","the token header or claims are not base64url JSON");let a=s.alg;if(!Z(a))throw new d("algorithm",`the token is signed with ${String(a)}; only ES256 and PS256 are taken`);let u=s.kid;if(typeof u!="string"||u==="")throw new d("malformed","the token header names no kid");let c=await this.key(u);if(!c)throw new d("unknown_key",`no key ${u} in the project's key set`);if(c.alg!==a)throw new d("algorithm",`key ${u} is ${c.alg}, the token says ${a}`);let i=te(r[2]);if(!i)throw new d("malformed","the signature is not base64url");let l=new TextEncoder().encode(`${r[0]}.${r[1]}`);if(!await crypto.subtle.verify(_[c.alg].verify,c.key,i,l).catch(()=>!1))throw new d("signature","the signature does not verify");let m=this.check(o),h=o.cnf,y;if(h!==void 0){if(!t)throw new d("bound","the token is bound to a key (DPoP): it comes with the DPoP scheme and a proof, not as a Bearer");if(typeof h!="object"||h===null||typeof h.jkt!="string"||h.jkt==="")throw new d("bound","the token is bound to a key it does not name (cnf.jkt)");y=await G(e,h.jkt,t,this.now())}else if(t)throw new d("not_bound","the DPoP scheme came with a token bound to no key");if(!await this.stands(e,m.sessionId))throw new d("session_ended","the token's session has ended (signed out, revoked, or its user banned)");return y&&this.seenProofs.spend(y,this.now()),m}async verifyRequest(e){let t=e.headers instanceof Headers?e.headers:Oe(e.headers),r=t.get("authorization")??"";if(r==="")return null;let s=/^(bearer|dpop)\s+(\S+)$/i.exec(r);if(!s)throw new d("malformed","the Authorization header is not a Bearer or DPoP token");let o=s[1].toLowerCase()==="dpop",a=new URL(e.url,`http://${t.get("host")??"localhost"}`);return this.verify(s[2],o?{proof:t.get("dpop"),method:e.method,url:ee(t,a)}:void 0)}async stands(e,t){let r=this.now(),s=this.standings.get(t);if(s&&r<s.until)return s.live;let o=this.asking.get(t);o||(o=this.standing(e,t).finally(()=>this.asking.delete(t)),this.asking.set(t,o));let a;try{a=await o}catch(c){let i=this.standings.get(t),l=this.now();if(i&&l<i.at+this.standingStaleMs)return i.until=Math.min(l+this.standingTtlMs,i.at+this.standingStaleMs),i.live;throw new g("a session's standing cannot be read now",{cause:c})}let u=this.now();return this.standings.delete(t),this.standings.set(t,{live:a,at:u,until:u+this.standingTtlMs}),this.standings.size>Re&&this.standings.delete(this.standings.keys().next().value),a}check(e){if(e.iss!==this.issuer)throw new d("issuer",`the token was issued by ${String(e.iss)}, not this project`);if(!(Array.isArray(e.aud)?e.aud:[e.aud]).includes(this.issuer))throw new d("audience","the token is not meant for this project");if(e.project_id!==this.projectId)throw new d("project","the token names another project");let r=this.now()/1e3;if(typeof e.exp!="number"||e.exp+X<=r)throw new d("expired","the token has expired");if(e.nbf!==void 0&&(typeof e.nbf!="number"||e.nbf-X>r))throw new d("not_yet_valid","the token is not valid yet");if(typeof e.sub!="string"||e.sub===""||typeof e.auth_time!="number")throw new d("not_a_user","the token is not a user's");if(typeof e.session_id!="string"||e.session_id==="")throw new d("not_a_session","the token is no session's");let s=e.custom_claims;if(s!==void 0&&(typeof s!="object"||s===null||s.type!==void 0))throw new d("not_a_session","the token is a custom one (an exchange or an approval), not a session's");return{id:e.sub,email:typeof e.email=="string"?e.email:null,emailVerified:e.email_verified===!0,role:typeof e.role=="string"?e.role:null,sessionId:typeof e.session_id=="string"?e.session_id:null,claims:Object.freeze({...e})}}async key(e){let t=this.now();if(t>=this.keysUntil){let s=this.keys.size>0&&t<this.keysUntil+Pe;if(this.lastFailure!==void 0&&t-this.lastFetch<this.refetchIntervalMs){if(!s)throw new g("the project's key set cannot be read now",{cause:this.lastFailure})}else try{await this.refresh()}catch(o){if(!s)throw o}}let r=this.keys.get(e);return!r&&t-this.lastFetch>=this.refetchIntervalMs&&(await this.refresh(),r=this.keys.get(e)),r}refresh(){if(this.inflight)return this.inflight;let e=this.load().finally(()=>{this.inflight=null});return this.inflight=e,e}async load(){this.lastFetch=this.now();let e,t;try{if(t=await this.fetchImpl(`${this.issuer}/.well-known/jwks.json`,{redirect:"error",headers:{accept:"application/json"},signal:AbortSignal.timeout(this.fetchTimeoutMs)}),!t.ok)throw new Error(`the project's key set answered ${t.status}`);e=await t.json()}catch(o){throw this.lastFailure=o,new g("the project's key set cannot be read now",{cause:o})}this.lastFailure=void 0;let r=new Map;for(let o of Array.isArray(e.keys)?e.keys:[]){let a=o.alg;if(typeof o.kid!="string"||!Z(a))continue;let u=_[a];if(o.kty!==u.kty||o.use!==void 0&&o.use!=="sig")continue;let{d:c,...i}=o;try{r.set(o.kid,{alg:a,key:await crypto.subtle.importKey("jwk",i,u.import,!1,["verify"])})}catch{}}this.keys=r;let s=je(t.headers.get("cache-control"))??this.maxKeyAgeMs;this.keysUntil=this.now()+Math.min(Math.max(s,this.refetchIntervalMs),this.maxKeyAgeMs)}};function ee(n,e){let t=n.get("x-forwarded-proto")?.split(",")[0]?.trim().toLowerCase(),r=t==="https"||t==="http"?t:e.protocol.slice(0,-1),s=n.get("host")??e.host;return xe.test(s)?`${r}://${s}${e.pathname}`:""}var xe=/^(?:[a-z0-9-]+(?:\.[a-z0-9-]+)*|\[[0-9a-f:.]+\])(?::[0-9]{1,5})?$/i;function Oe(n){let e=new Headers;for(let[t,r]of Object.entries(n))if(r!==void 0)for(let s of Array.isArray(r)?r:[r])e.append(t,s);return e}function je(n){let e=/(?:^|,)\s*max-age=(\d+)/i.exec(n??"");return e?Number(e[1])*1e3:void 0}function te(n){if(!/^[A-Za-z0-9_-]*$/.test(n)||n.length%4===1)return null;let e=atob(n.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(n.length/4)*4,"=")),t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function Q(n){let e=te(n);if(!e)return null;try{let t=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(e));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Me(n,e,t=Date.now()){let r=Object.hasOwn(n.entitlements,e)?n.entitlements[e]:void 0;return r?.active?r.expires_at===null?!0:Date.parse(r.expires_at)>(typeof t=="number"?t:t.getTime()):!1}var k=class extends Error{receipt;constructor(e){super(`the reservation ${JSON.stringify(e.idempotency_key)} is ${e.status} already: its job is not run again (a new one is a new Idempotency-Key)`),this.name="ReservationSettled",this.receipt=e}};async function Ce(n,e,t,r){let{idempotencyKey:s,amount:o,ttlSeconds:a,metadata:u}=t;if(typeof s!="string"||s==="")throw new TypeError("idempotencyKey names the reservation for good: a retry with it is the same hold, never a second");let c={amount:o,...t.credits!==void 0?{credits:t.credits}:{limit:t.limit},...a!==void 0?{ttl_seconds:a}:{},...u!==void 0?{metadata:u}:{}},i=(await n.purchases.holdSpend({path:{customer_id:e},headers:{"Idempotency-Key":s},body:c})).data;if(i.status!=="held")throw new k(i);let l={customer_id:i.customer,spend_id:i.id},p;try{p=await r(i)}catch(m){throw await n.purchases.releaseSpend({path:l}).catch(()=>{}),m}return await n.purchases.commitSpend({path:l}),p}async function*Le(n){let e,t=new Set;do{let r=(await n(e)).data;yield r;let s=r.next_cursor??void 0;if(s!==void 0&&t.has(s))throw new Error(`the listing answered a cursor it had answered before (${s})`);s!==void 0&&t.add(s),e=s}while(e)}var Ue=/^[A-Za-z_][A-Za-z0-9_]{0,127}$/,Ke=/^(PALBASE_|NODE_|BUN_|NPM_|LD_|DYLD_|GIT_|SSH_)|^(PATH|HOME|SHELL|USER|TMPDIR|TMP|TEMP|PWD|IFS|ENV|BASH_ENV|SSL_CERT_FILE|SSL_CERT_DIR|CURL_CA_BUNDLE|REQUESTS_CA_BUNDLE|NO_PROXY|ALL_PROXY|HTTP_PROXY|HTTPS_PROXY|PG\w*)$/i;function ne(n){return!Ue.test(n)||Ke.test(n)||/_PROXY$/i.test(n)}var Ne=/^(PORT|PALBASE_(URL|PROJECT_ID|MACHINE|REPLICAS|SECRET_KEY|WEBHOOK_SECRET|PLATFORM_SECRET|CONTRACT_OUT|SECRETS|DB_[A-Z0-9_]+))$/;function $e(n){return Ne.test(n)}async function Ie(n={}){let e=n.env??process.env,t=e.PALBASE_SECRETS;if(t===void 0||t==="")return;if(t!=="development"&&t!=="production")throw new TypeError(`PALBASE_SECRETS is development or production, not ${t}`);let r=n.url??e.PALBASE_URL??"",s=n.secretKey??e.PALBASE_SECRET_KEY??"";if(r===""||s==="")throw new TypeError("PALBASE_SECRETS reads the project's Secrets with PALBASE_URL and PALBASE_SECRET_KEY: give both (palbase env:pull writes them)");let o=v({url:new URL(r).origin,secretKey:s,fetch:n.fetch}),{data:a}=await o.secrets.getEnvironmentValues({path:{environment:t}}),u=[],c=[],i=[];for(let[l,p]of Object.entries(a.values)){if(ne(l)){i.push(l);continue}if(e[l]!==void 0&&e[l]!==""){c.push(l);continue}e[l]=p,u.push(l)}return{set:t,loaded:u.sort(),kept:c.sort(),refused:i.sort()}}export{v as a,f as b,B as c,F as d,H as e,pe as f,d as g,g as h,Te as i,T as j,ee as k,Me as l,k as m,Ce as n,Le as o,ne as p,$e as q,Ie as r};
|