PageSourceSearch

https://www.patricknesbitt.ai/assets/StudioAtlasReview-DnJEN4ti.js

js patricknesbitt.ai collected 2026-10-05 15:10:58 UTC 6,791 bytes, 4 lines download raw bytes

1import{j as e,r as h,e as S,u as j}from"./query-vendor-xE32BUwA.js";import{j as x}from"./index-BmlH4SZ6.js";import{L as q}from"./label-B41weyOR.js";import{T as R}from"./textarea-g2HXwSuO.js";import{i as E}from"./sanitization-CvPPKYCV.js";import{R as T,S as A}from"./RequireAdmin-DHJ0qCJv.js";import{supabase as C}from"./client-miKtLRar.js";import"./react-vendor-DACtqSey.js";import"./ui-vendor-sWY5FKeG.js";import"./purify.es-Bc-0F0ao.js";import"./input-BXcHsnsE.js";import"./index-2BeCE6ue.js";import"./index-BFANB4Sp.js";import"./tslib.es6-Ds0fHAFP.js";import"./index-CRjDHfM3.js";import"./SEOHead-Dw7MUQ1Q.js";const b=t=>String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),k=t=>/^https:\/\/[^\s"'<>]+$/.test(String(t??""))?String(t):null;function y(t){let a=b(t);return a=a.replace(/`([^`]+)`/g,"<code>$1</code>"),a=a.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),a=a.replace(/(^|[^*])\*([^*\s][^*]*)\*/g,"$1<em>$2</em>"),a=a.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(l,s,o)=>{const n=k(o.replace(/&amp;/g,"&"));return n?`<a href="${b(n)}">${s}</a>`:s}),a}function L(t){const a=[];let l=[],s=null;const o=()=>{l.length&&a.push(`<p>${y(l.join(" "))}</p>`),l=[]},n=()=>{s&&a.push(`<${s.tag}>${s.items.map(r=>`<li>${y(r)}</li>`).join("")}</${s.tag}>`),s=null};for(const r of String(t??"").replace(/\r\n?/g,`
2`).split(`
3`)){const c=r.trim();if(!c){o(),n();continue}const u=/^(#{1,6})\s+(.+)$/.exec(c);if(u){o(),n();const d=u[1].length<=2?2:3;a.push(`<h${d}>${y(u[2])}</h${d}>`);continue}const i=/^\d+\.\s+(.+)$/.exec(c),p=/^[-*]\s+(.+)$/.exec(c);if(i||p){o();const d=i?"ol":"ul";s&&s.tag!==d&&n(),s||(s={tag:d,items:[]}),s.items.push((i||p)[1]);continue}n(),l.push(c)}return o(),n(),a.join(`
4`)}function I({page:t,onDecide:a,busy:l,error:s}){const[o,n]=h.useState(""),r=o.trim(),c=Array.isArray(t.sources)?t.sources.filter(i=>i&&typeof i.label=="string"&&typeof i.url=="string"&&E(i.url)):[],u=i=>{l||i!=="approved"&&!r||a({id:t.id,decision:i,revision_sha256:t.revision_sha256,notes:i==="approved"?"":r})};return e.jsxs("article",{"aria-label":t.title,className:"rounded-lg border bg-card p-5 shadow-sm sm:p-6",children:[e.jsxs("div",{className:"border-b pb-4",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:t.view.replace(/_/g," ")}),e.jsx("h3",{className:"mt-1 text-xl font-semibold",children:t.title})]}),e.jsx("div",{className:"prose prose-slate dark:prose-invert max-w-none py-5 break-words",children:e.jsx("div",{className:"prose max-w-none",dangerouslySetInnerHTML:{__html:L(t.body_md||"")}})}),c.length>0&&e.jsxs("div",{className:"border-t py-4 text-sm",children:[e.jsx("h4",{className:"font-medium",children:"Sources"}),e.jsx("ul",{className:"mt-2 space-y-1",children:c.map((i,p)=>e.jsx("li",{children:e.jsx("a",{href:i.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline-offset-4 hover:underline",children:i.label})},`${i.url}-${p}`))})]}),e.jsxs("div",{className:"space-y-3 border-t pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(q,{htmlFor:`atlas-note-${t.id}`,children:"Note"}),e.jsx(R,{id:`atlas-note-${t.id}`,value:o,onChange:i=>n(i.target.value),disabled:l})]}),s&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:s}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(x,{type:"button",onClick:()=>u("approved"),disabled:l,children:"Approve"}),e.jsx(x,{type:"button",variant:"outline",onClick:()=>u("changes_requested"),disabled:l||!r,children:"Request changes"}),e.jsx(x,{type:"button",variant:"destructive",onClick:()=>u("rejected"),disabled:l||!r,children:"Reject"})]})]})]})}function K({pages:t,publishedToday:a,onDecide:l,busyId:s,error:o}){const n=t.filter(r=>r.status==="pending").slice().sort((r,c)=>r.created_at.localeCompare(c.created_at));return e.jsxs("section",{className:"mx-auto max-w-4xl space-y-5","aria-label":"Atlas review queue",children:[e.jsxs("header",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsxs("h2",{className:"text-2xl font-semibold",children:[n.length," waiting"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a," of 15 published today"]})]}),n.length===0?e.jsx("p",{className:"rounded-lg border p-8 text-center text-muted-foreground",children:"Nothing waiting"}):n.map(r=>e.jsx(I,{page:r,onDecide:l,busy:s!=null,error:(o==null?void 0:o.id)===r.id?o.message:void 0},`${r.id}:${r.revision_sha256}`))]})}const _=["atlas-review","pending"],N=["atlas-review","published-today"],v=C;function P(){var i,p;const t=S(),[a,l]=h.useState(null),[s,o]=h.useState(null),n=h.useRef(!1),r=j({queryKey:_,queryFn:async()=>{const{data:d,error:m}=await v.from("atlas_pages").select("id, slug, process_pcf_id, view, title, description, body_md, sources, revision_sha256, status, created_at").eq("status","pen
4ding").order("created_at",{ascending:!0});if(m)throw new Error(m.message);return d||[]},staleTime:0,refetchOnMount:"always"}),c=j({queryKey:N,queryFn:async()=>{const d=`${new Date().toISOString().slice(0,10)}T00:00:00.000Z`,{count:m,error:f}=await v.from("atlas_pages").select("id",{count:"exact",head:!0}).eq("status","published").gte("published_at",d);if(f)throw new Error(f.message);return m??0},staleTime:0,refetchOnMount:"always",refetchInterval:6e4}),u=h.useCallback(async({id:d,decision:m,revision_sha256:f,notes:$})=>{if(!n.current){n.current=!0,l(d),o(null);try{const{data:g,error:w}=await v.rpc("atlas_review_page",{p_id:d,p_decision:m,p_revision_sha256:f,p_notes:$});if(w)throw new Error(w.message);if(g===!1)throw new Error("This page changed since you opened it. Review the current draft before deciding.")}catch(g){o({id:d,message:g instanceof Error?g.message:"The decision was refused. Try again."})}finally{await Promise.allSettled([t.invalidateQueries({queryKey:_}),t.invalidateQueries({queryKey:N})]),n.current=!1,l(null)}}},[t]);return{pages:r.data||[],publishedToday:c.data??0,isLoading:r.isPending||c.isPending,loadError:((i=r.error)==null?void 0:i.message)||((p=c.error)==null?void 0:p.message)||null,busyId:a,decisionError:s,decide:u,refresh:()=>Promise.all([r.refetch(),c.refetch()])}}function ee(){const{pages:t,publishedToday:a,isLoading:l,loadError:s,busyId:o,decisionError:n,decide:r,refresh:c}=P();return e.jsx(T,{children:e.jsxs(A,{title:"Atlas review",description:"Review Process Atlas drafts",children:[l&&e.jsx("p",{role:"status",children:"Loading Atlas pages..."}),s&&e.jsxs("div",{role:"alert",className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-destructive",children:s}),e.jsx(x,{variant:"outline",onClick:()=>{c()},children:"Retry"})]}),!l&&!s&&e.jsx(K,{pages:t,publishedToday:a,onDecide:r,busyId:o,error:n})]})})}export{ee 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.