@memoarchitect/architect 0.8.26 → 0.8.27
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.
- package/README.md +1 -1
- package/dist/assets/{AiWorkspace-Z3BbnmaP.js → AiWorkspace-Dp5oBDww.js} +1 -1
- package/dist/assets/{AnalysisWorkspace-DjaUOo7U.js → AnalysisWorkspace-CNHTkSRD.js} +1 -1
- package/dist/assets/{ComplianceWizard-DKxZ1z25.js → ComplianceWizard-CAJDtLdv.js} +1 -1
- package/dist/assets/{DSMView-DJhmrXYm.js → DSMView-Bv9j1Vk_.js} +1 -1
- package/dist/assets/{Dashboard-CYT7KjqU.js → Dashboard-BnOwnA1R.js} +1 -1
- package/dist/assets/{DhfDashboard-DacdOtkU.js → DhfDashboard-CQpiYHtW.js} +1 -1
- package/dist/assets/{DhfWorkbench-CIhopT8J.js → DhfWorkbench-DHxWuiiL.js} +3 -3
- package/dist/assets/{DiagramCanvas-CLE_nv7Y.js → DiagramCanvas-DtLlTvJf.js} +3 -3
- package/dist/assets/{DiagramEditor-puQuE8gB.js → DiagramEditor-DP_PiI7K.js} +2 -2
- package/dist/assets/{ElementDetailView-D5XvAL_i.js → ElementDetailView-BQsWfbPD.js} +1 -1
- package/dist/assets/{ExplorerTreeRow-DUmcEsqf.js → ExplorerTreeRow-CmGPHRI8.js} +1 -1
- package/dist/assets/{ImportView-9y1nhQS4.js → ImportView-YFBlvgF_.js} +1 -1
- package/dist/assets/{LayerGrid-bhFpOIbe.js → LayerGrid-KXyuibWY.js} +1 -1
- package/dist/assets/{LayerTable-RuswZVUI.js → LayerTable-CGsFJsKs.js} +1 -1
- package/dist/assets/{MaxGraphCanvas-D3BXQK2y.js → MaxGraphCanvas-BNn0Jxr6.js} +1 -1
- package/dist/assets/{ModelDiff-Cl2dhlk3.js → ModelDiff-CJCXuz_h.js} +1 -1
- package/dist/assets/{OntologyDecompositionDiagram-aONGngg4.js → OntologyDecompositionDiagram-5JWUI_PB.js} +1 -1
- package/dist/assets/{OntologyViewer-VOrKTRuQ.js → OntologyViewer-DxIWCcJM.js} +2 -2
- package/dist/assets/{ReviewDashboard--LMXZ3F4.js → ReviewDashboard-Qyj8RRFp.js} +1 -1
- package/dist/assets/{ScenarioEditor-bB4iBbgO.js → ScenarioEditor-BIAh6tLX.js} +1 -1
- package/dist/assets/{StatisticsDashboard-iXimfU20.js → StatisticsDashboard-CtI1hlfO.js} +1 -1
- package/dist/assets/{TabularView-DnIfq-TB.js → TabularView-DXxpRshk.js} +1 -1
- package/dist/assets/{TraceabilityMatrix-eilGn6Sr.js → TraceabilityMatrix-qEKmDy8z.js} +1 -1
- package/dist/assets/{UiScreensWorkspace-Cs1ivqzc.js → UiScreensWorkspace-BHhs5tcY.js} +1 -1
- package/dist/assets/{WorkflowWizard-C7jI6C59.js → WorkflowWizard-BjtGPRsS.js} +1 -1
- package/dist/assets/index-Cdkjp-H4.css +1 -0
- package/dist/assets/{index-CG-gfw-s.js → index-a2rpMs5Y.js} +70 -70
- package/dist/assets/{index.es-DABt8CUc.js → index.es-BwDQ0kmQ.js} +1 -1
- package/dist/assets/{jspdf.es.min-G-Vwo9yG.js → jspdf.es.min-KfOikWO5.js} +3 -3
- package/dist/assets/{notation-scene-DLZms6VR.js → notation-scene-CxT28i2i.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-standalone/index.html +183 -183
- package/lib/bin/memo-architect.js +15 -6
- package/lib/bin/memo-architect.js.map +1 -1
- package/package.json +3 -3
- package/dist/assets/index-DXB4CKwW.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-
|
|
2
|
-
var Fe=Object.defineProperty;var Se=(t,r,l)=>r in t?Fe(t,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[r]=l;var U=(t,r,l)=>Se(t,typeof r!="symbol"?r+"":r,l);import{_ as G,u as _,g as Ee,a as je,l as we,s as Ce,b as Re,c as ke,F as u,C as n,d as De,e as Ae,L as _e,f as Te,h as Le}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-DtLlTvJf.js","assets/reactflow-C9OlmOYw.js","assets/zustand-CrhqMOHB.js","assets/index-a2rpMs5Y.js","assets/index-Cdkjp-H4.css","assets/notation-scene-CxT28i2i.js","assets/layout-providers-BSDYNZu0.js","assets/elk-6l8mIQnQ.js","assets/ExplorerTreeRow-CmGPHRI8.js","assets/DiagramToolbarControls-XMGLx08e.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-BNn0Jxr6.js","assets/SysmlCodeEditor-i0BHj3of.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var Fe=Object.defineProperty;var Se=(t,r,l)=>r in t?Fe(t,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[r]=l;var U=(t,r,l)=>Se(t,typeof r!="symbol"?r+"":r,l);import{_ as G,u as _,g as Ee,a as je,l as we,s as Ce,b as Re,c as ke,F as u,C as n,d as De,e as Ae,L as _e,f as Te,h as Le}from"./index-a2rpMs5Y.js";import{j as e,a as Me}from"./reactflow-C9OlmOYw.js";import{a as s}from"./zustand-CrhqMOHB.js";import{I as y}from"./DiagramToolbarControls-XMGLx08e.js";const Y="memo.renderer.reactflow";class Ne{constructor(){U(this,"providers",new Map);U(this,"components",new Map)}register(r){const l=this.providers.get(r.descriptor.id);if(l&&l!==r)throw new Error(`Renderer provider already registered: ${r.descriptor.id}`);this.providers.set(r.descriptor.id,r)}unregister(r){return this.components.delete(r),this.providers.delete(r)}get(r){return this.providers.get(r)}has(r){return this.providers.has(r)}list(r=[]){return[...this.providers.values()].map(l=>l.descriptor).filter(l=>r.every(i=>l.capabilities.includes(i))).sort((l,i)=>l.name.localeCompare(i.name))}loadComponent(r){const l=this.providers.get(r)??this.providers.get(Y);if(!l)throw new Error(`Renderer provider not found: ${r} (no default registered)`);const i=l.descriptor.id;let a=this.components.get(i);return a||(a=l.loadComponent(),this.components.set(i,a)),a}}const $e={descriptor:{id:"memo.renderer.reactflow",name:"ReactFlow",engine:"ReactFlow (@xyflow/react 12)",version:"12",contractVersion:"1",license:"MIT",description:"Default authoring canvas — React node components, palette, full editing.",capabilities:["interactive-editing","all-view-kinds","manual-layout","undo-redo","minimap","orthogonal-routes"]},loadComponent:()=>G(()=>import("./DiagramCanvas-DtLlTvJf.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(t=>t.DiagramCanvas)},ze={descriptor:{id:"memo.renderer.maxgraph",name:"maxGraph",engine:"maxGraph (@maxgraph/core — draw.io rendering engine lineage)",version:"0.x",contractVersion:"1",license:"Apache-2.0",description:"draw.io-style retained-mode canvas — SVG cells, rubberband selection, image export.",capabilities:["all-view-kinds","manual-layout","export-image"]},loadComponent:()=>G(()=>import("./MaxGraphCanvas-BNn0Jxr6.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8])).then(t=>t.MaxGraphCanvas)},B=new Ne;B.register($e);B.register(ze);const Ie={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Be="memo.diagram.renderer.v3",Oe="renderer",Pe="memo.renderer.",ae=new Set;function q(t){const r=t==null?void 0:t.trim();if(r)return r.includes(".")?r:`${Pe}${r}`}function Ve(){if(!(typeof window>"u"))try{return q(new URLSearchParams(window.location.search).get(Oe))}catch{return}}function Ue(){if(!(typeof window>"u"))try{return q(window.localStorage.getItem(Be))}catch{return}}function Ge(){try{const t=Ie;return q(t==null?void 0:t.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function ce(){return Ve()??Ue()??Ge()??Y}function Ye(t){return ae.add(t),()=>ae.delete(t)}function qe(){return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:13},children:"Loading renderer…"})}function We(){const t=s.useSyncExternalStore(Ye,ce,ce),r=B.has(t)?t:Y,l=s.useMemo(()=>s.lazy(()=>B.loadComponent(r).then(i=>({default:i}))),[r]);return e.jsx("div",{className:"relative flex flex-1 overflow-hidden",children:e.jsx(s.Suspense,{fallback:e.jsx(qe,{}),children:e.jsx(l,{})})})}const He=s.lazy(()=>G(()=>import("./SysmlCodeEditor-i0BHj3of.js"),__vite__mapDeps([12,1,2,13])).then(t=>({default:t.SysmlCodeEditor})));function Ke(t,r){const l=(t.elementIds??[]).map(i=>r[i]).filter(Boolean).map(i=>` ${i.construct??"part"} ${i.id} : ${i.kind};`).join(`
|
|
3
3
|
`);return[`package '${t.name}' {`,` // Diagram: ${t.diagramType.toUpperCase()} | Viewpoint: ${t.viewpointId}`,l||" // No elements selected","}"].join(`
|
|
4
4
|
`)}function Qe({diagram:t}){const r=_(c=>c.model),l=_(c=>c.updateDiagramElementIds),[i,a]=s.useState(""),f=s.useMemo(()=>Ae(r),[r]),S=s.useCallback(c=>{const m=new Set(t.elementIds??[]);m.has(c)?m.delete(c):m.add(c),l(t.id,[...m])},[t.id,t.elementIds,l]),R=s.useMemo(()=>new Set(t.elementIds??[]),[t.elementIds]),E=_e.filter(c=>f.has(c));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{width:"220px",borderLeft:`1px solid ${n.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"px-2 py-1.5",style:{borderBottom:`1px solid ${n.border}`},children:[e.jsxs("div",{className:"font-semibold mb-1",style:{color:n.primary,fontSize:u.xs},children:["Elements (",R.size," selected)"]}),e.jsx("input",{value:i,onChange:c=>a(c.target.value),placeholder:"Filter…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{background:"#F0F0ED",border:`1px solid ${n.border}`,color:n.primary,fontSize:u.xs}})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:E.map(c=>{const m=(f.get(c)??[]).filter(p=>!i||p.name.toLowerCase().includes(i.toLowerCase())||p.id.toLowerCase().includes(i.toLowerCase()));if(m.length===0)return null;const O=Le[c]??n.muted;return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:O,fontSize:u.badge},children:Te[c]??c}),m.map(p=>e.jsxs("label",{className:"flex items-center gap-2 px-3 py-0.5 cursor-pointer",style:{fontSize:u.xs},onMouseEnter:x=>x.currentTarget.style.background="#F0F0ED",onMouseLeave:x=>x.currentTarget.style.background="transparent",children:[e.jsx("input",{type:"checkbox",checked:R.has(p.id),onChange:()=>S(p.id),style:{accentColor:n.accent}}),e.jsx("span",{className:"truncate",style:{color:n.primary},title:p.id,children:p.name||p.id})]},p.id))]},c)})})]})}function de({tone:t,message:r,actions:l}){const i=t==="conflict";return e.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-1.5 flex-wrap",style:{background:i?"#FEF2F2":"#FFFBEB",borderBottom:`1px solid ${i?"#FECACA":"#FDE68A"}`,color:i?"#B91C1C":"#92400E",fontSize:u.xs,flexShrink:0},children:[e.jsx("span",{className:"flex-1",style:{minWidth:180},children:r}),l.map(a=>e.jsx("button",{onClick:a.onClick,title:a.hint,style:{fontSize:u.xs,padding:"2px 8px",borderRadius:5,cursor:"pointer",background:"#FFFFFF",border:`1px solid ${i?"#FECACA":"#FDE68A"}`,color:"inherit",fontWeight:600,whiteSpace:"nowrap"},children:a.label},a.label))]})}const Xe=4e3;function Je({at:t}){const[r,l]=s.useState(!1);return s.useEffect(()=>{if(!t)return;l(!0);const i=setTimeout(()=>l(!1),Xe);return()=>clearTimeout(i)},[t]),r?e.jsx("span",{title:"A source file this view depends on changed; the view was rebuilt",style:{fontSize:u.badge,padding:"1px 6px",borderRadius:999,background:"#ECFDF5",color:"#047857",border:"1px solid #A7F3D0",whiteSpace:"nowrap"},children:"↻ Refreshed from source"}):null}const Ze=[];function nt({diagramId:t}){const r=_(o=>o.model),l=_(o=>o.diagramParseErrors[t]??Ze),i=_(o=>o.lastSourceChange),a=Ee(r,t),[f,S]=s.useState("visual"),[R,E]=s.useState(""),[c,m]=s.useState(!1),[O,p]=s.useState(!1),[x,W]=s.useState(!1),[h,T]=s.useState(!1),[k,F]=s.useState(null),[ue,H]=s.useState(null),[L,D]=s.useState(null),[M,N]=s.useState(null),[fe,he]=s.useState(null),[K,Q]=s.useState([]),[g,X]=s.useState(()=>localStorage.getItem("memo.diagramEditor.autoSave")==="true"),[j,pe]=s.useState(null),w=s.useRef(),b=s.useRef(""),J=s.useRef(0),A=s.useRef(void 0),$=s.useRef(0),Z=s.useRef(!1);s.useEffect(()=>{Z.current=h},[h]),s.useEffect(()=>{const o=()=>pe(document.getElementById("memo-diagram-editor-controls"));o();const v=new MutationObserver(o);return v.observe(document.body,{childList:!0,subtree:!0}),()=>v.disconnect()},[]);const ee=s.useMemo(()=>je(r,t),[r,t]),z=s.useCallback(async()=>{const o=++$.current,v=t;m(!0);try{const d=await we(v);if($.current!==o)return!1;const le=d.text??"";return b.current=le,A.current=d.revision,E(le),p(!0),T(!1),F(null),N(null),D(null),!0}catch(d){return $.current===o&&F(d instanceof Error?d.message:String(d)),!1}finally{$.current===o&&m(!1)}},[t]);s.useEffect(()=>{if(clearTimeout(w.current),F(null),H(null),T(!1),D(null),N(null),Q([]),A.current=void 0,!(!a||!r)){if(!a.sourceFile||window.__MEMO_DATA__){const o=Ke(a,r.elements);b.current=o,E(o),m(!1),p(!1);return}E(""),b.current="",p(!1),z()}},[t,a==null?void 0:a.sourceFile]),s.useEffect(()=>{if(!i||!(a!=null&&a.sourceFile)||window.__MEMO_DATA__||!Ce(i,ee))return;he(i.at);const o=i.files.includes(a.sourceFile);if(o){if(Z.current){D({files:i.files.filter(v=>ee.includes(v)),at:i.at,touchesOwnSource:o});return}z()}},[i==null?void 0:i.seq]);const xe=o=>{b.current=o,E(o),T(!0),F(null)},I=s.useCallback(async o=>{if(!a)return;const v=++J.current;W(!0),F(null);try{if(a.sourceFile){if(!A.current)throw new Error("Reload the source before saving this edit.");const d=await Re(t,o,A.current);if(d.conflict){N({theirs:d.text??"",revision:d.revision,at:Date.now()}),F(d.error??"The file changed on disk since this edit began.");return}A.current=d.revision,N(null),D(null),Q(d.parseErrors??[])}else ke(t,o);b.current===o&&T(!1),H(Date.now())}catch(d){F(d instanceof Error?d.message:String(d))}finally{J.current===v&&W(!1)}},[a,t]),te=s.useCallback(()=>{clearTimeout(w.current),z()},[z]),me=s.useCallback(()=>{navigator.clipboard.writeText(b.current)},[]),ge=s.useCallback(()=>{const o=new Blob([b.current],{type:"text/plain;charset=utf-8"}),v=URL.createObjectURL(o),d=document.createElement("a");d.href=v,d.download=`${t}-rejected.sysml`,d.click(),URL.revokeObjectURL(v)},[t]);s.useEffect(()=>(localStorage.setItem("memo.diagramEditor.autoSave",String(g)),clearTimeout(w.current),g&&h&&!c&&!M&&(w.current=setTimeout(()=>void I(b.current),800)),()=>clearTimeout(w.current)),[g,h,c,R,I,M]);const P=s.useCallback(()=>{clearTimeout(w.current),I(b.current)},[I]),ve=s.useMemo(()=>Object.values((r==null?void 0:r.elements)??{}).map(o=>({id:o.id,name:o.name,kind:o.kind})),[r==null?void 0:r.elements]);if(!a)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:n.faint,fontSize:u.sm},children:"Diagram not found"});const re=a.auto,C=!re||!!a.sourceFile&&O,se=e.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden",children:[M&&e.jsx(de,{tone:"conflict",message:`${a.sourceFile} changed on disk. Your rejected edit remains in this buffer and was not written.`,actions:[{label:"Copy draft",onClick:me,hint:"Copy the rejected SysML edit"},{label:"Download rejected edit",onClick:ge,hint:"Export the rejected SysML edit"},{label:"Reveal file",onClick:()=>De(a.sourceFile),hint:"Open the changed source file"},{label:"Reload from disk",onClick:te,hint:"Discard the draft and load current disk content"}]}),!M&&L&&e.jsx(de,{tone:"notice",message:L.files.length>1?`${L.files.length} source files changed on disk. Your unsaved edits are untouched.`:`${L.files[0]} changed on disk. Your unsaved edits are untouched.`,actions:[{label:"Reload from disk",onClick:te,hint:"Discards your unsaved edits"},{label:"Keep editing",onClick:()=>D(null),hint:"Dismiss until the next change"}]}),e.jsx("div",{className:"flex-1 overflow-hidden",style:{background:"#1E1E1E"},children:e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"h-full flex items-center justify-center",style:{color:"#9CA3AF",fontSize:u.xs},children:"Loading SysML editor…"}),children:e.jsx(He,{value:R,sourceFile:a.sourceFile,readOnly:!C||c,symbols:ve,onChange:xe,onSave:()=>{C&&h&&P()}})})}),K.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C1407",color:"#FCD34D",borderTop:"1px solid #3B2A0A",fontFamily:"monospace"},title:"Saved, but the file does not parse — the model keeps its last good state for this file",children:K.join(" · ")}),l.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#F87171",borderTop:"1px solid #3B0A0A",fontFamily:"monospace"},children:l.join(" · ")}),k&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#FCA5A5",borderTop:"1px solid #3B0A0A"},children:k}),!C&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#F9F9F8",color:n.faint,borderTop:`1px solid ${n.border}`},children:a.sourceFile&&window.__MEMO_DATA__?"Static build — run memo-architect dev to edit the SysML source":a.sourceFile?"The SysML source could not be loaded":"Generated model view — no editable SysML source file"})]}),oe=e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsx(We,{})}),!re&&e.jsx(Qe,{diagram:a})]}),ne=(j==null?void 0:j.dataset.compactDiagramTools)==="true",ie={visual:"split",split:"text",text:"visual"},V={visual:"Visual",split:"Both",text:"Text"},be=f==="visual"?e.jsx(y.eye,{}):f==="split"?e.jsx(y.split,{}):e.jsx(y.code,{}),ye=j?e.jsxs(e.Fragment,{children:[C&&e.jsx("button",{type:"button","aria-label":`Auto-save ${g?"on":"off"}`,"aria-pressed":g,onClick:()=>X(o=>!o),title:`Auto-save ${g?"on":"off"}. Click to turn it ${g?"off":"on"}.`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:0,borderRadius:5,border:`1px solid ${g?"#A7F3D0":n.border}`,cursor:"pointer",background:g?"#ECFDF5":"#FFFFFF",color:g?"#047857":n.secondary},children:e.jsx(y.clock,{})}),C&&e.jsx("button",{"aria-label":"Save SysML",onClick:P,disabled:!h||x||c,title:"Save SysML (Ctrl/Cmd+S)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:0,borderRadius:5,border:`1px solid ${n.border}`,cursor:!h||x||c?"default":"pointer",background:h?n.accent:"#F0F0ED",color:h?"#FFFFFF":n.faint},children:e.jsx(y.save,{})}),ne?e.jsx("button",{type:"button","aria-label":`Editor mode: ${V[f]}`,title:`Editor mode: ${V[f]}. Click to switch to ${V[ie[f]]}.`,onClick:()=>S(ie[f]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",borderRadius:5,border:"1px solid #1B3A4B",cursor:"pointer",background:"#1B3A4B",color:"#FFFFFF"},children:be}):e.jsxs("select",{"aria-label":"Diagram editor view",title:"Choose editor view",value:f,onChange:o=>S(o.target.value),style:{fontSize:u.xs,height:28,padding:"0 6px",borderRadius:5,border:`1px solid ${n.border}`,background:"#FFFFFF",color:n.primary},children:[e.jsx("option",{value:"visual",children:"Visual"}),e.jsx("option",{value:"split",children:"Both"}),e.jsx("option",{value:"text",children:"Text"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Je,{at:fe}),c&&e.jsx("span",{style:{color:n.faint,fontSize:u.xs},children:"Loading source…"}),x&&e.jsx("span",{style:{color:n.faint,fontSize:u.xs},children:"Saving…"}),!x&&k&&e.jsx("span",{title:k,style:{color:"#EF4444",fontSize:u.xs},children:"Save failed"}),!x&&!k&&h&&e.jsx("span",{style:{color:"#B45309",fontSize:u.xs},children:"Unsaved"}),!x&&!h&&ue&&e.jsx("span",{style:{color:"#15803D",fontSize:u.xs},children:"Saved"}),!x&&l.length>0&&e.jsxs("span",{style:{color:"#EF4444",fontSize:u.xs},children:[l.length," error",l.length>1?"s":""]}),C&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-1",style:{color:n.secondary,fontSize:u.xs},title:"Save changes 800ms after typing",children:[e.jsx("input",{type:"checkbox",checked:g,onChange:o=>X(o.target.checked),style:{accentColor:n.accent}}),"Auto-save"]}),e.jsx("button",{onClick:P,disabled:!h||x||c,title:"Save SysML (Ctrl/Cmd+S)",style:{fontSize:u.xs,padding:"3px 10px",borderRadius:"5px",border:`1px solid ${n.border}`,cursor:!h||x||c?"default":"pointer",background:h?n.accent:"#F0F0ED",color:h?"#FFFFFF":n.faint,fontWeight:600},children:"Save"})]}),e.jsxs("label",{className:"flex items-center gap-1",style:{color:n.secondary,fontSize:u.xs},children:["View",e.jsxs("select",{"aria-label":"Diagram editor view",value:f,onChange:o=>S(o.target.value),style:{fontSize:u.xs,padding:"3px 8px",borderRadius:"5px",border:`1px solid ${n.border}`,background:"#FFFFFF",color:n.primary},children:[e.jsx("option",{value:"visual",children:"Visual"}),e.jsx("option",{value:"split",children:"Both"}),e.jsx("option",{value:"text",children:"Text"})]})]})]});return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"relative flex items-center justify-center px-3 py-2",style:{borderBottom:`1px solid ${n.border}`,background:"#FAFAF8",flexShrink:0},children:[f!=="visual"&&e.jsxs("button",{type:"button",onClick:()=>S("visual"),title:"Return to the visual diagram",className:"absolute left-3 flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-semibold",style:{border:`1px solid ${n.border}`,background:"#FFFFFF",color:n.primary},children:[e.jsx(y.eye,{}),"Return to diagram"]}),e.jsx("span",{className:"truncate",style:{color:n.primary,fontSize:u.md,fontWeight:700},children:a.name}),f==="visual"&&e.jsxs("div",{className:"absolute right-3 flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>window.dispatchEvent(new Event("memo:toggle-diagram-elements")),title:"Show or hide Diagram Elements","aria-label":"Show or hide Diagram Elements",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${n.border}`,borderRadius:5,background:"#FFFFFF",color:n.secondary,cursor:"pointer"},children:e.jsx(y.elements,{size:18})}),e.jsx("button",{type:"button",onClick:()=>window.dispatchEvent(new Event("memo:toggle-diagram-toolbar")),title:"Show or hide Toolbar","aria-label":"Show or hide Toolbar",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${n.border}`,borderRadius:5,background:"#FFFFFF",color:n.secondary,cursor:"pointer"},children:e.jsx(y.tools,{size:18})})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[f==="visual"&&oe,f==="text"&&se,f==="split"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"50%",borderRight:`1px solid ${n.border}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:se}),e.jsx("div",{style:{width:"50%",display:"flex",overflow:"hidden"},children:oe})]})]}),j&&Me.createPortal(e.jsx("div",{className:ne?"contents":"flex flex-wrap items-center gap-2",children:ye}),j)]})}export{nt as DiagramEditor};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as E}from"./zustand-CrhqMOHB.js";import{u as h,k as C,C as i,F as a,h as V,x as D,P as z,y as F,R as f,z as P,A as U,B as S,G as u}from"./index-
|
|
1
|
+
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as E}from"./zustand-CrhqMOHB.js";import{u as h,k as C,C as i,F as a,h as V,x as D,P as z,y as F,R as f,z as P,A as U,B as S,G as u}from"./index-a2rpMs5Y.js";const r="page",_=new Set(["Scenario","UseCase","UserActivity"]);function H(p){return p?p.split(`
|
|
2
2
|
`).filter(o=>o.trim()).map((o,d)=>{const m=o.match(/^\d+\.\s*(.*)/);return{index:d,text:m?m[1].trim():o.trim()}}):[]}function Y({element:p,layerColor:o,onSave:d}){const m=E.useMemo(()=>H(p.doc||""),[p.doc]),[w,y]=E.useState(!1);return w||m.length===0?e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:a.xs,color:i.faint,marginBottom:6,marginTop:0},children:["One step per line, numbered: ",e.jsx("code",{children:"1. User does something"})]}),e.jsx(F,{value:p.doc||"",onSave:x=>{d(x),y(!1)},density:r,multiline:!0,placeholder:"Click to add scenario steps…"})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>y(!0),style:{position:"absolute",top:0,right:0,fontSize:a.xs,color:i.muted,padding:"2px 9px",border:`1px solid ${i.border}`,borderRadius:"6px",background:i.surface,cursor:"pointer"},onMouseEnter:x=>{x.currentTarget.style.borderColor=i.accent},onMouseLeave:x=>{x.currentTarget.style.borderColor=i.border},children:"✎ Edit steps"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",paddingTop:4},children:[e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:a.xs,fontWeight:700,background:o,color:"#fff",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Start"}),m.map((x,s)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[e.jsx(M,{color:o}),e.jsxs("div",{style:{width:"100%",maxWidth:"560px",display:"flex",alignItems:"flex-start",gap:"12px",background:i.surface,border:`1px solid ${o}30`,borderRadius:"8px",padding:"10px 14px",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsx("span",{style:{flexShrink:0,width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:o+"18",color:o,fontSize:a.xs,fontWeight:700},children:s+1}),e.jsx("span",{style:{fontSize:a.sm,color:i.primary,lineHeight:1.5,paddingTop:"3px"},children:x.text})]})]},s)),e.jsx(M,{color:o}),e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:a.xs,fontWeight:700,background:o+"20",color:o,letterSpacing:"0.06em",textTransform:"uppercase",border:`1px solid ${o}40`},children:"End"})]})]})}function M({color:p}){return e.jsx("div",{style:{width:"2px",height:"20px",background:p+"50",position:"relative"},children:e.jsx("div",{style:{position:"absolute",bottom:-5,left:"50%",transform:"translateX(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`6px solid ${p}80`}})})}function q({elementId:p}={}){var N,$,B,L;const o=h(t=>t.activeView),d=h(t=>t.model),m=h(t=>t.validation),w=h(t=>t.updateElementField),y=h(t=>t.updateElementAttribute),x=h(t=>t.applyEdit),s=p??(o.type==="element-detail"?o.elementId:null),n=s&&d?d.elements[s]:null,R=E.useMemo(()=>{if(!d||!s)return{incoming:[],outgoing:[]};const t=C(d,s);return{incoming:t.filter(c=>c.targetId===s),outgoing:t.filter(c=>c.sourceId===s)}},[d,s]),b=E.useMemo(()=>!m||!s?[]:m.violations.filter(t=>t.elementId===s),[m,s]);if(!n||!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:i.surfaceAlt},children:e.jsxs("div",{className:"text-center",style:{color:i.faint,marginTop:"-48px"},children:[e.jsxs("div",{style:{position:"relative",width:"280px",maxWidth:"60vw",margin:"0 auto -32px"},children:[e.jsx("img",{src:"/logo.png",alt:"MEMO",style:{width:"100%",display:"block",opacity:.5,mixBlendMode:"multiply"}}),e.jsx("span",{style:{position:"absolute",left:"59%",top:"60%",color:"#8B949E",fontSize:"19px",fontWeight:600,letterSpacing:"0.02em",whiteSpace:"nowrap"},children:"Architect"})]}),e.jsx("p",{style:{fontSize:a.md,margin:0},children:"Select an element to view details"})]})});const j=V[n.layer]||i.muted,l=(N=n.provenance)==null?void 0:N.declaration,k=(l==null?void 0:l.writable)!==!1,g=($=d==null?void 0:d.registries)==null?void 0:$.kinds.find(t=>t.name===n.kind),T=((B=g==null?void 0:g.namespace)==null?void 0:B[1])??((L=g==null?void 0:g.namespace)==null?void 0:L[0]),O=(t,c)=>{w(s,t,c),x(s)},I=(t,c)=>{y(s,t,c),x(s)},v=Object.entries(n.attributes).filter(([t])=>t!=="id"&&t!=="name"),A=_.has(n.kind);return e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:"#EEF4F7"},children:e.jsxs("div",{style:{maxWidth:"1040px",margin:"0 auto",padding:"20px 28px 48px"},children:[e.jsxs("header",{style:{background:i.surface,border:"1px solid rgba(60,60,67,0.12)",borderLeft:`4px solid ${j}`,borderRadius:"16px",padding:"14px 18px",marginBottom:16,boxShadow:"0 1px 3px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",style:{marginBottom:8},children:[e.jsx("span",{className:"px-2 py-0.5 rounded-md font-semibold",style:{background:j+"18",color:j,fontSize:a.xs},children:n.kind}),e.jsx("span",{className:"px-2 py-0.5 rounded-md",style:{background:i.surfaceAlt,color:i.muted,fontSize:a.xs},children:n.layer}),T&&e.jsx("span",{style:{color:i.faint,fontSize:a.xs},children:T.replace(/[_-]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}),n.shortId&&e.jsx("span",{style:{marginLeft:"auto",color:i.faint,fontSize:a.xs,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:n.shortId})]}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:i.primary,lineHeight:1.2,margin:0},children:n.name}),e.jsx("div",{style:{marginTop:9,paddingTop:8,borderTop:`1px solid ${i.borderLight}`},children:e.jsx(D,{density:r})})]}),b.length>0&&e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #FEE2E2",background:"#FEF2F2",marginBottom:20},children:[e.jsxs("div",{className:"px-4 py-2 font-semibold",style:{color:"#DC2626",fontSize:a.sm,borderBottom:"1px solid #FEE2E2"},children:[b.length," violation",b.length!==1?"s":""]}),b.map((t,c)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{fontSize:a.xs},children:[e.jsx("span",{style:{color:"#DC2626"},children:"✖"}),e.jsxs("span",{style:{color:i.faint},children:["[",t.ruleId,"]"]}),e.jsx("span",{style:{color:"#991B1B"},children:t.description})]},c))]}),e.jsx(z,{title:A?"Flow":"Description",density:r,collapsible:!1,children:A&&k?e.jsx(Y,{element:n,layerColor:j,onSave:t=>O("doc",t)}):k?e.jsx(F,{value:n.attributes.description||"",onSave:t=>I("description",t),density:r,multiline:!0,placeholder:"Click to add a description…"}):e.jsx(f,{value:n.attributes.description||n.doc||"",editability:{kind:"derived",reason:`This ${(l==null?void 0:l.origin)??"library"} declaration is read-only.`},density:r})}),e.jsxs(z,{title:"Attributes",count:v.length,density:r,collapsible:!1,children:[v.length===0&&e.jsx("p",{style:{fontSize:a.sm,color:i.faint,margin:0},children:"This element defines no attributes."}),v.length>0&&e.jsx("div",{style:{borderTop:`1px solid ${i.border}`,maxWidth:900},children:v.map(([t,c])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(150px, 24%) minmax(0, 1fr)",gap:16,alignItems:"center",padding:"7px 0",borderBottom:`1px solid ${i.borderLight}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{color:i.secondary,fontSize:a.sm,fontWeight:600},children:t}),e.jsx("div",{style:{color:i.faint,fontSize:"10px"},children:"Editable"})]}),k?e.jsx(F,{value:String(c??""),onSave:W=>I(t,W),density:r,placeholder:"Add value…",compact:!0}):e.jsx(f,{value:String(c??""),editability:{kind:"derived",reason:`This ${(l==null?void 0:l.origin)??"library"} declaration is read-only.`},density:r})]},t))})]}),e.jsx(P,{element:n,outgoing:R.outgoing,incoming:R.incoming,density:r}),e.jsx("div",{style:{background:i.surface,borderRadius:12,marginBottom:16},children:e.jsx(U,{subject:n})}),e.jsx(z,{title:"Origin",density:r,collapsible:!1,children:e.jsxs("div",{style:{maxWidth:720},children:[e.jsx(S,{label:"SysML source file",editability:u("file"),density:r,children:e.jsx(f,{value:n.file??"—",editability:u("file"),density:r,mono:!0})}),l&&e.jsxs(e.Fragment,{children:[e.jsx(S,{label:"Origin",editability:u("origin"),density:r,children:e.jsx(f,{value:l.origin,editability:u("origin"),density:r})}),e.jsx(S,{label:"Package",editability:u("package"),density:r,children:e.jsx(f,{value:`${l.packageName}${l.packageVersion?` v${l.packageVersion}`:""}`,editability:u("package"),density:r})}),e.jsx(S,{label:"Access",editability:u("access"),density:r,children:e.jsx(f,{value:l.writable?"Editable project content":"Read-only reusable content",editability:u("access"),density:r})})]})]})})]})})}export{q as ElementDetailView};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as s}from"./reactflow-C9OlmOYw.js";import{a as F}from"./zustand-CrhqMOHB.js";import{u as ne,F as W}from"./index-CG-gfw-s.js";const ce=new Set(["overlay","transient"]);function V(t){if(!t)return"";const o=t.lastIndexOf("::");return o>=0?t.slice(o+2):t}function $(t){if(t===void 0||t==="")return;const o=Number(t);return Number.isFinite(o)?o:void 0}function ie(t){const o=t.attributes??{},g=$(o["bounds.x"]),d=$(o["bounds.y"]),l=$(o["bounds.width"]),a=$(o["bounds.height"]);if(!(g===void 0||d===void 0||l===void 0||a===void 0))return{x:g,y:d,width:l,height:a}}function le(t,o){return{x:t.x+o.x*t.width,y:t.y+o.y*t.height,width:o.width*t.width,height:o.height*t.height}}function G(t,o){const g=new Map;for(const d of t){if(d.type.toLowerCase()!==o)continue;const l=g.get(d.sourceId)??[];l.push(d.targetId),g.set(d.sourceId,l)}return g}function ue(t,o={}){var x,r,k;const g=Object.values(t.elements??{}),d=new Map(g.map(b=>[b.id,b])),l=t.relationships??[],a=g.filter(b=>b.kind==="ScreenCapture"),u=o.captureId?a.find(b=>b.id===o.captureId):a[0];if(!u)return{nodes:[],emptyReason:"No ScreenCapture in this view."};const E=G(l,"capturesscreen"),S=(E.get(u.id)??[])[0],C=S?d.get(S):void 0;if(!C)return{capture:u,nodes:[],emptyReason:`"${u.name}" is not linked to a screen by CapturesScreen.`};const z=G(l,"composes"),R=G(l,"navigatesto"),v={x:0,y:0,width:1,height:1},w=[],I=new Set,f=new Set([...E.values()].flat()),c=(b,M,D,P)=>{if(I.has(b.id))return;I.add(b.id);const p=b.attributes??{},N=V(p.detectionMethod),L=(z.get(b.id)??[]).filter(U=>{const y=d.get(U);return!!y&&y.kind==="UIElement"&&!!ie(y)});if(w.push({element:b,rect:M,depth:D,childIds:L,parentId:P,formKind:V(p.formKind),disclosureKind:V(p.disclosureKind)||"inline",boundaryColor:p.boundaryColor||void 0,boundaryWidth:$(p.boundaryWidth),unconfirmed:N==="automatic"&&!(p.confirmedBy??"").trim(),detectionConfidence:$(p.detectionConfidence),navigatesToId:(R.get(b.id)??[])[0]}),!(b.id!==C.id&&f.has(b.id)))for(const U of L){const y=d.get(U);c(y,le(M,ie(y)),D+1,b.id)}};return c(C,v,0),{capture:u,screen:C,imageUri:pe((x=u.attributes)==null?void 0:x.imageUri),pixelWidth:$((r=u.attributes)==null?void 0:r.pixelWidth),pixelHeight:$((k=u.attributes)==null?void 0:k.pixelHeight),nodes:w}}function pe(t){if(t)return t.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`/${t}`}function xe(t){return Object.values(t.elements??{}).filter(o=>o.kind==="ScreenCapture")}function K(t,o){const d=(t.relationships??[]).find(l=>l.type.toLowerCase()==="capturesscreen"&&l.targetId===o);if(d)return(t.elements??{})[d.sourceId]??Object.values(t.elements??{}).find(l=>l.id===d.sourceId)}function ye(t,o,g){const d=new Map((t.relationships??[]).filter(u=>u.type.toLowerCase()==="composes").map(u=>[u.targetId,u.sourceId])),l=new Set;let a=d.get(g);for(;a&&a!==o&&!l.has(a);){l.add(a);const u=K(t,a);if(u)return u;a=d.get(a)}return K(t,o)}function _(t){return ce.has(t.disclosureKind)}const he={screen:"#1B3A4B",panel:"#2DD4A8",dialog:"#A855F7",field:"#E4572E",button:"#A855F7",selector:"#F59E0B",table:"#3B82F6",chart:"#3B82F6",decoration:"#9CA3AF"},ge=t=>t.boundaryColor||he[t.formKind]||"#6B7280",X=(t,o=0,g=1)=>Math.max(o,Math.min(g,t));function Fe({diagram:t,model:o,captureId:g,viewpointFilter:d,editable:l=!1,drawMode:a=!1,newElementDefaultName:u="New UIElement",onCreateBounds:E,onBoundsChange:S,proposals:C=[],onAcceptProposal:z,onRejectProposal:R}){var Z;const v=ne(e=>e.inspectElement),w=ne(e=>e.selectedElementId),[I,f]=F.useState([]),[c,x]=F.useState(null),[r,k]=F.useState(null),[b,M]=F.useState(null),D=F.useRef(null),P=I[I.length-1]??g;F.useEffect(()=>f([]),[g]),F.useEffect(()=>{a||k(e=>(e==null?void 0:e.kind)==="create"?null:e)},[a]);const p=F.useMemo(()=>ue(o,{captureId:P}),[o,P]),N=F.useMemo(()=>d?p.nodes.filter(e=>d(e.element)):p.nodes,[p.nodes,d]),L=N.find(e=>e.element.id===w),y=N.find(e=>e.element.id===b)??L,oe=new Set((y==null?void 0:y.childIds)??[]),q=F.useCallback(e=>{const i=e.navigatesToId??e.element.id,n=K(o,i);(n==null?void 0:n.id)!==P&&n&&f(m=>[...m,n.id])},[o,P]);if(!p.nodes.length)return s.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:s.jsxs("div",{className:"text-center",style:{maxWidth:420},children:[s.jsx("h3",{style:{fontSize:W.lg,fontWeight:600,color:"#374151",marginBottom:8},children:t.name}),s.jsx("p",{style:{fontSize:W.md,color:"#9CA3AF",lineHeight:1.6},children:p.emptyReason??"Nothing to lay out in this view."})]})});const re=[...N].sort((e,i)=>{const n=_(e)?1:0,m=_(i)?1:0;return n-m||e.depth-i.depth}),se=p.pixelWidth&&p.pixelHeight?p.pixelHeight/p.pixelWidth:.625,O=(e,i)=>{var m;const n=(m=D.current)==null?void 0:m.getBoundingClientRect();return n?{x:X((e-n.left)/n.width),y:X((i-n.top)/n.height)}:{x:0,y:0}},B=e=>{if(e.kind==="draw")return{x:Math.min(e.startX,e.currentX),y:Math.min(e.startY,e.currentY),width:Math.abs(e.currentX-e.startX),height:Math.abs(e.currentY-e.startY)};const i=e.currentX-e.startX,n=e.currentY-e.startY;return e.kind==="move"?{...e.baseRect,x:X(e.baseRect.x+i,0,1-e.baseRect.width),y:X(e.baseRect.y+n,0,1-e.baseRect.height)}:{...e.baseRect,width:X(e.baseRect.width+i,.01,1-e.baseRect.x),height:X(e.baseRect.height+n,.01,1-e.baseRect.y)}},ae=(e,i)=>{var m;const n=e.parentId?(m=p.nodes.find(A=>A.element.id===e.parentId))==null?void 0:m.rect:void 0;return n?{x:(i.x-n.x)/n.width,y:(i.y-n.y)/n.height,width:i.width/n.width,height:i.height/n.height}:i},de=()=>{if(!c)return;const e=B(c);c.kind==="draw"?e.width>=.01&&e.height>=.01&&k({kind:"create",rect:e,name:u}):(Math.abs(c.currentX-c.startX)>=.002||Math.abs(c.currentY-c.startY)>=.002)&&k(c.node?{kind:"edit",node:c.node,rect:e}:{kind:"create",rect:e,name:(r==null?void 0:r.kind)==="create"?r.name:u}),x(null)},J=(e,i,n)=>{var A;e.stopPropagation();const m=O(e.clientX,e.clientY);(A=D.current)==null||A.setPointerCapture(e.pointerId),x({kind:i,node:n.kind==="edit"?n.node:void 0,baseRect:n.rect,startX:m.x,startY:m.y,currentX:m.x,currentY:m.y})},Q=()=>{if(r){if(r.kind==="create"){const e=r.name.trim();if(!e)return;E==null||E(r.rect,e)}else S==null||S(r.node.element.id,ae(r.node,r.rect));k(null)}};return s.jsxs("div",{className:"flex-1 flex flex-col overflow-auto",style:{background:"#F7F7F5"},children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",style:{borderBottom:"1px solid #E5E5E0"},children:[s.jsx("span",{style:{fontSize:W.sm,fontWeight:600,color:"#374151"},children:(Z=p.screen)==null?void 0:Z.name}),I.length>0&&s.jsx("button",{onClick:()=>f(e=>e.slice(0,-1)),style:{fontSize:W.xs,padding:"2px 8px",marginLeft:"auto",border:"1px solid #E5E5E0",borderRadius:6,background:"#FFFFFF",color:"#374151",cursor:"pointer"},children:"← Back"})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{ref:D,role:"application","aria-label":"Screen region canvas",onPointerDown:e=>{if(!l||!a||r||e.target!==e.currentTarget)return;const i=O(e.clientX,e.clientY);e.currentTarget.setPointerCapture(e.pointerId),x({kind:"draw",startX:i.x,startY:i.y,currentX:i.x,currentY:i.y})},onPointerMove:e=>{if(!c)return;const i=O(e.clientX,e.clientY);x(n=>n?{...n,currentX:i.x,currentY:i.y}:null)},onPointerUp:de,onPointerCancel:()=>x(null),style:{position:"relative",width:"100%",maxWidth:900,paddingBottom:`${se*100}%`,margin:"0 auto",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:8,backgroundImage:p.imageUri?`url(${p.imageUri})`:void 0,backgroundSize:"contain",backgroundRepeat:"no-repeat",cursor:a&&!r?"crosshair":"default"},children:[!p.imageUri&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{fontSize:W.xs,color:"#9CA3AF"},children:"No image at this capture’s imageUri — boxes shown without a backdrop"}),!a&&re.map(e=>{const i=e.element.id===w,n=e.element.id===b,m=e.element.id===(y==null?void 0:y.element.id),A=oe.has(e.element.id),H=!!y&&!m&&!A,Y=ge(e),ee=K(o,e.navigatesToId??e.element.id),te=!!ee&&ee.id!==P;return s.jsxs("div",{id:`screen-node-${e.element.id}`,onClick:h=>{h.stopPropagation(),v(e.element.id)},onDoubleClick:h=>{h.stopPropagation(),q(e)},onMouseEnter:()=>M(e.element.id),onMouseLeave:()=>M(h=>h===e.element.id?null:h),onPointerDown:h=>{var T;if(!l||a||r||e.depth===0)return;h.stopPropagation(),v(e.element.id);const j=O(h.clientX,h.clientY);(T=D.current)==null||T.setPointerCapture(h.pointerId),x({kind:"move",node:e,baseRect:e.rect,startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})},title:`${e.element.name} · ${e.formKind}${te?" · double-click to open":""}`,style:{position:"absolute",left:`${e.rect.x*100}%`,top:`${e.rect.y*100}%`,width:`${e.rect.width*100}%`,height:`${e.rect.height*100}%`,border:`${e.boundaryWidth??(i||n?2:1)}px ${e.unconfirmed?"dashed":"solid"} ${H?"#9CA3AF":Y}`,borderRadius:3,background:H?"#6B728012":n?`color-mix(in srgb, ${Y} 12%, transparent)`:i?`color-mix(in srgb, ${Y} 6%, transparent)`:"transparent",boxShadow:_(e)?"0 2px 10px rgba(0,0,0,0.18)":void 0,opacity:H?.18:1,pointerEvents:a?"none":"auto",cursor:l&&i?"move":"pointer",transition:"opacity 120ms ease, border-width 120ms ease"},children:[(i||!L)&&e.depth>0&&s.jsxs("span",{style:{position:"absolute",top:-2,left:2,transform:"translateY(-100%)",fontSize:9,fontWeight:600,color:Y,background:"#FFFFFFDD",padding:"0 3px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none"},children:[e.element.name,e.unconfirmed&&e.detectionConfidence!==void 0&&` · ${Math.round(e.detectionConfidence*100)}%?`]}),te&&s.jsx("button",{type:"button","aria-label":`Open ${e.element.name}`,onPointerDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),q(e)},style:{position:"absolute",top:3,right:3,zIndex:3,width:22,height:22,borderRadius:5,border:`1px solid ${Y}`,background:"#FFFFFFE8",color:Y,fontSize:13,lineHeight:"18px",cursor:"pointer",opacity:H?.25:1},title:`Open nested region ${e.element.name}`,children:"↗"}),l&&i&&e.depth>0&&s.jsx("span",{onPointerDown:h=>{var T;h.stopPropagation();const j=O(h.clientX,h.clientY);(T=D.current)==null||T.setPointerCapture(h.pointerId),x({kind:"resize",node:e,baseRect:e.rect,startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})},title:"Drag to resize",style:{position:"absolute",width:10,height:10,right:-5,bottom:-5,borderRadius:2,background:Y,border:"1px solid #FFFFFF",cursor:"nwse-resize"}})]},e.element.id)}),!a&&C.filter(e=>e.status==="pending").map((e,i)=>s.jsx("div",{title:`Detected boundary · ${Math.round(e.confidence*100)}% confidence`,style:{position:"absolute",zIndex:20+i,left:`${e.bounds.x*100}%`,top:`${e.bounds.y*100}%`,width:`${e.bounds.width*100}%`,height:`${e.bounds.height*100}%`,border:"2px dashed #2563EB",borderRadius:3,background:"#2563EB12",pointerEvents:"none"},children:s.jsxs("span",{style:{position:"absolute",top:2,right:2,display:"inline-flex",gap:3,pointerEvents:"auto",background:"#FFFFFFEE",padding:2,borderRadius:5,boxShadow:"0 1px 4px rgba(0,0,0,0.16)"},children:[s.jsx("button",{type:"button","aria-label":`Accept detected region ${e.id}`,onPointerDown:n=>n.stopPropagation(),onClick:n=>{n.stopPropagation(),z==null||z(e.id)},title:"Accept region",style:{width:22,height:20,border:0,borderRadius:4,background:"#DCFCE7",color:"#15803D",cursor:"pointer"},children:"✓"}),s.jsx("button",{type:"button","aria-label":`Reject detected region ${e.id}`,onPointerDown:n=>n.stopPropagation(),onClick:n=>{n.stopPropagation(),R==null||R(e.id)},title:"Reject region",style:{width:22,height:20,border:0,borderRadius:4,background:"#FEE2E2",color:"#DC2626",cursor:"pointer"},children:"×"})]})},e.id)),c&&s.jsx("div",{style:{position:"absolute",left:`${B(c).x*100}%`,top:`${B(c).y*100}%`,width:`${B(c).width*100}%`,height:`${B(c).height*100}%`,border:"2px dashed #0F766E",background:"#2DD4A81A",pointerEvents:"none"}}),r&&!c&&s.jsxs("div",{"aria-label":r.kind==="create"?"New region boundary draft":"Edited region boundary draft",onPointerDown:e=>J(e,"move",r),style:{position:"absolute",zIndex:80,left:`${r.rect.x*100}%`,top:`${r.rect.y*100}%`,width:`${r.rect.width*100}%`,height:`${r.rect.height*100}%`,border:"2px dashed #0F766E",borderRadius:3,background:"#2DD4A824",cursor:"move",boxShadow:"0 0 0 1px #FFFFFF99"},children:[s.jsxs("span",{style:{position:"absolute",top:4,left:4,display:"flex",gap:4,padding:3,borderRadius:6,background:"#FFFFFFF2",boxShadow:"0 1px 5px rgba(15,23,42,0.18)"},children:[r.kind==="create"&&s.jsx("input",{autoFocus:!0,"aria-label":"New UIElement name",placeholder:"UIElement name",value:r.name,onPointerDown:e=>e.stopPropagation(),onFocus:e=>e.currentTarget.select(),onChange:e=>k(i=>(i==null?void 0:i.kind)==="create"?{...i,name:e.target.value}:i),onKeyDown:e=>{e.key==="Enter"&&Q(),e.key==="Escape"&&k(null)},style:{width:150,border:"1px solid #CBD5E1",borderRadius:4,padding:"3px 6px",color:"#1F2937",fontSize:10}}),s.jsx("button",{type:"button",disabled:r.kind==="create"&&!r.name.trim(),onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),Q()},"aria-label":"Confirm region boundary",title:"Save this boundary",style:{border:0,borderRadius:4,padding:"3px 7px",background:"#DCFCE7",color:"#15803D",cursor:r.kind==="create"&&!r.name.trim()?"not-allowed":"pointer",opacity:r.kind==="create"&&!r.name.trim()?.5:1,fontSize:10,fontWeight:700},children:"✓ Confirm"}),s.jsx("button",{type:"button",onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),k(null)},"aria-label":"Cancel region boundary",title:"Discard this boundary change",style:{border:0,borderRadius:4,padding:"3px 7px",background:"#FEE2E2",color:"#DC2626",cursor:"pointer",fontSize:10,fontWeight:700},children:"× Cancel"})]}),s.jsx("span",{"aria-label":"Resize region boundary draft",onPointerDown:e=>J(e,"resize",r),title:"Drag to resize before confirming",style:{position:"absolute",width:12,height:12,right:-6,bottom:-6,borderRadius:2,background:"#0F766E",border:"2px solid #FFFFFF",cursor:"nwse-resize"}})]}),a&&!c&&!r&&s.jsx("div",{style:{position:"absolute",zIndex:70,left:8,top:8,padding:"5px 8px",borderRadius:6,pointerEvents:"none",background:"#0F766EEB",color:"#FFFFFF",fontSize:10,fontWeight:650},children:"Click and drag to define a region"})]})})]})}function ve({id:t,label:o,depth:g,hasChildren:d,expanded:l,selected:a,badge:u,badgeColor:E="#0F766E",count:S,title:C,onClick:z,onDelete:R}){const[v,w]=F.useState(null),I=F.useRef(null);return F.useEffect(()=>{if(!v)return;const f=x=>{var r;(r=I.current)!=null&&r.contains(x.target)||w(null)},c=x=>{x.key==="Escape"&&w(null)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",c),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",c)}},[v]),s.jsxs("div",{role:"none",children:[s.jsxs("button",{type:"button",role:"treeitem","aria-selected":a,"aria-expanded":d?l:void 0,"data-tree-id":t,onClick:z,onContextMenu:R?f=>{f.preventDefault(),f.stopPropagation(),w({x:f.clientX,y:f.clientY})}:void 0,title:C,className:"flex items-center gap-1.5 w-full text-left",style:{minHeight:28,padding:"4px 8px",paddingLeft:8+g*18,border:0,borderRadius:6,cursor:"pointer",background:a?"#2DD4A818":"transparent",color:a?"#0F766E":"#374151"},onMouseEnter:f=>{a||(f.currentTarget.style.background="#F0F0ED")},onMouseLeave:f=>{f.currentTarget.style.background=a?"#2DD4A818":"transparent"},children:[s.jsx("span",{"aria-hidden":!0,style:{width:12,textAlign:"center",flexShrink:0,fontSize:9,color:"#9CA3AF",transform:l?"rotate(90deg)":"none",transition:"transform 120ms ease",visibility:d?"visible":"hidden"},children:"▶"}),u&&s.jsx("span",{style:{minWidth:27,height:17,padding:"0 4px",borderRadius:4,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:`${E}18`,color:E,fontSize:9,fontWeight:800},children:u}),s.jsx("span",{className:"truncate",style:{flex:1,fontSize:W.xs,fontWeight:d?650:500},children:o}),S!==void 0&&s.jsx("span",{style:{color:"#9CA3AF",fontSize:9},children:S})]}),v&&R&&s.jsx("div",{ref:I,role:"menu",className:"fixed z-50 rounded-lg overflow-hidden py-1",style:{left:v.x,top:v.y,minWidth:180,background:"#FFFFFF",border:"1px solid #E5E7EB",boxShadow:"0 8px 24px rgba(0,0,0,0.16)"},children:s.jsx("button",{type:"button",role:"menuitem",onClick:async()=>{w(null);const f=typeof o=="string"?o:C??"this element";if(!window.confirm(`Delete “${f}”?
|
|
1
|
+
import{j as s}from"./reactflow-C9OlmOYw.js";import{a as F}from"./zustand-CrhqMOHB.js";import{u as ne,F as W}from"./index-a2rpMs5Y.js";const ce=new Set(["overlay","transient"]);function V(t){if(!t)return"";const o=t.lastIndexOf("::");return o>=0?t.slice(o+2):t}function $(t){if(t===void 0||t==="")return;const o=Number(t);return Number.isFinite(o)?o:void 0}function ie(t){const o=t.attributes??{},g=$(o["bounds.x"]),d=$(o["bounds.y"]),l=$(o["bounds.width"]),a=$(o["bounds.height"]);if(!(g===void 0||d===void 0||l===void 0||a===void 0))return{x:g,y:d,width:l,height:a}}function le(t,o){return{x:t.x+o.x*t.width,y:t.y+o.y*t.height,width:o.width*t.width,height:o.height*t.height}}function G(t,o){const g=new Map;for(const d of t){if(d.type.toLowerCase()!==o)continue;const l=g.get(d.sourceId)??[];l.push(d.targetId),g.set(d.sourceId,l)}return g}function ue(t,o={}){var x,r,k;const g=Object.values(t.elements??{}),d=new Map(g.map(b=>[b.id,b])),l=t.relationships??[],a=g.filter(b=>b.kind==="ScreenCapture"),u=o.captureId?a.find(b=>b.id===o.captureId):a[0];if(!u)return{nodes:[],emptyReason:"No ScreenCapture in this view."};const E=G(l,"capturesscreen"),S=(E.get(u.id)??[])[0],C=S?d.get(S):void 0;if(!C)return{capture:u,nodes:[],emptyReason:`"${u.name}" is not linked to a screen by CapturesScreen.`};const z=G(l,"composes"),R=G(l,"navigatesto"),v={x:0,y:0,width:1,height:1},w=[],I=new Set,f=new Set([...E.values()].flat()),c=(b,M,D,P)=>{if(I.has(b.id))return;I.add(b.id);const p=b.attributes??{},N=V(p.detectionMethod),L=(z.get(b.id)??[]).filter(U=>{const y=d.get(U);return!!y&&y.kind==="UIElement"&&!!ie(y)});if(w.push({element:b,rect:M,depth:D,childIds:L,parentId:P,formKind:V(p.formKind),disclosureKind:V(p.disclosureKind)||"inline",boundaryColor:p.boundaryColor||void 0,boundaryWidth:$(p.boundaryWidth),unconfirmed:N==="automatic"&&!(p.confirmedBy??"").trim(),detectionConfidence:$(p.detectionConfidence),navigatesToId:(R.get(b.id)??[])[0]}),!(b.id!==C.id&&f.has(b.id)))for(const U of L){const y=d.get(U);c(y,le(M,ie(y)),D+1,b.id)}};return c(C,v,0),{capture:u,screen:C,imageUri:pe((x=u.attributes)==null?void 0:x.imageUri),pixelWidth:$((r=u.attributes)==null?void 0:r.pixelWidth),pixelHeight:$((k=u.attributes)==null?void 0:k.pixelHeight),nodes:w}}function pe(t){if(t)return t.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(t)?t:`/${t}`}function xe(t){return Object.values(t.elements??{}).filter(o=>o.kind==="ScreenCapture")}function K(t,o){const d=(t.relationships??[]).find(l=>l.type.toLowerCase()==="capturesscreen"&&l.targetId===o);if(d)return(t.elements??{})[d.sourceId]??Object.values(t.elements??{}).find(l=>l.id===d.sourceId)}function ye(t,o,g){const d=new Map((t.relationships??[]).filter(u=>u.type.toLowerCase()==="composes").map(u=>[u.targetId,u.sourceId])),l=new Set;let a=d.get(g);for(;a&&a!==o&&!l.has(a);){l.add(a);const u=K(t,a);if(u)return u;a=d.get(a)}return K(t,o)}function _(t){return ce.has(t.disclosureKind)}const he={screen:"#1B3A4B",panel:"#2DD4A8",dialog:"#A855F7",field:"#E4572E",button:"#A855F7",selector:"#F59E0B",table:"#3B82F6",chart:"#3B82F6",decoration:"#9CA3AF"},ge=t=>t.boundaryColor||he[t.formKind]||"#6B7280",X=(t,o=0,g=1)=>Math.max(o,Math.min(g,t));function Fe({diagram:t,model:o,captureId:g,viewpointFilter:d,editable:l=!1,drawMode:a=!1,newElementDefaultName:u="New UIElement",onCreateBounds:E,onBoundsChange:S,proposals:C=[],onAcceptProposal:z,onRejectProposal:R}){var Z;const v=ne(e=>e.inspectElement),w=ne(e=>e.selectedElementId),[I,f]=F.useState([]),[c,x]=F.useState(null),[r,k]=F.useState(null),[b,M]=F.useState(null),D=F.useRef(null),P=I[I.length-1]??g;F.useEffect(()=>f([]),[g]),F.useEffect(()=>{a||k(e=>(e==null?void 0:e.kind)==="create"?null:e)},[a]);const p=F.useMemo(()=>ue(o,{captureId:P}),[o,P]),N=F.useMemo(()=>d?p.nodes.filter(e=>d(e.element)):p.nodes,[p.nodes,d]),L=N.find(e=>e.element.id===w),y=N.find(e=>e.element.id===b)??L,oe=new Set((y==null?void 0:y.childIds)??[]),q=F.useCallback(e=>{const i=e.navigatesToId??e.element.id,n=K(o,i);(n==null?void 0:n.id)!==P&&n&&f(m=>[...m,n.id])},[o,P]);if(!p.nodes.length)return s.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:s.jsxs("div",{className:"text-center",style:{maxWidth:420},children:[s.jsx("h3",{style:{fontSize:W.lg,fontWeight:600,color:"#374151",marginBottom:8},children:t.name}),s.jsx("p",{style:{fontSize:W.md,color:"#9CA3AF",lineHeight:1.6},children:p.emptyReason??"Nothing to lay out in this view."})]})});const re=[...N].sort((e,i)=>{const n=_(e)?1:0,m=_(i)?1:0;return n-m||e.depth-i.depth}),se=p.pixelWidth&&p.pixelHeight?p.pixelHeight/p.pixelWidth:.625,O=(e,i)=>{var m;const n=(m=D.current)==null?void 0:m.getBoundingClientRect();return n?{x:X((e-n.left)/n.width),y:X((i-n.top)/n.height)}:{x:0,y:0}},B=e=>{if(e.kind==="draw")return{x:Math.min(e.startX,e.currentX),y:Math.min(e.startY,e.currentY),width:Math.abs(e.currentX-e.startX),height:Math.abs(e.currentY-e.startY)};const i=e.currentX-e.startX,n=e.currentY-e.startY;return e.kind==="move"?{...e.baseRect,x:X(e.baseRect.x+i,0,1-e.baseRect.width),y:X(e.baseRect.y+n,0,1-e.baseRect.height)}:{...e.baseRect,width:X(e.baseRect.width+i,.01,1-e.baseRect.x),height:X(e.baseRect.height+n,.01,1-e.baseRect.y)}},ae=(e,i)=>{var m;const n=e.parentId?(m=p.nodes.find(A=>A.element.id===e.parentId))==null?void 0:m.rect:void 0;return n?{x:(i.x-n.x)/n.width,y:(i.y-n.y)/n.height,width:i.width/n.width,height:i.height/n.height}:i},de=()=>{if(!c)return;const e=B(c);c.kind==="draw"?e.width>=.01&&e.height>=.01&&k({kind:"create",rect:e,name:u}):(Math.abs(c.currentX-c.startX)>=.002||Math.abs(c.currentY-c.startY)>=.002)&&k(c.node?{kind:"edit",node:c.node,rect:e}:{kind:"create",rect:e,name:(r==null?void 0:r.kind)==="create"?r.name:u}),x(null)},J=(e,i,n)=>{var A;e.stopPropagation();const m=O(e.clientX,e.clientY);(A=D.current)==null||A.setPointerCapture(e.pointerId),x({kind:i,node:n.kind==="edit"?n.node:void 0,baseRect:n.rect,startX:m.x,startY:m.y,currentX:m.x,currentY:m.y})},Q=()=>{if(r){if(r.kind==="create"){const e=r.name.trim();if(!e)return;E==null||E(r.rect,e)}else S==null||S(r.node.element.id,ae(r.node,r.rect));k(null)}};return s.jsxs("div",{className:"flex-1 flex flex-col overflow-auto",style:{background:"#F7F7F5"},children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",style:{borderBottom:"1px solid #E5E5E0"},children:[s.jsx("span",{style:{fontSize:W.sm,fontWeight:600,color:"#374151"},children:(Z=p.screen)==null?void 0:Z.name}),I.length>0&&s.jsx("button",{onClick:()=>f(e=>e.slice(0,-1)),style:{fontSize:W.xs,padding:"2px 8px",marginLeft:"auto",border:"1px solid #E5E5E0",borderRadius:6,background:"#FFFFFF",color:"#374151",cursor:"pointer"},children:"← Back"})]}),s.jsx("div",{className:"p-4",children:s.jsxs("div",{ref:D,role:"application","aria-label":"Screen region canvas",onPointerDown:e=>{if(!l||!a||r||e.target!==e.currentTarget)return;const i=O(e.clientX,e.clientY);e.currentTarget.setPointerCapture(e.pointerId),x({kind:"draw",startX:i.x,startY:i.y,currentX:i.x,currentY:i.y})},onPointerMove:e=>{if(!c)return;const i=O(e.clientX,e.clientY);x(n=>n?{...n,currentX:i.x,currentY:i.y}:null)},onPointerUp:de,onPointerCancel:()=>x(null),style:{position:"relative",width:"100%",maxWidth:900,paddingBottom:`${se*100}%`,margin:"0 auto",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:8,backgroundImage:p.imageUri?`url(${p.imageUri})`:void 0,backgroundSize:"contain",backgroundRepeat:"no-repeat",cursor:a&&!r?"crosshair":"default"},children:[!p.imageUri&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{fontSize:W.xs,color:"#9CA3AF"},children:"No image at this capture’s imageUri — boxes shown without a backdrop"}),!a&&re.map(e=>{const i=e.element.id===w,n=e.element.id===b,m=e.element.id===(y==null?void 0:y.element.id),A=oe.has(e.element.id),H=!!y&&!m&&!A,Y=ge(e),ee=K(o,e.navigatesToId??e.element.id),te=!!ee&&ee.id!==P;return s.jsxs("div",{id:`screen-node-${e.element.id}`,onClick:h=>{h.stopPropagation(),v(e.element.id)},onDoubleClick:h=>{h.stopPropagation(),q(e)},onMouseEnter:()=>M(e.element.id),onMouseLeave:()=>M(h=>h===e.element.id?null:h),onPointerDown:h=>{var T;if(!l||a||r||e.depth===0)return;h.stopPropagation(),v(e.element.id);const j=O(h.clientX,h.clientY);(T=D.current)==null||T.setPointerCapture(h.pointerId),x({kind:"move",node:e,baseRect:e.rect,startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})},title:`${e.element.name} · ${e.formKind}${te?" · double-click to open":""}`,style:{position:"absolute",left:`${e.rect.x*100}%`,top:`${e.rect.y*100}%`,width:`${e.rect.width*100}%`,height:`${e.rect.height*100}%`,border:`${e.boundaryWidth??(i||n?2:1)}px ${e.unconfirmed?"dashed":"solid"} ${H?"#9CA3AF":Y}`,borderRadius:3,background:H?"#6B728012":n?`color-mix(in srgb, ${Y} 12%, transparent)`:i?`color-mix(in srgb, ${Y} 6%, transparent)`:"transparent",boxShadow:_(e)?"0 2px 10px rgba(0,0,0,0.18)":void 0,opacity:H?.18:1,pointerEvents:a?"none":"auto",cursor:l&&i?"move":"pointer",transition:"opacity 120ms ease, border-width 120ms ease"},children:[(i||!L)&&e.depth>0&&s.jsxs("span",{style:{position:"absolute",top:-2,left:2,transform:"translateY(-100%)",fontSize:9,fontWeight:600,color:Y,background:"#FFFFFFDD",padding:"0 3px",borderRadius:2,whiteSpace:"nowrap",pointerEvents:"none"},children:[e.element.name,e.unconfirmed&&e.detectionConfidence!==void 0&&` · ${Math.round(e.detectionConfidence*100)}%?`]}),te&&s.jsx("button",{type:"button","aria-label":`Open ${e.element.name}`,onPointerDown:h=>h.stopPropagation(),onClick:h=>{h.stopPropagation(),q(e)},style:{position:"absolute",top:3,right:3,zIndex:3,width:22,height:22,borderRadius:5,border:`1px solid ${Y}`,background:"#FFFFFFE8",color:Y,fontSize:13,lineHeight:"18px",cursor:"pointer",opacity:H?.25:1},title:`Open nested region ${e.element.name}`,children:"↗"}),l&&i&&e.depth>0&&s.jsx("span",{onPointerDown:h=>{var T;h.stopPropagation();const j=O(h.clientX,h.clientY);(T=D.current)==null||T.setPointerCapture(h.pointerId),x({kind:"resize",node:e,baseRect:e.rect,startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})},title:"Drag to resize",style:{position:"absolute",width:10,height:10,right:-5,bottom:-5,borderRadius:2,background:Y,border:"1px solid #FFFFFF",cursor:"nwse-resize"}})]},e.element.id)}),!a&&C.filter(e=>e.status==="pending").map((e,i)=>s.jsx("div",{title:`Detected boundary · ${Math.round(e.confidence*100)}% confidence`,style:{position:"absolute",zIndex:20+i,left:`${e.bounds.x*100}%`,top:`${e.bounds.y*100}%`,width:`${e.bounds.width*100}%`,height:`${e.bounds.height*100}%`,border:"2px dashed #2563EB",borderRadius:3,background:"#2563EB12",pointerEvents:"none"},children:s.jsxs("span",{style:{position:"absolute",top:2,right:2,display:"inline-flex",gap:3,pointerEvents:"auto",background:"#FFFFFFEE",padding:2,borderRadius:5,boxShadow:"0 1px 4px rgba(0,0,0,0.16)"},children:[s.jsx("button",{type:"button","aria-label":`Accept detected region ${e.id}`,onPointerDown:n=>n.stopPropagation(),onClick:n=>{n.stopPropagation(),z==null||z(e.id)},title:"Accept region",style:{width:22,height:20,border:0,borderRadius:4,background:"#DCFCE7",color:"#15803D",cursor:"pointer"},children:"✓"}),s.jsx("button",{type:"button","aria-label":`Reject detected region ${e.id}`,onPointerDown:n=>n.stopPropagation(),onClick:n=>{n.stopPropagation(),R==null||R(e.id)},title:"Reject region",style:{width:22,height:20,border:0,borderRadius:4,background:"#FEE2E2",color:"#DC2626",cursor:"pointer"},children:"×"})]})},e.id)),c&&s.jsx("div",{style:{position:"absolute",left:`${B(c).x*100}%`,top:`${B(c).y*100}%`,width:`${B(c).width*100}%`,height:`${B(c).height*100}%`,border:"2px dashed #0F766E",background:"#2DD4A81A",pointerEvents:"none"}}),r&&!c&&s.jsxs("div",{"aria-label":r.kind==="create"?"New region boundary draft":"Edited region boundary draft",onPointerDown:e=>J(e,"move",r),style:{position:"absolute",zIndex:80,left:`${r.rect.x*100}%`,top:`${r.rect.y*100}%`,width:`${r.rect.width*100}%`,height:`${r.rect.height*100}%`,border:"2px dashed #0F766E",borderRadius:3,background:"#2DD4A824",cursor:"move",boxShadow:"0 0 0 1px #FFFFFF99"},children:[s.jsxs("span",{style:{position:"absolute",top:4,left:4,display:"flex",gap:4,padding:3,borderRadius:6,background:"#FFFFFFF2",boxShadow:"0 1px 5px rgba(15,23,42,0.18)"},children:[r.kind==="create"&&s.jsx("input",{autoFocus:!0,"aria-label":"New UIElement name",placeholder:"UIElement name",value:r.name,onPointerDown:e=>e.stopPropagation(),onFocus:e=>e.currentTarget.select(),onChange:e=>k(i=>(i==null?void 0:i.kind)==="create"?{...i,name:e.target.value}:i),onKeyDown:e=>{e.key==="Enter"&&Q(),e.key==="Escape"&&k(null)},style:{width:150,border:"1px solid #CBD5E1",borderRadius:4,padding:"3px 6px",color:"#1F2937",fontSize:10}}),s.jsx("button",{type:"button",disabled:r.kind==="create"&&!r.name.trim(),onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),Q()},"aria-label":"Confirm region boundary",title:"Save this boundary",style:{border:0,borderRadius:4,padding:"3px 7px",background:"#DCFCE7",color:"#15803D",cursor:r.kind==="create"&&!r.name.trim()?"not-allowed":"pointer",opacity:r.kind==="create"&&!r.name.trim()?.5:1,fontSize:10,fontWeight:700},children:"✓ Confirm"}),s.jsx("button",{type:"button",onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),k(null)},"aria-label":"Cancel region boundary",title:"Discard this boundary change",style:{border:0,borderRadius:4,padding:"3px 7px",background:"#FEE2E2",color:"#DC2626",cursor:"pointer",fontSize:10,fontWeight:700},children:"× Cancel"})]}),s.jsx("span",{"aria-label":"Resize region boundary draft",onPointerDown:e=>J(e,"resize",r),title:"Drag to resize before confirming",style:{position:"absolute",width:12,height:12,right:-6,bottom:-6,borderRadius:2,background:"#0F766E",border:"2px solid #FFFFFF",cursor:"nwse-resize"}})]}),a&&!c&&!r&&s.jsx("div",{style:{position:"absolute",zIndex:70,left:8,top:8,padding:"5px 8px",borderRadius:6,pointerEvents:"none",background:"#0F766EEB",color:"#FFFFFF",fontSize:10,fontWeight:650},children:"Click and drag to define a region"})]})})]})}function ve({id:t,label:o,depth:g,hasChildren:d,expanded:l,selected:a,badge:u,badgeColor:E="#0F766E",count:S,title:C,onClick:z,onDelete:R}){const[v,w]=F.useState(null),I=F.useRef(null);return F.useEffect(()=>{if(!v)return;const f=x=>{var r;(r=I.current)!=null&&r.contains(x.target)||w(null)},c=x=>{x.key==="Escape"&&w(null)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",c),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",c)}},[v]),s.jsxs("div",{role:"none",children:[s.jsxs("button",{type:"button",role:"treeitem","aria-selected":a,"aria-expanded":d?l:void 0,"data-tree-id":t,onClick:z,onContextMenu:R?f=>{f.preventDefault(),f.stopPropagation(),w({x:f.clientX,y:f.clientY})}:void 0,title:C,className:"flex items-center gap-1.5 w-full text-left",style:{minHeight:28,padding:"4px 8px",paddingLeft:8+g*18,border:0,borderRadius:6,cursor:"pointer",background:a?"#2DD4A818":"transparent",color:a?"#0F766E":"#374151"},onMouseEnter:f=>{a||(f.currentTarget.style.background="#F0F0ED")},onMouseLeave:f=>{f.currentTarget.style.background=a?"#2DD4A818":"transparent"},children:[s.jsx("span",{"aria-hidden":!0,style:{width:12,textAlign:"center",flexShrink:0,fontSize:9,color:"#9CA3AF",transform:l?"rotate(90deg)":"none",transition:"transform 120ms ease",visibility:d?"visible":"hidden"},children:"▶"}),u&&s.jsx("span",{style:{minWidth:27,height:17,padding:"0 4px",borderRadius:4,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:`${E}18`,color:E,fontSize:9,fontWeight:800},children:u}),s.jsx("span",{className:"truncate",style:{flex:1,fontSize:W.xs,fontWeight:d?650:500},children:o}),S!==void 0&&s.jsx("span",{style:{color:"#9CA3AF",fontSize:9},children:S})]}),v&&R&&s.jsx("div",{ref:I,role:"menu",className:"fixed z-50 rounded-lg overflow-hidden py-1",style:{left:v.x,top:v.y,minWidth:180,background:"#FFFFFF",border:"1px solid #E5E7EB",boxShadow:"0 8px 24px rgba(0,0,0,0.16)"},children:s.jsx("button",{type:"button",role:"menuitem",onClick:async()=>{w(null);const f=typeof o=="string"?o:C??"this element";if(!window.confirm(`Delete “${f}”?
|
|
2
2
|
|
|
3
3
|
All incoming and outgoing relationships will also be deleted. This cannot be undone.`))return;const c=await R();c.success||window.alert(c.error??"The element could not be deleted.")},style:{width:"100%",border:0,padding:"8px 12px",textAlign:"left",cursor:"pointer",background:"#FFFFFF",color:"#DC2626",fontSize:12,fontWeight:600},children:"Delete element…"})})]})}export{ve as E,Fe as S,K as a,ye as b,ue as c,xe as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-C9OlmOYw.js";import{u as n}from"./index-
|
|
1
|
+
import{j as e}from"./reactflow-C9OlmOYw.js";import{u as n}from"./index-a2rpMs5Y.js";import"./zustand-CrhqMOHB.js";function p(){const i=n(t=>t.setBulkImportOpen),s=n(t=>t.connected),a=[{icon:"📄",title:"Import Elements from CSV",description:"Import model elements from a CSV or tab-separated file. Supports column mapping, artifact type presets, and batch preview before committing.",action:()=>i(!0),requiresConnection:!0}];return e.jsx("div",{style:{flex:1,overflow:"auto",padding:"40px 48px",background:"linear-gradient(135deg, #F0F4F7 0%, #E8EFF3 100%)",minHeight:0},children:e.jsxs("div",{style:{maxWidth:720,margin:"0 auto"},children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"#1B3A4B",marginBottom:6},children:"Import"}),e.jsx("p",{style:{fontSize:"14px",color:"#6B7280",marginBottom:36},children:"Bring data into your model from external sources."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:a.map(t=>{const r=t.requiresConnection&&!s;return e.jsxs("button",{onClick:r?void 0:t.action,disabled:r,style:{display:"flex",alignItems:"flex-start",gap:20,padding:"20px 24px",borderRadius:12,textAlign:"left",background:r?"rgba(255,255,255,0.4)":"rgba(255,255,255,0.75)",border:`1px solid ${r?"rgba(255,255,255,0.6)":"rgba(255,255,255,0.95)"}`,boxShadow:r?"none":"0 2px 8px rgba(0,0,0,0.06)",cursor:r?"not-allowed":"pointer",transition:"all 0.15s",opacity:r?.55:1},onMouseEnter:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.95)",o.currentTarget.style.boxShadow="0 4px 16px rgba(0,0,0,0.1)",o.currentTarget.style.transform="translateY(-1px)")},onMouseLeave:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.75)",o.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)",o.currentTarget.style.transform="none")},children:[e.jsx("div",{style:{fontSize:28,lineHeight:1,flexShrink:0,marginTop:2},children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"#1B3A4B",marginBottom:4},children:t.title}),e.jsx("div",{style:{fontSize:"13px",color:"#6B7280",lineHeight:1.55},children:t.description}),r&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:8},children:"Connect to the dev server to use this import."})]})]},t.title)})})]})})}export{p as ImportView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./reactflow-C9OlmOYw.js";import{a as f}from"./zustand-CrhqMOHB.js";import{L as M}from"./index-
|
|
1
|
+
import{j as t}from"./reactflow-C9OlmOYw.js";import{a as f}from"./zustand-CrhqMOHB.js";import{L as M}from"./index-a2rpMs5Y.js";const $={"purpose-operational":{bg:"#f0f7ff",header:"#cce5ff",text:"#1e40af",border:"#93c5fd"},requirements:{bg:"#f0f6ff",header:"#dae8fc",text:"#1d4ed8",border:"#93c5fd"},architecture:{bg:"#f0faf0",header:"#d5e8d4",text:"#166534",border:"#86efac"},risk:{bg:"#fff5f5",header:"#f8cecc",text:"#991b1b",border:"#fca5a5"},"vv-evidence":{bg:"#faf5ff",header:"#e1d5e7",text:"#6b21a8",border:"#c4b5fd"},"dhf-outputs":{bg:"#fffbeb",header:"#fff2cc",text:"#92400e",border:"#fcd34d"},other:{bg:"#f9fafb",header:"#f3f4f6",text:"#374151",border:"#d1d5db"}},F=[{id:"purpose-operational",label:"Purpose & Operational",abbr:"PUR",layerIds:["purpose","business","operational"]},{id:"requirements",label:"Requirements",abbr:"REQ",layerIds:["requirements"]},{id:"architecture",label:"Architecture",abbr:"ARCH",layerIds:["functional","behavior","logical","physical","software","interfaces","ui"],subGroups:[{label:"Functional",layerIds:["functional","behavior"]},{label:"Logical",layerIds:["logical"]},{label:"Physical",layerIds:["physical"]},{label:"Software",layerIds:["software"]},{label:"Interfaces",layerIds:["interfaces","ui"]}]},{id:"risk",label:"Risk",abbr:"RISK",layerIds:["risk","safety","cybersecurity"]},{id:"vv-evidence",label:"V&V & Evidence",abbr:"V&V",layerIds:["verification","analysis"]},{id:"dhf-outputs",label:"DHF Outputs",abbr:"DHF",layerIds:["design-control","qms","software-lifecycle","operations","clinical","privacy"]}],A=Object.fromEntries(M.map((n,r)=>[n,r]));function O(n){return[...n].sort((r,d)=>(A[r.id]??99)-(A[d.id]??99))}function T(n){return[...n].sort((r,d)=>{const a=r.derivesFrom?1:0,x=d.derivesFrom?1:0;return a!==x?a-x:r.name.localeCompare(d.name)})}function B({kind:n,layerColor:r,domainBg:d,selected:a,onClick:x,onContextMenu:N,isFlashing:p,flashTick:R}){const[b,g]=f.useState(!1),[v,j]=f.useState(!1);f.useEffect(()=>{if(!p)return;j(!0);const w=setTimeout(()=>j(!1),700);return()=>clearTimeout(w)},[p,R]);const m=a?`${r}18`:b?`${r}0C`:"#ffffff",I=a?r:"transparent",k=r;return t.jsxs("button",{"data-kind":n.name,onClick:x,onContextMenu:N,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),className:"text-left transition-all",style:{width:"130px",minHeight:"55px",background:m,border:`1px solid ${I}`,borderLeft:`3px solid ${k}`,borderRadius:"6px",padding:"6px 8px",cursor:"pointer",transform:v?"scale(1.04)":"scale(1)",boxShadow:v?`0 0 0 2px ${r}, 0 0 12px ${r}60`:a?`0 0 0 1px ${r}40`:b?"0 1px 3px rgba(0,0,0,0.08)":"none",flexShrink:0},children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{style:{fontSize:"9px",fontFamily:"monospace",color:r,opacity:.8,textTransform:"uppercase",letterSpacing:"0.02em",lineHeight:1},children:n.construct.replace("part def","pd").replace("connection def","cd").replace("attribute def","ad")}),n.instanceCount>0&&t.jsx("span",{style:{fontSize:"9px",color:"#6B7280",background:`${r}15`,borderRadius:"8px",padding:"0 4px",lineHeight:"14px"},children:n.instanceCount})]}),t.jsx("div",{style:{fontSize:"11px",fontWeight:n.derivesFrom?400:600,color:a?r:"#1F2937",lineHeight:1.3,wordBreak:"break-word"},children:n.name}),n.derivesFrom&&t.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:"2px",lineHeight:1},children:["↳ ",n.derivesFrom]})]})}function z({layers:n,selectedKind:r,onKindClick:d,activeLayerId:a,flashKindName:x,flashTick:N}){const p=f.useRef({}),[R,b]=f.useState(null),[g,v]=f.useState(()=>new Set(F.map(e=>e.id).concat(["other"])));if(f.useEffect(()=>{if(!a)return;const e=p.current[a];if(e){e.scrollIntoView({behavior:"smooth",block:"start"}),b(a);const o=setTimeout(()=>b(null),1200);return()=>clearTimeout(o)}},[a]),n.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12",style:{color:"#9CA3AF"},children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl mb-2",children:"⬡"}),t.jsx("div",{className:"text-xs",children:"No layers found in this ontology"})]})});const j=new Set(F.flatMap(e=>e.layerIds)),m=O(n.filter(e=>!j.has(e.id)));function I(e,o){e.preventDefault()}function k(e){v(o=>{const s=new Set(o);return s.has(e)?s.delete(e):s.add(e),s})}const w=(e,o,s)=>T(e).map(l=>t.jsx(B,{kind:l,layerColor:o,domainBg:s,selected:r===l.name,onClick:()=>d(r===l.name?null:l.name),onContextMenu:u=>I(u,l.name),isFlashing:x===l.name,flashTick:N},l.name)),C=(e,o)=>{const s=$[e.id]??$.other,L=o.reduce((i,c)=>i+c.kindCount,0),l=L===0,u=g.has(e.id),E=O(o);return t.jsxs("div",{ref:i=>{p.current[e.id]=i},className:"rounded-xl overflow-hidden transition-all",style:{border:`1px solid ${s.border}`,background:s.bg,outline:R===e.id?`2px solid ${s.border}`:"none",outlineOffset:"2px"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 cursor-pointer select-none",style:{background:s.header,borderBottom:u?"none":`1px solid ${s.border}`},onClick:()=>k(e.id),title:u?"Expand":"Collapse",children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",style:{transition:"transform 150ms ease",transform:u?"rotate(-90deg)":"rotate(0deg)",flexShrink:0},children:t.jsx("path",{d:"M4 6L8 10L12 6",stroke:s.text,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),t.jsx("span",{style:{fontSize:"10px",fontWeight:700,color:s.text,letterSpacing:"0.08em",textTransform:"uppercase",minWidth:"32px",textAlign:"center"},children:e.abbr}),t.jsx("span",{style:{width:"1px",height:"14px",background:`${s.border}`,opacity:.5}}),t.jsx("span",{className:"text-xs font-semibold flex-1",style:{color:s.text},children:e.label}),t.jsx("span",{className:"text-xs",style:{color:s.text,opacity:.7},children:l?"no kinds":`${L} kinds`})]}),!u&&(l?t.jsx("div",{className:"px-4 py-1.5 text-xs italic",style:{color:s.text,opacity:.4},children:"(no elements)"}):t.jsx("div",{className:"p-3 space-y-3",children:e.subGroups?e.subGroups.map(i=>{const c=E.filter(y=>i.layerIds.includes(y.id));if(c.length===0)return null;const h=c.flatMap(y=>y.kinds);if(h.length===0)return null;const S=c[0].color??s.text;return t.jsxs("div",{children:[t.jsxs("div",{className:"text-xs font-medium mb-1.5 flex items-center gap-1.5",style:{color:s.text,opacity:.75},ref:y=>{c.forEach(H=>{p.current[H.id]=y})},children:[t.jsx("span",{className:"inline-block w-2 h-2 rounded-sm flex-shrink-0",style:{background:S}}),i.label]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:w(h,S,s.bg)})]},i.label)}):(()=>{var h;const i=E.flatMap(S=>S.kinds),c=((h=E[0])==null?void 0:h.color)??s.text;return t.jsx("div",{className:"flex flex-wrap gap-2",children:w(i,c,s.bg)})})()}))]},e.id)};return t.jsxs("div",{className:"space-y-3 mb-6",children:[F.map(e=>{const o=n.filter(s=>e.layerIds.includes(s.id));return o.length===0?null:C(e,o)}),m.length>0&&C({id:"other",label:"Other",abbr:"EXT",layerIds:m.map(e=>e.id)},m)]})}export{z as LayerGrid};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as t}from"./reactflow-C9OlmOYw.js";import{a}from"./zustand-CrhqMOHB.js";import{h as A}from"./index-
|
|
1
|
+
import{j as t}from"./reactflow-C9OlmOYw.js";import{a}from"./zustand-CrhqMOHB.js";import{h as A}from"./index-a2rpMs5Y.js";function q({layers:p,selectedKind:L,onKindClick:S}){const[F,D]=a.useState("name"),[g,j]=a.useState("asc"),[h,M]=a.useState(""),[c,T]=a.useState(!1),[i,v]=a.useState("all"),[d,E]=a.useState("all"),[B,f]=a.useState(!1),[N,b]=a.useState(!1),y=a.useMemo(()=>p.flatMap(e=>e.kinds.map(s=>({...s,layerLabel:e.label,layerColor:A[e.id]??e.color??"#6B7280"}))),[p]),R=a.useMemo(()=>[...new Set(p.map(e=>e.id))],[p]),K=a.useMemo(()=>[...new Set(y.map(e=>e.construct))],[y]),C=a.useMemo(()=>{let e=y;if(h.trim()){const s=h.toLowerCase();e=e.filter(o=>{var l,r;return o.name.toLowerCase().includes(s)||o.label.toLowerCase().includes(s)||o.layer.toLowerCase().includes(s)||(((l=o.description)==null?void 0:l.toLowerCase().includes(s))??!1)||(((r=o.derivesFrom)==null?void 0:r.toLowerCase().includes(s))??!1)})}return i!=="all"&&(e=e.filter(s=>s.layer===i)),d!=="all"&&(e=e.filter(s=>s.construct===d)),e},[y,h,i,d]),x=a.useMemo(()=>[...C].sort((e,s)=>{var l,r;let o=0;switch(F){case"name":o=e.name.localeCompare(s.name);break;case"layer":o=e.layer.localeCompare(s.layer);break;case"construct":o=e.construct.localeCompare(s.construct);break;case"instanceCount":o=e.instanceCount-s.instanceCount;break;case"derivesFrom":o=(e.derivesFrom??"").localeCompare(s.derivesFrom??"");break;case"derivedByCount":o=(((l=e.derivedBy)==null?void 0:l.length)??0)-(((r=s.derivedBy)==null?void 0:r.length)??0);break}return g==="asc"?o:-o}),[C,F,g]),k=a.useMemo(()=>{if(c)return null;const e=new Map;for(const s of x)e.has(s.layer)||e.set(s.layer,[]),e.get(s.layer).push(s);return e},[x,c]);function u(e){F===e?j(s=>s==="asc"?"desc":"asc"):(D(e),j("asc"))}const z=a.useCallback(()=>{const e=[["Name","Layer","Construct","Instances","Derives From","Derived By","Description"]];for(const n of x)e.push([n.name,n.layer,n.construct,String(n.instanceCount),n.derivesFrom??"",(n.derivedBy??[]).join("; "),n.description??""]);const s=e.map(n=>n.map($=>`"${$.replace(/"/g,'""')}"`).join(",")).join(`
|
|
2
2
|
`),o=new Blob([s],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download="ontology-kinds.csv",r.click(),URL.revokeObjectURL(l)},[x]),m=({k:e})=>t.jsx("span",{style:{fontSize:"10px",color:F===e?"#1B3A4B":"#D1D5DB",marginLeft:"3px"},children:F===e?g==="asc"?"▲":"▼":"⇅"}),w=(e,s)=>{var l,r;const o=L===e.name;return t.jsxs("div",{className:"grid items-center cursor-pointer text-xs",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",padding:"7px 16px",background:o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF",borderLeft:o?`3px solid ${e.layerColor}`:"3px solid transparent",transition:"background 100ms ease"},onClick:()=>S(o?null:e.name),onMouseEnter:n=>{o||(n.currentTarget.style.background="#F0F7FF")},onMouseLeave:n=>{o||(n.currentTarget.style.background=o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF")},children:[t.jsxs("div",{className:"flex items-center gap-2 truncate",children:[t.jsx("span",{className:"w-2 h-2 rounded flex-shrink-0",style:{backgroundColor:e.layerColor}}),t.jsx("span",{style:{color:"#1a1a1a",fontWeight:o?600:400},children:e.name})]}),t.jsx("span",{className:"capitalize",style:{color:"#6B7280"},children:e.layer}),t.jsx("span",{className:"font-mono",style:{color:"#9CA3AF"},children:e.construct}),t.jsx("span",{className:"text-right",style:{color:e.instanceCount>0?"#1B3A4B":"#D1D5DB"},children:e.instanceCount>0?e.instanceCount:"—"}),t.jsx("span",{className:"truncate",style:{color:e.derivesFrom?"#2563EB":"#D1D5DB"},children:e.derivesFrom??"—"}),t.jsx("span",{className:"text-right",style:{color:(((l=e.derivedBy)==null?void 0:l.length)??0)>0?"#374151":"#D1D5DB"},children:(((r=e.derivedBy)==null?void 0:r.length)??0)>0?e.derivedBy.length:"—"})]},`${e.layer}:${e.name}`)};return t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("input",{type:"text",placeholder:"Search kinds...",value:h,onChange:e=>M(e.target.value),className:"px-2.5 py-1.5 text-xs rounded-md flex-1 min-w-[140px]",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none",maxWidth:"240px"},onFocus:e=>e.currentTarget.style.borderColor="#2563EB",onBlur:e=>e.currentTarget.style.borderColor="#E5E7EB"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{f(!B),b(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:i!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Layer: ",i==="all"?"All":i]}),B&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"120px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{v("all"),f(!1)},children:"All"}),R.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 capitalize",style:{color:"#374151"},onClick:()=>{v(e),f(!1)},children:e},e))]})]}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{b(!N),f(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:d!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Construct: ",d==="all"?"All":d]}),N&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"140px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{E("all"),b(!1)},children:"All"}),K.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 font-mono",style:{color:"#374151"},onClick:()=>{E(e),b(!1)},children:e},e))]})]}),t.jsx("button",{onClick:()=>T(!c),className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:c?"#1B3A4B":"#F9FAFB",color:c?"#2DD4A8":"#374151"},children:c?"Grouped":"Flatten"}),t.jsx("button",{onClick:z,className:"px-2.5 py-1.5 text-xs rounded-md ml-auto",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151"},title:"Export as CSV",children:"Export CSV"}),t.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:[C.length," / ",y.length," kinds"]})]}),t.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"grid text-xs font-medium",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",padding:"8px 16px",color:"#6B7280",position:"sticky",top:0,zIndex:5},children:[t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("name"),children:["Kind ",t.jsx(m,{k:"name"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("layer"),children:["Layer ",t.jsx(m,{k:"layer"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("construct"),children:["Construct ",t.jsx(m,{k:"construct"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("instanceCount"),children:["# ",t.jsx(m,{k:"instanceCount"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("derivesFrom"),children:["Derives From ",t.jsx(m,{k:"derivesFrom"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("derivedByCount"),children:["Subs ",t.jsx(m,{k:"derivedByCount"})]})]}),c?x.map((e,s)=>w(e,s)):k&&[...k.entries()].map(([e,s])=>{const o=p.find(r=>r.id===e),l=A[e]??"#6B7280";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-semibold",style:{background:`${l}08`,borderTop:"1px solid #E5E5E0",color:l},children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:l}}),(o==null?void 0:o.label)??e,t.jsxs("span",{className:"font-normal",style:{color:"#9CA3AF"},children:["(",s.length,")"]})]}),s.map((r,n)=>w(r,n))]},e)}),x.length===0&&t.jsx("div",{className:"py-8 text-center text-xs",style:{color:"#9CA3AF"},children:"No kinds match the current filters"})]})]})}export{q as LayerTable};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as jsxRuntimeExports}from"./reactflow-C9OlmOYw.js";import{a as reactExports}from"./zustand-CrhqMOHB.js";import{D as DIAGRAM_TYPE_META,u as useModelStore,g as getDiagram,J as sendDiagramLayoutUpdate,F as FONT,i as getRegistries}from"./index-
|
|
1
|
+
import{j as jsxRuntimeExports}from"./reactflow-C9OlmOYw.js";import{a as reactExports}from"./zustand-CrhqMOHB.js";import{D as DIAGRAM_TYPE_META,u as useModelStore,g as getDiagram,J as sendDiagramLayoutUpdate,F as FONT,i as getRegistries}from"./index-a2rpMs5Y.js";import{c as computeFBSLayout,F as buildFunctionalTree,b as computeContainmentLayout,H as buildDecompositionTree,d as computeUseCaseViewLayout,w as useCaseViewOptions,e as computeContextViewLayout,f as computeInterconnectionLayout,g as computeActionFlowViewLayout,h as computeStateTransitionLayout,i as computeSequenceLayout,v as resolveGeneralMode,j as computeGeneralViewLayout,E as buildGeneralViewTree,k as computeLayout,U as projectLayoutToNotationScene,s as selectedLayoutProviderId,q as commonDisplayLevels,V as notationSceneToSvg,K as GridView,L as BrowserView,R as RelationshipPicker}from"./notation-scene-CxT28i2i.js";import{S as ScreenLayoutView}from"./ExplorerTreeRow-CmGPHRI8.js";import"./layout-providers-BSDYNZu0.js";import"./elk-6l8mIQnQ.js";class ImageBox{constructor(t,e,i){this.src=t,this.width=e,this.height=i}}class EventObject{constructor(t="",...e){if(this.consumed=!1,this.name=t,this.properties={},e[0]&&e[0].constructor===Object)for(const[i,s]of Object.entries(e[0]))this.properties[i]=s;else for(let i=0;i<e.length;i+=2)e[i+1]!==null&&(this.properties[e[i]]=e[i+1])}getName(){return this.name}getProperties(){return this.properties}getProperty(t){return this.properties[t]}isConsumed(){return this.consumed}consume(){this.consumed=!0}}class EventSource{constructor(t=null){this.eventListeners=[],this.eventsEnabled=!0,this.eventSource=null,this.eventSource=t}isEventsEnabled(){return this.eventsEnabled}setEventsEnabled(t){this.eventsEnabled=t}getEventSource(){return this.eventSource}setEventSource(t){this.eventSource=t}addListener(t,e){this.eventListeners.push({name:t,funct:e})}removeListener(t){let e=0;for(;e<this.eventListeners.length;)this.eventListeners[e].funct===t?this.eventListeners.splice(e,1):e+=1}fireEvent(t,e=null){if(this.isEventsEnabled()){t||(t=new EventObject("")),e||(e=this.getEventSource()),e||(e=this);for(const i of this.eventListeners)(i.name===null||i.name===t.getName())&&i.funct.apply(this,[e,t])}}destroy(){this.eventListeners.length=0}}const DEFAULT_HOTSPOT=.3,MIN_HOTSPOT_SIZE=8,MAX_HOTSPOT_SIZE=0,IDENTITY_FIELD_NAME="mxObjectId",NS_SVG="http://www.w3.org/2000/svg",NS_XLINK="http://www.w3.org/1999/xlink",SHADOWCOLOR="gray",SHADOW_OFFSET_X=2,SHADOW_OFFSET_Y=3,SHADOW_OPACITY=1,TOOLTIP_VERTICAL_OFFSET=16,DEFAULT_VALID_COLOR="#00FF00",DEFAULT_INVALID_COLOR="#FF0000",OUTLINE_HIGHLIGHT_COLOR="#00FF00",OUTLINE_HIGHLIGHT_STROKEWIDTH=5,HIGHLIGHT_STROKEWIDTH=3,HIGHLIGHT_SIZE=2,HIGHLIGHT_OPACITY=100,INVALID_CONNECT_TARGET_COLOR="#FF0000",DROP_TARGET_COLOR="#0000FF",VALID_COLOR="#00FF00",INVALID_COLOR="#FF0000",EDGE_SELECTION_COLOR="#00FF00",VERTEX_SELECTION_COLOR="#00FF00",VERTEX_SELECTION_STROKEWIDTH=1,EDGE_SELECTION_STROKEWIDTH=1,VERTEX_SELECTION_DASHED=!0,EDGE_SELECTION_DASHED=!0,GUIDE_COLOR="#FF0000",GUIDE_STROKEWIDTH=1,HANDLE_SIZE=6,LABEL_HANDLE_SIZE=4,HANDLE_FILLCOLOR="#00FF00",HANDLE_STROKECOLOR="black",LABEL_HANDLE_FILLCOLOR="yellow",CONNECT_HANDLE_FILLCOLOR="#0000FF",LOCKED_HANDLE_FILLCOLOR="#FF0000",DEFAULT_FONTFAMILY="Arial,Helvetica,sans-serif",DEFAULT_FONTSIZE=11,DEFAULT_TEXT_DIRECTION="",LINE_HEIGHT=1.2,WORD_WRAP="normal",DEFAULT_FONTSTYLE=0,DEFAULT_STARTSIZE=40,DEFAULT_MARKERSIZE=6,DEFAULT_IMAGESIZE=24,ENTITY_SEGMENT=30,RECTANGLE_ROUNDING_FACTOR=.15,LINE_ARCSIZE=20,ARROW_SPACING=0,ARROW_WIDTH=30,ARROW_SIZE=30,PAGE_FORMAT_A4_PORTRAIT=[0,0,827,1169],NONE="none",FONT_STYLE_MASK={BOLD:1,ITALIC:2,UNDERLINE:4,STRIKETHROUGH:8},DIRECTION_MASK={NONE:0,WEST:1,NORTH:2,SOUTH:4,EAST:8,ALL:15},NODE_TYPE={ELEMENT:1},isWindowObjectAvailable=()=>typeof window<"u",isUserAgentAvailable=()=>!!navigator.userAgent,isUserAgentIncludes=r=>navigator.userAgent.includes(r),isAppVersionAvailable=()=>!!navigator.appVersion,isAppVersionIncludes=r=>navigator.appVersion.includes(r);class Client{}Client.basePath=".";Client.setBasePath=r=>{typeof r<"u"&&r.length>0?(r.substring(r.length-1)==="/"&&(r=r.substring(0,r.length-1)),Client.basePath=r):Client.basePath="."};Client.imageBasePath=".";Client.setImageBasePath=r=>{typeof r<"u"&&r.length>0?(r.substring(r.length-1)==="/"&&(r=r.substring(0,r.length-1)),Client.imageBasePath=r):Client.imageBasePath=`${Client.basePath}/images`};Client.IS_EDGE=isWindowObjectAvailable()&&isUserAgentAvailable()&&!!navigator.userAgent.match(/Edge\//);Client.IS_NS=isWindowObjectAvailable()&&isUserAgentAvailable()&&isUserAgentIncludes("Mozilla/")&&!isUserAgentIncludes("MSIE")&&!isUserAgentIncludes("Edge/");Client.IS_SF=isWindowObjectAvailable()&&/Apple Computer, Inc/.test(navigator.vendor);Client.IS_ANDROID=isWindowObjectAvailable()&&isAppVersionAvailable()&&isAppVersionIncludes("Android");Client.IS_IOS=isWindowObjectAvailable()&&/iP(hone|od|ad)/.test(navigator.platform);Client.IS_GC=isWindowObjectAvailable()&&/Google Inc/.test(navigator.vendor);Client.IS_CHROMEAPP=isWindowObjectAvailable()&&window.chrome!=null&&chrome.app!=null&&chrome.app.runtime!=null;Client.IS_FF=isUserAgentAvailable()&&navigator.userAgent.toLowerCase().includes("firefox");Client.IS_MT=isWindowObjectAvailable()&&isUserAgentAvailable()&&(isUserAgentIncludes("Firefox/")&&!isUserAgentIncludes("Firefox/1.")&&!isUserAgentIncludes("Firefox/2.")||isUserAgentIncludes("Iceweasel/")&&!isUserAgentIncludes("Iceweasel/1.")&&!isUserAgentIncludes("Iceweasel/2.")||isUserAgentIncludes("SeaMonkey/")&&!isUserAgentIncludes("SeaMonkey/1.")||isUserAgentIncludes("Iceape/")&&!isUserAgentIncludes("Iceape/1."));var Mt;Client.IS_SVG=isWindowObjectAvailable()&&((Mt=navigator.appName)==null?void 0:Mt.toUpperCase())!=="MICROSOFT INTERNET EXPLORER";Client.NO_FO=isWindowObjectAvailable()&&(!document.createElementNS||document.createElementNS(NS_SVG,"foreignObject").toString()!=="[object SVGForeignObjectElement]"||isUserAgentIncludes("Opera/"));Client.IS_WIN=isWindowObjectAvailable()&&isAppVersionAvailable()&&isAppVersionIncludes("Win");Client.IS_MAC=isWindowObjectAvailable()&&isAppVersionAvailable()&&isAppVersionIncludes("Mac");Client.IS_CHROMEOS=isWindowObjectAvailable()&&/\bCrOS\b/.test(navigator.appVersion);Client.IS_TOUCH=isWindowObjectAvailable()&&"ontouchstart"in document.documentElement;Client.IS_POINTER=isWindowObjectAvailable()&&!!window.PointerEvent&&isAppVersionAvailable()&&!isAppVersionIncludes("Mac");Client.IS_LOCAL=isWindowObjectAvailable()&&!document.location.href.includes("http://")&&!document.location.href.includes("https://");const getMainEvent=r=>{let t=r;return(t.type==="touchstart"||t.type==="touchmove")&&t.touches&&t.touches[0]?t=t.touches[0]:t.type==="touchend"&&t.changedTouches&&t.changedTouches[0]&&(t=t.changedTouches[0]),t},getClientX=r=>getMainEvent(r).clientX,getClientY=r=>getMainEvent(r).clientY,getSource=r=>r.target,isConsumed=r=>{const t=r;return t.isConsumed!==void 0&&t.isConsumed},isTouchEvent=r=>{const t=r;return t.pointerType?t.pointerType==="touch"||t.pointerType===t.MSPOINTER_TYPE_TOUCH:t.mozInputSource!==void 0?t.mozInputSource===5:t.type.indexOf("touch")===0},isPenEvent=r=>{const t=r;return t.pointerType?t.pointerType=="pen"||t.pointerType===t.MSPOINTER_TYPE_PEN:t.mozInputSource!==void 0?t.mozInputSource===2:t.type.indexOf("pen")===0},isMultiTouchEvent=r=>{const t=r;return t.type&&t.type.indexOf("touch")==0&&t.touches!==void 0&&t.touches.length>1},isMouseEvent=r=>{const t=r;return t.pointerType?t.pointerType=="mouse"||t.pointerType===t.MSPOINTER_TYPE_MOUSE:t.mozInputSource!==void 0?t.mozInputSource===1:t.type.indexOf("mouse")===0},isLeftMouseButton=r=>"buttons"in r&&(r.type==="mousedown"||r.type==="mousemove")?r.buttons===1:r.which!==void 0?r.which===1:r.button===1,isRightMouseButton=r=>r.button===2,isPopupTrigger=r=>isRightMouseButton(r)||Client.IS_MAC&&isControlDown(r)&&!isShiftDown(r)&&!isMetaDown(r)&&!isAltDown(r),isShiftDown=r=>r.shiftKey,isAltDown=r=>r.altKey,isControlDown=r=>r.ctrlKey,isMetaDown=r=>r.metaKey;class NoOpLogger{debug(t){}enter(t){}error(t,...e){}info(t){}leave(t,e){}show(){}trace(t){}warn(t){}}const shallowCopy=(r,t)=>{for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e)){const i=r[e];Array.isArray(i)?t[e]=[...i]:t[e]=i}};class NoOpI18n{isEnabled(){return!1}get(){return null}addResource(){}}const GlobalConfig={i18n:new NoOpI18n,logger:new NoOpLogger},StyleDefaultsConfig={fontFamily:DEFAULT_FONTFAMILY,fontSize:DEFAULT_FONTSIZE,imageSize:DEFAULT_IMAGESIZE,lineArcSize:LINE_ARCSIZE,markerSize:DEFAULT_MARKERSIZE,roundingFactor:RECTANGLE_ROUNDING_FACTOR,shadowColor:SHADOWCOLOR,shadowOffsetX:SHADOW_OFFSET_X,shadowOffsetY:SHADOW_OFFSET_Y,shadowOpacity:SHADOW_OPACITY,startSize:DEFAULT_STARTSIZE},doEval=expression=>eval(expression),isElement=r=>(r==null?void 0:r.nodeType)===NODE_TYPE.ELEMENT,isNullish=r=>r==null,log=()=>GlobalConfig.logger,mixInto=r=>t=>{const e=Reflect.ownKeys(t);try{for(const i of e)Object.defineProperty(r.prototype,i,{value:t[i],writable:!0})}catch(i){log().error("Error while mixing",i)}},matchBinaryMask=(r,t)=>(r&t)===t,blocks=new Set(["BLOCKQUOTE","DIV","H1","H2","H3","H4","H5","H6","OL","P","PRE","TABLE","UL"]),extractTextWithWhitespace=r=>{const t=[];function e(i){if(!(i.length==1&&(i[0].nodeName=="BR"||i[0].innerHTML==`
|
|
2
2
|
`)))for(let s=0;s<i.length;s+=1){const n=i[s];n.nodeName=="BR"||n.innerHTML==`
|
|
3
3
|
`||(i.length==1||s==0)&&n.nodeName=="DIV"&&n.innerHTML.toLowerCase()=="<br>"?t.push(`
|
|
4
4
|
`):(n.nodeType===3||n.nodeType===4?n.nodeValue&&n.nodeValue.length>0&&t.push(n.nodeValue):n.nodeType!==8&&n.childNodes.length>0&&e(Array.from(n.childNodes)),s<i.length-1&&blocks.has(i[s+1].nodeName)&&t.push(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as y}from"./zustand-CrhqMOHB.js";import{u as F,h as j}from"./index-
|
|
1
|
+
import{j as e}from"./reactflow-C9OlmOYw.js";import{a as y}from"./zustand-CrhqMOHB.js";import{u as F,h as j}from"./index-a2rpMs5Y.js";function N(l,u){const o=[],i=[],m=[],g=new Set(Object.keys(l.elements)),x=new Set(Object.keys(u.elements));for(const a of x)g.has(a)||o.push(u.elements[a]);for(const a of g)x.has(a)||i.push(l.elements[a]);for(const a of g){if(!x.has(a))continue;const p=l.elements[a],t=u.elements[a],c=[];p.name!==t.name&&c.push(`name: "${p.name}" → "${t.name}"`),p.kind!==t.kind&&c.push(`kind: ${p.kind} → ${t.kind}`),p.layer!==t.layer&&c.push(`layer: ${p.layer} → ${t.layer}`),p.doc!==t.doc&&c.push("doc changed");const s=JSON.stringify(p.attributes),n=JSON.stringify(t.attributes);s!==n&&c.push("attributes changed"),c.length>0&&m.push({element:t,changes:c})}const v=new Set(l.relationships.map(a=>a.id)),h=new Set(u.relationships.map(a=>a.id)),f=u.relationships.filter(a=>!v.has(a.id)),d=l.relationships.filter(a=>!h.has(a.id));return{added:o,removed:i,changed:m,addedRels:f,removedRels:d,summary:{added:o.length,removed:i.length,changed:m.length,addedRels:f.length,removedRels:d.length}}}function A(){const l=F(s=>s.model),u=F(s=>s.selectElement),[o,i]=y.useState(null),[m,g]=y.useState(""),[x,v]=y.useState([]),[h,f]=y.useState(null),[d,a]=y.useState("all"),p=y.useCallback(()=>{if(!l)return;const s=m.trim()||`Snapshot ${x.length+1}`;v(n=>[...n,{name:s,model:JSON.parse(JSON.stringify(l)),timestamp:Date.now()}]),g("")},[l,m,x.length]);y.useEffect(()=>{h!==null&&x[h]&&i(x[h].model)},[h,x]);const t=y.useMemo(()=>!o||!l?null:N(o,l),[o,l]),c=t?t.summary.added+t.summary.removed+t.summary.changed:0;return e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-64 flex flex-col overflow-hidden",style:{background:"#FFFFFF",borderRight:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"px-4 py-3",style:{background:"linear-gradient(135deg, #1B3A4B, #2D6A7A)"},children:[e.jsx("h2",{className:"text-sm font-bold tracking-wide",style:{color:"#2DD4A8"},children:"Model Diff"}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:"rgba(255,255,255,0.6)"},children:"Compare model states"})]}),e.jsx("div",{className:"px-3 py-2.5",style:{borderBottom:"1px solid #E5E5E0"},children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("input",{type:"text",value:m,onChange:s=>g(s.target.value),placeholder:"Snapshot name...",className:"flex-1 text-xs px-2 py-1.5 rounded focus:outline-none",style:{background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#1a1a1a"},onKeyDown:s=>s.key==="Enter"&&p()}),e.jsx("button",{onClick:p,className:"px-2 py-1.5 text-xs rounded font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:"Snap"})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto text-xs py-1",children:[x.length===0&&e.jsx("div",{className:"px-4 py-8 text-center",style:{color:"#9CA3AF"},children:"Take a snapshot to create a baseline for comparison."}),x.map((s,n)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer mx-1 rounded-lg",style:{background:h===n?"#2DD4A818":"transparent",fontWeight:h===n?500:400},onMouseEnter:r=>{h!==n&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{h!==n&&(r.currentTarget.style.background=h===n?"#2DD4A818":"transparent")},onClick:()=>f(n),children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:"#2DD4A8"}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"truncate",style:{color:"#374151"},children:s.name}),e.jsxs("div",{style:{color:"#9CA3AF",fontSize:"10px"},children:[new Date(s.timestamp).toLocaleTimeString()," · ",Object.keys(s.model.elements).length," elements"]})]})]},n))]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:[!t&&e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"#9CA3AF"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px",opacity:.5},children:"↔"}),e.jsx("div",{className:"text-sm",children:"Take a snapshot, then make changes to see the diff"}),e.jsx("div",{className:"text-xs mt-2",style:{color:"#D1D5DB"},children:"Snapshots capture the current model state for comparison"})]})}),t&&e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#374151"},children:c===0?"No changes":`${c} element changes`}),t.summary.addedRels+t.summary.removedRels>0&&e.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:["+ ",t.summary.addedRels+t.summary.removedRels," relationship changes"]})]}),e.jsx("div",{className:"flex gap-2 mb-4",children:[{key:"all",label:"All",count:c,color:"#6B7280"},{key:"added",label:"Added",count:t.summary.added,color:"#2ECC71"},{key:"removed",label:"Removed",count:t.summary.removed,color:"#E74C3C"},{key:"changed",label:"Changed",count:t.summary.changed,color:"#F39C12"}].map(s=>e.jsxs("button",{onClick:()=>a(s.key),className:"px-2.5 py-1 text-xs rounded-full font-medium",style:{background:d===s.key?s.color+"20":"#F3F4F6",color:d===s.key?s.color:"#9CA3AF",border:`1px solid ${d===s.key?s.color+"40":"#E5E5E0"}`},children:[s.label," (",s.count,")"]},s.key))}),(d==="all"||d==="added")&&t.added.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#2ECC71"},children:["Added (",t.added.length,")"]}),e.jsx("div",{className:"space-y-1",children:t.added.map(s=>e.jsx(b,{element:s,type:"added",onClick:()=>u(s.id)},s.id))})]}),(d==="all"||d==="removed")&&t.removed.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#E74C3C"},children:["Removed (",t.removed.length,")"]}),e.jsx("div",{className:"space-y-1",children:t.removed.map(s=>e.jsx(b,{element:s,type:"removed",onClick:()=>{}},s.id))})]}),(d==="all"||d==="changed")&&t.changed.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#F39C12"},children:["Changed (",t.changed.length,")"]}),e.jsx("div",{className:"space-y-1",children:t.changed.map(({element:s,changes:n})=>e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg cursor-pointer",style:{background:"#FFFFFF",border:"1px solid #F39C1240"},onMouseEnter:r=>r.currentTarget.style.background="#FDF8F0",onMouseLeave:r=>r.currentTarget.style.background="#FFFFFF",onClick:()=>u(s.id),children:[e.jsx("span",{className:"text-xs mt-0.5",style:{color:"#F39C12"},children:"●"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#374151"},children:s.name}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{background:(j[s.layer]||"#95A5A6")+"18",color:j[s.layer]||"#95A5A6"},children:s.kind})]}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:n.join(", ")})]})]},s.id))})]}),(t.addedRels.length>0||t.removedRels.length>0)&&e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#6B7280"},children:"Relationship Changes"}),e.jsxs("div",{className:"space-y-1",children:[t.addedRels.map(s=>{var n,r;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg",style:{background:"#F0FDF4",border:"1px solid #BBF7D0"},children:[e.jsx("span",{style:{color:"#2ECC71"},children:"+"}),e.jsx("span",{style:{color:"#374151"},children:((n=l==null?void 0:l.elements[s.sourceId])==null?void 0:n.name)||s.sourceId}),e.jsx("span",{style:{color:"#2563EB"},children:s.type}),e.jsx("span",{style:{color:"#374151"},children:((r=l==null?void 0:l.elements[s.targetId])==null?void 0:r.name)||s.targetId})]},s.id)}),t.removedRels.map(s=>{var n,r;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg",style:{background:"#FEF2F2",border:"1px solid #FECACA"},children:[e.jsx("span",{style:{color:"#E74C3C"},children:"-"}),e.jsx("span",{style:{color:"#374151"},children:((n=o==null?void 0:o.elements[s.sourceId])==null?void 0:n.name)||s.sourceId}),e.jsx("span",{style:{color:"#2563EB"},children:s.type}),e.jsx("span",{style:{color:"#374151"},children:((r=o==null?void 0:o.elements[s.targetId])==null?void 0:r.name)||s.targetId})]},s.id)})]})]}),c===0&&t.addedRels.length===0&&t.removedRels.length===0&&e.jsxs("div",{className:"text-center py-8",style:{color:"#9CA3AF"},children:[e.jsx("div",{style:{fontSize:"24px",marginBottom:"8px"},children:"✓"}),e.jsx("div",{className:"text-sm",children:"No differences between snapshot and current model"})]})]})]})]})}function b({element:l,type:u,onClick:o}){const i=u==="added"?{bg:"#F0FDF4",border:"#BBF7D0",dot:"#2ECC71",hoverBg:"#DCFCE7"}:{bg:"#FEF2F2",border:"#FECACA",dot:"#E74C3C",hoverBg:"#FEE2E2"};return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg cursor-pointer text-xs",style:{background:i.bg,border:`1px solid ${i.border}`},onMouseEnter:m=>m.currentTarget.style.background=i.hoverBg,onMouseLeave:m=>m.currentTarget.style.background=i.bg,onClick:o,children:[e.jsx("span",{style:{color:i.dot},children:"●"}),e.jsx("span",{className:"font-medium truncate",style:{color:"#374151"},children:l.name}),e.jsx("span",{className:"ml-auto px-1.5 py-0.5 rounded",style:{background:(j[l.layer]||"#95A5A6")+"18",color:j[l.layer]||"#95A5A6"},children:l.kind})]})}export{A as ModelDiff,N as computeModelDiff};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,H as C,P as k,R as D,c as S,k as O,l as R,m as T}from"./reactflow-C9OlmOYw.js";import{a as p}from"./zustand-CrhqMOHB.js";/* empty css */import{r as I}from"./layout-providers-BSDYNZu0.js";import{h as L,u as h,Z as P,$ as M,d as z}from"./index-CG-gfw-s.js";import"./elk-6l8mIQnQ.js";const A={ontology:{bg:"#EFF6FF",fg:"#2563EB",border:"#BFDBFE"},profile:{bg:"#F0FDF4",fg:"#16A34A",border:"#BBF7D0"},extension:{bg:"#FFF7ED",fg:"#EA580C",border:"#FED7AA"}};function H({data:i}){const s=i,l=A[s.type]??A.ontology;return e.jsxs("div",{"data-testid":`ontology-package-node-${s.name}`,onClick:s.onClick,onDoubleClick:s.onDoubleClick,onContextMenu:s.onContextMenu,style:{background:"#FFFFFF",border:s.selected?"2px solid #2563EB":"1px solid #E5E5E0",borderRadius:"12px",padding:"16px",minWidth:"240px",maxWidth:"300px",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 200ms ease, transform 200ms ease"},children:[e.jsx(C,{type:"target",position:k.Top,id:"top",style:w}),e.jsx(C,{type:"source",position:k.Bottom,id:"bottom",style:w}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("span",{style:{padding:"1px 8px",fontSize:"10px",borderRadius:"9999px",fontWeight:600,background:l.bg,color:l.fg,border:`1px solid ${l.border}`},children:s.type}),e.jsxs("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:["v",s.version]})]}),e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1a1a1a",marginBottom:"4px"},children:s.name}),s.description&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"10px",lineHeight:"1.4"},children:s.description.length>80?s.description.slice(0,80)+"…":s.description}),e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"8px",height:"6px",borderRadius:"3px",overflow:"hidden"},children:s.layers.slice(0,12).map(d=>{const n=L[d.id]??d.color??"#6B7280";return e.jsx("div",{style:{flex:Math.max(d.kindCount,1),background:n,borderRadius:"1px"},title:`${d.label}: ${d.kindCount} kinds`},d.id)})}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"11px",color:"#6B7280"},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.kindCount})," kinds"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.layerCount})," layers"]})]})]})}const w={width:"8px",height:"8px",background:"#2563EB",border:"2px solid #FFFFFF",opacity:0},W=p.memo(H);function $({onClose:i}){const s=h(o=>o.availableOntologies),l=h(o=>o.ontologyInstallStatus),d=h(o=>o.setOntologyInstallStatus),[n,c]=p.useState(""),[r,g]=p.useState(null);function t(){n.trim()&&(d({installing:!0}),P(n.trim()),c(""))}function x(o){M(o),g(null)}return e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},onClick:i,children:e.jsxs("div",{className:"rounded-xl shadow-2xl overflow-hidden",style:{background:"#FFFFFF",width:"520px",maxHeight:"600px",border:"1px solid #E5E5E0"},onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Manage Ontology Library"}),e.jsx("button",{onClick:i,className:"text-sm px-2 py-0.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"x"})]}),e.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto",style:{maxHeight:"480px"},children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium block mb-1.5",style:{color:"#374151"},children:"Add Ontology"}),e.jsx("p",{className:"text-xs mb-2",style:{color:"#9CA3AF"},children:"Enter a git URL (https://...git), npm package name (@memoarchitect/...), or local path."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"https://gitlab.com/org/my-ontology.git",value:n,onChange:o=>c(o.target.value),onKeyDown:o=>o.key==="Enter"&&t(),className:"flex-1 px-3 py-2 text-xs rounded-lg",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none"},onFocus:o=>o.currentTarget.style.borderColor="#2563EB",onBlur:o=>o.currentTarget.style.borderColor="#E5E7EB",disabled:l.installing}),e.jsx("button",{onClick:t,disabled:!n.trim()||l.installing,className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:l.installing?"#9CA3AF":"#1B3A4B",color:"#FFFFFF",opacity:!n.trim()||l.installing?.5:1,cursor:!n.trim()||l.installing?"not-allowed":"pointer"},children:l.installing?"Installing...":"Install"})]}),l.error&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA"},children:l.error}),l.lastInstalled&&!l.error&&e.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#F0FDF4",color:"#16A34A",border:"1px solid #BBF7D0"},children:["Installed ",l.lastInstalled]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium block mb-2",style:{color:"#374151"},children:["Installed Packages (",s.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.map(o=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FAFAF8"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#1a1a1a"},children:o.name}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:o.type==="ontology"?"#EFF6FF":o.type==="profile"?"#F0FDF4":"#FFF7ED",color:o.type==="ontology"?"#2563EB":o.type==="profile"?"#16A34A":"#EA580C",fontSize:"10px"},children:o.type})]}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",o.version," · ",o.kindCount," kinds · ",o.layers.length," layers"]})]}),r===o.name?e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>x(o.name),className:"px-2 py-1 text-xs rounded",style:{background:"#DC2626",color:"#FFFFFF"},children:"Confirm"}),e.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs rounded",style:{background:"#F3F4F6",color:"#374151"},children:"Cancel"})]}):e.jsx("button",{onClick:()=>g(o.name),className:"text-xs px-2 py-1 rounded hover:bg-red-50",style:{color:"#DC2626",border:"1px solid #FECACA"},children:"Remove"})]},o.name)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-xs",style:{color:"#9CA3AF"},children:"No ontology packages installed"})]})]})]})]})})}const _={ontologyPackage:W},Y=260,V=180;async function K(i){const s=new Map(i.map(t=>[t.name,t])),l={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.spacing.nodeNodeBetweenLayers":"100","elk.spacing.nodeNode":"32","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=24, left=24, bottom=24, right=24]"},children:i.map(t=>({id:t.name,width:Y,height:V})),edges:i.filter(t=>t.extends&&s.has(t.extends)).map((t,x)=>({id:`e-${x}`,sources:[t.extends],targets:[t.name]}))},d=await I(l),n=new Map;for(const t of d.children??[])n.set(t.id,{x:t.x??0,y:t.y??0});const c={ontology:"#3B82F6",profile:"#10B981",extension:"#F59E0B"},r=i.map(t=>({id:t.name,type:"ontologyPackage",position:n.get(t.name)??{x:0,y:0},data:{name:t.name,type:t.type,version:t.version,description:t.description,kindCount:t.kindCount,layerCount:t.layers.length,layers:t.layers.map(x=>({id:x.id,label:x.label,color:x.color,kindCount:x.kindCount})),selected:t.selected,onClick:()=>{}}})),g=[];for(const t of i)if(t.extends&&s.has(t.extends)){const x=c[t.type]??"#94A3B8";g.push({id:`${t.extends}->${t.name}`,source:t.extends,target:t.name,type:"smoothstep",data:{edgeType:"extends"},style:{stroke:x,strokeWidth:2,strokeDasharray:"6 3"},animated:!1,label:"extends",labelStyle:{fontSize:9,fill:x,fontWeight:500},labelBgStyle:{fill:"#F7F7F5",fillOpacity:.9},labelBgPadding:[4,2],markerEnd:{type:"arrowclosed",color:x,width:14,height:14}})}return{nodes:r,edges:g}}function G(i,s){const l=new Map;for(const c of s)c.extends&&(l.has(c.extends)||l.set(c.extends,[]),l.get(c.extends).push(c.name));const d=new Set([i]),n=[i];for(;n.length;){const c=n.shift();for(const r of l.get(c)??[])d.has(r)||(d.add(r),n.push(r))}return d}function Z(){const i=h(a=>a.availableOntologies),s=h(a=>a.setActiveView),l=h(a=>a.hiddenEdgeTypes),d=h(a=>a.toggleHiddenEdgeType),[n,c]=p.useState(!1),[r,g]=p.useState({nodes:[],edges:[]}),[t,x]=p.useState(null),{fitView:o}=S();p.useEffect(()=>{let a=!1;return K(i).then(u=>{a||g(u)}).catch(u=>{console.error("[OntologyDiagram] ELK layout failed:",u)}),()=>{a=!0}},[i]);const F=p.useCallback(a=>{s({type:"ontology-detail",packageName:a})},[s]),E=p.useCallback(a=>{const u=G(a,i),m=r.nodes.filter(y=>u.has(y.id));m.length!==0&&o({nodes:m.map(y=>({id:y.id})),duration:400,padding:.2})},[i,r.nodes,o]),v=p.useCallback((a,u)=>{a.preventDefault(),x({x:a.clientX,y:a.clientY,packageName:u})},[]);p.useEffect(()=>{const a=u=>{if(u.key==="Escape"){if(t){x(null);return}o({padding:.1,duration:300})}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,o]);const{nodes:N,edges:B}=p.useMemo(()=>{const a=r.nodes.map(m=>({...m,data:{...m.data,onClick:()=>E(m.id),onDoubleClick:()=>F(m.id),onContextMenu:y=>v(y,m.id)}})),u=r.edges.filter(m=>{var j;const y=(j=m.data)==null?void 0:j.edgeType;return!y||!l.has(y)});return{nodes:a,edges:u}},[r,E,F,v,l]),f=p.useRef(null);p.useEffect(()=>{if(!t)return;const a=u=>{f.current&&!f.current.contains(u.target)&&x(null)};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[t]);const b=l.has("extends");return i.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[e.jsx("div",{className:"text-3xl mb-3",children:"◉"}),e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:"#374151"},children:"No ontology packages found"}),e.jsx("div",{className:"text-xs",children:"Start the dev server to load ontology packages"})]})}):e.jsxs("div",{className:"flex-1",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"#1a1a1a"},children:"Ontology Library"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"#9CA3AF"},children:[i.length," package",i.length!==1?"s":""," available. Click to zoom, double-click to open, right-click for source."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{"data-testid":"toggle-tracing",onClick:()=>d("extends"),title:b?"Show extends tracing edges":"Hide extends tracing edges",className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:b?{background:"#F0F0ED",color:"#6B7280",border:"1px solid #E5E5E0"}:{background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},children:b?"Show Tracing":"Hide Tracing"}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:{background:"#1B3A4B",color:"#2DD4A8"},children:"+ Add Ontology"})]})]}),n&&e.jsx($,{onClose:()=>c(!1)}),e.jsx("div",{style:{flex:1,height:"calc(100% - 72px)"},children:e.jsxs(O,{nodes:N,edges:B,nodeTypes:_,fitView:!0,fitViewOptions:{padding:.1},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.2,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[e.jsx(R,{color:"#E5E5E0",gap:24,size:1}),e.jsx(T,{showInteractive:!1})]})}),t&&e.jsx(U,{menuRef:f,state:t,onClose:()=>x(null),packages:i})]})}const U=({state:i,onClose:s,packages:l,menuRef:d})=>{const n=l.find(r=>r.name===i.packageName);function c(){if(!n)return;const r=n.rootDir?`${n.rootDir}/memo.package.yaml`:"";r?z(r):window.open(`vscode://file/${encodeURIComponent(n.name)}`),s()}return e.jsxs("div",{ref:d,style:{position:"fixed",top:i.y,left:i.x,zIndex:1e3,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",padding:"4px",minWidth:"180px",fontSize:"12px"},children:[e.jsx("div",{style:{padding:"6px 10px",color:"#9CA3AF",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px"},children:i.packageName}),e.jsx("button",{onClick:c,disabled:!(n!=null&&n.rootDir),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",border:"none",background:"transparent",cursor:n!=null&&n.rootDir?"pointer":"not-allowed",color:n!=null&&n.rootDir?"#1a1a1a":"#9CA3AF",borderRadius:"4px"},onMouseEnter:r=>{n!=null&&n.rootDir&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:"Open source"})]})};function oe(){return e.jsx(D,{children:e.jsx(Z,{})})}export{oe as OntologyDecompositionDiagram,oe as default};
|
|
1
|
+
import{j as e,H as C,P as k,R as D,c as S,k as O,l as R,m as T}from"./reactflow-C9OlmOYw.js";import{a as p}from"./zustand-CrhqMOHB.js";/* empty css */import{r as I}from"./layout-providers-BSDYNZu0.js";import{h as L,u as h,Z as P,$ as M,d as z}from"./index-a2rpMs5Y.js";import"./elk-6l8mIQnQ.js";const A={ontology:{bg:"#EFF6FF",fg:"#2563EB",border:"#BFDBFE"},profile:{bg:"#F0FDF4",fg:"#16A34A",border:"#BBF7D0"},extension:{bg:"#FFF7ED",fg:"#EA580C",border:"#FED7AA"}};function H({data:i}){const s=i,l=A[s.type]??A.ontology;return e.jsxs("div",{"data-testid":`ontology-package-node-${s.name}`,onClick:s.onClick,onDoubleClick:s.onDoubleClick,onContextMenu:s.onContextMenu,style:{background:"#FFFFFF",border:s.selected?"2px solid #2563EB":"1px solid #E5E5E0",borderRadius:"12px",padding:"16px",minWidth:"240px",maxWidth:"300px",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 200ms ease, transform 200ms ease"},children:[e.jsx(C,{type:"target",position:k.Top,id:"top",style:w}),e.jsx(C,{type:"source",position:k.Bottom,id:"bottom",style:w}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("span",{style:{padding:"1px 8px",fontSize:"10px",borderRadius:"9999px",fontWeight:600,background:l.bg,color:l.fg,border:`1px solid ${l.border}`},children:s.type}),e.jsxs("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:["v",s.version]})]}),e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1a1a1a",marginBottom:"4px"},children:s.name}),s.description&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"10px",lineHeight:"1.4"},children:s.description.length>80?s.description.slice(0,80)+"…":s.description}),e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"8px",height:"6px",borderRadius:"3px",overflow:"hidden"},children:s.layers.slice(0,12).map(d=>{const n=L[d.id]??d.color??"#6B7280";return e.jsx("div",{style:{flex:Math.max(d.kindCount,1),background:n,borderRadius:"1px"},title:`${d.label}: ${d.kindCount} kinds`},d.id)})}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"11px",color:"#6B7280"},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.kindCount})," kinds"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.layerCount})," layers"]})]})]})}const w={width:"8px",height:"8px",background:"#2563EB",border:"2px solid #FFFFFF",opacity:0},W=p.memo(H);function $({onClose:i}){const s=h(o=>o.availableOntologies),l=h(o=>o.ontologyInstallStatus),d=h(o=>o.setOntologyInstallStatus),[n,c]=p.useState(""),[r,g]=p.useState(null);function t(){n.trim()&&(d({installing:!0}),P(n.trim()),c(""))}function x(o){M(o),g(null)}return e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},onClick:i,children:e.jsxs("div",{className:"rounded-xl shadow-2xl overflow-hidden",style:{background:"#FFFFFF",width:"520px",maxHeight:"600px",border:"1px solid #E5E5E0"},onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Manage Ontology Library"}),e.jsx("button",{onClick:i,className:"text-sm px-2 py-0.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"x"})]}),e.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto",style:{maxHeight:"480px"},children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium block mb-1.5",style:{color:"#374151"},children:"Add Ontology"}),e.jsx("p",{className:"text-xs mb-2",style:{color:"#9CA3AF"},children:"Enter a git URL (https://...git), npm package name (@memoarchitect/...), or local path."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"https://gitlab.com/org/my-ontology.git",value:n,onChange:o=>c(o.target.value),onKeyDown:o=>o.key==="Enter"&&t(),className:"flex-1 px-3 py-2 text-xs rounded-lg",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none"},onFocus:o=>o.currentTarget.style.borderColor="#2563EB",onBlur:o=>o.currentTarget.style.borderColor="#E5E7EB",disabled:l.installing}),e.jsx("button",{onClick:t,disabled:!n.trim()||l.installing,className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:l.installing?"#9CA3AF":"#1B3A4B",color:"#FFFFFF",opacity:!n.trim()||l.installing?.5:1,cursor:!n.trim()||l.installing?"not-allowed":"pointer"},children:l.installing?"Installing...":"Install"})]}),l.error&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA"},children:l.error}),l.lastInstalled&&!l.error&&e.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#F0FDF4",color:"#16A34A",border:"1px solid #BBF7D0"},children:["Installed ",l.lastInstalled]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium block mb-2",style:{color:"#374151"},children:["Installed Packages (",s.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.map(o=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FAFAF8"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#1a1a1a"},children:o.name}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:o.type==="ontology"?"#EFF6FF":o.type==="profile"?"#F0FDF4":"#FFF7ED",color:o.type==="ontology"?"#2563EB":o.type==="profile"?"#16A34A":"#EA580C",fontSize:"10px"},children:o.type})]}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",o.version," · ",o.kindCount," kinds · ",o.layers.length," layers"]})]}),r===o.name?e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>x(o.name),className:"px-2 py-1 text-xs rounded",style:{background:"#DC2626",color:"#FFFFFF"},children:"Confirm"}),e.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs rounded",style:{background:"#F3F4F6",color:"#374151"},children:"Cancel"})]}):e.jsx("button",{onClick:()=>g(o.name),className:"text-xs px-2 py-1 rounded hover:bg-red-50",style:{color:"#DC2626",border:"1px solid #FECACA"},children:"Remove"})]},o.name)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-xs",style:{color:"#9CA3AF"},children:"No ontology packages installed"})]})]})]})]})})}const _={ontologyPackage:W},Y=260,V=180;async function K(i){const s=new Map(i.map(t=>[t.name,t])),l={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.spacing.nodeNodeBetweenLayers":"100","elk.spacing.nodeNode":"32","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=24, left=24, bottom=24, right=24]"},children:i.map(t=>({id:t.name,width:Y,height:V})),edges:i.filter(t=>t.extends&&s.has(t.extends)).map((t,x)=>({id:`e-${x}`,sources:[t.extends],targets:[t.name]}))},d=await I(l),n=new Map;for(const t of d.children??[])n.set(t.id,{x:t.x??0,y:t.y??0});const c={ontology:"#3B82F6",profile:"#10B981",extension:"#F59E0B"},r=i.map(t=>({id:t.name,type:"ontologyPackage",position:n.get(t.name)??{x:0,y:0},data:{name:t.name,type:t.type,version:t.version,description:t.description,kindCount:t.kindCount,layerCount:t.layers.length,layers:t.layers.map(x=>({id:x.id,label:x.label,color:x.color,kindCount:x.kindCount})),selected:t.selected,onClick:()=>{}}})),g=[];for(const t of i)if(t.extends&&s.has(t.extends)){const x=c[t.type]??"#94A3B8";g.push({id:`${t.extends}->${t.name}`,source:t.extends,target:t.name,type:"smoothstep",data:{edgeType:"extends"},style:{stroke:x,strokeWidth:2,strokeDasharray:"6 3"},animated:!1,label:"extends",labelStyle:{fontSize:9,fill:x,fontWeight:500},labelBgStyle:{fill:"#F7F7F5",fillOpacity:.9},labelBgPadding:[4,2],markerEnd:{type:"arrowclosed",color:x,width:14,height:14}})}return{nodes:r,edges:g}}function G(i,s){const l=new Map;for(const c of s)c.extends&&(l.has(c.extends)||l.set(c.extends,[]),l.get(c.extends).push(c.name));const d=new Set([i]),n=[i];for(;n.length;){const c=n.shift();for(const r of l.get(c)??[])d.has(r)||(d.add(r),n.push(r))}return d}function Z(){const i=h(a=>a.availableOntologies),s=h(a=>a.setActiveView),l=h(a=>a.hiddenEdgeTypes),d=h(a=>a.toggleHiddenEdgeType),[n,c]=p.useState(!1),[r,g]=p.useState({nodes:[],edges:[]}),[t,x]=p.useState(null),{fitView:o}=S();p.useEffect(()=>{let a=!1;return K(i).then(u=>{a||g(u)}).catch(u=>{console.error("[OntologyDiagram] ELK layout failed:",u)}),()=>{a=!0}},[i]);const F=p.useCallback(a=>{s({type:"ontology-detail",packageName:a})},[s]),E=p.useCallback(a=>{const u=G(a,i),m=r.nodes.filter(y=>u.has(y.id));m.length!==0&&o({nodes:m.map(y=>({id:y.id})),duration:400,padding:.2})},[i,r.nodes,o]),v=p.useCallback((a,u)=>{a.preventDefault(),x({x:a.clientX,y:a.clientY,packageName:u})},[]);p.useEffect(()=>{const a=u=>{if(u.key==="Escape"){if(t){x(null);return}o({padding:.1,duration:300})}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,o]);const{nodes:N,edges:B}=p.useMemo(()=>{const a=r.nodes.map(m=>({...m,data:{...m.data,onClick:()=>E(m.id),onDoubleClick:()=>F(m.id),onContextMenu:y=>v(y,m.id)}})),u=r.edges.filter(m=>{var j;const y=(j=m.data)==null?void 0:j.edgeType;return!y||!l.has(y)});return{nodes:a,edges:u}},[r,E,F,v,l]),f=p.useRef(null);p.useEffect(()=>{if(!t)return;const a=u=>{f.current&&!f.current.contains(u.target)&&x(null)};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[t]);const b=l.has("extends");return i.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[e.jsx("div",{className:"text-3xl mb-3",children:"◉"}),e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:"#374151"},children:"No ontology packages found"}),e.jsx("div",{className:"text-xs",children:"Start the dev server to load ontology packages"})]})}):e.jsxs("div",{className:"flex-1",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"#1a1a1a"},children:"Ontology Library"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"#9CA3AF"},children:[i.length," package",i.length!==1?"s":""," available. Click to zoom, double-click to open, right-click for source."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{"data-testid":"toggle-tracing",onClick:()=>d("extends"),title:b?"Show extends tracing edges":"Hide extends tracing edges",className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:b?{background:"#F0F0ED",color:"#6B7280",border:"1px solid #E5E5E0"}:{background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},children:b?"Show Tracing":"Hide Tracing"}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:{background:"#1B3A4B",color:"#2DD4A8"},children:"+ Add Ontology"})]})]}),n&&e.jsx($,{onClose:()=>c(!1)}),e.jsx("div",{style:{flex:1,height:"calc(100% - 72px)"},children:e.jsxs(O,{nodes:N,edges:B,nodeTypes:_,fitView:!0,fitViewOptions:{padding:.1},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.2,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[e.jsx(R,{color:"#E5E5E0",gap:24,size:1}),e.jsx(T,{showInteractive:!1})]})}),t&&e.jsx(U,{menuRef:f,state:t,onClose:()=>x(null),packages:i})]})}const U=({state:i,onClose:s,packages:l,menuRef:d})=>{const n=l.find(r=>r.name===i.packageName);function c(){if(!n)return;const r=n.rootDir?`${n.rootDir}/memo.package.yaml`:"";r?z(r):window.open(`vscode://file/${encodeURIComponent(n.name)}`),s()}return e.jsxs("div",{ref:d,style:{position:"fixed",top:i.y,left:i.x,zIndex:1e3,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",padding:"4px",minWidth:"180px",fontSize:"12px"},children:[e.jsx("div",{style:{padding:"6px 10px",color:"#9CA3AF",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px"},children:i.packageName}),e.jsx("button",{onClick:c,disabled:!(n!=null&&n.rootDir),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",border:"none",background:"transparent",cursor:n!=null&&n.rootDir?"pointer":"not-allowed",color:n!=null&&n.rootDir?"#1a1a1a":"#9CA3AF",borderRadius:"4px"},onMouseEnter:r=>{n!=null&&n.rootDir&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:"Open source"})]})};function oe(){return e.jsx(D,{children:e.jsx(Z,{})})}export{oe as OntologyDecompositionDiagram,oe as default};
|