PageSourceSearch

https://www.person.ai/assets/HumanLimits-DlbiTAyN.js

js person.ai collected 2026-10-05 15:11:36 UTC 33,104 bytes, 11 lines download raw bytes

1import{a as x,j as e}from"./vendor-radix-DA_aSpdM.js";import{i as ks}from"./selfHealingClient-gRPkGxKK.js";import{A as Fs}from"./AdminLayout-nimK7lg5.js";import{c as Je,a as Ue,g as je,f as T,E as j,G as k,I as F,F as L,B as _,L as Is,w as Rs,k as Hs,l as Es,m as Ms,n as Bs,o as qs,p as zs}from"./App-B5Gw_pr3.js";import{T as Ps,a as Vs,b as W,c as G}from"./tabs-Bc3EQd27.js";import{B as f}from"./badge-B-Ty_vzC.js";import{I as n}from"./input-Be8YzUgr.js";import{T as b}from"./textarea-n-HpBHGA.js";import{L as a}from"./label-C-UxXqOz.js";import{S as B,a as q,b as z,c as P,d as g}from"./select-Cs9UswgO.js";import{T as ne,a as oe,b as v,c,d as ce,e as r}from"./table-3R3SFTii.js";import{S as de}from"./scroll-area-LC1Lxa-W.js";import{S as Ks}from"./switch-KoJN558F.js";import{A as Os,a as Js,b as Us,c as Qs,d as Ws,e as Gs,f as Xs,g as Ys}from"./alert-dialog-CItKMd6C.js";import{C as Zs,a as $s,b as et}from"./collapsible-_UOuurKf.js";import{u as ge}from"./useMutation-C6S-pLIW.js";import{supabase as V}from"./client-CfsuD3lc.js";import{F as Ke}from"./flask-conical-CnxH0GOd.js";import{C as st}from"./chevron-down-BVDfP_2L.js";import{S as tt}from"./search-BFm-z-Ci.js";import{E as Te}from"./eye-WQc0jBQG.js";import{Z as Qe}from"./zap-BEAmS9r2.js";import{C as it}from"./chart-column-fxXAAZC4.js";import{P as me}from"./plus-BhUN7TZ6.js";import{B as Oe}from"./brain-D0GmRisc.js";import{R as at,T as rt,B as lt}from"./generateCategoricalChart-BLauEe_n.js";import{B as nt}from"./BarChart-CpN7LaLF.js";import{X as ot,Y as ct}from"./YAxis-CgNcT2DU.js";import{P as dt}from"./pencil-CmRPkfhU.js";import{T as mt}from"./trash-2-B59JfgoK.js";import"./vendor-supabase-BQ1HIAaS.js";import"./edgeFunctionErrors-tek4dUTq.js";import"./SkipToContent-CRgQc9eq.js";import"./brand-logo-kjEenLET.js";import"./sheet-BHtbuGFR.js";import"./separator-Cgp4LhR9.js";import"./ImpersonationToggle-BRocflVz.js";import"./dropdown-menu-ChdUSMQt.js";import"./chevron-right-Cmx-b24l.js";import"./circle-DL6kpMyo.js";import"./shield-C-xd0eAw.js";import"./user-CgX6Dyy8.js";import"./credit-card-dMGg-XQc.js";import"./crown-D0qgxAkK.js";import"./useLandingPagePermissions-BjPztEie.js";import"./message-square-DFAlivbY.js";import"./file-text-OpyKyVh6.js";import"./activity-DRKg8dQb.js";import"./trending-up-l4bIqg9u.js";import"./mail-DDgusAuE.js";import"./gauge-BRHHaukB.js";import"./heart-YBbuRWzl.js";import"./phone-Cs-wLLGh.js";import"./image-CqJayY8t.js";import"./video-D1DWu8bZ.js";import"./star-1ED16WG2.js";import"./wand-sparkles-Db2hkwxf.js";import"./sparkles-D-iVX4_g.js";import"./file-plus-D7lTECvR.js";import"./circle-user-Co-3pjw4.js";import"./mic-wZvsWghy.js";import"./headphones-RLJv_3gl.js";import"./briefcase-C-ZD2yWu.js";import"./dollar-sign-XmxulMHk.js";import"./sliders-vertical-kFQXeN6m.js";import"./layers-C8ORVey8.js";import"./users-BR4IszS0.js";import"./bot-BCTcZgdo.js";import"./DebugPanel-BwQGyL_D.js";import"./copy-B1KPSnbw.js";import"./minimize-2-cUlE5igx.js";import"./scroll-text-DXxYYgQf.js";import"./shield-check-DAIRPbOF.js";import"./arrow-left-DFNdcU_9.js";import"./log-out-CtF_CrgZ.js";import"./useKeyboardVisibility-ByIRFiiI.js";import"./useSafeTimers-Dtwb407y.js";import"./globe-Cvbm9E-T.js";import"./calendar-fhbGUQ2x.js";import"./palette-Dz_xSOuh.js";import"./clipboard-check-Cs7z8jbJ.js";import"./message-circle-D3WZC271.js";import"./hash-DOoXCYFm.js";import"./scale-4QH1X5M8.js";import"./index-C1MkrzIu.js";import"./sentry-kztijHPz.js";import"./platformErrorLogger-4hUhfrtL.js";import"./lazyWithRetry-DxnkR6rW.js";import"./edgeFunctionClient-Cktd4gAf.js";import"./chevron-up-BctWVrXv.js";import"./index-Dh4i1-J3.js";/**
2 * @license lucide-react v0.462.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 xt=Je("Ear",[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]]);/**
7 * @license lucide-react v0.462.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 We=Je("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);function ve(l,d){return Ue({queryKey:[l],queryFn:async()=>{const{data:o,error:m}=await V.from(l).select("*").order(d,{ascending:!0});if(m)throw m;return o||[]}})}function ht(){return ve("human_sensory_limits","sense_type")}function pt(){return ve("human_capability_limits","category")}function ut(){return ve("human_joint_limits","joint_name")}function jt(){return ve("human_impossibilities","severity")}function xe(l){const d=je();return ge({mutationFn:async({id:o,isActive:m})=>{const{error:h}=await V.from(l).update({is_active:m}).eq("id",o);if(h)throw h},onSuccess:()=>{d.invalidateQueries({queryKey:[l]}),T.success("Rule status updated")},onError:o=>{T.error("Failed to update rule status")}})}function he(l){const d=je();return ge({mutationFn:async({id:o,updates:m})=>{const{error:h}=await V.from(l).update(m).eq("id",o);if(h)throw h},onSuccess:()=>{d.invalidateQueries({queryKey:[l]}),T.success("Rule updated successfully")},onError:o=>{T.error("Failed to update rule")}})}function pe(l){const d=je();return ge({mutationFn:async o=>{const{error:m}=await V.from(l).insert(o);if(m)throw m},onSuccess:()=>{d.invalidateQueries({queryKey:[l]}),T.success("Rule created successfully")},onError:o=>{T.error("Failed to create rule")}})}function ue(l){const d=je();return ge({mutationFn:async o=>{const{error:m}=await V.from(l).delete().eq("id",o);if(m)throw m},onSuccess:()=>{d.invalidateQueries({queryKey:[l]}),T.success("Rule deleted successfully")},onError:o=>{T.error("Failed to delete rule")}})}function gt(l="30d"){const o={"7d":7,"30d":30,"90d":90}[l],m=new Date(Date.now()-o*24*60*60*1e3).toISOString();return Ue({queryKey:["human-limits-usage-stats",l],queryFn:async()=>{const{data:h,error:I}=await V.from("prompt_generation_logs").select("metadata, created_at").gte("created_at",m).not("metadata","is",null);if(I)throw I;const C={},D={};let R=0;for(const p of h||[]){const u=p.metadata;if(!u)continue;const H=u.human_impossibilities,w=u.required_negative_terms;(H&&H.length>0||w&&w.length>0)&&R++;for(const A of H||[])C[A]=(C[A]||0)+1;for(const A of w||[])D[A]=(D[A]||0)+1}const ye=Object.entries(C).map(([p,u])=>({name:p,count:u})).sort((p,u)=>u.count-p.count),fe=Object.entries(D).map(([p,u])=>({term:p,count:u})).sort((p,u)=>u.count-p.count);return{totalGenerations:(h==null?void 0:h.length)||0,totalWithLimits:R,topImpossibilities:ye,topNegativeTerms:fe}},staleTime:300*1e3})}const vt={vision:Te,hearing:xt,touch:We,taste:Oe,smell:Oe,proprioception:Qe},X=x.forwardRef(({tableType:l,row:d,nameField:o,onToggle:m,onEdit:h,onDelete:I},C)=>e.jsxs("div",{ref:C,className:"flex items-center gap-1",children:[e.jsx(Ks,{checked:d.is_active,onCheckedChange:D=>{m(l,d.id,D)},className:"mr-1"}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(l,d),children:e.jsx(dt,{className:"h-3.5 w-3.5"})}),e.jsx(_,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>I(l,d.id,d[o]||"this rule"),children:e.jsx(mt,{className:"h-3.5 w-3.5"})})]}));X.displayName="ActionButtons";function ta(){var Re,He,Ee,Me,Be,qe,ze,Pe;
11const[l,d]=x.useState(""),[o,m]=x.useState("all"),[h,I]=x.useState("all"),[C,D]=x.useState("all"),[R,ye]=x.useState("all"),[fe,p]=x.useState(!1),[u,H]=x.useState("edit"),[w,A]=x.useState("sensory"),[i,Ne]=x.useState({}),[Ge,be]=x.useState(!1),[E,Ae]=x.useState(null),[Le,Xe]=x.useState(!1),[Y,Ye]=x.useState(""),[De,ke]=x.useState(!1),[S,Fe]=x.useState(null),[Ie,Ze]=x.useState("30d"),{data:K=[],isLoading:$e}=ht(),{data:O=[],isLoading:es}=pt(),{data:Z=[],isLoading:ss}=ut(),{data:J=[],isLoading:ts}=jt(),{data:y,isLoading:$}=gt(Ie),is=xe("human_sensory_limits"),as=xe("human_capability_limits"),rs=xe("human_joint_limits"),ls=xe("human_impossibilities"),ns=he("human_sensory_limits"),os=he("human_capability_limits"),cs=he("human_joint_limits"),ds=he("human_impossibilities"),ms=pe("human_sensory_limits"),xs=pe("human_capability_limits"),hs=pe("human_joint_limits"),ps=pe("human_impossibilities"),us=ue("human_sensory_limits"),js=ue("human_capability_limits"),gs=ue("human_joint_limits"),vs=ue("human_impossibilities"),ys=s=>({sensory:is,capability:as,joint:rs,impossibilities:ls})[s],fs=s=>({sensory:ns,capability:os,joint:cs,impossibilities:ds})[s],Ns=s=>({sensory:ms,capability:xs,joint:hs,impossibilities:ps})[s],bs=s=>({sensory:us,capability:js,joint:gs,impossibilities:vs})[s],ee=(s,t)=>{if(!l)return s;const N=l.toLowerCase();return s.filter(M=>t.some(Ds=>{var Ve;return(Ve=M[Ds])==null?void 0:Ve.toString().toLowerCase().includes(N)}))},se=s=>R==="all"?s:s.filter(t=>t.is_active===(R==="active")),_e=se(ee(K,["sense_type","parameter","limit_type"])).filter(s=>o==="all"||s.sense_type===o),Ce=se(ee(O,["category","capability","normal_range"])).filter(s=>h==="all"||s.category===h),we=se(ee(Z,["joint_name","movement_type","notes"])),Se=se(ee(J,["category","impossibility","detection_keywords"])).filter(s=>C==="all"||s.severity===C),_s=[...new Set(K.map(s=>s.sense_type))].filter(Boolean),Cs=[...new Set(O.map(s=>s.category))].filter(Boolean),ws=[...new Set(J.map(s=>s.severity))].filter(Boolean),te=$e||es||ss||ts,ie=(s,t,N)=>{ys(s).mutate({id:t,isActive:N})},ae=(s,t)=>{H("edit"),A(s),Ne({...t}),p(!0)},re=(s,t,N)=>{Ae({id:t,table:s,name:N}),be(!0)},le=s=>{H("create"),A(s),Ne({is_active:!0}),p(!0)},Ss=()=>{const{id:s,created_at:t,updated_at:N,...M}=i;u==="edit"?fs(w).mutate({id:s,updates:M},{onSuccess:()=>p(!1)}):Ns(w).mutate(M,{onSuccess:()=>p(!1)})},Ts=()=>{E&&bs(E.table).mutate(E.id,{onSuccess:()=>{be(!1),Ae(null)}})},As=async()=>{if(Y.trim()){ke(!0),Fe(null);try{const s=await ks("check-prompt-impossibilities",{prompt:Y,poseType:"general"});Fe(s)}catch(s){T.error("Prompt test failed: "+s.message)}finally{ke(!1)}}},U=s=>Array.isArray(s)?s.join(", "):typeof s=="string"?s:"",Q=s=>s.split(",").map(t=>t.trim()).filter(Boolean),Ls=()=>{const s=(t,N)=>Ne(M=>({...M,[t]:N}));switch(w){case"sensory":return e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(a,{children:"Sense Type"}),e.jsx(n,{value:i.sense_type||"",onChange:t=>s("sense_type",t.target.value)})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Limit Type"}),e.jsx(n,{value:i.limit_type||"",onChange:t=>s("limit_type",t.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Parameter"}),e.jsx(n,{value:i.parameter||"",onChange:t=>s("parameter",t.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(a,{children:"Value Range"}),e.jsx(n,{value:i.value_range||"",onChange:t=>s("value_range",t.target.value)})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Unit"}),e.jsx(n,{value:i.unit||"",onChange:t=>s("unit",t.target.value),placeholder:"e.g. Hz, nm, dB"})]})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Comparison Context"}),e.jsx(n,{value:i.comparison_context||"",onChange:t=>s("comparison_context",t.target.value),placeholder:"Context for comparing values"})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Scene Validation Keywords (comma-separated)"}),e.jsx(b,{value:U(i.scene_validation_keywords),onChange:t=>s("scene_validation_keywords",Q(t.target.value)),placeholder:"Keywords the edge function uses for scene matching"})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Negative Prompt Terms (comma-separated)"}),e.jsx(b,{value:U(i.negative_prompt_terms),onChange:t=>s("negative_prompt_terms",Q(t.target.value))})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Application Notes"}),e.jsx(b,{value:i.application_notes||"",onChange:t=>s("application_notes",t.target.value)})]})]});case"capability":return e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(a,{children:"Category"}),e.jsx(n,{value:i.category||"",onChange:t=>s("category",t.target.value)})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Measurement Unit"}),e.jsx(n,{value:i.measurement_unit||"",onChange:t=>s("measurement_unit",t.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Capability"}),e.jsx(n,{value:i.capability||"",onChange:t=>s("capability",t.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(a,{children:"Normal Range"}),e.jsx(n,{value:i.normal_range||"",onChange:t=>s("normal_range",t.target.value)})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Elite Range"}),e.jsx(n,{value:i.elite_range||"",onChange:t=>s("elite_range",t.target.value),placeholder:"e.g. top 1% range"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(a,{children:"World Record"}),e.jsx(n,{value:i.world_record||"",onChange:t=>s("world_record",t.target.value),placeholder:"Known world record value"})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Source Reference"}),e.jsx(n,{value:i.source_reference||"",onChange:t=>s("source_reference",t.target.value),placeholder:"Citation or source URL"})]})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Notes"}),e.jsx(b,{value:i.notes||"",onChange:t=>s("notes",t.target.value)})]})]});case"joint":return e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(a,{children:"Joint Name"}),e.jsx(n,{value:i.joint_name||"",onChange:t=>s("joint_name",t.target.value)})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Movement Type"}),e.jsx(n,{value:i.movement_type||"",onChange:t=>s("movement_type",t.target.value)})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(a,{children:"Normal Max Degrees"}),e.jsx(n,{type:"number",value:i.normal_max_degrees??"",onChange:t=>s("normal_max_degrees",Number(t.target.value))})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Normal Min Degrees"}),e.jsx(n,{type:"number",value:i.normal_min_degrees??"",onChange:t=>s("normal_min_degrees",Number(t.target.value))})]})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Source"}),e.jsx(n,{value:i.source||"",onChange:t=>s("source",t.target.value),placeholder:"Reference source for this data"})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Notes"}),e.jsx(b,{value:i.notes||"",onChange:t=>s("notes",t.target.value)})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Detection Keywords (comma-separated)"}),e.jsx(b,{value:U(i.detection_keywords),onChange:t=>s("detection_keywords",Q(t.target.value))})]})]});case"impossibilities":return e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(a,{children:"Category"}),e.jsx(n,{value:i.category||"",onChange:t=>s("category",t.target.value)})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Subcategory"}),e.jsx(n,{value:i.subcategory||"",onChange:t=>s("subcategory",t.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Impossibility"}),e.jsx(n,{value:i.impossibility||"",onChange:t=>s("impossibility",t.target.value)})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Description"}),e.jsx(b,{value:i.description||"",onChange:t=>s("description",t.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(a,{children:"Severity"}),e.jsxs(B,{value:i.severity||"",onValueChange:t=>s("severity",t),children:[e.jsx(q,{children:e.jsx(z,{placeholder:"Select severity"})}),e.jsxs(P,{children:[e.jsx(g,{value:"critical",children:"Critical"}),e.jsx(g,{value:"warning",children:"Warning"}),e.jsx(g,{value:"info",children:"Info"})]})]})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Applies to Poses"}),e.jsxs(B,{value:i.applies_to_poses||"all",onValueChange:t=>s("applies_to_poses",t),children:[e.jsx(q,{children:e.jsx(z,{})}),e.jsxs(P,{children:[e.jsx(g,{value:"all",children:"All"}),e.jsx(g,{value:"standing",children:"Standing"}),e.jsx(g,{value:"sitting",children:"Sitting"}),e.jsx(g,{value:"lying",children:"Lying"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Detection Keywords (comma-separated)"}),e.jsx(b,{value:U(i.detection_keywords),onChange:t=>s("detection_keywords",Q(t.target.value))})]}),e.jsxs("div",{children:[e.jsx(a,{children:"Negative Prompt Terms (comma-separated)"}),e.jsx(b,{value:U(i.negative_prompt_terms),onChange:t=>s("negative_prompt_terms",Q(t.target.value))})]})]})}};return e.jsx(Fs,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Human Limits Admin"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage anatomical, sensory, and capability constraints used for prompt validation"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{variant:"outline",className:"gap-1",children:[K.length," Sensory"]}),e.jsxs(f,{variant:"outline",className:"gap-1",children:[O.length," Capability"]}),e.jsxs(f,{variant:"outline",className:"gap-1",children:[Z.length," Joint"]}),e.jsxs(f,{variant:"outline",className:"gap-1",children:[J.length," Impossibilities"]})]})]}),e.jsx(Zs,{open:Le,onOpenChange:Xe,children:e.jsxs(j,{children:[e.jsx($s,{asChild:!0,children:e.jsx(k,{className:"cursor-pointer pb-3 hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(F,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ke,{className:"h-5 w-5"}),"Prompt Tester"]}),e.jsx(st,{className:`h-4 w-4 transition-transform ${Le?"rotate-180":""}`})]})})}),e.jsx(et,{children:e.jsxs(L,{className:"pt-0 space-y-4",children:[e.jsx("div",{className:"flex gap-2",children:e.jsx(b,{placeholder:"Paste a prompt to test which impossibility rules match...",value:Y,onChange:s=>Ye(s.target.value),className:"min-h-[80px]"})}),e.jsxs(_,{onClick:As,disabled:De||!Y.trim(),children:[De?e.jsx(Is,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ke,{className:"h-4 w-4 mr-2"}),"Test Against Rules"]}),S&&e.jsxs("div",{className:"space-y-3 mt-4",children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsxs(j,{className:"p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Flagged Issues"}),e.jsx("p",{className:"text-2xl font-bold",children:((Re=S.flaggedItems)==null?void 0:Re.length)||0})]}),e.jsxs(j,{className:"p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Critical"}),e.jsx("p",{className:"text-2xl font-bold text-destructive",children:((He=S.flaggedItems)==null?void 0:He.filter(s=>s.severity==="critical").length)||0})]}),e.jsxs(j,{className:"p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Joint Violations"}),e.jsx("p",{className:"text-2xl font-bold",children:((Ee=S.jointViolations)==null?void 0:Ee.length)||0})]}),e.jsxs(j,{className:"p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Negative Terms"}),e.jsx("p",{className:"text-2xl font-bold",children:((Me=S.allNegativeTerms)==null?void 0:Me.length)||0})]})]}),((Be=S.flaggedItems)==null?void 0:Be.length)>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Matched Impossibilities"}),e.jsx("div",{className:"space-y-1",children:S.flaggedItems.map((s,t)=>{var N;return e.jsxs("div",{className:"flex items-center gap-2 text-sm p-2 rounded bg-muted",children:[e.jsx(f,{variant:s.severity==="critical"?"destructive":"secondary",children:s.severity}),e.jsx("span",{children:s.impossibility}),e.jsxs("span",{className:"text-xs text-muted-foreground ml-auto",children:["matched: ",(N=s.matchedKeywords)==null?void 0:N.join(", ")
11]})]},t)})})]}),((qe=S.allNegativeTerms)==null?void 0:qe.length)>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Injected Negative Terms"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:S.allNegativeTerms.map((s,t)=>e.jsx(f,{variant:"outline",className:"text-xs",children:s},t))})]})]})]})})]})}),e.jsx(j,{children:e.jsx(L,{className:"pt-4",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(tt,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(n,{placeholder:"Search across all tables...",value:l,onChange:s=>d(s.target.value),className:"pl-9"})]}),e.jsxs(B,{value:R,onValueChange:ye,children:[e.jsx(q,{className:"w-[140px]",children:e.jsx(z,{placeholder:"Status"})}),e.jsxs(P,{children:[e.jsx(g,{value:"all",children:"All Status"}),e.jsx(g,{value:"active",children:"Active"}),e.jsx(g,{value:"inactive",children:"Inactive"})]})]})]})})}),e.jsxs(Ps,{defaultValue:"sensory",className:"space-y-4",children:[e.jsxs(Vs,{className:"grid w-full grid-cols-5",children:[e.jsxs(W,{value:"sensory",className:"gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),"Sensory (",_e.length,")"]}),e.jsxs(W,{value:"capability",className:"gap-2",children:[e.jsx(Qe,{className:"h-4 w-4"}),"Capability (",Ce.length,")"]}),e.jsxs(W,{value:"joint",className:"gap-2",children:[e.jsx(We,{className:"h-4 w-4"}),"Joint (",we.length,")"]}),e.jsxs(W,{value:"impossibilities",className:"gap-2",children:[e.jsx(Rs,{className:"h-4 w-4"}),"Impossibilities (",Se.length,")"]}),e.jsxs(W,{value:"analytics",className:"gap-2",children:[e.jsx(it,{className:"h-4 w-4"}),"Analytics"]})]}),e.jsx(G,{value:"sensory",children:e.jsxs(j,{children:[e.jsx(k,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(F,{className:"text-lg",children:"Human Sensory Limits"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(B,{value:o,onValueChange:m,children:[e.jsx(q,{className:"w-[150px]",children:e.jsx(z,{placeholder:"Sense type"})}),e.jsxs(P,{children:[e.jsx(g,{value:"all",children:"All Senses"}),_s.map(s=>e.jsx(g,{value:s,children:s.charAt(0).toUpperCase()+s.slice(1)},s))]})]}),e.jsxs(_,{size:"sm",onClick:()=>le("sensory"),children:[e.jsx(me,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})}),e.jsx(L,{children:e.jsx(de,{className:"h-[500px]",children:e.jsxs(ne,{children:[e.jsx(oe,{children:e.jsxs(v,{children:[e.jsx(c,{className:"w-[100px]",children:"Sense"}),e.jsx(c,{className:"w-[100px]",children:"Type"}),e.jsx(c,{children:"Parameter"}),e.jsx(c,{children:"Value Range"}),e.jsx(c,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(ce,{children:te?e.jsx(v,{children:e.jsx(r,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):_e.length===0?e.jsx(v,{children:e.jsx(r,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No sensory limits found"})}):_e.map(s=>{const t=vt[s.sense_type]||Te;return e.jsxs(v,{children:[e.jsx(r,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"capitalize",children:s.sense_type})]})}),e.jsx(r,{children:e.jsx(f,{variant:s.limit_type==="limitation"?"destructive":"secondary",children:s.limit_type})}),e.jsx(r,{className:"font-medium",children:s.parameter}),e.jsx(r,{className:"text-muted-foreground",children:s.value_range||"—"}),e.jsx(r,{children:e.jsx(X,{tableType:"sensory",row:s,nameField:"parameter",onToggle:ie,onEdit:ae,onDelete:re})})]},s.id)})})]})})})]})}),e.jsx(G,{value:"capability",children:e.jsxs(j,{children:[e.jsx(k,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(F,{className:"text-lg",children:"Human Capability Limits"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(B,{value:h,onValueChange:I,children:[e.jsx(q,{className:"w-[150px]",children:e.jsx(z,{placeholder:"Category"})}),e.jsxs(P,{children:[e.jsx(g,{value:"all",children:"All Categories"}),Cs.map(s=>e.jsx(g,{value:s,children:s.charAt(0).toUpperCase()+s.slice(1).replace(/_/g," ")},s))]})]}),e.jsxs(_,{size:"sm",onClick:()=>le("capability"),children:[e.jsx(me,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})}),e.jsx(L,{children:e.jsx(de,{className:"h-[500px]",children:e.jsxs(ne,{children:[e.jsx(oe,{children:e.jsxs(v,{children:[e.jsx(c,{className:"w-[120px]",children:"Category"}),e.jsx(c,{children:"Capability"}),e.jsx(c,{children:"Normal Range"}),e.jsx(c,{className:"w-[100px]",children:"Unit"}),e.jsx(c,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(ce,{children:te?e.jsx(v,{children:e.jsx(r,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):Ce.length===0?e.jsx(v,{children:e.jsx(r,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No capability limits found"})}):Ce.map(s=>{var t;return e.jsxs(v,{children:[e.jsx(r,{children:e.jsx(f,{variant:"outline",className:"capitalize",children:(t=s.category)==null?void 0:t.replace(/_/g," ")})}),e.jsx(r,{className:"font-medium",children:s.capability}),e.jsx(r,{className:"text-muted-foreground",children:s.normal_range}),e.jsx(r,{className:"text-muted-foreground",children:s.measurement_unit||"—"}),e.jsx(r,{children:e.jsx(X,{tableType:"capability",row:s,nameField:"capability",onToggle:ie,onEdit:ae,onDelete:re})})]},s.id)})})]})})})]})}),e.jsx(G,{value:"joint",children:e.jsxs(j,{children:[e.jsx(k,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(F,{className:"text-lg",children:"Human Joint Limits"}),e.jsxs(_,{size:"sm",onClick:()=>le("joint"),children:[e.jsx(me,{className:"h-4 w-4 mr-1"}),"Add"]})]})}),e.jsx(L,{children:e.jsx(de,{className:"h-[500px]",children:e.jsxs(ne,{children:[e.jsx(oe,{children:e.jsxs(v,{children:[e.jsx(c,{className:"w-[120px]",children:"Joint"}),e.jsx(c,{className:"w-[140px]",children:"Movement"}),e.jsx(c,{className:"w-[100px]",children:"Max°"}),e.jsx(c,{children:"Notes"}),e.jsx(c,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(ce,{children:te?e.jsx(v,{children:e.jsx(r,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):we.length===0?e.jsx(v,{children:e.jsx(r,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No joint limits found"})}):we.map(s=>{var t;return e.jsxs(v,{children:[e.jsx(r,{className:"font-medium capitalize",children:s.joint_name}),e.jsx(r,{children:e.jsx(f,{variant:"secondary",className:"capitalize",children:(t=s.movement_type)==null?void 0:t.replace(/_/g," ")})}),e.jsxs(r,{className:"font-mono",children:[s.normal_max_degrees,"°"]}),e.jsx(r,{className:"text-muted-foreground text-sm",children:s.notes||"—"}),e.jsx(r,{children:e.jsx(X,{tableType:"joint",row:s,nameField:"joint_name",onToggle:ie,onEdit:ae,onDelete:re})})]},s.id)})})]})})})]})}),e.jsx(G,{value:"impossibilities",children:e.jsxs(j,{children:[e.jsx(k,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(F,{className:"text-lg",children:"Human Impossibilities"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(B,{value:C,onValueChange:D,children:[e.jsx(q,{className:"w-[150px]",children:e.jsx(z,{placeholder:"Severity"})}),e.jsxs(P,{children:[e.jsx(g,{value:"all",children:"All Severities"}),ws.map(s=>e.jsx(g,{value:s,children:s.charAt(0).toUpperCase()+s.slice(1)},s))]})]}),e.jsxs(_,{size:"sm",onClick:()=>le("impossibilities"),children:[e.jsx(me,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})}),e.jsx(L,{children:e.jsx(de,{className:"h-[500px]",children:e.jsxs(ne,{children:[e.jsx(oe,{children:e.jsxs(v,{children:[e.jsx(c,{className:"w-[120px]",children:"Category"}),e.jsx(c,{className:"w-[100px]",children:"Severity"}),e.jsx(c,{children:"Impossibility"}),e.jsx(c,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(ce,{children:te?e.jsx(v,{children:e.jsx(r,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):Se.length===0?e.jsx(v,{children:e.jsx(r,{colSpan:4,className:"text-center py-8 text-muted-foreground",children:"No impossibilities found"})}):Se.map(s=>{var t;return e.jsxs(v,{children:[e.jsx(r,{children:e.jsx(f,{variant:"outline",className:"capitalize",children:(t=s.category)==null?void 0:t.replace(/_/g," ")})}),e.jsx(r,{children:e.jsx(f,{variant:s.severity==="critical"?"destructive":s.severity==="warning"?"default":"secondary",children:s.severity})}),e.jsx(r,{className:"font-medium",children:s.impossibility}),e.jsx(r,{children:e.jsx(X,{tableType:"impossibilities",row:s,nameField:"impossibility",onToggle:ie,onEdit:ae,onDelete:re})})]},s.id)})})]})})})]})}),e.jsx(G,{value:"analytics",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Rule Usage Analytics"}),e.jsx("div",{className:"inline-flex items-center gap-1 p-1 bg-muted rounded-lg",children:["7d","30d","90d"].map(s=>e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>Ze(s),className:`px-3 py-1.5 text-sm font-medium transition-all ${Ie===s?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:s==="7d"?"7 Days":s==="30d"?"30 Days":"90 Days"},s))})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs(j,{className:"p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Rules"}),e.jsx("p",{className:"text-2xl font-bold",children:K.length+O.length+Z.length+J.length})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active Rules"}),e.jsx("p",{className:"text-2xl font-bold",children:[...K,...O,...Z,...J].filter(s=>s.is_active).length})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Generations"}),e.jsx("p",{className:"text-2xl font-bold",children:$?"...":(y==null?void 0:y.totalGenerations)||0})]}),e.jsxs(j,{className:"p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"With Limits Applied"}),e.jsx("p",{className:"text-2xl font-bold",children:$?"...":(y==null?void 0:y.totalWithLimits)||0})]})]}),e.jsxs(j,{children:[e.jsx(k,{className:"pb-3",children:e.jsx(F,{className:"text-lg",children:"Top 10 Triggered Impossibilities"})}),e.jsx(L,{children:$?e.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Loading analytics..."}):(((ze=y==null?void 0:y.topImpossibilities)==null?void 0:ze.length)||0)===0?e.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"No usage data found for this period"}):e.jsx(at,{width:"100%",height:300,children:e.jsxs(nt,{data:y.topImpossibilities.slice(0,10),layout:"vertical",margin:{left:20,right:20},children:[e.jsx(ot,{type:"number"}),e.jsx(ct,{dataKey:"name",type:"category",width:200,tick:{fontSize:12}}),e.jsx(rt,{}),e.jsx(lt,{dataKey:"count",fill:"hsl(var(--primary))",radius:[0,4,4,0]})]})})})]}),e.jsxs(j,{children:[e.jsx(k,{className:"pb-3",children:e.jsx(F,{className:"text-lg",children:"Most Used Negative Terms"})}),e.jsx(L,{children:$?e.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"Loading..."}):(((Pe=y==null?void 0:y.topNegativeTerms)==null?void 0:Pe.length)||0)===0?e.jsx("div",{className:"flex items-center justify-center py-12 text-muted-foreground",children:"No negative terms tracked for this period"}):e.jsx("div",{className:"flex flex-wrap gap-2",children:y.topNegativeTerms.slice(0,30).map(({term:s,count:t})=>e.jsxs(f,{variant:"outline",className:"text-xs gap-1",children:[s," ",e.jsxs("span",{className:"text-muted-foreground",children:["(",t,")"]})]},s))})})]})]})})]}),e.jsx(Hs,{open:fe,onOpenChange:p,children:e.jsxs(Es,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(Ms,{children:[e.jsxs(Bs,{children:[u==="edit"?"Edit":"Create"," ",w.charAt(0).toUpperCase()+w.slice(1)," Rule"]}),e.jsx(qs,{children:u==="edit"?"Modify the fields below and save.":"Fill in the fields to create a new rule."})]}),Ls(),e.jsxs(zs,{children:[e.jsx(_,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsx(_,{onClick:Ss,children:u==="edit"?"Save Changes":"Create Rule"})]})]})}),e.jsx(Os,{open:Ge,onOpenChange:be,children:e.jsxs(Js,{children:[e.jsxs(Us,{children:[e.jsx(Qs,{children:"Delete Rule"}),e.jsxs(Ws,{children:['Are you sure you want to delete "',E==null?void 0:E.name,'"? This action cannot be undone.']})]}),e.jsxs(Gs,{children:[e.jsx(Xs,{children:"Cancel"}),e.jsx(Ys,{onClick:Ts,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})})}export{ta as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.