PageSourceSearch

https://southernfm.com.au/assets/UserManagementTab-BeEWq6oK.js

js southernfm.com.au collected 2026-10-02 07:51:01 UTC 29,961 bytes, 7 lines download raw bytes

1import{q as vs,a as Ss,r as n,j as e,h as A,f as ks,B as c,D as z,c as K,d as W,e as H,aO as Y,aP as q,aX as Cs,ab as i,s as N,J as _s,aY as Ps}from"./index-BvsqCpEz.js";import{u as As,N as be,H as se}from"./use-auth-4OwtEfAA.js";import{I as V}from"./input-BedoGODD.js";import{L as O}from"./label-Csx6IcxK.js";import{C as J}from"./checkbox-DVEqSMus.js";import{S as Ge}from"./switch-D7vhGPpr.js";import{B as Ds}from"./badge-BI94o_1V.js";import{M as as}from"./multi-select-BC0307uh.js";import{o as Es,T as Ze,A as Is,a as Os,b as Us,c as Ls,d as Ts,e as Rs,f as Fs,g as Ms,P as Bs}from"./MemberDashboard-Cs5Sf23a.js";import{p as $s,P as zs,a as Ks,b as Ws}from"./posts-permissions-DHmQ6dwK.js";import{W as Hs}from"./WelcomeEmailDialog-B1V3Khg4.js";import{U as Ys}from"./user-plus-Dt_gPiLj.js";import{R as qs}from"./refresh-cw-Dooswkp8.js";import{L as es}from"./lock-CH019ZGb.js";import{K as Vs}from"./key-round-Box5SVhW.js";import"./check-B97Uezjq.js";import"./popover-BRjrXi5Z.js";import"./index-5yHiP4fM.js";import"./wind-DW6YfAyS.js";import"./arrow-left-DasGo8Zs.js";import"./calendar-BX6XEece.js";import"./user-DLmK3dAG.js";import"./format-Dogvratb.js";import"./download-0HDG1NIG.js";import"./circle-check-12h59Bk8.js";import"./circle-alert-DQWk7aEq.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ns=vs("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),T=(l,D)=>{if(!l)return D??"";if(typeof l=="string")return l;try{return JSON.stringify(l)}catch{return D??String(l)}},Js={hub:[{key:"manage_csa",label:"Manage CSAs",desc:"Create, edit, and delete Community Service Announcements"}],news:[{key:"manage_critical",label:"Approve Noticeboard Posts",desc:"Review, approve, or decline posts submitted to the station noticeboard"}],kb:[{key:"manage_kb",label:"Knowledge Base Editor",desc:"Create, edit, archive, restore KB pages, and view version history"},{key:"delete_kb",label:"Delete KB Pages",desc:"Permanently delete KB pages (including archived one
6s)"}],resources:[{key:"manage_resources",label:"Manage Resources",desc:"Add, edit, and delete downloadable member resources"}],newsletter:[{key:"manage_newsletter",label:"Comms Editor",desc:"Create, edit, and send the member newsletter, and manage its templates"}],bookings:[{key:"manage_bookings",label:"Manage All Bookings",desc:"Edit or cancel any member's studio booking, and block out studio time"}],myshow:[{key:"facebook_publish",label:"Publish to Facebook",desc:"Allow this user to publish their posts to the station's Facebook Page. On by default; turn off to revoke.",defaultOn:!0}],shows:[{key:"manage_show_names",label:"Rename Shows",desc:"Edit a show's name"},{key:"delete_archived_shows",label:"Delete Archived Shows",desc:"Permanently delete shows from the archive"}],posts:[{key:"post_station",label:"Station Posts & Podcasts",desc:"Create station-level posts and community news (not linked to a show)"},{key:"post_any_show",label:"Post on Behalf of Any Show",desc:"Create show posts/podcasts for any show, not just their own"},{key:"facebook_publish",label:"Publish to Facebook",desc:"Allow this user to publish posts to the station's Facebook Page. On by default; turn off to revoke.",defaultOn:!0},{key:"manage_post_settings",label:"Manage Posting Controls",desc:"Access the station-wide master switches that pause publishing, re-publishing, and Facebook posting"}]},ss=[{value:"hidden",label:"Hidden"},{value:"view",label:"View"},{value:"edit",label:"Edit"}],Qs=({perms:l,setTabLevel:D,setScopeValue:x,allShowOptions:U})=>{const R=[{value:"station",label:"Station-level (no show)"},...U],k=["all","bulk","wp_import"].some(m=>l.tabs[m]==="edit"),v=({label:m,keyName:b,options:C})=>{const u=l.edit_scope[b],L=u==="*";return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx(O,{className:"text-[11px] font-bold uppercase tracking-wider text-muted-foreground",children:m}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground cursor-pointer",children:[e.jsx(J,{checked:L,onCheckedChange:j=>x(b,j?"*":[]),className:"h-3.5 w-3.5"}),"All"]})]}),!L&&e.jsx(as,{options:C,value:u,onChange:j=>x(b,j),placeholder:`Select ${m.toLowerCase()}…`,searchable:!0,emptyMeansAll:!1,inlineContent:!0})]})};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:"Sub-tabs"}),e.jsx("div",{className:"space-y-1.5",children:zs.map(m=>{const b=l.tabs[m.id]??"hidden",C=m.allowsEdit?ss:ss.filter(u=>u.value!=="edit");return e.jsxs("div",{className:"flex items-center justify-between gap-2 p-1.5 rounded-md bg-muted/40",children:[e.jsx("span",{className:"text-xs font-medium text-foreground",children:m.label}),e.jsx("div",{className:"inline-flex rounded-md border border-border bg-background overflow-hidden",children:C.map(u=>e.jsx("button",{type:"button",onClick:()=>D(m.id,u.value),className:`px-2.5 py-1 text-[11px] font-medium transition-colors ${b===u.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:u.label},u.value))})]},m.id)})}),k&&e.jsxs("div",{className:"space-y-2.5 p-2.5 rounded-lg border border-border bg-muted/30",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:"Edit scope"}),e.jsx(v,{label:"Post Types",keyName:"post_types",options:Ks}),e.jsx(v,{label:"Statuses",keyName:"statuses",options:Ws}),e.jsx(v,{label:"Shows",keyName:"show_ids",options:R})]})]})},ts=({isAdmin:l,setIsAdmin:D,permissions:x,setPermissions:U,showIds:R,setShowIds:k,allShowOptions:v,linkedShowName:m,disabledShowId:b})=>{const[C,u]=n.useState(se[0].id),L=(r,p)=>{U({...x,[r]:p??!x[r]})},j=$s(x==null?void 0:x.posts),Q=r=>{U({...x,posts:r})}
6,he=(r,p)=>{Q({...j,tabs:{...j.tabs,[r]:p}})},F=(r,p)=>{Q({...j,edit_scope:{...j.edit_scope,[r]:p}})},M=se.find(r=>r.id===C)??se[0],te=r=>{const p=r.permission,_=!!r.default,w=_||!!x[p],S=Js[r.id]??[],X=r.id==="myshow",G=r.id==="posts";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 pb-3 border-b border-border",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:r.label}),_&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground",children:[e.jsx(es,{className:"h-2.5 w-2.5"})," Always on"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:r.description})]}),_?e.jsx(Ge,{checked:!0,disabled:!0,className:"shrink-0 mt-1"}):e.jsx(Ge,{checked:w,onCheckedChange:f=>L(p,!!f),className:"shrink-0 mt-1"})]}),!w&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Enable this tab to configure its permissions."}),w&&S.length===0&&!X&&!G&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No additional permissions for this tab."}),w&&G&&e.jsx(Qs,{perms:j,setTabLevel:he,setScopeValue:F,allShowOptions:v}),w&&S.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:"Sub-permissions"}),S.map(f=>{const Z=x[f.key],ae=f.defaultOn?Z!==!1:!!Z;return e.jsxs("label",{className:"flex items-start gap-2.5 p-2 rounded-md hover:bg-muted/50 cursor-pointer border border-transparent hover:border-border",children:[e.jsx(J,{checked:ae,onCheckedChange:E=>L(f.key,(f.defaultOn,!!E)),className:"mt-0.5"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:f.label}),e.jsx("p",{className:"text-xs text-muted-foreground leading-snug",children:f.desc})]})]},f.key)})]}),w&&X&&e.jsxs("div",{children:[e.jsx(O,{className:"text-[11px] font-bold uppercase tracking-wider text-muted-foreground mb-1 block",children:"Accessible Shows"}),m&&e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs px-2 py-0.5 rounded-full bg-muted text-muted-foreground",children:[e.jsx(es,{className:"h-3 w-3"})," ",m]}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"(linked show account — always accessible)"})]}),e.jsx(as,{options:v,value:R,onChange:k,disabledValues:b?[b]:[],placeholder:m?"Add extra shows…":"Select shows…",searchable:!0,emptyMeansAll:!1,inlineContent:!0}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:m?'Extra shows this user can manage in "My Show", on top of their own show above.':'Shows the user can manage in "My Show". Their own presenter show is included automatically.'})]})]})};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("label",{className:"flex items-start gap-3 p-3 rounded-2xl bg-amber-50 border border-amber-200 cursor-pointer",children:[e.jsx(J,{checked:l,onCheckedChange:r=>D(!!r),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-sm font-semibold text-foreground flex items-center gap-1.5",children:[e.jsx(ns,{className:"h-3.5 w-3.5 text-amber-600"}),"Admin"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Full access to every tab - overrides all permissions below"})]})]}),l?e.jsx("p",{className:"text-xs text-amber-600 italic",children:"Admin users have all permissions automatically."}):e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 rounded-2xl border border-border bg-card overflow-hidden",children:[e.jsx("nav",{className:"md:w-56 shrink-0 md:border-r border-border bg-muted/30 p-2 md:max-h-[60vh] md:overflow-y-auto",children:e.jsx("div",{className:"space-y-0.5",children:se.map(r=>{const p=r.permission,w=!!r.default||!!x[p],S=r.id===C;return e.jsxs("button",{type:"button",onClick:()=>u(r.id),className:`w-full text-left px-2.5 py-1.5 rounded-md text-sm transition-colors flex items-center justify-between gap-2 ${S?"bg-primary text-primary-foreground":"text-foreground hover:bg-muted"}`,children:[e.jsx("span",{className:"truncate",children:r.label}),e.jsx("span",{className:`shrink-0 h-1.5 w-1.5 rounded-full ${w?S?"bg-primary-foreground":"bg-emerald-500":S?"bg-primary-foreground
6/40":"bg-muted-foreground/40"}`})]},r.id)})})}),e.jsx("div",{className:"flex-1 min-w-0 p-4 md:max-h-[60vh] md:overflow-y-auto",children:te(M)})]})]})},vt=()=>{const{user:l,isAdmin:D}=As(),x=Ss(),[U,R]=n.useState(null),[k,v]=n.useState(null),m=async s=>{R(s.id);try{await Cs(s.id),i.success(`Now viewing as ${s.display_name}`),window.location.hash="tab=hub",x("/member#tab=hub")}catch(t){i.error("Could not switch user",{description:t==null?void 0:t.message})}finally{R(null)}},[b,C]=n.useState([]),[u,L]=n.useState([]),[j,Q]=n.useState(!0),[he,F]=n.useState(!1),[M,te]=n.useState(""),[r,p]=n.useState(""),[_,w]=n.useState(""),[S,X]=n.useState(!1),[G,f]=n.useState(be),[Z,ae]=n.useState([]),[E,je]=n.useState(!1),[we,ye]=n.useState(!1),[B,ne]=n.useState(null),[re,Ne]=n.useState(""),[ve,Se]=n.useState(!1),[h,oe]=n.useState(null),[ke,Ce]=n.useState(!1),[_e,Pe]=n.useState({}),[xe,Ae]=n.useState([]),[De,Ee]=n.useState(!1),[Ie,Oe]=n.useState(!1),[$,ie]=n.useState(null),[le,Ue]=n.useState(""),[Le,Te]=n.useState(!1),[rs,ue]=n.useState(null),[P,de]=n.useState(null),[Re,Fe]=n.useState(!1),[pe,os]=n.useState(""),[is,ce]=n.useState(!1),[Me,Be]=n.useState(!1),[me,$e]=n.useState(!1),[ze,ls]=n.useState(0),[I,ds]=n.useState([]),[Ke,We]=n.useState(!1),cs=async()=>{Be(!0),We(!1);try{const{data:s,error:t}=await N.functions.invoke("manage-users",{body:{action:"sync_show_account_emails",dry_run:!0}});t||s!=null&&s.error?i.error("Failed to check logins",{description:T(s==null?void 0:s.error,t==null?void 0:t.message)}):(ls((s==null?void 0:s.checked)??0),ds((s==null?void 0:s.changes)??[]),ce(!0))}catch{i.error("Failed to check logins")}Be(!1)},ms=async()=>{$e(!0);try{const{data:s,error:t}=await N.functions.invoke("manage-users",{body:{action:"sync_show_account_emails"}});if(t||s!=null&&s.error)i.error("Failed to sync logins",{description:T(s==null?void 0:s.error,t==null?void 0:t.message)});else{const o=((s==null?void 0:s.changes)??[]).filter(a=>a.updated);i.success(`${o.length} login${o.length===1?"":"s"} updated`,{description:o.map(a=>`${a.show}: ${a.from} → ${a.to}`).join(`
7`)||void 0,duration:15e3});const{data:d}=await N.functions.invoke("manage-users",{body:{action:"list"}}),g=(d==null?void 0:d.users)??[];if(C(g),Ke&&o.length){let a=0;const y=[];for(const fe of o){const Qe=g.find(Ns=>{var Xe;return((Xe=Ns.email)==null?void 0:Xe.toLowerCase())===fe.to.toLowerCase()});if(!Qe){y.push(fe.to);continue}const{data:ge,error:ys}=await N.functions.invoke("manage-users",{body:{action:"send_welcome_email",user_id:Qe.id}});ys||ge!=null&&ge.error?y.push(fe.to):a++}a&&i.success(`Welcome email sent to ${a} account${a===1?"":"s"}`),y.length&&i.error("Some welcome emails failed",{description:y.join(", ")})}ce(!1)}}catch{i.error("Failed to sync logins")}$e(!1)},ee=async()=>{Q(!0);const[s,t]=await Promise.all([N.functions.invoke("manage-users",{body:{action:"list"}}),N.from("shows").select("id, name, vacant").eq("archived",!1).order("name")]);s.error?i.error("Failed to load users"):C(s.data.users??[]),L((t.data??[]).filter(o=>!o.vacant).map(o=>({value:o.id,label:o.name}))),Q(!1)};n.useEffect(()=>{l&&ee()},[l]);const hs=b.filter(s=>!s.show_id),xs=b.filter(s=>!!s.show_id),He=s=>{if(!pe.trim())return s;const t=pe.trim().toLowerCase();return s.filter(o=>o.display_name.toLowerCase().includes(t)||o.email.toLowerCase().includes(t)||o.show_name&&o.show_name.toLowerCase().includes(t))},us=He(hs),ps=He(xs),fs=async()=>{if(!M||!r){i.error("Name and email required");return}if(E&&(!_||_.length<8)){i.error("Password must be at least 8 characters");return}ye(!0);const{data:s,error:t}=await N.functions.invoke("manage-users",{body:{action:"create",email:M,...E?{password:_}:{},display_name:r,is_admin:S,permissions:G,accessible_show_ids:Z,password_login_enabled:E}});ye(!1),t||s!=null&&s.error?i.error("Failed to create user",{description:T(s==null?void 0:s.error,t==null?void 0:t.message)}):(i.success("User created!"),ue({userId:s.user_id,email:M,displayName:r,justCreated:!0}),F(!1),te(""),p(""),w(""),X(!1),f(be),ae([]),je(!1),ee())},gs=async()=>{if(!h)return;Oe(!0);const s=h.show_id,t=s?xe.filter(g=>g!==s):xe,{data:o,error:d}=await N.functions.invoke("manage-users",{body:{action:"update_permissions",user_id:h.id,is_admin:ke,permissions:_e,accessible_show_ids:t,password_login_enabled:De}});Oe(!1),d||o!=null&&o.error?i.error("Failed to update",{description:T(o==null?void 0:o.error,d==null?void 0:d.message)}):(i.success("Permissions updated!"),oe(null),ee())},bs=async()=>
7{if(!$||!le.trim())return;Te(!0);const{data:s,error:t}=await N.functions.invoke("manage-users",{body:{action:"update_name",user_id:$.id,display_name:le.trim()}});Te(!1),t||s!=null&&s.error?i.error("Failed",{description:T(s==null?void 0:s.error,t==null?void 0:t.message)}):(i.success("Name updated!"),ie(null),ee())},js=async()=>{if(!B||!re)return;Se(!0);const{data:s,error:t}=await N.functions.invoke("manage-users",{body:{action:"reset_password",user_id:B.id,password:re}});Se(!1),t||s!=null&&s.error?i.error("Failed",{description:T(s==null?void 0:s.error,t==null?void 0:t.message)}):(i.success("Password reset!"),ne(null),Ne(""))},ws=async()=>{if(!P)return;Fe(!0);const{data:s,error:t}=await N.functions.invoke("manage-users",{body:{action:"delete",user_id:P.id}});Fe(!1),t||s!=null&&s.error?i.error("Failed",{description:T(s==null?void 0:s.error,t==null?void 0:t.message)}):(i.success("User deleted"),de(null),ee())},Ye=({u:s})=>{var o,d,g;if(s.is_admin)return e.jsx("span",{className:"text-xs bg-amber-100 text-amber-700 px-2 py-0.5 rounded-full font-medium",children:"Admin"});const t=[];return se.filter(a=>!a.default).forEach(a=>{var y;(y=s.permissions)!=null&&y[a.permission]&&t.push(a.label)}),(o=s.permissions)!=null&&o.manage_critical&&t.push("Approver"),(d=s.permissions)!=null&&d.post_station&&t.push("Station Posts"),(g=s.permissions)!=null&&g.post_any_show&&t.push("Any Show"),t.length===0?e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Default only"}):e.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(a=>e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full",children:a},a))})},qe=be,Ve=s=>{if(s.is_admin)return!1;const t=s.permissions??{},o=Object.entries(t).some(([a,y])=>y===!0&&!qe[a]),d=Object.entries(qe).some(([a,y])=>y===!0&&t[a]===!1),g=(s.accessible_show_ids??[]).length>0;return o||d||g},Je=({userList:s,title:t,showShowColumn:o,isShowAccounts:d})=>e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3",children:[e.jsxs("h3",{className:"font-display text-base font-bold text-foreground",children:[t," (",s.length,")"]}),d&&e.jsxs(c,{variant:"outline",size:"sm",onClick:cs,disabled:Me,children:[Me?e.jsx(A,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Sync logins"]})]}),d&&e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Show accounts are created via the Shows tab. You can manage their permissions and passwords here."}),(()=>{const g=a=>e.jsxs(e.Fragment,{children:[!d&&e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",title:"Edit name",onClick:()=>{ie(a),Ue(a.display_name)},children:e.jsx(Bs,{className:"h-4 w-4"})}),e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",title:"Edit permissions",onClick:()=>{oe(a),Ce(a.is_admin),Pe({...a.permissions}),Ae([...a.accessible_show_ids??[],...a.show_id?[a.show_id]:[]]),Ee(!!a.password_login_enabled)},children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",title:"Resend welcome email",onClick:()=>ue({userId:a.id,email:a.email,displayName:a.display_name}),children:e.jsx(_s,{className:"h-4 w-4"})}),e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",title:"Reset password",onClick:()=>ne(a),children:e.jsx(Vs,{className:"h-4 w-4"})}),D&&a.id!==(l==null?void 0:l.id)&&e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8",title:"Sign in as this user",onClick:()=>v(a),disabled:U===a.id,children:U===a.id?e.jsx(A,{className:"h-4 w-4 animate-spin"}):e.jsx(Ps,{className:"h-4 w-4"})}),!d&&a.id!==(l==null?void 0:l.id)&&e.jsx(c,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",title:"Delete user",onClick:()=>de(a),children:e.jsx(Ze,{className:"h-4 w-4"})})]});return e.jsxs("div",{className:"bg-card border border-border rounded-xl overflow-hidden",children:[e.jsx("div",{className:"md:hidden divide-y divide-border",children:s.length===0?e.jsx("div",{className:"px-4 py-8 text-center text-muted-foreground text-sm",children:"No users"}):s.map(a=>e.jsxs("div",{className:"p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"font-medium text-foreground truncate flex items-center gap-2",children:[a.display_name,d&&Ve(a)&&e.jsx("span",{className:"inline-flex items-center rounded-full border border-transparent bg-secondary px-1.5 py-0 text-[10px] font-semibold text-secondary-foreground shrink-0",children:"Custom"})]}),e.jsx("p",{className:"text-xs text-muted-foreground break-all",children:a.email}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Show: ",a.show_name??"-"]})]}),e.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:g(a)})]}),e.jsx(Ye,{u:a})]},a.id))}),e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 border-b border-border",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"Name"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"Email"}),o&&e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"Show"}),e.jsx("th",{className:"text-left px-4 py-3 font-semibold text-muted-foreground",children:"Permissions"}),e.jsx("th",{className:"text-right px-4 py-3 font-semibold text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:s.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:o?5:4,className:"px-4 py-8 text-center text-muted-foreground",children:"No users"})}):s.map(a=>e.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/30 transition-colors",children:[e.jsx("td",{className:"px-4 py-3 font-medium text-foreground",children:e.jsxs("div",{className:"flex items-center gap-2",children:[a.display_name,d&&Ve(a)&&e.jsx(Ds,{variant:"secondary",className:"text-[10px] px-1.5 py-0 shrink-0",children:"Custom"})]})}),e.jsx("td",{className:"px-4 py-3 text-muted-foreground text-xs",children:a.email}),o&&e.jsx("td",{className:"px-4 py-3 text-muted-foreground text-xs",children:a.show_name??"-"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(Ye,{u:a})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex items-center justify-end gap-1",children:g(a)})})]},a.id))})]})})]})})()]});return j?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(A,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 mb-6",children:[e.jsx("h2",{className:"font-display text-lg font-bold text-foreground",children:"User Management"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 sm:flex-initial",children:[e.jsx(ks,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none"}
7),e.jsx(V,{placeholder:"Search users or shows...",value:pe,onChange:s=>os(s.target.value),className:"pl-9 w-full sm:w-64"})]}),e.jsxs(c,{variant:"outline",onClick:()=>F(!0),children:[e.jsx(Ys,{className:"h-4 w-4 mr-2"}),"Create User"]})]})]}),Je({userList:us,title:"Permanent Users"}),Je({userList:ps,title:"Show Accounts",showShowColumn:!0,isShowAccounts:!0}),e.jsx(z,{open:he,onOpenChange:F,children:e.jsxs(K,{className:"max-w-7xl w-[95vw] h-[90vh] p-0 rounded-lg overflow-hidden flex flex-col gap-0",onPointerDownOutside:s=>{const t=s.target;t!=null&&t.closest("[data-radix-popper-content-wrapper]")&&s.preventDefault()},onInteractOutside:s=>{const t=s.target;t!=null&&t.closest("[data-radix-popper-content-wrapper]")&&s.preventDefault()},children:[e.jsxs(W,{className:"p-6 pb-4 border-b border-border shrink-0",children:[e.jsx(H,{children:"Create New User"}),e.jsx(Y,{children:"Add a new member account with permissions."})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(O,{children:"Display Name"}),e.jsx(V,{value:r,onChange:s=>p(s.target.value),placeholder:"John Smith"})]}),e.jsxs("div",{children:[e.jsx(O,{children:"Email"}),e.jsx(V,{type:"email",value:M,onChange:s=>te(s.target.value),placeholder:"[email protected]"})]}),e.jsxs("label",{className:"flex items-start gap-3 p-3 rounded-lg border border-border cursor-pointer",children:[e.jsx(J,{checked:E,onCheckedChange:s=>je(!!s),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Allow password login"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"If off, the user can only sign in via a one-time code emailed to them."})]})]}),E&&e.jsxs("div",{children:[e.jsx(O,{children:"Initial Password"}),e.jsx(V,{type:"text",value:_,onChange:s=>w(s.target.value),placeholder:"Minimum 8 characters"})]}),e.jsxs("div",{children:[e.jsx(O,{className:"mb-2 block",children:"Permissions"}),e.jsx(ts,{isAdmin:S,setIsAdmin:X,permissions:G,setPermissions:f,showIds:Z,setShowIds:ae,allShowOptions:u})]})]})}),e.jsxs(q,{className:"p-6 pt-4 border-t border-border shrink-0",children:[e.jsx(c,{variant:"outline",onClick:()=>F(!1),children:"Cancel"}),e.jsxs(c,{onClick:fs,disabled:we,children:[we?e.jsx(A,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Es,{className:"h-4 w-4 mr-2"}),"Create"]})]})]})}),e.jsx(z,{open:!!h,onOpenChange:()=>oe(null),children:e.jsxs(K,{className:"max-w-7xl w-[95vw] h-[90vh] p-0 rounded-lg overflow-hidden flex flex-col gap-0",onPointerDownOutside:s=>{const t=s.target;t!=null&&t.closest("[data-radix-popper-content-wrapper]")&&s.preventDefault()},onInteractOutside:s=>{const t=s.target;t!=null&&t.closest("[data-radix-popper-content-wrapper]")&&s.preventDefault()},children:[e.jsxs(W,{className:"p-6 pb-4 border-b border-border shrink-0",children:[e.jsx(H,{children:"Edit Permissions"}),e.jsxs(Y,{children:[h==null?void 0:h.display_name," (",h==null?void 0:h.email,")"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("label",{className:"flex items-start gap-3 p-3 rounded-lg border border-border cursor-pointer",children:[e.jsx(J,{checked:De,onCheckedChange:s=>Ee(!!s),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Allow password login"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"If off, the user can only sign in via a one-time code emailed to them."})]})]}),e.jsx(ts,{isAdmin:ke,setIsAdmin:Ce,permissions:_e,setPermissions:Pe,showIds:xe,setShowIds:Ae,allShowOptions:u,linkedShowName:(h==null?void 0:h.show_name)??null,disabledShowId:(h==null?void 0:h.show_id)??null})]})}),e.jsxs(q,{className:"p-6 pt-4 border-t border-border shrink-0",children:[e.jsx(c,{variant:"outline",onClick:()=>oe(null),children:"Cancel"}),e.jsxs(c,{onClick:gs,disabled:Ie,children:[Ie&&e.jsx(A,{className:"h-4 w-4 animate-spin mr-2"}),"Save"]})]})]})}),e.jsx(z,{open:!!$,onOpenChange:()=>ie(null),children:e.jsxs(K,{children:[e.jsxs(W,{children:[e.jsx(H,{children:"Edit Display Name"}),e.jsx(Y,{children:$==null?void 0:$.email})]}),e.jsxs("div",{className:"py-2",children:[e.jsx(O,{children:"Display Name"}),e.jsx(V,{value:le,onChange:s=>Ue(s.target.value)})]}),e.jsxs(q,{children:[e.jsx(c,{variant:"outline",onClick:()=>ie(null),children:"Cancel"}),e.jsxs(c,{onClick:bs,disabled:Le||!le.trim(),children:[Le&&e.jsx(A,{className:"h-4 w-4 animate-spin mr-2"}),"Save"]})]})]})}),e.jsx(z,{open:!!B,onOpenChange:()=>ne(null),children:e.jsxs(K,{children:[e.jsxs(W,{children:[e.jsx(H,{children:"Reset Password"}),e.jsx(Y,{children:B==null?void 0:B.email})]}),e.jsxs("div",{className:"py-2",children:[e.jsx(O,{children:"New Password"}),e.jsx(V,{type:"text",value:re,onChange:s=>Ne(s.target.value),placeholder:"Minimum 8 characters"})]}),e.jsxs(q,{children:[e.jsx(c,{variant:"outline",onClick:()=>ne(null),children:"Cancel"}),e.jsxs(c,{onClick:js,disabled:ve||re.length<8,children:[ve&&e.jsx(A,{className:"h-4 w-4 animate-spin mr-2"}),"Reset Password"]})]})]})}),e.jsx(z,{open:!!P,onOpenChange:()=>de(null),children:e.jsxs(K,{children:[e.jsxs(W,{children:[e.jsx(H,{children:"Delete User"}),e.jsxs(Y,{children:["Are you sure you want to permanently delete ",e.jsx("strong",{children:P==null?void 0:P.display_name})," (",P==null?void 0:P.email,")? This cannot be undone."]})]}),e.jsxs(q,{children:[e.jsx(c,{variant:"outline",onClick:()=>de(null),children:"Cancel"}),e.jsxs(c,{variant:"destructive",onClick:ws,disabled:Re,children:[Re?e.jsx(A,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ze,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}),e.jsx(Hs,{target:rs,onClose:()=>ue(null)}),e.jsx(z,{open:is,onOpenChange:s=>{!s&&!me&&ce(!1)},children:e.jsxs(K,{className:"max-w-lg",children:[e.jsxs(W,{children:[e.jsx(H,{children:"Sync show account logins"}),e.jsx(Y,{children:I.length===0?`All ${ze} show account logins already match their show.`:`${I.length} of ${ze} show account login${I.length===1?"":"s"} will change:`})]}),I.length>0&&e.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2 rounded-lg border border-border p-3 text-xs",children:I.map((s,t)=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:s.show}
7),e.jsxs("p",{className:"text-muted-foreground break-all",children:[s.from||"unknown"," ",e.jsx("span",{className:"mx-1",children:"→"})," ",e.jsx("span",{className:"text-foreground",children:s.to})]}),s.error&&e.jsx("p",{className:"text-destructive",children:s.error})]},t))}),I.length>0&&e.jsxs("label",{className:"flex items-start gap-2 text-sm cursor-pointer",children:[e.jsx(J,{checked:Ke,onCheckedChange:s=>We(!!s),className:"mt-0.5"}),e.jsxs("span",{children:["Resend the welcome email to these accounts",e.jsx("span",{className:"block text-xs text-muted-foreground",children:"Lets them know their new login address."})]})]}),e.jsxs(q,{children:[e.jsx(c,{variant:"outline",onClick:()=>ce(!1),disabled:me,children:I.length===0?"Close":"Cancel"}),I.length>0&&e.jsxs(c,{onClick:ms,disabled:me,children:[me&&e.jsx(A,{className:"h-4 w-4 mr-2 animate-spin"}),"Apply changes"]})]})]})}),e.jsx(Is,{open:!!k,onOpenChange:s=>!s&&v(null),children:e.jsxs(Os,{children:[e.jsxs(Us,{children:[e.jsx(Ls,{children:"Sign in as user"}),e.jsxs(Ts,{children:["Sign in as ",k==null?void 0:k.display_name,"? You'll see the site exactly as they do. You can return to your admin account from the banner at the top."]})]}),e.jsxs(Rs,{children:[e.jsx(Fs,{children:"Cancel"}),e.jsx(Ms,{onClick:()=>{const s=k;v(null),s&&m(s)},children:"Sign in"})]})]})})]})};export{vt as default};

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.