@memoarchitect/architect 0.6.5 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +45 -4
  2. package/dist/assets/AiWorkspace-Bu9TlIWg.js +7 -0
  3. package/dist/assets/AnalysisWorkspace-CodmoI-v.js +39 -0
  4. package/dist/assets/{ComplianceWizard-DWolzleI.js → ComplianceWizard-CTihkUi-.js} +1 -1
  5. package/dist/assets/DSMView-BiC845df.js +1 -0
  6. package/dist/assets/Dashboard-CgnNLhKq.js +1 -0
  7. package/dist/assets/{DhfDashboard-D9JxRAbD.js → DhfDashboard-w-dJoJHU.js} +1 -1
  8. package/dist/assets/{DhfWorkbench-BQv2WQ9o.js → DhfWorkbench-o6B_MT-0.js} +15 -15
  9. package/dist/assets/DiagramCanvas-CqGqDbgT.js +3 -0
  10. package/dist/assets/DiagramEditor-UJDHcAUF.js +4 -0
  11. package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +1 -0
  12. package/dist/assets/ElementDetailView-10U0rr33.js +2 -0
  13. package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +3 -0
  14. package/dist/assets/{ImportView-33dFwj6A.js → ImportView-D8svP04Q.js} +1 -1
  15. package/dist/assets/{LayerGrid-B3MBWswK.js → LayerGrid-DEe0Ryz-.js} +1 -1
  16. package/dist/assets/{LayerTable-DyIzIt5M.js → LayerTable-CN_b2rDr.js} +2 -2
  17. package/dist/assets/{MaxGraphCanvas-BS5wYazZ.js → MaxGraphCanvas-bo8oPBct.js} +6 -6
  18. package/dist/assets/{ModelDiff-BoFREnpg.js → ModelDiff-xe95oVua.js} +1 -1
  19. package/dist/assets/{OntologyDecompositionDiagram-IG1gj1c3.js → OntologyDecompositionDiagram-BL9R8bdB.js} +1 -1
  20. package/dist/assets/{OntologyViewer-CQTEg-GI.js → OntologyViewer-CtqNkkCn.js} +2 -2
  21. package/dist/assets/{RelationshipOverlay-B9bqt4zl.js → RelationshipOverlay-DL0N8Vmk.js} +1 -1
  22. package/dist/assets/{RelationshipsSection-DttMvF2i.js → RelationshipsSection-BoJ0aUXe.js} +1 -1
  23. package/dist/assets/{ReviewDashboard-BJ_smBGS.js → ReviewDashboard-DeTge2oC.js} +1 -1
  24. package/dist/assets/ScenarioEditor-FAEYTHgP.js +3 -0
  25. package/dist/assets/{StatisticsDashboard-CBYJGUPH.js → StatisticsDashboard-BAZRqIPN.js} +1 -1
  26. package/dist/assets/{SysmlCodeEditor-Die2RUsz.js → SysmlCodeEditor-BBfup_Ni.js} +1 -1
  27. package/dist/assets/TabularView-I4LjHhoH.js +1 -0
  28. package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +3 -0
  29. package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +1 -0
  30. package/dist/assets/{WorkflowWizard-CbkDyd1W.js → WorkflowWizard-VwpEHt3R.js} +1 -1
  31. package/dist/assets/element-options-B7AgTB8R.js +3 -0
  32. package/dist/assets/html2canvas.esm-QH1iLAAe.js +22 -0
  33. package/dist/assets/index-BWMNo4wW.css +1 -0
  34. package/dist/assets/index-Bij8Q4Kg.js +45 -0
  35. package/dist/assets/index.es-ClbJxlAQ.js +18 -0
  36. package/dist/assets/jspdf.es.min-DZ68BGxk.js +170 -0
  37. package/dist/assets/notation-scene-DT8LpWVK.js +1 -0
  38. package/dist/assets/purify.es-DP5U8-sc.js +3 -0
  39. package/dist/assets/{reactflow-CsCqNKB-.js → reactflow-s7jmJtXx.js} +5 -5
  40. package/dist/index.html +3 -3
  41. package/lib/__tests__/compiler-bundling.test.d.ts +2 -0
  42. package/lib/__tests__/compiler-bundling.test.d.ts.map +1 -0
  43. package/lib/__tests__/compiler-bundling.test.js +32 -0
  44. package/lib/__tests__/compiler-bundling.test.js.map +1 -0
  45. package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts +2 -0
  46. package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts.map +1 -0
  47. package/lib/__tests__/standard-sysml-diagrams-smoke.test.js +22 -0
  48. package/lib/__tests__/standard-sysml-diagrams-smoke.test.js.map +1 -0
  49. package/lib/__tests__/supervised-child-args.test.d.ts +2 -0
  50. package/lib/__tests__/supervised-child-args.test.d.ts.map +1 -0
  51. package/lib/__tests__/supervised-child-args.test.js +35 -0
  52. package/lib/__tests__/supervised-child-args.test.js.map +1 -0
  53. package/lib/bin/memo-architect.js +30 -4
  54. package/lib/bin/memo-architect.js.map +1 -1
  55. package/lib/commands/dev.d.ts +18 -2
  56. package/lib/commands/dev.d.ts.map +1 -1
  57. package/lib/commands/dev.js +56 -8
  58. package/lib/commands/dev.js.map +1 -1
  59. package/lib/commands/example.d.ts +1 -0
  60. package/lib/commands/example.d.ts.map +1 -1
  61. package/lib/commands/example.js +2 -0
  62. package/lib/commands/example.js.map +1 -1
  63. package/lib/feature-grants.d.ts.map +1 -1
  64. package/lib/feature-grants.js +2 -2
  65. package/lib/feature-grants.js.map +1 -1
  66. package/package.json +12 -6
  67. package/dist/assets/AiWorkspace-DHZ6a9HJ.js +0 -3
  68. package/dist/assets/DSMView-TdC3EADB.js +0 -1
  69. package/dist/assets/Dashboard-DBfAOCJv.js +0 -1
  70. package/dist/assets/DhfSettingsPanel-Firov0IF.js +0 -1
  71. package/dist/assets/DiagramCanvas-BfwO8YE5.js +0 -1
  72. package/dist/assets/DiagramEditor-Cp9ORYoN.js +0 -4
  73. package/dist/assets/ElementDetailView-DOrG8v7V.js +0 -2
  74. package/dist/assets/ScenarioEditor-D06nbX4h.js +0 -3
  75. package/dist/assets/TabularView-BLzDtgmK.js +0 -1
  76. package/dist/assets/TraceabilityMatrix-DbL_FkAC.js +0 -1
  77. package/dist/assets/index-B8HDzVLs.css +0 -1
  78. package/dist/assets/index-D0vtjNjX.js +0 -3280
  79. package/dist/assets/layout-selection-DIQaaOIC.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as n}from"./reactflow-s7jmJtXx.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as E,F as je,M as Se,H as Ee}from"./index-Bij8Q4Kg.js";import{l as Ce,c as ve,a as he,E as pe,S as Ie,b as ke}from"./ExplorerTreeRow-DqhF_qoO.js";import{a as ee,I as k,T as Ae,b as Me,c as me}from"./DiagramToolbarControls-B2gZFJlg.js";const Ue=(r,s,o=.006)=>s.x>=r.x-o&&s.y>=r.y-o&&s.x+s.width<=r.x+r.width+o&&s.y+s.height<=r.y+r.height+o;function Be(r){const{data:s,width:o,height:d}=r;if(o<8||d<8||s.length<o*d*4)return[];const u=new Uint8Array(o*d);for(let h=0;h<u.length;h++){const m=h*4;u[h]=Math.round(s[m]*.299+s[m+1]*.587+s[m+2]*.114)}const c=new Uint8Array(o*d);for(let h=1;h<d-1;h++)for(let m=1;m<o-1;m++){const g=h*o+m,C=Math.abs(u[g+1]-u[g-1]),F=Math.abs(u[g+o]-u[g-o]);if(C+F>=42)for(let S=-1;S<=1;S++)for(let p=-1;p<=1;p++)c[g+S*o+p]=1}const b=new Uint8Array(o*d),N=[],v=[];for(let h=0;h<c.length;h++){if(!c[h]||b[h])continue;b[h]=1,v.push(h);let m=o,g=d,C=0,F=0,S=0;for(;v.length;){const R=v.pop(),A=R%o,$=Math.floor(R/o);m=Math.min(m,A),C=Math.max(C,A),g=Math.min(g,$),F=Math.max(F,$),S++;for(let B=-1;B<=1;B++)for(let K=-1;K<=1;K++){if(!K&&!B)continue;const z=A+K,L=$+B;if(z<0||L<0||z>=o||L>=d)continue;const I=L*o+z;c[I]&&!b[I]&&(b[I]=1,v.push(I))}}const p=C-m+1,Y=F-g+1,U={x:m/o,y:g/d,width:p/o,height:Y/d},P=U.width*U.height;if(U.width<.07||U.height<.035||P<.004||P>.93)continue;const J=Math.max(1,2*p+2*Y),V=Math.max(.45,Math.min(.96,S/J));N.push({rect:U,confidence:V})}const D=[];for(const h of N.sort((m,g)=>g.confidence-m.confidence||g.rect.width*g.rect.height-m.rect.width*m.rect.height))if(D.some(g=>{const C=Math.abs(g.rect.x-h.rect.x),F=Math.abs(g.rect.y-h.rect.y),S=Math.abs(g.rect.width-h.rect.width),p=Math.abs(g.rect.height-h.rect.height);return C+F+S+p<.035})||D.push(h),D.length>=24)break;const j=D.sort((h,m)=>m.rect.width*m.rect.height-h.rect.width*h.rect.height);return j.map((h,m)=>{let g,C=1/0;for(let F=0;F<j.length;F++){if(F===m||!Ue(j[F].rect,h.rect))continue;const S=j[F].rect.width*j[F].rect.height,p=h.rect.width*h.rect.height;S>p*1.08&&S<C&&(g=F,C=S)}return{bounds:h.rect,confidence:h.confidence,parentIndex:g}})}async function Ne(r){const s=new Image;s.decoding="async",s.src=r,await s.decode();const o=Math.min(1,640/Math.max(s.naturalWidth,s.naturalHeight)),d=Math.max(1,Math.round(s.naturalWidth*o)),u=Math.max(1,Math.round(s.naturalHeight*o)),c=document.createElement("canvas");c.width=d,c.height=u;const b=c.getContext("2d",{willReadFrequently:!0});return b?(b.drawImage(s,0,0,d,u),Be(b.getImageData(0,0,d,u))):[]}const ge=r=>({"bounds.x":String(Number(r.x.toFixed(5))),"bounds.y":String(Number(r.y.toFixed(5))),"bounds.width":String(Number(r.width.toFixed(5))),"bounds.height":String(Number(r.height.toFixed(5)))}),De=(r,s)=>({x:(r.x-s.x)/s.width,y:(r.y-s.y)/s.height,width:r.width/s.width,height:r.height/s.height}),Re=r=>r?r.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(r)?r:`/${r}`:"";function $e(r){return new Promise((s,o)=>{const d=new FileReader;d.onerror=()=>o(d.error??new Error("Could not read the image.")),d.onload=()=>{const u=String(d.result),c=new Image;c.onerror=()=>o(new Error("The selected file is not a readable image.")),c.onload=()=>s({base64:u.slice(u.indexOf(",")+1),width:c.naturalWidth,height:c.naturalHeight}),c.src=u},d.readAsDataURL(r)})}function ne(r){const s=r.reduce((o,d)=>{const u=[d.id,d.shortId,d.attributes.id].map(c=>/^UIE-(\d+)$/i.exec(c??"")).filter(c=>!!c).map(c=>Number(c[1]));return Math.max(o,...u)},0);return`UIE-${String(s+1).padStart(3,"0")}`}function ze(r){const s=r.reduce((o,d)=>{const u=[d.id,d.shortId,d.attributes.id].map(c=>/^UIA-(\d+)$/i.exec(c??"")).filter(c=>!!c).map(c=>Number(c[1]));return Math.max(o,...u)},0);return`UIA-${String(s+1).padStart(3,"0")}`}function re(r,s,o){var N;const d=((N=r.match(/(\d+)$/))==null?void 0:N[1])??"1",u=`${s}${Number(d)}`,c=new Set(o.map(v=>v.id));if(!c.has(u))return u;let b=2;for(;c.has(`${u}_${b}`);)b++;return`${u}_${b}`}function fe(r,s){const o=s.find(u=>u.id===r.id);if(o)return o;const d=r.name.toLowerCase().replace(/region layout|screen layout|[^a-z0-9]/g,"");return s.find(u=>{const c=u.name.toLowerCase().replace(/[^a-z0-9]/g,"");return c.length>0&&(d.includes(c)||c.includes(d))})}async function ie(r,s){var d;const o=Date.now()+1e4;for(;Date.now()<o;){const u=(d=E.getState().model)==null?void 0:d.elements[r];if(u&&u!==s)return;await new Promise(c=>setTimeout(c,100))}throw new Error("The new element was saved, but the rebuilt model did not arrive.")}async function Te(r,s,o){var u;const d=Date.now()+1e4;for(;Date.now()<d;){if((u=E.getState().model)==null?void 0:u.relationships.find(b=>b.type.toLowerCase()===r.toLowerCase()&&b.sourceId===s&&b.targetId===o))return!0;await new Promise(b=>setTimeout(b,100))}return!1}const Le=(r,s,o)=>{var d;return!!((d=E.getState().model)!=null&&d.relationships.some(u=>u.type.toLowerCase()===r.toLowerCase()&&u.sourceId===s&&u.targetId===o))};function He(){const r=E(e=>e.model),s=E(e=>e.createModelElement),o=E(e=>e.persistElementAttributes),d=E(e=>e.createRelationship),u=E(e=>e.createDiagram),c=E(e=>e.inspectElement),b=E(e=>e.selectedElementId),N=E(e=>e.deleteModelElement),[v,D]=x.useState(),[j,h]=x.useState(),[m,g]=x.useState(!1),[C,F]=x.useState(""),[S,p]=x.useState(""),[Y,U]=x.useState(!1),[P,J]=x.useState("NewUIScreen"),[V,R]=x.useState(!1),[A,$]=x.useState([]),[B,K]=x.useState(new Set),z=x.useRef(new Map),L=x.useRef(null),I=x.useMemo(()=>((r==null?void 0:r.diagrams)??[]).filter(e=>e.viewKind==="geometry"),[r]),O=x.useMemo(()=>r?Ce(r):[],[r]),X=x.useMemo(()=>r?Object.values(r.elements).filter(e=>{var t;return e.kind==="UIElement"&&((t=e.attributes.formKind)==null?void 0:t.endsWith("screen"))}):[],[r]),T=x.useMemo(()=>I.find(e=>e.id===v),[I,v]),Q=x.useMemo(()=>T?fe(T,X):void 0,[T,X]),Z=x.useMemo(()=>{const e=new Map;for(const t of(r==null?void 0:r.relationships)??[])t.type.toLowerCase()==="capturesscreen"&&e.set(t.sourceId,t.targetId);return e},[r]),G=x.useMemo(()=>Q?O.filter(e=>Z.get(e.id)===Q.id):[],[Z,O,Q]);if(x.useEffect(()=>{var e;I.some(t=>t.id===v)||D((e=I[0])==null?void 0:e.id)},[I,v]),x.useEffect(()=>{var e;G.some(t=>t.id===j)||h(((e=G[0])==null?void 0:e.id)??"__none__")},[j,G]),x.useEffect(()=>{$([]),z.current.clear()},[j]),!r)return null;const q=ve(r,{captureId:j}),_=Object.values(r.elements).filter(e=>e.kind==="UIElement"),w=Q??q.screen,xe=new Map(_.map(e=>[e.id,e])),W=new Map;for(const e of r.relationships){if(e.type.toLowerCase()!=="composes")continue;const t=xe.get(e.targetId);t&&W.set(e.sourceId,[...W.get(e.sourceId)??[],t])}const se=(e,t,i)=>{D(e);const a=t&&i?ke(r,t.id,i.id):t?he(r,t.id):void 0;a&&h(a.id),i&&c(i.id)},oe=e=>K(t=>{const i=new Set(t);return i.has(e)?i.delete(e):i.add(e),i}),ae=(e,t,i,a)=>n.jsxs("div",{role:"none",children:[n.jsx(pe,{id:`element:${e.id}`,label:e.name,depth:a,hasChildren:(W.get(e.id)??[]).length>0,expanded:!B.has(`element:${e.id}`),selected:e.id===b,badge:"UIE",badgeColor:"#0F766E",count:(W.get(e.id)??[]).length||void 0,title:`${e.name} · ${e.attributes.formKind??"UIElement"}`,onClick:()=>{(W.get(e.id)??[]).length&&oe(`element:${e.id}`),se(t,i,e)},onDelete:()=>N(e.id)}),!B.has(`element:${e.id}`)&&(W.get(e.id)??[]).map(l=>ae(l,t,i,a+1))]},e.id),te=async(e,t,i)=>{let a="";for(let l=0;l<3;l++){if(Le(e,t,i))return;const f=await d({type:e,sourceId:t,targetId:i,direction:"outgoing",selectedElementId:t});if(f.success&&await Te(e,t,i))return;a=f.success?"The relationship was written but did not appear in the rebuilt model.":f.error??"The relationship could not be created.",await new Promise(y=>setTimeout(y,250*(l+1)))}throw new Error(a||`Could not connect ${i} beneath ${t}.`)},de=async()=>{var t,i,a;const e=P.trim();if(e){p("Creating UI screen…");try{const l=ne(_),f=re(l,"uiElement",_),y=s({id:f,name:e,kind:"UIElement",construct:"part",layer:"implementation",file:"model/generated.sysml",doc:"",attributes:{id:l,description:`Root user-interface screen ${e}.`,formKind:"UIElementFormKind::screen",disclosureKind:"UIDisclosureKind::inline",detectionMethod:"BoundsDetectionKind::manual","bounds.x":"0","bounds.y":"0","bounds.width":"1","bounds.height":"1"}});await ie(y,(t=E.getState().model)==null?void 0:t.elements[y]);const M=((a=(i=r.viewpoints)==null?void 0:i.find(H=>H.label.toLowerCase().includes("ui layout")))==null?void 0:a.id)??"__model";u({id:l,name:`${e} — Region Layout`,diagramType:"bdd",viewKind:"geometry",viewpointId:M,elementIds:[f],activate:!1}),D(l),h("__none__"),c(f),U(!1),J("NewUIScreen"),p("UI screen created. Choose a capture asset or upload one.")}catch(l){p(l instanceof Error?l.message:String(l))}}},be=async e=>{if(!w)return p("Create or select a UI screen first.");const t=Z.get(e.id);if(t&&t!==w.id){const i=Object.values(r.elements).find(a=>a.id===t);return p(`“${e.name}” already depicts ${(i==null?void 0:i.name)??t}; duplicate the asset before reassigning it.`)}try{t||await te("CapturesScreen",e.id,w.id),h(e.id),R(!1),p(`Using capture asset “${e.name}”.`)}catch(i){p(i instanceof Error?i.message:String(i))}},ce=async(e,t={})=>{var i,a;if(!w){p("Add or capture a screen before drawing regions.");return}p("Saving region…");try{const l=ne(_),f=re(l,"uiElement",_);return s({id:f,name:((i=t.name)==null?void 0:i.trim())||`Region ${l}`,kind:"UIElement",construct:"part",layer:w.layer,file:w.file||"model/generated.sysml",doc:"",attributes:{id:l,...ge(e),formKind:"UIElementFormKind::panel",disclosureKind:"UIDisclosureKind::inline",detectionMethod:t.automatic?"BoundsDetectionKind::automaticConfirmed":"BoundsDetectionKind::manual",...t.confidence!==void 0?{detectionConfidence:String(Number(t.confidence.toFixed(3)))}:{},...t.automatic?{confirmedBy:"currentReviewer",confirmedAt:new Date().toISOString()}:{},boundaryColor:"#14B8A6",boundaryOpacity:"0.12"}}),await ie(f,(a=E.getState().model)==null?void 0:a.elements[f]),await te("Composes",t.parentElementId??w.id,f),g(!1),p("Region saved."),f}catch(l){p(l instanceof Error?l.message:String(l));return}},ye=async e=>{var t,i;if(!T||!w)return p("Choose a geometry view with a screen before uploading.");p("Saving capture…");try{const a=await $e(e),l=e.name.toLowerCase().split(".").pop(),f=e.type||(l==="png"?"image/png":l==="webp"?"image/webp":l==="jpg"||l==="jpeg"?"image/jpeg":"");if(!f)throw new Error("Choose a PNG, JPEG, or WebP capture.");const y=await Ee({viewName:T.name,fileName:e.name,base64:a.base64,mediaType:f});if(!y.success||!y.imageUri||!y.imageHash)throw new Error(y.error||"Capture upload failed.");const M=ze(O),H=s({id:re(M,"uiAsset",O),name:`${w.name} capture`,kind:"ScreenCapture",construct:"part",layer:w.layer,file:w.file||"model/generated.sysml",doc:"",attributes:{id:M,imageUri:y.imageUri,imageHash:y.imageHash,pixelWidth:String(a.width),pixelHeight:String(a.height),capturedBuild:C.trim(),captureContext:T.name}});await ie(H,(t=E.getState().model)==null?void 0:t.elements[H]),await te("CapturesScreen",H,w.id);for(const ue of _)(i=ue.attributes.detectionMethod)!=null&&i.endsWith("automatic")&&o(ue.id,{confirmedBy:"",confirmedAt:""});h(H),p("Capture saved; automatic regions require confirmation.")}catch(a){p(a instanceof Error?a.message:String(a))}},we=async()=>{if(!q.imageUri)return p("Attach a screen-capture asset before detecting regions.");p("Detecting nested boundaries…");try{const t=(await Ne(q.imageUri)).map((i,a)=>({id:`proposal-${a+1}`,bounds:i.bounds,confidence:i.confidence,parentId:i.parentIndex!==void 0?`proposal-${i.parentIndex+1}`:void 0,status:"pending"}));z.current.clear(),$(t),p(t.length?`${t.length} boundary proposal${t.length===1?"":"s"} found. Accept or reject each box.`:"No strong rectangular boundaries were detected; draw regions manually.")}catch(e){p(e instanceof Error?e.message:String(e))}},le=async e=>{const t=z.current.get(e);if(t)return t;const i=A.find(y=>y.id===e);if(!i||i.status==="rejected")return;let a,l=i.bounds;if(i.parentId){const y=A.find(M=>M.id===i.parentId);y&&y.status!=="rejected"&&(a=await le(y.id),a&&(l=De(i.bounds,y.bounds)))}const f=await ce(l,{parentElementId:a,automatic:!0,confidence:i.confidence});return f&&(z.current.set(e,f),$(y=>y.map(M=>M.id===e?{...M,status:"accepted"}:M))),f},Fe=e=>{const t=new Set([e]);let i=!0;for(;i;){i=!1;for(const a of A)a.parentId&&t.has(a.parentId)&&!t.has(a.id)&&(t.add(a.id),i=!0)}$(a=>a.map(l=>t.has(l.id)?{...l,status:"rejected"}:l)),p(`Rejected ${t.size} proposal${t.size===1?"":"s"}.`)};return n.jsxs("div",{className:"flex flex-1 min-h-0",style:{background:"#F7F7F5"},children:[n.jsxs("aside",{style:{width:250,flexShrink:0,borderRight:"1px solid #E5E5E0",background:"#FFFFFF",padding:"16px 12px",overflowY:"auto"},children:[n.jsxs("div",{className:"flex items-center",style:{margin:"0 8px 4px"},children:[n.jsx("h1",{style:{margin:0,flex:1,color:"#1B3A4B",fontSize:18,fontWeight:700},children:"UI Screens"}),n.jsx(ee,{icon:n.jsx(k.plus,{}),ariaLabel:"Add UI element",title:"Create a root UIElement screen",onClick:()=>U(e=>!e),active:Y})]}),n.jsx("p",{style:{margin:"0 8px 16px",color:"#6B7280",fontSize:12},children:"Capture, mark up, and trace screen regions."}),Y&&n.jsxs("div",{style:{margin:"0 4px 12px",padding:10,background:"#F7F7F5",border:"1px solid #E5E5E0",borderRadius:8},children:[n.jsx("label",{style:{display:"block",color:"#6B7280",fontSize:10,fontWeight:600,marginBottom:4},children:"UI ELEMENT NAME"}),n.jsx("input",{"aria-label":"New UI screen name",value:P,onChange:e=>J(e.target.value),onKeyDown:e=>{e.key==="Enter"&&de()},style:{width:"100%",border:"1px solid #D8D8D2",borderRadius:6,padding:"6px 8px",fontSize:12}}),n.jsxs("div",{className:"flex gap-2",style:{marginTop:8},children:[n.jsx("button",{onClick:()=>void de(),disabled:!P.trim(),style:{flex:1,border:0,borderRadius:6,padding:"5px 8px",background:"#1B3A4B",color:"#FFFFFF",fontSize:11,cursor:"pointer"},children:"Create screen"}),n.jsx("button",{onClick:()=>U(!1),style:{border:"1px solid #D8D8D2",borderRadius:6,padding:"5px 8px",background:"#FFFFFF",color:"#4B5563",fontSize:11,cursor:"pointer"},children:"Cancel"})]})]}),n.jsx("div",{role:"tree","aria-label":"UI screen hierarchy",children:I.map(e=>{const t=fe(e,X)??X.find(l=>{var f;return((f=he(r,l.id))==null?void 0:f.attributes.captureContext)===e.name});if(!t)return null;const i=`screen:${t.id}`,a=W.get(t.id)??[];return n.jsxs("div",{role:"none",style:{marginBottom:4},children:[n.jsx(pe,{id:i,label:t.name,depth:0,hasChildren:a.length>0,expanded:!B.has(i),selected:t.id===b,badge:"UIE",badgeColor:"#0F766E",title:"Root UIElement screen",onClick:()=>{a.length&&oe(i),se(e.id,t,t)},onDelete:()=>N(t.id)}),!B.has(i)&&n.jsx("div",{role:"group",children:a.map(l=>ae(l,e.id,t,1))})]},e.id)})})]}),n.jsx("main",{className:"flex-1 flex flex-col min-w-0 relative",children:T?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"flex items-center px-3 py-2",style:{minHeight:48,background:"#F7F7F5",borderBottom:"1px solid #E5E5E0"},children:n.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg",style:{width:"fit-content",maxWidth:"100%",background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:[n.jsx("span",{title:"Choose the independent capture asset used as the canvas backdrop",children:n.jsx(k.capture,{})}),n.jsxs("select",{"aria-label":"Attached screen capture",value:j??"__none__",onChange:e=>h(e.target.value),className:"text-xs font-semibold rounded-lg px-2 py-1",style:{color:"#5B6470",background:"#FFFFFF",border:"1px solid #E2E1DB",maxWidth:220},children:[G.length===0&&n.jsx("option",{value:"__none__",children:"No capture attached"}),G.map(e=>n.jsx("option",{value:e.id,children:e.name},e.id))]}),n.jsx(ee,{icon:n.jsx(k.info,{}),onClick:()=>q.capture&&c(q.capture.id),ariaLabel:"Inspect capture asset",title:"Open this ScreenCapture asset in Properties"}),n.jsx(ee,{icon:n.jsx(k.library,{}),label:"Assets",active:V,onClick:()=>R(e=>!e),title:"Choose a ScreenCapture from the asset library"}),n.jsx("input",{"aria-label":"New capture asset build",value:C,onChange:e=>F(e.target.value),placeholder:"Asset build",title:"Software build that produced the new capture asset",className:"text-xs rounded-lg px-2 py-1",style:{width:112,color:"#5B6470",background:"#FFFFFF",border:"1px solid #E2E1DB"}}),n.jsx(Ae,{children:n.jsx(ee,{icon:n.jsx(k.upload,{}),label:"Add capture",onClick:()=>{var e;return(e=L.current)==null?void 0:e.click()},title:"Create a ScreenCapture asset from a PNG, JPEG, or WebP image"})}),n.jsx("input",{ref:L,type:"file",accept:"image/png,image/jpeg,image/webp",hidden:!0,onChange:e=>{var t;return((t=e.target.files)==null?void 0:t[0])&&ye(e.target.files[0])}}),n.jsx(Me,{}),n.jsx(me,{icon:n.jsx(k.rectangle,{}),label:m?"Cancel drawing":"Add region",active:m,onClick:()=>g(e=>!e),title:"Drag a rectangle, then edit the region in Properties"}),n.jsx(me,{icon:n.jsx(k.detect,{}),label:"Detect",active:A.some(e=>e.status==="pending"),badge:A.filter(e=>e.status==="pending").length||void 0,onClick:()=>void we(),title:"Propose nested regions from detected image boundaries"}),S&&n.jsx("span",{role:"status",className:"truncate",style:{marginLeft:"auto",fontSize:je.xs,color:"#6B7280",maxWidth:180},children:S})]})}),j==="__none__"?n.jsx("div",{className:"flex-1 flex items-center justify-center p-8",style:{background:"#F7F7F5"},children:n.jsxs("div",{style:{width:"min(560px, 100%)",padding:28,textAlign:"center",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:14,boxShadow:"0 4px 18px rgba(15,23,42,0.06)"},children:[n.jsx("div",{style:{display:"inline-flex",padding:12,borderRadius:12,background:"#E1F5EE",color:"#0F766E"},children:n.jsx(k.capture,{size:28})}),n.jsxs("h2",{style:{margin:"14px 0 6px",color:"#1B3A4B",fontSize:18,fontWeight:700},children:["Add a visual asset to ",w==null?void 0:w.name]}),n.jsx("p",{style:{margin:"0 auto 18px",maxWidth:430,color:"#6B7280",fontSize:12,lineHeight:1.5},children:"Upload a new screen capture or link an existing ScreenCapture from the asset library. The asset remains independent and is connected through CapturesScreen."}),n.jsxs("div",{className:"flex justify-center gap-2",children:[n.jsxs("button",{onClick:()=>{var e;return(e=L.current)==null?void 0:e.click()},className:"flex items-center gap-2",style:{padding:"8px 13px",border:0,borderRadius:8,background:"#1B3A4B",color:"#FFFFFF",cursor:"pointer",fontSize:12,fontWeight:600},children:[n.jsx(k.upload,{})," Upload screen capture"]}),n.jsxs("button",{onClick:()=>R(!0),className:"flex items-center gap-2",style:{padding:"8px 13px",border:"1px solid #D8D8D2",borderRadius:8,background:"#FFFFFF",color:"#374151",cursor:"pointer",fontSize:12,fontWeight:600},children:[n.jsx(k.library,{})," Choose from asset library"]})]}),n.jsx("p",{style:{margin:"14px 0 0",color:"#9CA3AF",fontSize:10},children:"You can also create the CapturesScreen relationship later in Properties."})]})}):n.jsx(Ie,{diagram:T,model:r,captureId:j,editable:!0,drawMode:m,newElementDefaultName:`Region ${ne(_)}`,proposals:A,onAcceptProposal:e=>void le(e),onRejectProposal:Fe,onCreateBounds:(e,t)=>void ce(e,{name:t}),onBoundsChange:(e,t)=>o(e,ge(t))}),V&&n.jsx("div",{className:"absolute inset-0 flex items-start justify-center",onMouseDown:e=>{e.target===e.currentTarget&&R(!1)},style:{zIndex:50,paddingTop:70,background:"#0F172A33",backdropFilter:"blur(1px)"},children:n.jsxs("div",{role:"dialog","aria-label":"ScreenCapture asset library",style:{width:"min(720px, calc(100% - 40px))",maxHeight:"calc(100% - 100px)",overflowY:"auto",background:"#FFFFFF",border:"1px solid #D1D5DB",borderRadius:12,boxShadow:"0 18px 50px rgba(15,23,42,0.22)"},children:[n.jsxs("div",{className:"flex items-center",style:{position:"sticky",top:0,zIndex:2,padding:"12px 14px",background:"#FFFFFF",borderBottom:"1px solid #E5E5E0"},children:[n.jsxs("div",{style:{flex:1},children:[n.jsx("strong",{style:{color:"#1B3A4B",fontSize:14},children:"ScreenCapture asset library"}),n.jsx("div",{style:{color:"#6B7280",fontSize:10},children:"Choose an unassigned asset or one already linked to this screen."})]}),n.jsx("button",{"aria-label":"Close asset library",onClick:()=>R(!1),style:{width:28,height:28,border:0,borderRadius:6,background:"#F0F0ED",color:"#4B5563",cursor:"pointer"},children:"×"})]}),n.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(205px, 1fr))",gap:10,padding:12},children:[O.length===0&&n.jsx("div",{style:{gridColumn:"1 / -1",padding:28,textAlign:"center",color:"#9CA3AF",fontSize:12},children:"No capture assets yet. Upload the first capture."}),O.map(e=>{const t=Z.get(e.id),i=t?Object.values(r.elements).find(l=>l.id===t):void 0,a=!t||t===(w==null?void 0:w.id);return n.jsxs("button",{disabled:!a,onClick:()=>void be(e),style:{display:"block",minWidth:0,padding:0,overflow:"hidden",textAlign:"left",border:`1px solid ${e.id===j?"#2DD4A8":"#E5E5E0"}`,borderRadius:9,background:e.id===j?"#F0FDFA":"#FFFFFF",color:a?"#374151":"#9CA3AF",cursor:a?"pointer":"not-allowed",opacity:a?1:.58},children:[n.jsx("div",{style:{height:118,background:"#F3F4F6",borderBottom:"1px solid #E5E5E0"},children:e.attributes.imageUri?n.jsx("img",{src:Re(e.attributes.imageUri),alt:"",style:{width:"100%",height:"100%",objectFit:"contain"}}):n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx(k.capture,{size:28})})}),n.jsxs("div",{style:{padding:"8px 9px"},children:[n.jsx("div",{className:"truncate",style:{fontSize:11,fontWeight:650},children:e.name}),n.jsx("div",{className:"truncate",style:{fontSize:10,marginTop:3},children:i?`Depicts ${i.name}`:"Unassigned asset"}),e.attributes.capturedBuild&&n.jsx("div",{className:"truncate",style:{fontSize:9,color:"#9CA3AF",marginTop:2},children:e.attributes.capturedBuild})]})]},e.id)})]})]})})]}):n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"#6B7280",textAlign:"center"},children:n.jsxs("div",{children:[n.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:4},children:n.jsx(Se,{size:190})}),n.jsx("h2",{style:{color:"#374151",fontSize:18},children:"No screen-layout views"}),n.jsx("p",{children:"Add a MemoScreenLayoutView to begin."})]})})})]})}export{He as UiScreensWorkspace,ze as nextUiAssetId,ne as nextUiElementId,re as usageIdentifier};
@@ -1 +1 @@
1
- import{j as t}from"./reactflow-CsCqNKB-.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as p}from"./index-D0vtjNjX.js";const l=[{id:"setup",icon:"🎯",title:"Set Up Your Device",description:"Define who your device is for, what it does, and who uses it. Start with actors and intended use.",standard:"IEC 62366 · ISO 14971 §4",getCount:e=>Object.values(e.elements).filter(s=>["actor","stakeholder","usecase","goal"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="actor").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="usecase").length;return`${s} actor(s) · ${i} use case(s)`}},{id:"requirements",icon:"📋",title:"Define Requirements",description:"Capture user needs and system requirements. These form the basis of your V&V plan.",standard:"IEC 62304 §5.2 · 21 CFR 820.30(c)",getCount:e=>Object.values(e.elements).filter(s=>["systemrequirement","requirement","userneed"].includes(s.kind.toLowerCase())).length,getTarget:()=>5,actionLabel:"View Catalog",actionView:"catalog",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="userneed").length,i=Object.values(e.elements).filter(n=>["systemrequirement","requirement"].includes(n.kind.toLowerCase())).length;return`${s} user need(s) · ${i} system requirement(s)`}},{id:"hazards",icon:"⚠️",title:"Identify Hazards",description:"List all hazards your device could cause. Add hazardous situations and potential harms.",standard:"ISO 14971 §5–6",getCount:e=>Object.values(e.elements).filter(s=>["hazard","hazardoussituation","harm"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Risk Layer",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="hazard").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="harm").length;return`${s} hazard(s) · ${i} harm(s)`}},{id:"risk-controls",icon:"🔗",title:"Connect Risk Chain",description:"Add risk controls and connect them to hazards with Mitigates relationships. Verify the ISO 14971 chain.",standard:"ISO 14971 §7–8",getCount:e=>e.relationships.filter(s=>s.type.toLowerCase()==="mitigates").length,getTarget:()=>2,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="riskcontrol").length,i=e.relationships.filter(n=>n.type.toLowerCase()==="mitigates").length;return`${s} risk control(s) · ${i} mitigates link(s)`}},{id:"architecture",icon:"🏗️",title:"Define Architecture",description:"Add system and subsystem elements. This grounds requirements to real components.",standard:"IEC 62304 §5.3 · ISO 14971 §9",getCount:e=>Object.values(e.elements).filter(s=>["system","subsystem","logicalcomponent","softwarecomponent"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>["system","subsystem"].includes(n.kind.toLowerCase())).length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="softwarecomponent").length;return`${s} system/subsystem · ${i} software component(s)`}},{id:"verification",icon:"🧪",title:"Link Verification",description:"Add tests and link them to requirements. This closes the V&V loop and prepares your design review package.",standard:"IEC 62304 §5.7–5.8 · 21 CFR 820.30(g)",getCount:e=>Object.values(e.elements).filter(s=>s.kind.toLowerCase()==="test").length,getTarget:()=>3,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="test").length,i=e.relationships.filter(n=>["satisfies","refines","traces","verifies"].includes(n.type.toLowerCase())).length;return`${s} test(s) · ${i} traceability link(s)`}}];function m({step:e,index:s,isActive:i,model:n,onSelect:d,onAction:c}){const r=e.getCount(n),o=e.getTarget(),a=r>=o,u=Math.min(100,Math.round(r/o*100)),h=e.getDetails(n),g=a?"#2ECC71":r>0?"#F39C12":"#E5E5E0";return t.jsxs("button",{onClick:d,style:{textAlign:"left",background:i?"#FFFFFF":"transparent",border:`1px solid ${i?"#1B3A4B20":"transparent"}`,borderRadius:"10px",padding:"14px 16px",cursor:"pointer",width:"100%",transition:"all 0.15s",boxShadow:i?"0 2px 8px rgba(0,0,0,0.06)":"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[t.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",flexShrink:0,background:a?"#2ECC71":i?"#1B3A4B":"#F3F4F6",color:a||i?"#FFFFFF":"#6B7280",display:"flex",alignItems:"center",justifyContent:"center",fontSize:a?"14px":"12px",fontWeight:700},children:a?"✓":s+1}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:i?"#1B3A4B":"#374151"},children:[e.icon," ",e.title]}),r>0&&t.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"1px 6px",borderRadius:"999px",background:g+"20",color:g},children:r})]}),h&&t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"2px"},children:h})]}),t.jsxs("div",{style:{width:"40px",textAlign:"right",fontSize:"10px",color:"#9CA3AF",flexShrink:0},children:[u,"%"]})]}),t.jsx("div",{style:{marginTop:"8px",height:"3px",background:"#F3F4F6",borderRadius:"2px",marginLeft:"38px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"2px",background:g,width:`${u}%`,transition:"width 0.4s ease"}})})]})}function f({step:e,model:s,onAction:i}){const n=e.getCount(s),d=e.getTarget(),c=n>=d;return t.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"24px"},children:[t.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:e.icon}),t.jsx("h2",{style:{fontSize:"18px",fontWeight:800,color:"#1B3A4B",margin:"0 0 6px 0"},children:e.title}),t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#9CA3AF",marginBottom:"12px",fontFamily:"monospace"},children:e.standard}),t.jsx("p",{style:{fontSize:"13px",color:"#4B6E80",lineHeight:"1.7",margin:"0 0 20px 0"},children:e.description}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"8px",background:c?"#2ECC7110":n>0?"#F39C1210":"#F3F4F6",marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"24px",fontWeight:800,color:c?"#2ECC71":n>0?"#F39C12":"#9CA3AF"},children:n}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:c?`✓ Target reached (${d}+ recommended)`:`${d-n} more recommended`}),t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:e.getDetails(s)})]})]}),t.jsxs("button",{onClick:()=>i(e.actionView),style:{width:"100%",padding:"12px",borderRadius:"8px",background:"#1B3A4B",color:"#FFFFFF",border:"none",fontSize:"13px",fontWeight:600,cursor:"pointer",transition:"background 0.15s"},onMouseEnter:r=>r.currentTarget.style.background="#244D63",onMouseLeave:r=>r.currentTarget.style.background="#1B3A4B",children:[e.actionLabel," →"]})]})}function y({model:e}){const s=l.filter(n=>n.getCount(e)>=n.getTarget()).length,i=Math.round(s/l.length*100);return t.jsxs("div",{style:{padding:"16px 20px",background:"#FFFFFF",borderRadius:"12px",border:"1px solid #E5E5E0",marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:"Golden Path Progress"}),t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:[s,"/",l.length," steps"]})]}),t.jsx("div",{style:{height:"6px",background:"#F3F4F6",borderRadius:"3px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"3px",background:i>=100?"#2ECC71":"#2DD4A8",width:`${i}%`,transition:"width 0.4s ease"}})})]})}function j(){const e=p(o=>o.model),s=p(o=>o.setActiveView),i=p(o=>o.setExplorerTab),n=x.useMemo(()=>{if(!e)return 0;for(let o=0;o<l.length;o++)if(l[o].getCount(e)<l[o].getTarget())return o;return l.length-1},[e]),[d,c]=x.useState(n);if(!e)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:t.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"No model data"})});function r(o){switch(o){case"model":i("model"),s({type:"dashboard"});break;case"traceability":s({type:"traceability"});break;case"statistics":s({type:"statistics"});break;case"catalog":i("model"),s({type:"dashboard"});break}}return t.jsx("div",{style:{flex:1,overflowY:"auto",background:"#F7F7F5",padding:"28px 40px"},children:t.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"20px"},children:[t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:"20px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:"Workflow Wizard"}),t.jsx("p",{style:{fontSize:"12px",color:"#6B7280",margin:0},children:"Follow the golden path to a complete, review-ready device model"})]}),t.jsx("button",{onClick:()=>s({type:"dashboard"}),style:{fontSize:"12px",color:"#6B7280",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"6px 12px",cursor:"pointer",fontWeight:500},children:"← Back to Dashboard"})]}),t.jsx(y,{model:e}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"380px 1fr",gap:"16px"},children:[t.jsx("div",{style:{background:"#F9FAFB",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"8px",display:"flex",flexDirection:"column",gap:"2px"},children:l.map((o,a)=>t.jsx(m,{step:o,index:a,isActive:a===d,model:e,onSelect:()=>c(a),onAction:r},o.id))}),t.jsx(f,{step:l[d],model:e,onAction:r})]})]})})}export{j as WorkflowWizard};
1
+ import{j as t}from"./reactflow-s7jmJtXx.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as p}from"./index-Bij8Q4Kg.js";const l=[{id:"setup",icon:"🎯",title:"Set Up Your Device",description:"Define who your device is for, what it does, and who uses it. Start with actors and intended use.",standard:"IEC 62366 · ISO 14971 §4",getCount:e=>Object.values(e.elements).filter(s=>["actor","stakeholder","usecase","goal"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="actor").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="usecase").length;return`${s} actor(s) · ${i} use case(s)`}},{id:"requirements",icon:"📋",title:"Define Requirements",description:"Capture user needs and system requirements. These form the basis of your V&V plan.",standard:"IEC 62304 §5.2 · 21 CFR 820.30(c)",getCount:e=>Object.values(e.elements).filter(s=>["systemrequirement","requirement","userneed"].includes(s.kind.toLowerCase())).length,getTarget:()=>5,actionLabel:"View Catalog",actionView:"catalog",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="userneed").length,i=Object.values(e.elements).filter(n=>["systemrequirement","requirement"].includes(n.kind.toLowerCase())).length;return`${s} user need(s) · ${i} system requirement(s)`}},{id:"hazards",icon:"⚠️",title:"Identify Hazards",description:"List all hazards your device could cause. Add hazardous situations and potential harms.",standard:"ISO 14971 §5–6",getCount:e=>Object.values(e.elements).filter(s=>["hazard","hazardoussituation","harm"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Risk Layer",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="hazard").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="harm").length;return`${s} hazard(s) · ${i} harm(s)`}},{id:"risk-controls",icon:"🔗",title:"Connect Risk Chain",description:"Add risk controls and connect them to hazards with Mitigates relationships. Verify the ISO 14971 chain.",standard:"ISO 14971 §7–8",getCount:e=>e.relationships.filter(s=>s.type.toLowerCase()==="mitigates").length,getTarget:()=>2,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="riskcontrol").length,i=e.relationships.filter(n=>n.type.toLowerCase()==="mitigates").length;return`${s} risk control(s) · ${i} mitigates link(s)`}},{id:"architecture",icon:"🏗️",title:"Define Architecture",description:"Add system and subsystem elements. This grounds requirements to real components.",standard:"IEC 62304 §5.3 · ISO 14971 §9",getCount:e=>Object.values(e.elements).filter(s=>["system","subsystem","logicalcomponent","softwarecomponent"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>["system","subsystem"].includes(n.kind.toLowerCase())).length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="softwarecomponent").length;return`${s} system/subsystem · ${i} software component(s)`}},{id:"verification",icon:"🧪",title:"Link Verification",description:"Add tests and link them to requirements. This closes the V&V loop and prepares your design review package.",standard:"IEC 62304 §5.7–5.8 · 21 CFR 820.30(g)",getCount:e=>Object.values(e.elements).filter(s=>s.kind.toLowerCase()==="test").length,getTarget:()=>3,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="test").length,i=e.relationships.filter(n=>["satisfies","refines","traces","verifies"].includes(n.type.toLowerCase())).length;return`${s} test(s) · ${i} traceability link(s)`}}];function m({step:e,index:s,isActive:i,model:n,onSelect:d,onAction:c}){const r=e.getCount(n),o=e.getTarget(),a=r>=o,u=Math.min(100,Math.round(r/o*100)),h=e.getDetails(n),g=a?"#2ECC71":r>0?"#F39C12":"#E5E5E0";return t.jsxs("button",{onClick:d,style:{textAlign:"left",background:i?"#FFFFFF":"transparent",border:`1px solid ${i?"#1B3A4B20":"transparent"}`,borderRadius:"10px",padding:"14px 16px",cursor:"pointer",width:"100%",transition:"all 0.15s",boxShadow:i?"0 2px 8px rgba(0,0,0,0.06)":"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[t.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",flexShrink:0,background:a?"#2ECC71":i?"#1B3A4B":"#F3F4F6",color:a||i?"#FFFFFF":"#6B7280",display:"flex",alignItems:"center",justifyContent:"center",fontSize:a?"14px":"12px",fontWeight:700},children:a?"✓":s+1}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:i?"#1B3A4B":"#374151"},children:[e.icon," ",e.title]}),r>0&&t.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"1px 6px",borderRadius:"999px",background:g+"20",color:g},children:r})]}),h&&t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"2px"},children:h})]}),t.jsxs("div",{style:{width:"40px",textAlign:"right",fontSize:"10px",color:"#9CA3AF",flexShrink:0},children:[u,"%"]})]}),t.jsx("div",{style:{marginTop:"8px",height:"3px",background:"#F3F4F6",borderRadius:"2px",marginLeft:"38px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"2px",background:g,width:`${u}%`,transition:"width 0.4s ease"}})})]})}function f({step:e,model:s,onAction:i}){const n=e.getCount(s),d=e.getTarget(),c=n>=d;return t.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"24px"},children:[t.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:e.icon}),t.jsx("h2",{style:{fontSize:"18px",fontWeight:800,color:"#1B3A4B",margin:"0 0 6px 0"},children:e.title}),t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#9CA3AF",marginBottom:"12px",fontFamily:"monospace"},children:e.standard}),t.jsx("p",{style:{fontSize:"13px",color:"#4B6E80",lineHeight:"1.7",margin:"0 0 20px 0"},children:e.description}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"8px",background:c?"#2ECC7110":n>0?"#F39C1210":"#F3F4F6",marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"24px",fontWeight:800,color:c?"#2ECC71":n>0?"#F39C12":"#9CA3AF"},children:n}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:c?`✓ Target reached (${d}+ recommended)`:`${d-n} more recommended`}),t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:e.getDetails(s)})]})]}),t.jsxs("button",{onClick:()=>i(e.actionView),style:{width:"100%",padding:"12px",borderRadius:"8px",background:"#1B3A4B",color:"#FFFFFF",border:"none",fontSize:"13px",fontWeight:600,cursor:"pointer",transition:"background 0.15s"},onMouseEnter:r=>r.currentTarget.style.background="#244D63",onMouseLeave:r=>r.currentTarget.style.background="#1B3A4B",children:[e.actionLabel," →"]})]})}function y({model:e}){const s=l.filter(n=>n.getCount(e)>=n.getTarget()).length,i=Math.round(s/l.length*100);return t.jsxs("div",{style:{padding:"16px 20px",background:"#FFFFFF",borderRadius:"12px",border:"1px solid #E5E5E0",marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:"Golden Path Progress"}),t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:[s,"/",l.length," steps"]})]}),t.jsx("div",{style:{height:"6px",background:"#F3F4F6",borderRadius:"3px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"3px",background:i>=100?"#2ECC71":"#2DD4A8",width:`${i}%`,transition:"width 0.4s ease"}})})]})}function j(){const e=p(o=>o.model),s=p(o=>o.setActiveView),i=p(o=>o.setExplorerTab),n=x.useMemo(()=>{if(!e)return 0;for(let o=0;o<l.length;o++)if(l[o].getCount(e)<l[o].getTarget())return o;return l.length-1},[e]),[d,c]=x.useState(n);if(!e)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:t.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"No model data"})});function r(o){switch(o){case"model":i("model"),s({type:"dashboard"});break;case"traceability":s({type:"traceability"});break;case"statistics":s({type:"statistics"});break;case"catalog":i("model"),s({type:"dashboard"});break}}return t.jsx("div",{style:{flex:1,overflowY:"auto",background:"#F7F7F5",padding:"28px 40px"},children:t.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"20px"},children:[t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:"20px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:"Workflow Wizard"}),t.jsx("p",{style:{fontSize:"12px",color:"#6B7280",margin:0},children:"Follow the golden path to a complete, review-ready device model"})]}),t.jsx("button",{onClick:()=>s({type:"dashboard"}),style:{fontSize:"12px",color:"#6B7280",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"6px 12px",cursor:"pointer",fontWeight:500},children:"← Back to Dashboard"})]}),t.jsx(y,{model:e}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"380px 1fr",gap:"16px"},children:[t.jsx("div",{style:{background:"#F9FAFB",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"8px",display:"flex",flexDirection:"column",gap:"2px"},children:l.map((o,a)=>t.jsx(m,{step:o,index:a,isActive:a===d,model:e,onSelect:()=>c(a),onAction:r},o.id))}),t.jsx(f,{step:l[d],model:e,onAction:r})]})]})})}export{j as WorkflowWizard};
@@ -0,0 +1,3 @@
1
+ import{j as c}from"./reactflow-s7jmJtXx.js";import{a as E}from"./zustand-CrhqMOHB.js";import{C as l,F as R,h as W,S as G}from"./index-Bij8Q4Kg.js";const J=["composes","composedOf","decomposedBy","aggregation","includes","includesStep","containsEvent","moduleUses"];function _(e){const r=new Set(e.relationships.map(t=>t.type));return J.filter(t=>r.has(t))}function Z(e){return[...new Set(e.relationships.map(r=>r.type))].sort()}function V(e){const r=new Map;for(const t of Object.values(e.elements)){const o=t.layer||"unassigned";let n=r.get(o);n||(n=new Map,r.set(o,n)),n.set(t.kind,(n.get(t.kind)??0)+1)}return[...r.entries()].map(([t,o])=>({layer:t,elementCount:[...o.values()].reduce((n,s)=>n+s,0),kinds:[...o.entries()].map(([n,s])=>({kind:n,elementCount:s})).sort((n,s)=>s.elementCount-n.elementCount||n.kind.localeCompare(s.kind))})).sort((t,o)=>o.elementCount-t.elementCount||t.layer.localeCompare(o.layer))}function ee(e,r){const t=new Set(r??_(e)),o=new Map;for(const s of e.relationships){if(t.has(s.type))continue;const d=e.elements[s.sourceId],i=e.elements[s.targetId];!d||!i||d.layer!==i.layer||o.set(d.layer,(o.get(d.layer)??0)+1)}const n=V(e);if(n.length!==0)return[...n].sort((s,d)=>(o.get(d.layer)??0)-(o.get(s.layer)??0)||d.elementCount-s.elementCount||s.layer.localeCompare(d.layer))[0].layer}function ye(e,r){const t=new Set(_(e)),o=new Map;for(const i of e.relationships){if(t.has(i.type))continue;const f=e.elements[i.sourceId],g=e.elements[i.targetId];if(!f||!g||f.layer===g.layer)continue;const p=`${f.layer}>${g.layer}`;o.set(p,(o.get(p)??0)+1)}const n=[...o.entries()].sort((i,f)=>f[1]-i[1]||i[0].localeCompare(f[0]))[0];if(!n){const i=ee(e,r);return{rows:i,columns:i}}const[s,d]=n[0].split(">");return{rows:s,columns:d}}function te(e,r){const t=new Map;for(const n of Object.values(e.elements)){const s=n.parentAction??n.owner;s&&e.elements[s]&&t.set(n.id,s)}const o=new Set(r);for(const n of e.relationships)o.has(n.type)&&(!e.elements[n.sourceId]||!e.elements[n.targetId]||n.sourceId!==n.targetId&&t.set(n.targetId,n.sourceId));for(const n of[...t.keys()]){const s=new Set([n]);let d=t.get(n);for(;d;){if(s.has(d)){t.delete(d);break}s.add(d),d=t.get(d)}}return t}function ne(e,r){const t=[],o=new Set([e]);let n=r.get(e);for(;n&&!o.has(n);)t.push(n),o.add(n),n=r.get(n);return t}function K(e,r,t,o,n){const s=new Set((o==null?void 0:o.kinds)??[]),d=new Set((o==null?void 0:o.elementIds)??[]),i=u=>(!(o!=null&&o.layer)||u.layer===o.layer)&&(s.size===0||s.has(u.kind))&&(d.size===0||d.has(u.id)),f=new Set;for(const u of Object.values(e.elements))if(i(u)){f.add(u.id);for(const w of ne(u.id,r))f.add(w)}const g=new Map,p=u=>{const w=g.get(u);if(w)return w;const S=[u];g.set(u,S);for(const A of t.get(u)??[])A!==u&&S.push(...p(A));return S},v=new Map,y=(u,w)=>{const S=v.get(u);if(S)return S;const A=e.elements[u],x={id:u,name:(A==null?void 0:A.name)??u,kind:(A==null?void 0:A.kind)??"Unknown",layer:(A==null?void 0:A.layer)??"",isElement:!0,children:[],members:p(u),depth:w};return v.set(u,x),x.children=(t.get(u)??[]).filter(L=>f.has(L)&&L!==u).map(L=>y(L,w+1)),x};let $=[...f].filter(u=>{const w=r.get(u);return!w||!f.has(w)}).map(u=>y(u,0));n&&($=oe($,e));const k=new Map,h=new Map,j=(u,w)=>{w&&h.set(u.id,w),u.children.forEach(S=>j(S,u));for(const S of u.members)k.has(S)||k.set(S,u)};return $.forEach(u=>j(u,void 0)),{roots:$,ownerOf:k,parentNodeOf:h}}function oe(e,r){var d;const t=[],o=new Map,n=i=>{const f=i.join("::"),g=o.get(f);if(g)return g;const p={id:`pkg:${f}`,name:i[i.length-1],kind:"Package",layer:"",isElement:!1,children:[],members:[],depth:i.length-1};return o.set(f,p),i.length===1?t.push(p):n(i.slice(0,-1)).children.push(p),p};for(const i of e){const f=(d=r.elements[i.id])==null?void 0:d.package;if(!f){t.push(i);continue}n(f.split("::")).children.push(i)}const s=(i,f)=>{i.depth=f,i.children.forEach(g=>s(g,f+1)),i.isElement||(i.members=i.children.flatMap(g=>g.members))};return t.forEach(i=>s(i,0)),t}function q(e,r,t){const o=(i,f)=>i.name.localeCompare(f.name),n=(i,f)=>i.kind.localeCompare(f.kind)||o(i,f),s=i=>i.length<2?i:r==="natural"?[...i].sort(o):r==="kind"?[...i].sort(n):r==="partition"?re(i,t):se(i,t),d=i=>{const f=s(i);for(const g of f)g.children=d(g.children);return f};return d(e)}function re(e,r){const t=[...e].sort((n,s)=>n.name.localeCompare(s.name)),o=[];for(;t.length>0;){const n=t.filter(s=>!t.some(d=>d!==s&&r(d,s)));if(n.length===0){o.push(...t);break}for(const s of n)o.push(s),t.splice(t.indexOf(s),1)}return o}function se(e,r){const t=e.map((s,d)=>d),o=s=>t[s]===s?s:t[s]=o(t[s]);for(let s=0;s<e.length;s++)for(let d=s+1;d<e.length;d++)(r(e[s],e[d])||r(e[d],e[s]))&&(t[o(s)]=o(d));const n=new Map;return e.forEach((s,d)=>{const i=o(d),f=n.get(i);f?f.push(s):n.set(i,[s])}),[...n.values()].map(s=>s.sort((d,i)=>d.name.localeCompare(i.name))).sort((s,d)=>d.length-s.length||s[0].name.localeCompare(d[0].name)).flat()}function Y(e,r){const t=[],o=(n,s,d)=>{const i=n.children.length>0,f=i&&r.has(n.id);if(t.push({node:n,index:t.length+1,depth:s,expandable:i,expanded:f,ancestorIds:d,memberCount:n.members.length}),!f)return;const g=[...d,n.id];for(const p of n.children)o(p,s+1,g)};return e.forEach(n=>o(n,0,[])),t}function be(e,r=1/0){const t=[],o=(n,s)=>{s>=r||(n.children.length>0&&t.push(n.id),n.children.forEach(d=>o(d,s+1)))};return e.forEach(n=>o(n,0)),t}function we(e,r={}){var B,D;const t=r.containmentTypes??_(e),o=te(e,t),n=new Map;for(const[a,m]of o){const I=n.get(m);I?I.push(a):n.set(m,[a])}const s=new Set(r.dependencyTypes??[]),d=a=>(s.size===0||s.has(a.type))&&!t.includes(a.type),i=e.relationships.filter(d),f=r.groupByPackage??!1,g=K(e,o,n,r.rows,f),p=K(e,o,n,r.columns,f),v=a=>{const m=new Set,I=C=>{const z=[];let O=a.ownerOf.get(C);for(;O;)z.push(O.id),O=a.parentNodeOf.get(O.id);return z},M=(C,z)=>{for(const O of I(C))for(const T of I(z))O!==T&&m.add(`${O}>${T}`)};for(const C of i)M(C.sourceId,C.targetId),r.symmetric&&M(C.targetId,C.sourceId);return(C,z)=>C!==z&&m.has(`${C.id}>${z.id}`)},y=r.ordering??"natural",b=q(g.roots,y,v(g)),$=q(p.roots,y,v(p)),k=Y(b,((B=r.rows)==null?void 0:B.expanded)??new Set),h=Y($,((D=r.columns)==null?void 0:D.expanded)??new Set),j=new Map;k.forEach((a,m)=>j.set(a.node.id,m));const u=new Map;h.forEach((a,m)=>u.set(a.node.id,m));const w=(a,m,I)=>{let M=m.ownerOf.get(a);const C=new Set;for(;M&&!C.has(M.id);){C.add(M.id);const z=I.get(M.id);if(z!==void 0)return z;M=m.parentNodeOf.get(M.id)}},S=Array.from({length:k.length},()=>Array.from({length:h.length},()=>null));let A=0,x=0;const L=(a,m,I)=>{const M=w(m,g,j),C=w(I,p,u);if(M===void 0||C===void 0)return;const z=k[M],O=h[C],T=z.node.id===O.node.id;let F=S[M][C];F||(F={strength:0,types:[],relationshipIds:[],diagonal:T,aggregated:z.node.id!==m||O.node.id!==I},S[M][C]=F),F.strength++,(z.node.id!==m||O.node.id!==I)&&(F.aggregated=!0),F.types.includes(a.type)||F.types.push(a.type),F.relationshipIds.push(a.id),T?x++:A++};for(const a of i)L(a,a.sourceId,a.targetId),r.symmetric&&L(a,a.targetId,a.sourceId);return{rowRoots:b,columnRoots:$,rows:k,columns:h,matrix:S,totalDependencies:A,candidateDependencies:i.length,elementCount:Object.keys(e.elements).length,stats:ie(k,h,S,x),availableDependencyTypes:Z(e)}}function ie(e,r,t,o){const n=new Map;r.forEach((p,v)=>n.set(p.node.id,v));let s=0,d=0,i=0,f=0;const g=new Array(r.length).fill(0);e.forEach((p,v)=>{let y=0;t[v].forEach((b,$)=>{if(!b||b.diagonal)return;y+=b.strength,g[$]+=b.strength;const k=n.get(p.node.id);k!==void 0&&$<k&&(s+=b.strength)}),f=Math.max(f,y)}),e.forEach((p,v)=>{const y=t[v].some(k=>k&&!k.diagonal),b=n.get(p.node.id),$=b!==void 0&&t.some(k=>k[b]&&!k[b].diagonal);!y&&!$&&i++});for(let p=0;p<e.length;p++){const v=n.get(e[p].node.id);if(v!==void 0)for(let y=0;y<r.length;y++){const b=t[p][y];if(!b||b.diagonal||y>=v)continue;const $=e.findIndex(k=>k.node.id===r[y].node.id);$>=0&&t[$][v]&&d++}}return g.forEach(p=>{f=Math.max(f,p)}),{feedback:s,couplings:d,isolated:i,maxDegree:f,internal:o}}const X=300,N=24,ae=9e4;function H(e){return e<=0?"2px solid #94A3B8":e===1?"1px solid #B6C4D0":`1px solid ${l.borderLight}`}function Q(e){return e.map((r,t)=>{if(t===0)return null;const o=e[t-1];return r.ancestorIds.includes(o.node.id)?null:Math.min(r.depth,o.depth)})}function ke({result:e,onToggleRow:r,onToggleColumn:t,onSelectElement:o,selectedElementId:n,renderCell:s,onCellClick:d,cellSize:i=26,showColumnNames:f=!1,footer:g}){const[p,v]=E.useState(null),{rows:y,columns:b,matrix:$,elementCount:k}=e,h=E.useMemo(()=>Q(y),[y]),j=E.useMemo(()=>Q(b),[b]),u=x=>x.ancestorIds[0]??x.node.id,w=x=>x.length>N?`${x.slice(0,N-1)}…`:x,S=f?34+Math.min(N,Math.max(0,...b.map(x=>x.node.name.length)))*4.6:26;if(y.length===0||b.length===0)return c.jsx("div",{className:"flex-1 flex items-center justify-center",style:{padding:"40px"},children:c.jsxs("div",{style:{textAlign:"center",maxWidth:"340px"},children:[c.jsx("div",{style:{fontSize:"34px",opacity:.35,marginBottom:"10px"},children:"▦"}),c.jsx("h3",{style:{fontSize:R.md,fontWeight:600,color:l.secondary,marginBottom:"6px"},children:"Nothing to plot"}),c.jsx("p",{style:{fontSize:R.xs,color:l.faint,lineHeight:1.6},children:"No element matches the chosen row and column types. Widen either axis, or clear the type filter to see the whole model."})]})});const A=y.length*b.length>ae;return c.jsxs("div",{style:{padding:"14px",overflow:"auto",flex:1},children:[A&&c.jsxs("div",{style:{marginBottom:"10px",padding:"8px 10px",borderRadius:"6px",background:"#FEF3C7",border:"1px solid #FCD34D",fontSize:R.xs,color:"#92400E"},children:[y.length.toLocaleString()," × ",b.length.toLocaleString()," is past what stays responsive to draw. Collapse a few subsystems, or narrow the row and column types."]}),!A&&c.jsxs("div",{style:{display:"inline-block",minWidth:"100%"},children:[c.jsxs("div",{style:{display:"flex",position:"sticky",top:0,zIndex:20,background:l.surface},children:[c.jsxs("div",{style:{width:X,flexShrink:0,height:S,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",paddingRight:"8px",paddingBottom:"3px",fontSize:"10px",color:l.faint,borderBottom:`1px solid ${l.border}`},children:[y.length," rows ","×"," ",b.length," cols"]}),b.map((x,L)=>{const B=(p==null?void 0:p.column)===L;return c.jsxs("div",{onClick:()=>x.expandable?t(x.node.id):o==null?void 0:o(x.node.id),onMouseEnter:()=>v({row:-1,column:L}),onMouseLeave:()=>v(null),title:`${x.index}. ${x.node.name} (${x.node.kind})${x.expandable?" — click to expand":""}`,style:{width:i,flexShrink:0,height:S,position:"relative",cursor:"pointer",borderLeft:j[L]===null?void 0:H(j[L]),borderBottom:`1px solid ${l.border}`,background:B?"#EAF7F3":"transparent"},children:[f&&c.jsxs("div",{style:{position:"absolute",bottom:"20px",left:i/2,transformOrigin:"bottom left",transform:"rotate(-45deg)",whiteSpace:"nowrap",fontSize:"10px",color:B?l.primary:l.muted,fontWeight:x.expandable?600:400},children:[x.expandable?x.expanded?"− ":"+ ":"",w(x.node.name)]}),c.jsx("div",{style:{position:"absolute",bottom:"3px",width:"100%",textAlign:"center",fontSize:"9px",color:B?l.primary:l.faint,fontWeight:B?700:400},children:x.index})]},x.node.id)})]}),y.map((x,L)=>{const B=(p==null?void 0:p.row)===L,D=n===x.node.id;return c.jsxs("div",{style:{display:"flex",borderTop:h[L]===null?void 0:H(h[L])},children:[c.jsx(le,{entry:x,height:i,hovered:B,selected:D,onToggle:()=>r(x.node.id),onSelect:()=>o==null?void 0:o(x.node.id)}),b.map((a,m)=>{const I=$[L][m],M=s?s(I,x,a):ce(I),C=(p==null?void 0:p.row)===L||(p==null?void 0:p.column)===m,z=u(x)===u(a),O=x.node.id===a.node.id,T=M.background??(O?"#E3E8EE":C?"#F1F7F5":z?"#FAFBFC":l.surface),F=M.text??(O?de(x,k):void 0),U=!!I||M.actionable;return c.jsx("div",{onMouseEnter:()=>v({row:L,column:m}),onMouseLeave:()=>v(null),onClick:U?()=>d==null?void 0:d(x,a,I):void 0,title:M.title??pe(I,x,a),style:{width:i,height:i,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:i<22?"9px":"10px",fontWeight:600,color:M.color??(O?l.faint:l.secondary),background:T,borderRight:`1px solid ${l.borderLight}`,borderBottom:`1px solid ${l.borderLight}`,borderLeft:j[m]===null?void 0:H(j[m]),cursor:U?"pointer":"default",outline:(p==null?void 0:p.row)===L&&(p==null?void 0:p.column)===m?`2px solid ${l.accent}`:void 0,outlineOffset:"-2px"},children:F},a.node.id)})]},x.node.id)})]}),g]})}function le({entry:e,height:r,hovered:t,selected:o,onToggle:n,onSelect:s}){const d=e.depth*14,i={width:X,flexShrink:0,height:r,display:"flex",alignItems:"center",gap:"5px",paddingLeft:`${6+d}px`,paddingRight:"7px",position:"sticky",left:0,zIndex:10,background:o?"#E8F8F3":t?"#F1F7F5":l.surface,borderRight:`1px solid ${l.border}`,borderBottom:`1px solid ${l.borderLight}`,fontSize:"11px",color:t||o?l.primary:l.secondary,fontWeight:e.expandable?600:400};return c.jsxs("div",{style:i,children:[c.jsx("button",{type:"button",onClick:e.expandable?n:void 0,"aria-label":e.expandable?`${e.expanded?"Collapse":"Expand"} ${e.node.name}`:void 0,disabled:!e.expandable,style:{width:"13px",height:"13px",flexShrink:0,padding:0,lineHeight:"11px",borderRadius:"3px",fontSize:"10px",border:e.expandable?`1px solid ${l.border}`:"1px solid transparent",background:e.expandable?l.surface:"transparent",color:l.muted,cursor:e.expandable?"pointer":"default"},children:e.expandable?e.expanded?"−":"+":""}),c.jsx("span",{style:{width:"3px",height:"13px",borderRadius:"2px",flexShrink:0,background:e.node.isElement?W[e.node.layer]||"#9CA3AF":"#CBD5E1"}}),c.jsx("span",{onClick:s,title:`${e.node.name} (${e.node.kind})`,style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:e.node.name}),e.expandable&&!e.expanded&&e.memberCount>1&&c.jsx("span",{style:{fontSize:"9px",color:l.faint},title:`${e.memberCount} elements rolled up`,children:e.memberCount}),c.jsx("span",{style:{fontSize:"9px",color:l.faint,width:"22px",textAlign:"right"},children:e.index})]})}function de(e,r){return e.node.children.length===0||r===0?"·":`${Math.round(e.memberCount/r*100)}%`}function ce(e){return e?e.diagonal?{text:String(e.strength),color:l.muted}:{text:String(e.strength),color:l.primary}:{}}function pe(e,r,t){const o=`${r.node.name} → ${t.node.name}`;if(!e)return o;if(e.diagonal)return`${r.node.name}: ${e.strength} internal dependenc${e.strength===1?"y":"ies"}`;const n=e.types.join(", ");return`${o}
2
+ ${e.strength} dependenc${e.strength===1?"y":"ies"} (${n})${e.aggregated?`
3
+ rolled up from collapsed parts`:""}`}function ue(e,r){if(r.length===0)return!0;const t=`${e.label??e.value} ${e.group??""} ${e.keywords??""}`.toLowerCase();return r.every(o=>t.includes(o))}function fe(e,r){const t=r.trim().toLowerCase().split(/\s+/).filter(Boolean);if(t.length===0)return e;const o=[],n=[];for(const s of e){if(!ue(s,t))continue;(s.label??s.value).toLowerCase().startsWith(t[0])?o.push(s):n.push(s)}return[...o,...n]}function Se({label:e,options:r,selected:t,onChange:o,allLabel:n="All",placeholder:s="Type to filter…",width:d=150,title:i,describedAs:f,maxVisible:g=300}){var D;const[p,v]=E.useState(!1),[y,b]=E.useState(""),[$,k]=E.useState(0),h=E.useRef(null),j=E.useRef(null),u=E.useMemo(()=>new Set(t),[t]),w=E.useMemo(()=>fe(r,y),[r,y]),S=w.length>g?w.slice(0,g):w,A=w.length-S.length;E.useEffect(()=>{k(0)},[y,p]),E.useEffect(()=>{if(!p)return;const a=m=>{var I;(I=h.current)!=null&&I.contains(m.target)||(v(!1),b(""))};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[p]),E.useEffect(()=>{var a;p&&((a=j.current)==null||a.focus())},[p]);const x=E.useCallback(a=>{o(u.has(a)?t.filter(m=>m!==a):[...t,a])},[o,t,u]),L=a=>{if(a.key==="Escape"){v(!1),b("");return}a.key==="ArrowDown"&&(a.preventDefault(),k(m=>Math.min(m+1,S.length-1))),a.key==="ArrowUp"&&(a.preventDefault(),k(m=>Math.max(m-1,0))),a.key==="Enter"&&S[$]&&(a.preventDefault(),x(S[$].value))},B=t.length===0?n:t.length===1?((D=r.find(a=>a.value===t[0]))==null?void 0:D.label)??t[0]:`${t.length} selected`;return c.jsxs("div",{ref:h,style:{position:"relative",display:"flex",alignItems:"center",gap:"5px"},children:[c.jsx("span",{style:{fontSize:R.xs,color:l.muted,whiteSpace:"nowrap"},children:e}),c.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":p,title:i??(t.length>0?t.join(", "):n),onClick:()=>v(a=>!a),style:{width:d,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",padding:"3px 7px",borderRadius:"5px",border:`1px solid ${t.length>0?l.accent:l.border}`,background:l.surface,fontSize:R.xs,color:t.length>0?l.primary:l.muted,cursor:"pointer",textAlign:"left"},children:[c.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:B}),c.jsx("span",{style:{fontSize:"9px",color:l.faint},children:"▼"})]}),p&&c.jsxs("div",{role:"listbox",style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:60,width:Math.max(d+70,220),background:l.surface,border:`1px solid ${l.border}`,borderRadius:"7px",boxShadow:G.lg,overflow:"hidden"},children:[c.jsx("input",{ref:j,value:y,onChange:a=>b(a.target.value),onKeyDown:L,placeholder:s,"aria-label":`Filter ${f??e}`,style:{width:"100%",padding:"7px 9px",border:"none",borderBottom:`1px solid ${l.borderLight}`,fontSize:R.xs,outline:"none",color:l.primary}}),c.jsxs("div",{style:{maxHeight:"260px",overflowY:"auto"},children:[w.length===0&&c.jsxs("div",{style:{padding:"10px",fontSize:R.xs,color:l.faint},children:["Nothing matches ","“",y,"”"]}),S.map((a,m)=>{var C;const I=u.has(a.value),M=a.group&&a.group!==((C=S[m-1])==null?void 0:C.group)?a.group:null;return c.jsxs("div",{children:[M&&c.jsx("div",{style:{position:"sticky",top:0,zIndex:1,padding:"4px 9px 2px",fontSize:"10px",fontWeight:600,color:l.faint,background:l.surface,borderBottom:`1px solid ${l.borderLight}`},children:M}),c.jsxs("div",{role:"option","aria-selected":I,onMouseEnter:()=>k(m),onClick:()=>x(a.value),style:{display:"flex",alignItems:"center",gap:"7px",padding:"5px 9px",cursor:"pointer",fontSize:R.xs,background:m===$?l.surfaceAlt:"transparent",color:l.primary},children:[c.jsx("input",{type:"checkbox",readOnly:!0,checked:I,style:{accentColor:l.accent}}),a.color&&c.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"2px",background:a.color,flexShrink:0}}),c.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.label??a.value}),a.hint&&c.jsx("span",{style:{color:l.faint,fontSize:"11px"},children:a.hint})]})]},a.value)}),A>0&&c.jsxs("div",{style:{padding:"7px 9px",fontSize:"11px",color:l.faint,borderTop:`1px solid ${l.borderLight}`},children:[A.toLocaleString()," more match. Keep typing to narrow, or use"," ","Select matches to take all ",w.length.toLocaleString(),"."]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"6px 9px",borderTop:`1px solid ${l.borderLight}`},children:[c.jsxs("button",{type:"button",onClick:()=>o(w.map(a=>a.value)),style:{fontSize:"11px",color:"#2563EB",background:"none",border:"none",cursor:"pointer",padding:0},children:["Select ",y?`matches (${w.length})`:`all (${r.length})`]}),c.jsx("button",{type:"button",onClick:()=>o([]),style:{fontSize:"11px",color:l.muted,background:"none",border:"none",cursor:"pointer",padding:0},children:"None"}),t.length>0&&c.jsxs("span",{style:{marginLeft:"auto",fontSize:"11px",color:l.faint},children:[t.length," picked"]})]})]})]})}function P(e){const r=e.replace(/[_-]+/g," ").trim();return r.charAt(0).toUpperCase()+r.slice(1)}function he(e,r){if(e.kind)return e.kind;if(e.layer){const t=r.find(o=>o.layer===e.layer);return t&&t.kinds.length===1?t.kinds[0].kind:P(e.layer)}return"Everything"}function ve({label:e,layers:r,value:t,onChange:o,width:n=165,title:s,describedAs:d}){const[i,f]=E.useState(!1),[g,p]=E.useState(""),v=E.useRef(null),y=E.useRef(null);E.useEffect(()=>{if(!i)return;const h=j=>{var u;(u=v.current)!=null&&u.contains(j.target)||(f(!1),p(""))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[i]),E.useEffect(()=>{var h;i&&((h=y.current)==null||h.focus())},[i]);const b=E.useMemo(()=>{const h=g.trim().toLowerCase().split(/\s+/).filter(Boolean);if(h.length===0)return r;const j=u=>h.every(w=>u.toLowerCase().includes(w));return r.map(u=>{if(j(P(u.layer)))return u;const w=u.kinds.filter(S=>j(`${S.kind} ${u.layer}`));return w.length>0?{...u,kinds:w}:null}).filter(u=>u!==null)},[r,g]),$=h=>{o(h),f(!1),p("")},k=(h,j)=>({display:"flex",alignItems:"center",gap:"7px",padding:j?"4px 9px 4px 26px":"5px 9px",cursor:"pointer",fontSize:R.xs,background:h?"#E8F8F3":"transparent",color:l.primary,fontWeight:h?600:400});return c.jsxs("div",{ref:v,style:{position:"relative",display:"flex",alignItems:"center",gap:"5px"},children:[c.jsx("span",{style:{fontSize:R.xs,color:l.muted,whiteSpace:"nowrap"},children:e}),c.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":i,title:s,onClick:()=>f(h=>!h),style:{width:n,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",padding:"3px 7px",borderRadius:"5px",border:`1px solid ${l.accent}`,background:l.surface,fontSize:R.xs,color:l.primary,cursor:"pointer",textAlign:"left"},children:[c.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"6px",overflow:"hidden"},children:[t.layer&&c.jsx("span",{style:{width:"3px",height:"12px",borderRadius:"2px",flexShrink:0,background:W[t.layer]||"#9CA3AF"}}),c.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:he(t,r)})]}),c.jsx("span",{style:{fontSize:"9px",color:l.faint},children:"▼"})]}),i&&c.jsxs("div",{role:"listbox",style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:60,width:Math.max(n+60,240),background:l.surface,border:`1px solid ${l.border}`,borderRadius:"7px",boxShadow:G.lg,overflow:"hidden"},children:[c.jsx("input",{ref:y,value:g,onChange:h=>p(h.target.value),onKeyDown:h=>{h.key==="Escape"&&(f(!1),p(""))},placeholder:"Filter layers and types…","aria-label":`Filter ${d??e}`,style:{width:"100%",padding:"7px 9px",border:"none",borderBottom:`1px solid ${l.borderLight}`,fontSize:R.xs,outline:"none",color:l.primary}}),c.jsxs("div",{style:{maxHeight:"300px",overflowY:"auto"},children:[b.length===0&&c.jsxs("div",{style:{padding:"10px",fontSize:R.xs,color:l.faint},children:["Nothing matches ","“",g,"”"]}),b.map(h=>c.jsxs("div",{children:[c.jsxs("div",{role:"option","aria-selected":t.layer===h.layer&&!t.kind,onClick:()=>$({layer:h.layer}),style:k(t.layer===h.layer&&!t.kind,!1),children:[c.jsx("span",{style:{width:"3px",height:"12px",borderRadius:"2px",flexShrink:0,background:W[h.layer]||"#9CA3AF"}}),c.jsx("span",{style:{flex:1},children:P(h.layer)}),c.jsx("span",{style:{color:l.faint,fontSize:"11px"},children:h.elementCount})]}),h.kinds.length>1&&h.kinds.map(j=>c.jsxs("div",{role:"option","aria-selected":t.kind===j.kind,onClick:()=>$({layer:h.layer,kind:j.kind}),style:k(t.kind===j.kind,!0),children:[c.jsx("span",{style:{flex:1,color:l.secondary},children:j.kind}),c.jsx("span",{style:{color:l.faint,fontSize:"11px"},children:j.elementCount})]},j.kind))]},h.layer))]})]})]})}function je(e,r){return e?Object.values(e.elements).filter(t=>(!r.layer||t.layer===r.layer)&&(!r.kind||t.kind===r.kind)).sort((t,o)=>t.kind.localeCompare(o.kind)||t.name.localeCompare(o.name)).map(t=>({value:t.id,label:t.name,group:t.kind,hint:t.shortId,keywords:`${t.id} ${t.shortId??""} ${t.package??""}`})):[]}export{ve as A,ke as H,Se as T,be as a,ye as b,we as c,_ as d,je as e,V as l,Z as r,ee as s};