import{T as S,c as b,a as r,u as m,Z as w,w as d,b as e,t as s,f as x,o as y,g as k,F as C,q as T,p as v}from"./app-z_grtNg1.js";import{_ as q}from"./MobileAppLayout-BU3NJWTn.js";import{_ as u}from"./AppCard-C2KBW1s0.js";import"./ToastStack-xenoaUxd.js";import"./AppModal-DLkXyhIS.js";const A={class:"space-y-4"},N={class:"space-y-3 text-sm"},R={class:"rounded-xl border border-slate-200 bg-slate-50 p-3"},j={class:"mt-1 break-all font-semibold text-slate-900"},P={class:"grid grid-cols-2 gap-2 text-xs"},E={class:"rounded-xl border border-slate-200 bg-slate-50 p-2.5"},O={class:"mt-1 font-semibold text-slate-900 capitalize"},B={class:"rounded-xl border border-slate-200 bg-slate-50 p-2.5"},$={class:"mt-1 font-semibold text-slate-900"},F={class:"rounded-xl border border-amber-200 bg-amber-50 p-3 text-xs text-amber-900"},H={class:"font-semibold"},I=["disabled"],K={key:0,class:"rounded-xl border border-emerald-200 bg-emerald-50 p-3 text-xs text-emerald-900"},U={class:"mt-1 break-all font-mono"},V={class:"space-y-3 text-xs"},X={class:"rounded-xl border border-slate-200 bg-slate-50 p-3"},D={class:"mt-1 text-slate-600"},J={class:"rounded-xl border border-slate-200 bg-slate-50 p-3"},M={class:"mt-1 font-mono text-slate-700"},z={class:"space-y-3 text-xs"},Z={class:"rounded-xl border border-slate-200 bg-slate-50 p-3"},G={class:"overflow-x-auto whitespace-pre-wrap text-slate-700"},L={class:"rounded-xl border border-slate-200 bg-slate-50 p-3"},Q={class:"overflow-x-auto whitespace-pre-wrap text-slate-700"},oe={__name:"Access",props:{client:{type:Object,required:!0},api:{type:Object,required:!0},one_time_secret:{type:String,default:null}},setup(o){const g=o,i=T(""),c=S({}),p=async(n,t)=>{const l=String(n||"").trim();if(l){try{await navigator.clipboard.writeText(l)}catch{const a=document.createElement("textarea");a.value=l,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a)}i.value=t,setTimeout(()=>{i.value===t&&(i.value="")},1200)}},f=()=>{c.post(route("app.api-access.rotate"),{preserveScroll:!0})},_=v(()=>{const n=JSON.stringify({idempotency_key:"idem-123456",category_slug:"airtime_vtu",network_id:1,plan_id:10,phone:"08012345678",amount:500},null,2);return[`POST ${g.api.base_url}/purchase/airtime`,"Headers: X-Api-Key, X-Timestamp, X-Nonce, X-Signature","Body:",n].join(`
`)}),h=v(()=>`const method = 'POST';
const path = '/api/v1/purchase/airtime';
const timestamp = Math.floor(Date.now()/1000).toString();
const nonce = crypto.randomUUID();
const body = JSON.stringify({ /* payload */ });
const bodyHash = sha256(body);
const payload = [method, path, timestamp, nonce, bodyHash].join('\\n');
const signature = hmacSha256(payload, SECRET);`);return(n,t)=>(y(),b(C,null,[r(m(w),{title:"API Access"}),r(q,{title:"API Access",subtitle:"Manage reseller API keys and request signing"},{default:d(()=>[e("div",A,[r(u,{title:"Client Credentials",subtitle:"Use these credentials for your external reseller integration."},{default:d(()=>[e("div",N,[e("div",R,[t[2]||(t[2]=e("div",{class:"text-[11px] uppercase tracking-wide text-slate-500"},"Public Key",-1)),e("div",j,s(o.client.public_key),1),e("button",{type:"button",class:"mt-2 rounded-md border border-slate-300 px-2.5 py-1 text-xs font-semibold text-slate-700",onClick:t[0]||(t[0]=l=>p(o.client.public_key,"pk"))},s(i.value==="pk"?"Copied":"Copy Public Key"),1)]),e("div",P,[e("div",E,[t[3]||(t[3]=e("div",{class:"text-slate-500"},"Status",-1)),e("div",O,s(o.client.status),1)]),e("div",B,[t[4]||(t[4]=e("div",{class:"text-slate-500"},"Rate limit / min",-1)),e("div",$,s(o.client.rate_limit_per_minute),1)])]),e("div",F,[t[5]||(t[5]=x(" Secret ends with: ",-1)),e("span",H,s(o.client.secret_last4||"----"),1),t[6]||(t[6]=x(". Rotate if secret is exposed. ",-1))]),e("button",{type:"button",class:"inline-flex items-center justify-center rounded-xl bg-slate-900 px-4 py-2.5 text-sm font-semibold text-white hover:bg-slate-800 disabled:opacity-60",disabled:m(c).processing,onClick:f},s(m(c).processing?"Rotating...":"Rotate Secret"),9,I),o.one_time_secret?(y(),b("div",K,[t[7]||(t[7]=e("div",{class:"font-semibold"},"New Secret (shown once)",-1)),e("div",U,s(o.one_time_secret),1),e("button",{type:"button",class:"mt-2 rounded-md border border-emerald-300 bg-white px-2.5 py-1 font-semibold text-emerald-800",onClick:t[1]||(t[1]=l=>p(o.one_time_secret,"secret"))},s(i.value==="secret"?"Copied":"Copy Secret"),1)])):k("",!0)])]),_:1}),r(u,{title:"Signing Rules",subtitle:"Every request must be signed with your secret."},{default:d(()=>[e("div",V,[e("div",X,[t[8]||(t[8]=e("div",{class:"font-semibold text-slate-800"},"Required Headers",-1)),e("div",D,s(o.api.headers.join(", ")),1)]),e("div",J,[t[9]||(t[9]=e("div",{class:"font-semibold text-slate-800"},"Signature Format",-1)),e("div",M,s(o.api.signature_format),1)])])]),_:1}),r(u,{title:"Samples",subtitle:"Use this as a quick integration guide."},{default:d(()=>[e("div",z,[e("div",Z,[t[10]||(t[10]=e("div",{class:"mb-1 font-semibold text-slate-800"},"Sample Request",-1)),e("pre",G,s(_.value),1)]),e("div",L,[t[11]||(t[11]=e("div",{class:"mb-1 font-semibold text-slate-800"},"JS Signing Example",-1)),e("pre",Q,s(h.value),1)])])]),_:1})])]),_:1})],64))}};export{oe as default};
