palbase 0.25.0 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/ai/index.js +2 -2
  2. package/dist/backend/engine.js +2 -2
  3. package/dist/backend/env.js +1 -1
  4. package/dist/backend/index.js +3 -3
  5. package/dist/backend/stack.js +1 -1
  6. package/dist/backend/test.js +2 -2
  7. package/dist/chunks/{GFYILAJU.js → 3NXLBGEQ.js} +2 -2
  8. package/dist/chunks/{C7SBJV6T.js → 3SLLOZC4.js} +1 -1
  9. package/dist/chunks/{5BIBYYM4.js → 4CLXBBRV.js} +1 -1
  10. package/dist/chunks/{VF4FX3QH.js → 5XNUS4RO.js} +2 -2
  11. package/dist/chunks/{B773R25P.js → 7HZ4EKJP.js} +2 -2
  12. package/dist/chunks/{HFKZ7GWV.js → B3UA4AVW.js} +2 -2
  13. package/dist/chunks/{OFLYZJK7.js → BA4P3PMP.js} +1 -1
  14. package/dist/chunks/{WS7DI7CS.js → CIVBMN5Z.js} +2 -2
  15. package/dist/chunks/{Q45P37LH.js → FCJKKXVF.js} +1 -1
  16. package/dist/chunks/{4GJ2ZPTN.js → G6HTDGFI.js} +2 -2
  17. package/dist/chunks/{S4GD7FCI.js → GP64QR4G.js} +2 -2
  18. package/dist/chunks/{2MYJV4YR.js → HRPJA5AL.js} +2 -2
  19. package/dist/chunks/{J3KELWNZ.js → IERZK64H.js} +1 -1
  20. package/dist/chunks/{EVUBM4NK.js → IVTH3I2M.js} +2 -2
  21. package/dist/chunks/{UN5JMFWV.js → JN6E6CVV.js} +2 -2
  22. package/dist/chunks/{MQK4YZM7.js → JPUEFD5R.js} +1 -1
  23. package/dist/chunks/{Y5PIIC4Y.js → JRVM63RG.js} +2 -2
  24. package/dist/chunks/{YAVAXQGR.js → LSJGREA3.js} +2 -2
  25. package/dist/chunks/{4YCXKEZV.js → Q2SNPNA4.js} +1 -1
  26. package/dist/chunks/{NLPK3G5Q.js → RRMYWHH6.js} +2 -2
  27. package/dist/chunks/{Z347DQJS.js → VFPMVP2K.js} +2 -2
  28. package/dist/chunks/{DUMTTL2J.js → Y5WCHNQI.js} +2 -2
  29. package/dist/chunks/{NANJIH3L.js → YE7MYOBE.js} +2 -2
  30. package/dist/cli.js +2 -2
  31. package/dist/cloud/index.js +2 -2
  32. package/dist/refuse/ai.js +1 -1
  33. package/dist/refuse/backend.js +1 -1
  34. package/dist/refuse/cloud.js +1 -1
  35. package/dist/refuse/server.js +1 -1
  36. package/dist/server/index.js +2 -2
  37. package/dist/server/testing.js +2 -2
  38. package/dist/web/index.js +2 -2
  39. package/dist/web/message.js +2 -2
  40. package/dist/web/palbe.js +2 -2
  41. package/dist/web/paywall.js +2 -2
  42. package/dist/web/push-sw.js +1 -1
  43. package/dist/web/ssr.js +2 -2
  44. package/dist/web/vite.js +2 -2
  45. package/package.json +2 -2
@@ -1,4 +1,4 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
2
  var Rt=d=>[...new Uint8Array(d)].map(t=>t.toString(16).padStart(2,"0")).join(""),At=d=>`pw-font-${d}`;function ne(d){return(typeof d=="string"?/^asset:([0-9a-f-]{36})$/.exec(d):null)?.[1]}async function an(d,t={}){let a={},l=t.fetch??((c,p)=>globalThis.fetch(c,p));return await Promise.all(d.map(async c=>{try{if(!/^https:\/\//.test(c.url))return;let p=await l(c.url,{signal:t.signal,credentials:"omit"});if(!p.ok)return;let g=await p.arrayBuffer();if(g.byteLength!==c.bytes&&c.bytes>0||Rt(await globalThis.crypto.subtle.digest("SHA-256",g))!==c.sha256.toLowerCase())return;let w=_t(c.kind,new Uint8Array(g));if(w===void 0)return;let y=await Et(c,g,w,t);y&&(a[c.id]=y)}catch{}})),a}var C=(d,t,a=0)=>d.length>=a+t.length&&t.every((l,c)=>d[a+c]===l),W=d=>[...d].map(t=>t.charCodeAt(0));function _t(d,t){switch(d){case"image":return C(t,[137,80,78,71,13,10,26,10])?"image/png":C(t,[255,216,255])?"image/jpeg":C(t,W("RIFF"))&&C(t,W("WEBP"),8)?"image/webp":void 0;case"video":return C(t,W("ftyp"),4)?C(t,W("qt "),8)?"video/quicktime":"video/mp4":C(t,[26,69,223,163])?"video/webm":void 0;case"font":return C(t,W("wOF2"))?"font/woff2":C(t,W("wOFF"))?"font/woff":C(t,W("OTTO"))?"font/otf":C(t,[0,1,0,0])||C(t,W("true"))?"font/ttf":void 0;case"html":return C(t,[80,75,3,4])||C(t,[80,75,5,6])?"application/zip":void 0;default:return}}async function Et(d,t,a,l){switch(d.kind){case"image":case"video":return{kind:d.kind,url:URL.createObjectURL(new Blob([t],{type:a}))};case"font":{let c=At(d.id),p=globalThis.FontFace,g=l.fonts??globalThis.document?.fonts;if(!p||!g)return;let h=new p(c,t,{display:"block"});return await h.load(),g.add(h),{kind:"font",url:"",family:c}}case"html":{let c=await Lt(new Uint8Array(t)),p=Ot(c);return p===void 0?void 0:{kind:"html",url:"",html:p}}}}async function Lt(d){let t=new DataView(d.buffer,d.byteOffset,d.byteLength),a=-1;for(let h=d.length-22;h>=Math.max(0,d.length-22-65535);h--)if(t.getUint32(h,!0)===101010256){a=h;break}if(a<0)throw new Error("not a zip");let l=t.getUint16(a+10,!0),c=t.getUint32(a+16,!0),p=new Map,g=0;for(let h=0;h<l;h++){if(t.getUint32(c,!0)!==33639248)throw new Error("a broken zip");let w=t.getUint16(c+10,!0),y=t.getUint32(c+20,!0),m=t.getUint32(c+24,!0),v=t.getUint16(c+28,!0),_=t.getUint16(c+30,!0),P=t.getUint16(c+32,!0),R=t.getUint32(c+42,!0),x=new TextDecoder().decode(d.subarray(c+46,c+46+v));if(c+=46+v+_+P,x.endsWith("/"))continue;if(x.startsWith("/")||x.split("/").includes(".."))throw new Error("a path leaving the zip");if(g+=m,p.size>=200||g>20971520)throw new Error("a zip too large");let T=R+30+t.getUint16(R+26,!0)+t.getUint16(R+28,!0),O=d.subarray(T,T+y);if(w===0)p.set(x,O);else if(w===8)p.set(x,await Pt(O));else throw new Error("a zip entry compressed another way")}return p}async function Pt(d){let t=new Response(new Uint8Array(d)).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(t).arrayBuffer())}var Tt={html:"text/html",css:"text/css",js:"text/javascript",mjs:"text/javascript",json:"application/json",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",woff2:"font/woff2",woff:"font/woff",ttf:"font/ttf",otf:"font/otf"};function qe(d,t){let a=Tt[d.split(".").pop()?.toLowerCase()??""]??"application/octet-stream",l="";for(let c=0;c<t.length;c+=32768)l+=String.fromCharCode(...t.subarray(c,c+32768));return`data:${a};base64,${btoa(l)}`}var $t="default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:; script-src 'unsafe-inline' data:";function Ot(d){let t=d.get("index.html");if(!t)return;let a=new TextDecoder().decode(t),l=y=>new TextDecoder().decode(d.get(y)),c=y=>{let m=y.replace(/^\.\//,"").split(/[?#]/)[0];return d.has(m)?m:void 0},p=y=>y.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(m,v,_)=>{let P=c(_);return P?`url("${qe(P,d.get(P))}")`:m}),g=globalThis.DOMParser;if(!g)return;let h=new g().parseFromString(a,"text/html");for(let y of[...h.querySelectorAll('link[rel~="stylesheet"][href]')]){let m=c(y.getAttribute("href")),v=h.createElement("style");v.textContent=m?p(l(m)):"",y.replaceWith(v)}for(let y of[...h.querySelectorAll("style")])y.textContent=p(y.textContent??"");for(let y of[...h.querySelectorAll("[src], [href], [poster]")])for(let m of["src","href","poster"]){let v=y.getAttribute(m);if(v===null)continue;let _=c(v);_?y.setAttribute(m,qe(_,d.get(_))):/^(https?:)?\/\//i.test(v)&&y.removeAttribute(m)}for(let y of[...h.querySelectorAll("[style]")])y.setAttribute("style",p(y.getAttribute("style")??""));let w=h.createElement("meta");return w.setAttribute("http-equiv","Content-Security-Policy"),w.setAttribute("content",$t),h.head.prepend(w),`<!doctype html>${h.documentElement.outerHTML}`}var K=(d,t,a)=>`M${d-a} ${t}a${a} ${a} 0 1 0 ${2*a} 0a${a} ${a} 0 1 0 ${-2*a} 0`,de={ad_free:["M3 7h18v10H3z","M4 4l16 16"],bell:["M6 16v-5a6 6 0 0 1 12 0v5l2 2H4z","M10 21a2 2 0 0 0 4 0"],bolt:["M13 2L4 14h7l-1 8 9-12h-7z"],book:["M5 4h11a3 3 0 0 1 3 3v13H8a3 3 0 0 1-3-3z","M5 17a3 3 0 0 1 3-3h11"],chart:["M3 20h18","M6 20v-8","M11 20V5","M16 20v-6","M21 20V9"],chat:["M4 5h16v11H9l-5 4z"],check:["M5 12l5 5 9-10"],check_circle:[K(12,12,9),"M8 12l3 3 5-6"],clock:[K(12,12,9),"M12 7v5l3 2"],cloud:["M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 9a4.5 4.5 0 0 1-.5 9z"],crown:["M3 8l4 4 5-7 5 7 4-4-2 11H5z"],download:["M12 4v11","M7 10l5 5 5-5","M4 20h16"],gift:["M3 9h18v4H3z","M5 13v8h14v-8","M12 9v12","M12 9C10 5 6 5 6 7.5S12 9 12 9zm0 0c2-4 6-4 6-1.5S12 9 12 9z"],globe:[K(12,12,9),"M3 12h18","M12 3a14 14 0 0 1 0 18a14 14 0 0 1 0-18z"],heart:["M12 20s-7-4.5-9-9a4.5 4.5 0 0 1 9-3 4.5 4.5 0 0 1 9 3c-2 4.5-9 9-9 9z"],infinity:["M7 9a3 3 0 1 0 0 6c3 0 7-6 10-6a3 3 0 1 1 0 6c-3 0-7-6-10-6z"],lock_open:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 7.5-2"],music:["M9 18V5l11-2v13",K(6,18,3),K(17,16,3)],people:[K(9,8,3.5),"M2 20a7 7 0 0 1 14 0","M16 4.5a3.5 3.5 0 0 1 0 7","M18 14a6 6 0 0 1 4 6"],person:[K(12,8,4),"M4 21a8 8 0 0 1 16 0"],photo:["M3 5h18v14H3z",K(8.5,9.5,1.5),"M3 17l5-5 4 4 3-3 6 6"],shield:["M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z"],sparkles:["M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8z","M19 15l.8 2.2L22 18l-2.2.8L19 21l-.8-2.2L16 18l2.2-.8z"],star:["M12 3l2.8 5.7 6.2.9-4.5 4.4 1 6.2L12 17.3l-5.5 2.9 1-6.2L3 9.6l6.2-.9z"],video:["M3 6h12v12H3z","M15 10l6-3v10l-6-3z"],arrow_right:["M4 12h15","M13 6l6 6-6 6"],calendar:["M4 6h16v15H4z","M4 10h16","M8 3v5","M16 3v5"],close:["M6 6l12 12","M18 6L6 18"],lock:["M5 11h14v10H5z","M8 11V7a4 4 0 0 1 8 0v4"],play:["M7 4l13 8-13 8z"],quote:["M5 17c3 0 4-2 4-5V7H4v5h3","M15 17c3 0 4-2 4-5V7h-5v5h3"],trophy:["M7 4h10v5a5 5 0 0 1-10 0z","M7 6H4v2a3 3 0 0 0 3 3","M17 6h3v2a3 3 0 0 1-3 3","M12 14v4","M8 21h8","M9 18h6v3H9z"]};var Be="http://www.w3.org/2000/svg";function pe(d,t,a){let l=d.createElementNS(Be,"svg");l.setAttribute("viewBox","0 0 24 24"),l.setAttribute("width",String(a)),l.setAttribute("height",String(a)),l.setAttribute("fill","none"),l.setAttribute("stroke","currentColor"),l.setAttribute("stroke-width","2"),l.setAttribute("stroke-linecap","round"),l.setAttribute("stroke-linejoin","round"),l.setAttribute("aria-hidden","true"),l.setAttribute("focusable","false");for(let c of t){let p=d.createElementNS(Be,"path");p.setAttribute("d",c),l.append(p)}return l}var dn=2,pn=2,f=(d,t=!1)=>({kind:"value",value:"plain",def:d,required:t}),j=d=>({kind:"value",value:"color",def:d}),We=d=>({kind:"value",value:"spacing",def:d}),zt=d=>({kind:"value",value:"radius",def:d}),X=(d=!1)=>({kind:"text",required:d}),Me=(d,t=!1)=>({kind:"list",item:d,required:t}),se=(d,t=!1)=>({kind:"object",item:d,required:t}),Ke=(d=!1)=>({kind:"component",required:d}),Re={kind:"components"},Ge={stack:{axis:f("vertical"),spacing:We(0),align:f("center"),distribution:f("start"),scroll:f(!1),children:Re},text:{text:X(),spans:Me("span"),font:f(),size:f(),weight:f(),line_height:f(),letter_spacing:f(),color:{kind:"value",value:"textColor",def:"text"},align:f("center"),max_lines:f(),uppercase:f(!1)},image:{src:f(void 0,!0),fit:f("fit"),aspect:f(),mask:se("mask"),overlay:{kind:"value",value:"textColor"},alt:X(),decorative:f(!1)},icon:{name:f(void 0,!0),color:j("accent"),size:f(24)},video:{src:f(void 0,!0),poster:f(),autoplay:f(!0),loop:f(!0),mute:f(!0),controls:f(!1),fit:f("fill"),aspect:f(),alt:X()},button:{action:se("action",!0),content:Ke(!0)},purchase_button:{content:Ke(!0),package:f()},package:{product:f(void 0,!0),plan:f(void 0,!0),selected:f(!1),offer:f(),children:Re},tabs:{},switch:{},carousel:{pages:Re,peek:f(0),spacing:f(8),loop:f(!1),auto_advance_ms:f(),indicator:se("indicator"),height:f("")},countdown:{},timeline:{items:Me("timeline_item",!0),line_color:j("accent"),line_width:f(2),icon_color:j("on_accent"),color:j("text"),spacing:f(16)},features:{items:Me("feature",!0),icon_color:j("accent"),color:j("text"),spacing:f(12)},spacer:{size:We()},divider:{color:j("muted"),thickness:f(1)},custom_html:{src:f(void 0,!0),height:f("",!0)}},Ht={style:{padding:{kind:"edges"},margin:{kind:"edges"},width:f(""),height:f(""),max_width:f(),background:{kind:"fill"},border:se("border"),corners:{kind:"corners"},shadow:se("shadow"),opacity:f(1)},border:{width:f(),color:j("")},shadow:{color:j(""),radius:f(0),x:f(0),y:f(0)},linear:{type:f(""),angle:f(180),stops:f()},radial:{type:f(""),center_x:f(.5),center_y:f(.5),radius:f(.5),stops:f()},image_fill:{type:f(""),src:f(),fit:f("fill")},video_fill:{type:f(""),src:f(),poster:f(),loop:f(!0)},animation:{type:f(""),duration_ms:f(300),delay_ms:f(0),easing:f("ease_out")},action:{type:f(""),url:f(),sheet:f(),package:f()},mask:{shape:f(""),radius:zt(0),depth:f(16)},span:{text:X(!0),bold:f(!1),italic:f(!1),underline:f(!1),strikethrough:f(!1),color:j(""),link:f()},timeline_item:{icon:f(void 0,!0),title:X(!0),text:X(),color:j("")},feature:{icon:f(void 0,!0),text:X(!0)},indicator:{style:f("dots"),color:j("muted"),active_color:j("accent"),size:f(8),spacing:f(6)},typography:{font:f("system"),size:f(),weight:f(400),line_height:f(),letter_spacing:f(0),text_style:f("body")}},Xe=new Set(["package","purchase_button"]),Ct={action:{type:f(""),url:f(),link:f(),sheet:f(),placement:f(),name:f(),value:f(),offer:f(),dismiss:f(!0)},presentation:{type:f(""),position:f("bottom"),auto_dismiss_seconds:f(),dismissible:f(!0),backdrop:j("#00000080")}},jt={modal:["type","dismissible","backdrop"],fullscreen:["type"],banner:["type","position","auto_dismiss_seconds","dismissible"],card:["type"]},Ft={linear:"linear",radial:"radial",image:"image_fill",video:"video_fill"},Nt=["top","bottom","leading","trailing"],Dt=["top_leading","top_trailing","bottom_leading","bottom_trailing"],Jt=Object.keys(Ge),un=Jt.filter(d=>!Xe.has(d)),Ye=/\{\{\s*([^{}]*?)\s*\}\}/g,Q=(d,t)=>typeof d=="object"&&d!==null&&Object.hasOwn(d,t),M=d=>typeof d=="object"&&d!==null&&!Array.isArray(d)?d:{},I=d=>Array.isArray(d)?d:[],G=(d,t)=>d??t;function It(d){let t="";for(let a of new TextEncoder().encode(d)){let l=String.fromCharCode(a);t+=/^[A-Za-z0-9._~-]$/.test(l)?l:`%${a.toString(16).toUpperCase().padStart(2,"0")}`}return t}function Vt(d){let t=Math.floor(d/86400),a=Math.floor(d%86400/3600),l=Math.floor(d%3600/60),c=d%60,p=h=>String(h).padStart(2,"0");return{countdown:t>0?`${t}d ${p(a)}:${p(l)}:${p(c)}`:a>0?`${a}:${p(l)}:${p(c)}`:`${p(l)}:${p(c)}`,days:String(t),hours:p(a),minutes:p(l),seconds:p(c)}}function fn(d){let t=[],a=c=>{if(Array.isArray(c))return c.forEach(a);if(typeof c!="object"||c===null)return;let p=c;if(p.type==="package"&&typeof p.product=="string"&&typeof p.plan=="string"){let g=`${p.product}.${p.plan}`;t.includes(g)||t.push(g)}for(let g of Object.keys(p).sort())a(p[g])},l=d;for(let c of["header","root","footer"])a(l[c]);for(let c of Object.keys(M(l.sheets)).sort())a(M(M(l.sheets)[c]).root);return t}function Ut(d){let t=new Map,a=c=>{if(Array.isArray(c))return c.forEach(a);if(typeof c!="object"||c===null)return;let p=c;if(p.type==="package"&&typeof p.offer=="string"){let g=`${p.product}.${p.plan}`;t.has(g)||t.set(g,p.offer)}for(let g of Object.keys(p).sort())a(p[g])},l=d;for(let c of["header","root","footer","sheets"])a(l[c]);return t}function gn(d,t){return _e(d,t).tree}function _e(d,t){return new ue("paywall",d,t).resolve()}function hn(d,t){return Ee(d,t).tree}function Ee(d,t){let{variables:a,...l}=t;return new ue("message",d,{...l,packages:{"":{...a}}}).resolve()}var ue=class{kind;d;opts;lang;texts={};palette;typography={};radii;spacing;packages;offers;selected="";tab="";paths=new WeakMap;tabsShown={};switchesOn={};countdowns={};constructor(t,a,l){this.kind=t,this.d=a,this.opts=l,this.offers=Ut(a);let c={};for(let[y,m]of Object.entries(l.packages??{})){let v={...m};this.open(y)||(m.price!==void 0?v.offer_price=m.price:delete v.offer_price),c[y]=v}this.packages=c;let p=M(this.d.locales),g=String(this.d.default_locale??""),h=l.locale;Q(p,h)||(h=h.split("-")[0]??"",Q(p,h)||(h=g)),this.lang=h;for(let y of[g,h])for(let[m,v]of Object.entries(M(p[y])))typeof v=="string"&&(this.texts[m]=v);let w=M(this.d.theme);this.palette=M(M(w.colors)[l.appearance]);for(let[y,m]of Object.entries(M(w.typography))){let v={};for(let[_,P]of Object.entries(this.objectFields("typography"))){let R=G(M(m)[_],P.def);R!=null&&(v[_]=R)}this.typography[y]=v}this.radii=M(w.radii),this.spacing=M(w.spacing)}open(t){let a=this.offers.get(t);return a!==void 0&&(this.opts.offers??[]).includes(a)}fields(t){if(!(this.kind==="message"&&Xe.has(t)))return Ge[t]}objectFields(t){return(this.kind==="message"?Ct[t]:void 0)??Ht[t]??{}}resolve(){let[t,a]=this.initialState();this.tab=t,this.selected=this.kind==="paywall"?a:"";let l={theme:{colors:this.palette,typography:this.typography,radii:this.radii,spacing:this.spacing}};this.kind==="paywall"&&(l.selected=a);let c=this.d.presentation;if(typeof c=="object"&&c!==null){let g=this.item("presentation",M(c),void 0)??{},h=jt[String(M(c).type)]??[];for(let w of Object.keys(g))h.includes(w)||delete g[w];l.presentation=g}for(let g of["header","root","footer"]){let h=this.d[g];if(typeof h=="object"&&h!==null){let w=this.component(M(h),g,"",!1);w&&(l[g]=w)}}let p={};if(typeof this.d.sheets=="object"&&this.d.sheets!==null){let g={};for(let[h,w]of Object.entries(M(this.d.sheets))){let y=this.component(M(M(w).root),`sheets.${h}.root`,"",!1);y&&(g[h]=y);let m=this.text(M(w).title,this.packages[this.selected]);m!==null&&(p[h]=m)}l.sheets=g}return{tree:l,pathOf:g=>this.paths.get(g),tabs:this.tabsShown,switches:this.switchesOn,sheetTitles:p,countdowns:this.countdowns,language:this.lang}}switchOn(t,a){return this.opts.switches&&Object.hasOwn(this.opts.switches,a)?this.opts.switches[a]:this.opts.switch?this.opts.switch==="on":t.default===!0}tabShown(t,a){let c=I(t.tabs).map(M).map(g=>String(g.id)),p=this.opts.tabs?.[a];return p!==void 0&&c.includes(p)?p:this.opts.tab?this.opts.tab:typeof t.default=="string"&&t.default!==""?t.default:c[0]??""}initialState(){let t="",a="",l="",c="",p=(h,w)=>{if(Array.isArray(h)){h.forEach((m,v)=>p(m,`${w}[${v}]`));return}if(typeof h!="object"||h===null)return;let y=h;switch(y.type){case"package":{let m=`${y.product}.${y.plan}`;l===""&&(l=m),y.selected===!0&&a===""&&(a=m);break}case"switch":{let m=this.switchOn(y,w),v=m?y.on_package:y.off_package;typeof v=="string"&&c===""&&(c=v),p(m?y.on:y.off,`${w}.${m?"on":"off"}`);return}case"tabs":{let m=this.tabShown(y,w);t===""&&(t=m),I(y.tabs).forEach((v,_)=>{let P=M(v);P.id===m&&(typeof P.package=="string"&&c===""&&(c=P.package),p(P.content,`${w}.tabs[${_}].content`))});return}}for(let m of Object.keys(y).sort())m!=="sheets"&&p(y[m],w===""?m:`${w}.${m}`)};for(let h of["header","root","footer"])p(this.d[h],h);let g=this.opts.selected||c||a||l;return[t,g]}holds(t,a){let l=a||this.selected;for(let[c,p]of Object.entries(t))switch(c){case"selected_package":if(!I(p).includes(this.selected))return!1;break;case"intro_eligible":if((this.opts.eligible??[]).includes(l)!==p)return!1;break;case"offer_open":if(this.open(l)!==p)return!1;break;case"platform":if(!I(p).includes(this.opts.platform))return!1;break;case"locale":if(!I(p).includes(this.opts.locale)&&!I(p).includes(this.lang))return!1;break;case"appearance":if(p!==this.opts.appearance)return!1;break;case"tab":if(p!==this.tab)return!1;break}return!0}component(t,a,l,c){if(typeof t.visible=="object"&&t.visible!==null&&!this.holds(M(t.visible),l))return null;let p=String(t.type),g=l,h=c;p==="package"&&(g=`${t.product}.${t.plan}`,h=g===this.selected);let w={type:p};this.paths.set(w,a),Q(t,"id")&&(w.id=t.id);let y={...M(t.style)};h&&Object.assign(y,M(M(t.states).selected)),Object.keys(y).length>0&&(w.style=this.style(y)),typeof t.animation=="object"&&t.animation!==null&&(w.animation=this.defaults(M(t.animation),this.objectFields("animation")));let m=this.packages[g||this.selected];switch(p){case"tabs":return this.tabs(t,w,a,g);case"switch":return this.switchOf(t,w,a,g,h);case"countdown":return this.countdown(t,w,a,g,h);case"purchase_button":{let v=typeof t.package=="string"?t.package:this.selected;w.package=v,this.open(v)&&(w.offer=this.offers.get(v));let _=this.component(M(t.content),`${a}.content`,v,h);return _?(w.content=_,w):null}case"package":w.product=t.product,w.plan=t.plan,w.selected=h,typeof t.offer=="string"&&(this.opts.offers??[]).includes(t.offer)&&(w.offer=t.offer)}for(let[v,_]of Object.entries(this.fields(p)??{})){if(p==="package"&&(v==="product"||v==="plan"||v==="selected"||v==="offer"))continue;let P=t[v],R=Q(t,v);switch(_.kind){case"component":{if(!R)continue;let x=this.component(M(P),`${a}.${v}`,g,h);if(!x&&_.required)return null;x&&(w[v]=x);break}case"components":{let x=[];I(P).forEach((T,O)=>{let V=this.component(M(T),`${a}.${v}[${O}]`,g,h);V&&x.push(V)}),w[v]=x;break}case"text":{let x=this.text(P,m);if(x!==null)w[v]=x;else if(_.required||p==="text"&&v==="text"&&R)return null;break}case"list":{let x=[];for(let T of I(P)){let O=this.item(_.item,M(T),m);O&&x.push(O)}if(p==="text"&&x.length===0&&R)return null;R&&(w[v]=x);break}case"object":{if(R){let x=this.object(M(P),_.item,m);if(x===null&&_.required)return null;w[v]=x}else v==="indicator"&&(w[v]=this.object({},_.item,m));break}case"value":{let x=this.value(G(P,_.def),_);x!=null&&x!==""&&(w[v]=x);break}}}return p==="text"&&this.typeStyle(w),w}typeStyle(t){if(typeof t.size!="string"){t.size!==void 0&&t.size!==null&&(t.text_style="body");return}let a=this.typography[t.size];for(let l of["font","weight","line_height","letter_spacing","text_style"])!Q(t,l)&&a?.[l]!==void 0&&a?.[l]!==null&&(t[l]=a[l]);t.size=a?.size??null}tabs(t,a,l,c){let p=this.tabShown(t,l);this.tabsShown[l]=p;let g=[];return I(t.tabs).forEach((h,w)=>{let y=M(h),m=y.id===p,v=this.component(M(y.label),`${l}.tabs[${w}].label`,c,m);if(g.push({id:y.id,selected:m,label:v}),m){let _=this.component(M(y.content),`${l}.tabs[${w}].content`,c,!1);_&&(a.content=_)}}),a.tabs=g,typeof t.bar=="object"&&t.bar!==null&&(a.bar=this.style(M(t.bar))),a}switchOf(t,a,l,c,p){let g=this.switchOn(t,l);this.switchesOn[l]=g,a.on=g;let h=this.text(t.label,this.packages[c||this.selected]);h!==null&&(a.label=h),a.tint=this.color(String(G(t.tint,"accent")));let w=g?"on":"off",y=this.component(M(t[w]),`${l}.${w}`,c,p);return y&&(a.content=y),a}countdown(t,a,l,c,p){let g=M(t.target),h=this.opts.now??Date.now(),w;if(typeof g.after_open_seconds=="number"?w=Math.trunc(g.after_open_seconds)-(this.opts.openedSecondsAgo??0):w=Math.trunc((Date.parse(String(g.at))-h)/1e3),w>0){a.state="counting",a.remaining_seconds=w,this.countdowns[l]=w;let y=this.packages,m={};for(let[_,P]of Object.entries(y))m[_]={...P,...Vt(w)};this.packages=m;let v=this.component(M(t.counting),`${l}.counting`,c,p);return v&&(a.content=v),this.packages=y,a}if(a.state="ended",a.remaining_seconds=0,typeof t.ended=="object"&&t.ended!==null){let y=this.component(M(t.ended),`${l}.ended`,c,p);y&&(a.content=y)}return a}item(t,a,l){let c={};for(let[p,g]of Object.entries(this.objectFields(t))){let h=a[p];if(g.kind==="text"){let w=this.text(h,l);if(w!==null)c[p]=w;else if(g.required)return null}else{let w=g.def,y=this.value(G(h,w),g);y!=null&&(Q(a,p)||w!=null&&w!=="")&&(c[p]=y)}}return c}object(t,a,l){if(a==="style")return this.style(t);let c=this.item(a,t,l)??{};if(a==="action")for(let p of["url","link"]){if(typeof c[p]!="string")continue;let g=qt(c[p],l);if(g===null)return null;c[p]=g}return c}defaults(t,a){let l={};for(let[c,p]of Object.entries(a)){let g=G(t[c],p.def);g!=null&&g!==""&&(l[c]=g)}return l}style(t){let a={};for(let[l,c]of Object.entries(t)){let p=this.objectFields("style")[l];if(!p){a[l]=c;continue}switch(p.kind){case"edges":a[l]=this.sides(c,Nt,this.spacing);break;case"corners":a[l]=this.sides(c,Dt,this.radii);break;case"fill":a[l]=this.fill(c);break;case"object":{let g=M(c),h={};for(let[w,y]of Object.entries(this.objectFields(p.item))){let m=G(g[w],y.def);m!=null&&m!==""&&(h[w]=this.value(m,y))}a[l]=h;break}default:a[l]=c}}return a}sides(t,a,l){let c={};for(let p of a){let g=typeof t=="object"&&t!==null?G(M(t)[p],0):t;c[p]=Ae(g,l)}return c}fill(t){if(typeof t=="string")return{type:"color",color:this.color(t)};let a=M(t),l=this.defaults(a,this.objectFields(Ft[String(a.type)]??""));return Array.isArray(a.stops)&&(l.stops=a.stops.map(c=>({color:this.color(String(M(c).color)),at:M(c).at}))),l}value(t,a){if(a.kind!=="value")return t;switch(a.value){case"color":return typeof t=="string"&&t!==""?this.color(t):t;case"textColor":return typeof t=="string"?this.color(t):t==null?t:this.fill(t);case"spacing":return Ae(t,this.spacing);case"radius":return Ae(t,this.radii);default:return t}}color(t){let a=Object.hasOwn(this.palette,t)?this.palette[t]:void 0;return typeof a=="string"?a:t}text(t,a){let l;if(typeof t=="string")l=t;else if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let p=t.t;l=typeof p=="string"&&Object.hasOwn(this.texts,p)?this.texts[p]:""}else return null;let c=!1;return l=l.replace(Ye,(p,g)=>{let h=a&&Object.hasOwn(a,g)?a[g]:void 0;return typeof h!="string"||h===""?(c=!0,""):h}),c||l.trim()===""?null:l}};function qt(d,t){let a=!1,l=d.replace(Ye,(c,p)=>{let g=t&&Object.hasOwn(t,p)?t[p]:void 0;return typeof g!="string"||g===""?(a=!0,""):It(g)});return a?null:l}function Ae(d,t){return typeof d=="string"?Object.hasOwn(t,d)?t[d]:null:d}var Bt={packages:"Choose a plan",close:"Close",restore:"Restore purchases",page:(d,t)=>`${d} of ${t}`},ee={system:'-apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',rounded:'ui-rounded, "SF Pro Rounded", Nunito, "Varela Round", system-ui, -apple-system, sans-serif',serif:'ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif',mono:'ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace'},Wt=1.35,Ze=20,Kt=new Set(["button","purchase_button","package","text"]),Gt=new Set(["ar","he","fa","ur","ps","yi","dv","ug","ku","sd"]),Qe={ease_out:"cubic-bezier(0.16, 1, 0.3, 1)",ease_in_out:"cubic-bezier(0.65, 0, 0.35, 1)",spring:"cubic-bezier(0.34, 1.56, 0.64, 1)"},Xt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},Yt={start:"flex-start",center:"center",end:"flex-end",space_between:"space-between",space_around:"space-around",space_evenly:"space-evenly"},Zt={stack:["children"],package:["children"],button:["content"],purchase_button:["content"],tabs:["tabs","content"],switch:["content"],carousel:["pages"],countdown:["content"]},Qt={package:["selected"],purchase_button:["package"],switch:["on"],countdown:["state","remaining_seconds"]},en=`
3
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:${ee.system};font-size:1rem;line-height:1.3;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;text-rendering:optimizeLegibility}
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
2
- import{c as D,g as b,l as O,m as _,s as F}from"./4YCXKEZV.js";import{b as w}from"./NANJIH3L.js";var I=20,M=2048,S=256,j=/^[A-Za-z][A-Za-z0-9_.-]{0,39}$/,m=e=>new w({op:"GetPlacementPaywall",status:0,code:"invalid_attributes",message:e});function L(e){let n='"';for(let t=0;t<e.length;t++){let a=e.charCodeAt(t);a===34?n+='\\"':a===92?n+="\\\\":a>=32&&a<=126?n+=e[t]:n+=`\\u${a.toString(16).padStart(4,"0")}`}return`${n}"`}function T(e){let n=Object.keys(e??{}).sort((i,r)=>i<r?-1:i>r?1:0);if(n.length===0)return;if(n.length>I)throw m(`${n.length} attributes: at most ${I}`);let t=[];for(let i of n){if(!j.test(i))throw m(`the attribute ${JSON.stringify(i)}: a key is a letter, then letters, digits and _ . -, at most 40`);let r=e[i],s;if(typeof r=="string"){if(new TextEncoder().encode(r).length>S)throw m(`the attribute ${JSON.stringify(i)} is over ${S} bytes`);s=L(r)}else if(typeof r=="number"){if(!Number.isFinite(r))throw m(`the attribute ${JSON.stringify(i)} is no number`);s=String(Object.is(r,-0)?0:r)}else if(typeof r=="boolean")s=r?"true":"false";else throw m(`the attribute ${JSON.stringify(i)}: a value is a text, a number or a boolean`);t.push(`"${i}":${s}`)}let a=`{${t.join(",")}}`;if(a.length>M)throw m(`the attributes are ${a.length} bytes: at most ${M}`);return a}function x(e){let n=/^P(\d+)([DWMY])$/.exec(e??"");if(!n)return null;let t=Number(n[1]);if(!Number.isSafeInteger(t)||t<1)return null;switch(n[2]){case"D":return{count:t,unit:"day",months:t*12/365};case"W":return{count:t,unit:"week",months:t*12/52};case"M":return{count:t,unit:"month",months:t};default:return{count:t,unit:"year",months:t*12}}}function R(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function $(e,n,t){let a=e/10**R(n);try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(a)}catch{return`${a.toFixed(R(n))} ${n}`}}function X(e,n){try{let t=new Intl.NumberFormat(n,{style:"unit",unit:e.unit,unitDisplay:"long"});return e.count>1?t.format(e.count):t.formatToParts(1).filter(i=>i.type==="unit").map(i=>i.value).join("").trim()||t.format(1)}catch{return e.count>1?`${e.count} ${e.unit}s`:e.unit}}var K={en:e=>`${e} free`,tr:e=>`${e} \xFCcretsiz`,de:e=>`${e} kostenlos`,es:e=>`${e} gratis`,it:e=>`${e} gratis`,nl:e=>`${e} gratis`,pt:e=>`${e} gr\xE1tis`,sv:e=>`${e} gratis`,da:e=>`${e} gratis`,nb:e=>`${e} gratis`};function B(e,n){let t;try{t=new Intl.NumberFormat(n,{style:"unit",unit:e.unit,unitDisplay:"long"}).format(e.count)}catch{t=`${e.count} ${e.unit}${e.count>1?"s":""}`}let a=K[n.split("-")[0].toLowerCase()];return a?a(t):t}function H(e,n){try{return new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:0}).format(e)}catch{return`${Math.round(e*100)}%`}}function E(e,n){let t=new Map,a=new Map;for(let r of e){let s=x(r.period);if(!s)continue;let u=r.price.amount/s.months;t.set(r.key,u),a.set(r.price.currency,Math.max(a.get(r.price.currency)??0,u))}let i={};for(let r of e){let s={product_name:r.productName,price:$(r.price.amount,r.price.currency,n)},u=x(r.period);if(u){s.period=X(u,n),s.price_per_month=$(Math.round(t.get(r.key)),r.price.currency,n);let o=a.get(r.price.currency)??0,d=o>0?Math.floor((1-t.get(r.key)/o)*100)/100:0;d>=.01&&(s.savings=H(d,n))}let l=r.intro?.mode==="free_trial"?x(r.intro.duration):null;l&&(s.trial=B(l,n)),r.offer&&(s.offer_price=$(Math.floor((r.price.amount*(100-r.offer.percentOff)+50)/100),r.price.currency,n)),i[r.key]=s}return i}var V={version:"0.25.0"};var C=`palbase-js/${V.version}`;var k=class{placement;source;definition;assets;offerings;offers;shown;deps;exposed=!1;constructor(n,t,a,i,r,s,u={},l=[]){this.placement=n,this.source=t,this.definition=a,this.assets=u,this.offerings=i,this.offers=l,this.shown=r,this.deps=s}packages(n){return E(Y(this.offerings,O(this.definition),n,Z(this.definition,this.offers)),n)}render(n,t){let a=t.locale??globalThis.navigator?.language??this.definition.default_locale,i=t.appearance===void 0?q():void 0,r=this.packages(a),s=F(n,{definition:this.definition,locale:a,appearance:t.appearance??(i?.matches?"dark":"light"),platform:"web",packages:r,eligible:Object.entries(r).filter(([,o])=>o.trial).map(([o])=>o),offers:this.offers.filter(o=>o.web).map(o=>o.key),links:t.links,assets:this.assets},{onPurchase:async o=>{try{let d=await this.deps.checkout({product:o.product,plan:o.plan,successUrl:t.successUrl,cancelUrl:t.cancelUrl,...o.offer!==void 0?{offer:o.offer}:{}});t.onCheckout?t.onCheckout(d,o):globalThis.location.assign(d)}catch(d){if(!t.onError)throw d;t.onError(d,o)}},onClose:t.onClose,onLink:t.onLink,labels:t.labels}),u=o=>s.update({appearance:o.matches?"dark":"light"});i?.addEventListener?.("change",u),!this.exposed&&this.shown&&(this.exposed=!0,this.deps.expose(this));let l=s.destroy.bind(s);return s.destroy=()=>{i?.removeEventListener?.("change",u),l()},s}};function q(){try{return globalThis.matchMedia?.("(prefers-color-scheme: dark)")}catch{return}}function W(e,n){if(!e)return;let t=n.split("-")[0];return e[n]?.name??e[t]?.name??Object.values(e).find(a=>a.name)?.name}function Y(e,n,t,a=new Map){let i=[];for(let r of n){let[s,u]=r.split("."),l=e.products.find(f=>f.key===s),o=l?.channels.web,d=o?.plans.find(f=>f.key===u);if(!l||!o||!d)continue;let p=a.get(r),g=p?.discount?p.discount.percent:p?.trial?100:void 0;i.push({key:r,productName:W(o.locales,t)??l.key,price:{amount:d.price.amount,currency:d.price.currency},period:d.period,intro:d.intro,...g!==void 0?{offer:{percentOff:g}}:{}})}return i}function Z(e,n){let t=new Map;for(let[a,i]of _(e)){let r=n.find(s=>s.key===i);r?.web&&t.set(a,r)}return t}var G={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"}},N=e=>({type:"button",action:{type:e},content:{type:"text",text:{t:e},size:"caption",color:"muted"}});function Q(e){let n=e.products.flatMap(t=>(t.channels.web?.plans??[]).map(a=>({product:t.key,plan:a.key}))).slice(0,6);return n.length===0?null:{schema:2,name:"Default",default_locale:"en",locales:G,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:n.map(({product:t,plan:a})=>({type:"package",product:t,plan:a,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:[N("terms"),N("privacy")]}]}}}function h(){try{return globalThis.localStorage}catch{return}}function ee(e){try{let n=h()?.getItem(e);if(!n)return;let t=JSON.parse(n),a=t?.answer;return typeof a!="object"||a===null||typeof a.paywall_id!="string"||typeof a.version!="number"||typeof a.definition!="object"||a.definition===null||typeof a.offerings!="object"||a.definition.schema!==2?void 0:{etag:typeof t.etag=="string"?t.etag:void 0,answer:a}}catch{return}}function P(e,n){try{n?h()?.setItem(e,JSON.stringify(n)):h()?.removeItem(e)}catch{}}var z=()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,U;function te(e){let n=`palbase.installation.${e}`;try{let t=h()?.getItem(n);if(t&&/^[A-Za-z0-9._:-]{1,128}$/.test(t))return t;let a=z();if(h()?.setItem(n,a),h()?.getItem(n)===a)return a}catch{}return U??=z(),U}async function ye(e,n,t,a,i={}){let{signal:r,fetch:s}=i,u=T(i.attributes),l=`palbase.paywall.${n}.${t}`,o=te(n),p={checkout:a,expose:async c=>{if(c.shown)try{let v={paywall_id:c.shown.paywallId,version:c.shown.version,...c.shown.variant!==void 0?{variant:c.shown.variant}:{},...c.shown.ruleId!==void 0?{rule_id:c.shown.ruleId}:{}};await e.recordPaywallExposure({path:{placement:t},headers:{"X-Palbase-Installation":o},body:v})}catch{}}},g=async(c,v)=>new k(t,v,c.definition,c.offerings,{paywallId:c.paywall_id,version:c.version,...c.variant!==void 0?{variant:c.variant}:{},...c.rule_id!==void 0?{ruleId:c.rule_id}:{}},p,await D(c.assets??[],{signal:r,...s?{fetch:s}:{}}),c.offers??[]),f=ee(l),y;try{y=await e.getPlacementPaywall({path:{placement:t},query:{channel:"web"},headers:{"X-Palbase-Paywall-Schema":2,"X-Palbase-Installation":o,"X-Platform":"web","X-Palbase-SDK":C,...i.appVersion?{"X-Palbase-Client-Version":i.appVersion}:{},...i.app?{"X-Palbase-App":i.app}:{},...i.locale?{"Accept-Language":i.locale}:{},...u!==void 0?{"X-Palbase-Attributes":u}:{},...f?.etag?{"If-None-Match":f.etag}:{}},signal:r})}catch(c){if(c instanceof w&&c.status===404||c instanceof w&&c.status===400&&c.code.startsWith("invalid_"))return P(l,void 0),A(e,t,p,r);if(f&&!r?.aborted)return g(f.answer,"cache");throw c}return y.status===200?(P(l,{etag:y.headers.get("etag")??void 0,answer:y.data}),g(y.data,"server")):y.status===304&&f?g(f.answer,"server"):(P(l,void 0),A(e,t,p,r))}async function A(e,n,t,a){let i=(await e.getOfferings({query:{channel:"web"},signal:a})).data,r=Q(i);return r?new k(n,"default",r,i,void 0,t):null}export{T as a,x as b,$ as c,X as d,E as e,k as f,Q as g,ye as h};
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
+ import{c as D,g as b,l as O,m as _,s as F}from"./Q2SNPNA4.js";import{b as w}from"./YE7MYOBE.js";var I=20,M=2048,S=256,j=/^[A-Za-z][A-Za-z0-9_.-]{0,39}$/,m=e=>new w({op:"GetPlacementPaywall",status:0,code:"invalid_attributes",message:e});function L(e){let n='"';for(let t=0;t<e.length;t++){let a=e.charCodeAt(t);a===34?n+='\\"':a===92?n+="\\\\":a>=32&&a<=126?n+=e[t]:n+=`\\u${a.toString(16).padStart(4,"0")}`}return`${n}"`}function T(e){let n=Object.keys(e??{}).sort((i,r)=>i<r?-1:i>r?1:0);if(n.length===0)return;if(n.length>I)throw m(`${n.length} attributes: at most ${I}`);let t=[];for(let i of n){if(!j.test(i))throw m(`the attribute ${JSON.stringify(i)}: a key is a letter, then letters, digits and _ . -, at most 40`);let r=e[i],s;if(typeof r=="string"){if(new TextEncoder().encode(r).length>S)throw m(`the attribute ${JSON.stringify(i)} is over ${S} bytes`);s=L(r)}else if(typeof r=="number"){if(!Number.isFinite(r))throw m(`the attribute ${JSON.stringify(i)} is no number`);s=String(Object.is(r,-0)?0:r)}else if(typeof r=="boolean")s=r?"true":"false";else throw m(`the attribute ${JSON.stringify(i)}: a value is a text, a number or a boolean`);t.push(`"${i}":${s}`)}let a=`{${t.join(",")}}`;if(a.length>M)throw m(`the attributes are ${a.length} bytes: at most ${M}`);return a}function x(e){let n=/^P(\d+)([DWMY])$/.exec(e??"");if(!n)return null;let t=Number(n[1]);if(!Number.isSafeInteger(t)||t<1)return null;switch(n[2]){case"D":return{count:t,unit:"day",months:t*12/365};case"W":return{count:t,unit:"week",months:t*12/52};case"M":return{count:t,unit:"month",months:t};default:return{count:t,unit:"year",months:t*12}}}function R(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function $(e,n,t){let a=e/10**R(n);try{return new Intl.NumberFormat(t,{style:"currency",currency:n}).format(a)}catch{return`${a.toFixed(R(n))} ${n}`}}function X(e,n){try{let t=new Intl.NumberFormat(n,{style:"unit",unit:e.unit,unitDisplay:"long"});return e.count>1?t.format(e.count):t.formatToParts(1).filter(i=>i.type==="unit").map(i=>i.value).join("").trim()||t.format(1)}catch{return e.count>1?`${e.count} ${e.unit}s`:e.unit}}var K={en:e=>`${e} free`,tr:e=>`${e} \xFCcretsiz`,de:e=>`${e} kostenlos`,es:e=>`${e} gratis`,it:e=>`${e} gratis`,nl:e=>`${e} gratis`,pt:e=>`${e} gr\xE1tis`,sv:e=>`${e} gratis`,da:e=>`${e} gratis`,nb:e=>`${e} gratis`};function B(e,n){let t;try{t=new Intl.NumberFormat(n,{style:"unit",unit:e.unit,unitDisplay:"long"}).format(e.count)}catch{t=`${e.count} ${e.unit}${e.count>1?"s":""}`}let a=K[n.split("-")[0].toLowerCase()];return a?a(t):t}function H(e,n){try{return new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:0}).format(e)}catch{return`${Math.round(e*100)}%`}}function E(e,n){let t=new Map,a=new Map;for(let r of e){let s=x(r.period);if(!s)continue;let u=r.price.amount/s.months;t.set(r.key,u),a.set(r.price.currency,Math.max(a.get(r.price.currency)??0,u))}let i={};for(let r of e){let s={product_name:r.productName,price:$(r.price.amount,r.price.currency,n)},u=x(r.period);if(u){s.period=X(u,n),s.price_per_month=$(Math.round(t.get(r.key)),r.price.currency,n);let o=a.get(r.price.currency)??0,d=o>0?Math.floor((1-t.get(r.key)/o)*100)/100:0;d>=.01&&(s.savings=H(d,n))}let l=r.intro?.mode==="free_trial"?x(r.intro.duration):null;l&&(s.trial=B(l,n)),r.offer&&(s.offer_price=$(Math.floor((r.price.amount*(100-r.offer.percentOff)+50)/100),r.price.currency,n)),i[r.key]=s}return i}var V={version:"0.25.1"};var C=`palbase-js/${V.version}`;var k=class{placement;source;definition;assets;offerings;offers;shown;deps;exposed=!1;constructor(n,t,a,i,r,s,u={},l=[]){this.placement=n,this.source=t,this.definition=a,this.assets=u,this.offerings=i,this.offers=l,this.shown=r,this.deps=s}packages(n){return E(Y(this.offerings,O(this.definition),n,Z(this.definition,this.offers)),n)}render(n,t){let a=t.locale??globalThis.navigator?.language??this.definition.default_locale,i=t.appearance===void 0?q():void 0,r=this.packages(a),s=F(n,{definition:this.definition,locale:a,appearance:t.appearance??(i?.matches?"dark":"light"),platform:"web",packages:r,eligible:Object.entries(r).filter(([,o])=>o.trial).map(([o])=>o),offers:this.offers.filter(o=>o.web).map(o=>o.key),links:t.links,assets:this.assets},{onPurchase:async o=>{try{let d=await this.deps.checkout({product:o.product,plan:o.plan,successUrl:t.successUrl,cancelUrl:t.cancelUrl,...o.offer!==void 0?{offer:o.offer}:{}});t.onCheckout?t.onCheckout(d,o):globalThis.location.assign(d)}catch(d){if(!t.onError)throw d;t.onError(d,o)}},onClose:t.onClose,onLink:t.onLink,labels:t.labels}),u=o=>s.update({appearance:o.matches?"dark":"light"});i?.addEventListener?.("change",u),!this.exposed&&this.shown&&(this.exposed=!0,this.deps.expose(this));let l=s.destroy.bind(s);return s.destroy=()=>{i?.removeEventListener?.("change",u),l()},s}};function q(){try{return globalThis.matchMedia?.("(prefers-color-scheme: dark)")}catch{return}}function W(e,n){if(!e)return;let t=n.split("-")[0];return e[n]?.name??e[t]?.name??Object.values(e).find(a=>a.name)?.name}function Y(e,n,t,a=new Map){let i=[];for(let r of n){let[s,u]=r.split("."),l=e.products.find(f=>f.key===s),o=l?.channels.web,d=o?.plans.find(f=>f.key===u);if(!l||!o||!d)continue;let p=a.get(r),g=p?.discount?p.discount.percent:p?.trial?100:void 0;i.push({key:r,productName:W(o.locales,t)??l.key,price:{amount:d.price.amount,currency:d.price.currency},period:d.period,intro:d.intro,...g!==void 0?{offer:{percentOff:g}}:{}})}return i}function Z(e,n){let t=new Map;for(let[a,i]of _(e)){let r=n.find(s=>s.key===i);r?.web&&t.set(a,r)}return t}var G={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"}},N=e=>({type:"button",action:{type:e},content:{type:"text",text:{t:e},size:"caption",color:"muted"}});function Q(e){let n=e.products.flatMap(t=>(t.channels.web?.plans??[]).map(a=>({product:t.key,plan:a.key}))).slice(0,6);return n.length===0?null:{schema:2,name:"Default",default_locale:"en",locales:G,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:n.map(({product:t,plan:a})=>({type:"package",product:t,plan:a,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:[N("terms"),N("privacy")]}]}}}function h(){try{return globalThis.localStorage}catch{return}}function ee(e){try{let n=h()?.getItem(e);if(!n)return;let t=JSON.parse(n),a=t?.answer;return typeof a!="object"||a===null||typeof a.paywall_id!="string"||typeof a.version!="number"||typeof a.definition!="object"||a.definition===null||typeof a.offerings!="object"||a.definition.schema!==2?void 0:{etag:typeof t.etag=="string"?t.etag:void 0,answer:a}}catch{return}}function P(e,n){try{n?h()?.setItem(e,JSON.stringify(n)):h()?.removeItem(e)}catch{}}var z=()=>globalThis.crypto?.randomUUID?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,U;function te(e){let n=`palbase.installation.${e}`;try{let t=h()?.getItem(n);if(t&&/^[A-Za-z0-9._:-]{1,128}$/.test(t))return t;let a=z();if(h()?.setItem(n,a),h()?.getItem(n)===a)return a}catch{}return U??=z(),U}async function ye(e,n,t,a,i={}){let{signal:r,fetch:s}=i,u=T(i.attributes),l=`palbase.paywall.${n}.${t}`,o=te(n),p={checkout:a,expose:async c=>{if(c.shown)try{let v={paywall_id:c.shown.paywallId,version:c.shown.version,...c.shown.variant!==void 0?{variant:c.shown.variant}:{},...c.shown.ruleId!==void 0?{rule_id:c.shown.ruleId}:{}};await e.recordPaywallExposure({path:{placement:t},headers:{"X-Palbase-Installation":o},body:v})}catch{}}},g=async(c,v)=>new k(t,v,c.definition,c.offerings,{paywallId:c.paywall_id,version:c.version,...c.variant!==void 0?{variant:c.variant}:{},...c.rule_id!==void 0?{ruleId:c.rule_id}:{}},p,await D(c.assets??[],{signal:r,...s?{fetch:s}:{}}),c.offers??[]),f=ee(l),y;try{y=await e.getPlacementPaywall({path:{placement:t},query:{channel:"web"},headers:{"X-Palbase-Paywall-Schema":2,"X-Palbase-Installation":o,"X-Platform":"web","X-Palbase-SDK":C,...i.appVersion?{"X-Palbase-Client-Version":i.appVersion}:{},...i.app?{"X-Palbase-App":i.app}:{},...i.locale?{"Accept-Language":i.locale}:{},...u!==void 0?{"X-Palbase-Attributes":u}:{},...f?.etag?{"If-None-Match":f.etag}:{}},signal:r})}catch(c){if(c instanceof w&&c.status===404||c instanceof w&&c.status===400&&c.code.startsWith("invalid_"))return P(l,void 0),A(e,t,p,r);if(f&&!r?.aborted)return g(f.answer,"cache");throw c}return y.status===200?(P(l,{etag:y.headers.get("etag")??void 0,answer:y.data}),g(y.data,"server")):y.status===304&&f?g(f.answer,"server"):(P(l,void 0),A(e,t,p,r))}async function A(e,n,t,a){let i=(await e.getOfferings({query:{channel:"web"},signal:a})).data,r=Q(i);return r?new k(n,"default",r,i,void 0,t):null}export{T as a,x as b,$ as c,X as d,E as e,k as f,Q as g,ye as h};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
2
- import{a as u,b as d}from"./NANJIH3L.js";var p={too_many_chats:()=>"this user is in as many chats as they may be (100): delete or leave one before starting another",too_many_endpoints:()=>"the project holds as many tool endpoints as it may (32): delete one (ai.endpoints.delete) before putting another",too_many_messages:t=>`this user has sent as many messages this minute as the project allows${t.retryAfter!==void 0?`: write again in ${t.retryAfter} s`:""}`,history_full:()=>"the project keeps as much chat history as it may: delete chats to write again",not_your_turn:()=>"this turn is another member's: only the member who started it (or the project's server) answers its tools and decides its approvals",not_a_member:()=>"the member the server acts as (as) is not in this chat: put them in it first (chats.members.put), or act as the server",goal_lapsed:()=>"the goal was set as a member who no longer stands where they stood then (out of the chat, or the chat no longer theirs alone): it is not resumed \u2014 clear it, or set another for the chat as it is now",goal_achieved:()=>"the goal is achieved: set a new one (chats.goal.set) to work on",turn_running:()=>"the chat's agent is at work on a turn: fork it once the turn has ended, or stop it first (chats.stop)",fork_too_large:()=>"what came before that message is more than a fork begins with (512 KiB): fork it before an earlier message",too_many_voices:t=>`this user has started as many voices this hour as the project allows (5)${t.retryAfter!==void 0?`: start again in ${t.retryAfter} s`:""}`,voice_active:()=>"another member's voice is live in this chat \u2014 one voice talks in a chat at a time: wait for it to end",not_your_voice:()=>"this voice is another member's: only its member \u2014 or the server as itself \u2014 reads, tells and closes it",voice_closed:()=>"the voice has ended: start a new one (chats.voice.start)",no_workspace:()=>"this chat works in no workspace, and files go into one: start the chat with a workspace, or send pictures as images",attachment_not_found:()=>"a picture or a file given is not one its writer may attach: a file of the project's storage \u2014 for a member, their own or a public bucket's",attachment_too_large:()=>"an attachment is past its bound: 5 MiB a picture, 15 MiB a file",attachment_changed:()=>"a file changed while it was being attached: send the message again",unsupported_image:()=>"a picture is not png, jpeg, webp or gif by its bytes: send it as a file",image_not_found:()=>"a picture given is not a file of the project's storage: upload it first (storage.from(bucket).upload(path, file)) and give that bucket and path",storage_unavailable:t=>`the project's storage did not answer when the model was to read a picture${t.retryAfter!==void 0?`: try again in ${t.retryAfter} s`:"; try again shortly"}`,draft_changed:()=>"the agent's draft was saved again since its revision was read: read it again (ai.agents.get) and make the change on that one",agent_defined_in_code:()=>"this agent is the backend's code's (its build's contract names it): it is changed in the code, and has no draft, versions or delete",nothing_to_publish:()=>"the agent's draft is the version published already: save a change to it first (ai.agents.saveDraft)",agent_not_published:()=>"the agent has no version published yet: publish its draft (ai.agents.publish) before a chat or an answer names it",ai_budget_reached:()=>"the project's monthly AI budget is spent: Palbase's models serve it again when the month turns (UTC) or an owner or admin raises the budget (Studio \u203A AI \u203A Settings, or palbase ai:settings:set --monthly-budget) \u2014 or connect the project's own key for the model's provider (ai.connectProvider), which its provider bills",ai_payment_required:()=>"the month's free AI dollar is spent and the project's account has no balance to pay for Palbase's models: top it up (Studio \u203A Billing) \u2014 or connect the project's own key for the model's provider (ai.connectProvider), which its provider bills",billing_unavailable:t=>`Palbase's billing did not say whether its models serve the project${t.retryAfter!==void 0?`: try again in ${t.retryAfter} s`:"; try again shortly"}`},g=new WeakSet;function c(t){if(!(t instanceof d)||g.has(t))return t;let r=p[t.code];if(!r)return t;let s=new d({op:t.op,status:t.status,code:t.code,message:`${r(t)} (${t.op}: ${t.status} ${t.code})`,requestId:t.requestId,retryAfter:t.retryAfter,body:t.body,cause:t});return g.add(s),s}function m(t){return t.catch(r=>{throw c(r)})}function _(t){if(typeof t!="object"||t===null)return;let r=t,s=r.data;if(typeof r.type!="string"||typeof s!="object"||s===null||Array.isArray(s))return;let e=u(s),i=typeof r.id=="number"&&Number.isSafeInteger(r.id)?r.id:0;switch(r.type){case"message":return typeof e.client_id=="string"?{type:"message",seq:i,message:e}:void 0;case"turn":{if(typeof e.response_id!="string"||typeof e.status!="string")return;let n={...e,type:"turn",seq:i};return n.waiting??=null,n.error??=null,n}case"text":{let n=e.offset;return typeof e.response_id!="string"||typeof n!="number"||!Number.isInteger(n)||n<0?void 0:{type:"text",response_id:e.response_id,offset:n,text:typeof e.text=="string"?e.text:""}}case"reset":{let n=e.offset;return typeof e.response_id!="string"||typeof n!="number"||!Number.isInteger(n)||n<0?void 0:{type:"reset",response_id:e.response_id,offset:n}}case"tool":{if(typeof e.call_id!="string"||typeof e.response_id!="string")return;let n=e.omitted_bytes;return{...e,type:"tool",seq:i,omittedBytes:typeof n=="number"&&Number.isSafeInteger(n)&&n>0?n:0,outputTruncated:e.output_truncated===!0}}case"agent":return typeof e.parent_response_id=="string"?{...e,type:"agent",seq:i}:void 0;case"thinking":{if(typeof e.response_id!="string")return;let n=typeof e.run_id=="string"?e.run_id:"";return e.unavailable===!0?{type:"thinking",seq:i,response_id:e.response_id,run_id:n,text:"",unavailable:!0,model:typeof e.model=="string"?e.model:"",reason:typeof e.reason=="string"?e.reason:""}:typeof e.text!="string"?void 0:{type:"thinking",seq:i,response_id:e.response_id,run_id:n,...typeof e.step_id=="string"&&e.step_id!==""?{step_id:e.step_id}:{},text:e.text}}case"goal":{if(typeof e.goal_id!="string"||typeof e.kind!="string")return;let{seq:n,...o}=e;return{...o,type:"goal",seq:i,...typeof n=="number"?{turn:n}:{}}}case"history":{if(!Array.isArray(e.items)||typeof e.part!="number"||!Number.isInteger(e.part)||e.part<0)return;let n=e.items.filter(a=>typeof a=="object"&&a!==null&&(a.role==="user"||a.role==="assistant")&&typeof a.text=="string"),o=e.forked_from;return{type:"history",forked_from:o&&typeof o.chat_id=="string"?o:null,part:e.part,parts:typeof e.parts=="number"?e.parts:e.part+1,items:n}}case"voice":return typeof e.voice_id!="string"||e.voice_id===""||typeof e.status!="string"?void 0:{...e,type:"voice",seq:i,user_id:typeof e.user_id=="string"?e.user_id:null};case"transcript":return typeof e.id!="string"||e.id===""||typeof e.text!="string"?void 0:{type:"transcript",seq:i,id:e.id,voice_id:typeof e.voice_id=="string"?e.voice_id:"",role:typeof e.role=="string"?e.role:"",user_id:typeof e.user_id=="string"?e.user_id:null,author_name:typeof e.author_name=="string"?e.author_name:"",text:e.text,final:e.final!==!1,created_at:typeof e.created_at=="string"?e.created_at:""};default:return}}function b(t){let r=0;for(let s=0;s<t.length;s++){let e=t.charCodeAt(s);e<128?r+=1:e<2048?r+=2:e>=55296&&e<=56319&&s+1<t.length&&(t.charCodeAt(s+1)&64512)===56320?(r+=4,s++):r+=3}return r}function l(t,r){if(r<=0)return 0;let s=0;for(let e=0;e<t.length;e++){let i=t.charCodeAt(e),n=3,o=1;if(i<128?n=1:i<2048?n=2:i>=55296&&i<=56319&&e+1<t.length&&(t.charCodeAt(e+1)&64512)===56320&&(n=4,o=2),s+=n,s>=r)return e+o;e+=o-1}return t.length}function v(t,r){return t.slice(l(t,r))}export{m as a,_ as b,b as c,l as d,v as e};
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
+ import{a as u,b as d}from"./YE7MYOBE.js";var p={too_many_chats:()=>"this user is in as many chats as they may be (100): delete or leave one before starting another",too_many_endpoints:()=>"the project holds as many tool endpoints as it may (32): delete one (ai.endpoints.delete) before putting another",too_many_messages:t=>`this user has sent as many messages this minute as the project allows${t.retryAfter!==void 0?`: write again in ${t.retryAfter} s`:""}`,history_full:()=>"the project keeps as much chat history as it may: delete chats to write again",not_your_turn:()=>"this turn is another member's: only the member who started it (or the project's server) answers its tools and decides its approvals",not_a_member:()=>"the member the server acts as (as) is not in this chat: put them in it first (chats.members.put), or act as the server",goal_lapsed:()=>"the goal was set as a member who no longer stands where they stood then (out of the chat, or the chat no longer theirs alone): it is not resumed \u2014 clear it, or set another for the chat as it is now",goal_achieved:()=>"the goal is achieved: set a new one (chats.goal.set) to work on",turn_running:()=>"the chat's agent is at work on a turn: fork it once the turn has ended, or stop it first (chats.stop)",fork_too_large:()=>"what came before that message is more than a fork begins with (512 KiB): fork it before an earlier message",too_many_voices:t=>`this user has started as many voices this hour as the project allows (5)${t.retryAfter!==void 0?`: start again in ${t.retryAfter} s`:""}`,voice_active:()=>"another member's voice is live in this chat \u2014 one voice talks in a chat at a time: wait for it to end",not_your_voice:()=>"this voice is another member's: only its member \u2014 or the server as itself \u2014 reads, tells and closes it",voice_closed:()=>"the voice has ended: start a new one (chats.voice.start)",no_workspace:()=>"this chat works in no workspace, and files go into one: start the chat with a workspace, or send pictures as images",attachment_not_found:()=>"a picture or a file given is not one its writer may attach: a file of the project's storage \u2014 for a member, their own or a public bucket's",attachment_too_large:()=>"an attachment is past its bound: 5 MiB a picture, 15 MiB a file",attachment_changed:()=>"a file changed while it was being attached: send the message again",unsupported_image:()=>"a picture is not png, jpeg, webp or gif by its bytes: send it as a file",image_not_found:()=>"a picture given is not a file of the project's storage: upload it first (storage.from(bucket).upload(path, file)) and give that bucket and path",storage_unavailable:t=>`the project's storage did not answer when the model was to read a picture${t.retryAfter!==void 0?`: try again in ${t.retryAfter} s`:"; try again shortly"}`,draft_changed:()=>"the agent's draft was saved again since its revision was read: read it again (ai.agents.get) and make the change on that one",agent_defined_in_code:()=>"this agent is the backend's code's (its build's contract names it): it is changed in the code, and has no draft, versions or delete",nothing_to_publish:()=>"the agent's draft is the version published already: save a change to it first (ai.agents.saveDraft)",agent_not_published:()=>"the agent has no version published yet: publish its draft (ai.agents.publish) before a chat or an answer names it",ai_budget_reached:()=>"the project's monthly AI budget is spent: Palbase's models serve it again when the month turns (UTC) or an owner or admin raises the budget (Studio \u203A AI \u203A Settings, or palbase ai:settings:set --monthly-budget) \u2014 or connect the project's own key for the model's provider (ai.connectProvider), which its provider bills",ai_payment_required:()=>"the month's free AI dollar is spent and the project's account has no balance to pay for Palbase's models: top it up (Studio \u203A Billing) \u2014 or connect the project's own key for the model's provider (ai.connectProvider), which its provider bills",billing_unavailable:t=>`Palbase's billing did not say whether its models serve the project${t.retryAfter!==void 0?`: try again in ${t.retryAfter} s`:"; try again shortly"}`},g=new WeakSet;function c(t){if(!(t instanceof d)||g.has(t))return t;let r=p[t.code];if(!r)return t;let s=new d({op:t.op,status:t.status,code:t.code,message:`${r(t)} (${t.op}: ${t.status} ${t.code})`,requestId:t.requestId,retryAfter:t.retryAfter,body:t.body,cause:t});return g.add(s),s}function m(t){return t.catch(r=>{throw c(r)})}function _(t){if(typeof t!="object"||t===null)return;let r=t,s=r.data;if(typeof r.type!="string"||typeof s!="object"||s===null||Array.isArray(s))return;let e=u(s),i=typeof r.id=="number"&&Number.isSafeInteger(r.id)?r.id:0;switch(r.type){case"message":return typeof e.client_id=="string"?{type:"message",seq:i,message:e}:void 0;case"turn":{if(typeof e.response_id!="string"||typeof e.status!="string")return;let n={...e,type:"turn",seq:i};return n.waiting??=null,n.error??=null,n}case"text":{let n=e.offset;return typeof e.response_id!="string"||typeof n!="number"||!Number.isInteger(n)||n<0?void 0:{type:"text",response_id:e.response_id,offset:n,text:typeof e.text=="string"?e.text:""}}case"reset":{let n=e.offset;return typeof e.response_id!="string"||typeof n!="number"||!Number.isInteger(n)||n<0?void 0:{type:"reset",response_id:e.response_id,offset:n}}case"tool":{if(typeof e.call_id!="string"||typeof e.response_id!="string")return;let n=e.omitted_bytes;return{...e,type:"tool",seq:i,omittedBytes:typeof n=="number"&&Number.isSafeInteger(n)&&n>0?n:0,outputTruncated:e.output_truncated===!0}}case"agent":return typeof e.parent_response_id=="string"?{...e,type:"agent",seq:i}:void 0;case"thinking":{if(typeof e.response_id!="string")return;let n=typeof e.run_id=="string"?e.run_id:"";return e.unavailable===!0?{type:"thinking",seq:i,response_id:e.response_id,run_id:n,text:"",unavailable:!0,model:typeof e.model=="string"?e.model:"",reason:typeof e.reason=="string"?e.reason:""}:typeof e.text!="string"?void 0:{type:"thinking",seq:i,response_id:e.response_id,run_id:n,...typeof e.step_id=="string"&&e.step_id!==""?{step_id:e.step_id}:{},text:e.text}}case"goal":{if(typeof e.goal_id!="string"||typeof e.kind!="string")return;let{seq:n,...o}=e;return{...o,type:"goal",seq:i,...typeof n=="number"?{turn:n}:{}}}case"history":{if(!Array.isArray(e.items)||typeof e.part!="number"||!Number.isInteger(e.part)||e.part<0)return;let n=e.items.filter(a=>typeof a=="object"&&a!==null&&(a.role==="user"||a.role==="assistant")&&typeof a.text=="string"),o=e.forked_from;return{type:"history",forked_from:o&&typeof o.chat_id=="string"?o:null,part:e.part,parts:typeof e.parts=="number"?e.parts:e.part+1,items:n}}case"voice":return typeof e.voice_id!="string"||e.voice_id===""||typeof e.status!="string"?void 0:{...e,type:"voice",seq:i,user_id:typeof e.user_id=="string"?e.user_id:null};case"transcript":return typeof e.id!="string"||e.id===""||typeof e.text!="string"?void 0:{type:"transcript",seq:i,id:e.id,voice_id:typeof e.voice_id=="string"?e.voice_id:"",role:typeof e.role=="string"?e.role:"",user_id:typeof e.user_id=="string"?e.user_id:null,author_name:typeof e.author_name=="string"?e.author_name:"",text:e.text,final:e.final!==!1,created_at:typeof e.created_at=="string"?e.created_at:""};default:return}}function b(t){let r=0;for(let s=0;s<t.length;s++){let e=t.charCodeAt(s);e<128?r+=1:e<2048?r+=2:e>=55296&&e<=56319&&s+1<t.length&&(t.charCodeAt(s+1)&64512)===56320?(r+=4,s++):r+=3}return r}function l(t,r){if(r<=0)return 0;let s=0;for(let e=0;e<t.length;e++){let i=t.charCodeAt(e),n=3,o=1;if(i<128?n=1:i<2048?n=2:i>=55296&&i<=56319&&e+1<t.length&&(t.charCodeAt(e+1)&64512)===56320&&(n=4,o=2),s+=n,s>=r)return e+o;e+=o-1}return t.length}function v(t,r){return t.slice(l(t,r))}export{m as a,_ as b,b as c,l as d,v as e};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
2
- import{b}from"./C7SBJV6T.js";import{a as k,b as A}from"./Q45P37LH.js";import{randomBytes as _}from"node:crypto";async function N(){let n={keys:[{id:"k1",key:_(32).toString("base64url"),activates_at:new Date(0).toISOString()}],lookup:_(32).toString("base64url")},e=new b({fetch:async()=>n});return await e.load(),e.close(),e}var f=class extends Error{status;error;data;body;constructor(e,a,l,d){let u=d!==null&&typeof d=="object"?d:{},o=u.error??String(l);super(`${e} ${a} \u2192 ${l} ${o}${u.error_description?`: ${u.error_description}`:""}`),this.name="TestApiError",this.status=l,this.error=o,this.data=u.data,this.body=u}};function x(n,e){if(!n)throw new Error(`${e} is not set: the test client has nowhere to send its requests \u2014 \`palbase test\` sets it, as the platform's test run does`);return n}function B(n){let e=n.split(".")[1];if(!e)return null;try{let a=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof a.exp=="number"?a.exp-Math.floor(Date.now()/1e3):null}catch{return null}}function L(n){try{return JSON.parse(n)}catch{return n}}function $(n){let e=x(n.baseUrl,"PALBASE_TEST_BASE_URL").replace(/\/+$/,""),a=n.apiKey||void 0,l=(n.authUrl??e).replace(/\/+$/,""),d=n.fetch??fetch,u=[],o=null;async function c(r,t,s,i,T={},O=!0){let g={...T.headers},m=h=>Object.keys(g).some(R=>R.toLowerCase()===h);a!==void 0&&!m("apikey")&&(g.apikey=a),o&&O&&!m("authorization")&&(g.authorization=`Bearer ${o}`),i!==void 0&&!m("content-type")&&(g["content-type"]="application/json");let I=Date.now(),p=await d(`${r}${s}`,{method:t,headers:g,body:i===void 0?void 0:JSON.stringify(i)}),E=await p.text(),S=E?L(E):void 0;if(u.push({method:t,path:s,status:p.status,ms:Date.now()-I}),!p.ok){let h=p.status===401&&o?B(o):null;throw h!==null&&h<=0?new f(t,s,p.status,{error:"access_token_expired",error_description:`this run's access token expired ${-h}s ago: a test user's token is made for one run \u2014 run the tests again (\`palbase test\` makes new ones)`}):new f(t,s,p.status,S)}return S}let y={requests:u,get:(r,t)=>c(e,"GET",r,void 0,t),post:(r,t,s)=>c(e,"POST",r,t,s),patch:(r,t,s)=>c(e,"PATCH",r,t,s),put:(r,t,s)=>c(e,"PUT",r,t,s),delete:(r,t)=>c(e,"DELETE",r,void 0,t),query:(r,t,s)=>c(e,"QUERY",r,t,s),async signInAs(r){let t=n.identities?.[r];if(!t){let s=Object.keys(n.identities??{});throw s.length===0?new Error(`no test user named ${JSON.stringify(r)}: this run has no test users \u2014 none were named (the machine's test users, or \`palbase test --users <names>\`), or they could not be made: the run's log says which`):new Error(`no test user named ${JSON.stringify(r)} \u2014 this run has: ${s.join(", ")}. A run makes the test users its machine names (palbase machines:update <machine> --test-users <names>) or \`palbase test --users <names>\` names`)}return t.accessToken?(o=t.accessToken,{id:t.id??"",email:t.email}):y.signIn(t)},async signIn(r){if(a===void 0)throw new Error("PALBASE_TEST_API_KEY is not set: a sign-in at the project's auth is made with a publishable key of the project's (palbase apps:sdkconfig shows one) \u2014 a run's test users come with their tokens: api.signInAs(name)");let t=i=>c(l,"POST","/auth/login",r,i?{headers:i}:{},!1),s;try{s=await t()}catch(i){let T=i instanceof f&&i.status===403?k(i.body):null;if(!T)throw i;s=await t(await A(T))}return o=s.access_token,s.user??{id:""}},async signOut(){await c(l,"POST","/auth/logout",void 0),o=null},asAnonymous(){o=null}};return y}function P(n){if(!n)return{};let e;try{e=JSON.parse(n)}catch{throw new Error("PALBASE_TEST_IDENTITIES is set but is not JSON: the run that started these tests handed over a broken set of test users")}if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("PALBASE_TEST_IDENTITIES is not an object of test users by name");return e}var j={get stack(){return!!process.env.PALBASE_TEST_BASE_URL},minted(n){return Object.prototype.hasOwnProperty.call(P(process.env.PALBASE_TEST_IDENTITIES),n)}},w,q=new Proxy({},{get(n,e){return w??=$({baseUrl:process.env.PALBASE_TEST_BASE_URL??"",apiKey:process.env.PALBASE_TEST_API_KEY??"",authUrl:process.env.PALBASE_TEST_AUTH_URL,identities:P(process.env.PALBASE_TEST_IDENTITIES)}),Reflect.get(w,e,w)}});export{N as a,f as b,$ as c,j as d,q as e};
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
+ import{b}from"./3SLLOZC4.js";import{a as k,b as A}from"./FCJKKXVF.js";import{randomBytes as _}from"node:crypto";async function N(){let n={keys:[{id:"k1",key:_(32).toString("base64url"),activates_at:new Date(0).toISOString()}],lookup:_(32).toString("base64url")},e=new b({fetch:async()=>n});return await e.load(),e.close(),e}var f=class extends Error{status;error;data;body;constructor(e,a,l,d){let u=d!==null&&typeof d=="object"?d:{},o=u.error??String(l);super(`${e} ${a} \u2192 ${l} ${o}${u.error_description?`: ${u.error_description}`:""}`),this.name="TestApiError",this.status=l,this.error=o,this.data=u.data,this.body=u}};function x(n,e){if(!n)throw new Error(`${e} is not set: the test client has nowhere to send its requests \u2014 \`palbase test\` sets it, as the platform's test run does`);return n}function B(n){let e=n.split(".")[1];if(!e)return null;try{let a=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return typeof a.exp=="number"?a.exp-Math.floor(Date.now()/1e3):null}catch{return null}}function L(n){try{return JSON.parse(n)}catch{return n}}function $(n){let e=x(n.baseUrl,"PALBASE_TEST_BASE_URL").replace(/\/+$/,""),a=n.apiKey||void 0,l=(n.authUrl??e).replace(/\/+$/,""),d=n.fetch??fetch,u=[],o=null;async function c(r,t,s,i,T={},O=!0){let g={...T.headers},m=h=>Object.keys(g).some(R=>R.toLowerCase()===h);a!==void 0&&!m("apikey")&&(g.apikey=a),o&&O&&!m("authorization")&&(g.authorization=`Bearer ${o}`),i!==void 0&&!m("content-type")&&(g["content-type"]="application/json");let I=Date.now(),p=await d(`${r}${s}`,{method:t,headers:g,body:i===void 0?void 0:JSON.stringify(i)}),E=await p.text(),S=E?L(E):void 0;if(u.push({method:t,path:s,status:p.status,ms:Date.now()-I}),!p.ok){let h=p.status===401&&o?B(o):null;throw h!==null&&h<=0?new f(t,s,p.status,{error:"access_token_expired",error_description:`this run's access token expired ${-h}s ago: a test user's token is made for one run \u2014 run the tests again (\`palbase test\` makes new ones)`}):new f(t,s,p.status,S)}return S}let y={requests:u,get:(r,t)=>c(e,"GET",r,void 0,t),post:(r,t,s)=>c(e,"POST",r,t,s),patch:(r,t,s)=>c(e,"PATCH",r,t,s),put:(r,t,s)=>c(e,"PUT",r,t,s),delete:(r,t)=>c(e,"DELETE",r,void 0,t),query:(r,t,s)=>c(e,"QUERY",r,t,s),async signInAs(r){let t=n.identities?.[r];if(!t){let s=Object.keys(n.identities??{});throw s.length===0?new Error(`no test user named ${JSON.stringify(r)}: this run has no test users \u2014 none were named (the machine's test users, or \`palbase test --users <names>\`), or they could not be made: the run's log says which`):new Error(`no test user named ${JSON.stringify(r)} \u2014 this run has: ${s.join(", ")}. A run makes the test users its machine names (palbase machines:update <machine> --test-users <names>) or \`palbase test --users <names>\` names`)}return t.accessToken?(o=t.accessToken,{id:t.id??"",email:t.email}):y.signIn(t)},async signIn(r){if(a===void 0)throw new Error("PALBASE_TEST_API_KEY is not set: a sign-in at the project's auth is made with a publishable key of the project's (palbase apps:sdkconfig shows one) \u2014 a run's test users come with their tokens: api.signInAs(name)");let t=i=>c(l,"POST","/auth/login",r,i?{headers:i}:{},!1),s;try{s=await t()}catch(i){let T=i instanceof f&&i.status===403?k(i.body):null;if(!T)throw i;s=await t(await A(T))}return o=s.access_token,s.user??{id:""}},async signOut(){await c(l,"POST","/auth/logout",void 0),o=null},asAnonymous(){o=null}};return y}function P(n){if(!n)return{};let e;try{e=JSON.parse(n)}catch{throw new Error("PALBASE_TEST_IDENTITIES is set but is not JSON: the run that started these tests handed over a broken set of test users")}if(e===null||typeof e!="object"||Array.isArray(e))throw new Error("PALBASE_TEST_IDENTITIES is not an object of test users by name");return e}var j={get stack(){return!!process.env.PALBASE_TEST_BASE_URL},minted(n){return Object.prototype.hasOwnProperty.call(P(process.env.PALBASE_TEST_IDENTITIES),n)}},w,q=new Proxy({},{get(n,e){return w??=$({baseUrl:process.env.PALBASE_TEST_BASE_URL??"",apiKey:process.env.PALBASE_TEST_API_KEY??"",authUrl:process.env.PALBASE_TEST_AUTH_URL,identities:P(process.env.PALBASE_TEST_IDENTITIES)}),Reflect.get(w,e,w)}});export{N as a,f as b,$ as c,j as d,q as e};
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
2
- import{a as g,b}from"./Q45P37LH.js";var A=Symbol.for("palbase.data"),T=globalThis,m=T[A]??=new WeakSet;function S(t){return t instanceof Date||ArrayBuffer.isView(t)||t instanceof ArrayBuffer}function k(t){let e=[t];for(;e.length>0;){let n=e.pop();if(!(typeof n!="object"||n===null||m.has(n)||S(n))){m.add(n);for(let a of Array.isArray(n)?n:Object.values(n))e.push(a)}}return t}var l=class extends Error{status;code;requestId;retryAfter;body;op;get isNetworkError(){return this.code==="network_error"}constructor(e){super(e.message,e.cause===void 0?void 0:{cause:e.cause}),this.name="PalbaseError",this.op=e.op,this.status=e.status,this.code=e.code,this.requestId=e.requestId,this.retryAfter=e.retryAfter,this.body=e.body}};function C(t,e,n){let a=String(n);if(a===""||a==="."||a==="..")throw new l({op:t,status:0,code:"invalid_path_parameter",message:`${t}: ${e} cannot be ${a===""?"empty":JSON.stringify(a)}`});return encodeURIComponent(a)}var x=new Set(["apikey","authorization"]),q=64*1024;function W(t){let e=E(t.baseUrl),n=t.fetch??globalThis.fetch,a=t.solveProofOfWork??!0,u=async(r,o)=>{let d=v(e,r),s=new Headers;for(let[h,y]of Object.entries(r.headers??{}))y!=null&&!x.has(h.toLowerCase())&&s.set(h,String(y));for(let[h,y]of Object.entries(o))s.set(h,y);await j(r,t.credentials,s),s.has("accept")||s.set("accept","application/json");let f={method:r.method,headers:s,redirect:"manual",signal:r.signal,...r.keepalive?{keepalive:!0}:{}};r.body&&r.body.value!==void 0&&(s.set("content-type",r.body.contentType),f.body=L(r.body.kind,r.body.value),R(f.body)||(f.duplex="half"));let i;try{i=r.onUploadProgress&&t.xmlHttpRequest?await $(t.xmlHttpRequest,r.op,d,f,r.onUploadProgress):await n(d,f)}catch(h){throw r.signal?.aborted||h instanceof l?h:new l({op:r.op,status:0,code:"network_error",message:`${r.op}: the request did not reach ${e.origin}`,cause:h})}let c=r.answers[i.status]??(r.ownResponse&&i.status>=200&&i.status<300?"raw":void 0);if(c===void 0)throw i.status>=200&&i.status<300?(await i.body?.cancel(),new l({op:r.op,status:i.status,code:"undeclared_answer",message:`${r.op}: the server answered ${i.status}, which its contract does not declare; the request may have taken effect`})):await O(r.op,i);let p;switch(c){case"json":try{p=k(await i.json())}catch(h){throw new l({op:r.op,status:i.status,code:"invalid_json",message:`${r.op}: the answer is not JSON`,cause:h})}break;case"raw":p=i;break;default:await i.body?.cancel(),p=void 0}return{status:i.status,data:p,headers:i.headers}};return{async send(r){try{return await u(r,{})}catch(o){let d=a&&o instanceof l&&o.status===403?g(o.body):null,s=r.body?.value;if(!d||r.body?.kind==="raw"&&!R(s))throw o;let f=o,i;try{i=await b(d,{signal:r.signal})}catch(c){throw r.signal?.aborted?c:new l({op:r.op,status:403,code:"pow_unsolved",message:`${r.op}: ${c instanceof Error?c.message:String(c)}`,requestId:f.requestId,body:f.body,cause:c})}return u(r,i)}}}}function $(t,e,n,a,u){return new Promise((r,o)=>{let d=a.signal;if(d?.aborted)return o(d.reason);let s=new t,f=()=>s.abort();d?.addEventListener("abort",f,{once:!0});let i=c=>{d?.removeEventListener("abort",f),c()};s.open(a.method??"GET",n.href),s.responseType="arraybuffer",new Headers(a.headers).forEach((c,p)=>s.setRequestHeader(p,c)),s.upload&&(s.upload.onprogress=c=>{c.lengthComputable&&u(c.loaded,c.total)}),s.onload=()=>i(()=>{if(s.responseURL!==""&&s.responseURL!==n.href){o(new l({op:e,status:0,code:"undeclared_redirect",message:`${e}: the server redirected; the answer is another address's, and was not read`}));return}if(s.status<200||s.status>599)return o(new TypeError(`${e}: answered ${s.status}`));let c=s.status===204||s.status===205||s.status===304;r(new Response(c?null:s.response,{status:s.status,statusText:s.statusText,headers:U(s.getAllResponseHeaders())}))}),s.onerror=()=>i(()=>o(new TypeError(`${e}: the request failed`))),s.onabort=()=>i(()=>o(d?.reason??new DOMException("The request was aborted","AbortError"))),s.send(a.body)})}function U(t){let e=new Headers;for(let n of t.split(/\r?\n/)){let a=n.indexOf(":");if(!(a<=0))try{e.append(n.slice(0,a).trim(),n.slice(a+1).trim())}catch{}}return e}function E(t){let e;try{e=new URL(t)}catch{throw new TypeError(`baseUrl ${JSON.stringify(t)} is not an absolute URL`)}let n=e.hostname==="localhost"||e.hostname.endsWith(".localhost")||e.hostname==="127.0.0.1"||e.hostname==="[::1]";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&n))throw new TypeError(`baseUrl must be https (http only for a loopback address): ${e.origin}`);if(e.username||e.password||e.search||e.hash)throw new TypeError("baseUrl carries no user, query or fragment");if(e.pathname!=="/"&&e.pathname!=="")throw new TypeError("baseUrl is the project origin alone, with no path");return e}function v(t,e){if(!e.path.startsWith("/")||e.path.startsWith("//"))throw new l({op:e.op,status:0,code:"invalid_path",message:`${e.op}: path ${JSON.stringify(e.path)} is not absolute`});let n=new URL(e.path+P(e.query),t);if(n.origin!==t.origin)throw new l({op:e.op,status:0,code:"invalid_path",message:`${e.op}: path leaves the project's origin`});return n}async function j(t,e,n){if(t.auth.length===0)return;let a=t.auth.some(o=>o.includes("userJWT"))?await e.accessToken?.():void 0,u=o=>{switch(o){case"ApiKeyAuth":return!!(e.publishableKey??e.secretKey);case"SecretKeyAuth":case"AdminAuth":return!!(e.secretKey??e.token);case"PalbaseBearer":return!!e.token;case"userJWT":return!!a&&!e.token;default:return!1}},r=t.auth.filter(o=>o.every(u)).reduce((o,d)=>o===void 0||d.length>o.length?d:o,void 0);if(!r)throw new l({op:t.op,status:0,code:"missing_credential",message:`${t.op} needs one of: ${t.auth.map(o=>o.length===0?"nothing":o.join(" + ")).join(" | ")}`});for(let o of r)o==="ApiKeyAuth"?n.set("apikey",e.publishableKey??e.secretKey):(o==="SecretKeyAuth"||o==="AdminAuth"||o==="PalbaseBearer")&&e.token?n.set("authorization",`Bearer ${e.token}`):o==="SecretKeyAuth"||o==="AdminAuth"?n.set("apikey",e.secretKey):o==="userJWT"&&n.set("authorization",`Bearer ${a}`)}function L(t,e){switch(t){case"json":return JSON.stringify(e);case"form":{let n=new URLSearchParams;for(let[a,u]of Object.entries(e))w(n,a,u);return n}case"raw":return e}}function R(t){return!!(t==null||typeof t=="string"||t instanceof URLSearchParams||t instanceof Blob||t instanceof FormData||t instanceof ArrayBuffer||ArrayBuffer.isView(t))}function P(t){if(!t)return"";let e=new URLSearchParams;for(let[a,u]of Object.entries(t))w(e,a,u);let n=e.toString();return n===""?"":`?${n}`}function w(t,e,n){if(n!=null){if(Array.isArray(n)){for(let a of n)w(t,e,a);return}if(n instanceof Date){t.append(e,n.toISOString());return}t.append(e,typeof n=="object"?JSON.stringify(n):String(n))}}async function O(t,e){let n=await B(e,q).catch(()=>""),a;try{a=n===""?void 0:JSON.parse(n)}catch{a=n}let u=_(a)?a:void 0,r=Number(e.headers.get("retry-after")),o=e.status>=300&&e.status<400;return new l({op:t,status:e.status,code:u?.error??(o?"undeclared_redirect":`http_${e.status}`),message:u?.error_description??(o?`${t}: the server redirected (${e.status}); the request was not followed, its credentials stay here`:`${t}: ${e.status} ${e.statusText}`.trim()),requestId:u?.request_id??e.headers.get("x-request-id")??void 0,retryAfter:u?.retry_after??(Number.isFinite(r)&&r>0?r:void 0),body:a})}async function B(t,e){if(!t.body)return"";let n=t.body.getReader(),a=[],u=0;for(;u<e;){let{done:d,value:s}=await n.read();if(d)break;a.push(s),u+=s.byteLength}await n.cancel().catch(()=>{});let r=new Uint8Array(Math.min(u,e)),o=0;for(let d of a){let s=Math.min(d.byteLength,r.byteLength-o);if(r.set(d.subarray(0,s),o),o+=s,o>=r.byteLength)break}return new TextDecoder().decode(r)}function _(t){return typeof t=="object"&&t!==null&&typeof t.error=="string"}export{k as a,l as b,C as c,W as d,E as e,R as f};
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
+ import{a as g,b}from"./FCJKKXVF.js";var A=Symbol.for("palbase.data"),T=globalThis,m=T[A]??=new WeakSet;function S(t){return t instanceof Date||ArrayBuffer.isView(t)||t instanceof ArrayBuffer}function k(t){let e=[t];for(;e.length>0;){let n=e.pop();if(!(typeof n!="object"||n===null||m.has(n)||S(n))){m.add(n);for(let a of Array.isArray(n)?n:Object.values(n))e.push(a)}}return t}var l=class extends Error{status;code;requestId;retryAfter;body;op;get isNetworkError(){return this.code==="network_error"}constructor(e){super(e.message,e.cause===void 0?void 0:{cause:e.cause}),this.name="PalbaseError",this.op=e.op,this.status=e.status,this.code=e.code,this.requestId=e.requestId,this.retryAfter=e.retryAfter,this.body=e.body}};function C(t,e,n){let a=String(n);if(a===""||a==="."||a==="..")throw new l({op:t,status:0,code:"invalid_path_parameter",message:`${t}: ${e} cannot be ${a===""?"empty":JSON.stringify(a)}`});return encodeURIComponent(a)}var x=new Set(["apikey","authorization"]),q=64*1024;function W(t){let e=E(t.baseUrl),n=t.fetch??globalThis.fetch,a=t.solveProofOfWork??!0,u=async(r,o)=>{let d=v(e,r),s=new Headers;for(let[h,y]of Object.entries(r.headers??{}))y!=null&&!x.has(h.toLowerCase())&&s.set(h,String(y));for(let[h,y]of Object.entries(o))s.set(h,y);await j(r,t.credentials,s),s.has("accept")||s.set("accept","application/json");let f={method:r.method,headers:s,redirect:"manual",signal:r.signal,...r.keepalive?{keepalive:!0}:{}};r.body&&r.body.value!==void 0&&(s.set("content-type",r.body.contentType),f.body=L(r.body.kind,r.body.value),R(f.body)||(f.duplex="half"));let i;try{i=r.onUploadProgress&&t.xmlHttpRequest?await $(t.xmlHttpRequest,r.op,d,f,r.onUploadProgress):await n(d,f)}catch(h){throw r.signal?.aborted||h instanceof l?h:new l({op:r.op,status:0,code:"network_error",message:`${r.op}: the request did not reach ${e.origin}`,cause:h})}let c=r.answers[i.status]??(r.ownResponse&&i.status>=200&&i.status<300?"raw":void 0);if(c===void 0)throw i.status>=200&&i.status<300?(await i.body?.cancel(),new l({op:r.op,status:i.status,code:"undeclared_answer",message:`${r.op}: the server answered ${i.status}, which its contract does not declare; the request may have taken effect`})):await O(r.op,i);let p;switch(c){case"json":try{p=k(await i.json())}catch(h){throw new l({op:r.op,status:i.status,code:"invalid_json",message:`${r.op}: the answer is not JSON`,cause:h})}break;case"raw":p=i;break;default:await i.body?.cancel(),p=void 0}return{status:i.status,data:p,headers:i.headers}};return{async send(r){try{return await u(r,{})}catch(o){let d=a&&o instanceof l&&o.status===403?g(o.body):null,s=r.body?.value;if(!d||r.body?.kind==="raw"&&!R(s))throw o;let f=o,i;try{i=await b(d,{signal:r.signal})}catch(c){throw r.signal?.aborted?c:new l({op:r.op,status:403,code:"pow_unsolved",message:`${r.op}: ${c instanceof Error?c.message:String(c)}`,requestId:f.requestId,body:f.body,cause:c})}return u(r,i)}}}}function $(t,e,n,a,u){return new Promise((r,o)=>{let d=a.signal;if(d?.aborted)return o(d.reason);let s=new t,f=()=>s.abort();d?.addEventListener("abort",f,{once:!0});let i=c=>{d?.removeEventListener("abort",f),c()};s.open(a.method??"GET",n.href),s.responseType="arraybuffer",new Headers(a.headers).forEach((c,p)=>s.setRequestHeader(p,c)),s.upload&&(s.upload.onprogress=c=>{c.lengthComputable&&u(c.loaded,c.total)}),s.onload=()=>i(()=>{if(s.responseURL!==""&&s.responseURL!==n.href){o(new l({op:e,status:0,code:"undeclared_redirect",message:`${e}: the server redirected; the answer is another address's, and was not read`}));return}if(s.status<200||s.status>599)return o(new TypeError(`${e}: answered ${s.status}`));let c=s.status===204||s.status===205||s.status===304;r(new Response(c?null:s.response,{status:s.status,statusText:s.statusText,headers:U(s.getAllResponseHeaders())}))}),s.onerror=()=>i(()=>o(new TypeError(`${e}: the request failed`))),s.onabort=()=>i(()=>o(d?.reason??new DOMException("The request was aborted","AbortError"))),s.send(a.body)})}function U(t){let e=new Headers;for(let n of t.split(/\r?\n/)){let a=n.indexOf(":");if(!(a<=0))try{e.append(n.slice(0,a).trim(),n.slice(a+1).trim())}catch{}}return e}function E(t){let e;try{e=new URL(t)}catch{throw new TypeError(`baseUrl ${JSON.stringify(t)} is not an absolute URL`)}let n=e.hostname==="localhost"||e.hostname.endsWith(".localhost")||e.hostname==="127.0.0.1"||e.hostname==="[::1]";if(e.protocol!=="https:"&&!(e.protocol==="http:"&&n))throw new TypeError(`baseUrl must be https (http only for a loopback address): ${e.origin}`);if(e.username||e.password||e.search||e.hash)throw new TypeError("baseUrl carries no user, query or fragment");if(e.pathname!=="/"&&e.pathname!=="")throw new TypeError("baseUrl is the project origin alone, with no path");return e}function v(t,e){if(!e.path.startsWith("/")||e.path.startsWith("//"))throw new l({op:e.op,status:0,code:"invalid_path",message:`${e.op}: path ${JSON.stringify(e.path)} is not absolute`});let n=new URL(e.path+P(e.query),t);if(n.origin!==t.origin)throw new l({op:e.op,status:0,code:"invalid_path",message:`${e.op}: path leaves the project's origin`});return n}async function j(t,e,n){if(t.auth.length===0)return;let a=t.auth.some(o=>o.includes("userJWT"))?await e.accessToken?.():void 0,u=o=>{switch(o){case"ApiKeyAuth":return!!(e.publishableKey??e.secretKey);case"SecretKeyAuth":case"AdminAuth":return!!(e.secretKey??e.token);case"PalbaseBearer":return!!e.token;case"userJWT":return!!a&&!e.token;default:return!1}},r=t.auth.filter(o=>o.every(u)).reduce((o,d)=>o===void 0||d.length>o.length?d:o,void 0);if(!r)throw new l({op:t.op,status:0,code:"missing_credential",message:`${t.op} needs one of: ${t.auth.map(o=>o.length===0?"nothing":o.join(" + ")).join(" | ")}`});for(let o of r)o==="ApiKeyAuth"?n.set("apikey",e.publishableKey??e.secretKey):(o==="SecretKeyAuth"||o==="AdminAuth"||o==="PalbaseBearer")&&e.token?n.set("authorization",`Bearer ${e.token}`):o==="SecretKeyAuth"||o==="AdminAuth"?n.set("apikey",e.secretKey):o==="userJWT"&&n.set("authorization",`Bearer ${a}`)}function L(t,e){switch(t){case"json":return JSON.stringify(e);case"form":{let n=new URLSearchParams;for(let[a,u]of Object.entries(e))w(n,a,u);return n}case"raw":return e}}function R(t){return!!(t==null||typeof t=="string"||t instanceof URLSearchParams||t instanceof Blob||t instanceof FormData||t instanceof ArrayBuffer||ArrayBuffer.isView(t))}function P(t){if(!t)return"";let e=new URLSearchParams;for(let[a,u]of Object.entries(t))w(e,a,u);let n=e.toString();return n===""?"":`?${n}`}function w(t,e,n){if(n!=null){if(Array.isArray(n)){for(let a of n)w(t,e,a);return}if(n instanceof Date){t.append(e,n.toISOString());return}t.append(e,typeof n=="object"?JSON.stringify(n):String(n))}}async function O(t,e){let n=await B(e,q).catch(()=>""),a;try{a=n===""?void 0:JSON.parse(n)}catch{a=n}let u=_(a)?a:void 0,r=Number(e.headers.get("retry-after")),o=e.status>=300&&e.status<400;return new l({op:t,status:e.status,code:u?.error??(o?"undeclared_redirect":`http_${e.status}`),message:u?.error_description??(o?`${t}: the server redirected (${e.status}); the request was not followed, its credentials stay here`:`${t}: ${e.status} ${e.statusText}`.trim()),requestId:u?.request_id??e.headers.get("x-request-id")??void 0,retryAfter:u?.retry_after??(Number.isFinite(r)&&r>0?r:void 0),body:a})}async function B(t,e){if(!t.body)return"";let n=t.body.getReader(),a=[],u=0;for(;u<e;){let{done:d,value:s}=await n.read();if(d)break;a.push(s),u+=s.byteLength}await n.cancel().catch(()=>{});let r=new Uint8Array(Math.min(u,e)),o=0;for(let d of a){let s=Math.min(d.byteLength,r.byteLength-o);if(r.set(d.subarray(0,s),o),o+=s,o>=r.byteLength)break}return new TextDecoder().decode(r)}function _(t){return typeof t=="object"&&t!==null&&typeof t.error=="string"}export{k as a,l as b,C as c,W as d,E as e,R as f};
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
2
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
3
3
  var mb=Object.defineProperty;var st=(e,t)=>{for(var n in t)mb(e,n,{get:t[n],enumerable:!0})};import{parseArgs as Yb}from"node:util";var hb=Symbol.for("palbase.data"),fb=globalThis,Fl=fb[hb]??=new WeakSet;function yb(e){return e instanceof Date||ArrayBuffer.isView(e)||e instanceof ArrayBuffer}function Ta(e){let t=[e];for(;t.length>0;){let n=t.pop();if(!(typeof n!="object"||n===null||Fl.has(n)||yb(n))){Fl.add(n);for(let s of Array.isArray(n)?n:Object.values(n))t.push(s)}}return e}var bb="X-PoW-Challenge-ID",wb="X-PoW-Nonce";function Jl(e){if(typeof e!="object"||e===null)return null;let t=e;if(t.error!=="pow_required"||typeof t.challenge!="object"||t.challenge===null)return null;let{id:n,prefix:s,difficulty:a}=t.challenge;return typeof n!="string"||typeof s!="string"||typeof a!="number"||!Number.isInteger(a)||a<0?null:{id:n,prefix:s,difficulty:a}}function vb(e){return 8*2**e}var Wn;async function _b(){if(Wn)return Wn;let e=globalThis;if(e.process?.versions?.node!==void 0||e.process?.versions?.bun!==void 0)try{let s=(await import("node:crypto")).createHash;if(typeof s=="function")return Wn=a=>new Uint8Array(s("sha256").update(a).digest()),Wn}catch{}let t=new TextEncoder;return Wn=async n=>new Uint8Array(await crypto.subtle.digest("SHA-256",t.encode(n))),Wn}function kb(e){let t=0;for(let n of e){if(n===0){t+=8;continue}return t+Math.clz32(n)-24}return t}var Sb=4096,$b=typeof globalThis.setImmediate=="function"?()=>new Promise(e=>globalThis.setImmediate(e)):()=>new Promise(e=>setTimeout(e,0));async function Wl(e,t={}){if(e.difficulty>24)throw new Error(`proof-of-work: difficulty ${e.difficulty} is above auth's ceiling of 24`);let n=await _b(),s=vb(e.difficulty),a=Date.now()+(t.timeLimitMs??12e4);for(let r=0;r<s;r++){if(r%Sb===0&&r>0){if(await $b(),t.signal?.aborted)throw t.signal.reason??new DOMException("proof-of-work aborted","AbortError");if(Date.now()>a)throw new Error(`proof-of-work: gave up on difficulty ${e.difficulty} after ${r} attempts`)}let i=n(e.prefix+r),o=i instanceof Uint8Array?i:await i;if(kb(o)>=e.difficulty)return{[bb]:e.id,[wb]:String(r)}}throw new Error(`proof-of-work: no nonce for difficulty ${e.difficulty} within ${s} attempts`)}var j=class extends Error{status;code;requestId;retryAfter;body;op;get isNetworkError(){return this.code==="network_error"}constructor(t){super(t.message,t.cause===void 0?void 0:{cause:t.cause}),this.name="PalbaseError",this.op=t.op,this.status=t.status,this.code=t.code,this.requestId=t.requestId,this.retryAfter=t.retryAfter,this.body=t.body}};function g(e,t,n){let s=String(n);if(s===""||s==="."||s==="..")throw new j({op:e,status:0,code:"invalid_path_parameter",message:`${e}: ${t} cannot be ${s===""?"empty":JSON.stringify(s)}`});return encodeURIComponent(s)}var Pb=new Set(["apikey","authorization"]),Ab=64*1024;function ci(e){let t=Ea(e.baseUrl),n=e.fetch??globalThis.fetch,s=e.solveProofOfWork??!0,a=async(r,i)=>{let o=Eb(t,r),l=new Headers;for(let[b,w]of Object.entries(r.headers??{}))w!=null&&!Pb.has(b.toLowerCase())&&l.set(b,String(w));for(let[b,w]of Object.entries(i))l.set(b,w);await Cb(r,e.credentials,l),l.has("accept")||l.set("accept","application/json");let d={method:r.method,headers:l,redirect:"manual",signal:r.signal,...r.keepalive?{keepalive:!0}:{}};r.body&&r.body.value!==void 0&&(l.set("content-type",r.body.contentType),d.body=jb(r.body.kind,r.body.value),Vn(d.body)||(d.duplex="half"));let p;try{p=r.onUploadProgress&&e.xmlHttpRequest?await Rb(e.xmlHttpRequest,r.op,o,d,r.onUploadProgress):await n(o,d)}catch(b){throw r.signal?.aborted||b instanceof j?b:new j({op:r.op,status:0,code:"network_error",message:`${r.op}: the request did not reach ${t.origin}`,cause:b})}let u=r.answers[p.status]??(r.ownResponse&&p.status>=200&&p.status<300?"raw":void 0);if(u===void 0)throw p.status>=200&&p.status<300?(await p.body?.cancel(),new j({op:r.op,status:p.status,code:"undeclared_answer",message:`${r.op}: the server answered ${p.status}, which its contract does not declare; the request may have taken effect`})):await xb(r.op,p);let m;switch(u){case"json":try{m=Ta(await p.json())}catch(b){throw new j({op:r.op,status:p.status,code:"invalid_json",message:`${r.op}: the answer is not JSON`,cause:b})}break;case"raw":m=p;break;default:await p.body?.cancel(),m=void 0}return{status:p.status,data:m,headers:p.headers}};return{async send(r){try{return await a(r,{})}catch(i){let o=s&&i instanceof j&&i.status===403?Jl(i.body):null,l=r.body?.value;if(!o||r.body?.kind==="raw"&&!Vn(l))throw i;let d=i,p;try{p=await Wl(o,{signal:r.signal})}catch(u){throw r.signal?.aborted?u:new j({op:r.op,status:403,code:"pow_unsolved",message:`${r.op}: ${u instanceof Error?u.message:String(u)}`,requestId:d.requestId,body:d.body,cause:u})}return a(r,p)}}}}function Rb(e,t,n,s,a){return new Promise((r,i)=>{let o=s.signal;if(o?.aborted)return i(o.reason);let l=new e,d=()=>l.abort();o?.addEventListener("abort",d,{once:!0});let p=u=>{o?.removeEventListener("abort",d),u()};l.open(s.method??"GET",n.href),l.responseType="arraybuffer",new Headers(s.headers).forEach((u,m)=>l.setRequestHeader(m,u)),l.upload&&(l.upload.onprogress=u=>{u.lengthComputable&&a(u.loaded,u.total)}),l.onload=()=>p(()=>{if(l.responseURL!==""&&l.responseURL!==n.href){i(new j({op:t,status:0,code:"undeclared_redirect",message:`${t}: the server redirected; the answer is another address's, and was not read`}));return}if(l.status<200||l.status>599)return i(new TypeError(`${t}: answered ${l.status}`));let u=l.status===204||l.status===205||l.status===304;r(new Response(u?null:l.response,{status:l.status,statusText:l.statusText,headers:Tb(l.getAllResponseHeaders())}))}),l.onerror=()=>p(()=>i(new TypeError(`${t}: the request failed`))),l.onabort=()=>p(()=>i(o?.reason??new DOMException("The request was aborted","AbortError"))),l.send(s.body)})}function Tb(e){let t=new Headers;for(let n of e.split(/\r?\n/)){let s=n.indexOf(":");if(!(s<=0))try{t.append(n.slice(0,s).trim(),n.slice(s+1).trim())}catch{}}return t}function Ea(e){let t;try{t=new URL(e)}catch{throw new TypeError(`baseUrl ${JSON.stringify(e)} is not an absolute URL`)}let n=t.hostname==="localhost"||t.hostname.endsWith(".localhost")||t.hostname==="127.0.0.1"||t.hostname==="[::1]";if(t.protocol!=="https:"&&!(t.protocol==="http:"&&n))throw new TypeError(`baseUrl must be https (http only for a loopback address): ${t.origin}`);if(t.username||t.password||t.search||t.hash)throw new TypeError("baseUrl carries no user, query or fragment");if(t.pathname!=="/"&&t.pathname!=="")throw new TypeError("baseUrl is the project origin alone, with no path");return t}function Eb(e,t){if(!t.path.startsWith("/")||t.path.startsWith("//"))throw new j({op:t.op,status:0,code:"invalid_path",message:`${t.op}: path ${JSON.stringify(t.path)} is not absolute`});let n=new URL(t.path+Ob(t.query),e);if(n.origin!==e.origin)throw new j({op:t.op,status:0,code:"invalid_path",message:`${t.op}: path leaves the project's origin`});return n}async function Cb(e,t,n){if(e.auth.length===0)return;let s=e.auth.some(i=>i.includes("userJWT"))?await t.accessToken?.():void 0,a=i=>{switch(i){case"ApiKeyAuth":return!!(t.publishableKey??t.secretKey);case"SecretKeyAuth":case"AdminAuth":return!!(t.secretKey??t.token);case"PalbaseBearer":return!!t.token;case"userJWT":return!!s&&!t.token;default:return!1}},r=e.auth.filter(i=>i.every(a)).reduce((i,o)=>i===void 0||o.length>i.length?o:i,void 0);if(!r)throw new j({op:e.op,status:0,code:"missing_credential",message:`${e.op} needs one of: ${e.auth.map(i=>i.length===0?"nothing":i.join(" + ")).join(" | ")}`});for(let i of r)i==="ApiKeyAuth"?n.set("apikey",t.publishableKey??t.secretKey):(i==="SecretKeyAuth"||i==="AdminAuth"||i==="PalbaseBearer")&&t.token?n.set("authorization",`Bearer ${t.token}`):i==="SecretKeyAuth"||i==="AdminAuth"?n.set("apikey",t.secretKey):i==="userJWT"&&n.set("authorization",`Bearer ${s}`)}function jb(e,t){switch(e){case"json":return JSON.stringify(t);case"form":{let n=new URLSearchParams;for(let[s,a]of Object.entries(t))gi(n,s,a);return n}case"raw":return t}}function Vn(e){return!!(e==null||typeof e=="string"||e instanceof URLSearchParams||e instanceof Blob||e instanceof FormData||e instanceof ArrayBuffer||ArrayBuffer.isView(e))}function Ob(e){if(!e)return"";let t=new URLSearchParams;for(let[s,a]of Object.entries(e))gi(t,s,a);let n=t.toString();return n===""?"":`?${n}`}function gi(e,t,n){if(n!=null){if(Array.isArray(n)){for(let s of n)gi(e,t,s);return}if(n instanceof Date){e.append(t,n.toISOString());return}e.append(t,typeof n=="object"?JSON.stringify(n):String(n))}}async function xb(e,t){let n=await Mb(t,Ab).catch(()=>""),s;try{s=n===""?void 0:JSON.parse(n)}catch{s=n}let a=Ib(s)?s:void 0,r=Number(t.headers.get("retry-after")),i=t.status>=300&&t.status<400;return new j({op:e,status:t.status,code:a?.error??(i?"undeclared_redirect":`http_${t.status}`),message:a?.error_description??(i?`${e}: the server redirected (${t.status}); the request was not followed, its credentials stay here`:`${e}: ${t.status} ${t.statusText}`.trim()),requestId:a?.request_id??t.headers.get("x-request-id")??void 0,retryAfter:a?.retry_after??(Number.isFinite(r)&&r>0?r:void 0),body:s})}async function Mb(e,t){if(!e.body)return"";let n=e.body.getReader(),s=[],a=0;for(;a<t;){let{done:o,value:l}=await n.read();if(o)break;s.push(l),a+=l.byteLength}await n.cancel().catch(()=>{});let r=new Uint8Array(Math.min(a,t)),i=0;for(let o of s){let l=Math.min(o.byteLength,r.byteLength-i);if(r.set(o.subarray(0,l),i),i+=l,i>=r.byteLength)break}return new TextDecoder().decode(r)}function Ib(e){return typeof e=="object"&&e!==null&&typeof e.error=="string"}var Ca={project:{type:"string",short:"P",value:"project",description:"the project (name or id; org/project when the name is in two organizations)"},env:{type:"string",short:"E",value:"env",description:"the project's environment (slug or ref)"},json:{type:"boolean",description:"print the answer as JSON"},"non-interactive":{type:"boolean",description:"never ask: refuse what would need a question"},yes:{type:"boolean",short:"y",description:"confirm a change to a production environment without asking"},debug:{type:"boolean",description:"print each request the command sends"},help:{type:"boolean",short:"h",description:"show help"}};var y=class extends Error{exitCode;hint;code;reported;constructor(t,n,s={}){super(n),this.name="CliError",this.code=t,this.hint=s.hint,this.exitCode=s.exitCode??1,this.reported=s.reported??!1}};function h(e,t){return new y("usage",e,{hint:t,exitCode:2})}var ja=class{io;json;constructor(t,n){this.io=t,this.json=n}result(t,n){this.json?this.io.stdout(`${JSON.stringify(t,null,2)}
4
4
  `):n()}line(t=""){this.io.stdout(`${G(t)}
5
5
  `)}note(t){this.io.stderr(`${G(t)}
@@ -9,7 +9,7 @@ var mb=Object.defineProperty;var st=(e,t)=>{for(var n in t)mb(e,n,{get:t[n],enum
9
9
  `);let i;try{i=await this.io.fetch(t,{method:n.method,headers:{...n.headers,...a},body:n.body,signal:n.signal,...s?{}:{duplex:"half"},redirect:"manual"})}catch(l){throw n.signal?.aborted?l:new y("network_error",`${new URL(t).origin} could not be reached: ${l instanceof Error?l.message:String(l)}`)}if(this.debug&&this.io.stderr(`< ${i.status} ${i.headers.get("x-request-id")??""}
10
10
  `),i.status!==503||!s||r>=Vb||!Wb.has(await fi(i)??""))return i;await i.body?.cancel();let o=Number(i.headers.get("retry-after")??"");await this.io.sleep((Number.isFinite(o)&&o>0?Math.min(o,30):1)*1e3)}}async exchange(t,n,s){let a=await this.token(),r=await this.send(t,n,s,a.value);if(r.status===401&&a.renewable){let i=await this.renew(await this.currentSession());r=await this.send(t,n,s,i.access_token)}return{res:r,renewable:a.renewable}}async answered(t,n,s,a){if(s.status===204)return;let r=await s.text(),i=r===""?void 0:Hb(r);if(s.ok)return i;let o=i??{};throw s.status===401?o.error==="token_not_for_machines"?pp(new URL(this.cloud.studioApi).host):a?Hn():this.tokenRefused("Studio"):new j({op:`${t} ${n}`,status:s.status,code:o.error??`http_${s.status}`,message:o.error_description??`Studio answered ${s.status}`,requestId:o.request_id??s.headers.get("x-request-id")??void 0,body:i})}tokenRefused(t){return(this.io.env.PALBASE_TOKEN??"").startsWith("pbe_")?new y("token_refused",`${t} refused PALBASE_TOKEN, an environment's token: it ended (a few hours at most), it was revoked, or what minted it no longer holds`,{hint:"mint another: palbase env:tokens:create --scope <scope> (an admin), or with the environment's secret key (Studio's POST /environments/{ref}/tokens)"}):new y("token_refused",`${t} refused PALBASE_TOKEN: it was revoked, it ended, or the one who made it no longer holds its role`,{hint:"an admin makes a new one: palbase tokens:create <name>"})}async token(){let t=this.io.env.PALBASE_TOKEN;return t&&t!==""?{value:t,renewable:!1}:{value:(await this.currentSession()).access_token,renewable:!0}}async renew(t){let n=await rp(this.io,this.cloud,t);return await this.state.writeSession(n),this.session=n,n}async send(t,n,s,a){let r=`${this.cloud.studioApi}${Jb}${n}`;this.debug&&this.io.stderr(`> ${t} ${r}
11
11
  `);try{let i=await this.io.fetch(r,{method:t,headers:{...a===void 0?{}:{authorization:`Bearer ${a}`},accept:"application/json",...s===void 0?{}:{"content-type":"application/json"}},body:s===void 0?void 0:JSON.stringify(s),redirect:"manual"});return this.debug&&this.io.stderr(`< ${i.status} ${i.headers.get("x-request-id")??""}
12
- `),i}catch(i){throw new y("network_error",`Studio (${this.cloud.studioApi}) could not be reached: ${i instanceof Error?i.message:String(i)}`)}}};function pp(e){return new y("token_not_for_machines",`the platform's edge refused PALBASE_TOKEN at ${e}, taking it for a machine's address (token_not_for_machines): the token itself was not refused`,{hint:"nothing is wrong with the token: run this again in a few minutes, and tell Palbase if it lasts"})}async function fi(e){let t=await e.clone().json().catch(()=>null),n=t&&typeof t=="object"?t.error:void 0;return typeof n=="string"&&/^(console|token|edge)_/.test(n)?n:void 0}function Hb(e){try{return JSON.parse(e)}catch{return e}}var dp={version:"0.25.0"};var La=dp.version;async function hp(e,t,n){let s=new Map(n.map(i=>[i.name,i])),a=e.includes("--json"),r=e.includes("--debug");try{let{name:i,at:o}=Zb(e);if(i===void 0)return e.includes("--version")?(t.stdout(`palbase ${La}
12
+ `),i}catch(i){throw new y("network_error",`Studio (${this.cloud.studioApi}) could not be reached: ${i instanceof Error?i.message:String(i)}`)}}};function pp(e){return new y("token_not_for_machines",`the platform's edge refused PALBASE_TOKEN at ${e}, taking it for a machine's address (token_not_for_machines): the token itself was not refused`,{hint:"nothing is wrong with the token: run this again in a few minutes, and tell Palbase if it lasts"})}async function fi(e){let t=await e.clone().json().catch(()=>null),n=t&&typeof t=="object"?t.error:void 0;return typeof n=="string"&&/^(console|token|edge)_/.test(n)?n:void 0}function Hb(e){try{return JSON.parse(e)}catch{return e}}var dp={version:"0.25.1"};var La=dp.version;async function hp(e,t,n){let s=new Map(n.map(i=>[i.name,i])),a=e.includes("--json"),r=e.includes("--debug");try{let{name:i,at:o}=Zb(e);if(i===void 0)return e.includes("--version")?(t.stdout(`palbase ${La}
13
13
  `),0):(t.stdout(mp(n)),e.length===0||e.includes("--help")||e.includes("-h")?0:2);if(i==="help"){let S=e[o+1],$=S===void 0?void 0:s.get(S);if(S!==void 0&&!$)throw up(S,n);return t.stdout($?gp($):mp(n)),0}let l=s.get(i);if(!l)throw up(i,n);let d=[...e.slice(0,o),...e.slice(o+1)];if(d.includes("--help")||d.includes("-h"))return t.stdout(gp(l)),0;let{flags:p,positionals:u}=Qb(l,d),m=l.args??{min:0,max:0};if(u.length<m.min)throw h(`${l.name} needs ${m.min===1?"an argument":`${m.min} arguments`}`,bi(l));if(u.length>m.max)throw h(`${l.name} takes ${m.max===0?"no argument":`at most ${m.max}`}: ${JSON.stringify(u.slice(m.max))} is left over`,bi(l));let b={project:p.project,env:p.env,json:p.json===!0,nonInteractive:p["non-interactive"]===!0,yes:p.yes===!0,debug:p.debug===!0},w=Ql(t.env),_=new Oa(np(t.configDir,w)),E={io:t,state:_,out:new ja(t,b.json),global:b,args:u,flags:p,interactive:t.interactive&&!b.nonInteractive,cloud:w,studio:new Ia(t,w,_,b.debug)};return await l.run(E)??0}catch(i){return ew(i,t,a,r)}}function Zb(e){let t=new Set;for(let[n,s]of Object.entries(Ca))s.type==="string"&&(t.add(`--${n}`),s.short&&t.add(`-${s.short}`));for(let n=0;n<e.length;n++){let s=e[n];if(s==="--")return{at:-1};if(t.has(s)){n++;continue}if(!s.startsWith("-"))return{name:s,at:n}}return{at:-1}}function Qb(e,t){let n={...Ca,...e.flags??{}},s={};for(let[a,r]of Object.entries(n))s[a]={type:r.type,...r.short?{short:r.short}:{},...r.multiple?{multiple:!0}:{}};try{let{values:a,positionals:r}=Yb({args:t,options:s,strict:!0,allowPositionals:!0});return{flags:a,positionals:r}}catch(a){throw h(a instanceof Error?a.message.replace(/^.*?: /,""):String(a),`palbase help ${e.name}`)}}function ew(e,t,n,s){let a="error",r,i,o=1,l;return e instanceof y?(a=e.code,r=e.message,i=e.hint,o=e.exitCode):e instanceof j?(a=e.code,r=e.message,l=e.requestId,e.code==="token_out_of_scope"&&t.env.PALBASE_TOKEN&&(r=`${e.op} refused PALBASE_TOKEN: ${e.message}`,i="this is the token's reach, fixed when it was minted: a person's yes does not change it \u2014 mint a token whose scopes name this call, or have a person run it signed in")):r=e instanceof Error?e.message:String(e),n&&e instanceof y&&e.reported||(n?t.stdout(`${JSON.stringify({error:a,message:r,...i?{hint:i}:{},...l?{request_id:l}:{}},null,2)}
14
14
  `):(t.stderr(`error: ${G(r)}${l?` (request ${G(l)})`:""}
15
15
  `),i&&t.stderr(` ${G(i)}
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
2
- import{a as M}from"../chunks/J3KELWNZ.js";import{a as v,b as P,c as k,e as S,f as A,g as T,h as C,i as w,j as R,k as j,l as E,m as x,n as D}from"../chunks/YAVAXQGR.js";import{a as U,b as G}from"../chunks/B773R25P.js";import{b,c as r,d as f}from"../chunks/NANJIH3L.js";import"../chunks/Q45P37LH.js";import"../chunks/OFLYZJK7.js";function B(t){let e=v.client(t),i=P.client(t),s=k.client(t),g=S.client(t),p=A.client(t),a=T.client(t),d=C.client(t),l=w.client(t),n=R.client(t),u=j.client(t),m=E.client(t),c=x.client(t),o=D.client(t);return{ai:{draftAgent:e.draftAgent,listAgents:e.listAgents,getAgent:e.getAgent,putAgent:e.putAgent,deleteAgent:e.deleteAgent,publishAgent:e.publishAgent,rollbackAgent:e.rollbackAgent,listAgentVersions:e.listAgentVersions,listChats:e.listChats,createChat:e.createChat,getChat:e.getChat,deleteChat:e.deleteChat,decideChatApproval:e.decideChatApproval,forkChat:e.forkChat,getChatGoal:e.getChatGoal,setChatGoal:e.setChatGoal,clearChatGoal:e.clearChatGoal,updateChatGoal:e.updateChatGoal,putChatMember:e.putChatMember,deleteChatMember:e.deleteChatMember,listChatMessages:e.listChatMessages,sendChatMessage:e.sendChatMessage,getChatMessageAttachment:e.getChatMessageAttachment,listChatParts:e.listChatParts,putChatPipe:e.putChatPipe,deleteChatPipe:e.deleteChatPipe,sendSubagentMessage:e.sendSubagentMessage,stopSubagent:e.stopSubagent,stopChat:e.stopChat,listTurnToolCalls:e.listTurnToolCalls,getChatToolCall:e.getChatToolCall,answerChatToolCall:e.answerChatToolCall,listChatTurnArtifacts:e.listChatTurnArtifacts,getChatTurnArtifact:e.getChatTurnArtifact,getChatTurnCost:e.getChatTurnCost,startChatVoice:e.startChatVoice,getChatVoice:e.getChatVoice,closeChatVoice:e.closeChatVoice,commandChatVoice:e.commandChatVoice,getChatWorkspaceFile:e.getChatWorkspaceFile,addChatWorkspaceRepo:e.addChatWorkspaceRepo,createEmbeddings:e.createEmbeddings,listEndpoints:e.listEndpoints,putEndpoint:e.putEndpoint,deleteEndpoint:e.deleteEndpoint,createImage:e.createImage,getImage:e.getImage,getImageFile:e.getImageFile,listModels:e.listModels,listProviders:e.listProviders,connectProvider:e.connectProvider,disconnectProvider:e.disconnectProvider,listRepos:e.listRepos,putRepo:e.putRepo,deleteRepo:e.deleteRepo,createResponse:e.createResponse,getResponse:e.getResponse,cancelResponse:e.cancelResponse,followResponse:e.followResponse,getSettings:e.getSettings,putSettings:e.putSettings,getSpend:e.getSpend,askSupport:e.askSupport,listTools:e.listTools,listUsage:e.listUsage},analytics:{listAudiences:i.listAudiences,createAudience:i.createAudience,previewAudience:i.previewAudience,getAudience:i.getAudience,deleteAudience:i.deleteAudience,updateAudience:i.updateAudience,listAudienceMembers:i.listAudienceMembers,alias:i.alias,batch:i.batch,getEventBreakdown:i.getEventBreakdown,capture:i.capture,sendConsoleHistory:i.sendConsoleHistory,getConsoleConfig:i.getConsoleConfig,listConsoleRecords:i.listConsoleRecords,listEventNames:i.listEventNames,listEvents:i.listEvents,getEventTimeline:i.getEventTimeline,runFunnel:i.runFunnel,identify:i.identify,page:i.page,sendPerf:i.sendPerf,listPerfGroups:i.listPerfGroups,getPerfConfig:i.getPerfConfig,getPerfTimeline:i.getPerfTimeline,listRequestLines:i.listRequestLines,getMachineTraffic:i.getMachineTraffic,runRetention:i.runRetention,screen:i.screen,getSettings:i.getSettings,putSettings:i.putSettings,getSummary:i.getSummary,listTraces:i.listTraces,sendTrace:i.sendTrace,sendTraceBatch:i.sendTraceBatch,getTraceHops:i.getTraceHops,listSessionTraces:i.listSessionTraces,getTraceSummary:i.getTraceSummary,getTraceTimeline:i.getTraceTimeline,searchPeople:i.searchPeople,setPersonProperties:i.setPersonProperties,getPerson:i.getPerson,listPersonEvents:i.listPersonEvents,getEventCatalog:i.getEventCatalog,defineEvent:i.defineEvent},auth:{adminVerifyDeviceAssertion:s.adminVerifyDeviceAssertion,adminGetAttestPolicy:s.adminGetAttestPolicy,adminGetAttestObservations:s.adminGetAttestObservations,adminRecordAttestObservations:s.adminRecordAttestObservations,adminListAuditEvents:s.adminListAuditEvents,adminExportAuditEvents:s.adminExportAuditEvents,adminVerifyAuditTrail:s.adminVerifyAuditTrail,adminGetAuthSettings:s.adminGetAuthSettings,adminUpdateAuthSettings:s.adminUpdateAuthSettings,adminGetBreachWatch:s.adminGetBreachWatch,adminListHooks:s.adminListHooks,adminCreateHook:s.adminCreateHook,adminUpdateHook:s.adminUpdateHook,adminDeleteHook:s.adminDeleteHook,adminListHookExecutions:s.adminListHookExecutions,adminListIntegrations:s.adminListIntegrations,adminPutIntegration:s.adminPutIntegration,adminDeleteIntegration:s.adminDeleteIntegration,adminListOAuthClients:s.adminListOAuthClients,adminCreateOAuthClient:s.adminCreateOAuthClient,adminGetOAuthClient:s.adminGetOAuthClient,adminDeleteOAuthClient:s.adminDeleteOAuthClient,adminUpdateOAuthClient:s.adminUpdateOAuthClient,adminListProviders:s.adminListProviders,adminGetPhoneSettings:s.adminGetPhoneSettings,adminUpdatePhoneSettings:s.adminUpdatePhoneSettings,adminToggleProvider:s.adminToggleProvider,adminListRoles:s.adminListRoles,adminUpsertRole:s.adminUpsertRole,adminDeleteRole:s.adminDeleteRole,adminListServiceAccounts:s.adminListServiceAccounts,adminCreateServiceAccount:s.adminCreateServiceAccount,adminGetServiceAccount:s.adminGetServiceAccount,adminRevokeServiceAccount:s.adminRevokeServiceAccount,adminRotateServiceAccount:s.adminRotateServiceAccount,adminListSessions:s.adminListSessions,adminRevokeSession:s.adminRevokeSession,adminListSigningKeys:s.adminListSigningKeys,adminRotateSigningKey:s.adminRotateSigningKey,socialAdminConfig:s.socialAdminConfig,socialCredentialPut:s.socialCredentialPut,socialCredentialDelete:s.socialCredentialDelete,socialProviderPatch:s.socialProviderPatch,adminGetStats:s.adminGetStats,adminSendTestTemplate:s.adminSendTestTemplate,adminListTestUsers:s.adminListTestUsers,adminCreateTestUsers:s.adminCreateTestUsers,adminSetTestUserPhone:s.adminSetTestUserPhone,adminCreateTestSignupAddress:s.adminCreateTestSignupAddress,adminDeleteTestUser:s.adminDeleteTestUser,adminCreateCustomToken:s.adminCreateCustomToken,adminListUsers:s.adminListUsers,adminCreateUser:s.adminCreateUser,adminImportUsers:s.adminImportUsers,adminGetUser:s.adminGetUser,adminDeleteUser:s.adminDeleteUser,adminUpdateUser:s.adminUpdateUser,adminBanUser:s.adminBanUser,adminGetUserConsents:s.adminGetUserConsents,adminRevokeUserCredentials:s.adminRevokeUserCredentials,adminExportUser:s.adminExportUser,adminListUserMfaFactors:s.adminListUserMfaFactors,adminResetUserMfa:s.adminResetUserMfa,adminResetUserPassword:s.adminResetUserPassword,adminListUserRoles:s.adminListUserRoles,adminAssignUserRole:s.adminAssignUserRole,adminRevokeUserRole:s.adminRevokeUserRole,adminRevokeUserSessions:s.adminRevokeUserSessions,adminUnbanUser:s.adminUnbanUser,adminGetInstallationConsents:s.adminGetInstallationConsents,adminRefuseConsents:s.adminRefuseConsents},flags:{getValues:g.getValues,batchUserValues:g.batchUserValues,getDelta:g.getDelta,getEvaluations:g.getEvaluations,listExperiments:g.listExperiments,startExperiment:g.startExperiment,getExperiment:g.getExperiment,getExperimentResults:g.getExperimentResults,stopExperiment:g.stopExperiment,declareExperimentWinner:g.declareExperimentWinner,getCurrentInstallations:g.getCurrentInstallations,getInstallationsDaily:g.getInstallationsDaily,getSnapshot:g.getSnapshot,listDefinitions:g.listDefinitions,getDefinition:g.getDefinition,putDefinition:g.putDefinition,deleteDefinition:g.deleteDefinition,activateTemplates:g.activateTemplates,getActiveTemplate:g.getActiveTemplate,getTemplateCapabilities:g.getTemplateCapabilities,getTemplateDraft:g.getTemplateDraft,createTemplateDraft:g.createTemplateDraft,discardTemplateDraft:g.discardTemplateDraft,putTemplateParameter:g.putTemplateParameter,removeTemplateParameter:g.removeTemplateParameter,reviewTemplateDraft:g.reviewTemplateDraft,publishTemplate:g.publishTemplate,getPublishReceipt:g.getPublishReceipt,restoreTemplateVersion:g.restoreTemplateVersion,listTemplateVersions:g.listTemplateVersions,getTemplateVersion:g.getTemplateVersion,getUserValues:g.getUserValues,putUserValues:g.putUserValues,deleteUserValues:g.deleteUserValues,putUserValue:g.putUserValue,deleteUserValue:g.deleteUserValue},journeys:{listJourneys:p.listJourneys,createJourney:p.createJourney,listPersonRuns:p.listPersonRuns,simulateJourney:p.simulateJourney,validateJourney:p.validateJourney,getJourney:p.getJourney,updateJourney:p.updateJourney,deleteJourney:p.deleteJourney,copyJourney:p.copyJourney,publishJourney:p.publishJourney,listJourneyRuns:p.listJourneyRuns,getJourneyStats:p.getJourneyStats,stopJourney:p.stopJourney,testJourney:p.testJourney},machines:{listMachines:a.listMachines,createMachine:a.createMachine,listMachineSizes:a.listMachineSizes,getMachineNetwork:a.getMachineNetwork,connectGitHub:a.connectGitHub,listInstallations:a.listInstallations,linkInstallation:a.linkInstallation,shareInstallation:a.shareInstallation,unlinkInstallation:a.unlinkInstallation,listRepositories:a.listRepositories,getMachine:a.getMachine,deleteMachine:a.deleteMachine,updateMachine:a.updateMachine,listBuilds:a.listBuilds,deployMachine:a.deployMachine,listMachinePreviews:a.listMachinePreviews,listMachineDomains:a.listMachineDomains,addMachineDomain:a.addMachineDomain,deleteMachineDomain:a.deleteMachineDomain,getBuild:a.getBuild,getBuildLog:a.getBuildLog,rollbackMachine:a.rollbackMachine,listDatabases:a.listDatabases,createDatabase:a.createDatabase,listDatabaseSizes:a.listDatabaseSizes,getDatabase:a.getDatabase,deleteDatabase:a.deleteDatabase,updateDatabase:a.updateDatabase,undeleteDatabase:a.undeleteDatabase,purgeDatabase:a.purgeDatabase,getDatabaseCredentials:a.getDatabaseCredentials,changeDatabasePassword:a.changeDatabasePassword,readMachineLogs:a.readMachineLogs,getMachineMetrics:a.getMachineMetrics,getMachineContract:a.getMachineContract,restoreDatabase:a.restoreDatabase,getDatabaseSchema:a.getDatabaseSchema,getDatabaseMetrics:a.getDatabaseMetrics,queryDatabase:a.queryDatabase,listCrons:a.listCrons,listCronRuns:a.listCronRuns,runCron:a.runCron,pauseCron:a.pauseCron,resumeCron:a.resumeCron,listTasks:a.listTasks,enqueueTask:a.enqueueTask,getTask:a.getTask,cancelTask:a.cancelTask,retryTask:a.retryTask,listTaskTypes:a.listTaskTypes,makeTemplatedTestUsers:a.makeTemplatedTestUsers,templateTestUser:a.templateTestUser,deleteTemplatedTestUser:a.deleteTemplatedTestUser,listSites:a.listSites,createSite:a.createSite,getSite:a.getSite,deleteSite:a.deleteSite,updateSite:a.updateSite,listSiteReleases:a.listSiteReleases,createSiteRelease:a.createSiteRelease,uploadSiteFile:a.uploadSiteFile,finishSiteRelease:a.finishSiteRelease,rollbackSite:a.rollbackSite,listSiteBuilds:a.listSiteBuilds,deploySite:a.deploySite,listSitePreviews:a.listSitePreviews,listSiteDomains:a.listSiteDomains,addSiteDomain:a.addSiteDomain,deleteSiteDomain:a.deleteSiteDomain,getSiteBuild:a.getSiteBuild},messaging:{adminAccessLog:d.adminAccessLog,adminListConversations:d.adminListConversations,adminCreateConversation:d.adminCreateConversation,adminGetConversation:d.adminGetConversation,adminDeleteConversation:d.adminDeleteConversation,adminAddMembers:d.adminAddMembers,adminRemoveMember:d.adminRemoveMember,adminListMessages:d.adminListMessages,adminSendMessage:d.adminSendMessage,adminDeleteMessage:d.adminDeleteMessage,adminFileUrl:d.adminFileUrl,adminPutProfile:d.adminPutProfile,adminListReports:d.adminListReports,adminGetReport:d.adminGetReport,adminReportFileUrl:d.adminReportFileUrl,adminResolveReport:d.adminResolveReport,getSettings:d.getSettings,putSettings:d.putSettings,rotateHookSecret:d.rotateHookSecret},notify:{getDeliverability:l.getDeliverability,listDevices:l.listDevices,getDeviceStats:l.getDeviceStats,deleteMyDevice:l.deleteMyDevice,sendEmail:l.sendEmail,listInAppCampaigns:l.listInAppCampaigns,createInAppCampaign:l.createInAppCampaign,getInAppCampaign:l.getInAppCampaign,putInAppCampaign:l.putInAppCampaign,deleteInAppCampaign:l.deleteInAppCampaign,getInAppCampaignStats:l.getInAppCampaignStats,listInAppTemplates:l.listInAppTemplates,sendInbox:l.sendInbox,listInboxMessages:l.listInboxMessages,listNotifyMessages:l.listNotifyMessages,getNotifyMessage:l.getNotifyMessage,cancelMessage:l.cancelMessage,getMetricsSummary:l.getMetricsSummary,listNotifyProviders:l.listNotifyProviders,putNotifyProvider:l.putNotifyProvider,deleteNotifyProvider:l.deleteNotifyProvider,sendPush:l.sendPush,getNotifySettings:l.getNotifySettings,putNotifySettings:l.putNotifySettings,sendSms:l.sendSms,listEmailTemplates:l.listEmailTemplates,getEmailTemplate:l.getEmailTemplate,putEmailTemplate:l.putEmailTemplate,deleteEmailTemplate:l.deleteEmailTemplate,listPushTemplates:l.listPushTemplates,getPushTemplate:l.getPushTemplate,putPushTemplate:l.putPushTemplate,deletePushTemplate:l.deletePushTemplate,listSmsTemplates:l.listSmsTemplates,getSmsTemplate:l.getSmsTemplate,putSmsTemplate:l.putSmsTemplate,deleteSmsTemplate:l.deleteSmsTemplate,listWhatsAppTemplates:l.listWhatsAppTemplates,getWhatsAppTemplate:l.getWhatsAppTemplate,putWhatsAppTemplate:l.putWhatsAppTemplate,deleteWhatsAppTemplate:l.deleteWhatsAppTemplate,listTestUserMessages:l.listTestUserMessages,listTopics:l.listTopics,createTopic:l.createTopic,deleteTopic:l.deleteTopic,changeTopic:l.changeTopic,addTopicSubscribers:l.addTopicSubscribers,removeTopicSubscriber:l.removeTopicSubscriber,listUserDevices:l.listUserDevices,getUserPreferences:l.getUserPreferences,setUserPreferences:l.setUserPreferences,startVerification:l.startVerification,checkVerification:l.checkVerification,getWebPushStatus:l.getWebPushStatus,sendWhatsApp:l.sendWhatsApp,listWhatsAppInbound:l.listWhatsAppInbound},purchases:{getAppleAccount:n.getAppleAccount,disconnectApple:n.disconnectApple,createAppleGrant:n.createAppleGrant,getAppleReadiness:n.getAppleReadiness,setXcodeCertificate:n.setXcodeCertificate,clearXcodeCertificate:n.clearXcodeCertificate,getGoogleAccount:n.getGoogleAccount,connectGoogle:n.connectGoogle,disconnectGoogle:n.disconnectGoogle,getCatalog:n.getCatalog,saveCatalog:n.saveCatalog,planCatalog:n.planCatalog,getCatalogPlan:n.getCatalogPlan,confirmCatalogPlan:n.confirmCatalogPlan,declineCatalogPlan:n.declineCatalogPlan,validateCatalog:n.validateCatalog,listCharts:n.listCharts,getChartsOverview:n.getChartsOverview,getChart:n.getChart,getCustomer:n.getCustomer,grantCredits:n.grantCredits,listCreditEntries:n.listCreditEntries,forgiveCredits:n.forgiveCredits,listCustomerGrants:n.listCustomerGrants,grantEntitlement:n.grantEntitlement,revokeGrant:n.revokeGrant,holdSpend:n.holdSpend,setCustomerLimit:n.setCustomerLimit,clearCustomerLimit:n.clearCustomerLimit,grantLimit:n.grantLimit,spend:n.spend,commitSpend:n.commitSpend,extendHold:n.extendHold,releaseSpend:n.releaseSpend,reverseSpend:n.reverseSpend,listExperiments:n.listExperiments,startExperiment:n.startExperiment,getExperiment:n.getExperiment,getExperimentResults:n.getExperimentResults,stopExperiment:n.stopExperiment,declareExperimentWinner:n.declareExperimentWinner,getOfferings:n.getOfferings,listPaywalls:n.listPaywalls,createPaywall:n.createPaywall,listPaywallAssets:n.listPaywallAssets,registerPaywallAsset:n.registerPaywallAsset,deletePaywallAsset:n.deletePaywallAsset,listPaywallTemplates:n.listPaywallTemplates,getPaywallTemplateAsset:n.getPaywallTemplateAsset,validatePaywall:n.validatePaywall,getPaywall:n.getPaywall,deletePaywall:n.deletePaywall,savePaywallDraft:n.savePaywallDraft,publishPaywall:n.publishPaywall,listPaywallVersions:n.listPaywallVersions,getPaywallVersion:n.getPaywallVersion,listPlacements:n.listPlacements,listAttributeKeys:n.listAttributeKeys,setPlacement:n.setPlacement,deletePlacement:n.deletePlacement,recordPaywallExposure:n.recordPaywallExposure,getPlacementPaywall:n.getPlacementPaywall,previewPlacement:n.previewPlacement,getPlacementResults:n.getPlacementResults,getPlacementRules:n.getPlacementRules,setPlacementRules:n.setPlacementRules,getSettings:n.getSettings,updateSettings:n.updateSettings,getStripeAccount:n.getStripeAccount,disconnectStripe:n.disconnectStripe,checkStripeAccount:n.checkStripeAccount,createCheckout:n.createCheckout,createCheckoutRedemption:n.createCheckoutRedemption,createStripeGrant:n.createStripeGrant,createStripeAppInstall:n.createStripeAppInstall,getOfferStats:n.getOfferStats,listCoupons:n.listCoupons,createCoupon:n.createCoupon,getCoupon:n.getCoupon,revokeCoupon:n.revokeCoupon,listCouponCodes:n.listCouponCodes,setXcodeOfferKey:n.setXcodeOfferKey,searchCustomers:n.searchCustomers,getCustomerHistory:n.getCustomerHistory,listCatalogRevisions:n.listCatalogRevisions,getCatalogRevision:n.getCatalogRevision,restoreCatalogRevision:n.restoreCatalogRevision,extendSubscription:n.extendSubscription,refundSubscription:n.refundSubscription,cancelSubscription:n.cancelSubscription},realtime:{broadcast:u.broadcast,getChannels:u.getChannels,putChannels:u.putChannels,getLimits:u.getLimits,putLimits:u.putLimits,revalidate:u.revalidate,writeState:u.writeState,getStats:u.getStats},secrets:{listSecretAudit:m.listSecretAudit,listFieldKeys:m.listFieldKeys,getFieldKeys:m.getFieldKeys,openFields:m.openFields,sealPlaceholder:m.sealPlaceholder,rotateFieldKeys:m.rotateFieldKeys,listTransitKeys:m.listTransitKeys,getTransitKeys:m.getTransitKeys,getTransitPublicKeys:m.getTransitPublicKeys,rotateTransitKeys:m.rotateTransitKeys,retireTransitKey:m.retireTransitKey,listSecrets:m.listSecrets,getEnvironmentValues:m.getEnvironmentValues,getSecret:m.getSecret,putSecret:m.putSecret,deleteSecret:m.deleteSecret,rollbackSecret:m.rollbackSecret,listSecretVersions:m.listSecretVersions},storage:{listBuckets:c.listBuckets,getBucket:c.getBucket,putBucket:c.putBucket,deleteBucket:c.deleteBucket,copyObject:c.copyObject,moveObject:c.moveObject,listObjects:c.listObjects,getObject:c.getObject,putObject:c.putObject,deleteObject:c.deleteObject,headObject:c.headObject,createSignedUrl:c.createSignedUrl,createUploadUrl:c.createUploadUrl,getStorageStats:c.getStorageStats},stores:{listActions:o.listActions,getAction:o.getAction,confirmAction:o.confirmAction,declineAction:o.declineAction,getAppleAccount:o.getAppleAccount,disconnectApple:o.disconnectApple,checkAppleAccount:o.checkAppleAccount,createAppleGrant:o.createAppleGrant,getSandboxReadiness:o.getSandboxReadiness,listSandboxTesters:o.listSandboxTesters,clearSandboxPurchaseHistory:o.clearSandboxPurchaseHistory,updateSandboxTester:o.updateSandboxTester,listApps:o.listApps,listFeedback:o.listFeedback,getFeedback:o.getFeedback,listGroups:o.listGroups,createGroup:o.createGroup,linkApp:o.linkApp,getListing:o.getListing,setListing:o.setListing,planListing:o.planListing,createPackage:o.createPackage,uploadScreenshot:o.uploadScreenshot,getReviewInfo:o.getReviewInfo,setReviewInfo:o.setReviewInfo,getUploadKey:o.getUploadKey,getAppStoreVersion:o.getAppStoreVersion,prepareAppStoreVersion:o.prepareAppStoreVersion,planPhasedRelease:o.planPhasedRelease,planReleaseVersion:o.planReleaseVersion,planSubmitReview:o.planSubmitReview,planWithdrawReview:o.planWithdrawReview,getAppVitals:o.getAppVitals,getAppWebhook:o.getAppWebhook,makeAppWebhook:o.makeAppWebhook,pingAppWebhook:o.pingAppWebhook,getGoogleAccount:o.getGoogleAccount,connectGoogle:o.connectGoogle,disconnectGoogle:o.disconnectGoogle,checkGoogleAccount:o.checkGoogleAccount,deleteGroup:o.deleteGroup,renameGroup:o.renameGroup,addGroupBuild:o.addGroupBuild,listTesters:o.listTesters,setTesters:o.setTesters,listPackages:o.listPackages,getPackage:o.getPackage,planBetaReview:o.planBetaReview,listDeliveries:o.listDeliveries,deliver:o.deliver,getSignedBundleLink:o.getSignedBundleLink,planExpire:o.planExpire,planExportCompliance:o.planExportCompliance,setWhatToTest:o.setWhatToTest,getAppleSession:o.getAppleSession,disconnectAppleSession:o.disconnectAppleSession,checkAppleSession:o.checkAppleSession,createAppleIdGrant:o.createAppleIdGrant,getAppReview:o.getAppReview,getReviewAttachment:o.getReviewAttachment,setReviewDraft:o.setReviewDraft,sendReviewDraft:o.sendReviewDraft,getAppPrivacy:o.getAppPrivacy,setAppPrivacy:o.setAppPrivacy,makeAppRecord:o.makeAppRecord,removeAppRecord:o.removeAppRecord,listMadeAppleKeys:o.listMadeAppleKeys,makeAppleKey:o.makeAppleKey,revokeMadeAppleKey:o.revokeMadeAppleKey,shareAppleSession:o.shareAppleSession,unshareAppleSession:o.unshareAppleSession}}}function I(t){return{orgs:{async list(e){return t.send({op:"orgs.list",method:"GET",path:"/v1/orgs",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e?.signal})},async get(e){return t.send({op:"orgs.get",method:"GET",path:"/v1/orgs/"+r("orgs.get","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async members(e){return t.send({op:"orgs.members",method:"GET",path:"/v1/orgs/"+r("orgs.members","id",e.path.id)+"/members",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async auditLog(e){return t.send({op:"orgs.auditLog",method:"GET",path:"/v1/orgs/"+r("orgs.auditLog","id",e.path.id)+"/audit",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})}},invitations:{async mine(e){return t.send({op:"invitations.mine",method:"GET",path:"/v1/invitations",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e?.signal})},async accept(e){return t.send({op:"invitations.accept",method:"POST",path:"/v1/invitations/"+r("invitations.accept","id",e.path.id)+"/accept",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})}},orgWebhooks:{async list(e){return t.send({op:"orgWebhooks.list",method:"GET",path:"/v1/orgs/"+r("orgWebhooks.list","id",e.path.id)+"/webhooks",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async add(e){return t.send({op:"orgWebhooks.add",method:"POST",path:"/v1/orgs/"+r("orgWebhooks.add","id",e.path.id)+"/webhooks",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async remove(e){return t.send({op:"orgWebhooks.remove",method:"DELETE",path:"/v1/orgs/"+r("orgWebhooks.remove","id",e.path.id)+"/webhooks/"+r("orgWebhooks.remove","endpoint",e.path.endpoint),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})}},projects:{async mine(e){return t.send({op:"projects.mine",method:"GET",path:"/v1/projects",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e?.signal})},async environmentsMine(e){return t.send({op:"projects.environmentsMine",method:"GET",path:"/v1/environments",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e?.signal})},async list(e){return t.send({op:"projects.list",method:"GET",path:"/v1/orgs/"+r("projects.list","id",e.path.id)+"/projects",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async create(e){return t.send({op:"projects.create",method:"POST",path:"/v1/orgs/"+r("projects.create","id",e.path.id)+"/projects",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async get(e){return t.send({op:"projects.get",method:"GET",path:"/v1/projects/"+r("projects.get","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async remove(e){return t.send({op:"projects.remove",method:"DELETE",path:"/v1/projects/"+r("projects.remove","id",e.path.id),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,query:e.query,headers:e.headers,signal:e.signal})},async rename(e){return t.send({op:"projects.rename",method:"PATCH",path:"/v1/projects/"+r("projects.rename","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async addEnvironment(e){return t.send({op:"projects.addEnvironment",method:"POST",path:"/v1/projects/"+r("projects.addEnvironment","id",e.path.id)+"/environments",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async environment(e){return t.send({op:"projects.environment",method:"GET",path:"/v1/environments/"+r("projects.environment","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async removeEnvironment(e){return t.send({op:"projects.removeEnvironment",method:"DELETE",path:"/v1/environments/"+r("projects.removeEnvironment","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,query:e.query,headers:e.headers,signal:e.signal})},async renameEnvironment(e){return t.send({op:"projects.renameEnvironment",method:"PATCH",path:"/v1/environments/"+r("projects.renameEnvironment","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async keys(e){return t.send({op:"projects.keys",method:"GET",path:"/v1/environments/"+r("projects.keys","ref",e.path.ref)+"/keys",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async usage(e){return t.send({op:"projects.usage",method:"GET",path:"/v1/environments/"+r("projects.usage","ref",e.path.ref)+"/usage",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})},async personalKey(e){return t.send({op:"projects.personalKey",method:"POST",path:"/v1/environments/"+r("projects.personalKey","ref",e.path.ref)+"/personal-key",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async revokePersonalKey(e){return t.send({op:"projects.revokePersonalKey",method:"DELETE",path:"/v1/environments/"+r("projects.revokePersonalKey","ref",e.path.ref)+"/personal-key/"+r("projects.revokePersonalKey","key",e.path.key),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})},async shareInstallation(e){return t.send({op:"projects.shareInstallation",method:"POST",path:"/v1/environments/"+r("projects.shareInstallation","ref",e.path.ref)+"/github/installations",auth:[["PalbaseBearer"]],answers:{},ownResponse:!0,idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})}},apps:{async list(e){return t.send({op:"apps.list",method:"GET",path:"/v1/projects/"+r("apps.list","id",e.path.id)+"/apps",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async create(e){return t.send({op:"apps.create",method:"POST",path:"/v1/projects/"+r("apps.create","id",e.path.id)+"/apps",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async get(e){return t.send({op:"apps.get",method:"GET",path:"/v1/projects/"+r("apps.get","id",e.path.id)+"/apps/"+r("apps.get","app",e.path.app),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async remove(e){return t.send({op:"apps.remove",method:"DELETE",path:"/v1/projects/"+r("apps.remove","id",e.path.id)+"/apps/"+r("apps.remove","app",e.path.app),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async update(e){return t.send({op:"apps.update",method:"PATCH",path:"/v1/projects/"+r("apps.update","id",e.path.id)+"/apps/"+r("apps.update","app",e.path.app),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async restore(e){return t.send({op:"apps.restore",method:"POST",path:"/v1/projects/"+r("apps.restore","id",e.path.id)+"/apps/"+r("apps.restore","app",e.path.app)+"/restore",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async setIn(e){return t.send({op:"apps.setIn",method:"PUT",path:"/v1/environments/"+r("apps.setIn","ref",e.path.ref)+"/apps/"+r("apps.setIn","app",e.path.app),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async removeFrom(e){return t.send({op:"apps.removeFrom",method:"DELETE",path:"/v1/environments/"+r("apps.removeFrom","ref",e.path.ref)+"/apps/"+r("apps.removeFrom","app",e.path.app),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})},async config(e){return t.send({op:"apps.config",method:"GET",path:"/v1/environments/"+r("apps.config","ref",e.path.ref)+"/apps/"+r("apps.config","app",e.path.app)+"/config",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})}},snippets:{async list(e){return t.send({op:"snippets.list",method:"GET",path:"/v1/environments/"+r("snippets.list","ref",e.path.ref)+"/snippets",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async create(e){return t.send({op:"snippets.create",method:"POST",path:"/v1/environments/"+r("snippets.create","ref",e.path.ref)+"/snippets",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async remove(e){return t.send({op:"snippets.remove",method:"DELETE",path:"/v1/environments/"+r("snippets.remove","ref",e.path.ref)+"/snippets/"+r("snippets.remove","id",e.path.id),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})},async change(e){return t.send({op:"snippets.change",method:"PATCH",path:"/v1/environments/"+r("snippets.change","ref",e.path.ref)+"/snippets/"+r("snippets.change","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})}},chartViews:{async list(e){return t.send({op:"chartViews.list",method:"GET",path:"/v1/environments/"+r("chartViews.list","ref",e.path.ref)+"/chart-views",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async create(e){return t.send({op:"chartViews.create",method:"POST",path:"/v1/environments/"+r("chartViews.create","ref",e.path.ref)+"/chart-views",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async remove(e){return t.send({op:"chartViews.remove",method:"DELETE",path:"/v1/environments/"+r("chartViews.remove","ref",e.path.ref)+"/chart-views/"+r("chartViews.remove","id",e.path.id),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})},async change(e){return t.send({op:"chartViews.change",method:"PATCH",path:"/v1/environments/"+r("chartViews.change","ref",e.path.ref)+"/chart-views/"+r("chartViews.change","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})}},webhooks:{async list(e){return t.send({op:"webhooks.list",method:"GET",path:"/v1/environments/"+r("webhooks.list","ref",e.path.ref)+"/webhooks",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async add(e){return t.send({op:"webhooks.add",method:"POST",path:"/v1/environments/"+r("webhooks.add","ref",e.path.ref)+"/webhooks",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async deliveries(e){return t.send({op:"webhooks.deliveries",method:"GET",path:"/v1/environments/"+r("webhooks.deliveries","ref",e.path.ref)+"/webhooks/deliveries",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})},async redeliver(e){return t.send({op:"webhooks.redeliver",method:"POST",path:"/v1/environments/"+r("webhooks.redeliver","ref",e.path.ref)+"/webhooks/deliveries/"+r("webhooks.redeliver","delivery",e.path.delivery)+"/redeliver",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async change(e){return t.send({op:"webhooks.change",method:"PUT",path:"/v1/environments/"+r("webhooks.change","ref",e.path.ref)+"/webhooks/"+r("webhooks.change","endpoint",e.path.endpoint),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async remove(e){return t.send({op:"webhooks.remove",method:"DELETE",path:"/v1/environments/"+r("webhooks.remove","ref",e.path.ref)+"/webhooks/"+r("webhooks.remove","endpoint",e.path.endpoint),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})}},environmentTokens:{async list(e){return t.send({op:"environmentTokens.list",method:"GET",path:"/v1/environments/"+r("environmentTokens.list","ref",e.path.ref)+"/tokens",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async mint(e){return t.send({op:"environmentTokens.mint",method:"POST",path:"/v1/environments/"+r("environmentTokens.mint","ref",e.path.ref)+"/tokens",auth:[["PalbaseBearer"],[]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async revoke(e){return t.send({op:"environmentTokens.revoke",method:"DELETE",path:"/v1/environments/"+r("environmentTokens.revoke","ref",e.path.ref)+"/tokens/"+r("environmentTokens.revoke","id",e.path.id),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})}},billing:{async bill(e){return t.send({op:"billing.bill",method:"GET",path:"/v1/orgs/"+r("billing.bill","id",e.path.id)+"/billing",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async confirm(e){return t.send({op:"billing.confirm",method:"POST",path:"/v1/orgs/"+r("billing.confirm","id",e.path.id)+"/billing/checkout/"+r("billing.confirm","session",e.path.session)+"/confirm",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async cards(e){return t.send({op:"billing.cards",method:"GET",path:"/v1/orgs/"+r("billing.cards","id",e.path.id)+"/billing/cards",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async defaultCard(e){return t.send({op:"billing.defaultCard",method:"PUT",path:"/v1/orgs/"+r("billing.defaultCard","id",e.path.id)+"/billing/cards/"+r("billing.defaultCard","card",e.path.card)+"/default",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async removeCard(e){return t.send({op:"billing.removeCard",method:"DELETE",path:"/v1/orgs/"+r("billing.removeCard","id",e.path.id)+"/billing/cards/"+r("billing.removeCard","card",e.path.card),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async customer(e){return t.send({op:"billing.customer",method:"GET",path:"/v1/orgs/"+r("billing.customer","id",e.path.id)+"/billing/customer",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async setCustomer(e){return t.send({op:"billing.setCustomer",method:"PUT",path:"/v1/orgs/"+r("billing.setCustomer","id",e.path.id)+"/billing/customer",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async charges(e){return t.send({op:"billing.charges",method:"GET",path:"/v1/orgs/"+r("billing.charges","id",e.path.id)+"/billing/charges",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})},async csv(e){return t.send({op:"billing.csv",method:"GET",path:"/v1/orgs/"+r("billing.csv","id",e.path.id)+"/billing/charges.csv",auth:[["PalbaseBearer"]],answers:{},ownResponse:!0,query:e.query,signal:e.signal})},async invoices(e){return t.send({op:"billing.invoices",method:"GET",path:"/v1/orgs/"+r("billing.invoices","id",e.path.id)+"/billing/invoices",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})},async transfer(e){return t.send({op:"billing.transfer",method:"POST",path:"/v1/orgs/"+r("billing.transfer","id",e.path.id)+"/billing/transfers",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async environment(e){return t.send({op:"billing.environment",method:"GET",path:"/v1/orgs/"+r("billing.environment","id",e.path.id)+"/billing/environments/"+r("billing.environment","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async steer(e){return t.send({op:"billing.steer",method:"PATCH",path:"/v1/orgs/"+r("billing.steer","id",e.path.id)+"/billing/environments/"+r("billing.steer","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async topUp(e){return t.send({op:"billing.topUp",method:"POST",path:"/v1/orgs/"+r("billing.topUp","id",e.path.id)+"/billing/environments/"+r("billing.topUp","ref",e.path.ref)+"/topups",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async bankTransfer(e){return t.send({op:"billing.bankTransfer",method:"POST",path:"/v1/orgs/"+r("billing.bankTransfer","id",e.path.id)+"/billing/environments/"+r("billing.bankTransfer","ref",e.path.ref)+"/bank-transfers",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async ledger(e){return t.send({op:"billing.ledger",method:"GET",path:"/v1/orgs/"+r("billing.ledger","id",e.path.id)+"/billing/environments/"+r("billing.ledger","ref",e.path.ref)+"/ledger",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})}},accessRequests:{async request(e){return t.send({op:"accessRequests.request",method:"POST",path:"/v1/access-requests",auth:[["PalbaseBearer"],[]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})}},docs:{async search(e){return t.send({op:"docs.search",method:"GET",path:"/v1/docs/search",auth:[["PalbaseBearer"],[]],answers:{200:"json"},query:e.query,signal:e.signal})}}}}function L(t){let{mint:e,revoke:i}=t;return async s=>{let g=await e(s),p=s.body?.role,a=s.body?.on_behalf_of;if(p===void 0&&a===void 0)return g;let d=g.data,l=[];if(p!==void 0&&d.role!==p&&l.push(`role ${p} (it came back ${d.role==null?"at its minter's":d.role})`),a!==void 0&&d.on_behalf_of!==a.trim()&&l.push("on_behalf_of"),l.length===0)return g;let n;try{await i({path:{ref:s.path.ref,id:String(d.id)}})}catch(m){n=m}let u=`Studio minted the token without the ${l.join(" and ")} asked for \u2014 it is older than this SDK`;throw new b({op:"environmentTokens.mint",status:0,code:"token_role_not_kept",message:n===void 0?`environmentTokens.mint: ${u}; the token (${d.id}) was revoked at once and is not returned \u2014 mint it again once Studio is updated`:`environmentTokens.mint: ${u}, and revoking it failed (${n instanceof Error?n.message:String(n)}) \u2014 revoke token ${d.id} of environment ${s.path.ref} yourself, now`,cause:n})}}var y={pbo_:"an organization's",pbe_:"an environment's"},z=/^[A-Za-z0-9_-]*$/,K=64,h=44;function O(t){if(typeof t!="string"||t==="")return"token is missing: pass an access token, an organization's (pbo_\u2026) or an environment's (pbe_\u2026)";let e=t.slice(0,4);if(!Object.hasOwn(y,e))return`token has the wrong prefix: an access token starts with pbo_ (an organization's) or pbe_ (an environment's)${/^pb_[a-z0-9]+_[cs]/.test(t)?" \u2014 a project key belongs in palbase/server or palbase/web":""}`;let i=t.slice(4);if(i.length!==K)return`token has the wrong length: ${y[e]} access token is ${e} and ${K} characters, this one has ${i.length} after it`;if(!z.test(i))return`token is not ${y[e]} access token: after ${e} come base64url characters alone (A\u2013Z, a\u2013z, 0\u20139, - and _)`;let s=N(i),g=(s[h]<<24|s[h+1]<<16|s[h+2]<<8|s[h+3])>>>0;if($(e,s.subarray(0,h))!==g)return"token's checksum does not match: it was mistyped or cut, or made before access tokens carried one \u2014 make a new token"}function H(t){return O(t)===void 0}function W(t){let e=O(t);if(e!==void 0)throw new TypeError(e)}var J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function N(t){let e=new Uint8Array(t.length*6/8),i=0,s=0,g=0;for(let p of t)i=i<<6|J.indexOf(p),s+=6,s>=8&&(s-=8,e[g++]=i>>s&255);return e}var V=(()=>{let t=new Uint32Array(256);for(let e=0;e<256;e++){let i=e;for(let s=0;s<8;s++)i=i&1?3988292384^i>>>1:i>>>1;t[e]=i>>>0}return t})();function $(t,e){let i=4294967295;for(let s=0;s<t.length;s++)i=V[(i^t.charCodeAt(s))&255]^i>>>8;for(let s of e)i=V[(i^s)&255]^i>>>8;return(i^4294967295)>>>0}var q="palbase.studio",X="palbase";function Y(){let t=globalThis;return typeof t.window<"u"||typeof t.document<"u"||typeof t.importScripts=="function"||M()}var _=class{domain;#e;#t=new Map;constructor(e){if(Y())throw new TypeError("palbase/cloud runs on a server: its access token opens the organization's projects, so it never goes into a browser, a web worker or a mobile app \u2014 keep it on your server, and have your app call that");W(e?.token);let i=e.domain??q;if(typeof i!="string"||!/^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(i))throw new TypeError(`domain ${JSON.stringify(i)} is not a domain`);this.domain=i;let s=e.token;this.#e=p=>G(f({baseUrl:p,credentials:{token:s},fetch:e.fetch,solveProofOfWork:!1}),e.retry??U);let g=I(this.#e(`https://palbase.app.${i}`));g.environmentTokens.mint=L(g.environmentTokens),Object.assign(this,g)}project(e){if(typeof e!="string"||!/^[a-z0-9]{1,63}$/.test(e))throw new TypeError(`${JSON.stringify(e)} is not an environment's ref`);let i=this.#t.get(e);return i||(i=B(this.#e(e===X?`https://connect.${this.domain}`:`https://${e}.${this.domain}`)),this.#t.set(e,i)),i}};export{q as DEFAULT_DOMAIN,_ as PalbaseCloud,b as PalbaseError,H as tokenIsWellFormed};
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
+ import{a as M}from"../chunks/IERZK64H.js";import{a as v,b as P,c as k,e as S,f as A,g as T,h as C,i as w,j as R,k as j,l as E,m as x,n as D}from"../chunks/LSJGREA3.js";import{a as U,b as G}from"../chunks/7HZ4EKJP.js";import{b,c as r,d as f}from"../chunks/YE7MYOBE.js";import"../chunks/FCJKKXVF.js";import"../chunks/BA4P3PMP.js";function B(t){let e=v.client(t),i=P.client(t),s=k.client(t),g=S.client(t),p=A.client(t),a=T.client(t),d=C.client(t),l=w.client(t),n=R.client(t),u=j.client(t),m=E.client(t),c=x.client(t),o=D.client(t);return{ai:{draftAgent:e.draftAgent,listAgents:e.listAgents,getAgent:e.getAgent,putAgent:e.putAgent,deleteAgent:e.deleteAgent,publishAgent:e.publishAgent,rollbackAgent:e.rollbackAgent,listAgentVersions:e.listAgentVersions,listChats:e.listChats,createChat:e.createChat,getChat:e.getChat,deleteChat:e.deleteChat,decideChatApproval:e.decideChatApproval,forkChat:e.forkChat,getChatGoal:e.getChatGoal,setChatGoal:e.setChatGoal,clearChatGoal:e.clearChatGoal,updateChatGoal:e.updateChatGoal,putChatMember:e.putChatMember,deleteChatMember:e.deleteChatMember,listChatMessages:e.listChatMessages,sendChatMessage:e.sendChatMessage,getChatMessageAttachment:e.getChatMessageAttachment,listChatParts:e.listChatParts,putChatPipe:e.putChatPipe,deleteChatPipe:e.deleteChatPipe,sendSubagentMessage:e.sendSubagentMessage,stopSubagent:e.stopSubagent,stopChat:e.stopChat,listTurnToolCalls:e.listTurnToolCalls,getChatToolCall:e.getChatToolCall,answerChatToolCall:e.answerChatToolCall,listChatTurnArtifacts:e.listChatTurnArtifacts,getChatTurnArtifact:e.getChatTurnArtifact,getChatTurnCost:e.getChatTurnCost,startChatVoice:e.startChatVoice,getChatVoice:e.getChatVoice,closeChatVoice:e.closeChatVoice,commandChatVoice:e.commandChatVoice,getChatWorkspaceFile:e.getChatWorkspaceFile,addChatWorkspaceRepo:e.addChatWorkspaceRepo,createEmbeddings:e.createEmbeddings,listEndpoints:e.listEndpoints,putEndpoint:e.putEndpoint,deleteEndpoint:e.deleteEndpoint,createImage:e.createImage,getImage:e.getImage,getImageFile:e.getImageFile,listModels:e.listModels,listProviders:e.listProviders,connectProvider:e.connectProvider,disconnectProvider:e.disconnectProvider,listRepos:e.listRepos,putRepo:e.putRepo,deleteRepo:e.deleteRepo,createResponse:e.createResponse,getResponse:e.getResponse,cancelResponse:e.cancelResponse,followResponse:e.followResponse,getSettings:e.getSettings,putSettings:e.putSettings,getSpend:e.getSpend,askSupport:e.askSupport,listTools:e.listTools,listUsage:e.listUsage},analytics:{listAudiences:i.listAudiences,createAudience:i.createAudience,previewAudience:i.previewAudience,getAudience:i.getAudience,deleteAudience:i.deleteAudience,updateAudience:i.updateAudience,listAudienceMembers:i.listAudienceMembers,alias:i.alias,batch:i.batch,getEventBreakdown:i.getEventBreakdown,capture:i.capture,sendConsoleHistory:i.sendConsoleHistory,getConsoleConfig:i.getConsoleConfig,listConsoleRecords:i.listConsoleRecords,listEventNames:i.listEventNames,listEvents:i.listEvents,getEventTimeline:i.getEventTimeline,runFunnel:i.runFunnel,identify:i.identify,page:i.page,sendPerf:i.sendPerf,listPerfGroups:i.listPerfGroups,getPerfConfig:i.getPerfConfig,getPerfTimeline:i.getPerfTimeline,listRequestLines:i.listRequestLines,getMachineTraffic:i.getMachineTraffic,runRetention:i.runRetention,screen:i.screen,getSettings:i.getSettings,putSettings:i.putSettings,getSummary:i.getSummary,listTraces:i.listTraces,sendTrace:i.sendTrace,sendTraceBatch:i.sendTraceBatch,getTraceHops:i.getTraceHops,listSessionTraces:i.listSessionTraces,getTraceSummary:i.getTraceSummary,getTraceTimeline:i.getTraceTimeline,searchPeople:i.searchPeople,setPersonProperties:i.setPersonProperties,getPerson:i.getPerson,listPersonEvents:i.listPersonEvents,getEventCatalog:i.getEventCatalog,defineEvent:i.defineEvent},auth:{adminVerifyDeviceAssertion:s.adminVerifyDeviceAssertion,adminGetAttestPolicy:s.adminGetAttestPolicy,adminGetAttestObservations:s.adminGetAttestObservations,adminRecordAttestObservations:s.adminRecordAttestObservations,adminListAuditEvents:s.adminListAuditEvents,adminExportAuditEvents:s.adminExportAuditEvents,adminVerifyAuditTrail:s.adminVerifyAuditTrail,adminGetAuthSettings:s.adminGetAuthSettings,adminUpdateAuthSettings:s.adminUpdateAuthSettings,adminGetBreachWatch:s.adminGetBreachWatch,adminListHooks:s.adminListHooks,adminCreateHook:s.adminCreateHook,adminUpdateHook:s.adminUpdateHook,adminDeleteHook:s.adminDeleteHook,adminListHookExecutions:s.adminListHookExecutions,adminListIntegrations:s.adminListIntegrations,adminPutIntegration:s.adminPutIntegration,adminDeleteIntegration:s.adminDeleteIntegration,adminListOAuthClients:s.adminListOAuthClients,adminCreateOAuthClient:s.adminCreateOAuthClient,adminGetOAuthClient:s.adminGetOAuthClient,adminDeleteOAuthClient:s.adminDeleteOAuthClient,adminUpdateOAuthClient:s.adminUpdateOAuthClient,adminListProviders:s.adminListProviders,adminGetPhoneSettings:s.adminGetPhoneSettings,adminUpdatePhoneSettings:s.adminUpdatePhoneSettings,adminToggleProvider:s.adminToggleProvider,adminListRoles:s.adminListRoles,adminUpsertRole:s.adminUpsertRole,adminDeleteRole:s.adminDeleteRole,adminListServiceAccounts:s.adminListServiceAccounts,adminCreateServiceAccount:s.adminCreateServiceAccount,adminGetServiceAccount:s.adminGetServiceAccount,adminRevokeServiceAccount:s.adminRevokeServiceAccount,adminRotateServiceAccount:s.adminRotateServiceAccount,adminListSessions:s.adminListSessions,adminRevokeSession:s.adminRevokeSession,adminListSigningKeys:s.adminListSigningKeys,adminRotateSigningKey:s.adminRotateSigningKey,socialAdminConfig:s.socialAdminConfig,socialCredentialPut:s.socialCredentialPut,socialCredentialDelete:s.socialCredentialDelete,socialProviderPatch:s.socialProviderPatch,adminGetStats:s.adminGetStats,adminSendTestTemplate:s.adminSendTestTemplate,adminListTestUsers:s.adminListTestUsers,adminCreateTestUsers:s.adminCreateTestUsers,adminSetTestUserPhone:s.adminSetTestUserPhone,adminCreateTestSignupAddress:s.adminCreateTestSignupAddress,adminDeleteTestUser:s.adminDeleteTestUser,adminCreateCustomToken:s.adminCreateCustomToken,adminListUsers:s.adminListUsers,adminCreateUser:s.adminCreateUser,adminImportUsers:s.adminImportUsers,adminGetUser:s.adminGetUser,adminDeleteUser:s.adminDeleteUser,adminUpdateUser:s.adminUpdateUser,adminBanUser:s.adminBanUser,adminGetUserConsents:s.adminGetUserConsents,adminRevokeUserCredentials:s.adminRevokeUserCredentials,adminExportUser:s.adminExportUser,adminListUserMfaFactors:s.adminListUserMfaFactors,adminResetUserMfa:s.adminResetUserMfa,adminResetUserPassword:s.adminResetUserPassword,adminListUserRoles:s.adminListUserRoles,adminAssignUserRole:s.adminAssignUserRole,adminRevokeUserRole:s.adminRevokeUserRole,adminRevokeUserSessions:s.adminRevokeUserSessions,adminUnbanUser:s.adminUnbanUser,adminGetInstallationConsents:s.adminGetInstallationConsents,adminRefuseConsents:s.adminRefuseConsents},flags:{getValues:g.getValues,batchUserValues:g.batchUserValues,getDelta:g.getDelta,getEvaluations:g.getEvaluations,listExperiments:g.listExperiments,startExperiment:g.startExperiment,getExperiment:g.getExperiment,getExperimentResults:g.getExperimentResults,stopExperiment:g.stopExperiment,declareExperimentWinner:g.declareExperimentWinner,getCurrentInstallations:g.getCurrentInstallations,getInstallationsDaily:g.getInstallationsDaily,getSnapshot:g.getSnapshot,listDefinitions:g.listDefinitions,getDefinition:g.getDefinition,putDefinition:g.putDefinition,deleteDefinition:g.deleteDefinition,activateTemplates:g.activateTemplates,getActiveTemplate:g.getActiveTemplate,getTemplateCapabilities:g.getTemplateCapabilities,getTemplateDraft:g.getTemplateDraft,createTemplateDraft:g.createTemplateDraft,discardTemplateDraft:g.discardTemplateDraft,putTemplateParameter:g.putTemplateParameter,removeTemplateParameter:g.removeTemplateParameter,reviewTemplateDraft:g.reviewTemplateDraft,publishTemplate:g.publishTemplate,getPublishReceipt:g.getPublishReceipt,restoreTemplateVersion:g.restoreTemplateVersion,listTemplateVersions:g.listTemplateVersions,getTemplateVersion:g.getTemplateVersion,getUserValues:g.getUserValues,putUserValues:g.putUserValues,deleteUserValues:g.deleteUserValues,putUserValue:g.putUserValue,deleteUserValue:g.deleteUserValue},journeys:{listJourneys:p.listJourneys,createJourney:p.createJourney,listPersonRuns:p.listPersonRuns,simulateJourney:p.simulateJourney,validateJourney:p.validateJourney,getJourney:p.getJourney,updateJourney:p.updateJourney,deleteJourney:p.deleteJourney,copyJourney:p.copyJourney,publishJourney:p.publishJourney,listJourneyRuns:p.listJourneyRuns,getJourneyStats:p.getJourneyStats,stopJourney:p.stopJourney,testJourney:p.testJourney},machines:{listMachines:a.listMachines,createMachine:a.createMachine,listMachineSizes:a.listMachineSizes,getMachineNetwork:a.getMachineNetwork,connectGitHub:a.connectGitHub,listInstallations:a.listInstallations,linkInstallation:a.linkInstallation,shareInstallation:a.shareInstallation,unlinkInstallation:a.unlinkInstallation,listRepositories:a.listRepositories,getMachine:a.getMachine,deleteMachine:a.deleteMachine,updateMachine:a.updateMachine,listBuilds:a.listBuilds,deployMachine:a.deployMachine,listMachinePreviews:a.listMachinePreviews,listMachineDomains:a.listMachineDomains,addMachineDomain:a.addMachineDomain,deleteMachineDomain:a.deleteMachineDomain,getBuild:a.getBuild,getBuildLog:a.getBuildLog,rollbackMachine:a.rollbackMachine,listDatabases:a.listDatabases,createDatabase:a.createDatabase,listDatabaseSizes:a.listDatabaseSizes,getDatabase:a.getDatabase,deleteDatabase:a.deleteDatabase,updateDatabase:a.updateDatabase,undeleteDatabase:a.undeleteDatabase,purgeDatabase:a.purgeDatabase,getDatabaseCredentials:a.getDatabaseCredentials,changeDatabasePassword:a.changeDatabasePassword,readMachineLogs:a.readMachineLogs,getMachineMetrics:a.getMachineMetrics,getMachineContract:a.getMachineContract,restoreDatabase:a.restoreDatabase,getDatabaseSchema:a.getDatabaseSchema,getDatabaseMetrics:a.getDatabaseMetrics,queryDatabase:a.queryDatabase,listCrons:a.listCrons,listCronRuns:a.listCronRuns,runCron:a.runCron,pauseCron:a.pauseCron,resumeCron:a.resumeCron,listTasks:a.listTasks,enqueueTask:a.enqueueTask,getTask:a.getTask,cancelTask:a.cancelTask,retryTask:a.retryTask,listTaskTypes:a.listTaskTypes,makeTemplatedTestUsers:a.makeTemplatedTestUsers,templateTestUser:a.templateTestUser,deleteTemplatedTestUser:a.deleteTemplatedTestUser,listSites:a.listSites,createSite:a.createSite,getSite:a.getSite,deleteSite:a.deleteSite,updateSite:a.updateSite,listSiteReleases:a.listSiteReleases,createSiteRelease:a.createSiteRelease,uploadSiteFile:a.uploadSiteFile,finishSiteRelease:a.finishSiteRelease,rollbackSite:a.rollbackSite,listSiteBuilds:a.listSiteBuilds,deploySite:a.deploySite,listSitePreviews:a.listSitePreviews,listSiteDomains:a.listSiteDomains,addSiteDomain:a.addSiteDomain,deleteSiteDomain:a.deleteSiteDomain,getSiteBuild:a.getSiteBuild},messaging:{adminAccessLog:d.adminAccessLog,adminListConversations:d.adminListConversations,adminCreateConversation:d.adminCreateConversation,adminGetConversation:d.adminGetConversation,adminDeleteConversation:d.adminDeleteConversation,adminAddMembers:d.adminAddMembers,adminRemoveMember:d.adminRemoveMember,adminListMessages:d.adminListMessages,adminSendMessage:d.adminSendMessage,adminDeleteMessage:d.adminDeleteMessage,adminFileUrl:d.adminFileUrl,adminPutProfile:d.adminPutProfile,adminListReports:d.adminListReports,adminGetReport:d.adminGetReport,adminReportFileUrl:d.adminReportFileUrl,adminResolveReport:d.adminResolveReport,getSettings:d.getSettings,putSettings:d.putSettings,rotateHookSecret:d.rotateHookSecret},notify:{getDeliverability:l.getDeliverability,listDevices:l.listDevices,getDeviceStats:l.getDeviceStats,deleteMyDevice:l.deleteMyDevice,sendEmail:l.sendEmail,listInAppCampaigns:l.listInAppCampaigns,createInAppCampaign:l.createInAppCampaign,getInAppCampaign:l.getInAppCampaign,putInAppCampaign:l.putInAppCampaign,deleteInAppCampaign:l.deleteInAppCampaign,getInAppCampaignStats:l.getInAppCampaignStats,listInAppTemplates:l.listInAppTemplates,sendInbox:l.sendInbox,listInboxMessages:l.listInboxMessages,listNotifyMessages:l.listNotifyMessages,getNotifyMessage:l.getNotifyMessage,cancelMessage:l.cancelMessage,getMetricsSummary:l.getMetricsSummary,listNotifyProviders:l.listNotifyProviders,putNotifyProvider:l.putNotifyProvider,deleteNotifyProvider:l.deleteNotifyProvider,sendPush:l.sendPush,getNotifySettings:l.getNotifySettings,putNotifySettings:l.putNotifySettings,sendSms:l.sendSms,listEmailTemplates:l.listEmailTemplates,getEmailTemplate:l.getEmailTemplate,putEmailTemplate:l.putEmailTemplate,deleteEmailTemplate:l.deleteEmailTemplate,listPushTemplates:l.listPushTemplates,getPushTemplate:l.getPushTemplate,putPushTemplate:l.putPushTemplate,deletePushTemplate:l.deletePushTemplate,listSmsTemplates:l.listSmsTemplates,getSmsTemplate:l.getSmsTemplate,putSmsTemplate:l.putSmsTemplate,deleteSmsTemplate:l.deleteSmsTemplate,listWhatsAppTemplates:l.listWhatsAppTemplates,getWhatsAppTemplate:l.getWhatsAppTemplate,putWhatsAppTemplate:l.putWhatsAppTemplate,deleteWhatsAppTemplate:l.deleteWhatsAppTemplate,listTestUserMessages:l.listTestUserMessages,listTopics:l.listTopics,createTopic:l.createTopic,deleteTopic:l.deleteTopic,changeTopic:l.changeTopic,addTopicSubscribers:l.addTopicSubscribers,removeTopicSubscriber:l.removeTopicSubscriber,listUserDevices:l.listUserDevices,getUserPreferences:l.getUserPreferences,setUserPreferences:l.setUserPreferences,startVerification:l.startVerification,checkVerification:l.checkVerification,getWebPushStatus:l.getWebPushStatus,sendWhatsApp:l.sendWhatsApp,listWhatsAppInbound:l.listWhatsAppInbound},purchases:{getAppleAccount:n.getAppleAccount,disconnectApple:n.disconnectApple,createAppleGrant:n.createAppleGrant,getAppleReadiness:n.getAppleReadiness,setXcodeCertificate:n.setXcodeCertificate,clearXcodeCertificate:n.clearXcodeCertificate,getGoogleAccount:n.getGoogleAccount,connectGoogle:n.connectGoogle,disconnectGoogle:n.disconnectGoogle,getCatalog:n.getCatalog,saveCatalog:n.saveCatalog,planCatalog:n.planCatalog,getCatalogPlan:n.getCatalogPlan,confirmCatalogPlan:n.confirmCatalogPlan,declineCatalogPlan:n.declineCatalogPlan,validateCatalog:n.validateCatalog,listCharts:n.listCharts,getChartsOverview:n.getChartsOverview,getChart:n.getChart,getCustomer:n.getCustomer,grantCredits:n.grantCredits,listCreditEntries:n.listCreditEntries,forgiveCredits:n.forgiveCredits,listCustomerGrants:n.listCustomerGrants,grantEntitlement:n.grantEntitlement,revokeGrant:n.revokeGrant,holdSpend:n.holdSpend,setCustomerLimit:n.setCustomerLimit,clearCustomerLimit:n.clearCustomerLimit,grantLimit:n.grantLimit,spend:n.spend,commitSpend:n.commitSpend,extendHold:n.extendHold,releaseSpend:n.releaseSpend,reverseSpend:n.reverseSpend,listExperiments:n.listExperiments,startExperiment:n.startExperiment,getExperiment:n.getExperiment,getExperimentResults:n.getExperimentResults,stopExperiment:n.stopExperiment,declareExperimentWinner:n.declareExperimentWinner,getOfferings:n.getOfferings,listPaywalls:n.listPaywalls,createPaywall:n.createPaywall,listPaywallAssets:n.listPaywallAssets,registerPaywallAsset:n.registerPaywallAsset,deletePaywallAsset:n.deletePaywallAsset,listPaywallTemplates:n.listPaywallTemplates,getPaywallTemplateAsset:n.getPaywallTemplateAsset,validatePaywall:n.validatePaywall,getPaywall:n.getPaywall,deletePaywall:n.deletePaywall,savePaywallDraft:n.savePaywallDraft,publishPaywall:n.publishPaywall,listPaywallVersions:n.listPaywallVersions,getPaywallVersion:n.getPaywallVersion,listPlacements:n.listPlacements,listAttributeKeys:n.listAttributeKeys,setPlacement:n.setPlacement,deletePlacement:n.deletePlacement,recordPaywallExposure:n.recordPaywallExposure,getPlacementPaywall:n.getPlacementPaywall,previewPlacement:n.previewPlacement,getPlacementResults:n.getPlacementResults,getPlacementRules:n.getPlacementRules,setPlacementRules:n.setPlacementRules,getSettings:n.getSettings,updateSettings:n.updateSettings,getStripeAccount:n.getStripeAccount,disconnectStripe:n.disconnectStripe,checkStripeAccount:n.checkStripeAccount,createCheckout:n.createCheckout,createCheckoutRedemption:n.createCheckoutRedemption,createStripeGrant:n.createStripeGrant,createStripeAppInstall:n.createStripeAppInstall,getOfferStats:n.getOfferStats,listCoupons:n.listCoupons,createCoupon:n.createCoupon,getCoupon:n.getCoupon,revokeCoupon:n.revokeCoupon,listCouponCodes:n.listCouponCodes,setXcodeOfferKey:n.setXcodeOfferKey,searchCustomers:n.searchCustomers,getCustomerHistory:n.getCustomerHistory,listCatalogRevisions:n.listCatalogRevisions,getCatalogRevision:n.getCatalogRevision,restoreCatalogRevision:n.restoreCatalogRevision,extendSubscription:n.extendSubscription,refundSubscription:n.refundSubscription,cancelSubscription:n.cancelSubscription},realtime:{broadcast:u.broadcast,getChannels:u.getChannels,putChannels:u.putChannels,getLimits:u.getLimits,putLimits:u.putLimits,revalidate:u.revalidate,writeState:u.writeState,getStats:u.getStats},secrets:{listSecretAudit:m.listSecretAudit,listFieldKeys:m.listFieldKeys,getFieldKeys:m.getFieldKeys,openFields:m.openFields,sealPlaceholder:m.sealPlaceholder,rotateFieldKeys:m.rotateFieldKeys,listTransitKeys:m.listTransitKeys,getTransitKeys:m.getTransitKeys,getTransitPublicKeys:m.getTransitPublicKeys,rotateTransitKeys:m.rotateTransitKeys,retireTransitKey:m.retireTransitKey,listSecrets:m.listSecrets,getEnvironmentValues:m.getEnvironmentValues,getSecret:m.getSecret,putSecret:m.putSecret,deleteSecret:m.deleteSecret,rollbackSecret:m.rollbackSecret,listSecretVersions:m.listSecretVersions},storage:{listBuckets:c.listBuckets,getBucket:c.getBucket,putBucket:c.putBucket,deleteBucket:c.deleteBucket,copyObject:c.copyObject,moveObject:c.moveObject,listObjects:c.listObjects,getObject:c.getObject,putObject:c.putObject,deleteObject:c.deleteObject,headObject:c.headObject,createSignedUrl:c.createSignedUrl,createUploadUrl:c.createUploadUrl,getStorageStats:c.getStorageStats},stores:{listActions:o.listActions,getAction:o.getAction,confirmAction:o.confirmAction,declineAction:o.declineAction,getAppleAccount:o.getAppleAccount,disconnectApple:o.disconnectApple,checkAppleAccount:o.checkAppleAccount,createAppleGrant:o.createAppleGrant,getSandboxReadiness:o.getSandboxReadiness,listSandboxTesters:o.listSandboxTesters,clearSandboxPurchaseHistory:o.clearSandboxPurchaseHistory,updateSandboxTester:o.updateSandboxTester,listApps:o.listApps,listFeedback:o.listFeedback,getFeedback:o.getFeedback,listGroups:o.listGroups,createGroup:o.createGroup,linkApp:o.linkApp,getListing:o.getListing,setListing:o.setListing,planListing:o.planListing,createPackage:o.createPackage,uploadScreenshot:o.uploadScreenshot,getReviewInfo:o.getReviewInfo,setReviewInfo:o.setReviewInfo,getUploadKey:o.getUploadKey,getAppStoreVersion:o.getAppStoreVersion,prepareAppStoreVersion:o.prepareAppStoreVersion,planPhasedRelease:o.planPhasedRelease,planReleaseVersion:o.planReleaseVersion,planSubmitReview:o.planSubmitReview,planWithdrawReview:o.planWithdrawReview,getAppVitals:o.getAppVitals,getAppWebhook:o.getAppWebhook,makeAppWebhook:o.makeAppWebhook,pingAppWebhook:o.pingAppWebhook,getGoogleAccount:o.getGoogleAccount,connectGoogle:o.connectGoogle,disconnectGoogle:o.disconnectGoogle,checkGoogleAccount:o.checkGoogleAccount,deleteGroup:o.deleteGroup,renameGroup:o.renameGroup,addGroupBuild:o.addGroupBuild,listTesters:o.listTesters,setTesters:o.setTesters,listPackages:o.listPackages,getPackage:o.getPackage,planBetaReview:o.planBetaReview,listDeliveries:o.listDeliveries,deliver:o.deliver,getSignedBundleLink:o.getSignedBundleLink,planExpire:o.planExpire,planExportCompliance:o.planExportCompliance,setWhatToTest:o.setWhatToTest,getAppleSession:o.getAppleSession,disconnectAppleSession:o.disconnectAppleSession,checkAppleSession:o.checkAppleSession,createAppleIdGrant:o.createAppleIdGrant,getAppReview:o.getAppReview,getReviewAttachment:o.getReviewAttachment,setReviewDraft:o.setReviewDraft,sendReviewDraft:o.sendReviewDraft,getAppPrivacy:o.getAppPrivacy,setAppPrivacy:o.setAppPrivacy,makeAppRecord:o.makeAppRecord,removeAppRecord:o.removeAppRecord,listMadeAppleKeys:o.listMadeAppleKeys,makeAppleKey:o.makeAppleKey,revokeMadeAppleKey:o.revokeMadeAppleKey,shareAppleSession:o.shareAppleSession,unshareAppleSession:o.unshareAppleSession}}}function I(t){return{orgs:{async list(e){return t.send({op:"orgs.list",method:"GET",path:"/v1/orgs",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e?.signal})},async get(e){return t.send({op:"orgs.get",method:"GET",path:"/v1/orgs/"+r("orgs.get","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async members(e){return t.send({op:"orgs.members",method:"GET",path:"/v1/orgs/"+r("orgs.members","id",e.path.id)+"/members",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async auditLog(e){return t.send({op:"orgs.auditLog",method:"GET",path:"/v1/orgs/"+r("orgs.auditLog","id",e.path.id)+"/audit",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})}},invitations:{async mine(e){return t.send({op:"invitations.mine",method:"GET",path:"/v1/invitations",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e?.signal})},async accept(e){return t.send({op:"invitations.accept",method:"POST",path:"/v1/invitations/"+r("invitations.accept","id",e.path.id)+"/accept",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})}},orgWebhooks:{async list(e){return t.send({op:"orgWebhooks.list",method:"GET",path:"/v1/orgs/"+r("orgWebhooks.list","id",e.path.id)+"/webhooks",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async add(e){return t.send({op:"orgWebhooks.add",method:"POST",path:"/v1/orgs/"+r("orgWebhooks.add","id",e.path.id)+"/webhooks",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async remove(e){return t.send({op:"orgWebhooks.remove",method:"DELETE",path:"/v1/orgs/"+r("orgWebhooks.remove","id",e.path.id)+"/webhooks/"+r("orgWebhooks.remove","endpoint",e.path.endpoint),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})}},projects:{async mine(e){return t.send({op:"projects.mine",method:"GET",path:"/v1/projects",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e?.signal})},async environmentsMine(e){return t.send({op:"projects.environmentsMine",method:"GET",path:"/v1/environments",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e?.signal})},async list(e){return t.send({op:"projects.list",method:"GET",path:"/v1/orgs/"+r("projects.list","id",e.path.id)+"/projects",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async create(e){return t.send({op:"projects.create",method:"POST",path:"/v1/orgs/"+r("projects.create","id",e.path.id)+"/projects",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async get(e){return t.send({op:"projects.get",method:"GET",path:"/v1/projects/"+r("projects.get","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async remove(e){return t.send({op:"projects.remove",method:"DELETE",path:"/v1/projects/"+r("projects.remove","id",e.path.id),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,query:e.query,headers:e.headers,signal:e.signal})},async rename(e){return t.send({op:"projects.rename",method:"PATCH",path:"/v1/projects/"+r("projects.rename","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async addEnvironment(e){return t.send({op:"projects.addEnvironment",method:"POST",path:"/v1/projects/"+r("projects.addEnvironment","id",e.path.id)+"/environments",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async environment(e){return t.send({op:"projects.environment",method:"GET",path:"/v1/environments/"+r("projects.environment","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async removeEnvironment(e){return t.send({op:"projects.removeEnvironment",method:"DELETE",path:"/v1/environments/"+r("projects.removeEnvironment","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,query:e.query,headers:e.headers,signal:e.signal})},async renameEnvironment(e){return t.send({op:"projects.renameEnvironment",method:"PATCH",path:"/v1/environments/"+r("projects.renameEnvironment","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async keys(e){return t.send({op:"projects.keys",method:"GET",path:"/v1/environments/"+r("projects.keys","ref",e.path.ref)+"/keys",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async usage(e){return t.send({op:"projects.usage",method:"GET",path:"/v1/environments/"+r("projects.usage","ref",e.path.ref)+"/usage",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})},async personalKey(e){return t.send({op:"projects.personalKey",method:"POST",path:"/v1/environments/"+r("projects.personalKey","ref",e.path.ref)+"/personal-key",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async revokePersonalKey(e){return t.send({op:"projects.revokePersonalKey",method:"DELETE",path:"/v1/environments/"+r("projects.revokePersonalKey","ref",e.path.ref)+"/personal-key/"+r("projects.revokePersonalKey","key",e.path.key),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})},async shareInstallation(e){return t.send({op:"projects.shareInstallation",method:"POST",path:"/v1/environments/"+r("projects.shareInstallation","ref",e.path.ref)+"/github/installations",auth:[["PalbaseBearer"]],answers:{},ownResponse:!0,idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})}},apps:{async list(e){return t.send({op:"apps.list",method:"GET",path:"/v1/projects/"+r("apps.list","id",e.path.id)+"/apps",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async create(e){return t.send({op:"apps.create",method:"POST",path:"/v1/projects/"+r("apps.create","id",e.path.id)+"/apps",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async get(e){return t.send({op:"apps.get",method:"GET",path:"/v1/projects/"+r("apps.get","id",e.path.id)+"/apps/"+r("apps.get","app",e.path.app),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async remove(e){return t.send({op:"apps.remove",method:"DELETE",path:"/v1/projects/"+r("apps.remove","id",e.path.id)+"/apps/"+r("apps.remove","app",e.path.app),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async update(e){return t.send({op:"apps.update",method:"PATCH",path:"/v1/projects/"+r("apps.update","id",e.path.id)+"/apps/"+r("apps.update","app",e.path.app),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async restore(e){return t.send({op:"apps.restore",method:"POST",path:"/v1/projects/"+r("apps.restore","id",e.path.id)+"/apps/"+r("apps.restore","app",e.path.app)+"/restore",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async setIn(e){return t.send({op:"apps.setIn",method:"PUT",path:"/v1/environments/"+r("apps.setIn","ref",e.path.ref)+"/apps/"+r("apps.setIn","app",e.path.app),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async removeFrom(e){return t.send({op:"apps.removeFrom",method:"DELETE",path:"/v1/environments/"+r("apps.removeFrom","ref",e.path.ref)+"/apps/"+r("apps.removeFrom","app",e.path.app),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})},async config(e){return t.send({op:"apps.config",method:"GET",path:"/v1/environments/"+r("apps.config","ref",e.path.ref)+"/apps/"+r("apps.config","app",e.path.app)+"/config",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})}},snippets:{async list(e){return t.send({op:"snippets.list",method:"GET",path:"/v1/environments/"+r("snippets.list","ref",e.path.ref)+"/snippets",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async create(e){return t.send({op:"snippets.create",method:"POST",path:"/v1/environments/"+r("snippets.create","ref",e.path.ref)+"/snippets",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async remove(e){return t.send({op:"snippets.remove",method:"DELETE",path:"/v1/environments/"+r("snippets.remove","ref",e.path.ref)+"/snippets/"+r("snippets.remove","id",e.path.id),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})},async change(e){return t.send({op:"snippets.change",method:"PATCH",path:"/v1/environments/"+r("snippets.change","ref",e.path.ref)+"/snippets/"+r("snippets.change","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})}},chartViews:{async list(e){return t.send({op:"chartViews.list",method:"GET",path:"/v1/environments/"+r("chartViews.list","ref",e.path.ref)+"/chart-views",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async create(e){return t.send({op:"chartViews.create",method:"POST",path:"/v1/environments/"+r("chartViews.create","ref",e.path.ref)+"/chart-views",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async remove(e){return t.send({op:"chartViews.remove",method:"DELETE",path:"/v1/environments/"+r("chartViews.remove","ref",e.path.ref)+"/chart-views/"+r("chartViews.remove","id",e.path.id),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})},async change(e){return t.send({op:"chartViews.change",method:"PATCH",path:"/v1/environments/"+r("chartViews.change","ref",e.path.ref)+"/chart-views/"+r("chartViews.change","id",e.path.id),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})}},webhooks:{async list(e){return t.send({op:"webhooks.list",method:"GET",path:"/v1/environments/"+r("webhooks.list","ref",e.path.ref)+"/webhooks",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async add(e){return t.send({op:"webhooks.add",method:"POST",path:"/v1/environments/"+r("webhooks.add","ref",e.path.ref)+"/webhooks",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async deliveries(e){return t.send({op:"webhooks.deliveries",method:"GET",path:"/v1/environments/"+r("webhooks.deliveries","ref",e.path.ref)+"/webhooks/deliveries",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})},async redeliver(e){return t.send({op:"webhooks.redeliver",method:"POST",path:"/v1/environments/"+r("webhooks.redeliver","ref",e.path.ref)+"/webhooks/deliveries/"+r("webhooks.redeliver","delivery",e.path.delivery)+"/redeliver",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async change(e){return t.send({op:"webhooks.change",method:"PUT",path:"/v1/environments/"+r("webhooks.change","ref",e.path.ref)+"/webhooks/"+r("webhooks.change","endpoint",e.path.endpoint),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async remove(e){return t.send({op:"webhooks.remove",method:"DELETE",path:"/v1/environments/"+r("webhooks.remove","ref",e.path.ref)+"/webhooks/"+r("webhooks.remove","endpoint",e.path.endpoint),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})}},environmentTokens:{async list(e){return t.send({op:"environmentTokens.list",method:"GET",path:"/v1/environments/"+r("environmentTokens.list","ref",e.path.ref)+"/tokens",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async mint(e){return t.send({op:"environmentTokens.mint",method:"POST",path:"/v1/environments/"+r("environmentTokens.mint","ref",e.path.ref)+"/tokens",auth:[["PalbaseBearer"],[]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async revoke(e){return t.send({op:"environmentTokens.revoke",method:"DELETE",path:"/v1/environments/"+r("environmentTokens.revoke","ref",e.path.ref)+"/tokens/"+r("environmentTokens.revoke","id",e.path.id),auth:[["PalbaseBearer"]],answers:{204:"empty"},idempotent:!0,headers:e.headers,signal:e.signal})}},billing:{async bill(e){return t.send({op:"billing.bill",method:"GET",path:"/v1/orgs/"+r("billing.bill","id",e.path.id)+"/billing",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async confirm(e){return t.send({op:"billing.confirm",method:"POST",path:"/v1/orgs/"+r("billing.confirm","id",e.path.id)+"/billing/checkout/"+r("billing.confirm","session",e.path.session)+"/confirm",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async cards(e){return t.send({op:"billing.cards",method:"GET",path:"/v1/orgs/"+r("billing.cards","id",e.path.id)+"/billing/cards",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async defaultCard(e){return t.send({op:"billing.defaultCard",method:"PUT",path:"/v1/orgs/"+r("billing.defaultCard","id",e.path.id)+"/billing/cards/"+r("billing.defaultCard","card",e.path.card)+"/default",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async removeCard(e){return t.send({op:"billing.removeCard",method:"DELETE",path:"/v1/orgs/"+r("billing.removeCard","id",e.path.id)+"/billing/cards/"+r("billing.removeCard","card",e.path.card),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,signal:e.signal})},async customer(e){return t.send({op:"billing.customer",method:"GET",path:"/v1/orgs/"+r("billing.customer","id",e.path.id)+"/billing/customer",auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async setCustomer(e){return t.send({op:"billing.setCustomer",method:"PUT",path:"/v1/orgs/"+r("billing.setCustomer","id",e.path.id)+"/billing/customer",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async charges(e){return t.send({op:"billing.charges",method:"GET",path:"/v1/orgs/"+r("billing.charges","id",e.path.id)+"/billing/charges",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})},async csv(e){return t.send({op:"billing.csv",method:"GET",path:"/v1/orgs/"+r("billing.csv","id",e.path.id)+"/billing/charges.csv",auth:[["PalbaseBearer"]],answers:{},ownResponse:!0,query:e.query,signal:e.signal})},async invoices(e){return t.send({op:"billing.invoices",method:"GET",path:"/v1/orgs/"+r("billing.invoices","id",e.path.id)+"/billing/invoices",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})},async transfer(e){return t.send({op:"billing.transfer",method:"POST",path:"/v1/orgs/"+r("billing.transfer","id",e.path.id)+"/billing/transfers",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async environment(e){return t.send({op:"billing.environment",method:"GET",path:"/v1/orgs/"+r("billing.environment","id",e.path.id)+"/billing/environments/"+r("billing.environment","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{200:"json"},signal:e.signal})},async steer(e){return t.send({op:"billing.steer",method:"PATCH",path:"/v1/orgs/"+r("billing.steer","id",e.path.id)+"/billing/environments/"+r("billing.steer","ref",e.path.ref),auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async topUp(e){return t.send({op:"billing.topUp",method:"POST",path:"/v1/orgs/"+r("billing.topUp","id",e.path.id)+"/billing/environments/"+r("billing.topUp","ref",e.path.ref)+"/topups",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async bankTransfer(e){return t.send({op:"billing.bankTransfer",method:"POST",path:"/v1/orgs/"+r("billing.bankTransfer","id",e.path.id)+"/billing/environments/"+r("billing.bankTransfer","ref",e.path.ref)+"/bank-transfers",auth:[["PalbaseBearer"]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})},async ledger(e){return t.send({op:"billing.ledger",method:"GET",path:"/v1/orgs/"+r("billing.ledger","id",e.path.id)+"/billing/environments/"+r("billing.ledger","ref",e.path.ref)+"/ledger",auth:[["PalbaseBearer"]],answers:{200:"json"},query:e.query,signal:e.signal})}},accessRequests:{async request(e){return t.send({op:"accessRequests.request",method:"POST",path:"/v1/access-requests",auth:[["PalbaseBearer"],[]],answers:{200:"json"},idempotent:!0,headers:e.headers,body:{kind:"json",contentType:"application/json",value:e.body},signal:e.signal})}},docs:{async search(e){return t.send({op:"docs.search",method:"GET",path:"/v1/docs/search",auth:[["PalbaseBearer"],[]],answers:{200:"json"},query:e.query,signal:e.signal})}}}}function L(t){let{mint:e,revoke:i}=t;return async s=>{let g=await e(s),p=s.body?.role,a=s.body?.on_behalf_of;if(p===void 0&&a===void 0)return g;let d=g.data,l=[];if(p!==void 0&&d.role!==p&&l.push(`role ${p} (it came back ${d.role==null?"at its minter's":d.role})`),a!==void 0&&d.on_behalf_of!==a.trim()&&l.push("on_behalf_of"),l.length===0)return g;let n;try{await i({path:{ref:s.path.ref,id:String(d.id)}})}catch(m){n=m}let u=`Studio minted the token without the ${l.join(" and ")} asked for \u2014 it is older than this SDK`;throw new b({op:"environmentTokens.mint",status:0,code:"token_role_not_kept",message:n===void 0?`environmentTokens.mint: ${u}; the token (${d.id}) was revoked at once and is not returned \u2014 mint it again once Studio is updated`:`environmentTokens.mint: ${u}, and revoking it failed (${n instanceof Error?n.message:String(n)}) \u2014 revoke token ${d.id} of environment ${s.path.ref} yourself, now`,cause:n})}}var y={pbo_:"an organization's",pbe_:"an environment's"},z=/^[A-Za-z0-9_-]*$/,K=64,h=44;function O(t){if(typeof t!="string"||t==="")return"token is missing: pass an access token, an organization's (pbo_\u2026) or an environment's (pbe_\u2026)";let e=t.slice(0,4);if(!Object.hasOwn(y,e))return`token has the wrong prefix: an access token starts with pbo_ (an organization's) or pbe_ (an environment's)${/^pb_[a-z0-9]+_[cs]/.test(t)?" \u2014 a project key belongs in palbase/server or palbase/web":""}`;let i=t.slice(4);if(i.length!==K)return`token has the wrong length: ${y[e]} access token is ${e} and ${K} characters, this one has ${i.length} after it`;if(!z.test(i))return`token is not ${y[e]} access token: after ${e} come base64url characters alone (A\u2013Z, a\u2013z, 0\u20139, - and _)`;let s=N(i),g=(s[h]<<24|s[h+1]<<16|s[h+2]<<8|s[h+3])>>>0;if($(e,s.subarray(0,h))!==g)return"token's checksum does not match: it was mistyped or cut, or made before access tokens carried one \u2014 make a new token"}function H(t){return O(t)===void 0}function W(t){let e=O(t);if(e!==void 0)throw new TypeError(e)}var J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function N(t){let e=new Uint8Array(t.length*6/8),i=0,s=0,g=0;for(let p of t)i=i<<6|J.indexOf(p),s+=6,s>=8&&(s-=8,e[g++]=i>>s&255);return e}var V=(()=>{let t=new Uint32Array(256);for(let e=0;e<256;e++){let i=e;for(let s=0;s<8;s++)i=i&1?3988292384^i>>>1:i>>>1;t[e]=i>>>0}return t})();function $(t,e){let i=4294967295;for(let s=0;s<t.length;s++)i=V[(i^t.charCodeAt(s))&255]^i>>>8;for(let s of e)i=V[(i^s)&255]^i>>>8;return(i^4294967295)>>>0}var q="palbase.studio",X="palbase";function Y(){let t=globalThis;return typeof t.window<"u"||typeof t.document<"u"||typeof t.importScripts=="function"||M()}var _=class{domain;#e;#t=new Map;constructor(e){if(Y())throw new TypeError("palbase/cloud runs on a server: its access token opens the organization's projects, so it never goes into a browser, a web worker or a mobile app \u2014 keep it on your server, and have your app call that");W(e?.token);let i=e.domain??q;if(typeof i!="string"||!/^[a-z0-9-]+(\.[a-z0-9-]+)+$/.test(i))throw new TypeError(`domain ${JSON.stringify(i)} is not a domain`);this.domain=i;let s=e.token;this.#e=p=>G(f({baseUrl:p,credentials:{token:s},fetch:e.fetch,solveProofOfWork:!1}),e.retry??U);let g=I(this.#e(`https://palbase.app.${i}`));g.environmentTokens.mint=L(g.environmentTokens),Object.assign(this,g)}project(e){if(typeof e!="string"||!/^[a-z0-9]{1,63}$/.test(e))throw new TypeError(`${JSON.stringify(e)} is not an environment's ref`);let i=this.#t.get(e);return i||(i=B(this.#e(e===X?`https://connect.${this.domain}`:`https://${e}.${this.domain}`)),this.#t.set(e,i)),i}};export{q as DEFAULT_DOMAIN,_ as PalbaseCloud,b as PalbaseError,H as tokenIsWellFormed};
package/dist/refuse/ai.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
2
  throw new Error("palbase/ai is for servers: it speaks with the project secret key, which never goes into a browser or a mobile app \u2014 call your backend, and let it ask the model");
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
2
  throw new Error("palbase/backend is a server framework: it runs on your backend, never in a browser or a mobile app \u2014 apps use palbase/web (or the native SDKs)");
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
2
  throw new Error("palbase/cloud is for servers: its access token opens the organization's projects, so it belongs on your server and never in a browser or a mobile app \u2014 have your app call your server");
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
2
  throw new Error("palbase/server is for servers: 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");
@@ -1,2 +1,2 @@
1
- /*! palbase 0.25.0 — Palbase SDK License (see LICENSE) */
2
- import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"../chunks/S4GD7FCI.js";import{a as c,b as d}from"../chunks/C7SBJV6T.js";import"../chunks/5BIBYYM4.js";import"../chunks/J3KELWNZ.js";import{o as b}from"../chunks/YAVAXQGR.js";import"../chunks/B773R25P.js";import{b as a}from"../chunks/NANJIH3L.js";import"../chunks/Q45P37LH.js";import"../chunks/OFLYZJK7.js";export{o as AuthUnavailable,b as EVENT_TYPES,c as FieldError,d as Fields,a as PalbaseError,t as ReservationSettled,n as TokenError,q as TokenVerifier,f as Transit,e as TransitRefusal,g as TransitRequest,i as WebhookSignatureError,h as createServer,s as isEntitled,y as loadSecrets,v as pages,x as platformOwn,w as processOwn,r as requestAddress,p as sessionStanding,l as signatureHeader,k as verifySignature,j as verifyWebhook,m as verifyWebhookRequest,u as withReservation};
1
+ /*! palbase 0.25.1 — Palbase SDK License (see LICENSE) */
2
+ import{a as e,b as f,c as g,d as h,e as i,f as j,g as k,h as l,i as m,j as n,k as o,l as p,m as q,n as r,o as s,p as t,q as u,r as v,s as w,t as x,u as y}from"../chunks/GP64QR4G.js";import{a as c,b as d}from"../chunks/3SLLOZC4.js";import"../chunks/4CLXBBRV.js";import"../chunks/IERZK64H.js";import{o as b}from"../chunks/LSJGREA3.js";import"../chunks/7HZ4EKJP.js";import{b as a}from"../chunks/YE7MYOBE.js";import"../chunks/FCJKKXVF.js";import"../chunks/BA4P3PMP.js";export{o as AuthUnavailable,b as EVENT_TYPES,c as FieldError,d as Fields,a as PalbaseError,t as ReservationSettled,n as TokenError,q as TokenVerifier,f as Transit,e as TransitRefusal,g as TransitRequest,i as WebhookSignatureError,h as createServer,s as isEntitled,y as loadSecrets,v as pages,x as platformOwn,w as processOwn,r as requestAddress,p as sessionStanding,l as signatureHeader,k as verifySignature,j as verifyWebhook,m as verifyWebhookRequest,u as withReservation};