import{f as a,t as i,x as l,y as v,i as n,g as e,G as d,J as g,B as u,F as b,z as f,N as B,C as y,D as h,A as I,e as P,a as w}from"./vue-core-Ewsep5yp.js";import{u as V,h as N,r as Y,d as j}from"./inertia-Ckpa2qIg.js";import{A as F}from"./AdminLayout-j5U7h0Jh.js";import{u as H}from"./useConfirm-BuAOQkqU.js";import{n as _,a7 as L,I as M,u as D,i as O,m as U}from"./heroicons-BDwnQUYs.js";import"./PwaInstallPrompt-DoLwZwXF.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./LocaleSwitcher-9HahHW1U.js";import"./app-oHOEXACs.js";import"./monaco-JW8DSIgC.js";import"./ConfirmDialog-CAAUJZjl.js";import"./OnoxLogo-CeDonOUJ.js";const G={key:0,class:"mb-6 rounded-xl border-2 border-orange-300 bg-orange-50 p-5 dark:border-orange-700 dark:bg-orange-950"},K={class:"flex items-start gap-3"},W={key:1,class:"mb-4 rounded-xl border-2 border-amber-300 bg-amber-50 p-4"},q={class:"flex items-start gap-3"},E={class:"flex-1"},J={class:"mt-2 flex items-center gap-2"},Q={class:"flex-1 rounded bg-white px-3 py-2 font-mono text-xs break-all"},R={class:"mb-4 flex justify-end"},X={key:2,class:"rounded-xl border border-dashed border-slate-300 bg-white p-12 text-center"},Z={key:3,class:"overflow-hidden rounded-xl border border-slate-200 bg-white shadow-sm"},ee={class:"min-w-full divide-y divide-slate-200"},te={class:"divide-y divide-slate-100"},se={class:"px-4 py-2 font-semibold"},le={class:"px-4 py-2"},oe={class:"flex flex-wrap gap-1"},ae={class:"px-4 py-2 text-xs"},ne={class:"px-4 py-2 text-xs"},ie={class:"px-4 py-2 text-right"},re=["onClick"],de={key:4,class:"fixed inset-0 z-50 flex items-center justify-center bg-slate-900/50 p-4"},ue={class:"w-full max-w-lg rounded-xl bg-white p-6 shadow-xl"},xe={class:"mb-4 flex items-center justify-between"},me={class:"flex flex-wrap gap-2"},pe=["onClick"],be={class:"flex justify-end gap-2"},ce=["disabled"],$e={__name:"ApiTokens",props:{tokens:Array,available_abilities:Array,sanctum_missing:{type:Boolean,default:!1}},setup(m){const{ask:A}=H(),C=j(),c=P(()=>C.props.flash?.new_token),x=w(!1),k=w(!0),o=V({name:"",abilities:["*"],expires_in_days:365}),T=()=>o.post(route("admin.api-tokens.store"),{onSuccess:()=>{x.value=!1,o.reset(),o.abilities=["*"],o.expires_in_days=365}}),S=async r=>{await A({title:"Onaylayın",message:`'${r.name}' token'ı iptal edilsin mi?`,variant:"danger",confirmText:"Sil",cancelText:"İptal"})&&Y.delete(route("admin.api-tokens.destroy",r.id))},$=r=>{navigator.clipboard.writeText(r),alert("Kopyalandı!")},z=r=>{const t=o.abilities.indexOf(r);t>=0?o.abilities.splice(t,1):o.abilities.push(r)};return(r,t)=>(n(),a(b,null,[i(l(N),{title:"API Token'ları"}),i(F,null,{header:v(()=>[...t[7]||(t[7]=[d("API Token'ları",-1)])]),default:v(()=>[m.sanctum_missing?(n(),a("div",G,[e("div",K,[i(l(_),{class:"h-6 w-6 flex-shrink-0 text-orange-600 dark:text-orange-400"}),t[8]||(t[8]=e("div",{class:"flex-1"},[e("h3",{class:"font-bold text-orange-900 dark:text-orange-200"},"Laravel Sanctum kurulu değil"),e("p",{class:"mt-1 text-sm text-orange-800 dark:text-orange-300"},[d(" API token özelliği "),e("strong",null,"laravel/sanctum"),d(" paketine bağımlıdır. Sunucuda şu komutu çalıştırın: ")]),e("pre",{class:"mt-3 rounded-lg bg-slate-900 px-4 py-3 text-xs text-slate-100"},[e("code",null,`composer require laravel/sanctum
php artisan vendor:publish --provider="Laravel\\Sanctum\\SanctumServiceProvider"
php artisan migrate`)]),e("p",{class:"mt-3 text-xs text-orange-700 dark:text-orange-400"},[d(" Sonrasında User modeline "),e("code",{class:"rounded bg-orange-100 px-1 dark:bg-orange-900"},"use HasApiTokens;"),d(" trait'ini ekleyin. ")])],-1))])])):g("",!0),c.value&&k.value?(n(),a("div",W,[e("div",q,[i(l(_),{class:"h-6 w-6 text-amber-600 flex-shrink-0"}),e("div",E,[t[9]||(t[9]=e("h3",{class:"font-bold text-amber-900"},"Token'ı şimdi kopyalayın — bir daha gösterilmez!",-1)),e("div",J,[e("code",Q,u(c.value),1),e("button",{onClick:t[0]||(t[0]=s=>$(c.value)),class:"rounded-lg bg-amber-600 px-3 py-2 text-sm font-medium text-white hover:bg-amber-700"},[i(l(L),{class:"h-4 w-4"})])]),e("button",{onClick:t[1]||(t[1]=s=>k.value=!1),class:"mt-2 text-xs text-amber-700 underline"},"Anladım, gizle")])])])):g("",!0),e("div",R,[e("button",{onClick:t[2]||(t[2]=s=>x.value=!0),class:"inline-flex items-center gap-2 rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700"},[i(l(M),{class:"h-4 w-4"}),t[10]||(t[10]=d(" Yeni Token ",-1))])]),m.tokens.length===0?(n(),a("div",X,[i(l(D),{class:"mx-auto h-14 w-14 text-slate-300"}),t[11]||(t[11]=e("h3",{class:"mt-3 text-lg font-semibold"},"API token yok",-1)),t[12]||(t[12]=e("p",{class:"mt-1 text-sm text-slate-500"},"WHMCS webhook ve harici entegrasyonlar için token oluşturun.",-1))])):(n(),a("div",Z,[e("table",ee,[t[13]||(t[13]=e("thead",{class:"bg-slate-50"},[e("tr",null,[e("th",{class:"px-4 py-3 text-left text-xs font-semibold uppercase text-slate-500"},"Ad"),e("th",{class:"px-4 py-3 text-left text-xs font-semibold uppercase text-slate-500"},"Yetkiler"),e("th",{class:"px-4 py-3 text-left text-xs font-semibold uppercase text-slate-500"},"Son Kullanım"),e("th",{class:"px-4 py-3 text-left text-xs font-semibold uppercase text-slate-500"},"Bitiş"),e("th",{class:"px-4 py-3"})])],-1)),e("tbody",te,[(n(!0),a(b,null,f(m.tokens,s=>(n(),a("tr",{key:s.id,class:"hover:bg-slate-50"},[e("td",se,u(s.name),1),e("td",le,[e("div",oe,[(n(!0),a(b,null,f(s.abilities,p=>(n(),a("span",{key:p,class:"rounded bg-slate-100 px-2 py-0.5 text-xs font-mono"},u(p),1))),128))])]),e("td",ae,u(s.last_used_at||"Hiç"),1),e("td",ne,u(s.expires_at||"Yok"),1),e("td",ie,[e("button",{onClick:p=>S(s),class:"rounded p-1.5 text-red-500 hover:bg-red-50"},[i(l(O),{class:"h-4 w-4"})],8,re)])]))),128))])])])),x.value?(n(),a("div",de,[e("div",ue,[e("div",xe,[t[14]||(t[14]=e("h3",{class:"text-lg font-semibold"},"Yeni API Token",-1)),e("button",{onClick:t[3]||(t[3]=s=>x.value=!1)},[i(l(U),{class:"h-5 w-5 text-slate-400"})])]),e("form",{onSubmit:B(T,["prevent"]),class:"space-y-4"},[e("div",null,[t[15]||(t[15]=e("label",{class:"block text-sm font-medium"},"Token Adı",-1)),y(e("input",{"onUpdate:modelValue":t[4]||(t[4]=s=>l(o).name=s),type:"text",placeholder:"WHMCS Integration",class:"mt-1 w-full rounded-lg border border-slate-300 px-3 py-2 text-sm"},null,512),[[h,l(o).name]])]),e("div",null,[t[16]||(t[16]=e("label",{class:"block text-sm font-medium mb-2"},"Yetkiler",-1)),e("div",me,[(n(!0),a(b,null,f(m.available_abilities,s=>(n(),a("button",{key:s,type:"button",onClick:p=>z(s),class:I(["rounded-full px-3 py-1 text-xs font-mono",l(o).abilities.includes(s)?"bg-indigo-600 text-white":"bg-slate-100 text-slate-700"])},u(s),11,pe))),128))])]),e("div",null,[t[17]||(t[17]=e("label",{class:"block text-sm font-medium"},"Geçerlilik (gün)",-1)),y(e("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>l(o).expires_in_days=s),type:"number",min:"1",class:"mt-1 w-full rounded-lg border border-slate-300 px-3 py-2 text-sm"},null,512),[[h,l(o).expires_in_days,void 0,{number:!0}]]),t[18]||(t[18]=e("p",{class:"mt-1 text-xs text-slate-500"},"Boş bırakılırsa süresiz.",-1))]),e("div",be,[e("button",{type:"button",onClick:t[6]||(t[6]=s=>x.value=!1),class:"rounded-lg border border-slate-300 px-4 py-2 text-sm"},"İptal"),e("button",{type:"submit",disabled:l(o).processing,class:"rounded-lg bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700"},"Oluştur",8,ce)])],32)])])):g("",!0)]),_:1})],64))}};export{$e as default};
