1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,97955,e=>{"use strict";var t=e.i(43476),n=e.i(70703),a=e.i(22016),r=e.i(71645),i=e.i(52922),l=e.i(96177);let o=["heavenecohub.com","heaven-eco-hub.firebaseapp.com"];var s=e.i(7085),d=e.i(87646),c=e.i(89970),p=e.i(3310);e.i(47167);var u=e.i(77813);let h={heavenUsd:.01,decimals:6,source:"baseline-floor",sourceLabel:null,fallback:!0},m=h,y=!1,g=new Set;function x(e){return g.add(e),y||(y=!0,fetch(`${u.API_BASE}/v1/price`).then(e=>e.ok?e.json():null).then(e=>{if(!e||"number"!=typeof e.heavenUsd||!(e.heavenUsd>0))throw Error("unusable rate");m={heavenUsd:e.heavenUsd,decimals:"number"==typeof e.decimals?e.decimals:6,source:e.source??"set",sourceLabel:e.sourceLabel??null,fallback:!0===e.fallback},g.forEach(e=>e())}).catch(()=>{y=!1})),()=>{g.delete(e)}}let f=()=>m,b=()=>h;function v(){return(0,r.useSyncExternalStore)(x,f,b)}function w(e){if(!(e>0))return"â";let t=e>=1?2:e>=.01?4:6;return e.toFixed(t).replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"")}function j(e,t,n=6){if(!(t>0)||!(e>0))return 0;let a=10**n,r=Math.round(t*a);return r<=0?0:Math.ceil(Math.round(e*a)/r)}var S=e.i(32959);let k=[10,25,50,100];function C({onClose:e}){let{buyEnergyWithPayPal:n,pending:a}=(0,i.useAccount)(),{heavenUsd:l,decimals:o}=v(),[s,d]=(0,r.useState)("25"),[c,p]=(0,r.useState)(!1),[u,h]=(0,r.useState)(""),m=Number(s),y=Number.isFinite(m)&&m>=5&&m<=5e3,g=y?j(m,l,o):0;async function x(){if(h(""),!y)return void h(`Enter an amount between $5 and $${5e3.toLocaleString("en-US")}.`);let e=await n(Number(m.toFixed(2)));e?window.location.href=e:h("PayPal could not start that purchase. Nothing was charged.")}return(0,t.jsxs)("div",{style:{marginTop:"14px",padding:"clamp(1rem, 2.5vw, 1.35rem)",borderRadius:"4px",background:"rgba(255,255,255,0.55)",border:"1px solid rgba(255,255,255,0.85)",borderLeft:"3px solid #ffc439",display:"grid",gap:"12px"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.58rem",margin:0},children:"How much energy?"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--muted)",margin:"4px 0 0"},children:"Enter any amount in US dollars. It buys energy at todayâs rate and lands in your balance â no wallet needed."})]}),(0,t.jsx)("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:k.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{d(String(e)),h("")},style:{...S.chipButton,fontSize:"0.68rem",padding:"7px 14px",background:Number(s)===e?"rgba(255,196,57,0.28)":"rgba(255,255,255,0.5)",borderColor:Number(s)===e?"#f0b429":"rgba(65,75,87,0.2)"},children:["$",e]},e))}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"pp-amount",style:{...S.label,display:"block",marginBottom:"6px"},children:"Amount in USD"}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",flexWrap:"wrap"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",flex:"1 1 140px"},children:[(0,t.jsx)("span",{style:{...S.body,fontSize:"1.1rem",color:"var(--ink)"},children:"$"}),(0,t.jsx)("input",{id:"pp-amount",type:"number",inputMode:"decimal",min:5,max:5e3,step:"1",value:s,disabled:a,onChange:e=>{d(e.target.value),h("")},onFocus:()=>p(!0),onBlur:()=>p(!1),style:{...S.input,...c?S.inputFocus:null,opacity:a?.6:1}})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.9rem",color:"var(--ink)",margin:0,whiteSpace:"nowrap"},children:y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("strong",{children:(0,S.fmtHeaven)(g)})," energy"]}):(0,t.jsx)("span",{style:{color:"var(--muted)"},children:"â"})})]})]}),u&&(0,t.jsx)("p",{role:"alert",style:{...S.body,fontSize:"0.82rem",color:"#9B3B29",margin:0},children:u}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"center"},children:[(0,t.jsx)("button",{type:"button",disabled:a||!y,onClick:()=>void x(),style:{...S.chipButton,background:"#ffc439",borderColor:"#f0b429",color:"#003087",fontWeight:700,padding:"11px 22px",opacity:a||!y?.5:1},children:a?"Opening PayPalâ¦":y?`Pay $${m.toFixed(2)} with PayPal`:"Enter an amount"}),(0,t.jsx)("button",{type:"button",onClick:e,disabled:a,style:S.chipButton,children:"Cancel"})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.74rem",color:"var(--muted)",margin:0},children:"A one-off purchase, not a subscription â nothing recurring is set up. Nothing is taken until you approve it at PayPal."})]})}let z={position:"relative",display:"inline-flex"},A={position:"absolute",top:"-9px",right:"-6px",fontFamily:"var(--font-poppins), system-ui, sans-serif",fontSize:"0.58rem",fontWeight:600,letterSpacing:"0.04em",lineHeight:1,padding:"4px 8px",borderRadius:"999px",border:"1px solid",whiteSpace:"nowrap",pointerEvents:"none"};function E({account:e}){let{pending:n,opError:a}=(0,i.useAccount)(),[l,o]=(0,r.useState)(!1),s=(0,i.energyTotals)(e),d=function(e){let[t,n]=(0,r.useState)(e),a=(0,r.useRef)(e);return(0,r.useEffect)(()=>{let t={n:a.current};a.current=e;let r=c.gsap.to(t,{n:e,duration:.9,ease:"power2.out",onUpdate:()=>n(t.n)});return()=>{r.kill()}},[e]),t}(e.balance),u=e.walletLink?.status==="linked"||(0,p.connectionFor)(e,"heaven-wallet").connected,h=Math.max(0,e.reserved??0),m=s.allowance>0?Math.min(100,s.used/s.allowance*100):0;return(0,t.jsxs)("section",{className:"glass-premium","aria-labelledby":"ha-balance-title",style:{borderRadius:"4px",padding:"clamp(1.5rem, 4vw, 2.25rem)",display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(260px, 100%), 1fr))",gap:"clamp(1.5rem, 4vw, 2.5rem)",alignItems:"center"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{id:"ha-balance-title",style:S.eyebrow,children:"Total Heaven Energy balance"}),(0,t.jsxs)("p",{style:{fontFamily:"var(--font-cormorant)",fontWeight:300,fontSize:"clamp(3rem, 8vw, 4.4rem)",lineHeight:1,color:"var(--ink)",margin:"0.35rem 0 0",textShadow:"0 0 50px rgba(251,240,205,0.85)"},children:[(0,S.fmtHeaven)(Math.round(100*d)/100),(0,t.jsx)("span",{style:{fontSize:"0.32em",letterSpacing:"0.12em",color:"var(--gold-a11y)",marginLeft:"0.5rem"},children:"HEAVEN ENERGY"})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"18px",flexWrap:"wrap",margin:"0.9rem 0 1.1rem"},children:[(0,t.jsx)(W,{k:"Spent this cycle",v:`${(0,S.fmtHeaven)(s.used)} energy`}),h>0&&(0,t.jsx)(W,{k:"Held by jobs running",v:`${(0,S.fmtHeaven)(h)} energy`})]}),h>0&&(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.78rem",color:"var(--muted)",margin:"0 0 1rem"},children:[(0,S.fmtHeaven)(h)," energy is held by work in progress. If a job fails it comes straight back to you."]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"center",paddingTop:"9px"},children:[(0,t.jsxs)("span",{style:z,children:[(0,t.jsx)("button",{type:"button",className:"btn-primary",disabled:!u||n,onClick:()=>document.getElementById("ha-wallet")?.scrollIntoView({behavior:"smooth",block:"start"}),style:{padding:"11px 24px",fontSize:"0.72rem",opacity:u&&!n?1:.45},children:n?"Workingâ¦":"Buy energy with $HEAVEN using Heaven Wallet"}),(0,t.jsx)("span",{style:{...A,background:"#E4F2EB",borderColor:"#B9DBCC",color:"#2F7D5F"},children:"0% transaction charges"})]}),(0,t.jsxs)("span",{style:z,children:[(0,t.jsx)("button",{type:"button",disabled:n,onClick:()=>o(e=>!e),style:{...S.chipButton,background:"#ffc439",borderColor:"#f0b429",color:"#003087",fontWeight:700,padding:"11px 22px",opacity:n?.5:1}
1,children:l?"Close":"Buy energy with PayPal"}),(0,t.jsx)("span",{style:{...A,background:"#F7EEDC",borderColor:"#E4CFA4",color:"#8A6220"},children:"6% transaction charges"})]}),a&&(0,t.jsx)("span",{role:"alert",style:{...S.body,fontSize:"0.76rem",color:"#9B3B29"},children:a}),!u&&!l&&(0,t.jsx)("span",{style:{...S.body,fontSize:"0.76rem",color:"var(--muted)"},children:"Connect Heaven Wallet further down, or pay with a card instead."})]}),l&&(0,t.jsx)(C,{onClose:()=>o(!1)})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:"12px",flexWrap:"wrap"},children:[(0,t.jsx)("p",{style:S.eyebrow,children:"Per-app allowances this cycle"}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)"},children:s.allowance>0?`${(0,S.fmtHeaven)(s.used)} of ${(0,S.fmtHeaven)(s.allowance)} used`:"No per-app plan active"})]}),(0,t.jsx)("div",{role:"meter","aria-valuenow":Math.round(m),"aria-valuemin":0,"aria-valuemax":100,"aria-label":"Combined subscription energy used this cycle",style:{height:"12px",borderRadius:"2px",background:"rgba(65,75,87,0.1)",overflow:"hidden",margin:"12px 0",border:"1px solid rgba(255,255,255,0.7)"},children:(0,t.jsx)("div",{style:{width:`${m}%`,height:"100%",background:`linear-gradient(90deg, ${(0,S.meterColor)(m,"var(--gold)")} 0%, var(--gold-light) 100%)`,boxShadow:"0 0 14px rgba(211,171,84,0.55)",transition:"width 0.7s cubic-bezier(0.4,0,0.2,1)"}})}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.88rem",color:"var(--muted)",margin:0},children:[(0,t.jsxs)("strong",{style:{color:"var(--ink)",fontWeight:600},children:[(0,S.fmtHeaven)(s.remaining)," energy"]})," ","remaining of what is included across your active per-app plans â Luna CEO, Heaven Health and Coda Play. A monthly package is separate: it tops up the balance above, which every app can draw on. Anything beyond an allowance comes from that balance, never silently."]})]})]})}function W({k:e,v:n}){return(0,t.jsxs)("span",{style:{display:"grid",gap:"2px"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.58rem"},children:e}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.9rem",color:"var(--ink)",fontWeight:600},children:n})]})}var H=e.i(57688);function B({app:e,account:n,connection:a,flag:l}){let{connectApp:o,disconnectApp:s}=(0,i.useAccount)(),[d,c]=(0,r.useState)(null),[u,h]=(0,r.useState)(!1),[m,y]=(0,r.useState)(!1),g=e.planId?p.PLAN_BY_ID[e.planId]:null,x=g&&n.subscriptions?.some(t=>t.planId===e.planId&&t.active)?g:null,f="luna-heaven"===e.linkedVia,b=(0,p.lunaLinkState)(n),v=(0,p.isAppConnected)(n,e),w=(0,p.meterFor)(n,e);async function j(){if(d)try{await navigator.clipboard.writeText(d),h(!0),window.setTimeout(()=>h(!1),2e3)}catch{}}return(0,t.jsxs)("div",{className:"glass",style:{position:"relative",borderRadius:"4px",padding:"clamp(1.25rem, 3vw, 1.6rem)",display:"flex",flexDirection:"column",gap:"1rem",borderTop:`2px solid ${v?e.accent:"rgba(255,255,255,0.9)"}`,transition:"border-color 0.4s ease"},children:[l&&(0,t.jsx)("span",{style:{position:"absolute",top:"-10px",right:"12px",fontFamily:"var(--font-poppins), system-ui, sans-serif",fontSize:"0.58rem",fontWeight:600,letterSpacing:"0.09em",textTransform:"uppercase",lineHeight:1,padding:"5px 10px",borderRadius:"999px",background:"var(--gold)",color:"#2A2110",boxShadow:"0 4px 14px rgba(211,171,84,0.45)",pointerEvents:"none"},children:l}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"14px",flexWrap:"wrap"},children:[(0,t.jsx)("div",{style:{width:"52px",height:"52px",borderRadius:"3px",flexShrink:0,display:"grid",placeItems:"center",overflow:"hidden",background:"rgba(255,255,255,0.7)",border:`1px solid ${e.accent}44`,boxShadow:`0 4px 16px ${e.accent}22`},children:(0,t.jsx)(H.default,{src:e.logo,alt:"",width:52,height:52,style:{objectFit:"contain",width:"100%",height:"100%"}})}),(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("h3",{style:{fontFamily:"var(--font-cormorant)",fontWeight:400,fontSize:"1.35rem",color:"var(--ink)",lineHeight:1.15,margin:0},children:e.name}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)",margin:"3px 0 0"},children:e.tagline})]}),(0,t.jsxs)("span",{style:{...S.label,fontSize:"0.58rem",flexShrink:0,display:"inline-flex",alignItems:"center",gap:"6px",padding:"5px 10px",borderRadius:"2px",background:v?`${e.accent}1A`:"rgba(65,75,87,0.07)",color:v?e.accent:"var(--muted)",border:`1px solid ${v?`${e.accent}44`:"rgba(65,75,87,0.12)"}`},children:[(0,t.jsx)("span",{"aria-hidden":"true",style:{width:"5px",height:"5
1px",borderRadius:"50%",background:v?e.accent:"var(--muted)",boxShadow:v?`0 0 8px ${e.accent}`:"none"}}),f&&"confirming"===b?"Confirming":v?"Connected":"Not connected"]})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.86rem",color:"var(--muted)",margin:0},children:e.description}),(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 14px",alignItems:"baseline",padding:"10px 12px",borderRadius:"3px",background:"rgba(255,255,255,0.45)",border:"1px solid rgba(255,255,255,0.7)"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.58rem"},children:"Meters"}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.8rem",color:"var(--ink)"},children:e.meters}),x&&(0,t.jsxs)("span",{style:{...S.body,fontSize:"0.78rem",color:"var(--muted)",width:"100%"},children:["Charges draw from ",(0,t.jsx)("strong",{style:{color:e.accent,fontWeight:600},children:x.name}),", then from your $HEAVEN balance."]})]}),v&&(0,t.jsxs)("div",{style:{display:"grid",gap:"8px"},children:[w.reported?(0,t.jsxs)("div",{style:{display:"grid",gap:"6px"},children:[(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 20px"},children:[(0,t.jsx)($,{k:"Energy reported",v:`${(0,S.fmtHeaven)(w.energy)} $HEAVEN`}),w.lastAt&&(0,t.jsx)($,{k:"Last sync",v:(0,S.fmtDateTime)(w.lastAt)})]}),w.byArea.length>1&&(0,t.jsx)("div",{style:{display:"grid",gap:"2px",paddingLeft:"1px"},children:w.byArea.map(e=>(0,t.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"baseline"},children:[(0,t.jsx)("span",{style:{...S.body,fontSize:"0.74rem",color:"var(--muted)",minWidth:"7.5rem",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:e.area}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.74rem",color:"var(--ink)",fontVariantNumeric:"tabular-nums"},children:(0,S.fmtHeaven)(e.energy)})]},e.area))})]}):(0,t.jsx)("p",{style:{...S.body,fontSize:"0.74rem",color:"var(--muted)",margin:0},children:"No energy reported yet â nothing has been metered against this account from here."}),f?(0,t.jsx)("p",{style:{...S.body,fontSize:"0.74rem",color:"var(--muted)",margin:0},children:"No key to copy or keep â this runs on the link you already made."}):d?(0,t.jsxs)("div",{style:{padding:"10px 12px",borderRadius:"3px",background:"rgba(211,171,84,0.1)",border:"1px solid rgba(211,171,84,0.35)"},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.58rem",color:"var(--gold-a11y)",margin:"0 0 6px"},children:"Your API key â copy it now, it is shown once"}),(0,t.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"center",flexWrap:"wrap"},children:[(0,t.jsx)("code",{style:{flex:1,minWidth:"min(200px, 100%)",fontSize:"0.72rem",wordBreak:"break-all",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--ink)"},children:d}),(0,t.jsx)("button",{type:"button",onClick:j,style:{...S.chipButton,borderColor:"rgba(211,171,84,0.5)"},children:u?"Copied":"Copy"})]})]}):a.apiKeyFingerprint&&(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.74rem",color:"var(--muted)",margin:0},children:["Key"," ",(0,t.jsx)("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--ink)"},children:a.apiKeyFingerprint})," ","is live. The secret is never stored â reconnect to issue a new one."]})]}),(0,t.jsx)("div",{style:{marginTop:"auto",display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"center"},children:f?(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.6rem",color:"var(--muted)",display:"block"},children:"linked"===b?"Managed in Luna Heaven":"confirming"===b?"Waiting for Luna to confirm":"Connect Luna Heaven first"}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.8rem",color:"var(--muted)"},children:"linked"===b?"Ending it is one action, on the Luna panel at the top of this page.":"confirming"===b?"You approved Luna from this account, so nothing more is needed from you. This opens as soon as Luna confirms the link.":"This opens inside the Luna Heaven app. Connect Luna at the top of this page and it comes with it â there is nothing separate to set up here."})]}):e.connectable||a.connected?a.connected?m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{style:{...S.body,fontSize:"0.8rem",color:"var(--muted)"},children:"Revoke access and stop metering?"}),(0,t.jsx)("button",{type:"button",onClick:function(){s(e.id),c(null),y(!1)},style:{...S.chipButton,borderColor:"rgba(194,84,63,0.4)",color:"#9B3B29"},children:"Yes, disconnect"}),(0,t.jsx)("button",{type:"button",onClick:()=>y(!1),style:S.chipButton,children:"Keep connected"})]}):(0,t.jsx)("button",{type:"button",onClick:()=>y(!0),style:S.chipButton,children:"Disconnect"}):(0,t.jsxs)("button",{type:"button",onClick:function(){c(o(e.id)),y(!1)},className:"btn-primary",style:{padding:"11px 26px",fontSize:"0.74rem"},children:["Connect ",e.name]}):(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.6rem",color:"var(--muted)",display:"block"},children:"Not ready to connect"}),(0,t.jsxs)("span",{style:{...S.body,fontSize:"0.8rem",color:"var(--muted)"},children:[e.name," is not wired to your account yet. Nothing to do â it will appear here when it is."]})]})}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.7rem",color:"var(--muted)",margin:0},children:[f?"Granted by your Luna Heaven connection: ":"Grants: ",e.scopes.join(" · ")]})]})}function $({k:e,v:n}){return(0,t.jsxs)("span",{style:{display:"flex",gap:"7px",alignItems:"baseline"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.58rem"},children:e}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.82rem",color:"var(--ink)",fontWeight:600},children:n})]})}function I({apps:e,account:n,featuredId:a,journeyName:r}){let i=e.map(e=>(0,t.jsx)(B,{app:e,account:n,connection:(0,p.connectionFor)(n,e.id),flag:e.id===a?"Most popular":void 0},e.id));return(0,t.jsx)(T,{count:e.length,label:r,children:i})}function T({children:e,count:n,label:a}){let i=(0,r.useRef)(null),[l,o]=(0,r.useState)(!0),[s,d]=(0,r.useState)(!1),[c,p]=(0,r.useState)(0),[u,h]=(0,r.useState)(!1),m=(0,r.useCallback)(()=>{let e=i.current;if(!e)return;let t=e.scrollWidth-e.clientWidth;h(t>4),o(e.scrollLeft<=4),d(e.scrollLeft>=t-4);let a=e.scrollWidth/n;p(a>0?Math.min(n-1,Math.round(e.scrollLeft/a)):0)},[n]);(0,r.useEffect)(()=>{let e=i.current;if(!e)return;m(),e.addEventListener("scroll",m,{passive:!0});let t=new ResizeObserver(m);return t.observe(e),()=>{e.removeEventListener("scroll",m),t.disconnect()}},[m]);let y=e=>{let t=i.current;if(!t)return;let n=t.firstElementChild,a=parseFloat(getComputedStyle(t).columnGap||"0")||0,r=n?n.offsetWidth+a:.8*t.clientWidth,l=!window.matchMedia("(prefers-reduced-motion: reduce)").matches;t.scrollBy({left:e*r,behavior:l?"smooth":"auto"})};return(0,t.jsxs)("div",{children:[u&&(0,t.jsxs)("div",{style:P,children:[(0,t.jsxs)("p",{style:{...S.eyebrow,color:"var(--muted)",margin:0},"aria-hidden":"true",children:[c+1," / ",n]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,t.jsx)(N,{dir:"prev",disabled:l,onClick:()=>y(-1),label:`Previous app in ${a}`}),(0,t.jsx)(N,{dir:"next",disabled:s,onClick:()=>y(1),label:`Next app in ${a}`})]})]}),(0,t.jsx)("div",{ref:i,className:"ha-carousel",tabIndex:u?0:-1,role:"group","aria-label":u?`${a} â ${n} apps, scroll for more`:`${a} â ${n} apps`,children:e})]})}function N({dir:e,disabled:n,onClick:a,label:r}){return(0,t.jsx)("button",{type:"button","aria-disabled":n,onClick:()=>{n||a()},"aria-label":r,style:{...F,opacity:n?.3:1},children:(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14","aria-hidden":"true",fill:"none",children:(0,t.jsx)("path",{d:"prev"===e?"M9 2 4 7l5 5":"M5 2l5 5-5 5",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})}let P={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px",marginBottom:"0.7rem"},F={width:"34px",height:"34px",display:"grid",placeItems:"center",borderRadius:"999px",border:"1px solid rgba(211,171,84,0.45)",background:"rgba(255,255,255,0.72)",color:"var(--ink)",cursor:"none",transition:"opacity 200ms ease, background 200ms ease"},R=["payments.request","payments.auto"],D="firebase"===l.backendKind?"server"
1:"demo";function L(e,t,n=4){let a=e.replace(/^0+(?=\d)/,"").padStart(t+1,"0"),r=a.slice(0,a.length-t),i=t>0?a.slice(a.length-t):"";if(!/[1-9]/.test(i))return r;let l=i.slice(0,n).replace(/0+$/,"");return l?`${r}.${l}`:`<0.${"0".repeat(Math.max(0,n-1))}1`}let M={status:"unlinked"},V={enabled:!1,minimumBalance:0,rebuyAmount:0,dailyCap:0,spentToday:0,windowStart:null,lastTriggerAt:null,lastError:null,inFlightPaymentId:null},Y=new Map,U=new Map;function O(e=16){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}let _={startPairing(e){let t,n=O(),a=O(32),r=new Date(Date.now()+3e5).toISOString();return Y.set(n,{pairingId:n,challenge:a,expiresAt:r,status:"pending"}),{pairingId:n,...(t=new URLSearchParams({v:"1",id:n,c:a,scope:R.join(" "),hub:"Heaven Eco Hub",acct:e,exp:r}).toString(),{uri:`https://heaven-wallet.com/link#${t}`,deepLink:`heavenwallet://link?${t}`}),expiresAt:r,grants:R,pollIntervalMs:1200}},pairingStatus(e){let t=Y.get(e);return t?{status:"pending"===t.status&&Date.parse(t.expiresAt)<Date.now()?"expired":t.status,reason:null,wallet:null,account:null}:{status:"expired",reason:null,wallet:null,account:null}},approvePairing(e){let t=Y.get(e);return t&&(t.status="linked"),{status:"linked",address:"0x0379d03F1B6E7880EA169708d2C17B746b260c86",chainId:56,label:"Demo device",walletName:"Heaven Wallet (demo)",linkedAt:new Date().toISOString(),grants:[...R],canAutoCharge:!0,mandate:{maxPerCharge:5e3,maxPerDay:2e4,expiresAt:null},autoRebuy:{...V},lastPaymentAt:null}},buy(e){let t=O(),n=new Date(Date.now()+9e5).toISOString();return U.set(t,{paymentId:t,energy:e,status:"awaiting_approval",expiresAt:n}),{paymentId:t,status:"awaiting_approval",energy:e,heaven:e,expiresAt:n,pushed:!0,pollIntervalMs:1200}},settle(e){let t=U.get(e);return t&&(t.status="settled"),t},paymentStatus(e){let t=U.get(e),n=t?"awaiting_approval"===t.status&&Date.parse(t.expiresAt)<Date.now()?"expired":t.status:"expired";return{status:n,energy:t?.energy??0,heaven:t?.energy??0,txHash:"settled"===n?`0xdemo${O(28)}`:null,failureReason:null,failureData:null,account:null}}},q=[250,1e3,5e3];function G(e,t,n){let a=new Date().toISOString();return{...e,balance:Math.round((e.balance+t)*100)/100,ledger:[{id:`wal-${a}-${t}`,appId:"heaven-wallet",label:n?"Automatic rebuy from Heaven Wallet":"Energy purchase from Heaven Wallet",amount:-t,fromAllowance:0,fromBalance:-t,at:a},...e.ledger].slice(0,200)}}function K({link:e}){let{account:n,applyAccount:a,patchAccount:l}=(0,i.useAccount)(),[o,s]=(0,r.useState)("1000"),[d,c]=(0,r.useState)(null),[p,h]=(0,r.useState)("idle"),[m,y]=(0,r.useState)(""),[g,x]=(0,r.useState)(null),[f,b]=(0,r.useState)(null),[v,w]=(0,r.useState)(null),j=(0,r.useRef)(null),k=Number.parseInt(o,10),C=Number.isInteger(k)&&k>=10&&k<=99e3,z="starting"===p||"awaiting_approval"===p||"broadcast"===p||"stalled"===p,A=(0,r.useCallback)((e,t,n,r=null,i=null)=>{h(e),b(r),w(i),"settled"===e&&(x(t),n?a(n):"demo"===D&&l(e=>G(e,t,!1)))},[a,l]);async function E(){if(C&&!z){h("starting"),y(""),x(null),b(null),w(null);try{let e,t=await ("server"===D?(e=k,(0,u.sessionCall)("/v1/wallet/purchase",{energy:e})):Promise.resolve(_.buy(k)));c(t),h("awaiting_approval")}catch(e){y(e instanceof Error?e.message:"Heaven Wallet could not be reached."),h("idle")}}}(0,r.useEffect)(()=>{if(!d||"awaiting_approval"!==p&&"broadcast"!==p&&"stalled"!==p)return;let e=!1,t=0,n=async()=>{try{var a;let t,n=await (a=d.paymentId,"server"===D?(t=a,(0,u.sessionCall)("/v1/wallet/purchase/status",{paymentId:t})):Promise.resolve(_.paymentStatus(a)));if(e)return;let r=n.status;if("settled"===r||"declined"===r||"failed"===r||"expired"===r)return void A(r,n.energy,n.account,n.failureReason,n.failureData);("broadcast"===r||"stalled"===r)&&h(r)}catch{}e||(t=window.setTimeout(n,d.pollIntervalMs))};return t=window.setTimeout(n,d.pollIntervalMs),()=>{e=!0,window.clearTimeout(t)}},[d,p,A]);let W=(e.grants??[]).includes("payments.request");return(0,t.jsxs)("div",{style:J,children:[(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:"12px",flexWrap:"wrap",alignItems:"baseline"},children:[(0,t.jsx)("p",{style:S.eyebrow,children:"Buy energy"}),(0,t.jsxs)("span",{style:{...S.body,fontSize:"0.78rem",color:"var(--muted)"},children:["1 $HEAVEN = 1 energy · balance ",(0,S.fmtHeaven)(n?.balance??0)]})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--muted)",margin:"6px 0 12px",maxWidth:"54ch"},children:"The amount is requested from your wallet and settles in $HEAVEN. You approve and sign it on your device â nothing is taken until you do."}),(0,t.jsx)("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",marginBottom:"12px"},children:q.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>{s(String(e)),j.current?.focus()},style:{...S.chipButton,borderColor:k===e?"var(--gold)":"rgba(65,75,87,0.2)",color:k===e?"var(--gold-a11y)":"var(--white)"},children:(0,S.fmtHeaven)(e)},e))}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"flex-start"},children:[(0,t.jsxs)("label",{style:{flex:"1 1 180px",minWidth:"min(150px, 100%)"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.58rem",display:"block",marginBottom:"5px"},children:"Energy to buy"}),(0,t.jsx)("input",{ref:j,type:"number",inputMode:"numeric",min:10,max:99e3,step:1,value:o,disabled:z,onChange:e=>s(e.target.value),style:{...S.input,opacity:z?.6:1}})]}),(0,t.jsx)("button",{type:"button",className:"btn-primary",disabled:!C||z||!W,onClick:()=>void E(),style:{padding:"12px 26px",fontSize:"0.72rem",marginTop:"22px",opacity:C&&!z&&W?1:.45},children:z?"Waiting for your walletâ¦":`Pay ${C?(0,S.fmtHeaven)(k):"â"} $HEAVEN`})]}),C&&!z&&(0,t.jsxs)("p",{style:X("var(--muted)"),children:[(0,S.fmtHeaven)(k)," energy costs"," ",(0,t.jsxs)("strong",{style:{color:"var(--ink)"},children:[(0,S.fmtHeaven)(k)," $HEAVEN"]})," ","â one for one, with nothing added. You will also need a little BNB in your wallet for the network fee, which is neither our charge nor Heaven Walletâs. No $HEAVEN yet?"," ",(0,t.jsx)("a",{href:"https://www.heaventoken.com/terminal",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--gold-a11y)",cursor:"none",textDecoration:"underline",textUnderlineOffset:"3px"},children:"Buy it on the terminal"}),"."]}),!C&&""!==o.trim()&&(0,t.jsxs)("p",{style:X("var(--muted)"),children:["Enter a whole number between ",10," and ",(0,S.fmtHeaven)(99e3),"."]}),!W&&(0,t.jsx)("p",{style:X("#9B3B29"),children:"This link cannot request payments. Reconnect the wallet and approve the payment permission."}),"awaiting_approval"===p&&d&&(0,t.jsxs)("div",{style:{...Q("rgba(211,171,84,0.1)","rgba(211,171,84,0.4)"),marginTop:"12px"},children:[(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--ink)",margin:0},children:["Approve ",(0,t.jsxs)("strong",{children:[(0,S.fmtHeaven)(d.heaven)," $HEAVEN"]})," in Heaven Wallet.",!d.pushed&&" Your wallet will pick this up on its next sync."]}),"demo"===D&&(0,t.jsx)("button",{type:"button",style:{...S.chipButton,marginTop:"9px"},onClick:()=>{_.settle(d.paymentId),A("settled",d.energy,null)},children:"Simulate approval in the wallet"})]}),("broadcast"===p||"stalled"===p)&&(0,t.jsx)("div",{style:{...Q("rgba(211,171,84,0.1)","rgba(211,171,84,0.4)"),marginTop:"12px"},children:(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--ink)",margin:0},children:"stalled"===p?"Your transfer is taking longer than usual to confirm on the network. Nothing more to do â your energy is credited automatically the moment it settles.":"Transfer sent â confirming on the network. This is usually a few seconds; your energy is credited automatically once it settles."})}),"settled"===p&&null!==g&&(0,t.jsxs)("p",{style:X("#3F6B53"),children:[(0,S.fmtHeaven)(g)," energy added. Your balance is now"," ",(0,S.fmtHeaven)(n?.balance??0),"."]}),("declined"===p||"failed"===p||"expired"===p)&&(0,t.jsx)("p",{style:X("#9B3B29"),role:"alert",children:function(e,t,n){if("insufficient_gas"===t){if(n){let e=L(n.requiredBase,n.decimals),t=L(n.availableBase,n.decimals);return`Your wallet needs ${e} ${n.symbol} to pay the network fee and has ${t}. Your $HEAVEN is untouched â top up ${n.symbol} on BNB Smart Chain and try again.`}return"Your wallet needs a little BNB to pay the network fee. Your $HEAVEN is untouched â add BNB on BNB Smart Chain and try again."}return"declined"===e?"Declined in the wallet â nothing was charged.":"expired"===e?"The request expired before it was approved. Nothing was charged.":t?`The payment did not go through (${t}). Nothing was charged.`:"The payment did not go through. Nothing was charged."}(p,f,v)}
1),m&&(0,t.jsx)("p",{style:X("#9B3B29"),role:"alert",children:m})]})}let J={padding:"clamp(0.9rem, 2.5vw, 1.15rem)",borderRadius:"3px",background:"rgba(255,255,255,0.45)",border:"1px solid rgba(255,255,255,0.7)"},X=e=>({...S.body,fontSize:"0.8rem",color:e,margin:"10px 0 0"}),Q=(e,t)=>({padding:"11px 13px",borderRadius:"3px",background:e,border:`1px solid ${t}`});function Z({link:e}){var n,a,l;let{applyAccount:o,patchAccount:s}=(0,i.useAccount)(),d=e.autoRebuy,[c,p]=(0,r.useState)(String(d.minimumBalance||250)),[h,m]=(0,r.useState)(String(d.rebuyAmount||1e3)),[y,g]=(0,r.useState)(String(d.dailyCap||5e3)),[x,f]=(0,r.useState)(!1),[b,v]=(0,r.useState)(""),[w,j]=(0,r.useState)(""),k=Number.parseInt(c,10),C=Number.parseInt(h,10),z=Number.parseInt(y,10),A=[n=k,a=C,l=z].every(Number.isInteger)?n<0||n>99e3?`The floor must be between 0 and ${(0,S.fmtHeaven)(99e3)}.`:a<10?"A rebuy is at least 10 $HEAVEN.":a>99e3?`A rebuy is at most ${(0,S.fmtHeaven)(99e3)} $HEAVEN.`:l<a?"The daily ceiling has to cover at least one rebuy.":null:"All three need to be whole numbers of $HEAVEN.",E=e.mandate,W=E?Math.min(C,E.maxPerCharge):C,H=E?Math.min(z,E.maxPerDay):z;async function B(e){if(e&&A)return;f(!0),v(""),j("");let t={enabled:e,minimumBalance:k,rebuyAmount:C,dailyCap:z};try{if("server"===D){let e,n=await (e=t,(0,u.sessionCall)("/v1/wallet/autorebuy",e));o(n.account)}else s(e=>ee(e,{...d,...t,rebuyAmount:W,dailyCap:H,lastError:null,windowStart:d.windowStart??new Date().toISOString()}));j(e?"Automatic rebuy is on.":"Automatic rebuy is off.")}catch(e){v(e instanceof Error?e.message:"That did not go through.")}finally{f(!1)}}if(function(e,t){let{account:n,patchAccount:a}=(0,i.useAccount)(),l=(0,r.useRef)(!1);(0,r.useEffect)(()=>{if("demo"!==D||!n||"linked"!==e.status||!t.enabled||l.current||n.balance>=t.minimumBalance)return;let r=Math.max(0,t.dailyCap-t.spentToday),i=Math.min(t.rebuyAmount,r);if(i<10)return;l.current=!0;let o=window.setTimeout(()=>{a(e=>ee(G(e,i,!0),{...t,spentToday:t.spentToday+i,lastTriggerAt:new Date().toISOString(),windowStart:t.windowStart??new Date().toISOString()})),l.current=!1},900);return()=>{window.clearTimeout(o),l.current=!1}},[n,e.status,t,a])}(e,d),"server"===D)return(0,t.jsxs)("div",{style:en,children:[(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:"12px",flexWrap:"wrap",alignItems:"baseline"},children:[(0,t.jsx)("p",{style:S.eyebrow,children:"Automatic rebuy"}),(0,t.jsx)("span",{style:{...S.label,fontSize:"0.56rem"},children:"Not yet"})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--muted)",margin:"7px 0 0",maxWidth:"56ch"},children:"Heaven Wallet cannot issue $HEAVEN payment mandates yet, so there is nothing for a standing rule to charge. Every purchase needs your approval for now. The moment the wallet supports it, you will be able to set a floor and a rebuy amount here â and the ceiling will be yours to choose, in the wallet, revocable there at any moment."})]});if(!e.canAutoCharge)return(0,t.jsxs)("div",{style:en,children:[(0,t.jsx)("p",{style:S.eyebrow,children:"Automatic rebuy"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--muted)",margin:"7px 0 0",maxWidth:"54ch"},children:"This link has no payment mandate, so nothing can be charged without you approving it each time. Reconnect Heaven Wallet and approve automatic payments to set a rule here â you choose the ceiling in the wallet, and it is revocable there at any moment."})]});let $=Math.max(0,d.dailyCap-d.spentToday);return(0,t.jsxs)("div",{style:en,children:[(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:"12px",flexWrap:"wrap",alignItems:"baseline"},children:[(0,t.jsx)("p",{style:S.eyebrow,children:"Automatic rebuy"}),(0,t.jsx)("span",{style:{...S.label,fontSize:"0.56rem",color:d.enabled?"#3F6B53":"var(--muted)"},children:d.enabled?"Armed":"Off"})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--muted)",margin:"6px 0 12px",maxWidth:"56ch"},children:"Never run out mid-job. When your balance falls below the floor, Heaven Wallet is charged for the rebuy amount automatically â no prompt, no card, and never past the daily ceiling."}),(0,t.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(130px, 100%), 1fr))",gap:"10px"},children:[(0,t.jsx)(et,{k:"Buy when I fall below",v:c,onChange:p,disabled:x,hint:"$HEAVEN"}),(0,t.jsx)(et,{k:"Buy this much",v:h,onChange:m,disabled:x,hint:E&&C>E.maxPerCharge?`capped at ${(0,S.fmtHeaven)(E.maxPerCharge)}`:"$HEAVEN"}),(0,t.jsx)(et,{k:"Never more per day",v:y,onChange:g,disabled:x,hint:E&&z>E.maxPerDay?`capped at ${(0,S.fmtHeaven)(E.maxPerDay)}`:"$HEAVEN"})]}),!A&&(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--ink)",margin:"12px 0 0"},children:["Below ",(0,t.jsx)("strong",{children:(0,S.fmtHeaven)(k)}),", buy"," ",(0,t.jsxs)("strong",{children:[(0,S.fmtHeaven)(W)," $HEAVEN"]})," â up to"," ",(0,t.jsx)("strong",{children:(0,S.fmtHeaven)(H)})," in any 24 hours."]}),A&&(0,t.jsx)("p",{style:ea("var(--muted)"),children:A}),(0,t.jsxs)("div",{style:{display:"flex",gap:"9px",flexWrap:"wrap",alignItems:"center",marginTop:"14px"},children:[(0,t.jsx)("button",{type:"button",className:"btn-primary",disabled:x||!!A,onClick:()=>void B(!0),style:{padding:"11px 24px",fontSize:"0.72rem",opacity:x||A?.45:1},children:d.enabled?"Update rule":"Turn on automatic rebuy"}),d.enabled&&(0,t.jsx)("button",{type:"button",style:S.chipButton,disabled:x,onClick:()=>void B(!1),children:"Turn off"})]}),d.enabled&&(0,t.jsxs)("p",{style:ea("var(--muted)"),children:[(0,S.fmtHeaven)(d.spentToday)," of ",(0,S.fmtHeaven)(d.dailyCap)," used in this 24-hour window · ",(0,S.fmtHeaven)($)," left",d.lastTriggerAt&&` \xb7 last rebuy ${new Date(d.lastTriggerAt).toLocaleStr
1ing("en-GB",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}`]}),d.inFlightPaymentId&&(0,t.jsx)("p",{style:ea("var(--gold-a11y)"),children:"A rebuy is with your wallet now."}),d.lastError&&(0,t.jsx)("p",{style:ea("#9B3B29"),role:"alert",children:d.lastError}),b&&(0,t.jsx)("p",{style:ea("#9B3B29"),role:"alert",children:b}),w&&!b&&(0,t.jsx)("p",{style:ea("#3F6B53"),children:w})]})}function ee(e,t){return{...e,walletLink:{...e.walletLink??{status:"linked"},autoRebuy:t}}}function et({k:e,v:n,onChange:a,disabled:r,hint:i}){return(0,t.jsxs)("label",{style:{display:"block"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.56rem",display:"block",marginBottom:"5px"},children:e}),(0,t.jsx)("input",{type:"number",inputMode:"numeric",min:0,step:1,value:n,disabled:r,onChange:e=>a(e.target.value),style:{...S.input,opacity:r?.6:1}}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.68rem",color:"var(--muted)"},children:i})]})}let en={padding:"clamp(0.9rem, 2.5vw, 1.15rem)",borderRadius:"3px",background:"rgba(255,255,255,0.45)",border:"1px solid rgba(255,255,255,0.7)"},ea=e=>({...S.body,fontSize:"0.8rem",color:e,margin:"10px 0 0"}),er=[26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085],ei=[[10,1,0],[16,1,0],[26,1,0],[18,2,0],[24,2,0],[16,4,0],[18,4,0],[22,2,2],[22,3,2],[26,4,1],[30,1,4],[22,6,2],[22,8,1],[24,4,5],[24,5,5],[28,7,3],[28,10,1],[26,9,4],[26,3,11],[26,3,13]],el=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90]],eo=new Uint8Array(512),es=new Uint8Array(256),ed=1;for(let e=0;e<255;e++)eo[e]=ed,es[ed]=e,256&(ed<<=1)&&(ed^=285);for(let e=255;e<512;e++)eo[e]=eo[e-255];function ec(e,t){return 0===e||0===t?0:eo[es[e]+es[t]]}class ep{bits=[];put(e,t){for(let n=t-1;n>=0;n--)this.bits.push(e>>>n&1)}}function eu(e){let[t,n,a]=ei[e-1];return er[e-1]-t*(n+a)}function eh(e,t,n){for(let a=-1;a<=7;a++)for(let r=-1;r<=7;r++){let i=t+a,l=n+r;if(i<0||i>=e.length||l<0||l>=e.length)continue;let o=(0===a||6===a)&&r>=0&&r<=6,s=(0===r||6===r)&&a>=0&&a<=6,d=a>=2&&a<=4&&r>=2&&r<=4;e[i][l]=o||s||d?1:0}}let em=[(e,t)=>(e+t)%2==0,e=>e%2==0,(e,t)=>t%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(e/2)+Math.floor(t/3))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>((e+t)%2+e*t%3)%2==0],ey=e=>Math.max(0,Math.round((Date.parse(e)-Date.now())/1e3));function eg({handle:e,onClose:n,onRefresh:a,onLinked:l}){var o;let s,{applyAccount:d}=(0,i.useAccount)(),[c,p]=(0,r.useState)("pending"),[h,m]=(0,r.useState)(!1),[y,g]=(0,r.useState)(()=>ey(e.expiresAt)),x=(0,r.useRef)(null),f=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=document.querySelector("main"),t=document.body.style.overflow;return e?.setAttribute("aria-hidden","true"),document.body.style.overflow="hidden",()=>{e?.removeAttribute("aria-hidden"),document.body.style.overflow=t}},[]),(0,r.useEffect)(()=>{if("pending"!==c)return;let t=!1,n=0,a=async()=>{try{var r;let n,a=await (r=e.pairingId,"server"===D?(n=r,(0,u.sessionCall)("/v1/wallet/pair/status",{pairingId:n})):Promise.resolve(_.pairingStatus(r)));if(t)return;if("pending"!==a.status){p(a.status),"linked"===a.status&&(a.account&&d(a.account),l(a.wallet));return}}catch{}t||(n=window.setTimeout(a,e.pollIntervalMs))};return n=window.setTimeout(a,e.pollIntervalMs),()=>{t=!0,window.clearTimeout(n)}},[e,c,d,l]),(0,r.useEffect)(()=>{if("pending"!==c)return;let t=window.setInterval(()=>{let t=ey(e.expiresAt);g(t),0===t&&p("expired")},1e3);return()=>window.clearInterval(t)},[e,c]),(0,r.useEffect)(()=>{let e=document.activeElement;x.current?.focus();let t=e=>{if("Escape"===e.key)return void n();if("Tab"!==e.key)return;let t=f.current?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!t?.length)return;let a=t[0],r=t[t.length-1],i=document.activeElement;e.shiftKey&&i===a?(e.preventDefault(),r.focus()):e.shiftKey||i!==r||(e.preventDefault(),a.focus())};return window.addEventListener("keydown",t),()=>{window.removeEventListener("keydown",t),e?.focus?.()}},[n]);let b=(0,r.useMemo)(()=>(function(e,t={}
1){let{quiet:n=4,dark:a="#0F1A14",light:r="#FFFFFF"}=t,i=function(e){let t=new TextEncoder().encode(e),n=function(e){for(let t=1;t<=20;t++){let n=4+(t<10?8:16);if(8*eu(t)>=n+8*e)return t}throw Error("Payload too large for a level-M QR code.")}(t.length),a=function(e,t){let[n,a,r]=ei[t-1],i=a+r,l=Math.floor(e.length/i),o=[],s=[],d=0;for(let t=0;t<i;t++){let r=t<a?l:l+1,i=e.subarray(d,d+r);d+=r,o.push(i),s.push(function(e,t){let n=function(e){let t=new Uint8Array([1]);for(let n=0;n<e;n++){let e=new Uint8Array(t.length+1);for(let a=0;a<t.length;a++)e[a]^=t[a],e[a+1]^=ec(t[a],eo[n]);t=e}return t}(t),a=new Uint8Array(t);for(let r of e){let e=r^a[0];if(a.copyWithin(0,1),a[t-1]=0,0!==e)for(let r=0;r<t;r++)a[r]^=ec(n[r+1],e)}return a}(i,n))}let c=new Uint8Array(er[t-1]),p=0;for(let e=0;e<l+1;e++)for(let t of o)e<t.length&&(c[p++]=t[e]);for(let e=0;e<n;e++)for(let t of s)c[p++]=t[e];return c}(function(e,t){let n=eu(t),a=new ep;for(let n of(a.put(4,4),a.put(e.length,t<10?8:16),e))a.put(n,8);let r=8*n;for(a.put(0,Math.min(4,r-a.bits.length));a.bits.length%8!=0;)a.bits.push(0);let i=new Uint8Array(n);for(let e=0;e<a.bits.length;e+=8){let t=0;for(let n=0;n<8;n++)t=t<<1|a.bits[e+n];i[e/8]=t}for(let e=a.bits.length/8;e<n;e++)i[e]=(e-a.bits.length/8)%2==0?236:17;return i}(t,n),n),r=4*n+17,i=null,l=1/0;for(let e=0;e<8;e++){let t=function(e){return Array.from({length:e},()=>new Int8Array(e).fill(-1))}(r);!function(e,t){let n=e.length;eh(e,0,0),eh(e,0,n-7),eh(e,n-7,0);for(let t=8;t<n-8;t++){let n=+(t%2==0);e[6][t]=n,e[t][6]=n}let a=el[t-1];for(let t of a)for(let r of a)if(!(t<=8&&r<=8||t<=8&&r>=n-9||t>=n-9&&r<=8))for(let n=-2;n<=2;n++)for(let a=-2;a<=2;a++)e[t+n][r+a]=+(1!==Math.max(Math.abs(n),Math.abs(a)));e[n-8][8]=1;for(let t=0;t<9;t++)-1===e[8][t]&&(e[8][t]=0),-1===e[t][8]&&(e[t][8]=0);for(let t=0;t<8;t++)-1===e[8][n-1-t]&&(e[8][n-1-t]=0),-1===e[n-1-t][8]&&(e[n-1-t][8]=0);t>=7&&function(e,t){let n=e.length,a=t<<12;for(let e=0;e<12;e++)a>>>17-e&1&&(a^=7973<<5-e);let r=t<<12|a;for(let t=0;t<18;t++){let a=r>>>t&1,i=Math.floor(t/3),l=t%3;e[i][n-11+l]=a,e[n-11+l][i]=a}}(e,t)}(t,n),function(e,t,n){let a=e.length,r=em[n],i=0,l=!0;for(let n=a-1;n>=1;n-=2){6===n&&(n=5);for(let o=0;o<a;o++){let s=l?a-1-o:o;for(let a of[n,n-1]){if(-1!==e[s][a])continue;let n=(t[i>>>3]??0)>>>7-(7&i)&1;e[s][a]=r(s,a)?1^n:n,i++}}l=!l}}(t,a,e),function(e,t){let n=e.length,a=0|t,r=a<<10;for(let e=0;e<5;e++)r>>>14-e&1&&(r^=1335<<4-e);let i=(a<<10|r)^21522;for(let t=0;t<15;t++){let a=i>>>t&1;t<6?e[t][8]=a:6===t?e[7][8]=a:7===t?e[8][8]=a:8===t?e[8][7]=a:e[8][14-t]=a,t<8?e[8][n-1-t]=a:e[n-15+t][8]=a}}(t,e);let o=function(e){let t=e.length,n=0;for(let a=0;a<t;a++)for(let r of[t=>e[a][t],t=>e[t][a]]){let e=1;for(let a=1;a<t;a++)r(a)===r(a-1)?5==++e?n+=3:e>5&&(n+=1):e=1}for(let a=0;a<t-1;a++)for(let r=0;r<t-1;r++){let t=e[a][r];t===e[a][r+1]&&t===e[a+1][r]&&t===e[a+1][r+1]&&(n+=3)}let a=[[1,0,1,1,1,0,1,0,0,0,0],[0,0,0,0,1,0,1,1,1,0,1]];for(let r=0;r<t;r++)for(let i=0;i<=t-11;i++)for(let t of a){let a=!0,l=!0;for(let n=0;n<11;n++)e[r][i+n]!==t[n]&&(a=!1),e[i+n][r]!==t[n]&&(l=!1);a&&(n+=40),l&&(n+=40)}let r=0;for(let n=0;n<t;n++)for(let a=0;a<t;a++)r+=e[n][a];return n+10*Math.floor(Math.abs(100*r/(t*t)-50)/5)}(t);o<l&&(l=o,i=t)}return i.map(e=>Array.from(e,e=>1===e))}(e),l=i.length+2*n,o="";return i.forEach((e,t)=>{e.forEach((e,a)=>{e&&(o+=`M${a+n} ${t+n}h1v1h-1z`)})}),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${l} ${l}" shape-rendering="crispEdges" role="img"><rect width="${l}" height="${l}" fill="${r}"/><path d="${o}" fill="${a}"/></svg>`})(e.uri,{dark:"#28313D",light:"#FFFFFF"}),[e.uri]);async function v(){try{await navigator.clipboard.writeText(e.uri),m(!0),window.setTimeout(()=>m(!1),2e3)}catch{}}return(0,t.jsx)("div",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"ha-qr-title",onClick:e=>{e.target===e.currentTarget&&n()},style:{position:"fixed",inset:0,zIndex:1100,display:"grid",placeItems:"center",padding:"clamp(1rem, 5vw, 3rem)",background:"rgba(20,28,38,0.86)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"},children:(0,t.jsxs)("div",{className:"glass-premium",style:{borderRadius:"4px",padding:"clamp(1.5rem, 4vw, 2.25rem)",maxWidth:"440px",width:"100%",maxHeight:"90vh",overflowY:"auto",textAlign:"center"},children:[(0,t.jsx)("p",{style:S.eyebrow,children:"Heaven Wallet"}),(0,t.jsx)("h2",{id:"ha-qr-title",style:{fontFamily:"var(--font-cormorant)",fontWeight:300,fontSize:"clamp(1.6rem, 4.5vw, 2.1rem)",lineHeight:1.1,color:"var(--ink)",margin:"0.4rem 0 0.6rem"},children:"linked"===c?"Wallet connected":"Scan to connect"}
1),"linked"===c?(0,t.jsx)(ex,{tone:"good",title:"Heaven Wallet is linked.",detail:"You can buy energy in $HEAVEN and set an automatic rebuy from your account.",action:(0,t.jsx)("button",{type:"button",className:"btn-primary",onClick:n,children:"Done"})}):"declined"===c?(0,t.jsx)(ex,{tone:"bad",title:"Declined in the wallet.",detail:"Nothing was connected and nothing was charged.",action:(0,t.jsx)("button",{type:"button",style:S.chipButton,onClick:a,children:"Show a new code"})}):"expired"===c?(0,t.jsx)(ex,{tone:"bad",title:"This code has expired.",detail:"A pairing code is live for five minutes. Generate a fresh one when you are ready to scan.",action:(0,t.jsx)("button",{type:"button",className:"btn-primary",onClick:a,children:"New code"})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.88rem",color:"var(--muted)",margin:"0 0 1.1rem"},children:["Open ",(0,t.jsx)("strong",{style:{color:"var(--ink)"},children:"Heaven Wallet"})," on your phone, tap scan, and point it at this code."]}),(0,t.jsx)("div",{style:{width:"min(260px, 70vw)",margin:"0 auto",padding:"14px",borderRadius:"4px",background:"#FFFFFF",border:"1px solid rgba(65,75,87,0.14)",boxShadow:"0 10px 40px rgba(40,49,61,0.14)",lineHeight:0},children:(0,t.jsx)("div",{role:"img","aria-label":"Heaven Wallet pairing code",style:{width:"100%"},dangerouslySetInnerHTML:{__html:b}})}),(0,t.jsxs)("p",{style:{...S.label,fontSize:"0.6rem",margin:"0.9rem 0 0.2rem"},children:["Waiting for approval · expires in ",(s=Math.floor((o=y)/60),`${s}:${String(o%60).padStart(2,"0")}`)]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.76rem",color:"var(--muted)",margin:"0 0 1.1rem"},children:"You approve what the wallet may ask of you â nothing more. Your balance is public on the chain, so nothing needs permission to be read, and no payment can be taken without you signing it."}),(0,t.jsxs)("div",{style:{display:"flex",gap:"8px",justifyContent:"center",flexWrap:"wrap"},children:[(0,t.jsx)("a",{href:e.deepLink,style:{...S.chipButton,textDecoration:"none",display:"inline-block"},children:"Open on this device"}),(0,t.jsx)("button",{type:"button",style:S.chipButton,onClick:()=>void v(),children:h?"Link copied":"Copy link"})]}),"demo"===D&&(0,t.jsxs)("div",{style:{marginTop:"1.25rem",padding:"11px 13px",borderRadius:"3px",background:"rgba(211,171,84,0.1)",border:"1px dashed rgba(211,171,84,0.45)"},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.56rem",color:"var(--gold-a11y)",margin:"0 0 7px"},children:"Demo mode â no Heaven API configured"}),(0,t.jsx)("button",{type:"button",style:S.chipButton,onClick:()=>{let t=_.approvePairing(e.pairingId);p("linked"),l(t)},children:"Simulate approval in the wallet"})]})]}),(0,t.jsx)("div",{style:{marginTop:"1.4rem"},children:(0,t.jsx)("button",{ref:x,type:"button",onClick:n,style:{...S.body,fontSize:"0.78rem",color:"var(--muted)",background:"none",border:"none",cursor:"none",padding:"6px"},children:"linked"===c?"Close":"Cancel"})})]})})}function ex({tone:e,title:n,detail:a,action:r}){return(0,t.jsxs)("div",{style:{display:"grid",gap:"0.8rem",justifyItems:"center",padding:"0.5rem 0"},children:[(0,t.jsx)("span",{"aria-hidden":"true",style:{width:"52px",height:"52px",borderRadius:"50%",display:"grid",placeItems:"center",fontSize:"1.5rem",background:"good"===e?"rgba(79,122,98,0.14)":"rgba(194,84,63,0.12)",color:"good"===e?"#3F6B53":"#9B3B29"},children:"good"===e?"â¦":"·"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.95rem",color:"var(--ink)",margin:0},children:n}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)",margin:0,maxWidth:"38ch"},children:a}),r]})}let ef={"payments.request":"Ask you to approve a payment","payments.auto":"Charge your standing mandate for automatic rebuys"};function eb({app:e,account:n}){var a;let l,{patchAccount:o,applyAccount:s,emailVerified:d}=(0,i.useAccount)(),[c,h]=(0,r.useState)(null),[m,y]=(0,r.useState)(!1),[g,x]=(0,r.useState)(!1),[f,b]=(0,r.useState)(!1),[v,w]=(0,r.useState)(""),j=(l=n?.walletLink)&&"linked"===l.status?{...l,autoRebuy:{...V,...l.autoRebuy??{}}}:M,k="linked"===j.status,C=(0,r.useCallback)(async()=>{y(!0),w("");try{var e;h(await (e=n.profile.email,"server"===D?(0,u.sessionCall)("/v1/wallet/pair",{}
1):Promise.resolve(_.startPairing(e))))}catch(e){w(e instanceof Error?e.message:"Could not start a pairing.")}finally{y(!1)}},[n.profile.email]),z=(0,r.useCallback)(e=>{e&&o(t=>({...t,walletLink:e,connections:{...t.connections,"heaven-wallet":{...(0,p.connectionFor)(t,"heaven-wallet"),connected:!0,connectedAt:e.linkedAt??new Date().toISOString(),lastSyncAt:new Date().toISOString()}}}))},[o]);async function A(){b(!0),w("");try{let e=await ("server"===D?(0,u.sessionCall)("/v1/wallet/unlink",{}):Promise.resolve({ok:!0}));e?.account?s(e.account):o(e=>({...e,walletLink:{status:"unlinked"},connections:{...e.connections,"heaven-wallet":{...(0,p.connectionFor)(e,"heaven-wallet"),connected:!1,connectedAt:null}}})),x(!1)}catch(e){w(e instanceof Error?e.message:"Could not disconnect.")}finally{b(!1)}}return(0,t.jsxs)("div",{className:"glass-premium",style:{borderRadius:"4px",padding:"clamp(1.25rem, 3vw, 1.75rem)",display:"flex",flexDirection:"column",gap:"1.1rem",borderTop:`2px solid ${k?e.accent:"rgba(255,255,255,0.9)"}`,transition:"border-color 0.4s ease"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:"14px",flexWrap:"wrap"},children:[(0,t.jsx)("div",{style:{width:"52px",height:"52px",borderRadius:"3px",flexShrink:0,display:"grid",placeItems:"center",overflow:"hidden",background:"rgba(255,255,255,0.7)",border:`1px solid ${e.accent}44`,boxShadow:`0 4px 16px ${e.accent}22`},children:(0,t.jsx)(H.default,{src:e.logo,alt:"",width:52,height:52,style:{objectFit:"contain",width:"100%",height:"100%"}})}),(0,t.jsxs)("div",{style:{flex:1,minWidth:"min(200px, 100%)"},children:[(0,t.jsx)("h3",{style:{fontFamily:"var(--font-cormorant)",fontWeight:400,fontSize:"1.45rem",color:"var(--ink)",lineHeight:1.15,margin:0},children:e.name}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)",margin:"3px 0 0"},children:k?`${j.walletName??"Heaven Wallet"} \xb7 ${(a=j.address)?`${a.slice(0,6)}â¦${a.slice(-4)}`:"no address"} \xb7 BNB Smart Chain`:e.tagline})]}),(0,t.jsxs)("span",{style:{...S.label,fontSize:"0.58rem",flexShrink:0,display:"inline-flex",alignItems:"center",gap:"6px",padding:"5px 10px",borderRadius:"2px",background:k?`${e.accent}1A`:"rgba(65,75,87,0.07)",color:k?e.accent:"var(--muted)",border:`1px solid ${k?`${e.accent}44`:"rgba(65,75,87,0.12)"}`},children:[(0,t.jsx)("span",{"aria-hidden":"true",style:{width:"5px",height:"5px",borderRadius:"50%",background:k?e.accent:"var(--muted)",boxShadow:k?`0 0 8px ${e.accent}`:"none"}}),k?"Connected":"Not connected"]})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.88rem",color:"var(--muted)",margin:0,maxWidth:"72ch"},children:e.description}),(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 14px",alignItems:"baseline",padding:"10px 12px",borderRadius:"3px",background:"rgba(255,255,255,0.45)",border:"1px solid rgba(255,255,255,0.7)"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.58rem"},children:"Meters"}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.8rem",color:"var(--ink)"},children:e.meters}),k&&j.linkedAt&&(0,t.jsxs)("span",{style:{...S.body,fontSize:"0.78rem",color:"var(--muted)",width:"100%"},children:["Linked ",(0,S.fmtDateTime)(j.linkedAt),j.lastPaymentAt&&` \xb7 last payment ${(0,S.fmtDateTime)(j.lastPaymentAt)}`]})]}),k?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(300px, 100%), 1fr))",gap:"clamp(0.8rem, 2vw, 1.1rem)"},children:[(0,t.jsx)(K,{link:j}),(0,t.jsx)(Z,{link:j})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"center"},children:[g?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{style:{...S.body,fontSize:"0.8rem",color:"var(--muted)"},children:"Disconnect the wallet and cancel any automatic rebuy?"}),(0,t.jsx)("button",{type:"button",disabled:f,onClick:()=>void A(),style:{...S.chipButton,borderColor:"rgba(194,84,63,0.4)",color:"#9B3B29"},children:f?"Disconnectingâ¦":"Yes, disconnect"}),(0,t.jsx)("button",{type:"button",style:S.chipButton,onClick:()=>x(!1),children:"Keep connected"})]}):(0,t.jsx)("button",{type:"button",style:S.chipButton,onClick:()=>x(!0),children:"Disconnect wallet"}),v&&(0,t.jsx)("span",{role:"alert",style:{...S.body,fontSize:"0.78rem",color:"#9B3B29"},children:v})]})]}):(0,t.jsxs)("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap",alignItems:"center"},children:[(0,t.jsx)("button",{type:"button",className:"btn-primary",disabled:m||!1===d,onClick:()=>void C(),style:{padding:"12px 28px",fontSize:"0.74rem",opacity:m?.6:1},children:m?"Preparing a codeâ¦":"Connect Heaven Wallet"}),!1===d&&(0,t.jsx)("p",{style:{...S.body,fontSize:"0.8rem",color:"var(--muted)",margin:"10px 0 0"},children:"You can pair now. Buying energy needs a confirmed email address â the link is in your inbox."}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.8rem",color:"var(--muted)"},children:"Scan a code with the wallet on your phone. Takes a few seconds."}),v&&(0,t.jsx)("span",{role:"alert",style:{...S.body,fontSize:"0.78rem",color:"#9B3B29"},children:v})]}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.7rem",color:"var(--muted)",margin:0},children:["Grants: ",(k?j.grants??[]:Object.keys(ef)).map(e=>ef[e]??e).join(" · "),"demo"===D&&" · demo mode, no Heaven API configured"]}),c&&(0,t.jsx)(eg,{handle:c,onClose:()=>h(null),onRefresh:()=>{h(null),C()},onLinked:z},c.pairingId)]})}Object.setPrototypeOf(ef,null);let ev={"heaven-wallet":{label:"Payment authorisation",amount:2},"luna-ceo":{label:"Social video render · 30s",amount:48},"heaven-health":{label:"Cure Finder deep research run",amount:36},"coda-blocks":{label:"Approved in-app purchase · Kai",amount:12},"heaven-homes":{label:"Property video · 2-bed listing",amount:30},"heaven-code-studio":{label:"Development run · build & test",amount:44},"heaven-chat":{label:"Assisted reply · translated thread",amount:6},"heaven-soul-mates":{label:"Match run · introductions",amount:18}};function ew({account:e}){let{reportCharge:n,pending:a}=(0,i.useAccount)(),r=p.APPS.filter(t=>(0,p.connectionFor)(e,t.id).connected);return(0,t.jsxs)("section",{className:"glass","aria-labelledby":"ha-ledger-title",style:{borderRadius:"4px",padding:"clamp(1.25rem, 3vw, 1.75rem)"},children:[(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:"12px",flexWrap:"wrap",alignItems:"baseline"},children:[(0,t.jsx)("p",{id:"ha-ledger-title",style:S.eyebrow,children:"Energy ledger"}),(0,t.jsxs)("span",{style:{...S.body,fontSize:"0.78rem",color:"var(--muted)"},children:[e.ledger.length," ",1===e.ledger.length?"entry":"entries"]})]}),0===e.ledger.length?(0,t.jsx)("p",{style:{...S.body,fontSize:"0.88rem",color:"var(--muted)",margin:"1rem 0 0"},children:"Nothing metered yet. Once you connect an app, every charge it reports appears here â what it was for, what it cost, and where it came from."}):(0,t.jsx)("ul",{style:{listStyle:"none",margin:"1.1rem 0 0",padding:0,display:"grid",gap:"2px"},children:e.ledger.slice(0,12).map(e=>{let n=(0,p.appForId)(e.appId),a=e.amount<0;return(0,t.jsxs)("li",{style:{display:"flex",justifyContent:"space-between",gap:"14px",alignItems:"center",padding:"11px 12px",borderRadius:"3px",background:"rgba(255,255,255,0.42)",borderLeft:`2px solid ${a?"var(--emerald)":n.accent}`},children:[(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsx)("p",{style:{...S.body,fontSize:"0.86rem",color:"var(--ink)",margin:0},children:e.label}),(0,t.jsxs)("p",{style:{...S.label,fontSize:"0.56rem",margin:"3px 0 0"},children:[n.name," · ",(0,S.fmtDateTime)(e.at),!a&&e.fromAllowance>0&&` \xb7 ${(0,S.fmtHeaven)(e.fromAllowance)} from allowance`,!a&&e.fromBalance>0&&` \xb7 ${(0,S.fmtHeaven)(e.fromBalance)} from balance`]})]}),(0,t.jsxs)("span",{style:{...S.body,fontSize:"0.92rem",fontWeight:600,whiteSpace:"nowrap",color:a?"var(--emerald)":"var(--ink)"},children:[a?"+":"â",(0,S.fmtHeaven)(Math.abs(e.amount))]})]},e.id)})}),r.length>0&&(0,t.jsxs)("div",{style:{marginTop:"1.4rem",paddingTop:"1.1rem",borderTop:"1px solid rgba(65,75,87,0.12)"},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.56rem",margin:"0 0 9px"},children:"Preview â simulate an energy report from a connected app"}),(0,t.jsx)("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"},children:r.map(e=>(0,t.jsxs)("button",{type:"button",disabled:a,onClick:()=>n(e.id,ev[e.id].label,ev[e.id].amount),style:{...S.chipButton,fontSize:"0.64rem",padding:"8px 13px",borderColor:`${e.accent}55`,opacity:a?.5:1},children:[e.name," · ",ev[e.id].amount]},e.id))})]})]})}function ej({account:e}){let{updateProfile:n,signOut:a}=(0,i.useAccount)(),l=e.profile,[o,s]=(0,r.useState)(!1),[d,c]=(0,r.useState)(""),[p,u]=(0,r.useState)({name:l.name,country:l.country,walletAddress:l.walletAddress}),h=e=>({style:{...S.input,...d===e?S.inputFocus:null},onFocus:()=>c(e),onBlur:()=>c("")});return(0,t.jsxs)("section",{className:"glass","aria-labelledby":"ha-profile-title",style:{borderRadius:"4px",padding:"clamp(1.25rem, 3vw, 1.75rem)"},children:[(0,t.jsx)("p",{id:"ha-profile-title",style:S.eyebrow,children:"Your profile"}),(0,t.jsxs)("div",{style:{display:"flex",gap:"16px",alignItems:"center",margin:"1rem 0 1.25rem"},children:[(0,t.jsx)("div",{"aria-hidden":"true",style:{width:"64px",height:"64px",borderRadius:"50%",flexShrink:0,display:"grid",placeItems:"center",fontFamily:"var(--font-cinzel)",fontSize:"1.5rem",fontWeight:700,color:"var(--ink)",background:`conic-gradient(from 210deg, hsl(${l.avatarHue} 62% 86%), var(--gold-pale), hsl(${(l.avatarHue+120)%360} 58% 88%), hsl(${l.avatarHue} 62% 86%))`,border:"1px solid rgba(255,255,255,0.9)",boxShadow:"0 6px 22px rgba(143,191,232,0.35), inset 0 2px 0 rgba(255,255,255,0.8)"},children:l.name.trim().charAt(0).toUpperCase()||"H"}),(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsx)("h2",{style:{fontFamily:"var(--font-cormorant)",fontWeight:400,fontSize:"1.5rem",color:"var(--ink)",margin:0,lineHeight:1.1},children:l.name}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--gold-a11y)",margin:"2px 0 0"},children:l.handle})]})]}),o?(0,t.jsxs)("div",{style:{display:"grid",gap:"0.9rem"},children:[(0,t.jsx)(eS,{id:"pf-name",text:"Name",children:(0,t.jsx)("input",{id:"pf-name",type:"text",value:p.name,onChange:e=>u(t=>({...t,name:e.target.value})),...h("name")}
1)}),(0,t.jsx)(eS,{id:"pf-country",text:"Country",children:(0,t.jsx)("input",{id:"pf-country",type:"text",value:p.country,placeholder:"Grenada",onChange:e=>u(t=>({...t,country:e.target.value})),...h("country")})}),(0,t.jsx)(eS,{id:"pf-wallet",text:"BSC wallet address",children:(0,t.jsx)("input",{id:"pf-wallet",type:"text",value:p.walletAddress,placeholder:"0xâ¦",onChange:e=>u(t=>({...t,walletAddress:e.target.value})),...h("wallet")})}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px"},children:[(0,t.jsx)("button",{type:"button",onClick:function(){n({name:p.name.trim()||l.name,country:p.country.trim(),walletAddress:p.walletAddress.trim()}),s(!1)},className:"btn-primary",style:{padding:"10px 22px",fontSize:"0.7rem"},children:"Save"}),(0,t.jsx)("button",{type:"button",onClick:function(){u({name:l.name,country:l.country,walletAddress:l.walletAddress}),s(!1)},style:S.chipButton,children:"Cancel"})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("dl",{style:{display:"grid",gap:"12px",margin:0},children:[(0,t.jsx)(ek,{k:"Email",v:l.email}),(0,t.jsx)(ek,{k:"Country",v:l.country||"Not set"}),(0,t.jsx)(ek,{k:"Wallet",v:e.walletLink?.address||l.walletAddress||"Not linked",mono:!!(e.walletLink?.address||l.walletAddress)}),(0,t.jsx)(ek,{k:"Member since",v:(0,S.fmtDate)(e.createdAt)}),(0,t.jsx)(ek,{k:"Account ID",v:e.id,mono:!0})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px",marginTop:"1.4rem",flexWrap:"wrap"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>s(!0),style:S.chipButton,children:"Edit profile"}),(0,t.jsx)("button",{type:"button",onClick:a,style:{...S.chipButton,borderColor:"rgba(194,84,63,0.35)",color:"#9B3B29"},children:"Sign out"})]})]})]})}function eS({id:e,text:n,children:a}){return(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:e,style:{...S.label,display:"block",marginBottom:"6px"},children:n}),a]})}function ek({k:e,v:n,mono:a=!1}){return(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:"14px",alignItems:"baseline"},children:[(0,t.jsx)("dt",{style:{...S.label,fontSize:"0.58rem"},children:e}),(0,t.jsx)("dd",{style:{...S.body,fontSize:a?"0.76rem":"0.86rem",color:"var(--ink)",margin:0,textAlign:"right",wordBreak:"break-all",fontFamily:a?"ui-monospace, SFMono-Regular, Menlo, monospace":"var(--font-nunito)"},children:n})]})}function eC({account:e}){let[n,a]=(0,r.useState)("all"),[i,l]=(0,r.useState)(""),[o,s]=(0,r.useState)(!1),d=(e.ledger??[]).filter(e=>"all"===n||("purchases"===n?e.amount<0:e.amount>0)),c=o?d:d.slice(0,8),p=(e.ledger??[]).filter(e=>e.amount<0).reduce((e,t)=>e+Math.abs(t.amount),0),u=(e.ledger??[]).filter(e=>e.amount>0).reduce((e,t)=>e+t.amount,0);async function h(e){try{await navigator.clipboard.writeText(e),l(e),window.setTimeout(()=>l(""),2e3)}catch{}}return(0,t.jsxs)("section",{className:"glass","aria-labelledby":"ha-receipts-title",style:{borderRadius:"4px",padding:"clamp(1.25rem, 3vw, 1.75rem)"},children:[(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:"12px",flexWrap:"wrap",alignItems:"baseline"},children:[(0,t.jsx)("p",{id:"ha-receipts-title",style:S.eyebrow,children:"Receipts"}),(0,t.jsxs)("span",{style:{...S.body,fontSize:"0.78rem",color:"var(--muted)"},children:[(0,S.fmtHeaven)(p)," bought · ",(0,S.fmtHeaven)(u)," spent"]})]}),(0,t.jsx)("div",{role:"group","aria-label":"Filter receipts",style:{display:"flex",gap:"6px",margin:"1rem 0 1.1rem",flexWrap:"wrap"},children:[["all","Everything"],["purchases","Purchases"],["charges","Energy used"]].map(([e,r])=>(0,t.jsx)("button",{type:"button",onClick:()=>a(e),"aria-pressed":n===e,style:{...S.chipButton,fontSize:"0.64rem",padding:"7px 13px",background:n===e?"rgba(211,171,84,0.18)":"rgba(255,255,255,0.5)",borderColor:n===e?"var(--gold)":"rgba(65,75,87,0.2)",color:n===e?"var(--gold-a11y)":"var(--white)"},children:r},e))}),0===c.length?(0,t.jsx)("p",{style:{...S.body,fontSize:"0.88rem",color:"var(--muted)",margin:0},children:"Nothing here yet. Buy energy or connect an app, and every movement appears with its receipt."}):(0,t.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:"8px"},children:c.map(e=>(0,t.jsx)(ez,{entry:e,copied:i,onCopy:h},e.id))}),d.length>8&&(0,t.jsx)("button",{type:"button",onClick:()=>s(e=>!e),style:{...S.chipButton,marginTop:"1rem",fontSize:"0.66rem"},children:o?"Show fewer":`Show all ${d.length}`})]})}function ez({entry:e,copied:n,onCopy:a}){let r,i=(0,p.appForId)(e.appId),l=e.amount<0,o=l?"var(--emerald)":i.accent;return(0,t.jsxs)("li",{style:{padding:"13px 14px",borderRadius:"3px",background:"rgba(255,255,255,0.45)",border:"1px solid rgba(255,255,255,0.7)",borderLeft:`2px solid ${o}`,display:"grid",gap:"8px"},children:[(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:"14px",alignItems:"baseline"},children:[(0,t.jsx)("span",{style:{...S.body,fontSize:"0.9rem",color:"var(--ink)"},children:e.label}),(0,t.jsxs)("span",{style:{...S.body,fontSize:"0.95rem",fontWeight:600,color:o,whiteSpace:"nowrap"},children:[l?"+":"â",(0,S.fmtHeaven)(Math.abs(e.amount))]})]}),(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:[(0,t.jsx)(eA,{k:"When",v:(0,S.fmtDateTime)(e.at)}),(0,t.jsx)(eA,{k:"App",v:i.name}),!l&&e.fromAllowance>0&&(0,t.jsx)(eA,{k:"From allowance",v:(0,S.fmtHeaven)(e.fromAllowance)}),!l&&e.fromBalance>0&&(0,t.jsx)(eA,{k:"From balance",v:(0,S.fmtHeaven)(e.fromBalance)}),e.jobId&&(0,t.jsx)(eA,{k:"Job",v:e.jobId})]}),e.txHash?(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center",paddingTop:"8px",borderTop:"1px solid rgba(65,75,87,0.1
1)"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.56rem"},children:"On chain"}),(0,t.jsx)("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.72rem",color:"var(--ink)",wordBreak:"break-all"},children:(r=e.txHash,`${r.slice(0,10)}â¦${r.slice(-8)}`)}),(0,t.jsx)("a",{href:`https://bscscan.com/tx/${e.txHash}`,target:"_blank",rel:"noopener noreferrer",style:{...S.body,fontSize:"0.74rem",color:"var(--gold-a11y)",cursor:"none",textDecoration:"underline",textUnderlineOffset:"3px"},children:"View on BscScan"}),(0,t.jsx)("button",{type:"button",onClick:()=>a(e.txHash),style:{...S.chipButton,fontSize:"0.6rem",padding:"5px 10px"},children:n===e.txHash?"Copied":"Copy hash"})]}):(0,t.jsx)("p",{style:{...S.label,fontSize:"0.56rem",margin:0},children:"Metered internally â no chain transaction"})]})}function eA({k:e,v:n}){return(0,t.jsxs)("span",{style:{display:"flex",gap:"6px",alignItems:"baseline"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.56rem"},children:e}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.78rem",color:"var(--ink)"},children:n})]})}function eE(){let{changePassword:e,deleteAccount:n}=(0,i.useAccount)(),[a,l]=(0,r.useState)("none"),[o,s]=(0,r.useState)(""),[d,c]=(0,r.useState)(""),[p,u]=(0,r.useState)(""),[h,m]=(0,r.useState)(""),[y,g]=(0,r.useState)(""),[x,f]=(0,r.useState)(!1),[b,v]=(0,r.useState)(""),[w,j]=(0,r.useState)("");function k(e){l(e),s(""),c(""),u(""),m(""),v(""),j("")}let C=e=>({style:{...S.input,...y===e?S.inputFocus:null},onFocus:()=>g(e),onBlur:()=>g("")});async function z(t){if(t.preventDefault(),v(""),d.length<8)return v("Your new password needs at least 8 characters.");if(d!==p)return v("Those two passwords donât match.");if(d===o)return v("That is the password you already have.");f(!0);try{await e(o,d),k("none"),j("Your password has been changed.")}catch(e){v(e instanceof Error?e.message:"Could not change it. Try again.")}finally{f(!1)}}async function A(e){if(e.preventDefault(),v(""),"DELETE"!==h.trim().toUpperCase())return v("Type DELETE to confirm you mean it.");f(!0);try{await n(o)}catch(e){v(e instanceof Error?e.message:"Could not delete the account."),f(!1)}}return(0,t.jsxs)("section",{className:"glass","aria-labelledby":"ha-security-title",style:{borderRadius:"4px",padding:"clamp(1.25rem, 3vw, 1.75rem)"},children:[(0,t.jsx)("p",{id:"ha-security-title",style:S.eyebrow,children:"Security"}),w&&(0,t.jsx)("p",{role:"status",style:{...S.body,fontSize:"0.85rem",color:"#2F6B4F",margin:"0.9rem 0 0"},children:w}),"none"===a&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{style:{...S.body,fontSize:"0.86rem",color:"var(--muted)",margin:"0.9rem 0 1.25rem"},children:"Change your password, or close your account for good."}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>k("password"),style:S.chipButton,children:"Change password"}),(0,t.jsx)("button",{type:"button",onClick:()=>k("delete"),style:{...S.chipButton,borderColor:"rgba(194,84,63,0.35)",color:"#9B3B29"},children:"Delete account"})]})]}),"password"===a&&(0,t.jsxs)("form",{onSubmit:z,style:{display:"grid",gap:"0.9rem",marginTop:"1rem"},children:[(0,t.jsx)(eH,{id:"sec-cur",text:"Current password",children:(0,t.jsx)("input",{id:"sec-cur",type:"password",autoComplete:"current-password",value:o,onChange:e=>s(e.target.value),...C("cur")})}),(0,t.jsx)(eH,{id:"sec-new",text:"New password",children:(0,t.jsx)("input",{id:"sec-new",type:"password",autoComplete:"new-password",value:d,onChange:e=>c(e.target.value),placeholder:"At least 8 characters",...C("new")})}),(0,t.jsx)(eH,{id:"sec-cf",text:"Confirm new password",children:(0,t.jsx)("input",{id:"sec-cf",type:"password",autoComplete:"new-password",value:p,onChange:e=>u(e.target.value),...C("cf")})}),b&&(0,t.jsx)("p",{role:"alert",style:eW,children:b}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px"},children:[(0,t.jsx)("button",{type:"submit",className:"btn-primary",disabled:x,style:{padding:"10px 22px",fontSize:"0.7rem",opacity:x?.6:1},children:x?"Savingâ¦":"Save"}),(0,t.jsx)("button",{type:"button",onClick:()=>k("none"),style:S.chipButton,children:"Cancel"})]})]}),"delete"===a&&(0,t.jsxs)("form",{onSubmit:A,style:{display:"grid",gap:"0.9rem",marginTop:"1rem"},children:[(0,t.jsx)("p",{style:{...S.body,fontSize:"0.86rem",margin:0},children:"This removes your account, your balance and your history, and cannot be undone. Any connected app loses access immediately."}),(0,t.jsx)(eH,{id:"sec-typed",text:"Type DELETE to confirm",children:(0,t.jsx)("input",{id:"sec-typed",type:"text",value:h,autoComplete:"off",onChange:e=>m(e.target.value),placeholder:"DELETE",...C("typed")})}),(0,t.jsx)(eH,{id:"sec-del-pw",text:"Your password",children:(0,t.jsx)("input",{id:"sec-del-pw",type:"password",autoComplete:"current-password",value:o,onChange:e=>s(e.target.value),...C("delpw")})}),b&&(0,t.jsx)("p",{role:"alert",style:eW,children:b}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px"},children:[(0,t.jsx)("button",{type:"submit",disabled:x,style:{...S.chipButton,borderColor:"rgba(194,84,63,0.5)",color:"#9B3B29",opacity:x?.6:1},children:x?"Deletingâ¦":"Delete my account for good"}),(0,t.jsx)("button",{type:"button",onClick:()=>k("none"),style:S.chipButton,children:"Keep my account"})]})]})]})}let eW={...S.body,fontSize:"0.84rem",color:"#9B3B29",background:"rgba(194,84,63,0.09)",border:"1px solid rgba(194,84,63,0.24)",borderRadius:"3px",padding:"10px 12px",margin:0};function eH({id:e,text:n,children:a}){return(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:e,style:{...S.label,display:"block",marginBottom:"6px"},children:n}),a]})}function eB(){let e,{heavenUsd:n,sourceLabel:a,fallback:r}=v(),{account:l}=(0,i.useAccount)(),o=l?.walletLink?.status==="linked"?l.walletLink.address:null;return(0,t.jsxs)("section",{className:"glass","aria-labelledby":"ha-buy-title",style:{borderRadius:"4px",padding:"clamp(1.25rem, 3vw, 1.6rem)",display:"flex",flexWrap:"wrap",gap:"16px",alignItems:"center",justifyContent:"space-between",borderTop:"2px solid var(--gold)"},children:[(0,t.jsxs)("div",{style:{minWidth:0,flex:"1 1 320px"},children:[(0,t.jsx)("p",{id:"ha-buy-title",style:S.eyebrow,children:"Need $HEAVEN?"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.95rem",color:"var(--ink)",margin:"6px 0 0",fontWeight:500},children:"Buy it on the Heaven Token terminal."}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.86rem",color:"var(--muted)",margin:"6px 0 0",maxWidth:"58ch"},children:"Your account spends $HEAVEN and can charge a wallet that holds
1some, but tokens are bought on the terminal â priced in USDT, straight to the wallet you paired here."}),(0,t.jsxs)("p",{style:{...S.label,fontSize:"0.56rem",margin:"10px 0 0"},children:[w(n)," USDT per $HEAVEN",r?" · the terminal could not be reached, so this is a fallback":""]}),a&&!r&&(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.76rem",color:"var(--muted)",margin:"4px 0 0"},children:[a,"."]})]}),(0,t.jsx)("a",{href:(e=new URL("https://www.heaventoken.com/terminal"),o&&e.searchParams.set("to",o),e.searchParams.set("return",`${window.location.origin}/account/`),e.toString()),target:"_blank",rel:"noopener noreferrer",className:"btn-primary",style:{padding:"12px 26px",fontSize:"0.72rem",textDecoration:"none",flexShrink:0},children:"Buy $HEAVEN"})]})}function e$(){return(0,t.jsxs)("aside",{"aria-label":"Paying with $HEAVEN you already hold",style:{borderRadius:"4px",padding:"clamp(1.1rem, 3vw, 1.5rem)",background:"linear-gradient(135deg, rgba(123,111,176,0.16) 0%, rgba(123,111,176,0.07) 100%)",border:"1px solid rgba(123,111,176,0.42)",borderLeft:"3px solid #7B6FB0",display:"flex",flexWrap:"wrap",gap:"16px",alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsxs)("div",{style:{minWidth:0,flex:"1 1 clamp(16rem, 60%, 44rem)"},children:[(0,t.jsx)("p",{style:{...S.eyebrow,color:"#5B5090",margin:0},children:"Already hold $HEAVEN?"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.95rem",margin:"6px 0 0",color:"var(--ink)",fontWeight:500},children:"Your tokens buy energy here."}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.86rem",margin:"6px 0 0",color:"var(--muted)"},children:"We take them at the live Heaven Terminal rate, read at the moment you pay â so the number on the terminal is the number you are charged. Connect Heaven Wallet below to spend tokens you already hold."})]}),(0,t.jsx)("a",{href:"https://www.heaventoken.com/terminal",target:"_blank",rel:"noopener noreferrer","aria-label":"Open the Heaven Terminal to see the live rate (opens in a new tab)",style:{...S.chipButton,flexShrink:0,textDecoration:"none",display:"inline-block",borderColor:"rgba(123,111,176,0.55)",color:"#5B5090",background:"rgba(255,255,255,0.62)"},children:"Open Heaven Terminal"})]})}let eI=[{id:"monthly-30",usd:30,name:"30 a month",blurb:"Enough for steady use of one app, or a light month across several."},{id:"monthly-60",usd:60,name:"60 a month",blurb:"Room to run marketing and research together without watching the meter."},{id:"monthly-90",usd:90,name:"90 a month",blurb:"For running the whole ecosystem â promotion, video, research and builds."}],eT=eI.reduce((e,t)=>(e[t.id]=t,e),{}),eN=[{id:"dashboard",label:"Dashboard",hint:"Balance, apps and receipts"},{id:"subscriptions",label:"Subscriptions",hint:"Your monthly energy package"}];function eP(e){return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}function eF(){return"#subscriptions"===window.location.hash?"subscriptions":"dashboard"}function eR(){return(0,r.useSyncExternalStore)(eP,eF,()=>"dashboard")}function eD(){eL("dashboard");let e=20,t=()=>{let n=document.getElementById("ha-wallet");n?n.scrollIntoView({behavior:"smooth",block:"start"}):e-- >0&&requestAnimationFrame(t)};requestAnimationFrame(t)}function eL(e){eF()!==e&&("dashboard"===e?(window.history.pushState({},"",window.location.pathname+window.location.search),window.dispatchEvent(new HashChangeEvent("hashchange"))):window.location.hash="#subscriptions",window.scrollTo({top:0,behavior:"auto"}))}function eM({account:e}){let{choosePackage:n,subscribeWithPayPal:a,cancelPayPal:l,pending:o,opError:s}=(0,i.useAccount)(),{heavenUsd:d,decimals:c}=v(),[u,h]=(0,r.useState)(!1);async function m(e){let t=await a(e);t&&(window.location.href=t)}let y=e.energyPackage??null,g=e.walletLink?.status==="linked"||(0,p.connectionFor)(e,"heaven-wallet").connected;return(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{style:{marginBottom:"1.35rem"},children:[(0,t.jsx)("h2",{style:S.sectionTitle,children:"Monthly energy package"}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.9rem",color:"var(--muted)",margin:"5px 0 0",maxWidth:"64ch"},children:["Energy into your balance every month, funding every app â the ones on a plan and the ones without. Two ways to pay, and they are genuinely different: ",(0,t.jsx)("strong",{style:{color:"var(--ink)"},children:"$HEAVEN from your wallet"}),", priced in USDT at the live rate, or"," ",(0,t.jsx)("strong",{style:{color:"var(--ink)"},children:"US dollars through PayPal"}),", a fixed price charged to a card."]})]}),(0,t.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(240px, 100%), 1fr))",gap:"clamp(1rem, 2.5vw, 1.5rem)"},children:eI.map(e=>{let a=y?.packageId===e.id,r=j(e.usd,d,c);return(0,t.jsxs)("article",{className:a?"glass-premium":"glass",style:{borderRadius:"4px",padding:"clamp(1.25rem, 3vw, 1.6rem)",display:"flex",flexDirection:"column",gap:"0.9rem",borderTop:`2px solid ${a?"var(--gold)":"rgba(255,255,255,0.9)"}`},children:[(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:"10px",alignItems:"flex-start"},children:[(0,t.jsx)("h3",{style:{fontFamily:"var(--font-cormorant)",fontWeight:400,fontSize:"1.3rem",color:"var(--ink)",margin:0},children:e.name}),a&&(0,t.jsx)("span",{style:{...S.label,fontSize:"0.54rem",padding:"4px 8px",borderRadius:"2px",background:"rgba(211,171,84,0.18)",color:"var(--gold-a11y)",border:"1px solid rgba(211,171,84,0.45)"},children:y?"paused"===y.status?"Paused":"awaiting_payment"===y.status?"Awaiting approval":"pending_approval"===y.paypalStatus?"Finish at PayPal":"payment_failed"===y.paypalStatus?"Payment failed":"Active":"Active"})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{style:{fontFamily:"var(--font-cormorant)",fontWeight:300,fontSize:"2.2rem",color:"var(--ink)",margin:0,lineHeight:1},children:[(0,S.fmtHeaven)(r),(0,t.jsx)("span",{style:{fontSize:"0.32em",letterSpacing:"0.1em",color:"var(--gold-a11y)",marginLeft:"0.5rem"},children:"energy"})]}),(0,t.jsx)("p",{style:{...S.label,fontSize:"0.58rem",margin:"6px 0 0"},children:"every month"})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)",margin:0},children:e.blurb}),(0,t.jsxs)("div",{style:{marginTop:"auto",display:"grid",gap:"14px"},children:[(0,t.jsxs)("div",{style:{display:"grid",gap:"6px"},children:[(0,t.jsx)("button",{type:"button",className:a&&y?.payVia!=="paypal"?void 0:"btn-primary",disabled:o,onClick:()=>n(e.id),style:a&&y?.payVia!=="paypal"?{...S.chipButton,width:"100%",justifyContent:"center",opacity:o?.5:1}:{padding:"11px 22px",fontSize:"0.7rem",width:"100%",justifyContent:"center",opacity:o?.5:1},children:a&&y?.payVia!=="paypal"?"Your package":"Pay in $HEAVEN"}),(0,t.jsxs)("p",{style:{...S.label,fontSize:"0.54rem",margin:0,textAlign:"center",lineHeight:1.5},children:[(0,S.fmtHeaven)(r)," $HEAVEN from your wallet",(0,t.jsx)("br",{}),(0,t.jsxs)("span",{style:{textTransform:"none",letterSpacing:0,color:"var(--muted)"},children:[e.usd," USDT of tokens at ",w(d)," each â approved on your phone"]})]})]}),(0,t.jsxs)("div",{style:{display:"grid",gap:"6px"},children:[(0,t.jsx)("button",{type:"button",disabled:o,onClick:()=>void m(e.id),style:{...S.chipButton,width:"100%",justifyContent:"center",background:"#ffc439",borderColor:"#f0b429",color:"#003087",fontWeight:700,opacity:o?.5:1},children:a&&y?.payVia==="paypal"?"Your package":"Pay with PayPal"}),(0,t.jsxs)("p",{style:{...S.label,fontSize:"0.54rem",margin:0,textAlign:"center",lineHeight:1.5},children:["$",e.usd,".00 USD by card or PayPal balance",(0,t.jsx)("br",{}),(0,t.jsx)("span",{style:{textTransform:"none",letterSpacing:0,color:"var(--muted)"},children:"charged automatically each month â no approval needed"})]})]})]})]},e.id)})}),s&&(0,t.jsx)("p",{role:"alert",style:{...S.body,fontSize:"0.82rem",color:"#9B3B29",margin:"1rem 0 0"},children:s}),y?(0,t.jsxs)("div",{className:"glass",style:{borderRadius:"4px",padding:"clamp(1rem, 2.5vw, 1.35rem)",marginTop:"clamp(1rem, 2.5vw, 1.5rem)",display:"grid",gap:"10px"},children:[(0,t.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 22px"},children:[(0,t.jsx)(eV,{k:"awaiting_payment"===y.status?"Due":"Next charge",v:"awaiting_payment"===y.status?"now":(0,S.fmtDate)(y.renewsAt)}),(0,t.jsx)(eV,{k:"paypal"===y.payVia?"Charged":"Costs",v:"paypal"===y.payVia?`$${y.usd}.00 USD`:`${(0,S.fmtHeaven)(j(y.usd,d,c))} $HEAVEN (${y.usd} USDT)`}),(0,t.jsx)(eV,{k:"Buys",v:`${(0,S.fmtHeaven)(j(y.usd,d,c))} energy`}),y.lastChargedAt&&(0,t.jsx)(eV,{k:"Last charged",v:(0,S.fmtDate)(y.lastChargedAt)})]}),"paypal"===y.payVia&&(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--ink)",margin:0},children:["Paid by ",(0,t.jsx)("strong",{children:"PayPal"})," in USD, charged automatically each month â no approval needed after the first.","pending_approval"===y.paypalStatus&&" Waiting for you to finish at PayPal.","payment_failed"===y.paypalStatus&&" PayPal could not take the last payment â check your payment method there."]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--muted)",margin:0},children:"paypal"===y.payVia?"Cancel here and PayPal stops charging you. Your remaining energy stays yours.":"awaiting_payment"===y.status?"A renewal is waiting for you to approve it in Heaven Wallet. Nothing is charged until you do.":g?"On renewal day your phone will buzz and you approve the payment in Heaven Wallet â one tap, and nothing is taken until you do. Heaven Wallet cannot charge a standing $HEAVEN mandate yet; the day it can, this becomes automatic and we will tell you before it does.":"Connect Heaven Wallet so renewals can be paid. Without it, nothing can be charged and the package will simply sit due."}
1),"paypal"!==y.payVia&&!g&&(0,t.jsx)("button",{type:"button",onClick:eD,style:{...S.chipButton,alignSelf:"start"},children:"Take me to Heaven Wallet"}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap"},children:[("paypal"!==y.payVia||"cancelled"!==y.paypalStatus)&&(0,t.jsx)("button",{type:"button",disabled:o,onClick:()=>n(null,"paused"===y.status?"resume":"pause"),style:S.chipButton,children:"paused"===y.status?"Resume":"Pause renewals"}),u?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{style:{...S.body,fontSize:"0.8rem",color:"var(--muted)"},children:"Cancel the package?"}),(0,t.jsx)("button",{type:"button",disabled:o,onClick:()=>{"paypal"===y.payVia?l():n(null,"cancel"),h(!1)},style:{...S.chipButton,borderColor:"rgba(194,84,63,0.4)",color:"#9B3B29"},children:"Yes, cancel"}),(0,t.jsx)("button",{type:"button",onClick:()=>h(!1),style:S.chipButton,children:"Keep it"})]}):(0,t.jsx)("button",{type:"button",onClick:()=>h(!0),style:S.chipButton,children:"Cancel"})]})]}):(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",color:"var(--muted)",margin:"1rem 0 0",maxWidth:"62ch"},children:"No package yet. You can buy energy one purchase at a time instead â a package simply means not having to think about it each month."})]})}function eV({k:e,v:n}){return(0,t.jsxs)("span",{style:{display:"flex",gap:"7px",alignItems:"baseline"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.56rem"},children:e}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.85rem",color:"var(--ink)",fontWeight:600},children:n})]})}function eY(){let e=eR(),{account:n}=(0,i.useAccount)(),a=n?.energyPackage??null,r={subscriptions:a?`$${a.usd} a month${"paused"===a.status?" · paused":""}`:"Not subscribed yet"};return(0,t.jsxs)("nav",{"aria-label":"Client area",className:"ha-rail",style:eU,children:[(0,t.jsx)("p",{style:{...S.eyebrow,padding:"0 4px",marginBottom:"2px"},children:"Your account"}),eN.map(n=>{let a=n.id===e;return(0,t.jsxs)("button",{type:"button","aria-current":a?"page":void 0,onClick:()=>eL(n.id),style:{...eO,background:a?"rgba(211,171,84,0.16)":"transparent",borderColor:a?"rgba(211,171,84,0.5)":"transparent",color:a?"var(--ink)":"var(--muted)"},children:[(0,t.jsx)("span",{style:{fontWeight:a?600:500,fontSize:"0.86rem"},children:n.label}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.68rem",color:"var(--muted)",lineHeight:1.35},children:r[n.id]??n.hint})]},n.id)})]})}let eU={display:"flex",flexDirection:"column",gap:"6px",alignSelf:"start"},eO={display:"flex",flexDirection:"column",gap:"3px",textAlign:"left",width:"100%",padding:"11px 14px",borderRadius:"4px",border:"1px solid",fontFamily:"var(--font-poppins), system-ui, sans-serif",letterSpacing:"0.01em",cursor:"none",transition:"background 240ms ease, color 240ms ease, border-color 240ms ease"};function e_({account:e}){let n=(0,p.lunaLinkState)(e);return"linked"===n?(0,t.jsx)(eG,{}):"confirming"===n?(0,t.jsx)(eq,{}):(0,t.jsx)(eJ,{})}function eq(){let{refreshAccount:e,pending:n}=(0,i.useAccount)();return(0,t.jsxs)("section",{"aria-labelledby":"ha-luna-wait",style:{...eQ,...e0},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",flexWrap:"wrap"},children:[(0,t.jsx)("span",{style:{...e5,background:"var(--gold)",boxShadow:"0 0 0 3px rgba(211,171,84,0.22)"},"aria-hidden":"true"}),(0,t.jsx)("p",{id:"ha-luna-wait",style:{...S.body,fontSize:"0.88rem",color:"var(--ink)",margin:0,fontWeight:500},children:"Luna has your permission"})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)",margin:"8px 0 0",maxWidth:"62ch"},children:"You approved Luna from this account, so nothing more is needed from you. Luna confirms the link from its side, and this turns green when it does â at the latest the first time an app draws on your memory pod."}),(0,t.jsx)("button",{type:"button",disabled:n,onClick:()=>{e()},style:{...S.chipButton,alignSelf:"start",marginTop:"12px",opacity:n?.5:1},children:n?"Checkingâ¦":"Check again"})]})}function eG(){return(0,t.jsxs)("div",{role:"status",style:{...eQ,...e1},children:[(0,t.jsx)("span",{style:e5,"aria-hidden":"true"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.86rem",color:"var(--ink)",margin:0,fontWeight:500},children:"Connected to Luna"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.78rem",color:"var(--muted)",margin:0},children:"Your memory pod is live and every Heaven app draws on it."})]})}let eK=[{n:1,title:"Get the Luna Heaven app",text:"In a browser on any device, or from Google Play on Android. Same account either way."},{n:2,title:"Create your Luna account",text:"The app walks you through it. It takes a minute."},{n:3,title:"Connect it to Heaven Eco Hub",text:"One tap inside Luna. This is the connection that matters â everything else follows from it."}];function eJ(){return(0,t.jsxs)("section",{"aria-labelledby":"ha-luna-title",style:{...eQ,...eZ},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:"10px",flexWrap:"wrap"},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.6rem",color:"var(--gold-a11y)",margin:0},children:"Do this first"}),(0,t.jsx)("span",{style:e2,children:"Not connected"})]}),(0,t.jsx)("h2",{id:"ha-luna-title",style:{fontFamily:"var(--font-cormorant)",fontWeight:400,fontSize:"clamp(1.35rem, 3.4vw, 1.9rem)",lineHeight:1.15,color:"var(--ink)",margin:"8px 0 0"},children:"Connect to Heaven Intelligence"}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.92rem",color:"var(--muted)",margin:"8px 0 0",maxWidth:"64ch"},children:["Luna is the brain behind every Heaven app. Connecting her creates"," ",(0,t.jsx)("strong",{style:{color:"var(--ink)",fontWeight:600},children:"your own sovereign memory pod"})," ","â private to you, holding what you tell it and nobody elseâs. Every app you connect afterwards draws on that same pod, so they know you rather than starting from nothing each time."]}),(0,t.jsx)("ol",{style:e4,children:eK.map(e=>(0,t.jsxs)("li",{style:{display:"flex",gap:"12px",alignItems:"flex-start"},children:[(0,t.jsx)("span",{"aria-hidden":"true",style:e8,children:e.n}),(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsx)("p",{style:{...S.body,fontSize:"0.88rem",color:"var(--ink)",margin:0,fontWeight:500},children:e.title}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.8rem",color:"var(--muted)",margin:"2px 0 0"},children:e.text})]})]},e.n))}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap",marginTop:"1.1rem"},children:[(0,t.jsx)(eX,{href:"https://luna-heaven.com",primary:!0,children:"Open Luna in a browser"}),(0,t.jsx)(eX,{href:"https://play.google.com/store/apps/details?id=com.heavenecohub.luna_mobile",children:"Get it on Google Play"})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.76rem",color:"var(--muted)",margin:"0.9rem 0 0"},children:"On iPhone, use the browser version for now â the App Store release is on its way. This panel turns green the moment you are connected, and nothing here needs doing twice."})]})}function eX({href:e,children:n,primary:a}){return(0,t.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{...e6,background:a?"var(--gold)":"rgba(255,255,255,0.72)",color:a?"#2A2110":"var(--ink)",borderColor:a?"var(--gold)":"rgba(211,171,84,0.45)",fontWeight:a?600:500},children:n})}let eQ={borderRadius:"4px",padding:"clamp(1rem, 2.6vw, 1.5rem)",border:"1px solid",backdropFilter:"blur(24px) saturate(180%)",WebkitBackdropFilter:"blur(24px) saturate(180%)"},eZ={background:"linear-gradient(135deg, rgba(211,171,84,0.20) 0%, rgba(211,171,84,0.10) 100%)",borderColor:"rgba(211,171,84,0.55)",borderLeft:"3px solid var(--gold)",boxShadow:"0 8px 28px rgba(211,171,84,0.20)"},e0={background:"rgba(255,255,255,0.58)",borderColor:"rgba(211,171,84,0.45)",borderLeft:"3px solid var(--gold)"}
1,e1={display:"flex",alignItems:"center",gap:"10px",flexWrap:"wrap",background:"rgba(255,255,255,0.55)",borderColor:"rgba(47,125,95,0.35)",borderLeft:"3px solid #2F7D5F",padding:"12px clamp(1rem, 2.6vw, 1.4rem)"},e5={width:"9px",height:"9px",borderRadius:"50%",background:"#2F7D5F",boxShadow:"0 0 0 3px rgba(47,125,95,0.18)",flexShrink:0},e2={fontFamily:"var(--font-poppins), system-ui, sans-serif",fontSize:"0.58rem",fontWeight:600,letterSpacing:"0.09em",textTransform:"uppercase",padding:"4px 9px",borderRadius:"999px",background:"rgba(168,118,44,0.16)",border:"1px solid rgba(168,118,44,0.4)",color:"#8A6220"},e4={listStyle:"none",margin:"1.1rem 0 0",padding:0,display:"grid",gap:"12px"},e8={flexShrink:0,width:"24px",height:"24px",borderRadius:"50%",display:"grid",placeItems:"center",fontFamily:"var(--font-poppins), system-ui, sans-serif",fontSize:"0.7rem",fontWeight:600,color:"var(--ink)",background:"rgba(255,255,255,0.75)",border:"1px solid rgba(211,171,84,0.5)"},e6={fontFamily:"var(--font-poppins), system-ui, sans-serif",fontSize:"0.72rem",letterSpacing:"0.06em",textTransform:"uppercase",textDecoration:"none",padding:"10px 18px",borderRadius:"4px",border:"1px solid",cursor:"none",transition:"transform 200ms ease, box-shadow 200ms ease"},e3=()=>()=>{},e7=()=>window.location.search,e9=()=>null;function te(){let{refreshAccount:e,captureOrder:n,account:a}=(0,i.useAccount)(),l=(0,r.useSyncExternalStore)(e3,e7,e9),o=null!==l&&new URLSearchParams(l).get("paypal"),s=null===l?null:new URLSearchParams(l).get("token"),[d]=(0,r.useState)(()=>"order"===o||"done"===o||"cancelled"===o?o:null),[c,p]=(0,r.useState)(()=>"order"===d?s?"checking":"slow":"done"===d?"checking":"idle");return((0,r.useEffect)(()=>{if("order"!==d||!s)return;let e=!0;return(async()=>{let t=await n(s);e&&(p("credited"===t?"done":"not_charged"===t?"slow":"unconfirmed"),"credited"===t&&window.history.replaceState({},"",window.location.pathname))})(),()=>{e=!1}},[d,s,n]),(0,r.useEffect)(()=>{if("done"!==d)return;let t=!0,n=0,a=async()=>{if(!t)return;n+=1;let r=await e();if(t){if(r?.energyPackage?.paypalStatus==="active"){p("done"),window.history.replaceState({},"",window.location.pathname);return}if(n>=15)return void p("slow");window.setTimeout(a,2e3)}};return a(),()=>{t=!1}},[d,e]),"cancelled"===d)?(0,t.jsx)(tt,{tone:"quiet",children:"You came back from PayPal without finishing. Nothing was charged, and your package is unchanged."}):"checking"===c?(0,t.jsx)(tt,{tone:"busy",children:"order"===d?"Taking your payment and crediting your energyâ¦":"Confirming your payment with PayPalâ¦"}):"done"===c&&"order"===d?(0,t.jsx)(tt,{tone:"good",children:"Payment taken. Your energy is in your balance."}):"done"===c?(0,t.jsxs)(tt,{tone:"good",children:["PayPal payment confirmed. ",a?.energyPackage?.usd?`Your ${a.energyPackage.usd} a month package is active, and your energy is in your balance.`:"Your package is active."]}):"slow"===c&&"order"===d?(0,t.jsx)(tt,{tone:"quiet",children:"That payment did not complete, and PayPal has taken nothing. Nothing has been charged and no energy was added â you can try again whenever you like."}):"unconfirmed"===c&&"order"===d?(0,t.jsx)(tt,{tone:"quiet",children:"We couldnât confirm the result of that payment. Please check your balance before trying again â if your energy isnât there within a few minutes, contact us with your PayPal receipt and weâll sort it out. Donât pay again until youâve checked."}):"slow"===c?(0,t.jsx)(tt,{tone:"quiet",children:"PayPal has taken your payment but has not told us yet â this can take a few minutes. Your energy will appear on its own; there is nothing to do and nothing to pay again."}):null}function tt({tone:e,children:n}){let a={good:{bg:"rgba(79,122,98,0.12)",border:"rgba(79,122,98,0.4)",accent:"var(--emerald)"},busy:{bg:"rgba(211,171,84,0.12)",border:"rgba(211,171,84,0.4)",accent:"var(--gold-a11y)"},quiet:{bg:"rgba(255,255,255,0.5)",border:"rgba(65,75,87,0.15)",accent:"var(--muted)"}}[e];return(0,t.jsxs)("div",{role:"status",style:{borderRadius:"4px",padding:"clamp(1rem, 2.5vw, 1.25rem)",background:a.bg,border:`1px solid ${a.border}`,borderLeft:`3px solid ${a.accent}`},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.58rem",color:a.accent,margin:0},children:"PayPal"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.9rem",margin:"5px 0 0",color:"var(--ink)"},children:n})]})}function tn({account:e}){let n,{renewNow:a,pending:l,opError:o}=(0,i.useAccount)(),{heavenUsd:s,decimals:d}=v(),[c,p]=(0,r.useState)(!1),u=e.energyPackage;if(!u||"awaiting_payment"!==u.status)return null;let h=eT[u.packageId];if("paypal"===u.payVia)return"payment_failed"!==u.paypalStatus?null:(0,t.jsxs)("div",{role:"status",style:{borderRadius:"4px",padding:"clamp(1.1rem, 3vw, 1.5rem)",background:"linear-gradient(135deg, rgba(211,171,84,0.22) 0%, rgba(211,171,84,0.12) 100%)",border:"1px solid rgba(211,171,84,0.6)",borderLeft:"3px solid var(--gold)",boxShadow:"0 8px 28px rgba(211,171,84,0.22)"},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.62rem",color:"var(--gold-a11y)",margin:0},children:"PayPal could not take this monthâs payment"}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.95rem",margin:"6px 0 0",color:"var(--ink)",fontWeight:500},children:["Your ",h?.name??`${u.usd} a month`," package is unpaid."]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",margin:"6px 0 0",color:"var(--muted)"},children:"Update your payment method in PayPal and they will try again â there is nothing to approve here. PayPal tries three times before pausing the subscription."}),(0,t.jsx)("button",{type:"button",onClick:()=>eL("subscriptions"),style:{...S.chipButton,marginTop:"12px",alignSelf:"start"},children:"See your package"})]});let m=eT[u.packageId],y=j(u.usd,s,d),g=Math.max(0,14-(u.dueSince?(n=u.dueSince,Math.max(0,Math.floor((Date.now()-Date.parse(n))/864e5))):0)),x=e.walletLink?.status==="linked";return(0,t.jsxs)("div",{role:"status",style:{borderRadius:"4px",padding:"clamp(1.1rem, 3vw, 1.5rem)",background:"linear-gradient(135deg, rgba(211,171,84,0.22) 0%, rgba(211,171,84,0.12) 100%)",border:"1px solid rgba(211,171,84,0.6)",borderLeft:"3px solid var(--gold)",boxShadow:"0 8px 28px rgba(211,171,84,0.22)",display:"flex",flexWrap:"wrap",gap:"14px",alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsxs)("div",{style:{minWidth:0,flex:"1 1 320px"},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.62rem",color:"var(--gold-a11y)",margin:0},children:u.pendingPaymentId?"Waiting for your approval":"Your package is due"}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.95rem",margin:"6px 0 0",color:"var(--ink)",fontWeight:500},children:[m?.name??`${u.usd} a month`," â ",(0,S.fmtHeaven)(y)," $HEAVEN for ",u.usd," USDT."]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.84rem",margin:"6px 0 0",color:"var(--muted)"},children:u.pendingPaymentId?"Open Heaven Wallet on your phone and approve it. Nothing is taken until you do â and if you miss it, come back here and ask again.":x?`Press below and your phone will buzz. Nothing is taken until you approve it. ${g<=3?`If it stays unpaid for another ${g} day${1===g?"":"s"} the package pauses itself.`:""}`:"Connect Heaven Wallet further down so this can be paid. Nothing is charged until you approve it on your device."}),o&&(0,t.jsx)("p",{role:"alert",style:{...S.body,fontSize:"0.82rem",color:"#9B3B29",margin:"6px 0 0"},children:o})]}),x&&!u.pendingPaymentId&&(0,t.jsx)("button",{type:"button",className:"btn-primary",disabled:l||c,onClick:()=>{p(!0),Promise.resolve(a()).finally(()=>p(!1))},style:{padding:"12px 26px",fontSize:"0.72rem",opacity:l||c?.6:1},children:l||c?"Sending to your walletâ¦":`Renew for ${u.usd} USDT`}),u.pendingPaymentId&&(0,t.jsx)("span",{style:{...S.chipButton,cursor:"default",borderColor:"rgba(211,171,84,0.5)"},children:"Check your phone"})]})}function ta({app:e,account:n,balance:a}){let r=(0,p.isAppConnected)(n,e),i=(0,p.meterFor)(n,e);return(0,t.jsxs)("article",{className:"glass",style:{borderRadius:"4px",padding:"clamp(1.25rem, 3vw, 1.6rem)",display:"flex",flexDirection:"column",gap:"0.9rem",borderTop:`2px solid ${r?e.accent:"rgba(255,255,255,0.9)"}`},children:[(0,t.jsxs)("header",{style:{display:"flex",gap:"12px",alignItems:"flex-start"},children:[(0,t.jsx)("div",{style:{width:"40px",height:"40px",borderRadius:"3px",flexShrink:0,display:"grid",placeItems:"center",overflow:"hidden",background:"rgba(255,255,255,0.7)",border:`1px solid ${e.accent}44`},children:(0,t.jsx)(H.default,{src:e.logo,alt:"",width:40,height:40,style:{objectFit:"contain",width:"100%",height:"100%"}})}),(0,t.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,t.jsx)("h3",{style:{fontFamily:"var(--font-cormorant)",fontWeight:400,fontSize:"1.25rem",color:"var(--ink)",margin:0,lineHeight:1.15},children:e.name}),(0,t.jsx)("p",{style:{...S.label,fontSize:"0.56rem",margin:"4px 0 0"},children:"Pay as you go"})]}),(0,t.jsx)("span",{style:{...S.label,fontSize:"0.56rem",flexShrink:0,padding:"5px 9px",borderRadius:"2px",background:r?`${e.accent}1A`:"rgba(65,75,87,0.07)",color:r?e.accent:"var(--muted)",border:`1px solid ${r?`${e.accent}44`:"rgba(65,75,87,0.12)"}`},children:r?"Connected":"Not connected"})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("span",{style:{...S.body,fontSize:"1.5rem",fontFamily:"var(--font-cormorant)",color:"var(--ink)",lineHeight:1},children:[(0,S.fmtHeaven)(a),(0,t.jsx)("span",{style:{fontSize:"0.5em",color:"var(--muted)",marginLeft:"6px",letterSpacing:"0.08em"},children:"available"})]}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.8rem",color:"var(--muted)",margin:"7px 0 0"},children:"No monthly allowance â charges come straight from your $HEAVEN balance, so this app can spend whatever you hold."})]}),(0,t.jsxs)("div",{style:{padding:"10px 12px",borderRadius:"3px",background:"rgba(255,255,255,0.45)",border:"1px solid rgba(255,255,255,0.7)"},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.56rem",margin:0},children:"Meters"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.8rem",color:"var(--ink)",margin:"3px 0 0"},children:e.meters})]}),(0,t.jsx)("div",{style:{marginTop:"auto",display:"flex",flexWrap:"wrap",gap:"4px 16px"},children:i.reported?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tr,{k:"Spent so far",v:`${(0,S.fmtHeaven)(i.energy)} $HEAVEN`}),i.lastAt&&(0,t.jsx)(tr,{k:"Last charge",v:(0,S.fmtDateTime)(i.lastAt)}
1)]}):(0,t.jsx)(tr,{k:"Spent so far",v:"Nothing yet"})}),!r&&(0,t.jsx)("p",{style:{...S.body,fontSize:"0.74rem",color:"var(--muted)",margin:0},children:"luna-heaven"===e.linkedVia?"Connect Luna Heaven and this comes with it â nothing is being metered yet.":"Not connected â nothing is being metered."})]})}function tr({k:e,v:n}){return(0,t.jsxs)("span",{style:{display:"flex",gap:"6px",alignItems:"baseline"},children:[(0,t.jsx)("span",{style:{...S.label,fontSize:"0.56rem"},children:e}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.82rem",color:"var(--ink)",fontWeight:600},children:n})]})}let ti=[{id:"whatsapp",name:"WhatsApp",href:(e,t)=>`https://wa.me/?text=${encodeURIComponent(`${t} ${e}`)}`},{id:"social",name:"X",href:(e,t)=>`https://x.com/intent/post?text=${encodeURIComponent(t)}&url=${encodeURIComponent(e)}`}],tl="I use the Heaven AI systems â health, coding and Luna CEO. Join the newsletter here:";function to(){let{refreshAccount:e}=(0,i.useAccount)(),[n,a]=(0,r.useState)(null),[l,o]=(0,r.useState)(null),[s,d]=(0,r.useState)(!1),[c,p]=(0,r.useState)(!1),[h,m]=(0,r.useState)("idle"),[y,g]=(0,r.useState)(null),x=(0,r.useCallback)(()=>(0,u.sessionGet)("/v1/referrals/summary"),[]);(0,r.useEffect)(()=>{let e=!0;return(async()=>{try{let t=await x();if(!e)return;a(t),o(null)}catch(t){if(!e)return;o(t instanceof u.SessionCallError&&t.status<500?t.message:"Your referral link could not be loaded just now.")}})(),()=>{e=!1}},[x]);let f=async e=>{let t=`${tl} 2 3${e}`,n=!1;try{await navigator.clipboard.writeText(t),n=!0}catch{}m(n?"copied":"attempted"),window.setTimeout(()=>m("idle"),6e3);try{window.location.href=`mailto:?subject=${encodeURIComponent("Heaven Eco Hub")}&body=${encodeURIComponent(`${tl} 4 5${e}`)}`}catch{}},b=async e=>{try{await navigator.clipboard.writeText(e),p(!0),window.setTimeout(()=>p(!1),2200)}catch{o("Your browser would not let us copy. Select the link and copy it by hand.")}},v=async()=>{let t;d(!0),o(null),g(null);try{t=await (0,u.sessionCall)("/v1/referrals/claim",{})}catch(e){o(e instanceof u.SessionCallError?e.message:"That did not go through. Nothing was claimed â try again."),d(!1);return}g(t.energy??0);try{let[n,r]=await Promise.all([e(),x()]);a(r),n||"number"!=typeof t.balance||o("Claimed. Your balance is still catching up â reload in a moment.")}catch{o("Claimed. We could not refresh the page â reload to see the new balance.")}finally{d(!1)}};if(!n&&!l)return null;let w=n?.url??null,j=n?.code??null;return(0,t.jsxs)("article",{className:"glass-premium",style:{borderRadius:"4px",padding:"clamp(1.4rem, 3.5vw, 2rem)",display:"grid",gap:"1.35rem",borderTop:"2px solid var(--gold)"},children:[(0,t.jsxs)("header",{children:[(0,t.jsx)("p",{style:S.eyebrow,children:"Refer to earn"}),(0,t.jsx)("h2",{style:{...S.sectionTitle,fontSize:"clamp(1.4rem, 3.2vw, 1.9rem)",margin:"5px 0 0"},children:"Invite a friend, earn energy"}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.9rem",color:"var(--muted)",margin:"8px 0 0",maxWidth:"60ch"},children:["Share your link. When someone you invite joins and becomes a paying member, ",n?(0,S.fmtHeaven)(n.rewardEnergy):"â"," energy is yours â spendable across Heaven Health, Heaven Code Studio and Luna CEO, exactly like energy you have bought."]})]}),l&&(0,t.jsx)("p",{style:{...S.body,fontSize:"0.85rem",color:"#C2543F",margin:0},children:l}),n&&(0,t.jsxs)(t.Fragment,{children:[w&&j?(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{style:{...S.label,margin:"0 0 7px"},children:"Your link"}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px",flexWrap:"wrap",alignItems:"center"},children:[(0,t.jsx)("code",{style:{flex:"1 1 280px",minWidth:0,padding:"11px 13px",borderRadius:"3px",background:"rgba(255,255,255,0.6)",border:"1px solid rgba(65,75,87,0.14)",fontFamily:"var(--font-nunito)",fontSize:"0.82rem",color:"var(--ink)",overflowX:"auto",whiteSpace:"nowrap"},children:w}),(0,t.jsx)("button",{type:"button",onClick:()=>void b(w),style:S.chipButton,children:c?"Copied":"Copy"})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"9px",flexWrap:"wrap",marginTop:"11px",alignItems:"center"},children:[ti.map(e=>(0,t.jsx)("a",{href:e.href(`${w}&c=${e.id}`,tl),target:"_blank",rel:"noopener noreferrer",style:{...S.chipButton,textDecoration:"none",display:"inline-block"},children:e.name},e.id)),(0,t.jsx)("button",{type:"button",onClick:()=>void f(`${w}&c=email`),style:S.chipButton,children:"idle"===h?"Email":"Copied"})]}),"idle"!==h&&(0,t.jsx)("p",{role:"status",style:{...S.body,fontSize:"0.78rem",color:"var(--muted)",margin:"8px 0 0",maxWidth:"56ch"},children:"copied"===h?"Invite copied. Your email app should be opening â if it does not, just paste.":"Opening your email app. If nothing happens, use Copy above and paste the link."})]}):(0,t.jsx)("p",{style:{...S.body,fontSize:"0.88rem",color:"var(--muted)",margin:0,maxWidth:"56ch"},children:"Confirm your email address and your referral link appears here. Check your inbox for the link we sent when you signed up."}),(0,t.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"10px"},children:[{k:"Confirmed invites",v:String(n.confirmed)},{k:"Energy earned",v:(0,S.fmtHeaven)(n.earnedEnergy)},{k:"Ready to claim",v:(0,S.fmtHeaven)(n.claimableEnergy)}].map(e=>(0,t.jsxs)("div",{style:{padding:"12px 14px",borderRadius:"3px",background:"rgba(255,255,255,0.45)",border:"1px solid rgba(255,255,255,0.7)"},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.56rem",margin:0},children:e.k}),(0,t.jsx)("p",{style:{fontFamily:"var(--font-cormorant)",fontSize:"1.55rem",color:"var(--ink)",margin:"3px 0 0",lineHeight:1},children:e.v})]},e.k))}),(0,t.jsxs)("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap",alignItems:"center"},children:[(0,t.jsx)("button",{type:"button",className:"btn-primary",onClick:()=>void v(),disabled:s||!n.verified||n.claimableEnergy<=0,style:{opacity:s||!n.verified||n.claimableEnergy<=0?.5:1},children:s?"Claimingâ¦":n.claimableEnergy>0?`Claim ${(0,S.fmtHeaven)(n.claimableEnergy)}${n.more?"+":""} energy`:"Nothing to claim yet"}),n.verified?n.claimableEnergy<=0?(0,t.jsx)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)",margin:0,maxWidth:"44ch"},children:"Rewards land here when a friend you invited becomes a paying member â not when they click, and not when they sign up."}):null:(0,t.jsx)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)",margin:0,maxWidth:"44ch"},children:"Confirm your email address first â check your inbox. Anything you earn keeps until you do."})]}),(0,t.jsxs)("div",{role:"status","aria-live":"polite",style:{display:"grid",gap:"6px"},children:[null!==y&&y>0&&(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.85rem",color:"var(--gold-a11y)",margin:0},children:[(0,S.fmtHeaven)(y)," energy added to your balance.",n.more&&" There is more waiting â claim again."]}),0===y&&(0,t.jsx)("p",{style:{...S.body,fontSize:"0.85rem",color:"var(--muted)",margin:0},children:"Nothing was outstanding â those rewards had already been added, or did not qualify. Your balance is unchanged."})]}),n.awaitingCount>0&&(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)",margin:0,maxWidth:"60ch"}
5,children:[1===n.awaitingCount?"One invite has been confirmed and is waiting":`${n.awaitingCount} invites have been confirmed and are waiting`," for your friend to become a paying member. Nothing is needed from you."]}),n.heldCount>0&&(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.82rem",color:"var(--muted)",margin:0,maxWidth:"60ch"},children:[1===n.heldCount?"One referral is":`${n.heldCount} referrals are`," being checked by us. That is routine above a certain rate and nothing is lost â they appear here once they clear."]}),n.recent.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{style:{...S.label,margin:"0 0 8px"},children:"Recent"}),(0,t.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:"6px"},children:n.recent.map((e,n)=>{let a=function(e){switch(e){case"claimed":return{text:"Added to your balance",tone:"var(--muted)"};case"claimable":return{text:"Ready to claim",tone:"var(--gold-a11y)"};case"pending_purchase":return{text:"Waiting on your friend to join",tone:"var(--muted)"};case"clawed_back":return{text:"Reversed",tone:"var(--muted)"};case"pending_review":return{text:"Being checked",tone:"var(--muted)"};case"duplicate":return{text:"Already referred",tone:"var(--muted)"};default:return{text:"Did not qualify",tone:"var(--muted)"}}}(e.state);return(0,t.jsxs)("li",{style:{display:"flex",justifyContent:"space-between",gap:"12px",padding:"9px 12px",borderRadius:"3px",background:"rgba(255,255,255,0.4)",...S.body,fontSize:"0.82rem"},children:[(0,t.jsx)("span",{style:{color:"var(--muted)"},children:(0,S.fmtDate)(e.at)}),(0,t.jsxs)("span",{style:{color:a.tone,textAlign:"right"},children:[a.text,e.energy>0&&(0,t.jsxs)("span",{style:{color:"var(--ink)",marginLeft:"8px"},children:["+",(0,S.fmtHeaven)(e.energy)]})]})]},`${e.at}-${n}`)})})]}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.76rem",color:"var(--muted)",margin:0,maxWidth:"64ch"},children:["This link is tied to ",n.tiedTo??"the confirmed address on this account",". A referral is counted once your friend takes a monthly package or buys at least $60 of energy â not on a signup alone. If you joined the Heaven newsletter with a different address, that link earns separately; tell us and we will put both on this account."]})]})]})}function ts(){let{emailVerified:e,resendVerification:n,refreshVerification:a,signInEmail:l}=(0,i.useAccount)(),[o,s]=(0,r.useState)(!1),[d,c]=(0,r.useState)(0),[p,u]=(0,r.useState)(!1),[h,m]=(0,r.useState)("");if((0,r.useEffect)(()=>{if(d<=0)return;let e=window.setInterval(()=>c(e=>Math.max(0,e-1)),1e3);return()=>window.clearInterval(e)},[d]),(0,r.useEffect)(()=>{if(!1!==e)return;let t=()=>{"visible"===document.visibilityState&&a()};return window.addEventListener("focus",t),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("focus",t),document.removeEventListener("visibilitychange",t)}},[e,a]),!1!==e)return null;async function y(){u(!0),m("");try{await n(),s(!0),c(60)}catch(e){m(e instanceof Error?e.message:"Could not send it. Try again shortly.")}finally{u(!1)}}return(0,t.jsxs)("div",{role:"status",style:{borderRadius:"4px",padding:"clamp(1.1rem, 3vw, 1.5rem)",background:"linear-gradient(135deg, rgba(211,171,84,0.22) 0%, rgba(211,171,84,0.12) 100%)",border:"1px solid rgba(211,171,84,0.6)",borderLeft:"3px solid var(--gold)",boxShadow:"0 8px 28px rgba(211,171,84,0.22)",display:"flex",flexWrap:"wrap",gap:"14px",alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.62rem",color:"var(--gold-a11y)",margin:0},children:"Confirm your email to finish setting up"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.95rem",margin:"6px 0 0",color:"var(--ink)",fontWeight:500},children:o?`A fresh link is on its way to ${l??"your address"}.`:`We sent a link to ${l??"your address"}. Follow it and this disappears.`}),(0,t.jsxs)("p",{style:{...S.body,fontSize:"0.84rem",margin:"6px 0 0",color:"var(--muted)"},children:["Until then you can look around, edit your profile and pair your wallet â but ",(0,t.jsx)("strong",{style:{color:"var(--ink)"},children:"buying energy, starting a plan, connecting an app and claiming referral rewards will not work"}),". Check your spam folder if it has not arrived."]}),h&&(0,t.jsx)("p",{style:{...S.body,fontSize:"0.8rem",color:"#9B3B29",margin:"6px 0 0"},children:h})]}),(0,t.jsxs)("div",{style:{display:"grid",gap:"6px",justifyItems:"end"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>void y(),disabled:p||d>0,style:{...S.chipButton,borderColor:"rgba(211,171,84,0.55)",opacity:p||d>0?.6:1},children:p?"Sendingâ¦":d>0?`Send again in ${d}s`:o?"Send it again":"Resend the link"}),o&&0===d&&(0,t.jsx)("span",{style:{...S.body,fontSize:"0.72rem",color:"var(--muted)",textAlign:"right",maxWidth:"22ch"},children:"Still nothing? Check spam, then try once more."})]})]})}let td=[{title:"Built to be the most secure wallet there is",detail
5:"Secured with our partners at COVR. Your keys stay yours â Heaven Eco Hub never holds them and never can."},{title:"Money you earn across Heaven arrives here",detail:"Connect the wallet once and every Heaven app you earn with â Luna CEO, Heaven Homes, Coda Blocks â can pay you into it, without setting each one up separately."},{title:"A Mastercard to spend it, digital or physical",detail:"Spend what you have earned in over 170 countries, or hold it and save. It behaves like any other card, funded by what you make here."},{title:"Trust funds and multiple accounts",detail:"Keep money for a purpose separate from money for spending â set up a trust fund, or run several accounts side by side."},{title:"Heaven Dreams, to aim at something",detail:"Create a dream inside the wallet, put money behind it, and watch it come closer. Saving with a reason rather than a balance."}];function tc({connected:e}){return(0,t.jsxs)("div",{style:{marginBottom:"clamp(1rem, 2.5vw, 1.4rem)"},children:[(0,t.jsxs)("div",{style:{display:"flex",gap:"14px",alignItems:"flex-start",marginBottom:"1rem"},children:[(0,t.jsx)("span",{"aria-hidden":"true",style:{flexShrink:0,width:"38px",height:"38px",borderRadius:"50%",display:"grid",placeItems:"center",fontFamily:"var(--font-cormorant)",fontSize:"1.3rem",fontWeight:600,color:"var(--ink)",background:e?"linear-gradient(135deg, var(--gold-pale) 0%, var(--gold) 100%)":"rgba(255,255,255,0.7)",border:"1px solid rgba(211,171,84,0.5)",boxShadow:e?"0 4px 16px rgba(211,171,84,0.35)":"none"},children:"1"}),(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsxs)("p",{style:S.eyebrow,children:["Step one",e?" · done":""]}),(0,t.jsx)("h3",{style:{...S.sectionTitle,fontSize:"clamp(1.3rem, 3vw, 1.7rem)",margin:"3px 0 0"},children:"Connect Heaven Wallet"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.9rem",color:"var(--muted)",margin:"6px 0 0",maxWidth:"62ch"},children:"Your financial stability journey starts here â and it is how you receive the money you earn from Heavenâs products, apps and tools."})]})]}),!e&&(0,t.jsxs)("div",{className:"glass-light",style:{borderRadius:"4px",padding:"clamp(1.1rem, 3vw, 1.5rem)",borderLeft:"2px solid var(--gold)"},children:[(0,t.jsx)("p",{style:{...S.label,fontSize:"0.58rem",margin:"0 0 12px"},children:"Why Heaven Wallet"}),(0,t.jsx)("ul",{style:{listStyle:"none",margin:0,padding:0,display:"grid",gap:"13px"},children:td.map(e=>(0,t.jsxs)("li",{style:{display:"flex",gap:"11px",alignItems:"flex-start"},children:[(0,t.jsx)("span",{"aria-hidden":"true",style:{color:"var(--gold-a11y)",lineHeight:1.5,flexShrink:0},children:"â¦"}),(0,t.jsxs)("span",{style:{minWidth:0},children:[(0,t.jsx)("strong",{style:{...S.body,fontSize:"0.9rem",color:"var(--ink)",fontWeight:600,display:"block"},children:e.title}),(0,t.jsx)("span",{style:{...S.body,fontSize:"0.85rem",color:"var(--muted)"},children:e.detail})]})]},e.title))})]})]})}function tp({account:e}){let n=(0,r.useRef)(null),a=(0,r.useRef)(null),{account:l}=(0,i.useAccount)(),o=l??e,s=eR(),d=!!o.energyPackage;(0,r.useEffect)(()=>{let e=n.current?.querySelectorAll("[data-reveal]");if(!e?.length)return;let t=c.gsap.fromTo(e,{y:24,opacity:0},{y:0,opacity:1,duration:.8,stagger:.09,ease:"power3.out",delay:.1});return()=>{t.kill()}},[s]);let u=(0,r.useRef)(!0);(0,r.useEffect)(()=>{if(u.current){u.current=!1;return}a.current?.focus({preventScroll:!0})},[s]);let h=p.APPS.filter(e=>(0,p.isAppConnected)(o,e)).length,m=p.APPS.find(e=>"heaven-wallet"===e.id),y=new Set(p.JOURNEYS.flatMap(e=>e.apps)),g=p.APPS.filter(e=>"heaven-wallet"!==e.id&&!y.has(e.id)),x=[...p.PLANS.map(e=>p.APP_BY_ID[e.appId]).filter(Boolean),...p.PAYG_APPS],f=[...p.JOURNEYS.map(e=>({...e,entries:e.apps.map(e=>p.APP_BY_ID[e]).filter(Boolean)})),...g.length?[{id:"more",name:"Everything else",kicker:"Also available",blurb:"Apps that meter energy against this account.",entries:g}]:[]];return(0,t.jsxs)("div",{ref:n,className:"ha-page",style:{maxWidth:"1240px",margin:"0 auto",padding:"clamp(6rem, 14vw, 8.5rem) clamp(1.25rem, 5vw, 3rem) clamp(4rem, 10vw, 6rem)",display:"grid",gap:"clamp(2.5rem, 6vw, 4rem)",position:"relative",zIndex:2},children:[(0,t.jsxs)("header",{"data-reveal":!0,children:[(0,t.jsxs)("p",{style:S.eyebrow,children:["Welcome back, ",o.profile.name.split(" ")[0]]}),(0,t.jsx)("h1",{style:{fontFamily:"var(--font-cormorant)",fontWeight:300,fontSize:"clamp(2.6rem, 7vw, 4.4rem)",lineHeight:1.02,color:"var(--ink)",margin:"0.5rem 0 0.75rem",textShadow:"0 0 60px rgba(251,240,205,0.9)"},children:"dashboard"===s?"Start your journey":"Your subscriptions"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"1rem",color:"var(--muted)",maxWidth:"58ch"},children:"dashboard"===s?"Connect the Heaven apps you use. Each one reports the energy it spends on your behalf, drawn from your $HEAVEN balance â so you always know exactly where your energy goes.":"What you pay each month, how you pay it, and what it buys. Everything here can be changed or stopped, and it takes effect from your next charge."})]}),(0,t.jsx)(te,{}),(0,t.jsx)(ts,{}),(0,t.jsx)(tn,{account:o}),(0,t.jsx)(e$,{}),(0,t.jsx)(e_,{account:o}),(0,t.jsxs)("div",{className:"ha-shell",children:[(0,t.jsx)(eY,{}),(0,t.jsx)("div",{ref:a,id:"ha-main",tabIndex:-1,"aria-label":"dashboard"===s?"Dashboard":"Subscriptions",style:{display:"grid",gap:"clamp(2.5rem, 6vw, 4rem)",minWidth:0,outline:"none"},children:"dashboard"===s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("section",{"data-reveal":!0,"aria-label":"Balance and energy",children:(0,t.jsx)(E,{account:o})}),(0,t.jsx)("section",{"data-reveal":!0,"aria-label":"Buy $HEAVEN",children:(0,t.jsx)(eB,{})}),(0,t.jsx)("section",{"data-reveal":!0,"aria-label":"Refer a friend",children:(0,t.jsx)(to,{})}),(0,t.jsxs)("section",{"data-reveal":!0,"aria-labelledby":"ha-connect-title",children:[(0,t.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:"14px",flexWrap:"wrap",alignItems:"baseline",marginBottom:"1.35rem"},children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{id:"ha-connect-title",style:S.sectionTitle,children:"Connect your apps"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.9rem",color:"var(--muted)",margin:"5px 0 0",maxWidth:"58ch"},children:"Start with the wallet, then connect whichever apps you use. Each one reports the energy it spends back to you in real time."})]}),(0,t.jsxs)("span",{style:{...S.eyebrow,color:"var(--muted)"},children:[h," of ",p.APPS.length," connected"]})]}),(0,t.jsxs)("div",{id:"ha-wallet",style:{marginBottom:"clamp(1.5rem, 4vw, 2.25rem)",scrollMarginTop:"6rem"},children:[(0,t.jsx)(tc,{connected:(0,p.connectionFor)(o,"heaven-wallet").connected||o.walletLink?.status==="linked"}),(0,t.jsx)(eb,{app:m,account:o})]}),(0,t.jsxs)("div",{style:{display:"flex",gap:"14px",alignItems:"flex-start",marginBottom:"1rem"},children:[(0,t.jsx)("span",{"aria-hidden":"true",style:{flexShrink:0,width:"38px",height:"38px",borderRadius:"50%",display:"grid",placeItems:"center",fontFamily:"var(--font-cormorant)",fontSize:"1.3rem",fontWeight:600,color:"var(--ink)",background:"rgba(255,255,255,0.7)",border:"1px solid rgba(211,171,84,0.5)"},children:"2"}),(0,t.jsxs)("div",{style:{minWidth:0},children:[(0,t.jsx)("p",{style:S.eyebrow,children:"Step two"}),(0,t.jsx)("h3",{style:{...S.sectionTitle,fontSize:"clamp(1.3rem, 3vw, 1.7rem)",margin:"3px 0 0"},children:"Choose a journey, connect what runs it"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.9rem",color:"var(--muted)",margin:"6px 0 0",maxWidth:"58ch"},children:"Every app below belongs to something you are trying to do. Connecting one issues an API key that links it to this account, so it can report what it spends and pay you what you earn."})]})]}),(0,t.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"clamp(2rem, 5vw, 3rem)"},children:f.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{style:{marginBottom:"1.1rem",maxWidth:"62ch"},children:[(0,t.jsx)("p",{style:{...S.eyebrow,color:"var(--gold-a11y)"},children:e.kicker}),(0,t.jsx)("h4",{style:{fontFamily:"var(--font-cormorant)",fontWeight:400,fontSize:"clamp(1.35rem, 3vw, 1.85rem)",lineHeight:1.15,color:"var(--ink)",margin:"5px 0 0"},children:e.name}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.88rem",color:"var(--muted)",margin:"7px 0 0"},children:e.blurb})]}),(0,t.jsx)(I,{apps:e.entries,account:o,featuredId:"heaven-code-studio",journeyName:e.n
5ame})]},e.id))})]}),(0,t.jsxs)("section",{"data-reveal":!0,"aria-labelledby":"ha-subs-title",children:[(0,t.jsxs)("div",{style:{marginBottom:"1.35rem"},children:[(0,t.jsx)("h2",{id:"ha-subs-title",style:S.sectionTitle,children:"Where your energy goes"}),(0,t.jsx)("p",{style:{...S.body,fontSize:"0.9rem",color:"var(--muted)",margin:"5px 0 0",maxWidth:"62ch"},children:"Every app charges your $HEAVEN balance directly as it works, so what it can spend is simply what you hold. Each one that spends energy is listed here."})]}),(0,t.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(300px, 100%), 1fr))",gap:"clamp(1rem, 2.5vw, 1.5rem)"},children:x.map(e=>(0,t.jsx)(ta,{app:e,account:o,balance:o.balance},e.id))})]}),(0,t.jsx)("section",{"data-reveal":!0,"aria-label":"Receipts",children:(0,t.jsx)(eC,{account:o})}),(0,t.jsxs)("section",{"data-reveal":!0,"aria-label":"Profile and energy ledger",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(320px, 100%), 1fr))",gap:"clamp(1rem, 2.5vw, 1.5rem)",alignItems:"start"},children:[(0,t.jsx)(ej,{account:o}),(0,t.jsx)(ew,{account:o}),(0,t.jsx)(eE,{})]}),!d&&(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("section",{"data-reveal":!0,"aria-label":"Monthly energy package",children:(0,t.jsx)(eM,{account:o})})})]}):(0,t.jsx)("section",{"data-reveal":!0,"aria-label":"Monthly energy package",children:(0,t.jsx)(eM,{account:o})})})]})]})}let tu=(0,n.default)(()=>e.A(97097),{loadableGenerated:{modules:[71358]},ssr:!1}),th=(0,n.default)(()=>e.A(93196),{loadableGenerated:{modules:[72363]},ssr:!1});function tm(){let{account:e,signOut:n}=(0,i.useAccount)();return(0,t.jsx)("header",{style:{position:"fixed",top:0,left:0,right:0,zIndex:1e3,padding:"14px clamp(1rem, 4vw, 40px)",background:"rgba(255,255,255,0.72)",backdropFilter:"blur(24px) saturate(180%)",WebkitBackdropFilter:"blur(24px) saturate(180%)",borderBottom:"1px solid rgba(211,171,84,0.25)",boxShadow:"0 1px 0 rgba(255,255,255,0.6), 0 8px 40px rgba(100,130,160,0.18)"},children:(0,t.jsxs)("div",{style:{maxWidth:"1240px",margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"16px"},children:[(0,t.jsxs)(a.default,{href:"/",style:{display:"flex",alignItems:"center",gap:"10px",textDecoration:"none",cursor:"none"},children:[(0,t.jsx)(s.default,{size:26,style:{opacity:.9,flexShrink:0}}),(0,t.jsxs)("span",{style:{display:"flex",flexDirection:"column",lineHeight:1},children:[(0,t.jsx)("span",{style:{fontFamily:"var(--font-nunito)",fontSize:"1.15rem",fontWeight:700,letterSpacing:"0.28em",color:"var(--white)"},children:"heaven"}),(0,t.jsx)("span",{style:{...S.label,fontSize:"0.5rem",color:"var(--gold)",letterSpacing:"0.3em",marginTop:"3px"},children:"client area"})]})]}),(0,t.jsxs)("nav",{style:{display:"flex",alignItems:"center",gap:"clamp(10px, 2vw, 22px)"},children:[(0,t.jsx)(a.default,{href:"/",style:{...S.body,fontSize:"0.74rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--muted)",textDecoration:"none",cursor:"none"},children:"Main site"}),e&&(0,t.jsx)("button",{type:"button",onClick:n,style:{...S.body,fontSize:"0.74rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--muted)",background:"none",border:"none",cursor:"none"},children:"Sign out"})]})]})})}function ty(){let{account:e,ready:n}=(0,i.useAccount)();return n?e?(0,t.jsx)(tp,{account:e}):(0,t.jsx)(d.default,{}):(0,t.jsx)("div",{style:{minHeight:"100vh",display:"grid",placeItems:"center",position:"relative",zIndex:2},children:(0,t.jsx)("p",{style:{...S.label,color:"var(--muted)"},children:"Opening your accountâ¦"})})}function tg(){return"device"!==l.backendKind?null:(0,t.jsx)("p",{style:{...S.body,position:"relative",zIndex:2,fontSize:"0.72rem",color:"var(--muted)",textAlign:"center",maxWidth:"52ch",margin:"0 auto",padding:"0 1.25rem clamp(2rem, 6vw, 3.5rem)"},children:"This account is stored on this device only. Sign in from another browser and you will start a new one."})}e.s(["default",0,function(){return(0,r.useEffect)(()=>{!function(){let{hostname:e,pathname:t,search:n,hash:a}=window.location;o.includes(e)&&window.location.replace(`https://www.heavenecohub.com${t}${n}${a}`)}()},[]),(0,t.jsxs)(i.AccountProvider,{children:[(0,t.jsx)(tu,{}),(0,t.jsx)(th,{}),(0,t.jsx)(tm,{}),(0,t.jsx)("main",{"aria-label":"Heaven Eco Hub client area",children:(0,t.jsx)(ty,{})}),(0,t.jsx)(tg,{})]})}],97955)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.