PageSourceSearch

https://myechoboard.com/assets/AdminAIReview-BBDtjEbH.js

js myechoboard.com collected 2026-10-02 00:19:54 UTC 33,118 bytes, 1 lines download raw bytes

1import{j as e,r as a}from"./vendor-react-BfgFmtGS.js";import{MainLayout as r}from"./MainLayout-B-JwvN1-.js";import{PageHeader as s}from"./PageHeader-BnvONm3p.js";import{B as t}from"./button-CYJdLL_L.js";import{I as l}from"./input-Cv-gXlbe.js";import{B as o}from"./badge-Cd6jhgwG.js";import{a as i,u as n}from"./useAuth-DynbexoK.js";import{supabase as d}from"./supabase-client-2CObC91N.js";import{c}from"./cloudAiCostEstimate-DFc2VZN-.js";import{g as u}from"./shareUrls-CnKIAmlW.js";import{g as m}from"./safeExternalUrl-Hy3HQFqY.js";import{d as p,L as x}from"./vendor-router-QOYqHwMx.js";import{B as h}from"./bot-Dxnvkk4K.js";import{A as g}from"./arrow-left-DAvP91ch.js";import{S as y}from"./search-D_LVchoc.js";import{R as f}from"./refresh-cw-BjP_646P.js";import{L as b}from"./loader-circle-fXsKc0TP.js";import{f as _}from"./vendor-date-CJZoUMEw.js";import{C as j}from"./chevron-down-B1qfJDmk.js";import{U as v}from"./user-Ds9XOBLy.js";import{E as N}from"./external-link-BI4-_4re.js";import{S as w}from"./sparkles-Bqh4sfNh.js";import{F as k}from"./file-text-B5ffPq62.js";import{M as S}from"./mic-B76gHqs6.js";import{L as A}from"./link-2-D0DLgMN3.js";import{S as C}from"./sticky-note-BsUyFHul.js";import{V as $}from"./video-Bo3AcXon.js";import{I as E}from"./image-Cz6bY_bo.js";const L=[{key:"last_hour",label:"Last hour",description:"Touched in the last 60 minutes"},{key:"last_6_hours",label:"Last 6 hours",description:"Touched in the last 6 hours"},{key:"last_12_hours",label:"Last 12 hours",description:"Touched in the last 12 hours"},{key:"today",label:"Today",description:"Touched since local midnight"},{key:"last_3_days",label:"Last 3 days",description:"Touched in the last 72 hours"}],T=()=>{const e=new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate()).toISOString()},I=e=>{const a=Date.now();switch(e){case"last_hour":return new Date(a-36e5).toISOString();case"last_6_hours":return new Date(a-216e5).toISOString();case"last_12_hours":return new Date(a-432e5).toISOString();case"today":return T();case"last_3_days":return new Date(a-2592e5).toISOString()}},D=a=>{switch(a){case"image":return e.jsx(E,{className:"w-3.5 h-3.5"});case"video":return e.jsx($,{className:"w-3.5 h-3.5"});case"note":return e.jsx(C,{className:"w-3.5 h-3.5"});case"link":case"url":return e.jsx(A,{className:"w-3.5 h-3.5"});case"voice":return e.jsx(S,{className:"w-3.5 h-3.5"});case"document":return e.jsx(k,{className:"w-3.5 h-3.5"});default:return e.jsx(w,{className:"w-3.5 h-3.5"})}},F=e=>Array.isArray(e)?e.filter(e=>"string"==typeof e&&e.trim().length>0):[],O=e=>e.replace(/_+/g," ").replace(/\s+/g," ").trim(),P=["category","style","aesthetic_styles","mood","primary_subject","objects","materials","composition","human_presence","dominant_color","primary_color","secondary_colors","palette","width","height","aspect_ratio","locations","art_medium","architecture_style","food_type","animals","era","activity","use_case","body_type","hair_color","hair_type","time_of_day","occasion","skin_tone","weather","environment","lighting","camera_angle","age","pose","facial_expression","clothing_style","eye_contact","energy","story","vibe","color_temperature","visual_complexity","visual_energy","entities","clothes"],M={category:"Category",style:"Style",aesthetic_styles:"Aesthetic",mood:"Mood",primary_subject:"Primary Subject",objects:"Objects",materials:"Materials",composition:"Composition",human_presence:"Human Presence",dominant_color:"Dominant Color",primary_color:"Primary Color",secondary_colors:"Secondary Colors",palette:"Palette",width:"Width",height:"Height",aspect_ratio:"Aspect Ratio",locations:"Locations",art_medium:"Art Medium",architecture_style:"Architecture Style",food_type:"Food Type",animals:"Animals",era:"Era",activity:"Activity",use_case:"Use Case",body_type:"Body Type",hair_color:"Hair Color",hair_type:"Hair Type",time_of_day:"Time of Day",occasion:"Occasion",skin_tone:"Skin Tone",weather:"Weather",environment:"Environment",lighting:"Lighting",camera_angle:"Camera Angle",age:"Age",pose:"Pose",facial_expression:"Facial Expression",clothing_style:"Clothing Style",eye_contact:"Eye Contact",energy:"Energy",story:"Story",vibe:"Vibe",color_temperature:"Color Temperature",visual_complexity:"Visual Complexity",visual_energy:"Visual Energy",entities:"Entities",clothes:"Clothes"},R=[{key:"tags",label:"Tags"},{key:"style",label:"Styles"},{key:"aesthetic_styles",label:"Aesthetics"},{key:"category",label:"Categories"},{key:"mood",label:"Moods"},{key:"human_presence",label:"Human Presence"},{key:"primary_subject",label:"Subjects"},{key:"objects",label:"Objects"},{key:"materials",label:"Materials"},{key:"composition",label:"Composition"},{key:"colors",label:"Colors"},{key:"locations",label:"Locations"},{key:"art_medium",label:"Art Medium"},{key:"architecture_style",label:"Architecture Style"},{key:"food_type",label:"Food Type"},{key:"animals",label:"Animals"},{key:"era",label:"Era"},{key:"activity",label:"Activity"},{key:"use_case",label:"Use Case"},{key:"body_type",label:"Body Type"},{key:"hair_color",label:"Hair Color"},{key:"hair_type",label:"Hair Type"},{key:"time_of_day",label:"Time of Day"},{key:"occasion",label:"Occasion"},{key:"skin_tone",label:"Skin Tone"},{key:"weather",label:"Weather"},{key:"environment",label:"Environment"},{key:"lighting",label:"Lighting"},{key:"camera_angle",label:"Camera Angle"},{key:"age",label:"Age"},{key:"pose",label:"Pose"},{key:"facial_expression",label:"Facial Expression"},{key:"clothing_style",label:"Clothing Style"},{key:"eye_contact",label:"Eye Contact"},{key:"energy",label:"Energy"},{key:"story",label:"Story"},{key:"vibe",label:"Vibe"},{key:"color_temperature",label:"Color Temperature"},{key:"visual_complexity",label:"Visual Complexity"},{key:"visual_energy",label:"Visual Energy"},{key:"entities",label:"Entities"},{key:"clothes",label:"Clothes"}],U=["processing_mode","reprocessed","processed_at","category","style","aesthetic_styles","mood","primary_subject","objects","materials","composition","human_presence","dominant_color","primary_color","secondary_colors","palette","tags","width","height","aspect_ratio","locations","art_medium","architecture_style","food_type","animals","era","activity","use_case","body_type","hair_color","hair_type","time_of_day","occasion","skin_tone","weather","environment","lighting","camera_angle","age","pose","facial_expression","clothing_style","eye_contact","energy","story","vibe","color_temperature","visual_complexity","visual_energy","entities","clothes"],H=e=>"string"==typeof e&&e.trim().length>0||"number"==typeof e&&Number.isFinite(e),B=e=>Array.isArray(e)&&e.some(e=>"string"==typeof e&&e.trim().length>0),V=(e,a)=>{const r=e.raw_metadata||{},s=e.ai_metadata||{};if("tags"===a)return F(e.tags);if("colors"===a){const e=[r.dominant_color,r.primary_color,...Array.isArray(r.secondary_colors)?r.secondary_colors:[],...Array.isArray(r.palette)?r.palette:[],s.dominant_color,s.primary_color,...Array.isArray(s.secondary_colors)?s.secondary_colors:[],...Array.isArray(s.palette)?s.palette:[]];return[...new Set(e.filter(e=>"string"==typeof e).map(e=>
1e.trim()).filter(Boolean))]}const t=r[a]??s[a];return Array.isArray(t)?t.filter(e=>"string"==typeof e&&e.trim().length>0).map(e=>e.trim()):"string"==typeof t&&t.trim().length>0?[t.trim()]:[]},z=e=>M[e]||e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()),q=e=>e?"cheap_metadata"===e||"ai_metadata"===e?"AI metadata":"embed_only"===e?"Embeddings only":"title_only"===e?"Title repair":"rich_analysis"===e?"Rich analysis":e.replace(/_/g," "):null,Q=e=>e&&Number.isFinite(e)?e>=1?`${e.toFixed(2)}:1`:`1:${(1/e).toFixed(2)}`:null;function W({embedded:r=!1}){var k,S,A,C,$;const{isAdmin:E,isLoading:M}=i(),{toast:W}=n(),[J,Y]=a.useState(""),[G,X]=a.useState("today"),[Z,K]=a.useState("cloud"),[ee,ae]=a.useState(0),[re,se]=a.useState([]),[te,le]=a.useState(null),[oe,ie]=a.useState([]),[ne,de]=a.useState(null),[ce,ue]=a.useState(0),[me,pe]=a.useState({last_hour:0,last_6_hours:0,last_12_hours:0,today:0,last_3_days:0}),[xe,he]=a.useState([]),[ge,ye]=a.useState(0),[fe,be]=a.useState(!0),[_e,je]=a.useState(!1),[ve,Ne]=a.useState(!1),[we,ke]=a.useState(!1),[Se,Ae]=a.useState({}),[Ce,$e]=a.useState({}),Ee=a.useMemo(()=>J.trim(),[J]),Le=(null==(k=L.find(e=>e.key===G))?void 0:k.label)||"Today",Te=async()=>{if("all"===Z){ke(!0);try{const{data:e,error:a}=await d.rpc("admin_get_ai_review_window_counts",{p_search_query:Ee||null,p_today_since:T()});if(a)throw a;const r=L.reduce((e,a)=>(e[a.key]=0,e),{});(e||[]).forEach(e=>{e.window_key in r&&(r[e.window_key]=Number(e.echo_count)||0)}),pe(r)}catch(e){W({title:"Failed to load review counts",description:e.message,variant:"error"})}finally{ke(!1)}}},Ie=async()=>{try{const{data:e,error:a}=await d.rpc("admin_list_ai_corpus_review_runs",{p_limit:25});if(a)throw a;const r=e||[];ie(r),de(e=>{var a;return e&&r.some(a=>a.id===e)?e:(null==(a=r[0])?void 0:a.id)||null}),ue(e=>{var a;return e||Number((null==(a=r[0])?void 0:a.loaded_count)||0)})}catch(e){W({title:"Failed to load cloud corpus runs",description:e.message,variant:"error"})}},De=async(e,a)=>{var r,s,t;a?Ne(!0):je(!0);try{const{data:l,error:o}="reused"===Z?await d.rpc("admin_get_ai_reused_memories",{p_run_id:te,p_search_query:Ee||null,p_limit:6,p_offset:e}):"cloud"===Z?await d.rpc("admin_get_ai_corpus_review_rows",{p_run_id:ne,p_search_query:Ee||null,p_limit:6,p_offset:e}):await d.rpc("admin_get_recent_processed_memories",{p_search_query:Ee||null,p_limit:6,p_offset:e,p_feed_mode:"recently_touched",p_since:I(G)});if(o)throw o;const i=(l||[]).map(e=>({...e,tags:F(e.tags)}));he(e=>a?[...e,...i]:i),"reused"===Z?ae(Number((null==(r=i[0])?void 0:r.total_count)||0)):"cloud"===Z&&ue(Number((null==(s=i[0])?void 0:s.total_count)||(null==(t=oe.find(e=>e.id===ne))?void 0:t.loaded_count)||0)),ye(e),be(6===i.length)}catch(l){W({title:"Failed to load AI reviews",description:l.message,variant:"error"})}finally{je(!1),Ne(!1)}};return a.useEffect(()=>{if(!E)return;if("cloud"===Z&&!ne)return;if("reused"===Z&&!te)return;const e=window.setTimeout(()=>{Te(),De(0,!1)},200);return()=>window.clearTimeout(e)},[E,Ee,G,Z,te,ne]),a.useEffect(()=>{E&&"reused"===Z&&(async()=>{try{const{data:e,error:a}=await d.from("admin_ai_processing_jobs").select("id,status,created_at,completed_at,target_count,processed_count,skipped_count,failed_count").gt("skipped_count",0).in("status",["queued","running","stopping","completed","failed","cancelled","exhausted"]).order("created_at",{ascending:!1}).limit(25);if(a)throw a;const r=e||[];se(r),le(e=>{var a;return e&&r.some(a=>a.id===e)?e:(null==(a=r[0])?void 0:a.id)||null})}catch(e){W({title:"Failed to load reused-run history",description:e.message,variant:"error"})}})()},[E,Z]),a.useEffect(()=>{E&&"cloud"===Z&&Ie()},[E,Z]),M?null:E?e.jsxs("div",{className:r?"space-y-6":"max-w-7xl mx-auto p-6 space-y-6",children:[r?null:e.jsx(s,{title:"AI Echo Review",description:"Review the latest processed echoes, including generated titles, descriptions, and tags.",rightAction:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(x,{to:"/admin#ai",children:e.jsxs(t,{variant:"default",size:"sm",className:"rounded-xl gap-2",children:[e.jsx(h,{className:"w-4 h-4"}),"AI Workspace"]})}),e.jsx(x,{to:"/admin",children:e.jsxs(t,{variant:"outline",size:"sm",className:"rounded-xl gap-2",children:[e.jsx(g,{className:"w-4 h-4"}),"Admin"]})})]})}),r?null:e.jsx("div",{className:"rounded-[1.5rem] border border-border/50 bg-card/50 p-2 shadow-soft",children:e.jsx("div",{className:"flex gap-2 overflow-x-auto no-scrollbar",children:[{label:"AI Processing",to:"/admin#ai"},{label:"Pinterest",to:"/admin#pinterest"},{label:"Filters",to:"/admin#filters"},{label:"Users",to:"/admin#users"},{label:"Reports",to:"/admin#reports"}].map(a=>e.jsx(x,{to:a.to,className:"shrink-0",children:e.jsx(t,{variant:"/admin#ai"===a.to?"default":"ghost",size:"sm",className:"rounded-xl",children:a.label})},a.to))})}),e.jsxs("div",{className:"rounded-[2rem] border border-border/50 bg-card/60 backdrop-blur-xl p-5 shadow-soft",children:[e.jsxs("div",{className:"mb-5 flex flex-wrap gap-2",children:[e.jsxs(t,{type:"button",size:"sm",variant:"cloud"===Z?"default":"outline",className:"rounded-xl",onClick:()=>{K("cloud"),ye(0),be(!0)},children:["Cloud AI results","cloud"===Z&&ce>
10?` (${ce.toLocaleString()})`:""]}),e.jsx(t,{type:"button",size:"sm",variant:"all"===Z?"default":"outline",className:"rounded-xl",onClick:()=>{K("all"),ye(0),be(!0)},children:"All processed"}),e.jsxs(t,{type:"button",size:"sm",variant:"reused"===Z?"default":"outline",className:"rounded-xl",onClick:()=>{K("reused"),ye(0),be(!0)},children:["Reused / skipped","reused"===Z&&ee>0?` (${ee.toLocaleString()})`:""]})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"max-w-3xl",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"cloud"===Z?"Cloud AI results":"reused"===Z?"Reused / Skipped Echoes":"All AI-Processed Echoes"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["cloud"===Z?"Shows Qwen metadata and Voyage embeddings from cloud processing. Ready runs await Stage 4; published runs are active throughout Echo.":"reused"===Z?"These echoes reused existing or local metadata, so Echo skipped a new Qwen generation call. Embeddings were kept or refreshed as needed.":"Shows every echo touched by AI processing, sorted by latest AI activity using embedding refresh time first, then metadata processed time. This tab excludes unpublished cloud shadow runs."," Search titles, descriptions, tags, or owner."]})]}),e.jsxs("div",{className:"grid w-full items-end gap-3 "+("cloud"===Z||"reused"===Z?"md:grid-cols-2 xl:grid-cols-[minmax(20rem,1.25fr)_minmax(18rem,1fr)_auto]":"md:grid-cols-[minmax(18rem,1fr)_auto]"),children:["cloud"===Z&&e.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground",children:"Cloud corpus run"}),e.jsxs("select",{value:ne||"",onChange:e=>{var a;const r=e.target.value||null;de(r),ue(Number((null==(a=oe.find(e=>e.id===r))?void 0:a.loaded_count)||0)),ye(0),be(!0)},className:"h-10 w-full rounded-xl border border-input bg-background px-3 text-sm text-foreground",children:[0===oe.length&&e.jsx("option",{value:"",children:"Latest loaded cloud run"}),oe.map(a=>e.jsxs("option",{value:a.id,children:[new Date(a.ready_at||a.created_at).toLocaleString()," · ",a.status," · ",Number(a.loaded_count).toLocaleString()," loaded · ",Number(a.embedded_count).toLocaleString()," embedded"]},a.id))]})]}),"reused"===Z&&e.jsxs("label",{className:"flex min-w-0 flex-col gap-1",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.16em] text-muted-foreground",children:"Processing run"}),e.jsxs("select",{value:te||"",onChange:e=>{le(e.target.value||null),ye(0),be(!0)},className:"h-10 w-full rounded-xl border border-input bg-background px-3 text-sm text-foreground",children:[0===re.length&&e.jsx("option",{value:"",children:"Latest run with reusable echoes"}),re.map(a=>e.jsxs("option",{value:a.id,children:["running"===a.status||"stopping"===a.status?("running"===a.status?"Running":"Stopping")+" · ":"",new Date(a.completed_at||a.created_at).toLocaleString()," · ",a.skipped_count.toLocaleString()," reused · ",a.processed_count.toLocaleString()," processed"]},a.id))]})]}),e.jsxs("div",{className:"relative w-full",children:[e.jsx(y,{className:"w-4 h-4 text-muted-foreground absolute left-3 top-1/2 -translate-y-1/2"}),e.jsx(l,{value:J,onChange:e=>Y(e.target.value),placeholder:"Search AI text, tags, or owner",className:"pl-9 rounded-xl"})]}),e.jsxs(t,{variant:"outline",className:"h-10 rounded-xl gap-2",onClick:()=>{Te(),"cloud"===Z&&Ie(),De(0,!1)},disabled:_e||we,children:[e.jsx(f,{className:"w-4 h-4 "+(_e||we?"animate-spin":"")}),"Refresh"]})]})]}),"cloud"===Z?e.jsx("div",{className:"mt-5 grid gap-2 sm:grid-cols-2 lg:grid-cols-5",children:[["Loaded results",ce],["Generated",Number((null==(S=oe.find(e=>e.id===ne))?void 0:S.generated_count)||0)],["Qwen embedded",Number((null==(A=oe.find(e=>e.id===ne))?void 0:A.embedded_count)||0)],["Failed",Number((null==(C=oe.find(e=>e.id===ne))?void 0:C.failed_count)||0)],["Qwen estimate",`$${c(null==($=oe.find(e=>e.id===ne))?void 0:$.actual_spend_usd).toFixed(2)}`]].map(([a,r])=>e.jsxs("div",{className:"rounded-2xl border border-sky-500/20 bg-sky-500/[0.06] px-4 py-3",children:[e.jsx("span",{className:"block text-xs font-bold uppercase tracking-[0.16em] text-muted-foreground",children:a}),e.jsx("span",{className:"mt-2 block text-2xl font-bold leading-none text-foreground",children:"number"==typeof r?r.toLocaleStr
1ing():r})]},a))}):"all"===Z&&e.jsx("div",{className:"mt-5 grid gap-2 sm:grid-cols-2 lg:grid-cols-5",children:L.map(a=>{const r=G===a.key,s=me[a.key]??0;return e.jsxs("button",{type:"button",onClick:()=>{X(a.key),ye(0),be(!0),Ae({}),$e({})},className:"rounded-2xl border px-4 py-3 text-left transition-colors "+(r?"border-primary/40 bg-primary/10 text-foreground shadow-sm":"border-border/50 bg-background/40 text-muted-foreground hover:bg-background/70"),"aria-pressed":r,title:a.description,children:[e.jsx("span",{className:"block text-xs font-bold uppercase tracking-[0.16em]",children:a.label}),e.jsxs("span",{className:"mt-2 flex items-end gap-2",children:[e.jsx("span",{className:"text-2xl font-bold leading-none text-foreground",children:we?"...":s.toLocaleString()}),e.jsx("span",{className:"pb-0.5 text-xs font-medium",children:1===s?"echo":"echoes"})]})]},a.key)})})]}),e.jsx("div",{className:"space-y-4",children:_e?e.jsxs("div",{className:"rounded-[2rem] border border-border/50 bg-card/60 p-10 flex items-center justify-center gap-3 text-muted-foreground",children:[e.jsx(b,{className:"w-5 h-5 animate-spin"}),"Loading processed echoes..."]}):0===xe.length?e.jsxs("div",{className:"rounded-[2rem] border border-dashed border-border/60 bg-card/40 p-10 text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:"No processed echoes found"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["No reviewable echoes in ",Le.toLowerCase(),". Try a wider time tab or a different search term."]})]}):xe.map(a=>{var r,s,l,i,n,d,c,p,g,y,f;const b=F(a.tags),k=u({id:a.id,ownerUsername:a.owner_username}),S=(e=>{var a,r,s;return(null==(a=e.content)?void 0:a.trim())||(null==(r=e.description)?void 0:r.trim())||(null==(s=e.ai_description)?void 0:s.trim())||""})(a).slice(0,240),A=a.owner_username?`@${a.owner_username}`:a.owner_full_name||"Unknown owner",C=a.processed_at||a.updated_at,$=a.touch_at||C,E="string"==typeof(null==(r=a.raw_metadata)?void 0:r.embedding_refreshed_at)?a.raw_metadata.embedding_refreshed_at:null,L=(e=>{var a;return"string"==typeof(null==(a=e.raw_metadata)?void 0:a.processing_mode)?e.raw_metadata.processing_mode:null})(a),T=(e=>{const a=e.ai_metadata||{};return P.flatMap(e=>{const r=a[e];if(H(r))return[{key:e,type:"scalar",value:String(r).trim()}];if(B(r)){const a=r.filter(e=>"string"==typeof e&&e.trim().length>0).map(e=>e.trim());return a.length>0?[{key:e,type:"array",value:a}]:[]}return[]})})(a),I=(e=>{const a=e.raw_metadata||{},r=e.ai_metadata||{},s=a.human_presence??r.human_presence;return"string"==typeof s&&s.trim().length>0?s.trim():null})(a),M=(e=>{for(const a of[e.ai_metadata,e.raw_metadata]){const e=null==a?void 0:a._echo_pipeline;if(!e||"object"!=typeof e||Array.isArray(e))continue;const r=e.embedding_caption;if("string"==typeof r&&r.trim())return r.trim()}return null})(a),W=M?M.split(/\s+/).filter(Boolean).length:0,J=(e=>{const a=e.raw_metadata||{},r=new Set;return[...U,...Object.keys(a).sort((e,a)=>e.localeCompare(a))].filter(e=>!r.has(e)&&(r.add(e),!0)).flatMap(e=>{const r=a[e];if(H(r))return[{key:e,type:"scalar",value:String(r).trim()}];if(B(r)){const a=r.filter(e=>"string"==typeof e&&e.trim().length>0).map(e=>e.trim());return a.length>0?[{key:e,type:"array",value:a}]:[]}return r&&"object"==typeof r&&!Array.isArray(r)?[{key:e,type:"json",value:JSON.stringify(r)}]:[]})})(a),Y=T.length>0,G=J.length>0,X=!!Se[a.id],Z=!!Ce[a.id],K=R.map(e=>({...e,values:V(a,e.key)})),ee=[(null==(s=a.style)?void 0:s.trim())?`Style: ${O(a.style)}`:null,(null==(l=a.mood)?void 0:l.trim())?`Mood: ${O(a.mood)}`:null,b.length>0?`${b.length} tags`:null,q(L)?`Mode: ${q(L)}`:null].filter(e=>Boolean(e));return e.jsxs("div",{className:"rounded-[2rem] border border-border/50 bg-card/60 backdrop-blur-xl p-5 shadow-soft",children:[e.jsx("button",{type:"button",onClick:()=>Ae(e=>({...e,[a.id]:!e[a.id]})),className:"w-full text-left",children:e.jsxs("div",{className:"flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(o,{variant:"secondary",className:"gap-1.5",children:[D(a.type),a.type]}),e.jsxs(o,{variant:"default",className:"gap-1.5",children:[e.jsx(h,{className:"w-3.5 h-3.5"}),"AI processed"]}),a.corpus_version?e.jsxs(o,{variant:"outline",className:"gap-1.5 border-sky-500/40 bg-sky-500/10 text-sky-700 dark:text-sky-200",children:["published"===a.corpus_status?"Live throughout Echo":"Awaiting Stage 4 publish"," · ",a.embedding_provider||"OpenRouter"]}):null,a.reuse_reason&&e.jsx(o,{variant:"outline",className:"gap-1.5 border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-200",children:"Generation skipped · metadata reused"}),e.jsx(o,{variant:"outline",className:"gap-1.5",children:a.processing_status}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Latest touch ",_(new Date($),{addSuffix:!0})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Processed ",_(new Date(C),{addSuffix:!0})]}),E&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Embedding refreshed ",_(new Date(E),{addSuffix:!0})]})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"hidden sm:block shrink-0",children:a.image_url?e.jsx("img",{src:a.image_url,alt:a.ai_title||a.title||"Echo preview",className:"h-24 w-24 rounded-2xl object-cover border border-border/50 bg-muted/20"}):e.jsx("div",{className:"flex h-24 w-24 items-center justify-center rounded-2xl border border-dashed border-border/60 bg-muted/20 text-muted-foreground",children:D(a.type)})}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-base font-semibold text-foreground",children:(null==(i=a.ai_title)?void 0:i.trim())||(null==(n=a.title)?void 0:n.trim())||"Untitled"}),(null==(d=a.title)?void 0:d.trim())&&(null==(c=a.ai_title)?void 0:c.trim())&&a.ai_title.trim()!==a.title.trim()?e.jsxs("p",{className:"text-sm text-foreground
1/70 mt-1",children:["Original: ",a.title.trim()]}):null]}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:(null==(p=a.ai_description)?void 0:p.trim())||S||"No AI description"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(o,{variant:"outline",className:"rounded-full",children:a.owner_full_name||A}),ee.map(r=>e.jsx(o,{variant:"outline",className:"rounded-full",children:r},`${a.id}-${r}`)),b.slice(0,4).map(r=>e.jsx(o,{variant:"secondary",className:"rounded-full",children:O(r)},`${a.id}-summary-tag-${r}`))]})]})]})]}),e.jsx("div",{className:"flex items-start justify-end xl:pl-4",children:e.jsxs("div",{className:"inline-flex items-center gap-2 rounded-xl border border-border/50 bg-background/50 px-3 py-2 text-sm text-muted-foreground",children:[X?"Collapse":"Expand",e.jsx(j,{className:"h-4 w-4 transition-transform "+(X?"rotate-180":"")})]})})]})}),X?e.jsxs("div",{className:"mt-5 flex flex-col gap-5 xl:flex-row xl:items-start xl:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(o,{variant:"secondary",className:"gap-1.5",children:[D(a.type),a.type]}),e.jsxs(o,{variant:"default",className:"gap-1.5",children:[e.jsx(h,{className:"w-3.5 h-3.5"}),"AI processed"]}),a.corpus_version?e.jsxs(o,{variant:"outline",className:"gap-1.5 border-sky-500/40 bg-sky-500/10 text-sky-700 dark:text-sky-200",children:["published"===a.corpus_status?"Live throughout Echo":"Awaiting Stage 4 publish"," · ",a.embedding_provider||"OpenRouter"]}):null,e.jsx(o,{variant:"outline",className:"gap-1.5",children:a.processing_status}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Latest touch ",_(new Date($),{addSuffix:!0})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Processed ",_(new Date(C),{addSuffix:!0})]}),E&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Embedding refreshed ",_(new Date(E),{addSuffix:!0})]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-2xl border border-border/50 bg-background/40 p-4 space-y-2",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Original"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:(null==(g=a.title)?void 0:g.trim())||"Untitled"}),a.description?e.jsx("p",{className:"text-sm text-muted-foreground mt-2 whitespace-pre-wrap leading-relaxed",children:a.description}):null,!a.description&&S?e.jsx("p",{className:"text-sm text-muted-foreground mt-2 whitespace-pre-wrap leading-relaxed",children:S}):null]})]}),e.jsxs("div",{className:"rounded-2xl border border-primary/20 bg-primary/5 p-4 space-y-2",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] text-primary/80",children:"AI Review Copy"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:(null==(y=a.ai_title)?void 0:y.trim())||"No AI title"}),e.jsx("p",{className:"text-sm text-foreground/80 mt-2 whitespace-pre-wrap leading-relaxed",children:(null==(f=a.ai_description)?void 0:f.trim())||"No AI description"})]})]})]}),M?e.jsxs("div",{className:"rounded-2xl border border-sky-500/25 bg-sky-500/[0.07] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] text-sky-700 dark:text-sky-200",children:"Private retrieval caption"}),e.jsxs(o,{variant:"outline",className:"rounded-full border-sky-500/30 bg-background/40 text-[11px]",children:["Admin QA · indexing only · ",W," words"]})]}),e.jsx("p",{className:"mt-3 text-sm font-medium leading-7 text-foreground whitespace-pre-wrap",children:M})]}):null,b.length>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(r=>e.jsx(o,{variant:"outline",className:"rounded-full",children:O(r)},`${a.id}-${r}`))})]}):null,e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Human Presence"}),e.jsx("div",{className:"rounded-2xl border border-border/50 bg-background/30 p-3",children:I?e.jsx(o,{variant:"secondary",className:"rounded-full",children:O(I)}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not detected yet"})})]}),Y?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"AI Metadata"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:T.map(r=>"scalar"===r.type?e.jsxs(o,{variant:"secondary",className:"rounded-full gap-2",children:[r.key.includes("color")?e.jsx("span",{className:"inline-block h-3 w-3 rounded-full border border-black/10",style:{backgroundColor:r.value}}):null,z(r.key),": ","aspect_ratio"===r.key?Q(Number(r.value))||r.value:O(r.value)]},`${a.id}-${r.key}-${r.value}`):r.value.map(s=>e.jsxs(o,{variant:"secondary",className:"rounded-full gap-2",children:["secondary_colors"===r.key||"palette"===r.key?e.jsx("span",{className:"inline-block h-3 w-3 rounded-full border border-black/10",style:{backgroundColor:s}}):null,z(r.key),": ",O(s)]},`${a.id}-${r.key}-${s}`)))})]}):null,e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Explore Fields"}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-3",children:K.map(r=>e.jsxs("div",{className:"rounded-2xl border border-border/50 bg-background/30 p-3 space-y-2",children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.16em] text-muted-foreground",children:r.label}),r.values.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:r.values.map(s=>e.jsxs(o,{variant:"outline",className:"rounded-full gap-2",children:["colors"===r.key?e.jsx("span",{className:"inline-block h-3 w-3 rounded-full border border-black/10",style:{backgroundColor:s}}):null,O(s)]},`${a.id}-explore-${r.key}-${s}`))}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Not present yet"})]},`${a.id}-explore-${r.key}`))})]}),G?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("button",{type:"button",onClick:()=>$e(e=>({...e,[a.id]:!e[a.id]})),className:"flex w-full items-center justify-between rounded-2xl border border-border/50 bg-background/40 px-4 py-3 text-left transition-colors hover:bg-background/60",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.18em] text-muted-foreground",children:"Raw AI Metadata"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Full metadata payload from processing for inspection and QA."})]}),e.jsx(j,{className:"h-4 w-4 text-muted-foreground transition-transform "+(Z?"rotate-180":"")})]}),Z?e.jsxs("div",{className:"rounded-2xl border border-border/50 bg-background/30 p-4 space-y-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:J.map(r=>"scalar"===r.type?e.jsxs(o,{variant:"outline",className:"rounded-full gap-2",children:[r.key.includes("color")&&!r.value.startsWith("{")?e.jsx("span",{className:"inline-block h-3 w-3 rounded-full border border-black/10",style:{backgroundColor:r.value}}):null,z(r.key),": ","aspect_ratio"===r.key&&Q(Number(r.value))||r.value]},`${a.id}-raw-${r.key}-${r.value}`):"array"===r.type?r.value.map(s=>e.jsxs(o,{variant:"outline",className:"rounded-full gap-2",children:["secondary_colors"===r.key||"palette"===r.key?e.jsx("span",{className:"inline-block h-3 w-3 rounded-full border border-black/10",style:{backgroundColor:s}}):null,z(r.key),": ",s]},`${a.id}-raw-${r.key}-${s}`)):e.jsxs(o,{variant:"outline",className:"rounded-full",children:[z(r.key),": object"]},`${a.id}-raw-${r.key}`))}),e.jsx("div",{className:"rounded-xl border border-border/50 bg-black/[0.04] dark:bg-white/[0.03] p-3 overflow-x-auto",children:e.jsx("pre",{className:"text-xs leading-relaxed text-foreground
1/80 whitespace-pre-wrap break-words",children:JSON.stringify(a.raw_metadata,null,2)})})]}):null]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(v,{className:"w-4 h-4"}),a.owner_full_name||A,a.owner_username?e.jsx("span",{className:"text-primary",children:A}):null]}),e.jsxs("span",{children:["Created ",_(new Date(a.created_at),{addSuffix:!0})]}),m(a.source_url)?e.jsxs("a",{href:m(a.source_url)||void 0,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-primary hover:underline",children:[e.jsx(N,{className:"w-4 h-4"}),"Source"]}):null]})]}),e.jsxs("div",{className:"w-full xl:w-56 space-y-3",children:[a.image_url?e.jsx("a",{href:a.image_url,target:"_blank",rel:"noreferrer",className:"block",children:e.jsx("img",{src:a.image_url,alt:a.ai_title||a.title||"Echo preview",className:"w-full aspect-[4/3] rounded-2xl object-cover border border-border/50 bg-muted/20"})}):e.jsx("div",{className:"w-full aspect-[4/3] rounded-2xl border border-dashed border-border/60 bg-muted/20 flex items-center justify-center text-muted-foreground",children:D(a.type)}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(x,{to:k,children:e.jsxs(t,{className:"w-full rounded-xl gap-2",children:[e.jsx(w,{className:"w-4 h-4"}),"Open Echo"]})}),a.owner_username?e.jsx(x,{to:`/u/${a.owner_username}`,target:"_blank",children:e.jsxs(t,{variant:"outline",className:"w-full rounded-xl gap-2",children:[e.jsx(v,{className:"w-4 h-4"}),"Open Profile"]})}):null]})]})]}):null]},a.id)})}),xe.length>0&&fe?e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(t,{variant:"outline",className:"rounded-xl",disabled:ve,onClick:()=>{De(ge+6,!0)},children:ve?e.jsxs(e.Fragment,{children:[e.jsx(b,{className:"w-4 h-4 mr-2 animate-spin"}),"Loading..."]}):"Load more echoes"})}):null]}):r?null:e.jsx(p,{to:"/",replace:!0})}function J(){return e.jsx(r,{children:e.jsx(W,{})})}export{W as AdminAIReviewPanel,J 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.