PageSourceSearch

https://chatpilots.ai/static/js/6388.9a393deb.chunk.js

js chatpilots.ai collected 2026-10-05 13:03:15 UTC 213,452 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkPump=self.webpackChunkPump||[]).push([[6388],{5801(e,t,n){n.d(t,{A:()=>o});var a=n(65043),i=n(27867),r=n(70579);var l=function(e){return[".cp-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,.55); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; animation: cp-fade 0.15s ease; }",".cp-modal { width: 90%; max-width: 620px; background: var(--cp-elevated); border: 1px solid var(--cp-border); border-radius: 16px; box-shadow: var(--cp-shadow); overflow: hidden; display: flex; flex-direction: column; max-height: 76vh; animation: cp-slide 0.2s ease; }",".cp-search { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--cp-border-soft); }",".cp-input.ant-input { flex: 1; background: transparent !important; border: none !important; color: var(--cp-title) !important; font-size: 15px !important; box-shadow: none !important; padding: 0 !important; }",".cp-input.ant-input::placeholder { color: var(--cp-faint) !important; }",".cp-hint { color: var(--cp-faint); font-size: 10px; font-weight: 600; }",".cp-list { flex: 1; overflow-y: auto; padding: 8px 0; }",".cp-group-title { padding: 10px 18px 6px; font-size: 10px; font-weight: 800; color: var(--cp-muted); text-transform: uppercase; letter-spacing: 1.5px; }",".cp-item { display: flex; align-items: center; gap: 12px; padding: 10px 18px; cursor: pointer; transition: background 0.1s ease; }",".cp-item.active { background: var(--cp-side-item-hover); }",".cp-icon { width: 32px; height: 32px; min-width: 32px; border-radius: 8px; background: var(--cp-side-item); display: flex; align-items: center; justify-content: center; color: var(--cp-violet); font-size: 14px; }",".cp-item.active .cp-icon { background: var(--cp-violet-fill); color: #fff; }",".cp-title { color: var(--cp-title); font-size: 13px; font-weight: 600; }",".cp-sub { color: var(--cp-muted); font-size: 11px; margin-top: 2px; }",".cp-enter { color: var(--cp-violet); font-size: 12px; }",".cp-empty { padding: 40px 20px; text-align: center; color: var(--cp-muted); font-size: 13px; }",".cp-footer { padding: 10px 18px; border-top: 1px solid var(--cp-border-soft); display: flex; gap: 16px; color: var(--cp-muted); font-size: 10px; }",".cp-footer kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--cp-border); border-radius: 4px; background: var(--cp-surface2); color: var(--cp-text2); font-size: 10px; font-family: monospace; }","@keyframes cp-fade { from { opacity: 0; } to { opacity: 1; } }","@keyframes cp-slide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }"].join("\n").replace(/\.cp-/g,"."+e+"-")};const o=function(e){var t=e.items||[],n=e.prefix||"cp",o=e.openEvent||"sa-open-palette",s=(0,a.useState)(!1),d=s[0],c=s[1],u=(0,a.useState)(""),p=u[0],m=u[1],g=(0,a.useState)(0),h=g[0],x=g[1],f=(0,a.useRef)(null),y=(0,a.useRef)(null);(0,a.useEffect)(function(){var e=function(e){!e.metaKey&&!e.ctrlKey||"k"!==e.key&&"K"!==e.key||(e.preventDefault(),c(function(e){return!e})),"Escape"===e.key&&d&&c(!1)},t=function(){c(!0)};return window.addEventListener("keydown",e),window.addEventListener(o,t),function(){window.removeEventListener("keydown",e),window.removeEventListener(o,t)}},[d,o]),(0,a.useEffect)(function(){d&&f.current?setTimeout(function(){try{f.current.focus()}catch(e){}},50):(m(""),x(0))},[d]);var b=function(){var e=p.trim().toLowerCase();return e?t.filter(function(t){return-1!==(t.title+" "+(t.subtitle||"")+" "+(t.group||"")+" "+(t.keywords||[])).toLowerCase().indexOf(e)}):t}(),v=function(){var e={};return b.forEach(function(t,n){var a=t.group||"Genel";e[a]||(e[a]=[]),e[a].push(Object.assign({},t,{_flatIdx:n}))}),e}();return(0,a.useEffect)(function(){h>=b.length&&x(Math.max(0,b.length-1))},[b.length]),d?(0,r.jsxs)("div",{className:n+"-backdrop",onClick:function(){c(!1)},children:[(0,r.jsx)("style",{children:l(n)}),(0,r.jsxs)("div",{className:n+"-modal",onClick:function(e){e.stopPropagation()},children:[(0,r.jsxs)("div",{className:n+"-search",children:[(0,r.jsx)(i.Icon,{type:"search",style:{color:"#8b5cf6",fontSize:16}}),(0,r.jsx)(i.Input,{ref:f,value:p,onChange:function(e){m(e.target.value),x(0)},onKeyDown:function(e){if("ArrowDown"===e.key)e.preventDefault(),x(function(e){return Math.min(e+1,b.length-1)});else if("ArrowUp"===e.key)e.preventDefault(),x(function(e){return Math.max(0,e-1)});else if("Enter"===e.key){e.preventDefault();var t=b[h];t&&t.action&&(t.action(),c(!1))}},placeholder:e.placeholder||"Ara veya bir komut sec...",className:n+"-input"}),(0,r.jsx)("span",{className:n+"-hint",children:"ESC ile kapat"})]}),(0,r.jsx)("div",{className:n+"-list",ref:y,children:0===b.length?(0,r.jsxs)("div",{className:n+"-empty",children:[(0,r.jsx)(i.Icon,{type:"question-circle"}),' "',p,'" ',e.emptyText||"icin sonuc yok"]}):Object.keys(v).map(function(e){return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:n+"-group-title",children:e}),v[e].map(function(e){var t=e._flatIdx===h;return(0,r.jsxs)("div",{className:n+"-item"+(t?" active":""),onMouseEnter:function(){x(e._flatIdx)},onClick:function(){e.action&&e.action(),c(!1)},children:[(0,r.jsx)("div",{className:n+"-icon",children:e.icon?(0,r.jsx)(i.Icon,{type:e.icon}):(0,r.jsx)(i.Icon,{type:"arrow-right"})}),(0,r.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,r.jsx)("div",{className:n+"-title",children:e.title}),e.subtitle&&(0,r.jsx)("div",{className:n+"-sub",children:e.subt
1itle})]}),t&&(0,r.jsx)("span",{className:n+"-enter",children:(0,r.jsx)(i.Icon,{type:"enter"})})]},e.id)})]},e)})}),(0,r.jsxs)("div",{className:n+"-footer",children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{children:"\u2191"})," ",(0,r.jsx)("kbd",{children:"\u2193"})," gez"]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{children:"\u21b5"})," sec"]}),(0,r.jsxs)("span",{children:[(0,r.jsx)("kbd",{children:"ESC"})," kapat"]})]})]})]}):null}},16388(e,t,n){n.r(t),n.d(t,{default:()=>Kt});var a=n(65043),i=n(27867),r=n(51318),l=n(10340),o=n(29370),s=n(25133),d=n(6867);const c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s.Ay.post(d.A.users.list,e)},u=e=>s.Ay.post(d.A.users.create,e),p=e=>s.Ay.post(d.A.users.update,e),m=e=>s.Ay.post(d.A.users.delete,e),g=e=>s.Ay.post(d.A.tenantMembers.list,e),h=e=>s.Ay.post(d.A.tenantMembers.create,e),x=e=>s.Ay.post(d.A.tenantMembers.update,e),f=e=>s.Ay.post(d.A.tenantMembers.delete,e),y=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s.Ay.post(d.A.subscriptionsAdmin.list,e)},b=e=>s.Ay.post(d.A.subscriptionsAdmin.create,e),v=e=>s.Ay.post(d.A.subscriptionsAdmin.update,e),j=e=>s.Ay.post(d.A.subscriptionsAdmin.delete,e),k=()=>s.Ay.post(d.A.subscriptions.plans,{}),_=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s.Ay.post(d.A.transactionLogsAdmin.list,e)},w=e=>s.Ay.post(d.A.transactionLogsAdmin.create,e),S=e=>s.Ay.post(d.A.transactionLogsAdmin.update,e),z=e=>s.Ay.post(d.A.transactionLogsAdmin.delete,e),A=()=>s.Ay.post(d.A.tenants.list,{}),T=e=>s.Ay.post(d.A.whatsappAccounts.create,e),I=e=>s.Ay.post(d.A.whatsappAccounts.update,e),C=e=>s.Ay.post(d.A.whatsappAccounts.delete,e);var B=n(22555),D=n(70579);const W="var(--cp-info)",N="#34d399",K="#25D366",F="var(--cp-faint)",O=e=>String(e||"").replace(/[^0-9+]/g,""),M=e=>{e&&e.stopPropagation&&e.stopPropagation()},L={display:"inline-flex",alignItems:"center",gap:4,padding:"4px 8px",borderRadius:6,fontSize:11,fontWeight:600,textDecoration:"none",border:"1px solid transparent",transition:"all .15s",cursor:"pointer"},R=e=>{let{email:t,phone:n,ownerName:r,layout:l="compact",onStopPropagation:o=!0}=e;const s=O(n),d=(e=>{const t=O(e);return t?"https://wa.me/".concat(t.replace(/^\+/,"")):null})(n),c=!!t,u=!!s,p=o?M:void 0,m="compact"===l,g=m?(0,B.A)((0,B.A)({},L),{},{padding:"2px 6px",fontSize:10,height:22}):L,h=c?m?(0,D.jsx)(i.Tooltip,{title:t,children:(0,D.jsx)("a",{href:"mailto:".concat(t),onClick:p,style:(0,B.A)((0,B.A)({},g),{},{background:"rgba(96,165,250,0.08)",color:W,borderColor:"rgba(96,165,250,0.2)"}),children:"\u2709"})}):(0,D.jsxs)("a",{href:"mailto:".concat(t),onClick:p,style:(0,B.A)((0,B.A)({},L),{},{background:"rgba(96,165,250,0.08)",color:W,borderColor:"rgba(96,165,250,0.2)"}),title:"Email gonder",children:["\u2709 ",(0,D.jsx)("span",{style:{maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}):null,x=u?(0,D.jsxs)("a",{href:"tel:".concat(s),onClick:p,style:(0,B.A)((0,B.A)({},g),{},{background:"rgba(52,211,153,0.08)",color:N,borderColor:"rgba(52,211,153,0.2)"}),title:"Telefon ile ara",children:["\ud83d\udcde ",n]}):null,f=u?(0,D.jsx)(i.Tooltip,{title:"WhatsApp'tan mesaj at",children:(0,D.jsx)("a",{href:d,target:"_blank",rel:"noopener noreferrer",onClick:p,style:(0,B.A)((0,B.A)({},g),{},{background:"rgba(37,211,102,0.10)",color:K,borderColor:"rgba(37,211,102,0.25)"}),children:"\ud83d\udcac"})}):null,y=u?(0,D.jsx)(i.Tooltip,{title:"Numarayi kopyala",children:(0,D.jsx)("span",{onClick:e=>{M(e),(e=>{if(e)try{if(navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(e).then(()=>i.message.success("Panoya kopyalandi"),()=>i.message.warning("Kopyalanamadi"));else{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t),i.message.success("Panoya kopyalandi")}}catch(t){i.message.warning("Kopyalanamadi")}})(n)},style:(0,B.A)((0,B.A)({},g),{},{background:"rgba(255,255,255,0.04)",color:F,borderColor:"rgba(255,255,255,0.08)"}),children:"\u2398"})}):null;if(!c&&!u)return(0,D.jsx)("span",{style:{color:F,fontSize:11},children:"\u0130leti\u015fim yok"});
1const b=[h,x,f,y].filter(Boolean),v="row"===l||"compact"===l?"row":"column",j="row"===l||"compact"===l?"center":"flex-start";return(0,D.jsxs)("div",{style:{display:"flex",flexDirection:v,gap:4,flexWrap:"wrap",alignItems:j},children:[r?(0,D.jsx)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginBottom:2,width:"stack"===l?"100%":"auto"},children:r}):null,b.map((e,t)=>(0,D.jsx)(a.Fragment,{children:e},t))]})},{Option:E}=i.Select,{confirm:P}=i.Modal,G=e=>{var t=Number(String(e||"").trim());return Number.isFinite(t)&&t>0?t:null},Y=e=>{if(!e)return"-";try{return new Date(e).toLocaleDateString("tr-TR")}catch(t){return"-"}},H=e=>{if(!e)return"Hi\xe7 giri\u015f yapmad\u0131";try{const t=(Date.now()-new Date(e).getTime())/1e3;return t<60?"az \xf6nce":t<3600?Math.floor(t/60)+"d \xf6nce":t<86400?Math.floor(t/3600)+"s \xf6nce":t<2592e3?Math.floor(t/86400)+"g \xf6nce":Math.floor(t/2592e3)+"ay \xf6nce"}catch(t){return"-"}},V=e=>(t,n)=>String(t[e]||"").localeCompare(String(n[e]||"")),U=e=>(t,n)=>new Date(t[e]||0).getTime()-new Date(n[e]||0).getTime(),q=(0,l.Ng)(null,{userLoginAs:o.T6})(i.Form.create()(e=>{let{form:t,userLoginAs:n}=e;const[r,l]=(0,a.useState)([]),[o,g]=(0,a.useState)(!1),[h,x]=(0,a.useState)([]),[f,y]=(0,a.useState)(!1),[b,v]=(0,a.useState)(void 0),[j,k]=(0,a.useState)(void 0),[_,w]=(0,a.useState)(""),[S,z]=(0,a.useState)(null),[T,I]=(0,a.useState)(!1),[C,B]=(0,a.useState)(!1),[W,N]=(0,a.useState)(!1),[K,F]=(0,a.useState)(!1),[O,M]=(0,a.useState)({id:null,full_name:"",email:"",status:"active",password:"",role:"agent",tenant_id:""}),[L,q]=(0,a.useState)(null),[J,X]=(0,a.useState)("undefined"!==typeof window&&window.innerWidth<768);(0,a.useEffect)(()=>{var e=function(){X(window.innerWidth<768)};return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]);(0,a.useMemo)(()=>{var e={};return h.forEach(function(t){e[t.id]=t.name||t.slug||"Sirket #"+t.id}),e},[h]);const Z=async e=>{g(!0);try{var t=await s.Ay.get(d.A.superAdmin.usersEnriched),n=t&&t.data&&t.data.data?t.data.data:[],a=Array.isArray(n)?n:[];e&&(a=a.filter(function(t){return Array.isArray(t.tenants)&&t.tenants.some(function(t){return Number(t.tenant_id)===Number(e)})})),l(a)}catch(p){try{var r=e?{tenant_id:e}:{},o=await c(r),u=o&&o.data&&o.data.data?o.data.data:[];l(u.filter(function(e){return!e.is_super_admin}))}catch(m){l([]),i.message.error("Kullanicilar yuklenemedi")}}finally{g(!1)}};(0,a.useEffect)(()=>{(async()=>{y(!0);try{var e=await A(),t=e&&e.data&&e.data.data?e.data.data:[];x(Array.isArray(t)?t:[])}catch(n){x([])}finally{y(!1)}})(),Z(null)},[]);const Q=(0,a.useMemo)(()=>{var e=_.trim().toLowerCase();return r.filter(function(t){return("active"!==j||"disabled"!==String(t.status||"").toLowerCase())&&(("disabled"!==j||"disabled"===String(t.status||"").toLowerCase())&&(!e||-1!==(t.id+" "+(t.email||"")+" "+(t.full_name||"")+" "+(t.contact_number||"")+" "+(t.primary_tenant_name||"")).toLowerCase().indexOf(e)))})},[r,_,j]),$=(0,a.useMemo)(()=>{const e={total:r.length,active:0,disabled:0,recent:0},t=Date.now()-6048e5;return r.forEach(n=>{"disabled"===String(n.status||"").toLowerCase()?e.disabled++:e.active++;(n.created_at?new Date(n.created_at).getTime():0)>t&&e.recent++}),e},[r]),ee=e=>
1{e&&e.is_super_admin?i.message.warning("Super admin duzenlenemez"):(M({id:e.id,full_name:e.full_name||"",email:e.email||"",status:e.status||"active",password:"",role:e.role||"agent",tenant_id:e.tenant_id?String(e.tenant_id):b?String(b):""}),N(!0))},te=e=>{e&&e.is_super_admin||P({title:"Silme onayi",content:"Bu kullanici silinecek. Devam edilsin mi?",okText:"Sil",okType:"danger",cancelText:"Vazgec",onOk:async()=>{try{var t={id:e.id};b&&(t.tenant_id=Number(b)),await m(t),i.message.success("Silindi"),Z(b?Number(b):null)}catch(n){i.message.error("Silinemedi")}}})},ne=e=>{e&&!e.is_super_admin&&P({title:"Kullanici olarak giris",content:(e.full_name||e.email||"Bu kullanici")+" icin panele gecilecek.",okText:"Giris Yap",cancelText:"Vazgec",onOk:async()=>{z(e.id);try{var t=await n(e.id,{persist:!1});if(t&&0===t.error&&t.token&&t.user){var a=e.id+"-"+Date.now()+"-"+Math.random().toString(36).slice(2,8);return localStorage.setItem("impersonation:"+a,JSON.stringify({token:t.token,user:t.user})),i.message.success("Giris yapildi"),void window.open("/panel?impersonation="+encodeURIComponent(a),"_blank","noopener")}i.message.error("Giris basarisiz")}catch(r){i.message.error("Giris basarisiz")}finally{z(null)}}})};b&&Number(b);const ae=(e,t,n)=>(0,D.jsx)(i.Col,{xs:12,sm:6,children:(0,D.jsxs)(i.Card,{bodyStyle:{padding:12},style:{background:n+"0d",border:"1px solid "+n+"33"},children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-faint)",fontWeight:700,letterSpacing:.5},children:e}),(0,D.jsx)("div",{style:{fontSize:22,fontWeight:800,color:n},children:t})]})});return(0,D.jsxs)("div",{style:{padding:J?0:4},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16,flexWrap:"wrap",gap:12},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h2",{style:{color:"var(--cp-title)",margin:0,fontSize:20,fontWeight:800},children:"Kullan\u0131c\u0131lar"}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",fontSize:12,marginTop:4},children:"T\xfcm tenant kullan\u0131c\u0131lar\u0131, son giri\u015f, ba\u011fl\u0131 \u015firket bilgileri"})]}),(0,D.jsxs)(i.Button,{type:"primary",onClick:()=>{t.resetFields(),t.setFieldsValue({status:"active",role:"agent",tenant_id:b?String(b):""}),I(!0)},children:[(0,D.jsx)(i.Icon,{type:"plus"})," Yeni Kullan\u0131c\u0131"]})]}),(0,D.jsxs)(i.Row,{gutter:[10,10],style:{marginBottom:16},children:[ae("TOPLAM",$.total,"var(--cp-muted)"),ae("AKT\u0130F",$.active,"var(--cp-ok)"),ae("PAS\u0130F",$.disabled,"#ef4444"),ae("SON 7G YEN\u0130",$.recent,"var(--cp-info)")]}),(0,D.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:12,padding:10,background:"rgba(255,255,255,0.02)",borderRadius:10,border:"1px solid rgba(255,255,255,0.05)",alignItems:"center"},children:[(0,D.jsx)(i.Select,{showSearch:!0,allowClear:!0,value:b,onChange:e=>{v(e),Z(e?Number(e):null)},placeholder:f?"Y\xfckleniyor...":"\u015eirket se\xe7",style:{minWidth:180,flex:"1 1 180px",maxWidth:280},optionFilterProp:"children",loading:f,filterOption:(e,t)=>String(t.props.children||"").toLowerCase().indexOf(e.toLowerCase())>=0,children:h.map(e=>(0,D.jsxs)(E,{value:String(e.id),children:[e.name," #",e.id]},e.id))}),(0,D.jsxs)(i.Select,{allowClear:!0,value:j,onChange:e=>k(e),placeholder:"Durum",style:{width:140},children:[(0,D.jsx)(E,{value:"active",children:"Aktif"}),(0,D.jsx)(E,{value:"disabled",children:"Pasif"})]}),(0,D.jsx)(i.Input,{value:_,onChange:e=>w(e.target.value),placeholder:"Ad, email, telefon, \u015firket ara",prefix:(0,D.jsx)(i.Icon,{type:"search"}),allowClear:!0,style:{minWidth:200,flex:"1 1 200px",maxWidth:320}}),(0,D.jsx)(i.Button,{onClick:()=>{v(void 0),k(void 0),w(""),Z(null)},children:"Temizle"}),(0,D.jsxs)(i.Button,{onClick:()=>Z(b?Number(b):null),loading:o,children:[(0,D.jsx)(i.Icon,{type:"reload"})," Yenile"]}),(0,D.jsxs)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:[Q.length," / ",r.length]})]}),J?(0,D.jsx)("div",{children:o&&0===r.length?(0,D.jsx)("div",{style:{textAlign:"center",padding:30,color:"var(--cp-faint)"},children:"Y\xfckleniyor..."}):0===Q.length?(0,D.jsx)(i.Empty,{description:"Kay\u0131t yok"}):Q.map(e=>{const t="disabled"!==String(e.status||"").toLowerCase();return(0,D.jsxs)("div",{onClick:()=>q(e),style:{padding:14,background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:12,marginBottom:10,cursor:"pointer"},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:700,fontSize:14},children:["#",e.id," \xb7 ",e.full_name||"(isimsiz)"]}),e.primary_tenant_name?(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginTop:2},children:[e.primary_tenant_name,e.primary_role?" \xb7 "+e.primary_role:""]}):null]}),(0,D.jsx)(i.Tag,{color:t?"green":"red",style:{margin:0},children:t?"Aktif":"Pasif"})]}),(0,D.jsx)("div",{onClick:e=>e.stopPropagation(),style:{marginBottom:8},children:(0,D.jsx)(R,{email:e.email,phone:e.contact_number,layout:"compact"})}),(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginBottom:8},children:["Son giri\u015f: ",H(e.last_login_at)]}),(0,D.jsxs)("div",{onClick:e=>e.stopPropagation(),style:{display:"flex",gap:6,flexWrap:"wrap"},children:[(0,D.jsx)(i.Button,{size:"default",type:"primary",loading:S===e.id,onClick:()=>ne(e),style:{minHeight:36},children:"Giri\u015f Yap"}),(0,D.jsx)(i.Button,{size:"default",onClick:()=>ee(e),style:{minHeight:36},children:"D\xfczenle"}),(0,D.jsx)(i.Button,{size:"default",type:"danger",onClick:()=>te(e),style:{minHeight:36},children:"Sil"})]})]},e.id)})}):(0,D.jsx)(i.Table,{rowKey:"id",loading:o,dataSource:Q,size:"small",pagination:{pageSize:20,showSizeChanger:!0,showTotal:e=>"Toplam "+e},scroll:{x:"max-content"},onRow:e=>({onClick:()=>q(e),style:{cursor:"pointer"}}),columns:[{title:"ID",dataIndex:"id",width:60,fixed:"left",sorter:(ie="id",(e,t)=>Number(e[ie]||0)-Number(t[ie]||0)),defaultSortOrder:"descend"},{title:"Kullan\u0131c\u0131",dataIndex:"full_name",width:200,sorter:V("full_name"),render:(e,t)=>(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontWeight:600,fontSize:13},children:t.full_name||"(isimsiz)"}),t.primary_tenant_name?(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginTop:2},children:[t.primary_tenant_name,t.primary_role?" \xb7 "+t.primary_role:"",t.tenant_count>1?(0,D.jsxs)(i.Tag,{style:{marginLeft:6,fontSize:10},children:["+",t.tenant_count-1," \u015firket"]}):null]}):null]})},{title:"\u0130leti\u015fim",key:"contact",width:240,render:(e,t)=>(0,D.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,D.jsx)(R,{email:t.email,phone:t.contact_number,layout:"compact"})})},{title:"Durum",dataIndex:"status",width:90,sorter:V("status"),render:e=>{var t="disabled"!==String(e||"").toLowerCase();return(0,D.jsx)(i.Tag,{color:t?"green":"red",children:t?"Aktif":"Pasif"})}},{title:"Son Giri\u015f",dataIndex:"last_login_at",width:130,sorter:U("last_login_at"),render:e=>(0,D.jsx)("span",{style:{fontSize:11,color:e?"var(--cp-muted)":"#475569"},children:H(e)})},{title:"Kay\u0131t",dataIndex:"created_at",width:100,sorter:U("created_at"),render:(e,t)=>Y(t.created_at||t.createdAt)},{title:"\u0130\u015flem",key:"actions",width:240,fixed:"right",render:(e,t)=>(0,D.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},onClick:e=>e.stopPropagation(),children:[(0,D.jsx)(i.Button,{size:"small",type:"primary",loading:S===t.id,disabled:!!t.is_super_admin,onClick:()=>ne(t),children:"Giri\u015f"}),(0,D.jsx)(i.Button,{size:"small",disabled:!!t.is_super_admin,onClick:()=>ee(t),children:"D\xfczenle"}),(0,D.jsx)(i.Button,{size:"small",type:"danger",disabled:!!t.is_super_admin,onClick:()=>te(t),children:"Sil"})]})}]}),(0,D.jsx)(i.Drawer,{title:L?L.full_name||L.email||"Kullanici":"Detay",visible:!!L,onClose:function(){q(null)},width:J?"100%":480,bodyStyle:{background:"var(--cp-bg2)",color:"var(--cp-text)",padding:20},headerStyle:{background:"var(--cp-bg2)",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:L&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:16,flexWrap:"wrap"},children:[L.email?(0,D.jsx)(i.Button,{size:"default",href:"mailto:"+L.email,style:{background:"rgba(96,165,250,0.1)",color:"var(--cp-info)",borderColor:"rgba(96,165,250,0.3)"},children:"\u2709 Email"}):null,L.contact_number?(0,D.jsx)(i.Button,{size:"default",href:"tel:"+String(L.contact_number).replace(/[^0-9+]/g,""),style:{background:"rgba(52,211,153,0.1)",color:"#34d399",borderColor:"rgba(52,211,153,0.3)"},children:"\ud83d\udcde Ara"}):null,L.contact_number?(0,D.jsx)(i.Button,{size:"default",href:"https://wa.me/"+String(L.contact_number).replace(/[^0-9+]/g,"").replace(/^\+/,""),target:"_blank",style:{background:"rgba(37,211,102,0.1)",color:"#25D366",borderColor:"rgba(37,211,102,0.3)"},children:"\ud83d\udcac WhatsApp"}):null]}),(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:14,padding:16,marginBottom:16},children:[(0,D.jsx)("div",{style:{fontSize:13,fontWeight:700,marginBottom:12},children:"Kullan\u0131c\u0131 Bilgileri"}),(0,D.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,
1color:"var(--cp-faint)"},children:"Ad Soyad"}),(0,D.jsx)("div",{style:{fontWeight:600},children:L.full_name||"-"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"ID"}),(0,D.jsxs)("div",{children:["#",L.id]})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"E-posta"}),(0,D.jsx)("div",{style:{wordBreak:"break-all"},children:L.email||"-"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Telefon"}),(0,D.jsx)("div",{children:L.contact_number||"-"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Durum"}),(0,D.jsx)("div",{children:(0,D.jsx)(i.Tag,{color:"disabled"!==String(L.status||"").toLowerCase()?"green":"red",children:"disabled"!==String(L.status||"").toLowerCase()?"Aktif":"Pasif"})})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Son Giri\u015f"}),(0,D.jsx)("div",{children:H(L.last_login_at)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Kay\u0131t"}),(0,D.jsx)("div",{children:Y(L.created_at||L.createdAt)})]})]})]}),Array.isArray(L.tenants)&&L.tenants.length>0?(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:14,padding:16,marginBottom:16},children:[(0,D.jsxs)("div",{style:{fontSize:13,fontWeight:700,marginBottom:12},children:["Ba\u011fl\u0131 \u015eirketler (",L.tenants.length,")"]}),(0,D.jsx)(i.Table,{dataSource:L.tenants,rowKey:"tenant_id",size:"small",pagination:!1,columns:[{title:"ID",dataIndex:"tenant_id",width:50},{title:"Ad",dataIndex:"name",render:e=>e||"\u2014"},{title:"Slug",dataIndex:"slug",render:e=>e?(0,D.jsx)(i.Tag,{color:"blue",children:e}):"\u2014"},{title:"Rol",dataIndex:"role",render:e=>e?(0,D.jsx)(i.Tag,{color:"purple",children:e}):"\u2014"},{title:"Durum",dataIndex:"status",render:e=>(0,D.jsx)(i.Tag,{color:"active"===e?"green":"trial"===e?"blue":"orange",children:e})}]})]}):null,(0,D.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,D.jsxs)(i.Button,{type:"primary",onClick:function(){ne(L)},disabled:!!L.is_super_admin,loading:S===L.id,children:[(0,D.jsx)(i.Icon,{type:"login"})," Giris Yap"]}),(0,D.jsxs)(i.Button,{onClick:function(){ee(L),q(null)},disabled:!!L.is_super_admin,children:[(0,D.jsx)(i.Icon,{type:"edit"})," Duzenle"]}),(0,D.jsxs)(i.Button,{onClick:function(){(e=>{var t=prompt("Yeni sifre girin (min 6 karakter):");!t||t.length<6?i.message.warning("Sifre en az 6 karakter olmali"):p({id:e.id,password:t}).then(function(){i.message.success("Sifre guncellendi")}).catch(function(){i.message.error("Sifre guncellenemedi")})})(L)},disabled:!!L.is_super_admin,style:{borderColor:"rgba(251,191,36,0.3)",color:"var(--cp-warn)"},children:[(0,D.jsx)(i.Icon,{type:"key"})," Sifre Sifirla"]}),(0,D.jsxs)(i.Button,{type:"danger",onClick:function(){te(L),q(null)},disabled:!!L.is_super_admin,children:[(0,D.jsx)(i.Icon,{type:"delete"})," Sil"]})]})]})}),(0,D.jsx)(i.Modal,{visible:T,title:"Yeni Kullanici",okText:"Kaydet",cancelText:"Vazgec",onOk:()=>{t.validateFields(async(e,n)=>{if(!e){var a=G(n.tenant_id);B(!0);try{var r={email:String(n.email||"").trim(),password:String(n.password||""),full_name:n.full_name?String(n.full_name).trim():null,status:n.status||"active"};a&&(r.tenant_id=a,r.role=n.role||"agent"),await u(r),i.message.success("Kullanici olusturuldu"),t.resetFields(),I(!1),Z(b?Number(b):null)}catch(l){i.message.error(l&&l.response&&l.response.data&&l.response.data.message||"Olusturulamadi")}finally{B(!1)}}})},onCancel:function(){I(!1)},confirmLoading:C,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"E-posta",children:t.getFieldDecorator("email",{rules:[{required:!0,message:"E-posta zorunlu"}]})((0,D.jsx)(i.Input,{placeholder:"[email protected]"}))}),(0,D.jsx)(i.Form.Item,{label:"Sifre",children:t.getFieldDecorator("password",{rules:[{required:!0,message:"Sifre zorunlu"}]})((0,D.jsx)(i.Input,{type:"password"}))}),(0,D.jsx)(i.Form.Item,{label:"Ad Soyad",children:t.getFieldDecorator("full_name")((0,D.jsx)(i.Input,{placeholder:"Ad Soyad"}))}),(0,D.jsx)(i.Form.Item,{label:"Durum",children:t.getFieldDecorator("status",{initialValue:"active"})((0,D.jsxs)(i.Select,{children:[(0,D.jsx)(E,{value:"active",children:"Aktif"}),(0,D.jsx)(E,{value:"disabled",children:"Pasif"})]}))}),(0,D.jsx)(i.Form.Item,{label:"Sirket",children:t.getFieldDecorator("tenant_id",{initialValue:b?String(b):""})((0,D.jsx)(i.Select,{showSearch:!0,allowClear:!0,placeholder:"Sirket sec (opsiyonel)",optionFilterProp:"children",filterOption:function(e,t){return String(t.props.children||"").toLowerCase().indexOf(e.toLowerCase())>=0},children:h.map(function(e){return(0,D.jsxs)(E,{value:String(e.id),children:[e.name," #",e.id]},e.id)})}))}),(0,D.jsx)(i.Form.Item,{label:"Rol",children:t.getFieldDecorator("role",{initialValue:"agent"})((0,D.jsxs)(i.Select,{children:[(0,D.jsx)(E,{value:"owner",children:"Owner"}),(0,D.jsx)(E,{value:"admin",children:"Admin"}),(0,D.jsx)(E,{value:"agent",children:"Agent"}),(0,D.jsx)(E,{value:"viewer",children:"Viewer"})]}))})]})}),(0,D.jsx)(i.Modal,{visible:W,title:"Kullaniciyi Duzenle",okText:"Guncelle",cancelText:"Vazgec",onOk:async()=>
1{if(O.id){var e=G(O.tenant_id);F(!0);try{var t={id:O.id};O.full_name&&(t.full_name=O.full_name.trim()),O.email&&(t.email=O.email.trim()),O.status&&(t.status=O.status),O.password&&(t.password=O.password),e&&O.role&&(t.tenant_id=e,t.role=O.role),await p(t),i.message.success("Guncellendi"),N(!1),Z(b?Number(b):null)}catch(n){i.message.error("Guncelleme basarisiz")}finally{F(!1)}}},onCancel:function(){N(!1)},confirmLoading:K,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"E-posta",children:(0,D.jsx)(i.Input,{value:O.email,onChange:function(e){M(Object.assign({},O,{email:e.target.value}))}})}),(0,D.jsx)(i.Form.Item,{label:"Sifre (opsiyonel)",children:(0,D.jsx)(i.Input,{type:"password",value:O.password,onChange:function(e){M(Object.assign({},O,{password:e.target.value}))},placeholder:"Bos birakirsaniz degismez"})}),(0,D.jsx)(i.Form.Item,{label:"Ad Soyad",children:(0,D.jsx)(i.Input,{value:O.full_name,onChange:function(e){M(Object.assign({},O,{full_name:e.target.value}))}})}),(0,D.jsx)(i.Form.Item,{label:"Durum",children:(0,D.jsxs)(i.Select,{value:O.status,onChange:function(e){M(Object.assign({},O,{status:e}))},children:[(0,D.jsx)(E,{value:"active",children:"Aktif"}),(0,D.jsx)(E,{value:"disabled",children:"Pasif"})]})}),(0,D.jsx)(i.Form.Item,{label:"Sirket",children:(0,D.jsx)(i.Select,{showSearch:!0,allowClear:!0,value:O.tenant_id||void 0,onChange:function(e){M(Object.assign({},O,{tenant_id:e||""}))},placeholder:"Sirket sec",optionFilterProp:"children",filterOption:function(e,t){return String(t.props.children||"").toLowerCase().indexOf(e.toLowerCase())>=0},children:h.map(function(e){return(0,D.jsxs)(E,{value:String(e.id),children:[e.name," #",e.id]},e.id)})})}),(0,D.jsx)(i.Form.Item,{label:"Rol",children:(0,D.jsxs)(i.Select,{value:O.role,onChange:function(e){M(Object.assign({},O,{role:e}))},children:[(0,D.jsx)(E,{value:"owner",children:"Owner"}),(0,D.jsx)(E,{value:"admin",children:"Admin"}),(0,D.jsx)(E,{value:"agent",children:"Agent"}),(0,D.jsx)(E,{value:"viewer",children:"Viewer"})]})})]})})]});var ie})),{Option:J}=i.Select,{confirm:X}=i.Modal,Z=e=>(t,n)=>Number(t[e]||0)-Number(n[e]||0),Q=e=>(t,n)=>String(t[e]||"").localeCompare(String(n[e]||"")),$=e=>{if(!e)return"-";try{return new Date(e).toLocaleDateString("tr-TR")}catch(t){return"-"}},ee=e=>{const t=String(e||"").trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)&&n>0?n:null},te=i.Form.create()(e=>{let{form:t}=e;const[n,r]=(0,a.useState)([]),[l,o]=(0,a.useState)(!1),[c,u]=(0,a.useState)("all"),[p,m]=(0,a.useState)("all"),[y,b]=(0,a.useState)(null),[v,j]=(0,a.useState)(""),[k,_]=(0,a.useState)([]),[w,S]=(0,a.useState)(!1),[z,T]=(0,a.useState)("undefined"!==typeof window&&window.innerWidth<768);(0,a.useEffect)(()=>{const e=()=>T(window.innerWidth<768);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const I=async()=>{o(!0);try{const e=await s.Ay.get(d.A.superAdmin.allTenantMembers),t=e&&e.data&&e.data.data?e.data.data:[];r(Array.isArray(t)?t:[])}catch(e){r([]),i.message.error("\xdcyeler y\xfcklenemedi.")}finally{o(!1)}},[C,W]=(0,a.useState)(!1),[N,K]=(0,a.useState)(!1),[F,O]=(0,a.useState)(!1),[M,L]=(0,a.useState)(!1),[E,P]=(0,a.useState)({id:null,user_id:"",role:"agent"}),G=async e=>{if(e){o(!0);try{const t=await g({tenant_id:e}),n=t&&t.data&&t.data.data?t.data.data:[];r(n)}catch(t){r([]),i.message.error("Tenant \xfcyeleri y\xfcklenemedi.")}finally{o(!1)}}else r([])};(0,a.useEffect)(()=>{(async()=>{S(!0);try{const e=await A(),t=e&&e.data&&e.data.data?e.data.data:[];return _(t),t}catch(e){return _([]),[]}finally{S(!1)}})(),I()},[]);const Y=(0,a.useMemo)(()=>{const e=v.trim().toLowerCase();return n.filter(t=>{if(c&&"all"!==c&&Number(t.tenant_id)!==Number(c))return!1;if(p&&"all"!==p&&t.role!==p)return!1;if(!e)return!0;return"".concat(t.id||""," ").concat(t.user_id||""," ").concat(t.role||""," ").concat(t.user_full_name||""," ").concat(t.user_email||""," ").concat(t.tenant_name||""," ").concat(t.tenant_slug||"").toLowerCase().includes(e)})},[n,v]),H=e=>{P({id:e.id,user_id:e.user_id?String(e.user_id):"",role:e.role||"agent"}),O(!0)},V=e=>{y&&X({title:"Silme onay\u0131",content:"Bu tenant \xfcyeli\u011fi kald\u0131r\u0131lacak.",okText:"Sil",okType:"danger",cancelText:"Vazge\xe7",onOk:async()=>{try{await f({id:e.id,tenant_id:y}),i.message.success("\xdcyelik kald\u0131r\u0131ld\u0131."),G(y)}catch(t){i.message.error("Silme ba\u015far\u0131s\u0131z.")}}})},U=((0,a.useMemo)(()=>k.reduce((e,t)=>
1(e[t.id]=t.name,e),{}),[k]),(0,a.useMemo)(()=>{const e={total:n.length,owner:0,admin:0,agent:0,viewer:0};return n.forEach(t=>{"owner"===t.role?e.owner++:"admin"===t.role?e.admin++:"agent"===t.role?e.agent++:"viewer"===t.role&&e.viewer++}),e},[n])),q={owner:"purple",admin:"blue",agent:"cyan",viewer:"default"},te=[{title:"ID",dataIndex:"id",width:60,fixed:"left",sorter:Z("id"),defaultSortOrder:"descend"},{title:"\u015eirket",dataIndex:"tenant_id",width:200,sorter:Z("tenant_id"),render:(e,t)=>(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:600,fontSize:12},children:["#",t.tenant_id," \xb7 ",t.tenant_name||"\u2014"]}),t.tenant_slug?(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0,marginTop:2,fontSize:10},children:t.tenant_slug}):null]})},{title:"\xdcye",dataIndex:"user_full_name",width:180,sorter:Q("user_full_name"),render:(e,t)=>(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontWeight:600,fontSize:12},children:t.user_full_name||"(isimsiz)"}),(0,D.jsxs)("div",{style:{fontSize:10,color:"var(--cp-muted)"},children:["#",t.user_id]})]})},{title:"Rol",dataIndex:"role",width:100,sorter:Q("role"),render:e=>(0,D.jsx)(i.Tag,{color:q[e]||"default",children:e||"agent"})},{title:"\u0130leti\u015fim",key:"contact",width:230,render:(e,t)=>(0,D.jsx)(R,{email:t.user_email,phone:t.contact_number,layout:"compact"})},{title:"Kay\u0131t",dataIndex:"created_at",width:100,sorter:(e,t)=>new Date(e.created_at||0).getTime()-new Date(t.created_at||0).getTime(),render:e=>$(e)},{title:"\u0130\u015flem",key:"actions",width:160,fixed:"right",render:(e,t)=>(0,D.jsxs)("div",{style:{display:"flex",gap:4},onClick:e=>e.stopPropagation(),children:[(0,D.jsx)(i.Button,{size:"small",onClick:()=>H(t),children:"D\xfczenle"}),(0,D.jsx)(i.Button,{size:"small",type:"danger",onClick:()=>V(t),children:"Sil"})]})}],ne=(e,t,n)=>(0,D.jsx)(i.Col,{xs:12,sm:6,md:4,children:(0,D.jsxs)(i.Card,{bodyStyle:{padding:12},style:{background:n+"0d",border:"1px solid "+n+"33"},children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-faint)",fontWeight:700,letterSpacing:.5},children:e}),(0,D.jsx)("div",{style:{fontSize:22,fontWeight:800,color:n},children:t})]})});return(0,D.jsxs)("div",{style:{padding:z?0:4},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16,flexWrap:"wrap",gap:12},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h2",{style:{color:"var(--cp-title)",margin:0,fontSize:20,fontWeight:800},children:"\u015eirket \xdcyeleri"}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",fontSize:12,marginTop:4},children:"T\xfcm tenant'lar\u0131n kullan\u0131c\u0131lar\u0131 ve rolleri"})]}),(0,D.jsx)(i.Button,{type:"primary",onClick:()=>{t.resetFields(),t.setFieldsValue({role:"agent"}),W(!0)},disabled:!y,children:"+ Yeni \xdcye (tenant se\xe7iliyse)"})]}),(0,D.jsxs)(i.Row,{gutter:[10,10],style:{marginBottom:16},children:[ne("TOPLAM",U.total,"var(--cp-muted)"),ne("OWNER",U.owner,"#a855f7"),ne("ADMIN",U.admin,"var(--cp-info)"),ne("AGENT",U.agent,"#06b6d4"),ne("VIEWER",U.viewer,"var(--cp-faint)")]}),(0,D.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:12,padding:10,background:"rgba(255,255,255,0.02)",borderRadius:10,border:"1px solid rgba(255,255,255,0.05)",alignItems:"center"},children:[(0,D.jsxs)(i.Select,{showSearch:!0,allowClear:!0,value:c||"all",onChange:e=>{if(!e||"all"===e)return u("all"),void b(null);u(String(e)),b(Number(e))},placeholder:w?"Y\xfckleniyor...":"T\xfcm tenantlar",style:{minWidth:180,flex:"1 1 180px",maxWidth:280},optionFilterProp:"children",loading:w,children:[(0,D.jsx)(J,{value:"all",children:"T\xfcm Tenantlar"},"all"),k.map(e=>(0,D.jsxs)(J,{value:String(e.id),children:[e.name," #",e.id]},e.id))]}),(0,D.jsxs)(i.Select,{value:p,onChange:e=>m(e),style:{width:140},children:[(0,D.jsx)(J,{value:"all",children:"T\xfcm Roller"}),(0,D.jsx)(J,{value:"owner",children:"Owner"}),(0,D.jsx)(J,{value:"admin",children:"Admin"}),(0,D.jsx)(J,{value:"agent",children:"Agent"}),(0,D.jsx)(J,{value:"viewer",children:"Viewer"})]}),(0,D.jsx)(i.Input,{value:v,onChange:e=>j(e.target.value),placeholder:"\xdcye, email, \u015firket, slug ara",prefix:(0,D.jsx)(i.Icon,{type:"search"}),allowClear:!0,style:{minWidth:200,flex:"1 1 200px",maxWidth:320}}),(0,D.jsxs)(i.Button,{onClick:I,loading:l,children:[(0,D.jsx)(i.Icon,{type:"reload"})," Yenile"]}),(0,D.jsxs)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:[Y.length," / ",n.length]})]}),z?(0,D.jsx)("div",{children:l&&0===n.length?(0,D.jsx)("div",{style:{textAlign:"center",padding:30,color:"var(--cp-faint)"},children:"Y\xfckleniyor..."}):0===Y.length?(0,D.jsx)(i.Empty,{description:"\xdcye yok"}):Y.map(e=>(0,D.jsxs)("div",{style:{padding:14,background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:12,marginBottom:10},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontWeight:700,fontSize:14},children:e.user_full_name||"(isimsiz)"}),(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginTop:2},children:["#",e.user_id," \xb7 ",e.tenant_name||"\u2014"]})]}),(0,D.jsx)(i.Tag,{color:q[e.role]||"default",style:{margin:0},children:e.role||"agent"})]}),(0,D.jsx)("div",{style:{marginBottom:8},children:(0,D.jsx)(R,{email:e.user_email,phone:e.contact_number,layout:"compact"})}
1),(0,D.jsxs)("div",{style:{fontSize:10,color:"var(--cp-faint)",marginBottom:8},children:["Kay\u0131t: ",$(e.created_at)]}),(0,D.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,D.jsx)(i.Button,{size:"default",onClick:()=>H(e),style:{minHeight:36},children:"D\xfczenle"}),(0,D.jsx)(i.Button,{size:"default",type:"danger",onClick:()=>V(e),style:{minHeight:36},children:"Sil"})]})]},e.id))}):(0,D.jsx)(i.Table,{rowKey:"id",loading:l,columns:te,dataSource:Y,size:"small",pagination:{pageSize:30,showSizeChanger:!0,showTotal:e=>"Toplam "+e},scroll:{x:"max-content"},locale:{emptyText:(0,D.jsx)(i.Empty,{description:"\xdcye yok"})}}),(0,D.jsx)(i.Modal,{visible:C,title:"Yeni Tenant \xdcyesi",okText:"Kaydet",cancelText:"Vazge\xe7",onOk:()=>{y?t.validateFields(async(e,n)=>{if(e)return;const a=ee(n.user_id);if(a){K(!0);try{await h({tenant_id:y,user_id:a,role:n.role||"agent"}),i.message.success("Tenant \xfcyesi eklendi."),t.resetFields(),W(!1),G(y)}catch(r){const e=r&&r.response&&r.response.data&&r.response.data.message?r.response.data.message:"Tenant \xfcyesi eklenemedi.";i.message.error(e)}finally{K(!1)}}else i.message.error("Ge\xe7erli bir user_id girin.")}):i.message.error("\xd6nce tenant_id ile listeleyin.")},onCancel:()=>W(!1),confirmLoading:N,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"User ID",children:t.getFieldDecorator("user_id",{rules:[{required:!0,message:"user_id zorunlu"}]})((0,D.jsx)(i.Input,{placeholder:"User ID"}))}),(0,D.jsx)(i.Form.Item,{label:"Rol",children:t.getFieldDecorator("role",{initialValue:"agent"})((0,D.jsxs)(i.Select,{children:[(0,D.jsx)(J,{value:"owner",children:"owner"}),(0,D.jsx)(J,{value:"admin",children:"admin"}),(0,D.jsx)(J,{value:"agent",children:"agent"}),(0,D.jsx)(J,{value:"viewer",children:"viewer"})]}))})]})}),(0,D.jsx)(i.Modal,{visible:F,title:"Tenant \xdcyesini D\xfczenle",okText:"G\xfcncelle",cancelText:"Vazge\xe7",onOk:async()=>{if(y&&E.id){L(!0);try{await x({id:E.id,tenant_id:y,role:E.role}),i.message.success("Tenant \xfcyesi g\xfcncellendi."),O(!1),G(y)}catch(e){i.message.error("G\xfcncelleme ba\u015far\u0131s\u0131z.")}finally{L(!1)}}},onCancel:()=>O(!1),confirmLoading:M,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"User ID",children:(0,D.jsx)(i.Input,{value:E.user_id,disabled:!0})}),(0,D.jsx)(i.Form.Item,{label:"Rol",children:(0,D.jsxs)(i.Select,{value:E.role,onChange:e=>P((0,B.A)((0,B.A)({},E),{},{role:e})),children:[(0,D.jsx)(J,{value:"owner",children:"owner"}),(0,D.jsx)(J,{value:"admin",children:"admin"}),(0,D.jsx)(J,{value:"agent",children:"agent"}),(0,D.jsx)(J,{value:"viewer",children:"viewer"})]})})]})})]})});var ne=[".mcl-wrap { display: flex; flex-direction: column; gap: 10px; }",".mcl-card {","  background: rgba(255,255,255,0.03);","  border: 1px solid rgba(255,255,255,0.06);","  border-radius: 12px;","  padding: 14px;","  color: var(--cp-text);","  transition: background 0.18s ease, transform 0.18s ease;","}",".mcl-card:active {","  background: rgba(139,92,246,0.06);","  transform: scale(0.995);","}",".mcl-card:hover { background: rgba(255,255,255,0.05); }",".mcl-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }",".mcl-row:last-child { margin-bottom: 0; }",".mcl-title { font-size: 14px; font-weight: 700; color: var(--cp-title); }",".mcl-sub { font-size: 12px; color: var(--cp-muted); }",".mcl-meta { font-size: 11px; color: var(--cp-faint); }",".mcl-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.04); }"].join("\n");const ae=function(e){var t=e.data||[],n=e.render,a=e.onItemClick,i=e.rowKey||"id";return n?(0,D.jsxs)("div",{className:"mcl-wrap",children:[(0,D.jsx)("style",{children:ne}),t.map(function(e,t){var r=void 0!==e[i]?e[i]:t;return(0,D.jsx)("div",{className:"mcl-card",onClick:function(){a&&a(e)},style:{cursor:a?"pointer":"default"},children:n(e,t)},r)})]}):null};var ie=["@keyframes sk-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.9; } }",".sk-wrap { width: 100%; }",".sk-row { height: 42px; background: linear-gradient(90deg, rgba(139,92,246,0.05) 0%, rgba(139,92,246,0.12) 50%, rgba(139,92,246,0.05) 100%); background-size: 200% 100%; border-radius: 8px; margin-bottom: 6px; animation: sk-pulse 1.4s ease-in-out infinite, sk-slide 2s ease-in-out infinite; }",".sk-row.sk-header { height: 32px; background: rgba(139,92,246,0.08); margin-bottom: 10px; }",".sk-card { background: linear-gradient(90deg, rgba(139,92,246,0.05) 0%, rgba(139,92,246,0.12) 50%, rgba(139,92,246,0.05) 100%); border-radius: 14px; animation: sk-pulse 1.4s ease-in-out infinite; }",".sk-text { height: 14px; background: rgba(139,92,246,0.08); border-radius: 4px; margin-bottom: 8px; animation: sk-pulse 1.4s ease-in-out infinite; }","@keyframes sk-slide { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }"].join("\n");const re=function(e){var t=e.type||"text",n=e.rows||3,a=e.height||80;return"table"===t?(0,D.jsxs)("div",{className:"sk-wrap",children:[(0,D.jsx)("style",{children:ie}),(0,D.jsx)("div",{className:"sk-row sk-header"}),Array.from({length:n}).map(function(e,t){return(0,D.jsx)("div",{className:"sk-row",style:{animationDelay:.
108*t+"s"}},t)})]}):"card"===t?(0,D.jsxs)("div",{className:"sk-wrap",children:[(0,D.jsx)("style",{children:ie}),(0,D.jsx)("div",{className:"sk-card",style:{height:a}})]}):(0,D.jsxs)("div",{className:"sk-wrap",children:[(0,D.jsx)("style",{children:ie}),Array.from({length:n}).map(function(e,t){return(0,D.jsx)("div",{className:"sk-text",style:{width:70+30*Math.random()+"%",animationDelay:.1*t+"s"}},t)})]})};var le=i.Select.Option;var oe=[".sdt-wrap { width: 100%; }",".sdt-filter-card {","  position: sticky;","  top: 0;","  z-index: 15;","  margin-bottom: 14px;","  background: rgba(12,14,22,0.92) !important;","  backdrop-filter: blur(10px);","  border: 1px solid rgba(255,255,255,0.05) !important;","  border-radius: 12px !important;","}",".sdt-body { min-height: 200px; }",".sdt-empty { text-align: center; padding: 60px 20px; color: var(--cp-faint); }",".sdt-mobile-pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 12px; margin-top: 12px; background: rgba(255,255,255,0.025); border: 1px solid rgba(255,255,255,0.05); border-radius: 12px; }",".sdt-page-label { color: var(--cp-muted); font-size: 11px; font-weight: 700; }",".sdt-bulk-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; background: rgba(139,92,246,0.08); border: 1px solid rgba(139,92,246,0.2); border-radius: 10px; }",".sdt-bulk-count { color: var(--cp-violet); font-weight: 700; font-size: 12px; }","@media(max-width: 767px) { .sdt-filter-card .ant-col { margin-bottom: 6px; } .sdt-filter-card { top: 56px; } }"].join("\n");const se=function(e){var t=e.loadFn,n=e.columns||[],r=e.filters||[],l=e.searchPlaceholder||"Ara...",o=e.rowKey||"id",s=e.rowClick,d=e.mobileRender,c=e.defaultLimit||20,u=e.refreshSignal,p=e.extraHeader,m=e.clientSideFilter,g=e.tableId||"default",h=e.bulkActions,x=e.rowClassName,f=e.exportFilename||"export",y=(0,a.useState)([]),b=y[0],v=y[1],j=(0,a.useState)(!1),k=j[0],_=j[1],w=(0,a.useState)(""),S=w[0],z=w[1],A=(0,a.useState)(""),T=A[0],I=A[1],C=(0,a.useState)({}),B=C[0],W=C[1],N=(0,a.useState)(1),K=N[0],F=N[1],O=(0,a.useState)(c),M=O[0],L=O[1],R=(0,a.useState)(0),E=R[0],P=R[1],G=(0,a.useState)(window.innerWidth<768),Y=G[0],H=G[1],V=(0,a.useState)([]),U=V[0],q=V[1],J=e.defaultSort||{field:null,order:null},X=(0,a.useState)({field:J.field||null,order:J.order||null}),Z=X[0],Q=X[1],$="sdt_cols_"+g,ee=(0,a.useState)(function(){try{var e=localStorage.getItem($);if(e)return JSON.parse(e)}catch(a){}var t={};return n.forEach(function(e){t[e.dataIndex||e.key||e.title]=!0}),t}),te=ee[0],ne=ee[1];(0,a.useEffect)(function(){try{localStorage.setItem($,JSON.stringify(te))}catch(e){}},[te,$]),(0,a.useEffect)(function(){var e=function(){H(window.innerWidth<768)};return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]),(0,a.useEffect)(function(){var e=setTimeout(function(){I(S),F(1)},300);return function(){clearTimeout(e)}},[S]);var ie=(0,a.useRef)(t);(0,a.useEffect)(function(){ie.current=t},[t]);var se=(0,a.useCallback)(function(){var e=ie.current;if(e){_(!0);var t={page:K,limit:M,search:T,filters:B};Promise.resolve(e(t)).then(function(e){if(!e)return v([]),void P(0);e.data&&"number"===typeof e.total?(v(Array.isArray(e.data)?e.data:[]),P(e.total)):Array.isArray(e)?(v(e),P(e.length)):e.data&&Array.isArray(e.data)?(v(e.data),P(e.data.length)):(v([]),P(0))}).catch(function(){v([]),P(0)}).finally(function(){_(!1)})}},[K,M,T,B]);(0,a.useEffect)(function(){se()},[se,u]);var de=(0,a.useMemo)(function(){var e=b;if(m){var t=String(T||"").trim().toLowerCase();e=e.filter(function(e){for(var n in B)if(void 0!==B[n]&&""!==B[n]&&e[n]!==B[n])return!1;return!t||-1!==JSON.stringify(e).toLowerCase().indexOf(t)})}return Z.field&&Z.order&&(e=e.slice().sort(function(e,t){var n,a=e[Z.field],i=t[Z.field];return null!==a&&void 0!==a||(a=""),null!==i&&void 0!==i||(i=""),n="number"===typeof a&&"number"===typeof i?a-i:String(a).localeCompare(String(i),"tr"),"asc"===Z.order?n:-n})),e},[b,T,B,m,Z]),ce=(0,a.useMemo)(function(){if(!m)return de;var e=(K-1)*M;return de.slice(e,e+M)},[de,K,M,m]),ue=m?ce:b,pe=m?de.length:E,me=(0,a.useMemo)(function(){return n.filter(function(e){var t=e.dataIndex||e.key||e.title;return!1!==te[t]}).map(function(e){var t=e.dataIndex||e.key;
1if(!t||!1===e.sorter)return e;var n=Z.field===t,a=e.title,r=(0,D.jsxs)("span",{style:{cursor:"pointer",userSelect:"none",display:"inline-flex",alignItems:"center",gap:4},title:"Siralamak icin tikla",onClick:function(e){e.stopPropagation(),n?"asc"===Z.order?Q({field:t,order:"desc"}):Q({field:null,order:null}):Q({field:t,order:"asc"})},children:[a,n?(0,D.jsx)(i.Icon,{type:"asc"===Z.order?"caret-up":"caret-down",style:{fontSize:10,color:"#8b5cf6"}}):(0,D.jsx)("span",{style:{fontSize:9,color:"rgba(148,163,184,0.5)",lineHeight:1},children:"\u2195"})]});return Object.assign({},e,{title:r})})},[n,Z,te]),ge=function(e){var t=e&&U.length?ue.filter(function(e){return-1!==U.indexOf(e[o])}):de;if(t.length){var n=Object.keys(t[0]||{}).filter(function(e){var n=t[0][e];return"object"!==typeof n||null===n}),a=[n.join(",")];t.forEach(function(e){a.push(n.map(function(t){var n=e[t];if(null===n||void 0===n)return"";var a=String(n).replace(/"/g,'""');return a.indexOf(",")>=0||a.indexOf('"')>=0||a.indexOf("\n")>=0?'"'+a+'"':a}).join(","))});var r=new Blob(["\ufeff"+a.join("\n")],{type:"text/csv;charset=utf-8;"}),l=document.createElement("a");l.href=URL.createObjectURL(r),l.download=f+"_"+(new Date).toISOString().slice(0,10)+".csv",l.click(),i.message.success(t.length+" kayit export edildi")}else i.message.warning("Export icin veri yok")},he=(0,D.jsx)(i.Menu,{style:{maxHeight:320,overflowY:"auto",background:"var(--cp-bg2)"},children:n.map(function(e){var t=e.dataIndex||e.key||e.title,n="string"===typeof e.title?e.title:e.dataIndex||e.key;return(0,D.jsx)(i.Menu.Item,{onClick:function(e){e.domEvent.stopPropagation()},children:(0,D.jsx)(i.Checkbox,{checked:!1!==te[t],onChange:function(e){var n=Object.assign({},te);n[t]=e.target.checked,ne(n)},style:{color:"var(--cp-text)"},children:n})},t)})}),xe=h&&!Y?{selectedRowKeys:U,onChange:function(e){q(e)}}:null;return(0,D.jsxs)("div",{className:"sdt-wrap",children:[(0,D.jsx)("style",{children:oe}),p,(0,D.jsxs)(i.Card,{className:"sdt-filter-card",bordered:!1,bodyStyle:{padding:Y?10:12},children:[(0,D.jsxs)(i.Row,{gutter:[10,10],type:"flex",align:"middle",children:[r.map(function(e){return(0,D.jsx)(i.Col,{xs:24,sm:12,md:4,children:(0,D.jsx)(i.Select,{allowClear:!0,value:B[e.key],onChange:function(t){!function(e,t){var n=Object.assign({},B);void 0===t||""===t?delete n[e]:n[e]=t,W(n),F(1)}(e.key,t)},placeholder:e.placeholder,style:{width:"100%"},children:(e.options||[]).map(function(e){return(0,D.jsx)(le,{value:e.value,children:e.label},e.value)})})},e.key)}),(0,D.jsx)(i.Col,{xs:24,sm:16,md:r.length?14-2*r.length:14,children:(0,D.jsx)(i.Input,{value:S,onChange:function(e){z(e.target.value)},placeholder:l,prefix:(0,D.jsx)(i.Icon,{type:"search"}),allowClear:!0})}),(0,D.jsx)(i.Col,{xs:12,sm:4,md:3,children:(0,D.jsx)(i.Button,{onClick:function(){z(""),W({}),F(1)},block:!0,icon:"close-circle",children:"Temizle"})}),(0,D.jsx)(i.Col,{xs:12,sm:4,md:3,children:(0,D.jsx)(i.Dropdown,{overlay:(0,D.jsxs)(i.Menu,{style:{background:"var(--cp-bg2)"},children:[(0,D.jsxs)(i.Menu.Item,{onClick:function(){ge(!1)},children:[(0,D.jsx)(i.Icon,{type:"download"})," Tumunu Export"]}),U.length>0&&(0,D.jsxs)(i.Menu.Item,{onClick:function(){ge(!0)},children:[(0,D.jsx)(i.Icon,{type:"check-square"})," Secili ",U.length]}),(0,D.jsx)(i.Menu.Divider,{}),(0,D.jsx)(i.Menu.SubMenu,{title:(0,D.jsxs)("span",{children:[(0,D.jsx)(i.Icon,{type:"setting"})," Kolonlar"]}),children:he.props.children})]}),trigger:["click"],children:(0,D.jsx)(i.Button,{block:!0,icon:"more",children:Y?"":"Araclar"})})})]}),U.length>0&&h&&!Y&&(0,D.jsxs)("div",{className:"sdt-bulk-bar",children:[(0,D.jsxs)("span",{className:"sdt-bulk-count",children:[U.length," secildi"]}),(0,D.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[h.map(function(e){return(0,D.jsx)(i.Button,{size:"small",type:"danger"===e.type?"danger":"primary"===e.type?"primary":"default",icon:e.icon,onClick:function(){var t=ue.filter(function(e){return-1!==U.indexOf(e[o])});e.onClick(t,function(){q([])})},children:e.label},e.key)}),(0,D.jsx)(i.Button,{size:"small",onClick:function(){q([])},icon:"close",children:"Iptal"})]})]})]}),(0,D.jsxs)("div",{className:"sdt-body",children:[k&&!ue.length?(0,D.jsx)(re,{rows:8,type:"table"}):ue.length?Y&&d?(0,D.jsx)(ae,{data:ue,render:d,onItemClick:s,rowKey:o}):(0,D.jsx)(i.Table,{dataSource:ue,rowKey:o,size:"small",loading:k,scroll:{x:"max-content"},rowSelection:xe,rowClassName:x,onRow:function(e){return{onClick:function(){s&&s(e)},style:s?{cursor:"pointer"}:{}}},columns:me,pagination:{current:K,pageSize:M,total:pe,showSizeChanger:!0,pageSizeOptions:["10","20","50","100"],showTotal:function(e,t){return t[0]+"-"+t[1]+" / "+e},onChange:function(e,t){F(e),t!==M&&L(t)},onShowSizeChange:function(e,t){L(t),F(1)}}}):(0,D.jsx)("div",{className:"sdt-empty",children:(0,D.jsx)(i.Empty,{description:(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"Kayit bulunamadi"})})}),Y&&d&&ue.length>0&&(0,D.jsxs)("div",{className:"sdt-mobile-pager",children:[(0,D.jsx)(i.Button,{disabled:K<=1,onClick:function(){F(K-1),window.scrollTo({top:0,behavior:"smooth"})},icon:"left",children:"Onceki"}),(0,D.jsxs)("span",{className:"sdt-page-label",children:[K," / ",Math.max(1,Math.ceil(pe/M))]}),(0,D.jsxs)(i.Button,{disabled:K>=Math.ceil(pe/M),onClick:function(){F(K+1),window.scrollTo({top:0,behavior:"smooth"})},children:["Sonraki ",(0,D.jsx)(i.Icon,{type:"right"})]})]})]})]})},de=e=>{const t=Number(e||0);return t>=1e3?(t/1e3).toFixed(t%1e3===0?0:1)+"k":String(t)},ce=e=>{let{used:t=0,total:n=0,remaining:a,addon:r=0,plan:l=0,size:o="sm",variant:s="badge"}=e;if(!n||n<=0)return(0,D.jsx)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:"\u2014"});const d=null!=a?a:Math.max(0,n-t),c=Math.min(100,Math.round(t/n*100)),u=(e=>e>=90?"#ef4444":e>=70?"var(--cp-warn)":"var(--cp-ok)")(c),p=(0,D.jsxs)("div",{style:{fontSize:11,lineHeight:1.6},children:[(0,D.jsxs)("div",{children:["Plan kotasi: ",(0,D.jsx)("strong",{children:l})]}),(0,D.jsxs)("div",{children:["Addon: ",(0,D.jsx)("strong",{children:r})]}),(0,D.jsxs)("div",{children:["Toplam: ",(0,D.jsx)("strong",{children:n})]}),(0,D.jsxs)("div",{children:["Kullanilan: ",(0,D.jsx)("strong",{children:t})," (%",c,")"]}),(0,D.jsxs)("div",{style:{color:"var(--cp-ok)"},children:["Kalan: ",(0,D.jsx)("strong",{children:d})]})]});if("ring"===s){const e="lg"===o?84:"md"===o?64:48,t="lg"===o?8:6,n=(e-t)/2,a=2*Math.PI*n,r=c/100*a;return(0,D.jsx)(i.Tooltip,{title:p,children:(0,D.jsxs)("div",{style:{position:"relative",width:e,height:e,display:"inline-block"},children:[(0,D.jsxs)("svg",{width:e,height:e,style:{transform:"rotate(-90deg)"},children:[(0,D.jsx)("circle",{cx:e/2,cy:e/2,r:n,stroke:"rgba(255,255,255,0.08)",strokeWidth:t,fill:"none"}),(0,D.jsx)("circle",{cx:e/2,cy:e/2,r:n,stroke:u,strokeWidth:t,fill:"none",strokeDasharray:"".concat(r," ").concat(a),strokeLinecap:"round"})]}),(0,D.jsxs)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",lineHeight:1},children:[(0,D.jsxs)("div",{style:{fontSize:"lg"===o?16:"md"===o?13:11,fontWeight:800,color:"var(--cp-text)"},children:["%",c]}),(0,D.jsx)("div",{style:{fontSize:9,color:"var(--cp-muted)",marginTop:1},children:"kullanildi"})]})]})})}return"bar"===s?(0,D.jsx)(i.Tooltip,{title:p,children:(0,D.jsxs)("div",{style:{minWidth:110},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,
1color:"var(--cp-muted)",marginBottom:2},children:[(0,D.jsxs)("span",{children:[de(d)," kaldi"]}),(0,D.jsxs)("span",{children:["%",c]})]}),(0,D.jsx)("div",{style:{height:6,background:"rgba(255,255,255,0.08)",borderRadius:3,overflow:"hidden"},children:(0,D.jsx)("div",{style:{height:"100%",width:"".concat(c,"%"),background:u,transition:"width .3s"}})})]})}):(0,D.jsx)(i.Tooltip,{title:p,children:(0,D.jsxs)("div",{style:{display:"inline-flex",flexDirection:"column",gap:2,padding:"3px 8px",borderRadius:6,background:"".concat(u,"1a"),border:"1px solid ".concat(u,"40"),fontSize:11,lineHeight:1.2,minWidth:80},children:[(0,D.jsxs)("span",{style:{color:u,fontWeight:700},children:[de(d)," / ",de(n)]}),(0,D.jsxs)("span",{style:{color:"var(--cp-muted)",fontSize:9},children:["%",c," kullanildi"]})]})})};var ue=i.Select.Option,pe=i.Modal.confirm,me=function(e){if(!e)return"-";try{return new Date(e).toLocaleDateString("tr-TR")}catch(t){return"-"}},ge=function(e){if(!e)return"-";try{var t=(Date.now()-new Date(e).getTime())/1e3;return t<60?"az once":t<3600?Math.floor(t/60)+"d once":t<86400?Math.floor(t/3600)+"s once":t<2592e3?Math.floor(t/86400)+"g once":t<31536e3?Math.floor(t/2592e3)+"ay once":Math.floor(t/31536e3)+"y once"}catch(n){return"-"}},he={active:"green",trial:"blue",suspended:"orange",deleted:"red"},xe={active:"Aktif",trial:"Deneme",suspended:"Askida",deleted:"Silindi"},fe=function(e){var t=String(e||"").replace(/[^0-9+]/g,"");return t?"https://wa.me/"+t.replace(/^\+/,""):null};const ye=(0,l.Ng)(null,{userLoginAs:o.T6})(function(e){var t=e.userLoginAs,n=(0,a.useState)(null),r=n[0],l=n[1],o=(0,a.useState)(null),c=o[0],u=o[1],p=(0,a.useState)(!1),m=p[0],g=p[1],h=(0,a.useState)(null),x=h[0],f=h[1],y=(0,a.useState)([]),b=y[0],v=y[1],j=(0,a.useState)(""),_=j[0],w=j[1],S=(0,a.useState)(null),z=S[0],T=S[1],I=(0,a.useState)(0),C=I[0],B=I[1],W=(0,a.useState)({total:0,active:0,trial:0,suspended:0}),N=W[0],K=W[1],F=(0,a.useState)(window.innerWidth<768),O=F[0],M=F[1],L=(0,a.useState)(null),E=L[0],P=L[1],G=(0,a.useState)(""),Y=G[0],H=G[1],V=(0,a.useState)([]),U=V[0],q=V[1],J=(0,a.useState)([]),X=J[0],Z=J[1];(0,a.useEffect)(function(){var e=function(){M(window.innerWidth<768)};return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]);(0,a.useEffect)(function(){k().then(function(e){var t=e&&e.data&&e.data.data?e.data.data:[];v(Array.isArray(t)?t:[])}).catch(function(){})},[]);var Q=function(e){l(e),g(!0),u(null),q([]),Z([]),s.Ay.get(d.A.superAdmin.tenantDetail+"/"+e.id).then(function(e){u(e&&e.data&&e.data.data||null)}).catch(function(){i.message.error("Detay yuklenemedi")}).finally(function(){g(!1)}),s.Ay.get(d.A.superAdmin.tenantRecentAiMessages.replace(":id",e.id)+"?limit=5").then(function(e){var t=e&&e.data&&e.data.data?e.data.data:[];q(Array.isArray(t)?t:[])}).catch(function(){q([])}),s.Ay.get(d.A.superAdmin.tenantUsageTrend.replace(":id",e.id)+"?days=30").then(function(e){var t=e&&e.data&&e.data.data&&e.data.data.points?e.data.data.points:[];Z(Array.isArray(t)?t:[])}).catch(function(){Z([])})},$=function(e,t,n){var a={tenant_id:e,action:t};n&&Object.assign(a,n),s.Ay.post(d.A.superAdmin.tenantAction,a).then(function(t){i.message.success(t&&t.data&&t.data.message||"Islem tamamlandi"),B(function(e){return e+1}),r&&r.id===e&&Q(r)}).catch(function(e){i.message.error(e&&e.response&&e.response.data&&e.response.data.message||"Islem basarisiz")})},ee=function(e){e&&(T(e),pe({title:"Kullanici olarak giris",content:"Bu kullanicinin paneline gecilecek.",okText:"Giris Yap",cancelText:"Vazgec",onOk:function(){return t(e,{persist:!1}).then(function(t){if(t&&0===t.error&&t.token&&t.user){var n=e+"-"+Date.now()+"-"+Math.random().toString(36).slice(2,8);localStorage.setItem("impersonation:"+n,JSON.stringify({token:t.token,user:t.user})),i.message.success("Giris yapildi"),window.open("/panel?impersonation="+encodeURIComponent(n),"_blank","noopener")}else i.message.error("Giris basarisiz")}).catch(function(){i.message.error("Giris basarisiz")}).finally(function(){T(null)})},onCancel:function(){T(null)}}))},te=c||{},ne=te.tenant||r||{},ae=te.subscription||{},ie=te.members||[],re=te.whatsapp_accounts||[],le=ie.find(function(e){return"owner"===e.role}),oe=function(e){return"connected"===e?"\u2713":"needs_attention"===e||"disconnected"===e?"\u26a0":"\u2022"},de=function(e){return"connected"===e?"var(--cp-ok)":"needs_attention"===e?"var(--cp-warn)":"disconnected"===e?"#ef4444":"var(--cp-muted)"},ye=function(e){var t=Array.isArray(e.wa_handles)?e.wa_handles:[],n=Array.isArray(e.ig_handles)?e.ig_handles:[];return t.length||n.length?(0,D.jsxs)("div",{style:{padding:"6px 4px",maxWidth:320},children:[t.length>0?(0,D.jsxs)("div",{style:{marginBottom:6}
1,children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-muted)",fontWeight:700,marginBottom:4},children:"WHATSAPP"}),t.map(function(e,t){return(0,D.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:6,fontSize:12,marginBottom:3},children:[(0,D.jsx)("span",{style:{color:de(e.status),fontWeight:700,minWidth:14},children:oe(e.status)}),(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{color:"var(--cp-text)"},children:e.phone||"\u2014"}),e.label?(0,D.jsx)("div",{style:{color:"var(--cp-muted)",fontSize:11},children:e.label}):null,e.last_error_short?(0,D.jsx)("div",{style:{color:"var(--cp-warn)",fontSize:11},children:e.last_error_short}):null]})]},"wa-"+t)})]}):null,n.length>0?(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-muted)",fontWeight:700,marginBottom:4},children:"INSTAGRAM"}),n.map(function(e,t){return(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,marginBottom:3},children:[(0,D.jsx)("span",{style:{color:de(e.status),fontWeight:700,minWidth:14},children:oe(e.status)}),(0,D.jsx)("div",{style:{color:"var(--cp-text)"},children:e.username?"@"+e.username:e.ig_user_id||"\u2014"})]},"ig-"+t)})]}):null]}):(0,D.jsx)("div",{style:{padding:6,color:"var(--cp-text2)",fontSize:12},children:"Hi\xe7 kanal ba\u011fl\u0131 de\u011fil"})},be=function(e){var t=Number(e.wa_connected||0),n=Number(e.wa_issues||0),a=Number(e.ig_connected||0),r=Number(e.ig_issues||0);if(!t&&!n&&!a&&!r)return(0,D.jsx)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:"\u2014"});var l=(0,D.jsxs)("div",{style:{fontSize:11,display:"flex",flexDirection:"column",gap:2,cursor:"help"},children:[t||n?(0,D.jsxs)("div",{children:[t?(0,D.jsxs)(i.Tag,{color:"green",style:{margin:0,marginRight:4},children:["WA ",t]}):null,n?(0,D.jsxs)(i.Tag,{color:"orange",style:{margin:0},children:["\u26a0 ",n]}):null]}):null,a||r?(0,D.jsxs)("div",{children:[a?(0,D.jsxs)(i.Tag,{color:"magenta",style:{margin:0,marginRight:4},children:["IG ",a]}):null,r?(0,D.jsxs)(i.Tag,{color:"orange",style:{margin:0},children:["\u26a0 ",r]}):null]}):null]});return(0,D.jsx)(i.Tooltip,{title:ye(e),placement:"left",children:l})},ve=[{title:"Sirket",dataIndex:"name",width:220,fixed:"left",render:function(e,t){return function(e){return(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:700,color:"var(--cp-text)",fontSize:13},children:["#",e.id," \xb7 ",e.name||"\u2014"]}),e.owner_full_name?(0,D.jsx)("div",{style:{color:"var(--cp-muted)",fontSize:11,marginTop:2},children:e.owner_full_name}):null,e.slug?(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0,marginTop:4,fontSize:10},children:e.slug}):null]})}(t)}},{title:"Iletisim",key:"contact",sorter:!1,width:240,render:function(e,t){return(0,D.jsx)(R,{email:t.owner_email,phone:t.contact_number,layout:"compact"})}},{title:"Plan & Kredi",dataIndex:"ai_credit_usage_pct",width:160,render:function(e,t){return function(e){var t,n=Number(e.ai_credit_total||0)>0;return(0,D.jsx)(i.Tooltip,{title:n?(0,D.jsxs)("div",{style:{fontSize:11},children:[(0,D.jsxs)("div",{children:["Plan: ",(0,D.jsx)("strong",{children:e.ai_credit_plan||0})]}),(0,D.jsxs)("div",{children:["Addon: ",(0,D.jsx)("strong",{children:e.ai_credit_addon||0})]}),(0,D.jsxs)("div",{children:["Kullanilan: ",(0,D.jsx)("strong",{children:e.ai_credit_used||0})," (%",e.ai_credit_usage_pct,")"]}),(0,D.jsxs)("div",{style:{color:"var(--cp-ok)"},children:["Kalan: ",(0,D.jsx)("strong",{children:e.ai_credit_remaining})]})]}):null,children:(0,D.jsxs)("div",{style:{fontSize:11,lineHeight:1.4,whiteSpace:"nowrap"},children:[e.plan_name?(0,D.jsx)(i.Tag,{color:"purple",style:{margin:0,fontSize:10},children:e.plan_name}):(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"Plan yok"}),n?(0,D.jsxs)("div",{style:{color:(t=e.ai_credit_usage_pct,t>=90?"#ef4444":t>=70?"var(--cp-warn)":"var(--cp-ok)"),marginTop:2,fontWeight:600},children:[e.ai_credit_remaining,"/",e.ai_credit_total," \xb7 %",e.ai_credit_usage_pct]}):null]})})}(t)}},{title:"Kanal",dataIndex:"wa_total",width:110,render:function(e,t){return be(t)}},{title:"Durum",dataIndex:"status",width:90,render:function(e){return(0,D.jsx)(i.Tag,{color:he[e]||"default",children:xe[e]||e})}},{title:"Son Aktivite",dataIndex:"owner_last_login_at",width:110,render:function(e,t){var n=t.owner_last_login_at||t.created_at||t.createdAt;return(0,D.jsx)("span",{style:{fontSize:11,color:"var(--cp-muted)"},children:ge(n)})}},{title:"Islem",key:"actions",sorter:!1,width:240,fixed:"right",render:function(e,t){return(0,D.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},onClick:function(e){e.stopPropagation()},children:[(0,D.jsx)(i.Button,{size:"small",type:"primary",onClick:function(){Q(t)},children:"Detay"}),(0,D.jsx)(i.Button,{size:"small",onClick:function(){P(t),H("")},style:{color:"var(--cp-warn)",borderColor:"rgba(251,191,36,0.4)"},children:"+Kredi"}),"active"===t.status&&(0,D.jsx)(i.Button,{size:"small",onClick:function(){$(t.id,"suspend")},children:"Askiya Al"}),("suspended"===t.status||"trial"===t.status)&&(0,D.jsx)(i.Button,{size:"small",onClick:function(){$(t.id,"activate")},children:"Aktif Et"})]})}}],je=function(e,t,n){return(0,D.jsxs)("div",{style:{flex:1,minWidth:110,padding:12,background:n?n+"0d":"rgba(255,255,255,0.03)",border:"1px solid "+(n?n+"33":"rgba(255,255,255,0.06)"),borderRadius:12},children:[(0,D.jsx)("div",{style:{fontSize:10,fontWeight:700,color:"var(--cp-faint)",letterSpacing:.5},children:e}),(0,D.jsx)("div",{style:{fontSize:22,fontWeight:800,color:n||"var(--cp-text)",marginTop:2},children:t})]})};return(0,D.jsxs)("div",{style:{padding:O?0:4},children:[(0,D.jsxs)("div",{style:{marginBottom:16},children:[(0,D.jsx)("h2",{style:{color:"var(--cp-title)",margin:0,fontSize:20,fontWeight:800},children:"Sirketler"}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",fontSize:12,marginTop:4},children:"Musteri yonetimi, AI kredi, plan ve kanal saglik ozeti"})]}),(0,D.jsxs)("div",{style:{display:"flex",gap:10,marginBottom:16,flexWrap:"wrap"},children:[je("TOPLAM",N.total,null),je("AKTIF",N.active,"var(--cp-ok)"),je("DENEME",N.trial,"var(--cp-info)"),je("ASKIDA",N.suspended,"var(--cp-warn)")]}),(0,D.jsx)(se,{loadFn:function(){return s.Ay.get(d.A.superAdmin.tenantsEnriched).then(function(e){var t=e&&e.data&&e.data.data?e.data.data:[],n=Array.isArray(t)?t:[],a={total:n.length,active:0,trial:0,suspended:0};
1return n.forEach(function(e){void 0!==a[e.status]&&a[e.status]++}),K(a),n}).catch(function(){return A().then(function(e){var t=e&&e.data&&e.data.data?e.data.data:[],n=Array.isArray(t)?t:[],a={total:n.length,active:0,trial:0,suspended:0};return n.forEach(function(e){void 0!==a[e.status]&&a[e.status]++}),K(a),n}).catch(function(){return[]})})},columns:ve,filters:[{key:"status",placeholder:"Durum",options:[{value:"active",label:"Aktif"},{value:"trial",label:"Deneme"},{value:"suspended",label:"Askida"}]}],searchPlaceholder:"Ad, slug veya email ara",rowKey:"id",rowClick:Q,mobileRender:function(e){return(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"mcl-row",style:{alignItems:"flex-start"},children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"mcl-title",children:["#",e.id," \xb7 ",e.name]}),e.owner_full_name?(0,D.jsx)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginTop:2},children:e.owner_full_name}):null]}),(0,D.jsx)(i.Tag,{color:he[e.status]||"default",children:xe[e.status]||e.status})]}),(0,D.jsx)("div",{className:"mcl-row",style:{marginTop:8},children:(0,D.jsx)(R,{email:e.owner_email,phone:e.contact_number,layout:"stack"})}),(0,D.jsxs)("div",{className:"mcl-row",style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"center",marginTop:10},children:[e.plan_name?(0,D.jsx)(i.Tag,{color:"purple",style:{margin:0},children:e.plan_name}):null,(0,D.jsx)(ce,{used:e.ai_credit_used,total:e.ai_credit_total,remaining:e.ai_credit_remaining,addon:e.ai_credit_addon,plan:e.ai_credit_plan,variant:"bar"})]}),(0,D.jsx)("div",{className:"mcl-row",style:{marginTop:6},children:be(e)}),(0,D.jsx)("div",{className:"mcl-row",style:{marginTop:6},children:(0,D.jsx)("span",{className:"mcl-meta",children:ge(e.owner_last_login_at||e.created_at||e.createdAt)})}),(0,D.jsxs)("div",{className:"mcl-actions",onClick:function(e){e.stopPropagation()},style:{marginTop:10},children:[(0,D.jsx)(i.Button,{size:"default",type:"primary",onClick:function(){Q(e)},style:{minHeight:36},children:"Detay"}),(0,D.jsx)(i.Button,{size:"default",onClick:function(){P(e),H("")},style:{color:"var(--cp-warn)",borderColor:"rgba(251,191,36,0.4)",minHeight:36},children:"+ Kredi"}),"active"===e.status&&(0,D.jsx)(i.Button,{size:"default",onClick:function(){$(e.id,"suspend")},style:{minHeight:36},children:"Askiya Al"}),("suspended"===e.status||"trial"===e.status)&&(0,D.jsx)(i.Button,{size:"default",onClick:function(){$(e.id,"activate")},style:{minHeight:36},children:"Aktif Et"})]})]})},clientSideFilter:!0,refreshSignal:C}),(0,D.jsx)(i.Drawer,{title:ne.name?ne.name+" (#"+ne.id+")":"Sirket Detay",visible:!!r,onClose:function(){l(null),u(null)},width:O?"100%":580,bodyStyle:{background:"var(--cp-bg2)",color:"var(--cp-text)",padding:20},headerStyle:{background:"var(--cp-bg2)",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:m?(0,D.jsx)("div",{style:{textAlign:"center",padding:40,color:"var(--cp-faint)"},children:"Yukleniyor..."}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{style:{display:"flex",gap:8,marginBottom:16,flexWrap:"wrap"},children:[ne.owner_email?(0,D.jsx)(i.Button,{size:"default",href:"mailto:"+ne.owner_email,style:{background:"rgba(96,165,250,0.1)",color:"var(--cp-info)",borderColor:"rgba(96,165,250,0.3)"},children:"\u2709 Email"}):null,ne.contact_number?(0,D.jsx)(i.Button,{size:"default",href:"tel:"+String(ne.contact_number).replace(/[^0-9+]/g,""),style:{background:"rgba(52,211,153,0.1)",color:"#34d399",borderColor:"rgba(52,211,153,0.3)"},children:"\ud83d\udcde Ara"}):null,ne.contact_number?(0,D.jsx)(i.Button,{size:"default",href:fe(ne.contact_number),target:"_blank",style:{background:"rgba(37,211,102,0.1)",color:"#25D366",borderColor:"rgba(37,211,102,0.3)"},children:"\ud83d\udcac WhatsApp"}):null,le&&(0,D.jsx)(i.Button,{size:"default",type:"primary",loading:z===le.user_id,onClick:function(){ee(le.user_id)},children:"\ud83d\udc64 Owner Giris"})]}),(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:14,padding:16,marginBottom:16},children:[(0,D.jsx)("div",{style:{fontSize:13,fontWeight:700,marginBottom:12},children:"Sirket Bilgileri"}),(0,D.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,
1color:"var(--cp-faint)"},children:"Ad"}),(0,D.jsx)("div",{style:{fontWeight:600},children:ne.name||"-"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Slug"}),(0,D.jsx)("div",{children:ne.slug||"-"})]}),le&&le.full_name?(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Owner"}),(0,D.jsx)("div",{style:{fontWeight:600},children:le.full_name})]}):null,(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Email"}),(0,D.jsx)("div",{style:{wordBreak:"break-all"},children:ne.owner_email||"-"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Telefon"}),(0,D.jsx)("div",{children:ne.contact_number||"-"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Durum"}),(0,D.jsx)("div",{children:(0,D.jsx)(i.Tag,{color:he[ne.status],children:xe[ne.status]||ne.status})})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Kayit"}),(0,D.jsx)("div",{children:me(ne.created_at||ne.createdAt)})]})]})]}),(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:14,padding:16,marginBottom:16},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12,flexWrap:"wrap",gap:8},children:[(0,D.jsx)("span",{style:{fontSize:13,fontWeight:700},children:"Abonelik & AI Kredi"}),(0,D.jsx)(i.Button,{size:"small",onClick:function(){f(ne),w(ae.plan_id?String(ae.plan_id):"")},children:"Plan Degistir"})]}),ae.plan_name?(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{display:"flex",gap:16,alignItems:"center",marginBottom:12,flexWrap:"wrap"},children:[(0,D.jsx)(ce,{used:ae.monthly_ai_credit_usage||0,total:(ae.plan_ai_credits||ae.monthly_ai_credit_limit||0)+(ae.addon_ai_credits||0)||ae.monthly_ai_credit_usage||0,remaining:null,addon:ae.addon_ai_credits||0,plan:ae.plan_ai_credits||ae.monthly_ai_credit_limit||0,variant:"ring",size:"lg"}),(0,D.jsx)("div",{style:{flex:1,minWidth:160},children:(0,D.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8,fontSize:11},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"Plan"}),(0,D.jsx)("div",{children:(0,D.jsx)(i.Tag,{color:"purple",children:ae.plan_name})})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"Durum"}),(0,D.jsx)("div",{children:(0,D.jsx)(i.Tag,{color:"active"===ae.status?"green":"orange",children:ae.status})})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"Sonraki Odeme"}),(0,D.jsx)("div",{children:me(ae.next_billing_at)})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"Addon"}),(0,D.jsx)("div",{children:ae.addon_ai_credits||0})]})]})})]}),X&&X.length>0?(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-faint)",fontWeight:700,marginBottom:6},children:"SON 30 GUN AI KREDI KULLANIMI"}),(0,D.jsx)("div",{style:{display:"flex",gap:2,alignItems:"flex-end",height:44,padding:"4px 0"},children:function(){var e=Math.max.apply(null,X.map(function(e){return Number(e.credits||0)}));return e||(e=1),X.map(function(t,n){var a=Math.max(2,Math.round(Number(t.credits||0)/e*38));return(0,D.jsx)("div",{title:t.day+": "+t.credits+" kredi",style:{flex:1,minWidth:4,height:a,background:"var(--cp-ok)",borderRadius:2,opacity:.85}},n)})}()})]}):null]}):(0,D.jsx)("div",{style:{color:"#475569",fontSize:12},children:"Abonelik bulunamadi"})]}),U&&U.length>0?(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:14,padding:16,marginBottom:16},children:[(0,D.jsx)("div",{style:{fontSize:13,fontWeight:700,marginBottom:10},children:"Son AI Mesajlari (Ornek Konusmalar)"}),(0,D.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:U.map(function(e){return(0,D.jsxs)("div",{style:{padding:"8px 10px",background:"rgba(96,165,250,0.06)",borderLeft:"3px solid var(--cp-info)",borderRadius:6,fontSize:12},children:[(0,D.jsxs)("div",{style:{color:"var(--cp-text)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[(e.body||"").slice(0,280),(e.body||"").length>280?"...":""]}
1),(0,D.jsxs)("div",{style:{fontSize:10,color:"var(--cp-faint)",marginTop:4},children:[e.channel?(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0,marginRight:6,fontSize:9},children:e.channel}):null,ge(e.created_at)]})]},e.id)})})]}):null,ie.length>0&&(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:14,padding:16,marginBottom:16},children:[(0,D.jsxs)("div",{style:{fontSize:13,fontWeight:700,marginBottom:12},children:["Kullanicilar (",ie.length,")"]}),(0,D.jsx)(i.Table,{dataSource:ie,rowKey:"id",size:"small",pagination:!1,scroll:{x:"max-content"},columns:[{title:"Ad",dataIndex:"full_name",render:function(e){return e||"-"}},{title:"Email",dataIndex:"email"},{title:"Rol",dataIndex:"role",render:function(e){return(0,D.jsx)(i.Tag,{color:"blue",children:e})}},{title:"Islem",width:80,render:function(e,t){return(0,D.jsx)(i.Button,{size:"small",type:"primary",loading:z===t.user_id,onClick:function(e){e.stopPropagation(),ee(t.user_id)},children:"Giris"})}}]})]}),re.length>0&&(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:14,padding:16,marginBottom:16},children:[(0,D.jsxs)("div",{style:{fontSize:13,fontWeight:700,marginBottom:12},children:["WhatsApp Hesaplari (",re.length,")"]}),(0,D.jsx)(i.Table,{dataSource:re,rowKey:"id",size:"small",pagination:!1,scroll:{x:"max-content"},columns:[{title:"Numara",dataIndex:"display_phone_number"},{title:"Isletme",dataIndex:"business_display_name"},{title:"Durum",dataIndex:"status",render:function(e){return(0,D.jsx)(i.Tag,{color:"connected"===e?"green":"orange",children:e})}}]})]}),(0,D.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[le&&(0,D.jsxs)(i.Button,{type:"primary",loading:z===le.user_id,onClick:function(){ee(le.user_id)},children:[(0,D.jsx)(i.Icon,{type:"login"})," Owner Olarak Giris"]}),(0,D.jsx)(i.Button,{onClick:function(){P(ne),H("")},style:{borderColor:"rgba(251,191,36,0.4)",color:"var(--cp-warn)"},children:"+ Kredi Ekle"}),(0,D.jsx)(i.Button,{onClick:function(){pe({title:"Aylik kullanimi sifirla",content:"Bu tenant'in aylik AI kredi kullanim sayaci 0'a inecek. Onaylar misin?",okText:"Sifirla",cancelText:"Vazgec",onOk:function(){$(ne.id,"reset_usage")}})},children:"Aylik Kullanimi Sifirla"}),"active"===ne.status&&(0,D.jsx)(i.Button,{onClick:function(){$(ne.id,"suspend")},children:"Askiya Al"}),("suspended"===ne.status||"trial"===ne.status)&&(0,D.jsx)(i.Button,{onClick:function(){$(ne.id,"activate")},style:{borderColor:"rgba(74,222,128,0.3)",color:"var(--cp-ok)"},children:"Aktif Et"})]})]})}),(0,D.jsx)(i.Modal,{title:"Plan Degistir",visible:!!x,onCancel:function(){f(null)},footer:null,children:x&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{marginBottom:12},children:[(0,D.jsx)("strong",{children:"Sirket:"})," ",x.name," (#",x.id,")"]}),(0,D.jsxs)("div",{style:{marginBottom:12},children:[(0,D.jsx)("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:"Yeni Plan"}),(0,D.jsx)(i.Select,{value:_||void 0,onChange:function(e){w(e)},placeholder:"Plan sec",style:{width:"100%"},children:b.map(function(e){return(0,D.jsxs)(ue,{value:String(e.id),children:[e.name," (",e.slug,")"]},e.id)})})]}),(0,D.jsx)(i.Button,{type:"primary",block:!0,disabled:!_,onClick:function(){$(x.id,"change_plan",{plan_id:Number(_)}),f(null)},style:{borderRadius:10,fontWeight:700},children:"Plani Degistir"})]})}),(0,D.jsx)(i.Modal,{title:"AI Kredi Ekle / Cikar",visible:!!E,onCancel:function(){P(null),H("")},footer:null,children:E&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{marginBottom:12},children:[(0,D.jsx)("strong",{children:"Sirket:"})," ",E.name," (#",E.id,")"]}),"undefined"!==typeof E.ai_credit_total?(0,D.jsxs)("div",{style:{marginBottom:12,padding:10,background:"rgba(251,191,36,0.08)",border:"1px solid rgba(251,191,36,0.2)",borderRadius:10,fontSize:12},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("strong",{children:"Plan Kotasi:"})," ",E.ai_credit_plan||0]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("strong",{children:"Eklenmis (Addon):"})," ",E.ai_credit_addon||0]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("strong",{children:"Kullanilan:"})," ",E.ai_credit_used||0]}),(0,D.jsxs)("div",{style:{color:"var(--cp-warn)",fontWeight:700,marginTop:4},children:["Kalan: ",E.ai_credit_remaining||0," / ",E.ai_credit_total||0]})]}):null,(0,D.jsxs)("div",{style:{marginBottom:12},children:[(0,D.jsx)("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:"Eklenecek Kredi (negatif sayi cikarir)"}),(0,D.jsx)("input",{type:"number",value:Y,onChange:function(e){H(e.target.value)},placeholder:"Orn: 100 veya -50",style:{width:"100%",padding:"8px 12px",borderRadius:8,border:"1px solid #d9d9d9"}})]}),(0,D.jsx)("div",{style:{display:"flex",gap:8},children:[100,500,1e3,5e3].map(function(e){return(0,D.jsxs)(i.Button,{size:"small",onClick:function(){H(String(e))},children:["+",e]},e)})}),(0,D.jsx)(i.Button,{type:"primary",block:!0,disabled:!Y||0===Number(Y),onClick:function(){$(E.id,"add_credit",{credits:Number(Y)}),P(null),H("")},style:{borderRadius:10,fontWeight:700,marginTop:12},children:Number(Y)>=0?"Kredi Ekle":"Kredi Cikar"})]})})]})}),be=e=>{if(!e)return"-";try{const t=(new Date(e).getTime()-Date.now())/1e3;if(Math.abs(t)<86400)return"bug\xfcn";const n=Math.round(t/86400);return n>0?n+"g sonra":Math.abs(n)+"g \xf6nce"}catch(t){return"-"}},{Option:ve}=i.Select,{confirm:je}=i.Modal,ke=["active","pending","failed","canceled","expired","suspended"],_e=e=>{const t=String(e||"").trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)&&n>0?n:null},we=e=>Number(e&&(e.monthly_ai_credit_usage||e.monthly_message_usage)||0),Se=e=>Number(e&&(e.ai_employee_usage||e.custom_bot_usage)||0),ze=i.Form.create()(e=>{let{form:t}=e;const[n,r]=(0,a.useState)([]),[l,o]=(0,a.useState)(!1),[s,d]=(0,a.useState)([]),[c,u]=(0,a.useState)(!1),[p,m]=(0,a.useState)(""),[g,h]=(0,a.useState)(""),[x,f]=(0,a.useState)(""),[_,w]=(0,a.useState)("undefined"!==typeof window&&window.innerWidth<768);(0,a.useEffect)(()=>{const e=()=>w(window.innerWidth<768);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[S,z]=(0,a.useState)(!1),[A,T]=(0,a.useState)(!1),[I,C]=(0,a.useState)(!1),[W,N]=(0,a.useState)(!1),[K,F]=(0,a.useState)({id:null,tenant_id:"",subscription_plan_id:"",status:"active",started_at:"",next_billing_at:"",monthly_ai_credit_usage:0,monthly_campaign_usage:0,ai_employee_usage:0}),O=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(!0);try{const t=await y(e),n=t&&t.data&&t.data.data?t.data.data:[];r(n)}catch(t){r([]),i.message.error("Abonelikler y\xfcklenemedi.")}finally{o(!1)}};(0,a.useEffect)(()=>{O({}),(async()=>{u(!0);try{const e=await k(),t=e&&e.data&&e.data.data?e.data.data:[];d(t)}catch(e){d([])}finally{u(!1)}})()},[]);const M=(0,a.useMemo)(()=>{const e=x.trim().toLowerCase();return e?n.filter(t=>{const n=t.subscription_plan&&t.subscription_plan.name?t.subscription_plan.name:"",a=t.tenant_summary||{};return"".concat(t.id||""," ").concat(t.tenant_id||""," ").concat(t.status||""," ").concat(n," ").concat(a.name||""," ").concat(a.owner_email||""," ").concat(a.contact_number||""," ").concat(a.owner_full_name||""," ").concat(a.slug||"").toLowerCase().includes(e)}):n},[n,x]),L=(0,a.useMemo)(()=>{const e={total:n.length,active:0,pending:0,cancelled:0};
1return n.forEach(t=>{"active"===t.status?e.active++:"pending"===t.status?e.pending++:"canceled"!==t.status&&"cancelled"!==t.status&&"expired"!==t.status||e.cancelled++}),e},[n]),E=e=>{F({id:e.id,tenant_id:e.tenant_id?String(e.tenant_id):"",subscription_plan_id:e.subscription_plan_id?String(e.subscription_plan_id):"",status:e.status||"active",started_at:e.started_at||"",next_billing_at:e.next_billing_at||"",monthly_ai_credit_usage:we(e),monthly_campaign_usage:e.monthly_campaign_usage||0,ai_employee_usage:Se(e)}),C(!0)},P=e=>{je({title:"Silme onay\u0131",content:"Bu abonelik silinecek. Devam edilsin mi?",okText:"Sil",okType:"danger",cancelText:"Vazge\xe7",onOk:async()=>{try{await j({id:e.id}),i.message.success("Abonelik silindi."),O({})}catch(t){i.message.error("Silme ba\u015far\u0131s\u0131z.")}}})},G=e=>{if(!e)return"-";try{return new Date(e).toLocaleDateString("tr-TR")}catch(t){return"-"}},Y=e=>(t,n)=>Number(t[e]||0)-Number(n[e]||0),H=e=>(t,n)=>new Date(t[e]||0).getTime()-new Date(n[e]||0).getTime(),V=[{title:"Abonelik",dataIndex:"id",width:150,fixed:"left",sorter:Y("id"),defaultSortOrder:"descend",render:(e,t)=>(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:700,fontSize:13},children:["#",t.id]}),t.subscription_plan?(0,D.jsx)(i.Tag,{color:"purple",style:{margin:0,marginTop:2},children:t.subscription_plan.name}):(0,D.jsx)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:t.subscription_plan_id})]})},{title:"\u015eirket",dataIndex:"tenant_id",width:200,sorter:Y("tenant_id"),render:(e,t)=>{const n=t.tenant_summary||{};return(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:600,fontSize:12},children:["#",t.tenant_id," \xb7 ",n.name||"\u2014"]}),n.owner_full_name?(0,D.jsx)("div",{style:{color:"var(--cp-muted)",fontSize:11,marginTop:2},children:n.owner_full_name}):null,n.slug?(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0,marginTop:2,fontSize:10},children:n.slug}):null]})}},{title:"\u0130leti\u015fim",key:"contact",width:220,render:(e,t)=>{const n=t.tenant_summary||{};return(0,D.jsx)(R,{email:n.owner_email,phone:n.contact_number,layout:"compact"})}},{title:"Durum",dataIndex:"status",width:100,sorter:(U="status",(e,t)=>String(e[U]||"").localeCompare(String(t[U]||""))),render:e=>(0,D.jsx)(i.Tag,{color:"active"===e?"green":"pending"===e?"orange":"red",children:e})},{title:"Ba\u015flang\u0131\xe7",dataIndex:"started_at",width:100,sorter:H("started_at"),render:G},{title:"Sonraki \xd6deme",dataIndex:"next_billing_at",width:130,sorter:H("next_billing_at"),render:e=>e?(0,D.jsxs)("div",{style:{fontSize:11},children:[(0,D.jsx)("div",{children:G(e)}),(0,D.jsx)("div",{style:{color:"var(--cp-muted)",fontSize:10},children:be(e)})]}):(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"\u2014"})},{title:"AI Kredi",dataIndex:"monthly_ai_credit_usage",width:80,sorter:Y("monthly_ai_credit_usage"),render:(e,t)=>(0,D.jsx)("span",{style:{color:"var(--cp-warn)",fontWeight:600},children:we(t)})},{title:"\u0130\u015flem",key:"actions",width:140,fixed:"right",render:(e,t)=>(0,D.jsxs)("div",{style:{display:"flex",gap:4},onClick:e=>e.stopPropagation(),children:[(0,D.jsx)(i.Button,{size:"small",onClick:()=>E(t),children:"D\xfczenle"}),(0,D.jsx)(i.Button,{size:"small",type:"danger",onClick:()=>P(t),children:"Sil"})]})}];var U;const q=(e,t,n,a)=>(0,D.jsx)(i.Col,{xs:12,sm:8,md:6,lg:6,children:(0,D.jsxs)(i.Card,{bodyStyle:{padding:12},onClick:a,style:{background:n+"0d",border:"1px solid "+n+"33",cursor:a?"pointer":"default"},children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-faint)",fontWeight:700,letterSpacing:.5},children:e}),(0,D.jsx)("div",{style:{fontSize:22,fontWeight:800,color:n},children:t})]})});return(0,D.jsxs)("div",{style:{padding:_?0:4},children:[(0,D.jsxs)("div",{style:{marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:12},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h2",{style:{color:"var(--cp-title)",margin:0,fontSize:20,fontWeight:800},children:"Abonelikler"}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",fontSize:12,marginTop:4}
1,children:"Tum tenant abonelikleri, plan, ai kredi ve odeme bilgileri"})]}),(0,D.jsx)(i.Button,{type:"primary",onClick:()=>{t.resetFields(),t.setFieldsValue({status:"active",monthly_ai_credit_usage:0,monthly_campaign_usage:0,ai_employee_usage:0}),z(!0)},children:"+ Yeni Abonelik"})]}),(0,D.jsxs)(i.Row,{gutter:[10,10],style:{marginBottom:16},children:[q("TOPLAM",L.total,"var(--cp-muted)"),q("AKTIF",L.active,"var(--cp-ok)"),q("BEKLEYEN",L.pending,"var(--cp-warn)"),q("IPTAL",L.cancelled,"#ef4444")]}),(0,D.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:12,padding:10,background:"rgba(255,255,255,0.02)",borderRadius:10,border:"1px solid rgba(255,255,255,0.05)",alignItems:"center"},children:[(0,D.jsx)(i.Input,{value:p,onChange:e=>m(e.target.value),placeholder:"Tenant ID",prefix:(0,D.jsx)(i.Icon,{type:"bank"}),style:{width:120}}),(0,D.jsx)(i.Select,{value:g||void 0,onChange:e=>h(e||""),placeholder:"Durum",style:{width:140},allowClear:!0,children:ke.map(e=>(0,D.jsx)(ve,{value:e,children:e},e))}),(0,D.jsx)(i.Button,{onClick:()=>{const e=_e(p);if(p.trim()&&!e)return void i.message.error("Ge\xe7erli bir tenant_id girin.");const t={};e&&(t.tenant_id=e),g&&(t.status=g),O(t)},children:"Filtrele"}),(0,D.jsx)(i.Button,{onClick:()=>{m(""),h(""),O({})},children:"Temizle"}),(0,D.jsx)(i.Input,{value:x,onChange:e=>f(e.target.value),placeholder:"\u015eirket/email/tel/plan ara",prefix:(0,D.jsx)(i.Icon,{type:"search"}),style:{minWidth:200,flex:"1 1 200px",maxWidth:320}}),(0,D.jsxs)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:[M.length," / ",n.length]})]}),_?(0,D.jsx)("div",{children:l&&0===n.length?(0,D.jsx)("div",{style:{textAlign:"center",padding:30,color:"var(--cp-faint)"},children:"Y\xfckleniyor..."}):0===M.length?(0,D.jsx)(i.Empty,{description:"Kay\u0131t yok"}):M.map(e=>{const t=e.tenant_summary||{};return(0,D.jsxs)("div",{style:{padding:14,background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:12,marginBottom:10},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:700,fontSize:14},children:["#",e.id," ",e.subscription_plan?(0,D.jsx)(i.Tag,{color:"purple",style:{marginLeft:6},children:e.subscription_plan.name}):null]}),(0,D.jsxs)("div",{style:{fontSize:12,marginTop:4},children:["#",e.tenant_id," \xb7 ",t.name||"\u2014"]}),t.owner_full_name?(0,D.jsx)("div",{style:{fontSize:11,color:"var(--cp-muted)"},children:t.owner_full_name}):null]}),(0,D.jsx)(i.Tag,{color:"active"===e.status?"green":"pending"===e.status?"orange":"red",style:{margin:0},children:e.status})]}),(0,D.jsx)("div",{style:{marginBottom:8},children:(0,D.jsx)(R,{email:t.owner_email,phone:t.contact_number,layout:"stack"})}),(0,D.jsxs)("div",{style:{display:"flex",gap:12,fontSize:11,color:"var(--cp-muted)",marginBottom:8,flexWrap:"wrap"},children:[(0,D.jsxs)("span",{children:["\ud83d\udcc5 ",G(e.started_at)]}),e.next_billing_at?(0,D.jsxs)("span",{children:["\ud83d\udcb3 ",be(e.next_billing_at)]}):null,(0,D.jsxs)("span",{style:{color:"var(--cp-warn)"},children:["\u26a1 ",we(e)," kredi"]})]}),(0,D.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,D.jsx)(i.Button,{size:"default",onClick:()=>E(e),style:{minHeight:36},children:"D\xfczenle"}),(0,D.jsx)(i.Button,{size:"default",type:"danger",onClick:()=>P(e),style:{minHeight:36},children:"Sil"})]})]},e.id)})}):(0,D.jsx)(i.Table,{rowKey:"id",loading:l,columns:V,dataSource:M,size:"small",pagination:{pageSize:20,showSizeChanger:!0,showTotal:function(e){return"Toplam "+e}},scroll:{x:"max-content"},locale:{emptyText:(0,D.jsx)(i.Empty,{description:"Kay\u0131t yok"})}}),(0,D.jsx)(i.Modal,{visible:S,title:"Yeni Abonelik",okText:"Kaydet",cancelText:"Vazge\xe7",onOk:()=>{t.validateFields(async(e,n)=>{if(e)return;const a=_e(n.tenant_id);if(!a)return void i.message.error("tenant_id zorunlu");const r=_e(n.subscription_plan_id);if(!n.subscription_plan_id||r){T(!0);try{await b({tenant_id:a,subscription_plan_id:r||null,status:n.status||"active",started_at:n.started_at||null,next_billing_at:n.next_billing_at||null,monthly_ai_credit_usage:Number(n.monthly_ai_credit_usage)||0,monthly_campaign_usage:Number(n.monthly_campaign_usage)||0,ai_employee_usage:Number(n.ai_employee_usage)||0}),i.message.success("Abonelik olu\u015fturuldu."),t.resetFields(),z(!1),O({})}catch(l){const e=l&&l.response&&l.response.data&&l.response.data.message?l.response.data.message:"Abonelik olu\u015fturulamad\u0131.";i.message.error(e)}finally{T(!1)}}else i.message.error("Ge\xe7erli bir plan se\xe7in.")})},onCancel:()=>z(!1),confirmLoading:A,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"Tenant ID",children:t.getFieldDecorator("tenant_id",{rules:[{required:!0,message:"tenant_id zorunlu"}]})((0,D.jsx)(i.Input,{placeholder:"Tenant ID"}))}),(0,D.jsx)(i.Form.Item,{label:"Plan",children:t.getFieldDecorator("subscription_plan_id")((0,D.jsx)(i.Select,{placeholder:c?"Y\xfckleniyor...":"Plan se\xe7",allowClear:!0,loading:c,children:s.map(e=>(0,D.jsx)(ve,{value:String(e.id),children:e.name},e.id))}
1))}),(0,D.jsx)(i.Form.Item,{label:"Durum",children:t.getFieldDecorator("status",{initialValue:"active"})((0,D.jsx)(i.Select,{children:ke.map(e=>(0,D.jsx)(ve,{value:e,children:e},e))}))}),(0,D.jsx)(i.Form.Item,{label:"Ba\u015flang\u0131\xe7 (YYYY-MM-DD)",children:t.getFieldDecorator("started_at")((0,D.jsx)(i.Input,{placeholder:"2024-01-01"}))}),(0,D.jsx)(i.Form.Item,{label:"Next Billing (YYYY-MM-DD)",children:t.getFieldDecorator("next_billing_at")((0,D.jsx)(i.Input,{placeholder:"2024-02-01"}))}),(0,D.jsx)(i.Form.Item,{label:"Ayl\u0131k AI Kredi Kullan\u0131m\u0131",children:t.getFieldDecorator("monthly_ai_credit_usage",{initialValue:0})((0,D.jsx)(i.Input,{}))}),(0,D.jsx)(i.Form.Item,{label:"Ayl\u0131k Kampanya Kullan\u0131m\u0131",children:t.getFieldDecorator("monthly_campaign_usage",{initialValue:0})((0,D.jsx)(i.Input,{}))}),(0,D.jsx)(i.Form.Item,{label:"AI \xc7al\u0131\u015fan Kullan\u0131m\u0131",children:t.getFieldDecorator("ai_employee_usage",{initialValue:0})((0,D.jsx)(i.Input,{}))})]})}),(0,D.jsx)(i.Modal,{visible:I,title:"Aboneli\u011fi D\xfczenle",okText:"G\xfcncelle",cancelText:"Vazge\xe7",onOk:async()=>{if(!K.id)return;const e=_e(K.tenant_id);if(K.tenant_id&&!e)return void i.message.error("Ge\xe7erli bir tenant_id girin.");const t=_e(K.subscription_plan_id);if(!K.subscription_plan_id||t){N(!0);try{await v({id:K.id,tenant_id:e,subscription_plan_id:t||null,status:K.status||"active",started_at:K.started_at||null,next_billing_at:K.next_billing_at||null,monthly_ai_credit_usage:Number(K.monthly_ai_credit_usage)||0,monthly_campaign_usage:Number(K.monthly_campaign_usage)||0,ai_employee_usage:Number(K.ai_employee_usage)||0}),i.message.success("Abonelik g\xfcncellendi."),C(!1),O({})}catch(n){i.message.error("G\xfcncelleme ba\u015far\u0131s\u0131z.")}finally{N(!1)}}else i.message.error("Ge\xe7erli bir plan se\xe7in.")},onCancel:()=>C(!1),confirmLoading:W,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"Tenant ID",children:(0,D.jsx)(i.Input,{value:K.tenant_id,onChange:e=>F((0,B.A)((0,B.A)({},K),{},{tenant_id:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Plan",children:(0,D.jsx)(i.Select,{value:K.subscription_plan_id||void 0,onChange:e=>F((0,B.A)((0,B.A)({},K),{},{subscription_plan_id:e})),allowClear:!0,children:s.map(e=>(0,D.jsx)(ve,{value:String(e.id),children:e.name},e.id))})}),(0,D.jsx)(i.Form.Item,{label:"Durum",children:(0,D.jsx)(i.Select,{value:K.status,onChange:e=>F((0,B.A)((0,B.A)({},K),{},{status:e})),children:ke.map(e=>(0,D.jsx)(ve,{value:e,children:e},e))})}),(0,D.jsx)(i.Form.Item,{label:"Ba\u015flang\u0131\xe7 (YYYY-MM-DD)",children:(0,D.jsx)(i.Input,{value:K.started_at,onChange:e=>F((0,B.A)((0,B.A)({},K),{},{started_at:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Next Billing (YYYY-MM-DD)",children:(0,D.jsx)(i.Input,{value:K.next_billing_at,onChange:e=>F((0,B.A)((0,B.A)({},K),{},{next_billing_at:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Ayl\u0131k AI Kredi Kullan\u0131m\u0131",children:(0,D.jsx)(i.Input,{value:K.monthly_ai_credit_usage,onChange:e=>F((0,B.A)((0,B.A)({},K),{},{monthly_ai_credit_usage:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Ayl\u0131k Kampanya Kullan\u0131m\u0131",children:(0,D.jsx)(i.Input,{value:K.monthly_campaign_usage,onChange:e=>F((0,B.A)((0,B.A)({},K),{},{monthly_campaign_usage:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"AI \xc7al\u0131\u015fan Kullan\u0131m\u0131",children:(0,D.jsx)(i.Input,{value:K.ai_employee_usage,onChange:e=>F((0,B.A)((0,B.A)({},K),{},{ai_employee_usage:e.target.value}))})})]})})]})}),{Option:Ae}=i.Select,{TextArea:Te}=i.Input,{confirm:Ie}=i.Modal,Ce=e=>{const t=String(e||"").trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)&&n>0?n:null},Be=i.Form.create()(e=>{let{form:t}=e;const[n,r]=(0,a.useState)([]),[l,o]=(0,a.useState)(!1),[s,d]=(0,a.useState)(""),[c,u]=(0,a.useState)(""),[p,m]=(0,a.useState)(""),[g,h]=(0,a.useState)(""),[x,f]=(0,a.useState)(""),[y,b]=(0,a.useState)(!1),[v,j]=(0,a.useState)(!1),[k,A]=(0,a.useState)("undefined"!==typeof window&&window.innerWidth<768);(0,a.useEffect)(()=>{const e=()=>A(window.innerWidth<768);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const[T,I]=(0,a.useState)(!1),[C,W]=(0,a.useState)(!1),[N,K]=(0,a.useState)({id:null,tenant_id:"",tenant_subscription_id:"",provider:"",status:"",reference:"",amount:"",currency:"",metadata:""}),F=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(!0);try{const t=await _(e),n=t&&t.data&&t.data.data?t.data.data:[];r(n)}catch(t){r([]),i.message.error("Transaction log listesi y\xfcklenemedi.")}finally{o(!1)}};(0,a.useEffect)(()=>{F({})},[]);const O=(0,a.useMemo)(()=>{const e=x.trim().toLowerCase();return e?n.filter(t=>{const n=t.tenant_summary||{};return"".concat(t.id||""," ").concat(t.provider||""," ").concat(t.status||""," ").concat(t.reference||""," ").concat(n.name||""," ").concat(n.owner_email||""," ").concat(n.contact_number||""," ").concat(n.owner_full_name||"").toLowerCase().includes(e)}):n},[n,x]),M=((0,a.useMemo)(()=>O.reduce((e,t)=>
1{const n=Number.parseFloat(t.amount);return Number.isFinite(n)?e+n:e},0),[O]),(0,a.useMemo)(()=>{const e={total:O.length,success:0,failed:0,pending:0,total_amount:0};return O.forEach(t=>{if("success"===t.status){e.success++;const n=Number.parseFloat(t.amount);Number.isFinite(n)&&(e.total_amount+=n)}else"failed"===t.status?e.failed++:"pending"===t.status&&e.pending++}),e},[O])),L=e=>{K({id:e.id,tenant_id:e.tenant_id?String(e.tenant_id):"",tenant_subscription_id:e.tenant_subscription_id?String(e.tenant_subscription_id):"",provider:e.provider||"",status:e.status||"",reference:e.reference||"",amount:e.amount||"",currency:e.currency||"",metadata:e.metadata?JSON.stringify(e.metadata,null,2):""}),I(!0)},E=e=>{Ie({title:"Silme onay\u0131",content:"Bu log silinecek. Devam edilsin mi?",okText:"Sil",okType:"danger",cancelText:"Vazge\xe7",onOk:async()=>{try{await z({id:e.id}),i.message.success("Log silindi."),F({})}catch(t){i.message.error("Silme ba\u015far\u0131s\u0131z.")}}})},P=e=>{if(!e)return"-";try{return new Date(e).toLocaleDateString("tr-TR")}catch(t){return"-"}},G=e=>Number(e||0).toLocaleString("tr-TR",{minimumFractionDigits:0,maximumFractionDigits:0})+" TL",Y=e=>(t,n)=>Number(t[e]||0)-Number(n[e]||0),H=e=>(t,n)=>String(t[e]||"").localeCompare(String(n[e]||"")),V=[{title:"ID",dataIndex:"id",width:60,fixed:"left",sorter:Y("id"),defaultSortOrder:"descend"},{title:"Tarih",dataIndex:"created_at",width:95,sorter:(U="created_at",(e,t)=>new Date(e[U]||0).getTime()-new Date(t[U]||0).getTime()),render:(e,t)=>(0,D.jsx)("span",{style:{fontSize:11},children:P(t.created_at||t.createdAt)})},{title:"\u015eirket",dataIndex:"tenant_id",width:200,sorter:Y("tenant_id"),render:(e,t)=>{const n=t.tenant_summary||{};return(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:600,fontSize:12},children:["#",t.tenant_id," \xb7 ",n.name||"\u2014"]}),n.owner_full_name?(0,D.jsx)("div",{style:{color:"var(--cp-muted)",fontSize:11,marginTop:2},children:n.owner_full_name}):null]})}},{title:"\u0130leti\u015fim",key:"contact",width:220,render:(e,t)=>{const n=t.tenant_summary||{};return(0,D.jsx)(R,{email:n.owner_email,phone:n.contact_number,layout:"compact"})}},{title:"Saglayici",dataIndex:"provider",width:100,sorter:H("provider")},{title:"Durum",dataIndex:"status",width:100,sorter:H("status"),render:e=>{var t="success"===e?"green":"pending"===e?"orange":"failed"===e?"red":"blue";return(0,D.jsx)(i.Tag,{color:t,children:e||"-"})}},{title:"Tutar",dataIndex:"amount",width:110,sorter:Y("amount"),render:e=>e?(0,D.jsx)("span",{style:{color:"var(--cp-ok)",fontWeight:700},children:G(e)}):"-"},{title:"Para Birimi",dataIndex:"currency",width:70,sorter:H("currency")},{title:"Referans",dataIndex:"reference",width:150,render:e=>{if(!e)return"-";const t=e.length>18?e.slice(0,18)+"...":e;return(0,D.jsx)(i.Tooltip,{title:e,children:(0,D.jsx)("span",{children:t})})}},{title:"Islem",key:"actions",width:140,fixed:"right",render:(e,t)=>(0,D.jsxs)("div",{style:{display:"flex",gap:4},onClick:e=>e.stopPropagation(),children:[(0,D.jsx)(i.Button,{size:"small",onClick:()=>L(t),children:"D\xfczenle"}),(0,D.jsx)(i.Button,{size:"small",type:"danger",onClick:()=>E(t),children:"Sil"})]})}];var U;const q=(e,t,n,a)=>(0,D.jsx)(i.Col,{xs:12,sm:8,md:6,lg:4,children:(0,D.jsxs)(i.Card,{bodyStyle:{padding:12},onClick:a,style:{background:n+"0d",border:"1px solid "+n+"33",cursor:a?"pointer":"default"},children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-faint)",fontWeight:700,letterSpacing:.5},children:e}),(0,D.jsx)("div",{style:{fontSize:22,fontWeight:800,color:n},children:t})]})});return(0,D.jsxs)("div",{style:{padding:k?0:4},children:[(0,D.jsxs)("div",{style:{marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:12},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h2",{style:{color:"var(--cp-title)",margin:0,fontSize:20,fontWeight:800},children:"\xd6deme Kay\u0131tlar\u0131"}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",fontSize:12,marginTop:4},children:"T\xfcm tenant \xf6demeleri, sa\u011flay\u0131c\u0131 bilgisi, ba\u015far\u0131/hata durumu"})]}),(0,D.jsx)(i.Button,{type:"primary",onClick:()=>{t.resetFields(),t.setFieldsValue({tenant_id:"",tenant_subscription_id:"",provider:"",status:"",reference:"",amount:"",currency:"",metadata:""}),b(!0)},children:"+ Yeni Kay\u0131t"})]}),(0,D.jsxs)(i.Row,{gutter:[10,10],style:{marginBottom:16}
1,children:[q("TOPLAM TUTAR",Number(M.total_amount).toLocaleString("tr-TR",{maximumFractionDigits:0})+" TL","var(--cp-ok)"),q("BA\u015eARILI",M.success,"var(--cp-ok)"),q("BA\u015eARISIZ",M.failed,"#ef4444"),q("BEKLEYEN",M.pending,"var(--cp-warn)"),q("TOPLAM KAYIT",M.total,"var(--cp-muted)")]}),(0,D.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:12,padding:10,background:"rgba(255,255,255,0.02)",borderRadius:10,border:"1px solid rgba(255,255,255,0.05)",alignItems:"center"},children:[(0,D.jsx)(i.Input,{value:s,onChange:e=>d(e.target.value),placeholder:"Tenant ID",prefix:(0,D.jsx)(i.Icon,{type:"bank"}),style:{width:120}}),(0,D.jsx)(i.Input,{value:p,onChange:e=>m(e.target.value),placeholder:"Provider",prefix:(0,D.jsx)(i.Icon,{type:"global"}),style:{width:140}}),(0,D.jsx)(i.Input,{value:g,onChange:e=>h(e.target.value),placeholder:"Status",prefix:(0,D.jsx)(i.Icon,{type:"tag"}),style:{width:120}}),(0,D.jsx)(i.Button,{onClick:()=>{const e=Ce(s);if(s.trim()&&!e)return void i.message.error("Ge\xe7erli bir tenant_id girin.");const t=Ce(c);if(c.trim()&&!t)return void i.message.error("Ge\xe7erli bir tenant_subscription_id girin.");const n={};e&&(n.tenant_id=e),t&&(n.tenant_subscription_id=t),p&&(n.provider=p.trim()),g&&(n.status=g.trim()),F(n)},children:"Filtrele"}),(0,D.jsx)(i.Button,{onClick:()=>{d(""),u(""),m(""),h(""),F({})},children:"Temizle"}),(0,D.jsx)(i.Input,{value:x,onChange:e=>f(e.target.value),placeholder:"\u015eirket/email/tel/referans ara",prefix:(0,D.jsx)(i.Icon,{type:"search"}),style:{minWidth:220,flex:"1 1 220px",maxWidth:320}}),(0,D.jsxs)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:[O.length," / ",n.length]})]}),k?(0,D.jsx)("div",{children:l&&0===n.length?(0,D.jsx)("div",{style:{textAlign:"center",padding:30,color:"var(--cp-faint)"},children:"Y\xfckleniyor..."}):0===O.length?(0,D.jsx)(i.Empty,{description:"Kay\u0131t yok"}):O.map(e=>{const t=e.tenant_summary||{},n="success"===e.status?"green":"pending"===e.status?"orange":"failed"===e.status?"red":"blue",a="success"===e.status?"var(--cp-ok)":"failed"===e.status?"#ef4444":"var(--cp-warn)";return(0,D.jsxs)("div",{style:{padding:14,background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:12,marginBottom:10},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontWeight:700,fontSize:14,color:a},children:e.amount?G(e.amount)+" "+(e.currency||"TRY"):"\u2014"}),(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginTop:2},children:[P(e.created_at||e.createdAt)," \xb7 ",e.provider||"\u2014"]})]}),(0,D.jsx)(i.Tag,{color:n,style:{margin:0},children:e.status})]}),(0,D.jsxs)("div",{style:{fontSize:12,marginBottom:6},children:[(0,D.jsxs)("strong",{children:["#",e.tenant_id]})," \xb7 ",t.name||"\u2014",t.owner_full_name?(0,D.jsxs)("span",{style:{color:"var(--cp-muted)"},children:[" \xb7 ",t.owner_full_name]}):null]}),(0,D.jsx)("div",{style:{marginBottom:8},children:(0,D.jsx)(R,{email:t.owner_email,phone:t.contact_number,layout:"stack"})}),e.reference?(0,D.jsxs)("div",{style:{fontSize:10,color:"var(--cp-faint)",fontFamily:"monospace",marginBottom:6},children:["Ref: ",e.reference]}):null,(0,D.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,D.jsx)(i.Button,{size:"default",onClick:()=>L(e),style:{minHeight:36},children:"D\xfczenle"}),(0,D.jsx)(i.Button,{size:"default",type:"danger",onClick:()=>E(e),style:{minHeight:36},children:"Sil"})]})]},e.id)})}):(0,D.jsx)(i.Table,{rowKey:"id",loading:l,columns:V,dataSource:O,size:"small",pagination:{pageSize:20,showSizeChanger:!0,showTotal:function(e){return"Toplam "+e}},scroll:{x:"max-content"},locale:{emptyText:(0,D.jsx)(i.Empty,{description:"Kay\u0131t yok"})}}),(0,D.jsx)(i.Modal,{visible:y,title:"Yeni Transaction Log",okText:"Kaydet",cancelText:"Vazge\xe7",onOk:()=>{t.validateFields(async(e,n)=>{if(e)return;const a=Ce(n.tenant_id);if(!a)return void i.message.error("tenant_id zorunlu");const r=Ce(n.tenant_subscription_id);if(n.tenant_subscription_id&&!r)return void i.message.error("Ge\xe7erli bir tenant_subscription_id girin.");let l=null;if(n.metadata)try{l=JSON.parse(n.metadata)}catch(o){return void i.message.error("metadata JSON format\u0131nda olmal\u0131.")}j(!0);try{await w({tenant_id:a,tenant_subscription_id:r||null,provider:String(n.provider||"").trim(),status:String(n.status||"").trim(),reference:n.reference||null,amount:n.amount?Number(n.amount):null,currency:n.currency||null,metadata:l}),i.message.success("Log olu\u015fturuldu."),t.resetFields(),b(!1),F({})}catch(o){const e=o&&o.response&&o.response.data&&o.response.data.message?o.response.data.message:"Log olu\u015fturulamad\u0131.";i.message.error(e)}finally{j(!1)}})},onCancel:()=>b(!1),confirmLoading:v,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"Tenant ID",children:t.getFieldDecorator("tenant_id",{rules:[{required:!0,message:"tenant_id zorunlu"}]})((0,D.jsx)(i.Input,{placeholder:"Tenant ID"}))}),(0,D.jsx)(i.Form.Item,{label:"Tenant Subscription ID",children:t.getFieldDecorator("tenant_subscription_id")((0,D.jsx)(i.Input,{placeholder:"Subscription ID"}))}),(0,D.jsx)(i.Form.Item,{label:"Provider",children:t.getFieldDecorator("provider",{rules:[{required:!0,message:"provider zorunlu"}]})((0,D.jsx)(i.Input,{placeholder:"iyzipay"}))}),(0,D.jsx)(i.Form.Item,{label:"Status",children:t.getFieldDecorator("status",{rules:[{required:!0,message:"status zorunlu"}]})((0,D.jsx)(i.Input,{placeholder:"success/pending"}))}),(0,D.jsx)(i.Form.Item,{label:"Reference",children:t.getFieldDecorator("reference")((0,D.jsx)(i.Input,{placeholder:"reference"}))}),(0,D.jsx)(i.Form.Item,{label:"Amount",children:t.getFieldDecorator("amount")((0,D.jsx)(i.Input,{placeholder:"0.00"}))}),(0,D.jsx)(i.Form.Item,{label:"Currency",children:t.getFieldDecorator("currency")((0,D.jsx)(i.Input,{placeholder:"TRY"}))}),(0,D.jsx)(i.Form.Item,{label:"Metadata (JSON)",children:t.getFieldDecorator("metadata")((0,D.jsx)(Te,{rows:4,placeholder:'{"key":"value"}'}))})]})}),(0,D.jsx)(i.Modal,{visible:T,title:"Transaction Log D\xfczenle",okText:"G\xfcncelle",cancelText:"Vazge\xe7",onOk:async()=>
1{if(!N.id)return;const e=Ce(N.tenant_id);if(N.tenant_id&&!e)return void i.message.error("Ge\xe7erli bir tenant_id girin.");const t=Ce(N.tenant_subscription_id);if(N.tenant_subscription_id&&!t)return void i.message.error("Ge\xe7erli bir tenant_subscription_id girin.");let n=null;if(N.metadata)try{n=JSON.parse(N.metadata)}catch(a){return void i.message.error("metadata JSON format\u0131nda olmal\u0131.")}W(!0);try{await S({id:N.id,tenant_id:e,tenant_subscription_id:t||null,provider:N.provider||"",status:N.status||"",reference:N.reference||null,amount:N.amount?Number(N.amount):null,currency:N.currency||null,metadata:n}),i.message.success("Log g\xfcncellendi."),I(!1),F({})}catch(a){i.message.error("G\xfcncelleme ba\u015far\u0131s\u0131z.")}finally{W(!1)}},onCancel:()=>I(!1),confirmLoading:C,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"Tenant ID",children:(0,D.jsx)(i.Input,{value:N.tenant_id,onChange:e=>K((0,B.A)((0,B.A)({},N),{},{tenant_id:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Tenant Subscription ID",children:(0,D.jsx)(i.Input,{value:N.tenant_subscription_id,onChange:e=>K((0,B.A)((0,B.A)({},N),{},{tenant_subscription_id:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Provider",children:(0,D.jsx)(i.Input,{value:N.provider,onChange:e=>K((0,B.A)((0,B.A)({},N),{},{provider:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Status",children:(0,D.jsx)(i.Input,{value:N.status,onChange:e=>K((0,B.A)((0,B.A)({},N),{},{status:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Reference",children:(0,D.jsx)(i.Input,{value:N.reference,onChange:e=>K((0,B.A)((0,B.A)({},N),{},{reference:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Amount",children:(0,D.jsx)(i.Input,{value:N.amount,onChange:e=>K((0,B.A)((0,B.A)({},N),{},{amount:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Currency",children:(0,D.jsx)(i.Input,{value:N.currency,onChange:e=>K((0,B.A)((0,B.A)({},N),{},{currency:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Metadata (JSON)",children:(0,D.jsx)(Te,{rows:4,value:N.metadata,onChange:e=>K((0,B.A)((0,B.A)({},N),{},{metadata:e.target.value}))})})]})})]})}),De={guest_start:"Misafir basladi",register:"Kayit",setup_done:"Kurulum",command:"Komut yazdi",tool_exec:"Is yaptirdi",channel_connected:"Kanal bagladi",plan_view:"Plan sayfasi",upgrade_click:"Yukselt'e basti",paid:"Odedi"},We=(0,B.A)((0,B.A)({},De),{},{login:"Giris",app_open:"Uygulama acildi",page_view:"Sayfa",chip_click:"Oneri cipi",voice_used:"Sesli komut",proposal_cancel:"Oneriyi iptal etti",proposal_confirm:"Oneriyi onayladi",template_picker_open:"Sablon secici",panel_open:"Panel acti",help_open:"Yardim",share_link_open:"Paylasim linki",notification_open:"Bildirim acti",setup_example_click:"Kurulum ornegi",file_attach:"Dosya ekledi",history_open:"Gecmis",next_chip_click:"Sonraki adim cipi",proof_click:"Kanit seridi",addon_click:"Ek kredi"});class Ne extends a.Component{constructor(){super(...arguments),this.state={loading:!0,days:14,data:null,error:null},this.load=async()=>{this.setState({loading:!0,error:null});try{const e=await s.Ay.get(d.A.superAdmin.productEvents+"?days="+this.state.days);this.setState({data:e&&e.data&&e.data.data||null,loading:!1})}catch(e){this.setState({error:e&&e.response&&e.response.data&&e.response.data.message||"Yuklenemedi",loading:!1})}},this.setDays=e=>this.setState({days:e},this.load)}componentDidMount(){this.load()}render(){const{loading:e,days:t,data:n,error:a}=this.state,r=n&&n.huni||[],l=r.length?r[0].tenant:0,o=n&&n.gunler||{},s=Object.keys(n&&n.toplam||{}).sort((e,t)=>n.toplam[t].adet-n.toplam[e].adet),d=Object.keys(o).sort().reverse().map(e=>{const t={key:e,gun:e.split("-").reverse().join(".")};return s.forEach(n=>{t[n]=o[e][n]?o[e][n].adet:0}),t}),c=[{title:"Gun",dataIndex:"gun",key:"gun",fixed:"left",width:90}].concat(s.map(e=>({title:We[e]||e,dataIndex:e,key:e,width:110,render:e=>e||(0,D.jsx)("span",{style:{opacity:.35},children:"0"})})));return(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8,marginBottom:14},children:[(0,D.jsx)("span",{style:{fontWeight:700,fontSize:16},children:"Urun olaylari"}),[7,14,30,90].map(e=>(0,D.jsxs)(i.Tag,{color:e===t?"purple":void 0,style:{cursor:"pointer"},onClick:()=>this.setDays(e),children:["son ",e," gun"]},e)),(0,D.jsx)(i.Tag,{style:{cursor:"pointer"},onClick:this.load,children:"yenile"}),n?(0,D.jsxs)("span",{style:{color:"var(--cp-faint)",fontSize:12},children:[n.aktif_tenant," aktif sirket \xb7 ",n.bekleyen," olay yazilmayi bekliyor"]}):null]}),a?(0,D.jsx)("div",{style:{color:"#ef4444",marginBottom:12},children:a}):null,(0,D.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:10,marginBottom:18},children:r.map((e,t)=>{const n=l?Math.round(e.tenant/l*100):0;return(0,D.jsxs)("div",{style:{padding:"12px 12px",borderRadius:12,background:"rgba(127,119,221,.08)",border:"1px solid rgba(127,119,221,.22)"},children:[(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-faint)"},children:[t+1,". ",De[e.event]||e.event]}),(0,D.jsx)("div",{style:{fontSize:22,fontWeight:800},children:e.tenant}),(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-faint)"},children:[l?"%"+n:"-"," sirket"]})]},e.event)})}),(0,D.jsx)("div",{style:{overflowX:"auto"},children:(0,D.jsx)(i.Table,{size:"small",loading:e,columns:c,dataSource:d,pagination:{pageSize:31},scroll:{x:90+110*s.length}})}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",fontSize:12,marginTop:10},children:'Huni = pencerede olayi en az bir kez ureten tekil sirket. "Odedi" olayi odeme webhook\'undan gelir; Paddle/magaza bildirimi dusmezse 0 kalir.'})]})}}const Ke=e=>{if(!e)return"-";try{return new Date(e).toLocaleDateString("tr-TR")}catch(t){return"-"}},Fe=e=>{if(!e)return null;try{return Math.round((new Date(e).getTime()-Date.now())/864e5)}catch(t){return null}},Oe=e=>null==e?"default":e<0||e<3?"red":e<14?"orange":"green",{Option:Me}=i.Select,{confirm:Le}=i.Modal,Re=["meta_cloud","twilio","infobip","other"],Ee=["connected","disconnected","needs_attention"],Pe=e=>{const t=String(e||"").trim();if(!t)return null;const n=Number(t);return Number.isFinite(n)&&n>0?n:null},Ge=i.Form.create()((0,l.Ng)(null,{userLoginAs:o.T6})(e=>{let{form:t,userLoginAs:n}=e;const[r,l]=(0,a.useState)([]),[o,c]=(0,a.useState)(!1),[u,p]=(0,a.useState)([]),[m,g]=(0,a.useState)(!1),[h,x]=(0,a.useState)("all"),[f,y]=(0,a.useState)(!1),[b,v]=(0,a.useState)("undefined"!==typeof window&&window.innerWidth<768),[j,k]=(0,a.useState)(null),[_,w]=(0,a.useState)("all"),[S,z]=(0,a.useState)(null),[W,N]=(0,a.useState)("");(0,a.useEffect)(()=>{const e=()=>v(window.innerWidth<768);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const K=e=>{e&&(k(e),Le({title:"Owner olarak giris",content:"Bu kullanicinin paneline gecilecek.",okText:"Giris Yap",cancelText:"Vazgec",onOk:()=>n(e,{persist:!1}).then(t=>{if(t&&0===t.error&&t.token&&t.user){const n=e+"-"+Date.now()+"-"+Math.random().toString(36).slice(2,8);localStorage.setItem("impersonation:"+n,JSON.stringify({token:t.token,user:t.user})),i.message.success("Giris yapildi"),window.open("/panel?impersonation="+encodeURIComponent(n),"_blank","noopener")}else i.message.error("Giris basarisiz")}).catch(()=>i.message.error("Giris basarisiz")).finally(()=>k(null)),onCancel:()=>k(null)}))},[F,O]=(0,a.useState)(!1),[M,L]=(0,a.useState)(!1),[E,P]=(0,a.useState)(!1),[G,Y]=(0,a.useState)(!1),[H,V]=(0,a.useState)({id:null,tenant_id:"",provider:"meta_cloud",status:"disconnected",waba_id:"",phone_number_id:"",display_phone_number:"",business_display_name:"",webhook_verify_token:"",webhook_secret:""}),U=async()=>{c(!0);try{const e=await s.Ay.get(d.A.superAdmin.whatsappAccountsEnriched),t=e&&e.data&&e.data.data?e.data.data:[];l(Array.isArray(t)?t:[])}catch(e){l([]),i.message.error("WhatsApp hesaplar\u0131 y\xfcklenemedi.")}finally{c(!1)}},q=async e=>{await U()};(0,a.useEffect)(()=>{(async()=>{await(async()=>{g(!0);try{const e=await A(),t=e&&e.data&&e.data.data?e.data.data:[];return p(t),t}catch(e){return p([]),[]}finally{g(!1)}})(),await U()})()},[]);const J=(0,a.useMemo)(()=>u.reduce((e,t)=>
1(e[t.id]=t.name,e),{}),[u]),X=()=>{if(!_||"all"===_)return z(null),void U();const e=Pe(_);e?(z(e),q()):i.message.error("Ge\xe7erli bir tenant_id girin.")},Z=(0,a.useMemo)(()=>{const e=W.trim().toLowerCase();return r.filter(t=>{if(_&&"all"!==_){const e=Number(_);if(Number(t.tenant_id)!==e)return!1}if(h&&"all"!==h&&t.status!==h)return!1;if(f){const e=Fe(t.token_expires_at);if(!("needs_attention"===t.status||"disconnected"===t.status||null!=e&&e<3))return!1}if(!e)return!0;return"".concat(t.id||""," ").concat(t.provider||""," ").concat(t.display_phone_number||""," ").concat(t.business_display_name||""," ").concat(t.waba_id||""," ").concat(t.tenant_name||""," ").concat(t.owner_email||""," ").concat(t.contact_number||"").toLowerCase().includes(e)})},[r,W,_,h,f]),Q=(0,a.useMemo)(()=>{const e={total:r.length,connected:0,needs_attention:0,disconnected:0,token_critical:0};return r.forEach(t=>{"connected"===t.status?e.connected++:"needs_attention"===t.status?e.needs_attention++:"disconnected"===t.status&&e.disconnected++;const n=Fe(t.token_expires_at);null!=n&&n<3&&e.token_critical++}),e},[r]),$=e=>{V({id:e.id,tenant_id:e.tenant_id?String(e.tenant_id):"",provider:e.provider||"meta_cloud",status:e.status||"disconnected",waba_id:e.waba_id||"",phone_number_id:e.phone_number_id||"",display_phone_number:e.display_phone_number||"",business_display_name:e.business_display_name||"",webhook_verify_token:e.webhook_verify_token||"",webhook_secret:e.webhook_secret||""}),P(!0)},ee=e=>{Le({title:"Silme onay\u0131",content:"Bu WhatsApp hesab\u0131 silinecek. Devam edilsin mi?",okText:"Sil",okType:"danger",cancelText:"Vazge\xe7",onOk:async()=>{try{await C({id:e.id,tenant_id:e.tenant_id}),i.message.success("WhatsApp hesab\u0131 silindi."),X()}catch(t){const e=t&&t.response&&t.response.data&&t.response.data.message?t.response.data.message:"Silme ba\u015far\u0131s\u0131z.";i.message.error(e)}}})},te=e=>"connected"===e?"green":"needs_attention"===e?"orange":"disconnected"===e?"red":"default",ne=e=>(t,n)=>Number(t[e]||0)-Number(n[e]||0),ae=[{title:"WA Hesabi",dataIndex:"id",width:230,fixed:"left",sorter:ne("id"),defaultSortOrder:"descend",render:(e,t)=>(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontWeight:700,color:"var(--cp-text)",fontSize:13},children:t.display_phone_number||"\u2014"}),t.business_display_name?(0,D.jsx)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginTop:2},children:t.business_display_name}):null,(0,D.jsxs)("div",{style:{display:"flex",gap:4,marginTop:4,flexWrap:"wrap"},children:[t.provider?(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0,fontSize:10},children:t.provider}):null,t.coexistence_enabled?(0,D.jsx)(i.Tag,{color:"green",style:{margin:0,fontSize:10},children:"\ud83d\udcf1 Coexistence"}):null]})]})},{title:"Tenant",dataIndex:"tenant_id",width:180,sorter:ne("tenant_id"),render:(e,t)=>(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:600,fontSize:12},children:["#",t.tenant_id," \xb7 ",t.tenant_name||J[t.tenant_id]||"\u2014"]}),t.owner_full_name?(0,D.jsx)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginTop:2},children:t.owner_full_name}):null,t.tenant_slug?(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0,marginTop:2,fontSize:10},children:t.tenant_slug}):null]})},{title:"Iletisim",key:"contact",width:220,render:(e,t)=>(0,D.jsx)(R,{email:t.owner_email,phone:t.contact_number,layout:"compact"})},{title:"Durum",dataIndex:"status",width:120,sorter:(ie="status",(e,t)=>String(e[ie]||"").localeCompare(String(t[ie]||""))),render:(e,t)=>(0,D.jsxs)("div",{children:[(0,D.jsx)(i.Tag,{color:te(e),children:e}),t.last_error?(0,D.jsx)(i.Tooltip,{title:(0,D.jsx)("div",{style:{maxWidth:400,whiteSpace:"pre-wrap"},children:t.last_error}),children:(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-warn)",marginTop:4},children:"\u26a0 Hata var"})}):null]})},{title:"Token Bitis",dataIndex:"token_expires_at",width:130,sorter:(e=>(t,n)=>new Date(t[e]||0).getTime()-new Date(n[e]||0).getTime())("token_expires_at"),render:(e,t)=>{if(!t.token_expires_at)return(0,D.jsx)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:"\u2014"});const n=Fe(t.token_expires_at);return(0,D.jsxs)("div",{style:{fontSize:11},children:[(0,D.jsx)(i.Tag,{color:Oe(n),style:{margin:0},children:null!=n?n<0?"S\xfcresi doldu":n+" g\xfcn":"\u2014"}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",marginTop:2},children:Ke(t.token_expires_at)})]})}},{title:"WABA",dataIndex:"waba_id",width:140,render:e=>{if(!e)return"-";const t=e.length>12?"".concat(e.slice(0,12),"..."):e;return(0,D.jsx)(i.Tooltip,{title:e,children:(0,D.jsx)("span",{style:{fontSize:11,fontFamily:"monospace"},children:t})})}},{title:"\u0130\u015flem",key:"actions",width:200,fixed:"right",render:(e,t)=>(0,D.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},onClick:e=>e.stopPropagation(),children:[(0,D.jsx)(i.Button,{size:"small",onClick:()=>$(t),children:"D\xfczenle"}),t.owner_user_id?(0,D.jsx)(i.Button,{size:"small",type:"primary",loading:j===t.owner_user_id,onClick:()=>
1K(t.owner_user_id),children:"\ud83d\udc64 Giris"}):null,(0,D.jsx)(i.Button,{size:"small",type:"danger",onClick:()=>ee(t),children:"Sil"})]})}];var ie;const re=(e,t,n,a)=>(0,D.jsx)(i.Col,{xs:12,sm:8,md:6,lg:4,children:(0,D.jsxs)(i.Card,{bodyStyle:{padding:12},onClick:a,style:{background:n+"0d",border:"1px solid "+n+"33",cursor:a?"pointer":"default"},children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-faint)",fontWeight:700,letterSpacing:.5},children:e}),(0,D.jsx)("div",{style:{fontSize:22,fontWeight:800,color:n},children:t})]})});return(0,D.jsxs)("div",{style:{padding:b?0:4},children:[(0,D.jsxs)("div",{style:{marginBottom:16,display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:12},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("h2",{style:{color:"var(--cp-title)",margin:0,fontSize:20,fontWeight:800},children:"WhatsApp Hesaplar\u0131"}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",fontSize:12,marginTop:4},children:"T\xfcm tenant'lara ait WA hesaplar\u0131, token durumu, hata bilgileri"})]}),(0,D.jsx)(i.Button,{type:"primary",onClick:()=>{t.resetFields(),t.setFieldsValue({tenant_id:S?String(S):"",provider:"meta_cloud",status:"disconnected"}),O(!0)},children:"+ Yeni Hesap"})]}),(0,D.jsxs)(i.Row,{gutter:[10,10],style:{marginBottom:16},children:[re("TOPLAM",Q.total,"var(--cp-muted)"),re("BA\u011eLI",Q.connected,"var(--cp-ok)",()=>{x("connected"),y(!1)}),re("D\u0130KKAT",Q.needs_attention,"var(--cp-warn)",()=>{x("needs_attention"),y(!1)}),re("KOPUK",Q.disconnected,"#ef4444",()=>{x("disconnected"),y(!1)}),re("TOKEN <3G",Q.token_critical,"#f97316",()=>{y(!0)})]}),(0,D.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:12,padding:10,background:"rgba(255,255,255,0.02)",borderRadius:10,border:"1px solid rgba(255,255,255,0.05)",alignItems:"center"},children:[(0,D.jsxs)(i.Select,{showSearch:!0,allowClear:!0,value:_||"all",onChange:e=>{if(!e||"all"===e)return w("all"),z(null),void U();w(String(e)),z(Number(e)),q(Number(e))},placeholder:m?"Tenantlar y\xfckleniyor...":"Tenant se\xe7",style:{minWidth:180,flex:"1 1 180px",maxWidth:280},optionFilterProp:"children",loading:m,children:[(0,D.jsx)(Me,{value:"all",children:"T\xfcm Tenantlar"},"all"),u.map(e=>(0,D.jsxs)(Me,{value:String(e.id),children:[e.name," #",e.id]},e.id))]}),(0,D.jsxs)(i.Select,{value:h,onChange:e=>x(e),style:{width:160},children:[(0,D.jsx)(Me,{value:"all",children:"T\xfcm Durumlar"}),(0,D.jsx)(Me,{value:"connected",children:"Ba\u011fl\u0131"}),(0,D.jsx)(Me,{value:"needs_attention",children:"Dikkat"}),(0,D.jsx)(Me,{value:"disconnected",children:"Kopuk"})]}),(0,D.jsx)(i.Input,{value:W,onChange:e=>N(e.target.value),placeholder:"Telefon, ad, waba, tenant ara",prefix:(0,D.jsx)(i.Icon,{type:"search"}),style:{minWidth:200,flex:"1 1 200px",maxWidth:280}}),(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"0 8px"},children:[(0,D.jsx)(i.Switch,{checked:f,onChange:e=>y(e),size:"small"}),(0,D.jsx)("span",{style:{fontSize:12,color:"var(--cp-warn)"},children:"Sadece sorunlu"})]}),(0,D.jsxs)(i.Button,{onClick:U,loading:o,children:[(0,D.jsx)(i.Icon,{type:"reload"})," Yenile"]}),(0,D.jsxs)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:[Z.length," / ",r.length]})]}),b?(0,D.jsx)("div",{children:o&&0===r.length?(0,D.jsx)("div",{style:{textAlign:"center",padding:30,color:"var(--cp-faint)"},children:"Y\xfckleniyor..."}):0===Z.length?(0,D.jsx)(i.Empty,{description:"Kay\u0131t yok"}):Z.map(e=>{const t=Fe(e.token_expires_at);return(0,D.jsxs)("div",{style:{padding:14,background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:12,marginBottom:10},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontWeight:700,fontSize:14},children:e.display_phone_number||"\u2014"}),e.business_display_name?(0,D.jsx)("div",{style:{fontSize:11,color:"var(--cp-muted)"},children:e.business_display_name}):null]}),(0,D.jsx)(i.Tag,{color:te(e.status),style:{margin:0},children:e.status})]}),(0,D.jsxs)("div",{style:{fontSize:12,marginBottom:6},children:[(0,D.jsxs)("strong",{children:["#",e.tenant_id]})," \xb7 ",e.tenant_name||"\u2014",e.owner_full_name?(0,D.jsxs)("span",{style:{color:"var(--cp-muted)"},children:[" \xb7 ",e.owner_full_name]}):null]}),(0,D.jsx)("div",{style:{marginBottom:8},children:(0,D.jsx)(R,{email:e.owner_email,phone:e.contact_number,layout:"stack"})}),(0,D.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginBottom:6,fontSize:11},children:[e.provider?(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0},children:e.provider}):null,e.coexistence_enabled?(0,D.jsx)(i.Tag,{color:"green",style:{margin:0},children:"\ud83d\udcf1 Coexistence"}):null,null!=t?(0,D.jsxs)(i.Tag,{color:Oe(t),style:{margin:0},children:["Token ",t<0?"s\xfcresi doldu":t+"g"]}):null]}),e.last_error?(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-warn)",padding:"6px 8px",background:"rgba(251,191,36,0.08)",borderRadius:6,marginBottom:8},children:["\u26a0 ",String(e.last_error).slice(0,120),String(e.last_error).length>120?"...":""]}):null,(0,D.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[(0,D.jsx)(i.Button,{size:"default",onClick:()=>$(e),style:{minHeight:36},children:"D\xfczenle"}),e.owner_user_id?(0,D.jsx)(i.Button,{size:"default",type:"primary",loading:j===e.owner_user_id,onClick:()=>
1K(e.owner_user_id),style:{minHeight:36},children:"\ud83d\udc64 Owner Giris"}):null,(0,D.jsx)(i.Button,{size:"default",type:"danger",onClick:()=>ee(e),style:{minHeight:36},children:"Sil"})]})]},e.id)})}):(0,D.jsx)(i.Table,{rowKey:"id",loading:o,columns:ae,dataSource:Z,size:"small",pagination:{pageSize:20,showSizeChanger:!0,showTotal:function(e){return"Toplam "+e}},scroll:{x:"max-content"},locale:{emptyText:(0,D.jsx)(i.Empty,{description:"Kay\u0131t yok"})}}),(0,D.jsx)(i.Modal,{visible:F,title:"Yeni WhatsApp Hesab\u0131",okText:"Kaydet",cancelText:"Vazge\xe7",onOk:()=>{t.validateFields(async(e,n)=>{if(e)return;const a=Pe(n.tenant_id);if(a){L(!0);try{await T({tenant_id:a,provider:n.provider||"meta_cloud",status:n.status||"disconnected",waba_id:n.waba_id||null,phone_number_id:n.phone_number_id||null,display_phone_number:n.display_phone_number||null,business_display_name:n.business_display_name||null,webhook_verify_token:n.webhook_verify_token||null,webhook_secret:n.webhook_secret||null}),i.message.success("WhatsApp hesab\u0131 olu\u015fturuldu."),t.resetFields(),O(!1),X()}catch(r){const e=r&&r.response&&r.response.data&&r.response.data.message?r.response.data.message:"WhatsApp hesab\u0131 olu\u015fturulamad\u0131.";i.message.error(e)}finally{L(!1)}}else i.message.error("tenant_id zorunlu")})},onCancel:()=>O(!1),confirmLoading:M,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"Tenant",children:t.getFieldDecorator("tenant_id",{rules:[{required:!0,message:"tenant_id zorunlu"}],initialValue:S?String(S):""})((0,D.jsx)(i.Select,{showSearch:!0,placeholder:m?"Tenantlar y\xfckleniyor...":"Tenant se\xe7",optionFilterProp:"children",loading:m,children:u.map(e=>(0,D.jsxs)(Me,{value:String(e.id),children:[e.name," #",e.id]},e.id))}
1))}),(0,D.jsx)(i.Form.Item,{label:"Provider",children:t.getFieldDecorator("provider",{initialValue:"meta_cloud"})((0,D.jsx)(i.Select,{children:Re.map(e=>(0,D.jsx)(Me,{value:e,children:e},e))}))}),(0,D.jsx)(i.Form.Item,{label:"Status",children:t.getFieldDecorator("status",{initialValue:"disconnected"})((0,D.jsx)(i.Select,{children:Ee.map(e=>(0,D.jsx)(Me,{value:e,children:e},e))}))}),(0,D.jsx)(i.Form.Item,{label:"WABA ID",children:t.getFieldDecorator("waba_id")((0,D.jsx)(i.Input,{placeholder:"waba_id"}))}),(0,D.jsx)(i.Form.Item,{label:"Phone Number ID",children:t.getFieldDecorator("phone_number_id")((0,D.jsx)(i.Input,{placeholder:"phone_number_id"}))}),(0,D.jsx)(i.Form.Item,{label:"Display Phone",children:t.getFieldDecorator("display_phone_number")((0,D.jsx)(i.Input,{placeholder:"+90..."}))}),(0,D.jsx)(i.Form.Item,{label:"Business Display Name",children:t.getFieldDecorator("business_display_name")((0,D.jsx)(i.Input,{placeholder:"Business name"}))}),(0,D.jsx)(i.Form.Item,{label:"Webhook Verify Token",children:t.getFieldDecorator("webhook_verify_token")((0,D.jsx)(i.Input,{placeholder:"token"}))}),(0,D.jsx)(i.Form.Item,{label:"Webhook Secret",children:t.getFieldDecorator("webhook_secret")((0,D.jsx)(i.Input,{placeholder:"secret"}))})]})}),(0,D.jsx)(i.Modal,{visible:E,title:"WhatsApp Hesab\u0131 D\xfczenle",okText:"G\xfcncelle",cancelText:"Vazge\xe7",onOk:async()=>{if(!H.id)return;const e=Pe(H.tenant_id);if(e){Y(!0);try{await I({id:H.id,tenant_id:e,provider:H.provider,status:H.status,waba_id:H.waba_id||null,phone_number_id:H.phone_number_id||null,display_phone_number:H.display_phone_number||null,business_display_name:H.business_display_name||null,webhook_verify_token:H.webhook_verify_token||null,webhook_secret:H.webhook_secret||null}),i.message.success("WhatsApp hesab\u0131 g\xfcncellendi."),P(!1),X()}catch(t){i.message.error("G\xfcncelleme ba\u015far\u0131s\u0131z.")}finally{Y(!1)}}else i.message.error("tenant_id zorunlu")},onCancel:()=>P(!1),confirmLoading:G,children:(0,D.jsxs)(i.Form,{layout:"vertical",children:[(0,D.jsx)(i.Form.Item,{label:"Tenant ID",children:(0,D.jsx)(i.Input,{value:H.tenant_id,onChange:e=>V((0,B.A)((0,B.A)({},H),{},{tenant_id:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Provider",children:(0,D.jsx)(i.Select,{value:H.provider,onChange:e=>V((0,B.A)((0,B.A)({},H),{},{provider:e})),children:Re.map(e=>(0,D.jsx)(Me,{value:e,children:e},e))})}),(0,D.jsx)(i.Form.Item,{label:"Status",children:(0,D.jsx)(i.Select,{value:H.status,onChange:e=>V((0,B.A)((0,B.A)({},H),{},{status:e})),children:Ee.map(e=>(0,D.jsx)(Me,{value:e,children:e},e))})}),(0,D.jsx)(i.Form.Item,{label:"WABA ID",children:(0,D.jsx)(i.Input,{value:H.waba_id,onChange:e=>V((0,B.A)((0,B.A)({},H),{},{waba_id:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Phone Number ID",children:(0,D.jsx)(i.Input,{value:H.phone_number_id,onChange:e=>V((0,B.A)((0,B.A)({},H),{},{phone_number_id:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Display Phone",children:(0,D.jsx)(i.Input,{value:H.display_phone_number,onChange:e=>V((0,B.A)((0,B.A)({},H),{},{display_phone_number:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Business Display Name",children:(0,D.jsx)(i.Input,{value:H.business_display_name,onChange:e=>V((0,B.A)((0,B.A)({},H),{},{business_display_name:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Webhook Verify Token",children:(0,D.jsx)(i.Input,{value:H.webhook_verify_token,onChange:e=>V((0,B.A)((0,B.A)({},H),{},{webhook_verify_token:e.target.value}))})}),(0,D.jsx)(i.Form.Item,{label:"Webhook Secret",children:(0,D.jsx)(i.Input,{value:H.webhook_secret,onChange:e=>V((0,B.A)((0,B.A)({},H),{},{webhook_secret:e.target.value}))})})]})})]})}));var Ye=i.Select.Option,He=function(e){if(!e)return"-";try{return new Date(e).toLocaleString("tr-TR")}catch(t){return"-"}},Ve=function(e){if(!e)return"-";try{var t=(Date.now()-new Date(e).getTime())/1e3;return t<60?"az once":t<3600?Math.floor(t/60)+"d once":t<86400?Math.floor(t/3600)+"s once":t<2592e3?Math.floor(t/86400)+"g once":Math.floor(t/2592e3)+"ay once"}catch(n){return"-"}},Ue={connected:"green",needs_attention:"orange",disconnected:"red",unknown:"default",no_channel:"default"},qe={connected:"Ba\u011fl\u0131",needs_attention:"Dikkat",disconnected:"Kopuk",unknown:"Bilinmiyor",no_channel:"Kanal yok"},Je={whatsapp:"WhatsApp",instagram:"Instagram",none:"\u2014"},Xe={whatsapp:"#25D366",instagram:"#E1306C",none:"#475569"};function Ze(e){if(!e)return null;try{var t=new Date(e).getTime(),n=Date.now();return Math.round((t-n)/864e5)}catch(a){return null}}function Qe(e){return null==e?"default":e<0||e<3?"red":e<14?"orange":"green"}const $e=function(){var e=(0,a.useState)([]),t=e[0],n=e[1],r=(0,a.useState)(!1),l=r[0],o=r[1],c=(0,a.useState)(""),u=c[0],p=c[1],m=(0,a.useState)("all"),g=m[0],h=m[1],x=(0,a.useState)("all"),f=x[0],y=x[1],b=(0,a.useState)(!1),v=b[0],j=b[1],k=(0,a.useState)("undefined"!==typeof window&&window.innerWidth<768),_=k[0],w=k[1];(0,a.useEffect)(function(){var e=function(){w(window.innerWidth<768)};return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]);var S=(0,a.useCallback)(function(){o(!0),s.Ay.get(d.A.superAdmin.channelsStatus).then(function(e){var t=e&&e.data&&e.data.data?e.data.data:[];n(Array.isArray(t)?t:[])}).catch(function(){n([]),i.message.error("Kanal durumlari yuklenemedi")}).finally(function(){o(!1)})},[]);(0,a.useEffect)(function(){S()},[S]);var z,A=(0,a.useMemo)(function(){var e={total:0,connected:0,issues:0,no_channel:0,token_critical:0};return t.forEach(function(t){if("no_channel"!==t.status){e.total++,"connected"===t.status?e.connected++:"needs_attention"!==t.status&&"disconnected"!==t.status||e.issues++;var n=Ze(t.token_expires_at);null!=n&&n<3&&e.token_critical++}else e.no_channel++}),e},[t]),T=(0,a.useMemo)(function(){var e=u.trim().toLowerCase();return t.filter(function(t){if("all"!==g&&t.channel!==g)return!1;if("all"!==f&&t.status!==f)return!1;if(v){var n=Ze(t.token_expires_at);if(!("needs_attention"===t.status||"disconnected"===t.status||"no_channel"===t.status||null!=n&&n<3))return!1}return!e||-1!==((t.tenant_name||"")+" "+(t.tenant_slug||"")+" "+(t.owner_email||"")+" "+(t.contact_number||"")+" "+(t.handle||"")+" "+(t.label||"")+" "+String(t.tenant_id||"")).toLowerCase().indexOf(e)})},[t,u,g,f,v]),I=function(e){return function(t,n){return String(t[e]||"").localeCompare(String(n[e]||""))}},C=function(e){return function(t,n){return new Date(t[e]||0).getTime()-new Date(n[e]||0).getTime()}},B=[{title:"Tenant",dataIndex:"tenant_id",width:220,sorter:(z="tenant_id",function(e,t){return Number(e[z]||0)-Number(t[z]||0)}),defaultSortOrder:"descend",render:function(e,t){return(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:700,color:"var(--cp-text)"},children:["#",t.tenant_id," \xb7 ",t.tenant_name||"\u2014"]}),t.tenant_slug?(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0,marginTop:2},children:t.tenant_slug}):null]})}},{title:"\u0130leti\u015fim",key:"contact",width:230,render:function(e,t){return(0,D.jsx)(R,{email:t.owner_email,phone:t.contact_number,layout:"compact"})}},{title:"Kanal",dataIndex:"channel",width:110,sorter:I("channel"),render:function(e){return"none"===e?(0,D.jsx)(i.Tag,{style:{margin:0,color:"var(--cp-muted)"},children:"Kanal yok"}):(0,D.jsx)(i.Tag,{color:Xe[e],style:{color:"#fff",borderColor:Xe[e]},children:Je[e]||e})}},{title:"Hesap",dataIndex:"handle",width:200,sorter:I("handle"),render:function(e,t){return(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontWeight:600},children:t.handle}),t.label?(0,D.jsx)("div",{style:{fontSize:11,color:"var(--cp-muted)"},children:t.label}):null,t.coexistence_enabled?(0,D.jsx)(i.Tag,{color:"green",style:{margin:0,marginTop:2,fontSize:10},children:"\ud83d\udcf1 Coexistence"}):null]})}},{title:"Durum",dataIndex:"status",width:110,sorter:I("status"),render:function(e){return(0,D.jsx)(i.Tag,{color:Ue[e]||"default",children:qe[e]||e})}},{title:"Token Biti\u015f",dataIndex:"token_expires_at",width:140,sorter:C("token_expires_at"),render:function(e,t){if(!t.token_expires_at)return(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"\u2014"});var n=Ze(t.token_expires_at),a=Qe(n);return(0,D.jsxs)("div",{style:{fontSize:11},children:[(0,D.jsx)(i.Tag,{color:a,style:{margin:0},children:null!=n?n<0?"S\xfcresi doldu":n+" g\xfcn":"\u2014"}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",marginTop:2},children:He(t.token_expires_at)})]})}},{title:"Hata",dataIndex:"last_error",width:200,sorter:!1,render:function(e){if(!e)return(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"\u2014"});var t=String(e),n=t.length>80?t.slice(0,80)+"...":t;return(0,D.jsx)(i.Tooltip,{title:(0,D.jsx)("div",{style:{maxWidth:400,whiteSpace:"pre-wrap"},children:t}),children:(0,D.jsx)("div",{style:{fontSize:11,color:"var(--cp-warn)",whiteSpace:"normal"},children:n})})}},{title:"G\xfcncellendi",dataIndex:"updated_at",width:110,sorter:C("updated_at"),render:function(e,t){return(0,D.jsx)("span",{style:{fontSize:11,color:"var(--cp-muted)"},children:Ve(t.updated_at)})}}],W=function(e,t,n,a){return(0,D.jsx)(i.Col,{xs:12,sm:8,md:6,lg:4,children:(0,D.jsxs)(i.Card,{bodyStyle:{padding:14},onClick:a,style:{background:n+"0d",border:"1px solid "+n+"33",cursor:a?"pointer":"default"}
1,children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-faint)",fontWeight:700,letterSpacing:.5},children:e}),(0,D.jsx)("div",{style:{fontSize:24,fontWeight:800,color:n},children:t})]})})};return(0,D.jsxs)("div",{style:{padding:_?0:4},children:[(0,D.jsxs)("div",{style:{marginBottom:16},children:[(0,D.jsx)("h2",{style:{color:"var(--cp-title)",margin:0,fontSize:20,fontWeight:800},children:"Kanal Durumlar\u0131"}),(0,D.jsx)("div",{style:{color:"var(--cp-faint)",fontSize:12,marginTop:4},children:"T\xfcm tenant'lar\u0131n WhatsApp + Instagram ba\u011flant\u0131 sa\u011fl\u0131\u011f\u0131 tek bak\u0131\u015fta. Token biti\u015f, hata mesajlar\u0131, sorunlu kanallar burada."})]}),(0,D.jsxs)(i.Row,{gutter:[10,10],style:{marginBottom:16},children:[W("TOPLAM HESAP",A.total,"var(--cp-muted)"),W("BA\u011eLI",A.connected,"var(--cp-ok)",function(){y("connected"),j(!1)}),W("SORUNLU",A.issues,"var(--cp-warn)",function(){j(!0)}),W("TOKEN <3G",A.token_critical,"#ef4444",function(){j(!0)}),W("KANAL YOK",A.no_channel,"#475569",function(){y("no_channel")})]}),(0,D.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginBottom:12,padding:10,background:"rgba(255,255,255,0.02)",borderRadius:10,border:"1px solid rgba(255,255,255,0.05)",alignItems:"center"},children:[(0,D.jsx)(i.Input.Search,{placeholder:"Tenant ad\u0131, email, telefon, handle ara",value:u,onChange:function(e){p(e.target.value)},style:{maxWidth:280,flex:"1 1 200px"}}),(0,D.jsxs)(i.Select,{value:g,onChange:function(e){h(e)},style:{width:140},children:[(0,D.jsx)(Ye,{value:"all",children:"T\xfcm Kanallar"}),(0,D.jsx)(Ye,{value:"whatsapp",children:"WhatsApp"}),(0,D.jsx)(Ye,{value:"instagram",children:"Instagram"}),(0,D.jsx)(Ye,{value:"none",children:"Kanal\u0131 Yok"})]}),(0,D.jsxs)(i.Select,{value:f,onChange:function(e){y(e)},style:{width:160},children:[(0,D.jsx)(Ye,{value:"all",children:"T\xfcm Durumlar"}),(0,D.jsx)(Ye,{value:"connected",children:"Ba\u011fl\u0131"}),(0,D.jsx)(Ye,{value:"needs_attention",children:"Dikkat Gerekli"}),(0,D.jsx)(Ye,{value:"disconnected",children:"Kopuk"}),(0,D.jsx)(Ye,{value:"no_channel",children:"Hi\xe7 Kanal\u0131 Yok"})]}),(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"0 8px"},children:[(0,D.jsx)(i.Switch,{checked:v,onChange:function(e){j(e)},size:"small"}),(0,D.jsx)("span",{style:{fontSize:12,color:"var(--cp-warn)"},children:"Sadece sorunlu"})]}),(0,D.jsxs)(i.Button,{onClick:S,loading:l,children:[(0,D.jsx)(i.Icon,{type:"reload"})," Yenile"]}),(0,D.jsxs)("span",{style:{color:"var(--cp-faint)",fontSize:11},children:[T.length," / ",t.length]})]}),_?(0,D.jsx)("div",{children:l&&0===t.length?(0,D.jsx)("div",{style:{textAlign:"center",padding:30,color:"var(--cp-faint)"},children:"Y\xfckleniyor..."}):0===T.length?(0,D.jsx)(i.Empty,{description:"Kay\u0131t yok"}):T.map(function(e){var t=Ze(e.token_expires_at),n=Qe(t);return(0,D.jsxs)("div",{style:{padding:14,background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:12,marginBottom:10},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:700,fontSize:14},children:["#",e.tenant_id," \xb7 ",e.tenant_name]}),e.tenant_slug?(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0,marginTop:2,fontSize:10},children:e.tenant_slug}):null]}),(0,D.jsx)(i.Tag,{color:Ue[e.status]||"default",style:{margin:0},children:qe[e.status]||e.status})]}),(0,D.jsx)("div",{style:{marginBottom:8},children:(0,D.jsx)(R,{email:e.owner_email,phone:e.contact_number,layout:"stack"})}),(0,D.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:6,flexWrap:"wrap"},children:["none"!==e.channel?(0,D.jsx)(i.Tag,{color:Xe[e.channel],style:{color:"#fff"},children:Je[e.channel]}):null,(0,D.jsx)("span",{style:{fontWeight:600},children:e.handle}),e.coexistence_enabled?(0,D.jsx)(i.Tag,{color:"green",style:{fontSize:10,margin:0},children:"\ud83d\udcf1 Coexistence"}):null]}),e.label?(0,D.jsx)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginBottom:6},children:e.label}):null,e.token_expires_at?(0,D.jsxs)("div",{style:{fontSize:11,marginBottom:6},children:["Token: ",(0,D.jsx)(i.Tag,{color:n,style:{margin:0},children:null!=t?t<0?"S\xfcresi doldu":t+" g\xfcn kald\u0131":"\u2014"})]}):null,e.last_error?(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-warn)",padding:"6px 8px",background:"rgba(251,191,36,0.08)",borderRadius:6,marginTop:6},children:["\u26a0 ",String(e.last_error).slice(0,120),String(e.last_error).length>120?"...":""]}
1):null,(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-faint)",marginTop:6},children:Ve(e.updated_at)})]},e.channel+"-"+(e.account_id||e.tenant_id))})}):(0,D.jsx)(i.Table,{loading:l,dataSource:T,columns:B,rowKey:function(e){return e.channel+"-"+(e.account_id||e.tenant_id)},size:"small",pagination:{pageSize:30,showSizeChanger:!0,pageSizeOptions:["20","30","50","100"]},scroll:{x:"max-content"},locale:{emptyText:(0,D.jsx)(i.Empty,{description:"Kay\u0131t yok"})}})]})};const et=function(e){let{onOpenTenant:t}=e;const[n,r]=(0,a.useState)([]),[l,o]=(0,a.useState)(!1),c=(0,a.useCallback)(()=>{o(!0),s.Ay.get(d.A.superAdmin.trialEndingSoon+"?days=7").then(e=>{const t=e&&e.data&&e.data.data?e.data.data:[];r(Array.isArray(t)?t:[])}).catch(()=>{r([]),i.message.warning("Trial listesi y\xfcklenemedi")}).finally(()=>o(!1))},[]);(0,a.useEffect)(()=>{c()},[c]);const u=e=>null==e?"default":e<0||e<=1?"red":e<=3?"orange":"blue",p=[{title:"\u015eirket",key:"tenant",width:200,render:(e,t)=>(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:700,fontSize:12},children:["#",t.id," \xb7 ",t.name]}),t.owner_full_name?(0,D.jsx)("div",{style:{color:"var(--cp-muted)",fontSize:11},children:t.owner_full_name}):null]})},{title:"\u0130leti\u015fim",key:"contact",width:220,render:(e,t)=>(0,D.jsx)(R,{email:t.owner_email,phone:t.contact_number,layout:"compact"})},{title:"Trial",dataIndex:"days_left",width:100,render:e=>(0,D.jsx)(i.Tag,{color:u(e),style:{margin:0},children:null!=e?e<0?"S\xfcresi doldu":e+" g\xfcn kald\u0131":"\u2014"})},{title:"WA",key:"wa",width:70,render:(e,t)=>t.wa_connected?(0,D.jsx)(i.Tag,{color:"green",style:{margin:0},children:t.wa_connected}):(0,D.jsx)("span",{style:{color:"var(--cp-faint)"},children:"\u2014"})},{title:"\u0130\u015flem",key:"actions",width:100,render:(e,n)=>(0,D.jsx)(i.Button,{size:"small",type:"primary",onClick:()=>t&&t(n.id),children:"A\xe7"})}];return(0,D.jsx)(i.Card,{title:(0,D.jsxs)("span",{children:[(0,D.jsx)("span",{style:{color:"#f97316"},children:"\ud83d\udd25"})," Trial Bitiyor (Sat\u0131\u015f Listesi)"]}),bordered:!1,style:{background:"rgba(249,115,22,0.04)",border:"1px solid rgba(249,115,22,0.2)"},bodyStyle:{padding:12},extra:(0,D.jsx)(i.Button,{size:"small",onClick:c,loading:l,children:(0,D.jsx)(i.Icon,{type:"reload"})}),children:l&&0===n.length?(0,D.jsx)("div",{style:{textAlign:"center",padding:20,color:"var(--cp-faint)"},children:"Y\xfckleniyor..."}):0===n.length?(0,D.jsx)(i.Empty,{description:"Trial bitiyor olan tenant yok \ud83d\udc4d"}):(0,D.jsx)(i.Table,{rowKey:"id",columns:p,dataSource:n.slice(0,10),size:"small",pagination:!1,scroll:{x:"max-content"}})})},tt=e=>Number(e||0).toLocaleString("tr-TR",{minimumFractionDigits:0,maximumFractionDigits:0}),nt=e=>{if(!e)return"\u2014";try{return new Date(e).toLocaleDateString("tr-TR")}catch(t){return"\u2014"}};const at=function(e){let{onOpenTenant:t}=e;const[n,r]=(0,a.useState)([]),[l,o]=(0,a.useState)(!1),c=(0,a.useCallback)(()=>{o(!0),s.Ay.get(d.A.superAdmin.topSpenders+"?limit=20").then(e=>{const t=e&&e.data&&e.data.data?e.data.data:[];r(Array.isArray(t)?t:[])}).catch(()=>{r([]),i.message.warning("VIP listesi y\xfcklenemedi")}).finally(()=>o(!1))},[]);(0,a.useEffect)(()=>{c()},[c]);const u=[{title:"#",dataIndex:"rank",width:40,render:e=>(0,D.jsx)("span",{style:{fontWeight:700,color:e<=3?"var(--cp-warn)":"var(--cp-muted)"},children:e})},{title:"\u015eirket",key:"tenant",width:200,render:(e,t)=>(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontWeight:700,fontSize:12},children:["#",t.tenant_id," \xb7 ",t.tenant_name]}),t.owner_full_name?(0,D.jsx)("div",{style:{color:"var(--cp-muted)",fontSize:11},children:t.owner_full_name}):null,t.plan_name?(0,D.jsx)(i.Tag,{color:"purple",style:{margin:0,marginTop:2,fontSize:10},children:t.plan_name}):null]})},{title:"\u0130leti\u015fim",key:"contact",width:220,render:(e,t)=>(0,D.jsx)(R,{email:t.owner_email,phone:t.contact_number,layout:"compact"})},{title:"Toplam \xd6denen",dataIndex:"total_amount",width:130,render:e=>(0,D.jsxs)("span",{style:{color:"var(--cp-ok)",fontWeight:800},children:[tt(e)," TL"]})},{title:"\u0130\u015flem Say\u0131s\u0131",dataIndex:"transaction_count",width:90,render:e=>(0,D.jsx)("span",{style:{color:"var(--cp-muted)"},children:e})},{title:"Son \xd6deme",dataIndex:"last_payment_at",width:100,render:e=>(0,D.jsx)("span",{style:{fontSize:11,color:"var(--cp-muted)"},children:nt(e)})},{title:"A\xe7",key:"actions",width:70,render:(e,n)=>(0,D.jsx)(i.Button,{size:"small",type:"primary",onClick:()=>t&&t(n.tenant_id),children:"A\xe7"})}];return(0,D.jsx)(i.Card,{title:(0,D.jsxs)("span",{children:[(0,D.jsx)("span",{style:{color:"var(--cp-warn)"},children:"\u2b50"})," En \xc7ok \xd6deyen 20 \u015eirket (VIP)"]}),bordered:!1,style:{background:"rgba(251,191,36,0.04)",border:"1px solid rgba(251,191,36,0.2)"},bodyStyle:{padding:12},extra:(0,D.jsx)(i.Button,{size:"small",onClick:c,loading:l,children:(0,D.jsx)(i.Icon,{type:"reload"})}),children:l&&0===n.length?(0,D.jsx)("div",{style:{textAlign:"center",padding:20,color:"var(--cp-faint)"},children:"Y\xfckleniyor..."}):0===n.length?(0,D.jsx)(i.Empty,{description:"Hen\xfcz \xf6deme kayd\u0131 yok"}):(0,D.jsx)(i.Table,{rowKey:"tenant_id",columns:u,dataSource:n,size:"small",pagination:!1,scroll:{x:"max-content",y:360}})})},it=e=>(t,n)=>Number(t[e]||0)-Number(n[e]||0),rt=e=>(t,n)=>String(t[e]||"").localeCompare(String(n[e]||"")),lt={pending:"orange",approved:"blue",paid:"green",rejected:"red",active:"green",suspended:"orange",closed:"default"},ot={pending:"Bekliyor",approved:"Onaylandi",paid:"Odendi",rejected:"Reddedildi",active:"Aktif",suspended:"Askida",closed:"Kapali"},st=e=>(0,D.jsx)(i.Tag,{color:lt[e]||"default",children:ot[e]||e}),dt=e=>
1Number(e||0).toLocaleString("tr-TR",{minimumFractionDigits:0,maximumFractionDigits:0})+" TL",ct=e=>{var t=e||null;if(!t)return"-";try{return new Date(t).toLocaleDateString("tr-TR")}catch(n){return"-"}},ut=()=>{const[e,t]=(0,a.useState)("affiliates"),[n,r]=(0,a.useState)({}),[l,o]=(0,a.useState)([]),[c,u]=(0,a.useState)([]),[p,m]=(0,a.useState)([]),[g,h]=(0,a.useState)(!0),[x,f]=(0,a.useState)(""),[y,b]=(0,a.useState)(null),[v,j]=(0,a.useState)(null),[k,_]=(0,a.useState)("undefined"!==typeof window&&window.innerWidth<768);(0,a.useEffect)(()=>{var e=function(){_(window.innerWidth<768)};return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}},[]);const[w,S]=(0,a.useState)(!1),[z,A]=(0,a.useState)(null),[T,I]=(0,a.useState)(""),[C,B]=(0,a.useState)(""),[W,N]=(0,a.useState)(""),[K,F]=(0,a.useState)(!1),O=(0,a.useCallback)(async()=>{h(!0);try{const[e,t,n]=await Promise.all([s.Ay.get(d.A.affiliates.adminStats).catch(()=>null),s.Ay.get(d.A.affiliates.adminList,{params:{search:x,limit:100}}).catch(()=>null),s.Ay.get(d.A.affiliates.adminCommissions,{params:{limit:100}}).catch(()=>null)]);r(e&&e.data&&e.data.data||{}),o(t&&t.data&&t.data.data&&t.data.data.affiliates||[]),m(n&&n.data&&n.data.data&&n.data.data.commissions||[])}catch(e){}finally{h(!1)}},[x]);(0,a.useEffect)(()=>{O()},[O]);const M=async e=>{b(e),S(!0),j(null);try{var t=await s.Ay.get(d.A.affiliates.adminDetail+"/"+e.id);j(t&&t.data&&t.data.data||null)}catch(n){i.message.error("Detay yuklenemedi")}finally{S(!1)}},L=e=>{var t=Number(e.balance||v&&v.stats&&v.stats.balance||0);A(e),N(String(t>0?t.toFixed(0):"0")),I(""),B("")},E=async(e,t)=>{try{await s.Ay.put("/api/affiliates/admin/"+e+"/status",{status:t}),i.message.success("Durum guncellendi"),await O()}catch(n){i.message.error("Guncellenemedi")}};var P=v||{},G=P.affiliate||y||{},Y=P.stats||{},H=P.customers||[],V=P.commissions||[],U=P.payouts||[];return(0,D.jsxs)("div",{style:{padding:20},children:[(0,D.jsx)("h2",{style:{color:"#f8fafc",marginBottom:20},children:"Danismanlik Yonetimi"}),(0,D.jsx)(i.Row,{gutter:[16,16],style:{marginBottom:24},children:[{t:"Toplam Danissman",v:n.total_affiliates||0},{t:"Aktif",v:n.active_affiliates||0},{t:"Komisyon Borcu",v:dt(n.total_balance)},{t:"Bu Ay Komisyon",v:dt(n.this_month_commissions)},{t:"Toplam Odenen",v:dt(n.total_paid)}].map(function(e,t){return(0,D.jsx)(i.Col,{xs:12,md:4,children:(0,D.jsx)(i.Card,{style:{borderRadius:16,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},bodyStyle:{padding:16},children:(0,D.jsx)(i.Statistic,{title:(0,D.jsx)("span",{style:{color:"var(--cp-muted)",fontSize:11},children:e.t}),value:e.v,valueStyle:{color:"#f8fafc",fontSize:22,fontWeight:800}})})},t)})}),(0,D.jsx)(i.Card,{style:{borderRadius:20,background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)"},bodyStyle:{padding:0},children:(0,D.jsxs)(i.Tabs,{activeKey:e,onChange:t,tabBarStyle:{padding:"0 20px",marginBottom:0},children:[(0,D.jsx)(i.Tabs.TabPane,{tab:"Danismanlar",children:(0,D.jsxs)("div",{style:{padding:20},children:[(0,D.jsx)(i.Input.Search,{placeholder:"Ad, email veya kod ara...",value:x,onChange:function(e){f(e.target.value)},onSearch:O,style:{maxWidth:400,marginBottom:16,borderRadius:10}}),k?(0,D.jsx)("div",{children:g&&0===l.length?(0,D.jsx)("div",{style:{textAlign:"center",padding:30,color:"var(--cp-faint)"},children:"Y\xfckleniyor..."}):0===l.length?(0,D.jsx)(i.Empty,{description:"Dan\u0131\u015fman yok"}):l.map(function(e){return(0,D.jsxs)("div",{onClick:function(){M(e)},style:{padding:14,background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:12,marginBottom:10,cursor:"pointer"},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:8},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{style:{fontWeight:700,fontSize:14},children:e.name||"(isimsiz)"}),(0,D.jsx)(i.Tag,{color:"blue",style:{margin:0,marginTop:2,fontSize:10},children:e.affiliate_code})]}),st(e.status)]}),(0,D.jsx)("div",{onClick:function(e){e.stopPropagation()},style:{marginBottom:8},children:(0,D.jsx)(R,{email:e.email,phone:e.phone,layout:"compact"})}),(0,D.jsxs)("div",{style:{display:"flex",gap:10,fontSize:11,color:"var(--cp-muted)",marginBottom:8,flexWrap:"wrap"},children:[(0,D.jsxs)("span",{children:["\ud83d\udc65 ",e.customer_count||0," m\xfc\u015fteri"]}),(0,D.jsxs)("span",{children:["\ud83d\udcb0 ",dt(e.total_earned)," kazan\xe7"]}),(0,D.jsxs)("span",{style:{color:Number(e.balance)>0?"var(--cp-warn)":"var(--cp-faint)",fontWeight:700},children:["\ud83d\udcca ",dt(e.balance)," bakiye"]})]}),(0,D.jsxs)("div",{onClick:function(e){e.stopPropagation()},style:{display:"flex",gap:6,flexWrap:"wrap"},children:[(0,D.jsx)(i.Button,{size:"default",type:"primary",onClick:function(){M(e)},style:{minHeight:36},children:"Detay"}),Number(e.balance)>0&&(0,D.jsx)(i.Button,{size:"default",style:{background:"#10b981",borderColor:"#10b981",color:"#fff",minHeight:36},onClick:function(){L(e)},children:"\xd6de"})]})]},e.id)})}):(0,D.jsx)(i.Table,{dataSource:l,rowKey:"id",size:"small",loading:g,pagination:{pageSize:20,showSizeChanger:!0,showTotal:function(e){return"Toplam "+e}},scroll:{x:"max-content"},onRow:function(e){return{onClick:function(){M(e)},style:{cursor:"pointer"}}},columns:[{title:"Ad",dataIndex:"name",width:140,sorter:rt("name")},{title:"\u0130leti\u015fim",key:"contact",width:220,render:function(e,t){return(0,D.jsx)("div",{onClick:function(e){e.stopPropagation()},children:(0,D.jsx)(R,{email:t.email,phone:t.phone,layout:"compact"})})}},{title:"Kod",dataIndex:"affiliate_code",width:140,sorter:rt("affiliate_code"),render:function(e){return(0,D.jsx)(i.Tag,{color:"blue",children:e})}},{title:"IBAN",dataIndex:"iban",width:100,render:function(e){return(e=>e?"****"+String(e).slice(-4):"-")(e)}},{title:"M\xfc\u015fteri",dataIndex:"customer_count",width:70,sorter:it("customer_count")},{title:"Kazan\xe7",dataIndex:"total_earned",width:110,sorter:it("total_earned"),render:function(e){return dt(e)}},{title:"Bakiye",dataIndex:"balance",width:110,sorter:it("balance"),defaultSortOrder:"descend",render:function(e){return(0,D.jsx)("span",{style:{color:Number(e)>0?"var(--cp-warn)":void 0,fontWeight:Number(e)>0?700:400},children:dt(e)})}},{title:"Durum",dataIndex:"status",width:90,sorter:rt("status"),render:function(e){return st(e)}},{title:"\u0130\u015flem",key:"actions",width:200,fixed:"right",render:function(e,t){return(0,D.jsxs)("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},onClick:function(e){e.stopPropagation()},children:[(0,D.jsx)(i.Button,{size:"small",type:"primary",onClick:function(){M(t)},children:"Detay"}),Number(t.balance)>0&&(0,D.jsx)(i.Button,{size:"small",style:{background:"#10b981",borderColor:"#10b981",color:"#fff"},onClick:function(){L(t)},children:"\xd6de"}),"active"===t.status&&(0,D.jsx)(i.Button,{size:"small",onClick:function(){E(t.id,"suspended")},children:"Ask\u0131ya Al"}),"suspended"===t.status&&(0,D.jsx)(i.Button,{size:"small",onClick:function(){E(t.id,"active")},children:"Aktif Et"})]})}}]})]})},"affiliates"),(0,D.jsx)(i.Tabs.TabPane,{tab:"Odeme Gecmisi",children:(0,D.jsx)("div",{style:{padding:20},children:(0,D.jsx)(i.Table,{dataSource:l.filter(function(e){return Number(e.total_paid)>0}),rowKey:"id",size:"small",loading:g,pagination:{pageSize:20,showSizeChanger:!0},scroll:{x:"max-content"},locale:{emptyText:"Henuz odeme yapilmadi"},columns:[{title:"Danissman",dataIndex:"name"},{title:"Kod",dataIndex:"affiliate_code",render:function(e){return(0,D.jsx)(i.Tag,{color:"blue",children:e})}},{title:"IBAN",dataIndex:"iban",render:function(e){return e||"-"}},{title:"Banka",dataIndex:"bank_name",render:function(e){return e||"-"}},{title:"Toplam Odenen",dataIndex:"total_paid",render:function(e){return(0,D.jsx)("span",{style:{color:"var(--cp-ok)",fontWeight:700},children:dt(e)})}},{title:"Kalan Bakiye",dataIndex:"balance",render:function(e){return dt(e)}}]})})},"payouts"),(0,D.jsx)(i.Tabs.TabPane,{tab:"Komisyonlar",children:(0,D.jsx)("div",{style:{padding:20},children:(0,D.jsx)(i.Table,{dataSource:p,rowKey:"id",size:"small",loading:g,pagination:{pageSize:30,showSizeChanger:!0},scroll:{x:"max-content"},columns:[{title:"Danissman",render:function(e,t){return t.affiliate&&t.affiliate.name||t.affiliate&&t.affiliate.affiliate_code||"-"}},{title:"Musteri",render:function(e,t){return t.tenant&&t.tenant.name||"-"}},{title:"Odeme",dataIndex:"amount",render:function(e){return dt(e)}},{title:"Komisyon",dataIndex:"commission_amount",render:function(e){return(0,D.jsx)("span",{style:{color:"var(--cp-ok)",fontWeight:700},children:dt(e)})}},{title:"Ay",dataIndex:"month_number"},{title:"Durum",dataIndex:"status",render:function(e){return st(e)}},{title:"Tarih",dataIndex:"created_at",render:function(e){return ct(e)}}]})})},"commissions")]})}),(0,D.jsx)(i.Drawer,{title:G.name?G.name+" - "+(G.affiliate_code||""):"Danissman Detay",visible:!!y,onClose:function(){b(null),j(null)},width:k?"100%":640,bodyStyle:{background:"var(--cp-bg2)",color:"var(--cp-text)",padding:20},headerStyle:{background:"var(--cp-bg2)",borderBottom:"1px solid rgba(255,255,255,0.06)",color:"var(--cp-title)"},children:w?(0,D.jsx)("div",{style:{textAlign:"center",padding:40,color:"var(--cp-faint)"},children:"Yukleniyor..."}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:14,padding:16,marginBottom:16},children:[(0,D.jsx)("div",{style:{fontSize:13,fontWeight:700,marginBottom:12},children:"Kisisel Bilgiler"}),(0,D.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,
1color:"var(--cp-faint)"},children:"Ad Soyad"}),(0,D.jsx)("div",{style:{fontWeight:600},children:G.name||"-"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Email"}),(0,D.jsx)("div",{children:G.email||"-"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Telefon"}),(0,D.jsx)("div",{children:G.phone||"-"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Kod"}),(0,D.jsx)("div",{children:(0,D.jsx)(i.Tag,{color:"blue",children:G.affiliate_code||"-"})})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Durum"}),(0,D.jsx)("div",{children:st(G.status)})]})]})]}),(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:14,padding:16,marginBottom:16},children:[(0,D.jsx)("div",{style:{fontSize:13,fontWeight:700,marginBottom:12},children:"Banka Bilgileri"}),(0,D.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"IBAN"}),(0,D.jsx)("div",{style:{fontFamily:"monospace",fontSize:13},children:G.iban||"Girilmemis"})]}),(0,D.jsxs)("div",{children:[(0,D.jsx)("span",{style:{fontSize:10,color:"var(--cp-faint)"},children:"Banka"}),(0,D.jsx)("div",{children:G.bank_name||"Girilmemis"})]})]})]}),(0,D.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:10,marginBottom:16},children:[{l:"Musteri",v:Y.customer_count||0},{l:"Kazanc",v:dt(Y.total_earned),c:"var(--cp-title)"},{l:"Bakiye",v:dt(Y.balance),c:"var(--cp-warn)"},{l:"Odenen",v:dt(Y.total_paid),c:"var(--cp-ok)"}].map(function(e,t){return(0,D.jsxs)("div",{style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:10,padding:12,textAlign:"center"},children:[(0,D.jsx)("div",{style:{fontSize:10,color:"var(--cp-faint)"},children:e.l}),(0,D.jsx)("div",{style:{fontSize:18,fontWeight:800,color:e.c||"var(--cp-title)"},children:e.v})]},t)})}),Number(Y.balance)>0&&(0,D.jsxs)(i.Button,{type:"primary",block:!0,style:{borderRadius:10,fontWeight:700,height:42,marginBottom:16,background:"#10b981",borderColor:"#10b981"},onClick:function(){L(G)},children:["Odeme Yap (",dt(Y.balance),")"]}),H.length>0&&(0,D.jsxs)("div",{style:{marginBottom:16},children:[(0,D.jsxs)("div",{style:{fontSize:13,fontWeight:700,marginBottom:8},children:["Musterileri (",H.length,")"]}),(0,D.jsx)(i.Table,{dataSource:H,rowKey:"tenant_id",size:"small",pagination:!1,columns:[{title:"Ad",dataIndex:"name"},{title:"Kayit",dataIndex:"signup_at",render:ct},{title:"Kalan Ay",dataIndex:"remaining_months",render:function(e){return(0,D.jsxs)(i.Tag,{color:e>0?"blue":"default",children:[e," ay"]})}},{title:"Komisyon",dataIndex:"total_commission",render:function(e){return dt(e)}}]})]}),V.length>0&&(0,D.jsxs)("div",{style:{marginBottom:16},children:[(0,D.jsxs)("div",{style:{fontSize:13,fontWeight:700,marginBottom:8},children:["Komisyonlar (",V.length,")"]}),(0,D.jsx)(i.Table,{dataSource:V,rowKey:"id",size:"small",pagination:{pageSize:10},columns:[{title:"Tarih",dataIndex:"created_at",render:ct},{title:"Odeme",dataIndex:"amount",render:dt},{title:"Komisyon",dataIndex:"commission_amount",render:function(e){return(0,D.jsx)("span",{style:{color:"var(--cp-ok)"},children:dt(e)})}},{title:"Ay",dataIndex:"month_number"},{title:"Durum",dataIndex:"status",render:st}]})]}),U.length>0&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{fontSize:13,fontWeight:700,marginBottom:8},children:["Odeme Gecmisi (",U.length,")"]}),(0,D.jsx)(i.Table,{dataSource:U,rowKey:"id",size:"small",pagination:!1,columns:[{title:"Tarih",dataIndex:"paid_at",render:ct},{title:"Tutar",dataIndex:"amount",render:function(e){return(0,D.jsx)("span",{style:{color:"var(--cp-ok)",fontWeight:700},children:dt(e)})}},{title:"Referans",dataIndex:"reference",render:function(e){return e||"-"}},{title:"Not",dataIndex:"notes",render:function(e){return e||"-"}}]})]})]})}),(0,D.jsx)(i.Modal,{title:"Odeme Yap \u2014 "+(z&&z.name||""),visible:!!z,onCancel:function(){A(null)},footer:null,children:z&&(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{style:{marginBottom:12,padding:12,background:"#f0fdf4",borderRadius:10,border:"1px solid #bbf7d0"},children:[(0,D.jsxs)("div",{style:{fontSize:12,color:"#166534",fontWeight:600},children:["Danissman: ",z.name," (",z.affiliate_code,")"]}),(0,D.jsxs)("div",{style:{fontSize:12,color:"#166534"},children:["IBAN: ",z.iban||"Girilmemis"]}),(0,D.jsxs)("div",{style:{fontSize:12,color:"#166534"},children:["Banka: ",z.bank_name||"-"]})]}),(0,D.jsxs)("div",{style:{marginBottom:10},children:[(0,D.jsx)("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:"Tutar (TL)"}),(0,D.jsx)(i.Input,{type:"number",value:W,onChange:function(e){N(e.target.value)}}),(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-muted)",marginTop:4},children:["Mevcut bakiye: ",dt(z.balance)]})]}),(0,D.jsxs)("div",{style:{marginBottom:10},children:[(0,D.jsx)("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:"Havale Referans No"}),(0,D.jsx)(i.Input,{value:T,onChange:function(e){I(e.target.value)},placeholder:"Banka referans numarasi"})]}),(0,D.jsxs)("div",{style:{marginBottom:14},children:[(0,D.jsx)("div",{style:{fontSize:12,fontWeight:600,marginBottom:4},children:"Not (opsiyonel)"}),(0,D.jsx)(i.Input.TextArea,{value:C,onChange:function(e){B(e.target.value)},rows:2})]}),(0,D.jsx)(i.Button,{type:"primary",block:!0,loading:K,onClick:async()=>
1{if(z){F(!0);try{await s.Ay.post(d.A.affiliates.adminPay,{affiliate_id:z.id,amount:Number(W),reference:T,note:C}),i.message.success("Odeme kaydedildi"),A(null),b(null),j(null),await O()}catch(e){i.message.error(e&&e.response&&e.response.data&&e.response.data.message||"Odeme yapilamadi")}finally{F(!1)}}},disabled:!W||Number(W)<=0,style:{borderRadius:10,fontWeight:700,background:"#10b981",borderColor:"#10b981"},children:"Odemeyi Kaydet"})]})})]})},{TextArea:pt}=i.Input,{confirm:mt}=i.Modal,gt=[{key:"all",label:"T\xfcm\xfc",hint:"Aktif + deneme",icon:"team"},{key:"active",label:"Aktif",hint:"\xd6deyen m\xfc\u015fteriler",icon:"check-circle"},{key:"trial",label:"Deneme",hint:"Deneme s\xfcrecinde",icon:"clock-circle"}],ht=()=>{const[e,t]=(0,a.useState)(""),[n,r]=(0,a.useState)(""),[l,o]=(0,a.useState)(""),[c,u]=(0,a.useState)("all"),[p,m]=(0,a.useState)(!1),[g,h]=(0,a.useState)(null),x=async()=>{m(!0);try{const a=await s.Ay.post(d.A.superAdmin.broadcast,{title:e.trim(),body:n.trim()||void 0,link:l.trim()||void 0,segment:c}),u=a&&a.data&&a.data.data||{};i.message.success(a&&a.data&&a.data.message||"G\xf6nderildi"),h(u),t(""),r(""),o("")}catch(a){i.message.error(a&&a.response&&a.response.data&&a.response.data.message||"G\xf6nderilemedi")}finally{m(!1)}},f={borderRadius:10,fontSize:15};return(0,D.jsxs)("div",{children:[(0,D.jsxs)("div",{className:"sa-sticky-bar",children:[(0,D.jsx)("h2",{style:{color:"var(--cp-title)",margin:0,fontSize:22,fontWeight:800},children:"Duyuru G\xf6nder"}),(0,D.jsx)("div",{style:{color:"#475569",fontSize:12,marginTop:4},children:"Kirac\u0131lara uygulama i\xe7i bildirim + telefon push'u g\xf6nder"})]}),(0,D.jsxs)(i.Card,{className:"sa-card",bordered:!1,style:{maxWidth:640,margin:"0 auto"},children:[(0,D.jsxs)("div",{style:{marginBottom:18},children:[(0,D.jsx)("div",{style:{fontSize:12,fontWeight:700,color:"var(--cp-faint)",marginBottom:8,textTransform:"uppercase",letterSpacing:.5},children:"Kime"}),(0,D.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:gt.map(e=>{const t=c===e.key;return(0,D.jsxs)("div",{onClick:()=>u(e.key),style:{flex:"1 1 90px",minWidth:90,cursor:"pointer",padding:"12px 10px",borderRadius:12,textAlign:"center",border:"1px solid "+(t?"rgba(139,92,246,0.5)":"rgba(255,255,255,0.06)"),background:t?"rgba(139,92,246,0.12)":"rgba(255,255,255,0.025)",transition:"all 0.18s"},children:[(0,D.jsx)(i.Icon,{type:e.icon,style:{fontSize:18,color:t?"#a78bfa":"var(--cp-faint)"}}),(0,D.jsx)("div",{style:{fontSize:13,fontWeight:700,color:t?"var(--cp-title)":"var(--cp-muted)",marginTop:4},children:e.label}),(0,D.jsx)("div",{style:{fontSize:10,color:"#475569",marginTop:2},children:e.hint})]},e.key)})})]}),(0,D.jsxs)("div",{style:{marginBottom:14},children:[(0,D.jsxs)("div",{style:{fontSize:12,fontWeight:700,color:"var(--cp-faint)",marginBottom:6,textTransform:"uppercase",letterSpacing:.5},children:["Ba\u015fl\u0131k ",(0,D.jsxs)("span",{style:{color:"var(--cp-faint)",fontWeight:400,textTransform:"none"},children:["(",e.length,"/120)"]})]}),(0,D.jsx)(i.Input,{value:e,maxLength:120,onChange:e=>t(e.target.value),placeholder:"\xd6rn. Yeni \xf6zellik: sesli yan\u0131t geldi \ud83c\udf89",size:"large",style:f})]}),(0,D.jsxs)("div",{style:{marginBottom:14},children:[(0,D.jsxs)("div",{style:{fontSize:12,fontWeight:700,color:"var(--cp-faint)",marginBottom:6,textTransform:"uppercase",letterSpacing:.5},children:["Mesaj ",(0,D.jsx)("span",{style:{color:"var(--cp-faint)",fontWeight:400,textTransform:"none"},children:"(iste\u011fe ba\u011fl\u0131)"})]}),(0,D.jsx)(pt,{value:n,onChange:e=>r(e.target.value),placeholder:"Detay yaz \u2014 bildirim g\xf6vdesinde g\xf6r\xfcn\xfcr.",autoSize:{minRows:3,maxRows:8},style:f})]}),(0,D.jsxs)("div",{style:{marginBottom:20},children:[(0,D.jsxs)("div",{style:{fontSize:12,fontWeight:700,color:"var(--cp-faint)",marginBottom:6,textTransform:"uppercase",letterSpacing:.5},children:["Ba\u011flant\u0131 ",(0,D.jsx)("span",{style:{color:"var(--cp-faint)",fontWeight:400,textTransform:"none"},children:"(iste\u011fe ba\u011fl\u0131 \u2014 t\u0131klay\u0131nca gider)"})]}
1),(0,D.jsx)(i.Input,{value:l,onChange:e=>o(e.target.value),placeholder:"/plan  veya  /araclar",size:"large",style:f})]}),(0,D.jsxs)(i.Button,{type:"primary",block:!0,size:"large",loading:p,onClick:()=>{if(!e.trim())return void i.message.warning("Ba\u015fl\u0131k gerekli");const t=(gt.find(e=>e.key===c)||{}).label||c;mt({title:"Duyuruyu g\xf6nder?",content:'"'.concat(e.trim(),'" ba\u015fl\u0131kl\u0131 duyuru "').concat(t,'" dilimindeki t\xfcm kirac\u0131lara bildirim + push olarak g\xf6nderilecek. Geri al\u0131namaz.'),okText:"G\xf6nder",cancelText:"Vazge\xe7",onOk:x})},style:{height:50,borderRadius:12,fontSize:16,fontWeight:700},children:[(0,D.jsx)(i.Icon,{type:"sound"})," Duyuruyu G\xf6nder"]}),g&&(0,D.jsxs)("div",{style:{marginTop:16,padding:"12px 16px",borderRadius:10,background:"rgba(74,222,128,0.08)",border:"1px solid rgba(74,222,128,0.2)",color:"var(--cp-ok)",fontSize:13,fontWeight:600},children:[(0,D.jsx)(i.Icon,{type:"check-circle"})," Son g\xf6nderim: ",g.sent,"/",g.total," kirac\u0131ya ula\u015ft\u0131",g.failed?" \xb7 ".concat(g.failed," ba\u015far\u0131s\u0131z"):""]})]})]})},xt={minHeight:"100%",background:"linear-gradient(180deg, #eff5fb 0%, #f8fbff 100%)",padding:24},ft={borderRadius:24,border:"1px solid #d7e3f1",boxShadow:"0 18px 40px rgba(15, 23, 42, 0.08)",overflow:"hidden"},yt={borderRadius:20,border:"1px solid #dbe4f0",boxShadow:"0 10px 24px rgba(15, 23, 42, 0.05)",height:"100%"},bt={healthy:{label:"Saglikli",color:"#16a34a",bg:"#dcfce7"},warning:{label:"Dikkat",color:"#dc2626",bg:"#fee2e2"},info:{label:"Bilgi",color:"#2563eb",bg:"#dbeafe"}},vt=e=>{if(!e)return"\u2014";const t=new Date(e);return Number.isNaN(t.getTime())?"\u2014":t.toLocaleString("tr-TR")},jt=e=>null===e||void 0===e||""===e?"\u2014":"boolean"===typeof e?e?"Evet":"Hayir":"object"===typeof e?null:String(e),kt=e=>{let{title:t,value:n,note:a,accent:i}=e;return(0,D.jsxs)("div",{style:{borderRadius:18,padding:16,background:"#fff",border:"1px solid #dbe4f0",boxShadow:"0 10px 24px rgba(15,23,42,0.04)"},children:[(0,D.jsx)("div",{style:{fontSize:12,fontWeight:800,color:i,textTransform:"uppercase",letterSpacing:.4},children:t}),(0,D.jsx)("div",{style:{fontSize:28,fontWeight:900,color:"#0f172a",marginTop:8},children:n}),(0,D.jsx)("div",{style:{fontSize:12,color:"var(--cp-faint)",marginTop:6},children:a})]})},_t=()=>{const[e,t]=(0,a.useState)(!0),[n,r]=(0,a.useState)(null),[l,o]=(0,a.useState)(""),[c,u]=(0,a.useState)(()=>"undefined"===typeof window||"1"!==window.localStorage.getItem("chatpilots.systemHealthGuideDismissed")),p=(0,a.useCallback)(async()=>{t(!0);try{var e;const t=await s.Ay.get(d.A.systemHealth.summary);r((null===t||void 0===t||null===(e=t.data)||void 0===e?void 0:e.data)||{status:"info",cards:{},socket:{clients:0},checked_at:null}),o("")}catch(i){var n,a;console.error("System health load error:",i),r(e=>e||{status:"warning",cards:{},socket:{clients:0},checked_at:null}),o((null===i||void 0===i||null===(n=i.response)||void 0===n||null===(a=n.data)||void 0===a?void 0:a.message)||(null===i||void 0===i?void 0:i.message)||"Sistem sagligi bilgisi alinamadi")}finally{t(!1)}},[]);(0,a.useEffect)(()=>{p();const e=setInterval(p,15e3);return()=>clearInterval(e)},[p]),(0,a.useEffect)(()=>{"undefined"!==typeof window&&window.localStorage.setItem("chatpilots.systemHealthGuideDismissed",c?"0":"1")},[c]);const m=(0,a.useMemo)(()=>{const e=n&&n.cards?n.cards:{};return Object.values(e).filter(Boolean)},[n]),g=bt[n&&n.status||"info"]||bt.info,h=m.filter(e=>"healthy"===e.level).length,x=m.filter(e=>"warning"===e.level).length;return e&&!n?(0,D.jsx)("div",{style:(0,B.A)((0,B.A)({},xt),{},{display:"flex",alignItems:"center",justifyContent:"center"}),children:(0,D.jsxs)("div",{style:{textAlign:"center"},children:[(0,D.jsx)(i.Spin,{size:"large"}),(0,D.jsx)("div",{style:{marginTop:16,color:"var(--cp-faint)",fontWeight:600},children:"Sistem sagligi kontrol ediliyor..."})]})}):(0,D.jsxs)("div",{className:"cp-workspace-shell cp-system-health-shell",style:xt,children:[c&&(0,D.jsx)(i.Card,{className:"cp-guide-card",style:(0,B.A)((0,B.A)({},yt),{},{marginBottom:18,background:"linear-gradient(135deg, #eff6ff 0%, #ffffff 65%)"}),bodyStyle:{padding:20},children:(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:16,flexWrap:"wrap",alignItems:"flex-start"},children:[(0,D.jsxs)("div",{style:{maxWidth:760},children:[(0,D.jsx)("div",{style:{fontSize:12,fontWeight:900,color:"#2563eb",marginBottom:6},children:"OPERASYON REHBERI"}),(0,D.jsx)("div",{style:{fontSize:22,fontWeight:900,color:"#0f172a",marginBottom:6},children:"Saglik ekraniyla problemi bul, sonra ilgili modulu ac"}),(0,D.jsx)("div",{style:{fontSize:13,color:"#475569",lineHeight:1.8},children:"Yesil kartlar stabil alanlari, kirmizi uyarilar ise aksiyon bekleyen servisleri gosterir. \xd6nce queue, kanal ve baglanti kartlarina bak; sonra ilgili operasyon ekranina gec."}),(0,D.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap",marginTop:12},children:["1. Uyarili karti bul","2. Oneriyi oku","3. Ilgili ekrana git"].map(e=>(0,D.jsx)("span",{style:{borderRadius:999,padding:"6px 12px",background:"#dbeafe",color:"#1d4ed8",fontSize:12,fontWeight:800},children:e},e))})]}),(0,D.jsxs)("div",{style:{minWidth:280,display:"grid",gap:10},children:[(0,D.jsxs)("div",{style:{background:"#fff",border:"1px solid #dbe4f0",borderRadius:16,padding:14},children:[(0,D.jsx)("div",{style:{fontSize:12,color:"var(--cp-faint)",fontWeight:800,marginBottom:4},children:"ONCELIKLI DURUM"}),(0,D.jsx)("div",{style:{fontSize:24,fontWeight:900,color:"#0f172a"},children:x>0?"".concat(x," uyari"):"Stabil"}),(0,D.jsx)("div",{style:{fontSize:12,color:"var(--cp-faint)",marginTop:6},children:x>0?"Operasyon ekibinin ilgilenmesi gereken alan var":"Kritik bir sorun gorunmuyor"})]}),(0,D.jsxs)("div",{className:"cp-guide-actions",style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,D.jsx)(i.Button,{type:"primary",style:{borderRadius:12,fontWeight:800},onClick:p,children:"Durumu Yenile"}),(0,D.jsx)(i.Button,{style:{borderRadius:12,fontWeight:700},onClick:()=>u(!1),children:"Rehberi Gizle"})]})]})]})}),(0,D.jsxs)(i.Card,{className:"cp-workspace-hero",style:ft,bodyStyle:{padding:0},children:[(0,D.jsx)("div",{style:{padding:28,background:"linear-gradient(135deg, var(--cp-bg2) 0%, #1d4ed8 50%, #0f766e 100%)",color:"#fff"},children:(0,D.jsxs)(i.Row,{gutter:[20,20],align:"middle",children:[(0,D.jsxs)(i.Col,{xs:24,xl:15,children:[(0,D.jsx)("div",{style:{display:"inline-flex",borderRadius:999,padding:"6px 12px",background:"rgba(255,255,255,0.12)",fontWeight:800,fontSize:12,marginBottom:14},children:"SISTEM SAGLIGI"}),(0,D.jsx)("div",{className:"cp-workspace-hero-title",style:{fontSize:30,fontWeight:900,lineHeight:1.1,marginBottom:10},children:"Altyapi, queue ve kanal sagligini tek ekranda izle."}
1),(0,D.jsx)("div",{className:"cp-workspace-hero-copy",style:{fontSize:14,lineHeight:1.8,color:"#dbeafe",maxWidth:760},children:"Veritabani, Redis, bot queue, outbound queue, WhatsApp, AI Email ve AI Cagri Merkezi durumu burada anlik gorunur."})]}),(0,D.jsx)(i.Col,{xs:24,xl:9,children:(0,D.jsxs)("div",{style:{borderRadius:22,background:"rgba(255,255,255,0.12)",padding:18,border:"1px solid rgba(255,255,255,0.12)"},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:10},children:[(0,D.jsx)("div",{style:{fontSize:13,fontWeight:800,color:"#bfdbfe"},children:"Genel Durum"}),(0,D.jsx)(i.Tag,{style:{border:"none",background:g.bg,color:g.color,borderRadius:999,fontWeight:800},children:g.label})]}),(0,D.jsx)(i.Progress,{percent:m.length?Math.round(h/m.length*100):0,showInfo:!1,strokeColor:"#34d399",trailColor:"rgba(255,255,255,0.18)"}),(0,D.jsxs)("div",{style:{fontSize:12,color:"#dbeafe",marginTop:10},children:[h,"/",m.length||0," modul saglikli \xb7 ",x," uyar\u0131"]}),(0,D.jsxs)("div",{style:{fontSize:11,color:"var(--cp-text2)",marginTop:8},children:["Son kontrol: ",vt(n&&n.checked_at)]})]})})]})}),(0,D.jsxs)("div",{style:{padding:24},children:[l&&(0,D.jsx)(i.Alert,{type:"warning",showIcon:!0,style:{borderRadius:16,marginBottom:20},message:"Sistem sagligi verisi eksik veya gecici olarak alinamadi",description:l}),(0,D.jsxs)(i.Row,{gutter:[12,12],style:{marginBottom:20},children:[(0,D.jsx)(i.Col,{xs:24,md:8,children:(0,D.jsx)(kt,{title:"Saglikli Moduller",value:h,note:"Tam calisan servis sayisi",accent:"#16a34a"})}),(0,D.jsx)(i.Col,{xs:24,md:8,children:(0,D.jsx)(kt,{title:"Uyari Gerektiren",value:x,note:"Operasyon aksiyonuna ihtiyac duyan alan",accent:"#dc2626"})}),(0,D.jsx)(i.Col,{xs:24,md:8,children:(0,D.jsx)(kt,{title:"Socket Baglantisi",value:n&&n.socket&&n.socket.clients||0,note:"Canli bagli istemci sayisi",accent:"#2563eb"})})]}),(0,D.jsx)(i.Alert,{type:x>0?"warning":"success",showIcon:!0,style:{borderRadius:16,marginBottom:20},message:x>0?"Dikkat isteyen moduller var":"Tum ana moduller stabil gorunuyor",description:x>0?"Asagidaki kartlarda queue, kanal ya da senkronizasyon bazli uyarilari gorebilirsin.":"Kritik servisler, queue ve kanal sagligi normal seviyede."}),(0,D.jsxs)(i.Row,{gutter:[18,18],children:[!m.length&&(0,D.jsx)(i.Col,{xs:24,children:(0,D.jsxs)(i.Card,{style:yt,bodyStyle:{padding:20},children:[(0,D.jsx)("div",{style:{fontSize:18,fontWeight:900,color:"#0f172a",marginBottom:8},children:"Saglik kartlari henuz hazir degil"}),(0,D.jsx)("div",{style:{fontSize:13,color:"var(--cp-faint)",lineHeight:1.8},children:"Health endpoint'i veri dondugunde bu ekranda veritabani, Redis, queue, WhatsApp ve AI Email modullerini goreceksin."})]})}),m.map(e=>{const t=bt[e.level]||bt.info,n=e.metrics||{},a=Object.entries(n).filter(e=>{let[,t]=e;return null!==jt(t)});return(0,D.jsx)(i.Col,{xs:24,lg:12,xl:8,children:(0,D.jsxs)(i.Card,{style:yt,bodyStyle:{padding:20},children:[(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:12,alignItems:"center",marginBottom:14},children:[(0,D.jsx)("div",{style:{fontSize:18,fontWeight:900,color:"#0f172a"},children:e.title}),(0,D.jsx)(i.Tag,{style:{border:"none",background:t.bg,color:t.color,borderRadius:999,fontWeight:800},children:t.label})]}),(0,D.jsx)("div",{style:{fontSize:14,fontWeight:800,color:"#0f172a",marginBottom:6},children:e.title&&e.title!==e.key?e.title:e.key}),(0,D.jsx)("div",{style:{fontSize:13,color:"#475569",lineHeight:1.7},children:e.description||"Durum bilgisi bekleniyor"}),(0,D.jsx)("div",{style:{marginTop:12,padding:12,borderRadius:14,background:"#f8fafc",border:"1px solid var(--cp-text)",fontSize:12,color:"var(--cp-faint)",lineHeight:1.7},children:e.recommendation||"Ek aksiyon onerisi bulunmuyor"}),(0,D.jsx)("div",{style:{marginTop:14,display:"grid",gap:8},children:a.slice(0,6).map(e=>{let[t,n]=e;return(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:12,fontSize:12},children:[(0,D.jsx)("div",{style:{color:"var(--cp-faint)"},children:t.replace(/_/g," ")}),(0,D.jsx)("div",{style:{color:"#0f172a",fontWeight:800,textAlign:"right"},children:jt(n)})]},t)})})]})},e.key)})]}),(0,D.jsx)("div",{style:{marginTop:22,display:"flex",justifyContent:"flex-end"},children:(0,D.jsx)(i.Button,{type:"primary",onClick:p,style:{borderRadius:12,height:42,fontWeight:800},children:"Saglik Durumunu Yenile"})})]})]})]})};
1const wt=function(e){var t=e.data||[],n=e.height||160,i=e.color||"#8b5cf6",r=!1!==e.fill,l=e.format||function(e){return e},o=(0,a.useMemo)(function(){if(!t.length)return null;var e=n,a=t.map(function(e){return Number(e.value||0)}),i=Math.max.apply(null,a),r=Math.max(1,i-0),l=740/Math.max(1,t.length-1),o=t.map(function(t,n){return{x:40+n*l,y:20+(e-20-30)*(1-(Number(t.value||0)-0)/r),raw:t}}),s=o.map(function(e,t){return(0===t?"M":"L")+e.x+","+e.y}).join(" "),d=s+" L"+o[o.length-1].x+","+(e-30)+" L"+o[0].x+","+(e-30)+" Z";return{W:800,H:e,padL:40,padR:20,padB:30,padT:20,max:i,points:o,linePath:s,areaPath:d}},[t,n]);if(!o)return(0,D.jsx)("div",{style:{padding:30,textAlign:"center",color:"#475569",fontSize:12},children:"Grafik verisi yok"});var s="tc-grad-"+Math.round(1e6*Math.random());return(0,D.jsx)("div",{style:{width:"100%"},children:(0,D.jsxs)("svg",{viewBox:"0 0 "+o.W+" "+o.H,preserveAspectRatio:"none",style:{width:"100%",height:n},children:[(0,D.jsx)("defs",{children:(0,D.jsxs)("linearGradient",{id:s,x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,D.jsx)("stop",{offset:"0%",stopColor:i,stopOpacity:"0.35"}),(0,D.jsx)("stop",{offset:"100%",stopColor:i,stopOpacity:"0"})]})}),[.25,.5,.75].map(function(e,t){var n=o.padT+(o.H-o.padT-o.padB)*e;return(0,D.jsx)("line",{x1:o.padL,y1:n,x2:o.W-o.padR,y2:n,stroke:"rgba(255,255,255,0.04)",strokeWidth:"1"},t)}),(0,D.jsx)("text",{x:o.padL-8,y:o.padT+4,fill:"#475569",fontSize:"10",textAnchor:"end",children:l(o.max)}),(0,D.jsx)("text",{x:o.padL-8,y:o.H-o.padB+4,fill:"#475569",fontSize:"10",textAnchor:"end",children:"0"}),r&&(0,D.jsx)("path",{d:o.areaPath,fill:"url(#"+s+")"}),(0,D.jsx)("path",{d:o.linePath,stroke:i,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),o.points.map(function(e,t){return(0,D.jsxs)("g",{children:[(0,D.jsx)("circle",{cx:e.x,cy:e.y,r:"3",fill:"#0b0f1a",stroke:i,strokeWidth:"2"}),(0,D.jsxs)("title",{children:[e.raw.label,": ",l(e.raw.value)]})]},t)}),o.points.map(function(e,t){return t%Math.max(1,Math.floor(o.points.length/6))!==0&&t!==o.points.length-1?null:(0,D.jsx)("text",{x:e.x,y:o.H-8,fill:"#475569",fontSize:"10",textAnchor:"middle",children:e.raw.label},t)})]})})};var St=[".af-wrap { position: relative; padding-left: 0; }",".af-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 4px; border-bottom: 1px solid rgba(255,255,255,0.03); }",".af-item:last-child { border-bottom: none; }",".af-dot { width: 30px; height: 30px; min-width: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; box-shadow: 0 0 0 3px rgba(0,0,0,0.2); }",".af-body { flex: 1; min-width: 0; }",".af-title { color: var(--cp-text); font-size: 13px; font-weight: 600; line-height: 1.35; }",".af-sub { color: var(--cp-faint); font-size: 11px; margin-top: 2px; line-height: 1.3; }",".af-time { color: #475569; font-size: 10px; font-weight: 600; white-space: nowrap; padding-top: 4px; }",".af-empty { text-align: center; padding: 30px 10px; color: #475569; font-size: 12px; }"].join("\n");const zt=function(e){var t=e.items||[],n=e.empty||"Son olay yok";return t.length?(0,D.jsxs)("div",{className:"af-wrap",children:[(0,D.jsx)("style",{children:St}),t.map(function(e){return(0,D.jsxs)("div",{className:"af-item",children:[(0,D.jsx)("div",{className:"af-dot",style:{background:e.color||"#8b5cf6"},children:e.icon?(0,D.jsx)(i.Icon,{type:e.icon}):null}),(0,D.jsxs)("div",{className:"af-body",children:[(0,D.jsx)("div",{className:"af-title",children:e.title}),e.subtitle&&(0,D.jsx)("div",{className:"af-sub",children:e.subt
1itle})]}),(0,D.jsx)("div",{className:"af-time",children:e.time||""})]},e.id)})]}):(0,D.jsx)("div",{className:"af-empty",children:n})};var At=n(5801);const{Content:Tt,Sider:It}=i.Layout,Ct=[{title:"GENEL",items:[{key:"dashboard",title:"Dashboard",iconType:"dashboard"},{key:"broadcast",title:"Duyuru Gonder",iconType:"sound"},{key:"systemHealth",title:"Sistem Sagligi",iconType:"heart"},{key:"productEvents",title:"Urun Olaylari",iconType:"line-chart"}]},{title:"KULLANICI YONETIMI",items:[{key:"tenants",title:"Sirketler",iconType:"shop"},{key:"users",title:"Kullanicilar",iconType:"user"},{key:"tenantMembers",title:"Sirket Uyeleri",iconType:"team"}]},{title:"FINANS",items:[{key:"tenantSubscriptions",title:"Abonelikler",iconType:"database"},{key:"transactionLogs",title:"Odeme Kayitlari",iconType:"file-text"},{key:"affiliates",title:"Danismanlar",iconType:"solution"}]},{title:"KANAL",items:[{key:"channelStatus",title:"Kanal Durumlari",iconType:"link"},{key:"whatsappAccounts",title:"WhatsApp Hesaplari",iconType:"message"}]}],Bt=e=>Number(e||0).toLocaleString("tr-TR",{minimumFractionDigits:0,maximumFractionDigits:0})+" TL",Dt=e=>{if(!e)return"-";try{return new Date(e).toLocaleDateString("tr-TR")}catch(t){return"-"}};class Wt extends a.Component{constructor(){super(...arguments),this.state={activeKey:"dashboard",dashboardData:null,dashboardLoading:!0,isMobile:"undefined"!==typeof window&&window.innerWidth<768,mobileMenuOpen:!1},this.handleMenuClick=e=>{this.setState({activeKey:e,mobileMenuOpen:!1})},this.handleLogout=()=>{this.props.userSignOut()},this.toggleMobileMenu=()=>{this.setState({mobileMenuOpen:!this.state.mobileMenuOpen})},this.handleResize=()=>{var e=window.innerWidth<768;e!==this.state.isMobile&&this.setState({isMobile:e,mobileMenuOpen:!1})},this.loadDashboard=()=>{this.setState({dashboardLoading:!0}),s.Ay.get(d.A.superAdmin.dashboardStats).then(e=>{this.setState({dashboardData:e&&e.data&&e.data.data||{}})}).catch(()=>{this.setState({dashboardData:{}})}).finally(()=>{this.setState({dashboardLoading:!1})})},this.renderDashboard=()=>{const e=this.state.dashboardData||{},t=e.tenants||{},n=e.users||{},a=e.whatsapp_accounts||{},r=e.subscriptions||{},l=e.revenue||{},o=e.affiliates||{},s=e.recent_tenants||[],d=e.recent_transactions||[],c=e=>this.setState({activeKey:e});if(this.state.dashboardLoading)return(0,D.jsxs)("div",{children:[(0,D.jsx)(re,{type:"text",rows:2}),(0,D.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:14,marginTop:20},children:[0,1,2,3,4,5].map(function(e){return(0,D.jsx)(re,{type:"card",height:100},e)})}),(0,D.jsx)("div",{style:{marginTop:20},children:(0,D.jsx)(re,{type:"table",rows:6})})]});var u=e.daily_signups||[];if(!u.length){var p=new Date;u=[];for(var m=6;m>=0;m--){var g=new Date(p.getTime()-864e5*m);u.push({label:String(g.getDate()).padStart(2,"0")+"."+String(g.getMonth()+1).padStart(2,"0"),value:0})}}var h=[];(s||[]).slice(0,5).forEach(function(e){h.push({id:"t-"+e.id,icon:"shop",color:"active"===e.status?"#10b981":"trial"===e.status?"#3b82f6":"#f59e0b",title:"Yeni sirket: "+(e.name||"-"),subtitle:"active"===e.status?"Aktif":"trial"===e.status?"Deneme":e.status,time:Dt(e.created_at)})}),(d||[]).slice(0,5).forEach(function(e){h.push({id:"x-"+e.id,icon:"dollar",color:"#10b981",title:(e.tenant_name||"Sirket")+" odeme yapti",subtitle:Bt(e.amount),time:Dt(e.created_at)})}),h.sort(function(e,t){return new Date(t.rawDate||0)-new Date(e.rawDate||0)}),h=h.slice(0,10);var x=[];t.suspended>0&&x.push({type:"warning",text:t.suspended+" sirket askida",action:"tenants"}),o.commission_debt>0&&x.push({type:"danger",text:Bt(o.commission_debt)+" komisyon odemesi bekliyor",action:"affiliates"}),a.total>0&&a.connected<a.total&&x.push({type:"warning",text:a.total-a.connected+" WhatsApp hatti bagli degil",action:"whatsappAccounts"});var f=l.last_month>0?Math.round((l.this_month-l.last_month)/l.last_month*100):0;return(0,D.jsxs)("div",{children:[(0,D.jsx)("div",{className:"sa-sticky-bar",children:(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:12,flexWrap:"wrap"},children:[(0,D.jsxs)("div",{children:[(0,D.jsxs)("h2",{style:{color:"var(--cp-title)",margin:0,fontSize:22,fontWeight:800},children:[function(){var e=(new Date).getHours();return e<6?"\u0130yi geceler":e<12?"G\xfcnayd\u0131n":e<18?"\u0130yi g\xfcnler":"\u0130yi ak\u015famlar"}(),this.props.authUser&&this.props.authUser.name?", "+this.props.authUser.name:""," \ud83d\udc4b"]}
1),(0,D.jsx)("div",{style:{color:"#475569",fontSize:12,marginTop:4},children:"Sistemin tamam\u0131n\u0131 buradan y\xf6net"})]}),(0,D.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,D.jsxs)(i.Button,{onClick:function(){window.dispatchEvent(new CustomEvent("sa-open-palette"))},style:{borderRadius:8},children:[(0,D.jsx)(i.Icon,{type:"search"})," ",(0,D.jsx)("span",{className:"hide-sm",children:"Hizli Ara"})," ",(0,D.jsx)("kbd",{className:"sa-kbd",children:"\u2318K"})]}),(0,D.jsxs)(i.Button,{type:"default",onClick:this.loadDashboard,style:{borderRadius:8},children:[(0,D.jsx)(i.Icon,{type:"reload"})," Yenile"]})]})]})}),x.length>0&&(0,D.jsx)("div",{style:{marginBottom:20},children:(0,D.jsx)(i.Row,{gutter:[10,10],children:x.map(function(e,t){var n="danger"===e.type?"var(--cp-danger)":"var(--cp-warn)",a="danger"===e.type?"rgba(248,113,113,0.08)":"rgba(251,191,36,0.06)";return(0,D.jsx)(i.Col,{xs:24,md:8,children:(0,D.jsxs)("div",{onClick:function(){e.action&&c(e.action)},style:{cursor:"pointer",padding:"12px 16px",background:a,border:"1px solid "+n+"33",borderLeft:"3px solid "+n,borderRadius:10,color:n,fontSize:13,fontWeight:600,display:"flex",alignItems:"center",gap:10},children:[(0,D.jsx)(i.Icon,{type:"warning"}),(0,D.jsx)("span",{style:{flex:1},children:e.text}),(0,D.jsx)(i.Icon,{type:"right",style:{fontSize:10}})]})},t)})})}),(0,D.jsx)(i.Row,{gutter:[14,14],style:{marginBottom:20},children:[{t:"Toplam Sirket",v:t.total||0,s:(t.active||0)+" aktif, "+(t.trial||0)+" deneme",c:"#8b5cf6",icon:"\ud83c\udfe2",nav:"tenants"},{t:"Aktif Abonelik",v:r.active||0,c:"#3b82f6",icon:"\ud83d\udccb",nav:"tenantSubscriptions"},{t:"Toplam Kullanici",v:n.total||0,c:"#06b6d4",icon:"\ud83d\udc64",nav:"users"},{t:"Bu Ay Gelir",v:Bt(l.this_month),s:"Gecen ay: "+Bt(l.last_month),c:"#10b981",icon:"\ud83d\udcb0",nav:"transactionLogs",delta:f},{t:"WhatsApp Hatti",v:a.total||0,s:(a.connected||0)+" bagli",c:"#25D366",icon:"\ud83d\udcac",nav:"whatsappAccounts"},{t:"Danismanlar",v:o.total||0,s:"Komisyon borcu: "+Bt(o.commission_debt),c:"#f59e0b",icon:"\ud83e\udd1d",nav:"affiliates"}].map((e,t)=>(0,D.jsx)(i.Col,{xs:12,sm:8,md:8,lg:4,children:(0,D.jsxs)("div",{className:"sa-stat-card",onClick:function(){e.nav&&c(e.nav)},style:{borderTop:"3px solid "+e.c},children:[(0,D.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:10},children:[(0,D.jsx)("span",{style:{fontSize:22},children:e.icon}),(0,D.jsx)("span",{style:{fontSize:11,color:"var(--cp-faint)",fontWeight:700,textTransform:"uppercase",letterSpacing:.5},children:e.t})]}),(0,D.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,D.jsx)("div",{style:{fontSize:26,fontWeight:900,color:"var(--cp-title)",letterSpacing:-.5},children:e.v}),"number"===typeof e.delta&&0!==e.delta&&(0,D.jsxs)("span",{style:{fontSize:11,fontWeight:700,color:e.delta>0?"var(--cp-ok)":"var(--cp-danger)",background:e.delta>0?"rgba(74,222,128,0.08)":"rgba(248,113,113,0.08)",padding:"2px 6px",borderRadius:6},children:[e.delta>0?"\u2191":"\u2193"," %",Math.abs(e.delta)]})]}),e.s&&(0,D.jsx)("div",{style:{fontSize:10,color:"#475569",marginTop:6},children:e.s})]})},t))}),(0,D.jsxs)(i.Row,{gutter:[14,14],style:{marginBottom:20},children:[(0,D.jsx)(i.Col,{xs:24,lg:14,children:(0,D.jsx)(i.Card,{className:"sa-card",bordered:!1,title:(0,D.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,D.jsx)("span",{children:"\ud83d\udcc8 Son 7 Gun - Yeni Sirket Egilimi"}),(0,D.jsxs)("span",{style:{fontSize:11,color:"#475569",fontWeight:500},children:["Toplam: ",u.reduce(function(e,t){return e+Number(t.value||0)},0)]})]}),children:(0,D.jsx)(wt,{data:u,height:200,color:"#8b5cf6",format:function(e){return e+""}})})}),(0,D.jsx)(i.Col,{xs:24,lg:10,children:(0,D.jsx)(i.Card,{className:"sa-card",bordered:!1,title:(0,D.jsx)("span",{children:"\u26a1 Son Aktiviteler"}),bodyStyle:{padding:"10px 14px",maxHeight:260,overflowY:"auto"},children:(0,D.jsx)(zt,{items:h,empty:"Henuz aktivite yok"})})})]}),(0,D.jsxs)(i.Row,{gutter:[14,14],style:{marginBottom:20},children:[(0,D.jsx)(i.Col,{xs:24,lg:12,children:(0,D.jsx)(i.Card,{className:"sa-card",title:"Son Kayit Olan Sirketler",bordered:!1,bodyStyle:{padding:0},children:(0,D.jsx)(i.Table,{dataSource:s,rowKey:"id",size:"small",pagination:!1,columns:[{title:"ID",dataIndex:"id",width:50},{title:"Ad",dataIndex:"name"},{title:"Durum",dataIndex:"status",width:80,render:e=>(0,D.jsx)(i.Tag,{color:"active"===e?"green":"trial"===e?"blue":"orange",children:e})},{title:"Tarih",dataIndex:"created_at",width:90,render:Dt}]})})}),(0,D.jsx)(i.Col,{xs:24,lg:12,children:(0,D.jsx)(i.Card,{className:"sa-card",title:"Son Odemeler",bordered:!1,bodyStyle:{padding:0},children:(0,D.jsx)(i.Table,{dataSource:d,rowKey:"id",size:"small",pagination:!1,columns:[{title:"Sirket",dataIndex:"tenant_name"},{title:"Tutar",dataIndex:"amount",width:100,render:e=>(0,D.jsx)("span",{style:{color:"var(--cp-ok)",fontWeight:700},children:Bt(e)})},{title:"Durum",dataIndex:"status",width:70,render:e=>(0,D.jsx)(i.Tag,{color:"green",children:e})},{title:"Tarih",dataIndex:"created_at",width:90,render:Dt}]})})})]}),(0,D.jsxs)(i.Row,{gutter:[14,14],style:{marginBottom:20},children:[(0,D.jsx)(i.Col,{xs:24,lg:12,children:(0,D.jsx)(et,{onOpenTenant:()=>c("tenants")})}),(0,D.jsx)(i.Col,{xs:24,lg:12,children:(0,D.jsx)(at,{onOpenTenant:()=>c("tenants")})})]}),(0,D.jsxs)("div",{style:{marginBottom:8},children:[(0,D.jsx)("div",{style:{fontSize:14,fontWeight:700,color:"var(--cp-title)",marginBottom:12},children:"Hizli Erisim"}),(0,D.jsx)(i.Row,{gutter:[14,14],children:[{icon:"\ud83d\udce3",label:"Duyuru Gonder",key:"broadcast"},{icon:"\ud83c\udfe2",label:"Sirketler",key:"tenants"},{icon:"\ud83d\udc64",label:"Kullanicilar",key:"users"},{icon:"\ud83d\udcb3",label:"Abonelikler",key:"tenantSubscriptions"},{icon:"\ud83d\udcca",label:"Odeme Kayitlari",key:"transactionLogs"},{icon:"\ud83d\udcac",label:"WhatsApp",key:"whatsappAccounts"}].map(e=>(0,D.jsx)(i.Col,{xs:12,md:8,lg:4,children:(0,D.jsxs)("div",{className:"sa-quick-btn",onClick:()=>c(e.key),children:[(0,D.jsx)("div",{className:"sa-qicon",children:e.icon}),(0,D.jsx)("div",{className:"sa-qlabel",children:e.label})]})},e.key))})]})]})},this.renderContent=()=>{const{activeKey:e}=this.state;return"tenants"===e?(0,D.jsx)(ye,{}):"users"===e?(0,D.jsx)(q,{}):"tenantMembers"===e?(0,D.jsx)(te,{}):"tenantSubscriptions"===e?(0,D.jsx)(ze,{}):"transactionLogs"===e?(0,D.jsx)(Be,{}):"whatsappAccounts"===e?(0,D.jsx)(Ge,{}):"channelStatus"===e?(0,D.jsx)($e,{}):"affiliates"===e?(0,D.jsx)(ut,{}):"broadcast"===e?(0,D.jsx)(ht,{}):"systemHealth"===e?(0,D.jsx)(_t,{}):"productEvents"===e?(0,D.jsx)(Ne,{}):this.renderDashboard()},this.renderBottomNav=()=>{const{activeKey:e}=this.state;return(0,D.jsx)("div",{className:"sa-bottomnav",children:[{key:"dashboard",label:"Ozet",icon:"dashboard"},{key:"tenants",label:"Sirketler",icon:"shop"},{key:"users",label:"Kullanici",icon:"user"},{key:"broadcast",label:"Duyuru",icon:"sound"},{key:"__menu",label:"Menu",icon:"menu"}].map(t=>{const n="__menu"!==t.key&&e===t.key;return(0,D.jsxs)("div",{className:"sa-bn-item"+(n?" active":""),onClick:()=>
1{if("__menu"!==t.key){this.setState({activeKey:t.key,mobileMenuOpen:!1});var e=document.querySelector(".sa-content");e&&(e.scrollTop=0)}else this.setState({mobileMenuOpen:!0})},children:[(0,D.jsx)(i.Icon,{type:t.icon}),(0,D.jsx)("span",{children:t.label})]},t.key)})})},this.renderSidebar=()=>{const{activeKey:e}=this.state;return(0,D.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:"100vh"},children:[(0,D.jsxs)("div",{style:{padding:"8px 20px 20px",borderBottom:"1px solid rgba(255,255,255,0.04)"},children:[(0,D.jsx)("div",{style:{fontSize:16,fontWeight:900,color:"var(--cp-title)",letterSpacing:.5},children:"CHATPILOTS.AI"}),(0,D.jsx)("div",{style:{fontSize:11,color:"#475569",marginTop:2},children:"Super Admin Paneli"})]}),(0,D.jsx)("div",{style:{flex:1,paddingTop:4,overflowY:"auto"},children:Ct.map((t,n)=>(0,D.jsxs)("div",{children:[n>0&&(0,D.jsx)("div",{className:"sa-group-sep"}),(0,D.jsx)("div",{className:"sa-group-title",children:t.title}),t.items.map(t=>(0,D.jsxs)("div",{className:"sa-menu-item"+(e===t.key?" active":""),onClick:()=>this.handleMenuClick(t.key),children:[(0,D.jsx)(i.Icon,{type:t.iconType}),(0,D.jsx)("span",{children:t.title})]},t.key))]},t.title))}),(0,D.jsxs)("div",{style:{padding:"16px 12px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[(0,D.jsxs)(i.Button,{block:!0,onClick:()=>{window.location.href="/"},style:{background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.06)",color:"var(--cp-muted)",height:38,borderRadius:8,marginBottom:8,fontSize:12,fontWeight:600},children:[(0,D.jsx)(i.Icon,{type:"arrow-left",style:{marginRight:6}}),"Ana Panele Don"]}),(0,D.jsxs)(i.Button,{block:!0,onClick:this.handleLogout,style:{background:"rgba(248,113,113,0.08)",border:"1px solid rgba(248,113,113,0.15)",color:"var(--cp-danger)",height:38,borderRadius:8,fontSize:12,fontWeight:600},children:[(0,D.jsx)(i.Icon,{type:"logout",style:{marginRight:6}}),"Cikis Yap"]})]})]})}}componentDidMount(){this.loadDashboard(),window.addEventListener("resize",this.handleResize)}componentWillUnmount(){window.removeEventListener("resize",this.handleResize)}render(){const{authUser:e}=this.props,{activeKey:t,isMobile:n,mobileMenuOpen:a}=this.state;if(!e||!e.is_super_admin)return(0,D.jsx)(r.rd,{to:"/super-admin"});var l="Dashboard";return Ct.forEach(function(e){e.items.forEach(function(e){e.key===t&&(l=e.title)})}),(0,D.jsxs)(i.Layout,{className:"sa-layout",children:[(0,D.jsx)("style",{children:"\nhtml, body, #root { height: 100%; margin: 0; overflow: hidden; }\n.sa-layout { height: 100vh; font-family: 'Inter', -apple-system, sans-serif; overflow: hidden; }\n.sa-sider { background: linear-gradient(180deg, #070b14 0%, var(--cp-bg2) 100%) !important; border-right: 1px solid rgba(255,255,255,0.04); height: 100vh !important; }\n.sa-sider .ant-layout-sider-children { height: 100vh; overflow-y: auto; overflow-x: hidden; }\n.sa-content {\n  background: var(--cp-bg) !important;\n  padding: 28px !important;\n  height: 100vh;\n  overflow-y: auto;\n  overflow-x: hidden;\n  scroll-behavior: smooth;\n  overscroll-behavior: contain;\n  position: relative;\n}\n.sa-content::before { content:''; position:absolute; top:0; left:0; right:0; bottom:0; pointer-events:none; z-index:0; background:radial-gradient(ellipse at 30% 20%,rgba(99,102,241,.04),transparent 60%); }\n.sa-content > * { position: relative; z-index: 1; }\n\n/* Custom scrollbar \u2014 inek */\n.sa-content::-webkit-scrollbar, .sa-sider ::-webkit-scrollbar { width: 10px; height: 10px; }\n.sa-content::-webkit-scrollbar-track, .sa-sider ::-webkit-scrollbar-track { background: transparent; }\n.sa-content::-webkit-scrollbar-thumb, .sa-sider ::-webkit-scrollbar-thumb {\n  background: rgba(139,92,246,0.15);\n  border-radius: 6px;\n  border: 2px solid transparent;\n  background-clip: padding-box;\n}\n.sa-content::-webkit-scrollbar-thumb:hover, .sa-sider ::-webkit-scrollbar-thumb:hover {\n  background: rgba(139,92,246,0.4);\n  background-clip: padding-box;\n  border: 2px solid transparent;\n}\n\n/* Sticky filter bar */\n.sa-sticky-bar {\n  position: sticky;\n  top: -28px;\n  margin: -28px -28px 16px -28px;\n  padding: 20px 28px 16px;\n  background: rgba(6,6,15,0.94);\n  backdrop-filter: blur(12px);\n  z-index: 20;\n  border-bottom: 1px solid rgba(255,255,255,0.04);\n}\n.sa-sticky-bar h2 { margin: 0 !important; }\n.sa-group-title { font-size: 10px; font-weight: 700; color: rgba(148,163,184,0.45); letter-spacing: 1.5px; padding: 20px 16px 6px; text-transform: uppercase; }\n.sa-group-sep { height:1px; background:rgba(255,255,255,0.03); margin:4px 16px 0; }\n.sa-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 8px; cursor: pointer; color: var(--cp-faint); font-size: 13px; font-weight: 500; transition: all 0.18s ease; margin: 2px 8px; border-left: 3px solid transparent; }\n.sa-menu-item:hover { color: var(--cp-text); background: rgba(255,255,255,0.04); transform: translateX(2px); }\n.sa-menu-item.active { color: var(--cp-title); background: rgba(99,102,241,0.12); border-left-color: #8b5cf6; box-shadow: inset 0 0 20px rgba(139,92,246,0.06); }\n.sa-menu-item .anticon { font-size: 15px; min-width: 16px; }\n.sa-stat-card { background: rgba(255,255,255,0.025); border: 1px solid rgba(255,255,255,0.05); border-radius: 14px; padding: 18px; position:relative; overflow:hidden; cursor: pointer; transition: all 0.2s ease; }\n.sa-stat-card:hover { background: rgba(139,92,246,0.05); border-color: rgba(139,92,246,0.2); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(139,92,246,0.1); }\n.sa-kbd { display: inline-block; margin-left: 6px; padding: 1px 5px; border: 1px solid rgba(255,255,255,0.1); border-radius: 4px; background:var(--cp-field); color: var(--cp-muted); font-size: 10px; font-family: monospace; font-weight: 600; }\n@media(max-width: 767px) { .hide-sm { display: none; } }\n.sa-stat { background: rgba(255,255,255,0.025); border: 1px solid rgba(255,255,255,0.05); border-radius: 14px; padding: 18px; position:relative; overflow:hidden; }\n.sa-stat::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; border-radius:14px 14px 0 0; }\n.sa-stat:nth-child(1) .sa-stat::before,.sa-stat-c1::before { background:linear-gradient(90deg,#8b5cf6,#6366f1); }\n.sa-stat .ant-statistic-title { color: var(--cp-faint) !important; font-size: 11px !important; }\n.sa-stat .ant-statistic-content-value { color: var(--cp-title) !important; font-size: 22px !important; font-weight: 800 !important; }\n.sa-card { background: rgba(255,255,255,0.025); border: 1px solid rgba(255,255,255,0.05); border-radius: 14px; }\n.sa-card .ant-card-head { border-bottom: 1px solid rgba(255,255,255,0.05); color: var(--cp-title); }\n.sa-card .ant-card-head-title { color: var(--cp-title) !important; font-size: 14px; font-weight: 700; }\n.sa-quick-btn { background: rgba(255,255,255,0.025); border: 1px solid rgba(255,255,255,0.05); border-radius: 14px; padding: 20px 14px; text-align: center; cursor: pointer; transition: all 0.2s; }\n.sa-quick-btn:hover { background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.2); transform:translateY(-2px); box-shadow:0 8px 24px rgba(99,102,241,0.12); }\n.sa-quick-btn .sa-qicon { font-size: 28px; margin-bottom: 8px; }\n.sa-quick-btn .sa-qlabel { font-size: 12px; font-weight: 600; color: var(--cp-muted); }\n\n/* \u2500\u2500 GLOBAL ANTD DARK OVERRIDES \u2500\u2500 */\n.sa-content .ant-card { background: rgba(255,255,255,0.025) !important; border: 1px solid rgba(255,255,255,0.06) !important; border-radius: 14px !important; color: var(--cp-text) !important; box-shadow:none !important; }\n.sa-content .ant-card-head { background: transparent !important; border-bottom: 1px solid rgba(255,255,255,0.06) !important; }\n.sa-content .ant-card-head-title { color: var(--cp-title) !important; font-weight: 700 !important; }\n.sa-content .ant-card-body { color: var(--cp-text) !important; }\n.sa-content .ant-card-bordered { border-color: rgba(255,255,255,0.06) !important; }\n\n.sa-content .ant-table { background: transparent !important; color: var(--cp-text2) !important; }\n.sa-content .ant-table-thead > tr > th { background: rgba(255,255,255,0.03) !important; color: #475569 !important; border-bottom: 1px solid rgba(255,255,255,0.06) !important; font-size: 10px !important; font-weight: 700 !important; text-transform: uppercase !important; letter-spacing: 0.5px !important; }\n.sa-content .ant-table-tbody > tr > td { border-bottom: 1px solid rgba(255,255,255,0.03) !important; color: var(--cp-text2) !important; font-size:12px !important; }\n.sa-content .ant-table-tbody > tr:hover > td { background: rgba(139,92,246,0.04) !important; }\n.sa-content .ant-table-placeholder { background: transparent !important; }\n.sa-content .ant-table-placeholder td { color: #475569 !important; }\n.sa-content .ant-empty-description { color: #475569 !important; }\n.sa-content .ant-table-footer { background: transparent !important; }\n\n.sa-content .ant-input,.sa-content .ant-input-search input,.sa-content textarea.ant-input { background: rgba(255,255,255,0.04) !important; border: 1px solid rgba(255,255,255,0.08) !important; color: var(--cp-text) !important; border-radius:8px !important; }\n.sa-content .ant-input::placeholder,.sa-content textarea.ant-input::placeholder { color: #475569 !important; }\n.sa-content .ant-input:focus,.sa-content .ant-input-focused { border-color: rgba(139,92,246,0.4) !important; box-shadow:0 0 0 2px rgba(139,92,246,0.08) !important; }\n.sa-content .ant-input-group-addon { background: rgba(255,255,255,0.06) !important; border-color: rgba(255,255,255,0.08) !important; color: var(--cp-muted) !important; }\n.sa-content .ant-input-search-button { background: rgba(255,255,255,0.06) !important; border-color: rgba(255,255,255,0.08) !important; color: var(--cp-muted) !important; }\n\n.sa-content .ant-select-selection { background: rgba(255,255,255,0.04) !important; border: 1px solid rgba(255,255,255,0.08) !important; color: var(--cp-text) !important; }\n.sa-content .ant-select-arrow { color: var(--cp-faint) !important; }\n.sa-content .ant-select-selection__placeholder { color: #475569 !important; }\n\n.sa-content .ant-btn { background: rgba(255,255,255,0.04) !important; border: 1px solid rgba(255,255,255,0.1) !important; color: var(--cp-text2) !important; border-radius:8px !important; font-weight:600 !important; }\n.sa-content .ant-btn:hover { background: rgba(255,255,255,0.08) !important; border-color: rgba(255,255,255,0.15) !important; color: var(--cp-title) !important; }\n.sa-content .ant-btn-primary { background: linear-gradient(135deg,#6366f1,#8b5cf6) !important; border-color: #6366f1 !important; color: #fff !important; }\n.sa-content .ant-btn-primary:hover { box-shadow:0 4px 16px rgba(99,102,241,0.35) !important; }\n.sa-content .ant-btn-danger { background: rgba(248,113,113,0.08) !important; border-color: rgba(248,113,113,0.2) !important; color: var(--cp-danger) !important; }\n.sa-content .ant-btn-danger:hover { background: rgba(248,113,113,0.15) !important; }\n\n.ant-modal-content { background: var(--cp-bg2) !important; border: 1px solid rgba(255,255,255,0.06) !important; border-radius: 16px !important; box-shadow:0 24px 60px rgba(0,0,0,0.5) !important; }\n.ant-modal-header { background: var(--cp-bg2) !important; border-bottom: 1px solid rgba(255,255,255,0.06) !important; border-radius:16px 16px 0 0 !important; }\n.ant-modal-title { color: var(--cp-title) !important; font-weight:700 !important; }\n.ant-modal-body { color: var(--cp-text) !important; }\n.ant-modal-body .ant-input,.ant-modal-body textarea.ant-input,.ant-modal-body .ant-select-selection { background: rgba(255,255,255,0.04) !important; border: 1px solid rgba(255,255,255,0.08) !important; color: var(--cp-text) !important; }\n.ant-modal-body .ant-form-item-label label,.ant-modal-body label { color: var(--cp-muted) !important; }\n.ant-modal-footer { border-top: 1px solid rgba(255,255,255,0.06) !important; background: var(--cp-bg2) !important; }\n.ant-modal-close-x { color: var(--cp-faint) !important; }\n.ant-modal-confirm-body .ant-modal-confirm-title { color: var(--cp-title) !important; }\n.ant-modal-confirm-body .ant-modal-confirm-content { color: var(--cp-muted) !important; }\n.ant-modal-confirm .ant-modal-confirm-btns .ant-btn { border-radius:8px !important; }\n\n.ant-drawer-content { background: var(--cp-bg2) !important; }\n.ant-drawer-header { background: var(--cp-bg2) !important; border-bottom: 1px solid rgba(255,255,255,0.06) !important; }\n.ant-drawer-title { color: var(--cp-title) !important; }\n.ant-drawer-body { color: var(--cp-text) !important; }\n.ant-drawer-close { color: var(--cp-faint) !important; }\n\n.sa-content .ant-form-item-label label,.sa-content label { color: var(--cp-muted) !important; }\n\n.sa-content .ant-pagination-item { background: rgba(255,255,255,0.04) !important; border-color: rgba(255,255,255,0.08) !important; border-radius:6px !important; }\n.sa-content .ant-pagination-item a { color: var(--cp-faint) !important; }\n.sa-content .ant-pagination-item-active { background: rgba(99,102,241,0.15) !important; border-color: #6366f1 !important; }\n.sa-content .ant-pagination-item-active a { color: var(--cp-violet) !important; }\n.sa-content .ant-pagination-prev .ant-pagination-item-link,.sa-content .ant-pagination-next .ant-pagination-item-link { background: rgba(255,255,255,0.04) !important; border-color: rgba(255,255,255,0.08) !important; color: var(--cp-faint) !important; border-radius:6px !important; }\n.sa-content .ant-pagination-disabled .ant-pagination-item-link { color: #1e293b !important; }\n\n.sa-content .ant-tabs-bar { border-bottom: 1px solid rgba(255,255,255,0.06) !important; }\n.sa-content .ant-tabs-tab { color: var(--cp-faint) !important; }\n.sa-content .ant-tabs-tab-active,.sa-content .ant-tabs-tab:hover { color: var(--cp-violet) !important; }\n.sa-content .ant-tabs-ink-bar { background: #8b5cf6 !important; }\n\n.sa-content .ant-switch { background: rgba(255,255,255,0.15) !important; }\n.sa-content .ant-switch-checked { background: #6366f1 !important; }\n.sa-content .ant-statistic-title { color: var(--cp-faint) !important; }\n.sa-content .ant-statistic-content { color: var(--cp-title) !important; }\n.sa-content h1,.sa-content h2,.sa-content h3,.sa-content h4 { color: var(--cp-title) !important; }\n.sa-content .ant-typography { color: var(--cp-text) !important; }\n.sa-content .ant-alert { background: rgba(255,255,255,0.03) !important; border-color: rgba(255,255,255,0.06) !important; }\n.sa-content .ant-alert-message { color: var(--cp-text) !important; }\n.sa-content .ant-spin-text { color: var(--cp-faint) !important; }\n.sa-content .ant-tag { border-radius:6px !important; }\n"+Nt}),!n&&(0,D.jsx)(It,{width:240,className:"sa-sider",style:{padding:"20px 0",position:"fixed",height:"100vh",left:0,top:0,zIndex:100},children:this.renderSidebar()}),n&&a&&(0,D.jsx)("div",{className:"sa-mobile-backdrop",onClick:this.toggleMobileMenu}),n&&(0,D.jsx)("div",{className:"sa-mobile-sider"+(a?" open":""),children:this.renderSidebar()}),(0,D.jsxs)(i.Layout,{style:{marginLeft:n?0:240},children:[n&&(0,D.jsxs)("div",{className:"sa-mobile-topbar",children:[(0,D.jsx)(i.Button,{type:"primary",shape:"circle",icon:"menu",onClick:this.toggleMobileMenu,className:"sa-hamburger"}),(0,D.jsx)("div",{className:"sa-mobile-title",children:l}),(0,D.jsx)(i.Button,{shape:"circle",icon:"logout",onClick:this.handleLogout,className:"sa-mobile-logout"})]}),(0,D.jsx)(Tt,{className:"sa-content",children:this.renderContent()}),n&&this.renderBottomNav()]}),(0,D.jsx)(At.A,{items:[{id:"nav-dashboard",title:"Dashboard",subtitle:"Genel bakis",icon:"dashboard",group:"Navigasyon",action:()=>this.setState({activeKey:"dashboard"})},{id:"nav-tenants",title:"Sirketler",subtitle:"Tum tenant'lar",icon:"shop",group:"Navigasyon",action:()=>this.setState({activeKey:"tenants"})},{id:"nav-users",title:"Kullanicilar",subtitle:"Sistem kullanicilari",icon:"user",group:"Navigasyon",action:()=>this.setState({activeKey:"users"})}
1,{id:"nav-members",title:"Sirket Uyeleri",icon:"team",group:"Navigasyon",action:()=>this.setState({activeKey:"tenantMembers"})},{id:"nav-subs",title:"Abonelikler",icon:"database",group:"Navigasyon",action:()=>this.setState({activeKey:"tenantSubscriptions"})},{id:"nav-tx",title:"Odeme Kayitlari",icon:"file-text",group:"Navigasyon",action:()=>this.setState({activeKey:"transactionLogs"})},{id:"nav-aff",title:"Danismanlar",icon:"solution",group:"Navigasyon",action:()=>this.setState({activeKey:"affiliates"})},{id:"nav-wa",title:"WhatsApp Hesaplari",icon:"message",group:"Navigasyon",action:()=>this.setState({activeKey:"whatsappAccounts"})},{id:"nav-broadcast",title:"Duyuru Gonder",subtitle:"Tum kiracilara bildirim",icon:"sound",group:"Navigasyon",action:()=>this.setState({activeKey:"broadcast"})},{id:"nav-health",title:"Sistem Sagligi",icon:"heart",group:"Navigasyon",action:()=>this.setState({activeKey:"systemHealth"})},{id:"act-refresh",title:"Dashboard'i Yenile",subtitle:"Son verileri cek",icon:"reload",group:"Islemler",action:()=>{this.setState({activeKey:"dashboard"}),this.loadDashboard()}},{id:"act-main",title:"Ana Panele Don",icon:"arrow-left",group:"Islemler",action:()=>{window.location.href="/"}},{id:"act-logout",title:"Cikis Yap",icon:"logout",group:"Islemler",action:()=>this.props.userSignOut()}]})]})}}const Nt="\n.sa-mobile-topbar {\n  position: sticky;\n  top: 0;\n  z-index: 90;\n  display: flex;\n  align-items: center;\n  gap: 12px;\n  padding: 10px 12px;\n  background: rgba(6,6,15,0.92);\n  backdrop-filter: blur(8px);\n  border-bottom: 1px solid rgba(255,255,255,0.06);\n}\n.sa-mobile-title {\n  flex: 1;\n  font-size: 15px;\n  font-weight: 800;\n  color: var(--cp-title);\n  letter-spacing: 0.2px;\n}\n.sa-hamburger, .sa-mobile-logout {\n  width: 36px !important;\n  height: 36px !important;\n  min-width: 36px !important;\n}\n.sa-mobile-backdrop {\n  position: fixed;\n  inset: 0;\n  background:var(--cp-field);\n  z-index: 199;\n  backdrop-filter: blur(2px);\n}\n.sa-mobile-sider {\n  position: fixed;\n  top: 0;\n  left: 0;\n  width: 260px;\n  height: 100vh;\n  background: linear-gradient(180deg, #070b14 0%, var(--cp-bg2) 100%);\n  border-right: 1px solid rgba(255,255,255,0.04);\n  transform: translateX(-100%);\n  transition: transform 0.28s ease;\n  z-index: 200;\n  overflow-y: auto;\n}\n.sa-mobile-sider.open { transform: translateX(0); }\n\n@media(max-width: 767px) {\n  .sa-content { padding: 14px !important; padding-bottom: 88px !important; }\n  .sa-content h2 { font-size: 18px !important; }\n  .ant-drawer-content-wrapper { width: 100% !important; max-width: 100vw !important; }\n  .ant-modal { max-width: 95vw !important; }\n  /* Dokunma dostu: mobilde butonlar ve girisler daha yuksek */\n  .sa-content .ant-btn { min-height: 40px; border-radius: 10px !important; }\n  .sa-content .ant-input, .sa-content .ant-select-selection { border-radius: 10px !important; }\n  .sa-sticky-bar { top: 0 !important; margin: -14px -14px 14px -14px !important; padding: 16px 14px 12px !important; }\n}\n\n/* \u2500\u2500 MOBIL ALT SEKME CUBUGU \u2014 en kolay gezinme deseni \u2500\u2500 */\n.sa-bottomnav {\n  position: fixed;\n  left: 0; right: 0; bottom: 0;\n  z-index: 150;\n  display: flex;\n  background: rgba(10,12,20,0.96);\n  backdrop-filter: blur(14px);\n  border-top: 1px solid rgba(255,255,255,0.07);\n  padding-bottom: env(safe-area-inset-bottom, 0px);\n}\n.sa-bn-item {\n  flex: 1;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  gap: 3px;\n  padding: 9px 2px 8px;\n  cursor: pointer;\n  color: var(--cp-faint);\n  font-size: 10.5px;\n  font-weight: 600;\n  transition: color 0.15s;\n  -webkit-tap-highlight-color: transparent;\n}\n.sa-bn-item .anticon { font-size: 20px; }\n.sa-bn-item.active { color: #a78bfa; }\n.sa-bn-item.active .anticon { color: #a78bfa; }\n.sa-bn-item:active { background: rgba(139,92,246,0.08); }\n",Kt=(0,l.Ng)(e=>{let{auth:t}=e;return{authUser:t.authUser}},{userSignOut:o.ff})(Wt)}}]);
2//# sourceMappingURL=6388.9a393deb.chunk.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.