Wizzas commited on
Commit
91b8068
·
verified ·
1 Parent(s): e3d580c

Update verified React dashboard

Browse files
frontend/dist/assets/TeamWorkspace-_fohkjz6.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{c as he,r as a,l as ct,a as it,b as ot,d as dt,e as mt,s as tt,f as O,R as ut,g as Be,h as e,i as Ue,p as at,n as Oe,j as rt,k as st,m as pt,w as Re,o as Qe,q as ht,t as ft,u as Et,v as yt,x as vt,y as gt,z as bt,A as wt,B as Nt,C as St,L as kt,S as _t,D as Ct,E as Xe,F as Dt,G as Rt,H as Ze,I as xt}from"./index-CaZty-YY.js";/**
2
+ * @license lucide-react v0.577.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 Tt=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]],qt=he("archive-restore",Tt);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const At=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],$e=he("cloud",At);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Lt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Pt=he("external-link",Lt);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Ft=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],It=he("log-in",Ft);/**
22
+ * @license lucide-react v0.577.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Mt=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],Ot=he("log-out",Mt);/**
27
+ * @license lucide-react v0.577.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const zt=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Ut=he("refresh-cw",zt);/**
32
+ * @license lucide-react v0.577.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const jt=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Ht=he("send",jt);/**
37
+ * @license lucide-react v0.577.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const Wt=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],$t=he("users",Wt),Ge="17:00",Bt=[{label:"Tomorrow",days:1},{label:"In 3 days",days:3},{label:"In 1 week",days:7},{label:"In 2 weeks",days:14}],Pe=n=>String(n).padStart(2,"0"),je=n=>n.getFullYear()+"-"+Pe(n.getMonth()+1)+"-"+Pe(n.getDate());function Je(n,s=new Date){const m=new Date(s);return m.setDate(m.getDate()+n),je(m)}const Ve=(n,s)=>n?n+"T"+(s||Ge):"",Gt=n=>({date:n?n.slice(0,10):"",time:n?n.slice(11,16):""}),nt=n=>{const[s,m]=n.split(":").map(Number);return(s%12||12)+":"+Pe(m)+" "+(s<12?"AM":"PM")};function Yt(n){const s=[];for(let m=420;m<=1200;m+=30)s.push(Pe(Math.floor(m/60))+":"+Pe(m%60));return n&&/^\d\d:\d\d$/.test(n)&&!s.includes(n)&&s.push(n),s.sort()}function Kt(n,s=new Date){const m=Math.round((new Date(n.slice(0,10)+"T00:00")-new Date(je(s)+"T00:00"))/864e5);return m===0?"today":m===1?"tomorrow":m>1?"in "+m+" days":m===-1?"yesterday":Math.abs(m)+" days ago"}function lt(n,s=new Date){if(!n||!Number.isFinite(Date.parse(n)))return"";const m=new Date(n.slice(0,10)+"T00:00"),i=D=>m.toLocaleDateString("en-GB",D);return i({weekday:"long"})+", "+m.getDate()+" "+i({month:"short"})+" "+m.getFullYear()+" at "+nt(n.slice(11,16))+" · "+Kt(n,s)}const ze=n=>new Date(n).toLocaleString([],{dateStyle:"medium",timeStyle:"short"}),Qt=n=>{const s=new Date(n);return je(s)+"T"+String(s.getHours()).padStart(2,"0")+":"+String(s.getMinutes()).padStart(2,"0")};function et({legend:n,prefix:s,value:m,time:i,setValue:D,setTime:v,disabled:z,required:_,keep:I}){const g=Gt(m),U=g.time||i,G=f=>D(Ve(f,U)),Y=f=>{v(f),g.date&&D(Ve(g.date,f))};return e.createElement("fieldset",{className:"due-field"},e.createElement("legend",null,n),e.createElement("div",{className:"due-shortcuts",role:"group","aria-label":n+" shortcuts"},I&&e.createElement("button",{type:"button",className:"chip"+(m?"":" selected"),"aria-pressed":!m,disabled:z,onClick:()=>D("")},"Keep current"),Bt.map(f=>{const M=Je(f.days);return e.createElement("button",{type:"button",key:f.days,className:"chip"+(g.date===M?" selected":""),"aria-pressed":g.date===M,disabled:z,onClick:()=>G(M)},f.label)})),e.createElement("div",{className:"due-inputs"},e.createElement("label",{className:"field"},s,"date",e.createElement("input",{type:"date",disabled:z,required:_,min:je(new Date),max:Je(365),value:g.date,onInput:f=>G(f.target.value),onChange:f=>G(f.target.value)})),e.createElement("label",{className:"field"},s,"time",e.createElement("select",{disabled:z,value:U,onChange:f=>Y(f.target.value)},Yt(U).map(f=>e.createElement("option",{key:f,value:f},nt(f)))))),e.createElement("p",{className:"caption due-summary","aria-live":"polite"},m?e.createElement(e.Fragment,null,"Due ",e.createElement("strong",null,lt(m))):I||"Pick a day within the next year. Time starts at 5:00 PM."))}function Xt({user:n,inspection:s,notes:m=[],inspections:i=[],inspectionLoading:D=!1,onSelectInspection:v,onEvidence:z}){var Ke;const _=a.useRef(0),I=a.useRef(!1),g=a.useRef(s==null?void 0:s.id),U=a.useRef(null),G=a.useRef(null),Y=a.useRef(null),[f,M]=a.useState("checking"),[T,j]=a.useState([]),[H,E]=a.useState([]),[de,h]=a.useState(""),[se,N]=a.useState([]),[q,L]=a.useState([]),[fe,A]=a.useState(""),[S,J]=a.useState(!1),[me,w]=a.useState(""),[P,Ee]=a.useState(""),[K,l]=a.useState(""),[b,W]=a.useState("Normal"),[ne,u]=a.useState(""),[R,ye]=a.useState(Ge),[V,le]=a.useState(!1),[ee,Se]=a.useState(""),[xe,ke]=a.useState(""),[_e,Te]=a.useState(null),[qe,He]=a.useState(0),[Ce,Ae]=a.useState(""),[Fe,ce]=a.useState(""),[ue,ve]=a.useState(""),[De,Q]=a.useState(Ge),c=T.find(t=>t.id===de),$=ct(m),ie=it(T),C=ot(s,m,T,D),Ie=dt({description:me,owner:P,supervisor:K,priority:b,due:ne},H),r=C.ready?Ie||(V?"":"Tick the box to confirm the defect."):C.reason,[d,o]=a.useState([]),[x,ge]=a.useState("all"),k=t=>["Resolved","Closed","Cancelled"].includes(t.state),X=t=>!k(t)&&Date.parse(t.due_at)<Date.now(),te=[["all","All",()=>!0],["open","Open",t=>!k(t)],["overdue","Overdue",X],["done","Done",k]],be=T.filter(((Ke=te.find(t=>t[0]===x))==null?void 0:Ke[2])||(()=>!0)),B=i.filter(t=>!t.archived_at),ae=B.map(t=>t.id).join(","),F=t=>pt(t.id===(s==null?void 0:s.id)?m:d.filter(p=>p.inspection_id===t.id),T),re=B.map(t=>({row:t,status:F(t)})).sort((t,p)=>(p.status.key==="ready")-(t.status.key==="ready")),pe=re.filter(t=>t.status.key==="ready").length,oe=mt(c,n.id,H.some(t=>t.user_id===n.id&&t.role==="developer")),we=!!c&&_e!==null&&_e!==c.version;async function Me(){const t=++_.current,p=await O(),y=await p.rpc("defectrag_ca_staff");if(t!==_.current)return;if(y.error||y.data!==!0)throw M("denied"),j([]),E([]),h(""),N([]),L([]),new Error("Sign in with an approved Staff account and verify the security code before opening corrective actions.");const Z=await Promise.all([p.from("corrective_actions").select("*").order("created_at",{ascending:!1}).limit(500),p.from("staff_members").select("user_id,display_name,role,revoked_at").is("revoked_at",null)]);if(t===_.current){if(Z.some(Le=>Le.error))throw M("unavailable"),j([]),E([]),h(""),N([]),L([]),Z.find(Le=>Le.error).error;M("authorized"),j(Z[0].data||[]),E(Z[1].data||[]),A(""),He(Le=>Le+1)}}a.useEffect(()=>{const t=tt(Me,{onState:p=>{p.error&&(M("unavailable"),A(p.error),j([]),E([]),h(""),N([]),L([]))}});return()=>{t.stop(),_.current++}},[n.id]),a.useEffect(()=>{const t=()=>{_.current++,M("checking"),j([]),E([]),h(""),N([]),L([]),Me().catch(p=>A(p.message))};return window.addEventListener("defectrag-auth-change",t),()=>window.removeEventListener("defectrag-auth-change",t)},[n.id]),a.useEffect(()=>{g.current&&g.current!==(s==null?void 0:s.id)&&(w(""),Ee(""),l(""),u(""),W("Normal")),g.current=s==null?void 0:s.id,le(!1)},[s==null?void 0:s.id]),a.useEffect(()=>{le(!1)},[$==null?void 0:$.id]),a.useEffect(()=>{let t=!0;const p=ae?ae.split(","):[];if(f!=="authorized"||!p.length){o([]);return}return O().then(y=>y.from("staff_notes").select("id,inspection_id,author_id,body,created_at").in("inspection_id",p).like("body",ut+"%").order("created_at").limit(2e3)).then(({data:y,error:Z})=>{if(t){if(Z)throw Z;o(y||[])}}).catch(()=>{t&&o([])}),()=>{t=!1}},[f,ae,qe]),a.useEffect(()=>{f==="authorized"&&Be(G.current)},[f,s==null?void 0:s.id,$==null?void 0:$.id]);function Ye(){ke(""),Se((c==null?void 0:c.state)||""),Ae((c==null?void 0:c.owner_id)||""),ce((c==null?void 0:c.supervisor_id)||""),ve(""),Te((c==null?void 0:c.version)??null)}a.useEffect(Ye,[c==null?void 0:c.id]),a.useEffect(()=>{c&&Be(U.current)},[c==null?void 0:c.id]),a.useEffect(()=>{let t=!0;const p=_.current;if(!c||f!=="authorized"){Y.current=null,N([]),L([]);return}return Y.current!==c.id&&(Y.current=c.id,N([]),L([])),O().then(y=>Promise.all([y.from("corrective_action_history").select("*").eq("case_id",c.id).order("version"),y.from("corrective_action_events").select("id,case_id,version,kind,status,attempts,last_error,created_at").eq("case_id",c.id).order("created_at",{ascending:!1})])).then(y=>{if(!(!t||p!==_.current)){if(y.some(Z=>Z.error))throw y.find(Z=>Z.error).error;N(y[0].data||[]),L(y[1].data||[])}}).catch(y=>{t&&p===_.current&&A(y.message)}),()=>{t=!1}},[c==null?void 0:c.id,c==null?void 0:c.version,qe,n.id,f]);async function We(t){if(!I.current){I.current=!0,J(!0),A("");try{await t(),await Me(),Re()}catch(p){A(p.message||"Corrective action request failed.")}finally{I.current=!1,J(!1)}}}const Ne=t=>{var p;return((p=H.find(y=>y.user_id===t))==null?void 0:p.display_name)||"Former / unavailable staff"};return e.createElement("section",{className:"card case-workspace",ref:G,tabIndex:-1,"aria-label":"Corrective Actions workspace"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,"Corrective Actions"),e.createElement("p",null,"Fix confirmed defects. Say who fixes each one, and by when.")),e.createElement("button",{className:"secondary",disabled:S,onClick:()=>We(Me)},"Refresh cases")),fe&&e.createElement("div",{className:"error",role:"alert"},Ue(fe)),f==="checking"&&e.createElement("p",{role:"status"},"Checking your access…"),f!=="checking"&&f!=="authorized"&&e.createElement("p",{className:"note"},"Sign in on the Staff workspace page and enter your security code. Then come back here."),f==="authorized"&&e.createElement(e.Fragment,null,e.createElement("div",{className:"case-stats",role:"group","aria-label":"Case summary"},e.createElement("div",null,e.createElement("b",null,ie.open),e.createElement("span",null,"Open")),e.createElement("div",{className:ie.overdue?"late":""},e.createElement("b",null,ie.overdue),e.createElement("span",null,"Overdue")),e.createElement("div",null,e.createElement("b",null,ie.resolved),e.createElement("span",null,"Done")),e.createElement("div",null,e.createElement("b",null,ie.averageResolutionHours===null?"–":ie.averageResolutionHours.toFixed(1)+" h"),e.createElement("span",null,"Average time to fix"))),e.createElement("h3",null,"Create a new case"),e.createElement("ol",{className:"stepper","aria-label":"Steps to create a case"},["Pick an inspection","Save a defect review","Assign the fix"].map((t,p)=>{const y=s?C.ready||C.existingCaseId?3:2:1;return e.createElement("li",{key:t,className:p+1<y?"done":p+1===y?"now":"","aria-current":p+1===y?"step":void 0},e.createElement("b",null,p+1<y?"✓":p+1),t)})),v&&e.createElement("label",{className:"field"},"Team inspection",e.createElement("select",{value:(s==null?void 0:s.id)||"",disabled:S||D,onChange:t=>v(t.target.value)},e.createElement("option",{value:""},"Pick an inspection"),re.map(({row:t,status:p})=>{var y;return e.createElement("option",{key:t.id,value:t.id},at((y=t.payload)==null?void 0:y.category)," · ",new Date(t.created_at).toLocaleString()," · ",t.id.slice(0,8)," — ",p.label)}))),v&&B.length>0&&e.createElement("p",{className:"caption"},pe?`${pe} inspection${pe>1?"s are":" is"} ready, listed first.`:"None are ready yet. A case needs a saved defect review."),v&&!B.length&&e.createElement("p",{className:"note"},"No Team inspections yet. Open a personal inspection and choose “Share with team”."),e.createElement("div",{className:"case-step "+(C.ready?"ready":"blocked")},e.createElement("strong",null,C.ready?"Ready to assign":s?C.existingCaseId?"This inspection already has a case":C.needsReview?"Step 2: save a defect review":"Not available yet":"Step 1: pick an inspection"),e.createElement("p",{id:"case-creation-guidance",role:"status"},C.reason),s&&!s.archived_at&&!D&&e.createElement("button",{type:"button",className:C.needsReview?"primary":"secondary",disabled:S,onClick:()=>z==null?void 0:z(s.id)},C.needsReview?"Open the review":"Open photo and review"),C.existingCaseId&&e.createElement("button",{type:"button",className:"secondary",onClick:()=>h(C.existingCaseId)},"Open existing case")),e.createElement("p",{className:"caption"},"You can fill this in now. Nothing is saved until you press “Create corrective action”."),!H.length&&e.createElement("p",{className:"note"},"No active Staff to assign. Press Refresh cases, or ask the administrator."),e.createElement("form",{className:"login-form","data-tour":"case","aria-label":"Assign corrective action","aria-describedby":"case-creation-guidance case-submit-guidance",onSubmit:t=>{if(t.preventDefault(),!(r||S||I.current))return We(async()=>{const p=await O(),y=await Qe(p,"defectrag_create_corrective_action",{p_inspection:s.id,p_review:C.review.id,p_confirmed:V,p_owner:P,p_supervisor:K,p_priority:b,p_description:me,p_due:new Date(ne).toISOString()});h(y),w(""),le(!1)})}},e.createElement("label",{className:"field"},"What needs fixing?",e.createElement("textarea",{disabled:S,required:!0,minLength:10,maxLength:2e3,value:me,onInput:t=>w(t.target.value),onChange:t=>w(t.target.value)})),e.createElement("label",{className:"field"},"Person responsible",e.createElement("select",{disabled:S,required:!0,value:P,onChange:t=>Ee(t.target.value)},e.createElement("option",{value:""},"Choose a person"),H.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Supervisor",e.createElement("select",{disabled:S,required:!0,value:K,onChange:t=>l(t.target.value)},e.createElement("option",{value:""},"Choose a person"),H.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Priority",e.createElement("select",{disabled:S,value:b,onChange:t=>W(t.target.value)},["Low","Normal","High","Critical"].map(t=>e.createElement("option",{key:t},t)))),et({legend:"Due date and time",prefix:"Due ",value:ne,time:R,setValue:u,setTime:ye,disabled:S,required:!0}),e.createElement("p",{className:"note"},"When email is switched on, saving a case emails the supervisor and copies the person responsible. See “Email delivery” in the case details."),e.createElement("label",{className:"consent-check"+(C.ready?"":" locked")},e.createElement("input",{type:"checkbox",disabled:S||!C.ready,checked:V,onChange:t=>le(t.target.checked)}),e.createElement("span",null,"I confirm Staff found a real defect that needs fixing.",!C.ready&&e.createElement("small",null,"Finish steps 1 and 2 first."))),e.createElement("p",{className:"note",id:"case-submit-guidance",role:"status"},r?"Not ready: "+r:"All set. Press the button to save."),e.createElement("button",{className:"primary",disabled:S||!!r},"Create corrective action")),e.createElement("div",{className:"section-title section-gap"},e.createElement("h3",null,"Saved cases"),T.length>0&&e.createElement("div",{className:"segmented case-filter",role:"group","aria-label":"Show cases"},te.map(([t,p,y])=>e.createElement("button",{type:"button",key:t,className:x===t?"on":"","aria-pressed":x===t,onClick:()=>ge(t)},p," ",e.createElement("span",{className:"count"},T.filter(y).length))))),e.createElement("div",{className:"table-wrap","data-tour":c?void 0:"case-update"},e.createElement("table",{className:"stackable"},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Case"),e.createElement("th",null,"Status"),e.createElement("th",null,"Owner"),e.createElement("th",null,"Priority"),e.createElement("th",null,"Due"),e.createElement("th",null))),e.createElement("tbody",null,be.map(t=>e.createElement("tr",{key:t.id,className:t.id===de?"selected-row":void 0},e.createElement("td",{"data-label":"Case"},t.id.slice(0,8)),e.createElement("td",{"data-label":"Status"},e.createElement("span",{className:"case-state "+t.state.toLowerCase().replace(/\s+/g,"-")},t.state),X(t)&&e.createElement("span",{className:"case-state overdue"},"Overdue")),e.createElement("td",{"data-label":"Owner"},Ne(t.owner_id)),e.createElement("td",{"data-label":"Priority"},e.createElement("span",{className:"priority "+String(t.priority||"").toLowerCase()},t.priority||"Normal")),e.createElement("td",{"data-label":"Due"},ze(t.due_at)),e.createElement("td",{className:"row-action"},e.createElement("button",{className:"text-button","aria-label":"Details for case "+t.id.slice(0,8),onClick:()=>h(t.id)},"Details")))))),T.length?!be.length&&e.createElement("p",{className:"caption"},"No cases in this group. Choose All to see every case."):e.createElement("p",{className:"caption"},"No cases yet.")),c&&e.createElement("div",{className:"cloud-message","data-tour":"case-update",ref:U,tabIndex:-1,"aria-label":"Corrective action case details"},e.createElement("div",{className:"section-title"},e.createElement("h3",null,"Case ",c.id.slice(0,8)," · ",c.state),e.createElement("button",{className:"text-button",onClick:()=>h("")},"Close details")),e.createElement("p",null,c.description),e.createElement("p",null,"Person responsible: ",Ne(c.owner_id)," · Supervisor: ",Ne(c.supervisor_id)," · Due: ",ze(c.due_at)),e.createElement("p",null,"Confirmed by: ",Ne(c.confirmed_by)),e.createElement("button",{className:"secondary",onClick:()=>z(c.inspection_id)},"Open photo and review"),Oe(c.state).length>0&&!oe&&e.createElement("p",{className:"note"},"Only the person responsible, the supervisor or a Developer can update this case."),!Oe(c.state).length&&e.createElement("p",{className:"note"},"This case is ",c.state.toLowerCase(),". You can read it but not change it."),we&&oe&&e.createElement("p",{className:"note",role:"status"},"Someone changed this case while you were typing. Your text is kept but not saved. Copy it, then load the latest case. ",e.createElement("button",{className:"secondary",disabled:S,onClick:()=>{Ye(),A("")}},"Load latest case and replace draft")),Oe(c.state).length>0&&oe&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),We(async()=>{if(we)throw new Error("The case changed. Load the latest case before saving.");const p=await O(),y=await Qe(p,"defectrag_update_corrective_action",{p_id:c.id,p_version:_e,p_state:ee,p_note:xe,p_owner:Ce,p_supervisor:Fe,p_due:ue?new Date(ue).toISOString():null});Te(y),ke(""),ve("")})}},e.createElement("label",{className:"field"},"Case status",e.createElement("select",{disabled:S||we,value:ee,onChange:t=>Se(t.target.value)},Oe(c.state).map(t=>e.createElement("option",{key:t},t)))),e.createElement("label",{className:"field"},"Person responsible",e.createElement("select",{disabled:S||we,required:!0,value:Ce,onChange:t=>Ae(t.target.value)},e.createElement("option",{value:""},"Choose a person"),H.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),e.createElement("label",{className:"field"},"Supervisor",e.createElement("select",{disabled:S||we,required:!0,value:Fe,onChange:t=>ce(t.target.value)},e.createElement("option",{value:""},"Choose a person"),H.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),et({legend:"New deadline (optional)",prefix:"New due ",value:ue,time:De,setValue:ve,setTime:Q,disabled:S||we,keep:"The deadline stays: "+lt(Qt(c.due_at))+"."}),e.createElement("label",{className:"field"},"What changed or was fixed?",e.createElement("textarea",{disabled:S,required:!0,minLength:3,maxLength:2e3,value:xe,onInput:t=>ke(t.target.value),onChange:t=>ke(t.target.value)})),e.createElement("button",{className:"primary",disabled:S||!ee||we},"Save case update")),e.createElement("h3",null,"Status history"),se.map(t=>e.createElement("p",{key:t.id},e.createElement("strong",null,t.state)," · ",Ne(t.actor_id)," · ",ze(t.created_at),e.createElement("br",null),t.note,t.snapshot&&e.createElement("small",null,e.createElement("br",null),"Owner: ",Ne(t.snapshot.owner_id)," · Supervisor: ",Ne(t.snapshot.supervisor_id)," · Due: ",ze(t.snapshot.due_at)))),e.createElement("h3",null,"Email delivery"),e.createElement("p",{className:"caption"},"Emails go to the supervisor, with a copy to the person responsible. If one fails, tell the administrator. The case stays saved either way."),!q.length&&e.createElement("p",{className:"caption"},"No emails recorded for this case yet."),q.map(t=>e.createElement("p",{key:t.id},rt(t.kind)," · ",st(t.status)," · attempts ",t.attempts,t.last_error?" · "+Ue(t.last_error):"")))))}function Zt({client:n,user:s,onChange:m}){var K;const[i,D]=a.useState(null),[v,z]=a.useState([]),[_,I]=a.useState([]),[g,U]=a.useState(null),[G,Y]=a.useState(""),[f,M]=a.useState(""),[T,j]=a.useState(""),[H,E]=a.useState(""),[de,h]=a.useState(""),[se,N]=a.useState(""),[q,L]=a.useState(!1),[fe,A]=a.useState([]),[S,J]=a.useState([]),me=((K=window.DEFECTRAG_PUBLIC_CONFIG)==null?void 0:K.registrationEnabled)===!0;async function w(){if(!s){D(null),A([]),J([]);return}const l=await ht(n);D(l);const{data:b,error:W}=await n.auth.mfa.listFactors();if(W)throw W;const ne=(b.totp||[]).filter(u=>u.status==="verified");if(z(ne),I((b.all||[]).filter(u=>u.factor_type==="totp"&&u.status==="unverified")),M(u=>{var R;return ne.some(ye=>ye.id===u)?u:((R=ne[0])==null?void 0:R.id)||""}),l.role==="developer"&&l.approved&&l.aal2){const[u,R]=await Promise.all([n.rpc("defectrag_access_directory"),n.rpc("defectrag_notification_status")]);if(u.error)throw u.error;if(R.error)throw R.error;A(u.data||[]),J(R.data||[])}else A([]),J([])}async function P(l){L(!0),N("");try{await l()}catch(b){N(b.message||"Security request failed.")}finally{L(!1)}}a.useEffect(()=>{let l=!0;return U(null),Y(""),A([]),J([]),n&&s?w().catch(b=>{l&&N(b.message)}):D(null),()=>{l=!1}},[n,s==null?void 0:s.id]);async function Ee(){await gt(n,(g==null?void 0:g.id)||f,G),Y(""),U(null),await w(),m(),N("Security code verified. Staff access is available only after the account is approved.")}return e.createElement("div",{className:"section-gap"},s&&e.createElement("h3",null,"Sign-in and account security"),se&&e.createElement("p",{className:"note",role:"status"},Ue(se)),s?e.createElement(e.Fragment,null,e.createElement("p",null,"Access: ",e.createElement("strong",null,i!=null&&i.revoked?"revoked":i!=null&&i.approved?"approved":(i==null?void 0:i.request_status)||"not requested")," · Authenticator: ",e.createElement("strong",null,i!=null&&i.aal2?"security code verified":"enter security code")),e.createElement("button",{className:"secondary",disabled:q,onClick:()=>P(w)},"Refresh account status"),i&&!i.approved&&!i.revoked&&!i.request_status&&e.createElement("form",{className:"login-form",onSubmit:l=>{l.preventDefault(),P(async()=>{await Et(n,T),await w(),N("Request sent. Check back here for Developer approval. Team and private Staff work are not available while the request is waiting."),m()})}},e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:T,maxLength:80,onChange:l=>j(l.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:q||!i.registration_enabled||!i.email_verified},"Request staff access")),e.createElement("p",{className:"caption"},"Use an authenticator app for the extra six-digit sign-in code. Keep access to that app. If it is lost, contact the workspace administrator; resetting the password does not remove this security check."),!g&&!v.length&&!_.length&&e.createElement("button",{className:"secondary",disabled:q,onClick:()=>P(async()=>U(await yt(n)))},"Set up a security code app"),!g&&_.map(l=>e.createElement("p",{key:l.id,className:"caption"},"Authenticator setup was not finished. ",e.createElement("button",{className:"text-button",disabled:q,onClick:()=>P(async()=>{const{error:b}=await n.auth.mfa.unenroll({factorId:l.id});if(b)throw b;await w()})},"Cancel incomplete setup"))),g&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("p",null,"Open an authenticator app, scan this private QR code, then enter the six-digit code below to finish. Do not share the QR code or security codes."),e.createElement("img",{src:g.totp.qr_code,width:"200",height:"200",alt:"Private authenticator enrollment QR code"}),e.createElement("button",{className:"text-button",disabled:q,onClick:()=>P(async()=>{const{error:l}=await n.auth.mfa.unenroll({factorId:g.id});if(l)throw l;U(null),Y("")})},"Cancel incomplete setup"))),!g&&v.length>0&&(i==null?void 0:i.aal2)&&e.createElement("p",{className:"caption"},"The security code is verified for this sign-in."),(g||v.length>0&&!(i!=null&&i.aal2))&&e.createElement("form",{className:"login-form",onSubmit:l=>{l.preventDefault(),P(Ee)}},!g&&e.createElement("label",{className:"field"},"Security code app",e.createElement("select",{value:f,onChange:l=>M(l.target.value)},v.map(l=>e.createElement("option",{key:l.id,value:l.id},l.friendly_name||"Authenticator")))),e.createElement("label",{className:"field"},"Six-digit security code",e.createElement("input",{inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,value:G,onChange:l=>Y(l.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:q},"Verify security code")),(i==null?void 0:i.role)==="developer"&&i.approved&&i.aal2&&e.createElement(e.Fragment,null,e.createElement("h3",{className:"section-gap"},"Staff access management"),e.createElement("p",null,"Approve or reject requests that are still waiting. Removing access stops new Staff actions but keeps inspection history."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Account"),e.createElement("th",null,"Status"),e.createElement("th",null,"Role"),e.createElement("th",null,"Action"))),e.createElement("tbody",null,fe.map(l=>e.createElement("tr",{key:l.user_id},e.createElement("td",null,l.display_name,e.createElement("br",null),e.createElement("small",null,l.email)),e.createElement("td",null,l.status),e.createElement("td",null,l.role||"applicant"),e.createElement("td",null,l.user_id!==s.id&&(l.status==="pending"?["approve","reject"]:l.status==="approved"?["revoke"]:[]).map(b=>e.createElement("button",{key:b,className:"text-button",disabled:q,onClick:()=>{window.confirm(`${b[0].toUpperCase()+b.slice(1)} access for ${l.display_name}?`)&&P(async()=>{await vt(n,l,b),await w(),m(),N("Account access updated. Check Email delivery below separately; saving this change does not confirm an email was sent.")})}},{approve:"Approve",reject:"Reject",revoke:"Remove access"}[b])))))))),e.createElement("h3",{className:"section-gap"},"Email delivery"),e.createElement("p",{className:"caption"},"Waiting emails have not been sent. Delivery depends on administrator settings and the email service being available. Sent means the email service accepted the message; it may still reach Spam or fail to arrive."),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Event"),e.createElement("th",null,"Delivery"),e.createElement("th",null,"Attempts"),e.createElement("th",null))),e.createElement("tbody",null,S.map(l=>e.createElement("tr",{key:l.id},e.createElement("td",null,rt(l.kind)),e.createElement("td",null,st(l.status)),e.createElement("td",null,l.attempts),e.createElement("td",null,l.status==="dead"&&e.createElement("button",{className:"text-button",disabled:q,onClick:()=>P(async()=>{const{error:b}=await n.rpc("defectrag_retry_notification",{p_id:l.id});if(b)throw b;await w()})},"Retry delivery"))))))))):me?e.createElement("details",{className:"register-panel"},e.createElement("summary",null,"New to Staff work? Create an account"),e.createElement("form",{className:"login-form",onSubmit:l=>{l.preventDefault(),P(async()=>{await ft(n,{email:H,password:de,displayName:T,redirectTo:location.origin+location.pathname}),h(""),N("Check the inbox and Spam folder for a confirmation email. Open its link, sign in, then choose Request staff access. A Developer must approve the request before Staff work is available.")})}},e.createElement("p",null,"New to Staff work? Create an account, confirm the email, then request access. The public demo can be used without an account."),e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:T,onChange:l=>j(l.target.value),maxLength:80,autoComplete:"name",required:!0})),e.createElement("label",{className:"field"},"Email",e.createElement("input",{type:"email",value:H,onChange:l=>E(l.target.value),autoComplete:"email",required:!0})),e.createElement("label",{className:"field"},"New password",e.createElement("input",{type:"password",minLength:12,value:de,onChange:l=>h(l.target.value),autoComplete:"new-password",required:!0})),e.createElement("button",{className:"secondary",disabled:q||!n},"Register account"))):e.createElement("p",{className:"caption"},"New account registration is currently closed. Existing Staff can sign in below. The public demo is still available."))}function Vt({onOpenInspection:n,onOpenCorrectiveActions:s,onChooseInspection:m,casesView:i=!1,initialInspectionId:D=null}){var Ie;const v=a.useRef(0),z=a.useRef(null),_=a.useRef(0),I=a.useRef(null),g=a.useRef(0),U=a.useRef(null),G=a.useRef(null),[Y,f]=a.useState(0),[M,T]=a.useState(!1),[j,H]=a.useState({state:"refreshing"}),[E,de]=a.useState(null),[h,se]=a.useState(null),[N,q]=a.useState([]),[L,fe]=a.useState({}),[A,S]=a.useState(""),[J,me]=a.useState(""),[w,P]=a.useState(!1),[Ee,K]=a.useState(""),[l,b]=a.useState(""),[W,ne]=a.useState(!1),[u,R]=a.useState(null),[ye,V]=a.useState([]),[le,ee]=a.useState([]),[Se,xe]=a.useState(""),[ke,_e]=a.useState(!1),[Te,qe]=a.useState(""),[He,Ce]=a.useState(!1),[Ae,Fe]=a.useState(null),ce=bt(),ue=wt(window.DEFECTRAG_PUBLIC_CONFIG);a.useEffect(()=>()=>{ye.filter(r=>r.startsWith("blob:")).forEach(r=>URL.revokeObjectURL(r))},[ye]),a.useEffect(()=>{I.current=u},[u]),a.useEffect(()=>{u&&Be(U.current)},[Y]),a.useEffect(()=>{if(!E||!h||!D)return;const r=E.id+":"+D;G.current!==r&&(G.current=r,$({id:D},{focus:!i}))},[E==null?void 0:E.id,h==null?void 0:h.user_id,D]);const ve=Nt(),De=ce&&Ae&&(!i||!h)?e.createElement(Zt,{key:(E==null?void 0:E.id)||"anonymous",client:Ae,user:E,onChange:()=>{Re(),E&&Q(c)}}):null;async function Q(r){P(!0),K(""),b("");try{await r()}catch(d){K(d.message||"Team request failed.")}finally{P(!1)}}async function c(){var F;const r=++_.current,d=v.current,o=(F=I.current)==null?void 0:F.id,{client:x,staff:ge}=await xt();let k=x.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);k=W?k.not("archived_at","is",null):k.is("archived_at",null);const[{data:X,error:te},{data:be,error:B},ae]=await Promise.all([k,x.from("staff_members").select("*"),o?x.from("staff_notes").select("*").eq("inspection_id",o).order("created_at"):{data:[]}]);if(te)throw te;if(B)throw B;if(ae.error)throw ae.error;if(r===_.current&&(se(ge),K(""),q(X||[]),fe(Object.fromEntries((be||[]).map(re=>[re.user_id,re.display_name]))),o&&d===v.current)){const re=(X||[]).find(pe=>pe.id===o);if(!re)v.current++,R(null),V([]),ee([]);else if(R(re),ee(ae.data||[]),!ce&&Date.now()-g.current>480*1e3){const pe=await Promise.all([re.image_path,re.heatmap_path].map(oe=>x.storage.from("team-inspections").createSignedUrl(oe,900)));if(r===_.current&&d===v.current){if(pe.some(oe=>oe.error))throw new Error("Shared image links could not refresh.");V(pe.map(oe=>oe.data.signedUrl)),g.current=Date.now()}}}}a.useEffect(()=>{if(!ve)return;let r=!1,d;return O().then(async o=>{!r&&ce&&Fe(o),d=o.auth.onAuthStateChange((ge,k)=>{var X;if(!r){const te=((X=k==null?void 0:k.user)==null?void 0:X.id)||null;z.current!==te&&(v.current++,_.current++,R(null),q([]),V([]),ee([]),se(null),z.current=te),de((k==null?void 0:k.user)||null),ge==="PASSWORD_RECOVERY"&&_e(!0)}}).data.subscription;const{data:x}=await o.auth.getUser();r||de(x.user)}).catch(o=>{r||K(o.message)}),()=>{r=!0,v.current++,d==null||d.unsubscribe()}},[ve]),a.useEffect(()=>{if(!E)return;const r=tt(c,{onState:d=>{H(d),d.error&&(K(d.error),ce&&(v.current++,q([]),fe({}),R(null),V([]),ee([]),se(null)))}});return()=>{r.stop(),_.current++}},[E==null?void 0:E.id,W]);async function $(r,{focus:d=!0}={}){const o=++v.current;T(!0);try{await Q(async()=>{if(o!==v.current)return;const x=await O(),ge=x.storage.from("team-inspections"),[{data:k,error:X},{data:te,error:be}]=await Promise.all([x.from("shared_inspections").select("*").eq("id",r.id).single(),x.from("staff_notes").select("*").eq("inspection_id",r.id).order("created_at")]);if(o!==v.current)return;if(X)throw X;if(be)throw be;const B=ce?await St(x,k):null,ae=B?B.map(F=>({data:{signedUrl:F}})):await Promise.all([k.image_path,k.heatmap_path].map(F=>ge.createSignedUrl(F,900)));if(ae.some(F=>F.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");if(o!==v.current){B==null||B.forEach(F=>URL.revokeObjectURL(F));return}I.current=k,g.current=Date.now(),R(k),V(ae.map(F=>F.data.signedUrl)),ee(te||[]),d&&f(F=>F+1)})}finally{o===v.current&&T(!1)}}function ie(){v.current++,I.current=null,T(!1),R(null),V([]),ee([])}async function C(){await Q(async()=>{const r=await O(),d=N.filter(o=>o.owner_id===E.id).map(o=>o.id);if(d.length){const{error:o}=await r.rpc("archive_team_inspections",{p_ids:d});if(o)throw o}v.current++,R(null),Ce(!1),await c(),Re()})}return ve?e.createElement(e.Fragment,null,e.createElement("section",{className:"card"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",null,e.createElement($t,{size:21})," ",i?"Corrective Actions access":"Staff workspace"),e.createElement("p",null,h?"Inspections your team has shared. New inspections stay private until you share them.":"Sign in to review inspections your team has shared.")),e.createElement("span",{className:"subtle-tag"},e.createElement($e,{size:13})," STAFF ACCESS")),Ee&&e.createElement("div",{className:"error",role:"alert"},Ue(Ee)),l&&e.createElement("div",{className:"success",role:"status"},e.createElement("span",null,l)),M&&e.createElement("p",{role:"status"},"Opening the shared photo and review…"),i&&!ue&&e.createElement("p",{className:"note"},"Corrective Actions has been turned off for this app. Inspections and reviews are still available. Contact the workspace administrator if needed."),E&&!h&&De,E?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(_t,{size:18}),e.createElement("strong",null,(h==null?void 0:h.display_name)||E.email),e.createElement("span",{className:"subtle-tag"},(h==null?void 0:h.role)||"CHECKING ACCESS")),e.createElement("button",{className:"secondary",disabled:w,onClick:()=>Q(c)},e.createElement(Ut,{size:16})," Refresh"),!i&&h&&ue&&e.createElement("button",{className:"secondary",onClick:()=>s==null?void 0:s()},"Open Corrective Actions"),i&&h&&e.createElement("button",{className:"secondary",onClick:()=>m==null?void 0:m()},"Choose a Team inspection"),e.createElement("button",{className:"secondary",onClick:()=>Q(async()=>{await(await O()).auth.signOut(),q([]),R(null),se(null)})},e.createElement(Ot,{size:16})," Sign out")),ke&&e.createElement("form",{className:"login-form",onSubmit:r=>{r.preventDefault(),Q(async()=>{const d=await O(),{error:o}=await d.auth.updateUser({password:Te});if(o)throw o;qe(""),_e(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:Te,onChange:r=>qe(r.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:w},"Save password")),!i&&e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("span",{role:"status"},N.length," shared inspections · ",j.state==="synced"?"updated "+new Date(j.at).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):j.state==="offline"?"offline; shown results may be out of date":j.state==="stale"?"update failed; shown results may be out of date":"refreshing…"),(h==null?void 0:h.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{ne(!W),R(null)}},e.createElement(qt,{size:16}),W?"Active history":"Restore archived team work"),!W&&e.createElement("button",{className:"secondary danger",disabled:w||!N.some(r=>r.owner_id===E.id),onClick:()=>Ce(!0)},e.createElement(Ct,{size:16})," Archive my shared inspections")),He&&e.createElement("div",{className:"note"},e.createElement("div",null,e.createElement("strong",null,"Archive your visible records?"),e.createElement("p",null,"They will leave the shared active history. Original files and conversations remain recoverable by a developer. Other staff members’ records will stay active."),e.createElement("div",{className:"button-row"},e.createElement("button",{className:"primary",disabled:w,onClick:C},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>Ce(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",{className:"stackable"},e.createElement("thead",null,e.createElement("tr",null,e.createElement("th",null,"Inspection"),e.createElement("th",null,"Product"),e.createElement("th",null,"Result"),e.createElement("th",null,"Shared by"),e.createElement("th",null,"Saved"),e.createElement("th",null))),e.createElement("tbody",null,N.map(r=>{var d;return e.createElement("tr",{key:r.id},e.createElement("td",{"data-label":"Inspection"},e.createElement("strong",null,r.id.slice(0,8))),e.createElement("td",{"data-label":"Product"},at(r.payload.category)),e.createElement("td",{"data-label":"Result"},e.createElement("span",{className:"badge "+((d=r.payload.verdict)==null?void 0:d.toLowerCase())},Xe(r.payload.verdict))),e.createElement("td",{"data-label":"Shared by"},L[r.owner_id]||"Staff member"),e.createElement("td",{"data-label":"Saved"},new Date(r.created_at).toLocaleString()),e.createElement("td",{className:"row-action"},e.createElement("button",{className:"text-button",disabled:w,onClick:()=>$(r)},"Review"),W&&(h==null?void 0:h.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:w,onClick:()=>Q(async()=>{const o=await O(),{error:x}=await o.rpc("restore_team_inspections",{p_ids:[r.id]});if(x)throw x;await c(),Re()})},"Restore")))}))),!N.length&&e.createElement("div",{className:"empty"},e.createElement($e,{size:30}),e.createElement("p",null,W?"No archived records to recover.":"No shared inspections yet. Open an inspection result and select Share with team."))))):e.createElement(e.Fragment,null,e.createElement("h3",{className:"section-gap"},"Sign in"),e.createElement("form",{className:"login-form",onSubmit:r=>{r.preventDefault(),Q(async()=>{const d=await O(),{error:o}=await d.auth.signInWithPassword({email:A,password:J});if(o)throw o;me("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:A,onChange:r=>S(r.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:J,onChange:r=>me(r.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:w},w?e.createElement(kt,{className:"spin",size:17}):e.createElement(It,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!A||w,onClick:()=>Q(async()=>{const r=await O(),{error:d}=await r.auth.resetPasswordForEmail(A,{redirectTo:location.origin+location.pathname});if(d)throw d;b("Password reset email requested. Check the inbox and the Spam folder.")})},"Reset password"),e.createElement("p",{className:"caption"},ce?"A new account needs Developer approval before Staff work is available. Approved Staff must also enter their security code when asked.":"The workspace administrator must approve an account before it can access Staff work.")),De),E&&h&&De&&e.createElement("details",{className:"account-panel section-gap"},e.createElement("summary",null,"Account & security"),De)),i&&E&&h&&ue&&e.createElement(Xt,{key:E.id,user:E,inspection:u,notes:le,inspections:N,inspectionLoading:M,onSelectInspection:r=>r?$({id:r},{focus:!1}):ie(),onEvidence:r=>$({id:r})}),E&&u&&e.createElement("section",{className:"card",ref:U,tabIndex:-1,"aria-labelledby":"shared-inspection-title"},e.createElement("div",{className:"section-title"},e.createElement("div",null,e.createElement("h2",{id:"shared-inspection-title"},"Shared inspection · ",u.id.slice(0,8)),e.createElement("p",null,"Shared by ",L[u.owner_id]||"a colleague",". These are saved results. Nothing is checked again.")),e.createElement("div",{className:"button-row"},n&&!u.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>n(u)},"Open full result and assistant"),!i&&ue&&!u.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>s==null?void 0:s(u)},"Create or view corrective actions"),e.createElement("button",{className:"text-button",onClick:ie},"Close"))),e.createElement("div",{className:"shared-images"},ye.map((r,d)=>e.createElement("img",{key:r,src:r,alt:d?"Saved highlighted areas":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED RESULT"),e.createElement("span",null,Xe(u.payload.verdict)," · score ",Number(u.payload.score).toFixed(5)," · review limit ",Number(u.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Saved assistant conversation"),(Ie=u.conversation)!=null&&Ie.length?u.conversation.map((r,d)=>e.createElement("p",{className:"cloud-message",key:d},e.createElement("strong",null,r.role==="user"?"Inspector":"Evidence Assistant",": "),r.question||r.answer)):e.createElement("p",{className:"caption"},"No assistant conversation was shared with this inspection."),!u.archived_at&&e.createElement(Dt,{key:u.id+String(le.length),current:le.map(r=>Ze(r,L)).filter(Boolean).at(-1),disabled:w,onSave:async r=>{const d=await O(),{error:o}=await d.from("staff_notes").insert({inspection_id:u.id,author_id:E.id,body:Rt(r.status,r.decision,r.note)});if(o)throw o;await $(u,{focus:!i}),Re()}}),e.createElement("h3",{className:"section-gap"},"Team notes"),le.filter(r=>!Ze(r,L)).map(r=>e.createElement("div",{className:"cloud-message",key:r.id},e.createElement("strong",null,L[r.author_id]||"Staff member"),e.createElement("p",null,r.body),e.createElement("small",null,new Date(r.created_at).toLocaleString()))),!u.archived_at&&e.createElement("form",{className:"question-form",onSubmit:r=>{r.preventDefault(),Q(async()=>{const d=await O(),{error:o}=await d.from("staff_notes").insert({inspection_id:u.id,author_id:E.id,body:Se.trim()});if(o)throw o;xe(""),await $(u),Re()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a note for the team…",value:Se,onChange:r=>xe(r.target.value)}),e.createElement("button",{className:"primary",disabled:w||!Se.trim()},e.createElement(Ht,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement($e,{size:32})),e.createElement("span",{className:"eyebrow"},"TEAM WORKSPACE"),e.createElement("h2",null,"Team workspace is not available yet."),e.createElement("p",null,"The workspace administrator needs to connect shared storage before Staff can sign in here."),e.createElement("div",{className:"setup-grid"},[["01","Connect shared storage","The workspace administrator completes this setup."],["02","Set up staff access","The administrator sets up approval and account security."],["03","Connect this dashboard","The administrator connects the app, then Staff can sign in."]].map(([r,d,o])=>e.createElement("div",{key:r},e.createElement("b",null,r),e.createElement("h3",null,d),e.createElement("p",null,o)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Administrator setup ",e.createElement(Pt,{size:16})),e.createElement("p",{className:"caption"},"Contact the workspace administrator for help. The public demo can be used without Staff access."))}export{Vt as default};
frontend/dist/assets/index-CaZty-YY.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/index.html CHANGED
@@ -1,3 +1,3 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)"/><meta name="theme-color" content="#0a0a0a" media="(prefers-color-scheme: dark)"/><script>try{var t=localStorage.getItem("defectrag-theme");if(t==="dark"||(t!=="light"&&matchMedia("(prefers-color-scheme: dark)").matches))document.documentElement.classList.add("dark")}catch(e){}</script><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-CvTX_vc1.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-C5YNZGyQ.css">
3
  </head><body><div id="root"></div></body></html>
 
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)"/><meta name="theme-color" content="#0a0a0a" media="(prefers-color-scheme: dark)"/><script>try{var t=localStorage.getItem("defectrag-theme");if(t==="dark"||(t!=="light"&&matchMedia("(prefers-color-scheme: dark)").matches))document.documentElement.classList.add("dark")}catch(e){}</script><meta name="description" content="Local visual anomaly inspection with traceable evidence."/><title>DefectRAG · Inspection intelligence</title><link rel="icon" type="image/svg+xml" href="./logo.svg"><script src="./config.js"></script> <script type="module" crossorigin src="./assets/index-CaZty-YY.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-C5YNZGyQ.css">
3
  </head><body><div id="root"></div></body></html>