PageSourceSearch

https://soulmessages-lab.lovable.app/assets/admin.users._userId-DAKaLtgS.js

js soulmessages-lab.lovable.app collected 2026-10-03 03:46:08 UTC 17,209 bytes, 7 lines download raw bytes

1import{r as h,j as e,m as b,h as R,i as I,a6 as Ce,L as _e,l as we}from"./index-Co_COyci.js";import{u as q}from"./useQuery-DqEksgYJ.js";import{u as C}from"./useServerFn-BKNxTzPx.js";import{C as S}from"./card-cZcrpr2o.js";import{B as A}from"./badge-gTQnF4Q_.js";import{B as g}from"./button-BPDTLcKN.js";import{u as K,P as k,c as Y,a as J,d as ye}from"./index-ClhDynps.js";import{c as Ae,u as Re}from"./index-D4YAOlz_.js";import{u as W}from"./index-BVi1qgC0.js";import{P as Ie}from"./index-zIssVxW5.js";import{u as X}from"./index-Dk27SgpW.js";import{c as F}from"./utils-BQHNewu7.js";import{C as Pe}from"./chevron-down-DHwl5xLU.js";import{I as ke}from"./input-sw4kdSYr.js";import{c as Se,d as De}from"./admin-dashboard.functions-DP4VpElx.js";import{r as P}from"./auth-middleware-Bw-vsZYX.js";import{A as Le}from"./arrow-left-B4z9jhh9.js";import{M as Te}from"./message-square-CNmKUjqu.js";import{D as Ee}from"./download-DOXtGI-v.js";import"./index-LHNt3CwB.js";import"./createLucideIcon-D9X7GujO.js";var L="Collapsible",[Oe,ee]=J(L),[$e,G]=Oe(L),te=h.forwardRef((t,o)=>{const{__scopeCollapsible:a,open:r,defaultOpen:i,disabled:s,onOpenChange:l,...d}=t,[c,p]=K({prop:r,defaultProp:i??!1,onChange:l,caller:L});return e.jsx($e,{scope:a,disabled:s,contentId:X(),open:c,onOpenToggle:h.useCallback(()=>p(x=>!x),[p]),children:e.jsx(k.div,{"data-state":V(c),"data-disabled":s?"":void 0,...d,ref:o})})});te.displayName=L;var se="CollapsibleTrigger",ae=h.forwardRef((t,o)=>{const{__scopeCollapsible:a,...r}=t,i=G(se,a);return e.jsx(k.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":V(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:o,onClick:Y(t.onClick,i.onOpenToggle)})});ae.displayName=se;var B="CollapsibleContent",ne=h.forwardRef((t,o)=>{const{forceMount:a,...r}=t,i=G(B,t.__scopeCollapsible);return e.jsx(Ie,{present:a||i.open,children:({present:s})=>e.jsx(ze,{...r,ref:o,present:s})})});ne.displayName=B;var ze=h.forwardRef((t,o)=>{const{__scopeCollapsible:a,present:r,children:i,...s}=t,l=G(B,a),[d,c]=h.useState(r),p=h.useRef(null),x=W(o,p),v=h.useRef(0),N=v.current,u=h.useRef(0),n=u.current,f=l.open||d,_=h.useRef(f),w=h.useRef(void 0);return h.useEffect(()=>{const m=requestAnimationFrame(()=>_.current=!1);return()=>cancelAnimationFrame(m)},[]),ye(()=>{const m=p.current;if(m){w.current=w.current||{transitionDuration:m.style.transitionDuration,animationName:m.style.animationName},m.style.transitionDuration="0s",m.style.animationName="none";const y=m.getBoundingClientRect();v.current=y.height,u.current=y.width,_.current||(m.style.transitionDuration=w.current.transitionDuration,m.style.animationName=w.current.animationName),c(r)}},[l.open,r]),e.jsx(k.div,{"data-state":V(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!f,...s,ref:x,style:{"--radix-collapsible-content-height":N?`${N}px`:void 0,"--radix-collapsible-content-width":n?`${n}px`:void 0,...t.style},children:f&&i})});function V(t){return t?"open":"closed"}var Me=te,Ue=ae,qe=ne,j="Accordion",Ke=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[H,Fe,Ge]=Ae(j),[T]=J(j,[Ge,ee]),Z=ee(),re=b.forwardRef((t,o)=>{const{type:a,...r}=t,i=r,s=r;return e.jsx(H.Provider,{scope:t.__scopeAccordion,children:a==="multiple"?e.jsx(Ze,{...s,ref:o}):e.jsx(He,{...i,ref:o})})});re.displayName=j;var[oe,Be]=T(j),[ie,Ve]=T(j,{collapsible:!1}),He=b.forwardRef((t,o)=>{const{value:a,defaultValue:r,onValueChange:i=()=>{},collapsible:s=!1,...l}=t,[d,c]=K({prop:a,defaultProp:r??"",onChange:i,caller:j});return e.jsx(oe,{scope:t.__scopeAccordion,value:b.useMemo(()=>d?[d]:[],[d]),onItemOpen:c,onItemClose:b.useCallback(()=>s&&c(""),[s,c]),children:e.jsx(ie,{scope:t.__scopeAccordion,collapsible:s,children:e.jsx(ce,{...l,ref:o})})})}),Ze=b.forwardRef((t,o)=>{const{value:a,defaultValue:r,onValueChange:i=()=>{},...s}=t,[l,d]=K({prop:a,defaultProp:r??[],onChange:i,caller:j}),c=b.useCallback(x=>d((v=[])=>[...v,x]),[d]),p=b.useCallback(x=>d((v=[])=>v.filter(N=>N!==x)),[d]);return e.jsx(oe,{scope:t.__scopeAccordion,value:l,onItemOpen:c,onItemClose:p,children:e.jsx(ie,{scope:t.__scopeAccordion,collapsible:!0,children:e.jsx(ce,{...s,ref:o})})})}),[Qe,E]=T(j),ce=b.forwardRef((t,o)=>{const{__scopeAccordion:a,disabled:r,dir:i,orientation:s="vertical",...l}=t,d=b.useRef(null),c=W(d,o),p=Fe(a),v=Re(i)==="ltr",N=Y(t.onKeyDown,u=>{if(!Ke.includes(u.key))return;const n=u.target,f=p().filter(M=>!M.ref.current?.disabled),_=f.findIndex(M=>M.ref.current===n),w=f.length;if(_===-1)return;u.preventDefault();let m=_;const y=0,O=w-1,$=()=>{m=_+1,m>O&&(m=y)},z=()=>{m=_-1,m<y&&(m=O)};switch(u.key){case"Home":m=y;break;case"End":m=O;break;case"ArrowRight":s==="horizontal"&&(v?$():z());break;case"ArrowDown":s==="vertical"&&$();break;case"ArrowLeft":s==="horizontal"&&(v?z():$());break;case"ArrowUp":s==="vertical"&&z();break}const Ne=m%w;f[Ne].ref.current?.focus()});return e.jsx(Qe,{scope:a,disabled:r,direction:i,orientation:s,children:e.jsx(H.Slot,{scope:a,children:e.jsx(k.div,{...l,"data-orientation":s,ref:c,onKeyDown:r?void 0:N})})})}),D="AccordionItem",[Ye,Q]=T(D),le=b.forwardRef((t,o)=>{const{__scopeAccordion:a,value:r,...i}=t,s=E(D,a),l=Be(D,a),d=Z(a),c=X(),p=r&&l.value.includes(r)||!1,x=s.disabled||t.disabled;return e.jsx(Ye,{scope:a,open:p,disabled:x,triggerId:c,children:e.jsx(Me,{"data-orientation":s.orientation,"data-state":fe(p),...d,...i,ref:o,disabled:x,open:p,onOpenChange:v=>{v?l.onItemOpen(r):l.onItemClose(r)}})})});le.displayName=D;var de="AccordionHeader",me=b.forwardRef((t,o)=>{const{__scopeAccordion:a,...r}=t,i=E(j,a),s=Q(de,a);return e.jsx(k.h3,{"data-orientation":i.orientation,"data-state":fe(s.open),"data-disabled":s.disabled?"":void 0,...r,ref:o})});me.displayName=de;var U="AccordionTrigger",pe=b.forwardRef((t,o)=>{const{__scopeAccordion:a,...r}=t,i=E(j,a),s=Q(U,a),l=Ve(U,a),d=Z(a);return e.jsx(H.ItemSlot,{scope:a,children:e.jsx(Ue,{"aria-disabled":s.open&&!l.collapsible||void 0,"data-orientation":i.orientation,id:s.triggerId,...d,...r,ref:o})})});pe.displayName=U;var ue="AccordionContent",xe=b.forwardRef((t,o)=>{const{__scopeAccordion:a,...r}=t,i=E(j,a),s=Q(ue,a),l=Z(a);return e.jsx(qe,{role:"region","aria-labelledby":s.triggerId,"data-orientation":i.orientation,...l,...r,ref:o,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...t.style}})});xe.displayName=ue;function fe(t){return t?"open":"closed"}var Je=re,We=le,Xe=me,he=pe,ve=xe;const et=Je,ge=h.forwardRef(({className:t,...o},a)=>e.jsx(We,{ref:a,className:F("border-b",t),...o}));ge.displayName="AccordionItem";const be=h.forwardRef(({className:t,children:o,...a},r)=>e.jsx(Xe,{className:"flex",children:e.jsxs(he,{ref:r,className:F("flex flex-1 items-center justify-between py-4 text-sm font-medium cursor-pointer transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180",t),...a,children:[o,e.jsx(Pe,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"})]})}));be.displayName=he.displayName;const je=h.forwardRef(({className:t,children:o,...a},r)=>e.jsx(ve,{ref:r,className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...a,children:e.jsx("div",{className:F("pb-4 pt-0",t),children:o})}));
1je.displayName=ve.displayName;const tt=R({method:"GET"}).middleware([P]).handler(I("2d2eacf6c2595a50ec2058e80e7cdf1a33df72788d1f7790692ca46806b65835")),st=R({method:"POST"}).middleware([P]).handler(I("9f852dc708eee73d33fa96ebc6db3e1747efa9eaf3a259577972089e114bd613")),at=R({method:"POST"}).middleware([P]).handler(I("4406fbf6a940542a34fed2d14e010d2c209fe044cd4447550773cc5783baf68b")),nt=R({method:"POST"}).middleware([P]).handler(I("1fa57863de0eab3b8cb0309efd9a9619fbcec7b20dec5f5225faaa6c0ff8cc7e")),rt=R({method:"POST"}).middleware([P]).handler(I("045bab7edaf2a56904338b1ef8ad8975517d234f16a705cded41c29795fe1238")),ot=R({method:"POST"}).middleware([P]).handler(I("5b9b1ad9963a372881f65c11606a607e4a826113f5d57b160cfded05b4284a63"));function kt(){const{userId:t}=Ce.useParams(),o=C(De),{data:a,isLoading:r}=q({queryKey:["admin-user",t],queryFn:()=>o({data:{userId:t}})});if(r)return e.jsx("div",{className:"p-6 text-muted-foreground",children:"Lädt…"});if(!a?.profile)return e.jsx("div",{className:"p-6 text-muted-foreground",children:"User nicht gefunden."});const i=a.profile;return e.jsxs("div",{className:"p-6 space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs(_e,{to:"/admin/users",children:[e.jsx(Le,{className:"w-4 h-4 mr-1"}),"Zurück"]})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:i.display_name??"—"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:i.user_id})]}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[a.roles.map(s=>e.jsx(A,{variant:"outline",children:s},s)),i.is_beta_tester&&e.jsx(A,{children:"Beta-Tester"})]})]}),e.jsxs(S,{className:"p-4",children:[e.jsxs("h2",{className:"font-semibold mb-3",children:["Subscriptions (",a.subscriptions.length,")"]}),a.subscriptions.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Keine Subscriptions."}):e.jsx("div",{className:"space-y-2",children:a.subscriptions.map(s=>e.jsxs("div",{className:"flex items-center justify-between border-b last:border-0 pb-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium",children:[s.tier," · ",s.interval]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.environment," · ",new Date(s.created_at).toLocaleDateString(),s.cancelled_at&&` · cancelled ${new Date(s.cancelled_at).toLocaleDateString()}`]})]}),e.jsx(A,{variant:s.status==="active"?"default":"outline",children:s.status})]},s.id))})]}),e.jsx(ct,{userId:t}),e.jsxs(S,{className:"p-4",children:[e.jsxs("h2",{className:"font-semibold mb-3 flex items-center gap-2",children:[e.jsx(Te,{className:"w-4 h-4"}),"Conversations (",a.conversations.length,")"]}),a.conversations.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Noch keine Conversations."}):e.jsx(et,{type:"multiple",className:"w-full",children:a.conversations.map(s=>e.jsxs(ge,{value:s.id,children:[e.jsx(be,{className:"text-sm",children:e.jsxs("div",{className:"flex items-center gap-2 text-left",children:[e.jsx("span",{children:s.gpt_icon}),e.jsx("span",{className:"font-medium",children:s.gpt_name}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["· ",s.title??"Untitled"]}),e.jsx("span",{className:"text-muted-foreground text-xs ml-auto",children:new Date(s.updated_at).toLocaleDateString()})]})}),e.jsx(je,{children:e.jsx(it,{conversationId:s.id})})]},s.id))})]})]})}function it({conversationId:t}){const o=C(Se),{data:a,isLoading:r}=q({queryKey:["admin-conv-msgs",t],queryFn:()=>o({data:{conversationId:t}})});function i(){if(!a)return;const s=a.map(p=>`**${p.role==="user"?"User":"GPT"}** (${new Date(p.created_at).toLocaleString()}):
2
3${p.content}
4`).join(`
5---
6
7`),l=new Blob([s],{type:"text/markdown"}),d=URL.createObjectURL(l),c=document.createElement("a");c.href=d,c.download=`conversation-${t.slice(0,8)}.md`,c.click(),URL.revokeObjectURL(d)}return r?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Lädt Nachrichten…"}):!a||a.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keine Nachrichten."}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(g,{variant:"outline",size:"sm",onClick:i,children:[e.jsx(Ee,{className:"w-3 h-3 mr-1"}),"Export .md"]})}),e.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto bg-muted/30 rounded p-3",children:a.map(s=>e.jsxs("div",{className:`text-sm ${s.role==="user"?"":"pl-4 border-l-2 border-primary/40"}`,children:[e.jsxs("p",{className:"text-[10px] uppercase text-muted-foreground mb-0.5",children:[s.role," · ",new Date(s.created_at).toLocaleStr
7ing()]}),e.jsx("p",{className:"whitespace-pre-wrap",children:s.content})]},s.id))})]})}function ct({userId:t}){const o=we(),a=C(tt),r=C(st),i=C(at),s=C(nt),l=C(rt),d=C(ot),[c,p]=h.useState(""),{data:x,isLoading:v}=q({queryKey:["admin-access",t],queryFn:()=>a({data:{userId:t}})});function N(){o.invalidateQueries({queryKey:["admin-access",t]}),o.invalidateQueries({queryKey:["admin-users"]})}const u=n=>n.then(N).catch(f=>alert(f.message));return v?e.jsx(S,{className:"p-4 text-sm text-muted-foreground",children:"Zugriffsdaten laden…"}):x?e.jsxs(S,{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsx("h2",{className:"font-semibold",children:"Zugang & Credits"}),e.jsx(ke,{placeholder:"Grund (wird protokolliert)",value:c,onChange:n=>p(n.target.value),className:"max-w-xs h-8 text-xs"})]}),e.jsx("div",{className:"space-y-3",children:x.perGpt.map(n=>e.jsxs("div",{className:"border rounded-lg p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{children:n.gpt_icon}),e.jsx("span",{className:"font-medium text-sm",children:n.gpt_name}),e.jsx(A,{variant:"outline",className:"text-[10px]",children:n.source}),n.has_unlimited&&e.jsx(A,{className:"text-[10px]",children:"Unbegrenzt"}),e.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[n.messages_used," genutzt · ",e.jsxs("strong",{className:"text-foreground",children:[n.remaining," übrig"]}),n.bonus_expires_at&&` · bis ${new Date(n.bonus_expires_at).toLocaleDateString()}`,n.bonus_expired&&" (abgelaufen)"]})]}),n.subscription&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Zahlung: ",n.subscription.plan_name," · ",n.subscription.interval," · ",n.payment_status,n.subscription.current_period_end&&` · bis ${new Date(n.subscription.current_period_end).toLocaleDateString()}`]}),n.coupons.length>0&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Coupons: ",n.coupons.map(f=>`${f.code} (${new Date(f.redeemed_at).toLocaleDateString()})`).join(", ")]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[[5,10,30].map(f=>e.jsxs(g,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>u(r({data:{userId:t,gptId:n.gpt_id,delta:f,reason:c}})),children:["+",f," Chats"]},f)),e.jsx(g,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>u(r({data:{userId:t,gptId:n.gpt_id,delta:-5,reason:c}})),children:"−5"}),e.jsx(g,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>u(i({data:{userId:t,gptId:n.gpt_id,reason:c}})),children:"Nutzung zurücksetzen"}),e.jsx(g,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>u(s({data:{userId:t,gptId:n.gpt_id,days:30,reason:c}})),children:"+30 Tage"}),e.jsx(g,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>u(s({data:{userId:t,gptId:n.gpt_id,days:null,reason:c}})),children:"Kein Ablauf"}),n.manual_grant?e.jsx(g,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>u(d({data:{grantId:n.manual_grant.id}})),children:"Zugang entziehen"}):e.jsxs(e.Fragment,{children:[e.jsx(g,{size:"sm",className:"h-7 text-xs",onClick:()=>u(l({data:{userId:t,gptId:n.gpt_id,days:30,reason:c}})),children:"Zugang 30 Tage"}),e.jsx(g,{size:"sm",className:"h-7 text-xs",onClick:()=>u(l({data:{userId:t,gptId:n.gpt_id,days:null,reason:c}})),children:"Zugang unbefristet"})]})]})]},n.gpt_id))}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(g,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>u(l({data:{userId:t,gptId:null,days:30,reason:c}})),children:"Alle GPTs · 30 Tage"}),e.jsx(g,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>u(l({data:{userId:t,gptId:null,days:null,reason:c}})),children:"Alle GPTs · unbefristet"})]}),x.grants.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-1",children:"Manuelle Freischaltungen"}),e.jsx("div",{className:"space-y-1",children:x.grants.map(n=>e.jsxs("div",{className:"flex items-center justify-between text-xs border-b last:border-0 py-1",children:[e.jsxs("span",{children:[n.gpt_name," · ",n.expires_at?`bis ${new Date(n.expires_at).toLocaleDateString()}`:"unbefristet",n.reason?` · ${n.reason}`:""]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{variant:n.active?"default":"outline",className:"text-[10px]",children:n.active?"aktiv":n.revoked_at?"entzogen":"abgelaufen"}),n.active&&e.jsx(g,{size:"sm",variant:"ghost",className:"h-6 text-[10px]",onClick:()=>u(d({data:{grantId:n.id}})),children:"entziehen"})]})]},n.id))})]}),x.adjustments.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-1",children:"Admin-Log"}),e.jsx("div",{className:"space-y-1 max-h-56 overflow-y-auto",children:x.adjustments.map(n=>e.jsxs("div",{className:"text-xs text-muted-foreground border-b last:border-0 py-1",children:[new Date(n.created_at).toLocaleStr
7ing()," · ",n.gpt_name," · ",n.action,n.delta?` (${n.delta>0?"+":""}${n.delta})`:"",n.reason?` · ${n.reason}`:""]},n.id))})]})]}):null}export{kt as component};

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.