@memoarchitect/architect 0.7.2 → 0.8.26

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 (71) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{AiWorkspace-Bu9TlIWg.js → AiWorkspace-Z3BbnmaP.js} +1 -1
  3. package/dist/assets/{AnalysisWorkspace-CodmoI-v.js → AnalysisWorkspace-DjaUOo7U.js} +1 -1
  4. package/dist/assets/{ComplianceWizard-CTihkUi-.js → ComplianceWizard-DKxZ1z25.js} +1 -1
  5. package/dist/assets/DSMView-DJhmrXYm.js +5 -0
  6. package/dist/assets/Dashboard-CYT7KjqU.js +1 -0
  7. package/dist/assets/DhfDashboard-DacdOtkU.js +1 -0
  8. package/dist/assets/DhfWorkbench-CIhopT8J.js +69 -0
  9. package/dist/assets/DiagramCanvas-CLE_nv7Y.js +4 -0
  10. package/dist/assets/{DiagramEditor-UJDHcAUF.js → DiagramEditor-puQuE8gB.js} +2 -2
  11. package/dist/assets/DiagramToolbarControls-XMGLx08e.js +1 -0
  12. package/dist/assets/{ElementDetailView-10U0rr33.js → ElementDetailView-D5XvAL_i.js} +1 -1
  13. package/dist/assets/ExplorerTreeRow-DUmcEsqf.js +3 -0
  14. package/dist/assets/{ImportView-D8svP04Q.js → ImportView-9y1nhQS4.js} +1 -1
  15. package/dist/assets/{LayerGrid-DEe0Ryz-.js → LayerGrid-bhFpOIbe.js} +1 -1
  16. package/dist/assets/{LayerTable-CN_b2rDr.js → LayerTable-RuswZVUI.js} +1 -1
  17. package/dist/assets/{MaxGraphCanvas-bo8oPBct.js → MaxGraphCanvas-D3BXQK2y.js} +1 -1
  18. package/dist/assets/{ModelDiff-xe95oVua.js → ModelDiff-Cl2dhlk3.js} +1 -1
  19. package/dist/assets/{OntologyDecompositionDiagram-BL9R8bdB.js → OntologyDecompositionDiagram-aONGngg4.js} +1 -1
  20. package/dist/assets/{OntologyViewer-CtqNkkCn.js → OntologyViewer-VOrKTRuQ.js} +2 -2
  21. package/dist/assets/{RelationshipOverlay-DL0N8Vmk.js → RelationshipOverlay-B3AN-bM-.js} +1 -1
  22. package/dist/assets/{RelationshipsSection-BoJ0aUXe.js → RelationshipsSection-DggeGBKP.js} +1 -1
  23. package/dist/assets/{ReviewDashboard-DeTge2oC.js → ReviewDashboard--LMXZ3F4.js} +1 -1
  24. package/dist/assets/{ScenarioEditor-FAEYTHgP.js → ScenarioEditor-bB4iBbgO.js} +1 -1
  25. package/dist/assets/{StatisticsDashboard-BAZRqIPN.js → StatisticsDashboard-iXimfU20.js} +1 -1
  26. package/dist/assets/{SysmlCodeEditor-BBfup_Ni.js → SysmlCodeEditor-i0BHj3of.js} +117 -117
  27. package/dist/assets/{TabularView-I4LjHhoH.js → TabularView-DnIfq-TB.js} +1 -1
  28. package/dist/assets/TraceabilityMatrix-eilGn6Sr.js +3 -0
  29. package/dist/assets/UiScreensWorkspace-Cs1ivqzc.js +1 -0
  30. package/dist/assets/{WorkflowWizard-VwpEHt3R.js → WorkflowWizard-C7jI6C59.js} +1 -1
  31. package/dist/assets/index-CG-gfw-s.js +4067 -0
  32. package/dist/assets/index-DXB4CKwW.css +1 -0
  33. package/dist/assets/{index.es-ClbJxlAQ.js → index.es-DABt8CUc.js} +1 -1
  34. package/dist/assets/{jspdf.es.min-DZ68BGxk.js → jspdf.es.min-G-Vwo9yG.js} +3 -3
  35. package/dist/assets/{layout-providers-Dr743WlP.js → layout-providers-BSDYNZu0.js} +1 -1
  36. package/dist/assets/notation-scene-DLZms6VR.js +1 -0
  37. package/dist/assets/{reactflow-s7jmJtXx.js → reactflow-C9OlmOYw.js} +1 -1
  38. package/dist/assets/xlsx-CkFp8p6R.js +105 -0
  39. package/dist/index.html +3 -3
  40. package/dist-standalone/index.html +5504 -0
  41. package/lib/__tests__/standalone-distribution.test.d.ts +2 -0
  42. package/lib/__tests__/standalone-distribution.test.d.ts.map +1 -0
  43. package/lib/__tests__/standalone-distribution.test.js +51 -0
  44. package/lib/__tests__/standalone-distribution.test.js.map +1 -0
  45. package/lib/__tests__/supervised-child-args.test.js +21 -1
  46. package/lib/__tests__/supervised-child-args.test.js.map +1 -1
  47. package/lib/commands/build.d.ts.map +1 -1
  48. package/lib/commands/build.js +15 -18
  49. package/lib/commands/build.js.map +1 -1
  50. package/lib/commands/dev.d.ts +14 -0
  51. package/lib/commands/dev.d.ts.map +1 -1
  52. package/lib/commands/dev.js +40 -1
  53. package/lib/commands/dev.js.map +1 -1
  54. package/lib/feature-grants.d.ts.map +1 -1
  55. package/lib/feature-grants.js +3 -1
  56. package/lib/feature-grants.js.map +1 -1
  57. package/package.json +10 -6
  58. package/dist/assets/DSMView-BiC845df.js +0 -1
  59. package/dist/assets/Dashboard-CgnNLhKq.js +0 -1
  60. package/dist/assets/DhfDashboard-w-dJoJHU.js +0 -1
  61. package/dist/assets/DhfWorkbench-o6B_MT-0.js +0 -69
  62. package/dist/assets/DiagramCanvas-CqGqDbgT.js +0 -3
  63. package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +0 -1
  64. package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +0 -3
  65. package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +0 -3
  66. package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +0 -1
  67. package/dist/assets/editor.worker-DyuDvpVp.js +0 -26
  68. package/dist/assets/element-options-B7AgTB8R.js +0 -3
  69. package/dist/assets/index-BWMNo4wW.css +0 -1
  70. package/dist/assets/index-Bij8Q4Kg.js +0 -45
  71. package/dist/assets/notation-scene-DT8LpWVK.js +0 -1
@@ -1,3 +0,0 @@
1
- import{j as n}from"./reactflow-s7jmJtXx.js";import{a as r}from"./zustand-CrhqMOHB.js";import{u as f,i as ke,r as H,j as ve,C as s,F as b}from"./index-Bij8Q4Kg.js";import{l as Ce,r as ie,e as re,c as je,b as Ee,A as le,T as P,a as ae,H as Re}from"./element-options-B7AgTB8R.js";const Te=[{id:"risk-control",label:"ISO 14971: Risk → Control",description:"Hazards and hazardous situations traced to risk controls",rowKinds:["Hazard","HazardousSituation"],columnKinds:["RiskControlMeasure","SafetyGoal"],linkTypes:["mitigates","tracesRisk","causes","leadsTo"]},{id:"req-test",label:"IEC 62304: Requirement → Test",description:"Software requirements traced to verification tests",rowKinds:["Requirement","SoftwareRequirement","SystemRequirement"],columnKinds:["Test","TestCase","VerificationActivity"],linkTypes:["verifiedBy","satisfiedBy","validates"]},{id:"req-function",label:"Requirement → Function",description:"Requirements traced to the functions that satisfy them",rowKinds:["Requirement","SystemRequirement"],columnKinds:["Function","SystemFunction"],linkTypes:["satisfiedBy","derivesFrom"]},{id:"function-component",label:"Function → Component",description:"Functions allocated to logical and physical components",rowKinds:["Function","SystemFunction"],columnKinds:["LogicalComponent","SoftwareModule","MechanicalPart","Component"],linkTypes:["allocatedTo","realizes"]},{id:"everything",label:"Everything",description:"Every element against every element, every relationship",rowKinds:[],columnKinds:[],linkTypes:[]}];function Me(){var oe;const i=f(e=>e.model),u=f(e=>e.connected),g=f(e=>e.selectElement),ce=f(e=>e.selectedElementId),Q=f(e=>e.selectedDiagramId),G=f(e=>e.createRelationship),U=f(e=>e.deleteRelationship),[m,A]=r.useState({}),[h,L]=r.useState({}),[O,K]=r.useState([]),[q,B]=r.useState([]),[x,V]=r.useState([]),[p,ue]=r.useState(!1),[Y,pe]=r.useState(26),[Z,me]=r.useState(!0),[J,v]=r.useState(new Set),[X,C]=r.useState(new Set),[l,j]=r.useState(null),[E,R]=r.useState(null),[T,_]=r.useState(""),[F,I]=r.useState(!1),W=r.useMemo(()=>ke(i),[i]),ee=r.useMemo(()=>i?Ce(i):[],[i]),he=r.useMemo(()=>{if(!i)return[];const e=new Map;for(const t of i.relationships)e.set(t.type,(e.get(t.type)??0)+1);return ie(i).map(t=>({value:t,hint:String(e.get(t)??0),color:H(t)}))},[i]),z=r.useMemo(()=>re(i,m),[i,m]),$=r.useMemo(()=>re(i,h),[i,h]);r.useEffect(()=>{const e=new Set(z.map(t=>t.value));K(t=>t.every(o=>e.has(o))?t:t.filter(o=>e.has(o)))},[z]),r.useEffect(()=>{const e=new Set($.map(t=>t.value));B(t=>t.every(o=>e.has(o))?t:t.filter(o=>e.has(o)))},[$]);const a=r.useMemo(()=>i?je(i,{rows:{layer:m.layer,kinds:m.kind?[m.kind]:[],elementIds:O,expanded:J},columns:{layer:h.layer,kinds:h.kind?[h.kind]:[],elementIds:q,expanded:X},dependencyTypes:x,symmetric:!0}):null,[i,m,h,O,q,x,J,X]),[M,xe]=r.useState(!1);r.useEffect(()=>{if(M||!i)return;const e=Ee(i);e.rows&&(A({layer:e.rows}),L({layer:e.columns}),xe(!0))},[i,M]);const[te,fe]=r.useState(!1);r.useEffect(()=>{if(te||!M||!a)return;const e=a.rowRoots.filter(o=>o.children.length>0).map(o=>o.id),t=a.columnRoots.filter(o=>o.children.length>0).map(o=>o.id);e.length===0&&t.length===0||(v(new Set(e)),C(new Set(t)),fe(!0))},[a,M,te]);const D=r.useCallback(e=>{if(!i)return null;for(const t of e){const o=Object.values(i.elements).find(d=>d.kind===t);if(o)return{layer:o.layer,kind:t}}return null},[i]),ge=r.useCallback(e=>{const t=new Set(i?ie(i):[]),o=D(e.rowKinds),d=D(e.columnKinds);o&&A(o),d&&L(d),V(e.linkTypes.filter(c=>t.has(c))),K([]),B([]),j(null)},[i,D]),ne=r.useMemo(()=>{var c;if(!i||!l)return[];const e=l.row.node.id,t=l.column.node.id;if(l.row.node.children.length===0&&l.column.node.children.length===0){const y=new Set(x);return i.relationships.filter(k=>(y.size===0||y.has(k.type))&&(k.sourceId===e&&k.targetId===t||k.sourceId===t&&k.targetId===e))}const d=new Set(((c=l.cell)==null?void 0:c.relationshipIds)??[]);return i.relationships.filter(y=>d.has(y.id))},[i,l,x]),w=r.useMemo(()=>{if(!i||!l||!W)return[];const e=i.elements[l.row.node.id],t=i.elements[l.column.node.id];return!e||!t||e.id===t.id?[]:ve(e,t,W)},[i,l,W]),N=r.useMemo(()=>{const e=new Set;for(const t of x)e.add(t),e.add(t.charAt(0).toUpperCase()+t.slice(1));return e},[x]),se=r.useMemo(()=>{const e=T.trim().toLowerCase();return w.filter(t=>!e||t.definition.name.toLowerCase().includes(e)).sort((t,o)=>{const d=Number(N.has(o.definition.name))-Number(N.has(t.definition.name));return d!==0?d:t.definition.name.localeCompare(o.definition.name)})},[w,T,N]),ye=!!(l&&l.row.node.isElement&&l.column.node.isElement&&!l.row.expanded&&!l.column.expanded&&l.row.node.children.length===0&&l.column.node.children.length===0),be=r.useCallback(async e=>{I(!0),R(null);const t=await G({type:e.definition.name,sourceId:e.sourceId,targetId:e.targetId,direction:e.direction,diagramId:Q??void 0});I(!1),R(t.success?{kind:"ok",message:`Trace written to ${t.sourceFile??"the model"}.`}:{kind:"error",message:t.error??"The trace could not be created."})},[G,Q]),we=r.useCallback(async e=>{I(!0),R(null);const t=await U(e);I(!1),R(t.success?{kind:"ok",message:`Trace removed from ${t.sourceFile??"the model"}.`}:{kind:"error",message:t.error??"The trace could not be removed."})},[U]),Se=r.useCallback((e,t,o)=>{if(e!=null&&e.diagonal)return{text:String(e.strength),color:s.muted,background:"#E3E8EE"};if(e){const c=e.types.length>0?H(e.types[0]):"#2DA98C",y=Math.min(.16+e.strength*.14,.6);return{text:e.aggregated?String(e.strength):"✓",color:c,background:`${c}${Math.round(y*255).toString(16).padStart(2,"0")}`,title:`${t.node.name} ↔ ${o.node.name}
2
- ${e.types.join(", ")}${p?`
3
- Click to inspect or remove`:""}`}}return p?t.node.isElement&&o.node.isElement&&t.node.children.length===0&&o.node.children.length===0&&t.node.id!==o.node.id?{actionable:!0,title:`Click to trace ${t.node.name} → ${o.node.name}`}:{}:{}},[p]),S=r.useMemo(()=>{if(!a)return{traced:0,total:0};const e=a.rows.filter(o=>o.node.children.length===0);return{traced:e.filter(o=>{const d=a.rows.indexOf(o);return a.matrix[d].some(c=>c&&!c.diagonal)}).length,total:e.length}},[a]);return!i||!a?n.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:s.faint,fontSize:b.sm},children:"No model loaded"}):n.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:"#FAFAF8"},children:[n.jsxs("div",{style:{borderBottom:`1px solid ${s.border}`,background:s.surface},children:[n.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",style:{flexWrap:"wrap"},children:[n.jsx("span",{style:{fontSize:b.sm,fontWeight:600,color:s.primary},children:"Traceability"}),n.jsxs("span",{style:{fontSize:"11px",color:s.faint},children:[a.totalDependencies," link",a.totalDependencies===1?"":"s"," shown",S.total>0&&` · ${S.traced}/${S.total} rows traced (${Math.round(S.traced/S.total*100)}%)`]}),n.jsx("div",{className:"flex-1"}),n.jsx(le,{label:"Rows",layers:ee,value:m,onChange:A,describedAs:"row scope",title:"What the rows list — one architecture layer, or one element type within it"}),n.jsx(P,{label:"of",allLabel:`All ${z.length} elements`,options:z,selected:O,onChange:K,width:130,describedAs:"row elements",placeholder:"Filter by name, kind or id…",title:"The individual elements listed down the side"}),n.jsx(le,{label:"Columns",layers:ee,value:h,onChange:L,describedAs:"column scope",title:"What the columns list — one architecture layer, or one element type within it"}),n.jsx(P,{label:"of",allLabel:`All ${$.length} elements`,options:$,selected:q,onChange:B,width:130,describedAs:"column elements",placeholder:"Filter by name, kind or id…",title:"The individual elements listed across the top"}),n.jsx(P,{label:"Trace via",allLabel:"Any relationship",options:he,selected:x,onChange:V,title:"Relationships counted as trace"})]}),n.jsxs("div",{className:"flex items-center gap-2 px-4 pb-2",style:{flexWrap:"wrap"},children:[n.jsx("span",{style:{fontSize:"11px",color:s.faint},children:"Presets"}),Te.map(e=>n.jsx("button",{onClick:()=>ge(e),title:e.description,style:{padding:"3px 8px",borderRadius:"5px",fontSize:"11px",border:`1px solid ${s.borderLight}`,background:s.surface,color:s.secondary,cursor:"pointer"},children:e.label},e.id)),n.jsx("div",{style:{width:"1px",height:"16px",background:s.borderLight,margin:"0 4px"}}),n.jsx("button",{onClick:()=>{a&&(v(new Set(ae(a.rowRoots))),C(new Set(ae(a.columnRoots))))},style:{padding:"3px 8px",borderRadius:"5px",fontSize:"11px",border:`1px solid ${s.border}`,background:s.surface,color:s.secondary,cursor:"pointer"},children:"Expand all"}),n.jsx("button",{onClick:()=>{v(new Set),C(new Set)},style:{padding:"3px 8px",borderRadius:"5px",fontSize:"11px",border:`1px solid ${s.border}`,background:s.surface,color:s.secondary,cursor:"pointer"},children:"Collapse all"}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:b.xs,color:s.muted},children:[n.jsx("input",{type:"checkbox",checked:Z,onChange:e=>me(e.target.checked),style:{accentColor:s.accent}}),"Column names"]}),n.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"5px",fontSize:b.xs,color:s.muted},children:["Zoom",n.jsx("input",{type:"range",min:14,max:44,step:2,value:Y,onChange:e=>pe(Number(e.target.value)),style:{width:"80px",accentColor:s.accent}})]}),n.jsx("div",{className:"flex-1"}),n.jsxs("label",{title:u?"Click cells to add or remove trace links. Only leaf-to-leaf cells can be edited.":"The dev server is unreachable, so nothing can be written to the model.",style:{display:"flex",alignItems:"center",gap:"6px",fontSize:b.xs,padding:"3px 9px",borderRadius:"5px",border:`1px solid ${p?s.accent:s.border}`,background:p?"#E8F8F3":s.surface,color:u?s.primary:s.faint,cursor:u?"pointer":"not-allowed",fontWeight:600},children:[n.jsx("input",{type:"checkbox",checked:p,disabled:!u,onChange:e=>{ue(e.target.checked),j(null)},style:{accentColor:s.accent}}),"Edit links"]})]}),E&&n.jsx("div",{style:{padding:"5px 16px",fontSize:"11px",color:E.kind==="ok"?"#0F766E":"#B91C1C",background:E.kind==="ok"?"#ECFDF5":"#FEF2F2",borderTop:`1px solid ${s.borderLight}`},children:E.message})]}),n.jsx(Re,{result:a,onToggleRow:e=>v(t=>de(t,e)),onToggleColumn:e=>C(t=>de(t,e)),onSelectElement:g,selectedElementId:ce,renderCell:Se,onCellClick:(e,t,o)=>{j({row:e,column:t,cell:o}),_("")},cellSize:Y,showColumnNames:Z}),l&&n.jsxs("div",{style:{position:"fixed",bottom:"76px",right:"20px",zIndex:100,width:"330px",maxHeight:"52vh",overflowY:"auto",padding:"12px 14px",borderRadius:"9px",background:s.surface,border:`1px solid ${s.border}`,boxShadow:"0 6px 22px rgba(0,0,0,0.14)",fontSize:b.xs},children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{style:{fontWeight:600,color:s.primary},children:[l.row.node.name," ","↔"," ",l.column.node.name]}),n.jsx("button",{onClick:()=>j(null),style:{color:s.faint,background:"none",border:"none",cursor:"pointer"},children:"✕"})]}),ne.length>0?n.jsx("div",{style:{marginTop:"9px",display:"flex",flexDirection:"column",gap:"5px"},children:ne.map(e=>{var t,o;return n.jsxs("div",{className:"flex items-center justify-between gap-2",style:{padding:"4px 6px",borderRadius:"5px",background:s.surfaceAlt},children:[n.jsx("span",{style:{color:H(e.type),fontWeight:500},children:e.type}),n.jsxs("span",{style:{flex:1,color:s.faint,fontSize:"10px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[((t=i.elements[e.sourceId])==null?void 0:t.name)??e.sourceId," ","→"," ",((o=i.elements[e.targetId])==null?void 0:o.name)??e.targetId]}),p&&n.jsx("button",{disabled:F||e.named===!1,onClick:()=>void we(e.id),title:e.named===!1?"This connection has no declared name, so it cannot be addressed for deletion. Name it in the source first.":"Remove this trace link",style:{fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid #FCA5A5",background:"#FEF2F2",color:"#B91C1C",cursor:F||e.named===!1?"not-allowed":"pointer",opacity:e.named===!1?.5:1},children:"Remove"})]},e.id)})}):n.jsx("div",{style:{marginTop:"8px",color:s.muted},children:"No trace between these two."}),((oe=l.cell)==null?void 0:oe.aggregated)&&n.jsx("div",{style:{marginTop:"8px",fontSize:"11px",color:s.faint},children:"This mark sums a collapsed subsystem. Expand both sides to edit individual links."}),p&&n.jsxs("div",{style:{marginTop:"11px",borderTop:`1px solid ${s.borderLight}`,paddingTop:"9px"},children:[n.jsx("div",{style:{fontSize:"11px",color:s.muted,marginBottom:"6px"},children:"Add a trace link"}),ye?w.length===0?n.jsxs("div",{style:{fontSize:"11px",color:s.faint},children:["The ontology allows no relationship between ",l.row.node.kind," and ",l.column.node.kind,"."]}):n.jsxs(n.Fragment,{children:[w.length>8&&n.jsx("input",{value:T,onChange:e=>_(e.target.value),placeholder:`Filter ${w.length} legal types…`,"aria-label":"Filter link types",style:{width:"100%",marginBottom:"7px",padding:"4px 7px",border:`1px solid ${s.border}`,borderRadius:"5px",fontSize:"11px",outline:"none",color:s.primary}}),n.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"5px"},children:[se.map(e=>{var o,d;const t=N.has(e.definition.name);return n.jsxs("button",{disabled:F,onClick:()=>void be(e),title:`${((o=i.elements[e.sourceId])==null?void 0:o.name)??e.sourceId} → ${((d=i.elements[e.targetId])==null?void 0:d.name)??e.targetId}`,style:{fontSize:"11px",padding:"3px 8px",borderRadius:"5px",border:`1px solid ${t?s.accent:s.border}`,background:t?"#E8F8F3":s.surface,color:s.primary,cursor:F?"wait":"pointer",fontWeight:t?600:400},children:[e.definition.name,n.jsx("span",{style:{color:s.faint,marginLeft:"4px"},children:e.direction==="outgoing"?"→":"←"})]},`${e.definition.name}-${e.direction}`)}),se.length===0&&n.jsxs("span",{style:{fontSize:"11px",color:s.faint},children:["No legal type matches ","“",T,"”","."]})]})]}):n.jsx("div",{style:{fontSize:"11px",color:s.faint},children:"Both sides must be individual elements. Expand the subsystems first."})]})]})]})}function de(i,u){const g=new Set(i);return g.has(u)?g.delete(u):g.add(u),g}export{Me as TraceabilityMatrix};
@@ -1 +0,0 @@
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};