1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4712],{31248:function(e,t,a){Promise.resolve().then(a.bind(a,51780))},51780:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return N}});var s=a(57437),r=a(2265),n=a(99376),l=a(27323),i=a(52618),c=a(93662),d=a(53882),o=a(66352),u=a(52652),m=a(22422),x=a(39502),b=a(13169),p=a(44659),h=a(57303),g=a(27648),f=a(53803),y=a(65929);let v="cmo0nwype001s0clhpc5pnkwt";function N(){let e=(0,n.useParams)(),t=(0,n.useSearchParams)(),a=e.username,i=(()=>{let e=t.get("tab");return"subscribe"===e||"content"===e||"api"===e||"tip"===e?e:"tip"})(),[c,d]=(0,r.useState)(i),{data:o}=(0,l.u)({address:f.M2.registry,abi:f.DY,functionName:"exists",args:[a]}),{data:u}=(0,l.u)({address:f.M2.registry,abi:f.DY,functionName:"getCreator",args:[a],query:{enabled:!!o}}),{data:m}=(0,l.u)({address:f.M2.tipJar,abi:f.ph,functionName:"getLifetimeReceived",args:[a],query:{enabled:!!o,refetchInterval:5e3}});if(!1===o)return(0,s.jsx)(M,{username:a});let b=(null==u?void 0:u.displayName)||a,p="";try{var h;if(null==u?void 0:null===(h=u.metadataURI)||void 0===h?void 0:h.startsWith("data:application/json,")){let e=decodeURIComponent(u.metadataURI.slice(22));p=JSON.parse(e).bio||""}}catch(e){}return(0,s.jsxs)("div",{className:"min-h-screen bg-paper",children:[(0,s.jsxs)("header",{className:"max-w-2xl mx-auto px-6 py-4 flex justify-between items-center gap-2",children:[(0,s.jsxs)(g.default,{href:"/",className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-6 h-6 rounded bg-accent"}),(0,s.jsx)("span",{className:"font-bold",children:"ArcPay"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(g.default,{href:"/faucet",className:"hidden sm:inline text-xs px-3 py-1.5 rounded-lg border border-gray-200 hover:border-accent transition",title:"Get free testnet USDC",children:"\uD83D\uDCA7 Faucet"}),(0,s.jsx)(w,{})]})]}),(0,s.jsxs)("main",{className:"max-w-lg mx-auto px-6 pt-6 pb-20",children:[(0,s.jsxs)("div",{className:"bg-white rounded-3xl shadow-xl border border-gray-100 overflow-hidden",children:[(0,s.jsx)("div",{className:"h-24 bg-accent"}),(0,s.jsxs)("div",{className:"px-6 pb-6 -mt-10",children:[(0,s.jsx)("div",{className:"w-20 h-20 rounded-full bg-white border-4 border-white shadow-lg flex items-center justify-center text-3xl font-bold text-accent",children:b.charAt(0).toUpperCase()}),(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold",children:b}),(0,s.jsxs)("div",{className:"text-gray-500 font-mono text-sm",children:["@",a]}),p&&(0,s.jsx)("p",{className:"mt-3 text-gray-700",children:p}),void 0!==m&&m>0n&&(0,s.jsxs)("div",{className:"mt-3 text-xs text-gray-500",children:["\uD83D\uDCB8 Lifetime tips: ",Number((0,x.b)(m,18)).toFixed(4)," USDC"]})]})]}),(0,s.jsxs)("div",{className:"border-t border-gray-100",children:[(0,s.jsx)("div",{className:"grid grid-cols-4 border-b border-gray-100",children:["tip","subscribe","content","api"].map(e=>(0,s.jsx)("button",{onClick:()=>d(e),className:"py-3 text-sm font-semibold ".concat(c===e?"text-accent border-b-2 border-accent":"text-gray-500"),children:"tip"===e?"\uD83D\uDCB8 Tip":"subscribe"===e?"\uD83D\uDCC5 Subscribe":"content"===e?"\uD83D\uDD12 Content":"â¡ API"},e))}),(0,s.jsxs)("div",{className:"p-6",children:["tip"===c&&(0,s.jsx)(S,{username:a}),"subscribe"===c&&(0,s.jsx)(D,{username:a}),"content"===c&&(0,s.jsx)(P,{username:a}),"api"===c&&(0,s.jsx)(I,{username:a})]})]})]}),(0,s.jsxs)("div",{className:"text-center mt-6 text-xs text-gray-400",children:["Powered by ",(0,s.jsx)(g.default,{href:"/",className:"font-semibold hover:text-gray-700",children:"ArcPay"})," on Arc Network \xb7 USDC native"]})]})]})}function j(e){let{address:t}=e,{data:a}=(0,i.K)({address:t}),[n,l]=(0,r.useState)(!1),c="".concat(t.slice(0,6),"...").concat(t.slice(-4));return(0,s.jsxs)("button",{onClick:()=>{navigator.clipboard.writeText(t),l(!0),setTimeout(()=>l(!1),1500)},className:"flex items-center gap-2 px-3 py-1.5 rounded-lg bg-white border border-gray-200 hover:border-accent transition",title:"Click to copy full address",children:[(0,s.jsx)("span",{className:"text-xs font-mono text-gray-700",children:n?"â Copied!":c}),a&&(0,s.jsxs)("span",{className:"text-xs font-semibold text-accent",children:[Number((0,x.b)(a.value,18)).toFixed(3)," USDC"]})]})}function w(){var e,t,a,r,n,l,i;let{ready:c,authenticated:d,user:o,login:x,logout:b}=(0,u.u)(),{wallets:p}=(0,m.u)(),h=p[0];if(!c)return(0,s.jsx)("button",{className:"px-3 py-1.5 rounded-lg bg-gray-100 text-sm",children:"Loading..."});if(!d)return(0,s.jsx)("button",{onClick:()=>x(),className:"px-4 py-2 rounded-xl bg-accent text-white text-sm font-semibold",children:"Sign in to pay"});let g=o?(null===(e=o.twitter)||void 0===e?void 0:e.username)?{source:"twitter",label:"@".concat(o.twitter.username),avatar:o.twitter.profilePictureUrl}:(null===(t=o.google)||void 0===t?void 0:t.email)?{source:"google",label:o.google.name||o.google.email}:(null===(a=o.discord)||void 0===a?void 0:a.username)?{source:"discord",label:o.discord.username}:(null===(r=o.farcaster)||void 0===r?void 0:r.username)?{source:"farcaster",label:"@".concat(o.farcaster.username),avatar:o.farcaster.pfp}:(null===(n=o.github)||void 0===n?void 0:n.username)?{source:"github",label:o.github.username}:(null===(l=o.apple)||void 0===l?void 0:l.email)?{source:"apple",label:o.apple.email}:(null===(i=o.email)||void 0===i?void 0:i.address)?{source:"email",label:o.email.address}:null:null;return(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[g&&(0,s.jsx)(C,{ident:g}),h&&(0,s.jsx)(j,{address:h.address}),(0,s.jsx)("button",{onClick:()=>b(),className:"px-2 py-1 rounded-md border border-gray-200 text-xs hover:bg-gray-50",children:"Sign out"})]})}function C(e){let{ident:t}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-lg bg-white border border-gray-200 max-w-[180px]",children:[t.avatar?(0,s.jsx)("img",{src:t.avatar,alt:"",className:"w-5 h-5 rounded-full object-cover"}):(0,s.jsx)("div",{className:"w-5 h-5 rounded-full bg-accent text-white flex items-center justify-center text-[10px] font-bold",children:{twitter:"\uD835\uDD4F",google:"G",discord:"\uD83D\uDCAC",farcaster:"á¶ ",github:"â¨",apple:"",email:"â"}[t.source]||""}),(0,s.jsx)("span",{className:"text-xs font-medium truncate",title:t.label,children:t.label})]})}function S(e){let{username:t}=e,{address:a}=(0,c.m)(),n=(0,d.t)(),{data:l}=(0,o.p)(),[i,u]=(0,r.useState)("0.005"),[m,g]=(0,r.useState)(""),[v,N]=(0,r.useState)(!1),[j,w]=(0,r.useState)(null),[C,S]=(0,r.useState)(""),[D,P]=(0,r.useState)(null),[I,M]=(0,r.useState)([]);(0,r.useEffect)(()=>{n&&(async()=>{try{let[e,a]=await Promise.all([n.readContract({address:f.M2.tipJar,abi:f.ph,functionName:"getTipsByCreator",args:[t]}),n.readContract({address:f.M2.tipJar,abi:f.ph,functionName:"protocolFeeBps",args:[]})]),s=[...e].slice(-10).reverse(),r=await Promise.all(s.map(async e=>{try{let t=await n.readContract({address:f.M2.tipJar,abi:f.ph,functionName:"getTip",args:[e]}),s=t.amount;return{id:e.toString(),from:t.from,amount:a<10000n?10000n*s/(10000n-a):s,message:t.message,timestamp:Number(t.timestamp)}}catch(e){return null}}));M(r.filter(e=>null!==e))}catch(e){}})()},[n,t,j]),(0,r.useEffect)(()=>
1{if(!n||!a){P(null);return}(async()=>{try{let e=(0,b.w)((0,p.qX)(t)),[s,r]=await Promise.all([n.readContract({address:f.M2.tipJar,abi:f.ph,functionName:"getTipsByFan",args:[a]}),n.readContract({address:f.M2.tipJar,abi:f.ph,functionName:"protocolFeeBps",args:[]})]),l=0,i=0n;await Promise.all(s.map(async t=>{try{let a=await n.readContract({address:f.M2.tipJar,abi:f.ph,functionName:"getTip",args:[t]});a.usernameHash===e&&(l++,i+=a.amount)}catch(e){}}));let c=r<10000n?10000n*i/(10000n-r):i;P({count:l,total:c})}catch(e){}})()},[n,a,t,j]);let k=async()=>{if(l&&a&&n){N(!0),S(""),w(null);try{let e=await l.writeContract({address:f.M2.tipJar,abi:f.ph,functionName:"tip",args:[t,m],value:(0,h.v)(i,18),gas:300000n});await n.waitForTransactionReceipt({hash:e}),w(e),g("")}catch(e){S(e.shortMessage||e.message)}finally{N(!1)}}};return(0,s.jsxs)("div",{children:[D&&D.count>0&&(0,s.jsxs)("div",{className:"mb-3 p-3 rounded-xl bg-red-50 border border-red-200 text-sm text-red-800",children:["\uD83D\uDCB8 You've tipped @",t," ",(0,s.jsx)("strong",{children:D.count})," time",1!==D.count?"s":""," \xb7 ",(0,s.jsxs)("strong",{children:[Number((0,x.b)(D.total,18)).toFixed(4)," USDC"]})]}),I.length>0&&(0,s.jsxs)("div",{className:"mb-4 border border-gray-100 rounded-xl bg-gray-50/60 p-3",children:[(0,s.jsxs)("div",{className:"text-[11px] text-gray-500 font-semibold uppercase tracking-wider mb-2 flex items-center gap-1",children:["\uD83C\uDF89 Recent supporters \xb7 ",I.length]}),(0,s.jsx)("div",{className:"space-y-1.5 max-h-44 overflow-y-auto pr-1",children:I.map(e=>{let t="".concat(e.from.slice(0,6),"...").concat(e.from.slice(-4)),a=e.from.slice(2,4),r=137*parseInt(a,16)%360;return(0,s.jsxs)("div",{className:"flex items-start gap-2 text-xs",children:[(0,s.jsx)("div",{className:"w-6 h-6 rounded-full flex items-center justify-center text-white font-bold text-[10px] shrink-0",style:{background:"linear-gradient(135deg, hsl(".concat(r,",70%,55%), hsl(").concat((r+60)%360,",70%,60%))")},children:a.toUpperCase()}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-baseline gap-1.5 flex-wrap",children:[(0,s.jsx)("span",{className:"font-mono text-gray-600",children:t}),(0,s.jsxs)("span",{className:"font-bold text-accent",children:[Number((0,x.b)(e.amount,18)).toFixed(4)," USDC"]}),e.timestamp>0&&(0,s.jsxs)("span",{className:"text-gray-400 text-[10px]",children:["\xb7 ",function(e){if(!e)return"";let t=Math.floor(Date.now()/1e3-e);return t<60?"".concat(t,"s ago"):t<3600?"".concat(Math.floor(t/60),"m ago"):t<86400?"".concat(Math.floor(t/3600),"h ago"):"".concat(Math.floor(t/86400),"d ago")}(e.timestamp)]})]}),e.message&&(0,s.jsxs)("div",{className:"text-gray-700 italic mt-0.5 truncate",title:e.message,children:['"',e.message,'"']})]})]},e.id)})})]}),(0,s.jsxs)("div",{className:"text-sm text-gray-600 mb-3",children:["Support @",t," with a USDC tip"]}),(0,s.jsx)("div",{className:"grid grid-cols-4 gap-2 mb-3",children:["0.001","0.005","0.01","0.05"].map(e=>(0,s.jsxs)("button",{onClick:()=>u(e),className:"py-2 rounded-xl text-sm font-semibold border-2 transition\n ".concat(i===e?"border-accent bg-accent/10 text-accent":"border-gray-200"),children:["$",e]},e))}),(0,s.jsx)("input",{value:i,onChange:e=>u(e.target.value.replace(/[^0-9.]/g,"")),className:"w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-accent focus:outline-none mb-3",placeholder:"Custom amount",inputMode:"decimal"}),(0,s.jsx)("textarea",{value:m,onChange:e=>g(e.target.value.slice(0,280)),className:"w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-accent focus:outline-none resize-none h-20 mb-3",placeholder:"Message (optional)"}),a?(0,s.jsx)("button",{onClick:k,disabled:v||!i,className:"w-full py-3 rounded-xl font-bold text-white bg-accent disabled:opacity-60",children:v?"Sending...":"Send $".concat(i," tip")}):(0,s.jsx)("div",{className:"text-center py-3 text-gray-500 text-sm bg-gray-50 rounded-xl",children:"Connect wallet to send tip"}),j&&(0,s.jsxs)("div",{className:"mt-3 text-green-600 text-sm bg-green-50 p-3 rounded-xl text-center",children:["â Tip sent! ",(0,s.jsx)(y.P,{tx:j})]}),C&&(0,s.jsx)("div",{className:"mt-3 text-red-500 text-sm bg-red-50 p-2 rounded-xl",children:C})]})}function D(e){let{username:t}=e,{address:a}=(0,c.m)(),n=(0,d.t)(),{data:l}=(0,o.p)(),[i,u]=(0,r.useState)([]),[m,h]=(0,r.useState)(!0),[g,y]=(0,r.useState)(1),[v,N]=(0,r.useState)(null),[j,w]=(0,r.useState)(!1),[C,S]=(0,r.useState)(null),[D,P]=(0,r.useState)(""),[I,M]=(0,r.useState)(null),[k,B]=(0,r.useState)("");(0,r.useEffect)(()=>{n&&(async()=>{h(!0);let e=[],s=(0,b.w)((0,p.qX)(t));for(let t=0;t<20;t++)try{let a=await n.readContract({address:f.M2.subscriptions,abi:f.e3,functionName:"getPlan",args:[BigInt(t)]});a.creatorHash===s&&e.push({id:t,name:a.name,price:a.pricePerMonth,active:a.active})}catch(e){break}if(u(e),h(!1),e[0]&&N(e[0].id),a){for(let t of e)try{let e=await n.readContract({address:f.M2.subscriptions,abi:f.e3,functionName:"activeSubOf",args:[a,BigInt(t.id)]});if(e>0n){let a=await n.readContract({address:f.M2.subscriptions,abi:f.e3,functionName:"getSubscription",args:[e-1n]}),s=Number(a.paidUntil),r=Number(a.startedAt);if(a.active&&1e3*s>Date.now()){M({planId:t.id,planName:t.name,paidUntil:s,subId:e-1n,startedAt:r});return}}}catch(e){}M(null)}})()},[n,t,a,C]);let T=async()=>
1{if(!l||!a||!n||null===v)return;let e=i.find(e=>e.id===v);if(e){w(!0),P(""),S(null);try{let t=e.price*BigInt(g),a=await l.writeContract({address:f.M2.subscriptions,abi:f.e3,functionName:"subscribe",args:[BigInt(v),BigInt(g)],value:t,gas:400000n});await n.waitForTransactionReceipt({hash:a}),S(a)}catch(a){var t,s,r,c,d;let e=(null==a?void 0:null===(s=a.cause)||void 0===s?void 0:null===(t=s.data)||void 0===t?void 0:t.errorName)||(null==a?void 0:null===(d=a.cause)||void 0===d?void 0:null===(c=d.cause)||void 0===c?void 0:null===(r=c.data)||void 0===r?void 0:r.errorName);"AlreadySubscribed"===e?P("You already have an active subscription to this plan. Cancel above first to re-subscribe."):"PlanInactive"===e?P("This plan is no longer active."):"WrongPayment"===e?P("Payment amount mismatch. Please refresh and try again."):P(a.shortMessage||a.message)}finally{w(!1)}}},U=async()=>{if(l&&n&&I&&confirm('Cancel subscription to "'.concat(I.planName,'"?\n\n')+"You'll get a prorated refund for the unused portion (contract computes this automatically). You can re-subscribe anytime.")){w(!0),P(""),S(null);try{let e=await l.writeContract({address:f.M2.subscriptions,abi:f.e3,functionName:"cancel",args:[I.subId],gas:300000n});await n.waitForTransactionReceipt({hash:e}),S(e),M(null)}catch(e){P(e.shortMessage||e.message)}finally{w(!1)}}},A=async()=>{if(!l||!a||!n||!I||null===v)return;let e=i.find(e=>e.id===v);if(e&&v===I.planId&&confirm('Extend "'.concat(I.planName,'" by ').concat(g," month").concat(g>1?"s":"","?\n\n")+"Step 1: cancel current subscription (you'll receive a prorated refund for the unused portion).\n"+"Step 2: start a new ".concat(g,"-month subscription.\n\n")+"This requires 2 wallet signatures.")){w(!0),P(""),S(null);try{B("Step 1 of 2 â cancelling current subscriptionâ¦");let t=await l.writeContract({address:f.M2.subscriptions,abi:f.e3,functionName:"cancel",args:[I.subId],gas:300000n});await n.waitForTransactionReceipt({hash:t}),M(null),B("Step 2 of 2 â starting new subscriptionâ¦");let a=e.price*BigInt(g),s=await l.writeContract({address:f.M2.subscriptions,abi:f.e3,functionName:"subscribe",args:[BigInt(v),BigInt(g)],value:a,gas:400000n});await n.waitForTransactionReceipt({hash:s}),S(s)}catch(e){var t,s,r,c,d;"AlreadySubscribed"===((null==e?void 0:null===(s=e.cause)||void 0===s?void 0:null===(t=s.data)||void 0===t?void 0:t.errorName)||(null==e?void 0:null===(d=e.cause)||void 0===d?void 0:null===(c=d.cause)||void 0===c?void 0:null===(r=c.data)||void 0===r?void 0:r.errorName))?P("Cancel step may not have settled yet. Please refresh and retry."):P(e.shortMessage||e.message)}finally{w(!1),B("")}}};return m?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"h-4 w-2/3 rounded bg-gray-100 animate-pulse"}),(0,s.jsxs)("div",{className:"p-4 rounded-xl border border-gray-100 bg-gray-50 space-y-2",children:[(0,s.jsx)("div",{className:"h-4 w-1/2 roun
1ded bg-gray-200 animate-pulse"}),(0,s.jsx)("div",{className:"h-3 w-1/3 rounded bg-gray-200 animate-pulse"})]}),(0,s.jsxs)("div",{className:"p-4 rounded-xl border border-gray-100 bg-gray-50 space-y-2",children:[(0,s.jsx)("div",{className:"h-4 w-1/3 rounded bg-gray-200 animate-pulse"}),(0,s.jsx)("div",{className:"h-3 w-1/4 rounded bg-gray-200 animate-pulse"})]})]}):0===i.length?(0,s.jsxs)("div",{className:"text-center py-10 px-6 border-2 border-dashed border-gray-200 rounded-2xl",children:[(0,s.jsx)("div",{className:"text-4xl mb-2",children:"\uD83D\uDCC5"}),(0,s.jsxs)("div",{className:"font-bold",children:["@",t," hasn't created a subscription plan yet."]}),(0,s.jsx)("div",{className:"text-sm text-gray-500 mt-1",children:"Tips and content may still be available in the other tabs."})]}):(0,s.jsxs)("div",{children:[I&&(0,s.jsxs)("div",{className:"mb-3 p-3 rounded-xl bg-blue-50 border border-blue-200 text-sm text-blue-800 flex items-center justify-between gap-3 flex-wrap",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:["â Active subscription: ",(0,s.jsx)("strong",{children:I.planName})," \xb7 valid until ",(0,s.jsx)("strong",{children:new Date(1e3*I.paidUntil).toLocaleDateString()})]}),(0,s.jsx)("button",{onClick:U,disabled:j,className:"shrink-0 px-2.5 py-1 rounded-lg border border-blue-300 hover:bg-blue-100 text-[11px] font-bold disabled:opacity-60",title:"Cancel and refund the unused portion",children:"Cancel & refund"})]}),(0,s.jsxs)("div",{className:"text-sm text-gray-600 mb-3",children:["Subscribe to @",t]}),(0,s.jsx)("div",{className:"space-y-2 mb-4",children:i.filter(e=>e.active).map(e=>(0,s.jsxs)("button",{onClick:()=>N(e.id),className:"w-full p-4 rounded-xl border-2 text-left transition\n ".concat(v===e.id?"border-accent bg-accent/5":"border-gray-200"),children:[(0,s.jsx)("div",{className:"font-bold",children:e.name}),(0,s.jsxs)("div",{className:"text-sm text-gray-600",children:["$",(0,x.b)(e.price,18)," / month"]})]},e.id))}),(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,s.jsx)("label",{className:"text-sm text-gray-600",children:"Duration:"}),[1,3,6,12].map(e=>(0,s.jsxs)("button",{onClick:()=>y(e),className:"px-3 py-1 rounded-full text-sm ".concat(g===e?"bg-accent text-white":"bg-gray-100"),children:[e,"mo"]},e))]}),null!==v&&i.find(e=>e.id===v)&&(0,s.jsxs)("div",{className:"text-sm text-gray-600 mb-3",children:["Total: ",(0,s.jsxs)("span",{className:"font-bold text-black",children:["$",(0,x.b)(i.find(e=>e.id===v).price*BigInt(g),18)," USDC"]})]}),a?I&&I.planId===v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{onClick:A,disabled:j,className:"w-full py-3 rounded-xl font-bold text-white bg-accent disabled:opacity-60",children:j?k||"Extendingâ¦":"Extend by ".concat(g," month").concat(g>1?"s":"")}),(0,s.jsx)("div",{className:"mt-2 text-xs text-gray-500 text-center",children:"Already subscribed \xb7 extending will cancel (prorated refund) and re-subscribe \xb7 2 signatures"})]}):(0,s.jsx)("button",{onClick:T,disabled:j||null===v,className:"w-full py-3 rounded-xl font-bold text-white bg-accent disabled:opacity-60",children:j?"Subscribing...":"Subscribe"}):(0,s.jsx)("div",{className:"text-center py-3 text-gray-500 text-sm bg-gray-50 rounded-xl",children:"Connect wallet to subscribe"}),C&&(0,s.jsx)("div",{className:"mt-3 text-green-600 text-sm bg-green-50 p-3 rounded-xl text-center",children:"â Subscribed!"}),D&&(0,s.jsx)("div",{className:"mt-3 text-red-500 text-sm bg-red-50 p-2 rounded-xl",children:D})]})}function P(e){let{username:t}=e,{address:a}=(0,c.m)(),n=(0,d.t)(),{data:l}=(0,o.p)(),[i,u]=(0,r.useState)([]),[m,b]=(0,r.useState)({}),[p,h]=(0,r.useState)(null),[g,y]=(0,r.useState)("");(0,r.useEffect)(()=>{n&&(async()=>{try{let e=await n.readContract({address:f.M2.contentPaywall,abi:f.HE,functionName:"getCreatorContents",args:[t]}),s=[];for(let t of e){let e=await n.readContract({address:f.M2.contentPaywall,abi:f.HE,functionName:"getContent",args:[t]});s.push({id:t,...e})}if(u(s),a){let e=await Promise.all(s.map(async e=>{try{let t=await n.readContract({address:f.M2.contentPaywall,abi:f.HE,functionName:"
1checkAccess",args:[e.id,a]});return[e.id,!!t]}catch(t){return[e.id,!1]}}));b(Object.fromEntries(e))}}catch(e){}})()},[n,t,a,p]);let v=async(e,t)=>{if(l&&n){h(e),y("");try{let a=await l.writeContract({address:f.M2.contentPaywall,abi:f.HE,functionName:"purchase",args:[e],value:t,gas:300000n});await n.waitForTransactionReceipt({hash:a}),b(t=>({...t,[e]:!0}))}catch(e){y(e.shortMessage||e.message)}finally{h(null)}}};if(0===i.length)return(0,s.jsx)("div",{className:"text-center py-8 text-gray-500 text-sm",children:"No paywalled content yet."});let N=i.filter(e=>e.active),j=N.filter(e=>m[e.id]).length;return(0,s.jsxs)("div",{children:[a&&j>0&&(0,s.jsxs)("div",{className:"mb-3 p-3 rounded-xl bg-purple-50 border border-purple-200 text-sm text-purple-800",children:["\uD83D\uDD13 You've unlocked ",(0,s.jsx)("strong",{children:j})," of ",(0,s.jsx)("strong",{children:N.length})," item",1!==N.length?"s":""," from @",t]}),(0,s.jsxs)("div",{className:"text-sm text-gray-600 mb-3",children:["Premium content from @",t]}),(0,s.jsx)("div",{className:"space-y-3",children:N.map(e=>{let t={};try{var r;(null===(r=e.metadataURI)||void 0===r?void 0:r.startsWith("data:application/json,"))&&(t=JSON.parse(decodeURIComponent(e.metadataURI.slice(22))))}catch(e){}let n=m[e.id];return(0,s.jsxs)("div",{className:"p-4 rounded-xl border ".concat(n?"border-green-300 bg-green-50/50":"border-gray-200"),children:[(0,s.jsx)("div",{className:"font-bold",children:t.title||e.id.slice(0,10)+"..."}),t.description&&(0,s.jsx)("div",{className:"text-sm text-gray-600 mt-1",children:t.description}),n&&t.url&&(0,s.jsx)("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-block text-sm text-accent hover:text-accent/80 underline",children:"\uD83D\uDD13 Open content â"}),(0,s.jsxs)("div",{className:"flex items-center justify-between mt-3",children:[(0,s.jsxs)("div",{className:"text-sm font-bold",children:["$",(0,x.b)(e.price,18)]}),n?(0,s.jsx)("div",{className:"px-4 py-1.5 bg-green-500 text-white rounded-full text-sm font-semibold",children:"â Unlocked"}):a?(0,s.jsx)("button",{onClick:()=>v(e.id,e.price),disabled:p===e.id,className:"px-4 py-1.5 bg-accent text-white rounded-full text-sm font-semibold disabled:opacity-60",children:p===e.id?"Buying...":"Unlock"}):(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"Connect wallet"})]})]},e.id)})}),g&&(0,s.jsx)("div",{className:"mt-3 text-red-500 text-sm bg-red-50 p-2 rounded-xl",children:g})]})}function I(e){let{username:t}=e,{address:a}=(0,c.m)(),n=(0,d.t)(),{data:l}=(0,o.p)(),[i,u]=(0,r.useState)([]),[m,b]=(0,r.useState)(null),[p,h]=(0,r.useState)(""),[v,N]=(0,r.useState)(null),[j,w]=(0,r.useState)(null),[C,S]=(0,r.useState)({});(0,r.useEffect)(()=>{n&&(async()=>{try{let e=await n.readContract({address:f.M2.payPerCall,abi:f.K2,functionName:"getCreatorEndpoints",args:[t]}),a=[];for(let t of e){let e=await n.readContract({address:f.M2.payPerCall,abi:f.K2,functionName:"getEndpoint",args:[t]});a.push({id:t,...e})}u(a)}catch(e){}})()},[n,t,v]);let D=async(e,t,s)=>{if(l&&n&&!(s<1)){b(e),h(""),N(null);try{let r;try{let l=await n.estimateContractGas({address:f.M2.payPerCall,abi:f.K2,functionName:"batchPay",args:[e,BigInt(s)],value:t*BigInt(s),account:a});r=120n*l/100n}catch(e){r=BigInt(2e5+12e4*s)}let i=await l.writeContract({address:f.M2.payPerCall,abi:f.K2,functionName:"batchPay",args:[e,BigInt(s)],value:t*BigInt(s),gas:r}),c=(await n.waitForTransactionReceipt({hash:i})).logs.filter(e=>e.address.toLowerCase()===f.M2.payPerCall.toLowerCase()).map(e=>e.topics[1]?(BigInt(e.topics[1])+1n).toString():"?");N({callIds:c,txs:[i]})}catch(t){var r,i,c,d,o;let e=(null==t?void 0:null===(i=t.cause)||void 0===i?void 0:null===(r=i.data)||void 0===r?void 0:r.errorName)||(null==t?void 0:null===(o=t.cause)||void 0===o?void 0:null===(d=o.cause)||void 0===d?void 0:null===(c=d.data)||void 0===c?void 0:c.errorName);"EndpointInactive"===e?h("This endpoint is no longer active."):"EndpointNotFound"===e?h("Endpoint not found on-chain."):"WrongPayment"===e?h("Payment amount mismatch â price may have changed. Please refresh and try again."):h(t.shortMessage||t.message)}finally{b(null)}}},P=async(e,t)=>{try{await navigator.clipboard.writeText(e),w(t),setTimeout(()=>w(null),1500)}catch(e){}},I=i.filter(e=>e.active);return 0===I.length?(0,s.jsxs)("div",{className:"text-center py-8 text-gray-500 text-sm",children:["@",t," hasn't registered any paid API endpoints yet."]}):(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"text-xs text-gray-600 mb-3 bg-amber-50 border border-amber-200 rounded-lg p-2",children:["â¡ ",(0,s.jsx)("strong",{children:"For developers & AI agents."})," Pay-per-call endpoints are designed for programmatic access via the ArcPay SDK."]}),(0,s.jsx)("div",{className:"space-y-3",children:I.map(e=>{var t;let r=null!==(t=C[e.id])&&void 0!==t?t:1,n=e.pricePerCall*BigInt(r);return(0,s.jsxs)("div",{className:"p-4 rounded-xl border border-gray-200",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between",children:[(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"font-bold font-mono",children:e.name}),(0,s.jsxs)("div",{className:"text-xs text-gray-500 mt-1",children:[Number(e.totalCalls)," total calls served"]})]}),(0,s.jsxs)("div",{className:"text-right shrink-0 ml-3",children:[(0,s.jsxs)("div",{className:"font-bold",children:["$",(0,x.b)(e.pricePerCall,18)]}),(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"/ call"})]})]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,s.jsxs)("div",{className:"flex-1 text-xs font-mono text-gray-500 truncate",title:e.id,children:[e.id.slice(0,14),"...",e.id.slice(-6)]}),(0,s.jsx)("button",{onClick:()=>P(e.id,e.id),className:"px-2 py-1 text-xs border border-gray-200 rounded-md hover:bg-gray-50",title:"Copy endpointId",children:j===e.id?"â":"\uD83D\uDCCB"})]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,s.jsx)("label",{className:"text-xs text-gray-500",children:"Calls:"}),[1,5,10,50].map(t=>(0,s.jsx)("button",{onClick:()=>S(a=>({...a,[e.id]:t})),className:"px-2.5 py-1 rounded-full text-xs font-semibold transition\n ".concat(r===t?"bg-accent text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:t},t)),(0,s.jsx)("input",{type:"number",min:1,value:r,onChange:t=>S(a=>({...a,[e.id]:Math.max(1,parseInt(t.target.value||"1"))})),className:"w-16 px-2 py-1 rounded-md border border-gray-200 text-xs"})]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"text-sm text-gray-600",children:["Total: ",(0,s.jsxs)("span",{className:"font-bold text-black",children:["$",(0,x.b)(n,18)," USDC"]})]}),a?(0,s.jsx)("button",{onClick:()=>D(e.id,e.pricePerCall,r),disabled:m===e.id,className:"px-4 py-1.5 bg-accent text-white rounded-full text-sm font-semibold disabled:opacity-60",children:m===e.id?"Paying...":1===r?"Pay for 1 call":"Pay for ".concat(r," calls")}):(0,s.jsx)("div",{className:"text-xs text-gray-500",children:"Connect wallet"})]})]},e.id)})}),v&&v.callIds.length>0&&(0,s.jsxs)("div",{className:"mt-4 p-4 rounded-xl bg-green-50 border border-green-200",children:[(0,s.jsxs)("div",{className:"text-sm font-bold text-green-800",children:["â Purchased ",v.callIds.length," call credit",1!==v.callIds.length?"s":""," \xb7 receipt",1!==v.callIds.length?"s":""," #",v.callIds[0],v.callIds.length>1?"â#".concat(v.callIds[v.callIds.length-1]):""]}),(0,s.jsx)("div",{className:"text-xs mt-1",children:(0,s.jsx)(y.P,{tx:v.txs[0]})}),(0,s.jsxs)("div",{className:"text-xs text-green-700 mt-2",children:["Credits are bound to your wallet address. Your app / AI agent must sign each request with the same wallet â the ",(0,s.jsx)(g.default,{href:"/",className:"underline",children:"ArcPay SDK"})," handles signing automatically."]})]}),p&&(0,s.jsx)("div",{className:"mt-3 text-red-500 text-sm bg-red-50 p-2 rounded-xl",children:p})]})}function M(e){let{username:t}=e,[a,n]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=!1;return fetch("/api/x-profile?handle=".concat(encodeURIComponent(t))).then(e=>e.ok?e.json():null).then(t=>{e||!t||t.error||n(t)}
1).catch(()=>{}),()=>{e=!0}},[t]);let l=(null==a?void 0:a.name)||t,i=null==a?void 0:a.description;return(0,s.jsxs)("div",{className:"min-h-screen bg-paper",children:[(0,s.jsxs)("header",{className:"max-w-2xl mx-auto px-6 py-4 flex justify-between items-center gap-2",children:[(0,s.jsxs)(g.default,{href:"/",className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-6 h-6 rounded bg-accent"}),(0,s.jsx)("span",{className:"font-bold",children:"ArcPay"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(g.default,{href:"/faucet",className:"hidden sm:inline text-xs px-3 py-1.5 rounded-lg border border-gray-200 hover:border-accent transition",title:"Get free testnet USDC",children:"\uD83D\uDCA7 Faucet"}),(0,s.jsx)(w,{})]})]}),(0,s.jsxs)("main",{className:"max-w-lg mx-auto px-6 pt-6 pb-20",children:[(0,s.jsxs)("div",{className:"bg-white rounded-3xl shadow-xl border border-gray-100 overflow-hidden",children:[(0,s.jsx)("div",{className:"h-24 bg-accent"}),(0,s.jsxs)("div",{className:"px-6 pb-6 -mt-10",children:[(null==a?void 0:a.avatar)?(0,s.jsx)("img",{src:a.avatar,alt:l,className:"w-20 h-20 rounded-full border-4 border-white shadow-lg object-cover"}):(0,s.jsx)("div",{className:"w-20 h-20 rounded-full bg-white border-4 border-white shadow-lg flex items-center justify-center text-3xl font-bold text-accent",children:l.charAt(0).toUpperCase()}),(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("h1",{className:"text-2xl font-bold",children:l}),(0,s.jsxs)("a",{href:"https://x.com/".concat(t),target:"_blank",rel:"noopener noreferrer",className:"text-gray-500 font-mono text-sm hover:text-accent",children:["@",t," â"]}),i&&(0,s.jsx)("p",{className:"mt-3 text-gray-700 text-sm",children:i}),(0,s.jsxs)("div",{className:"mt-3 text-xs bg-amber-50 border border-amber-200 text-amber-800 rounded-lg p-2.5",children:["â³ @",t," hasn't claimed ArcPay yet. Tips are safely held on-chain. They can"," ",(0,s.jsx)(g.default,{href:"/claim",className:"font-bold underline",children:"claim via X OAuth"})," any time."]})]})]}),(0,s.jsx)("div",{className:"border-t border-gray-100 p-6",children:(0,s.jsx)(k,{username:t})})]}),(0,s.jsxs)("div",{className:"text-center mt-6 text-xs text-gray-400",children:["Powered by ",(0,s.jsx)(g.default,{href:"/",className:"font-semibold hover:text-gray-700",children:"ArcPay"})," on Arc Network \xb7 USDC native"]})]})]})}function k(e){let{username:t}=e,{address:a}=(0,c.m)(),n=(0,d.t)(),{data:l}=(0,o.p)(),[i,u]=(0,r.useState)("0.005"),[m,b]=(0,r.useState)(""),[p,g]=(0,r.useState)(!1),[v,N]=(0,r.useState)(null),[j,w]=(0,r.useState)(""),[C,S]=(0,r.useState)(null);(0,r.useEffect)(()=>{n&&(async()=>{try{let e=await n.readContract({address:f.M2.tipJarByHandle,abi:f.sY,functionName:"availableToClaim",args:[t]});S(e)}catch(e){}})()},[n,t,v]);let D=async()=>{if(l&&a&&n){g(!0),w(""),N(null);try{let e=await l.writeContract({address:f.M2.tipJarByHandle,abi:f.sY,functionName:"tipByHandle",args:[t,m],value:(0,h.v)(i,18),gas:350000n});await n.waitForTransactionReceipt({hash:e}),N(e),b("")}catch(e){w(e.shortMessage||e.message)}finally{g(!1)}}};return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"text-sm text-gray-600 mb-2",children:["Support @",t," with a USDC tip â held on-chain until they claim."]}),null!==C&&C>0n&&(0,s.jsxs)("div",{className:"mb-3 text-xs bg-red-50 border border-red-200 text-red-800 rounded-lg p-2",children:["\uD83D\uDCB8 Pending for @",t,": ",(0,s.jsxs)("strong",{children:[Number((0,x.b)(C,18)).toFixed(4)," USDC"]})]}),(0,s.jsx)("div",{className:"grid grid-cols-4 gap-2 mb-3",children:["0.001","0.005","0.01","0.05"].map(e=>(0,s.jsxs)("button",{onClick:()=>u(e),className:"py-2 rounded-xl text-sm font-semibold border-2 transition\n ".concat(i===e?"border-accent bg-accent/10 text-accent":"border-gray-200"),children:["$",e]},e))}),(0,s.jsx)("input",{value:i,onChange:e=>u(e.target.value.replace(/[^0-9.]/g,"")),className:"w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-accent focus:outline-none mb-3",placeholder:"Custom amount",inputMode:"decimal"}),(0,s.jsx)("textarea",{value:m,onChange:e=>b(e.target.value.slice(0,280)),className:"w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-accent focus:outline-none resize-none h-20 mb-3",placeholder:"Message (optional)"}),a?(0,s.jsx)("button",{onClick:D,disabled:p||!i,className:"w-full py-3 rounded-xl font-bold text-white bg-accent disabled:opacity-60",children:p?"Sending...":"Send $".concat(i," tip")}):(0,s.jsx)("div",{className:"text-center py-3 text-gray-500 text-sm bg-gray-50 rounded-xl",children:"Connect wallet or sign in to tip"}),v&&(0,s.jsxs)("div",{className:"mt-3 text-green-600 text-sm bg-green-50 p-3 rounded-xl text-center",children:["â Tip sent! It's held for @",t," until they claim. ",(0,s.jsx)(y.P,{tx:v})]}),j&&(0,s.jsx)("div",{className:"mt-3 text-red-500 text-sm bg-red-50 p-2 rounded-xl",children:j})]})}!(v.length>=20)||v.includes("demo")||v.includes("replace")}},function(e){e.O(0,[2972,8181,287,1837,3412,5929,2971,2117,1744],function(){return e(e.s=31248)}),_N_E=e.O()}]); 2//# sourceMappingURL=page-f863f03bc9253817.js.map
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.