PageSourceSearch

https://www.retrofitpolicylab.uk/assets/Admin-C93omrPW.js

js retrofitpolicylab.uk collected 2026-10-07 18:55:03 UTC 16,902 bytes, 6 lines download raw bytes

1import{r as N,j as e,ax as L,ay as V,K,a0 as H,$ as G,a1 as Q,N as w,E as l,a6 as i,ak as c,az as Y,F as o,B as d,a2 as X,ai as J,x as Z,a4 as W,I as P,aA as C,ad as M,Z as ee,L as m,aB as se,Y as S,aC as ae,aD as te,aE as re,aF as A,al as B,aG as ne,aH as le,O as ie,aI as ce,aJ as oe,aK as de}from"./index-ncH4CRZS.js";import{P as me}from"./PageHeader-C09UPEO0.js";import"./SafeHtml-C47PcLaD.js";import"./purify.es-BFmuJLeH.js";function xe(s,a=[]){let t=[];function x(g,u){const n=N.createContext(u),h=t.length;t=[...t,u];function v(p){const{scope:f,children:k,...b}=p,D=(f==null?void 0:f[s][h])||n,F=N.useMemo(()=>b,Object.values(b));return e.jsx(D.Provider,{value:F,children:k})}function j(p,f){const k=(f==null?void 0:f[s][h])||n,b=N.useContext(k);if(b)return b;if(u!==void 0)return u;throw new Error(`\`${p}\` must be used within \`${g}\``)}return v.displayName=g+"Provider",[v,j]}const r=()=>{const g=t.map(u=>N.createContext(u));return function(n){const h=(n==null?void 0:n[s])||g;return N.useMemo(()=>({[`__scope${s}`]:{...n,[s]:h}}),[n,h])}};return r.scopeName=s,[x,he(r,...a)]}function he(...s){const a=s[0];if(s.length===1)return a;const t=()=>{const x=s.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(g){const u=x.reduce((n,{useScope:h,scopeName:v})=>{const p=h(g)[`__scope${v}`];return{...n,...p}},{});return N.useMemo(()=>({[`__scope${a.scopeName}`]:u}),[u])}};return t.scopeName=a.scopeName,t}var E="Progress",z=100,[ue,Ce]=xe(E),[ge,je]=ue(E),R=N.forwardRef((s,a)=>{const{__scopeProgress:t,value:x=null,max:r,getValueLabel:g=pe,...u}=s;(r||r===0)&&!_(r)&&console.error(fe(`${r}`,"Progress"));const n=_(r)?r:z;x!==null&&!I(x,n)&&console.error(Ne(`${x}`,"Progress"));const h=I(x,n)?x:null,v=y(h)?g(h,n):void 0;return e.jsx(ge,{scope:t,value:h,max:n,children:e.jsx(L.div,{"aria-valuemax":n,"aria-valuemin":0,"aria-valuenow":y(h)?h:void 0,"aria-valuetext":v,role:"progressbar","data-state":O(h,n),"data-value":h??void 0,"data-max":n,...u,ref:a})})});R.displayName=E;var $="ProgressIndicator",q=N.forwardRef((s,a)=>{const{__scopeProgress:t,...x}=s,r=je($,t);return e.jsx(L.div,{"data-state":O(r.value,r.max),"data-value":r.value??void 0,"data-max":r.max,...x,ref:a})});q.displayName=$;function pe(s,a){return`${Math.round(s/a*100)}%`}function O(s,a){return s==null?"indeterminate":s===a?"complete":"loading"}function y(s){return typeof s=="number"}function _(s){return y(s)&&!isNaN(s)&&s>0}function I(s,a){return y(s)&&!isNaN(s)&&s<=a&&s>=0}function fe(s,a){return`Invalid prop \`max\` of value \`${s}\` supplied to \`${a}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${z}\`.`}function Ne(s,a){return`Invalid prop \`value\` of value \`${s}\` supplied to \`${a}\`. The \`value\` prop must be:
2  - a positive number
3  - less than the value passed to \`max\` (or ${z} if no \`max\` prop is set)
4  - \`null\` or \`undefined\` if the progress is indeterminate.
5
6Defaulting to \`null\`.`}var U=R,ve=q;const T=N.forwardRef(({className:s,value:a,...t},x)=>e.jsx(U,{ref:x,className:V("relative h-4 w-full overflow-hidden rounded-full bg-secondary",s),...t,children:e.jsx(ve,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(a||0)}%)`}})}));T.displayName=U.displayName;const be=()=>{const{toast:s}=K(),a=H(),{data:t,isLoading:x,refetch:r}=G({queryKey:["stakeholderEmbeddingStats"],queryFn:async()=>{const[j,p,f]=await Promise.all([w.from("stakeholders").select("id",{count:"exact",head:!0}).eq("is_active",!0),w.from("stakeholder_chunks").select("stakeholder_id",{count:"exact",head:!0}),w.from("stakeholder_embedding_queue").select("stakeholder_id",{count:"exact",head:!0})]);return{active:j.count??0,embedded:p.count??0,queued:f.count??0}},refetchInterval:5e3}),g=Q({mutationFn:async()=>{const{data:j,error:p}=await w.functions.invoke("embed-stakeholders-backfill");if(p)throw p;return j},onSuccess:j=>{s({title:"Backfill enqueued",description:`${j.enqueued} stakeholders queued for re-embedding.`}),a.invalidateQueries({queryKey:["stakeholderEmbeddingStats"]})},onError:j=>s({title:"Backfill failed",description:j.message,variant:"destructive"})}),u=(t==null?void 0:t.active)??0,n=(t==null?void 0:t.embedded)??0,h=(t==null?void 0:t.queued)??0,v=u>0?Math.min(100,Math.round(n/u*100)):0;return e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(Y,{className:"h-5 w-5"}),"Stakeholder Embeddings"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Vector index powering future stakeholder search and assistant. Updates run automatically on edit (~30s debounce)."}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx(T,{value:v,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[n," / ",u," embedded"]}),e.jsxs("span",{children:[h," queued"]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>g.mutate(),disabled:g.isPending,children:g.isPending?"Enqueuing…":"Backfill all"}),e.jsx(d,{variant:"ghost",size:"sm",onClick:()=>r(),disabled:x,"aria-label":"Refresh",children:e.jsx(X,{className:"h-4 w-4"})})]})]})]})},Me=()=>{const{user:s}=J(),{data:a,isLoading:t}=Z(),{data:x,isLoading:r}=W("admin");return t||r?e.jsx(P,{children:e.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-4"}),e.jsx("p",{children:"Checking permissions..."})]})})}):x?e.jsxs(P,{children:[e.jsx("div",{style:{marginTop:"5rem",marginBottom:"5rem"},children:e.jsx(me,{title:"Admin",description:"Manage users, roles, and system settings"})}),e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 space-y-8",children:[e.jsxs(l,{children:[e.jsx(i,{children:e.jsxs(c,{className:"flex items-center gap-2",children:[e.jsx(M,{className:"h-5 w-5"}),"Your Admin Status"]})}),e.jsx(o,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s==null?void 0:s.email}),e.jsxs("p",{className:"text-sm text-gray-500",children:["User ID: ",s==null?void 0:s.id]})]}),e.jsx(ee,{variant:a==="super_admin"?"destructive":"default",children:(a==null?void 0:a.replace("_"," ").toUpperCase())||"NO ROLE"})]})})]}),a==="super_admin"&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2 text-muted-foreground",children:[e.jsx(M,{className:"h-5 w-5"}),"Users & Access"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(M,{className:"h-5 w-5"}),"User Management"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage user roles and permissions across the platform."}),e.jsx(m,{to:"/admin/user-roles",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage User Roles"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(se,{className:"h-5 w-5"}),"Auth Page Content"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Edit the footer message shown on the sign-in page."}),e.jsx(m,{to:"/admin/auth-content",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Edit Auth Content"})})]})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2 text-muted-foreground",children:[e.jsx(S,{className:"h-5 w-5"}),"Content & Media"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(S,{className:"h-5 w-5"}),"Manage Pages"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Create, edit, and manage pages and navigation."}),e.jsx(m,{to:"/admin/pages",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage Pages"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(ae,{className:"h-5 w-5"}),"Media Library"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Upload and manage images and videos for site content."}),e.jsx(m,{to:"/admin/media",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage Media"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(te,{className:"h-5 w-5"}),"Footer Links"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage the links displayed in the site footer."}),e.jsx(m,{to:"/admin/footer-links",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage Footer Links"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(re,{className:"h-5 w-5"}
vendor: 7,380 bytes, line 6
6),"Tag Clusters"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Organize and manage tag groupings for better content organization."}),e.jsx(m,{to:"/admin/tag-clusters",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage Tag Clusters"})})]})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2 text-muted-foreground",children:[e.jsx(A,{className:"h-5 w-5"}),"Data & Stakeholders"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5"}),"Stakeholders"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage stakeholders, relationships, and the network map."}),e.jsx(m,{to:"/admin/stakeholders",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage Stakeholders"})})]})]}),e.jsx(be,{}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(B,{className:"h-5 w-5"}),"StakeholderBot Prompts"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Edit the analyser and synthesiser prompts and models for the Stakeholder Assistant."}),e.jsx(m,{to:"/admin/stakeholder-bot",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage StakeholderBot"})})]})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2 text-muted-foreground",children:[e.jsx(B,{className:"h-5 w-5"}),"AI Prompts & Knowledge Base"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(S,{className:"h-5 w-5"}),"Knowledge Base"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Browse the research corpus the assistants retrieve from."}),e.jsx(m,{to:"/knowledge-base",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"View Knowledge Base"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(ne,{className:"h-5 w-5"}),"Persona Prompts"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage system prompts for persona chat interactions."}),e.jsx(m,{to:"/admin/persona-prompts",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage Prompts"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(le,{className:"h-5 w-5"}),"PolicyBot Prompts"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage the system prompt for the policy analysis chatbot."}),e.jsx(m,{to:"/admin/policy-bot",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage PolicyBot"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5"}),"StakeholderBot Prompts"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage the prompts and models for the Stakeholder Assistant chatbot."}),e.jsx(m,{to:"/admin/stakeholder-bot",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage StakeholderBot"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(ie,{className:"h-5 w-5"}),"Research Bot Prompts"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage the system prompts for the research assistant chatbot."}),e.jsx(m,{to:"/admin/research-bot",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage Research Bot"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(B,{className:"h-5 w-5"}),"Assumptions Bot"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Manage prompts for the Assumptions Assistant chatbot."}),e.jsx(m,{to:"/admin/assumptions-bot",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Manage Assumptions Bot"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5"}),"AI Architecture"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Every AI system on one page: live models, pipelines and data sources, with prompts editable in place."}),e.jsx(m,{to:"/admin/ai-architecture",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Open AI Architecture"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5"}),"AI operations"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Cost & performance dashboard"}),e.jsx(m,{to:"/admin/ai-operations",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Open AI Operations"})})]})]})]})]}),e.jsxs("section",{className:"space-y-4",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2 text-muted-foreground",children:[e.jsx(C,{className:"h-5 w-5"}),"Legal & Compliance"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(de,{className:"h-5 w-5"}),"Cookie Banner"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Edit the cookie consent banner text displayed to visitors."}),e.jsx(m,{to:"/admin/cookie-banner",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Edit Cookie Banner"})})]})]}),e.jsxs(l,{children:[e.jsx(i,{className:"pb-3",children:e.jsxs(c,{className:"text-lg flex items-center gap-2",children:[e.jsx(C,{className:"h-5 w-5"}),"Privacy Policy"]})}),e.jsxs(o,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Edit the privacy policy page content."}),e.jsx(m,{to:"/admin/privacy",children:e.jsx(d,{variant:"outline",size:"sm",className:"w-full",children:"Edit Privacy Policy"})})]})]})]})]})]})]})]}):e.jsx(P,{children:e.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(C,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-gray-600",children:"You don't have permission to access this page."}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Admin role or higher required."})]})})})};export{Me 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.