Wizzas commited on
Commit
287b587
·
verified ·
1 Parent(s): 2a199e6

Update verified React dashboard

Browse files
Files changed (28) hide show
  1. frontend/dist/assets/TeamWorkspace-CPunnPl_.js +41 -0
  2. frontend/dist/assets/email/robot-hello.gif +0 -0
  3. frontend/dist/assets/index-CsdyyyVC.js +0 -0
  4. frontend/dist/assets/sample-thumbs/candle_anomalous.jpg +0 -0
  5. frontend/dist/assets/sample-thumbs/candle_good.jpg +0 -0
  6. frontend/dist/assets/sample-thumbs/capsules_anomalous.jpg +0 -0
  7. frontend/dist/assets/sample-thumbs/capsules_good.jpg +0 -0
  8. frontend/dist/assets/sample-thumbs/cashew_anomalous.jpg +0 -0
  9. frontend/dist/assets/sample-thumbs/cashew_good.jpg +0 -0
  10. frontend/dist/assets/sample-thumbs/chewinggum_anomalous.jpg +0 -0
  11. frontend/dist/assets/sample-thumbs/chewinggum_good.jpg +0 -0
  12. frontend/dist/assets/sample-thumbs/fryum_anomalous.jpg +0 -0
  13. frontend/dist/assets/sample-thumbs/fryum_good.jpg +0 -0
  14. frontend/dist/assets/sample-thumbs/macaroni1_anomalous.jpg +0 -0
  15. frontend/dist/assets/sample-thumbs/macaroni1_good.jpg +0 -0
  16. frontend/dist/assets/sample-thumbs/macaroni2_anomalous.jpg +0 -0
  17. frontend/dist/assets/sample-thumbs/macaroni2_good.jpg +0 -0
  18. frontend/dist/assets/sample-thumbs/pcb1_anomalous.jpg +0 -0
  19. frontend/dist/assets/sample-thumbs/pcb1_good.jpg +0 -0
  20. frontend/dist/assets/sample-thumbs/pcb2_anomalous.jpg +0 -0
  21. frontend/dist/assets/sample-thumbs/pcb2_good.jpg +0 -0
  22. frontend/dist/assets/sample-thumbs/pcb3_anomalous.jpg +0 -0
  23. frontend/dist/assets/sample-thumbs/pcb3_good.jpg +0 -0
  24. frontend/dist/assets/sample-thumbs/pcb4_anomalous.jpg +0 -0
  25. frontend/dist/assets/sample-thumbs/pcb4_good.jpg +0 -0
  26. frontend/dist/assets/sample-thumbs/pipe_fryum_anomalous.jpg +0 -0
  27. frontend/dist/assets/sample-thumbs/pipe_fryum_good.jpg +0 -0
  28. frontend/dist/index.html +1 -1
frontend/dist/assets/TeamWorkspace-CPunnPl_.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{c as he,r as a,l as Ve,a as et,b as tt,d as at,e as rt,s as Ke,f as z,R as nt,g as Me,h as e,i as Oe,p as Qe,n as Pe,j as Ye,k as Xe,m as st,w as Ne,o as ze,q as lt,t as ct,u as it,v as ot,x as dt,y as ut,z as mt,A as pt,B as ft,C as je,L as ht,S as Et,D as vt,E as We,F as yt,G as gt,H as He,I as bt}from"./index-CsdyyyVC.js";/**
2
+ * @license lucide-react v0.468.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 wt=he("ArchiveRestore",[["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"}]]);/**
7
+ * @license lucide-react v0.468.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 Fe=he("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
12
+ * @license lucide-react v0.468.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 St=he("ExternalLink",[["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"}]]);/**
17
+ * @license lucide-react v0.468.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 kt=he("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
22
+ * @license lucide-react v0.468.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 Nt=he("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
27
+ * @license lucide-react v0.468.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 _t=he("RefreshCw",[["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"}]]);/**
32
+ * @license lucide-react v0.468.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 Ct=he("Send",[["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"}]]);/**
37
+ * @license lucide-react v0.468.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 Dt=he("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]),Ue="17:00",Rt=[{label:"Tomorrow",days:1},{label:"In 3 days",days:3},{label:"In 1 week",days:7},{label:"In 2 weeks",days:14}],xe=l=>String(l).padStart(2,"0"),Ie=l=>l.getFullYear()+"-"+xe(l.getMonth()+1)+"-"+xe(l.getDate());function Be(l,s=new Date){const u=new Date(s);return u.setDate(u.getDate()+l),Ie(u)}const Ge=(l,s)=>l?l+"T"+(s||Ue):"",Tt=l=>({date:l?l.slice(0,10):"",time:l?l.slice(11,16):""}),Ze=l=>{const[s,u]=l.split(":").map(Number);return(s%12||12)+":"+xe(u)+" "+(s<12?"AM":"PM")};function xt(l){const s=[];for(let u=420;u<=1200;u+=30)s.push(xe(Math.floor(u/60))+":"+xe(u%60));return l&&/^\d\d:\d\d$/.test(l)&&!s.includes(l)&&s.push(l),s.sort()}function Lt(l,s=new Date){const u=Math.round((new Date(l.slice(0,10)+"T00:00")-new Date(Ie(s)+"T00:00"))/864e5);return u===0?"today":u===1?"tomorrow":u>1?"in "+u+" days":u===-1?"yesterday":Math.abs(u)+" days ago"}function Je(l,s=new Date){if(!l||!Number.isFinite(Date.parse(l)))return"";const u=new Date(l.slice(0,10)+"T00:00"),i=T=>u.toLocaleDateString("en-GB",T);return i({weekday:"long"})+", "+u.getDate()+" "+i({month:"short"})+" "+u.getFullYear()+" at "+Ze(l.slice(11,16))+" · "+Lt(l,s)}const At=l=>{const s=new Date(l);return Ie(s)+"T"+String(s.getHours()).padStart(2,"0")+":"+String(s.getMinutes()).padStart(2,"0")};function $e({legend:l,prefix:s,value:u,time:i,setValue:T,setTime:y,disabled:j,required:_,keep:F}){const g=Tt(u),W=g.time||i,K=f=>T(Ge(f,W)),C=f=>{y(f),g.date&&T(Ge(g.date,f))};return e.createElement("fieldset",{className:"due-field"},e.createElement("legend",null,l),e.createElement("div",{className:"due-shortcuts",role:"group","aria-label":l+" shortcuts"},F&&e.createElement("button",{type:"button",className:"chip"+(u?"":" selected"),"aria-pressed":!u,disabled:j,onClick:()=>T("")},"Keep current"),Rt.map(f=>{const A=Be(f.days);return e.createElement("button",{type:"button",key:f.days,className:"chip"+(g.date===A?" selected":""),"aria-pressed":g.date===A,disabled:j,onClick:()=>K(A)},f.label)})),e.createElement("div",{className:"due-inputs"},e.createElement("label",{className:"field"},s,"date",e.createElement("input",{type:"date",disabled:j,required:_,min:Ie(new Date),max:Be(365),value:g.date,onInput:f=>K(f.target.value),onChange:f=>K(f.target.value)})),e.createElement("label",{className:"field"},s,"time",e.createElement("select",{disabled:j,value:W,onChange:f=>C(f.target.value)},xt(W).map(f=>e.createElement("option",{key:f,value:f},Ze(f)))))),e.createElement("p",{className:"caption due-summary","aria-live":"polite"},u?e.createElement(e.Fragment,null,"Due ",e.createElement("strong",null,Je(u))):F||"Pick a shortcut or a date. The time starts at 5:00 PM."))}function qt({user:l,inspection:s,notes:u=[],inspections:i=[],inspectionLoading:T=!1,onSelectInspection:y,onEvidence:j}){const _=a.useRef(0),F=a.useRef(!1),g=a.useRef(s==null?void 0:s.id),W=a.useRef(null),K=a.useRef(null),[C,f]=a.useState("checking"),[A,H]=a.useState([]),[q,ne]=a.useState([]),[m,B]=a.useState(""),[E,G]=a.useState([]),[P,k]=a.useState([]),[J,Q]=a.useState(""),[v,Se]=a.useState(!1),[V,oe]=a.useState(""),[w,M]=a.useState(""),[me,Y]=a.useState(""),[n,S]=a.useState("Normal"),[p,O]=a.useState(""),[L,I]=a.useState(Ue),[se,ee]=a.useState(!1),[Ee,_e]=a.useState(""),[Le,ve]=a.useState(""),[ke,Ce]=a.useState(null),[Ae,De]=a.useState(0),[Re,qe]=a.useState(""),[de,ye]=a.useState(""),[ge,pe]=a.useState(""),[X,be]=a.useState(Ue),c=A.find(t=>t.id===m),ue=Ve(u),we=et(A),x=tt(s,u,A,T),r=at({description:V,owner:w,supervisor:me,priority:n,due:p},q),o=x.ready?r||(se?"":"Confirm that the saved Staff review identifies a defect before creating the case."):x.reason,[d,D]=a.useState([]),le=i.filter(t=>!t.archived_at),N=le.map(t=>t.id).join(","),ce=t=>st(t.id===(s==null?void 0:s.id)?u:d.filter(h=>h.inspection_id===t.id),A),ie=le.map(t=>({row:t,status:ce(t)})).sort((t,h)=>(h.status.key==="ready")-(t.status.key==="ready")),fe=ie.filter(t=>t.status.key==="ready").length,Z=rt(c,l.id,q.some(t=>t.user_id===l.id&&t.role==="developer")),$=!!c&&ke!==null&&ke!==c.version;async function R(){const t=++_.current,h=await z(),b=await h.rpc("defectrag_ca_staff");if(t!==_.current)return;if(b.error||b.data!==!0)throw f("denied"),H([]),ne([]),B(""),G([]),k([]),new Error("Sign in with an approved Staff account and verify the security code before opening corrective actions.");const re=await Promise.all([h.from("corrective_actions").select("*").order("created_at",{ascending:!1}).limit(500),h.from("staff_members").select("user_id,display_name,role,revoked_at").is("revoked_at",null)]);if(t===_.current){if(re.some(Te=>Te.error))throw f("unavailable"),H([]),ne([]),B(""),G([]),k([]),re.find(Te=>Te.error).error;f("authorized"),H(re[0].data||[]),ne(re[1].data||[]),Q(""),De(Te=>Te+1)}}a.useEffect(()=>{const t=Ke(R,{onState:h=>{h.error&&(f("unavailable"),Q(h.error),H([]),ne([]),B(""),G([]),k([]))}});return()=>{t.stop(),_.current++}},[l.id]),a.useEffect(()=>{const t=()=>{_.current++,f("checking"),H([]),ne([]),B(""),G([]),k([]),R().catch(h=>Q(h.message))};return window.addEventListener("defectrag-auth-change",t),()=>window.removeEventListener("defectrag-auth-change",t)},[l.id]),a.useEffect(()=>{g.current&&g.current!==(s==null?void 0:s.id)&&(oe(""),M(""),Y(""),O(""),S("Normal")),g.current=s==null?void 0:s.id,ee(!1)},[s==null?void 0:s.id]),a.useEffect(()=>{ee(!1)},[ue==null?void 0:ue.id]),a.useEffect(()=>{let t=!0;const h=N?N.split(","):[];if(C!=="authorized"||!h.length){D([]);return}return z().then(b=>b.from("staff_notes").select("id,inspection_id,author_id,body,created_at").in("inspection_id",h).like("body",nt+"%").order("created_at").limit(2e3)).then(({data:b,error:re})=>{if(t){if(re)throw re;D(b||[])}}).catch(()=>{t&&D([])}),()=>{t=!1}},[C,N,Ae]),a.useEffect(()=>{C==="authorized"&&Me(K.current)},[C,s==null?void 0:s.id,ue==null?void 0:ue.id]);function te(){ve(""),_e((c==null?void 0:c.state)||""),qe((c==null?void 0:c.owner_id)||""),ye((c==null?void 0:c.supervisor_id)||""),pe(""),Ce((c==null?void 0:c.version)??null)}a.useEffect(te,[c==null?void 0:c.id]),a.useEffect(()=>{c&&Me(W.current)},[c==null?void 0:c.id]),a.useEffect(()=>{let t=!0;const h=_.current;if(G([]),k([]),!(!c||C!=="authorized"))return z().then(b=>Promise.all([b.from("corrective_action_history").select("*").eq("case_id",c.id).order("version"),b.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(b=>{if(!(!t||h!==_.current)){if(b.some(re=>re.error))throw b.find(re=>re.error).error;G(b[0].data||[]),k(b[1].data||[])}}).catch(b=>{t&&h===_.current&&Q(b.message)}),()=>{t=!1}},[c==null?void 0:c.id,c==null?void 0:c.version,Ae,l.id,C]);async function ae(t){if(!F.current){F.current=!0,Se(!0),Q("");try{await t(),await R(),Ne()}catch(h){Q(h.message||"Corrective action request failed.")}finally{F.current=!1,Se(!1)}}}const U=t=>{var h;return((h=q.find(b=>b.user_id===t))==null?void 0:h.display_name)||"Former / unavailable staff"};return e.createElement("section",{className:"card case-workspace",ref:K,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,"Track work needed after a Staff review confirms a defect. Assign someone to fix it, set a due date, and keep a record of progress.")),e.createElement("button",{className:"secondary",disabled:v,onClick:()=>ae(R)},"Refresh cases")),J&&e.createElement("div",{className:"error",role:"alert"},Oe(J)),C==="checking"&&e.createElement("p",{role:"status"},"Checking Staff access and the security code…"),C!=="checking"&&C!=="authorized"&&e.createElement("p",{className:"note"},"Open Staff workspace to check account approval and enter the security code. Then return here and try again."),C==="authorized"&&e.createElement(e.Fragment,null,e.createElement("p",{className:"caption"},"Showing up to 500 cases available to this account. Open: ",we.open," · Resolved / closed: ",we.resolved," · Overdue: ",we.overdue," · Average resolution: ",we.averageResolutionHours===null?"No resolved cases":we.averageResolutionHours.toFixed(1)+" hours",". Email delivery is separate from whether the case has been saved."),e.createElement("h3",null,"Create and assign a case"),e.createElement("p",{className:"caption"},"1. Choose a Team inspection. 2. Save its defect review. 3. Assign the work and deadline."),y&&e.createElement("label",{className:"field"},"Team inspection",e.createElement("select",{value:(s==null?void 0:s.id)||"",disabled:v||T,onChange:t=>y(t.target.value)},e.createElement("option",{value:""},"Choose a shared product inspection"),ie.map(({row:t,status:h})=>{var b;return e.createElement("option",{key:t.id,value:t.id},Qe((b=t.payload)==null?void 0:b.category)," · ",new Date(t.created_at).toLocaleString()," · ",t.id.slice(0,8)," — ",h.label)}))),y&&le.length>0&&e.createElement("p",{className:"caption"},fe?`${fe} inspection${fe>1?"s are":" is"} ready, listed first.`:"No inspection is ready yet. A case needs a saved review of Reviewed with “Reject: defect confirmed”."),y&&!le.length&&e.createElement("p",{className:"note"},"No active Team inspections are available. Open a saved Personal inspection and choose Share with team before creating a case."),e.createElement("div",{className:"case-step "+(x.ready?"ready":"blocked")},e.createElement("strong",null,x.ready?"Ready to assign":s?x.existingCaseId?"This inspection already has a case":x.needsReview?"Step 2 needed: confirm the defect in a Staff review":"Not available yet":"Step 1: choose a Team inspection"),e.createElement("p",{id:"case-creation-guidance",role:"status"},x.reason),s&&!s.archived_at&&!T&&e.createElement("button",{type:"button",className:x.needsReview?"primary":"secondary",disabled:v,onClick:()=>j==null?void 0:j(s.id)},x.needsReview?"Open this inspection’s review":"Open photo and Staff review"),x.existingCaseId&&e.createElement("button",{type:"button",className:"secondary",onClick:()=>B(x.existingCaseId)},"Open existing case")),e.createElement("p",{className:"caption"},"Assignment fields can be filled in as a draft. Nothing is saved or emailed until Create corrective action succeeds. Unsaved drafts stay on this page. Reloading, signing out or losing verified access can discard them."),!q.length&&e.createElement("p",{className:"note"},"No active Staff are available for assignment. Refresh cases or contact the workspace administrator. No account permissions will be changed here."),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(),!(o||v||F.current))return ae(async()=>{const h=await z(),b=await ze(h,"defectrag_create_corrective_action",{p_inspection:s.id,p_review:x.review.id,p_confirmed:se,p_owner:w,p_supervisor:me,p_priority:n,p_description:V,p_due:new Date(p).toISOString()});B(b),oe(""),ee(!1)})}},e.createElement("label",{className:"field"},"What needs fixing?",e.createElement("textarea",{disabled:v,required:!0,minLength:10,maxLength:2e3,value:V,onInput:t=>oe(t.target.value),onChange:t=>oe(t.target.value)})),e.createElement("label",{className:"field"},"Person responsible",e.createElement("select",{disabled:v,required:!0,value:w,onChange:t=>M(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),q.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:v,required:!0,value:me,onChange:t=>Y(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),q.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:v,value:n,onChange:t=>S(t.target.value)},["Low","Normal","High","Critical"].map(t=>e.createElement("option",{key:t},t)))),$e({legend:"Due date and time",prefix:"Due ",value:p,time:L,setValue:O,setTime:I,disabled:v,required:!0}),e.createElement("p",{className:"caption"},"Times use this device’s time zone. Choose a future deadline within the next year. The deadline is saved with the case."),e.createElement("p",{className:"note"},"Email reminders require administrator activation. Saving this case does not send an email by itself. The current n8n workflow targets the supervisor; it does not yet email the person responsible automatically. Confirm delivery with the supervisor separately."),e.createElement("label",{className:"consent-check"+(x.ready?"":" locked")},e.createElement("input",{type:"checkbox",disabled:v||!x.ready,checked:se,onChange:t=>ee(t.target.checked)}),e.createElement("span",null,"A Staff review has confirmed a defect that needs fixing. An unusual inspection result alone is not enough.",!x.ready&&e.createElement("small",null," Available after the review step above is complete."))),e.createElement("p",{className:"note",id:"case-submit-guidance",role:"status"},o?"Cannot create yet: "+o:"Ready to save the assignment. No email is sent by this button."),e.createElement("button",{className:"primary",disabled:v||!!o},"Create corrective action")),e.createElement("h3",{className:"section-gap"},"Saved cases"),e.createElement("div",{className:"table-wrap","data-tour":c?void 0:"case-update"},e.createElement("table",null,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,A.map(t=>e.createElement("tr",{key:t.id},e.createElement("td",null,t.id.slice(0,8)),e.createElement("td",null,t.state,!["Resolved","Closed","Cancelled"].includes(t.state)&&Date.parse(t.due_at)<Date.now()?" · Overdue":""),e.createElement("td",null,U(t.owner_id)),e.createElement("td",null,t.priority),e.createElement("td",null,new Date(t.due_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",onClick:()=>B(t.id)},"Details")))))),!A.length&&e.createElement("p",{className:"caption"},"No cases are available to this account yet.")),c&&e.createElement("div",{className:"cloud-message","data-tour":"case-update",ref:W,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:()=>B("")},"Close details")),e.createElement("p",null,c.description),e.createElement("p",null,"Person responsible: ",U(c.owner_id)," · Supervisor: ",U(c.supervisor_id)," · Due: ",new Date(c.due_at).toLocaleString()),e.createElement("p",null,"Confirmed by: ",U(c.confirmed_by)),e.createElement("button",{className:"secondary",onClick:()=>j(c.inspection_id)},"Open the linked photo and review"),Pe(c.state).length>0&&!Z&&e.createElement("p",{className:"note"},"Only the person responsible, the supervisor or a Developer can change this case after verifying their security code. Other Staff can read it."),!Pe(c.state).length&&e.createElement("p",{className:"note"},"This case is ",c.state.toLowerCase(),". Its saved assignment and history are available to read; further updates are not permitted."),$&&Z&&e.createElement("p",{className:"note",role:"status"},"This case changed while the update was being drafted. The draft has been kept; it has not been saved. Copy any text needed before loading the latest case. ",e.createElement("button",{className:"secondary",disabled:v,onClick:()=>{te(),Q("")}},"Load latest case and replace draft")),Pe(c.state).length>0&&Z&&e.createElement("form",{className:"login-form",onSubmit:t=>{t.preventDefault(),ae(async()=>{if($)throw new Error("The case changed. Load the latest case before saving.");const h=await z(),b=await ze(h,"defectrag_update_corrective_action",{p_id:c.id,p_version:ke,p_state:Ee,p_note:Le,p_owner:Re,p_supervisor:de,p_due:ge?new Date(ge).toISOString():null});Ce(b),ve(""),pe("")})}},e.createElement("label",{className:"field"},"Case status",e.createElement("select",{disabled:v||$,value:Ee,onChange:t=>_e(t.target.value)},Pe(c.state).map(t=>e.createElement("option",{key:t},t)))),e.createElement("label",{className:"field"},"Owner",e.createElement("select",{disabled:v||$,required:!0,value:Re,onChange:t=>qe(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),q.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:v||$,required:!0,value:de,onChange:t=>ye(t.target.value)},e.createElement("option",{value:""},"Choose active staff"),q.map(t=>e.createElement("option",{key:t.user_id,value:t.user_id},t.display_name)))),$e({legend:"Change due date and time (optional)",prefix:"New due ",value:ge,time:X,setValue:pe,setTime:be,disabled:v||$,keep:"The current due date stays: "+Je(At(c.due_at))+"."}),e.createElement("label",{className:"field"},"What changed or was fixed?",e.createElement("textarea",{disabled:v,required:!0,minLength:3,maxLength:2e3,value:Le,onInput:t=>ve(t.target.value),onChange:t=>ve(t.target.value)})),e.createElement("button",{className:"primary",disabled:v||!Ee||$},"Save case update")),e.createElement("h3",null,"Status history"),E.map(t=>e.createElement("p",{key:t.id},e.createElement("strong",null,t.state)," · ",U(t.actor_id)," · ",new Date(t.created_at).toLocaleString(),e.createElement("br",null),t.note,t.snapshot&&e.createElement("small",null,e.createElement("br",null),"Owner: ",U(t.snapshot.owner_id)," · Supervisor: ",U(t.snapshot.supervisor_id)," · Due: ",new Date(t.snapshot.due_at).toLocaleString()))),e.createElement("h3",null,"Email delivery"),e.createElement("p",{className:"caption"},"Waiting emails have not been sent. If delivery fails or is uncertain, contact the workspace administrator. The case stays saved even when the email service is unavailable."),P.map(t=>e.createElement("p",{key:t.id},Ye(t.kind)," · ",Xe(t.status)," · attempts ",t.attempts,t.last_error?" · "+Oe(t.last_error):"")))))}function Pt({client:l,user:s,onChange:u}){var Y;const[i,T]=a.useState(null),[y,j]=a.useState([]),[_,F]=a.useState([]),[g,W]=a.useState(null),[K,C]=a.useState(""),[f,A]=a.useState(""),[H,q]=a.useState(""),[ne,m]=a.useState(""),[B,E]=a.useState(""),[G,P]=a.useState(""),[k,J]=a.useState(!1),[Q,v]=a.useState([]),[Se,V]=a.useState([]),oe=((Y=window.DEFECTRAG_PUBLIC_CONFIG)==null?void 0:Y.registrationEnabled)===!0;async function w(){if(!s){T(null),v([]),V([]);return}const n=await lt(l);T(n);const{data:S,error:p}=await l.auth.mfa.listFactors();if(p)throw p;const O=(S.totp||[]).filter(L=>L.status==="verified");if(j(O),F((S.all||[]).filter(L=>L.factor_type==="totp"&&L.status==="unverified")),A(L=>{var I;return O.some(se=>se.id===L)?L:((I=O[0])==null?void 0:I.id)||""}),n.role==="developer"&&n.approved&&n.aal2){const[L,I]=await Promise.all([l.rpc("defectrag_access_directory"),l.rpc("defectrag_notification_status")]);if(L.error)throw L.error;if(I.error)throw I.error;v(L.data||[]),V(I.data||[])}else v([]),V([])}async function M(n){J(!0),P("");try{await n()}catch(S){P(S.message||"Security request failed.")}finally{J(!1)}}a.useEffect(()=>{let n=!0;return W(null),C(""),v([]),V([]),l&&s?w().catch(S=>{n&&P(S.message)}):T(null),()=>{n=!1}},[l,s==null?void 0:s.id]);async function me(){await ut(l,(g==null?void 0:g.id)||f,K),C(""),W(null),await w(),u(),P("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"),G&&e.createElement("p",{className:"note",role:"status"},Oe(G)),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:k,onClick:()=>M(w)},"Refresh account status"),i&&!i.approved&&!i.revoked&&!i.request_status&&e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),M(async()=>{await it(l,H),await w(),P("Request sent. Check back here for Developer approval. Team and private Staff work are not available while the request is waiting."),u()})}},e.createElement("label",{className:"field"},"Display name",e.createElement("input",{value:H,maxLength:80,onChange:n=>q(n.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:k||!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&&!y.length&&!_.length&&e.createElement("button",{className:"secondary",disabled:k,onClick:()=>M(async()=>W(await ot(l)))},"Set up a security code app"),!g&&_.map(n=>e.createElement("p",{key:n.id,className:"caption"},"Authenticator setup was not finished. ",e.createElement("button",{className:"text-button",disabled:k,onClick:()=>M(async()=>{const{error:S}=await l.auth.mfa.unenroll({factorId:n.id});if(S)throw S;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:k,onClick:()=>M(async()=>{const{error:n}=await l.auth.mfa.unenroll({factorId:g.id});if(n)throw n;W(null),C("")})},"Cancel incomplete setup"))),!g&&y.length>0&&(i==null?void 0:i.aal2)&&e.createElement("p",{className:"caption"},"The security code is verified for this sign-in."),(g||y.length>0&&!(i!=null&&i.aal2))&&e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),M(me)}},!g&&e.createElement("label",{className:"field"},"Security code app",e.createElement("select",{value:f,onChange:n=>A(n.target.value)},y.map(n=>e.createElement("option",{key:n.id,value:n.id},n.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:K,onChange:n=>C(n.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:k},"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,Q.map(n=>e.createElement("tr",{key:n.user_id},e.createElement("td",null,n.display_name,e.createElement("br",null),e.createElement("small",null,n.email)),e.createElement("td",null,n.status),e.createElement("td",null,n.role||"applicant"),e.createElement("td",null,n.user_id!==s.id&&(n.status==="pending"?["approve","reject"]:n.status==="approved"?["revoke"]:[]).map(S=>e.createElement("button",{key:S,className:"text-button",disabled:k,onClick:()=>{window.confirm(`${S[0].toUpperCase()+S.slice(1)} access for ${n.display_name}?`)&&M(async()=>{await dt(l,n,S),await w(),u(),P("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"}[S])))))))),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,Se.map(n=>e.createElement("tr",{key:n.id},e.createElement("td",null,Ye(n.kind)),e.createElement("td",null,Xe(n.status)),e.createElement("td",null,n.attempts),e.createElement("td",null,n.status==="dead"&&e.createElement("button",{className:"text-button",disabled:k,onClick:()=>M(async()=>{const{error:S}=await l.rpc("defectrag_retry_notification",{p_id:n.id});if(S)throw S;await w()})},"Retry delivery"))))))))):oe?e.createElement("details",{className:"register-panel"},e.createElement("summary",null,"New to Staff work? Create an account"),e.createElement("form",{className:"login-form",onSubmit:n=>{n.preventDefault(),M(async()=>{await ct(l,{email:ne,password:B,displayName:H,redirectTo:location.origin+location.pathname}),E(""),P("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:H,onChange:n=>q(n.target.value),maxLength:80,autoComplete:"name",required:!0})),e.createElement("label",{className:"field"},"Email",e.createElement("input",{type:"email",value:ne,onChange:n=>m(n.target.value),autoComplete:"email",required:!0})),e.createElement("label",{className:"field"},"New password",e.createElement("input",{type:"password",minLength:12,value:B,onChange:n=>E(n.target.value),autoComplete:"new-password",required:!0})),e.createElement("button",{className:"secondary",disabled:k||!l},"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 It({onOpenInspection:l,onOpenCorrectiveActions:s,onChooseInspection:u,casesView:i=!1,initialInspectionId:T=null}){var x;const y=a.useRef(0),j=a.useRef(null),_=a.useRef(0),F=a.useRef(null),g=a.useRef(0),W=a.useRef(null),K=a.useRef(null),[C,f]=a.useState(0),[A,H]=a.useState(!1),[q,ne]=a.useState({state:"refreshing"}),[m,B]=a.useState(null),[E,G]=a.useState(null),[P,k]=a.useState([]),[J,Q]=a.useState({}),[v,Se]=a.useState(""),[V,oe]=a.useState(""),[w,M]=a.useState(!1),[me,Y]=a.useState(""),[n,S]=a.useState(!1),[p,O]=a.useState(null),[L,I]=a.useState([]),[se,ee]=a.useState([]),[Ee,_e]=a.useState(""),[Le,ve]=a.useState(!1),[ke,Ce]=a.useState(""),[Ae,De]=a.useState(!1),[Re,qe]=a.useState(null),de=mt(),ye=pt(window.DEFECTRAG_PUBLIC_CONFIG);a.useEffect(()=>()=>{L.filter(r=>r.startsWith("blob:")).forEach(r=>URL.revokeObjectURL(r))},[L]),a.useEffect(()=>{F.current=p},[p]),a.useEffect(()=>{p&&Me(W.current)},[C]),a.useEffect(()=>{if(!m||!E||!T)return;const r=m.id+":"+T;K.current!==r&&(K.current=r,c({id:T},{focus:!i}))},[m==null?void 0:m.id,E==null?void 0:E.user_id,T]);const ge=ft(),pe=de&&Re&&(!i||!E)?e.createElement(Pt,{key:(m==null?void 0:m.id)||"anonymous",client:Re,user:m,onChange:()=>{Ne(),m&&X(be)}}):null;async function X(r){M(!0),Y("");try{await r()}catch(o){Y(o.message||"Team request failed.")}finally{M(!1)}}async function be(){var R;const r=++_.current,o=y.current,d=(R=F.current)==null?void 0:R.id,{client:D,staff:le}=await bt();let N=D.from("shared_inspections").select("*").order("created_at",{ascending:!1}).limit(200);N=n?N.not("archived_at","is",null):N.is("archived_at",null);const[{data:ce,error:ie},{data:fe,error:Z},$]=await Promise.all([N,D.from("staff_members").select("*"),d?D.from("staff_notes").select("*").eq("inspection_id",d).order("created_at"):{data:[]}]);if(ie)throw ie;if(Z)throw Z;if($.error)throw $.error;if(r===_.current&&(G(le),Y(""),k(ce||[]),Q(Object.fromEntries((fe||[]).map(te=>[te.user_id,te.display_name]))),d&&o===y.current)){const te=(ce||[]).find(ae=>ae.id===d);if(!te)y.current++,O(null),I([]),ee([]);else if(O(te),ee($.data||[]),Date.now()-g.current>480*1e3)if(de){const ae=await je(D,te);r===_.current&&o===y.current?(I(ae),g.current=Date.now()):ae.forEach(U=>URL.revokeObjectURL(U))}else{const ae=await Promise.all([te.image_path,te.heatmap_path].map(U=>D.storage.from("team-inspections").createSignedUrl(U,900)));if(r===_.current&&o===y.current){if(ae.some(U=>U.error))throw new Error("Shared image links could not refresh.");I(ae.map(U=>U.data.signedUrl)),g.current=Date.now()}}}}a.useEffect(()=>{if(!ge)return;let r=!1,o;return z().then(async d=>{!r&&de&&qe(d),o=d.auth.onAuthStateChange((le,N)=>{var ce;if(!r){const ie=((ce=N==null?void 0:N.user)==null?void 0:ce.id)||null;j.current!==ie&&(y.current++,_.current++,O(null),k([]),I([]),ee([]),G(null),j.current=ie),B((N==null?void 0:N.user)||null),le==="PASSWORD_RECOVERY"&&ve(!0)}}).data.subscription;const{data:D}=await d.auth.getUser();r||B(D.user)}).catch(d=>{r||Y(d.message)}),()=>{r=!0,y.current++,o==null||o.unsubscribe()}},[ge]),a.useEffect(()=>{if(!m)return;const r=Ke(be,{onState:o=>{ne(o),o.error&&(Y(o.error),de&&(y.current++,k([]),Q({}),O(null),I([]),ee([]),G(null)))}});return()=>{r.stop(),_.current++}},[m==null?void 0:m.id,n]);async function c(r,{focus:o=!0}={}){const d=++y.current;H(!0);try{await X(async()=>{if(d!==y.current)return;const D=await z(),le=D.storage.from("team-inspections"),[{data:N,error:ce},{data:ie,error:fe}]=await Promise.all([D.from("shared_inspections").select("*").eq("id",r.id).single(),D.from("staff_notes").select("*").eq("inspection_id",r.id).order("created_at")]);if(d!==y.current)return;if(ce)throw ce;if(fe)throw fe;const Z=de?await je(D,N):null,$=Z?Z.map(R=>({data:{signedUrl:R}})):await Promise.all([N.image_path,N.heatmap_path].map(R=>le.createSignedUrl(R,900)));if($.some(R=>R.error))throw new Error("Private images could not be loaded. Check staff/storage policies.");if(d!==y.current){Z==null||Z.forEach(R=>URL.revokeObjectURL(R));return}F.current=N,g.current=Date.now(),O(N),I($.map(R=>R.data.signedUrl)),ee(ie||[]),o&&f(R=>R+1)})}finally{d===y.current&&H(!1)}}function ue(){y.current++,F.current=null,H(!1),O(null),I([]),ee([])}async function we(){await X(async()=>{const r=await z(),o=P.filter(d=>d.owner_id===m.id).map(d=>d.id);if(o.length){const{error:d}=await r.rpc("archive_team_inspections",{p_ids:o});if(d)throw d}y.current++,O(null),De(!1),await be(),Ne()})}return ge?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(Dt,{size:21})," ",i?"Corrective Actions access":"Staff workspace"),e.createElement("p",null,E?"This account can access shared Team work. New inspections start in Personal Workspace and are shared only when chosen.":"Sign in to review inspections shared with the team. New inspections start in Personal Workspace and are shared only when chosen.")),e.createElement("span",{className:"subtle-tag"},e.createElement(Fe,{size:13})," STAFF ACCESS")),me&&e.createElement("div",{className:"error",role:"alert"},Oe(me)),A&&e.createElement("p",{role:"status"},"Opening the shared photo and review…"),i&&!ye&&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."),m&&!E&&pe,m?e.createElement(e.Fragment,null,e.createElement("div",{className:"team-toolbar"},e.createElement("div",null,e.createElement(Et,{size:18}),e.createElement("strong",null,(E==null?void 0:E.display_name)||m.email),e.createElement("span",{className:"subtle-tag"},(E==null?void 0:E.role)||"CHECKING ACCESS")),e.createElement("button",{className:"secondary",disabled:w,onClick:()=>X(be)},e.createElement(_t,{size:16})," Refresh"),!i&&E&&ye&&e.createElement("button",{className:"secondary",onClick:()=>s==null?void 0:s()},"Open Corrective Actions"),i&&E&&e.createElement("button",{className:"secondary",onClick:()=>u==null?void 0:u()},"Choose a Team inspection"),e.createElement("button",{className:"secondary",onClick:()=>X(async()=>{await(await z()).auth.signOut(),k([]),O(null),G(null)})},e.createElement(Nt,{size:16})," Sign out")),Le&&e.createElement("form",{className:"login-form",onSubmit:r=>{r.preventDefault(),X(async()=>{const o=await z(),{error:d}=await o.auth.updateUser({password:ke});if(d)throw d;Ce(""),ve(!1)})}},e.createElement("label",{className:"field"},"Set a new password",e.createElement("input",{type:"password",minLength:12,autoComplete:"new-password",value:ke,onChange:r=>Ce(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"},"Team Workspace · latest ",P.length," shared inspections · ",q.state==="synced"?"updated at "+new Date(q.at).toLocaleTimeString():q.state==="offline"?"offline; shown results may be out of date":q.state==="stale"?"update failed; shown results may be out of date":"refreshing…"," · checks for changes every 15 seconds"),(E==null?void 0:E.role)==="developer"&&e.createElement("button",{className:"secondary",onClick:()=>{S(!n),O(null)}},e.createElement(wt,{size:16}),n?"Active history":"Restore archived team work"),!n&&e.createElement("button",{className:"secondary danger",disabled:w||!P.some(r=>r.owner_id===m.id),onClick:()=>De(!0)},e.createElement(vt,{size:16})," Archive my shared inspections")),Ae&&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:we},"Archive my records"),e.createElement("button",{className:"secondary",onClick:()=>De(!1)},"Cancel")))),e.createElement("div",{className:"table-wrap"},e.createElement("table",null,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,P.map(r=>{var o;return e.createElement("tr",{key:r.id},e.createElement("td",null,e.createElement("strong",null,r.id.slice(0,8))),e.createElement("td",null,Qe(r.payload.category)),e.createElement("td",null,e.createElement("span",{className:"badge "+((o=r.payload.verdict)==null?void 0:o.toLowerCase())},We(r.payload.verdict))),e.createElement("td",null,J[r.owner_id]||"Staff member"),e.createElement("td",null,new Date(r.created_at).toLocaleString()),e.createElement("td",null,e.createElement("button",{className:"text-button",disabled:w,onClick:()=>c(r)},"Review"),n&&(E==null?void 0:E.role)==="developer"&&e.createElement("button",{className:"text-button",disabled:w,onClick:()=>X(async()=>{const d=await z(),{error:D}=await d.rpc("restore_team_inspections",{p_ids:[r.id]});if(D)throw D;await be(),Ne()})},"Restore")))}))),!P.length&&e.createElement("div",{className:"empty"},e.createElement(Fe,{size:30}),e.createElement("p",null,n?"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(),X(async()=>{const o=await z(),{error:d}=await o.auth.signInWithPassword({email:v,password:V});if(d)throw d;oe("")})}},e.createElement("label",{className:"field"},"Work email",e.createElement("input",{type:"email",autoComplete:"username",value:v,onChange:r=>Se(r.target.value),required:!0})),e.createElement("label",{className:"field"},"Password",e.createElement("input",{type:"password",autoComplete:"current-password",value:V,onChange:r=>oe(r.target.value),required:!0})),e.createElement("button",{className:"primary",disabled:w},w?e.createElement(ht,{className:"spin",size:17}):e.createElement(kt,{size:17})," Sign in"),e.createElement("button",{type:"button",className:"text-button",disabled:!v||w,onClick:()=>X(async()=>{const r=await z(),{error:o}=await r.auth.resetPasswordForEmail(v,{redirectTo:location.origin+location.pathname});if(o)throw o;Y("Password reset requested. Check the inbox and Spam folder.")})},"Reset password"),e.createElement("p",{className:"caption"},de?"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.")),pe),m&&E&&pe&&e.createElement("details",{className:"account-panel section-gap"},e.createElement("summary",null,"Account & security"),pe)),i&&m&&E&&ye&&e.createElement(qt,{key:m.id,user:m,inspection:p,notes:se,inspections:P,inspectionLoading:A,onSelectInspection:r=>r?c({id:r},{focus:!1}):ue(),onEvidence:r=>c({id:r})}),m&&p&&e.createElement("section",{className:"card",ref:W,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 · ",p.id.slice(0,8)),e.createElement("p",null,"Shared copy from ",J[p.owner_id]||"a colleague",". These are saved results. Opening them does not run another inspection.")),e.createElement("div",{className:"button-row"},l&&!p.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>l(p)},"Open full result and assistant"),!i&&ye&&!p.archived_at&&e.createElement("button",{className:"secondary",onClick:()=>s==null?void 0:s(p)},"Create or view corrective actions"),e.createElement("button",{className:"text-button",onClick:ue},"Close"))),e.createElement("div",{className:"shared-images"},L.map((r,o)=>e.createElement("img",{key:r,src:r,alt:o?"Saved highlighted areas":"Saved inspected product"}))),e.createElement("div",{className:"observation"},e.createElement("strong",null,"SAVED RESULT"),e.createElement("span",null,We(p.payload.verdict)," · score ",Number(p.payload.score).toFixed(5)," · review limit ",Number(p.payload.threshold).toFixed(5))),e.createElement("h3",{className:"section-gap"},"Saved assistant conversation"),(x=p.conversation)!=null&&x.length?p.conversation.map((r,o)=>e.createElement("p",{className:"cloud-message",key:o},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."),!p.archived_at&&e.createElement(yt,{key:p.id+String(se.length),current:se.map(r=>He(r,J)).filter(Boolean).at(-1),disabled:w,onSave:async r=>{const o=await z(),{error:d}=await o.from("staff_notes").insert({inspection_id:p.id,author_id:m.id,body:gt(r.status,r.decision,r.note)});if(d)throw d;await c(p,{focus:!i}),Ne()}}),e.createElement("h3",{className:"section-gap"},"Team notes"),se.filter(r=>!He(r,J)).map(r=>e.createElement("div",{className:"cloud-message",key:r.id},e.createElement("strong",null,J[r.author_id]||"Staff member"),e.createElement("p",null,r.body),e.createElement("small",null,new Date(r.created_at).toLocaleString()))),!p.archived_at&&e.createElement("form",{className:"question-form",onSubmit:r=>{r.preventDefault(),X(async()=>{const o=await z(),{error:d}=await o.from("staff_notes").insert({inspection_id:p.id,author_id:m.id,body:Ee.trim()});if(d)throw d;_e(""),await c(p),Ne()})}},e.createElement("input",{"aria-label":"Staff review note",maxLength:2e3,placeholder:"Add a note for the team…",value:Ee,onChange:r=>_e(r.target.value)}),e.createElement("button",{className:"primary",disabled:w||!Ee.trim()},e.createElement(Ct,{size:16})," Add note")))):e.createElement("section",{className:"card cloud-setup"},e.createElement("div",{className:"setup-icon"},e.createElement(Fe,{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,o,d])=>e.createElement("div",{key:r},e.createElement("b",null,r),e.createElement("h3",null,o),e.createElement("p",null,d)))),e.createElement("a",{className:"primary",href:"https://supabase.com/dashboard",target:"_blank",rel:"noreferrer"},"Administrator setup ",e.createElement(St,{size:16})),e.createElement("p",{className:"caption"},"Contact the workspace administrator for help. The public demo can be used without Staff access."))}export{It as default};
frontend/dist/assets/email/robot-hello.gif ADDED
frontend/dist/assets/index-CsdyyyVC.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/assets/sample-thumbs/candle_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/candle_good.jpg ADDED
frontend/dist/assets/sample-thumbs/capsules_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/capsules_good.jpg ADDED
frontend/dist/assets/sample-thumbs/cashew_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/cashew_good.jpg ADDED
frontend/dist/assets/sample-thumbs/chewinggum_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/chewinggum_good.jpg ADDED
frontend/dist/assets/sample-thumbs/fryum_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/fryum_good.jpg ADDED
frontend/dist/assets/sample-thumbs/macaroni1_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/macaroni1_good.jpg ADDED
frontend/dist/assets/sample-thumbs/macaroni2_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/macaroni2_good.jpg ADDED
frontend/dist/assets/sample-thumbs/pcb1_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/pcb1_good.jpg ADDED
frontend/dist/assets/sample-thumbs/pcb2_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/pcb2_good.jpg ADDED
frontend/dist/assets/sample-thumbs/pcb3_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/pcb3_good.jpg ADDED
frontend/dist/assets/sample-thumbs/pcb4_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/pcb4_good.jpg ADDED
frontend/dist/assets/sample-thumbs/pipe_fryum_anomalous.jpg ADDED
frontend/dist/assets/sample-thumbs/pipe_fryum_good.jpg ADDED
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="#132e32"/><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-BY_K4Azl.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-BhfDqrNT.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="#132e32"/><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-CsdyyyVC.js"></script>
2
  <link rel="stylesheet" crossorigin href="./assets/index-BhfDqrNT.css">
3
  </head><body><div id="root"></div></body></html>