@g1cloud/entity-modeler-next 5.2.12 → 5.2.13
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(_e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@g1cloud/open-bluesea-core")):typeof define=="function"&&define.amd?define(["exports","vue","@g1cloud/open-bluesea-core"],t):(_e=typeof globalThis<"u"?globalThis:_e||self,t(_e.EntityModeler={},_e.Vue,_e.OpenBlueseaCore))})(this,(function(_e,t,ie){"use strict";var HL=Object.defineProperty;var jL=(_e,t,ie)=>t in _e?HL(_e,t,{enumerable:!0,configurable:!0,writable:!0,value:ie}):_e[t]=ie;var ct=(_e,t,ie)=>jL(_e,typeof t!="symbol"?t+"":t,ie);const yy={startX:40,startY:40,columnGap:280,rowGap:220,perRow:4,defaultSize:{width:220,height:140}};function gy(e,n){const o=e%n.perRow,i=Math.floor(e/n.perRow);return{location:{x:n.startX+o*n.columnGap,y:n.startY+i*n.rowGap},size:{...n.defaultSize}}}function bc(e,n,o={}){const i={...yy,...o},a=new Map(e.entities.map(b=>[b.modelId,b])),r=new Map(n.entityLayouts.map(b=>[b.entityRef,b])),l=new Map(n.associationLayouts.map(b=>[b.associationRef,b])),s=new Map;for(const b of e.groups)for(const _ of b.memberEntityRefs)s.set(_,b.modelId);const c=new Map;for(const b of n.groupLayouts)for(const _ of b.memberNoteRefs??[])c.set(_,b.groupRef);let d=0;const u=e.entities.map(b=>{const _=s.get(b.modelId),E=r.get(b.modelId);if(E){const y={location:{x:E.geo.location.x,y:E.geo.location.y},size:{width:E.geo.size.width,height:E.geo.size.height}};return{entity:b,geo:y,collapsed:E.collapsed??!1,locked:E.locked??!1,groupRef:_,style:E.style,attributeStyles:E.attributeStyles,operationStyles:E.operationStyles}}const N=gy(d++,i);return{entity:b,geo:N,collapsed:!1,locked:!1,groupRef:_}}),m=new Map(n.groupLayouts.map(b=>[b.groupRef,b])),p=e.groups.map(b=>{const _=m.get(b.modelId),E=_?{location:{x:_.geo.location.x,y:_.geo.location.y},size:{width:_.geo.size.width,height:_.geo.size.height}}:{location:{x:0,y:0},size:{width:400,height:300}};return{group:b,geo:E,style:_==null?void 0:_.style,locked:(_==null?void 0:_.locked)??!1}}),f=e.associations.map(b=>{const _=l.get(b.modelId);return{association:b,waypoints:(_==null?void 0:_.waypoints)??[],sourceColumnRef:_==null?void 0:_.sourceColumnRef,targetColumnRef:_==null?void 0:_.targetColumnRef}}),h=n.notes.map(b=>({note:{...b,geo:{location:{x:b.geo.location.x,y:b.geo.location.y},size:{width:b.geo.size.width,height:b.geo.size.height}}},groupRef:c.get(b.modelId)})),g=[];for(const b of n.notes)for(const _ of b.connections??[])a.has(_.targetRef)&&g.push({noteRef:b.modelId,targetRef:_.targetRef,waypoints:_.waypoints.map(E=>({x:E.x,y:E.y}))});return{entities:u,associations:f,groups:p,notes:h,noteConnections:g}}const by={cellWidth:260,cellHeight:200,pad:24,headerHeight:28,ungroupedCols:4};function _c(e,n,o={}){const i={...by,...o},a=new Map(n.groupLayouts.map(u=>[u.groupRef,u.geo])),r=[];let l=0;for(const u of e.groups){const m=a.get(u.modelId),p=m?m.location:{x:0,y:0},f=m?m.size.width:800;m&&(l=Math.max(l,m.location.y+m.size.height));const h=Math.max(1,Math.floor((f-i.pad*2)/i.cellWidth));u.memberEntityRefs.forEach((g,b)=>{const _=b%h,E=Math.floor(b/h);r.push({id:g,location:{x:p.x+i.pad+_*i.cellWidth,y:p.y+i.pad+i.headerHeight+E*i.cellHeight}})})}const s=new Set(e.groups.flatMap(u=>u.memberEntityRefs)),c=e.entities.filter(u=>!s.has(u.modelId)),d=l>0?l+40:i.pad;return c.forEach((u,m)=>{const p=m%i.ungroupedCols,f=Math.floor(m/i.ungroupedCols);r.push({id:u.modelId,location:{x:i.pad+p*i.cellWidth,y:d+f*i.cellHeight}})}),r}const kc={cols:5,boxWidth:200,gap:60,baseX:0,baseY:0,headerHeight:48,rowHeight:24,footerHeight:16,minHeight:120};function _y(e,n={}){const o={...kc,...n},i=o.headerHeight+Math.max(0,e)*o.rowHeight+o.footerHeight;return Math.max(o.minHeight,i)}function qr(e,n={}){const o={...kc,...n},i=Math.max(1,o.cols),a=new Array(i).fill(o.baseY);return e.map((r,l)=>{const s=l%i,c=_y(r.attributeCount,o),d=o.baseX+s*(o.boxWidth+o.gap),u=a[s];return a[s]=u+c+o.gap,{id:r.id,location:{x:d,y:u},size:{width:o.boxWidth,height:c}}})}function eo(e){const n=new Map,o=new Map;for(const i of e){o.set(i.modelId,i),i.dbAttrs.length===1&&n.set(i.modelId,i.dbAttrs[0]);for(const a of i.dbAttrs)n.set(a.modelId,a),o.set(a.modelId,i)}return{attributeOf:i=>o.get(i),columnOf:i=>n.get(i),canon:i=>{var a;return((a=n.get(i))==null?void 0:a.modelId)??i}}}function Ec(e,n){const o=e.attributeOf(n);if(!o)return n;const i=o.name||"(이름 없음)";if(o.dbAttrs.length<=1)return i;const a=e.columnOf(n);if(!a)return`${i}(컬럼 ${o.dbAttrs.length}개 중 미지정)`;const r=o.dbAttrs.findIndex(l=>l.modelId===a.modelId);return`${i}.${a.physicalName||`#${r+1}`}`}const ky={UNDEFINED:"Undefined",JPA_ENTITY:"Entity",JPA_EMBEDDABLE:"Embeddable",JPA_MULTI_LANGUAGE_ENTITY:"MultiLanguageEntity",SERIALIZED_TYPE:"Serialized"};function mi(e){return ky[e]??e}function gt(e){return e==="JPA_EMBEDDABLE"||e==="SERIALIZED_TYPE"}function ln(e){return e==="SERIALIZED_TYPE"}const sa="inherited:";function Nc(e,n){return`${sa}${e}:${n}`}function to(e){return e.startsWith(sa)}function Wr(e){if(!to(e))return null;const n=e.slice(sa.length),o=n.indexOf(":");if(o<0)return null;const i=n.slice(0,o),a=n.slice(o+1);return!i||!a?null:{baseClass:i,field:a}}function fi(e,n){var a;if(gt(e.stereotype))return[];if(n.some(r=>r.name===e.name))return[];const o=e.superClass||((a=n.find(r=>r.default))==null?void 0:a.name);if(!o)return[];const i=n.find(r=>r.name===o);return i?i.columns.map(r=>({modelId:Nc(i.name,r.field),baseClass:i.name,field:r.field,physicalName:r.physicalName,dataType:r.dataType,logicalName:r.logicalName,length:r.length,scale:r.scale})):[]}function ca(e){return e.attrType.startsWith("RELATION")&&e.dbAttrs.length>0}function gn(e){return e.attrType==="RELATION_OWN"&&e.dbAttrs.length>1}function Jr(e){const n=new Set;for(const o of e)o.end2.attributeRef&&n.add(o.end2.attributeRef),o.end1.attributeRef&&o.end1.navigable&&n.add(o.end1.attributeRef);return n}function Xr(e,n,o){var a;if(e.attrType!=="RELATION_OWN"||o.has(e.modelId))return!1;const i=(a=e.derivedFrom)==null?void 0:a.associationRef;return i?n.attributes.some(r=>{var l;return r.modelId!==e.modelId&&r.attrType==="RELATION_OWN"&&((l=r.derivedFrom)==null?void 0:l.associationRef)===i&&o.has(r.modelId)}):!1}function no(e,n,o,i,a=0){var d;if(!ca(e))return;const r=i.find(u=>u.end1.attributeRef===e.modelId||u.end2.attributeRef===e.modelId),l=n==null?void 0:n.modelId,s=r?o.find(u=>u.modelId===(r.end1.entityRef===l?r.end2.entityRef:r.end1.entityRef)):void 0,c=(d=e.derivedFrom)==null?void 0:d.sourceAttributeRef;if(c){const u=s==null?void 0:s.attributes.find(m=>m.modelId===c);if(u!=null&&u.dbAttrs[a])return u.dbAttrs[a];if(u)return Vo(s)[a];for(const m of o){const p=m.attributes.find(f=>f.modelId===c);if(p)return p.dbAttrs[a]??Vo(s)[a]}}if(s)return Vo(s)[a]}function Vo(e){return((e==null?void 0:e.attributes)??[]).filter(n=>n.identifier&&(n.attrType==="NORMAL"||n.attrType==="RELATION_OWN")).slice().sort((n,o)=>n.order-o.order).flatMap(n=>n.dbAttrs)}function Ey(e,n,o){var i,a,r,l;if(e.attrType==="EMBED_PREDEF"){const s=(a=(i=n==null?void 0:n.embeddableCatalog)==null?void 0:i.find(c=>c.type===e.type))==null?void 0:a.fields;return e.dbAttrs.map((c,d)=>{var u;return((u=s==null?void 0:s[d])==null?void 0:u.name)||void 0})}if(e.attrType==="EMBED_OWN"){const s=(r=e.embedded)==null?void 0:r.embeddableRef,c=s!=null?(l=n==null?void 0:n.entities)==null?void 0:l.find(u=>u.modelId===s):void 0,d=wc(c,n,o);return d.length!==e.dbAttrs.length?e.dbAttrs.map(()=>{}):d.map(u=>u.propertyPath||void 0)}}function bn(e,n){return wc(e,n,new Set)}function wc(e,n,o){if(e==null||o.has(e.modelId))return[];const i=new Set(o).add(e.modelId);return e.attributes.flatMap(a=>{const r=Ey(a,n,i),l=a.name??"";return a.dbAttrs.map((s,c)=>({col:s,propertyPath:l?r===void 0?a.dbAttrs.length>1?"":l:r[c]?`${l}.${r[c]}`:"":"",defaultPhysical:s.physicalName??"",...s.sharedColumnRef!=null?{defaultSharedRef:s.sharedColumnRef}:{},ownColumn:!!s.physicalName&&s.sharedColumnRef==null}))})}const Ic=e=>e==null||e.trim()==="";function vc(e,n,o,i,a){var r,l,s,c;if(e.attrType==="EMBED_PREDEF")return(l=(r=a==null?void 0:a.embeddableCatalog)==null?void 0:r.find(d=>d.type===e.type))==null?void 0:l.fields[n];if(e.attrType==="EMBED_OWN"){const d=(s=e.embedded)==null?void 0:s.embeddableRef;return d==null||(c=bn(i.entities.find(u=>u.modelId===d))[n])==null?void 0:c.col}if(e.attrType.startsWith("RELATION"))return no(e,o,i.entities,i.associations,n)}function _n(e,n,o,i,a,r){const l=vc(e,o,i,a,r);return l?{...n,physicalName:n.physicalName||l.physicalName||"",dataType:n.dataType||l.dataType||"",length:n.length??l.length,scale:n.scale??l.scale,logicalName:Pn(n.logicalName)?n.logicalName:l.logicalName,...n.sharedColumnRef==null&&!n.physicalName&&l.sharedColumnRef!=null&&(e.attrType==="EMBED_OWN"||e.attrType==="EMBED_PREDEF")?{sharedColumnRef:l.sharedColumnRef}:{}}:n}function Pn(e){return e!=null&&Object.values(e).some(n=>!Ic(n))}function kn(e){var n,o;return Pn((n=e.table)==null?void 0:n.logicalName)?(o=e.table)==null?void 0:o.logicalName:e.classLogicalName}function Bo(e,n){return Pn(n==null?void 0:n.logicalName)?n==null?void 0:n.logicalName:e.fieldLogicalName}function pi(e,n,o,i,a,r){var l;return Ic(n.physicalName)?((l=vc(e,o,i,a,r))==null?void 0:l.physicalName)??"":n.physicalName}function Cc(e,n,o,i){var a,r,l,s;if(e.attrType==="EMBED_PREDEF")return((l=(r=(a=i==null?void 0:i.embeddableCatalog)==null?void 0:a.find(c=>c.type===e.type))==null?void 0:r.fields[n])==null?void 0:l.name)||void 0;if(e.attrType==="EMBED_OWN"){const c=(s=e.embedded)==null?void 0:s.embeddableRef;if(c==null)return;const d=o.entities.find(m=>m.modelId===c);if(!d)return;let u=0;for(const m of d.attributes)for(let p=0;p<m.dbAttrs.length;p++){if(u===n)return m.name||void 0;u++}}}function Zr(e,n){if(e.stereotype!=="JPA_EMBEDDABLE")return[e];const o=n.filter(i=>i.modelId!==e.modelId&&i.attributes.some(a=>{var r;return a.attrType==="EMBED_OWN"&&((r=a.embedded)==null?void 0:r.embeddableRef)===e.modelId}));return[e,...o]}function zn(e,n){return Zr(e,n).flatMap(o=>o.attributes.flatMap(i=>i.dbAttrs))}function Do(e){const n=new Map;for(const o of e)n.set(o.modelId,o);return n}function oo(e,n){if(e.sharedColumnRef==null)return null;const o=n.get(e.sharedColumnRef);return o?{physicalName:o.physicalName,insertable:!1,updatable:!1}:null}function Lo(e,n){if(e.packageName)return{kind:"explicit",value:e.packageName};const o=n.groups.find(i=>{var a;return(a=i.memberEntityRefs)==null?void 0:a.includes(e.modelId)});return{kind:"group",value:(o==null?void 0:o.packageName)??""}}function Ny(e,n,o){const i=Lo(e,o),a=Lo(n,o);return i.kind===a.kind&&i.value!==a.value}function Oo(e){const n=new Map;for(const o of e.entities){if(o.stereotype!=="SERIALIZED_TYPE"||!o.name)continue;const i=n.get(o.name);i?i.push(o):n.set(o.name,[o])}return n}function Sc(e,n){var i,a;const o=(i=n==null?void 0:n.serialization)==null?void 0:i.collectionType;if(!o)return e;if(o==="MAP"){const r=(a=n==null?void 0:n.serialization)==null?void 0:a.mapKeyType;return`Map<${r&&r.trim()?r.slice(r.lastIndexOf(".")+1):"?"}, ${e}>`}return`${o==="SET"?"Set":"List"}<${e}>`}function hi(e,n,o,i){if(n.size===0)return{kind:"none"};const a=n.has(e.type)?e.type:e.customType&&n.has(e.customType)?e.customType:void 0;if(!a)return{kind:"none"};const r=n.get(a);if(r.length===1)return{kind:"resolved",entity:r[0]};if(o&&i){const l=Lo(o,i),s=r.filter(c=>{const d=Lo(c,i);return d.kind===l.kind&&d.value===l.value});if(s.length===1)return{kind:"resolved",entity:s[0]}}return{kind:"ambiguous",name:a,candidates:r}}const xc=["BIT","TINYINT","SMALLINT","INTEGER","BIGINT","FLOAT","REAL","DOUBLE","NUMERIC","DECIMAL","CHAR","VARCHAR","LONGVARCHAR","DATE","TIME","TIMESTAMP","BINARY","VARBINARY","LONGVARBINARY","NULL","OTHER","JAVA_OBJECT","DISTINCT","STRUCT","ARRAY","BLOB","CLOB","REF","DATALINK","BOOLEAN","ROWID","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","SQLXML","REF_CURSOR","TIME_WITH_TIMEZONE","TIMESTAMP_WITH_TIMEZONE","SERIAL","BIG_SERIAL","JSONB"],wy=new Set(["NULL","OTHER","JAVA_OBJECT","DISTINCT","STRUCT","ARRAY","REF","DATALINK","ROWID","REF_CURSOR","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","SQLXML","TIME_WITH_TIMEZONE","BIT","TINYINT","FLOAT"]),Iy=xc.filter(e=>!wy.has(e)),vy={TIMESTAMP_WITH_TIMEZONE:"TIMESTAMP WITH TIME ZONE",BIG_SERIAL:"BIGSERIAL",DOUBLE:"DOUBLE PRECISION"};function Qr(e){return vy[e]??e}const Cy=new Set(["CHAR","VARCHAR","NCHAR","NVARCHAR","BINARY","VARBINARY","NUMERIC","DECIMAL"]),el=new Set(["NUMERIC","DECIMAL"]);function Rc(e,n=Iy){const o=[...n];return e&&!o.includes(e)?[e,...o]:o}const En="CustomType";function Ac(e){var o;if(e.type!==En)return;const n=(o=e.customType)==null?void 0:o.trim();return n||void 0}const io="GroupCodeEnum",tl="String",yi=[{value:"String",label:"String"},{value:"Integer",label:"Integer"},{value:"Long",label:"Long"},{value:"Double",label:"Double"},{value:"Boolean",label:"Boolean"},{value:"Date",label:"Date"},{value:"LocalDate",label:"LocalDate"},{value:"LocalDateTime",label:"LocalDateTime"},{value:"Instant",label:"Instant"},{value:"ZonedDateTime",label:"ZonedDateTime"},{value:"OffsetDateTime",label:"OffsetDateTime"},{value:"BigDecimal",label:"BigDecimal"},{value:"BigInteger",label:"BigInteger"},{value:"Currency",label:"Currency"},{value:"ByteArray",label:"Byte[]"},{value:"CharacterArray",label:"Character[]"},{value:"Short",label:"Short"},{value:"PrimitiveInt",label:"int",boxed:"Integer"},{value:"PrimitiveLong",label:"long",boxed:"Long"},{value:"PrimitiveDouble",label:"double",boxed:"Double"},{value:"PrimitiveBoolean",label:"boolean",boxed:"Boolean"},{value:"PrimitiveShort",label:"short",boxed:"Short"},{value:"PrimitiveByteArray",label:"byte[]",boxed:"Byte[]"},{value:"PrimitiveCharacterArray",label:"char[]",boxed:"Character[]"},{value:io,label:"GroupCodeEnum"},{value:"CustomMoneyType",label:"Money"},{value:En,label:"CustomType"}],Sy=new Map(yi.map(e=>[e.value,e.label]));function gi(e){return Sy.get(e)??e}const xy={TINYINT:"Short",SMALLINT:"Short",INTEGER:"Integer",BIGINT:"Long",SERIAL:"Integer",BIG_SERIAL:"Long",FLOAT:"Double",REAL:"Double",DOUBLE:"Double",NUMERIC:"BigDecimal",DECIMAL:"BigDecimal",CHAR:"String",VARCHAR:"String",LONGVARCHAR:"String",NCHAR:"String",NVARCHAR:"String",LONGNVARCHAR:"String",CLOB:"String",NCLOB:"String",BIT:"Boolean",BOOLEAN:"Boolean",DATE:"LocalDate",TIMESTAMP:"LocalDateTime",TIMESTAMP_WITH_TIMEZONE:"OffsetDateTime",BINARY:"ByteArray",VARBINARY:"ByteArray",LONGVARBINARY:"ByteArray",BLOB:"ByteArray"};function $c(e){if(e)return xy[e.toUpperCase()]}const Ry={String:new Set(["VARCHAR","CHAR","LONGVARCHAR","CLOB","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","JSONB"]),CharacterArray:new Set(["CHAR","VARCHAR","LONGVARCHAR","CLOB"]),Integer:new Set(["INTEGER","SERIAL","SMALLINT","NUMERIC","DECIMAL"]),Long:new Set(["BIGINT","BIG_SERIAL","NUMERIC","DECIMAL"]),Short:new Set(["SMALLINT","TINYINT","NUMERIC","DECIMAL"]),Double:new Set(["DOUBLE","FLOAT","REAL","NUMERIC","DECIMAL"]),BigDecimal:new Set(["NUMERIC","DECIMAL"]),BigInteger:new Set(["NUMERIC","DECIMAL","BIGINT"]),Boolean:new Set(["BOOLEAN","BIT","CHAR","VARCHAR"]),Date:new Set(["DATE","TIME","TIMESTAMP","TIMESTAMP_WITH_TIMEZONE"]),LocalDate:new Set(["DATE"]),LocalDateTime:new Set(["TIMESTAMP"]),Instant:new Set(["TIMESTAMP","TIMESTAMP_WITH_TIMEZONE"]),ZonedDateTime:new Set(["TIMESTAMP_WITH_TIMEZONE","TIMESTAMP"]),OffsetDateTime:new Set(["TIMESTAMP_WITH_TIMEZONE","TIMESTAMP"]),ByteArray:new Set(["BINARY","VARBINARY","LONGVARBINARY","BLOB"]),Currency:new Set(["VARCHAR","CHAR"]),[io]:new Set(["VARCHAR","CHAR"])},Ay=new Map(yi.filter(e=>e.boxed).map(e=>[e.value,e.boxed]));function $y(e,n){const o=e==null?void 0:e.trim(),i=n==null?void 0:n.trim();if(!o||!i||!xc.includes(i))return;const a=Ay.get(o)??o,r=Ry[a];if(r)return r.has(i)}const Ty=new Set([io,"CustomMoneyType"]),Tc=yi.filter(e=>!Ty.has(e.value)).map(e=>e.value===En?{...e,label:"CustomType (사용자정의)"}:e);function Mc(e,n=[],o=[]){const i=n.map(l=>{var c,d;const s=((c=l.label)==null?void 0:c.ko)??((d=l.label)==null?void 0:d.en);return{value:l.type,label:s?`${l.type} (${s})`:l.type}}),a=o.map(l=>({value:l,label:l})),r=[...Tc,...i,...a];return e&&!r.some(l=>l.value===e)?[{value:e,label:gi(e)},...r]:r}function My(e){return e.attrType.startsWith("EMBED")&&e.dbAttrs.length>0}function da(e,n){var r;if(!e.embedded||!e.attrType.startsWith("EMBED"))return;const o=n.find(l=>l.modelId===e.embedded.associationRef);if(!o)return;const i=o.end2.entityRef===e.embedded.embeddableRef?o.end2:o.end1;if(i.multiplicity==="ZERO_OR_MORE_INSTANCES"||i.multiplicity==="ONE_OR_MORE_INSTANCES")return((r=i.jpa)==null?void 0:r.collectionType)??"LIST"}function nl(e,n,o,i,a){var r;if(n.attrType==="DIVIDER"||e==="LOGICAL")return"";if((e==="CLASS"||gn(n))&&n.attrType.startsWith("RELATION")&&i)return o?`${o==="SET"?"Set":"List"}<${i}>`:i;if(o&&n.attrType.startsWith("EMBED"))return`${o==="SET"?"Set":"List"}<${gi(n.type)}>`;if(My(n))return gi(n.type);if(e==="CLASS"){const l=Ac(n)??gi(n.type);return a?Sc(l,a):l}return Qr(((r=n.dbAttrs[0])==null?void 0:r.dataType)??"")}function ua(e,n,o,i,a="(논리명)"){switch(e){case"CLASS":return n;case"PHYSICAL":return i||n;case"LOGICAL":return o||a;default:return i?`${o||a} · ${i}`:o||a}}const Vc="(미지정)",Vy="(이름 없음)",ma=e=>e==null||String(e).trim()==="",fa=e=>ma(e)?Vy:String(e),Bc=e=>ma(e)?Vc:String(e);function Dc(e){switch(e){case"NO_INSTANCE_OR_ONE_INSTANCE":return"0..1";case"EXACTLY_ONE_INSTANCE":return"1";case"ZERO_OR_MORE_INSTANCES":return"0..*";case"ONE_OR_MORE_INSTANCES":return"1..*"}return Vc}function Lc(e,n){const o=e.length?`(${e.length}${e.scale!=null?`,${e.scale}`:""})`:"",i=ma(n)?Bc(e.physicalName):String(n),a=ma(e.dataType)?"":String(e.dataType).trim();return a?`${i} ${a}${o}`:i}function pa(e,n){const o=a=>(a==null?void 0:a.ko)??(a==null?void 0:a.en)??(a==null?void 0:a.ja)??(a==null?void 0:a.zh),i=(o(e)??o(n)??"").trim();return i?` «${i}»`:""}function Oc(e){return[e.unique?"UNIQUE":"",e.autoIncrement?"AUTO_INCREMENT":"",e.sharedColumnRef?"SHARED":""].filter(Boolean)}function Pc(e,n){var r,l,s;const o=new Map(e.entities.map(c=>[c.modelId,c.name])),i=new Map;for(const c of e.groups)for(const d of c.memberEntityRefs)i.set(d,c.packageName||(((r=c.name)==null?void 0:r.ko)??c.modelId));const a=[];for(const c of e.entities){const d=(l=c.table)!=null&&l.physicalName?` (${c.table.physicalName})`:"",u=i.get(c.modelId);a.push(`## ${fa(c.name)}${d} «${mi(c.stereotype)}»${u?` [${u}]`:""}${pa(kn(c))}`);const m=Do(zn(c,e.entities)),p=b=>{var _;return b.sharedColumnRef?(_=oo(b,m))==null?void 0:_.physicalName:void 0},f=[...c.attributes].sort((b,_)=>b.order-_.order);for(const b of f){if(b.attrType==="DIVIDER"){a.push(` ${"─".repeat(8)}${b.name?` ${b.name} ${"─".repeat(8)}`:""}`);continue}const _=b.dbAttrs.map((V,C)=>_n(b,V,C,c,e,n)),E=[b.identifier?"PK":"",b.notNull&&!ln(c.stereotype)?"NOT NULL":""].filter(Boolean),N=hi(b,Oo(e),c,e),y=Ac(b)??b.type,k=N.kind==="resolved"?Sc(y,N.entity):Bc(y),S=` - ${fa(b.name)}: ${k}`,T=V=>V.length?` {${V.join(", ")}}`:"";if(_.length>1){a.push(`${S}${T(E)}${pa(b.fieldLogicalName,b.description)}`),_.forEach((V,C)=>{const x=Cc(b,C,e,n);a.push(` · ${x?`${x} → `:""}${Lc(V,p(V))}${T(Oc(V))}${pa(V.logicalName)}`)});continue}const B=_[0],A=B?` → ${Lc(B,p(B))}`:"";a.push(`${S}${A}${T([...E,...B?Oc(B):[]])}${pa(Bo(b,B),b.description)}`)}const h=eo(c.attributes);for(const b of c.indexes??[]){const _=b.columns.map(E=>{var N,y;return`${((N=h.attributeOf(E.columnRef))==null?void 0:N.name)??((y=Wr(E.columnRef))==null?void 0:y.field)??E.columnRef}${E.descending?" DESC":""}`}).join(", ");a.push(` index ${fa(b.name)}${b.unique?" UNIQUE":""}: ${_}`)}const g=[...c.operations??[]].sort((b,_)=>b.order-_.order);for(const b of g){const _=b.visibility?` {${b.visibility}}`:"",E=(s=b.description)!=null&&s.ko?` — ${b.description.ko}`:"";a.push(` method ${fa(b.name)}()${_}${E}`)}a.push("")}if(e.associations.length){a.push("# 관계");for(const c of e.associations){const d=o.get(c.end1.entityRef)??c.end1.entityRef,u=o.get(c.end2.entityRef)??c.end2.entityRef,m=c.end2.composition||c.end1.composition?" (composition)":"";a.push(` ${d} ${Dc(c.end1.multiplicity)} —— ${Dc(c.end2.multiplicity)} ${u}${m}`)}}return a.join(`
|
|
1
|
+
(function(_e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@g1cloud/open-bluesea-core")):typeof define=="function"&&define.amd?define(["exports","vue","@g1cloud/open-bluesea-core"],t):(_e=typeof globalThis<"u"?globalThis:_e||self,t(_e.EntityModeler={},_e.Vue,_e.OpenBlueseaCore))})(this,(function(_e,t,ie){"use strict";var HL=Object.defineProperty;var jL=(_e,t,ie)=>t in _e?HL(_e,t,{enumerable:!0,configurable:!0,writable:!0,value:ie}):_e[t]=ie;var ct=(_e,t,ie)=>jL(_e,typeof t!="symbol"?t+"":t,ie);const yy={startX:40,startY:40,columnGap:280,rowGap:220,perRow:4,defaultSize:{width:220,height:140}};function gy(e,n){const o=e%n.perRow,i=Math.floor(e/n.perRow);return{location:{x:n.startX+o*n.columnGap,y:n.startY+i*n.rowGap},size:{...n.defaultSize}}}function bc(e,n,o={}){const i={...yy,...o},a=new Map(e.entities.map(b=>[b.modelId,b])),r=new Map(n.entityLayouts.map(b=>[b.entityRef,b])),l=new Map(n.associationLayouts.map(b=>[b.associationRef,b])),s=new Map;for(const b of e.groups)for(const _ of b.memberEntityRefs)s.set(_,b.modelId);const c=new Map;for(const b of n.groupLayouts)for(const _ of b.memberNoteRefs??[])c.set(_,b.groupRef);let d=0;const u=e.entities.map(b=>{const _=s.get(b.modelId),E=r.get(b.modelId);if(E){const y={location:{x:E.geo.location.x,y:E.geo.location.y},size:{width:E.geo.size.width,height:E.geo.size.height}};return{entity:b,geo:y,collapsed:E.collapsed??!1,locked:E.locked??!1,groupRef:_,style:E.style,attributeStyles:E.attributeStyles,operationStyles:E.operationStyles}}const N=gy(d++,i);return{entity:b,geo:N,collapsed:!1,locked:!1,groupRef:_}}),m=new Map(n.groupLayouts.map(b=>[b.groupRef,b])),p=e.groups.map(b=>{const _=m.get(b.modelId),E=_?{location:{x:_.geo.location.x,y:_.geo.location.y},size:{width:_.geo.size.width,height:_.geo.size.height}}:{location:{x:0,y:0},size:{width:400,height:300}};return{group:b,geo:E,style:_==null?void 0:_.style,locked:(_==null?void 0:_.locked)??!1}}),f=e.associations.map(b=>{const _=l.get(b.modelId);return{association:b,waypoints:(_==null?void 0:_.waypoints)??[],sourceColumnRef:_==null?void 0:_.sourceColumnRef,targetColumnRef:_==null?void 0:_.targetColumnRef}}),h=n.notes.map(b=>({note:{...b,geo:{location:{x:b.geo.location.x,y:b.geo.location.y},size:{width:b.geo.size.width,height:b.geo.size.height}}},groupRef:c.get(b.modelId)})),g=[];for(const b of n.notes)for(const _ of b.connections??[])a.has(_.targetRef)&&g.push({noteRef:b.modelId,targetRef:_.targetRef,waypoints:_.waypoints.map(E=>({x:E.x,y:E.y}))});return{entities:u,associations:f,groups:p,notes:h,noteConnections:g}}const by={cellWidth:260,cellHeight:200,pad:24,headerHeight:28,ungroupedCols:4};function _c(e,n,o={}){const i={...by,...o},a=new Map(n.groupLayouts.map(u=>[u.groupRef,u.geo])),r=[];let l=0;for(const u of e.groups){const m=a.get(u.modelId),p=m?m.location:{x:0,y:0},f=m?m.size.width:800;m&&(l=Math.max(l,m.location.y+m.size.height));const h=Math.max(1,Math.floor((f-i.pad*2)/i.cellWidth));u.memberEntityRefs.forEach((g,b)=>{const _=b%h,E=Math.floor(b/h);r.push({id:g,location:{x:p.x+i.pad+_*i.cellWidth,y:p.y+i.pad+i.headerHeight+E*i.cellHeight}})})}const s=new Set(e.groups.flatMap(u=>u.memberEntityRefs)),c=e.entities.filter(u=>!s.has(u.modelId)),d=l>0?l+40:i.pad;return c.forEach((u,m)=>{const p=m%i.ungroupedCols,f=Math.floor(m/i.ungroupedCols);r.push({id:u.modelId,location:{x:i.pad+p*i.cellWidth,y:d+f*i.cellHeight}})}),r}const kc={cols:5,boxWidth:200,gap:60,baseX:0,baseY:0,headerHeight:48,rowHeight:24,footerHeight:16,minHeight:120};function _y(e,n={}){const o={...kc,...n},i=o.headerHeight+Math.max(0,e)*o.rowHeight+o.footerHeight;return Math.max(o.minHeight,i)}function qr(e,n={}){const o={...kc,...n},i=Math.max(1,o.cols),a=new Array(i).fill(o.baseY);return e.map((r,l)=>{const s=l%i,c=_y(r.attributeCount,o),d=o.baseX+s*(o.boxWidth+o.gap),u=a[s];return a[s]=u+c+o.gap,{id:r.id,location:{x:d,y:u},size:{width:o.boxWidth,height:c}}})}function eo(e){const n=new Map,o=new Map;for(const i of e){o.set(i.modelId,i),i.dbAttrs.length===1&&n.set(i.modelId,i.dbAttrs[0]);for(const a of i.dbAttrs)n.set(a.modelId,a),o.set(a.modelId,i)}return{attributeOf:i=>o.get(i),columnOf:i=>n.get(i),canon:i=>{var a;return((a=n.get(i))==null?void 0:a.modelId)??i}}}function Ec(e,n){const o=e.attributeOf(n);if(!o)return n;const i=o.name||"(이름 없음)";if(o.dbAttrs.length<=1)return i;const a=e.columnOf(n);if(!a)return`${i}(컬럼 ${o.dbAttrs.length}개 중 미지정)`;const r=o.dbAttrs.findIndex(l=>l.modelId===a.modelId);return`${i}.${a.physicalName||`#${r+1}`}`}const ky={UNDEFINED:"Undefined",JPA_ENTITY:"Entity",JPA_EMBEDDABLE:"Embeddable",JPA_MULTI_LANGUAGE_ENTITY:"MultiLanguageEntity",SERIALIZED_TYPE:"Serialized"};function mi(e){return ky[e]??e}function gt(e){return e==="JPA_EMBEDDABLE"||e==="SERIALIZED_TYPE"}function ln(e){return e==="SERIALIZED_TYPE"}const sa="inherited:";function Nc(e,n){return`${sa}${e}:${n}`}function to(e){return e.startsWith(sa)}function Wr(e){if(!to(e))return null;const n=e.slice(sa.length),o=n.indexOf(":");if(o<0)return null;const i=n.slice(0,o),a=n.slice(o+1);return!i||!a?null:{baseClass:i,field:a}}function fi(e,n){var a;if(gt(e.stereotype))return[];if(n.some(r=>r.name===e.name))return[];const o=e.superClass||((a=n.find(r=>r.default))==null?void 0:a.name);if(!o)return[];const i=n.find(r=>r.name===o);return i?i.columns.map(r=>({modelId:Nc(i.name,r.field),baseClass:i.name,field:r.field,physicalName:r.physicalName,dataType:r.dataType,logicalName:r.logicalName,length:r.length,scale:r.scale})):[]}function ca(e){return e.attrType.startsWith("RELATION")&&e.dbAttrs.length>0}function gn(e){return e.attrType==="RELATION_OWN"&&e.dbAttrs.length>1}function Jr(e){const n=new Set;for(const o of e)o.end2.attributeRef&&n.add(o.end2.attributeRef),o.end1.attributeRef&&o.end1.navigable&&n.add(o.end1.attributeRef);return n}function Xr(e,n,o){var a;if(e.attrType!=="RELATION_OWN"||o.has(e.modelId))return!1;const i=(a=e.derivedFrom)==null?void 0:a.associationRef;return i?n.attributes.some(r=>{var l;return r.modelId!==e.modelId&&r.attrType==="RELATION_OWN"&&((l=r.derivedFrom)==null?void 0:l.associationRef)===i&&o.has(r.modelId)}):!1}function no(e,n,o,i,a=0){var d;if(!ca(e))return;const r=i.find(u=>u.end1.attributeRef===e.modelId||u.end2.attributeRef===e.modelId),l=n==null?void 0:n.modelId,s=r?o.find(u=>u.modelId===(r.end1.entityRef===l?r.end2.entityRef:r.end1.entityRef)):void 0,c=(d=e.derivedFrom)==null?void 0:d.sourceAttributeRef;if(c){const u=s==null?void 0:s.attributes.find(m=>m.modelId===c);if(u!=null&&u.dbAttrs[a])return u.dbAttrs[a];if(u)return Vo(s)[a];for(const m of o){const p=m.attributes.find(f=>f.modelId===c);if(p)return p.dbAttrs[a]??Vo(s)[a]}}if(s)return Vo(s)[a]}function Vo(e){return((e==null?void 0:e.attributes)??[]).filter(n=>n.identifier&&(n.attrType==="NORMAL"||n.attrType==="RELATION_OWN")).slice().sort((n,o)=>n.order-o.order).flatMap(n=>n.dbAttrs)}function Ey(e,n,o){var i,a,r,l;if(e.attrType==="EMBED_PREDEF"){const s=(a=(i=n==null?void 0:n.embeddableCatalog)==null?void 0:i.find(c=>c.type===e.type))==null?void 0:a.fields;return e.dbAttrs.map((c,d)=>{var u;return((u=s==null?void 0:s[d])==null?void 0:u.name)||void 0})}if(e.attrType==="EMBED_OWN"){const s=(r=e.embedded)==null?void 0:r.embeddableRef,c=s!=null?(l=n==null?void 0:n.entities)==null?void 0:l.find(u=>u.modelId===s):void 0,d=wc(c,n,o);return d.length!==e.dbAttrs.length?e.dbAttrs.map(()=>{}):d.map(u=>u.propertyPath||void 0)}}function bn(e,n){return wc(e,n,new Set)}function wc(e,n,o){if(e==null||o.has(e.modelId))return[];const i=new Set(o).add(e.modelId);return e.attributes.flatMap(a=>{const r=Ey(a,n,i),l=a.name??"";return a.dbAttrs.map((s,c)=>({col:s,propertyPath:l?r===void 0?a.dbAttrs.length>1?"":l:r[c]?`${l}.${r[c]}`:"":"",defaultPhysical:s.physicalName??"",...s.sharedColumnRef!=null?{defaultSharedRef:s.sharedColumnRef}:{},ownColumn:!!s.physicalName&&s.sharedColumnRef==null}))})}const Ic=e=>e==null||e.trim()==="";function vc(e,n,o,i,a){var r,l,s,c;if(e.attrType==="EMBED_PREDEF")return(l=(r=a==null?void 0:a.embeddableCatalog)==null?void 0:r.find(d=>d.type===e.type))==null?void 0:l.fields[n];if(e.attrType==="EMBED_OWN"){const d=(s=e.embedded)==null?void 0:s.embeddableRef;return d==null||(c=bn(i.entities.find(u=>u.modelId===d))[n])==null?void 0:c.col}if(e.attrType.startsWith("RELATION"))return no(e,o,i.entities,i.associations,n)}function _n(e,n,o,i,a,r){const l=vc(e,o,i,a,r);return l?{...n,physicalName:n.physicalName||l.physicalName||"",dataType:n.dataType||l.dataType||"",length:n.length??l.length,scale:n.scale??l.scale,logicalName:Pn(n.logicalName)?n.logicalName:l.logicalName,...n.sharedColumnRef==null&&!n.physicalName&&l.sharedColumnRef!=null&&(e.attrType==="EMBED_OWN"||e.attrType==="EMBED_PREDEF")?{sharedColumnRef:l.sharedColumnRef}:{}}:n}function Pn(e){return e!=null&&Object.values(e).some(n=>!Ic(n))}function kn(e){var n,o;return Pn((n=e.table)==null?void 0:n.logicalName)?(o=e.table)==null?void 0:o.logicalName:e.classLogicalName}function Bo(e,n){return Pn(n==null?void 0:n.logicalName)?n==null?void 0:n.logicalName:e.fieldLogicalName}function pi(e,n,o,i,a,r){var l;return Ic(n.physicalName)?((l=vc(e,o,i,a,r))==null?void 0:l.physicalName)??"":n.physicalName}function Cc(e,n,o,i){var a,r,l,s;if(e.attrType==="EMBED_PREDEF")return((l=(r=(a=i==null?void 0:i.embeddableCatalog)==null?void 0:a.find(c=>c.type===e.type))==null?void 0:r.fields[n])==null?void 0:l.name)||void 0;if(e.attrType==="EMBED_OWN"){const c=(s=e.embedded)==null?void 0:s.embeddableRef;if(c==null)return;const d=o.entities.find(m=>m.modelId===c);if(!d)return;let u=0;for(const m of d.attributes)for(let p=0;p<m.dbAttrs.length;p++){if(u===n)return m.name||void 0;u++}}}function Zr(e,n){if(e.stereotype!=="JPA_EMBEDDABLE")return[e];const o=n.filter(i=>i.modelId!==e.modelId&&i.attributes.some(a=>{var r;return a.attrType==="EMBED_OWN"&&((r=a.embedded)==null?void 0:r.embeddableRef)===e.modelId}));return[e,...o]}function zn(e,n){return Zr(e,n).flatMap(o=>o.attributes.flatMap(i=>i.dbAttrs))}function Do(e){const n=new Map;for(const o of e)n.set(o.modelId,o);return n}function oo(e,n){if(e.sharedColumnRef==null)return null;const o=n.get(e.sharedColumnRef);return o?{physicalName:o.physicalName,insertable:!1,updatable:!1}:null}function Lo(e,n){if(e.packageName)return{kind:"explicit",value:e.packageName};const o=n.groups.find(i=>{var a;return(a=i.memberEntityRefs)==null?void 0:a.includes(e.modelId)});return{kind:"group",value:(o==null?void 0:o.packageName)??""}}function Ny(e,n,o){const i=Lo(e,o),a=Lo(n,o);return i.kind===a.kind&&i.value!==a.value}function Oo(e){const n=new Map;for(const o of e.entities){if(o.stereotype!=="SERIALIZED_TYPE"||!o.name)continue;const i=n.get(o.name);i?i.push(o):n.set(o.name,[o])}return n}function Sc(e,n){var i,a;const o=(i=n==null?void 0:n.serialization)==null?void 0:i.collectionType;if(!o)return e;if(o==="MAP"){const r=(a=n==null?void 0:n.serialization)==null?void 0:a.mapKeyType;return`Map<${r&&r.trim()?r.slice(r.lastIndexOf(".")+1):"?"}, ${e}>`}return`${o==="SET"?"Set":"List"}<${e}>`}function hi(e,n,o,i){if(n.size===0)return{kind:"none"};const a=n.has(e.type)?e.type:e.customType&&n.has(e.customType)?e.customType:void 0;if(!a)return{kind:"none"};const r=n.get(a);if(r.length===1)return{kind:"resolved",entity:r[0]};if(o&&i){const l=Lo(o,i),s=r.filter(c=>{const d=Lo(c,i);return d.kind===l.kind&&d.value===l.value});if(s.length===1)return{kind:"resolved",entity:s[0]}}return{kind:"ambiguous",name:a,candidates:r}}const xc=["BIT","TINYINT","SMALLINT","INTEGER","BIGINT","FLOAT","REAL","DOUBLE","NUMERIC","DECIMAL","CHAR","VARCHAR","LONGVARCHAR","DATE","TIME","TIMESTAMP","BINARY","VARBINARY","LONGVARBINARY","NULL","OTHER","JAVA_OBJECT","DISTINCT","STRUCT","ARRAY","BLOB","CLOB","REF","DATALINK","BOOLEAN","ROWID","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","SQLXML","REF_CURSOR","TIME_WITH_TIMEZONE","TIMESTAMP_WITH_TIMEZONE","SERIAL","BIG_SERIAL","JSONB"],wy=new Set(["NULL","OTHER","JAVA_OBJECT","DISTINCT","STRUCT","ARRAY","REF","DATALINK","ROWID","REF_CURSOR","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","SQLXML","TIME_WITH_TIMEZONE","BIT","TINYINT","FLOAT"]),Iy=xc.filter(e=>!wy.has(e)),vy={TIMESTAMP_WITH_TIMEZONE:"TIMESTAMP WITH TIME ZONE",BIG_SERIAL:"BIGSERIAL",DOUBLE:"DOUBLE PRECISION"};function Qr(e){return vy[e]??e}const Cy=new Set(["CHAR","VARCHAR","NCHAR","NVARCHAR","BINARY","VARBINARY","NUMERIC","DECIMAL"]),el=new Set(["NUMERIC","DECIMAL"]);function Rc(e,n=Iy){const o=[...n];return e&&!o.includes(e)?[e,...o]:o}const En="CustomType";function Ac(e){var o;if(e.type!==En)return;const n=(o=e.customType)==null?void 0:o.trim();return n||void 0}const io="GroupCodeEnum",tl="String",yi=[{value:"String",label:"String"},{value:"Integer",label:"Integer"},{value:"Long",label:"Long"},{value:"Double",label:"Double"},{value:"Boolean",label:"Boolean"},{value:"Date",label:"Date"},{value:"LocalDate",label:"LocalDate"},{value:"LocalDateTime",label:"LocalDateTime"},{value:"Instant",label:"Instant"},{value:"ZonedDateTime",label:"ZonedDateTime"},{value:"OffsetDateTime",label:"OffsetDateTime"},{value:"BigDecimal",label:"BigDecimal"},{value:"BigInteger",label:"BigInteger"},{value:"Currency",label:"Currency"},{value:"ByteArray",label:"Byte[]"},{value:"CharacterArray",label:"Character[]"},{value:"Short",label:"Short"},{value:"PrimitiveInt",label:"int",boxed:"Integer"},{value:"PrimitiveLong",label:"long",boxed:"Long"},{value:"PrimitiveDouble",label:"double",boxed:"Double"},{value:"PrimitiveBoolean",label:"boolean",boxed:"Boolean"},{value:"PrimitiveShort",label:"short",boxed:"Short"},{value:"PrimitiveByteArray",label:"byte[]",boxed:"Byte[]"},{value:"PrimitiveCharacterArray",label:"char[]",boxed:"Character[]"},{value:io,label:"GroupCodeEnum"},{value:"CustomMoneyType",label:"Money"},{value:En,label:"CustomType"}],Sy=new Map(yi.map(e=>[e.value,e.label]));function gi(e){return Sy.get(e)??e}const xy={TINYINT:"Short",SMALLINT:"Short",INTEGER:"Integer",BIGINT:"Long",SERIAL:"Integer",BIG_SERIAL:"Long",FLOAT:"Double",REAL:"Double",DOUBLE:"Double",NUMERIC:"BigDecimal",DECIMAL:"BigDecimal",CHAR:"String",VARCHAR:"String",LONGVARCHAR:"String",NCHAR:"String",NVARCHAR:"String",LONGNVARCHAR:"String",CLOB:"String",NCLOB:"String",BIT:"Boolean",BOOLEAN:"Boolean",DATE:"LocalDate",TIMESTAMP:"LocalDateTime",TIMESTAMP_WITH_TIMEZONE:"OffsetDateTime",BINARY:"ByteArray",VARBINARY:"ByteArray",LONGVARBINARY:"ByteArray",BLOB:"ByteArray"};function $c(e){if(e)return xy[e.toUpperCase()]}const Ry={String:new Set(["VARCHAR","CHAR","LONGVARCHAR","CLOB","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","JSONB"]),CharacterArray:new Set(["CHAR","VARCHAR","LONGVARCHAR","CLOB"]),Integer:new Set(["INTEGER","SERIAL","SMALLINT","NUMERIC","DECIMAL"]),Long:new Set(["BIGINT","BIG_SERIAL","NUMERIC","DECIMAL"]),Short:new Set(["SMALLINT","TINYINT","NUMERIC","DECIMAL"]),Double:new Set(["DOUBLE","FLOAT","REAL","NUMERIC","DECIMAL"]),BigDecimal:new Set(["NUMERIC","DECIMAL"]),BigInteger:new Set(["NUMERIC","DECIMAL","BIGINT"]),Boolean:new Set(["BOOLEAN","BIT","CHAR","VARCHAR"]),Date:new Set(["DATE","TIME","TIMESTAMP","TIMESTAMP_WITH_TIMEZONE"]),LocalDate:new Set(["DATE"]),LocalDateTime:new Set(["TIMESTAMP"]),Instant:new Set(["TIMESTAMP","TIMESTAMP_WITH_TIMEZONE"]),ZonedDateTime:new Set(["TIMESTAMP_WITH_TIMEZONE","TIMESTAMP"]),OffsetDateTime:new Set(["TIMESTAMP_WITH_TIMEZONE","TIMESTAMP"]),ByteArray:new Set(["BINARY","VARBINARY","LONGVARBINARY","BLOB"]),Currency:new Set(["VARCHAR","CHAR"]),[io]:new Set(["VARCHAR","CHAR"])},Ay=new Map(yi.filter(e=>e.boxed).map(e=>[e.value,e.boxed]));function $y(e,n){const o=e==null?void 0:e.trim(),i=n==null?void 0:n.trim();if(!o||!i||!xc.includes(i))return;const a=Ay.get(o)??o,r=Ry[a];if(r)return r.has(i)}const Ty=new Set([io,"CustomMoneyType"]),Tc=yi.filter(e=>!Ty.has(e.value)).map(e=>e.value===En?{...e,label:"CustomType (사용자정의)"}:e);function Mc(e,n=[],o=[]){const i=n.map(l=>{var c,d;const s=((c=l.label)==null?void 0:c.ko)??((d=l.label)==null?void 0:d.en);return{value:l.type,label:s?`${l.type} (${s})`:l.type}}),a=o.map(l=>({value:l,label:l})),r=[...Tc,...i,...a];return e&&!r.some(l=>l.value===e)?[{value:e,label:gi(e)},...r]:r}function My(e){return e.attrType.startsWith("EMBED")&&e.dbAttrs.length>0}function da(e,n){var r;if(!e.embedded||!e.attrType.startsWith("EMBED"))return;const o=n.find(l=>l.modelId===e.embedded.associationRef);if(!o)return;const i=o.end2.entityRef===e.embedded.embeddableRef?o.end2:o.end1;if(i.multiplicity==="ZERO_OR_MORE_INSTANCES"||i.multiplicity==="ONE_OR_MORE_INSTANCES")return((r=i.jpa)==null?void 0:r.collectionType)??"LIST"}function nl(e,n,o,i,a){var r;if(n.attrType==="DIVIDER"||e==="LOGICAL")return"";if((e==="CLASS"||gn(n))&&n.attrType.startsWith("RELATION")&&i)return o?`${o==="SET"?"Set":"List"}<${i}>`:i;if(o&&n.attrType.startsWith("EMBED"))return`${o==="SET"?"Set":"List"}<${gi(n.type)}>`;if(My(n))return gi(n.type);if(e==="CLASS"){const l=Ac(n)??gi(n.type);return a?Sc(l,a):l}return Qr(((r=n.dbAttrs[0])==null?void 0:r.dataType)??"")}function ua(e,n,o,i,a="(논리명)"){switch(e){case"CLASS":return n;case"PHYSICAL":return i||n;case"LOGICAL":return o||a;default:return i?`${o||a} · ${i}`:o||a}}const Vc="(미지정)",Vy="(이름 없음)",ma=e=>e==null||String(e).trim()==="",fa=e=>ma(e)?Vy:String(e),Bc=e=>ma(e)?Vc:String(e);function Dc(e){switch(e){case"NO_INSTANCE_OR_ONE_INSTANCE":return"0..1";case"EXACTLY_ONE_INSTANCE":return"1";case"ZERO_OR_MORE_INSTANCES":return"0..*";case"ONE_OR_MORE_INSTANCES":return"1..*"}return Vc}function Lc(e,n){const o=e.length?`(${e.length}${e.scale!=null?`,${e.scale}`:""})`:"",i=ma(n)?Bc(e.physicalName):String(n),a=ma(e.dataType)?"":String(e.dataType).trim();return a?`${i} ${a}${o}`:i}function pa(e,n){const o=a=>(a==null?void 0:a.ko)??(a==null?void 0:a.en)??(a==null?void 0:a.ja)??(a==null?void 0:a.zh),i=(o(e)??o(n)??"").trim();return i?` «${i}»`:""}function Oc(e){return[e.unique?"UNIQUE":"",e.autoIncrement?"AUTO_INCREMENT":"",e.sharedColumnRef?"SHARED":""].filter(Boolean)}function Pc(e,n){var r,l,s;const o=new Map(e.entities.map(c=>[c.modelId,c.name])),i=new Map;for(const c of e.groups)for(const d of c.memberEntityRefs)i.set(d,c.packageName||(((r=c.name)==null?void 0:r.ko)??c.modelId));const a=[];for(const c of e.entities){const d=(l=c.table)!=null&&l.physicalName?` (${c.table.physicalName})`:"",u=i.get(c.modelId);a.push(`## ${fa(c.name)}${d} «${mi(c.stereotype)}»${u?` [${u}]`:""}${pa(kn(c))}`);const m=Do(zn(c,e.entities)),p=b=>{var _;return b.sharedColumnRef?(_=oo(b,m))==null?void 0:_.physicalName:void 0},f=[...c.attributes].sort((b,_)=>b.order-_.order);for(const b of f){if(b.attrType==="DIVIDER"){a.push(` ${"─".repeat(8)}${b.name?` ${b.name} ${"─".repeat(8)}`:""}`);continue}const _=b.dbAttrs.map((V,C)=>_n(b,V,C,c,e,n)),E=[b.identifier?"PK":"",b.notNull&&!ln(c.stereotype)?"NOT NULL":""].filter(Boolean),N=hi(b,Oo(e),c,e),y=Ac(b)??b.type,k=N.kind==="resolved"?Sc(y,N.entity):Bc(y),S=` - ${fa(b.name)}: ${k}`,T=V=>V.length?` {${V.join(", ")}}`:"";if(_.length>1){a.push(`${S}${T(E)}${pa(void 0,b.description)}`),_.forEach((V,C)=>{const x=Cc(b,C,e,n);a.push(` · ${x?`${x} → `:""}${Lc(V,p(V))}${T(Oc(V))}${pa(V.logicalName)}`)});continue}const B=_[0],A=B?` → ${Lc(B,p(B))}`:"";a.push(`${S}${A}${T([...E,...B?Oc(B):[]])}${pa(Bo(b,B),b.description)}`)}const h=eo(c.attributes);for(const b of c.indexes??[]){const _=b.columns.map(E=>{var N,y;return`${((N=h.attributeOf(E.columnRef))==null?void 0:N.name)??((y=Wr(E.columnRef))==null?void 0:y.field)??E.columnRef}${E.descending?" DESC":""}`}).join(", ");a.push(` index ${fa(b.name)}${b.unique?" UNIQUE":""}: ${_}`)}const g=[...c.operations??[]].sort((b,_)=>b.order-_.order);for(const b of g){const _=b.visibility?` {${b.visibility}}`:"",E=(s=b.description)!=null&&s.ko?` — ${b.description.ko}`:"";a.push(` method ${fa(b.name)}()${_}${E}`)}a.push("")}if(e.associations.length){a.push("# 관계");for(const c of e.associations){const d=o.get(c.end1.entityRef)??c.end1.entityRef,u=o.get(c.end2.entityRef)??c.end2.entityRef,m=c.end2.composition||c.end1.composition?" (composition)":"";a.push(` ${d} ${Dc(c.end1.multiplicity)} —— ${Dc(c.end2.multiplicity)} ${u}${m}`)}}return a.join(`
|
|
2
2
|
`).trim()}function Po(e){return e.referenceOnly===!0}function ol(e){const n=new Set;for(const o of e.entities)Po(o)&&n.add(o.modelId);return n}function zc(e){return e.entities.filter(n=>!Po(n))}function Fc(e,n=ol(e)){return n.size===0?e.associations:e.associations.filter(o=>!n.has(o.end1.entityRef)&&!n.has(o.end2.entityRef))}function il(e,n){return n?{...e,entities:e.entities.map(o=>o.referenceOnly?o:{...o,referenceOnly:!0})}:e}function By(e,n){return Po(e)||n===!0}const Dy=e=>e&&e[0].toLowerCase()+e.slice(1);function ha(e){return e==="ZERO_OR_MORE_INSTANCES"||e==="ONE_OR_MORE_INSTANCES"}function Uc(e){return e!=="EXACTLY_ONE_INSTANCE"&&e!=="ONE_OR_MORE_INSTANCES"}function ya(e){switch(e){case"NO_INSTANCE_OR_ONE_INSTANCE":return"0..1";case"EXACTLY_ONE_INSTANCE":return"1";case"ZERO_OR_MORE_INSTANCES":return"0..*";case"ONE_OR_MORE_INSTANCES":return"1..*"}}function Ly(e){return/[^aeiou]y$/.test(e)?`${e.slice(0,-1)}ies`:/(s|x|z|ch|sh)$/.test(e)?`${e}es`:`${e}s`}function ga(e,n){const o=Dy(e);return n?Ly(o):o}function ao(e,n){if(!n.has(e))return e;for(let o=2;;o++){const i=`${e}${o}`;if(!n.has(i))return i}}function Oy(e){return e==="CLASS"?"class":"er"}function al(e,n,o){const i=Py(e);return n==="class"?Gy(i):Hy(i,o)}function Py(e){const n=ol(e);return n.size===0?e:{...e,entities:zc(e),associations:Fc(e,n)}}function bi(e,n){return(e??"").trim().replace(/[^0-9A-Za-z_]/g,"_").replace(/^(\d)/,"_$1")||n}function rl(e){return(e??"").replace(/"/g,"'").replace(/\s+/g," ").trim()}function Hc(e,n){const o=new Set,i=new Map;return e.entities.forEach((a,r)=>{const l=bi(n(a),`Entity_${r+1}`);let s=l,c=2;for(;o.has(s);)s=`${l}_${c++}`;o.add(s),i.set(a.modelId,s)}),i}function zy(e){return e.attrType==="RELATION_OWN"||e.attrType==="RELATION_REF"||e.derivedFrom!=null}const jc=ya;function ll(e){return e!=null&&Kc[e]!=null}const Kc={NO_INSTANCE_OR_ONE_INSTANCE:"|o",EXACTLY_ONE_INSTANCE:"||",ZERO_OR_MORE_INSTANCES:"}o",ONE_OR_MORE_INSTANCES:"}|"};function Gc(e,n){const o={NO_INSTANCE_OR_ONE_INSTANCE:"o|",EXACTLY_ONE_INSTANCE:"||",ZERO_OR_MORE_INSTANCES:"o{",ONE_OR_MORE_INSTANCES:"|{"},i=ll(e)?e:"ZERO_OR_MORE_INSTANCES";return(n==="left"?Kc:o)[i]}function Fy(e,n,o,i){if(e.dbAttrs.length===0)return[];const a=[];return e.dbAttrs.forEach((r,l)=>{var p;const s=_n(e,r,l,n,o,i);if(s.sharedColumnRef!=null)return;const c=l===0?e.name:Cc(e,l,o,i),d=bi(s.dataType||e.type,"unknown"),u=bi(s.physicalName||c,"col"),m=s.length?`(${s.length}${s.scale!=null?`,${s.scale}`:""})`:"";a.push(Uy(d,u,e,s.unique===!0,m,(p=s.logicalName)==null?void 0:p.ko))}),a}function Uy(e,n,o,i,a,r){const l=[o.identifier?"PK":"",zy(o)?"FK":"",i?"UK":""].filter(Boolean).join(", "),s=rl([r,a].filter(Boolean).join(" ")),c=[` ${e} ${n}`];return l&&c.push(l),c.join(" ")+(s?` "${s}"`:"")}function Hy(e,n){const o=Hc(e,r=>{var l;return((l=r.table)==null?void 0:l.physicalName)||r.name}),i=["erDiagram"];for(const r of e.entities){const l=o.get(r.modelId),s=[...r.attributes].filter(c=>c.attrType!=="DIVIDER").sort((c,d)=>c.order-d.order);if(s.length===0){i.push(` ${l}`);continue}i.push(` ${l} {`);for(const c of s)for(const d of Fy(c,r,e,n))i.push(d);i.push(" }")}const a=[];for(const r of e.associations){const l=o.get(r.end1.entityRef),s=o.get(r.end2.entityRef);if(!l||!s)continue;const c=`${Gc(r.end1.multiplicity,"left")}--${Gc(r.end2.multiplicity,"right")}`,d=rl(r.description);i.push(` ${l} ${c} ${s} : "${d}"`),(!ll(r.end1.multiplicity)||!ll(r.end2.multiplicity))&&a.push(`${l} -- ${s}`)}if(a.length>0){i.push(`%% ⚠ 다중성 미지정 ${a.length}건 — 0..*(가장 약한 주장)로 표기함. 모델을 정정할 지점:`);for(const r of a)i.push(`%% ${r}`)}return i.join(`
|
|
3
3
|
`)}function jy(e){return e&&e!=="UNDEFINED"?mi(e):null}function Ky(e){return(e??"").trim().replace(/</g,"~").replace(/>/g,"~").replace(/[^0-9A-Za-z_~]/g,"")||"any"}function Gy(e){const n=Hc(e,i=>i.name),o=["classDiagram"];for(const i of e.entities){const a=n.get(i.modelId),r=[],l=jy(i.stereotype);l&&r.push(` <<${l}>>`);const s=[...i.attributes].filter(c=>c.attrType!=="DIVIDER").sort((c,d)=>c.order-d.order);for(const c of s)r.push(` +${Ky(c.type)} ${bi(c.name,"field")}`);for(const c of[...i.operations??[]].sort((d,u)=>d.order-u.order))r.push(` +${bi(c.name,"op")}()`);r.length===0?o.push(` class ${a}`):(o.push(` class ${a} {`),o.push(...r),o.push(" }"))}for(const i of e.associations){const a=n.get(i.end1.entityRef),r=n.get(i.end2.entityRef);if(!a||!r)continue;const l=Yy(i),s=rl(i.description),c=` ${a} "${jc(i.end1.multiplicity)}" ${l} "${jc(i.end2.multiplicity)}" ${r}`;o.push(s?`${c} : ${s}`:c)}return o.join(`
|
|
4
4
|
`)}function Yy(e){return e.end1.composition||e.end2.composition?"*--":e.end2.navigable||e.end1.navigable?"-->":"--"}function Pe(){return crypto.randomUUID()}const qy={"|o":"NO_INSTANCE_OR_ONE_INSTANCE","||":"EXACTLY_ONE_INSTANCE","}o":"ZERO_OR_MORE_INSTANCES","}|":"ONE_OR_MORE_INSTANCES"},Wy={"o|":"NO_INSTANCE_OR_ONE_INSTANCE","||":"EXACTLY_ONE_INSTANCE","o{":"ZERO_OR_MORE_INSTANCES","|{":"ONE_OR_MORE_INSTANCES"};function Jy(e,n,o){var a,r;if(!o.size)return;const i=new Map(e.map(l=>[l.modelId,l]));for(const l of e){const s=l.attributes.filter(d=>o.has(d.modelId));if(!s.length)continue;const c=n.filter(d=>d.end2.entityRef===l.modelId).map(d=>({assoc:d,parent:i.get(d.end1.entityRef)})).filter(d=>d.parent!=null);if(c.length)for(const d of s){const u=(a=d.dbAttrs[0])==null?void 0:a.physicalName,m=(f,h)=>f.attributes.find(g=>{var b;return g.identifier&&(h==null||((b=g.dbAttrs[0])==null?void 0:b.physicalName)===h)});let p=c.length===1?c[0]:void 0;if(!p){const f=c.filter(h=>m(h.parent,u)!=null);f.length===1&&(p=f[0])}p&&(d.attrType="RELATION_OWN",d.derivedFrom={associationRef:p.assoc.modelId,sourceAttributeRef:((r=m(p.parent,u)??m(p.parent))==null?void 0:r.modelId)??""},p.assoc.end2.attributeRef||(p.assoc.end2.attributeRef=d.modelId))}}}function Xy(e,n){let o=e,i;const a=o.match(/"([^"]*)"\s*$/);a&&(i=a[1],o=o.slice(0,a.index).trim());const r=o.split(/\s+/).filter(Boolean);if(r.length<2)return null;const l=r[0],s=r[1],c=new Set(r.slice(2).join(" ").split(",").map(h=>h.trim()).filter(Boolean));let d,u,m;if(i!=null){const h=i.match(/\((\d+)(?:,\s*(\d+))?\)\s*$/);if(h){d=Number(h[1]),h[2]!=null&&(u=Number(h[2]));const g=i.slice(0,h.index).trim();g&&(m=g)}else i.trim()&&(m=i.trim())}const p={modelId:Pe(),physicalName:s,dataType:l};return d!=null&&(p.length=d),u!=null&&(p.scale=u),c.has("UK")&&(p.unique=!0),m&&(p.logicalName={ko:m}),{attr:{modelId:Pe(),name:s,type:$c(l)??"",attrType:"NORMAL",identifier:c.has("PK"),notNull:c.has("PK"),order:n,dbAttrs:[p]},foreignKey:c.has("FK")}}function Yc(e){const n=e.split(`
|
|
@@ -24,7 +24,7 @@ ${u}
|
|
|
24
24
|
`)+`
|
|
25
25
|
`}}function tb(e,n,o,i){const a=[`${n}.${e}`,...i?[i]:[],nt.jpaRepository,nt.querydslExecutor].sort(),r=[`package ${n};`,""];for(const l of a)r.push(`import ${l};`);return r.push(""),r.push(`public interface ${e}Repository extends JpaRepository<${e}, ${o}>, QuerydslPredicateExecutor<${e}> {`),r.push("}"),{fileName:`${e}Repository.java`,source:r.join(`
|
|
26
26
|
`)+`
|
|
27
|
-
`}}const co="com.example",nb="command.domain";function Nn(e,n,o={}){const i=Lo(e,n);if(i.kind==="explicit")return i.value;const a=o.packageConfig;if(a!=null&&a.basePackage){const r=i.value?`.${i.value}`:"",l=a.layerSuffix??nb,s=l?`.${l}`:"";return`${a.basePackage}${r}${s}`}return n.packageName||""}const ob="CustomMoneyType",ib="Money";function ab(e){return!(e.type!==ob||e.attrType!=="NORMAL"||e.identifier||e.dbAttrs.length>1)}function rb(e){const n=e.dbAttrs[0]??{modelId:Pe(),physicalName:"",dataType:""},o={modelId:Pe(),physicalName:"",dataType:""},{customType:i,...a}=e;return{...a,type:ib,attrType:"EMBED_PREDEF",dbAttrs:[n,o]}}function lb(e){let n=!1;const o=e.entities.map(i=>{let a=!1;const r=i.attributes.map(l=>ab(l)?(a=!0,n=!0,rb(l)):l);return a?{...i,attributes:r}:i});return n?{...e,entities:o}:e}function sb(e,n){const o=new Map,i=[],a=new Map;for(const h of e.entities){const g=new Map,b=new Map,_=new Map,E=(N,y,k)=>{if(!N)return;o.get(N)||o.set(N,[{entityId:y,assignedId:N}]),i.push({id:N,entityId:y,sink:k}),k(N)};for(const N of h.attributes){E(N.modelId,h.modelId,y=>g.set(N,y));for(const y of N.dbAttrs)E(y.modelId,h.modelId,k=>b.set(y,k))}for(const N of h.indexes??[])E(N.modelId,h.modelId,y=>_.set(N,y));a.set(h,{attrs:g,cols:b,idx:_})}const r=new Set(o.keys()),l=new Map;for(const h of i){const g=(l.get(h.id)??0)+1;if(l.set(h.id,g),g===1)continue;const b=cb(h.id,g-1,r);r.add(b),o.get(h.id).push({entityId:h.entityId,assignedId:b}),h.sink(b)}const s=[...o.values()].reduce((h,g)=>h+Math.max(0,g.length-1),0);if(s===0)return{logical:e,layout:n,reissued:0};const c=(h,g)=>{var _;if(!g||!h)return g;const b=o.get(g);return!b||b.length<2?g:((_=b.find(E=>E.entityId===h))==null?void 0:_.assignedId)??g},d=new Map(e.associations.map(h=>[h.modelId,h])),u=(h,g)=>{const b=d.get(h);if(b)return b.end1.entityRef===g?b.end2.entityRef:b.end1.entityRef},m=e.entities.map(h=>{var N;const g=a.get(h),b=h.attributes.map(y=>{const k=g.attrs.get(y),S=y.dbAttrs.map(A=>{const V=g.cols.get(A);return V===A.modelId?A:{...A,modelId:V}});let T=y.derivedFrom;if(T){const A=u(T.associationRef,h.modelId),V=c(A,T.sourceAttributeRef);V!==T.sourceAttributeRef&&(T={...T,sourceAttributeRef:V})}return k!==y.modelId||T!==y.derivedFrom||S.some((A,V)=>A!==y.dbAttrs[V])?{...y,modelId:k,dbAttrs:S,derivedFrom:T}:y}),_=(N=h.indexes)==null?void 0:N.map(y=>{const k=g.idx.get(y),S=y.columns.map(B=>{const A=c(h.modelId,B.columnRef);return A===B.columnRef?B:{...B,columnRef:A}});return k!==y.modelId||S.some((B,A)=>B!==y.columns[A])?{...y,modelId:k,columns:S}:y});return b.some((y,k)=>y!==h.attributes[k])||_&&h.indexes&&_.some((y,k)=>y!==h.indexes[k])?{...h,attributes:b,..._?{indexes:_}:{}}:h}),p=e.associations.map(h=>{const g=c(h.end1.entityRef,h.end1.attributeRef),b=c(h.end2.entityRef,h.end2.attributeRef);return g===h.end1.attributeRef&&b===h.end2.attributeRef?h:{...h,end1:g===h.end1.attributeRef?h.end1:{...h.end1,attributeRef:g},end2:b===h.end2.attributeRef?h.end2:{...h.end2,attributeRef:b}}}),f=n.associationLayouts.map(h=>{const g=d.get(h.associationRef);if(!g)return h;const b=c(g.end1.entityRef,h.sourceColumnRef),_=c(g.end2.entityRef,h.targetColumnRef);return b===h.sourceColumnRef&&_===h.targetColumnRef?h:{...h,sourceColumnRef:b,targetColumnRef:_}});return{logical:{...e,entities:m,associations:p},layout:f.some((h,g)=>h!==n.associationLayouts[g])?{...n,associationLayouts:f}:n,reissued:s}}function cb(e,n,o){let i=n;for(;;){const a=`dup${i}:${e}`;if(!o.has(a))return a;i++}}const db="5.2.12";function jt(e){return e.reduce((n,o)=>Math.max(n,o.order),-1)+1}function Rl(e,n,o){const i=new Set(n),a=e.filter(s=>i.has(s.modelId)),r=e.filter(s=>!i.has(s.modelId)),l=Math.max(0,Math.min(o,r.length));return[...r.slice(0,l),...a,...r.slice(l)]}function Rd(e){return!!e.derivedFrom&&e.dbAttrs.length>0}function Ad(e){for(const n of e){const o=[...n.attributes].sort((s,c)=>s.order-c.order),i=o.filter(Rd);if(!i.length)continue;const a=o.filter(s=>!Rd(s));let r=0;a.forEach((s,c)=>{s.identifier&&!s.derivedFrom&&(r=c+1)});const l=[...a.slice(0,r),...i,...a.slice(r)];l.forEach((s,c)=>s.order=c),n.attributes=l}}function Ko(e){return JSON.parse(JSON.stringify(e))}function $d(e,n,o){var B;const i=o.idFactory??Pe,a=o.offset??{x:0,y:0},{logical:r,layout:l}=e,s=new Set(n);if(o.includeRelated){const A=new Set(n);for(const V of r.associations){const C=A.has(V.end1.entityRef),x=A.has(V.end2.entityRef);C!==x&&s.add(C?V.end2.entityRef:V.end1.entityRef)}}const c=r.entities.filter(A=>s.has(A.modelId)),d=new Set(c.map(A=>A.modelId)),u=r.associations.filter(A=>d.has(A.end1.entityRef)&&d.has(A.end2.entityRef)),m=new Set(u.map(A=>A.modelId)),p=new Map,f=A=>{let V=p.get(A);return V||(V=i(),p.set(A,V)),V};for(const A of c){f(A.modelId);for(const V of A.attributes){f(V.modelId);for(const C of V.dbAttrs)f(C.modelId)}for(const V of A.indexes??[])f(V.modelId);for(const V of A.operations??[])f(V.modelId)}for(const A of u)f(A.modelId);const h=A=>p.get(A),g=c.map(A=>{const V=Ko(A);V.modelId=h(A.modelId),V.attributes=V.attributes.map(C=>ub(C,h,m,d));for(const C of V.indexes??[])C.modelId=h(C.modelId),C.columns=C.columns.map(x=>to(x.columnRef)?x:{...x,columnRef:h(x.columnRef)}).filter(x=>x.columnRef!==void 0);for(const C of V.operations??[])C.modelId=h(C.modelId);return V});Ad(g);const b=u.map(A=>{const V=Ko(A);return V.modelId=h(A.modelId),V.end1=Td(V.end1,h),V.end2=Td(V.end2,h),V}),_=[];for(const A of r.groups){const V=A.memberEntityRefs.filter(x=>d.has(x));if(V.length===0)continue;const C=Ko(A);C.modelId=f(A.modelId),C.memberEntityRefs=V.map(x=>h(x)),_.push(C)}const E=o.collisionSuffix??"_imported",N=new Set(o.existing.entities.map(A=>A.name)),y=new Set(o.existing.entities.map(A=>{var V;return(V=A.table)==null?void 0:V.physicalName}).filter(A=>!!A));for(const A of g)N.has(A.name)&&(A.name=`${A.name}${E}`),(B=A.table)!=null&&B.physicalName&&y.has(A.table.physicalName)&&(A.table.physicalName=`${A.table.physicalName}${E}`);const k=[];for(const A of l.entityLayouts){const V=h(A.entityRef);if(!V)continue;const C=Ko(A);C.entityRef=V,C.geo={...C.geo,location:Al(C.geo.location,a)},C.attributeStyles&&(C.attributeStyles=xa(C.attributeStyles,h)),C.operationStyles&&(C.operationStyles=xa(C.operationStyles,h)),k.push(C)}const S=[];for(const A of l.associationLayouts){const V=h(A.associationRef);if(!V)continue;const C=Ko(A);C.associationRef=V,C.sourceColumnRef=A.sourceColumnRef?h(A.sourceColumnRef):void 0,C.targetColumnRef=A.targetColumnRef?h(A.targetColumnRef):void 0,C.waypoints=C.waypoints.map(x=>Al(x,a)),S.push(C)}const T=[];for(const A of l.groupLayouts){const V=h(A.groupRef);if(!V)continue;const C=Ko(A);C.groupRef=V,C.geo={...C.geo,location:Al(C.geo.location,a)},delete C.memberNoteRefs,T.push(C)}return{logical:{entities:g,associations:b,groups:_},layout:{entityLayouts:k,associationLayouts:S,groupLayouts:T},idMap:p}}function Al(e,n){return{x:e.x+n.x,y:e.y+n.y}}function ub(e,n,o,i){e.modelId=n(e.modelId);for(const a of e.dbAttrs)if(a.modelId=n(a.modelId),a.sharedColumnRef!==void 0){const r=n(a.sharedColumnRef);r?a.sharedColumnRef=r:delete a.sharedColumnRef}return e.derivedFrom&&(o.has(e.derivedFrom.associationRef)?e.derivedFrom={associationRef:n(e.derivedFrom.associationRef),sourceAttributeRef:n(e.derivedFrom.sourceAttributeRef)??e.derivedFrom.sourceAttributeRef}:(delete e.derivedFrom,(e.attrType==="RELATION_OWN"||e.attrType==="RELATION_REF")&&(e.attrType="NORMAL"))),e.embedded&&(i.has(e.embedded.embeddableRef)?e.embedded={associationRef:n(e.embedded.associationRef)??e.embedded.associationRef,embeddableRef:n(e.embedded.embeddableRef)}:(delete e.embedded,e.attrType.startsWith("EMBED")&&(e.attrType="NORMAL"))),e}function Td(e,n){return{...e,entityRef:n(e.entityRef),attributeRef:e.attributeRef?n(e.attributeRef):void 0}}function xa(e,n){const o={};for(const[i,a]of Object.entries(e)){const r=n(i);r&&(o[r]=a)}return o}function $l(e){if(!("rev"in e))return e;const{rev:n,...o}=e;return o}function uo(e,n){if(e===n||e==null&&n==null)return!0;if(e==null||n==null)return!1;if(Array.isArray(e)||Array.isArray(n))return!Array.isArray(e)||!Array.isArray(n)||e.length!==n.length?!1:e.every((o,i)=>uo(o,n[i]));if(typeof e=="object"&&typeof n=="object"){const o=new Set([...Object.keys(e),...Object.keys(n)]);for(const i of o)if(!uo(e[i],n[i]))return!1;return!0}return!1}function mo(e,n,o){const i={},a=new Set([...Object.keys(e),...Object.keys(n)]);for(const r of a)o.has(r)||uo(e[r],n[r])||(i[r]=n[r]===void 0?null:n[r]);return Object.keys(i).length?i:null}function fo(e,n,o){const i=new Map(e.map(d=>[o(d),d])),a=new Map(n.map(d=>[o(d),d])),r=[],l=[],s=[];for(const[d,u]of a){const m=i.get(d);m?s.push({cur:m,tgt:u}):r.push(u)}for(const[d,u]of i)a.has(d)||l.push(u);const c=(d,u)=>o(d)<o(u)?-1:o(d)>o(u)?1:0;return r.sort(c),l.sort(c),s.sort((d,u)=>c(d.tgt,u.tgt)),{added:r,removed:l,common:s}}function mb(e,n){const o=new Set(e),i=new Set(n),a=n.filter(l=>!o.has(l)).sort(),r=e.filter(l=>!i.has(l)).sort();return{added:a,removed:r}}const fb=new Set(["attributes","operations","indexes","rev"]),pb=new Set(["end1","end2","rev"]),hb=new Set(["memberEntityRefs","rev"]),Md=new Set(["modelId"]),yb=new Set(["modelId","columns"]),gb=new Set([]);function bb(e,n,o,i){const a=fo(n.attributes??[],o.attributes??[],s=>s.modelId);for(const s of a.removed)i.push({kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:s.modelId});for(const s of a.added)i.push({kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of a.common){const d=mo(s,c,Md);d&&i.push({kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:s.modelId,patch:d})}const r=fo(n.operations??[],o.operations??[],s=>s.modelId);for(const s of r.removed)i.push({kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:s.modelId});for(const s of r.added)i.push({kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of r.common){const d=mo(s,c,Md);d&&i.push({kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:s.modelId,patch:d})}const l=fo(n.indexes??[],o.indexes??[],s=>s.modelId);for(const s of l.removed)i.push({kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId});for(const s of l.added)i.push({kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of l.common){if(!uo(s.columns,c.columns)){i.push({kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId}),i.push({kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:c});continue}const d=mo(s,c,yb);d&&i.push({kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId,patch:d})}}function _b(e,n,o){const i=fo(e.entities??[],n.entities??[],l=>l.modelId);for(const l of i.removed)o.push({kind:"entity.remove",casUnit:"logical",entityRef:l.modelId});for(const l of i.added)o.push({kind:"entity.add",casUnit:"logical",entityRef:l.modelId,value:$l(l)});for(const{cur:l,tgt:s}of i.common){const c=mo(l,s,fb);c&&o.push({kind:"entity.update",casUnit:"logical",containerRef:l.modelId,entityRef:l.modelId,patch:c}),bb(l.modelId,l,s,o)}const a=fo(e.associations??[],n.associations??[],l=>l.modelId);for(const l of a.removed)o.push({kind:"association.remove",casUnit:"logical",associationRef:l.modelId});for(const l of a.added)o.push({kind:"association.add",casUnit:"logical",associationRef:l.modelId,value:$l(l)});for(const{cur:l,tgt:s}of a.common){const c=mo(l,s,pb);c&&o.push({kind:"association.update",casUnit:"logical",containerRef:l.modelId,associationRef:l.modelId,patch:c});for(const d of["end1","end2"]){const u=mo(l[d]??{},s[d]??{},gb);u&&o.push({kind:"associationEnd.update",casUnit:"logical",containerRef:l.modelId,associationRef:l.modelId,end:d,patch:u})}}const r=fo(e.groups??[],n.groups??[],l=>l.modelId);for(const l of r.removed)o.push({kind:"group.remove",casUnit:"logical",groupRef:l.modelId});for(const l of r.added)o.push({kind:"group.add",casUnit:"logical",groupRef:l.modelId,value:$l(l)});for(const{cur:l,tgt:s}of r.common){const c=mo(l,s,hb);c&&o.push({kind:"group.update",casUnit:"logical",containerRef:l.modelId,groupRef:l.modelId,patch:c});const d=mb(l.memberEntityRefs??[],s.memberEntityRefs??[]);for(const u of d.removed)o.push({kind:"group.removeMember",casUnit:"logical",containerRef:l.modelId,groupRef:l.modelId,entityRef:u});for(const u of d.added)o.push({kind:"group.addMember",casUnit:"logical",containerRef:l.modelId,groupRef:l.modelId,entityRef:u})}}function Ra(e,n,o,i,a,r,l){const s=fo(e,n,o);for(const c of s.removed)l.push({kind:a,casUnit:"layout",[r]:o(c),value:void 0});for(const c of s.added)l.push({kind:i,casUnit:"layout",[r]:o(c),value:c});for(const{cur:c,tgt:d}of s.common)uo(c,d)||(l.push({kind:a,casUnit:"layout",[r]:o(c),value:void 0}),l.push({kind:i,casUnit:"layout",[r]:o(d),value:d}))}function kb(e,n,o){Ra(e.entityLayouts??[],n.entityLayouts??[],i=>i.entityRef,"entityLayout.add","entityLayout.remove","entityRef",o),Ra(e.associationLayouts??[],n.associationLayouts??[],i=>i.associationRef,"associationLayout.add","associationLayout.remove","associationRef",o),Ra(e.groupLayouts??[],n.groupLayouts??[],i=>i.groupRef,"groupLayout.add","groupLayout.remove","groupRef",o),Ra(e.notes??[],n.notes??[],i=>i.modelId,"note.add","note.remove","noteRef",o)}function Eb(e,n){const o=[];return _b(e.logical,n.logical,o),kb(e.layout,n.layout,o),o}function Nb(e){if(e.groupRef!=null)return"group";if(e.associationRef!=null)return e.end!=null?"associationEnd":"association";if(e.entityRef!=null&&e.attributeRef!=null)return"attribute";if(e.entityRef!=null&&e.operationRef!=null)return"operation";if(e.entityRef!=null&&e.indexRef!=null)return"index";if(e.entityRef!=null)return"entity";throw new Error("projectFieldAudit: 대상 로케이터가 비었습니다(entityRef/associationRef/groupRef 중 하나 필요).")}const wb={entity:new Set(["attributes","operations","indexes","rev","modelId"]),association:new Set(["end1","end2","rev","modelId"]),group:new Set(["memberEntityRefs","rev","modelId"]),attribute:new Set(["modelId"]),operation:new Set(["modelId"]),index:new Set(["modelId"]),associationEnd:new Set([])};class Ib{constructor(n){ct(this,"out",[]);ct(this,"last",new Map);this.fieldFilter=n}set(n,o,i){if(this.fieldFilter!=null&&o!==this.fieldFilter)return;const a=this.last.get(o);this.out.push({...wi(n),field:o,value:i,...this.last.has(o)?{oldValue:a}:{}}),this.last.set(o,i)}remove(n,o){if(o!=null){if(this.fieldFilter!=null&&o!==this.fieldFilter)return;this.out.push({...wi(n),field:o,value:void 0,removed:!0,...this.last.has(o)?{oldValue:this.last.get(o)}:{}}),this.last.delete(o);return}const i=this.fieldFilter!=null?[this.fieldFilter]:[...this.last.keys()];for(const a of i){if(!this.last.has(a)){this.out.push({...wi(n),field:a,value:void 0,removed:!0});continue}this.out.push({...wi(n),field:a,value:void 0,removed:!0,oldValue:this.last.get(a)}),this.last.delete(a)}}member(n,o,i){const a="memberEntityRefs";this.fieldFilter!=null&&a!==this.fieldFilter||this.out.push({...wi(n),field:a,value:o,...i?{removed:!0}:{}})}result(){return this.out}}function wi(e){const n={seq:e.seq};return e.ts!==void 0&&(n.ts=e.ts),e.origin!==void 0&&(n.origin=e.origin),e.author!==void 0&&(n.author=e.author),e.kind!==void 0&&(n.kind=e.kind),e.restoredFromSeq!==void 0&&(n.restoredFromSeq=e.restoredFromSeq),n}function sn(e,n,o,i){if(o==null||typeof o!="object")return;const a=wb[i];for(const[r,l]of Object.entries(o))a.has(r)||e.set(n,r,l)}function po(e,n,o){if(!(o==null||typeof o!="object"))for(const[i,a]of Object.entries(o))e.set(n,i,a)}function Tl(e,n){if(Array.isArray(e))return e.find(o=>o.modelId===n)}function Un(e,n){var r,l,s,c,d,u,m,p;const o=Nb(n),i=new Ib(n.field),a=[...e].sort((f,h)=>f.seq-h.seq);for(const f of a)for(const h of f.ops)switch(o){case"entity":if(h.entityRef!==n.entityRef)break;h.kind==="entity.add"?sn(i,f,h.value,"entity"):h.kind==="entity.update"?po(i,f,h.patch):h.kind==="entity.remove"&&i.remove(f);break;case"attribute":if(h.entityRef!==n.entityRef)break;if(h.kind==="entity.add"){const g=Tl((r=h.value)==null?void 0:r.attributes,n.attributeRef);g&&sn(i,f,g,"attribute")}else h.kind==="attribute.add"&&((l=h.value)==null?void 0:l.modelId)===n.attributeRef?sn(i,f,h.value,"attribute"):h.kind==="attribute.update"&&h.attributeRef===n.attributeRef?po(i,f,h.patch):(h.kind==="attribute.remove"&&h.attributeRef===n.attributeRef||h.kind==="entity.remove")&&i.remove(f);break;case"operation":if(h.entityRef!==n.entityRef)break;if(h.kind==="entity.add"){const g=Tl((s=h.value)==null?void 0:s.operations,n.operationRef);g&&sn(i,f,g,"operation")}else h.kind==="operation.add"&&((c=h.value)==null?void 0:c.modelId)===n.operationRef?sn(i,f,h.value,"operation"):h.kind==="operation.update"&&h.operationRef===n.operationRef?po(i,f,h.patch):(h.kind==="operation.remove"&&h.operationRef===n.operationRef||h.kind==="entity.remove")&&i.remove(f);break;case"index":if(h.entityRef!==n.entityRef)break;if(h.kind==="entity.add"){const g=Tl((d=h.value)==null?void 0:d.indexes,n.indexRef);g&&sn(i,f,g,"index")}else h.kind==="index.add"&&((u=h.value)==null?void 0:u.modelId)===n.indexRef?sn(i,f,h.value,"index"):h.kind==="index.update"&&h.indexRef===n.indexRef?po(i,f,h.patch):(h.kind==="index.remove"&&h.indexRef===n.indexRef||h.kind==="entity.remove")&&i.remove(f);break;case"association":if(h.associationRef!==n.associationRef)break;h.kind==="association.add"?sn(i,f,h.value,"association"):h.kind==="association.update"?po(i,f,h.patch):h.kind==="association.remove"&&i.remove(f);break;case"associationEnd":if(h.associationRef!==n.associationRef)break;if(h.kind==="association.add"){const g=(m=h.value)==null?void 0:m[n.end];sn(i,f,g,"associationEnd")}else h.kind==="associationEnd.update"&&h.end===n.end?po(i,f,h.patch):h.kind==="association.remove"&&i.remove(f);break;case"group":if(h.groupRef!==n.groupRef)break;if(h.kind==="group.add"){sn(i,f,h.value,"group");const g=(p=h.value)==null?void 0:p.memberEntityRefs;if(Array.isArray(g))for(const b of g)i.member(f,b,!1)}else h.kind==="group.update"?po(i,f,h.patch):h.kind==="group.remove"?i.remove(f):h.kind==="group.addMember"&&h.entityRef!=null?i.member(f,h.entityRef,!1):h.kind==="group.removeMember"&&h.entityRef!=null&&i.member(f,h.entityRef,!0);break}return i.result()}const rt={subject:null,existence:null,fieldAudit:!1,note:"레이아웃 축(LWW) — 감사·복원 diff는 논리 축 전용(AA-5: layout/note는 의도적 범위 밖)"},vb={"entity.add":{subject:"entity",existence:"add",fieldAudit:!0},"entity.update":{subject:"entity",existence:null,fieldAudit:!0},"entity.remove":{subject:"entity",existence:"remove",fieldAudit:!0},"attribute.add":{subject:"attribute",existence:"add",fieldAudit:!0},"attribute.update":{subject:"attribute",existence:null,fieldAudit:!0},"attribute.remove":{subject:"attribute",existence:"remove",fieldAudit:!0},"operation.add":{subject:"operation",existence:"add",fieldAudit:!0},"operation.update":{subject:"operation",existence:null,fieldAudit:!0},"operation.remove":{subject:"operation",existence:"remove",fieldAudit:!0},"index.add":{subject:"index",existence:"add",fieldAudit:!0},"index.update":{subject:"index",existence:null,fieldAudit:!0},"index.remove":{subject:"index",existence:"remove",fieldAudit:!0},"attribute.reorder":{subject:null,existence:null,fieldAudit:!1,note:"과거 어휘(호스트 지원·lib 미방출). 컬렉션 순서 축이라 subject 단위 필드 변경으로 표현 안 됨"},"operation.reorder":{subject:null,existence:null,fieldAudit:!1,note:"과거 어휘(호스트 지원·lib 미방출). attribute.reorder와 동형"},"association.add":{subject:"association",existence:"add",fieldAudit:!0},"association.update":{subject:"association",existence:null,fieldAudit:!0},"association.remove":{subject:"association",existence:"remove",fieldAudit:!0},"associationEnd.update":{subject:"associationEnd",existence:null,fieldAudit:!0},"group.add":{subject:"group",existence:"add",fieldAudit:!0},"group.update":{subject:"group",existence:null,fieldAudit:!0},"group.remove":{subject:"group",existence:"remove",fieldAudit:!0},"group.addMember":{subject:"group",existence:null,fieldAudit:!0},"group.removeMember":{subject:"group",existence:null,fieldAudit:!0},"entityLayout.add":rt,"entityLayout.remove":rt,"entityLayout.move":rt,"entityLayout.resize":rt,"entityLayout.setCollapsed":rt,"entityLayout.setLocked":rt,"entityLayout.setStyle":rt,"entityLayout.setAttrStyle":rt,"entityLayout.setOpStyle":rt,"groupLayout.add":rt,"groupLayout.remove":rt,"groupLayout.move":rt,"groupLayout.resize":rt,"groupLayout.setLocked":rt,"groupLayout.setStyle":rt,"groupLayout.addNoteMember":rt,"groupLayout.removeNoteMember":rt,"associationLayout.add":rt,"associationLayout.remove":rt,"associationLayout.setWaypoints":rt,"note.add":rt,"note.remove":rt,"note.move":rt,"note.resize":rt,"note.setMemo":rt,"note.setStyle":rt,"noteConnection.add":rt,"noteConnection.remove":rt,"noteConnection.setWaypoints":rt},Gt=e=>typeof e=="string"?e:void 0,Cb=e=>{var n;return Gt((n=e.value)==null?void 0:n.modelId)};function Vd(e){return Gt(e.containerRef)??Gt(e.entityRef)}function Ml(e,n,o,i){var l;const a=(l=e.value)==null?void 0:l[n];if(!Array.isArray(a))return[];const r=[];for(const s of a){const c=Gt(s.modelId);c&&r.push({subject:{kind:o,ref:c,...i?{entityRef:i}:{}},existence:"add",inline:!0})}return r}function Vl(e){const n=vb[e.kind];if(!n||!n.subject)return[];const o=e,i=n.existence??void 0;switch(n.subject){case"entity":{const a=Gt(o.entityRef);if(!a)return[];const r={subject:{kind:"entity",ref:a},...i?{existence:i}:{}};return e.kind!=="entity.add"?[r]:[r,...Ml(o,"attributes","attribute",a),...Ml(o,"operations","operation",a),...Ml(o,"indexes","index",a)]}case"attribute":case"operation":case"index":{const a=n.subject,r=Vd(o),l={attribute:"attributeRef",operation:"operationRef",index:"indexRef"}[a],s=i==="add"?Cb(o):Gt(o[l]);return s?[{subject:{kind:a,ref:s,...r?{entityRef:r}:{}},...i?{existence:i}:{}}]:[]}case"association":case"associationEnd":{const a=Gt(o.associationRef);if(!a)return[];const r=o.end==="end1"||o.end==="end2"?o.end:void 0;return[{subject:{kind:n.subject,ref:a,...r?{end:r}:{}},...i?{existence:i}:{}}]}case"group":{const a=Gt(o.groupRef);return a?[{subject:{kind:"group",ref:a},...i?{existence:i}:{}}]:[]}}}function Sb(e){const n=e,o=e.kind;if(o.startsWith("entity.")){const i=Gt(n.entityRef);return i?{kind:"entity",ref:i}:null}if(o.startsWith("attribute.")||o.startsWith("operation.")||o.startsWith("index.")){const i=Vd(n);return i?{kind:"entity",ref:i}:null}if(o.startsWith("associationEnd.")||o.startsWith("association.")){const i=Gt(n.associationRef);return i?{kind:"association",ref:i}:null}if(o.startsWith("group.")){const i=Gt(n.groupRef);return i?{kind:"group",ref:i}:null}return null}function xb(e,n){const o=e;return o.entityRef===n||o.containerRef===n}function Rb(e,n){const o=new Set,i=new Set,a=new Set,r={attribute:o,operation:i,index:a};for(const l of e)for(const s of l.ops)for(const{subject:c}of Vl(s))c.kind==="entity"||c.entityRef!==n||c.kind in r&&r[c.kind].add(c.ref);return{attributes:o,operations:i,indexes:a}}function Aa(e,n){return e.map(o=>({...o,subject:n}))}function Bd(e,n){const o=e.filter(s=>s.ops.some(c=>xb(c,n))),{attributes:i,operations:a,indexes:r}=Rb(o,n),l=[...Aa(Un(o,{entityRef:n}),{kind:"entity",ref:n})];for(const s of i)l.push(...Aa(Un(o,{entityRef:n,attributeRef:s}),{kind:"attribute",ref:s}));for(const s of a)l.push(...Aa(Un(o,{entityRef:n,operationRef:s}),{kind:"operation",ref:s}));for(const s of r)l.push(...Aa(Un(o,{entityRef:n,indexRef:s}),{kind:"index",ref:s}));return l.map((s,c)=>({e:s,i:c})).sort((s,c)=>s.e.seq-c.e.seq||s.i-c.i).map(({e:s})=>s)}function Bl(e){return`${e.kind}:${e.ref}:${e.end??""}`}function Ab(e){const n=new Set;for(const o of e)for(const i of o.ops)for(const a of Vl(i))a.existence==="add"&&n.add(Bl(a.subject));return n}function $b(e){const n=new Set,o=new Set,i=new Set,a={entity:n,association:o,group:i};for(const r of e)for(const l of r.ops){const s=Sb(l);s&&a[s.kind].add(s.ref)}return{entities:n,associations:o,groups:i}}function Tb(e){const{entities:n,associations:o,groups:i}=$b(e),a=[];for(const r of n)for(const l of Bd(e,r))a.push({...l,subject:{...l.subject,entityRef:r}});for(const r of o){for(const l of Un(e,{associationRef:r}))a.push({...l,subject:{kind:"association",ref:r}});for(const l of["end1","end2"])for(const s of Un(e,{associationRef:r,end:l}))a.push({...s,subject:{kind:"associationEnd",ref:r,end:l}})}for(const r of i)for(const l of Un(e,{groupRef:r}))a.push({...l,subject:{kind:"group",ref:r}});return a}function Dl(e){const n=Tb(e),o=Ab(e),i=new Map;for(const l of n){const s=Bl(l.subject),c=i.get(s);(c===void 0||l.seq<c)&&i.set(s,l.seq)}const a=new Map;for(const l of n){let s=a.get(l.seq);s||(s={meta:l,subjects:new Map},a.set(l.seq,s));const c=Bl(l.subject);let d=s.subjects.get(c);if(!d){const u=l.removed?"remove":i.get(c)===l.seq&&o.has(c)?"add":"update";d={subject:l.subject,verb:u,fields:[]},s.subjects.set(c,d)}l.removed?d.verb="remove":d.fields.push({field:l.field,value:l.value,...l.oldValue!==void 0?{oldValue:l.oldValue}:{}})}const r=[];for(const[l,s]of a){const c=s.meta;r.push({seq:l,...c.ts!==void 0?{ts:c.ts}:{},...c.origin!==void 0?{origin:c.origin}:{},...c.author!==void 0?{author:c.author}:{},...c.kind!==void 0?{kind:c.kind}:{},...c.restoredFromSeq!==void 0?{restoredFromSeq:c.restoredFromSeq}:{},actions:[...s.subjects.values()]})}return r.sort((l,s)=>s.seq-l.seq)}function Dd(e){return`${e.kind}:${e.ref}:${e.end??""}`}function Mb(e,n,o){const i=[];for(const a of e)if(!(a.seq<=n||a.seq>o))for(const r of a.ops)for(const l of Vl(r)){if(!l.existence||l.inline)continue;const s=l.subject;Vb.has(s.kind)&&!s.entityRef||i.push({seq:a.seq,subject:s,verb:l.existence,fields:[]})}return i}const Vb=new Set(["attribute","operation","index"]);function Ll(e,n){const{fromSeq:o}=n,i=Dl(e);let a=o;for(const m of e)m.seq>a&&(a=m.seq);const r=n.toSeq??a,l=i.filter(m=>m.seq>o&&m.seq<=r).reverse(),s=new Map,c=m=>{const p=Dd(m.subject);let f=s.get(p);f||(f={subject:m.subject,evs:[]},s.set(p,f)),f.evs.push(m)};for(const m of l)for(const p of m.actions)c({seq:m.seq,subject:p.subject,verb:p.verb,fields:p.fields});for(const m of Mb(e,o,r)){const p=s.get(Dd(m.subject));p!=null&&p.evs.some(f=>f.seq===m.seq)||c(m)}const d=[],u=new Set;for(const m of s.values()){m.evs.sort((f,h)=>f.seq-h.seq);const p=m.evs[m.evs.length-1];m.subject.kind==="entity"&&p.verb==="remove"&&u.add(m.subject.ref)}for(const m of s.values()){const p=m.evs[0].verb==="add",f=m.evs[m.evs.length-1].verb==="remove";if(m.subject.kind!=="entity"&&m.subject.entityRef&&u.has(m.subject.entityRef)||p&&f)continue;const h=new Map;let g=null;for(const _ of m.evs){_.verb==="add"&&g!==null&&g!=="add"&&h.clear(),g=_.verb;for(const E of _.fields){const N=h.get(E.field);N?N.lastValue=E.value:h.set(E.field,{firstOld:E.oldValue,hasOld:E.oldValue!==void 0,lastValue:E.value})}}if(f){d.push({subject:m.subject,verb:"removed",fields:[]});continue}if(p){const _=[];for(const[E,N]of h)_.push({field:E,value:N.lastValue});d.push({subject:m.subject,verb:"added",fields:_});continue}const b=[];for(const[_,E]of h)E.hasOld&&uo(E.firstOld,E.lastValue)||b.push({field:_,value:E.lastValue,...E.hasOld?{oldValue:E.firstOld}:{}});b.length!==0&&d.push({subject:m.subject,verb:"modified",fields:b})}return{fromSeq:o,toSeq:r,entries:d}}function Ld(e){const n=new Map,o=i=>{let a=n.get(i);return a||(a={verb:"modified",changedAttributeIds:new Set,changedOperationIds:new Set},n.set(i,a)),a};for(const i of e.entries){const a=i.subject;if(a.kind==="entity"){if(i.verb==="removed")continue;o(a.ref).verb=i.verb}else if((a.kind==="attribute"||a.kind==="operation"||a.kind==="index")&&a.entityRef){const r=o(a.entityRef);i.verb!=="removed"&&(a.kind==="attribute"?r.changedAttributeIds.add(a.ref):a.kind==="operation"&&r.changedOperationIds.add(a.ref))}}return n}class Ol{constructor(n){ct(this,"undoStack",[]);ct(this,"redoStack",[]);ct(this,"savePoint",null);ct(this,"listeners",new Set);ct(this,"commandListeners",new Set);ct(this,"coalesceSealed",!1);this.state=n}execute(n){n.apply(this.state);const o=this.undoStack.at(-1),i=!this.coalesceSealed&&n.coalesceKey!=null&&!!o&&o.coalesceKey===n.coalesceKey;this.coalesceSealed=!1,i?(n.invert=o.invert,this.undoStack[this.undoStack.length-1]=n):this.undoStack.push(n),this.redoStack=[],this.emitCommand(n,"do",i),this.emit()}undo(){const n=this.undoStack.pop();n&&(n.invert(this.state),this.redoStack.push(n),this.emitCommand(n,"undo",!1),this.emit())}redo(){const n=this.redoStack.pop();n&&(n.apply(this.state),this.undoStack.push(n),this.emitCommand(n,"redo",!1),this.emit())}sealCoalesce(){this.coalesceSealed=!0}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}markSavePoint(){this.savePoint=this.undoStack.at(-1)??null,this.sealCoalesce(),this.emit()}get isDirty(){return(this.undoStack.at(-1)??null)!==this.savePoint}onChange(n){return this.listeners.add(n),()=>this.listeners.delete(n)}onCommand(n){return this.commandListeners.add(n),()=>this.commandListeners.delete(n)}emit(){for(const n of this.listeners)n()}emitCommand(n,o,i){for(const a of this.commandListeners)a(n,o,i)}}function Dt(e){const n={};for(const[o,i]of Object.entries(e))n[o]=i===void 0?null:i;return n}function Od(e,n){return e.logical.entities.findIndex(o=>o.modelId===n)}function wt(e,n){return e.layout.entityLayouts.findIndex(o=>o.entityRef===n)}function Yt(e,n){return e.layout.associationLayouts.find(o=>o.associationRef===n)}function dt(e,n){const o=e.logical.entities.find(i=>i.modelId===n);if(!o)throw new Error(`엔티티 없음: ${n}`);return o}function wn(e,n,o){var i,a;return(a=(i=e.layout.notes.find(r=>r.modelId===n))==null?void 0:i.connections)==null?void 0:a.find(r=>r.targetRef===o)}function $a(e,n,o){return{label:`엔티티 추가: ${e.name}`,apply(i){i.logical.entities.push(e),i.layout.entityLayouts.push({entityRef:e.modelId,geo:n,...o})},invert(i){const a=Od(i,e.modelId);a>=0&&i.logical.entities.splice(a,1);const r=wt(i,e.modelId);r>=0&&i.layout.entityLayouts.splice(r,1)},emitOps(){const i={kind:"entity.add",casUnit:"logical",entityRef:e.modelId,value:e},a={kind:"entityLayout.add",casUnit:"layout",entityRef:e.modelId,value:{entityRef:e.modelId,geo:n,...o},incidental:!0};return{forward:[i,a],invert:[{kind:"entityLayout.remove",casUnit:"layout",entityRef:e.modelId,incidental:!0},{kind:"entity.remove",casUnit:"logical",entityRef:e.modelId}]}}}}function Pd(e){let n=null;const o=i=>i.end1.entityRef===e||i.end2.entityRef===e;return{label:"엔티티 삭제",apply(i){const a=Od(i,e);if(a<0)throw new Error(`엔티티 없음: ${e}`);const r=wt(i,e),l=[];i.logical.associations.forEach((u,m)=>{o(u)&&l.push({item:u,index:m})});const s=new Set(l.map(u=>u.item.modelId)),c=[];i.layout.associationLayouts.forEach((u,m)=>{s.has(u.associationRef)&&c.push({item:u,index:m})});const d=[];i.logical.groups.forEach(u=>{const m=u.memberEntityRefs.indexOf(e);m>=0&&d.push({groupId:u.modelId,index:m})}),n={entity:{item:i.logical.entities[a],index:a},entityLayout:r>=0?{item:i.layout.entityLayouts[r],index:r}:void 0,assocs:l,assocLayouts:c,groupMemberships:d},[...c].sort((u,m)=>m.index-u.index).forEach(u=>i.layout.associationLayouts.splice(u.index,1)),[...l].sort((u,m)=>m.index-u.index).forEach(u=>i.logical.associations.splice(u.index,1));for(const u of d){const m=i.logical.groups.find(p=>p.modelId===u.groupId);m==null||m.memberEntityRefs.splice(u.index,1)}r>=0&&i.layout.entityLayouts.splice(r,1),i.logical.entities.splice(a,1)},invert(i){if(n){i.logical.entities.splice(n.entity.index,0,n.entity.item),n.entityLayout&&i.layout.entityLayouts.splice(n.entityLayout.index,0,n.entityLayout.item),[...n.assocs].sort((a,r)=>a.index-r.index).forEach(a=>i.logical.associations.splice(a.index,0,a.item)),[...n.assocLayouts].sort((a,r)=>a.index-r.index).forEach(a=>i.layout.associationLayouts.splice(a.index,0,a.item));for(const a of n.groupMemberships){const r=i.logical.groups.find(l=>l.modelId===a.groupId);r==null||r.memberEntityRefs.splice(a.index,0,e)}}},emitOps(){if(!n)return{forward:[],invert:[]};const i=[],a=[];for(const r of n.assocs)i.push({kind:"association.remove",casUnit:"logical",associationRef:r.item.modelId}),a.push({kind:"association.add",casUnit:"logical",associationRef:r.item.modelId,value:r.item});for(const r of n.assocLayouts)i.push({kind:"associationLayout.remove",casUnit:"layout",associationRef:r.item.associationRef,incidental:!0}),a.push({kind:"associationLayout.add",casUnit:"layout",associationRef:r.item.associationRef,value:r.item,incidental:!0});for(const r of n.groupMemberships)i.push({kind:"group.removeMember",casUnit:"logical",containerRef:r.groupId,groupRef:r.groupId,entityRef:e}),a.push({kind:"group.addMember",casUnit:"logical",containerRef:r.groupId,groupRef:r.groupId,entityRef:e});return n.entityLayout&&(i.push({kind:"entityLayout.remove",casUnit:"layout",entityRef:e,incidental:!0}),a.push({kind:"entityLayout.add",casUnit:"layout",entityRef:e,value:n.entityLayout.item,incidental:!0})),i.push({kind:"entity.remove",casUnit:"logical",entityRef:e}),a.push({kind:"entity.add",casUnit:"logical",entityRef:e,value:n.entity.item}),{forward:i,invert:a.reverse()}}}}function Pl(e,n){const o={};return{label:"엔티티 수정",apply(i){const a=dt(i,e);for(const r of Object.keys(n))o[r]=a[r];Object.assign(a,n)},invert(i){Object.assign(dt(i,e),o)},emitOps(){return{forward:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:Dt(n)}],invert:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:Dt(o)}]}}}}function zd(e,n){let o="";return{label:`엔티티 이름 변경: ${n}`,apply(i){const a=dt(i,e);o=a.name,a.name=n},invert(i){dt(i,e).name=o},emitOps(){return{forward:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{name:n}}],invert:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{name:o}}]}}}}function Go(e,n){let o=null;return{label:"엔티티 이동",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a].geo;o={...r.location},r.location={...n}},invert(i){const a=wt(i,e);a>=0&&o&&(i.layout.entityLayouts[a].geo.location=o)},emitOps(){const i=a=>({kind:"entityLayout.move",casUnit:"layout",entityRef:e,value:{location:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function Fd(e,n){let o=null;return{label:"엔티티 크기 변경",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a].geo;o={...r.size},r.size={...n}},invert(i){const a=wt(i,e);a>=0&&o&&(i.layout.entityLayouts[a].geo.size=o)},emitOps(){const i=a=>({kind:"entityLayout.resize",casUnit:"layout",entityRef:e,value:{size:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function Ii(e,n){const o={...(e==null?void 0:e.properties)??{}};return n?o.swatch=n:delete o.swatch,Object.keys(o).length?{properties:o}:void 0}function Ud(e,n){let o;return{label:"엔티티 색상 변경",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a];o=r.style,r.style=Ii(r.style,n)},invert(i){const a=wt(i,e);a>=0&&(i.layout.entityLayouts[a].style=o)},emitOps(i){const a=wt(i,e),r=a>=0?i.layout.entityLayouts[a].style:void 0,l=s=>({kind:"entityLayout.setStyle",casUnit:"layout",entityRef:e,value:{style:s}});return{forward:[l(r)],invert:[l(o)]}}}}function Hd(e,n){let o;return{label:n?"엔티티 접기":"엔티티 펼치기",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a];o=r.collapsed,r.collapsed=n},invert(i){const a=wt(i,e);a>=0&&(i.layout.entityLayouts[a].collapsed=o)},emitOps(){const i=a=>({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:e,value:{collapsed:a}});return{forward:[i(n)],invert:[i(o)]}}}}function jd(e,n){let o;return{label:n?"엔티티 잠금":"엔티티 잠금 해제",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a];o=r.locked,r.locked=n},invert(i){const a=wt(i,e);a>=0&&(i.layout.entityLayouts[a].locked=o)},emitOps(){const i=a=>({kind:"entityLayout.setLocked",casUnit:"layout",entityRef:e,value:{locked:a}});return{forward:[i(n)],invert:[i(o)]}}}}function zl(e){let n=[];return{label:e?"모두 접기":"모두 펼치기",apply(o){n=o.layout.entityLayouts.map(i=>i.collapsed);for(const i of o.layout.entityLayouts)i.collapsed=e},invert(o){o.layout.entityLayouts.forEach((i,a)=>{i.collapsed=n[a]})},emitOps(o){const i=[],a=[];return o.layout.entityLayouts.forEach((r,l)=>{i.push({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:r.entityRef,value:{collapsed:e}}),a.push({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:r.entityRef,value:{collapsed:n[l]}})}),{forward:i,invert:a}}}}function Ta(e,n,o){let i;return{label:"속성 색상 변경",apply(a){const r=wt(a,e);if(r<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=a.layout.entityLayouts[r];i=l.attributeStyles;const s={...l.attributeStyles},c=Ii(s[n],o);c?s[n]=c:delete s[n],l.attributeStyles=Object.keys(s).length?s:void 0},invert(a){const r=wt(a,e);r>=0&&(a.layout.entityLayouts[r].attributeStyles=i)},emitOps(a){const r=wt(a,e),l=r>=0?a.layout.entityLayouts[r].attributeStyles:void 0,s=c=>({kind:"entityLayout.setAttrStyle",casUnit:"layout",entityRef:e,value:{attributeStyles:c}});return{forward:[s(l)],invert:[s(i)]}}}}function Ma(e,n,o){return{label:"그룹 추가",apply(i){i.logical.groups.push(e),i.layout.groupLayouts.push({groupRef:e.modelId,geo:n,...o})},invert(i){const a=i.logical.groups.findIndex(l=>l.modelId===e.modelId);a>=0&&i.logical.groups.splice(a,1);const r=i.layout.groupLayouts.findIndex(l=>l.groupRef===e.modelId);r>=0&&i.layout.groupLayouts.splice(r,1)},emitOps(){const i={kind:"group.add",casUnit:"logical",groupRef:e.modelId,value:e},a={kind:"groupLayout.add",casUnit:"layout",groupRef:e.modelId,value:{groupRef:e.modelId,geo:n,...o},incidental:!0};return{forward:[i,a],invert:[{kind:"groupLayout.remove",casUnit:"layout",groupRef:e.modelId,incidental:!0},{kind:"group.remove",casUnit:"logical",groupRef:e.modelId}]}}}}function Kd(e,n){const o={},i=a=>{const r=a.logical.groups.find(l=>l.modelId===e);if(!r)throw new Error(`그룹 없음: ${e}`);return r};return{label:"그룹 수정",apply(a){const r=i(a);for(const l of Object.keys(n))o[l]=r[l];Object.assign(r,n)},invert(a){Object.assign(i(a),o)},emitOps(){return{forward:[{kind:"group.update",casUnit:"logical",containerRef:e,groupRef:e,patch:Dt(n)}],invert:[{kind:"group.update",casUnit:"logical",containerRef:e,groupRef:e,patch:Dt(o)}]}}}}function Gd(e){let n=null;return{label:"그룹 해제",apply(o){const i=o.logical.groups.findIndex(r=>r.modelId===e);if(i<0)throw new Error(`그룹 없음: ${e}`);const a=o.layout.groupLayouts.findIndex(r=>r.groupRef===e);n={group:{item:o.logical.groups[i],index:i},layout:a>=0?{item:o.layout.groupLayouts[a],index:a}:void 0},a>=0&&o.layout.groupLayouts.splice(a,1),o.logical.groups.splice(i,1)},invert(o){n&&(o.logical.groups.splice(n.group.index,0,n.group.item),n.layout&&o.layout.groupLayouts.splice(n.layout.index,0,n.layout.item))},emitOps(){if(!n)return{forward:[],invert:[]};const o=[],i=[];return n.layout&&(o.push({kind:"groupLayout.remove",casUnit:"layout",groupRef:e,incidental:!0}),i.push({kind:"groupLayout.add",casUnit:"layout",groupRef:e,value:n.layout.item,incidental:!0})),o.push({kind:"group.remove",casUnit:"logical",groupRef:e}),i.push({kind:"group.add",casUnit:"logical",groupRef:e,value:n.group.item}),{forward:o,invert:i.reverse()}}}}function Yd(e,n){let o=!1;const i=a=>a.logical.groups.find(r=>r.modelId===e);return{label:"그룹에 편입",apply(a){const r=i(a);r&&!r.memberEntityRefs.includes(n)&&(r.memberEntityRefs.push(n),o=!0)},invert(a){if(!o)return;const r=i(a),l=(r==null?void 0:r.memberEntityRefs.indexOf(n))??-1;l>=0&&r.memberEntityRefs.splice(l,1)},emitOps(){return o?{forward:[{kind:"group.addMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:n}],invert:[{kind:"group.removeMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:n}]}:{forward:[],invert:[]}}}}function Va(e,n){let o=-1;const i=a=>a.logical.groups.find(r=>r.modelId===e);return{label:"그룹에서 제외",apply(a){const r=i(a);o=(r==null?void 0:r.memberEntityRefs.indexOf(n))??-1,o>=0&&r.memberEntityRefs.splice(o,1)},invert(a){var r;o<0||(r=i(a))==null||r.memberEntityRefs.splice(o,0,n)},emitOps(){return o<0?{forward:[],invert:[]}:{forward:[{kind:"group.removeMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:n}],invert:[{kind:"group.addMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:n}]}}}}function qd(e,n){let o=null;return{label:"그룹 이동",apply(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o={...a.geo.location},a.geo.location={...n}},invert(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);a&&o&&(a.geo.location=o)},emitOps(){const i=a=>({kind:"groupLayout.move",casUnit:"layout",groupRef:e,value:{location:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function Wd(e,n){let o=null;return{label:"그룹 크기 변경",apply(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o={...a.geo.size},a.geo.size={...n}},invert(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);a&&o&&(a.geo.size=o)},emitOps(){const i=a=>({kind:"groupLayout.resize",casUnit:"layout",groupRef:e,value:{size:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function Jd(e,n){let o;return{label:"그룹 색상 변경",apply(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o=a.style,a.style=Ii(a.style,n)},invert(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);a&&(a.style=o)},emitOps(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e),r=l=>({kind:"groupLayout.setStyle",casUnit:"layout",groupRef:e,value:{style:l}});return{forward:[r(a==null?void 0:a.style)],invert:[r(o)]}}}}function Xd(e,n){let o;return{label:n?"그룹 잠금":"그룹 잠금 해제",apply(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o=a.locked,a.locked=n},invert(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);a&&(a.locked=o)},emitOps(){const i=a=>({kind:"groupLayout.setLocked",casUnit:"layout",groupRef:e,value:{locked:a}});return{forward:[i(n)],invert:[i(o)]}}}}function qt(e,n){return{label:`속성 추가: ${n.name}`,apply(o){dt(o,e).attributes.push(n)},invert(o){const i=dt(o,e),a=i.attributes.findIndex(r=>r.modelId===n.modelId);a>=0&&i.attributes.splice(a,1)},emitOps(){return{forward:[{kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:n}],invert:[{kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:n.modelId}]}}}}function Wt(e,n,o){const i={},a=r=>{const l=dt(r,e).attributes.find(s=>s.modelId===n);if(!l)throw new Error(`속성 없음: ${n}`);return l};return{label:"속성 수정",apply(r){const l=a(r);for(const s of Object.keys(o))i[s]=l[s];Object.assign(l,o)},invert(r){Object.assign(a(r),i)},emitOps(){return{forward:[{kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:n,patch:Dt(o)}],invert:[{kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:n,patch:Dt(i)}]}}}}function Zd(e,n){let o=null;return{label:"속성 삭제",apply(i){const a=dt(i,e),r=a.attributes.findIndex(l=>l.modelId===n);if(r<0)throw new Error(`속성 없음: ${n}`);o={item:a.attributes[r],index:r},a.attributes.splice(r,1)},invert(i){o&&dt(i,e).attributes.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:n}],invert:[{kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}function Qd(e,n,o,i,a){const r=new Map(a.map(c=>[c.modelId,c.order])),l=[],s=[];for(const c of i){const d=r.get(c.modelId);if(d===c.order)continue;const u=n==="attributeRef"?{attributeRef:c.modelId}:{operationRef:c.modelId};l.push({kind:e,casUnit:"logical",containerRef:o,entityRef:o,...u,patch:{order:c.order}}),s.push({kind:e,casUnit:"logical",containerRef:o,entityRef:o,...u,patch:{order:d??c.order}})}return{forward:l,invert:s}}function Fl(e,n,o){let i=null;return{label:"속성 재정렬",apply(a){const r=dt(a,e);i=r.attributes.map(s=>({...s}));const l=Rl([...r.attributes].sort((s,c)=>s.order-c.order),n,o);r.attributes.splice(0,r.attributes.length,...l),r.attributes.forEach((s,c)=>s.order=c)},invert(a){i&&dt(a,e).attributes.splice(0,1/0,...i)},emitOps(a){const r=dt(a,e).attributes;return Qd("attribute.update","attributeRef",e,r,i??[])}}}function eu(e,n){let o=!1;return{label:`메서드 추가: ${n.name}`,apply(i){const a=dt(i,e);a.operations||(a.operations=[],o=!0),a.operations.push(n)},invert(i){var l;const a=dt(i,e),r=((l=a.operations)==null?void 0:l.findIndex(s=>s.modelId===n.modelId))??-1;r>=0&&a.operations.splice(r,1),o&&a.operations&&a.operations.length===0&&(a.operations=void 0)},emitOps(){return{forward:[{kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:n}],invert:[{kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:n.modelId}]}}}}function tu(e,n,o){const i={},a=r=>{var s;const l=(s=dt(r,e).operations)==null?void 0:s.find(c=>c.modelId===n);if(!l)throw new Error(`메서드 없음: ${n}`);return l};return{label:"메서드 수정",apply(r){const l=a(r);for(const s of Object.keys(o))i[s]=l[s];Object.assign(l,o)},invert(r){Object.assign(a(r),i)},emitOps(){return{forward:[{kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:n,patch:Dt(o)}],invert:[{kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:n,patch:Dt(i)}]}}}}function nu(e,n){let o=null;return{label:"메서드 삭제",apply(i){var s;const a=dt(i,e),r=((s=a.operations)==null?void 0:s.findIndex(c=>c.modelId===n))??-1;if(r<0)throw new Error(`메서드 없음: ${n}`);const l=a.operations.length===1;o={item:a.operations[r],index:r,wasSole:l},a.operations.splice(r,1),l&&(a.operations=void 0)},invert(i){if(!o)return;const a=dt(i,e);a.operations||(a.operations=[]),a.operations.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:n}],invert:[{kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}function ou(e,n,o){let i=null;return{label:"메서드 재정렬",apply(a){const r=dt(a,e),l=r.operations??[];i=l.map(c=>({...c}));const s=Rl([...l].sort((c,d)=>c.order-d.order),n,o);l.splice(0,l.length,...s),l.forEach((c,d)=>c.order=d),r.operations=l},invert(a){if(!i)return;const r=dt(a,e);r.operations&&r.operations.splice(0,1/0,...i)},emitOps(a){const r=dt(a,e).operations??[];return Qd("operation.update","operationRef",e,r,i??[])}}}function iu(e,n,o){let i;return{label:"메서드 색상 변경",apply(a){const r=wt(a,e);if(r<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=a.layout.entityLayouts[r];i=l.operationStyles;const s={...l.operationStyles},c=Ii(s[n],o);c?s[n]=c:delete s[n],l.operationStyles=Object.keys(s).length?s:void 0},invert(a){const r=wt(a,e);r>=0&&(a.layout.entityLayouts[r].operationStyles=i)},emitOps(a){const r=wt(a,e),l=r>=0?a.layout.entityLayouts[r].operationStyles:void 0,s=c=>({kind:"entityLayout.setOpStyle",casUnit:"layout",entityRef:e,value:{operationStyles:c}});return{forward:[s(l)],invert:[s(i)]}}}}function Ba(e,n){return{label:"관계 추가",apply(o){o.logical.associations.push(e),o.layout.associationLayouts.push(n)},invert(o){const i=o.logical.associations.findIndex(r=>r.modelId===e.modelId);i>=0&&o.logical.associations.splice(i,1);const a=o.layout.associationLayouts.findIndex(r=>r.associationRef===e.modelId);a>=0&&o.layout.associationLayouts.splice(a,1)},emitOps(){const o={kind:"association.add",casUnit:"logical",associationRef:e.modelId,value:e},i={kind:"associationLayout.add",casUnit:"layout",associationRef:e.modelId,value:n,incidental:!0};return{forward:[o,i],invert:[{kind:"associationLayout.remove",casUnit:"layout",associationRef:e.modelId,incidental:!0},{kind:"association.remove",casUnit:"logical",associationRef:e.modelId}]}}}}function au(e){let n=null;return{label:"관계 삭제",apply(o){const i=o.logical.associations.findIndex(r=>r.modelId===e);if(i<0)throw new Error(`관계 없음: ${e}`);const a=o.layout.associationLayouts.findIndex(r=>r.associationRef===e);n={assoc:{item:o.logical.associations[i],index:i},layout:a>=0?{item:o.layout.associationLayouts[a],index:a}:void 0},a>=0&&o.layout.associationLayouts.splice(a,1),o.logical.associations.splice(i,1)},invert(o){n&&(o.logical.associations.splice(n.assoc.index,0,n.assoc.item),n.layout&&o.layout.associationLayouts.splice(n.layout.index,0,n.layout.item))},emitOps(){if(!n)return{forward:[],invert:[]};const o=[],i=[];return n.layout&&(o.push({kind:"associationLayout.remove",casUnit:"layout",associationRef:e,incidental:!0}),i.push({kind:"associationLayout.add",casUnit:"layout",associationRef:e,value:n.layout.item,incidental:!0})),o.push({kind:"association.remove",casUnit:"logical",associationRef:e}),i.push({kind:"association.add",casUnit:"logical",associationRef:e,value:n.assoc.item}),{forward:o,invert:i.reverse()}}}}function Da(e,n){const o={},i=a=>{const r=a.logical.associations.find(l=>l.modelId===e);if(!r)throw new Error(`관계 없음: ${e}`);return r};return{label:"관계 수정",apply(a){const r=i(a);for(const l of Object.keys(n))o[l]=r[l];Object.assign(r,n)},invert(a){Object.assign(i(a),o)},emitOps(){return{forward:[{kind:"association.update",casUnit:"logical",containerRef:e,associationRef:e,patch:Dt(n)}],invert:[{kind:"association.update",casUnit:"logical",containerRef:e,associationRef:e,patch:Dt(o)}]}}}}function Jt(e,n,o){const i={},a=r=>{const l=r.logical.associations.find(s=>s.modelId===e);if(!l)throw new Error(`관계 없음: ${e}`);return l[n]};return{label:"관계 수정",apply(r){const l=a(r);for(const s of Object.keys(o))i[s]=l[s];Object.assign(l,o)},invert(r){Object.assign(a(r),i)},emitOps(){return{forward:[{kind:"associationEnd.update",casUnit:"logical",containerRef:e,associationRef:e,end:n,patch:Dt(o)}],invert:[{kind:"associationEnd.update",casUnit:"logical",containerRef:e,associationRef:e,end:n,patch:Dt(i)}]}}}}function ru(e,n){return{label:"인덱스 추가",apply(o){const i=dt(o,e);(i.indexes??(i.indexes=[])).push(n)},invert(o){var r;const i=dt(o,e),a=((r=i.indexes)==null?void 0:r.findIndex(l=>l.modelId===n.modelId))??-1;a>=0&&i.indexes.splice(a,1)},emitOps(){return{forward:[{kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:n}],invert:[{kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:n.modelId}]}}}}function La(e,n,o){const i={},a=r=>{var s;const l=(s=dt(r,e).indexes)==null?void 0:s.find(c=>c.modelId===n);if(!l)throw new Error(`인덱스 없음: ${n}`);return l};return{label:"인덱스 수정",apply(r){const l=a(r);for(const s of Object.keys(o))i[s]=l[s];Object.assign(l,o)},invert(r){Object.assign(a(r),i)},emitOps(){return{forward:[{kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:n,patch:Dt(o)}],invert:[{kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:n,patch:Dt(i)}]}}}}function lu(e,n){let o=null;return{label:"인덱스 삭제",apply(i){var l;const a=dt(i,e),r=((l=a.indexes)==null?void 0:l.findIndex(s=>s.modelId===n))??-1;if(r<0)throw new Error(`인덱스 없음: ${n}`);o={item:a.indexes[r],index:r},a.indexes.splice(r,1)},invert(i){o&&dt(i,e).indexes.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:n}],invert:[{kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}const cn=(e,n)=>({kind:"associationLayout.setWaypoints",casUnit:"layout",associationRef:e,value:{waypoints:n}}),vi=(e,n)=>{var o;return((o=Yt(e,n))==null?void 0:o.waypoints.map(i=>({...i})))??[]};function su(e,n,o){let i=null;return{label:"waypoint 이동",coalesceKey:`waypoint:${e}`,apply(a){const r=Yt(a,e);if(!r||!r.waypoints[n])throw new Error(`waypoint 없음: ${e}[${n}]`);i={...r.waypoints[n]},r.waypoints.splice(n,1,{...o})},invert(a){const r=Yt(a,e);r&&i&&r.waypoints.splice(n,1,i)},emitOps(a){const r=vi(a,e),l=r.map((s,c)=>c===n&&i?{...i}:s);return{forward:[cn(e,r)],invert:[cn(e,l)]}}}}function cu(e,n){let o=null;return{label:"waypoint 제거",apply(i){const a=Yt(i,e);if(!a||!a.waypoints[n])throw new Error(`waypoint 없음: ${e}[${n}]`);o={...a.waypoints[n]},a.waypoints.splice(n,1)},invert(i){const a=Yt(i,e);a&&o&&a.waypoints.splice(n,0,o)},emitOps(i){const a=vi(i,e),r=a.slice();return o&&r.splice(n,0,{...o}),{forward:[cn(e,a)],invert:[cn(e,r)]}}}}function du(e,n,o){let i=null;return{label:"waypoint 평행이동",apply(a){const r=Yt(a,e);if(!r)throw new Error(`관계 레이아웃 없음: ${e}`);i=r.waypoints.map(l=>({...l})),r.waypoints=i.map(l=>({x:l.x+n,y:l.y+o}))},invert(a){const r=Yt(a,e);r&&i&&(r.waypoints=i)},emitOps(a){return{forward:[cn(e,vi(a,e))],invert:[cn(e,i??[])]}}}}function uu(e){let n=null;return{label:"꺾은선 풀기",apply(o){const i=Yt(o,e);if(!i)throw new Error(`관계 레이아웃 없음: ${e}`);n=i.waypoints.map(a=>({...a})),i.waypoints=[]},invert(o){const i=Yt(o,e);i&&n&&(i.waypoints=n)},emitOps(o){return{forward:[cn(e,vi(o,e))],invert:[cn(e,n??[])]}}}}function mu(e,n,o){return{label:"waypoint 추가",apply(i){const a=Yt(i,e);if(!a)throw new Error(`관계 레이아웃 없음: ${e}`);a.waypoints.splice(n,0,{...o})},invert(i){const a=Yt(i,e);a==null||a.waypoints.splice(n,1)},emitOps(i){const a=vi(i,e),r=a.slice();return r.splice(n,1),{forward:[cn(e,a)],invert:[cn(e,r)]}}}}function fu(e){return{label:"노트 추가",apply(n){n.layout.notes.push(e)},invert(n){const o=n.layout.notes.findIndex(i=>i.modelId===e.modelId);o>=0&&n.layout.notes.splice(o,1)},emitOps(){return{forward:[{kind:"note.add",casUnit:"layout",noteRef:e.modelId,value:e}],invert:[{kind:"note.remove",casUnit:"layout",noteRef:e.modelId}]}}}}function pu(e){let n=null;return{label:"노트 삭제",apply(o){const i=o.layout.notes.findIndex(a=>a.modelId===e);if(i<0)throw new Error(`노트 없음: ${e}`);n={item:o.layout.notes[i],index:i},o.layout.notes.splice(i,1)},invert(o){n&&o.layout.notes.splice(n.index,0,n.item)},emitOps(){return n?{forward:[{kind:"note.remove",casUnit:"layout",noteRef:e}],invert:[{kind:"note.add",casUnit:"layout",noteRef:e,value:n.item}]}:{forward:[],invert:[]}}}}function Ci(e,n){let o=null;return{label:"노트 이동",apply(i){const a=i.layout.notes.find(r=>r.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o={...a.geo.location},a.geo.location={...n}},invert(i){const a=i.layout.notes.find(r=>r.modelId===e);a&&o&&(a.geo.location=o)},emitOps(){const i=a=>({kind:"note.move",casUnit:"layout",noteRef:e,value:{location:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function hu(e,n){let o=null;return{label:"노트 크기 변경",apply(i){const a=i.layout.notes.find(r=>r.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o={...a.geo.size},a.geo.size={...n}},invert(i){const a=i.layout.notes.find(r=>r.modelId===e);a&&o&&(a.geo.size=o)},emitOps(){const i=a=>({kind:"note.resize",casUnit:"layout",noteRef:e,value:{size:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function yu(e,n){let o="";return{label:"노트 내용 변경",apply(i){const a=i.layout.notes.find(r=>r.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o=a.memo,a.memo=n},invert(i){const a=i.layout.notes.find(r=>r.modelId===e);a&&(a.memo=o)},emitOps(){const i=a=>({kind:"note.setMemo",casUnit:"layout",noteRef:e,value:{memo:a}});return{forward:[i(n)],invert:[i(o)]}}}}function gu(e,n){let o;return{label:"노트 색상 변경",apply(i){const a=i.layout.notes.find(r=>r.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o=a.style,a.style=Ii(a.style,n)},invert(i){const a=i.layout.notes.find(r=>r.modelId===e);a&&(a.style=o)},emitOps(i){const a=i.layout.notes.find(l=>l.modelId===e),r=l=>({kind:"note.setStyle",casUnit:"layout",noteRef:e,value:{style:l}});return{forward:[r(a==null?void 0:a.style)],invert:[r(o)]}}}}function bu(e,n){let o=!1,i=!1;const a=r=>r.layout.groupLayouts.find(l=>l.groupRef===e);return{label:"그룹에 노트 편입",apply(r){const l=a(r);l&&(l.memberNoteRefs||(l.memberNoteRefs=[],i=!0),!l.memberNoteRefs.includes(n)&&(l.memberNoteRefs.push(n),o=!0))},invert(r){if(!o)return;const l=a(r);if(!(l!=null&&l.memberNoteRefs))return;const s=l.memberNoteRefs.indexOf(n);s>=0&&l.memberNoteRefs.splice(s,1),i&&delete l.memberNoteRefs},emitOps(){return o?{forward:[{kind:"groupLayout.addNoteMember",casUnit:"layout",groupRef:e,noteRef:n}],invert:[{kind:"groupLayout.removeNoteMember",casUnit:"layout",groupRef:e,noteRef:n}]}:{forward:[],invert:[]}}}}function _u(e,n){let o=-1;const i=a=>a.layout.groupLayouts.find(r=>r.groupRef===e);return{label:"그룹에서 노트 제외",apply(a){var l;const r=i(a);o=((l=r==null?void 0:r.memberNoteRefs)==null?void 0:l.indexOf(n))??-1,o>=0&&r.memberNoteRefs.splice(o,1)},invert(a){if(o<0)return;const r=i(a);r&&(r.memberNoteRefs||(r.memberNoteRefs=[]),r.memberNoteRefs.splice(o,0,n))},emitOps(){return o<0?{forward:[],invert:[]}:{forward:[{kind:"groupLayout.removeNoteMember",casUnit:"layout",groupRef:e,noteRef:n}],invert:[{kind:"groupLayout.addNoteMember",casUnit:"layout",groupRef:e,noteRef:n}]}}}}const Hn=(e,n,o)=>({kind:"noteConnection.setWaypoints",casUnit:"layout",noteRef:e,targetRef:n,value:{waypoints:o}}),Oa=(e,n,o)=>{var i;return((i=wn(e,n,o))==null?void 0:i.waypoints.map(a=>({...a})))??[]};function ku(e,n){let o=!1,i=!1;return{label:"노트 연결 추가",apply(a){const r=a.layout.notes.find(l=>l.modelId===e);if(!r)throw new Error(`노트 없음: ${e}`);if(r.connections||(r.connections=[],i=!0),r.connections.some(l=>l.targetRef===n)){o=!1;return}r.connections.push({targetRef:n,waypoints:[]}),o=!0},invert(a){if(!o)return;const r=a.layout.notes.find(s=>s.modelId===e);if(!(r!=null&&r.connections))return;const l=r.connections.findIndex(s=>s.targetRef===n);l>=0&&r.connections.splice(l,1),i&&delete r.connections},emitOps(){return o?{forward:[{kind:"noteConnection.add",casUnit:"layout",noteRef:e,targetRef:n,value:{targetRef:n,waypoints:[]}}],invert:[{kind:"noteConnection.remove",casUnit:"layout",noteRef:e,targetRef:n}]}:{forward:[],invert:[]}}}}function Eu(e,n){let o=null;return{label:"노트 연결 삭제",apply(i){var l;const a=i.layout.notes.find(s=>s.modelId===e),r=((l=a==null?void 0:a.connections)==null?void 0:l.findIndex(s=>s.targetRef===n))??-1;if(!(a!=null&&a.connections)||r<0)throw new Error(`노트 연결 없음: ${e}→${n}`);o={item:a.connections[r],index:r},a.connections.splice(r,1)},invert(i){if(!o)return;const a=i.layout.notes.find(r=>r.modelId===e);a!=null&&a.connections&&a.connections.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"noteConnection.remove",casUnit:"layout",noteRef:e,targetRef:n}],invert:[{kind:"noteConnection.add",casUnit:"layout",noteRef:e,targetRef:n,value:o.item}]}:{forward:[],invert:[]}}}}function Nu(e,n,o,i){let a=null;return{label:"waypoint 이동",coalesceKey:`noteConnWaypoint:${e}:${n}`,apply(r){const l=wn(r,e,n);if(!l||!l.waypoints[o])throw new Error(`waypoint 없음: ${e}→${n}[${o}]`);a={...l.waypoints[o]},l.waypoints.splice(o,1,{...i})},invert(r){const l=wn(r,e,n);l&&a&&l.waypoints.splice(o,1,a)},emitOps(r){const l=Oa(r,e,n),s=l.map((c,d)=>d===o&&a?{...a}:c);return{forward:[Hn(e,n,l)],invert:[Hn(e,n,s)]}}}}function wu(e,n,o,i){return{label:"waypoint 추가",apply(a){const r=wn(a,e,n);if(!r)throw new Error(`노트 연결 없음: ${e}→${n}`);r.waypoints.splice(o,0,{...i})},invert(a){const r=wn(a,e,n);r==null||r.waypoints.splice(o,1)},emitOps(a){const r=Oa(a,e,n),l=r.slice();return l.splice(o,1),{forward:[Hn(e,n,r)],invert:[Hn(e,n,l)]}}}}function Iu(e,n,o){let i=null;return{label:"waypoint 제거",apply(a){const r=wn(a,e,n);if(!r||!r.waypoints[o])throw new Error(`waypoint 없음: ${e}→${n}[${o}]`);i={...r.waypoints[o]},r.waypoints.splice(o,1)},invert(a){const r=wn(a,e,n);r&&i&&r.waypoints.splice(o,0,i)},emitOps(a){const r=Oa(a,e,n),l=r.slice();return i&&l.splice(o,0,{...i}),{forward:[Hn(e,n,r)],invert:[Hn(e,n,l)]}}}}function vu(e,n){let o=null;return{label:"꺾은선 풀기",apply(i){const a=wn(i,e,n);if(!a)throw new Error(`노트 연결 없음: ${e}→${n}`);o=a.waypoints.map(r=>({...r})),a.waypoints=[]},invert(i){const a=wn(i,e,n);a&&o&&(a.waypoints=o)},emitOps(i){return{forward:[Hn(e,n,Oa(i,e,n))],invert:[Hn(e,n,o??[])]}}}}function at(e,n,o){return{label:e,coalesceKey:o,apply(i){for(const a of n)a.apply(i)},invert(i){for(let a=n.length-1;a>=0;a--)n[a].invert(i)},emitOps(i){const a=n.map(r=>{if(!r.emitOps)throw new Error(`emitOps 미구현 command가 composite에 포함됨: ${r.label}`);return r.emitOps(i)});return{forward:a.flatMap(r=>r.forward),invert:a.slice().reverse().flatMap(r=>r.invert)}}}}const Bb=Object.freeze(Object.defineProperty({__proto__:null,addAssociation:Ba,addAttribute:qt,addEntity:$a,addEntityToGroup:Yd,addGroup:Ma,addIndex:ru,addNote:fu,addNoteConnection:ku,addNoteConnectionWaypoint:wu,addNoteToGroup:bu,addOperation:eu,addWaypoint:mu,clearNoteConnectionWaypoints:vu,clearWaypoints:uu,composite:at,moveEntity:Go,moveGroup:qd,moveNote:Ci,moveNoteConnectionWaypoint:Nu,moveWaypoint:su,removeAssociation:au,removeAttribute:Zd,removeEntity:Pd,removeEntityFromGroup:Va,removeGroup:Gd,removeIndex:lu,removeNote:pu,removeNoteConnection:Eu,removeNoteConnectionWaypoint:Iu,removeNoteFromGroup:_u,removeOperation:nu,removeWaypoint:cu,renameEntity:zd,reorderAttributes:Fl,reorderOperations:ou,resizeEntity:Fd,resizeGroup:Wd,resizeNote:hu,setAllEntitiesCollapsed:zl,setAttributeSwatch:Ta,setEntityCollapsed:Hd,setEntityLocked:jd,setEntitySwatch:Ud,setGroupLocked:Xd,setGroupSwatch:Jd,setNoteMemo:yu,setNoteSwatch:gu,setOperationSwatch:iu,translateWaypoints:du,updateAssociation:Da,updateAssociationEnd:Jt,updateAttribute:Wt,updateEntity:Pl,updateGroup:Kd,updateIndex:La,updateOperation:tu},Symbol.toStringTag,{value:"Module"}));class Cu{constructor(){ct(this,"revs",new Map);ct(this,"layoutVersion",0);ct(this,"logicalVersion",0)}seed(n){this.revs.clear();for(const[o,i]of Object.entries(n.revs??{}))this.revs.set(o,i);this.layoutVersion=n.layoutVersion??0,this.logicalVersion=n.logicalVersion??0}rev(n){return this.revs.get(n)??0}setRev(n,o){this.revs.set(n,o)}deleteRev(n){this.revs.delete(n)}snapshot(){return{revs:Object.fromEntries(this.revs),layoutVersion:this.layoutVersion,logicalVersion:this.logicalVersion}}}const Db=[400,1200];function Lb(e){var o;if(typeof e!="object"||e===null)return;const n=e;for(const i of[n.statusCode,n.status,(o=n.response)==null?void 0:o.status])if(typeof i=="number"&&Number.isFinite(i))return i}function Ob(e){const n=Lb(e);return n==null||n===408||n===429?!0:n<400||n>=500}const Pb=e=>new Promise(n=>setTimeout(n,e));class Su{constructor(n){ct(this,"cache",new Cu);ct(this,"newClientOpId");ct(this,"debounceMs");ct(this,"retryDelaysMs");ct(this,"emissions",new WeakMap);ct(this,"open",null);ct(this,"debounceHandle",null);ct(this,"queue",[]);ct(this,"sending",!1);ct(this,"_frozen",!1);ct(this,"stack",null);ct(this,"settledWaiters",[]);this.opts=n,this.newClientOpId=n.newClientOpId??Pe,this.debounceMs=n.debounceMs??300,this.retryDelaysMs=n.retryDelaysMs??Db}seed(n){this.cache.seed(n)}attach(n){this.stack=n,n.sealCoalesce();const o=n.onCommand((i,a,r)=>this.handle(i,a,r));return()=>{o(),this.stack===n&&(this.stack=null)}}get frozen(){return this._frozen}get hasPending(){return this.open!==null||this.queue.length>0||this.sending}cacheSnapshot(){return this.cache.snapshot()}flush(){this.flushOpen(!0)}whenSettled(){return this.hasPending?new Promise(n=>this.settledWaiters.push(n)):Promise.resolve()}handle(n,o,i){var l,s,c;if(this._frozen)return;let a;if(o==="do"){const d=(l=n.emitOps)==null?void 0:l.call(n,this.opts.state);if(!d)throw new Error(`op-mode에서 emitOps 미구현 command 실행: ${n.label}`);a=d}else{const d=this.emissions.get(n);if(!d)throw new Error(`op-mode ${o} 대상 command의 emission 미기록: ${n.label}`);a=d}const r=o==="undo"?a.invert:a.forward;if(o==="do"&&i&&this.open&&this.open.coalesceKey===n.coalesceKey){this.open.fwd=r,this.emissions.set(n,{forward:r,invert:this.open.inv}),this.resetDebounce();return}if(i){const d=new Error(`op-mode coalesce 경계 불일치: 스택은 병합했으나 어댑터에 대응 그룹이 없음 (${n.label}, key=${String(n.coalesceKey)})`);console.error("[op-sync]",d),(c=(s=this.opts).onError)==null||c.call(s,d)}if(this.flushOpen(!1),o==="do"&&(this.emissions.set(n,a),n.coalesceKey!=null)){this.open={coalesceKey:n.coalesceKey,fwd:r,inv:a.invert},this.startDebounce();return}r.length&&this.enqueue(this.buildBatch(r))}flushOpen(n){var i;this.cancelDebounce();const o=this.open;this.open=null,o&&o.fwd.length&&this.enqueue(this.buildBatch(o.fwd)),n&&((i=this.stack)==null||i.sealCoalesce())}startDebounce(){this.cancelDebounce(),this.debounceHandle=setTimeout(()=>{this.debounceHandle=null,this.flushOpen(!0)},this.debounceMs)}resetDebounce(){this.startDebounce()}cancelDebounce(){this.debounceHandle!=null&&(clearTimeout(this.debounceHandle),this.debounceHandle=null)}buildBatch(n){const o={},i=new Set;let a=!1,r=!1;for(const l of n)if(l.casUnit==="logical")if(a=!0,l.containerRef)i.add(l.containerRef);else{const s=l.entityRef??l.associationRef??l.groupRef;s&&(l.kind.endsWith(".add")?this.cache.setRev(s,0):l.kind.endsWith(".remove")&&this.cache.deleteRev(s))}else l.incidental||(r=!0);if(i.size){o.revs={};for(const l of i){const s=this.cache.rev(l);o.revs[l]=s,this.cache.setRev(l,s+1)}}return r&&(o.layout=this.cache.layoutVersion,this.cache.layoutVersion=o.layout+1),a&&(this.cache.logicalVersion+=1),{diagramId:this.opts.diagramId,ops:n,cas:o,origin:this.opts.origin??"gui",clientOpId:this.newClientOpId()}}enqueue(n){this.queue.push(n),this.pump()}async pump(){var i,a;if(this.sending||this._frozen)return;const n=this.queue.shift();if(!n){this.notifySettled();return}this.sending=!0;let o;for(let r=0;;r++)try{o=await this.opts.transport(n);break}catch(l){const s=this.retryDelaysMs.length+1;console.error(`[op-sync] op 전송 실패 (시도 ${r+1}/${s}):`,l),(a=(i=this.opts).onError)==null||a.call(i,l);const c=this.retryDelaysMs[r];if(c==null||!Ob(l)){this.sending=!1,console.error("[op-sync] 전송 실패 확정 → 하드 프리즈(kind:missing)"),this.freeze({kind:"missing"});return}await Pb(c)}this.sending=!1,o.ok?(this.reconcile(o),this.pump()):this.freeze(o.conflict)}reconcile(n){if(!(this.queue.length>0)){for(const[o,i]of Object.entries(n.revs))this.cache.setRev(o,i);this.cache.layoutVersion=n.layoutVersion,this.cache.logicalVersion=n.logicalVersion}}freeze(n){var o,i;this._frozen=!0,this.queue.length=0,this.open=null,this.cancelDebounce(),(i=(o=this.opts).onFreeze)==null||i.call(o,n),this.notifySettled()}notifySettled(){if(this.hasPending)return;const n=this.settledWaiters;this.settledWaiters=[];for(const o of n)o()}}const xu=["entity.add","entity.update","entity.remove","attribute.add","attribute.update","attribute.remove","association.add","association.remove","association.update","associationEnd.update","index.add","index.update","index.remove","operation.add","operation.update","operation.remove","attribute.reorder","operation.reorder","group.add","group.update","group.remove","group.addMember","group.removeMember"],Ru=["NORMAL","RELATION_OWN","RELATION_REF","EMBED_OWN","EMBED_REF","EMBED_PREDEF","DIVIDER"];function Au(e,n){var r;if(!n.length||!((r=e.indexes)!=null&&r.length))return[];const o=new Set(n),i=new Set;for(const l of e.attributes)if(o.has(l.modelId)){i.add(l.modelId);for(const s of l.dbAttrs)i.add(s.modelId)}if(!i.size)return[];const a=[];for(const l of e.indexes){const s=l.columns.filter(c=>!i.has(c.columnRef));s.length!==l.columns.length&&a.push({indexRef:l.modelId,columns:s})}return a}function zb(e){return bn(e).length}function Ul(e,n){return new Set(e.associations.filter(o=>{const i=o.end1.entityRef===n?o.end1:o.end2;return i.multiplicity==="ZERO_OR_MORE_INSTANCES"||i.multiplicity==="ONE_OR_MORE_INSTANCES"}).map(o=>o.modelId))}function Fb(e,n,o,i){var r;const a=new Set;for(const l of e.attributes)l.dbAttrs.forEach((s,c)=>{if(s.sharedColumnRef!=null)return;const d=pi(l,s,c,e,i);d&&a.add(d)});for(let l=n.dbAttrs.length;l<o.length;l++){const s=(r=o[l])==null?void 0:r.physicalName;if(s&&a.has(s))return!0}return!1}function $u(e,n,o=Pe){const i=e.entities.find(c=>c.modelId===n);if(!i)return[];const a=zb(i);if(a===0)return[];const r=Ul(e,n),l=bn(i).map(c=>c.col),s=[];for(const c of e.entities){const d=c.attributes.filter(u=>{var m;return u.attrType==="EMBED_OWN"&&((m=u.embedded)==null?void 0:m.embeddableRef)===n&&!r.has(u.embedded.associationRef)&&a-u.dbAttrs.length>0});if(!(d.length>1))for(const u of d){const m=a-u.dbAttrs.length;Fb(c,u,l,e)||s.push({entityId:c.modelId,attributeId:u.modelId,dbAttrs:[...u.dbAttrs,...Array.from({length:m},()=>({modelId:o(),physicalName:"",dataType:""}))],added:m})}}return s}function Tu(e,n,o){var p;const i=e.entities.find(f=>f.modelId===n);if(!i)return[];const a=i.attributes;if(o.length!==a.length)return[];const r=new Map(a.map(f=>[f.modelId,f])),l=[];for(const f of o){const h=r.get(f);if(!h)return[];l.push(h)}const s=a.flatMap(f=>f.dbAttrs).map(f=>f.modelId),c=l.flatMap(f=>f.dbAttrs).map(f=>f.modelId);if(s.length!==c.length)return[];if(s.every((f,h)=>f===c[h]))return[];const d=new Map(s.map((f,h)=>[f,h])),u=Ul(e,n),m=[];for(const f of e.entities)for(const h of f.attributes){if(h.attrType!=="EMBED_OWN"||((p=h.embedded)==null?void 0:p.embeddableRef)!==n||u.has(h.embedded.associationRef)||h.dbAttrs.length!==s.length)continue;const g=c.map(_=>h.dbAttrs[d.get(_)]),b=g.reduce((_,E,N)=>E===h.dbAttrs[N]?_:_+1,0);b&&m.push({entityId:f.modelId,attributeId:h.modelId,dbAttrs:g,moved:b})}return m}function Mu(e,n,o){var p;const i=e.entities.find(f=>f.modelId===n);if(!i)return[];const a=new Set(o),r=i.attributes.filter(f=>!a.has(f.modelId));if(r.length===i.attributes.length)return[];const l=bn(i).map(f=>f.col),s=l.map(f=>f.modelId),c=new Set(bn({...i,attributes:r}).map(f=>f.col.modelId)),d=new Set;if(s.forEach((f,h)=>{c.has(f)&&d.add(h)}),d.size===s.length)return[];const u=Ul(e,n),m=[];for(const f of e.entities)for(const h of f.attributes){if(h.attrType!=="EMBED_OWN"||((p=h.embedded)==null?void 0:p.embeddableRef)!==n||u.has(h.embedded.associationRef)||h.dbAttrs.length!==s.length)continue;const g=h.dbAttrs.filter((E,N)=>d.has(N)),b=h.dbAttrs.filter((E,N)=>!d.has(N));h.dbAttrs.some((E,N)=>{if(d.has(N))return!1;const y=l[N],k=!!E.physicalName&&E.physicalName!==((y==null?void 0:y.physicalName)??""),S=E.sharedColumnRef!=null&&E.sharedColumnRef!==(y==null?void 0:y.sharedColumnRef);return k||S})||m.push({entityId:f.modelId,attributeId:h.modelId,dbAttrs:g,dropped:b})}return m}function Ub(e,n){const o=()=>e.entities.filter(r=>{var l;return((l=r.table)==null?void 0:l.physicalName)===n.ref}),i=()=>e.entities.filter(r=>r.name===n.ref);if(n.by==="modelId")return e.entities.filter(r=>r.modelId===n.ref);if(n.by==="physicalName")return o();if(n.by==="name")return i();const a=o();return a.length?a:i()}function Hb(e,n){const o=()=>e.attributes.filter(r=>r.name===n.ref),i=()=>e.attributes.filter(r=>r.dbAttrs.some(l=>l.physicalName===n.ref));if(n.by==="modelId")return e.attributes.filter(r=>r.modelId===n.ref);if(n.by==="name")return o();if(n.by==="physicalName")return i();const a=o();return a.length?a:i()}function Vu(e,n,o){return e.associations.filter(i=>{const a=[i.end1.entityRef,i.end2.entityRef];return a.includes(n)&&a.includes(o)})}function Rt(e,n){const o=Ub(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>Gb(i,e))}}function jb(e,n){const o=()=>e.groups.filter(r=>r.packageName===n.ref),i=()=>e.groups.filter(r=>Object.values(r.name??{}).some(l=>l===n.ref));if(n.by==="modelId")return e.groups.filter(r=>r.modelId===n.ref);if(n.by==="packageName")return o();if(n.by==="name")return i();const a=o();return a.length?a:i()}function Hl(e,n){const o=jb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>({modelId:i.modelId,name:i.name??null,packageName:i.packageName??null,members:i.memberEntityRefs.length}))}}function jl(e,n,o){return e.reason==="not-found"?{code:"group-not-found",opIndex:n,handle:o}:{code:"group-ambiguous",opIndex:n,handle:o,matches:e.matches}}const Kb=new Set(["name","description","packageName","excludeDDLGeneration"]);function Gb(e,n){var a;const o=Lo(e,n).value,i=n.associations.filter(r=>{var l,s;return((l=r.end1)==null?void 0:l.entityRef)===e.modelId||((s=r.end2)==null?void 0:s.entityRef)===e.modelId});return{modelId:e.modelId,stereotype:e.stereotype,packageName:o||null,table:((a=e.table)==null?void 0:a.physicalName)||null,attributes:e.attributes.length,references:i.length,referencedBy:[...new Set(i.map(r=>{var c,d,u,m;const l=((c=r.end1)==null?void 0:c.entityRef)===e.modelId?(d=r.end2)==null?void 0:d.entityRef:(u=r.end1)==null?void 0:u.entityRef,s=n.entities.find(p=>p.modelId===l);return(s==null?void 0:s.name)||((m=s==null?void 0:s.table)==null?void 0:m.physicalName)||String(l??"?")}))]}}function Bu(e,n){const o=Hb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Yb(e,n){const o=()=>e.attributes.flatMap(r=>r.dbAttrs).filter(r=>r.physicalName===n.ref),i=()=>e.attributes.filter(r=>r.name===n.ref).flatMap(r=>r.dbAttrs);if(n.by==="modelId")return e.attributes.flatMap(r=>r.dbAttrs).filter(r=>r.modelId===n.ref);if(n.by==="physicalName")return o();if(n.by==="name")return i();const a=o();return a.length?a:i()}function qb(e,n){const o=Yb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Du(e,n){const o=e.filter(i=>i.physicalName===n.ref);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Kl(e){return e.by!==void 0&&e.by!=="name"}function Wb(e,n){return(e.indexes??[]).filter(o=>o.name===n.ref)}function Jb(e,n){return(e.operations??[]).filter(o=>o.name===n.ref)}function Xb(e,n){const o=Wb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Lu(e,n){const o=Jb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Ou(e){return e.physicalName!=null||e.dataType!=null||e.length!=null||e.scale!=null||e.columnLogicalName!=null||e.unique!=null||e.updatable!=null}function Pu(e){return Ou(e)&&e.dataType==null}function zu(e,n,o){const i=Ou(e);return{modelId:o(),name:e.name,type:e.type,attrType:"NORMAL",identifier:e.identifier??!1,notNull:e.notNull??!1,order:n,...e.transient?{transient:!0}:{},...e.groupCode?{groupCode:e.groupCode}:{},...e.defaultValue!=null?{defaultValue:e.defaultValue}:{},...e.attributeGroup?{attributeGroup:e.attributeGroup}:{},...e.description?{description:e.description}:{},...e.collectionType?{collectionType:e.collectionType}:{},...e.fieldLogicalName?{fieldLogicalName:e.fieldLogicalName}:{},dbAttrs:i?[{modelId:o(),physicalName:e.physicalName??e.name,dataType:e.dataType??"",...e.length?{length:e.length}:{},...e.scale?{scale:e.scale}:{},...e.columnLogicalName?{logicalName:e.columnLogicalName}:{},...e.unique!=null?{unique:e.unique}:{},...e.updatable!=null?{updatable:e.updatable}:{}}]:[]}}function Fu(e,n,o,i,a,r,l,s,c){const d=c(),u=new Map((e.embeddableOverrides??[]).map(f=>[f.field,f])),m=[];let p=!1;for(const f of n.fields){const h=u.get(f.name);if(h!=null&&h.sharedColumnPhysicalName){const g={ref:h.sharedColumnPhysicalName,by:"physicalName"},b=Du(zn(i,a),g);if(!b.ok){s.push(b.reason==="not-found"?{code:"shared-column-target-not-found",opIndex:r,entity:l,handle:g}:{code:"shared-column-target-ambiguous",opIndex:r,entity:l,handle:g,matches:b.matches}),p=!0;continue}m.push({modelId:c(),physicalName:"",dataType:"",sharedColumnRef:b.value.modelId});continue}m.push({modelId:c(),physicalName:(h==null?void 0:h.physicalName)??"",dataType:"",...h!=null&&h.length?{length:h.length}:{},...h!=null&&h.scale?{scale:h.scale}:{},...(h==null?void 0:h.insertable)!=null?{insertable:h.insertable}:{},...(h==null?void 0:h.updatable)!=null?{updatable:h.updatable}:{}})}return p?null:{modelId:d,name:e.name,type:n.type,attrType:"EMBED_PREDEF",identifier:e.identifier??!1,notNull:e.notNull??!1,order:o,...e.defaultValue!=null?{defaultValue:e.defaultValue}:{},...e.attributeGroup?{attributeGroup:e.attributeGroup}:{},...e.description?{description:e.description}:{},dbAttrs:m}}const Zb=new Set(["name","type","customType","attrType","identifier","notNull","transient","naturalId","naturalIdMutable","description","attributeGroup","groupCode","defaultValue","personalInfoAttributeType","order","dbAttrs","derivedIdFieldName","collectionType","fieldLogicalName"]),Yo=e=>new Set(Object.keys(e)),Qb=Yo({name:!0,stereotype:!0,physicalName:!0,useVersion:!0,attributes:!0,indexes:!0,operations:!0,serialization:!0,classLogicalName:!0}),Uu=Yo({name:!0,type:!0,identifier:!0,notNull:!0,transient:!0,physicalName:!0,dataType:!0,length:!0,scale:!0,groupCode:!0,defaultValue:!0,attributeGroup:!0,description:!0,columnLogicalName:!0,unique:!0,updatable:!0,embeddableOverrides:!0,collectionType:!0,fieldLogicalName:!0}),Hu=Yo({name:!0,unique:!0,columns:!0,description:!0,parameters:!0}),ju=Yo({name:!0,visibility:!0,sourceCode:!0,description:!0,personalInfoAttributeType:!0}),e_=Yo({from:!0,to:!0,fromMultiplicity:!0,toMultiplicity:!0,identifying:!0,composition:!0}),t_=Yo({name:!0,packageName:!0,description:!0,excludeDDLGeneration:!0,members:!0});function In(e,n){return ho(e,n)}const n_=new Set(["name","stereotype","packageName","superClass","schema","description","abstractClass","hasPersonalInfo","declarationOfInterfaces","table","classLogicalName","referenceOnly","serialization"]),o_=new Set(["description","identifying"]),i_=new Set(["multiplicity","navigable","composition"]),a_=new Set(["name","unique","description","parameters"]),r_=new Set(["name","visibility","sourceCode","description","order","personalInfoAttributeType"]);function ho(e,n,o=[]){const i=[];for(const a of Object.keys(e)){if(a.includes(".")){o.some(r=>a.startsWith(r))||i.push(a);continue}n.has(a)||i.push(a)}return i}const Gl=new Set(["physicalName","logicalName","dataType","length","scale","unique","autoIncrement","updatable","insertable","sharedColumnRef","multiValue","multiValueSeparator","sequenceName"]),l_=new Set([...Gl].filter(e=>e!=="sharedColumnRef"));function s_(e,n,o,i){if(i||o.some(l=>!l_.has(l))||e.attrType!=="NORMAL"||e.dbAttrs.length!==1)return null;const a={...e.dbAttrs[0]};for(const l of o)a[l]=n[l];const r={};for(const[l,s]of Object.entries(n))Gl.has(l)||(r[l]=s);return{...r,dbAttrs:[a]}}function c_(e,n,o,i,a,r,l,s){const c=new Map(o.map(m=>[m.field,m])),d=[];let u=!1;return e.dbAttrs.forEach((m,p)=>{const f=n.fields[p],h=f?c.get(f.name):void 0;if(!h){d.push(m);return}if(h.sharedColumnPhysicalName){const b={ref:h.sharedColumnPhysicalName,by:"physicalName"},_=Du(zn(i,a),b);if(!_.ok){s.push(_.reason==="not-found"?{code:"shared-column-target-not-found",opIndex:r,entity:l,handle:b}:{code:"shared-column-target-ambiguous",opIndex:r,entity:l,handle:b,matches:_.matches}),u=!0;return}d.push({modelId:m.modelId,physicalName:"",dataType:"",sharedColumnRef:_.value.modelId});return}const g={...m};delete g.sharedColumnRef,d.push({...g,...h.physicalName!=null?{physicalName:h.physicalName}:{},...h.length!=null?{length:h.length}:{},...h.scale!=null?{scale:h.scale}:{},...h.insertable!=null?{insertable:h.insertable}:{},...h.updatable!=null?{updatable:h.updatable}:{}})}),u?null:d}function Ku(e,n,o){return{modelId:o(),name:e.name,order:n,...e.visibility?{visibility:e.visibility}:{},...e.sourceCode?{sourceCode:e.sourceCode}:{},...e.description?{description:e.description}:{},...e.personalInfoAttributeType?{personalInfoAttributeType:e.personalInfoAttributeType}:{}}}function Gu(e,n,o,i,a,r){const l=[];let s=!1;for(const c of n.columns){const d=qb(e,c.column);if(!d.ok){a.push(d.reason==="not-found"?{code:"column-not-found",opIndex:o,entity:i,handle:c.column}:{code:"column-ambiguous",opIndex:o,entity:i,handle:c.column,matches:d.matches}),s=!0;continue}l.push({columnRef:d.value.modelId,descending:c.descending??!1})}return s?null:{modelId:r(),name:n.name,unique:n.unique??!1,columns:l,...n.description?{description:n.description}:{},...n.parameters?{parameters:n.parameters}:{}}}function qo(e,n,o,i){const a=`${o}:${i}`;n.seen.has(a)||(n.seen.add(a),n.pairs.push({entityId:o,attributeId:i}),e.push({kind:"attribute.remove",casUnit:"logical",containerRef:o,entityRef:o,attributeRef:i}))}function d_(e,n,o,i){const a=new Map;for(const{entityId:r,attributeId:l}of o.pairs){if(i.has(r))continue;const s=a.get(r)??[];s.push(l),a.set(r,s)}for(const[r,l]of a){const s=n.entities.find(c=>c.modelId===r);if(s)for(const c of Au(s,l))e.push({kind:"index.update",casUnit:"logical",containerRef:r,entityRef:r,indexRef:c.indexRef,patch:{columns:c.columns}})}}function u_(e,n,o,i,a,r){const l=m=>{const p=new Map;for(const{entityId:f,item:h}of m){if(a.has(f))continue;const g=p.get(f)??[];g.push(h),p.set(f,g)}return p},s=l(o.pairs.map(m=>({entityId:m.entityId,item:m.attributeId}))),c=l(i.map(m=>({entityId:m.entityId,item:m.attribute}))),d=new Set(e.filter(m=>m.kind==="attribute.update").map(m=>m.attributeRef)),u=m=>{d.has(m.attributeId)||(d.add(m.attributeId),e.push({kind:"attribute.update",casUnit:"logical",containerRef:m.entityId,entityRef:m.entityId,attributeRef:m.attributeId,patch:{dbAttrs:m.dbAttrs}}))};for(const[m,p]of s)if(!c.has(m))for(const f of Mu(n,m,p))u(f);for(const[m,p]of c){if(s.has(m))continue;const f={...n,entities:n.entities.map(h=>h.modelId===m?{...h,attributes:[...h.attributes,...p]}:h)};for(const h of $u(f,m,r))u(h)}}function Yu(e,n){const o={...e},i=[];for(const[a,r]of Object.entries(n)){if(!a.includes(".")){o[a]=r===null?void 0:r;continue}const l=/^dbAttrs\.(\d+)\.(.+)$/.exec(a);l&&i.push([Number(l[1]),l[2],r])}if(i.length){const a=(o.dbAttrs??[]).map(r=>({...r}));for(const[r,l,s]of i)a[r]&&(a[r][l]=s===null?void 0:s);o.dbAttrs=a}return o}function qu(e,n,o,i,a,r,l){var p;for(const f of i.remove)qo(e,r,o,f);for(const f of i.update)e.push({kind:"attribute.update",casUnit:"logical",containerRef:o,entityRef:o,attributeRef:f.attributeId,patch:f.patch}),a.attrPatches.push({entityId:o,attributeId:f.attributeId,patch:f.patch});const s=((p=n.entities.find(f=>f.modelId===o))==null?void 0:p.attributes)??[],c=[];for(const f of i.add){const h={...f,order:l(o,s)};e.push({kind:"attribute.add",casUnit:"logical",containerRef:o,entityRef:o,value:h}),a.cascadeAdds.push({entityId:o,attribute:h}),c.push(h)}const d=new Set(i.remove),u=[...s.filter(f=>!d.has(f.modelId)),...c],m=new Set(u.map(f=>f.modelId));for(const f of n.associations){if(f.end2.entityRef!==o)continue;const h=f.end2.attributeRef;if(h&&m.has(h))continue;const b=u.filter(_=>{var E;return((E=_.derivedFrom)==null?void 0:E.associationRef)===f.modelId&&_.dbAttrs.length>0}).sort((_,E)=>_.order-E.order)[0];b&&(e.push({kind:"associationEnd.update",casUnit:"logical",containerRef:f.modelId,associationRef:f.modelId,end:"end2",patch:{attributeRef:b.modelId}}),a.endPatches.push({associationRef:f.modelId,end:"end2",patch:{attributeRef:b.modelId}}))}}function Yl(e,n,o,i,a,r,l){for(const{entityId:s,plan:c}of cd(n,o,i))qu(e,n,s,c,a,r,l)}function m_(e,n,o,i,a,r){const l=new Map;for(const{entityId:p,attributeId:f}of i.pairs)l.has(p)||l.set(p,new Set),l.get(p).add(f);const s=new Map;for(const p of r.attrPatches)s.has(p.entityId)||s.set(p.entityId,[]),s.get(p.entityId).push(p);const c=new Map;for(const{entityId:p,attribute:f}of[...a,...r.cascadeAdds])c.has(p)||c.set(p,[]),c.get(p).push(f);const d=p=>{const f={};for(const[h,g]of Object.entries(p))h.includes(".")||(f[h]=g===null?void 0:g);return f},u=e.entities.filter(p=>!n.has(p.modelId)).map(p=>{const f=l.get(p.modelId),h=s.get(p.modelId),g=c.get(p.modelId);if(!f&&!h&&!g)return p;let b=p.attributes;return f&&(b=b.filter(_=>!f.has(_.modelId))),h&&(b=b.map(_=>{const E=h.filter(N=>N.attributeId===_.modelId);return E.length?E.reduce((N,y)=>Yu(N,y.patch),_):_})),g&&(b=[...b,...g]),{...p,attributes:b}}),m=e.associations.filter(p=>!o.has(p.modelId)&&!n.has(p.end1.entityRef)&&!n.has(p.end2.entityRef)).map(p=>{let f=p;for(const h of r.assocPatches)h.associationRef===p.modelId&&(f={...f,...d(h.patch)});for(const h of r.endPatches)h.associationRef===p.modelId&&(f={...f,[h.end]:{...f[h.end],...d(h.patch)}});return f}).concat(r.addedAssociations);return{...e,entities:u,associations:m}}function f_(e,n,o,i,a,r,l,s,c){if(!l.identifierCascadeParents.size)return;const d=m_(n,o,i,a,r,l),u=new Map;for(const m of l.identifierCascadeParents)for(const[p,f]of pl(d,m,s)){const h=u.get(p);u.set(p,h?fl(h,f):f)}for(const[m,p]of u)qu(e,d,m,sd(p),l,a,c)}function p_(e,n,o={}){const i=o.mkId??Pe,a=o.embeddableCatalog??[],r=y=>a.find(k=>k.type===y),l=[],s=[],c=new Map,d=(y,k)=>{const S=c.get(y)??jt(k);return c.set(y,S+1),S},u=new Map,m=new Set,p=new Set,f={seen:new Set,pairs:[]},h=[],g={attrPatches:[],cascadeAdds:[],addedAssociations:[],assocPatches:[],endPatches:[],identifierCascadeParents:new Set},b=new Set,_=(y,k)=>`${y}\0${k}`,E=new Set;for(const y of n)y.kind==="entity.add"&&(E.add(y.spec.name),y.spec.physicalName&&E.add(y.spec.physicalName));const N=new Set;return n.forEach((y,k)=>{var S,T,B,A,V;switch(y.kind){case"entity.add":{{const R={ref:y.spec.name},D=In(y.spec,Qb);if(D.length){s.push({code:"entity-spec-unknown-key",opIndex:k,handle:R,keys:D});break}let j=!1;for(const U of y.spec.attributes??[]){const ne=In(U,Uu);ne.length&&(s.push({code:"attribute-spec-unknown-key",opIndex:k,entity:R,handle:{ref:U.name},keys:ne}),j=!0)}for(const U of y.spec.indexes??[]){const ne=In(U,Hu);ne.length&&(s.push({code:"index-spec-unknown-key",opIndex:k,entity:R,handle:{ref:U.name},keys:ne}),j=!0)}for(const U of y.spec.operations??[]){const ne=In(U,ju);ne.length&&(s.push({code:"operation-spec-unknown-key",opIndex:k,entity:R,handle:{ref:U.name},keys:ne}),j=!0)}if(j)break}const C=e.entities.filter(R=>R.name===y.spec.name).map(R=>R.modelId);if(C.length||N.has(y.spec.name)){s.push({code:"entity-name-conflict",opIndex:k,handle:{ref:y.spec.name},matches:C});break}N.add(y.spec.name);const x=i(),$={modelId:x,name:y.spec.name,stereotype:y.spec.stereotype??"JPA_ENTITY",attributes:[],...y.spec.useVersion?{jpaAttrs:{useVersion:!0}}:{},...y.spec.physicalName?{table:{physicalName:y.spec.physicalName}}:{},...y.spec.serialization?{serialization:y.spec.serialization}:{},...y.spec.classLogicalName?{classLogicalName:y.spec.classLogicalName}:{}},w={ref:y.spec.name};let I=!1;for(const[R,D]of(y.spec.attributes??[]).entries()){if(D.type==="GroupCodeEnum"&&!D.groupCode){s.push({code:"groupcode-required",opIndex:k,entity:w,handle:{ref:D.name}}),I=!0;continue}if(!r(D.type)&&!((S=D.embeddableOverrides)!=null&&S.length)&&Pu(D)){s.push({code:"datatype-required",opIndex:k,entity:w,handle:{ref:D.name}}),I=!0;continue}const j=r(D.type);if(j){const U=Fu(D,j,R,$,e.entities,k,w,s,i);U?$.attributes.push(U):I=!0}else(T=D.embeddableOverrides)!=null&&T.length?(s.push({code:"embeddable-type-unresolved",opIndex:k,entity:w,handle:{ref:D.name}}),I=!0):$.attributes.push(zu(D,R,i))}const v=(y.spec.operations??[]).map((R,D)=>Ku(R,D,i));v.length&&($.operations=v);const M=[];for(const R of y.spec.indexes??[]){const D=Gu($,R,k,w,s,i);D?M.push(D):I=!0}if(M.length&&($.indexes=M),I)break;l.push({kind:"entity.add",casUnit:"logical",entityRef:x,value:$});break}case"entity.update":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=ho(y.patch,n_,["jpaAttrs.","table.","serialization."]);if(x.length){s.push({code:"entity-patch-unknown-key",opIndex:k,entity:y.entity,keys:x});break}const $=y.patch.stereotype;if(typeof $=="string"&&$!==C.value.stereotype){const w=$==="JPA_EMBEDDABLE"||C.value.stereotype==="JPA_EMBEDDABLE",I=$==="SERIALIZED_TYPE"||C.value.stereotype==="SERIALIZED_TYPE";if(w||I){s.push({code:w?"stereotype-embeddable-transition-unsupported":"stereotype-serialized-transition-unsupported",opIndex:k,entity:y.entity,from:C.value.stereotype??"",to:$});break}}l.push({kind:"entity.update",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,patch:y.patch});break}case"entity.remove":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=C.value.modelId,$=e.associations.filter(M=>M.end1.entityRef===x||M.end2.entityRef===x),w=new Set($.map(M=>M.modelId));for(const M of $)m.has(M.modelId)||(m.add(M.modelId),l.push({kind:"association.remove",casUnit:"logical",associationRef:M.modelId}));for(const M of e.entities)if(M.modelId!==x)for(const R of M.attributes)R.embedded&&w.has(R.embedded.associationRef)&&qo(l,f,M.modelId,R.modelId);for(const M of $){if(M.end1.entityRef===x||!M.end1.attributeRef)continue;const R=e.entities.find(j=>j.modelId===M.end1.entityRef),D=R==null?void 0:R.attributes.find(j=>j.modelId===M.end1.attributeRef&&j.attrType==="RELATION_REF");D&&qo(l,f,R.modelId,D.modelId)}const I={...e,entities:e.entities.filter(M=>M.modelId!==x),associations:e.associations.filter(M=>!w.has(M.modelId))},v=new Set($.filter(M=>M.end1.entityRef===x&&M.end2.entityRef!==x).map(M=>M.end2.entityRef));Yl(l,I,[...v],i,g,f,d);for(const M of e.groups)M.memberEntityRefs.includes(x)&&(b.has(_(M.modelId,x))||(b.add(_(M.modelId,x)),l.push({kind:"group.removeMember",casUnit:"logical",containerRef:M.modelId,groupRef:M.modelId,entityRef:x})));p.add(x),l.push({kind:"entity.remove",casUnit:"logical",entityRef:x});break}case"attribute.add":{{const I=In(y.spec,Uu);if(I.length){s.push({code:"attribute-spec-unknown-key",opIndex:k,entity:y.entity,handle:{ref:y.spec.name},keys:I});break}}const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}if(y.spec.type==="GroupCodeEnum"&&!y.spec.groupCode){s.push({code:"groupcode-required",opIndex:k,entity:y.entity,handle:{ref:y.spec.name}});break}if(!r(y.spec.type)&&!((B=y.spec.embeddableOverrides)!=null&&B.length)&&Pu(y.spec)){s.push({code:"datatype-required",opIndex:k,entity:y.entity,handle:{ref:y.spec.name}});break}const x=d(C.value.modelId,C.value.attributes),$=r(y.spec.type);let w;if($)w=Fu(y.spec,$,x,C.value,e.entities,k,y.entity,s,i);else if((A=y.spec.embeddableOverrides)!=null&&A.length){s.push({code:"embeddable-type-unresolved",opIndex:k,entity:y.entity,handle:{ref:y.spec.name}});break}else w=zu(y.spec,x,i);if(!w)break;l.push({kind:"attribute.add",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,value:w}),h.push({entityId:C.value.modelId,attribute:w}),w.identifier&&g.identifierCascadeParents.add(C.value.modelId);break}case"attribute.update":case"attribute.remove":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=Bu(C.value,y.attribute);if(!x.ok){s.push(x.reason==="not-found"?{code:"attribute-not-found",opIndex:k,entity:y.entity,handle:y.attribute}:{code:"attribute-ambiguous",opIndex:k,entity:y.entity,handle:y.attribute,matches:x.matches});break}if(y.kind==="attribute.update"){const $=[],w=[];let I=!1;for(const D of Object.keys(y.patch)){if(D.includes(".")){D.startsWith("dbAttrs.")?I=!0:w.push(D);continue}Gl.has(D)?$.push(D):Zb.has(D)||w.push(D)}if(w.length){s.push({code:"attribute-patch-unknown-key",opIndex:k,entity:y.entity,handle:y.attribute,keys:w});break}if("attrType"in y.patch){const D=String(y.patch.attrType),j=Ru.includes(D)?D!==x.value.attrType?"transition":void 0:"unknown-value";if(j){s.push({code:"attribute-attrtype-unsupported",opIndex:k,entity:y.entity,handle:y.attribute,reason:j,current:x.value.attrType,requested:D});break}}const v="type"in y.patch?y.patch.type:x.value.type,M="groupCode"in y.patch?y.patch.groupCode:x.value.groupCode;if(v==="GroupCodeEnum"&&!M){s.push({code:"groupcode-required",opIndex:k,entity:y.entity,handle:y.attribute});break}let R=y.patch;if($.length){const D=s_(x.value,y.patch,$,I);if(!D){s.push({code:"attribute-patch-dbattr-flat-key",opIndex:k,entity:y.entity,handle:y.attribute,keys:$});break}R=D}if((V=y.embeddableOverrides)!=null&&V.length){const D=r(x.value.type);if(!D||x.value.attrType!=="EMBED_PREDEF"){s.push({code:"embeddable-type-unresolved",opIndex:k,entity:y.entity,handle:y.attribute});break}const j=c_(x.value,D,y.embeddableOverrides,C.value,e.entities,k,y.entity,s);if(!j)break;R={...R,dbAttrs:j}}l.push({kind:"attribute.update",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,attributeRef:x.value.modelId,patch:R}),g.attrPatches.push({entityId:C.value.modelId,attributeId:x.value.modelId,patch:R});{const D=x.value,j=Yu(D,R),U=(j.identifier??!1)!==(D.identifier??!1),ne=(D.identifier||j.identifier)&&("type"in R||"customType"in R||"dbAttrs"in R||Object.keys(R).some(pe=>pe.startsWith("dbAttrs.")));(U||ne)&&g.identifierCascadeParents.add(C.value.modelId)}}else{const $=Ho(e,C.value.modelId,x.value.modelId);if($){const w=I=>{var v;return((v=e.entities.find(M=>M.modelId===I))==null?void 0:v.name)??I};s.push({code:"attribute-fk-managed",opIndex:k,entity:y.entity,handle:y.attribute,association:{from:w($.end1.entityRef),to:w($.end2.entityRef)}});break}qo(l,f,C.value.modelId,x.value.modelId),x.value.identifier&&g.identifierCascadeParents.add(C.value.modelId)}break}case"association.add":{{const M=In(y.spec,e_);if(M.length){s.push({code:"association-spec-unknown-key",opIndex:k,handle:{from:y.spec.from,to:y.spec.to},keys:M});break}}const C=Rt(e,y.spec.from),x=Rt(e,y.spec.to);if(C.ok||s.push(At(C.reason,k,y.spec.from,C.matches,E)),x.ok||s.push(At(x.reason,k,y.spec.to,x.matches,E)),!C.ok||!x.ok)break;if(y.spec.identifying&&C.value.modelId===x.value.modelId){s.push({code:"self-identifying",opIndex:k,handle:{from:y.spec.from,to:y.spec.to}});break}if(C.value.stereotype==="JPA_EMBEDDABLE"||x.value.stereotype==="JPA_EMBEDDABLE"){s.push({code:"embeddable-relation-unsupported",opIndex:k,handle:{from:y.spec.from,to:y.spec.to}});break}if(C.value.stereotype==="SERIALIZED_TYPE"||x.value.stereotype==="SERIALIZED_TYPE"){s.push({code:"serialized-relation-invalid",opIndex:k,handle:{from:y.spec.from,to:y.spec.to}});break}const $=i(),w={modelId:$,...y.spec.identifying!=null?{identifying:y.spec.identifying}:{},end1:{entityRef:C.value.modelId,multiplicity:y.spec.fromMultiplicity??"EXACTLY_ONE_INSTANCE",navigable:!1,composition:!1},end2:{entityRef:x.value.modelId,multiplicity:y.spec.toMultiplicity??"ZERO_OR_MORE_INSTANCES",navigable:!0,composition:y.spec.composition??!1}},I={...e,associations:[...e.associations,w]},v=_i(I,x.value.modelId,i);v.add[0]&&(w.end2.attributeRef=v.add[0].modelId),l.push({kind:"association.add",casUnit:"logical",associationRef:$,value:w}),g.addedAssociations.push(w);for(const M of v.add){const R={...M,order:d(x.value.modelId,x.value.attributes)};l.push({kind:"attribute.add",casUnit:"logical",containerRef:x.value.modelId,entityRef:x.value.modelId,value:R}),g.cascadeAdds.push({entityId:x.value.modelId,attribute:R})}break}case"association.remove":{const C=Rt(e,y.association.from),x=Rt(e,y.association.to);if(C.ok||s.push(At(C.reason,k,y.association.from,C.matches,E)),x.ok||s.push(At(x.reason,k,y.association.to,x.matches,E)),!C.ok||!x.ok)break;const $=Vu(e,C.value.modelId,x.value.modelId);if($.length!==1){s.push($.length===0?{code:"association-not-found",opIndex:k,handle:y.association}:{code:"association-ambiguous",opIndex:k,handle:y.association,matches:$.map(M=>M.modelId)});break}const w=$[0];m.has(w.modelId)||(m.add(w.modelId),l.push({kind:"association.remove",casUnit:"logical",associationRef:w.modelId}));const I=e.entities.find(M=>M.attributes.some(R=>{var D;return((D=R.embedded)==null?void 0:D.associationRef)===w.modelId}));if(I){const M=I.attributes.find(R=>{var D;return((D=R.embedded)==null?void 0:D.associationRef)===w.modelId});qo(l,f,I.modelId,M.modelId);break}if(w.end1.attributeRef){const M=e.entities.find(D=>D.modelId===w.end1.entityRef),R=M==null?void 0:M.attributes.find(D=>D.modelId===w.end1.attributeRef&&D.attrType==="RELATION_REF");R&&qo(l,f,M.modelId,R.modelId)}const v={...e,associations:e.associations.filter(M=>M.modelId!==w.modelId)};Yl(l,v,[w.end2.entityRef],i,g,f,d);break}case"association.update":{const C=Wu(e,y.association,k,s,E);if(!C)break;const x=y.patch.identifying,$=typeof x=="boolean"?x:void 0;if($===!0&&C.end1.entityRef===C.end2.entityRef){s.push({code:"self-identifying",opIndex:k,handle:y.association});break}const w=ho(y.patch,o_);if(w.length){s.push({code:"association-patch-unknown-key",opIndex:k,handle:y.association,keys:w});break}if(l.push({kind:"association.update",casUnit:"logical",containerRef:C.modelId,associationRef:C.modelId,patch:y.patch}),g.assocPatches.push({associationRef:C.modelId,patch:y.patch}),$!==void 0&&$!==(C.identifying??!1)){const I={...e,associations:e.associations.map(v=>v.modelId===C.modelId?{...v,identifying:$}:v)};Yl(l,I,[C.end2.entityRef],i,g,f,d)}break}case"associationEnd.update":{const C=Wu(e,y.association,k,s,E);if(!C)break;const x=y.end==="from"?"end1":"end2";if(Object.prototype.hasOwnProperty.call(y.patch,"navigable")){s.push({code:"navigable-toggle-unsupported",opIndex:k,handle:y.association});break}const $=ho(y.patch,i_,["jpa."]);if($.length){s.push({code:"association-end-patch-unknown-key",opIndex:k,handle:y.association,keys:$});break}l.push({kind:"associationEnd.update",casUnit:"logical",containerRef:C.modelId,associationRef:C.modelId,end:x,patch:y.patch}),g.endPatches.push({associationRef:C.modelId,end:x,patch:y.patch});break}case"index.add":{{const $=In(y.spec,Hu);if($.length){s.push({code:"index-spec-unknown-key",opIndex:k,entity:y.entity,handle:{ref:y.spec.name},keys:$});break}}const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=Gu(C.value,y.spec,k,y.entity,s,i);if(!x)break;l.push({kind:"index.add",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,indexRef:x.modelId,value:x});break}case"index.update":case"index.remove":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}if(Kl(y.index)){s.push({code:"handle-by-unsupported",opIndex:k,entity:y.entity,handle:y.index,target:"index"});break}const x=Xb(C.value,y.index);if(!x.ok){s.push(x.reason==="not-found"?{code:"index-not-found",opIndex:k,entity:y.entity,handle:y.index}:{code:"index-ambiguous",opIndex:k,entity:y.entity,handle:y.index,matches:x.matches});break}if(y.kind==="index.update"){if("columns"in y.patch){s.push({code:"index-columns-patch-unsupported",opIndex:k,entity:y.entity,handle:y.index});break}const $=ho(y.patch,a_);if($.length){s.push({code:"index-patch-unknown-key",opIndex:k,entity:y.entity,handle:y.index,keys:$});break}l.push({kind:"index.update",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,indexRef:x.value.modelId,patch:y.patch})}else l.push({kind:"index.remove",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,indexRef:x.value.modelId});break}case"operation.add":{{const w=In(y.spec,ju);if(w.length){s.push({code:"operation-spec-unknown-key",opIndex:k,entity:y.entity,handle:{ref:y.spec.name},keys:w});break}}const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=u.get(C.value.modelId)??(C.value.operations?jt(C.value.operations):0);u.set(C.value.modelId,x+1);const $=Ku(y.spec,x,i);l.push({kind:"operation.add",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,operationRef:$.modelId,value:$});break}case"operation.update":case"operation.remove":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}if(Kl(y.operation)){s.push({code:"handle-by-unsupported",opIndex:k,entity:y.entity,handle:y.operation,target:"operation"});break}const x=Lu(C.value,y.operation);if(!x.ok){s.push(x.reason==="not-found"?{code:"operation-not-found",opIndex:k,entity:y.entity,handle:y.operation}:{code:"operation-ambiguous",opIndex:k,entity:y.entity,handle:y.operation,matches:x.matches});break}if(y.kind==="operation.update"){const $=ho(y.patch,r_);if($.length){s.push({code:"operation-patch-unknown-key",opIndex:k,entity:y.entity,handle:y.operation,keys:$});break}l.push({kind:"operation.update",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,operationRef:x.value.modelId,patch:y.patch})}else l.push({kind:"operation.remove",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,operationRef:x.value.modelId});break}case"attribute.reorder":case"operation.reorder":{const C=y.kind==="attribute.reorder",x=Rt(e,y.entity);if(!x.ok){s.push(At(x.reason,k,y.entity,x.matches,E));break}const $=C?y.order:y.operations,w=[],I=new Set;let v=!1;for(const j of $){if(!C&&Kl(j)){s.push({code:"handle-by-unsupported",opIndex:k,entity:y.entity,handle:j,target:"operation"}),v=!0;continue}const U=C?Bu(x.value,j):Lu(x.value,j);if(!U.ok){s.push(U.reason==="not-found"?{code:"reorder-handle-not-found",opIndex:k,entity:y.entity,handle:j}:{code:"reorder-handle-ambiguous",opIndex:k,entity:y.entity,handle:j,matches:U.matches}),v=!0;continue}if(I.has(U.value.modelId)){s.push({code:"reorder-handle-duplicate",opIndex:k,entity:y.entity,handle:j}),v=!0;continue}I.add(U.value.modelId),w.push(U.value)}if(v)break;const R=[...C?x.value.attributes:x.value.operations??[]].sort((j,U)=>j.order-U.order).filter(j=>!I.has(j.modelId)),D=[...w,...R];if(D.forEach((j,U)=>{j.order!==U&&l.push(C?{kind:"attribute.update",casUnit:"logical",containerRef:x.value.modelId,entityRef:x.value.modelId,attributeRef:j.modelId,patch:{order:U}}:{kind:"operation.update",casUnit:"logical",containerRef:x.value.modelId,entityRef:x.value.modelId,operationRef:j.modelId,patch:{order:U}})}),C)for(const j of Tu(e,x.value.modelId,D.map(U=>U.modelId)))l.push({kind:"attribute.update",casUnit:"logical",containerRef:j.entityId,entityRef:j.entityId,attributeRef:j.attributeId,patch:{dbAttrs:j.dbAttrs}});break}case"group.add":{{const I=In(y.spec,t_);if(I.length){s.push({code:"group-spec-unknown-key",opIndex:k,keys:I});break}}const C=[];let x=!1;for(const I of y.spec.members){const v=Rt(e,I);if(!v.ok){s.push(At(v.reason,k,I,v.matches,E)),x=!0;continue}C.push(v.value.modelId)}if(x)break;const $=i(),w={modelId:$,excludeDDLGeneration:y.spec.excludeDDLGeneration??!1,memberEntityRefs:C,...y.spec.name?{name:y.spec.name}:{},...y.spec.packageName?{packageName:y.spec.packageName}:{},...y.spec.description?{description:y.spec.description}:{}};l.push({kind:"group.add",casUnit:"logical",groupRef:$,value:w});break}case"group.update":{const C=Hl(e,y.group);if(!C.ok){s.push(jl(C,k,y.group));break}const x=ho(y.patch,Kb);if(x.length){s.push({code:"group-patch-unknown-key",opIndex:k,handle:y.group,keys:x});break}l.push({kind:"group.update",casUnit:"logical",containerRef:C.value.modelId,groupRef:C.value.modelId,patch:y.patch});break}case"group.remove":{const C=Hl(e,y.group);if(!C.ok){s.push(jl(C,k,y.group));break}l.push({kind:"group.remove",casUnit:"logical",groupRef:C.value.modelId});break}case"group.addMember":case"group.removeMember":{const C=Hl(e,y.group);if(!C.ok){s.push(jl(C,k,y.group));break}const x=Rt(e,y.entity);if(!x.ok){s.push(At(x.reason,k,y.entity,x.matches,E));break}const $=C.value.memberEntityRefs.includes(x.value.modelId);if(y.kind==="group.addMember"?$:!$)break;if(y.kind==="group.removeMember"){if(b.has(_(C.value.modelId,x.value.modelId)))break;b.add(_(C.value.modelId,x.value.modelId))}l.push({kind:y.kind,casUnit:"logical",containerRef:C.value.modelId,groupRef:C.value.modelId,entityRef:x.value.modelId});break}}}),s.length||f_(l,e,p,m,f,h,g,i,d),s.length||d_(l,e,f,p),s.length||u_(l,e,f,h,p,i),s.length?{ok:!1,errors:s}:{ok:!0,ops:l}}function At(e,n,o,i,a){return e==="not-found"&&(a!=null&&a.has(o.ref))?{code:"pending-entity-ref",opIndex:n,handle:o}:e==="not-found"?{code:"entity-not-found",opIndex:n,handle:o}:{code:"entity-ambiguous",opIndex:n,handle:o,matches:i}}function Wu(e,n,o,i,a){const r=Rt(e,n.from),l=Rt(e,n.to);if(r.ok||i.push(At(r.reason,o,n.from,r.matches,a)),l.ok||i.push(At(l.reason,o,n.to,l.matches,a)),!r.ok||!l.ok)return null;const s=Vu(e,r.value.modelId,l.value.modelId);return s.length!==1?(i.push(s.length===0?{code:"association-not-found",opIndex:o,handle:n}:{code:"association-ambiguous",opIndex:o,handle:n,matches:s.map(c=>c.modelId)}),null):s[0]}const Ju={type:"object",description:"요소 지정 핸들. 엔티티: 물리명(table.physicalName) 우선, 논리명(name) 보조. 속성: 소속 엔티티 내 속성명 또는 컬럼 물리명.",properties:{ref:{type:"string",description:"매칭할 이름/물리명. by:'modelId'면 modelId 원문."},by:{type:"string",enum:["physicalName","name","modelId"],description:"매칭 키 고정(미지정 시 대상별 기본 순서). 'modelId'는 모호 해소 전용 탈출구 — 평시엔 쓰지 말고, entity-ambiguous 응답의 후보를 사용자에게 제시해 확인받은 뒤 그 modelId로 재전송할 때만 쓴다."}},required:["ref"],additionalProperties:!1},h_={type:"object",description:"엔티티 내 이름으로 지정(인덱스명·메서드명). 물리명 차원이 없어 매칭 키 고정(`by`)을 받지 않는다.",properties:{ref:{type:"string",description:"매칭할 이름."}},required:["ref"],additionalProperties:!1},y_={type:"object",description:"관계는 무명이라 양 끝 엔티티로 주소. from=부모(end1), to=자식(end2). 같은 쌍 복수 관계는 모호 보고.",properties:{from:{$ref:"#/$defs/handle"},to:{$ref:"#/$defs/handle"}},required:["from","to"],additionalProperties:!1},Xt={type:"object",properties:{ko:{type:"string"},en:{type:"string"},ja:{type:"string"},zh:{type:"string"}},additionalProperties:!1},g_={type:"object",description:"신규 엔티티. 자식(속성·인덱스·operation)은 별도 attribute.add 등이 아니라 여기 inline 배열로 담아라 — 같은 배치에서 갓 추가된 엔티티에 닿는 child op은 silent no-op이 된다(서버가 pending-entity-ref로 거부). 관계는 inline 불가 → 엔티티 추가 배치 확정 후 별도 배치로 association.add.",properties:{name:{type:"string"},stereotype:{type:"string",enum:["UNDEFINED","JPA_ENTITY","JPA_EMBEDDABLE","JPA_MULTI_LANGUAGE_ENTITY","SERIALIZED_TYPE"],description:"기본 JPA_ENTITY."},physicalName:{type:"string",description:"설정 시 table.physicalName."},classLogicalName:{...Xt,description:"**클래스** 논리명(다국어). 테이블이 없는 자리(직렬화 타입 SERIALIZED_TYPE)의 논리명이 여기 산다 — 그 타입은 table 자체를 갖지 않아 table.logicalName 을 줄 데가 없다. ⚠️테이블이 있는 엔티티는 table.logicalName 이 이기므로 그쪽을 쓴다."},useVersion:{type:"boolean",description:'JPA @Version(낙관적 락) → jpaAttrs.useVersion. @Version 필드는 별도 속성이 아니라 이 엔티티 플래그로 흡수 (버전 컬럼은 코드젠 소유). 기존 엔티티는 entity.update patch의 dotted key {"jpaAttrs.useVersion":true} 사용.'},attributes:{type:"array",description:"inline 속성(배열 순서가 order). attribute.add와 동일 규칙 — GroupCodeEnum은 groupCode 동반 필수.",items:{$ref:"#/$defs/attrSpec"}},indexes:{type:"array",description:"inline 인덱스. 컬럼 핸들은 이 엔티티가 inline으로 만드는 dbAttr 내에서 해소된다(attributes 동반 전제).",items:{$ref:"#/$defs/indexSpec"}},operations:{type:"array",description:"inline 도메인 메서드(배열 순서가 order).",items:{$ref:"#/$defs/operationSpec"}},serialization:{$ref:"#/$defs/serialization"}},required:["name"],additionalProperties:!1},b_={type:"object",description:"직렬화 타입의 컨테이너(SERIALIZED_TYPE 전용). 미지정 = 컬렉션이 아닌 단일 값(한 컬럼에 구조 하나). 신규 엔티티는 entity.add 에 함께 줘야 한다 — 같은 배치의 entity.update 는 갓 만든 엔티티에 닿지 못한다.",properties:{collectionType:{type:"string",enum:["LIST","SET","MAP"],description:"컨테이너 종류. 코퍼스 실재가 java.util 3종뿐이라 그만 표현한다(미지 컨테이너는 발명하지 않는다)."},mapKeyType:{type:"string",description:"collectionType='MAP' 일 때의 키 타입(단순명 또는 FQN). 그 외엔 무의미."}},additionalProperties:!1},__={type:"object",properties:{name:{type:"string"},type:{type:"string",description:"Java 타입(예: Long, String). GroupCodeEnum은 파생 타입이라 groupCode 동반 필수(없으면 거부). 호스트 임베더블 카탈로그에 등록된 predefined 임베더블 타입(예: Money, EmbeddableAddress)이면 EMBED_PREDEF로 다중 컬럼 확장(서브컬럼 조정은 embeddableOverrides)."},identifier:{type:"boolean"},notNull:{type:"boolean"},transient:{type:"boolean",description:"JPA @Transient(비영속) → Attribute.transient. 컬럼을 만들지 않으므로 physicalName/dataType 등 컬럼 필드는 함께 주지 않는다. 기존 속성은 attribute.update patch {transient:true}로도 가능."},physicalName:{type:"string",description:"설정 시 단일 dbAttr 컬럼 생성(미설정이면 name을 물리명으로)."},dataType:{type:"string",description:"dbAttr 물리 타입(예: BIGINT). physicalName/dataType/length/scale 중 하나라도 있으면 컬럼 생성."},length:{type:"integer",description:"dbAttr 컬럼 길이(VARCHAR(n)·DECIMAL precision)."},scale:{type:"integer",description:"dbAttr 소수 자릿수(DECIMAL/NUMERIC scale). length 동반이 일반적."},groupCode:{type:"string",description:"코드성 속성의 group code 바인딩. type=GroupCodeEnum이면 필수."},defaultValue:{type:"string",description:"속성 기본값(문자열 패스스루)."},attributeGroup:{type:"string",description:"속성 분류 그룹(예: 'code'·'amt')."},description:{...Xt,description:"속성 설명(다국어)."},columnLogicalName:{...Xt,description:'dbAttr 컬럼 논리명(다국어, 예: {ko:"체크아웃유형"}). 한글 업무명 보존 위치.'},fieldLogicalName:{...Xt,description:"**필드** 논리명(다국어). 평탄 `logicalName`(컬럼 논리명)과 **다른 축**이다 — 컬럼이 없는 자리(직렬화 타입 SERIALIZED_TYPE 의 자기 필드)는 dbAttrs 가 0이라 컬럼 논리명을 줄 데가 없고, 그 자리의 논리명이 여기 산다(캔버스 논리 뷰·탐색기 검색·코드젠 javadoc 이 읽는다). 컬럼이 있는 자리에서는 컬럼 논리명이 이긴다."},unique:{type:"boolean",description:"dbAttr UNIQUE 제약."},updatable:{type:"boolean",description:"dbAttr 갱신 가능(JPA @Column(updatable=))."},embeddableOverrides:{$ref:"#/$defs/embeddableOverrides"},collectionType:{type:"string",enum:["LIST","SET"],description:"이 «필드»가 컬렉션인가 — **직렬화 타입(SERIALIZED_TYPE)의 자기 필드 전용**(예: Set<String>·List<StoredFile>). 컬럼 있는 자리는 읽지 않는다 — 그쪽 컨테이너는 요소 타입이 소유한다(entity 의 serialization.collectionType). 요소가 문서 안 직렬화 타입이면 그 타입이 이미 감싸므로 지정하지 않는다. 미지정 = 컬렉션 아님."}},required:["name","type"],additionalProperties:!1},k_={type:"array",description:"predefined 임베더블 서브컬럼 오버라이드(속성 type이 카탈로그 엔트리이자 EMBED_PREDEF일 때만). field=카탈로그 필드명으로 매칭(@AttributeOverride 대응). 미설정 서브컬럼은 add=카탈로그 기본 상속 / update=기존값 유지. currency 등 공유 컬럼은 sharedColumnPhysicalName으로 SHARED_REF.",items:{type:"object",properties:{field:{type:"string",description:"대상 카탈로그 필드명(예: amount·currency)."},physicalName:{type:"string",description:"서브컬럼 물리명 오버라이드(@AttributeOverride column name). 미설정 시 카탈로그 기본."},length:{type:"integer",description:"서브컬럼 길이 오버라이드."},scale:{type:"integer",description:"서브컬럼 소수 자릿수 오버라이드."},insertable:{type:"boolean",description:"JPA @Column(insertable=). OWN 컬럼에만 저장."},updatable:{type:"boolean",description:"JPA @Column(updatable=). OWN 컬럼에만 저장."},sharedColumnPhysicalName:{type:"string",description:"SHARED_REF — 같은 엔터티(임베더블이면 owner 합집합) 다른 컬럼(물리명)을 공유해 read-only 투영(대표: currency). 설정 시 자체 컬럼 미보유, 타깃은 해소 시점 존재 필수."}},required:["field"],additionalProperties:!1}},Xu={type:"string",enum:["NO_INSTANCE_OR_ONE_INSTANCE","EXACTLY_ONE_INSTANCE","ZERO_OR_MORE_INSTANCES","ONE_OR_MORE_INSTANCES"]},E_={type:"object",description:'일반 연관 생성. 양 end 는 일반 엔티티여야 한다 — 임베더블(JPA_EMBEDDABLE)·직렬화 타입을 end 로 주면 거부된다. 직렬화 타입은 관계가 아니라 소비 속성의 type 으로 지목한다(attribute.update {type: "<타입명>"}). (임베드는 EMBED 관계여야 하고 이 어휘엔 없다 → 캔버스에서 연결).',properties:{from:{$ref:"#/$defs/handle"},to:{$ref:"#/$defs/handle"},fromMultiplicity:{...Xu,description:"end1 다중성(기본 EXACTLY_ONE_INSTANCE)."},toMultiplicity:{...Xu,description:"end2 다중성(기본 ZERO_OR_MORE_INSTANCES)."},identifying:{type:"boolean",description:"식별 관계(부모 PK가 자식 PK로 전파). self-association은 식별 불가."},composition:{type:"boolean",description:"end2 composition."}},required:["from","to"],additionalProperties:!1},N_={type:"object",properties:{name:{type:"string"},unique:{type:"boolean",description:"UNIQUE 인덱스 여부(기본 false)."},columns:{type:"array",description:"인덱스 컬럼(순서 의미 있음).",items:{type:"object",properties:{column:{...Ju,description:"컬럼 핸들 — 컬럼 물리명 우선, 속성명 보조(단일 컬럼 속성만). 엔티티 내에서 dbAttr modelId로 해소."},descending:{type:"boolean",description:"내림차순(기본 false)."}},required:["column"],additionalProperties:!1}},description:{type:"string",description:"인덱스 설명(평문)."},parameters:{type:"string",description:"인덱스 파라미터(패스스루)."}},required:["name","columns"],additionalProperties:!1},w_={type:"object",properties:{name:{type:"string"},visibility:{type:"string",enum:["PUBLIC","PRIVATE","PROTECTED","PACKAGE"],description:"가시성(기본 미설정)."},sourceCode:{type:"string",description:"Java 메서드 본문(멀티라인, 파라미터·반환 시그니처 포함)."},description:{...Xt,description:"메서드 설명(다국어)."},personalInfoAttributeType:{type:"string",description:"개인정보 속성 유형(패스스루)."}},required:["name"],additionalProperties:!1},I_={type:"object",properties:{name:{...Xt,description:'그룹 논리명(다국어, 예: {ko:"주문"}).'},packageName:{type:"string",description:"자바 패키지명 등 그룹 물리 식별(레거시 LogicalGroup.packageName)."},description:{type:"string",description:"그룹 설명(자유 텍스트 — 도메인 경계 메모)."},excludeDDLGeneration:{type:"boolean",description:"DDL 생성 제외(기본 false)."},members:{type:"array",description:"멤버 엔티티 핸들(물리명 우선/논리명 보조). 기존 엔티티여야 함 — 같은 배치 신규 엔티티는 별도 배치 후.",items:{$ref:"#/$defs/handle"}}},required:["members"],additionalProperties:!1},v_={type:"object",description:"기존 속성 부분 patch. 논리 필드 + 스칼라 단일 컬럼의 물리 필드(physicalName·dataType·length·scale 등 — 서버가 dbAttrs[0]에 매핑). EMBED_PREDEF/Money 서브컬럼 조정은 op-레벨 embeddableOverrides로(평탄 키는 다중 컬럼서 모호해 거부).",properties:{name:{type:"string"},type:{type:"string"},customType:{type:"string"},attrType:{type:"string",enum:[...Ru],description:"속성 종류. **현재 값과 다르게 주면 거부된다** — 관계/임베드/구분선은 동반 구조(관계 소유·embedded·빈 dbAttrs)가 있어야 성립하고 patch로는 표현할 수 없다. 관계 실체화는 association.add, 임베드 서브컬럼은 embeddableOverrides 소관."},identifier:{type:"boolean"},notNull:{type:"boolean"},transient:{type:"boolean"},naturalId:{type:"boolean"},naturalIdMutable:{type:"boolean"},derivedIdFieldName:{type:"string",description:"파생 식별(@MapsId) FK가 매핑되는 **스칼라 @Id 필드명**. 이 속성의 name은 연관 필드명(@MapsId @OneToOne 필드)이고 같은 관계가 두 Java 필드를 만든다. 단일 컬럼 @OneToOne 식별 FK에만 의미가 있고, 미설정 시 부모 PK 물리명의 camelCase로 파생된다(실물 관행). 컬럼은 공유하므로 속성은 하나이며 물리명은 지정하지 않는다."},description:{...Xt,description:"속성 설명(다국어)."},fieldLogicalName:{...Xt,description:"**필드** 논리명(다국어). 평탄 `logicalName`(컬럼 논리명)과 **다른 축**이다 — 컬럼이 없는 자리(직렬화 타입 SERIALIZED_TYPE 의 자기 필드)는 dbAttrs 가 0이라 컬럼 논리명을 줄 데가 없고, 그 자리의 논리명이 여기 산다(캔버스 논리 뷰·탐색기 검색·코드젠 javadoc 이 읽는다). 컬럼이 있는 자리에서는 컬럼 논리명이 이긴다."},attributeGroup:{type:"string"},groupCode:{type:"string"},defaultValue:{type:"string"},personalInfoAttributeType:{type:"string"},order:{type:"integer"},physicalName:{type:"string"},dataType:{type:"string"},length:{type:"integer"},scale:{type:"integer"},unique:{type:"boolean"},updatable:{type:"boolean"},insertable:{type:"boolean"},autoIncrement:{type:"boolean"},multiValue:{type:"boolean"},multiValueSeparator:{type:"string"},sequenceName:{type:"string"},logicalName:{...Xt,description:"**컬럼** 논리명(다국어). 대상이 스칼라 단일 컬럼일 때 dbAttrs[0]에 매핑된다 — dbAttrs 가 0인 속성(직렬화 타입 필드·transient)에 주면 거부되고, 그 자리의 논리명은 `fieldLogicalName` 이 받는다."}},additionalProperties:!1},C_={type:"object",description:"관계 부분 patch. 양 end 설정(multiplicity·nav·jpa)은 associationEnd.update로.",properties:{description:{type:"string"},identifying:{type:"boolean",description:"식별 관계(부모 PK가 자식 PK 일부로 전파)."}},additionalProperties:!1},S_={type:"object",description:"인덱스 부분 patch. columns(컬럼 구성) 변경은 index.remove+index.add로(패치 불가).",properties:{name:{type:"string"},unique:{type:"boolean"},description:{type:"string"},parameters:{type:"string"}},additionalProperties:!1},x_={type:"object",description:"메서드 부분 patch.",properties:{name:{type:"string"},visibility:{type:"string",enum:["PUBLIC","PRIVATE","PROTECTED","PACKAGE"]},sourceCode:{type:"string"},description:{...Xt,description:"메서드 설명(다국어)."},order:{type:"integer"},personalInfoAttributeType:{type:"string"}},additionalProperties:!1},R_={type:"object",description:'엔티티 부분 patch. 논리 키: name·stereotype·packageName·superClass·schema·description·abstractClass·hasPersonalInfo·referenceOnly·declarationOfInterfaces·table·serialization·classLogicalName. classLogicalName = **클래스** 논리명(테이블 없는 직렬화 타입의 논리명이 사는 곳 — 그 타입은 table 을 갖지 않는다). 테이블이 있는 엔티티는 table.logicalName(dotted-key)이 이긴다. serialization(직렬화 타입 컨테이너)은 통째로 주거나(예: {"serialization":{"collectionType":"LIST"}}) dotted-key로 준다({"serialization.collectionType":"LIST"}). 컬렉션 아님으로 되돌릴 땐 null 로 비운다(wire clear 규약). jpaAttrs 플래그(useVersion 등)는 형제 클로버 방지를 위해 dotted-key로 준다: {"jpaAttrs.useVersion": true}. 자식(attributes/indexes/operations)은 patch가 아니라 전용 op로 변경. stereotype 은 값 타입(JPA_EMBEDDABLE·SERIALIZED_TYPE) 경계를 넘을 수 없다 — 들어가고 나오는 전환은 PK 해제/부여·FK reconcile·EMBED 복원/해체가 동반되는 composite라 patch로 표현되지 않는다(거부. 전환은 GUI 소관).'},A_={type:"object",description:'관계 end 부분 patch. 논리 키: multiplicity·navigable·composition. jpa 설정(cascadeTypes·fetchType·orphanRemoval·orderBy·collectionType·collectionTable·orderColumn)은 형제 클로버 방지를 위해 dotted-key로: {"jpa.orphanRemoval": true}.'};function ft(e,n){return{type:"object",properties:{kind:{const:e},...n.properties},required:["kind",...n.required],additionalProperties:!1}}const $_={"entity.add":ft("entity.add",{properties:{spec:{$ref:"#/$defs/entitySpec"}},required:["spec"]}),"entity.update":ft("entity.update",{properties:{entity:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/entityUpdatePatch"}},required:["entity","patch"]}),"entity.remove":ft("entity.remove",{properties:{entity:{$ref:"#/$defs/handle"}},required:["entity"]}),"attribute.add":ft("attribute.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/attrSpec"}},required:["entity","spec"]}),"attribute.update":ft("attribute.update",{properties:{entity:{$ref:"#/$defs/handle"},attribute:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/attrUpdatePatch"},embeddableOverrides:{$ref:"#/$defs/embeddableOverrides"}},required:["entity","attribute","patch"]}),"attribute.remove":ft("attribute.remove",{properties:{entity:{$ref:"#/$defs/handle"},attribute:{$ref:"#/$defs/handle"}},required:["entity","attribute"]}),"association.add":ft("association.add",{properties:{spec:{$ref:"#/$defs/assocSpec"}},required:["spec"]}),"association.remove":ft("association.remove",{properties:{association:{$ref:"#/$defs/assocHandle"}},required:["association"]}),"association.update":ft("association.update",{properties:{association:{$ref:"#/$defs/assocHandle"},patch:{$ref:"#/$defs/assocUpdatePatch"}},required:["association","patch"]}),"associationEnd.update":ft("associationEnd.update",{properties:{association:{$ref:"#/$defs/assocHandle"},end:{type:"string",enum:["from","to"],description:"from=부모(end1), to=자식(end2)."},patch:{$ref:"#/$defs/assocEndUpdatePatch"}},required:["association","end","patch"]}),"index.add":ft("index.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/indexSpec"}},required:["entity","spec"]}),"index.update":ft("index.update",{properties:{entity:{$ref:"#/$defs/handle"},index:{$ref:"#/$defs/nameHandle"},patch:{$ref:"#/$defs/indexUpdatePatch"}},required:["entity","index","patch"]}),"index.remove":ft("index.remove",{properties:{entity:{$ref:"#/$defs/handle"},index:{$ref:"#/$defs/nameHandle"}},required:["entity","index"]}),"operation.add":ft("operation.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/operationSpec"}},required:["entity","spec"]}),"operation.update":ft("operation.update",{properties:{entity:{$ref:"#/$defs/handle"},operation:{$ref:"#/$defs/nameHandle"},patch:{$ref:"#/$defs/operationUpdatePatch"}},required:["entity","operation","patch"]}),"operation.remove":ft("operation.remove",{properties:{entity:{$ref:"#/$defs/handle"},operation:{$ref:"#/$defs/nameHandle"}},required:["entity","operation"]}),"attribute.reorder":ft("attribute.reorder",{properties:{entity:{$ref:"#/$defs/handle"},order:{type:"array",items:{$ref:"#/$defs/handle"},minItems:1}},required:["entity","order"]}),"operation.reorder":ft("operation.reorder",{properties:{entity:{$ref:"#/$defs/handle"},operations:{type:"array",items:{$ref:"#/$defs/nameHandle"},minItems:1}},required:["entity","operations"]}),"group.add":ft("group.add",{properties:{spec:{$ref:"#/$defs/groupSpec"}},required:["spec"]}),"group.update":ft("group.update",{properties:{group:{$ref:"#/$defs/groupHandle"},patch:{$ref:"#/$defs/groupUpdatePatch"}},required:["group","patch"]}),"group.remove":ft("group.remove",{properties:{group:{$ref:"#/$defs/groupHandle"}},required:["group"]}),"group.addMember":ft("group.addMember",{properties:{group:{$ref:"#/$defs/groupHandle"},entity:{$ref:"#/$defs/handle"}},required:["group","entity"]}),"group.removeMember":ft("group.removeMember",{properties:{group:{$ref:"#/$defs/groupHandle"},entity:{$ref:"#/$defs/handle"}},required:["group","entity"]})},T_={type:"object",description:"그룹 지정 핸들. 패키지명(packageName) 우선, 이름(name) 보조 — 이름은 다국어라 어느 로케일 값이든 일치하면 매칭. 'modelId'는 모호 해소 전용(group-ambiguous 후보를 사용자에게 확인받은 뒤).",properties:{ref:{type:"string",description:"매칭할 패키지명/이름. by:'modelId'면 modelId 원문."},by:{type:"string",enum:["packageName","name","modelId"],description:"매칭 키 고정(미지정 시 packageName → name)."}},required:["ref"],additionalProperties:!1},M_={type:"object",description:"그룹 부분 patch. 멤버 변경은 group.addMember/removeMember로(배열 통째 교체는 동시 편집이 서로를 덮는다).",properties:{name:{...Xt,description:"그룹 논리명(다국어)."},packageName:{type:"string"},description:{type:"string"},excludeDDLGeneration:{type:"boolean"}},additionalProperties:!1},Zu={anyOf:xu.map(e=>$_[e])},V_={type:"object",description:"엔티티 모델을 생성·수정·삭제할 때 호출한다. ops는 사람 핸들(엔티티 물리명/논리명, 속성명)로 지정하며 서버가 modelId로 해소한다. 모호하면 에러로 후보를 돌려주니 리소스로 현재 모델을 먼저 읽어 핸들을 확정하라.",properties:{ops:{type:"array",items:{$ref:"#/$defs/symbolicOp"}}},required:["ops"],additionalProperties:!1,$defs:{handle:Ju,nameHandle:h_,groupHandle:T_,assocHandle:y_,entitySpec:g_,serialization:b_,attrSpec:__,embeddableOverrides:k_,assocSpec:E_,indexSpec:N_,operationSpec:w_,groupSpec:I_,entityUpdatePatch:R_,attrUpdatePatch:v_,assocUpdatePatch:C_,assocEndUpdatePatch:A_,indexUpdatePatch:S_,operationUpdatePatch:x_,groupUpdatePatch:M_,symbolicOp:Zu}};function B_(e,n,o,i={}){const a=i.mkClientOpId??Pe,r=new Set;for(const s of o)s.casUnit==="logical"&&s.containerRef&&r.add(s.containerRef);const l={};if(r.size){l.revs={};for(const s of r)l.revs[s]=n[s]??0}return{diagramId:e,ops:o,cas:l,origin:i.origin??"agent",clientOpId:a()}}const Qu={location:{x:0,y:0},size:{width:220,height:140}};function em(e){return{modelId:e.modelId,physicalName:e.physicalName,logicalName:e.logicalName,dataType:e.dataType,length:e.length,scale:e.scale,unique:e.unique,autoIncrement:e.autoIncrement,updatable:e.updatable,insertable:e.insertable,sharedColumnRef:e.sharedColumnRef,multiValue:e.multiValue,multiValueSeparator:e.multiValueSeparator,sequenceName:e.sequenceName}}const D_=/^[-=_*~\s]{3,}$/;function L_(e){return e.attrType&&e.attrType!=="NORMAL"||!D_.test(e.name??"")?!1:!(e.dbAttrs??[]).some(n=>n.physicalName||n.dataType)}function O_(e){return e.type===En&&e.customType==="java.util.Currency"?{type:"Currency",customType:void 0}:{type:e.type,customType:e.customType}}function P_(e,n){if(e.attrType==="DIVIDER"||L_(e))return{modelId:e.modelId,name:e.attrType==="DIVIDER"?e.name:"",type:"",attrType:"DIVIDER",identifier:!1,notNull:!1,order:e.order??n,dbAttrs:[]};const o=O_(e);return{modelId:e.modelId,name:e.name,type:o.type,customType:o.customType,attrType:e.attrType,identifier:e.identifier,notNull:e.notNull,transient:e.transient_,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:e.order??n,dbAttrs:e.dbAttrs.map(em)}}function z_(e,n){const{modelId:o,name:i,visibility:a,sourceCode:r,description:l,order:s,personalInfoAttributeType:c,style:d,...u}=e;return{modelId:o,name:i,visibility:a,sourceCode:r,description:l?{ko:l}:void 0,order:s??n,personalInfoAttributeType:c,legacyRaw:Object.keys(u).length?u:void 0}}function F_(e){return{modelId:e.modelId,name:e.name,unique:e.unique,description:e.description,parameters:e.parameters,columns:e.indexColumns.map(n=>({columnRef:n.targetColumn.refId,descending:n.descending}))}}function U_(e){var n,o;return{modelId:e.modelId,name:e.name,stereotype:e.stereotype,packageName:e.packageName,superClass:e.superClass,schema:e.schema,description:e.description,abstractClass:e.abstractClass,hasPersonalInfo:e.hasPersonalInfo,declarationOfInterfaces:e.declarationOfInterfaces,attributes:e.attributes.map(P_),operations:(n=e.operations)==null?void 0:n.map(z_),indexes:(o=e.indexes)==null?void 0:o.map(F_),jpaAttrs:e.jpaAttrs,table:e.dbAttrs?{physicalName:e.dbAttrs.physicalName,logicalName:e.dbAttrs.logicalName}:void 0}}function H_(e){const n={};for(const i of e.attributes)i.style&&(n[i.modelId]=i.style);const o={};for(const i of e.operations??[])i.style&&(o[i.modelId]=i.style);return{entityRef:e.modelId,geo:e.geo??{...Qu},style:e.style,attributeStyles:Object.keys(n).length?n:void 0,operationStyles:Object.keys(o).length?o:void 0,collapsed:e.collapsed,locked:e.locked}}function tm(e){return e.jpaAttribute?{fetchType:e.jpaAttribute.fetchType,cascadeTypes:e.jpaAttribute.cascadeTypes,orphanRemoval:e.jpaAttribute.orphanRemoval,orderBy:e.jpaAttribute.orderBy,collectionType:e.jpaAttribute.collectionType,collectionTable:e.jpaAttribute.collectionTable,orderColumn:e.jpaAttribute.orderColumn}:void 0}function ql(e){var n;return{entityRef:e.endModel.refId,multiplicity:e.multiplicity,navigable:e.navigable,composition:e.composition,attributeRef:(n=e.attribute)==null?void 0:n.modelId,jpa:tm(e)}}function j_(e){if(e.end1.endModel.refId===e.end2.endModel.refId)return;const n=o=>Wl(o)&&(o==null?void 0:o.identifier)===!0;return n(e.end1.attribute)||n(e.end2.attribute)?!0:void 0}function K_(e){var i,a;const n={modelId:e.modelId,description:e.description,identifying:j_(e),end1:ql(e.end1),end2:ql(e.end2)},o={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:(i=e.end1.attribute)==null?void 0:i.modelId,targetColumnRef:(a=e.end2.attribute)==null?void 0:a.modelId,style:e.style};return{assoc:n,layout:o}}function Wl(e){var n;return!!e&&typeof e.attrType=="string"&&e.attrType.startsWith("RELATION")&&(((n=e.dbAttrs)==null?void 0:n.length)??0)>0}function nm(e){var n;return!!e&&typeof e.attrType=="string"&&e.attrType.startsWith("EMBED")&&(((n=e.dbAttrs)==null?void 0:n.length)??0)>0}function om(e){var o;const n=e.attribute;return(n==null?void 0:n.attrType)==="EMBED_OWN"&&(((o=n.dbAttrs)==null?void 0:o.length)??0)===0&&(e.multiplicity==="ZERO_OR_MORE_INSTANCES"||e.multiplicity==="ONE_OR_MORE_INSTANCES")}function im(e,n){return{modelId:e.modelId,name:e.name??"",type:e.type??"",customType:e.customType,attrType:e.attrType??"RELATION_OWN",identifier:e.identifier??!1,notNull:e.notNull??!1,transient:e.transient_,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:n,dbAttrs:(e.dbAttrs??[]).map(em)}}function G_(e,n,o){var y,k;const i=Wl(e.end1.attribute),a=Wl(e.end2.attribute);if(i===a)return K_(e);const r=i?e.end1:e.end2,l=i?e.end2:e.end1,s=r.attribute,c=(k=(y=s.dbAttrs)==null?void 0:y[0])==null?void 0:k.targetModelId,d=c?o.get(c):void 0,u=n.get(l.endModel.refId),m=u?u.attributes.reduce((S,T)=>Math.max(S,T.order),-1)+1:s.order??0,p={...im(s,m),attrType:"RELATION_OWN",derivedFrom:d?{associationRef:e.modelId,sourceAttributeRef:d}:void 0};u&&u.attributes.push(p);const f=n.get(r.endModel.refId),h=l.attribute;let g;if(h&&f&&r.navigable){const S=ha(l.multiplicity);g={modelId:h.modelId??crypto.randomUUID(),name:ao(h.name??ga((u==null?void 0:u.name)??l.endModel.refId,S),new Set(f.attributes.map(T=>T.name))),type:(u==null?void 0:u.name)??l.endModel.refId,attrType:"RELATION_REF",identifier:!1,notNull:!1,order:f.attributes.reduce((T,B)=>Math.max(T,B.order),-1)+1,dbAttrs:[]},f.attributes.push(g)}const b=(S,T)=>({entityRef:S.endModel.refId,multiplicity:S.multiplicity,navigable:S.navigable,composition:S.composition,attributeRef:T?g==null?void 0:g.modelId:p.modelId,jpa:tm(S)}),_=r.endModel.refId===l.endModel.refId,E={modelId:e.modelId,description:e.description,identifying:!_&&p.identifier===!0?!0:void 0,end1:b(e.end1,i),end2:b(e.end2,a)},N={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:i?d:p.modelId,targetColumnRef:i?p.modelId:d,style:e.style};return{assoc:E,layout:N}}function Y_(e,n){const o=e.targetModelId?n.get(e.targetModelId):void 0;return{modelId:e.modelId,physicalName:e.physicalName||(o==null?void 0:o.physicalName)||"",logicalName:e.logicalName??(o==null?void 0:o.logicalName),dataType:e.dataType||(o==null?void 0:o.dataType)||"",length:e.length??(o==null?void 0:o.length),scale:e.scale??(o==null?void 0:o.scale),unique:e.unique??(o==null?void 0:o.unique),autoIncrement:e.autoIncrement??(o==null?void 0:o.autoIncrement),updatable:e.updatable??(o==null?void 0:o.updatable),insertable:e.insertable??(o==null?void 0:o.insertable)}}function q_(e,n,o){var h;const i=((h=e.end1.attribute)==null?void 0:h.attrType)==="EMBED_OWN",a=i?e.end1:e.end2,r=i?e.end2:e.end1,l=a.attribute,s=n.get(r.endModel.refId),c=s?s.attributes.reduce((g,b)=>Math.max(g,b.order),-1)+1:l.order??0,d={...im(l,c),attrType:l.attrType??"EMBED_OWN",dbAttrs:(l.dbAttrs??[]).map(g=>Y_(g,o)),embedded:{associationRef:e.modelId,embeddableRef:a.endModel.refId}};s&&s.attributes.push(d);const u=g=>({...ql(g),legacyEmbedRaw:g.attribute}),m={modelId:e.modelId,description:e.description,end1:u(e.end1),end2:u(e.end2)},p=!i,f={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:p?d.modelId:void 0,targetColumnRef:p?void 0:d.modelId,style:e.style};return{assoc:m,layout:f}}function W_(e,n){var i,a,r,l;const o=[];for(const s of n){const c=(a=(i=s.end1)==null?void 0:i.endModel)==null?void 0:a.refId,d=(l=(r=s.end2)==null?void 0:r.endModel)==null?void 0:l.refId,u=c===e?d:c;!u||u===e||o.push({targetRef:u,waypoints:s.locations??[]})}return o}function am(e,n={x:0,y:0}){const{modelId:o,memo:i,geo:a,style:r,connections:l,ownedConnections:s,...c}=e;let d=l;if(!d&&Array.isArray(s)){const u=W_(o,s);u.length&&(d=u)}return{modelId:o,memo:i,geo:{location:{x:a.location.x+n.x,y:a.location.y+n.y},size:a.size},style:r,connections:d,legacyRaw:Object.keys(c).length?c:void 0}}function rm(e,n,o){if(!(o!=null&&o.length))return;const i=new Map(e.map(l=>[l.modelId,l])),a=new Map(n.map(l=>[l.modelId,l])),r=(l,s)=>{var c;return!!s&&!!((c=i.get(l??""))!=null&&c.attributes.some(d=>d.modelId===s))};for(const l of o){const s=a.get(l.associationRef);s&&(l.sourceColumnRef&&!r(s.end1.entityRef,l.sourceColumnRef)&&(l.sourceColumnRef=void 0),l.targetColumnRef&&!r(s.end2.entityRef,l.targetColumnRef)&&(l.targetColumnRef=void 0))}}function J_(e,n){const o=new Map(e.map(i=>[i.modelId,i]));for(const i of n){if(i.end1.navigable!==!0)continue;const a=o.get(i.end1.entityRef),r=o.get(i.end2.entityRef);if(!a||!r||gt(a.stereotype)||gt(r.stereotype))continue;const l=i.end1.attributeRef?a.attributes.find(p=>p.modelId===i.end1.attributeRef):void 0;if((l==null?void 0:l.attrType)==="RELATION_REF")continue;const s=`nav:${i.modelId}`,c=a.attributes.find(p=>p.modelId===s);if((c==null?void 0:c.attrType)==="RELATION_REF"){i.end1.attributeRef=s;continue}const d=ha(i.end2.multiplicity),u=ga(r.name,d),m=ao(u,new Set(a.attributes.map(p=>p.name)));a.attributes.push({modelId:s,name:m,type:r.name,attrType:"RELATION_REF",identifier:!1,notNull:!1,order:a.attributes.reduce((p,f)=>Math.max(p,f.order),-1)+1,dbAttrs:[]}),i.end1.attributeRef=s}}function X_(e,n){const o=new Map(e.map(i=>[i.modelId,i]));for(const i of n){if(i.identifying===!0||i.end1.entityRef===i.end2.entityRef)continue;const a=o.get(i.end1.entityRef),r=o.get(i.end2.entityRef);if(!a||!r||gt(a.stereotype)||gt(r.stereotype))continue;const l=r.attributes.find(s=>s.modelId===i.end2.attributeRef);l&&l.attrType.startsWith("RELATION")&&l.dbAttrs.length>0&&l.identifier===!0&&(i.identifying=!0)}}function lm(e,n){var i;const o=new Map(e.map(a=>[a.modelId,a]));for(const a of n){const r=o.get(a.end2.entityRef);if(!r)continue;const l=o.get(a.end1.entityRef);if(l&>(l.stereotype))continue;const s=a.end1.entityRef===a.end2.entityRef,c=a.identifying===!0||!s&&!Uc(a.end1.multiplicity);for(const d of r.attributes)!d.attrType.startsWith("RELATION")||d.dbAttrs.length===0||!(((i=d.derivedFrom)==null?void 0:i.associationRef)===a.modelId||!d.derivedFrom&&d.modelId===a.end2.attributeRef)||(d.notNull=c)}}function sm(e){const n=JSON.parse(JSON.stringify(e));return(n.schemaVersion??1)>=2&&"logical"in n?Z_(n):Q_(n)}function Z_(e){const n=e.id??e.logical.modelId??"",o={},i=m=>{const{rev:p,...f}=m;return p!=null&&(o[m.modelId]=p),f},a=e.logical.entities.map(i),r=e.logical.associations.map(i),l=e.logical.groups.map(i);J_(a,r),X_(a,r),lm(a,r);const{version:s,...c}=e.layout;rm(a,r,c.associationLayouts);const d={logical:{modelId:e.logical.modelId??n,packageName:e.logical.packageName,entities:a,associations:r,groups:l},layout:{...c,diagramId:c.diagramId??n,logicalModelRef:c.logicalModelRef??n}},u={id:e.id,version:e.version,diagramVersion:e.diagramVersion,size:e.size,packageName:e.packageName,schemaVersion:e.schemaVersion,opWriteEnabled:e.opWriteEnabled,referenceOnly:e.referenceOnly,revSeed:{revs:o,layoutVersion:s??0,logicalVersion:e.logical.version??0}};return{state:d,meta:u}}function Q_(e){var _,E;const n=e.id??"",o=[],i=[],a=[],r=[],l=[],s=[],c=[],d=(N,y)=>{o.push(U_(N));const k=H_(N);k.geo={location:{x:k.geo.location.x+y.x,y:k.geo.location.y+y.y},size:k.geo.size},i.push(k);for(const S of N.ownedAssociations??[])c.push(S)},u={x:0,y:0};for(const N of e.entities??[])d(N,u);const m=[];for(const N of e.groups??[]){const y=N.entities??[];l.push({modelId:N.modelId,name:N.name,description:N.description,packageName:N.packageName,excludeDDLGeneration:N.excludeDDLGeneration??!1,memberEntityRefs:y.map(S=>S.modelId)});const k=((_=N.geo)==null?void 0:_.location)??u;if(N.geo){const S=(N.notes??[]).map(T=>T.modelId);s.push({groupRef:N.modelId,geo:N.geo,style:N.style,locked:N.locked,memberNoteRefs:S.length?S:void 0})}for(const S of y)d(S,k);for(const S of N.notes??[])m.push(am(S,k))}const p=new Map(o.map(N=>[N.modelId,N])),f=new Map,h=new Map;for(const N of o)for(const y of N.attributes)for(const k of y.dbAttrs)f.set(k.modelId,y.modelId),h.set(k.modelId,k);for(const N of c)for(const y of[N.end1,N.end2]){const k=y.attribute;if(k&&(((E=k.dbAttrs)==null?void 0:E.length)??0)>0)for(const S of k.dbAttrs)S.modelId&&f.set(S.modelId,k.modelId)}for(const N of c){const y=nm(N.end1.attribute),k=nm(N.end2.attribute),S=om(N.end1)||om(N.end2),{assoc:T,layout:B}=y!==k||S?q_(N,p,h):G_(N,p,f);a.push(T),r.push(B)}rm(o,a,r),Ad(o),lm(o,a);const g={logical:{modelId:n,packageName:e.packageName,entities:o,associations:a,groups:l},layout:{diagramId:n,logicalModelRef:n,canvasSize:e.size,entityLayouts:i,associationLayouts:r,groupLayouts:s,notes:[...(e.notes??[]).map(N=>am(N)),...m]}},b={id:e.id,version:e.version,diagramVersion:e.diagramVersion,size:e.size,packageName:e.packageName,schemaVersion:e.schemaVersion??1};return{state:g,meta:b}}function cm(e){return{modelId:e.modelId,physicalName:e.physicalName,logicalName:e.logicalName,dataType:e.dataType,length:e.length,scale:e.scale,unique:e.unique,autoIncrement:e.autoIncrement,updatable:e.updatable,insertable:e.insertable,sharedColumnRef:e.sharedColumnRef,multiValue:e.multiValue,multiValueSeparator:e.multiValueSeparator,sequenceName:e.sequenceName}}function ek(e,n){return{modelId:e.modelId,name:e.name,type:e.type,customType:e.customType,attrType:e.attrType,identifier:e.identifier,notNull:e.notNull,transient_:e.transient,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:e.order,dbAttrs:e.dbAttrs.map(cm),style:n}}function tk(e,n){var o;return{...e.legacyRaw,modelId:e.modelId,name:e.name,visibility:e.visibility,sourceCode:e.sourceCode,description:(o=e.description)==null?void 0:o.ko,order:e.order,personalInfoAttributeType:e.personalInfoAttributeType,style:n}}function nk(e){return{modelId:e.modelId,name:e.name,unique:e.unique,description:e.description,parameters:e.parameters,indexColumns:e.columns.map(n=>({targetColumn:{refId:n.columnRef},descending:n.descending}))}}function jn(e,n){return{endModel:{refId:e.entityRef},multiplicity:e.multiplicity,navigable:e.navigable,composition:e.composition,jpaAttribute:e.jpa,attribute:n??(e.attributeRef?{modelId:e.attributeRef}:void 0)}}function ok(e,n){const o=n==null?void 0:n.attributes.find(i=>{var a;return i.modelId===((a=e.derivedFrom)==null?void 0:a.sourceAttributeRef)});return{modelId:e.modelId,name:e.name,type:e.type,attrType:"RELATION_REF",identifier:e.identifier,notNull:e.notNull,transient_:e.transient,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,order:e.order,dbAttrs:e.dbAttrs.map((i,a)=>{var r;return{...cm(i),targetModelId:(r=o==null?void 0:o.dbAttrs[a])==null?void 0:r.modelId}})}}function ik(e){return{modelId:e.modelId,name:e.name,type:e.type,attrType:"RELATION_OWN",dbAttrs:[]}}function dm(e,n){const o=l=>{if(!l.attributeRef)return;const s=n.logical.entities.find(c=>c.modelId===l.entityRef);return s==null?void 0:s.attributes.find(c=>c.modelId===l.attributeRef)},i=o(e.end1),a=o(e.end2),r=l=>(l==null?void 0:l.attrType)==="RELATION_OWN"?l:void 0;return(i==null?void 0:i.attrType)==="RELATION_REF"?{navEnd:e.end1,fkEnd:e.end2,navAttr:i,fk:r(a)}:(a==null?void 0:a.attrType)==="RELATION_REF"?{navEnd:e.end2,fkEnd:e.end1,navAttr:a,fk:r(i)}:null}function ak(e){const n=new Set;for(const o of e.logical.associations){const i=dm(o,e);i&&(n.add(i.navAttr.modelId),i.fk&&n.add(i.fk.modelId))}return n}function rk(e){const n=new Set;for(const o of e.logical.entities)for(const i of o.attributes)i.embedded&&n.add(i.modelId);return n}function lk(e,n){return e===n||JSON.stringify(e??null)===JSON.stringify(n??null)}function sk(e,n){const o=(i,a)=>i===a?void 0:i;return{modelId:e.modelId,targetModelId:n==null?void 0:n.modelId,physicalName:e.physicalName===((n==null?void 0:n.physicalName)??"")?"":e.physicalName,logicalName:lk(e.logicalName,n==null?void 0:n.logicalName)?void 0:e.logicalName,dataType:e.dataType===((n==null?void 0:n.dataType)??"")?"":e.dataType,length:o(e.length,n==null?void 0:n.length),scale:o(e.scale,n==null?void 0:n.scale),unique:o(e.unique,n==null?void 0:n.unique),autoIncrement:o(e.autoIncrement,n==null?void 0:n.autoIncrement),updatable:o(e.updatable,n==null?void 0:n.updatable),insertable:o(e.insertable,n==null?void 0:n.insertable)}}function ck(e,n,o){let i;for(const m of n.logical.entities){const p=m.attributes.find(f=>{var h;return((h=f.embedded)==null?void 0:h.associationRef)===e.modelId});if(p){i=p;break}}if(!i)return;const a=i.embedded.embeddableRef,r=n.logical.entities.find(m=>m.modelId===a);if(!r)return;const l=r.attributes.flatMap(m=>m.dbAttrs),s={modelId:i.modelId,name:i.name,type:i.type,attrType:i.attrType,identifier:i.identifier,notNull:i.notNull,transient_:i.transient,description:i.description,attributeGroup:i.attributeGroup,groupCode:i.groupCode,order:i.order,dbAttrs:i.dbAttrs.map((m,p)=>sk(m,l[p]))},c=e.end1.entityRef===a,d=c?e.end2:e.end1,u=d.attributeRef?{modelId:d.attributeRef,attrType:"EMBED_REF",dbAttrs:[]}:void 0;return{...o,end1:jn(e.end1,c?s:u),end2:jn(e.end2,c?u:s)}}function dk(e,n,o){const i={modelId:e.modelId,description:e.description,locations:(o==null?void 0:o.waypoints)??[],style:o==null?void 0:o.style};if(e.end1.legacyEmbedRaw||e.end2.legacyEmbedRaw)return{...i,end1:jn(e.end1,e.end1.legacyEmbedRaw),end2:jn(e.end2,e.end2.legacyEmbedRaw)};const a=ck(e,n,i);if(a)return a;const r=dm(e,n);if(r){const l=n.logical.entities.find(d=>d.modelId===r.navEnd.entityRef),s=r.fk?ok(r.fk,l):void 0,c=ik(r.navAttr);return{...i,end1:jn(e.end1,r.navEnd===e.end1?s:c),end2:jn(e.end2,r.navEnd===e.end2?s:c)}}return{...i,end1:jn(e.end1),end2:jn(e.end2)}}function um(e,n,o,i,a={x:0,y:0}){var u,m;const r=n.layout.entityLayouts.find(p=>p.entityRef===e.modelId),l=n.logical.associations.filter(p=>p.end1.entityRef===e.modelId),s=p=>n.layout.associationLayouts.find(f=>f.associationRef===p),c=(r==null?void 0:r.geo)??{...Qu},d={location:{x:c.location.x-a.x,y:c.location.y-a.y},size:c.size};return{modelId:e.modelId,name:e.name,stereotype:e.stereotype,packageName:e.packageName,superClass:e.superClass,schema:e.schema,description:e.description,abstractClass:e.abstractClass,hasPersonalInfo:e.hasPersonalInfo,declarationOfInterfaces:e.declarationOfInterfaces,attributes:e.attributes.filter(p=>!o.has(p.modelId)&&!i.has(p.modelId)).map(p=>{var f;return ek(p,(f=r==null?void 0:r.attributeStyles)==null?void 0:f[p.modelId])}),operations:(u=e.operations)==null?void 0:u.map(p=>{var f;return tk(p,(f=r==null?void 0:r.operationStyles)==null?void 0:f[p.modelId])}),ownedAssociations:l.map(p=>dk(p,n,s(p.modelId))),indexes:(m=e.indexes)==null?void 0:m.map(nk),jpaAttrs:e.jpaAttrs,dbAttrs:e.table?{physicalName:e.table.physicalName,logicalName:e.table.logicalName}:void 0,geo:d,style:r==null?void 0:r.style,collapsed:r==null?void 0:r.collapsed,locked:r==null?void 0:r.locked}}function uk(e,n,o,i){const a=n.layout.groupLayouts.find(c=>c.groupRef===e.modelId),r=e.memberEntityRefs.map(c=>n.logical.entities.find(d=>d.modelId===c)).filter(c=>!!c),l=(a==null?void 0:a.geo.location)??{x:0,y:0},s=((a==null?void 0:a.memberNoteRefs)??[]).map(c=>n.layout.notes.find(d=>d.modelId===c)).filter(c=>!!c).map(c=>mm(c,l));return{modelId:e.modelId,name:e.name,description:e.description,packageName:e.packageName,excludeDDLGeneration:e.excludeDDLGeneration,entities:r.map(c=>um(c,n,o,i,l)),notes:s.length?s:void 0,geo:a==null?void 0:a.geo,style:a==null?void 0:a.style,locked:a==null?void 0:a.locked}}function mm(e,n={x:0,y:0}){return{...e.legacyRaw,modelId:e.modelId,memo:e.memo,geo:{location:{x:e.geo.location.x-n.x,y:e.geo.location.y-n.y},size:e.geo.size},style:e.style,connections:e.connections}}function mk(e,n={}){const o=new Set(e.logical.groups.flatMap(s=>s.memberEntityRefs)),i=e.logical.entities.filter(s=>!o.has(s.modelId)),a=ak(e),r=rk(e),l=new Set(e.layout.groupLayouts.flatMap(s=>s.memberNoteRefs??[]));return{id:n.id,diagramVersion:n.diagramVersion,version:n.version,size:n.size??e.layout.canvasSize,packageName:n.packageName??e.logical.packageName,entities:i.map(s=>um(s,e,a,r)),groups:e.logical.groups.map(s=>uk(s,e,a,r)),notes:e.layout.notes.filter(s=>!l.has(s.modelId)).map(s=>mm(s))}}function fk(e,n={}){var a,r,l;const o=((a=n.revSeed)==null?void 0:a.revs)??{},i=s=>({...s,rev:o[s.modelId]??0});return{id:n.id,schemaVersion:2,opWriteEnabled:n.opWriteEnabled,referenceOnly:n.referenceOnly,version:n.version,diagramVersion:n.diagramVersion,packageName:n.packageName,size:n.size,logical:{version:((r=n.revSeed)==null?void 0:r.logicalVersion)??0,modelId:e.logical.modelId,packageName:e.logical.packageName,entities:e.logical.entities.map(i),associations:e.logical.associations.map(i),groups:e.logical.groups.map(i)},layout:{...e.layout,version:((l=n.revSeed)==null?void 0:l.layoutVersion)??0}}}const pk=["notNull"];function hk(e){var u;const n=()=>({navAdds:0,navRefPatches:0,identifyingPatches:0,attributeFieldPatches:0,attributeFieldsByName:{}});if((e.schemaVersion??1)<2||!("logical"in e))return{ops:[],revs:{},summary:n()};const o=e,{state:i,meta:a}=sm(e),r=((u=a.revSeed)==null?void 0:u.revs)??{},l=[],s=n(),c=new Map(o.logical.entities.map(m=>[m.modelId,new Map(m.attributes.map(p=>[p.modelId,p]))]));for(const m of i.logical.entities){const p=c.get(m.modelId);if(p)for(const f of m.attributes){const h=p.get(f.modelId);if(!h){l.push({kind:"attribute.add",casUnit:"logical",containerRef:m.modelId,entityRef:m.modelId,value:f}),s.navAdds++;continue}const g={};for(const b of pk)f[b]===!0!=(h[b]===!0)&&(g[b]=f[b],s.attributeFieldsByName[b]=(s.attributeFieldsByName[b]??0)+1);Object.keys(g).length!==0&&(l.push({kind:"attribute.update",casUnit:"logical",containerRef:m.modelId,entityRef:m.modelId,attributeRef:f.modelId,patch:g}),s.attributeFieldPatches++)}}const d=new Map(o.logical.associations.map(m=>[m.modelId,m]));for(const m of i.logical.associations){const p=d.get(m.modelId);p&&(m.end1.attributeRef&&m.end1.attributeRef!==p.end1.attributeRef&&(l.push({kind:"associationEnd.update",casUnit:"logical",containerRef:m.modelId,associationRef:m.modelId,end:"end1",patch:{attributeRef:m.end1.attributeRef}}),s.navRefPatches++),m.identifying===!0&&p.identifying!==!0&&(l.push({kind:"association.update",casUnit:"logical",containerRef:m.modelId,associationRef:m.modelId,patch:{identifying:!0}}),s.identifyingPatches++))}return{ops:l,revs:r,summary:s}}function Si(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function vn(e){return typeof e=="function"?e():t.unref(e)}const yk=typeof window<"u"&&typeof document<"u",gk=e=>typeof e<"u",bk=Object.prototype.toString,_k=e=>bk.call(e)==="[object Object]",kk=()=>{};function Ek(e,n){function o(...i){return new Promise((a,r)=>{Promise.resolve(e(()=>n.apply(this,i),{fn:n,thisArg:this,args:i})).then(a).catch(r)})}return o}const fm=e=>e();function Nk(e=fm){const n=t.ref(!0);function o(){n.value=!1}function i(){n.value=!0}const a=(...r)=>{n.value&&e(...r)};return{isActive:t.readonly(n),pause:o,resume:i,eventFilter:a}}function pm(e,n=!1,o="Timeout"){return new Promise((i,a)=>{setTimeout(n?()=>a(o):i,e)})}function wk(e,n,o={}){const{eventFilter:i=fm,...a}=o;return t.watch(e,Ek(i,n),a)}function Wo(e,n,o={}){const{eventFilter:i,...a}=o,{eventFilter:r,pause:l,resume:s,isActive:c}=Nk(i);return{stop:wk(e,n,{...a,eventFilter:r}),pause:l,resume:s,isActive:c}}function Ik(e,n={}){if(!t.isRef(e))return t.toRefs(e);const o=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(const i in e.value)o[i]=t.customRef(()=>({get(){return e.value[i]},set(a){var r;if((r=vn(n.replaceRef))!=null?r:!0)if(Array.isArray(e.value)){const s=[...e.value];s[i]=a,e.value=s}else{const s={...e.value,[i]:a};Object.setPrototypeOf(s,Object.getPrototypeOf(e.value)),e.value=s}else e.value[i]=a}}));return o}function Jl(e,n=!1){function o(m,{flush:p="sync",deep:f=!1,timeout:h,throwOnTimeout:g}={}){let b=null;const E=[new Promise(N=>{b=t.watch(e,y=>{m(y)!==n&&(b==null||b(),N(y))},{flush:p,deep:f,immediate:!0})})];return h!=null&&E.push(pm(h,g).then(()=>vn(e)).finally(()=>b==null?void 0:b())),Promise.race(E)}function i(m,p){if(!t.isRef(m))return o(y=>y===m,p);const{flush:f="sync",deep:h=!1,timeout:g,throwOnTimeout:b}=p??{};let _=null;const N=[new Promise(y=>{_=t.watch([e,m],([k,S])=>{n!==(k===S)&&(_==null||_(),y(k))},{flush:f,deep:h,immediate:!0})})];return g!=null&&N.push(pm(g,b).then(()=>vn(e)).finally(()=>(_==null||_(),vn(e)))),Promise.race(N)}function a(m){return o(p=>!!p,m)}function r(m){return i(null,m)}function l(m){return i(void 0,m)}function s(m){return o(Number.isNaN,m)}function c(m,p){return o(f=>{const h=Array.from(f);return h.includes(m)||h.includes(vn(m))},p)}function d(m){return u(1,m)}function u(m=1,p){let f=-1;return o(()=>(f+=1,f>=m),p)}return Array.isArray(vn(e))?{toMatch:o,toContains:c,changed:d,changedTimes:u,get not(){return Jl(e,!n)}}:{toMatch:o,toBe:i,toBeTruthy:a,toBeNull:r,toBeNaN:s,toBeUndefined:l,changed:d,changedTimes:u,get not(){return Jl(e,!n)}}}function Xl(e){return Jl(e)}function vk(e){var n;const o=vn(e);return(n=o==null?void 0:o.$el)!=null?n:o}const hm=yk?window:void 0;function ym(...e){let n,o,i,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([o,i,a]=e,n=hm):[n,o,i,a]=e,!n)return kk;Array.isArray(o)||(o=[o]),Array.isArray(i)||(i=[i]);const r=[],l=()=>{r.forEach(u=>u()),r.length=0},s=(u,m,p,f)=>(u.addEventListener(m,p,f),()=>u.removeEventListener(m,p,f)),c=t.watch(()=>[vk(n),vn(a)],([u,m])=>{if(l(),!u)return;const p=_k(m)?{...m}:m;r.push(...o.flatMap(f=>i.map(h=>s(u,f,h,p))))},{immediate:!0,flush:"post"}),d=()=>{c(),l()};return Si(d),d}function Ck(e){return typeof e=="function"?e:typeof e=="string"?n=>n.key===e:Array.isArray(e)?n=>e.includes(n.key):()=>!0}function gm(...e){let n,o,i={};e.length===3?(n=e[0],o=e[1],i=e[2]):e.length===2?typeof e[1]=="object"?(n=!0,o=e[0],i=e[1]):(n=e[0],o=e[1]):(n=!0,o=e[0]);const{target:a=hm,eventName:r="keydown",passive:l=!1,dedupe:s=!1}=i,c=Ck(n);return ym(a,r,u=>{u.repeat&&vn(s)||c(u)&&o(u)},l)}function Sk(e){return JSON.parse(JSON.stringify(e))}function Zl(e,n,o,i={}){var a,r,l;const{clone:s=!1,passive:c=!1,eventName:d,deep:u=!1,defaultValue:m,shouldEmit:p}=i,f=t.getCurrentInstance(),h=o||(f==null?void 0:f.emit)||((a=f==null?void 0:f.$emit)==null?void 0:a.bind(f))||((l=(r=f==null?void 0:f.proxy)==null?void 0:r.$emit)==null?void 0:l.bind(f==null?void 0:f.proxy));let g=d;n||(n="modelValue"),g=g||`update:${n.toString()}`;const b=N=>s?typeof s=="function"?s(N):Sk(N):N,_=()=>gk(e[n])?b(e[n]):m,E=N=>{p?p(N)&&h(g,N):h(g,N)};if(c){const N=_(),y=t.ref(N);let k=!1;return t.watch(()=>e[n],S=>{k||(k=!0,y.value=b(S),t.nextTick(()=>k=!1))}),t.watch(y,S=>{!k&&(S!==e[n]||u)&&E(S)},{deep:u}),y}else return t.computed({get(){return _()},set(N){E(N)}})}var xk={value:()=>{}};function Pa(){for(var e=0,n=arguments.length,o={},i;e<n;++e){if(!(i=arguments[e]+"")||i in o||/[\s.]/.test(i))throw new Error("illegal type: "+i);o[i]=[]}return new za(o)}function za(e){this._=e}function Rk(e,n){return e.trim().split(/^|\s+/).map(function(o){var i="",a=o.indexOf(".");if(a>=0&&(i=o.slice(a+1),o=o.slice(0,a)),o&&!n.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:i}})}za.prototype=Pa.prototype={constructor:za,on:function(e,n){var o=this._,i=Rk(e+"",o),a,r=-1,l=i.length;if(arguments.length<2){for(;++r<l;)if((a=(e=i[r]).type)&&(a=Ak(o[a],e.name)))return a;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++r<l;)if(a=(e=i[r]).type)o[a]=bm(o[a],e.name,n);else if(n==null)for(a in o)o[a]=bm(o[a],e.name,null);return this},copy:function(){var e={},n=this._;for(var o in n)e[o]=n[o].slice();return new za(e)},call:function(e,n){if((a=arguments.length-2)>0)for(var o=new Array(a),i=0,a,r;i<a;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(n,o)},apply:function(e,n,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],a=0,r=i.length;a<r;++a)i[a].value.apply(n,o)}};function Ak(e,n){for(var o=0,i=e.length,a;o<i;++o)if((a=e[o]).name===n)return a.value}function bm(e,n,o){for(var i=0,a=e.length;i<a;++i)if(e[i].name===n){e[i]=xk,e=e.slice(0,i).concat(e.slice(i+1));break}return o!=null&&e.push({name:n,value:o}),e}var Ql="http://www.w3.org/1999/xhtml";const _m={svg:"http://www.w3.org/2000/svg",xhtml:Ql,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Fa(e){var n=e+="",o=n.indexOf(":");return o>=0&&(n=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),_m.hasOwnProperty(n)?{space:_m[n],local:e}:e}function $k(e){return function(){var n=this.ownerDocument,o=this.namespaceURI;return o===Ql&&n.documentElement.namespaceURI===Ql?n.createElement(e):n.createElementNS(o,e)}}function Tk(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function km(e){var n=Fa(e);return(n.local?Tk:$k)(n)}function Mk(){}function es(e){return e==null?Mk:function(){return this.querySelector(e)}}function Vk(e){typeof e!="function"&&(e=es(e));for(var n=this._groups,o=n.length,i=new Array(o),a=0;a<o;++a)for(var r=n[a],l=r.length,s=i[a]=new Array(l),c,d,u=0;u<l;++u)(c=r[u])&&(d=e.call(c,c.__data__,u,r))&&("__data__"in c&&(d.__data__=c.__data__),s[u]=d);return new Ut(i,this._parents)}function Bk(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Dk(){return[]}function Em(e){return e==null?Dk:function(){return this.querySelectorAll(e)}}function Lk(e){return function(){return Bk(e.apply(this,arguments))}}function Ok(e){typeof e=="function"?e=Lk(e):e=Em(e);for(var n=this._groups,o=n.length,i=[],a=[],r=0;r<o;++r)for(var l=n[r],s=l.length,c,d=0;d<s;++d)(c=l[d])&&(i.push(e.call(c,c.__data__,d,l)),a.push(c));return new Ut(i,a)}function Nm(e){return function(){return this.matches(e)}}function wm(e){return function(n){return n.matches(e)}}var Pk=Array.prototype.find;function zk(e){return function(){return Pk.call(this.children,e)}}function Fk(){return this.firstElementChild}function Uk(e){return this.select(e==null?Fk:zk(typeof e=="function"?e:wm(e)))}var Hk=Array.prototype.filter;function jk(){return Array.from(this.children)}function Kk(e){return function(){return Hk.call(this.children,e)}}function Gk(e){return this.selectAll(e==null?jk:Kk(typeof e=="function"?e:wm(e)))}function Yk(e){typeof e!="function"&&(e=Nm(e));for(var n=this._groups,o=n.length,i=new Array(o),a=0;a<o;++a)for(var r=n[a],l=r.length,s=i[a]=[],c,d=0;d<l;++d)(c=r[d])&&e.call(c,c.__data__,d,r)&&s.push(c);return new Ut(i,this._parents)}function Im(e){return new Array(e.length)}function qk(){return new Ut(this._enter||this._groups.map(Im),this._parents)}function Ua(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Ua.prototype={constructor:Ua,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Wk(e){return function(){return e}}function Jk(e,n,o,i,a,r){for(var l=0,s,c=n.length,d=r.length;l<d;++l)(s=n[l])?(s.__data__=r[l],i[l]=s):o[l]=new Ua(e,r[l]);for(;l<c;++l)(s=n[l])&&(a[l]=s)}function Xk(e,n,o,i,a,r,l){var s,c,d=new Map,u=n.length,m=r.length,p=new Array(u),f;for(s=0;s<u;++s)(c=n[s])&&(p[s]=f=l.call(c,c.__data__,s,n)+"",d.has(f)?a[s]=c:d.set(f,c));for(s=0;s<m;++s)f=l.call(e,r[s],s,r)+"",(c=d.get(f))?(i[s]=c,c.__data__=r[s],d.delete(f)):o[s]=new Ua(e,r[s]);for(s=0;s<u;++s)(c=n[s])&&d.get(p[s])===c&&(a[s]=c)}function Zk(e){return e.__data__}function Qk(e,n){if(!arguments.length)return Array.from(this,Zk);var o=n?Xk:Jk,i=this._parents,a=this._groups;typeof e!="function"&&(e=Wk(e));for(var r=a.length,l=new Array(r),s=new Array(r),c=new Array(r),d=0;d<r;++d){var u=i[d],m=a[d],p=m.length,f=eE(e.call(u,u&&u.__data__,d,i)),h=f.length,g=s[d]=new Array(h),b=l[d]=new Array(h),_=c[d]=new Array(p);o(u,m,g,b,_,f,n);for(var E=0,N=0,y,k;E<h;++E)if(y=g[E]){for(E>=N&&(N=E+1);!(k=b[N])&&++N<h;);y._next=k||null}}return l=new Ut(l,i),l._enter=s,l._exit=c,l}function eE(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function tE(){return new Ut(this._exit||this._groups.map(Im),this._parents)}function nE(e,n,o){var i=this.enter(),a=this,r=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),n!=null&&(a=n(a),a&&(a=a.selection())),o==null?r.remove():o(r),i&&a?i.merge(a).order():a}function oE(e){for(var n=e.selection?e.selection():e,o=this._groups,i=n._groups,a=o.length,r=i.length,l=Math.min(a,r),s=new Array(a),c=0;c<l;++c)for(var d=o[c],u=i[c],m=d.length,p=s[c]=new Array(m),f,h=0;h<m;++h)(f=d[h]||u[h])&&(p[h]=f);for(;c<a;++c)s[c]=o[c];return new Ut(s,this._parents)}function iE(){for(var e=this._groups,n=-1,o=e.length;++n<o;)for(var i=e[n],a=i.length-1,r=i[a],l;--a>=0;)(l=i[a])&&(r&&l.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(l,r),r=l);return this}function aE(e){e||(e=rE);function n(m,p){return m&&p?e(m.__data__,p.__data__):!m-!p}for(var o=this._groups,i=o.length,a=new Array(i),r=0;r<i;++r){for(var l=o[r],s=l.length,c=a[r]=new Array(s),d,u=0;u<s;++u)(d=l[u])&&(c[u]=d);c.sort(n)}return new Ut(a,this._parents).order()}function rE(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function lE(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function sE(){return Array.from(this)}function cE(){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var i=e[n],a=0,r=i.length;a<r;++a){var l=i[a];if(l)return l}return null}function dE(){let e=0;for(const n of this)++e;return e}function uE(){return!this.node()}function mE(e){for(var n=this._groups,o=0,i=n.length;o<i;++o)for(var a=n[o],r=0,l=a.length,s;r<l;++r)(s=a[r])&&e.call(s,s.__data__,r,a);return this}function fE(e){return function(){this.removeAttribute(e)}}function pE(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hE(e,n){return function(){this.setAttribute(e,n)}}function yE(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function gE(e,n){return function(){var o=n.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function bE(e,n){return function(){var o=n.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function _E(e,n){var o=Fa(e);if(arguments.length<2){var i=this.node();return o.local?i.getAttributeNS(o.space,o.local):i.getAttribute(o)}return this.each((n==null?o.local?pE:fE:typeof n=="function"?o.local?bE:gE:o.local?yE:hE)(o,n))}function vm(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function kE(e){return function(){this.style.removeProperty(e)}}function EE(e,n,o){return function(){this.style.setProperty(e,n,o)}}function NE(e,n,o){return function(){var i=n.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,o)}}function wE(e,n,o){return arguments.length>1?this.each((n==null?kE:typeof n=="function"?NE:EE)(e,n,o??"")):Jo(this.node(),e)}function Jo(e,n){return e.style.getPropertyValue(n)||vm(e).getComputedStyle(e,null).getPropertyValue(n)}function IE(e){return function(){delete this[e]}}function vE(e,n){return function(){this[e]=n}}function CE(e,n){return function(){var o=n.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function SE(e,n){return arguments.length>1?this.each((n==null?IE:typeof n=="function"?CE:vE)(e,n)):this.node()[e]}function Cm(e){return e.trim().split(/^|\s+/)}function ts(e){return e.classList||new Sm(e)}function Sm(e){this._node=e,this._names=Cm(e.getAttribute("class")||"")}Sm.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function xm(e,n){for(var o=ts(e),i=-1,a=n.length;++i<a;)o.add(n[i])}function Rm(e,n){for(var o=ts(e),i=-1,a=n.length;++i<a;)o.remove(n[i])}function xE(e){return function(){xm(this,e)}}function RE(e){return function(){Rm(this,e)}}function AE(e,n){return function(){(n.apply(this,arguments)?xm:Rm)(this,e)}}function $E(e,n){var o=Cm(e+"");if(arguments.length<2){for(var i=ts(this.node()),a=-1,r=o.length;++a<r;)if(!i.contains(o[a]))return!1;return!0}return this.each((typeof n=="function"?AE:n?xE:RE)(o,n))}function TE(){this.textContent=""}function ME(e){return function(){this.textContent=e}}function VE(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function BE(e){return arguments.length?this.each(e==null?TE:(typeof e=="function"?VE:ME)(e)):this.node().textContent}function DE(){this.innerHTML=""}function LE(e){return function(){this.innerHTML=e}}function OE(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function PE(e){return arguments.length?this.each(e==null?DE:(typeof e=="function"?OE:LE)(e)):this.node().innerHTML}function zE(){this.nextSibling&&this.parentNode.appendChild(this)}function FE(){return this.each(zE)}function UE(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function HE(){return this.each(UE)}function jE(e){var n=typeof e=="function"?e:km(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function KE(){return null}function GE(e,n){var o=typeof e=="function"?e:km(e),i=n==null?KE:typeof n=="function"?n:es(n);return this.select(function(){return this.insertBefore(o.apply(this,arguments),i.apply(this,arguments)||null)})}function YE(){var e=this.parentNode;e&&e.removeChild(this)}function qE(){return this.each(YE)}function WE(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function JE(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function XE(e){return this.select(e?JE:WE)}function ZE(e){return arguments.length?this.property("__data__",e):this.node().__data__}function QE(e){return function(n){e.call(this,n,this.__data__)}}function e1(e){return e.trim().split(/^|\s+/).map(function(n){var o="",i=n.indexOf(".");return i>=0&&(o=n.slice(i+1),n=n.slice(0,i)),{type:n,name:o}})}function t1(e){return function(){var n=this.__on;if(n){for(var o=0,i=-1,a=n.length,r;o<a;++o)r=n[o],(!e.type||r.type===e.type)&&r.name===e.name?this.removeEventListener(r.type,r.listener,r.options):n[++i]=r;++i?n.length=i:delete this.__on}}}function n1(e,n,o){return function(){var i=this.__on,a,r=QE(n);if(i){for(var l=0,s=i.length;l<s;++l)if((a=i[l]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=r,a.options=o),a.value=n;return}}this.addEventListener(e.type,r,o),a={type:e.type,name:e.name,value:n,listener:r,options:o},i?i.push(a):this.__on=[a]}}function o1(e,n,o){var i=e1(e+""),a,r=i.length,l;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,d=s.length,u;c<d;++c)for(a=0,u=s[c];a<r;++a)if((l=i[a]).type===u.type&&l.name===u.name)return u.value}return}for(s=n?n1:t1,a=0;a<r;++a)this.each(s(i[a],n,o));return this}function Am(e,n,o){var i=vm(e),a=i.CustomEvent;typeof a=="function"?a=new a(n,o):(a=i.document.createEvent("Event"),o?(a.initEvent(n,o.bubbles,o.cancelable),a.detail=o.detail):a.initEvent(n,!1,!1)),e.dispatchEvent(a)}function i1(e,n){return function(){return Am(this,e,n)}}function a1(e,n){return function(){return Am(this,e,n.apply(this,arguments))}}function r1(e,n){return this.each((typeof n=="function"?a1:i1)(e,n))}function*l1(){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var i=e[n],a=0,r=i.length,l;a<r;++a)(l=i[a])&&(yield l)}var $m=[null];function Ut(e,n){this._groups=e,this._parents=n}function xi(){return new Ut([[document.documentElement]],$m)}function s1(){return this}Ut.prototype=xi.prototype={constructor:Ut,select:Vk,selectAll:Ok,selectChild:Uk,selectChildren:Gk,filter:Yk,data:Qk,enter:qk,exit:tE,join:nE,merge:oE,selection:s1,order:iE,sort:aE,call:lE,nodes:sE,node:cE,size:dE,empty:uE,each:mE,attr:_E,style:wE,property:SE,classed:$E,text:BE,html:PE,raise:FE,lower:HE,append:jE,insert:GE,remove:qE,clone:XE,datum:ZE,on:o1,dispatch:r1,[Symbol.iterator]:l1};function Zt(e){return typeof e=="string"?new Ut([[document.querySelector(e)]],[document.documentElement]):new Ut([[e]],$m)}function c1(e){let n;for(;n=e.sourceEvent;)e=n;return e}function dn(e,n){if(e=c1(e),n===void 0&&(n=e.currentTarget),n){var o=n.ownerSVGElement||n;if(o.createSVGPoint){var i=o.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}if(n.getBoundingClientRect){var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}}return[e.pageX,e.pageY]}const d1={passive:!1},Ri={capture:!0,passive:!1};function ns(e){e.stopImmediatePropagation()}function Xo(e){e.preventDefault(),e.stopImmediatePropagation()}function Tm(e){var n=e.document.documentElement,o=Zt(e).on("dragstart.drag",Xo,Ri);"onselectstart"in n?o.on("selectstart.drag",Xo,Ri):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Mm(e,n){var o=e.document.documentElement,i=Zt(e).on("dragstart.drag",null);n&&(i.on("click.drag",Xo,Ri),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in o?i.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}const Ha=e=>()=>e;function os(e,{sourceEvent:n,subject:o,target:i,identifier:a,active:r,x:l,y:s,dx:c,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}os.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function u1(e){return!e.ctrlKey&&!e.button}function m1(){return this.parentNode}function f1(e,n){return n??{x:e.x,y:e.y}}function p1(){return navigator.maxTouchPoints||"ontouchstart"in this}function h1(){var e=u1,n=m1,o=f1,i=p1,a={},r=Pa("start","drag","end"),l=0,s,c,d,u,m=0;function p(y){y.on("mousedown.drag",f).filter(i).on("touchstart.drag",b).on("touchmove.drag",_,d1).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(y,k){if(!(u||!e.call(this,y,k))){var S=N(this,n.call(this,y,k),y,k,"mouse");S&&(Zt(y.view).on("mousemove.drag",h,Ri).on("mouseup.drag",g,Ri),Tm(y.view),ns(y),d=!1,s=y.clientX,c=y.clientY,S("start",y))}}function h(y){if(Xo(y),!d){var k=y.clientX-s,S=y.clientY-c;d=k*k+S*S>m}a.mouse("drag",y)}function g(y){Zt(y.view).on("mousemove.drag mouseup.drag",null),Mm(y.view,d),Xo(y),a.mouse("end",y)}function b(y,k){if(e.call(this,y,k)){var S=y.changedTouches,T=n.call(this,y,k),B=S.length,A,V;for(A=0;A<B;++A)(V=N(this,T,y,k,S[A].identifier,S[A]))&&(ns(y),V("start",y,S[A]))}}function _(y){var k=y.changedTouches,S=k.length,T,B;for(T=0;T<S;++T)(B=a[k[T].identifier])&&(Xo(y),B("drag",y,k[T]))}function E(y){var k=y.changedTouches,S=k.length,T,B;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),T=0;T<S;++T)(B=a[k[T].identifier])&&(ns(y),B("end",y,k[T]))}function N(y,k,S,T,B,A){var V=r.copy(),C=dn(A||S,k),x,$,w;if((w=o.call(y,new os("beforestart",{sourceEvent:S,target:p,identifier:B,active:l,x:C[0],y:C[1],dx:0,dy:0,dispatch:V}),T))!=null)return x=w.x-C[0]||0,$=w.y-C[1]||0,function I(v,M,R){var D=C,j;switch(v){case"start":a[B]=I,j=l++;break;case"end":delete a[B],--l;case"drag":C=dn(R||M,k),j=l;break}V.call(v,y,new os(v,{sourceEvent:M,subject:w,target:p,identifier:B,active:j,x:C[0]+x,y:C[1]+$,dx:C[0]-D[0],dy:C[1]-D[1],dispatch:V}),T)}}return p.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Ha(!!y),p):e},p.container=function(y){return arguments.length?(n=typeof y=="function"?y:Ha(y),p):n},p.subject=function(y){return arguments.length?(o=typeof y=="function"?y:Ha(y),p):o},p.touchable=function(y){return arguments.length?(i=typeof y=="function"?y:Ha(!!y),p):i},p.on=function(){var y=r.on.apply(r,arguments);return y===r?p:y},p.clickDistance=function(y){return arguments.length?(m=(y=+y)*y,p):Math.sqrt(m)},p}function is(e,n,o){e.prototype=n.prototype=o,o.constructor=e}function Vm(e,n){var o=Object.create(e.prototype);for(var i in n)o[i]=n[i];return o}function Ai(){}var $i=.7,ja=1/$i,Zo="\\s*([+-]?\\d+)\\s*",Ti="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",un="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",y1=/^#([0-9a-f]{3,8})$/,g1=new RegExp(`^rgb\\(${Zo},${Zo},${Zo}\\)$`),b1=new RegExp(`^rgb\\(${un},${un},${un}\\)$`),_1=new RegExp(`^rgba\\(${Zo},${Zo},${Zo},${Ti}\\)$`),k1=new RegExp(`^rgba\\(${un},${un},${un},${Ti}\\)$`),E1=new RegExp(`^hsl\\(${Ti},${un},${un}\\)$`),N1=new RegExp(`^hsla\\(${Ti},${un},${un},${Ti}\\)$`),Bm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};is(Ai,yo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Dm,formatHex:Dm,formatHex8:w1,formatHsl:I1,formatRgb:Lm,toString:Lm});function Dm(){return this.rgb().formatHex()}function w1(){return this.rgb().formatHex8()}function I1(){return Um(this).formatHsl()}function Lm(){return this.rgb().formatRgb()}function yo(e){var n,o;return e=(e+"").trim().toLowerCase(),(n=y1.exec(e))?(o=n[1].length,n=parseInt(n[1],16),o===6?Om(n):o===3?new Lt(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):o===8?Ka(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):o===4?Ka(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=g1.exec(e))?new Lt(n[1],n[2],n[3],1):(n=b1.exec(e))?new Lt(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=_1.exec(e))?Ka(n[1],n[2],n[3],n[4]):(n=k1.exec(e))?Ka(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=E1.exec(e))?Fm(n[1],n[2]/100,n[3]/100,1):(n=N1.exec(e))?Fm(n[1],n[2]/100,n[3]/100,n[4]):Bm.hasOwnProperty(e)?Om(Bm[e]):e==="transparent"?new Lt(NaN,NaN,NaN,0):null}function Om(e){return new Lt(e>>16&255,e>>8&255,e&255,1)}function Ka(e,n,o,i){return i<=0&&(e=n=o=NaN),new Lt(e,n,o,i)}function v1(e){return e instanceof Ai||(e=yo(e)),e?(e=e.rgb(),new Lt(e.r,e.g,e.b,e.opacity)):new Lt}function as(e,n,o,i){return arguments.length===1?v1(e):new Lt(e,n,o,i??1)}function Lt(e,n,o,i){this.r=+e,this.g=+n,this.b=+o,this.opacity=+i}is(Lt,as,Vm(Ai,{brighter(e){return e=e==null?ja:Math.pow(ja,e),new Lt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?$i:Math.pow($i,e),new Lt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Lt(go(this.r),go(this.g),go(this.b),Ga(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Pm,formatHex:Pm,formatHex8:C1,formatRgb:zm,toString:zm}));function Pm(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}`}function C1(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}${bo((isNaN(this.opacity)?1:this.opacity)*255)}`}function zm(){const e=Ga(this.opacity);return`${e===1?"rgb(":"rgba("}${go(this.r)}, ${go(this.g)}, ${go(this.b)}${e===1?")":`, ${e})`}`}function Ga(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function go(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function bo(e){return e=go(e),(e<16?"0":"")+e.toString(16)}function Fm(e,n,o,i){return i<=0?e=n=o=NaN:o<=0||o>=1?e=n=NaN:n<=0&&(e=NaN),new Qt(e,n,o,i)}function Um(e){if(e instanceof Qt)return new Qt(e.h,e.s,e.l,e.opacity);if(e instanceof Ai||(e=yo(e)),!e)return new Qt;if(e instanceof Qt)return e;e=e.rgb();var n=e.r/255,o=e.g/255,i=e.b/255,a=Math.min(n,o,i),r=Math.max(n,o,i),l=NaN,s=r-a,c=(r+a)/2;return s?(n===r?l=(o-i)/s+(o<i)*6:o===r?l=(i-n)/s+2:l=(n-o)/s+4,s/=c<.5?r+a:2-r-a,l*=60):s=c>0&&c<1?0:l,new Qt(l,s,c,e.opacity)}function S1(e,n,o,i){return arguments.length===1?Um(e):new Qt(e,n,o,i??1)}function Qt(e,n,o,i){this.h=+e,this.s=+n,this.l=+o,this.opacity=+i}is(Qt,S1,Vm(Ai,{brighter(e){return e=e==null?ja:Math.pow(ja,e),new Qt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?$i:Math.pow($i,e),new Qt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,i=o+(o<.5?o:1-o)*n,a=2*o-i;return new Lt(rs(e>=240?e-240:e+120,a,i),rs(e,a,i),rs(e<120?e+240:e-120,a,i),this.opacity)},clamp(){return new Qt(Hm(this.h),Ya(this.s),Ya(this.l),Ga(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ga(this.opacity);return`${e===1?"hsl(":"hsla("}${Hm(this.h)}, ${Ya(this.s)*100}%, ${Ya(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Hm(e){return e=(e||0)%360,e<0?e+360:e}function Ya(e){return Math.max(0,Math.min(1,e||0))}function rs(e,n,o){return(e<60?n+(o-n)*e/60:e<180?o:e<240?n+(o-n)*(240-e)/60:n)*255}const ls=e=>()=>e;function x1(e,n){return function(o){return e+o*n}}function R1(e,n,o){return e=Math.pow(e,o),n=Math.pow(n,o)-e,o=1/o,function(i){return Math.pow(e+i*n,o)}}function A1(e){return(e=+e)==1?jm:function(n,o){return o-n?R1(n,o,e):ls(isNaN(n)?o:n)}}function jm(e,n){var o=n-e;return o?x1(e,o):ls(isNaN(e)?n:e)}const qa=(function e(n){var o=A1(n);function i(a,r){var l=o((a=as(a)).r,(r=as(r)).r),s=o(a.g,r.g),c=o(a.b,r.b),d=jm(a.opacity,r.opacity);return function(u){return a.r=l(u),a.g=s(u),a.b=c(u),a.opacity=d(u),a+""}}return i.gamma=e,i})(1);function $1(e,n){n||(n=[]);var o=e?Math.min(n.length,e.length):0,i=n.slice(),a;return function(r){for(a=0;a<o;++a)i[a]=e[a]*(1-r)+n[a]*r;return i}}function T1(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function M1(e,n){var o=n?n.length:0,i=e?Math.min(o,e.length):0,a=new Array(i),r=new Array(o),l;for(l=0;l<i;++l)a[l]=Mi(e[l],n[l]);for(;l<o;++l)r[l]=n[l];return function(s){for(l=0;l<i;++l)r[l]=a[l](s);return r}}function V1(e,n){var o=new Date;return e=+e,n=+n,function(i){return o.setTime(e*(1-i)+n*i),o}}function mn(e,n){return e=+e,n=+n,function(o){return e*(1-o)+n*o}}function B1(e,n){var o={},i={},a;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(a in n)a in e?o[a]=Mi(e[a],n[a]):i[a]=n[a];return function(r){for(a in o)i[a]=o[a](r);return i}}var ss=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,cs=new RegExp(ss.source,"g");function D1(e){return function(){return e}}function L1(e){return function(n){return e(n)+""}}function Km(e,n){var o=ss.lastIndex=cs.lastIndex=0,i,a,r,l=-1,s=[],c=[];for(e=e+"",n=n+"";(i=ss.exec(e))&&(a=cs.exec(n));)(r=a.index)>o&&(r=n.slice(o,r),s[l]?s[l]+=r:s[++l]=r),(i=i[0])===(a=a[0])?s[l]?s[l]+=a:s[++l]=a:(s[++l]=null,c.push({i:l,x:mn(i,a)})),o=cs.lastIndex;return o<n.length&&(r=n.slice(o),s[l]?s[l]+=r:s[++l]=r),s.length<2?c[0]?L1(c[0].x):D1(n):(n=c.length,function(d){for(var u=0,m;u<n;++u)s[(m=c[u]).i]=m.x(d);return s.join("")})}function Mi(e,n){var o=typeof n,i;return n==null||o==="boolean"?ls(n):(o==="number"?mn:o==="string"?(i=yo(n))?(n=i,qa):Km:n instanceof yo?qa:n instanceof Date?V1:T1(n)?$1:Array.isArray(n)?M1:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?B1:mn)(e,n)}var Gm=180/Math.PI,ds={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ym(e,n,o,i,a,r){var l,s,c;return(l=Math.sqrt(e*e+n*n))&&(e/=l,n/=l),(c=e*o+n*i)&&(o-=e*c,i-=n*c),(s=Math.sqrt(o*o+i*i))&&(o/=s,i/=s,c/=s),e*i<n*o&&(e=-e,n=-n,c=-c,l=-l),{translateX:a,translateY:r,rotate:Math.atan2(n,e)*Gm,skewX:Math.atan(c)*Gm,scaleX:l,scaleY:s}}var Wa;function O1(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?ds:Ym(n.a,n.b,n.c,n.d,n.e,n.f)}function P1(e){return e==null||(Wa||(Wa=document.createElementNS("http://www.w3.org/2000/svg","g")),Wa.setAttribute("transform",e),!(e=Wa.transform.baseVal.consolidate()))?ds:(e=e.matrix,Ym(e.a,e.b,e.c,e.d,e.e,e.f))}function qm(e,n,o,i){function a(d){return d.length?d.pop()+" ":""}function r(d,u,m,p,f,h){if(d!==m||u!==p){var g=f.push("translate(",null,n,null,o);h.push({i:g-4,x:mn(d,m)},{i:g-2,x:mn(u,p)})}else(m||p)&&f.push("translate("+m+n+p+o)}function l(d,u,m,p){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),p.push({i:m.push(a(m)+"rotate(",null,i)-2,x:mn(d,u)})):u&&m.push(a(m)+"rotate("+u+i)}function s(d,u,m,p){d!==u?p.push({i:m.push(a(m)+"skewX(",null,i)-2,x:mn(d,u)}):u&&m.push(a(m)+"skewX("+u+i)}function c(d,u,m,p,f,h){if(d!==m||u!==p){var g=f.push(a(f)+"scale(",null,",",null,")");h.push({i:g-4,x:mn(d,m)},{i:g-2,x:mn(u,p)})}else(m!==1||p!==1)&&f.push(a(f)+"scale("+m+","+p+")")}return function(d,u){var m=[],p=[];return d=e(d),u=e(u),r(d.translateX,d.translateY,u.translateX,u.translateY,m,p),l(d.rotate,u.rotate,m,p),s(d.skewX,u.skewX,m,p),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,m,p),d=u=null,function(f){for(var h=-1,g=p.length,b;++h<g;)m[(b=p[h]).i]=b.x(f);return m.join("")}}}var z1=qm(O1,"px, ","px)","deg)"),F1=qm(P1,", ",")",")"),U1=1e-12;function Wm(e){return((e=Math.exp(e))+1/e)/2}function H1(e){return((e=Math.exp(e))-1/e)/2}function j1(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ja=(function e(n,o,i){function a(r,l){var s=r[0],c=r[1],d=r[2],u=l[0],m=l[1],p=l[2],f=u-s,h=m-c,g=f*f+h*h,b,_;if(g<U1)_=Math.log(p/d)/n,b=function(T){return[s+T*f,c+T*h,d*Math.exp(n*T*_)]};else{var E=Math.sqrt(g),N=(p*p-d*d+i*g)/(2*d*o*E),y=(p*p-d*d-i*g)/(2*p*o*E),k=Math.log(Math.sqrt(N*N+1)-N),S=Math.log(Math.sqrt(y*y+1)-y);_=(S-k)/n,b=function(T){var B=T*_,A=Wm(k),V=d/(o*E)*(A*j1(n*B+k)-H1(k));return[s+V*f,c+V*h,d*A/Wm(n*B+k)]}}return b.duration=_*1e3*n/Math.SQRT2,b}return a.rho=function(r){var l=Math.max(.001,+r),s=l*l,c=s*s;return e(l,s,c)},a})(Math.SQRT2,2,4);var Qo=0,Vi=0,Bi=0,Jm=1e3,Xa,Di,Za=0,_o=0,Qa=0,Li=typeof performance=="object"&&performance.now?performance:Date,Xm=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function us(){return _o||(Xm(K1),_o=Li.now()+Qa)}function K1(){_o=0}function er(){this._call=this._time=this._next=null}er.prototype=Zm.prototype={constructor:er,restart:function(e,n,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?us():+o)+(n==null?0:+n),!this._next&&Di!==this&&(Di?Di._next=this:Xa=this,Di=this),this._call=e,this._time=o,ms()},stop:function(){this._call&&(this._call=null,this._time=1/0,ms())}};function Zm(e,n,o){var i=new er;return i.restart(e,n,o),i}function G1(){us(),++Qo;for(var e=Xa,n;e;)(n=_o-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Qo}function Qm(){_o=(Za=Li.now())+Qa,Qo=Vi=0;try{G1()}finally{Qo=0,q1(),_o=0}}function Y1(){var e=Li.now(),n=e-Za;n>Jm&&(Qa-=n,Za=e)}function q1(){for(var e,n=Xa,o,i=1/0;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(o=n._next,n._next=null,n=e?e._next=o:Xa=o);Di=e,ms(i)}function ms(e){if(!Qo){Vi&&(Vi=clearTimeout(Vi));var n=e-_o;n>24?(e<1/0&&(Vi=setTimeout(Qm,e-Li.now()-Qa)),Bi&&(Bi=clearInterval(Bi))):(Bi||(Za=Li.now(),Bi=setInterval(Y1,Jm)),Qo=1,Xm(Qm))}}function ef(e,n,o){var i=new er;return n=n==null?0:+n,i.restart(a=>{i.stop(),e(a+n)},n,o),i}var W1=Pa("start","end","cancel","interrupt"),J1=[],tf=0,nf=1,fs=2,tr=3,of=4,ps=5,nr=6;function or(e,n,o,i,a,r){var l=e.__transition;if(!l)e.__transition={};else if(o in l)return;X1(e,o,{name:n,index:i,group:a,on:W1,tween:J1,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:tf})}function hs(e,n){var o=en(e,n);if(o.state>tf)throw new Error("too late; already scheduled");return o}function fn(e,n){var o=en(e,n);if(o.state>tr)throw new Error("too late; already running");return o}function en(e,n){var o=e.__transition;if(!o||!(o=o[n]))throw new Error("transition not found");return o}function X1(e,n,o){var i=e.__transition,a;i[n]=o,o.timer=Zm(r,0,o.time);function r(d){o.state=nf,o.timer.restart(l,o.delay,o.time),o.delay<=d&&l(d-o.delay)}function l(d){var u,m,p,f;if(o.state!==nf)return c();for(u in i)if(f=i[u],f.name===o.name){if(f.state===tr)return ef(l);f.state===of?(f.state=nr,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete i[u]):+u<n&&(f.state=nr,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete i[u])}if(ef(function(){o.state===tr&&(o.state=of,o.timer.restart(s,o.delay,o.time),s(d))}),o.state=fs,o.on.call("start",e,e.__data__,o.index,o.group),o.state===fs){for(o.state=tr,a=new Array(p=o.tween.length),u=0,m=-1;u<p;++u)(f=o.tween[u].value.call(e,e.__data__,o.index,o.group))&&(a[++m]=f);a.length=m+1}}function s(d){for(var u=d<o.duration?o.ease.call(null,d/o.duration):(o.timer.restart(c),o.state=ps,1),m=-1,p=a.length;++m<p;)a[m].call(e,u);o.state===ps&&(o.on.call("end",e,e.__data__,o.index,o.group),c())}function c(){o.state=nr,o.timer.stop(),delete i[n];for(var d in i)return;delete e.__transition}}function ir(e,n){var o=e.__transition,i,a,r=!0,l;if(o){n=n==null?null:n+"";for(l in o){if((i=o[l]).name!==n){r=!1;continue}a=i.state>fs&&i.state<ps,i.state=nr,i.timer.stop(),i.on.call(a?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete o[l]}r&&delete e.__transition}}function Z1(e){return this.each(function(){ir(this,e)})}function Q1(e,n){var o,i;return function(){var a=fn(this,e),r=a.tween;if(r!==o){i=o=r;for(var l=0,s=i.length;l<s;++l)if(i[l].name===n){i=i.slice(),i.splice(l,1);break}}a.tween=i}}function e0(e,n,o){var i,a;if(typeof o!="function")throw new Error;return function(){var r=fn(this,e),l=r.tween;if(l!==i){a=(i=l).slice();for(var s={name:n,value:o},c=0,d=a.length;c<d;++c)if(a[c].name===n){a[c]=s;break}c===d&&a.push(s)}r.tween=a}}function t0(e,n){var o=this._id;if(e+="",arguments.length<2){for(var i=en(this.node(),o).tween,a=0,r=i.length,l;a<r;++a)if((l=i[a]).name===e)return l.value;return null}return this.each((n==null?Q1:e0)(o,e,n))}function ys(e,n,o){var i=e._id;return e.each(function(){var a=fn(this,i);(a.value||(a.value={}))[n]=o.apply(this,arguments)}),function(a){return en(a,i).value[n]}}function af(e,n){var o;return(typeof n=="number"?mn:n instanceof yo?qa:(o=yo(n))?(n=o,qa):Km)(e,n)}function n0(e){return function(){this.removeAttribute(e)}}function o0(e){return function(){this.removeAttributeNS(e.space,e.local)}}function i0(e,n,o){var i,a=o+"",r;return function(){var l=this.getAttribute(e);return l===a?null:l===i?r:r=n(i=l,o)}}function a0(e,n,o){var i,a=o+"",r;return function(){var l=this.getAttributeNS(e.space,e.local);return l===a?null:l===i?r:r=n(i=l,o)}}function r0(e,n,o){var i,a,r;return function(){var l,s=o(this),c;return s==null?void this.removeAttribute(e):(l=this.getAttribute(e),c=s+"",l===c?null:l===i&&c===a?r:(a=c,r=n(i=l,s)))}}function l0(e,n,o){var i,a,r;return function(){var l,s=o(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),c=s+"",l===c?null:l===i&&c===a?r:(a=c,r=n(i=l,s)))}}function s0(e,n){var o=Fa(e),i=o==="transform"?F1:af;return this.attrTween(e,typeof n=="function"?(o.local?l0:r0)(o,i,ys(this,"attr."+e,n)):n==null?(o.local?o0:n0)(o):(o.local?a0:i0)(o,i,n))}function c0(e,n){return function(o){this.setAttribute(e,n.call(this,o))}}function d0(e,n){return function(o){this.setAttributeNS(e.space,e.local,n.call(this,o))}}function u0(e,n){var o,i;function a(){var r=n.apply(this,arguments);return r!==i&&(o=(i=r)&&d0(e,r)),o}return a._value=n,a}function m0(e,n){var o,i;function a(){var r=n.apply(this,arguments);return r!==i&&(o=(i=r)&&c0(e,r)),o}return a._value=n,a}function f0(e,n){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(n==null)return this.tween(o,null);if(typeof n!="function")throw new Error;var i=Fa(e);return this.tween(o,(i.local?u0:m0)(i,n))}function p0(e,n){return function(){hs(this,e).delay=+n.apply(this,arguments)}}function h0(e,n){return n=+n,function(){hs(this,e).delay=n}}function y0(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?p0:h0)(n,e)):en(this.node(),n).delay}function g0(e,n){return function(){fn(this,e).duration=+n.apply(this,arguments)}}function b0(e,n){return n=+n,function(){fn(this,e).duration=n}}function _0(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?g0:b0)(n,e)):en(this.node(),n).duration}function k0(e,n){if(typeof n!="function")throw new Error;return function(){fn(this,e).ease=n}}function E0(e){var n=this._id;return arguments.length?this.each(k0(n,e)):en(this.node(),n).ease}function N0(e,n){return function(){var o=n.apply(this,arguments);if(typeof o!="function")throw new Error;fn(this,e).ease=o}}function w0(e){if(typeof e!="function")throw new Error;return this.each(N0(this._id,e))}function I0(e){typeof e!="function"&&(e=Nm(e));for(var n=this._groups,o=n.length,i=new Array(o),a=0;a<o;++a)for(var r=n[a],l=r.length,s=i[a]=[],c,d=0;d<l;++d)(c=r[d])&&e.call(c,c.__data__,d,r)&&s.push(c);return new Cn(i,this._parents,this._name,this._id)}function v0(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,o=e._groups,i=n.length,a=o.length,r=Math.min(i,a),l=new Array(i),s=0;s<r;++s)for(var c=n[s],d=o[s],u=c.length,m=l[s]=new Array(u),p,f=0;f<u;++f)(p=c[f]||d[f])&&(m[f]=p);for(;s<i;++s)l[s]=n[s];return new Cn(l,this._parents,this._name,this._id)}function C0(e){return(e+"").trim().split(/^|\s+/).every(function(n){var o=n.indexOf(".");return o>=0&&(n=n.slice(0,o)),!n||n==="start"})}function S0(e,n,o){var i,a,r=C0(n)?hs:fn;return function(){var l=r(this,e),s=l.on;s!==i&&(a=(i=s).copy()).on(n,o),l.on=a}}function x0(e,n){var o=this._id;return arguments.length<2?en(this.node(),o).on.on(e):this.each(S0(o,e,n))}function R0(e){return function(){var n=this.parentNode;for(var o in this.__transition)if(+o!==e)return;n&&n.removeChild(this)}}function A0(){return this.on("end.remove",R0(this._id))}function $0(e){var n=this._name,o=this._id;typeof e!="function"&&(e=es(e));for(var i=this._groups,a=i.length,r=new Array(a),l=0;l<a;++l)for(var s=i[l],c=s.length,d=r[l]=new Array(c),u,m,p=0;p<c;++p)(u=s[p])&&(m=e.call(u,u.__data__,p,s))&&("__data__"in u&&(m.__data__=u.__data__),d[p]=m,or(d[p],n,o,p,d,en(u,o)));return new Cn(r,this._parents,n,o)}function T0(e){var n=this._name,o=this._id;typeof e!="function"&&(e=Em(e));for(var i=this._groups,a=i.length,r=[],l=[],s=0;s<a;++s)for(var c=i[s],d=c.length,u,m=0;m<d;++m)if(u=c[m]){for(var p=e.call(u,u.__data__,m,c),f,h=en(u,o),g=0,b=p.length;g<b;++g)(f=p[g])&&or(f,n,o,g,p,h);r.push(p),l.push(u)}return new Cn(r,l,n,o)}var M0=xi.prototype.constructor;function V0(){return new M0(this._groups,this._parents)}function B0(e,n){var o,i,a;return function(){var r=Jo(this,e),l=(this.style.removeProperty(e),Jo(this,e));return r===l?null:r===o&&l===i?a:a=n(o=r,i=l)}}function rf(e){return function(){this.style.removeProperty(e)}}function D0(e,n,o){var i,a=o+"",r;return function(){var l=Jo(this,e);return l===a?null:l===i?r:r=n(i=l,o)}}function L0(e,n,o){var i,a,r;return function(){var l=Jo(this,e),s=o(this),c=s+"";return s==null&&(c=s=(this.style.removeProperty(e),Jo(this,e))),l===c?null:l===i&&c===a?r:(a=c,r=n(i=l,s))}}function O0(e,n){var o,i,a,r="style."+n,l="end."+r,s;return function(){var c=fn(this,e),d=c.on,u=c.value[r]==null?s||(s=rf(n)):void 0;(d!==o||a!==u)&&(i=(o=d).copy()).on(l,a=u),c.on=i}}function P0(e,n,o){var i=(e+="")=="transform"?z1:af;return n==null?this.styleTween(e,B0(e,i)).on("end.style."+e,rf(e)):typeof n=="function"?this.styleTween(e,L0(e,i,ys(this,"style."+e,n))).each(O0(this._id,e)):this.styleTween(e,D0(e,i,n),o).on("end.style."+e,null)}function z0(e,n,o){return function(i){this.style.setProperty(e,n.call(this,i),o)}}function F0(e,n,o){var i,a;function r(){var l=n.apply(this,arguments);return l!==a&&(i=(a=l)&&z0(e,l,o)),i}return r._value=n,r}function U0(e,n,o){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;return this.tween(i,F0(e,n,o??""))}function H0(e){return function(){this.textContent=e}}function j0(e){return function(){var n=e(this);this.textContent=n??""}}function K0(e){return this.tween("text",typeof e=="function"?j0(ys(this,"text",e)):H0(e==null?"":e+""))}function G0(e){return function(n){this.textContent=e.call(this,n)}}function Y0(e){var n,o;function i(){var a=e.apply(this,arguments);return a!==o&&(n=(o=a)&&G0(a)),n}return i._value=e,i}function q0(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,Y0(e))}function W0(){for(var e=this._name,n=this._id,o=lf(),i=this._groups,a=i.length,r=0;r<a;++r)for(var l=i[r],s=l.length,c,d=0;d<s;++d)if(c=l[d]){var u=en(c,n);or(c,e,o,d,l,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Cn(i,this._parents,e,o)}function J0(){var e,n,o=this,i=o._id,a=o.size();return new Promise(function(r,l){var s={value:l},c={value:function(){--a===0&&r()}};o.each(function(){var d=fn(this,i),u=d.on;u!==e&&(n=(e=u).copy(),n._.cancel.push(s),n._.interrupt.push(s),n._.end.push(c)),d.on=n}),a===0&&r()})}var X0=0;function Cn(e,n,o,i){this._groups=e,this._parents=n,this._name=o,this._id=i}function lf(){return++X0}var Sn=xi.prototype;Cn.prototype={constructor:Cn,select:$0,selectAll:T0,selectChild:Sn.selectChild,selectChildren:Sn.selectChildren,filter:I0,merge:v0,selection:V0,transition:W0,call:Sn.call,nodes:Sn.nodes,node:Sn.node,size:Sn.size,empty:Sn.empty,each:Sn.each,on:x0,attr:s0,attrTween:f0,style:P0,styleTween:U0,text:K0,textTween:q0,remove:A0,tween:t0,delay:y0,duration:_0,ease:E0,easeVarying:w0,end:J0,[Symbol.iterator]:Sn[Symbol.iterator]};function Z0(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Q0={time:null,delay:0,duration:250,ease:Z0};function eN(e,n){for(var o;!(o=e.__transition)||!(o=o[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return o}function tN(e){var n,o;e instanceof Cn?(n=e._id,e=e._name):(n=lf(),(o=Q0).time=us(),e=e==null?null:e+"");for(var i=this._groups,a=i.length,r=0;r<a;++r)for(var l=i[r],s=l.length,c,d=0;d<s;++d)(c=l[d])&&or(c,e,n,d,l,o||eN(c,n));return new Cn(i,this._parents,e,n)}xi.prototype.interrupt=Z1,xi.prototype.transition=tN;const ar=e=>()=>e;function nN(e,{sourceEvent:n,target:o,transform:i,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function xn(e,n,o){this.k=e,this.x=n,this.y=o}xn.prototype={constructor:xn,scale:function(e){return e===1?this:new xn(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new xn(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ei=new xn(1,0,0);xn.prototype;function gs(e){e.stopImmediatePropagation()}function Oi(e){e.preventDefault(),e.stopImmediatePropagation()}function oN(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function iN(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function sf(){return this.__zoom||ei}function aN(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function rN(){return navigator.maxTouchPoints||"ontouchstart"in this}function lN(e,n,o){var i=e.invertX(n[0][0])-o[0][0],a=e.invertX(n[1][0])-o[1][0],r=e.invertY(n[0][1])-o[0][1],l=e.invertY(n[1][1])-o[1][1];return e.translate(a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a),l>r?(r+l)/2:Math.min(0,r)||Math.max(0,l))}function sN(){var e=oN,n=iN,o=lN,i=aN,a=rN,r=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],s=250,c=Ja,d=Pa("start","zoom","end"),u,m,p,f=500,h=150,g=0,b=10;function _(w){w.property("__zoom",sf).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",V).filter(a).on("touchstart.zoom",C).on("touchmove.zoom",x).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(w,I,v,M){var R=w.selection?w.selection():w;R.property("__zoom",sf),w!==R?k(w,I,v,M):R.interrupt().each(function(){S(this,arguments).event(M).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},_.scaleBy=function(w,I,v,M){_.scaleTo(w,function(){var R=this.__zoom.k,D=typeof I=="function"?I.apply(this,arguments):I;return R*D},v,M)},_.scaleTo=function(w,I,v,M){_.transform(w,function(){var R=n.apply(this,arguments),D=this.__zoom,j=v==null?y(R):typeof v=="function"?v.apply(this,arguments):v,U=D.invert(j),ne=typeof I=="function"?I.apply(this,arguments):I;return o(N(E(D,ne),j,U),R,l)},v,M)},_.translateBy=function(w,I,v,M){_.transform(w,function(){return o(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof v=="function"?v.apply(this,arguments):v),n.apply(this,arguments),l)},null,M)},_.translateTo=function(w,I,v,M,R){_.transform(w,function(){var D=n.apply(this,arguments),j=this.__zoom,U=M==null?y(D):typeof M=="function"?M.apply(this,arguments):M;return o(ei.translate(U[0],U[1]).scale(j.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof v=="function"?-v.apply(this,arguments):-v),D,l)},M,R)};function E(w,I){return I=Math.max(r[0],Math.min(r[1],I)),I===w.k?w:new xn(I,w.x,w.y)}function N(w,I,v){var M=I[0]-v[0]*w.k,R=I[1]-v[1]*w.k;return M===w.x&&R===w.y?w:new xn(w.k,M,R)}function y(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function k(w,I,v,M){w.on("start.zoom",function(){S(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(M).end()}).tween("zoom",function(){var R=this,D=arguments,j=S(R,D).event(M),U=n.apply(R,D),ne=v==null?y(U):typeof v=="function"?v.apply(R,D):v,pe=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),he=R.__zoom,ye=typeof I=="function"?I.apply(R,D):I,be=c(he.invert(ne).concat(pe/he.k),ye.invert(ne).concat(pe/ye.k));return function(le){if(le===1)le=ye;else{var ve=be(le),ze=pe/ve[2];le=new xn(ze,ne[0]-ve[0]*ze,ne[1]-ve[1]*ze)}j.zoom(null,le)}})}function S(w,I,v){return!v&&w.__zooming||new T(w,I)}function T(w,I){this.that=w,this.args=I,this.active=0,this.sourceEvent=null,this.extent=n.apply(w,I),this.taps=0}T.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,I){return this.mouse&&w!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var I=Zt(this.that).datum();d.call(w,this.that,new nN(w,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:d}),I)}};function B(w,...I){if(!e.apply(this,arguments))return;var v=S(this,I).event(w),M=this.__zoom,R=Math.max(r[0],Math.min(r[1],M.k*Math.pow(2,i.apply(this,arguments)))),D=dn(w);if(v.wheel)(v.mouse[0][0]!==D[0]||v.mouse[0][1]!==D[1])&&(v.mouse[1]=M.invert(v.mouse[0]=D)),clearTimeout(v.wheel);else{if(M.k===R)return;v.mouse=[D,M.invert(D)],ir(this),v.start()}Oi(w),v.wheel=setTimeout(j,h),v.zoom("mouse",o(N(E(M,R),v.mouse[0],v.mouse[1]),v.extent,l));function j(){v.wheel=null,v.end()}}function A(w,...I){if(p||!e.apply(this,arguments))return;var v=w.currentTarget,M=S(this,I,!0).event(w),R=Zt(w.view).on("mousemove.zoom",ne,!0).on("mouseup.zoom",pe,!0),D=dn(w,v),j=w.clientX,U=w.clientY;Tm(w.view),gs(w),M.mouse=[D,this.__zoom.invert(D)],ir(this),M.start();function ne(he){if(Oi(he),!M.moved){var ye=he.clientX-j,be=he.clientY-U;M.moved=ye*ye+be*be>g}M.event(he).zoom("mouse",o(N(M.that.__zoom,M.mouse[0]=dn(he,v),M.mouse[1]),M.extent,l))}function pe(he){R.on("mousemove.zoom mouseup.zoom",null),Mm(he.view,M.moved),Oi(he),M.event(he).end()}}function V(w,...I){if(e.apply(this,arguments)){var v=this.__zoom,M=dn(w.changedTouches?w.changedTouches[0]:w,this),R=v.invert(M),D=v.k*(w.shiftKey?.5:2),j=o(N(E(v,D),M,R),n.apply(this,I),l);Oi(w),s>0?Zt(this).transition().duration(s).call(k,j,M,w):Zt(this).call(_.transform,j,M,w)}}function C(w,...I){if(e.apply(this,arguments)){var v=w.touches,M=v.length,R=S(this,I,w.changedTouches.length===M).event(w),D,j,U,ne;for(gs(w),j=0;j<M;++j)U=v[j],ne=dn(U,this),ne=[ne,this.__zoom.invert(ne),U.identifier],R.touch0?!R.touch1&&R.touch0[2]!==ne[2]&&(R.touch1=ne,R.taps=0):(R.touch0=ne,D=!0,R.taps=1+!!u);u&&(u=clearTimeout(u)),D&&(R.taps<2&&(m=ne[0],u=setTimeout(function(){u=null},f)),ir(this),R.start())}}function x(w,...I){if(this.__zooming){var v=S(this,I).event(w),M=w.changedTouches,R=M.length,D,j,U,ne;for(Oi(w),D=0;D<R;++D)j=M[D],U=dn(j,this),v.touch0&&v.touch0[2]===j.identifier?v.touch0[0]=U:v.touch1&&v.touch1[2]===j.identifier&&(v.touch1[0]=U);if(j=v.that.__zoom,v.touch1){var pe=v.touch0[0],he=v.touch0[1],ye=v.touch1[0],be=v.touch1[1],le=(le=ye[0]-pe[0])*le+(le=ye[1]-pe[1])*le,ve=(ve=be[0]-he[0])*ve+(ve=be[1]-he[1])*ve;j=E(j,Math.sqrt(le/ve)),U=[(pe[0]+ye[0])/2,(pe[1]+ye[1])/2],ne=[(he[0]+be[0])/2,(he[1]+be[1])/2]}else if(v.touch0)U=v.touch0[0],ne=v.touch0[1];else return;v.zoom("touch",o(N(j,U,ne),v.extent,l))}}function $(w,...I){if(this.__zooming){var v=S(this,I).event(w),M=w.changedTouches,R=M.length,D,j;for(gs(w),p&&clearTimeout(p),p=setTimeout(function(){p=null},f),D=0;D<R;++D)j=M[D],v.touch0&&v.touch0[2]===j.identifier?delete v.touch0:v.touch1&&v.touch1[2]===j.identifier&&delete v.touch1;if(v.touch1&&!v.touch0&&(v.touch0=v.touch1,delete v.touch1),v.touch0)v.touch0[1]=this.__zoom.invert(v.touch0[0]);else if(v.end(),v.taps===2&&(j=dn(j,this),Math.hypot(m[0]-j[0],m[1]-j[1])<b)){var U=Zt(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return _.wheelDelta=function(w){return arguments.length?(i=typeof w=="function"?w:ar(+w),_):i},_.filter=function(w){return arguments.length?(e=typeof w=="function"?w:ar(!!w),_):e},_.touchable=function(w){return arguments.length?(a=typeof w=="function"?w:ar(!!w),_):a},_.extent=function(w){return arguments.length?(n=typeof w=="function"?w:ar([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),_):n},_.scaleExtent=function(w){return arguments.length?(r[0]=+w[0],r[1]=+w[1],_):[r[0],r[1]]},_.translateExtent=function(w){return arguments.length?(l[0][0]=+w[0][0],l[1][0]=+w[1][0],l[0][1]=+w[0][1],l[1][1]=+w[1][1],_):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},_.constrain=function(w){return arguments.length?(o=w,_):o},_.duration=function(w){return arguments.length?(s=+w,_):s},_.interpolate=function(w){return arguments.length?(c=w,_):c},_.on=function(){var w=d.on.apply(d,arguments);return w===d?_:w},_.clickDistance=function(w){return arguments.length?(g=(w=+w)*w,_):Math.sqrt(g)},_.tapDistance=function(w){return arguments.length?(b=+w,_):b},_}var Me=(e=>(e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom",e))(Me||{}),bs=(e=>(e.Partial="partial",e.Full="full",e))(bs||{}),ko=(e=>(e.Bezier="default",e.SimpleBezier="simple-bezier",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e))(ko||{}),Rn=(e=>(e.Strict="strict",e.Loose="loose",e))(Rn||{}),_s=(e=>(e.Arrow="arrow",e.ArrowClosed="arrowclosed",e))(_s||{}),Pi=(e=>(e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal",e))(Pi||{}),cf=(e=>(e.TopLeft="top-left",e.TopCenter="top-center",e.TopRight="top-right",e.BottomLeft="bottom-left",e.BottomCenter="bottom-center",e.BottomRight="bottom-right",e))(cf||{});const cN=["INPUT","SELECT","TEXTAREA"],dN=typeof document<"u"?document:null;function ks(e){var n,o;const i=((o=(n=e.composedPath)==null?void 0:n.call(e))==null?void 0:o[0])||e.target,a=typeof(i==null?void 0:i.hasAttribute)=="function"?i.hasAttribute("contenteditable"):!1,r=typeof(i==null?void 0:i.closest)=="function"?i.closest(".nokey"):null;return cN.includes(i==null?void 0:i.nodeName)||a||!!r}function uN(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function df(e,n,o,i){const a=n.replace("+",`
|
|
27
|
+
`}}const co="com.example",nb="command.domain";function Nn(e,n,o={}){const i=Lo(e,n);if(i.kind==="explicit")return i.value;const a=o.packageConfig;if(a!=null&&a.basePackage){const r=i.value?`.${i.value}`:"",l=a.layerSuffix??nb,s=l?`.${l}`:"";return`${a.basePackage}${r}${s}`}return n.packageName||""}const ob="CustomMoneyType",ib="Money";function ab(e){return!(e.type!==ob||e.attrType!=="NORMAL"||e.identifier||e.dbAttrs.length>1)}function rb(e){const n=e.dbAttrs[0]??{modelId:Pe(),physicalName:"",dataType:""},o={modelId:Pe(),physicalName:"",dataType:""},{customType:i,...a}=e;return{...a,type:ib,attrType:"EMBED_PREDEF",dbAttrs:[n,o]}}function lb(e){let n=!1;const o=e.entities.map(i=>{let a=!1;const r=i.attributes.map(l=>ab(l)?(a=!0,n=!0,rb(l)):l);return a?{...i,attributes:r}:i});return n?{...e,entities:o}:e}function sb(e,n){const o=new Map,i=[],a=new Map;for(const h of e.entities){const g=new Map,b=new Map,_=new Map,E=(N,y,k)=>{if(!N)return;o.get(N)||o.set(N,[{entityId:y,assignedId:N}]),i.push({id:N,entityId:y,sink:k}),k(N)};for(const N of h.attributes){E(N.modelId,h.modelId,y=>g.set(N,y));for(const y of N.dbAttrs)E(y.modelId,h.modelId,k=>b.set(y,k))}for(const N of h.indexes??[])E(N.modelId,h.modelId,y=>_.set(N,y));a.set(h,{attrs:g,cols:b,idx:_})}const r=new Set(o.keys()),l=new Map;for(const h of i){const g=(l.get(h.id)??0)+1;if(l.set(h.id,g),g===1)continue;const b=cb(h.id,g-1,r);r.add(b),o.get(h.id).push({entityId:h.entityId,assignedId:b}),h.sink(b)}const s=[...o.values()].reduce((h,g)=>h+Math.max(0,g.length-1),0);if(s===0)return{logical:e,layout:n,reissued:0};const c=(h,g)=>{var _;if(!g||!h)return g;const b=o.get(g);return!b||b.length<2?g:((_=b.find(E=>E.entityId===h))==null?void 0:_.assignedId)??g},d=new Map(e.associations.map(h=>[h.modelId,h])),u=(h,g)=>{const b=d.get(h);if(b)return b.end1.entityRef===g?b.end2.entityRef:b.end1.entityRef},m=e.entities.map(h=>{var N;const g=a.get(h),b=h.attributes.map(y=>{const k=g.attrs.get(y),S=y.dbAttrs.map(A=>{const V=g.cols.get(A);return V===A.modelId?A:{...A,modelId:V}});let T=y.derivedFrom;if(T){const A=u(T.associationRef,h.modelId),V=c(A,T.sourceAttributeRef);V!==T.sourceAttributeRef&&(T={...T,sourceAttributeRef:V})}return k!==y.modelId||T!==y.derivedFrom||S.some((A,V)=>A!==y.dbAttrs[V])?{...y,modelId:k,dbAttrs:S,derivedFrom:T}:y}),_=(N=h.indexes)==null?void 0:N.map(y=>{const k=g.idx.get(y),S=y.columns.map(B=>{const A=c(h.modelId,B.columnRef);return A===B.columnRef?B:{...B,columnRef:A}});return k!==y.modelId||S.some((B,A)=>B!==y.columns[A])?{...y,modelId:k,columns:S}:y});return b.some((y,k)=>y!==h.attributes[k])||_&&h.indexes&&_.some((y,k)=>y!==h.indexes[k])?{...h,attributes:b,..._?{indexes:_}:{}}:h}),p=e.associations.map(h=>{const g=c(h.end1.entityRef,h.end1.attributeRef),b=c(h.end2.entityRef,h.end2.attributeRef);return g===h.end1.attributeRef&&b===h.end2.attributeRef?h:{...h,end1:g===h.end1.attributeRef?h.end1:{...h.end1,attributeRef:g},end2:b===h.end2.attributeRef?h.end2:{...h.end2,attributeRef:b}}}),f=n.associationLayouts.map(h=>{const g=d.get(h.associationRef);if(!g)return h;const b=c(g.end1.entityRef,h.sourceColumnRef),_=c(g.end2.entityRef,h.targetColumnRef);return b===h.sourceColumnRef&&_===h.targetColumnRef?h:{...h,sourceColumnRef:b,targetColumnRef:_}});return{logical:{...e,entities:m,associations:p},layout:f.some((h,g)=>h!==n.associationLayouts[g])?{...n,associationLayouts:f}:n,reissued:s}}function cb(e,n,o){let i=n;for(;;){const a=`dup${i}:${e}`;if(!o.has(a))return a;i++}}const db="5.2.13";function jt(e){return e.reduce((n,o)=>Math.max(n,o.order),-1)+1}function Rl(e,n,o){const i=new Set(n),a=e.filter(s=>i.has(s.modelId)),r=e.filter(s=>!i.has(s.modelId)),l=Math.max(0,Math.min(o,r.length));return[...r.slice(0,l),...a,...r.slice(l)]}function Rd(e){return!!e.derivedFrom&&e.dbAttrs.length>0}function Ad(e){for(const n of e){const o=[...n.attributes].sort((s,c)=>s.order-c.order),i=o.filter(Rd);if(!i.length)continue;const a=o.filter(s=>!Rd(s));let r=0;a.forEach((s,c)=>{s.identifier&&!s.derivedFrom&&(r=c+1)});const l=[...a.slice(0,r),...i,...a.slice(r)];l.forEach((s,c)=>s.order=c),n.attributes=l}}function Ko(e){return JSON.parse(JSON.stringify(e))}function $d(e,n,o){var B;const i=o.idFactory??Pe,a=o.offset??{x:0,y:0},{logical:r,layout:l}=e,s=new Set(n);if(o.includeRelated){const A=new Set(n);for(const V of r.associations){const C=A.has(V.end1.entityRef),x=A.has(V.end2.entityRef);C!==x&&s.add(C?V.end2.entityRef:V.end1.entityRef)}}const c=r.entities.filter(A=>s.has(A.modelId)),d=new Set(c.map(A=>A.modelId)),u=r.associations.filter(A=>d.has(A.end1.entityRef)&&d.has(A.end2.entityRef)),m=new Set(u.map(A=>A.modelId)),p=new Map,f=A=>{let V=p.get(A);return V||(V=i(),p.set(A,V)),V};for(const A of c){f(A.modelId);for(const V of A.attributes){f(V.modelId);for(const C of V.dbAttrs)f(C.modelId)}for(const V of A.indexes??[])f(V.modelId);for(const V of A.operations??[])f(V.modelId)}for(const A of u)f(A.modelId);const h=A=>p.get(A),g=c.map(A=>{const V=Ko(A);V.modelId=h(A.modelId),V.attributes=V.attributes.map(C=>ub(C,h,m,d));for(const C of V.indexes??[])C.modelId=h(C.modelId),C.columns=C.columns.map(x=>to(x.columnRef)?x:{...x,columnRef:h(x.columnRef)}).filter(x=>x.columnRef!==void 0);for(const C of V.operations??[])C.modelId=h(C.modelId);return V});Ad(g);const b=u.map(A=>{const V=Ko(A);return V.modelId=h(A.modelId),V.end1=Td(V.end1,h),V.end2=Td(V.end2,h),V}),_=[];for(const A of r.groups){const V=A.memberEntityRefs.filter(x=>d.has(x));if(V.length===0)continue;const C=Ko(A);C.modelId=f(A.modelId),C.memberEntityRefs=V.map(x=>h(x)),_.push(C)}const E=o.collisionSuffix??"_imported",N=new Set(o.existing.entities.map(A=>A.name)),y=new Set(o.existing.entities.map(A=>{var V;return(V=A.table)==null?void 0:V.physicalName}).filter(A=>!!A));for(const A of g)N.has(A.name)&&(A.name=`${A.name}${E}`),(B=A.table)!=null&&B.physicalName&&y.has(A.table.physicalName)&&(A.table.physicalName=`${A.table.physicalName}${E}`);const k=[];for(const A of l.entityLayouts){const V=h(A.entityRef);if(!V)continue;const C=Ko(A);C.entityRef=V,C.geo={...C.geo,location:Al(C.geo.location,a)},C.attributeStyles&&(C.attributeStyles=xa(C.attributeStyles,h)),C.operationStyles&&(C.operationStyles=xa(C.operationStyles,h)),k.push(C)}const S=[];for(const A of l.associationLayouts){const V=h(A.associationRef);if(!V)continue;const C=Ko(A);C.associationRef=V,C.sourceColumnRef=A.sourceColumnRef?h(A.sourceColumnRef):void 0,C.targetColumnRef=A.targetColumnRef?h(A.targetColumnRef):void 0,C.waypoints=C.waypoints.map(x=>Al(x,a)),S.push(C)}const T=[];for(const A of l.groupLayouts){const V=h(A.groupRef);if(!V)continue;const C=Ko(A);C.groupRef=V,C.geo={...C.geo,location:Al(C.geo.location,a)},delete C.memberNoteRefs,T.push(C)}return{logical:{entities:g,associations:b,groups:_},layout:{entityLayouts:k,associationLayouts:S,groupLayouts:T},idMap:p}}function Al(e,n){return{x:e.x+n.x,y:e.y+n.y}}function ub(e,n,o,i){e.modelId=n(e.modelId);for(const a of e.dbAttrs)if(a.modelId=n(a.modelId),a.sharedColumnRef!==void 0){const r=n(a.sharedColumnRef);r?a.sharedColumnRef=r:delete a.sharedColumnRef}return e.derivedFrom&&(o.has(e.derivedFrom.associationRef)?e.derivedFrom={associationRef:n(e.derivedFrom.associationRef),sourceAttributeRef:n(e.derivedFrom.sourceAttributeRef)??e.derivedFrom.sourceAttributeRef}:(delete e.derivedFrom,(e.attrType==="RELATION_OWN"||e.attrType==="RELATION_REF")&&(e.attrType="NORMAL"))),e.embedded&&(i.has(e.embedded.embeddableRef)?e.embedded={associationRef:n(e.embedded.associationRef)??e.embedded.associationRef,embeddableRef:n(e.embedded.embeddableRef)}:(delete e.embedded,e.attrType.startsWith("EMBED")&&(e.attrType="NORMAL"))),e}function Td(e,n){return{...e,entityRef:n(e.entityRef),attributeRef:e.attributeRef?n(e.attributeRef):void 0}}function xa(e,n){const o={};for(const[i,a]of Object.entries(e)){const r=n(i);r&&(o[r]=a)}return o}function $l(e){if(!("rev"in e))return e;const{rev:n,...o}=e;return o}function uo(e,n){if(e===n||e==null&&n==null)return!0;if(e==null||n==null)return!1;if(Array.isArray(e)||Array.isArray(n))return!Array.isArray(e)||!Array.isArray(n)||e.length!==n.length?!1:e.every((o,i)=>uo(o,n[i]));if(typeof e=="object"&&typeof n=="object"){const o=new Set([...Object.keys(e),...Object.keys(n)]);for(const i of o)if(!uo(e[i],n[i]))return!1;return!0}return!1}function mo(e,n,o){const i={},a=new Set([...Object.keys(e),...Object.keys(n)]);for(const r of a)o.has(r)||uo(e[r],n[r])||(i[r]=n[r]===void 0?null:n[r]);return Object.keys(i).length?i:null}function fo(e,n,o){const i=new Map(e.map(d=>[o(d),d])),a=new Map(n.map(d=>[o(d),d])),r=[],l=[],s=[];for(const[d,u]of a){const m=i.get(d);m?s.push({cur:m,tgt:u}):r.push(u)}for(const[d,u]of i)a.has(d)||l.push(u);const c=(d,u)=>o(d)<o(u)?-1:o(d)>o(u)?1:0;return r.sort(c),l.sort(c),s.sort((d,u)=>c(d.tgt,u.tgt)),{added:r,removed:l,common:s}}function mb(e,n){const o=new Set(e),i=new Set(n),a=n.filter(l=>!o.has(l)).sort(),r=e.filter(l=>!i.has(l)).sort();return{added:a,removed:r}}const fb=new Set(["attributes","operations","indexes","rev"]),pb=new Set(["end1","end2","rev"]),hb=new Set(["memberEntityRefs","rev"]),Md=new Set(["modelId"]),yb=new Set(["modelId","columns"]),gb=new Set([]);function bb(e,n,o,i){const a=fo(n.attributes??[],o.attributes??[],s=>s.modelId);for(const s of a.removed)i.push({kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:s.modelId});for(const s of a.added)i.push({kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of a.common){const d=mo(s,c,Md);d&&i.push({kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:s.modelId,patch:d})}const r=fo(n.operations??[],o.operations??[],s=>s.modelId);for(const s of r.removed)i.push({kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:s.modelId});for(const s of r.added)i.push({kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of r.common){const d=mo(s,c,Md);d&&i.push({kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:s.modelId,patch:d})}const l=fo(n.indexes??[],o.indexes??[],s=>s.modelId);for(const s of l.removed)i.push({kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId});for(const s of l.added)i.push({kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of l.common){if(!uo(s.columns,c.columns)){i.push({kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId}),i.push({kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:c});continue}const d=mo(s,c,yb);d&&i.push({kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId,patch:d})}}function _b(e,n,o){const i=fo(e.entities??[],n.entities??[],l=>l.modelId);for(const l of i.removed)o.push({kind:"entity.remove",casUnit:"logical",entityRef:l.modelId});for(const l of i.added)o.push({kind:"entity.add",casUnit:"logical",entityRef:l.modelId,value:$l(l)});for(const{cur:l,tgt:s}of i.common){const c=mo(l,s,fb);c&&o.push({kind:"entity.update",casUnit:"logical",containerRef:l.modelId,entityRef:l.modelId,patch:c}),bb(l.modelId,l,s,o)}const a=fo(e.associations??[],n.associations??[],l=>l.modelId);for(const l of a.removed)o.push({kind:"association.remove",casUnit:"logical",associationRef:l.modelId});for(const l of a.added)o.push({kind:"association.add",casUnit:"logical",associationRef:l.modelId,value:$l(l)});for(const{cur:l,tgt:s}of a.common){const c=mo(l,s,pb);c&&o.push({kind:"association.update",casUnit:"logical",containerRef:l.modelId,associationRef:l.modelId,patch:c});for(const d of["end1","end2"]){const u=mo(l[d]??{},s[d]??{},gb);u&&o.push({kind:"associationEnd.update",casUnit:"logical",containerRef:l.modelId,associationRef:l.modelId,end:d,patch:u})}}const r=fo(e.groups??[],n.groups??[],l=>l.modelId);for(const l of r.removed)o.push({kind:"group.remove",casUnit:"logical",groupRef:l.modelId});for(const l of r.added)o.push({kind:"group.add",casUnit:"logical",groupRef:l.modelId,value:$l(l)});for(const{cur:l,tgt:s}of r.common){const c=mo(l,s,hb);c&&o.push({kind:"group.update",casUnit:"logical",containerRef:l.modelId,groupRef:l.modelId,patch:c});const d=mb(l.memberEntityRefs??[],s.memberEntityRefs??[]);for(const u of d.removed)o.push({kind:"group.removeMember",casUnit:"logical",containerRef:l.modelId,groupRef:l.modelId,entityRef:u});for(const u of d.added)o.push({kind:"group.addMember",casUnit:"logical",containerRef:l.modelId,groupRef:l.modelId,entityRef:u})}}function Ra(e,n,o,i,a,r,l){const s=fo(e,n,o);for(const c of s.removed)l.push({kind:a,casUnit:"layout",[r]:o(c),value:void 0});for(const c of s.added)l.push({kind:i,casUnit:"layout",[r]:o(c),value:c});for(const{cur:c,tgt:d}of s.common)uo(c,d)||(l.push({kind:a,casUnit:"layout",[r]:o(c),value:void 0}),l.push({kind:i,casUnit:"layout",[r]:o(d),value:d}))}function kb(e,n,o){Ra(e.entityLayouts??[],n.entityLayouts??[],i=>i.entityRef,"entityLayout.add","entityLayout.remove","entityRef",o),Ra(e.associationLayouts??[],n.associationLayouts??[],i=>i.associationRef,"associationLayout.add","associationLayout.remove","associationRef",o),Ra(e.groupLayouts??[],n.groupLayouts??[],i=>i.groupRef,"groupLayout.add","groupLayout.remove","groupRef",o),Ra(e.notes??[],n.notes??[],i=>i.modelId,"note.add","note.remove","noteRef",o)}function Eb(e,n){const o=[];return _b(e.logical,n.logical,o),kb(e.layout,n.layout,o),o}function Nb(e){if(e.groupRef!=null)return"group";if(e.associationRef!=null)return e.end!=null?"associationEnd":"association";if(e.entityRef!=null&&e.attributeRef!=null)return"attribute";if(e.entityRef!=null&&e.operationRef!=null)return"operation";if(e.entityRef!=null&&e.indexRef!=null)return"index";if(e.entityRef!=null)return"entity";throw new Error("projectFieldAudit: 대상 로케이터가 비었습니다(entityRef/associationRef/groupRef 중 하나 필요).")}const wb={entity:new Set(["attributes","operations","indexes","rev","modelId"]),association:new Set(["end1","end2","rev","modelId"]),group:new Set(["memberEntityRefs","rev","modelId"]),attribute:new Set(["modelId"]),operation:new Set(["modelId"]),index:new Set(["modelId"]),associationEnd:new Set([])};class Ib{constructor(n){ct(this,"out",[]);ct(this,"last",new Map);this.fieldFilter=n}set(n,o,i){if(this.fieldFilter!=null&&o!==this.fieldFilter)return;const a=this.last.get(o);this.out.push({...wi(n),field:o,value:i,...this.last.has(o)?{oldValue:a}:{}}),this.last.set(o,i)}remove(n,o){if(o!=null){if(this.fieldFilter!=null&&o!==this.fieldFilter)return;this.out.push({...wi(n),field:o,value:void 0,removed:!0,...this.last.has(o)?{oldValue:this.last.get(o)}:{}}),this.last.delete(o);return}const i=this.fieldFilter!=null?[this.fieldFilter]:[...this.last.keys()];for(const a of i){if(!this.last.has(a)){this.out.push({...wi(n),field:a,value:void 0,removed:!0});continue}this.out.push({...wi(n),field:a,value:void 0,removed:!0,oldValue:this.last.get(a)}),this.last.delete(a)}}member(n,o,i){const a="memberEntityRefs";this.fieldFilter!=null&&a!==this.fieldFilter||this.out.push({...wi(n),field:a,value:o,...i?{removed:!0}:{}})}result(){return this.out}}function wi(e){const n={seq:e.seq};return e.ts!==void 0&&(n.ts=e.ts),e.origin!==void 0&&(n.origin=e.origin),e.author!==void 0&&(n.author=e.author),e.kind!==void 0&&(n.kind=e.kind),e.restoredFromSeq!==void 0&&(n.restoredFromSeq=e.restoredFromSeq),n}function sn(e,n,o,i){if(o==null||typeof o!="object")return;const a=wb[i];for(const[r,l]of Object.entries(o))a.has(r)||e.set(n,r,l)}function po(e,n,o){if(!(o==null||typeof o!="object"))for(const[i,a]of Object.entries(o))e.set(n,i,a)}function Tl(e,n){if(Array.isArray(e))return e.find(o=>o.modelId===n)}function Un(e,n){var r,l,s,c,d,u,m,p;const o=Nb(n),i=new Ib(n.field),a=[...e].sort((f,h)=>f.seq-h.seq);for(const f of a)for(const h of f.ops)switch(o){case"entity":if(h.entityRef!==n.entityRef)break;h.kind==="entity.add"?sn(i,f,h.value,"entity"):h.kind==="entity.update"?po(i,f,h.patch):h.kind==="entity.remove"&&i.remove(f);break;case"attribute":if(h.entityRef!==n.entityRef)break;if(h.kind==="entity.add"){const g=Tl((r=h.value)==null?void 0:r.attributes,n.attributeRef);g&&sn(i,f,g,"attribute")}else h.kind==="attribute.add"&&((l=h.value)==null?void 0:l.modelId)===n.attributeRef?sn(i,f,h.value,"attribute"):h.kind==="attribute.update"&&h.attributeRef===n.attributeRef?po(i,f,h.patch):(h.kind==="attribute.remove"&&h.attributeRef===n.attributeRef||h.kind==="entity.remove")&&i.remove(f);break;case"operation":if(h.entityRef!==n.entityRef)break;if(h.kind==="entity.add"){const g=Tl((s=h.value)==null?void 0:s.operations,n.operationRef);g&&sn(i,f,g,"operation")}else h.kind==="operation.add"&&((c=h.value)==null?void 0:c.modelId)===n.operationRef?sn(i,f,h.value,"operation"):h.kind==="operation.update"&&h.operationRef===n.operationRef?po(i,f,h.patch):(h.kind==="operation.remove"&&h.operationRef===n.operationRef||h.kind==="entity.remove")&&i.remove(f);break;case"index":if(h.entityRef!==n.entityRef)break;if(h.kind==="entity.add"){const g=Tl((d=h.value)==null?void 0:d.indexes,n.indexRef);g&&sn(i,f,g,"index")}else h.kind==="index.add"&&((u=h.value)==null?void 0:u.modelId)===n.indexRef?sn(i,f,h.value,"index"):h.kind==="index.update"&&h.indexRef===n.indexRef?po(i,f,h.patch):(h.kind==="index.remove"&&h.indexRef===n.indexRef||h.kind==="entity.remove")&&i.remove(f);break;case"association":if(h.associationRef!==n.associationRef)break;h.kind==="association.add"?sn(i,f,h.value,"association"):h.kind==="association.update"?po(i,f,h.patch):h.kind==="association.remove"&&i.remove(f);break;case"associationEnd":if(h.associationRef!==n.associationRef)break;if(h.kind==="association.add"){const g=(m=h.value)==null?void 0:m[n.end];sn(i,f,g,"associationEnd")}else h.kind==="associationEnd.update"&&h.end===n.end?po(i,f,h.patch):h.kind==="association.remove"&&i.remove(f);break;case"group":if(h.groupRef!==n.groupRef)break;if(h.kind==="group.add"){sn(i,f,h.value,"group");const g=(p=h.value)==null?void 0:p.memberEntityRefs;if(Array.isArray(g))for(const b of g)i.member(f,b,!1)}else h.kind==="group.update"?po(i,f,h.patch):h.kind==="group.remove"?i.remove(f):h.kind==="group.addMember"&&h.entityRef!=null?i.member(f,h.entityRef,!1):h.kind==="group.removeMember"&&h.entityRef!=null&&i.member(f,h.entityRef,!0);break}return i.result()}const rt={subject:null,existence:null,fieldAudit:!1,note:"레이아웃 축(LWW) — 감사·복원 diff는 논리 축 전용(AA-5: layout/note는 의도적 범위 밖)"},vb={"entity.add":{subject:"entity",existence:"add",fieldAudit:!0},"entity.update":{subject:"entity",existence:null,fieldAudit:!0},"entity.remove":{subject:"entity",existence:"remove",fieldAudit:!0},"attribute.add":{subject:"attribute",existence:"add",fieldAudit:!0},"attribute.update":{subject:"attribute",existence:null,fieldAudit:!0},"attribute.remove":{subject:"attribute",existence:"remove",fieldAudit:!0},"operation.add":{subject:"operation",existence:"add",fieldAudit:!0},"operation.update":{subject:"operation",existence:null,fieldAudit:!0},"operation.remove":{subject:"operation",existence:"remove",fieldAudit:!0},"index.add":{subject:"index",existence:"add",fieldAudit:!0},"index.update":{subject:"index",existence:null,fieldAudit:!0},"index.remove":{subject:"index",existence:"remove",fieldAudit:!0},"attribute.reorder":{subject:null,existence:null,fieldAudit:!1,note:"과거 어휘(호스트 지원·lib 미방출). 컬렉션 순서 축이라 subject 단위 필드 변경으로 표현 안 됨"},"operation.reorder":{subject:null,existence:null,fieldAudit:!1,note:"과거 어휘(호스트 지원·lib 미방출). attribute.reorder와 동형"},"association.add":{subject:"association",existence:"add",fieldAudit:!0},"association.update":{subject:"association",existence:null,fieldAudit:!0},"association.remove":{subject:"association",existence:"remove",fieldAudit:!0},"associationEnd.update":{subject:"associationEnd",existence:null,fieldAudit:!0},"group.add":{subject:"group",existence:"add",fieldAudit:!0},"group.update":{subject:"group",existence:null,fieldAudit:!0},"group.remove":{subject:"group",existence:"remove",fieldAudit:!0},"group.addMember":{subject:"group",existence:null,fieldAudit:!0},"group.removeMember":{subject:"group",existence:null,fieldAudit:!0},"entityLayout.add":rt,"entityLayout.remove":rt,"entityLayout.move":rt,"entityLayout.resize":rt,"entityLayout.setCollapsed":rt,"entityLayout.setLocked":rt,"entityLayout.setStyle":rt,"entityLayout.setAttrStyle":rt,"entityLayout.setOpStyle":rt,"groupLayout.add":rt,"groupLayout.remove":rt,"groupLayout.move":rt,"groupLayout.resize":rt,"groupLayout.setLocked":rt,"groupLayout.setStyle":rt,"groupLayout.addNoteMember":rt,"groupLayout.removeNoteMember":rt,"associationLayout.add":rt,"associationLayout.remove":rt,"associationLayout.setWaypoints":rt,"note.add":rt,"note.remove":rt,"note.move":rt,"note.resize":rt,"note.setMemo":rt,"note.setStyle":rt,"noteConnection.add":rt,"noteConnection.remove":rt,"noteConnection.setWaypoints":rt},Gt=e=>typeof e=="string"?e:void 0,Cb=e=>{var n;return Gt((n=e.value)==null?void 0:n.modelId)};function Vd(e){return Gt(e.containerRef)??Gt(e.entityRef)}function Ml(e,n,o,i){var l;const a=(l=e.value)==null?void 0:l[n];if(!Array.isArray(a))return[];const r=[];for(const s of a){const c=Gt(s.modelId);c&&r.push({subject:{kind:o,ref:c,...i?{entityRef:i}:{}},existence:"add",inline:!0})}return r}function Vl(e){const n=vb[e.kind];if(!n||!n.subject)return[];const o=e,i=n.existence??void 0;switch(n.subject){case"entity":{const a=Gt(o.entityRef);if(!a)return[];const r={subject:{kind:"entity",ref:a},...i?{existence:i}:{}};return e.kind!=="entity.add"?[r]:[r,...Ml(o,"attributes","attribute",a),...Ml(o,"operations","operation",a),...Ml(o,"indexes","index",a)]}case"attribute":case"operation":case"index":{const a=n.subject,r=Vd(o),l={attribute:"attributeRef",operation:"operationRef",index:"indexRef"}[a],s=i==="add"?Cb(o):Gt(o[l]);return s?[{subject:{kind:a,ref:s,...r?{entityRef:r}:{}},...i?{existence:i}:{}}]:[]}case"association":case"associationEnd":{const a=Gt(o.associationRef);if(!a)return[];const r=o.end==="end1"||o.end==="end2"?o.end:void 0;return[{subject:{kind:n.subject,ref:a,...r?{end:r}:{}},...i?{existence:i}:{}}]}case"group":{const a=Gt(o.groupRef);return a?[{subject:{kind:"group",ref:a},...i?{existence:i}:{}}]:[]}}}function Sb(e){const n=e,o=e.kind;if(o.startsWith("entity.")){const i=Gt(n.entityRef);return i?{kind:"entity",ref:i}:null}if(o.startsWith("attribute.")||o.startsWith("operation.")||o.startsWith("index.")){const i=Vd(n);return i?{kind:"entity",ref:i}:null}if(o.startsWith("associationEnd.")||o.startsWith("association.")){const i=Gt(n.associationRef);return i?{kind:"association",ref:i}:null}if(o.startsWith("group.")){const i=Gt(n.groupRef);return i?{kind:"group",ref:i}:null}return null}function xb(e,n){const o=e;return o.entityRef===n||o.containerRef===n}function Rb(e,n){const o=new Set,i=new Set,a=new Set,r={attribute:o,operation:i,index:a};for(const l of e)for(const s of l.ops)for(const{subject:c}of Vl(s))c.kind==="entity"||c.entityRef!==n||c.kind in r&&r[c.kind].add(c.ref);return{attributes:o,operations:i,indexes:a}}function Aa(e,n){return e.map(o=>({...o,subject:n}))}function Bd(e,n){const o=e.filter(s=>s.ops.some(c=>xb(c,n))),{attributes:i,operations:a,indexes:r}=Rb(o,n),l=[...Aa(Un(o,{entityRef:n}),{kind:"entity",ref:n})];for(const s of i)l.push(...Aa(Un(o,{entityRef:n,attributeRef:s}),{kind:"attribute",ref:s}));for(const s of a)l.push(...Aa(Un(o,{entityRef:n,operationRef:s}),{kind:"operation",ref:s}));for(const s of r)l.push(...Aa(Un(o,{entityRef:n,indexRef:s}),{kind:"index",ref:s}));return l.map((s,c)=>({e:s,i:c})).sort((s,c)=>s.e.seq-c.e.seq||s.i-c.i).map(({e:s})=>s)}function Bl(e){return`${e.kind}:${e.ref}:${e.end??""}`}function Ab(e){const n=new Set;for(const o of e)for(const i of o.ops)for(const a of Vl(i))a.existence==="add"&&n.add(Bl(a.subject));return n}function $b(e){const n=new Set,o=new Set,i=new Set,a={entity:n,association:o,group:i};for(const r of e)for(const l of r.ops){const s=Sb(l);s&&a[s.kind].add(s.ref)}return{entities:n,associations:o,groups:i}}function Tb(e){const{entities:n,associations:o,groups:i}=$b(e),a=[];for(const r of n)for(const l of Bd(e,r))a.push({...l,subject:{...l.subject,entityRef:r}});for(const r of o){for(const l of Un(e,{associationRef:r}))a.push({...l,subject:{kind:"association",ref:r}});for(const l of["end1","end2"])for(const s of Un(e,{associationRef:r,end:l}))a.push({...s,subject:{kind:"associationEnd",ref:r,end:l}})}for(const r of i)for(const l of Un(e,{groupRef:r}))a.push({...l,subject:{kind:"group",ref:r}});return a}function Dl(e){const n=Tb(e),o=Ab(e),i=new Map;for(const l of n){const s=Bl(l.subject),c=i.get(s);(c===void 0||l.seq<c)&&i.set(s,l.seq)}const a=new Map;for(const l of n){let s=a.get(l.seq);s||(s={meta:l,subjects:new Map},a.set(l.seq,s));const c=Bl(l.subject);let d=s.subjects.get(c);if(!d){const u=l.removed?"remove":i.get(c)===l.seq&&o.has(c)?"add":"update";d={subject:l.subject,verb:u,fields:[]},s.subjects.set(c,d)}l.removed?d.verb="remove":d.fields.push({field:l.field,value:l.value,...l.oldValue!==void 0?{oldValue:l.oldValue}:{}})}const r=[];for(const[l,s]of a){const c=s.meta;r.push({seq:l,...c.ts!==void 0?{ts:c.ts}:{},...c.origin!==void 0?{origin:c.origin}:{},...c.author!==void 0?{author:c.author}:{},...c.kind!==void 0?{kind:c.kind}:{},...c.restoredFromSeq!==void 0?{restoredFromSeq:c.restoredFromSeq}:{},actions:[...s.subjects.values()]})}return r.sort((l,s)=>s.seq-l.seq)}function Dd(e){return`${e.kind}:${e.ref}:${e.end??""}`}function Mb(e,n,o){const i=[];for(const a of e)if(!(a.seq<=n||a.seq>o))for(const r of a.ops)for(const l of Vl(r)){if(!l.existence||l.inline)continue;const s=l.subject;Vb.has(s.kind)&&!s.entityRef||i.push({seq:a.seq,subject:s,verb:l.existence,fields:[]})}return i}const Vb=new Set(["attribute","operation","index"]);function Ll(e,n){const{fromSeq:o}=n,i=Dl(e);let a=o;for(const m of e)m.seq>a&&(a=m.seq);const r=n.toSeq??a,l=i.filter(m=>m.seq>o&&m.seq<=r).reverse(),s=new Map,c=m=>{const p=Dd(m.subject);let f=s.get(p);f||(f={subject:m.subject,evs:[]},s.set(p,f)),f.evs.push(m)};for(const m of l)for(const p of m.actions)c({seq:m.seq,subject:p.subject,verb:p.verb,fields:p.fields});for(const m of Mb(e,o,r)){const p=s.get(Dd(m.subject));p!=null&&p.evs.some(f=>f.seq===m.seq)||c(m)}const d=[],u=new Set;for(const m of s.values()){m.evs.sort((f,h)=>f.seq-h.seq);const p=m.evs[m.evs.length-1];m.subject.kind==="entity"&&p.verb==="remove"&&u.add(m.subject.ref)}for(const m of s.values()){const p=m.evs[0].verb==="add",f=m.evs[m.evs.length-1].verb==="remove";if(m.subject.kind!=="entity"&&m.subject.entityRef&&u.has(m.subject.entityRef)||p&&f)continue;const h=new Map;let g=null;for(const _ of m.evs){_.verb==="add"&&g!==null&&g!=="add"&&h.clear(),g=_.verb;for(const E of _.fields){const N=h.get(E.field);N?N.lastValue=E.value:h.set(E.field,{firstOld:E.oldValue,hasOld:E.oldValue!==void 0,lastValue:E.value})}}if(f){d.push({subject:m.subject,verb:"removed",fields:[]});continue}if(p){const _=[];for(const[E,N]of h)_.push({field:E,value:N.lastValue});d.push({subject:m.subject,verb:"added",fields:_});continue}const b=[];for(const[_,E]of h)E.hasOld&&uo(E.firstOld,E.lastValue)||b.push({field:_,value:E.lastValue,...E.hasOld?{oldValue:E.firstOld}:{}});b.length!==0&&d.push({subject:m.subject,verb:"modified",fields:b})}return{fromSeq:o,toSeq:r,entries:d}}function Ld(e){const n=new Map,o=i=>{let a=n.get(i);return a||(a={verb:"modified",changedAttributeIds:new Set,changedOperationIds:new Set},n.set(i,a)),a};for(const i of e.entries){const a=i.subject;if(a.kind==="entity"){if(i.verb==="removed")continue;o(a.ref).verb=i.verb}else if((a.kind==="attribute"||a.kind==="operation"||a.kind==="index")&&a.entityRef){const r=o(a.entityRef);i.verb!=="removed"&&(a.kind==="attribute"?r.changedAttributeIds.add(a.ref):a.kind==="operation"&&r.changedOperationIds.add(a.ref))}}return n}class Ol{constructor(n){ct(this,"undoStack",[]);ct(this,"redoStack",[]);ct(this,"savePoint",null);ct(this,"listeners",new Set);ct(this,"commandListeners",new Set);ct(this,"coalesceSealed",!1);this.state=n}execute(n){n.apply(this.state);const o=this.undoStack.at(-1),i=!this.coalesceSealed&&n.coalesceKey!=null&&!!o&&o.coalesceKey===n.coalesceKey;this.coalesceSealed=!1,i?(n.invert=o.invert,this.undoStack[this.undoStack.length-1]=n):this.undoStack.push(n),this.redoStack=[],this.emitCommand(n,"do",i),this.emit()}undo(){const n=this.undoStack.pop();n&&(n.invert(this.state),this.redoStack.push(n),this.emitCommand(n,"undo",!1),this.emit())}redo(){const n=this.redoStack.pop();n&&(n.apply(this.state),this.undoStack.push(n),this.emitCommand(n,"redo",!1),this.emit())}sealCoalesce(){this.coalesceSealed=!0}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}markSavePoint(){this.savePoint=this.undoStack.at(-1)??null,this.sealCoalesce(),this.emit()}get isDirty(){return(this.undoStack.at(-1)??null)!==this.savePoint}onChange(n){return this.listeners.add(n),()=>this.listeners.delete(n)}onCommand(n){return this.commandListeners.add(n),()=>this.commandListeners.delete(n)}emit(){for(const n of this.listeners)n()}emitCommand(n,o,i){for(const a of this.commandListeners)a(n,o,i)}}function Dt(e){const n={};for(const[o,i]of Object.entries(e))n[o]=i===void 0?null:i;return n}function Od(e,n){return e.logical.entities.findIndex(o=>o.modelId===n)}function wt(e,n){return e.layout.entityLayouts.findIndex(o=>o.entityRef===n)}function Yt(e,n){return e.layout.associationLayouts.find(o=>o.associationRef===n)}function dt(e,n){const o=e.logical.entities.find(i=>i.modelId===n);if(!o)throw new Error(`엔티티 없음: ${n}`);return o}function wn(e,n,o){var i,a;return(a=(i=e.layout.notes.find(r=>r.modelId===n))==null?void 0:i.connections)==null?void 0:a.find(r=>r.targetRef===o)}function $a(e,n,o){return{label:`엔티티 추가: ${e.name}`,apply(i){i.logical.entities.push(e),i.layout.entityLayouts.push({entityRef:e.modelId,geo:n,...o})},invert(i){const a=Od(i,e.modelId);a>=0&&i.logical.entities.splice(a,1);const r=wt(i,e.modelId);r>=0&&i.layout.entityLayouts.splice(r,1)},emitOps(){const i={kind:"entity.add",casUnit:"logical",entityRef:e.modelId,value:e},a={kind:"entityLayout.add",casUnit:"layout",entityRef:e.modelId,value:{entityRef:e.modelId,geo:n,...o},incidental:!0};return{forward:[i,a],invert:[{kind:"entityLayout.remove",casUnit:"layout",entityRef:e.modelId,incidental:!0},{kind:"entity.remove",casUnit:"logical",entityRef:e.modelId}]}}}}function Pd(e){let n=null;const o=i=>i.end1.entityRef===e||i.end2.entityRef===e;return{label:"엔티티 삭제",apply(i){const a=Od(i,e);if(a<0)throw new Error(`엔티티 없음: ${e}`);const r=wt(i,e),l=[];i.logical.associations.forEach((u,m)=>{o(u)&&l.push({item:u,index:m})});const s=new Set(l.map(u=>u.item.modelId)),c=[];i.layout.associationLayouts.forEach((u,m)=>{s.has(u.associationRef)&&c.push({item:u,index:m})});const d=[];i.logical.groups.forEach(u=>{const m=u.memberEntityRefs.indexOf(e);m>=0&&d.push({groupId:u.modelId,index:m})}),n={entity:{item:i.logical.entities[a],index:a},entityLayout:r>=0?{item:i.layout.entityLayouts[r],index:r}:void 0,assocs:l,assocLayouts:c,groupMemberships:d},[...c].sort((u,m)=>m.index-u.index).forEach(u=>i.layout.associationLayouts.splice(u.index,1)),[...l].sort((u,m)=>m.index-u.index).forEach(u=>i.logical.associations.splice(u.index,1));for(const u of d){const m=i.logical.groups.find(p=>p.modelId===u.groupId);m==null||m.memberEntityRefs.splice(u.index,1)}r>=0&&i.layout.entityLayouts.splice(r,1),i.logical.entities.splice(a,1)},invert(i){if(n){i.logical.entities.splice(n.entity.index,0,n.entity.item),n.entityLayout&&i.layout.entityLayouts.splice(n.entityLayout.index,0,n.entityLayout.item),[...n.assocs].sort((a,r)=>a.index-r.index).forEach(a=>i.logical.associations.splice(a.index,0,a.item)),[...n.assocLayouts].sort((a,r)=>a.index-r.index).forEach(a=>i.layout.associationLayouts.splice(a.index,0,a.item));for(const a of n.groupMemberships){const r=i.logical.groups.find(l=>l.modelId===a.groupId);r==null||r.memberEntityRefs.splice(a.index,0,e)}}},emitOps(){if(!n)return{forward:[],invert:[]};const i=[],a=[];for(const r of n.assocs)i.push({kind:"association.remove",casUnit:"logical",associationRef:r.item.modelId}),a.push({kind:"association.add",casUnit:"logical",associationRef:r.item.modelId,value:r.item});for(const r of n.assocLayouts)i.push({kind:"associationLayout.remove",casUnit:"layout",associationRef:r.item.associationRef,incidental:!0}),a.push({kind:"associationLayout.add",casUnit:"layout",associationRef:r.item.associationRef,value:r.item,incidental:!0});for(const r of n.groupMemberships)i.push({kind:"group.removeMember",casUnit:"logical",containerRef:r.groupId,groupRef:r.groupId,entityRef:e}),a.push({kind:"group.addMember",casUnit:"logical",containerRef:r.groupId,groupRef:r.groupId,entityRef:e});return n.entityLayout&&(i.push({kind:"entityLayout.remove",casUnit:"layout",entityRef:e,incidental:!0}),a.push({kind:"entityLayout.add",casUnit:"layout",entityRef:e,value:n.entityLayout.item,incidental:!0})),i.push({kind:"entity.remove",casUnit:"logical",entityRef:e}),a.push({kind:"entity.add",casUnit:"logical",entityRef:e,value:n.entity.item}),{forward:i,invert:a.reverse()}}}}function Pl(e,n){const o={};return{label:"엔티티 수정",apply(i){const a=dt(i,e);for(const r of Object.keys(n))o[r]=a[r];Object.assign(a,n)},invert(i){Object.assign(dt(i,e),o)},emitOps(){return{forward:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:Dt(n)}],invert:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:Dt(o)}]}}}}function zd(e,n){let o="";return{label:`엔티티 이름 변경: ${n}`,apply(i){const a=dt(i,e);o=a.name,a.name=n},invert(i){dt(i,e).name=o},emitOps(){return{forward:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{name:n}}],invert:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{name:o}}]}}}}function Go(e,n){let o=null;return{label:"엔티티 이동",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a].geo;o={...r.location},r.location={...n}},invert(i){const a=wt(i,e);a>=0&&o&&(i.layout.entityLayouts[a].geo.location=o)},emitOps(){const i=a=>({kind:"entityLayout.move",casUnit:"layout",entityRef:e,value:{location:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function Fd(e,n){let o=null;return{label:"엔티티 크기 변경",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a].geo;o={...r.size},r.size={...n}},invert(i){const a=wt(i,e);a>=0&&o&&(i.layout.entityLayouts[a].geo.size=o)},emitOps(){const i=a=>({kind:"entityLayout.resize",casUnit:"layout",entityRef:e,value:{size:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function Ii(e,n){const o={...(e==null?void 0:e.properties)??{}};return n?o.swatch=n:delete o.swatch,Object.keys(o).length?{properties:o}:void 0}function Ud(e,n){let o;return{label:"엔티티 색상 변경",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a];o=r.style,r.style=Ii(r.style,n)},invert(i){const a=wt(i,e);a>=0&&(i.layout.entityLayouts[a].style=o)},emitOps(i){const a=wt(i,e),r=a>=0?i.layout.entityLayouts[a].style:void 0,l=s=>({kind:"entityLayout.setStyle",casUnit:"layout",entityRef:e,value:{style:s}});return{forward:[l(r)],invert:[l(o)]}}}}function Hd(e,n){let o;return{label:n?"엔티티 접기":"엔티티 펼치기",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a];o=r.collapsed,r.collapsed=n},invert(i){const a=wt(i,e);a>=0&&(i.layout.entityLayouts[a].collapsed=o)},emitOps(){const i=a=>({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:e,value:{collapsed:a}});return{forward:[i(n)],invert:[i(o)]}}}}function jd(e,n){let o;return{label:n?"엔티티 잠금":"엔티티 잠금 해제",apply(i){const a=wt(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=i.layout.entityLayouts[a];o=r.locked,r.locked=n},invert(i){const a=wt(i,e);a>=0&&(i.layout.entityLayouts[a].locked=o)},emitOps(){const i=a=>({kind:"entityLayout.setLocked",casUnit:"layout",entityRef:e,value:{locked:a}});return{forward:[i(n)],invert:[i(o)]}}}}function zl(e){let n=[];return{label:e?"모두 접기":"모두 펼치기",apply(o){n=o.layout.entityLayouts.map(i=>i.collapsed);for(const i of o.layout.entityLayouts)i.collapsed=e},invert(o){o.layout.entityLayouts.forEach((i,a)=>{i.collapsed=n[a]})},emitOps(o){const i=[],a=[];return o.layout.entityLayouts.forEach((r,l)=>{i.push({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:r.entityRef,value:{collapsed:e}}),a.push({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:r.entityRef,value:{collapsed:n[l]}})}),{forward:i,invert:a}}}}function Ta(e,n,o){let i;return{label:"속성 색상 변경",apply(a){const r=wt(a,e);if(r<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=a.layout.entityLayouts[r];i=l.attributeStyles;const s={...l.attributeStyles},c=Ii(s[n],o);c?s[n]=c:delete s[n],l.attributeStyles=Object.keys(s).length?s:void 0},invert(a){const r=wt(a,e);r>=0&&(a.layout.entityLayouts[r].attributeStyles=i)},emitOps(a){const r=wt(a,e),l=r>=0?a.layout.entityLayouts[r].attributeStyles:void 0,s=c=>({kind:"entityLayout.setAttrStyle",casUnit:"layout",entityRef:e,value:{attributeStyles:c}});return{forward:[s(l)],invert:[s(i)]}}}}function Ma(e,n,o){return{label:"그룹 추가",apply(i){i.logical.groups.push(e),i.layout.groupLayouts.push({groupRef:e.modelId,geo:n,...o})},invert(i){const a=i.logical.groups.findIndex(l=>l.modelId===e.modelId);a>=0&&i.logical.groups.splice(a,1);const r=i.layout.groupLayouts.findIndex(l=>l.groupRef===e.modelId);r>=0&&i.layout.groupLayouts.splice(r,1)},emitOps(){const i={kind:"group.add",casUnit:"logical",groupRef:e.modelId,value:e},a={kind:"groupLayout.add",casUnit:"layout",groupRef:e.modelId,value:{groupRef:e.modelId,geo:n,...o},incidental:!0};return{forward:[i,a],invert:[{kind:"groupLayout.remove",casUnit:"layout",groupRef:e.modelId,incidental:!0},{kind:"group.remove",casUnit:"logical",groupRef:e.modelId}]}}}}function Kd(e,n){const o={},i=a=>{const r=a.logical.groups.find(l=>l.modelId===e);if(!r)throw new Error(`그룹 없음: ${e}`);return r};return{label:"그룹 수정",apply(a){const r=i(a);for(const l of Object.keys(n))o[l]=r[l];Object.assign(r,n)},invert(a){Object.assign(i(a),o)},emitOps(){return{forward:[{kind:"group.update",casUnit:"logical",containerRef:e,groupRef:e,patch:Dt(n)}],invert:[{kind:"group.update",casUnit:"logical",containerRef:e,groupRef:e,patch:Dt(o)}]}}}}function Gd(e){let n=null;return{label:"그룹 해제",apply(o){const i=o.logical.groups.findIndex(r=>r.modelId===e);if(i<0)throw new Error(`그룹 없음: ${e}`);const a=o.layout.groupLayouts.findIndex(r=>r.groupRef===e);n={group:{item:o.logical.groups[i],index:i},layout:a>=0?{item:o.layout.groupLayouts[a],index:a}:void 0},a>=0&&o.layout.groupLayouts.splice(a,1),o.logical.groups.splice(i,1)},invert(o){n&&(o.logical.groups.splice(n.group.index,0,n.group.item),n.layout&&o.layout.groupLayouts.splice(n.layout.index,0,n.layout.item))},emitOps(){if(!n)return{forward:[],invert:[]};const o=[],i=[];return n.layout&&(o.push({kind:"groupLayout.remove",casUnit:"layout",groupRef:e,incidental:!0}),i.push({kind:"groupLayout.add",casUnit:"layout",groupRef:e,value:n.layout.item,incidental:!0})),o.push({kind:"group.remove",casUnit:"logical",groupRef:e}),i.push({kind:"group.add",casUnit:"logical",groupRef:e,value:n.group.item}),{forward:o,invert:i.reverse()}}}}function Yd(e,n){let o=!1;const i=a=>a.logical.groups.find(r=>r.modelId===e);return{label:"그룹에 편입",apply(a){const r=i(a);r&&!r.memberEntityRefs.includes(n)&&(r.memberEntityRefs.push(n),o=!0)},invert(a){if(!o)return;const r=i(a),l=(r==null?void 0:r.memberEntityRefs.indexOf(n))??-1;l>=0&&r.memberEntityRefs.splice(l,1)},emitOps(){return o?{forward:[{kind:"group.addMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:n}],invert:[{kind:"group.removeMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:n}]}:{forward:[],invert:[]}}}}function Va(e,n){let o=-1;const i=a=>a.logical.groups.find(r=>r.modelId===e);return{label:"그룹에서 제외",apply(a){const r=i(a);o=(r==null?void 0:r.memberEntityRefs.indexOf(n))??-1,o>=0&&r.memberEntityRefs.splice(o,1)},invert(a){var r;o<0||(r=i(a))==null||r.memberEntityRefs.splice(o,0,n)},emitOps(){return o<0?{forward:[],invert:[]}:{forward:[{kind:"group.removeMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:n}],invert:[{kind:"group.addMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:n}]}}}}function qd(e,n){let o=null;return{label:"그룹 이동",apply(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o={...a.geo.location},a.geo.location={...n}},invert(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);a&&o&&(a.geo.location=o)},emitOps(){const i=a=>({kind:"groupLayout.move",casUnit:"layout",groupRef:e,value:{location:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function Wd(e,n){let o=null;return{label:"그룹 크기 변경",apply(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o={...a.geo.size},a.geo.size={...n}},invert(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);a&&o&&(a.geo.size=o)},emitOps(){const i=a=>({kind:"groupLayout.resize",casUnit:"layout",groupRef:e,value:{size:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function Jd(e,n){let o;return{label:"그룹 색상 변경",apply(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o=a.style,a.style=Ii(a.style,n)},invert(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);a&&(a.style=o)},emitOps(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e),r=l=>({kind:"groupLayout.setStyle",casUnit:"layout",groupRef:e,value:{style:l}});return{forward:[r(a==null?void 0:a.style)],invert:[r(o)]}}}}function Xd(e,n){let o;return{label:n?"그룹 잠금":"그룹 잠금 해제",apply(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o=a.locked,a.locked=n},invert(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e);a&&(a.locked=o)},emitOps(){const i=a=>({kind:"groupLayout.setLocked",casUnit:"layout",groupRef:e,value:{locked:a}});return{forward:[i(n)],invert:[i(o)]}}}}function qt(e,n){return{label:`속성 추가: ${n.name}`,apply(o){dt(o,e).attributes.push(n)},invert(o){const i=dt(o,e),a=i.attributes.findIndex(r=>r.modelId===n.modelId);a>=0&&i.attributes.splice(a,1)},emitOps(){return{forward:[{kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:n}],invert:[{kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:n.modelId}]}}}}function Wt(e,n,o){const i={},a=r=>{const l=dt(r,e).attributes.find(s=>s.modelId===n);if(!l)throw new Error(`속성 없음: ${n}`);return l};return{label:"속성 수정",apply(r){const l=a(r);for(const s of Object.keys(o))i[s]=l[s];Object.assign(l,o)},invert(r){Object.assign(a(r),i)},emitOps(){return{forward:[{kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:n,patch:Dt(o)}],invert:[{kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:n,patch:Dt(i)}]}}}}function Zd(e,n){let o=null;return{label:"속성 삭제",apply(i){const a=dt(i,e),r=a.attributes.findIndex(l=>l.modelId===n);if(r<0)throw new Error(`속성 없음: ${n}`);o={item:a.attributes[r],index:r},a.attributes.splice(r,1)},invert(i){o&&dt(i,e).attributes.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:n}],invert:[{kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}function Qd(e,n,o,i,a){const r=new Map(a.map(c=>[c.modelId,c.order])),l=[],s=[];for(const c of i){const d=r.get(c.modelId);if(d===c.order)continue;const u=n==="attributeRef"?{attributeRef:c.modelId}:{operationRef:c.modelId};l.push({kind:e,casUnit:"logical",containerRef:o,entityRef:o,...u,patch:{order:c.order}}),s.push({kind:e,casUnit:"logical",containerRef:o,entityRef:o,...u,patch:{order:d??c.order}})}return{forward:l,invert:s}}function Fl(e,n,o){let i=null;return{label:"속성 재정렬",apply(a){const r=dt(a,e);i=r.attributes.map(s=>({...s}));const l=Rl([...r.attributes].sort((s,c)=>s.order-c.order),n,o);r.attributes.splice(0,r.attributes.length,...l),r.attributes.forEach((s,c)=>s.order=c)},invert(a){i&&dt(a,e).attributes.splice(0,1/0,...i)},emitOps(a){const r=dt(a,e).attributes;return Qd("attribute.update","attributeRef",e,r,i??[])}}}function eu(e,n){let o=!1;return{label:`메서드 추가: ${n.name}`,apply(i){const a=dt(i,e);a.operations||(a.operations=[],o=!0),a.operations.push(n)},invert(i){var l;const a=dt(i,e),r=((l=a.operations)==null?void 0:l.findIndex(s=>s.modelId===n.modelId))??-1;r>=0&&a.operations.splice(r,1),o&&a.operations&&a.operations.length===0&&(a.operations=void 0)},emitOps(){return{forward:[{kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:n}],invert:[{kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:n.modelId}]}}}}function tu(e,n,o){const i={},a=r=>{var s;const l=(s=dt(r,e).operations)==null?void 0:s.find(c=>c.modelId===n);if(!l)throw new Error(`메서드 없음: ${n}`);return l};return{label:"메서드 수정",apply(r){const l=a(r);for(const s of Object.keys(o))i[s]=l[s];Object.assign(l,o)},invert(r){Object.assign(a(r),i)},emitOps(){return{forward:[{kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:n,patch:Dt(o)}],invert:[{kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:n,patch:Dt(i)}]}}}}function nu(e,n){let o=null;return{label:"메서드 삭제",apply(i){var s;const a=dt(i,e),r=((s=a.operations)==null?void 0:s.findIndex(c=>c.modelId===n))??-1;if(r<0)throw new Error(`메서드 없음: ${n}`);const l=a.operations.length===1;o={item:a.operations[r],index:r,wasSole:l},a.operations.splice(r,1),l&&(a.operations=void 0)},invert(i){if(!o)return;const a=dt(i,e);a.operations||(a.operations=[]),a.operations.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:n}],invert:[{kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}function ou(e,n,o){let i=null;return{label:"메서드 재정렬",apply(a){const r=dt(a,e),l=r.operations??[];i=l.map(c=>({...c}));const s=Rl([...l].sort((c,d)=>c.order-d.order),n,o);l.splice(0,l.length,...s),l.forEach((c,d)=>c.order=d),r.operations=l},invert(a){if(!i)return;const r=dt(a,e);r.operations&&r.operations.splice(0,1/0,...i)},emitOps(a){const r=dt(a,e).operations??[];return Qd("operation.update","operationRef",e,r,i??[])}}}function iu(e,n,o){let i;return{label:"메서드 색상 변경",apply(a){const r=wt(a,e);if(r<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=a.layout.entityLayouts[r];i=l.operationStyles;const s={...l.operationStyles},c=Ii(s[n],o);c?s[n]=c:delete s[n],l.operationStyles=Object.keys(s).length?s:void 0},invert(a){const r=wt(a,e);r>=0&&(a.layout.entityLayouts[r].operationStyles=i)},emitOps(a){const r=wt(a,e),l=r>=0?a.layout.entityLayouts[r].operationStyles:void 0,s=c=>({kind:"entityLayout.setOpStyle",casUnit:"layout",entityRef:e,value:{operationStyles:c}});return{forward:[s(l)],invert:[s(i)]}}}}function Ba(e,n){return{label:"관계 추가",apply(o){o.logical.associations.push(e),o.layout.associationLayouts.push(n)},invert(o){const i=o.logical.associations.findIndex(r=>r.modelId===e.modelId);i>=0&&o.logical.associations.splice(i,1);const a=o.layout.associationLayouts.findIndex(r=>r.associationRef===e.modelId);a>=0&&o.layout.associationLayouts.splice(a,1)},emitOps(){const o={kind:"association.add",casUnit:"logical",associationRef:e.modelId,value:e},i={kind:"associationLayout.add",casUnit:"layout",associationRef:e.modelId,value:n,incidental:!0};return{forward:[o,i],invert:[{kind:"associationLayout.remove",casUnit:"layout",associationRef:e.modelId,incidental:!0},{kind:"association.remove",casUnit:"logical",associationRef:e.modelId}]}}}}function au(e){let n=null;return{label:"관계 삭제",apply(o){const i=o.logical.associations.findIndex(r=>r.modelId===e);if(i<0)throw new Error(`관계 없음: ${e}`);const a=o.layout.associationLayouts.findIndex(r=>r.associationRef===e);n={assoc:{item:o.logical.associations[i],index:i},layout:a>=0?{item:o.layout.associationLayouts[a],index:a}:void 0},a>=0&&o.layout.associationLayouts.splice(a,1),o.logical.associations.splice(i,1)},invert(o){n&&(o.logical.associations.splice(n.assoc.index,0,n.assoc.item),n.layout&&o.layout.associationLayouts.splice(n.layout.index,0,n.layout.item))},emitOps(){if(!n)return{forward:[],invert:[]};const o=[],i=[];return n.layout&&(o.push({kind:"associationLayout.remove",casUnit:"layout",associationRef:e,incidental:!0}),i.push({kind:"associationLayout.add",casUnit:"layout",associationRef:e,value:n.layout.item,incidental:!0})),o.push({kind:"association.remove",casUnit:"logical",associationRef:e}),i.push({kind:"association.add",casUnit:"logical",associationRef:e,value:n.assoc.item}),{forward:o,invert:i.reverse()}}}}function Da(e,n){const o={},i=a=>{const r=a.logical.associations.find(l=>l.modelId===e);if(!r)throw new Error(`관계 없음: ${e}`);return r};return{label:"관계 수정",apply(a){const r=i(a);for(const l of Object.keys(n))o[l]=r[l];Object.assign(r,n)},invert(a){Object.assign(i(a),o)},emitOps(){return{forward:[{kind:"association.update",casUnit:"logical",containerRef:e,associationRef:e,patch:Dt(n)}],invert:[{kind:"association.update",casUnit:"logical",containerRef:e,associationRef:e,patch:Dt(o)}]}}}}function Jt(e,n,o){const i={},a=r=>{const l=r.logical.associations.find(s=>s.modelId===e);if(!l)throw new Error(`관계 없음: ${e}`);return l[n]};return{label:"관계 수정",apply(r){const l=a(r);for(const s of Object.keys(o))i[s]=l[s];Object.assign(l,o)},invert(r){Object.assign(a(r),i)},emitOps(){return{forward:[{kind:"associationEnd.update",casUnit:"logical",containerRef:e,associationRef:e,end:n,patch:Dt(o)}],invert:[{kind:"associationEnd.update",casUnit:"logical",containerRef:e,associationRef:e,end:n,patch:Dt(i)}]}}}}function ru(e,n){return{label:"인덱스 추가",apply(o){const i=dt(o,e);(i.indexes??(i.indexes=[])).push(n)},invert(o){var r;const i=dt(o,e),a=((r=i.indexes)==null?void 0:r.findIndex(l=>l.modelId===n.modelId))??-1;a>=0&&i.indexes.splice(a,1)},emitOps(){return{forward:[{kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:n}],invert:[{kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:n.modelId}]}}}}function La(e,n,o){const i={},a=r=>{var s;const l=(s=dt(r,e).indexes)==null?void 0:s.find(c=>c.modelId===n);if(!l)throw new Error(`인덱스 없음: ${n}`);return l};return{label:"인덱스 수정",apply(r){const l=a(r);for(const s of Object.keys(o))i[s]=l[s];Object.assign(l,o)},invert(r){Object.assign(a(r),i)},emitOps(){return{forward:[{kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:n,patch:Dt(o)}],invert:[{kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:n,patch:Dt(i)}]}}}}function lu(e,n){let o=null;return{label:"인덱스 삭제",apply(i){var l;const a=dt(i,e),r=((l=a.indexes)==null?void 0:l.findIndex(s=>s.modelId===n))??-1;if(r<0)throw new Error(`인덱스 없음: ${n}`);o={item:a.indexes[r],index:r},a.indexes.splice(r,1)},invert(i){o&&dt(i,e).indexes.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:n}],invert:[{kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}const cn=(e,n)=>({kind:"associationLayout.setWaypoints",casUnit:"layout",associationRef:e,value:{waypoints:n}}),vi=(e,n)=>{var o;return((o=Yt(e,n))==null?void 0:o.waypoints.map(i=>({...i})))??[]};function su(e,n,o){let i=null;return{label:"waypoint 이동",coalesceKey:`waypoint:${e}`,apply(a){const r=Yt(a,e);if(!r||!r.waypoints[n])throw new Error(`waypoint 없음: ${e}[${n}]`);i={...r.waypoints[n]},r.waypoints.splice(n,1,{...o})},invert(a){const r=Yt(a,e);r&&i&&r.waypoints.splice(n,1,i)},emitOps(a){const r=vi(a,e),l=r.map((s,c)=>c===n&&i?{...i}:s);return{forward:[cn(e,r)],invert:[cn(e,l)]}}}}function cu(e,n){let o=null;return{label:"waypoint 제거",apply(i){const a=Yt(i,e);if(!a||!a.waypoints[n])throw new Error(`waypoint 없음: ${e}[${n}]`);o={...a.waypoints[n]},a.waypoints.splice(n,1)},invert(i){const a=Yt(i,e);a&&o&&a.waypoints.splice(n,0,o)},emitOps(i){const a=vi(i,e),r=a.slice();return o&&r.splice(n,0,{...o}),{forward:[cn(e,a)],invert:[cn(e,r)]}}}}function du(e,n,o){let i=null;return{label:"waypoint 평행이동",apply(a){const r=Yt(a,e);if(!r)throw new Error(`관계 레이아웃 없음: ${e}`);i=r.waypoints.map(l=>({...l})),r.waypoints=i.map(l=>({x:l.x+n,y:l.y+o}))},invert(a){const r=Yt(a,e);r&&i&&(r.waypoints=i)},emitOps(a){return{forward:[cn(e,vi(a,e))],invert:[cn(e,i??[])]}}}}function uu(e){let n=null;return{label:"꺾은선 풀기",apply(o){const i=Yt(o,e);if(!i)throw new Error(`관계 레이아웃 없음: ${e}`);n=i.waypoints.map(a=>({...a})),i.waypoints=[]},invert(o){const i=Yt(o,e);i&&n&&(i.waypoints=n)},emitOps(o){return{forward:[cn(e,vi(o,e))],invert:[cn(e,n??[])]}}}}function mu(e,n,o){return{label:"waypoint 추가",apply(i){const a=Yt(i,e);if(!a)throw new Error(`관계 레이아웃 없음: ${e}`);a.waypoints.splice(n,0,{...o})},invert(i){const a=Yt(i,e);a==null||a.waypoints.splice(n,1)},emitOps(i){const a=vi(i,e),r=a.slice();return r.splice(n,1),{forward:[cn(e,a)],invert:[cn(e,r)]}}}}function fu(e){return{label:"노트 추가",apply(n){n.layout.notes.push(e)},invert(n){const o=n.layout.notes.findIndex(i=>i.modelId===e.modelId);o>=0&&n.layout.notes.splice(o,1)},emitOps(){return{forward:[{kind:"note.add",casUnit:"layout",noteRef:e.modelId,value:e}],invert:[{kind:"note.remove",casUnit:"layout",noteRef:e.modelId}]}}}}function pu(e){let n=null;return{label:"노트 삭제",apply(o){const i=o.layout.notes.findIndex(a=>a.modelId===e);if(i<0)throw new Error(`노트 없음: ${e}`);n={item:o.layout.notes[i],index:i},o.layout.notes.splice(i,1)},invert(o){n&&o.layout.notes.splice(n.index,0,n.item)},emitOps(){return n?{forward:[{kind:"note.remove",casUnit:"layout",noteRef:e}],invert:[{kind:"note.add",casUnit:"layout",noteRef:e,value:n.item}]}:{forward:[],invert:[]}}}}function Ci(e,n){let o=null;return{label:"노트 이동",apply(i){const a=i.layout.notes.find(r=>r.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o={...a.geo.location},a.geo.location={...n}},invert(i){const a=i.layout.notes.find(r=>r.modelId===e);a&&o&&(a.geo.location=o)},emitOps(){const i=a=>({kind:"note.move",casUnit:"layout",noteRef:e,value:{location:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function hu(e,n){let o=null;return{label:"노트 크기 변경",apply(i){const a=i.layout.notes.find(r=>r.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o={...a.geo.size},a.geo.size={...n}},invert(i){const a=i.layout.notes.find(r=>r.modelId===e);a&&o&&(a.geo.size=o)},emitOps(){const i=a=>({kind:"note.resize",casUnit:"layout",noteRef:e,value:{size:{...a}}});return{forward:[i(n)],invert:[i(o)]}}}}function yu(e,n){let o="";return{label:"노트 내용 변경",apply(i){const a=i.layout.notes.find(r=>r.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o=a.memo,a.memo=n},invert(i){const a=i.layout.notes.find(r=>r.modelId===e);a&&(a.memo=o)},emitOps(){const i=a=>({kind:"note.setMemo",casUnit:"layout",noteRef:e,value:{memo:a}});return{forward:[i(n)],invert:[i(o)]}}}}function gu(e,n){let o;return{label:"노트 색상 변경",apply(i){const a=i.layout.notes.find(r=>r.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o=a.style,a.style=Ii(a.style,n)},invert(i){const a=i.layout.notes.find(r=>r.modelId===e);a&&(a.style=o)},emitOps(i){const a=i.layout.notes.find(l=>l.modelId===e),r=l=>({kind:"note.setStyle",casUnit:"layout",noteRef:e,value:{style:l}});return{forward:[r(a==null?void 0:a.style)],invert:[r(o)]}}}}function bu(e,n){let o=!1,i=!1;const a=r=>r.layout.groupLayouts.find(l=>l.groupRef===e);return{label:"그룹에 노트 편입",apply(r){const l=a(r);l&&(l.memberNoteRefs||(l.memberNoteRefs=[],i=!0),!l.memberNoteRefs.includes(n)&&(l.memberNoteRefs.push(n),o=!0))},invert(r){if(!o)return;const l=a(r);if(!(l!=null&&l.memberNoteRefs))return;const s=l.memberNoteRefs.indexOf(n);s>=0&&l.memberNoteRefs.splice(s,1),i&&delete l.memberNoteRefs},emitOps(){return o?{forward:[{kind:"groupLayout.addNoteMember",casUnit:"layout",groupRef:e,noteRef:n}],invert:[{kind:"groupLayout.removeNoteMember",casUnit:"layout",groupRef:e,noteRef:n}]}:{forward:[],invert:[]}}}}function _u(e,n){let o=-1;const i=a=>a.layout.groupLayouts.find(r=>r.groupRef===e);return{label:"그룹에서 노트 제외",apply(a){var l;const r=i(a);o=((l=r==null?void 0:r.memberNoteRefs)==null?void 0:l.indexOf(n))??-1,o>=0&&r.memberNoteRefs.splice(o,1)},invert(a){if(o<0)return;const r=i(a);r&&(r.memberNoteRefs||(r.memberNoteRefs=[]),r.memberNoteRefs.splice(o,0,n))},emitOps(){return o<0?{forward:[],invert:[]}:{forward:[{kind:"groupLayout.removeNoteMember",casUnit:"layout",groupRef:e,noteRef:n}],invert:[{kind:"groupLayout.addNoteMember",casUnit:"layout",groupRef:e,noteRef:n}]}}}}const Hn=(e,n,o)=>({kind:"noteConnection.setWaypoints",casUnit:"layout",noteRef:e,targetRef:n,value:{waypoints:o}}),Oa=(e,n,o)=>{var i;return((i=wn(e,n,o))==null?void 0:i.waypoints.map(a=>({...a})))??[]};function ku(e,n){let o=!1,i=!1;return{label:"노트 연결 추가",apply(a){const r=a.layout.notes.find(l=>l.modelId===e);if(!r)throw new Error(`노트 없음: ${e}`);if(r.connections||(r.connections=[],i=!0),r.connections.some(l=>l.targetRef===n)){o=!1;return}r.connections.push({targetRef:n,waypoints:[]}),o=!0},invert(a){if(!o)return;const r=a.layout.notes.find(s=>s.modelId===e);if(!(r!=null&&r.connections))return;const l=r.connections.findIndex(s=>s.targetRef===n);l>=0&&r.connections.splice(l,1),i&&delete r.connections},emitOps(){return o?{forward:[{kind:"noteConnection.add",casUnit:"layout",noteRef:e,targetRef:n,value:{targetRef:n,waypoints:[]}}],invert:[{kind:"noteConnection.remove",casUnit:"layout",noteRef:e,targetRef:n}]}:{forward:[],invert:[]}}}}function Eu(e,n){let o=null;return{label:"노트 연결 삭제",apply(i){var l;const a=i.layout.notes.find(s=>s.modelId===e),r=((l=a==null?void 0:a.connections)==null?void 0:l.findIndex(s=>s.targetRef===n))??-1;if(!(a!=null&&a.connections)||r<0)throw new Error(`노트 연결 없음: ${e}→${n}`);o={item:a.connections[r],index:r},a.connections.splice(r,1)},invert(i){if(!o)return;const a=i.layout.notes.find(r=>r.modelId===e);a!=null&&a.connections&&a.connections.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"noteConnection.remove",casUnit:"layout",noteRef:e,targetRef:n}],invert:[{kind:"noteConnection.add",casUnit:"layout",noteRef:e,targetRef:n,value:o.item}]}:{forward:[],invert:[]}}}}function Nu(e,n,o,i){let a=null;return{label:"waypoint 이동",coalesceKey:`noteConnWaypoint:${e}:${n}`,apply(r){const l=wn(r,e,n);if(!l||!l.waypoints[o])throw new Error(`waypoint 없음: ${e}→${n}[${o}]`);a={...l.waypoints[o]},l.waypoints.splice(o,1,{...i})},invert(r){const l=wn(r,e,n);l&&a&&l.waypoints.splice(o,1,a)},emitOps(r){const l=Oa(r,e,n),s=l.map((c,d)=>d===o&&a?{...a}:c);return{forward:[Hn(e,n,l)],invert:[Hn(e,n,s)]}}}}function wu(e,n,o,i){return{label:"waypoint 추가",apply(a){const r=wn(a,e,n);if(!r)throw new Error(`노트 연결 없음: ${e}→${n}`);r.waypoints.splice(o,0,{...i})},invert(a){const r=wn(a,e,n);r==null||r.waypoints.splice(o,1)},emitOps(a){const r=Oa(a,e,n),l=r.slice();return l.splice(o,1),{forward:[Hn(e,n,r)],invert:[Hn(e,n,l)]}}}}function Iu(e,n,o){let i=null;return{label:"waypoint 제거",apply(a){const r=wn(a,e,n);if(!r||!r.waypoints[o])throw new Error(`waypoint 없음: ${e}→${n}[${o}]`);i={...r.waypoints[o]},r.waypoints.splice(o,1)},invert(a){const r=wn(a,e,n);r&&i&&r.waypoints.splice(o,0,i)},emitOps(a){const r=Oa(a,e,n),l=r.slice();return i&&l.splice(o,0,{...i}),{forward:[Hn(e,n,r)],invert:[Hn(e,n,l)]}}}}function vu(e,n){let o=null;return{label:"꺾은선 풀기",apply(i){const a=wn(i,e,n);if(!a)throw new Error(`노트 연결 없음: ${e}→${n}`);o=a.waypoints.map(r=>({...r})),a.waypoints=[]},invert(i){const a=wn(i,e,n);a&&o&&(a.waypoints=o)},emitOps(i){return{forward:[Hn(e,n,Oa(i,e,n))],invert:[Hn(e,n,o??[])]}}}}function at(e,n,o){return{label:e,coalesceKey:o,apply(i){for(const a of n)a.apply(i)},invert(i){for(let a=n.length-1;a>=0;a--)n[a].invert(i)},emitOps(i){const a=n.map(r=>{if(!r.emitOps)throw new Error(`emitOps 미구현 command가 composite에 포함됨: ${r.label}`);return r.emitOps(i)});return{forward:a.flatMap(r=>r.forward),invert:a.slice().reverse().flatMap(r=>r.invert)}}}}const Bb=Object.freeze(Object.defineProperty({__proto__:null,addAssociation:Ba,addAttribute:qt,addEntity:$a,addEntityToGroup:Yd,addGroup:Ma,addIndex:ru,addNote:fu,addNoteConnection:ku,addNoteConnectionWaypoint:wu,addNoteToGroup:bu,addOperation:eu,addWaypoint:mu,clearNoteConnectionWaypoints:vu,clearWaypoints:uu,composite:at,moveEntity:Go,moveGroup:qd,moveNote:Ci,moveNoteConnectionWaypoint:Nu,moveWaypoint:su,removeAssociation:au,removeAttribute:Zd,removeEntity:Pd,removeEntityFromGroup:Va,removeGroup:Gd,removeIndex:lu,removeNote:pu,removeNoteConnection:Eu,removeNoteConnectionWaypoint:Iu,removeNoteFromGroup:_u,removeOperation:nu,removeWaypoint:cu,renameEntity:zd,reorderAttributes:Fl,reorderOperations:ou,resizeEntity:Fd,resizeGroup:Wd,resizeNote:hu,setAllEntitiesCollapsed:zl,setAttributeSwatch:Ta,setEntityCollapsed:Hd,setEntityLocked:jd,setEntitySwatch:Ud,setGroupLocked:Xd,setGroupSwatch:Jd,setNoteMemo:yu,setNoteSwatch:gu,setOperationSwatch:iu,translateWaypoints:du,updateAssociation:Da,updateAssociationEnd:Jt,updateAttribute:Wt,updateEntity:Pl,updateGroup:Kd,updateIndex:La,updateOperation:tu},Symbol.toStringTag,{value:"Module"}));class Cu{constructor(){ct(this,"revs",new Map);ct(this,"layoutVersion",0);ct(this,"logicalVersion",0)}seed(n){this.revs.clear();for(const[o,i]of Object.entries(n.revs??{}))this.revs.set(o,i);this.layoutVersion=n.layoutVersion??0,this.logicalVersion=n.logicalVersion??0}rev(n){return this.revs.get(n)??0}setRev(n,o){this.revs.set(n,o)}deleteRev(n){this.revs.delete(n)}snapshot(){return{revs:Object.fromEntries(this.revs),layoutVersion:this.layoutVersion,logicalVersion:this.logicalVersion}}}const Db=[400,1200];function Lb(e){var o;if(typeof e!="object"||e===null)return;const n=e;for(const i of[n.statusCode,n.status,(o=n.response)==null?void 0:o.status])if(typeof i=="number"&&Number.isFinite(i))return i}function Ob(e){const n=Lb(e);return n==null||n===408||n===429?!0:n<400||n>=500}const Pb=e=>new Promise(n=>setTimeout(n,e));class Su{constructor(n){ct(this,"cache",new Cu);ct(this,"newClientOpId");ct(this,"debounceMs");ct(this,"retryDelaysMs");ct(this,"emissions",new WeakMap);ct(this,"open",null);ct(this,"debounceHandle",null);ct(this,"queue",[]);ct(this,"sending",!1);ct(this,"_frozen",!1);ct(this,"stack",null);ct(this,"settledWaiters",[]);this.opts=n,this.newClientOpId=n.newClientOpId??Pe,this.debounceMs=n.debounceMs??300,this.retryDelaysMs=n.retryDelaysMs??Db}seed(n){this.cache.seed(n)}attach(n){this.stack=n,n.sealCoalesce();const o=n.onCommand((i,a,r)=>this.handle(i,a,r));return()=>{o(),this.stack===n&&(this.stack=null)}}get frozen(){return this._frozen}get hasPending(){return this.open!==null||this.queue.length>0||this.sending}cacheSnapshot(){return this.cache.snapshot()}flush(){this.flushOpen(!0)}whenSettled(){return this.hasPending?new Promise(n=>this.settledWaiters.push(n)):Promise.resolve()}handle(n,o,i){var l,s,c;if(this._frozen)return;let a;if(o==="do"){const d=(l=n.emitOps)==null?void 0:l.call(n,this.opts.state);if(!d)throw new Error(`op-mode에서 emitOps 미구현 command 실행: ${n.label}`);a=d}else{const d=this.emissions.get(n);if(!d)throw new Error(`op-mode ${o} 대상 command의 emission 미기록: ${n.label}`);a=d}const r=o==="undo"?a.invert:a.forward;if(o==="do"&&i&&this.open&&this.open.coalesceKey===n.coalesceKey){this.open.fwd=r,this.emissions.set(n,{forward:r,invert:this.open.inv}),this.resetDebounce();return}if(i){const d=new Error(`op-mode coalesce 경계 불일치: 스택은 병합했으나 어댑터에 대응 그룹이 없음 (${n.label}, key=${String(n.coalesceKey)})`);console.error("[op-sync]",d),(c=(s=this.opts).onError)==null||c.call(s,d)}if(this.flushOpen(!1),o==="do"&&(this.emissions.set(n,a),n.coalesceKey!=null)){this.open={coalesceKey:n.coalesceKey,fwd:r,inv:a.invert},this.startDebounce();return}r.length&&this.enqueue(this.buildBatch(r))}flushOpen(n){var i;this.cancelDebounce();const o=this.open;this.open=null,o&&o.fwd.length&&this.enqueue(this.buildBatch(o.fwd)),n&&((i=this.stack)==null||i.sealCoalesce())}startDebounce(){this.cancelDebounce(),this.debounceHandle=setTimeout(()=>{this.debounceHandle=null,this.flushOpen(!0)},this.debounceMs)}resetDebounce(){this.startDebounce()}cancelDebounce(){this.debounceHandle!=null&&(clearTimeout(this.debounceHandle),this.debounceHandle=null)}buildBatch(n){const o={},i=new Set;let a=!1,r=!1;for(const l of n)if(l.casUnit==="logical")if(a=!0,l.containerRef)i.add(l.containerRef);else{const s=l.entityRef??l.associationRef??l.groupRef;s&&(l.kind.endsWith(".add")?this.cache.setRev(s,0):l.kind.endsWith(".remove")&&this.cache.deleteRev(s))}else l.incidental||(r=!0);if(i.size){o.revs={};for(const l of i){const s=this.cache.rev(l);o.revs[l]=s,this.cache.setRev(l,s+1)}}return r&&(o.layout=this.cache.layoutVersion,this.cache.layoutVersion=o.layout+1),a&&(this.cache.logicalVersion+=1),{diagramId:this.opts.diagramId,ops:n,cas:o,origin:this.opts.origin??"gui",clientOpId:this.newClientOpId()}}enqueue(n){this.queue.push(n),this.pump()}async pump(){var i,a;if(this.sending||this._frozen)return;const n=this.queue.shift();if(!n){this.notifySettled();return}this.sending=!0;let o;for(let r=0;;r++)try{o=await this.opts.transport(n);break}catch(l){const s=this.retryDelaysMs.length+1;console.error(`[op-sync] op 전송 실패 (시도 ${r+1}/${s}):`,l),(a=(i=this.opts).onError)==null||a.call(i,l);const c=this.retryDelaysMs[r];if(c==null||!Ob(l)){this.sending=!1,console.error("[op-sync] 전송 실패 확정 → 하드 프리즈(kind:missing)"),this.freeze({kind:"missing"});return}await Pb(c)}this.sending=!1,o.ok?(this.reconcile(o),this.pump()):this.freeze(o.conflict)}reconcile(n){if(!(this.queue.length>0)){for(const[o,i]of Object.entries(n.revs))this.cache.setRev(o,i);this.cache.layoutVersion=n.layoutVersion,this.cache.logicalVersion=n.logicalVersion}}freeze(n){var o,i;this._frozen=!0,this.queue.length=0,this.open=null,this.cancelDebounce(),(i=(o=this.opts).onFreeze)==null||i.call(o,n),this.notifySettled()}notifySettled(){if(this.hasPending)return;const n=this.settledWaiters;this.settledWaiters=[];for(const o of n)o()}}const xu=["entity.add","entity.update","entity.remove","attribute.add","attribute.update","attribute.remove","association.add","association.remove","association.update","associationEnd.update","index.add","index.update","index.remove","operation.add","operation.update","operation.remove","attribute.reorder","operation.reorder","group.add","group.update","group.remove","group.addMember","group.removeMember"],Ru=["NORMAL","RELATION_OWN","RELATION_REF","EMBED_OWN","EMBED_REF","EMBED_PREDEF","DIVIDER"];function Au(e,n){var r;if(!n.length||!((r=e.indexes)!=null&&r.length))return[];const o=new Set(n),i=new Set;for(const l of e.attributes)if(o.has(l.modelId)){i.add(l.modelId);for(const s of l.dbAttrs)i.add(s.modelId)}if(!i.size)return[];const a=[];for(const l of e.indexes){const s=l.columns.filter(c=>!i.has(c.columnRef));s.length!==l.columns.length&&a.push({indexRef:l.modelId,columns:s})}return a}function zb(e){return bn(e).length}function Ul(e,n){return new Set(e.associations.filter(o=>{const i=o.end1.entityRef===n?o.end1:o.end2;return i.multiplicity==="ZERO_OR_MORE_INSTANCES"||i.multiplicity==="ONE_OR_MORE_INSTANCES"}).map(o=>o.modelId))}function Fb(e,n,o,i){var r;const a=new Set;for(const l of e.attributes)l.dbAttrs.forEach((s,c)=>{if(s.sharedColumnRef!=null)return;const d=pi(l,s,c,e,i);d&&a.add(d)});for(let l=n.dbAttrs.length;l<o.length;l++){const s=(r=o[l])==null?void 0:r.physicalName;if(s&&a.has(s))return!0}return!1}function $u(e,n,o=Pe){const i=e.entities.find(c=>c.modelId===n);if(!i)return[];const a=zb(i);if(a===0)return[];const r=Ul(e,n),l=bn(i).map(c=>c.col),s=[];for(const c of e.entities){const d=c.attributes.filter(u=>{var m;return u.attrType==="EMBED_OWN"&&((m=u.embedded)==null?void 0:m.embeddableRef)===n&&!r.has(u.embedded.associationRef)&&a-u.dbAttrs.length>0});if(!(d.length>1))for(const u of d){const m=a-u.dbAttrs.length;Fb(c,u,l,e)||s.push({entityId:c.modelId,attributeId:u.modelId,dbAttrs:[...u.dbAttrs,...Array.from({length:m},()=>({modelId:o(),physicalName:"",dataType:""}))],added:m})}}return s}function Tu(e,n,o){var p;const i=e.entities.find(f=>f.modelId===n);if(!i)return[];const a=i.attributes;if(o.length!==a.length)return[];const r=new Map(a.map(f=>[f.modelId,f])),l=[];for(const f of o){const h=r.get(f);if(!h)return[];l.push(h)}const s=a.flatMap(f=>f.dbAttrs).map(f=>f.modelId),c=l.flatMap(f=>f.dbAttrs).map(f=>f.modelId);if(s.length!==c.length)return[];if(s.every((f,h)=>f===c[h]))return[];const d=new Map(s.map((f,h)=>[f,h])),u=Ul(e,n),m=[];for(const f of e.entities)for(const h of f.attributes){if(h.attrType!=="EMBED_OWN"||((p=h.embedded)==null?void 0:p.embeddableRef)!==n||u.has(h.embedded.associationRef)||h.dbAttrs.length!==s.length)continue;const g=c.map(_=>h.dbAttrs[d.get(_)]),b=g.reduce((_,E,N)=>E===h.dbAttrs[N]?_:_+1,0);b&&m.push({entityId:f.modelId,attributeId:h.modelId,dbAttrs:g,moved:b})}return m}function Mu(e,n,o){var p;const i=e.entities.find(f=>f.modelId===n);if(!i)return[];const a=new Set(o),r=i.attributes.filter(f=>!a.has(f.modelId));if(r.length===i.attributes.length)return[];const l=bn(i).map(f=>f.col),s=l.map(f=>f.modelId),c=new Set(bn({...i,attributes:r}).map(f=>f.col.modelId)),d=new Set;if(s.forEach((f,h)=>{c.has(f)&&d.add(h)}),d.size===s.length)return[];const u=Ul(e,n),m=[];for(const f of e.entities)for(const h of f.attributes){if(h.attrType!=="EMBED_OWN"||((p=h.embedded)==null?void 0:p.embeddableRef)!==n||u.has(h.embedded.associationRef)||h.dbAttrs.length!==s.length)continue;const g=h.dbAttrs.filter((E,N)=>d.has(N)),b=h.dbAttrs.filter((E,N)=>!d.has(N));h.dbAttrs.some((E,N)=>{if(d.has(N))return!1;const y=l[N],k=!!E.physicalName&&E.physicalName!==((y==null?void 0:y.physicalName)??""),S=E.sharedColumnRef!=null&&E.sharedColumnRef!==(y==null?void 0:y.sharedColumnRef);return k||S})||m.push({entityId:f.modelId,attributeId:h.modelId,dbAttrs:g,dropped:b})}return m}function Ub(e,n){const o=()=>e.entities.filter(r=>{var l;return((l=r.table)==null?void 0:l.physicalName)===n.ref}),i=()=>e.entities.filter(r=>r.name===n.ref);if(n.by==="modelId")return e.entities.filter(r=>r.modelId===n.ref);if(n.by==="physicalName")return o();if(n.by==="name")return i();const a=o();return a.length?a:i()}function Hb(e,n){const o=()=>e.attributes.filter(r=>r.name===n.ref),i=()=>e.attributes.filter(r=>r.dbAttrs.some(l=>l.physicalName===n.ref));if(n.by==="modelId")return e.attributes.filter(r=>r.modelId===n.ref);if(n.by==="name")return o();if(n.by==="physicalName")return i();const a=o();return a.length?a:i()}function Vu(e,n,o){return e.associations.filter(i=>{const a=[i.end1.entityRef,i.end2.entityRef];return a.includes(n)&&a.includes(o)})}function Rt(e,n){const o=Ub(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>Gb(i,e))}}function jb(e,n){const o=()=>e.groups.filter(r=>r.packageName===n.ref),i=()=>e.groups.filter(r=>Object.values(r.name??{}).some(l=>l===n.ref));if(n.by==="modelId")return e.groups.filter(r=>r.modelId===n.ref);if(n.by==="packageName")return o();if(n.by==="name")return i();const a=o();return a.length?a:i()}function Hl(e,n){const o=jb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>({modelId:i.modelId,name:i.name??null,packageName:i.packageName??null,members:i.memberEntityRefs.length}))}}function jl(e,n,o){return e.reason==="not-found"?{code:"group-not-found",opIndex:n,handle:o}:{code:"group-ambiguous",opIndex:n,handle:o,matches:e.matches}}const Kb=new Set(["name","description","packageName","excludeDDLGeneration"]);function Gb(e,n){var a;const o=Lo(e,n).value,i=n.associations.filter(r=>{var l,s;return((l=r.end1)==null?void 0:l.entityRef)===e.modelId||((s=r.end2)==null?void 0:s.entityRef)===e.modelId});return{modelId:e.modelId,stereotype:e.stereotype,packageName:o||null,table:((a=e.table)==null?void 0:a.physicalName)||null,attributes:e.attributes.length,references:i.length,referencedBy:[...new Set(i.map(r=>{var c,d,u,m;const l=((c=r.end1)==null?void 0:c.entityRef)===e.modelId?(d=r.end2)==null?void 0:d.entityRef:(u=r.end1)==null?void 0:u.entityRef,s=n.entities.find(p=>p.modelId===l);return(s==null?void 0:s.name)||((m=s==null?void 0:s.table)==null?void 0:m.physicalName)||String(l??"?")}))]}}function Bu(e,n){const o=Hb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Yb(e,n){const o=()=>e.attributes.flatMap(r=>r.dbAttrs).filter(r=>r.physicalName===n.ref),i=()=>e.attributes.filter(r=>r.name===n.ref).flatMap(r=>r.dbAttrs);if(n.by==="modelId")return e.attributes.flatMap(r=>r.dbAttrs).filter(r=>r.modelId===n.ref);if(n.by==="physicalName")return o();if(n.by==="name")return i();const a=o();return a.length?a:i()}function qb(e,n){const o=Yb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Du(e,n){const o=e.filter(i=>i.physicalName===n.ref);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Kl(e){return e.by!==void 0&&e.by!=="name"}function Wb(e,n){return(e.indexes??[]).filter(o=>o.name===n.ref)}function Jb(e,n){return(e.operations??[]).filter(o=>o.name===n.ref)}function Xb(e,n){const o=Wb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Lu(e,n){const o=Jb(e,n);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Ou(e){return e.physicalName!=null||e.dataType!=null||e.length!=null||e.scale!=null||e.columnLogicalName!=null||e.unique!=null||e.updatable!=null}function Pu(e){return Ou(e)&&e.dataType==null}function zu(e,n,o){const i=Ou(e);return{modelId:o(),name:e.name,type:e.type,attrType:"NORMAL",identifier:e.identifier??!1,notNull:e.notNull??!1,order:n,...e.transient?{transient:!0}:{},...e.groupCode?{groupCode:e.groupCode}:{},...e.defaultValue!=null?{defaultValue:e.defaultValue}:{},...e.attributeGroup?{attributeGroup:e.attributeGroup}:{},...e.description?{description:e.description}:{},...e.collectionType?{collectionType:e.collectionType}:{},...e.fieldLogicalName?{fieldLogicalName:e.fieldLogicalName}:{},dbAttrs:i?[{modelId:o(),physicalName:e.physicalName??e.name,dataType:e.dataType??"",...e.length?{length:e.length}:{},...e.scale?{scale:e.scale}:{},...e.columnLogicalName?{logicalName:e.columnLogicalName}:{},...e.unique!=null?{unique:e.unique}:{},...e.updatable!=null?{updatable:e.updatable}:{}}]:[]}}function Fu(e,n,o,i,a,r,l,s,c){const d=c(),u=new Map((e.embeddableOverrides??[]).map(f=>[f.field,f])),m=[];let p=!1;for(const f of n.fields){const h=u.get(f.name);if(h!=null&&h.sharedColumnPhysicalName){const g={ref:h.sharedColumnPhysicalName,by:"physicalName"},b=Du(zn(i,a),g);if(!b.ok){s.push(b.reason==="not-found"?{code:"shared-column-target-not-found",opIndex:r,entity:l,handle:g}:{code:"shared-column-target-ambiguous",opIndex:r,entity:l,handle:g,matches:b.matches}),p=!0;continue}m.push({modelId:c(),physicalName:"",dataType:"",sharedColumnRef:b.value.modelId});continue}m.push({modelId:c(),physicalName:(h==null?void 0:h.physicalName)??"",dataType:"",...h!=null&&h.length?{length:h.length}:{},...h!=null&&h.scale?{scale:h.scale}:{},...(h==null?void 0:h.insertable)!=null?{insertable:h.insertable}:{},...(h==null?void 0:h.updatable)!=null?{updatable:h.updatable}:{}})}return p?null:{modelId:d,name:e.name,type:n.type,attrType:"EMBED_PREDEF",identifier:e.identifier??!1,notNull:e.notNull??!1,order:o,...e.defaultValue!=null?{defaultValue:e.defaultValue}:{},...e.attributeGroup?{attributeGroup:e.attributeGroup}:{},...e.description?{description:e.description}:{},dbAttrs:m}}const Zb=new Set(["name","type","customType","attrType","identifier","notNull","transient","naturalId","naturalIdMutable","description","attributeGroup","groupCode","defaultValue","personalInfoAttributeType","order","dbAttrs","derivedIdFieldName","collectionType","fieldLogicalName"]),Yo=e=>new Set(Object.keys(e)),Qb=Yo({name:!0,stereotype:!0,physicalName:!0,useVersion:!0,attributes:!0,indexes:!0,operations:!0,serialization:!0,classLogicalName:!0}),Uu=Yo({name:!0,type:!0,identifier:!0,notNull:!0,transient:!0,physicalName:!0,dataType:!0,length:!0,scale:!0,groupCode:!0,defaultValue:!0,attributeGroup:!0,description:!0,columnLogicalName:!0,unique:!0,updatable:!0,embeddableOverrides:!0,collectionType:!0,fieldLogicalName:!0}),Hu=Yo({name:!0,unique:!0,columns:!0,description:!0,parameters:!0}),ju=Yo({name:!0,visibility:!0,sourceCode:!0,description:!0,personalInfoAttributeType:!0}),e_=Yo({from:!0,to:!0,fromMultiplicity:!0,toMultiplicity:!0,identifying:!0,composition:!0}),t_=Yo({name:!0,packageName:!0,description:!0,excludeDDLGeneration:!0,members:!0});function In(e,n){return ho(e,n)}const n_=new Set(["name","stereotype","packageName","superClass","schema","description","abstractClass","hasPersonalInfo","declarationOfInterfaces","table","classLogicalName","referenceOnly","serialization"]),o_=new Set(["description","identifying"]),i_=new Set(["multiplicity","navigable","composition"]),a_=new Set(["name","unique","description","parameters"]),r_=new Set(["name","visibility","sourceCode","description","order","personalInfoAttributeType"]);function ho(e,n,o=[]){const i=[];for(const a of Object.keys(e)){if(a.includes(".")){o.some(r=>a.startsWith(r))||i.push(a);continue}n.has(a)||i.push(a)}return i}const Gl=new Set(["physicalName","logicalName","dataType","length","scale","unique","autoIncrement","updatable","insertable","sharedColumnRef","multiValue","multiValueSeparator","sequenceName"]),l_=new Set([...Gl].filter(e=>e!=="sharedColumnRef"));function s_(e,n,o,i){if(i||o.some(l=>!l_.has(l))||e.attrType!=="NORMAL"||e.dbAttrs.length!==1)return null;const a={...e.dbAttrs[0]};for(const l of o)a[l]=n[l];const r={};for(const[l,s]of Object.entries(n))Gl.has(l)||(r[l]=s);return{...r,dbAttrs:[a]}}function c_(e,n,o,i,a,r,l,s){const c=new Map(o.map(m=>[m.field,m])),d=[];let u=!1;return e.dbAttrs.forEach((m,p)=>{const f=n.fields[p],h=f?c.get(f.name):void 0;if(!h){d.push(m);return}if(h.sharedColumnPhysicalName){const b={ref:h.sharedColumnPhysicalName,by:"physicalName"},_=Du(zn(i,a),b);if(!_.ok){s.push(_.reason==="not-found"?{code:"shared-column-target-not-found",opIndex:r,entity:l,handle:b}:{code:"shared-column-target-ambiguous",opIndex:r,entity:l,handle:b,matches:_.matches}),u=!0;return}d.push({modelId:m.modelId,physicalName:"",dataType:"",sharedColumnRef:_.value.modelId});return}const g={...m};delete g.sharedColumnRef,d.push({...g,...h.physicalName!=null?{physicalName:h.physicalName}:{},...h.length!=null?{length:h.length}:{},...h.scale!=null?{scale:h.scale}:{},...h.insertable!=null?{insertable:h.insertable}:{},...h.updatable!=null?{updatable:h.updatable}:{}})}),u?null:d}function Ku(e,n,o){return{modelId:o(),name:e.name,order:n,...e.visibility?{visibility:e.visibility}:{},...e.sourceCode?{sourceCode:e.sourceCode}:{},...e.description?{description:e.description}:{},...e.personalInfoAttributeType?{personalInfoAttributeType:e.personalInfoAttributeType}:{}}}function Gu(e,n,o,i,a,r){const l=[];let s=!1;for(const c of n.columns){const d=qb(e,c.column);if(!d.ok){a.push(d.reason==="not-found"?{code:"column-not-found",opIndex:o,entity:i,handle:c.column}:{code:"column-ambiguous",opIndex:o,entity:i,handle:c.column,matches:d.matches}),s=!0;continue}l.push({columnRef:d.value.modelId,descending:c.descending??!1})}return s?null:{modelId:r(),name:n.name,unique:n.unique??!1,columns:l,...n.description?{description:n.description}:{},...n.parameters?{parameters:n.parameters}:{}}}function qo(e,n,o,i){const a=`${o}:${i}`;n.seen.has(a)||(n.seen.add(a),n.pairs.push({entityId:o,attributeId:i}),e.push({kind:"attribute.remove",casUnit:"logical",containerRef:o,entityRef:o,attributeRef:i}))}function d_(e,n,o,i){const a=new Map;for(const{entityId:r,attributeId:l}of o.pairs){if(i.has(r))continue;const s=a.get(r)??[];s.push(l),a.set(r,s)}for(const[r,l]of a){const s=n.entities.find(c=>c.modelId===r);if(s)for(const c of Au(s,l))e.push({kind:"index.update",casUnit:"logical",containerRef:r,entityRef:r,indexRef:c.indexRef,patch:{columns:c.columns}})}}function u_(e,n,o,i,a,r){const l=m=>{const p=new Map;for(const{entityId:f,item:h}of m){if(a.has(f))continue;const g=p.get(f)??[];g.push(h),p.set(f,g)}return p},s=l(o.pairs.map(m=>({entityId:m.entityId,item:m.attributeId}))),c=l(i.map(m=>({entityId:m.entityId,item:m.attribute}))),d=new Set(e.filter(m=>m.kind==="attribute.update").map(m=>m.attributeRef)),u=m=>{d.has(m.attributeId)||(d.add(m.attributeId),e.push({kind:"attribute.update",casUnit:"logical",containerRef:m.entityId,entityRef:m.entityId,attributeRef:m.attributeId,patch:{dbAttrs:m.dbAttrs}}))};for(const[m,p]of s)if(!c.has(m))for(const f of Mu(n,m,p))u(f);for(const[m,p]of c){if(s.has(m))continue;const f={...n,entities:n.entities.map(h=>h.modelId===m?{...h,attributes:[...h.attributes,...p]}:h)};for(const h of $u(f,m,r))u(h)}}function Yu(e,n){const o={...e},i=[];for(const[a,r]of Object.entries(n)){if(!a.includes(".")){o[a]=r===null?void 0:r;continue}const l=/^dbAttrs\.(\d+)\.(.+)$/.exec(a);l&&i.push([Number(l[1]),l[2],r])}if(i.length){const a=(o.dbAttrs??[]).map(r=>({...r}));for(const[r,l,s]of i)a[r]&&(a[r][l]=s===null?void 0:s);o.dbAttrs=a}return o}function qu(e,n,o,i,a,r,l){var p;for(const f of i.remove)qo(e,r,o,f);for(const f of i.update)e.push({kind:"attribute.update",casUnit:"logical",containerRef:o,entityRef:o,attributeRef:f.attributeId,patch:f.patch}),a.attrPatches.push({entityId:o,attributeId:f.attributeId,patch:f.patch});const s=((p=n.entities.find(f=>f.modelId===o))==null?void 0:p.attributes)??[],c=[];for(const f of i.add){const h={...f,order:l(o,s)};e.push({kind:"attribute.add",casUnit:"logical",containerRef:o,entityRef:o,value:h}),a.cascadeAdds.push({entityId:o,attribute:h}),c.push(h)}const d=new Set(i.remove),u=[...s.filter(f=>!d.has(f.modelId)),...c],m=new Set(u.map(f=>f.modelId));for(const f of n.associations){if(f.end2.entityRef!==o)continue;const h=f.end2.attributeRef;if(h&&m.has(h))continue;const b=u.filter(_=>{var E;return((E=_.derivedFrom)==null?void 0:E.associationRef)===f.modelId&&_.dbAttrs.length>0}).sort((_,E)=>_.order-E.order)[0];b&&(e.push({kind:"associationEnd.update",casUnit:"logical",containerRef:f.modelId,associationRef:f.modelId,end:"end2",patch:{attributeRef:b.modelId}}),a.endPatches.push({associationRef:f.modelId,end:"end2",patch:{attributeRef:b.modelId}}))}}function Yl(e,n,o,i,a,r,l){for(const{entityId:s,plan:c}of cd(n,o,i))qu(e,n,s,c,a,r,l)}function m_(e,n,o,i,a,r){const l=new Map;for(const{entityId:p,attributeId:f}of i.pairs)l.has(p)||l.set(p,new Set),l.get(p).add(f);const s=new Map;for(const p of r.attrPatches)s.has(p.entityId)||s.set(p.entityId,[]),s.get(p.entityId).push(p);const c=new Map;for(const{entityId:p,attribute:f}of[...a,...r.cascadeAdds])c.has(p)||c.set(p,[]),c.get(p).push(f);const d=p=>{const f={};for(const[h,g]of Object.entries(p))h.includes(".")||(f[h]=g===null?void 0:g);return f},u=e.entities.filter(p=>!n.has(p.modelId)).map(p=>{const f=l.get(p.modelId),h=s.get(p.modelId),g=c.get(p.modelId);if(!f&&!h&&!g)return p;let b=p.attributes;return f&&(b=b.filter(_=>!f.has(_.modelId))),h&&(b=b.map(_=>{const E=h.filter(N=>N.attributeId===_.modelId);return E.length?E.reduce((N,y)=>Yu(N,y.patch),_):_})),g&&(b=[...b,...g]),{...p,attributes:b}}),m=e.associations.filter(p=>!o.has(p.modelId)&&!n.has(p.end1.entityRef)&&!n.has(p.end2.entityRef)).map(p=>{let f=p;for(const h of r.assocPatches)h.associationRef===p.modelId&&(f={...f,...d(h.patch)});for(const h of r.endPatches)h.associationRef===p.modelId&&(f={...f,[h.end]:{...f[h.end],...d(h.patch)}});return f}).concat(r.addedAssociations);return{...e,entities:u,associations:m}}function f_(e,n,o,i,a,r,l,s,c){if(!l.identifierCascadeParents.size)return;const d=m_(n,o,i,a,r,l),u=new Map;for(const m of l.identifierCascadeParents)for(const[p,f]of pl(d,m,s)){const h=u.get(p);u.set(p,h?fl(h,f):f)}for(const[m,p]of u)qu(e,d,m,sd(p),l,a,c)}function p_(e,n,o={}){const i=o.mkId??Pe,a=o.embeddableCatalog??[],r=y=>a.find(k=>k.type===y),l=[],s=[],c=new Map,d=(y,k)=>{const S=c.get(y)??jt(k);return c.set(y,S+1),S},u=new Map,m=new Set,p=new Set,f={seen:new Set,pairs:[]},h=[],g={attrPatches:[],cascadeAdds:[],addedAssociations:[],assocPatches:[],endPatches:[],identifierCascadeParents:new Set},b=new Set,_=(y,k)=>`${y}\0${k}`,E=new Set;for(const y of n)y.kind==="entity.add"&&(E.add(y.spec.name),y.spec.physicalName&&E.add(y.spec.physicalName));const N=new Set;return n.forEach((y,k)=>{var S,T,B,A,V;switch(y.kind){case"entity.add":{{const R={ref:y.spec.name},D=In(y.spec,Qb);if(D.length){s.push({code:"entity-spec-unknown-key",opIndex:k,handle:R,keys:D});break}let j=!1;for(const U of y.spec.attributes??[]){const ne=In(U,Uu);ne.length&&(s.push({code:"attribute-spec-unknown-key",opIndex:k,entity:R,handle:{ref:U.name},keys:ne}),j=!0)}for(const U of y.spec.indexes??[]){const ne=In(U,Hu);ne.length&&(s.push({code:"index-spec-unknown-key",opIndex:k,entity:R,handle:{ref:U.name},keys:ne}),j=!0)}for(const U of y.spec.operations??[]){const ne=In(U,ju);ne.length&&(s.push({code:"operation-spec-unknown-key",opIndex:k,entity:R,handle:{ref:U.name},keys:ne}),j=!0)}if(j)break}const C=e.entities.filter(R=>R.name===y.spec.name).map(R=>R.modelId);if(C.length||N.has(y.spec.name)){s.push({code:"entity-name-conflict",opIndex:k,handle:{ref:y.spec.name},matches:C});break}N.add(y.spec.name);const x=i(),$={modelId:x,name:y.spec.name,stereotype:y.spec.stereotype??"JPA_ENTITY",attributes:[],...y.spec.useVersion?{jpaAttrs:{useVersion:!0}}:{},...y.spec.physicalName?{table:{physicalName:y.spec.physicalName}}:{},...y.spec.serialization?{serialization:y.spec.serialization}:{},...y.spec.classLogicalName?{classLogicalName:y.spec.classLogicalName}:{}},w={ref:y.spec.name};let I=!1;for(const[R,D]of(y.spec.attributes??[]).entries()){if(D.type==="GroupCodeEnum"&&!D.groupCode){s.push({code:"groupcode-required",opIndex:k,entity:w,handle:{ref:D.name}}),I=!0;continue}if(!r(D.type)&&!((S=D.embeddableOverrides)!=null&&S.length)&&Pu(D)){s.push({code:"datatype-required",opIndex:k,entity:w,handle:{ref:D.name}}),I=!0;continue}const j=r(D.type);if(j){const U=Fu(D,j,R,$,e.entities,k,w,s,i);U?$.attributes.push(U):I=!0}else(T=D.embeddableOverrides)!=null&&T.length?(s.push({code:"embeddable-type-unresolved",opIndex:k,entity:w,handle:{ref:D.name}}),I=!0):$.attributes.push(zu(D,R,i))}const v=(y.spec.operations??[]).map((R,D)=>Ku(R,D,i));v.length&&($.operations=v);const M=[];for(const R of y.spec.indexes??[]){const D=Gu($,R,k,w,s,i);D?M.push(D):I=!0}if(M.length&&($.indexes=M),I)break;l.push({kind:"entity.add",casUnit:"logical",entityRef:x,value:$});break}case"entity.update":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=ho(y.patch,n_,["jpaAttrs.","table.","serialization."]);if(x.length){s.push({code:"entity-patch-unknown-key",opIndex:k,entity:y.entity,keys:x});break}const $=y.patch.stereotype;if(typeof $=="string"&&$!==C.value.stereotype){const w=$==="JPA_EMBEDDABLE"||C.value.stereotype==="JPA_EMBEDDABLE",I=$==="SERIALIZED_TYPE"||C.value.stereotype==="SERIALIZED_TYPE";if(w||I){s.push({code:w?"stereotype-embeddable-transition-unsupported":"stereotype-serialized-transition-unsupported",opIndex:k,entity:y.entity,from:C.value.stereotype??"",to:$});break}}l.push({kind:"entity.update",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,patch:y.patch});break}case"entity.remove":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=C.value.modelId,$=e.associations.filter(M=>M.end1.entityRef===x||M.end2.entityRef===x),w=new Set($.map(M=>M.modelId));for(const M of $)m.has(M.modelId)||(m.add(M.modelId),l.push({kind:"association.remove",casUnit:"logical",associationRef:M.modelId}));for(const M of e.entities)if(M.modelId!==x)for(const R of M.attributes)R.embedded&&w.has(R.embedded.associationRef)&&qo(l,f,M.modelId,R.modelId);for(const M of $){if(M.end1.entityRef===x||!M.end1.attributeRef)continue;const R=e.entities.find(j=>j.modelId===M.end1.entityRef),D=R==null?void 0:R.attributes.find(j=>j.modelId===M.end1.attributeRef&&j.attrType==="RELATION_REF");D&&qo(l,f,R.modelId,D.modelId)}const I={...e,entities:e.entities.filter(M=>M.modelId!==x),associations:e.associations.filter(M=>!w.has(M.modelId))},v=new Set($.filter(M=>M.end1.entityRef===x&&M.end2.entityRef!==x).map(M=>M.end2.entityRef));Yl(l,I,[...v],i,g,f,d);for(const M of e.groups)M.memberEntityRefs.includes(x)&&(b.has(_(M.modelId,x))||(b.add(_(M.modelId,x)),l.push({kind:"group.removeMember",casUnit:"logical",containerRef:M.modelId,groupRef:M.modelId,entityRef:x})));p.add(x),l.push({kind:"entity.remove",casUnit:"logical",entityRef:x});break}case"attribute.add":{{const I=In(y.spec,Uu);if(I.length){s.push({code:"attribute-spec-unknown-key",opIndex:k,entity:y.entity,handle:{ref:y.spec.name},keys:I});break}}const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}if(y.spec.type==="GroupCodeEnum"&&!y.spec.groupCode){s.push({code:"groupcode-required",opIndex:k,entity:y.entity,handle:{ref:y.spec.name}});break}if(!r(y.spec.type)&&!((B=y.spec.embeddableOverrides)!=null&&B.length)&&Pu(y.spec)){s.push({code:"datatype-required",opIndex:k,entity:y.entity,handle:{ref:y.spec.name}});break}const x=d(C.value.modelId,C.value.attributes),$=r(y.spec.type);let w;if($)w=Fu(y.spec,$,x,C.value,e.entities,k,y.entity,s,i);else if((A=y.spec.embeddableOverrides)!=null&&A.length){s.push({code:"embeddable-type-unresolved",opIndex:k,entity:y.entity,handle:{ref:y.spec.name}});break}else w=zu(y.spec,x,i);if(!w)break;l.push({kind:"attribute.add",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,value:w}),h.push({entityId:C.value.modelId,attribute:w}),w.identifier&&g.identifierCascadeParents.add(C.value.modelId);break}case"attribute.update":case"attribute.remove":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=Bu(C.value,y.attribute);if(!x.ok){s.push(x.reason==="not-found"?{code:"attribute-not-found",opIndex:k,entity:y.entity,handle:y.attribute}:{code:"attribute-ambiguous",opIndex:k,entity:y.entity,handle:y.attribute,matches:x.matches});break}if(y.kind==="attribute.update"){const $=[],w=[];let I=!1;for(const D of Object.keys(y.patch)){if(D.includes(".")){D.startsWith("dbAttrs.")?I=!0:w.push(D);continue}Gl.has(D)?$.push(D):Zb.has(D)||w.push(D)}if(w.length){s.push({code:"attribute-patch-unknown-key",opIndex:k,entity:y.entity,handle:y.attribute,keys:w});break}if("attrType"in y.patch){const D=String(y.patch.attrType),j=Ru.includes(D)?D!==x.value.attrType?"transition":void 0:"unknown-value";if(j){s.push({code:"attribute-attrtype-unsupported",opIndex:k,entity:y.entity,handle:y.attribute,reason:j,current:x.value.attrType,requested:D});break}}const v="type"in y.patch?y.patch.type:x.value.type,M="groupCode"in y.patch?y.patch.groupCode:x.value.groupCode;if(v==="GroupCodeEnum"&&!M){s.push({code:"groupcode-required",opIndex:k,entity:y.entity,handle:y.attribute});break}let R=y.patch;if($.length){const D=s_(x.value,y.patch,$,I);if(!D){s.push({code:"attribute-patch-dbattr-flat-key",opIndex:k,entity:y.entity,handle:y.attribute,keys:$});break}R=D}if((V=y.embeddableOverrides)!=null&&V.length){const D=r(x.value.type);if(!D||x.value.attrType!=="EMBED_PREDEF"){s.push({code:"embeddable-type-unresolved",opIndex:k,entity:y.entity,handle:y.attribute});break}const j=c_(x.value,D,y.embeddableOverrides,C.value,e.entities,k,y.entity,s);if(!j)break;R={...R,dbAttrs:j}}l.push({kind:"attribute.update",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,attributeRef:x.value.modelId,patch:R}),g.attrPatches.push({entityId:C.value.modelId,attributeId:x.value.modelId,patch:R});{const D=x.value,j=Yu(D,R),U=(j.identifier??!1)!==(D.identifier??!1),ne=(D.identifier||j.identifier)&&("type"in R||"customType"in R||"dbAttrs"in R||Object.keys(R).some(pe=>pe.startsWith("dbAttrs.")));(U||ne)&&g.identifierCascadeParents.add(C.value.modelId)}}else{const $=Ho(e,C.value.modelId,x.value.modelId);if($){const w=I=>{var v;return((v=e.entities.find(M=>M.modelId===I))==null?void 0:v.name)??I};s.push({code:"attribute-fk-managed",opIndex:k,entity:y.entity,handle:y.attribute,association:{from:w($.end1.entityRef),to:w($.end2.entityRef)}});break}qo(l,f,C.value.modelId,x.value.modelId),x.value.identifier&&g.identifierCascadeParents.add(C.value.modelId)}break}case"association.add":{{const M=In(y.spec,e_);if(M.length){s.push({code:"association-spec-unknown-key",opIndex:k,handle:{from:y.spec.from,to:y.spec.to},keys:M});break}}const C=Rt(e,y.spec.from),x=Rt(e,y.spec.to);if(C.ok||s.push(At(C.reason,k,y.spec.from,C.matches,E)),x.ok||s.push(At(x.reason,k,y.spec.to,x.matches,E)),!C.ok||!x.ok)break;if(y.spec.identifying&&C.value.modelId===x.value.modelId){s.push({code:"self-identifying",opIndex:k,handle:{from:y.spec.from,to:y.spec.to}});break}if(C.value.stereotype==="JPA_EMBEDDABLE"||x.value.stereotype==="JPA_EMBEDDABLE"){s.push({code:"embeddable-relation-unsupported",opIndex:k,handle:{from:y.spec.from,to:y.spec.to}});break}if(C.value.stereotype==="SERIALIZED_TYPE"||x.value.stereotype==="SERIALIZED_TYPE"){s.push({code:"serialized-relation-invalid",opIndex:k,handle:{from:y.spec.from,to:y.spec.to}});break}const $=i(),w={modelId:$,...y.spec.identifying!=null?{identifying:y.spec.identifying}:{},end1:{entityRef:C.value.modelId,multiplicity:y.spec.fromMultiplicity??"EXACTLY_ONE_INSTANCE",navigable:!1,composition:!1},end2:{entityRef:x.value.modelId,multiplicity:y.spec.toMultiplicity??"ZERO_OR_MORE_INSTANCES",navigable:!0,composition:y.spec.composition??!1}},I={...e,associations:[...e.associations,w]},v=_i(I,x.value.modelId,i);v.add[0]&&(w.end2.attributeRef=v.add[0].modelId),l.push({kind:"association.add",casUnit:"logical",associationRef:$,value:w}),g.addedAssociations.push(w);for(const M of v.add){const R={...M,order:d(x.value.modelId,x.value.attributes)};l.push({kind:"attribute.add",casUnit:"logical",containerRef:x.value.modelId,entityRef:x.value.modelId,value:R}),g.cascadeAdds.push({entityId:x.value.modelId,attribute:R})}break}case"association.remove":{const C=Rt(e,y.association.from),x=Rt(e,y.association.to);if(C.ok||s.push(At(C.reason,k,y.association.from,C.matches,E)),x.ok||s.push(At(x.reason,k,y.association.to,x.matches,E)),!C.ok||!x.ok)break;const $=Vu(e,C.value.modelId,x.value.modelId);if($.length!==1){s.push($.length===0?{code:"association-not-found",opIndex:k,handle:y.association}:{code:"association-ambiguous",opIndex:k,handle:y.association,matches:$.map(M=>M.modelId)});break}const w=$[0];m.has(w.modelId)||(m.add(w.modelId),l.push({kind:"association.remove",casUnit:"logical",associationRef:w.modelId}));const I=e.entities.find(M=>M.attributes.some(R=>{var D;return((D=R.embedded)==null?void 0:D.associationRef)===w.modelId}));if(I){const M=I.attributes.find(R=>{var D;return((D=R.embedded)==null?void 0:D.associationRef)===w.modelId});qo(l,f,I.modelId,M.modelId);break}if(w.end1.attributeRef){const M=e.entities.find(D=>D.modelId===w.end1.entityRef),R=M==null?void 0:M.attributes.find(D=>D.modelId===w.end1.attributeRef&&D.attrType==="RELATION_REF");R&&qo(l,f,M.modelId,R.modelId)}const v={...e,associations:e.associations.filter(M=>M.modelId!==w.modelId)};Yl(l,v,[w.end2.entityRef],i,g,f,d);break}case"association.update":{const C=Wu(e,y.association,k,s,E);if(!C)break;const x=y.patch.identifying,$=typeof x=="boolean"?x:void 0;if($===!0&&C.end1.entityRef===C.end2.entityRef){s.push({code:"self-identifying",opIndex:k,handle:y.association});break}const w=ho(y.patch,o_);if(w.length){s.push({code:"association-patch-unknown-key",opIndex:k,handle:y.association,keys:w});break}if(l.push({kind:"association.update",casUnit:"logical",containerRef:C.modelId,associationRef:C.modelId,patch:y.patch}),g.assocPatches.push({associationRef:C.modelId,patch:y.patch}),$!==void 0&&$!==(C.identifying??!1)){const I={...e,associations:e.associations.map(v=>v.modelId===C.modelId?{...v,identifying:$}:v)};Yl(l,I,[C.end2.entityRef],i,g,f,d)}break}case"associationEnd.update":{const C=Wu(e,y.association,k,s,E);if(!C)break;const x=y.end==="from"?"end1":"end2";if(Object.prototype.hasOwnProperty.call(y.patch,"navigable")){s.push({code:"navigable-toggle-unsupported",opIndex:k,handle:y.association});break}const $=ho(y.patch,i_,["jpa."]);if($.length){s.push({code:"association-end-patch-unknown-key",opIndex:k,handle:y.association,keys:$});break}l.push({kind:"associationEnd.update",casUnit:"logical",containerRef:C.modelId,associationRef:C.modelId,end:x,patch:y.patch}),g.endPatches.push({associationRef:C.modelId,end:x,patch:y.patch});break}case"index.add":{{const $=In(y.spec,Hu);if($.length){s.push({code:"index-spec-unknown-key",opIndex:k,entity:y.entity,handle:{ref:y.spec.name},keys:$});break}}const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=Gu(C.value,y.spec,k,y.entity,s,i);if(!x)break;l.push({kind:"index.add",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,indexRef:x.modelId,value:x});break}case"index.update":case"index.remove":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}if(Kl(y.index)){s.push({code:"handle-by-unsupported",opIndex:k,entity:y.entity,handle:y.index,target:"index"});break}const x=Xb(C.value,y.index);if(!x.ok){s.push(x.reason==="not-found"?{code:"index-not-found",opIndex:k,entity:y.entity,handle:y.index}:{code:"index-ambiguous",opIndex:k,entity:y.entity,handle:y.index,matches:x.matches});break}if(y.kind==="index.update"){if("columns"in y.patch){s.push({code:"index-columns-patch-unsupported",opIndex:k,entity:y.entity,handle:y.index});break}const $=ho(y.patch,a_);if($.length){s.push({code:"index-patch-unknown-key",opIndex:k,entity:y.entity,handle:y.index,keys:$});break}l.push({kind:"index.update",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,indexRef:x.value.modelId,patch:y.patch})}else l.push({kind:"index.remove",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,indexRef:x.value.modelId});break}case"operation.add":{{const w=In(y.spec,ju);if(w.length){s.push({code:"operation-spec-unknown-key",opIndex:k,entity:y.entity,handle:{ref:y.spec.name},keys:w});break}}const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}const x=u.get(C.value.modelId)??(C.value.operations?jt(C.value.operations):0);u.set(C.value.modelId,x+1);const $=Ku(y.spec,x,i);l.push({kind:"operation.add",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,operationRef:$.modelId,value:$});break}case"operation.update":case"operation.remove":{const C=Rt(e,y.entity);if(!C.ok){s.push(At(C.reason,k,y.entity,C.matches,E));break}if(Kl(y.operation)){s.push({code:"handle-by-unsupported",opIndex:k,entity:y.entity,handle:y.operation,target:"operation"});break}const x=Lu(C.value,y.operation);if(!x.ok){s.push(x.reason==="not-found"?{code:"operation-not-found",opIndex:k,entity:y.entity,handle:y.operation}:{code:"operation-ambiguous",opIndex:k,entity:y.entity,handle:y.operation,matches:x.matches});break}if(y.kind==="operation.update"){const $=ho(y.patch,r_);if($.length){s.push({code:"operation-patch-unknown-key",opIndex:k,entity:y.entity,handle:y.operation,keys:$});break}l.push({kind:"operation.update",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,operationRef:x.value.modelId,patch:y.patch})}else l.push({kind:"operation.remove",casUnit:"logical",containerRef:C.value.modelId,entityRef:C.value.modelId,operationRef:x.value.modelId});break}case"attribute.reorder":case"operation.reorder":{const C=y.kind==="attribute.reorder",x=Rt(e,y.entity);if(!x.ok){s.push(At(x.reason,k,y.entity,x.matches,E));break}const $=C?y.order:y.operations,w=[],I=new Set;let v=!1;for(const j of $){if(!C&&Kl(j)){s.push({code:"handle-by-unsupported",opIndex:k,entity:y.entity,handle:j,target:"operation"}),v=!0;continue}const U=C?Bu(x.value,j):Lu(x.value,j);if(!U.ok){s.push(U.reason==="not-found"?{code:"reorder-handle-not-found",opIndex:k,entity:y.entity,handle:j}:{code:"reorder-handle-ambiguous",opIndex:k,entity:y.entity,handle:j,matches:U.matches}),v=!0;continue}if(I.has(U.value.modelId)){s.push({code:"reorder-handle-duplicate",opIndex:k,entity:y.entity,handle:j}),v=!0;continue}I.add(U.value.modelId),w.push(U.value)}if(v)break;const R=[...C?x.value.attributes:x.value.operations??[]].sort((j,U)=>j.order-U.order).filter(j=>!I.has(j.modelId)),D=[...w,...R];if(D.forEach((j,U)=>{j.order!==U&&l.push(C?{kind:"attribute.update",casUnit:"logical",containerRef:x.value.modelId,entityRef:x.value.modelId,attributeRef:j.modelId,patch:{order:U}}:{kind:"operation.update",casUnit:"logical",containerRef:x.value.modelId,entityRef:x.value.modelId,operationRef:j.modelId,patch:{order:U}})}),C)for(const j of Tu(e,x.value.modelId,D.map(U=>U.modelId)))l.push({kind:"attribute.update",casUnit:"logical",containerRef:j.entityId,entityRef:j.entityId,attributeRef:j.attributeId,patch:{dbAttrs:j.dbAttrs}});break}case"group.add":{{const I=In(y.spec,t_);if(I.length){s.push({code:"group-spec-unknown-key",opIndex:k,keys:I});break}}const C=[];let x=!1;for(const I of y.spec.members){const v=Rt(e,I);if(!v.ok){s.push(At(v.reason,k,I,v.matches,E)),x=!0;continue}C.push(v.value.modelId)}if(x)break;const $=i(),w={modelId:$,excludeDDLGeneration:y.spec.excludeDDLGeneration??!1,memberEntityRefs:C,...y.spec.name?{name:y.spec.name}:{},...y.spec.packageName?{packageName:y.spec.packageName}:{},...y.spec.description?{description:y.spec.description}:{}};l.push({kind:"group.add",casUnit:"logical",groupRef:$,value:w});break}case"group.update":{const C=Hl(e,y.group);if(!C.ok){s.push(jl(C,k,y.group));break}const x=ho(y.patch,Kb);if(x.length){s.push({code:"group-patch-unknown-key",opIndex:k,handle:y.group,keys:x});break}l.push({kind:"group.update",casUnit:"logical",containerRef:C.value.modelId,groupRef:C.value.modelId,patch:y.patch});break}case"group.remove":{const C=Hl(e,y.group);if(!C.ok){s.push(jl(C,k,y.group));break}l.push({kind:"group.remove",casUnit:"logical",groupRef:C.value.modelId});break}case"group.addMember":case"group.removeMember":{const C=Hl(e,y.group);if(!C.ok){s.push(jl(C,k,y.group));break}const x=Rt(e,y.entity);if(!x.ok){s.push(At(x.reason,k,y.entity,x.matches,E));break}const $=C.value.memberEntityRefs.includes(x.value.modelId);if(y.kind==="group.addMember"?$:!$)break;if(y.kind==="group.removeMember"){if(b.has(_(C.value.modelId,x.value.modelId)))break;b.add(_(C.value.modelId,x.value.modelId))}l.push({kind:y.kind,casUnit:"logical",containerRef:C.value.modelId,groupRef:C.value.modelId,entityRef:x.value.modelId});break}}}),s.length||f_(l,e,p,m,f,h,g,i,d),s.length||d_(l,e,f,p),s.length||u_(l,e,f,h,p,i),s.length?{ok:!1,errors:s}:{ok:!0,ops:l}}function At(e,n,o,i,a){return e==="not-found"&&(a!=null&&a.has(o.ref))?{code:"pending-entity-ref",opIndex:n,handle:o}:e==="not-found"?{code:"entity-not-found",opIndex:n,handle:o}:{code:"entity-ambiguous",opIndex:n,handle:o,matches:i}}function Wu(e,n,o,i,a){const r=Rt(e,n.from),l=Rt(e,n.to);if(r.ok||i.push(At(r.reason,o,n.from,r.matches,a)),l.ok||i.push(At(l.reason,o,n.to,l.matches,a)),!r.ok||!l.ok)return null;const s=Vu(e,r.value.modelId,l.value.modelId);return s.length!==1?(i.push(s.length===0?{code:"association-not-found",opIndex:o,handle:n}:{code:"association-ambiguous",opIndex:o,handle:n,matches:s.map(c=>c.modelId)}),null):s[0]}const Ju={type:"object",description:"요소 지정 핸들. 엔티티: 물리명(table.physicalName) 우선, 논리명(name) 보조. 속성: 소속 엔티티 내 속성명 또는 컬럼 물리명.",properties:{ref:{type:"string",description:"매칭할 이름/물리명. by:'modelId'면 modelId 원문."},by:{type:"string",enum:["physicalName","name","modelId"],description:"매칭 키 고정(미지정 시 대상별 기본 순서). 'modelId'는 모호 해소 전용 탈출구 — 평시엔 쓰지 말고, entity-ambiguous 응답의 후보를 사용자에게 제시해 확인받은 뒤 그 modelId로 재전송할 때만 쓴다."}},required:["ref"],additionalProperties:!1},h_={type:"object",description:"엔티티 내 이름으로 지정(인덱스명·메서드명). 물리명 차원이 없어 매칭 키 고정(`by`)을 받지 않는다.",properties:{ref:{type:"string",description:"매칭할 이름."}},required:["ref"],additionalProperties:!1},y_={type:"object",description:"관계는 무명이라 양 끝 엔티티로 주소. from=부모(end1), to=자식(end2). 같은 쌍 복수 관계는 모호 보고.",properties:{from:{$ref:"#/$defs/handle"},to:{$ref:"#/$defs/handle"}},required:["from","to"],additionalProperties:!1},Xt={type:"object",properties:{ko:{type:"string"},en:{type:"string"},ja:{type:"string"},zh:{type:"string"}},additionalProperties:!1},g_={type:"object",description:"신규 엔티티. 자식(속성·인덱스·operation)은 별도 attribute.add 등이 아니라 여기 inline 배열로 담아라 — 같은 배치에서 갓 추가된 엔티티에 닿는 child op은 silent no-op이 된다(서버가 pending-entity-ref로 거부). 관계는 inline 불가 → 엔티티 추가 배치 확정 후 별도 배치로 association.add.",properties:{name:{type:"string"},stereotype:{type:"string",enum:["UNDEFINED","JPA_ENTITY","JPA_EMBEDDABLE","JPA_MULTI_LANGUAGE_ENTITY","SERIALIZED_TYPE"],description:"기본 JPA_ENTITY."},physicalName:{type:"string",description:"설정 시 table.physicalName."},classLogicalName:{...Xt,description:"**클래스** 논리명(다국어). 테이블이 없는 자리(직렬화 타입 SERIALIZED_TYPE)의 논리명이 여기 산다 — 그 타입은 table 자체를 갖지 않아 table.logicalName 을 줄 데가 없다. ⚠️테이블이 있는 엔티티는 table.logicalName 이 이기므로 그쪽을 쓴다."},useVersion:{type:"boolean",description:'JPA @Version(낙관적 락) → jpaAttrs.useVersion. @Version 필드는 별도 속성이 아니라 이 엔티티 플래그로 흡수 (버전 컬럼은 코드젠 소유). 기존 엔티티는 entity.update patch의 dotted key {"jpaAttrs.useVersion":true} 사용.'},attributes:{type:"array",description:"inline 속성(배열 순서가 order). attribute.add와 동일 규칙 — GroupCodeEnum은 groupCode 동반 필수.",items:{$ref:"#/$defs/attrSpec"}},indexes:{type:"array",description:"inline 인덱스. 컬럼 핸들은 이 엔티티가 inline으로 만드는 dbAttr 내에서 해소된다(attributes 동반 전제).",items:{$ref:"#/$defs/indexSpec"}},operations:{type:"array",description:"inline 도메인 메서드(배열 순서가 order).",items:{$ref:"#/$defs/operationSpec"}},serialization:{$ref:"#/$defs/serialization"}},required:["name"],additionalProperties:!1},b_={type:"object",description:"직렬화 타입의 컨테이너(SERIALIZED_TYPE 전용). 미지정 = 컬렉션이 아닌 단일 값(한 컬럼에 구조 하나). 신규 엔티티는 entity.add 에 함께 줘야 한다 — 같은 배치의 entity.update 는 갓 만든 엔티티에 닿지 못한다.",properties:{collectionType:{type:"string",enum:["LIST","SET","MAP"],description:"컨테이너 종류. 코퍼스 실재가 java.util 3종뿐이라 그만 표현한다(미지 컨테이너는 발명하지 않는다)."},mapKeyType:{type:"string",description:"collectionType='MAP' 일 때의 키 타입(단순명 또는 FQN). 그 외엔 무의미."}},additionalProperties:!1},__={type:"object",properties:{name:{type:"string"},type:{type:"string",description:"Java 타입(예: Long, String). GroupCodeEnum은 파생 타입이라 groupCode 동반 필수(없으면 거부). 호스트 임베더블 카탈로그에 등록된 predefined 임베더블 타입(예: Money, EmbeddableAddress)이면 EMBED_PREDEF로 다중 컬럼 확장(서브컬럼 조정은 embeddableOverrides)."},identifier:{type:"boolean"},notNull:{type:"boolean"},transient:{type:"boolean",description:"JPA @Transient(비영속) → Attribute.transient. 컬럼을 만들지 않으므로 physicalName/dataType 등 컬럼 필드는 함께 주지 않는다. 기존 속성은 attribute.update patch {transient:true}로도 가능."},physicalName:{type:"string",description:"설정 시 단일 dbAttr 컬럼 생성(미설정이면 name을 물리명으로)."},dataType:{type:"string",description:"dbAttr 물리 타입(예: BIGINT). physicalName/dataType/length/scale 중 하나라도 있으면 컬럼 생성."},length:{type:"integer",description:"dbAttr 컬럼 길이(VARCHAR(n)·DECIMAL precision)."},scale:{type:"integer",description:"dbAttr 소수 자릿수(DECIMAL/NUMERIC scale). length 동반이 일반적."},groupCode:{type:"string",description:"코드성 속성의 group code 바인딩. type=GroupCodeEnum이면 필수."},defaultValue:{type:"string",description:"속성 기본값(문자열 패스스루)."},attributeGroup:{type:"string",description:"속성 분류 그룹(예: 'code'·'amt')."},description:{...Xt,description:"속성 설명(다국어)."},columnLogicalName:{...Xt,description:'dbAttr 컬럼 논리명(다국어, 예: {ko:"체크아웃유형"}). 한글 업무명 보존 위치.'},fieldLogicalName:{...Xt,description:"**필드** 논리명(다국어). 평탄 `logicalName`(컬럼 논리명)과 **다른 축**이다 — 컬럼이 없는 자리(직렬화 타입 SERIALIZED_TYPE 의 자기 필드)는 dbAttrs 가 0이라 컬럼 논리명을 줄 데가 없고, 그 자리의 논리명이 여기 산다(캔버스 논리 뷰·탐색기 검색·코드젠 javadoc 이 읽는다). 컬럼이 있는 자리에서는 컬럼 논리명이 이긴다."},unique:{type:"boolean",description:"dbAttr UNIQUE 제약."},updatable:{type:"boolean",description:"dbAttr 갱신 가능(JPA @Column(updatable=))."},embeddableOverrides:{$ref:"#/$defs/embeddableOverrides"},collectionType:{type:"string",enum:["LIST","SET"],description:"이 «필드»가 컬렉션인가 — **직렬화 타입(SERIALIZED_TYPE)의 자기 필드 전용**(예: Set<String>·List<StoredFile>). 컬럼 있는 자리는 읽지 않는다 — 그쪽 컨테이너는 요소 타입이 소유한다(entity 의 serialization.collectionType). 요소가 문서 안 직렬화 타입이면 그 타입이 이미 감싸므로 지정하지 않는다. 미지정 = 컬렉션 아님."}},required:["name","type"],additionalProperties:!1},k_={type:"array",description:"predefined 임베더블 서브컬럼 오버라이드(속성 type이 카탈로그 엔트리이자 EMBED_PREDEF일 때만). field=카탈로그 필드명으로 매칭(@AttributeOverride 대응). 미설정 서브컬럼은 add=카탈로그 기본 상속 / update=기존값 유지. currency 등 공유 컬럼은 sharedColumnPhysicalName으로 SHARED_REF.",items:{type:"object",properties:{field:{type:"string",description:"대상 카탈로그 필드명(예: amount·currency)."},physicalName:{type:"string",description:"서브컬럼 물리명 오버라이드(@AttributeOverride column name). 미설정 시 카탈로그 기본."},length:{type:"integer",description:"서브컬럼 길이 오버라이드."},scale:{type:"integer",description:"서브컬럼 소수 자릿수 오버라이드."},insertable:{type:"boolean",description:"JPA @Column(insertable=). OWN 컬럼에만 저장."},updatable:{type:"boolean",description:"JPA @Column(updatable=). OWN 컬럼에만 저장."},sharedColumnPhysicalName:{type:"string",description:"SHARED_REF — 같은 엔터티(임베더블이면 owner 합집합) 다른 컬럼(물리명)을 공유해 read-only 투영(대표: currency). 설정 시 자체 컬럼 미보유, 타깃은 해소 시점 존재 필수."}},required:["field"],additionalProperties:!1}},Xu={type:"string",enum:["NO_INSTANCE_OR_ONE_INSTANCE","EXACTLY_ONE_INSTANCE","ZERO_OR_MORE_INSTANCES","ONE_OR_MORE_INSTANCES"]},E_={type:"object",description:'일반 연관 생성. 양 end 는 일반 엔티티여야 한다 — 임베더블(JPA_EMBEDDABLE)·직렬화 타입을 end 로 주면 거부된다. 직렬화 타입은 관계가 아니라 소비 속성의 type 으로 지목한다(attribute.update {type: "<타입명>"}). (임베드는 EMBED 관계여야 하고 이 어휘엔 없다 → 캔버스에서 연결).',properties:{from:{$ref:"#/$defs/handle"},to:{$ref:"#/$defs/handle"},fromMultiplicity:{...Xu,description:"end1 다중성(기본 EXACTLY_ONE_INSTANCE)."},toMultiplicity:{...Xu,description:"end2 다중성(기본 ZERO_OR_MORE_INSTANCES)."},identifying:{type:"boolean",description:"식별 관계(부모 PK가 자식 PK로 전파). self-association은 식별 불가."},composition:{type:"boolean",description:"end2 composition."}},required:["from","to"],additionalProperties:!1},N_={type:"object",properties:{name:{type:"string"},unique:{type:"boolean",description:"UNIQUE 인덱스 여부(기본 false)."},columns:{type:"array",description:"인덱스 컬럼(순서 의미 있음).",items:{type:"object",properties:{column:{...Ju,description:"컬럼 핸들 — 컬럼 물리명 우선, 속성명 보조(단일 컬럼 속성만). 엔티티 내에서 dbAttr modelId로 해소."},descending:{type:"boolean",description:"내림차순(기본 false)."}},required:["column"],additionalProperties:!1}},description:{type:"string",description:"인덱스 설명(평문)."},parameters:{type:"string",description:"인덱스 파라미터(패스스루)."}},required:["name","columns"],additionalProperties:!1},w_={type:"object",properties:{name:{type:"string"},visibility:{type:"string",enum:["PUBLIC","PRIVATE","PROTECTED","PACKAGE"],description:"가시성(기본 미설정)."},sourceCode:{type:"string",description:"Java 메서드 본문(멀티라인, 파라미터·반환 시그니처 포함)."},description:{...Xt,description:"메서드 설명(다국어)."},personalInfoAttributeType:{type:"string",description:"개인정보 속성 유형(패스스루)."}},required:["name"],additionalProperties:!1},I_={type:"object",properties:{name:{...Xt,description:'그룹 논리명(다국어, 예: {ko:"주문"}).'},packageName:{type:"string",description:"자바 패키지명 등 그룹 물리 식별(레거시 LogicalGroup.packageName)."},description:{type:"string",description:"그룹 설명(자유 텍스트 — 도메인 경계 메모)."},excludeDDLGeneration:{type:"boolean",description:"DDL 생성 제외(기본 false)."},members:{type:"array",description:"멤버 엔티티 핸들(물리명 우선/논리명 보조). 기존 엔티티여야 함 — 같은 배치 신규 엔티티는 별도 배치 후.",items:{$ref:"#/$defs/handle"}}},required:["members"],additionalProperties:!1},v_={type:"object",description:"기존 속성 부분 patch. 논리 필드 + 스칼라 단일 컬럼의 물리 필드(physicalName·dataType·length·scale 등 — 서버가 dbAttrs[0]에 매핑). EMBED_PREDEF/Money 서브컬럼 조정은 op-레벨 embeddableOverrides로(평탄 키는 다중 컬럼서 모호해 거부).",properties:{name:{type:"string"},type:{type:"string"},customType:{type:"string"},attrType:{type:"string",enum:[...Ru],description:"속성 종류. **현재 값과 다르게 주면 거부된다** — 관계/임베드/구분선은 동반 구조(관계 소유·embedded·빈 dbAttrs)가 있어야 성립하고 patch로는 표현할 수 없다. 관계 실체화는 association.add, 임베드 서브컬럼은 embeddableOverrides 소관."},identifier:{type:"boolean"},notNull:{type:"boolean"},transient:{type:"boolean"},naturalId:{type:"boolean"},naturalIdMutable:{type:"boolean"},derivedIdFieldName:{type:"string",description:"파생 식별(@MapsId) FK가 매핑되는 **스칼라 @Id 필드명**. 이 속성의 name은 연관 필드명(@MapsId @OneToOne 필드)이고 같은 관계가 두 Java 필드를 만든다. 단일 컬럼 @OneToOne 식별 FK에만 의미가 있고, 미설정 시 부모 PK 물리명의 camelCase로 파생된다(실물 관행). 컬럼은 공유하므로 속성은 하나이며 물리명은 지정하지 않는다."},description:{...Xt,description:"속성 설명(다국어)."},fieldLogicalName:{...Xt,description:"**필드** 논리명(다국어). 평탄 `logicalName`(컬럼 논리명)과 **다른 축**이다 — 컬럼이 없는 자리(직렬화 타입 SERIALIZED_TYPE 의 자기 필드)는 dbAttrs 가 0이라 컬럼 논리명을 줄 데가 없고, 그 자리의 논리명이 여기 산다(캔버스 논리 뷰·탐색기 검색·코드젠 javadoc 이 읽는다). 컬럼이 있는 자리에서는 컬럼 논리명이 이긴다."},attributeGroup:{type:"string"},groupCode:{type:"string"},defaultValue:{type:"string"},personalInfoAttributeType:{type:"string"},order:{type:"integer"},physicalName:{type:"string"},dataType:{type:"string"},length:{type:"integer"},scale:{type:"integer"},unique:{type:"boolean"},updatable:{type:"boolean"},insertable:{type:"boolean"},autoIncrement:{type:"boolean"},multiValue:{type:"boolean"},multiValueSeparator:{type:"string"},sequenceName:{type:"string"},logicalName:{...Xt,description:"**컬럼** 논리명(다국어). 대상이 스칼라 단일 컬럼일 때 dbAttrs[0]에 매핑된다 — dbAttrs 가 0인 속성(직렬화 타입 필드·transient)에 주면 거부되고, 그 자리의 논리명은 `fieldLogicalName` 이 받는다."}},additionalProperties:!1},C_={type:"object",description:"관계 부분 patch. 양 end 설정(multiplicity·nav·jpa)은 associationEnd.update로.",properties:{description:{type:"string"},identifying:{type:"boolean",description:"식별 관계(부모 PK가 자식 PK 일부로 전파)."}},additionalProperties:!1},S_={type:"object",description:"인덱스 부분 patch. columns(컬럼 구성) 변경은 index.remove+index.add로(패치 불가).",properties:{name:{type:"string"},unique:{type:"boolean"},description:{type:"string"},parameters:{type:"string"}},additionalProperties:!1},x_={type:"object",description:"메서드 부분 patch.",properties:{name:{type:"string"},visibility:{type:"string",enum:["PUBLIC","PRIVATE","PROTECTED","PACKAGE"]},sourceCode:{type:"string"},description:{...Xt,description:"메서드 설명(다국어)."},order:{type:"integer"},personalInfoAttributeType:{type:"string"}},additionalProperties:!1},R_={type:"object",description:'엔티티 부분 patch. 논리 키: name·stereotype·packageName·superClass·schema·description·abstractClass·hasPersonalInfo·referenceOnly·declarationOfInterfaces·table·serialization·classLogicalName. classLogicalName = **클래스** 논리명(테이블 없는 직렬화 타입의 논리명이 사는 곳 — 그 타입은 table 을 갖지 않는다). 테이블이 있는 엔티티는 table.logicalName(dotted-key)이 이긴다. serialization(직렬화 타입 컨테이너)은 통째로 주거나(예: {"serialization":{"collectionType":"LIST"}}) dotted-key로 준다({"serialization.collectionType":"LIST"}). 컬렉션 아님으로 되돌릴 땐 null 로 비운다(wire clear 규약). jpaAttrs 플래그(useVersion 등)는 형제 클로버 방지를 위해 dotted-key로 준다: {"jpaAttrs.useVersion": true}. 자식(attributes/indexes/operations)은 patch가 아니라 전용 op로 변경. stereotype 은 값 타입(JPA_EMBEDDABLE·SERIALIZED_TYPE) 경계를 넘을 수 없다 — 들어가고 나오는 전환은 PK 해제/부여·FK reconcile·EMBED 복원/해체가 동반되는 composite라 patch로 표현되지 않는다(거부. 전환은 GUI 소관).'},A_={type:"object",description:'관계 end 부분 patch. 논리 키: multiplicity·navigable·composition. jpa 설정(cascadeTypes·fetchType·orphanRemoval·orderBy·collectionType·collectionTable·orderColumn)은 형제 클로버 방지를 위해 dotted-key로: {"jpa.orphanRemoval": true}.'};function ft(e,n){return{type:"object",properties:{kind:{const:e},...n.properties},required:["kind",...n.required],additionalProperties:!1}}const $_={"entity.add":ft("entity.add",{properties:{spec:{$ref:"#/$defs/entitySpec"}},required:["spec"]}),"entity.update":ft("entity.update",{properties:{entity:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/entityUpdatePatch"}},required:["entity","patch"]}),"entity.remove":ft("entity.remove",{properties:{entity:{$ref:"#/$defs/handle"}},required:["entity"]}),"attribute.add":ft("attribute.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/attrSpec"}},required:["entity","spec"]}),"attribute.update":ft("attribute.update",{properties:{entity:{$ref:"#/$defs/handle"},attribute:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/attrUpdatePatch"},embeddableOverrides:{$ref:"#/$defs/embeddableOverrides"}},required:["entity","attribute","patch"]}),"attribute.remove":ft("attribute.remove",{properties:{entity:{$ref:"#/$defs/handle"},attribute:{$ref:"#/$defs/handle"}},required:["entity","attribute"]}),"association.add":ft("association.add",{properties:{spec:{$ref:"#/$defs/assocSpec"}},required:["spec"]}),"association.remove":ft("association.remove",{properties:{association:{$ref:"#/$defs/assocHandle"}},required:["association"]}),"association.update":ft("association.update",{properties:{association:{$ref:"#/$defs/assocHandle"},patch:{$ref:"#/$defs/assocUpdatePatch"}},required:["association","patch"]}),"associationEnd.update":ft("associationEnd.update",{properties:{association:{$ref:"#/$defs/assocHandle"},end:{type:"string",enum:["from","to"],description:"from=부모(end1), to=자식(end2)."},patch:{$ref:"#/$defs/assocEndUpdatePatch"}},required:["association","end","patch"]}),"index.add":ft("index.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/indexSpec"}},required:["entity","spec"]}),"index.update":ft("index.update",{properties:{entity:{$ref:"#/$defs/handle"},index:{$ref:"#/$defs/nameHandle"},patch:{$ref:"#/$defs/indexUpdatePatch"}},required:["entity","index","patch"]}),"index.remove":ft("index.remove",{properties:{entity:{$ref:"#/$defs/handle"},index:{$ref:"#/$defs/nameHandle"}},required:["entity","index"]}),"operation.add":ft("operation.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/operationSpec"}},required:["entity","spec"]}),"operation.update":ft("operation.update",{properties:{entity:{$ref:"#/$defs/handle"},operation:{$ref:"#/$defs/nameHandle"},patch:{$ref:"#/$defs/operationUpdatePatch"}},required:["entity","operation","patch"]}),"operation.remove":ft("operation.remove",{properties:{entity:{$ref:"#/$defs/handle"},operation:{$ref:"#/$defs/nameHandle"}},required:["entity","operation"]}),"attribute.reorder":ft("attribute.reorder",{properties:{entity:{$ref:"#/$defs/handle"},order:{type:"array",items:{$ref:"#/$defs/handle"},minItems:1}},required:["entity","order"]}),"operation.reorder":ft("operation.reorder",{properties:{entity:{$ref:"#/$defs/handle"},operations:{type:"array",items:{$ref:"#/$defs/nameHandle"},minItems:1}},required:["entity","operations"]}),"group.add":ft("group.add",{properties:{spec:{$ref:"#/$defs/groupSpec"}},required:["spec"]}),"group.update":ft("group.update",{properties:{group:{$ref:"#/$defs/groupHandle"},patch:{$ref:"#/$defs/groupUpdatePatch"}},required:["group","patch"]}),"group.remove":ft("group.remove",{properties:{group:{$ref:"#/$defs/groupHandle"}},required:["group"]}),"group.addMember":ft("group.addMember",{properties:{group:{$ref:"#/$defs/groupHandle"},entity:{$ref:"#/$defs/handle"}},required:["group","entity"]}),"group.removeMember":ft("group.removeMember",{properties:{group:{$ref:"#/$defs/groupHandle"},entity:{$ref:"#/$defs/handle"}},required:["group","entity"]})},T_={type:"object",description:"그룹 지정 핸들. 패키지명(packageName) 우선, 이름(name) 보조 — 이름은 다국어라 어느 로케일 값이든 일치하면 매칭. 'modelId'는 모호 해소 전용(group-ambiguous 후보를 사용자에게 확인받은 뒤).",properties:{ref:{type:"string",description:"매칭할 패키지명/이름. by:'modelId'면 modelId 원문."},by:{type:"string",enum:["packageName","name","modelId"],description:"매칭 키 고정(미지정 시 packageName → name)."}},required:["ref"],additionalProperties:!1},M_={type:"object",description:"그룹 부분 patch. 멤버 변경은 group.addMember/removeMember로(배열 통째 교체는 동시 편집이 서로를 덮는다).",properties:{name:{...Xt,description:"그룹 논리명(다국어)."},packageName:{type:"string"},description:{type:"string"},excludeDDLGeneration:{type:"boolean"}},additionalProperties:!1},Zu={anyOf:xu.map(e=>$_[e])},V_={type:"object",description:"엔티티 모델을 생성·수정·삭제할 때 호출한다. ops는 사람 핸들(엔티티 물리명/논리명, 속성명)로 지정하며 서버가 modelId로 해소한다. 모호하면 에러로 후보를 돌려주니 리소스로 현재 모델을 먼저 읽어 핸들을 확정하라.",properties:{ops:{type:"array",items:{$ref:"#/$defs/symbolicOp"}}},required:["ops"],additionalProperties:!1,$defs:{handle:Ju,nameHandle:h_,groupHandle:T_,assocHandle:y_,entitySpec:g_,serialization:b_,attrSpec:__,embeddableOverrides:k_,assocSpec:E_,indexSpec:N_,operationSpec:w_,groupSpec:I_,entityUpdatePatch:R_,attrUpdatePatch:v_,assocUpdatePatch:C_,assocEndUpdatePatch:A_,indexUpdatePatch:S_,operationUpdatePatch:x_,groupUpdatePatch:M_,symbolicOp:Zu}};function B_(e,n,o,i={}){const a=i.mkClientOpId??Pe,r=new Set;for(const s of o)s.casUnit==="logical"&&s.containerRef&&r.add(s.containerRef);const l={};if(r.size){l.revs={};for(const s of r)l.revs[s]=n[s]??0}return{diagramId:e,ops:o,cas:l,origin:i.origin??"agent",clientOpId:a()}}const Qu={location:{x:0,y:0},size:{width:220,height:140}};function em(e){return{modelId:e.modelId,physicalName:e.physicalName,logicalName:e.logicalName,dataType:e.dataType,length:e.length,scale:e.scale,unique:e.unique,autoIncrement:e.autoIncrement,updatable:e.updatable,insertable:e.insertable,sharedColumnRef:e.sharedColumnRef,multiValue:e.multiValue,multiValueSeparator:e.multiValueSeparator,sequenceName:e.sequenceName}}const D_=/^[-=_*~\s]{3,}$/;function L_(e){return e.attrType&&e.attrType!=="NORMAL"||!D_.test(e.name??"")?!1:!(e.dbAttrs??[]).some(n=>n.physicalName||n.dataType)}function O_(e){return e.type===En&&e.customType==="java.util.Currency"?{type:"Currency",customType:void 0}:{type:e.type,customType:e.customType}}function P_(e,n){if(e.attrType==="DIVIDER"||L_(e))return{modelId:e.modelId,name:e.attrType==="DIVIDER"?e.name:"",type:"",attrType:"DIVIDER",identifier:!1,notNull:!1,order:e.order??n,dbAttrs:[]};const o=O_(e);return{modelId:e.modelId,name:e.name,type:o.type,customType:o.customType,attrType:e.attrType,identifier:e.identifier,notNull:e.notNull,transient:e.transient_,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:e.order??n,dbAttrs:e.dbAttrs.map(em)}}function z_(e,n){const{modelId:o,name:i,visibility:a,sourceCode:r,description:l,order:s,personalInfoAttributeType:c,style:d,...u}=e;return{modelId:o,name:i,visibility:a,sourceCode:r,description:l?{ko:l}:void 0,order:s??n,personalInfoAttributeType:c,legacyRaw:Object.keys(u).length?u:void 0}}function F_(e){return{modelId:e.modelId,name:e.name,unique:e.unique,description:e.description,parameters:e.parameters,columns:e.indexColumns.map(n=>({columnRef:n.targetColumn.refId,descending:n.descending}))}}function U_(e){var n,o;return{modelId:e.modelId,name:e.name,stereotype:e.stereotype,packageName:e.packageName,superClass:e.superClass,schema:e.schema,description:e.description,abstractClass:e.abstractClass,hasPersonalInfo:e.hasPersonalInfo,declarationOfInterfaces:e.declarationOfInterfaces,attributes:e.attributes.map(P_),operations:(n=e.operations)==null?void 0:n.map(z_),indexes:(o=e.indexes)==null?void 0:o.map(F_),jpaAttrs:e.jpaAttrs,table:e.dbAttrs?{physicalName:e.dbAttrs.physicalName,logicalName:e.dbAttrs.logicalName}:void 0}}function H_(e){const n={};for(const i of e.attributes)i.style&&(n[i.modelId]=i.style);const o={};for(const i of e.operations??[])i.style&&(o[i.modelId]=i.style);return{entityRef:e.modelId,geo:e.geo??{...Qu},style:e.style,attributeStyles:Object.keys(n).length?n:void 0,operationStyles:Object.keys(o).length?o:void 0,collapsed:e.collapsed,locked:e.locked}}function tm(e){return e.jpaAttribute?{fetchType:e.jpaAttribute.fetchType,cascadeTypes:e.jpaAttribute.cascadeTypes,orphanRemoval:e.jpaAttribute.orphanRemoval,orderBy:e.jpaAttribute.orderBy,collectionType:e.jpaAttribute.collectionType,collectionTable:e.jpaAttribute.collectionTable,orderColumn:e.jpaAttribute.orderColumn}:void 0}function ql(e){var n;return{entityRef:e.endModel.refId,multiplicity:e.multiplicity,navigable:e.navigable,composition:e.composition,attributeRef:(n=e.attribute)==null?void 0:n.modelId,jpa:tm(e)}}function j_(e){if(e.end1.endModel.refId===e.end2.endModel.refId)return;const n=o=>Wl(o)&&(o==null?void 0:o.identifier)===!0;return n(e.end1.attribute)||n(e.end2.attribute)?!0:void 0}function K_(e){var i,a;const n={modelId:e.modelId,description:e.description,identifying:j_(e),end1:ql(e.end1),end2:ql(e.end2)},o={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:(i=e.end1.attribute)==null?void 0:i.modelId,targetColumnRef:(a=e.end2.attribute)==null?void 0:a.modelId,style:e.style};return{assoc:n,layout:o}}function Wl(e){var n;return!!e&&typeof e.attrType=="string"&&e.attrType.startsWith("RELATION")&&(((n=e.dbAttrs)==null?void 0:n.length)??0)>0}function nm(e){var n;return!!e&&typeof e.attrType=="string"&&e.attrType.startsWith("EMBED")&&(((n=e.dbAttrs)==null?void 0:n.length)??0)>0}function om(e){var o;const n=e.attribute;return(n==null?void 0:n.attrType)==="EMBED_OWN"&&(((o=n.dbAttrs)==null?void 0:o.length)??0)===0&&(e.multiplicity==="ZERO_OR_MORE_INSTANCES"||e.multiplicity==="ONE_OR_MORE_INSTANCES")}function im(e,n){return{modelId:e.modelId,name:e.name??"",type:e.type??"",customType:e.customType,attrType:e.attrType??"RELATION_OWN",identifier:e.identifier??!1,notNull:e.notNull??!1,transient:e.transient_,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:n,dbAttrs:(e.dbAttrs??[]).map(em)}}function G_(e,n,o){var y,k;const i=Wl(e.end1.attribute),a=Wl(e.end2.attribute);if(i===a)return K_(e);const r=i?e.end1:e.end2,l=i?e.end2:e.end1,s=r.attribute,c=(k=(y=s.dbAttrs)==null?void 0:y[0])==null?void 0:k.targetModelId,d=c?o.get(c):void 0,u=n.get(l.endModel.refId),m=u?u.attributes.reduce((S,T)=>Math.max(S,T.order),-1)+1:s.order??0,p={...im(s,m),attrType:"RELATION_OWN",derivedFrom:d?{associationRef:e.modelId,sourceAttributeRef:d}:void 0};u&&u.attributes.push(p);const f=n.get(r.endModel.refId),h=l.attribute;let g;if(h&&f&&r.navigable){const S=ha(l.multiplicity);g={modelId:h.modelId??crypto.randomUUID(),name:ao(h.name??ga((u==null?void 0:u.name)??l.endModel.refId,S),new Set(f.attributes.map(T=>T.name))),type:(u==null?void 0:u.name)??l.endModel.refId,attrType:"RELATION_REF",identifier:!1,notNull:!1,order:f.attributes.reduce((T,B)=>Math.max(T,B.order),-1)+1,dbAttrs:[]},f.attributes.push(g)}const b=(S,T)=>({entityRef:S.endModel.refId,multiplicity:S.multiplicity,navigable:S.navigable,composition:S.composition,attributeRef:T?g==null?void 0:g.modelId:p.modelId,jpa:tm(S)}),_=r.endModel.refId===l.endModel.refId,E={modelId:e.modelId,description:e.description,identifying:!_&&p.identifier===!0?!0:void 0,end1:b(e.end1,i),end2:b(e.end2,a)},N={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:i?d:p.modelId,targetColumnRef:i?p.modelId:d,style:e.style};return{assoc:E,layout:N}}function Y_(e,n){const o=e.targetModelId?n.get(e.targetModelId):void 0;return{modelId:e.modelId,physicalName:e.physicalName||(o==null?void 0:o.physicalName)||"",logicalName:e.logicalName??(o==null?void 0:o.logicalName),dataType:e.dataType||(o==null?void 0:o.dataType)||"",length:e.length??(o==null?void 0:o.length),scale:e.scale??(o==null?void 0:o.scale),unique:e.unique??(o==null?void 0:o.unique),autoIncrement:e.autoIncrement??(o==null?void 0:o.autoIncrement),updatable:e.updatable??(o==null?void 0:o.updatable),insertable:e.insertable??(o==null?void 0:o.insertable)}}function q_(e,n,o){var h;const i=((h=e.end1.attribute)==null?void 0:h.attrType)==="EMBED_OWN",a=i?e.end1:e.end2,r=i?e.end2:e.end1,l=a.attribute,s=n.get(r.endModel.refId),c=s?s.attributes.reduce((g,b)=>Math.max(g,b.order),-1)+1:l.order??0,d={...im(l,c),attrType:l.attrType??"EMBED_OWN",dbAttrs:(l.dbAttrs??[]).map(g=>Y_(g,o)),embedded:{associationRef:e.modelId,embeddableRef:a.endModel.refId}};s&&s.attributes.push(d);const u=g=>({...ql(g),legacyEmbedRaw:g.attribute}),m={modelId:e.modelId,description:e.description,end1:u(e.end1),end2:u(e.end2)},p=!i,f={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:p?d.modelId:void 0,targetColumnRef:p?void 0:d.modelId,style:e.style};return{assoc:m,layout:f}}function W_(e,n){var i,a,r,l;const o=[];for(const s of n){const c=(a=(i=s.end1)==null?void 0:i.endModel)==null?void 0:a.refId,d=(l=(r=s.end2)==null?void 0:r.endModel)==null?void 0:l.refId,u=c===e?d:c;!u||u===e||o.push({targetRef:u,waypoints:s.locations??[]})}return o}function am(e,n={x:0,y:0}){const{modelId:o,memo:i,geo:a,style:r,connections:l,ownedConnections:s,...c}=e;let d=l;if(!d&&Array.isArray(s)){const u=W_(o,s);u.length&&(d=u)}return{modelId:o,memo:i,geo:{location:{x:a.location.x+n.x,y:a.location.y+n.y},size:a.size},style:r,connections:d,legacyRaw:Object.keys(c).length?c:void 0}}function rm(e,n,o){if(!(o!=null&&o.length))return;const i=new Map(e.map(l=>[l.modelId,l])),a=new Map(n.map(l=>[l.modelId,l])),r=(l,s)=>{var c;return!!s&&!!((c=i.get(l??""))!=null&&c.attributes.some(d=>d.modelId===s))};for(const l of o){const s=a.get(l.associationRef);s&&(l.sourceColumnRef&&!r(s.end1.entityRef,l.sourceColumnRef)&&(l.sourceColumnRef=void 0),l.targetColumnRef&&!r(s.end2.entityRef,l.targetColumnRef)&&(l.targetColumnRef=void 0))}}function J_(e,n){const o=new Map(e.map(i=>[i.modelId,i]));for(const i of n){if(i.end1.navigable!==!0)continue;const a=o.get(i.end1.entityRef),r=o.get(i.end2.entityRef);if(!a||!r||gt(a.stereotype)||gt(r.stereotype))continue;const l=i.end1.attributeRef?a.attributes.find(p=>p.modelId===i.end1.attributeRef):void 0;if((l==null?void 0:l.attrType)==="RELATION_REF")continue;const s=`nav:${i.modelId}`,c=a.attributes.find(p=>p.modelId===s);if((c==null?void 0:c.attrType)==="RELATION_REF"){i.end1.attributeRef=s;continue}const d=ha(i.end2.multiplicity),u=ga(r.name,d),m=ao(u,new Set(a.attributes.map(p=>p.name)));a.attributes.push({modelId:s,name:m,type:r.name,attrType:"RELATION_REF",identifier:!1,notNull:!1,order:a.attributes.reduce((p,f)=>Math.max(p,f.order),-1)+1,dbAttrs:[]}),i.end1.attributeRef=s}}function X_(e,n){const o=new Map(e.map(i=>[i.modelId,i]));for(const i of n){if(i.identifying===!0||i.end1.entityRef===i.end2.entityRef)continue;const a=o.get(i.end1.entityRef),r=o.get(i.end2.entityRef);if(!a||!r||gt(a.stereotype)||gt(r.stereotype))continue;const l=r.attributes.find(s=>s.modelId===i.end2.attributeRef);l&&l.attrType.startsWith("RELATION")&&l.dbAttrs.length>0&&l.identifier===!0&&(i.identifying=!0)}}function lm(e,n){var i;const o=new Map(e.map(a=>[a.modelId,a]));for(const a of n){const r=o.get(a.end2.entityRef);if(!r)continue;const l=o.get(a.end1.entityRef);if(l&>(l.stereotype))continue;const s=a.end1.entityRef===a.end2.entityRef,c=a.identifying===!0||!s&&!Uc(a.end1.multiplicity);for(const d of r.attributes)!d.attrType.startsWith("RELATION")||d.dbAttrs.length===0||!(((i=d.derivedFrom)==null?void 0:i.associationRef)===a.modelId||!d.derivedFrom&&d.modelId===a.end2.attributeRef)||(d.notNull=c)}}function sm(e){const n=JSON.parse(JSON.stringify(e));return(n.schemaVersion??1)>=2&&"logical"in n?Z_(n):Q_(n)}function Z_(e){const n=e.id??e.logical.modelId??"",o={},i=m=>{const{rev:p,...f}=m;return p!=null&&(o[m.modelId]=p),f},a=e.logical.entities.map(i),r=e.logical.associations.map(i),l=e.logical.groups.map(i);J_(a,r),X_(a,r),lm(a,r);const{version:s,...c}=e.layout;rm(a,r,c.associationLayouts);const d={logical:{modelId:e.logical.modelId??n,packageName:e.logical.packageName,entities:a,associations:r,groups:l},layout:{...c,diagramId:c.diagramId??n,logicalModelRef:c.logicalModelRef??n}},u={id:e.id,version:e.version,diagramVersion:e.diagramVersion,size:e.size,packageName:e.packageName,schemaVersion:e.schemaVersion,opWriteEnabled:e.opWriteEnabled,referenceOnly:e.referenceOnly,revSeed:{revs:o,layoutVersion:s??0,logicalVersion:e.logical.version??0}};return{state:d,meta:u}}function Q_(e){var _,E;const n=e.id??"",o=[],i=[],a=[],r=[],l=[],s=[],c=[],d=(N,y)=>{o.push(U_(N));const k=H_(N);k.geo={location:{x:k.geo.location.x+y.x,y:k.geo.location.y+y.y},size:k.geo.size},i.push(k);for(const S of N.ownedAssociations??[])c.push(S)},u={x:0,y:0};for(const N of e.entities??[])d(N,u);const m=[];for(const N of e.groups??[]){const y=N.entities??[];l.push({modelId:N.modelId,name:N.name,description:N.description,packageName:N.packageName,excludeDDLGeneration:N.excludeDDLGeneration??!1,memberEntityRefs:y.map(S=>S.modelId)});const k=((_=N.geo)==null?void 0:_.location)??u;if(N.geo){const S=(N.notes??[]).map(T=>T.modelId);s.push({groupRef:N.modelId,geo:N.geo,style:N.style,locked:N.locked,memberNoteRefs:S.length?S:void 0})}for(const S of y)d(S,k);for(const S of N.notes??[])m.push(am(S,k))}const p=new Map(o.map(N=>[N.modelId,N])),f=new Map,h=new Map;for(const N of o)for(const y of N.attributes)for(const k of y.dbAttrs)f.set(k.modelId,y.modelId),h.set(k.modelId,k);for(const N of c)for(const y of[N.end1,N.end2]){const k=y.attribute;if(k&&(((E=k.dbAttrs)==null?void 0:E.length)??0)>0)for(const S of k.dbAttrs)S.modelId&&f.set(S.modelId,k.modelId)}for(const N of c){const y=nm(N.end1.attribute),k=nm(N.end2.attribute),S=om(N.end1)||om(N.end2),{assoc:T,layout:B}=y!==k||S?q_(N,p,h):G_(N,p,f);a.push(T),r.push(B)}rm(o,a,r),Ad(o),lm(o,a);const g={logical:{modelId:n,packageName:e.packageName,entities:o,associations:a,groups:l},layout:{diagramId:n,logicalModelRef:n,canvasSize:e.size,entityLayouts:i,associationLayouts:r,groupLayouts:s,notes:[...(e.notes??[]).map(N=>am(N)),...m]}},b={id:e.id,version:e.version,diagramVersion:e.diagramVersion,size:e.size,packageName:e.packageName,schemaVersion:e.schemaVersion??1};return{state:g,meta:b}}function cm(e){return{modelId:e.modelId,physicalName:e.physicalName,logicalName:e.logicalName,dataType:e.dataType,length:e.length,scale:e.scale,unique:e.unique,autoIncrement:e.autoIncrement,updatable:e.updatable,insertable:e.insertable,sharedColumnRef:e.sharedColumnRef,multiValue:e.multiValue,multiValueSeparator:e.multiValueSeparator,sequenceName:e.sequenceName}}function ek(e,n){return{modelId:e.modelId,name:e.name,type:e.type,customType:e.customType,attrType:e.attrType,identifier:e.identifier,notNull:e.notNull,transient_:e.transient,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:e.order,dbAttrs:e.dbAttrs.map(cm),style:n}}function tk(e,n){var o;return{...e.legacyRaw,modelId:e.modelId,name:e.name,visibility:e.visibility,sourceCode:e.sourceCode,description:(o=e.description)==null?void 0:o.ko,order:e.order,personalInfoAttributeType:e.personalInfoAttributeType,style:n}}function nk(e){return{modelId:e.modelId,name:e.name,unique:e.unique,description:e.description,parameters:e.parameters,indexColumns:e.columns.map(n=>({targetColumn:{refId:n.columnRef},descending:n.descending}))}}function jn(e,n){return{endModel:{refId:e.entityRef},multiplicity:e.multiplicity,navigable:e.navigable,composition:e.composition,jpaAttribute:e.jpa,attribute:n??(e.attributeRef?{modelId:e.attributeRef}:void 0)}}function ok(e,n){const o=n==null?void 0:n.attributes.find(i=>{var a;return i.modelId===((a=e.derivedFrom)==null?void 0:a.sourceAttributeRef)});return{modelId:e.modelId,name:e.name,type:e.type,attrType:"RELATION_REF",identifier:e.identifier,notNull:e.notNull,transient_:e.transient,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,order:e.order,dbAttrs:e.dbAttrs.map((i,a)=>{var r;return{...cm(i),targetModelId:(r=o==null?void 0:o.dbAttrs[a])==null?void 0:r.modelId}})}}function ik(e){return{modelId:e.modelId,name:e.name,type:e.type,attrType:"RELATION_OWN",dbAttrs:[]}}function dm(e,n){const o=l=>{if(!l.attributeRef)return;const s=n.logical.entities.find(c=>c.modelId===l.entityRef);return s==null?void 0:s.attributes.find(c=>c.modelId===l.attributeRef)},i=o(e.end1),a=o(e.end2),r=l=>(l==null?void 0:l.attrType)==="RELATION_OWN"?l:void 0;return(i==null?void 0:i.attrType)==="RELATION_REF"?{navEnd:e.end1,fkEnd:e.end2,navAttr:i,fk:r(a)}:(a==null?void 0:a.attrType)==="RELATION_REF"?{navEnd:e.end2,fkEnd:e.end1,navAttr:a,fk:r(i)}:null}function ak(e){const n=new Set;for(const o of e.logical.associations){const i=dm(o,e);i&&(n.add(i.navAttr.modelId),i.fk&&n.add(i.fk.modelId))}return n}function rk(e){const n=new Set;for(const o of e.logical.entities)for(const i of o.attributes)i.embedded&&n.add(i.modelId);return n}function lk(e,n){return e===n||JSON.stringify(e??null)===JSON.stringify(n??null)}function sk(e,n){const o=(i,a)=>i===a?void 0:i;return{modelId:e.modelId,targetModelId:n==null?void 0:n.modelId,physicalName:e.physicalName===((n==null?void 0:n.physicalName)??"")?"":e.physicalName,logicalName:lk(e.logicalName,n==null?void 0:n.logicalName)?void 0:e.logicalName,dataType:e.dataType===((n==null?void 0:n.dataType)??"")?"":e.dataType,length:o(e.length,n==null?void 0:n.length),scale:o(e.scale,n==null?void 0:n.scale),unique:o(e.unique,n==null?void 0:n.unique),autoIncrement:o(e.autoIncrement,n==null?void 0:n.autoIncrement),updatable:o(e.updatable,n==null?void 0:n.updatable),insertable:o(e.insertable,n==null?void 0:n.insertable)}}function ck(e,n,o){let i;for(const m of n.logical.entities){const p=m.attributes.find(f=>{var h;return((h=f.embedded)==null?void 0:h.associationRef)===e.modelId});if(p){i=p;break}}if(!i)return;const a=i.embedded.embeddableRef,r=n.logical.entities.find(m=>m.modelId===a);if(!r)return;const l=r.attributes.flatMap(m=>m.dbAttrs),s={modelId:i.modelId,name:i.name,type:i.type,attrType:i.attrType,identifier:i.identifier,notNull:i.notNull,transient_:i.transient,description:i.description,attributeGroup:i.attributeGroup,groupCode:i.groupCode,order:i.order,dbAttrs:i.dbAttrs.map((m,p)=>sk(m,l[p]))},c=e.end1.entityRef===a,d=c?e.end2:e.end1,u=d.attributeRef?{modelId:d.attributeRef,attrType:"EMBED_REF",dbAttrs:[]}:void 0;return{...o,end1:jn(e.end1,c?s:u),end2:jn(e.end2,c?u:s)}}function dk(e,n,o){const i={modelId:e.modelId,description:e.description,locations:(o==null?void 0:o.waypoints)??[],style:o==null?void 0:o.style};if(e.end1.legacyEmbedRaw||e.end2.legacyEmbedRaw)return{...i,end1:jn(e.end1,e.end1.legacyEmbedRaw),end2:jn(e.end2,e.end2.legacyEmbedRaw)};const a=ck(e,n,i);if(a)return a;const r=dm(e,n);if(r){const l=n.logical.entities.find(d=>d.modelId===r.navEnd.entityRef),s=r.fk?ok(r.fk,l):void 0,c=ik(r.navAttr);return{...i,end1:jn(e.end1,r.navEnd===e.end1?s:c),end2:jn(e.end2,r.navEnd===e.end2?s:c)}}return{...i,end1:jn(e.end1),end2:jn(e.end2)}}function um(e,n,o,i,a={x:0,y:0}){var u,m;const r=n.layout.entityLayouts.find(p=>p.entityRef===e.modelId),l=n.logical.associations.filter(p=>p.end1.entityRef===e.modelId),s=p=>n.layout.associationLayouts.find(f=>f.associationRef===p),c=(r==null?void 0:r.geo)??{...Qu},d={location:{x:c.location.x-a.x,y:c.location.y-a.y},size:c.size};return{modelId:e.modelId,name:e.name,stereotype:e.stereotype,packageName:e.packageName,superClass:e.superClass,schema:e.schema,description:e.description,abstractClass:e.abstractClass,hasPersonalInfo:e.hasPersonalInfo,declarationOfInterfaces:e.declarationOfInterfaces,attributes:e.attributes.filter(p=>!o.has(p.modelId)&&!i.has(p.modelId)).map(p=>{var f;return ek(p,(f=r==null?void 0:r.attributeStyles)==null?void 0:f[p.modelId])}),operations:(u=e.operations)==null?void 0:u.map(p=>{var f;return tk(p,(f=r==null?void 0:r.operationStyles)==null?void 0:f[p.modelId])}),ownedAssociations:l.map(p=>dk(p,n,s(p.modelId))),indexes:(m=e.indexes)==null?void 0:m.map(nk),jpaAttrs:e.jpaAttrs,dbAttrs:e.table?{physicalName:e.table.physicalName,logicalName:e.table.logicalName}:void 0,geo:d,style:r==null?void 0:r.style,collapsed:r==null?void 0:r.collapsed,locked:r==null?void 0:r.locked}}function uk(e,n,o,i){const a=n.layout.groupLayouts.find(c=>c.groupRef===e.modelId),r=e.memberEntityRefs.map(c=>n.logical.entities.find(d=>d.modelId===c)).filter(c=>!!c),l=(a==null?void 0:a.geo.location)??{x:0,y:0},s=((a==null?void 0:a.memberNoteRefs)??[]).map(c=>n.layout.notes.find(d=>d.modelId===c)).filter(c=>!!c).map(c=>mm(c,l));return{modelId:e.modelId,name:e.name,description:e.description,packageName:e.packageName,excludeDDLGeneration:e.excludeDDLGeneration,entities:r.map(c=>um(c,n,o,i,l)),notes:s.length?s:void 0,geo:a==null?void 0:a.geo,style:a==null?void 0:a.style,locked:a==null?void 0:a.locked}}function mm(e,n={x:0,y:0}){return{...e.legacyRaw,modelId:e.modelId,memo:e.memo,geo:{location:{x:e.geo.location.x-n.x,y:e.geo.location.y-n.y},size:e.geo.size},style:e.style,connections:e.connections}}function mk(e,n={}){const o=new Set(e.logical.groups.flatMap(s=>s.memberEntityRefs)),i=e.logical.entities.filter(s=>!o.has(s.modelId)),a=ak(e),r=rk(e),l=new Set(e.layout.groupLayouts.flatMap(s=>s.memberNoteRefs??[]));return{id:n.id,diagramVersion:n.diagramVersion,version:n.version,size:n.size??e.layout.canvasSize,packageName:n.packageName??e.logical.packageName,entities:i.map(s=>um(s,e,a,r)),groups:e.logical.groups.map(s=>uk(s,e,a,r)),notes:e.layout.notes.filter(s=>!l.has(s.modelId)).map(s=>mm(s))}}function fk(e,n={}){var a,r,l;const o=((a=n.revSeed)==null?void 0:a.revs)??{},i=s=>({...s,rev:o[s.modelId]??0});return{id:n.id,schemaVersion:2,opWriteEnabled:n.opWriteEnabled,referenceOnly:n.referenceOnly,version:n.version,diagramVersion:n.diagramVersion,packageName:n.packageName,size:n.size,logical:{version:((r=n.revSeed)==null?void 0:r.logicalVersion)??0,modelId:e.logical.modelId,packageName:e.logical.packageName,entities:e.logical.entities.map(i),associations:e.logical.associations.map(i),groups:e.logical.groups.map(i)},layout:{...e.layout,version:((l=n.revSeed)==null?void 0:l.layoutVersion)??0}}}const pk=["notNull"];function hk(e){var u;const n=()=>({navAdds:0,navRefPatches:0,identifyingPatches:0,attributeFieldPatches:0,attributeFieldsByName:{}});if((e.schemaVersion??1)<2||!("logical"in e))return{ops:[],revs:{},summary:n()};const o=e,{state:i,meta:a}=sm(e),r=((u=a.revSeed)==null?void 0:u.revs)??{},l=[],s=n(),c=new Map(o.logical.entities.map(m=>[m.modelId,new Map(m.attributes.map(p=>[p.modelId,p]))]));for(const m of i.logical.entities){const p=c.get(m.modelId);if(p)for(const f of m.attributes){const h=p.get(f.modelId);if(!h){l.push({kind:"attribute.add",casUnit:"logical",containerRef:m.modelId,entityRef:m.modelId,value:f}),s.navAdds++;continue}const g={};for(const b of pk)f[b]===!0!=(h[b]===!0)&&(g[b]=f[b],s.attributeFieldsByName[b]=(s.attributeFieldsByName[b]??0)+1);Object.keys(g).length!==0&&(l.push({kind:"attribute.update",casUnit:"logical",containerRef:m.modelId,entityRef:m.modelId,attributeRef:f.modelId,patch:g}),s.attributeFieldPatches++)}}const d=new Map(o.logical.associations.map(m=>[m.modelId,m]));for(const m of i.logical.associations){const p=d.get(m.modelId);p&&(m.end1.attributeRef&&m.end1.attributeRef!==p.end1.attributeRef&&(l.push({kind:"associationEnd.update",casUnit:"logical",containerRef:m.modelId,associationRef:m.modelId,end:"end1",patch:{attributeRef:m.end1.attributeRef}}),s.navRefPatches++),m.identifying===!0&&p.identifying!==!0&&(l.push({kind:"association.update",casUnit:"logical",containerRef:m.modelId,associationRef:m.modelId,patch:{identifying:!0}}),s.identifyingPatches++))}return{ops:l,revs:r,summary:s}}function Si(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function vn(e){return typeof e=="function"?e():t.unref(e)}const yk=typeof window<"u"&&typeof document<"u",gk=e=>typeof e<"u",bk=Object.prototype.toString,_k=e=>bk.call(e)==="[object Object]",kk=()=>{};function Ek(e,n){function o(...i){return new Promise((a,r)=>{Promise.resolve(e(()=>n.apply(this,i),{fn:n,thisArg:this,args:i})).then(a).catch(r)})}return o}const fm=e=>e();function Nk(e=fm){const n=t.ref(!0);function o(){n.value=!1}function i(){n.value=!0}const a=(...r)=>{n.value&&e(...r)};return{isActive:t.readonly(n),pause:o,resume:i,eventFilter:a}}function pm(e,n=!1,o="Timeout"){return new Promise((i,a)=>{setTimeout(n?()=>a(o):i,e)})}function wk(e,n,o={}){const{eventFilter:i=fm,...a}=o;return t.watch(e,Ek(i,n),a)}function Wo(e,n,o={}){const{eventFilter:i,...a}=o,{eventFilter:r,pause:l,resume:s,isActive:c}=Nk(i);return{stop:wk(e,n,{...a,eventFilter:r}),pause:l,resume:s,isActive:c}}function Ik(e,n={}){if(!t.isRef(e))return t.toRefs(e);const o=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(const i in e.value)o[i]=t.customRef(()=>({get(){return e.value[i]},set(a){var r;if((r=vn(n.replaceRef))!=null?r:!0)if(Array.isArray(e.value)){const s=[...e.value];s[i]=a,e.value=s}else{const s={...e.value,[i]:a};Object.setPrototypeOf(s,Object.getPrototypeOf(e.value)),e.value=s}else e.value[i]=a}}));return o}function Jl(e,n=!1){function o(m,{flush:p="sync",deep:f=!1,timeout:h,throwOnTimeout:g}={}){let b=null;const E=[new Promise(N=>{b=t.watch(e,y=>{m(y)!==n&&(b==null||b(),N(y))},{flush:p,deep:f,immediate:!0})})];return h!=null&&E.push(pm(h,g).then(()=>vn(e)).finally(()=>b==null?void 0:b())),Promise.race(E)}function i(m,p){if(!t.isRef(m))return o(y=>y===m,p);const{flush:f="sync",deep:h=!1,timeout:g,throwOnTimeout:b}=p??{};let _=null;const N=[new Promise(y=>{_=t.watch([e,m],([k,S])=>{n!==(k===S)&&(_==null||_(),y(k))},{flush:f,deep:h,immediate:!0})})];return g!=null&&N.push(pm(g,b).then(()=>vn(e)).finally(()=>(_==null||_(),vn(e)))),Promise.race(N)}function a(m){return o(p=>!!p,m)}function r(m){return i(null,m)}function l(m){return i(void 0,m)}function s(m){return o(Number.isNaN,m)}function c(m,p){return o(f=>{const h=Array.from(f);return h.includes(m)||h.includes(vn(m))},p)}function d(m){return u(1,m)}function u(m=1,p){let f=-1;return o(()=>(f+=1,f>=m),p)}return Array.isArray(vn(e))?{toMatch:o,toContains:c,changed:d,changedTimes:u,get not(){return Jl(e,!n)}}:{toMatch:o,toBe:i,toBeTruthy:a,toBeNull:r,toBeNaN:s,toBeUndefined:l,changed:d,changedTimes:u,get not(){return Jl(e,!n)}}}function Xl(e){return Jl(e)}function vk(e){var n;const o=vn(e);return(n=o==null?void 0:o.$el)!=null?n:o}const hm=yk?window:void 0;function ym(...e){let n,o,i,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([o,i,a]=e,n=hm):[n,o,i,a]=e,!n)return kk;Array.isArray(o)||(o=[o]),Array.isArray(i)||(i=[i]);const r=[],l=()=>{r.forEach(u=>u()),r.length=0},s=(u,m,p,f)=>(u.addEventListener(m,p,f),()=>u.removeEventListener(m,p,f)),c=t.watch(()=>[vk(n),vn(a)],([u,m])=>{if(l(),!u)return;const p=_k(m)?{...m}:m;r.push(...o.flatMap(f=>i.map(h=>s(u,f,h,p))))},{immediate:!0,flush:"post"}),d=()=>{c(),l()};return Si(d),d}function Ck(e){return typeof e=="function"?e:typeof e=="string"?n=>n.key===e:Array.isArray(e)?n=>e.includes(n.key):()=>!0}function gm(...e){let n,o,i={};e.length===3?(n=e[0],o=e[1],i=e[2]):e.length===2?typeof e[1]=="object"?(n=!0,o=e[0],i=e[1]):(n=e[0],o=e[1]):(n=!0,o=e[0]);const{target:a=hm,eventName:r="keydown",passive:l=!1,dedupe:s=!1}=i,c=Ck(n);return ym(a,r,u=>{u.repeat&&vn(s)||c(u)&&o(u)},l)}function Sk(e){return JSON.parse(JSON.stringify(e))}function Zl(e,n,o,i={}){var a,r,l;const{clone:s=!1,passive:c=!1,eventName:d,deep:u=!1,defaultValue:m,shouldEmit:p}=i,f=t.getCurrentInstance(),h=o||(f==null?void 0:f.emit)||((a=f==null?void 0:f.$emit)==null?void 0:a.bind(f))||((l=(r=f==null?void 0:f.proxy)==null?void 0:r.$emit)==null?void 0:l.bind(f==null?void 0:f.proxy));let g=d;n||(n="modelValue"),g=g||`update:${n.toString()}`;const b=N=>s?typeof s=="function"?s(N):Sk(N):N,_=()=>gk(e[n])?b(e[n]):m,E=N=>{p?p(N)&&h(g,N):h(g,N)};if(c){const N=_(),y=t.ref(N);let k=!1;return t.watch(()=>e[n],S=>{k||(k=!0,y.value=b(S),t.nextTick(()=>k=!1))}),t.watch(y,S=>{!k&&(S!==e[n]||u)&&E(S)},{deep:u}),y}else return t.computed({get(){return _()},set(N){E(N)}})}var xk={value:()=>{}};function Pa(){for(var e=0,n=arguments.length,o={},i;e<n;++e){if(!(i=arguments[e]+"")||i in o||/[\s.]/.test(i))throw new Error("illegal type: "+i);o[i]=[]}return new za(o)}function za(e){this._=e}function Rk(e,n){return e.trim().split(/^|\s+/).map(function(o){var i="",a=o.indexOf(".");if(a>=0&&(i=o.slice(a+1),o=o.slice(0,a)),o&&!n.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:i}})}za.prototype=Pa.prototype={constructor:za,on:function(e,n){var o=this._,i=Rk(e+"",o),a,r=-1,l=i.length;if(arguments.length<2){for(;++r<l;)if((a=(e=i[r]).type)&&(a=Ak(o[a],e.name)))return a;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++r<l;)if(a=(e=i[r]).type)o[a]=bm(o[a],e.name,n);else if(n==null)for(a in o)o[a]=bm(o[a],e.name,null);return this},copy:function(){var e={},n=this._;for(var o in n)e[o]=n[o].slice();return new za(e)},call:function(e,n){if((a=arguments.length-2)>0)for(var o=new Array(a),i=0,a,r;i<a;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(n,o)},apply:function(e,n,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],a=0,r=i.length;a<r;++a)i[a].value.apply(n,o)}};function Ak(e,n){for(var o=0,i=e.length,a;o<i;++o)if((a=e[o]).name===n)return a.value}function bm(e,n,o){for(var i=0,a=e.length;i<a;++i)if(e[i].name===n){e[i]=xk,e=e.slice(0,i).concat(e.slice(i+1));break}return o!=null&&e.push({name:n,value:o}),e}var Ql="http://www.w3.org/1999/xhtml";const _m={svg:"http://www.w3.org/2000/svg",xhtml:Ql,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Fa(e){var n=e+="",o=n.indexOf(":");return o>=0&&(n=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),_m.hasOwnProperty(n)?{space:_m[n],local:e}:e}function $k(e){return function(){var n=this.ownerDocument,o=this.namespaceURI;return o===Ql&&n.documentElement.namespaceURI===Ql?n.createElement(e):n.createElementNS(o,e)}}function Tk(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function km(e){var n=Fa(e);return(n.local?Tk:$k)(n)}function Mk(){}function es(e){return e==null?Mk:function(){return this.querySelector(e)}}function Vk(e){typeof e!="function"&&(e=es(e));for(var n=this._groups,o=n.length,i=new Array(o),a=0;a<o;++a)for(var r=n[a],l=r.length,s=i[a]=new Array(l),c,d,u=0;u<l;++u)(c=r[u])&&(d=e.call(c,c.__data__,u,r))&&("__data__"in c&&(d.__data__=c.__data__),s[u]=d);return new Ut(i,this._parents)}function Bk(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Dk(){return[]}function Em(e){return e==null?Dk:function(){return this.querySelectorAll(e)}}function Lk(e){return function(){return Bk(e.apply(this,arguments))}}function Ok(e){typeof e=="function"?e=Lk(e):e=Em(e);for(var n=this._groups,o=n.length,i=[],a=[],r=0;r<o;++r)for(var l=n[r],s=l.length,c,d=0;d<s;++d)(c=l[d])&&(i.push(e.call(c,c.__data__,d,l)),a.push(c));return new Ut(i,a)}function Nm(e){return function(){return this.matches(e)}}function wm(e){return function(n){return n.matches(e)}}var Pk=Array.prototype.find;function zk(e){return function(){return Pk.call(this.children,e)}}function Fk(){return this.firstElementChild}function Uk(e){return this.select(e==null?Fk:zk(typeof e=="function"?e:wm(e)))}var Hk=Array.prototype.filter;function jk(){return Array.from(this.children)}function Kk(e){return function(){return Hk.call(this.children,e)}}function Gk(e){return this.selectAll(e==null?jk:Kk(typeof e=="function"?e:wm(e)))}function Yk(e){typeof e!="function"&&(e=Nm(e));for(var n=this._groups,o=n.length,i=new Array(o),a=0;a<o;++a)for(var r=n[a],l=r.length,s=i[a]=[],c,d=0;d<l;++d)(c=r[d])&&e.call(c,c.__data__,d,r)&&s.push(c);return new Ut(i,this._parents)}function Im(e){return new Array(e.length)}function qk(){return new Ut(this._enter||this._groups.map(Im),this._parents)}function Ua(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Ua.prototype={constructor:Ua,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Wk(e){return function(){return e}}function Jk(e,n,o,i,a,r){for(var l=0,s,c=n.length,d=r.length;l<d;++l)(s=n[l])?(s.__data__=r[l],i[l]=s):o[l]=new Ua(e,r[l]);for(;l<c;++l)(s=n[l])&&(a[l]=s)}function Xk(e,n,o,i,a,r,l){var s,c,d=new Map,u=n.length,m=r.length,p=new Array(u),f;for(s=0;s<u;++s)(c=n[s])&&(p[s]=f=l.call(c,c.__data__,s,n)+"",d.has(f)?a[s]=c:d.set(f,c));for(s=0;s<m;++s)f=l.call(e,r[s],s,r)+"",(c=d.get(f))?(i[s]=c,c.__data__=r[s],d.delete(f)):o[s]=new Ua(e,r[s]);for(s=0;s<u;++s)(c=n[s])&&d.get(p[s])===c&&(a[s]=c)}function Zk(e){return e.__data__}function Qk(e,n){if(!arguments.length)return Array.from(this,Zk);var o=n?Xk:Jk,i=this._parents,a=this._groups;typeof e!="function"&&(e=Wk(e));for(var r=a.length,l=new Array(r),s=new Array(r),c=new Array(r),d=0;d<r;++d){var u=i[d],m=a[d],p=m.length,f=eE(e.call(u,u&&u.__data__,d,i)),h=f.length,g=s[d]=new Array(h),b=l[d]=new Array(h),_=c[d]=new Array(p);o(u,m,g,b,_,f,n);for(var E=0,N=0,y,k;E<h;++E)if(y=g[E]){for(E>=N&&(N=E+1);!(k=b[N])&&++N<h;);y._next=k||null}}return l=new Ut(l,i),l._enter=s,l._exit=c,l}function eE(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function tE(){return new Ut(this._exit||this._groups.map(Im),this._parents)}function nE(e,n,o){var i=this.enter(),a=this,r=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),n!=null&&(a=n(a),a&&(a=a.selection())),o==null?r.remove():o(r),i&&a?i.merge(a).order():a}function oE(e){for(var n=e.selection?e.selection():e,o=this._groups,i=n._groups,a=o.length,r=i.length,l=Math.min(a,r),s=new Array(a),c=0;c<l;++c)for(var d=o[c],u=i[c],m=d.length,p=s[c]=new Array(m),f,h=0;h<m;++h)(f=d[h]||u[h])&&(p[h]=f);for(;c<a;++c)s[c]=o[c];return new Ut(s,this._parents)}function iE(){for(var e=this._groups,n=-1,o=e.length;++n<o;)for(var i=e[n],a=i.length-1,r=i[a],l;--a>=0;)(l=i[a])&&(r&&l.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(l,r),r=l);return this}function aE(e){e||(e=rE);function n(m,p){return m&&p?e(m.__data__,p.__data__):!m-!p}for(var o=this._groups,i=o.length,a=new Array(i),r=0;r<i;++r){for(var l=o[r],s=l.length,c=a[r]=new Array(s),d,u=0;u<s;++u)(d=l[u])&&(c[u]=d);c.sort(n)}return new Ut(a,this._parents).order()}function rE(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function lE(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function sE(){return Array.from(this)}function cE(){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var i=e[n],a=0,r=i.length;a<r;++a){var l=i[a];if(l)return l}return null}function dE(){let e=0;for(const n of this)++e;return e}function uE(){return!this.node()}function mE(e){for(var n=this._groups,o=0,i=n.length;o<i;++o)for(var a=n[o],r=0,l=a.length,s;r<l;++r)(s=a[r])&&e.call(s,s.__data__,r,a);return this}function fE(e){return function(){this.removeAttribute(e)}}function pE(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hE(e,n){return function(){this.setAttribute(e,n)}}function yE(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function gE(e,n){return function(){var o=n.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function bE(e,n){return function(){var o=n.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function _E(e,n){var o=Fa(e);if(arguments.length<2){var i=this.node();return o.local?i.getAttributeNS(o.space,o.local):i.getAttribute(o)}return this.each((n==null?o.local?pE:fE:typeof n=="function"?o.local?bE:gE:o.local?yE:hE)(o,n))}function vm(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function kE(e){return function(){this.style.removeProperty(e)}}function EE(e,n,o){return function(){this.style.setProperty(e,n,o)}}function NE(e,n,o){return function(){var i=n.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,o)}}function wE(e,n,o){return arguments.length>1?this.each((n==null?kE:typeof n=="function"?NE:EE)(e,n,o??"")):Jo(this.node(),e)}function Jo(e,n){return e.style.getPropertyValue(n)||vm(e).getComputedStyle(e,null).getPropertyValue(n)}function IE(e){return function(){delete this[e]}}function vE(e,n){return function(){this[e]=n}}function CE(e,n){return function(){var o=n.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function SE(e,n){return arguments.length>1?this.each((n==null?IE:typeof n=="function"?CE:vE)(e,n)):this.node()[e]}function Cm(e){return e.trim().split(/^|\s+/)}function ts(e){return e.classList||new Sm(e)}function Sm(e){this._node=e,this._names=Cm(e.getAttribute("class")||"")}Sm.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function xm(e,n){for(var o=ts(e),i=-1,a=n.length;++i<a;)o.add(n[i])}function Rm(e,n){for(var o=ts(e),i=-1,a=n.length;++i<a;)o.remove(n[i])}function xE(e){return function(){xm(this,e)}}function RE(e){return function(){Rm(this,e)}}function AE(e,n){return function(){(n.apply(this,arguments)?xm:Rm)(this,e)}}function $E(e,n){var o=Cm(e+"");if(arguments.length<2){for(var i=ts(this.node()),a=-1,r=o.length;++a<r;)if(!i.contains(o[a]))return!1;return!0}return this.each((typeof n=="function"?AE:n?xE:RE)(o,n))}function TE(){this.textContent=""}function ME(e){return function(){this.textContent=e}}function VE(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function BE(e){return arguments.length?this.each(e==null?TE:(typeof e=="function"?VE:ME)(e)):this.node().textContent}function DE(){this.innerHTML=""}function LE(e){return function(){this.innerHTML=e}}function OE(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function PE(e){return arguments.length?this.each(e==null?DE:(typeof e=="function"?OE:LE)(e)):this.node().innerHTML}function zE(){this.nextSibling&&this.parentNode.appendChild(this)}function FE(){return this.each(zE)}function UE(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function HE(){return this.each(UE)}function jE(e){var n=typeof e=="function"?e:km(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function KE(){return null}function GE(e,n){var o=typeof e=="function"?e:km(e),i=n==null?KE:typeof n=="function"?n:es(n);return this.select(function(){return this.insertBefore(o.apply(this,arguments),i.apply(this,arguments)||null)})}function YE(){var e=this.parentNode;e&&e.removeChild(this)}function qE(){return this.each(YE)}function WE(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function JE(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function XE(e){return this.select(e?JE:WE)}function ZE(e){return arguments.length?this.property("__data__",e):this.node().__data__}function QE(e){return function(n){e.call(this,n,this.__data__)}}function e1(e){return e.trim().split(/^|\s+/).map(function(n){var o="",i=n.indexOf(".");return i>=0&&(o=n.slice(i+1),n=n.slice(0,i)),{type:n,name:o}})}function t1(e){return function(){var n=this.__on;if(n){for(var o=0,i=-1,a=n.length,r;o<a;++o)r=n[o],(!e.type||r.type===e.type)&&r.name===e.name?this.removeEventListener(r.type,r.listener,r.options):n[++i]=r;++i?n.length=i:delete this.__on}}}function n1(e,n,o){return function(){var i=this.__on,a,r=QE(n);if(i){for(var l=0,s=i.length;l<s;++l)if((a=i[l]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=r,a.options=o),a.value=n;return}}this.addEventListener(e.type,r,o),a={type:e.type,name:e.name,value:n,listener:r,options:o},i?i.push(a):this.__on=[a]}}function o1(e,n,o){var i=e1(e+""),a,r=i.length,l;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,d=s.length,u;c<d;++c)for(a=0,u=s[c];a<r;++a)if((l=i[a]).type===u.type&&l.name===u.name)return u.value}return}for(s=n?n1:t1,a=0;a<r;++a)this.each(s(i[a],n,o));return this}function Am(e,n,o){var i=vm(e),a=i.CustomEvent;typeof a=="function"?a=new a(n,o):(a=i.document.createEvent("Event"),o?(a.initEvent(n,o.bubbles,o.cancelable),a.detail=o.detail):a.initEvent(n,!1,!1)),e.dispatchEvent(a)}function i1(e,n){return function(){return Am(this,e,n)}}function a1(e,n){return function(){return Am(this,e,n.apply(this,arguments))}}function r1(e,n){return this.each((typeof n=="function"?a1:i1)(e,n))}function*l1(){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var i=e[n],a=0,r=i.length,l;a<r;++a)(l=i[a])&&(yield l)}var $m=[null];function Ut(e,n){this._groups=e,this._parents=n}function xi(){return new Ut([[document.documentElement]],$m)}function s1(){return this}Ut.prototype=xi.prototype={constructor:Ut,select:Vk,selectAll:Ok,selectChild:Uk,selectChildren:Gk,filter:Yk,data:Qk,enter:qk,exit:tE,join:nE,merge:oE,selection:s1,order:iE,sort:aE,call:lE,nodes:sE,node:cE,size:dE,empty:uE,each:mE,attr:_E,style:wE,property:SE,classed:$E,text:BE,html:PE,raise:FE,lower:HE,append:jE,insert:GE,remove:qE,clone:XE,datum:ZE,on:o1,dispatch:r1,[Symbol.iterator]:l1};function Zt(e){return typeof e=="string"?new Ut([[document.querySelector(e)]],[document.documentElement]):new Ut([[e]],$m)}function c1(e){let n;for(;n=e.sourceEvent;)e=n;return e}function dn(e,n){if(e=c1(e),n===void 0&&(n=e.currentTarget),n){var o=n.ownerSVGElement||n;if(o.createSVGPoint){var i=o.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}if(n.getBoundingClientRect){var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}}return[e.pageX,e.pageY]}const d1={passive:!1},Ri={capture:!0,passive:!1};function ns(e){e.stopImmediatePropagation()}function Xo(e){e.preventDefault(),e.stopImmediatePropagation()}function Tm(e){var n=e.document.documentElement,o=Zt(e).on("dragstart.drag",Xo,Ri);"onselectstart"in n?o.on("selectstart.drag",Xo,Ri):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function Mm(e,n){var o=e.document.documentElement,i=Zt(e).on("dragstart.drag",null);n&&(i.on("click.drag",Xo,Ri),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in o?i.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}const Ha=e=>()=>e;function os(e,{sourceEvent:n,subject:o,target:i,identifier:a,active:r,x:l,y:s,dx:c,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}os.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function u1(e){return!e.ctrlKey&&!e.button}function m1(){return this.parentNode}function f1(e,n){return n??{x:e.x,y:e.y}}function p1(){return navigator.maxTouchPoints||"ontouchstart"in this}function h1(){var e=u1,n=m1,o=f1,i=p1,a={},r=Pa("start","drag","end"),l=0,s,c,d,u,m=0;function p(y){y.on("mousedown.drag",f).filter(i).on("touchstart.drag",b).on("touchmove.drag",_,d1).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(y,k){if(!(u||!e.call(this,y,k))){var S=N(this,n.call(this,y,k),y,k,"mouse");S&&(Zt(y.view).on("mousemove.drag",h,Ri).on("mouseup.drag",g,Ri),Tm(y.view),ns(y),d=!1,s=y.clientX,c=y.clientY,S("start",y))}}function h(y){if(Xo(y),!d){var k=y.clientX-s,S=y.clientY-c;d=k*k+S*S>m}a.mouse("drag",y)}function g(y){Zt(y.view).on("mousemove.drag mouseup.drag",null),Mm(y.view,d),Xo(y),a.mouse("end",y)}function b(y,k){if(e.call(this,y,k)){var S=y.changedTouches,T=n.call(this,y,k),B=S.length,A,V;for(A=0;A<B;++A)(V=N(this,T,y,k,S[A].identifier,S[A]))&&(ns(y),V("start",y,S[A]))}}function _(y){var k=y.changedTouches,S=k.length,T,B;for(T=0;T<S;++T)(B=a[k[T].identifier])&&(Xo(y),B("drag",y,k[T]))}function E(y){var k=y.changedTouches,S=k.length,T,B;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),T=0;T<S;++T)(B=a[k[T].identifier])&&(ns(y),B("end",y,k[T]))}function N(y,k,S,T,B,A){var V=r.copy(),C=dn(A||S,k),x,$,w;if((w=o.call(y,new os("beforestart",{sourceEvent:S,target:p,identifier:B,active:l,x:C[0],y:C[1],dx:0,dy:0,dispatch:V}),T))!=null)return x=w.x-C[0]||0,$=w.y-C[1]||0,function I(v,M,R){var D=C,j;switch(v){case"start":a[B]=I,j=l++;break;case"end":delete a[B],--l;case"drag":C=dn(R||M,k),j=l;break}V.call(v,y,new os(v,{sourceEvent:M,subject:w,target:p,identifier:B,active:j,x:C[0]+x,y:C[1]+$,dx:C[0]-D[0],dy:C[1]-D[1],dispatch:V}),T)}}return p.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Ha(!!y),p):e},p.container=function(y){return arguments.length?(n=typeof y=="function"?y:Ha(y),p):n},p.subject=function(y){return arguments.length?(o=typeof y=="function"?y:Ha(y),p):o},p.touchable=function(y){return arguments.length?(i=typeof y=="function"?y:Ha(!!y),p):i},p.on=function(){var y=r.on.apply(r,arguments);return y===r?p:y},p.clickDistance=function(y){return arguments.length?(m=(y=+y)*y,p):Math.sqrt(m)},p}function is(e,n,o){e.prototype=n.prototype=o,o.constructor=e}function Vm(e,n){var o=Object.create(e.prototype);for(var i in n)o[i]=n[i];return o}function Ai(){}var $i=.7,ja=1/$i,Zo="\\s*([+-]?\\d+)\\s*",Ti="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",un="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",y1=/^#([0-9a-f]{3,8})$/,g1=new RegExp(`^rgb\\(${Zo},${Zo},${Zo}\\)$`),b1=new RegExp(`^rgb\\(${un},${un},${un}\\)$`),_1=new RegExp(`^rgba\\(${Zo},${Zo},${Zo},${Ti}\\)$`),k1=new RegExp(`^rgba\\(${un},${un},${un},${Ti}\\)$`),E1=new RegExp(`^hsl\\(${Ti},${un},${un}\\)$`),N1=new RegExp(`^hsla\\(${Ti},${un},${un},${Ti}\\)$`),Bm={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};is(Ai,yo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Dm,formatHex:Dm,formatHex8:w1,formatHsl:I1,formatRgb:Lm,toString:Lm});function Dm(){return this.rgb().formatHex()}function w1(){return this.rgb().formatHex8()}function I1(){return Um(this).formatHsl()}function Lm(){return this.rgb().formatRgb()}function yo(e){var n,o;return e=(e+"").trim().toLowerCase(),(n=y1.exec(e))?(o=n[1].length,n=parseInt(n[1],16),o===6?Om(n):o===3?new Lt(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):o===8?Ka(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):o===4?Ka(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=g1.exec(e))?new Lt(n[1],n[2],n[3],1):(n=b1.exec(e))?new Lt(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=_1.exec(e))?Ka(n[1],n[2],n[3],n[4]):(n=k1.exec(e))?Ka(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=E1.exec(e))?Fm(n[1],n[2]/100,n[3]/100,1):(n=N1.exec(e))?Fm(n[1],n[2]/100,n[3]/100,n[4]):Bm.hasOwnProperty(e)?Om(Bm[e]):e==="transparent"?new Lt(NaN,NaN,NaN,0):null}function Om(e){return new Lt(e>>16&255,e>>8&255,e&255,1)}function Ka(e,n,o,i){return i<=0&&(e=n=o=NaN),new Lt(e,n,o,i)}function v1(e){return e instanceof Ai||(e=yo(e)),e?(e=e.rgb(),new Lt(e.r,e.g,e.b,e.opacity)):new Lt}function as(e,n,o,i){return arguments.length===1?v1(e):new Lt(e,n,o,i??1)}function Lt(e,n,o,i){this.r=+e,this.g=+n,this.b=+o,this.opacity=+i}is(Lt,as,Vm(Ai,{brighter(e){return e=e==null?ja:Math.pow(ja,e),new Lt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?$i:Math.pow($i,e),new Lt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Lt(go(this.r),go(this.g),go(this.b),Ga(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Pm,formatHex:Pm,formatHex8:C1,formatRgb:zm,toString:zm}));function Pm(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}`}function C1(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}${bo((isNaN(this.opacity)?1:this.opacity)*255)}`}function zm(){const e=Ga(this.opacity);return`${e===1?"rgb(":"rgba("}${go(this.r)}, ${go(this.g)}, ${go(this.b)}${e===1?")":`, ${e})`}`}function Ga(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function go(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function bo(e){return e=go(e),(e<16?"0":"")+e.toString(16)}function Fm(e,n,o,i){return i<=0?e=n=o=NaN:o<=0||o>=1?e=n=NaN:n<=0&&(e=NaN),new Qt(e,n,o,i)}function Um(e){if(e instanceof Qt)return new Qt(e.h,e.s,e.l,e.opacity);if(e instanceof Ai||(e=yo(e)),!e)return new Qt;if(e instanceof Qt)return e;e=e.rgb();var n=e.r/255,o=e.g/255,i=e.b/255,a=Math.min(n,o,i),r=Math.max(n,o,i),l=NaN,s=r-a,c=(r+a)/2;return s?(n===r?l=(o-i)/s+(o<i)*6:o===r?l=(i-n)/s+2:l=(n-o)/s+4,s/=c<.5?r+a:2-r-a,l*=60):s=c>0&&c<1?0:l,new Qt(l,s,c,e.opacity)}function S1(e,n,o,i){return arguments.length===1?Um(e):new Qt(e,n,o,i??1)}function Qt(e,n,o,i){this.h=+e,this.s=+n,this.l=+o,this.opacity=+i}is(Qt,S1,Vm(Ai,{brighter(e){return e=e==null?ja:Math.pow(ja,e),new Qt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?$i:Math.pow($i,e),new Qt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,i=o+(o<.5?o:1-o)*n,a=2*o-i;return new Lt(rs(e>=240?e-240:e+120,a,i),rs(e,a,i),rs(e<120?e+240:e-120,a,i),this.opacity)},clamp(){return new Qt(Hm(this.h),Ya(this.s),Ya(this.l),Ga(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ga(this.opacity);return`${e===1?"hsl(":"hsla("}${Hm(this.h)}, ${Ya(this.s)*100}%, ${Ya(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Hm(e){return e=(e||0)%360,e<0?e+360:e}function Ya(e){return Math.max(0,Math.min(1,e||0))}function rs(e,n,o){return(e<60?n+(o-n)*e/60:e<180?o:e<240?n+(o-n)*(240-e)/60:n)*255}const ls=e=>()=>e;function x1(e,n){return function(o){return e+o*n}}function R1(e,n,o){return e=Math.pow(e,o),n=Math.pow(n,o)-e,o=1/o,function(i){return Math.pow(e+i*n,o)}}function A1(e){return(e=+e)==1?jm:function(n,o){return o-n?R1(n,o,e):ls(isNaN(n)?o:n)}}function jm(e,n){var o=n-e;return o?x1(e,o):ls(isNaN(e)?n:e)}const qa=(function e(n){var o=A1(n);function i(a,r){var l=o((a=as(a)).r,(r=as(r)).r),s=o(a.g,r.g),c=o(a.b,r.b),d=jm(a.opacity,r.opacity);return function(u){return a.r=l(u),a.g=s(u),a.b=c(u),a.opacity=d(u),a+""}}return i.gamma=e,i})(1);function $1(e,n){n||(n=[]);var o=e?Math.min(n.length,e.length):0,i=n.slice(),a;return function(r){for(a=0;a<o;++a)i[a]=e[a]*(1-r)+n[a]*r;return i}}function T1(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function M1(e,n){var o=n?n.length:0,i=e?Math.min(o,e.length):0,a=new Array(i),r=new Array(o),l;for(l=0;l<i;++l)a[l]=Mi(e[l],n[l]);for(;l<o;++l)r[l]=n[l];return function(s){for(l=0;l<i;++l)r[l]=a[l](s);return r}}function V1(e,n){var o=new Date;return e=+e,n=+n,function(i){return o.setTime(e*(1-i)+n*i),o}}function mn(e,n){return e=+e,n=+n,function(o){return e*(1-o)+n*o}}function B1(e,n){var o={},i={},a;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(a in n)a in e?o[a]=Mi(e[a],n[a]):i[a]=n[a];return function(r){for(a in o)i[a]=o[a](r);return i}}var ss=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,cs=new RegExp(ss.source,"g");function D1(e){return function(){return e}}function L1(e){return function(n){return e(n)+""}}function Km(e,n){var o=ss.lastIndex=cs.lastIndex=0,i,a,r,l=-1,s=[],c=[];for(e=e+"",n=n+"";(i=ss.exec(e))&&(a=cs.exec(n));)(r=a.index)>o&&(r=n.slice(o,r),s[l]?s[l]+=r:s[++l]=r),(i=i[0])===(a=a[0])?s[l]?s[l]+=a:s[++l]=a:(s[++l]=null,c.push({i:l,x:mn(i,a)})),o=cs.lastIndex;return o<n.length&&(r=n.slice(o),s[l]?s[l]+=r:s[++l]=r),s.length<2?c[0]?L1(c[0].x):D1(n):(n=c.length,function(d){for(var u=0,m;u<n;++u)s[(m=c[u]).i]=m.x(d);return s.join("")})}function Mi(e,n){var o=typeof n,i;return n==null||o==="boolean"?ls(n):(o==="number"?mn:o==="string"?(i=yo(n))?(n=i,qa):Km:n instanceof yo?qa:n instanceof Date?V1:T1(n)?$1:Array.isArray(n)?M1:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?B1:mn)(e,n)}var Gm=180/Math.PI,ds={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ym(e,n,o,i,a,r){var l,s,c;return(l=Math.sqrt(e*e+n*n))&&(e/=l,n/=l),(c=e*o+n*i)&&(o-=e*c,i-=n*c),(s=Math.sqrt(o*o+i*i))&&(o/=s,i/=s,c/=s),e*i<n*o&&(e=-e,n=-n,c=-c,l=-l),{translateX:a,translateY:r,rotate:Math.atan2(n,e)*Gm,skewX:Math.atan(c)*Gm,scaleX:l,scaleY:s}}var Wa;function O1(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?ds:Ym(n.a,n.b,n.c,n.d,n.e,n.f)}function P1(e){return e==null||(Wa||(Wa=document.createElementNS("http://www.w3.org/2000/svg","g")),Wa.setAttribute("transform",e),!(e=Wa.transform.baseVal.consolidate()))?ds:(e=e.matrix,Ym(e.a,e.b,e.c,e.d,e.e,e.f))}function qm(e,n,o,i){function a(d){return d.length?d.pop()+" ":""}function r(d,u,m,p,f,h){if(d!==m||u!==p){var g=f.push("translate(",null,n,null,o);h.push({i:g-4,x:mn(d,m)},{i:g-2,x:mn(u,p)})}else(m||p)&&f.push("translate("+m+n+p+o)}function l(d,u,m,p){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),p.push({i:m.push(a(m)+"rotate(",null,i)-2,x:mn(d,u)})):u&&m.push(a(m)+"rotate("+u+i)}function s(d,u,m,p){d!==u?p.push({i:m.push(a(m)+"skewX(",null,i)-2,x:mn(d,u)}):u&&m.push(a(m)+"skewX("+u+i)}function c(d,u,m,p,f,h){if(d!==m||u!==p){var g=f.push(a(f)+"scale(",null,",",null,")");h.push({i:g-4,x:mn(d,m)},{i:g-2,x:mn(u,p)})}else(m!==1||p!==1)&&f.push(a(f)+"scale("+m+","+p+")")}return function(d,u){var m=[],p=[];return d=e(d),u=e(u),r(d.translateX,d.translateY,u.translateX,u.translateY,m,p),l(d.rotate,u.rotate,m,p),s(d.skewX,u.skewX,m,p),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,m,p),d=u=null,function(f){for(var h=-1,g=p.length,b;++h<g;)m[(b=p[h]).i]=b.x(f);return m.join("")}}}var z1=qm(O1,"px, ","px)","deg)"),F1=qm(P1,", ",")",")"),U1=1e-12;function Wm(e){return((e=Math.exp(e))+1/e)/2}function H1(e){return((e=Math.exp(e))-1/e)/2}function j1(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ja=(function e(n,o,i){function a(r,l){var s=r[0],c=r[1],d=r[2],u=l[0],m=l[1],p=l[2],f=u-s,h=m-c,g=f*f+h*h,b,_;if(g<U1)_=Math.log(p/d)/n,b=function(T){return[s+T*f,c+T*h,d*Math.exp(n*T*_)]};else{var E=Math.sqrt(g),N=(p*p-d*d+i*g)/(2*d*o*E),y=(p*p-d*d-i*g)/(2*p*o*E),k=Math.log(Math.sqrt(N*N+1)-N),S=Math.log(Math.sqrt(y*y+1)-y);_=(S-k)/n,b=function(T){var B=T*_,A=Wm(k),V=d/(o*E)*(A*j1(n*B+k)-H1(k));return[s+V*f,c+V*h,d*A/Wm(n*B+k)]}}return b.duration=_*1e3*n/Math.SQRT2,b}return a.rho=function(r){var l=Math.max(.001,+r),s=l*l,c=s*s;return e(l,s,c)},a})(Math.SQRT2,2,4);var Qo=0,Vi=0,Bi=0,Jm=1e3,Xa,Di,Za=0,_o=0,Qa=0,Li=typeof performance=="object"&&performance.now?performance:Date,Xm=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function us(){return _o||(Xm(K1),_o=Li.now()+Qa)}function K1(){_o=0}function er(){this._call=this._time=this._next=null}er.prototype=Zm.prototype={constructor:er,restart:function(e,n,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?us():+o)+(n==null?0:+n),!this._next&&Di!==this&&(Di?Di._next=this:Xa=this,Di=this),this._call=e,this._time=o,ms()},stop:function(){this._call&&(this._call=null,this._time=1/0,ms())}};function Zm(e,n,o){var i=new er;return i.restart(e,n,o),i}function G1(){us(),++Qo;for(var e=Xa,n;e;)(n=_o-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Qo}function Qm(){_o=(Za=Li.now())+Qa,Qo=Vi=0;try{G1()}finally{Qo=0,q1(),_o=0}}function Y1(){var e=Li.now(),n=e-Za;n>Jm&&(Qa-=n,Za=e)}function q1(){for(var e,n=Xa,o,i=1/0;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(o=n._next,n._next=null,n=e?e._next=o:Xa=o);Di=e,ms(i)}function ms(e){if(!Qo){Vi&&(Vi=clearTimeout(Vi));var n=e-_o;n>24?(e<1/0&&(Vi=setTimeout(Qm,e-Li.now()-Qa)),Bi&&(Bi=clearInterval(Bi))):(Bi||(Za=Li.now(),Bi=setInterval(Y1,Jm)),Qo=1,Xm(Qm))}}function ef(e,n,o){var i=new er;return n=n==null?0:+n,i.restart(a=>{i.stop(),e(a+n)},n,o),i}var W1=Pa("start","end","cancel","interrupt"),J1=[],tf=0,nf=1,fs=2,tr=3,of=4,ps=5,nr=6;function or(e,n,o,i,a,r){var l=e.__transition;if(!l)e.__transition={};else if(o in l)return;X1(e,o,{name:n,index:i,group:a,on:W1,tween:J1,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:tf})}function hs(e,n){var o=en(e,n);if(o.state>tf)throw new Error("too late; already scheduled");return o}function fn(e,n){var o=en(e,n);if(o.state>tr)throw new Error("too late; already running");return o}function en(e,n){var o=e.__transition;if(!o||!(o=o[n]))throw new Error("transition not found");return o}function X1(e,n,o){var i=e.__transition,a;i[n]=o,o.timer=Zm(r,0,o.time);function r(d){o.state=nf,o.timer.restart(l,o.delay,o.time),o.delay<=d&&l(d-o.delay)}function l(d){var u,m,p,f;if(o.state!==nf)return c();for(u in i)if(f=i[u],f.name===o.name){if(f.state===tr)return ef(l);f.state===of?(f.state=nr,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete i[u]):+u<n&&(f.state=nr,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete i[u])}if(ef(function(){o.state===tr&&(o.state=of,o.timer.restart(s,o.delay,o.time),s(d))}),o.state=fs,o.on.call("start",e,e.__data__,o.index,o.group),o.state===fs){for(o.state=tr,a=new Array(p=o.tween.length),u=0,m=-1;u<p;++u)(f=o.tween[u].value.call(e,e.__data__,o.index,o.group))&&(a[++m]=f);a.length=m+1}}function s(d){for(var u=d<o.duration?o.ease.call(null,d/o.duration):(o.timer.restart(c),o.state=ps,1),m=-1,p=a.length;++m<p;)a[m].call(e,u);o.state===ps&&(o.on.call("end",e,e.__data__,o.index,o.group),c())}function c(){o.state=nr,o.timer.stop(),delete i[n];for(var d in i)return;delete e.__transition}}function ir(e,n){var o=e.__transition,i,a,r=!0,l;if(o){n=n==null?null:n+"";for(l in o){if((i=o[l]).name!==n){r=!1;continue}a=i.state>fs&&i.state<ps,i.state=nr,i.timer.stop(),i.on.call(a?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete o[l]}r&&delete e.__transition}}function Z1(e){return this.each(function(){ir(this,e)})}function Q1(e,n){var o,i;return function(){var a=fn(this,e),r=a.tween;if(r!==o){i=o=r;for(var l=0,s=i.length;l<s;++l)if(i[l].name===n){i=i.slice(),i.splice(l,1);break}}a.tween=i}}function e0(e,n,o){var i,a;if(typeof o!="function")throw new Error;return function(){var r=fn(this,e),l=r.tween;if(l!==i){a=(i=l).slice();for(var s={name:n,value:o},c=0,d=a.length;c<d;++c)if(a[c].name===n){a[c]=s;break}c===d&&a.push(s)}r.tween=a}}function t0(e,n){var o=this._id;if(e+="",arguments.length<2){for(var i=en(this.node(),o).tween,a=0,r=i.length,l;a<r;++a)if((l=i[a]).name===e)return l.value;return null}return this.each((n==null?Q1:e0)(o,e,n))}function ys(e,n,o){var i=e._id;return e.each(function(){var a=fn(this,i);(a.value||(a.value={}))[n]=o.apply(this,arguments)}),function(a){return en(a,i).value[n]}}function af(e,n){var o;return(typeof n=="number"?mn:n instanceof yo?qa:(o=yo(n))?(n=o,qa):Km)(e,n)}function n0(e){return function(){this.removeAttribute(e)}}function o0(e){return function(){this.removeAttributeNS(e.space,e.local)}}function i0(e,n,o){var i,a=o+"",r;return function(){var l=this.getAttribute(e);return l===a?null:l===i?r:r=n(i=l,o)}}function a0(e,n,o){var i,a=o+"",r;return function(){var l=this.getAttributeNS(e.space,e.local);return l===a?null:l===i?r:r=n(i=l,o)}}function r0(e,n,o){var i,a,r;return function(){var l,s=o(this),c;return s==null?void this.removeAttribute(e):(l=this.getAttribute(e),c=s+"",l===c?null:l===i&&c===a?r:(a=c,r=n(i=l,s)))}}function l0(e,n,o){var i,a,r;return function(){var l,s=o(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),c=s+"",l===c?null:l===i&&c===a?r:(a=c,r=n(i=l,s)))}}function s0(e,n){var o=Fa(e),i=o==="transform"?F1:af;return this.attrTween(e,typeof n=="function"?(o.local?l0:r0)(o,i,ys(this,"attr."+e,n)):n==null?(o.local?o0:n0)(o):(o.local?a0:i0)(o,i,n))}function c0(e,n){return function(o){this.setAttribute(e,n.call(this,o))}}function d0(e,n){return function(o){this.setAttributeNS(e.space,e.local,n.call(this,o))}}function u0(e,n){var o,i;function a(){var r=n.apply(this,arguments);return r!==i&&(o=(i=r)&&d0(e,r)),o}return a._value=n,a}function m0(e,n){var o,i;function a(){var r=n.apply(this,arguments);return r!==i&&(o=(i=r)&&c0(e,r)),o}return a._value=n,a}function f0(e,n){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(n==null)return this.tween(o,null);if(typeof n!="function")throw new Error;var i=Fa(e);return this.tween(o,(i.local?u0:m0)(i,n))}function p0(e,n){return function(){hs(this,e).delay=+n.apply(this,arguments)}}function h0(e,n){return n=+n,function(){hs(this,e).delay=n}}function y0(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?p0:h0)(n,e)):en(this.node(),n).delay}function g0(e,n){return function(){fn(this,e).duration=+n.apply(this,arguments)}}function b0(e,n){return n=+n,function(){fn(this,e).duration=n}}function _0(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?g0:b0)(n,e)):en(this.node(),n).duration}function k0(e,n){if(typeof n!="function")throw new Error;return function(){fn(this,e).ease=n}}function E0(e){var n=this._id;return arguments.length?this.each(k0(n,e)):en(this.node(),n).ease}function N0(e,n){return function(){var o=n.apply(this,arguments);if(typeof o!="function")throw new Error;fn(this,e).ease=o}}function w0(e){if(typeof e!="function")throw new Error;return this.each(N0(this._id,e))}function I0(e){typeof e!="function"&&(e=Nm(e));for(var n=this._groups,o=n.length,i=new Array(o),a=0;a<o;++a)for(var r=n[a],l=r.length,s=i[a]=[],c,d=0;d<l;++d)(c=r[d])&&e.call(c,c.__data__,d,r)&&s.push(c);return new Cn(i,this._parents,this._name,this._id)}function v0(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,o=e._groups,i=n.length,a=o.length,r=Math.min(i,a),l=new Array(i),s=0;s<r;++s)for(var c=n[s],d=o[s],u=c.length,m=l[s]=new Array(u),p,f=0;f<u;++f)(p=c[f]||d[f])&&(m[f]=p);for(;s<i;++s)l[s]=n[s];return new Cn(l,this._parents,this._name,this._id)}function C0(e){return(e+"").trim().split(/^|\s+/).every(function(n){var o=n.indexOf(".");return o>=0&&(n=n.slice(0,o)),!n||n==="start"})}function S0(e,n,o){var i,a,r=C0(n)?hs:fn;return function(){var l=r(this,e),s=l.on;s!==i&&(a=(i=s).copy()).on(n,o),l.on=a}}function x0(e,n){var o=this._id;return arguments.length<2?en(this.node(),o).on.on(e):this.each(S0(o,e,n))}function R0(e){return function(){var n=this.parentNode;for(var o in this.__transition)if(+o!==e)return;n&&n.removeChild(this)}}function A0(){return this.on("end.remove",R0(this._id))}function $0(e){var n=this._name,o=this._id;typeof e!="function"&&(e=es(e));for(var i=this._groups,a=i.length,r=new Array(a),l=0;l<a;++l)for(var s=i[l],c=s.length,d=r[l]=new Array(c),u,m,p=0;p<c;++p)(u=s[p])&&(m=e.call(u,u.__data__,p,s))&&("__data__"in u&&(m.__data__=u.__data__),d[p]=m,or(d[p],n,o,p,d,en(u,o)));return new Cn(r,this._parents,n,o)}function T0(e){var n=this._name,o=this._id;typeof e!="function"&&(e=Em(e));for(var i=this._groups,a=i.length,r=[],l=[],s=0;s<a;++s)for(var c=i[s],d=c.length,u,m=0;m<d;++m)if(u=c[m]){for(var p=e.call(u,u.__data__,m,c),f,h=en(u,o),g=0,b=p.length;g<b;++g)(f=p[g])&&or(f,n,o,g,p,h);r.push(p),l.push(u)}return new Cn(r,l,n,o)}var M0=xi.prototype.constructor;function V0(){return new M0(this._groups,this._parents)}function B0(e,n){var o,i,a;return function(){var r=Jo(this,e),l=(this.style.removeProperty(e),Jo(this,e));return r===l?null:r===o&&l===i?a:a=n(o=r,i=l)}}function rf(e){return function(){this.style.removeProperty(e)}}function D0(e,n,o){var i,a=o+"",r;return function(){var l=Jo(this,e);return l===a?null:l===i?r:r=n(i=l,o)}}function L0(e,n,o){var i,a,r;return function(){var l=Jo(this,e),s=o(this),c=s+"";return s==null&&(c=s=(this.style.removeProperty(e),Jo(this,e))),l===c?null:l===i&&c===a?r:(a=c,r=n(i=l,s))}}function O0(e,n){var o,i,a,r="style."+n,l="end."+r,s;return function(){var c=fn(this,e),d=c.on,u=c.value[r]==null?s||(s=rf(n)):void 0;(d!==o||a!==u)&&(i=(o=d).copy()).on(l,a=u),c.on=i}}function P0(e,n,o){var i=(e+="")=="transform"?z1:af;return n==null?this.styleTween(e,B0(e,i)).on("end.style."+e,rf(e)):typeof n=="function"?this.styleTween(e,L0(e,i,ys(this,"style."+e,n))).each(O0(this._id,e)):this.styleTween(e,D0(e,i,n),o).on("end.style."+e,null)}function z0(e,n,o){return function(i){this.style.setProperty(e,n.call(this,i),o)}}function F0(e,n,o){var i,a;function r(){var l=n.apply(this,arguments);return l!==a&&(i=(a=l)&&z0(e,l,o)),i}return r._value=n,r}function U0(e,n,o){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;return this.tween(i,F0(e,n,o??""))}function H0(e){return function(){this.textContent=e}}function j0(e){return function(){var n=e(this);this.textContent=n??""}}function K0(e){return this.tween("text",typeof e=="function"?j0(ys(this,"text",e)):H0(e==null?"":e+""))}function G0(e){return function(n){this.textContent=e.call(this,n)}}function Y0(e){var n,o;function i(){var a=e.apply(this,arguments);return a!==o&&(n=(o=a)&&G0(a)),n}return i._value=e,i}function q0(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,Y0(e))}function W0(){for(var e=this._name,n=this._id,o=lf(),i=this._groups,a=i.length,r=0;r<a;++r)for(var l=i[r],s=l.length,c,d=0;d<s;++d)if(c=l[d]){var u=en(c,n);or(c,e,o,d,l,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Cn(i,this._parents,e,o)}function J0(){var e,n,o=this,i=o._id,a=o.size();return new Promise(function(r,l){var s={value:l},c={value:function(){--a===0&&r()}};o.each(function(){var d=fn(this,i),u=d.on;u!==e&&(n=(e=u).copy(),n._.cancel.push(s),n._.interrupt.push(s),n._.end.push(c)),d.on=n}),a===0&&r()})}var X0=0;function Cn(e,n,o,i){this._groups=e,this._parents=n,this._name=o,this._id=i}function lf(){return++X0}var Sn=xi.prototype;Cn.prototype={constructor:Cn,select:$0,selectAll:T0,selectChild:Sn.selectChild,selectChildren:Sn.selectChildren,filter:I0,merge:v0,selection:V0,transition:W0,call:Sn.call,nodes:Sn.nodes,node:Sn.node,size:Sn.size,empty:Sn.empty,each:Sn.each,on:x0,attr:s0,attrTween:f0,style:P0,styleTween:U0,text:K0,textTween:q0,remove:A0,tween:t0,delay:y0,duration:_0,ease:E0,easeVarying:w0,end:J0,[Symbol.iterator]:Sn[Symbol.iterator]};function Z0(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Q0={time:null,delay:0,duration:250,ease:Z0};function eN(e,n){for(var o;!(o=e.__transition)||!(o=o[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return o}function tN(e){var n,o;e instanceof Cn?(n=e._id,e=e._name):(n=lf(),(o=Q0).time=us(),e=e==null?null:e+"");for(var i=this._groups,a=i.length,r=0;r<a;++r)for(var l=i[r],s=l.length,c,d=0;d<s;++d)(c=l[d])&&or(c,e,n,d,l,o||eN(c,n));return new Cn(i,this._parents,e,n)}xi.prototype.interrupt=Z1,xi.prototype.transition=tN;const ar=e=>()=>e;function nN(e,{sourceEvent:n,target:o,transform:i,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function xn(e,n,o){this.k=e,this.x=n,this.y=o}xn.prototype={constructor:xn,scale:function(e){return e===1?this:new xn(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new xn(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ei=new xn(1,0,0);xn.prototype;function gs(e){e.stopImmediatePropagation()}function Oi(e){e.preventDefault(),e.stopImmediatePropagation()}function oN(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function iN(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function sf(){return this.__zoom||ei}function aN(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function rN(){return navigator.maxTouchPoints||"ontouchstart"in this}function lN(e,n,o){var i=e.invertX(n[0][0])-o[0][0],a=e.invertX(n[1][0])-o[1][0],r=e.invertY(n[0][1])-o[0][1],l=e.invertY(n[1][1])-o[1][1];return e.translate(a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a),l>r?(r+l)/2:Math.min(0,r)||Math.max(0,l))}function sN(){var e=oN,n=iN,o=lN,i=aN,a=rN,r=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],s=250,c=Ja,d=Pa("start","zoom","end"),u,m,p,f=500,h=150,g=0,b=10;function _(w){w.property("__zoom",sf).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",V).filter(a).on("touchstart.zoom",C).on("touchmove.zoom",x).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(w,I,v,M){var R=w.selection?w.selection():w;R.property("__zoom",sf),w!==R?k(w,I,v,M):R.interrupt().each(function(){S(this,arguments).event(M).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},_.scaleBy=function(w,I,v,M){_.scaleTo(w,function(){var R=this.__zoom.k,D=typeof I=="function"?I.apply(this,arguments):I;return R*D},v,M)},_.scaleTo=function(w,I,v,M){_.transform(w,function(){var R=n.apply(this,arguments),D=this.__zoom,j=v==null?y(R):typeof v=="function"?v.apply(this,arguments):v,U=D.invert(j),ne=typeof I=="function"?I.apply(this,arguments):I;return o(N(E(D,ne),j,U),R,l)},v,M)},_.translateBy=function(w,I,v,M){_.transform(w,function(){return o(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof v=="function"?v.apply(this,arguments):v),n.apply(this,arguments),l)},null,M)},_.translateTo=function(w,I,v,M,R){_.transform(w,function(){var D=n.apply(this,arguments),j=this.__zoom,U=M==null?y(D):typeof M=="function"?M.apply(this,arguments):M;return o(ei.translate(U[0],U[1]).scale(j.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof v=="function"?-v.apply(this,arguments):-v),D,l)},M,R)};function E(w,I){return I=Math.max(r[0],Math.min(r[1],I)),I===w.k?w:new xn(I,w.x,w.y)}function N(w,I,v){var M=I[0]-v[0]*w.k,R=I[1]-v[1]*w.k;return M===w.x&&R===w.y?w:new xn(w.k,M,R)}function y(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function k(w,I,v,M){w.on("start.zoom",function(){S(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(M).end()}).tween("zoom",function(){var R=this,D=arguments,j=S(R,D).event(M),U=n.apply(R,D),ne=v==null?y(U):typeof v=="function"?v.apply(R,D):v,pe=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),he=R.__zoom,ye=typeof I=="function"?I.apply(R,D):I,be=c(he.invert(ne).concat(pe/he.k),ye.invert(ne).concat(pe/ye.k));return function(le){if(le===1)le=ye;else{var ve=be(le),ze=pe/ve[2];le=new xn(ze,ne[0]-ve[0]*ze,ne[1]-ve[1]*ze)}j.zoom(null,le)}})}function S(w,I,v){return!v&&w.__zooming||new T(w,I)}function T(w,I){this.that=w,this.args=I,this.active=0,this.sourceEvent=null,this.extent=n.apply(w,I),this.taps=0}T.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,I){return this.mouse&&w!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var I=Zt(this.that).datum();d.call(w,this.that,new nN(w,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:d}),I)}};function B(w,...I){if(!e.apply(this,arguments))return;var v=S(this,I).event(w),M=this.__zoom,R=Math.max(r[0],Math.min(r[1],M.k*Math.pow(2,i.apply(this,arguments)))),D=dn(w);if(v.wheel)(v.mouse[0][0]!==D[0]||v.mouse[0][1]!==D[1])&&(v.mouse[1]=M.invert(v.mouse[0]=D)),clearTimeout(v.wheel);else{if(M.k===R)return;v.mouse=[D,M.invert(D)],ir(this),v.start()}Oi(w),v.wheel=setTimeout(j,h),v.zoom("mouse",o(N(E(M,R),v.mouse[0],v.mouse[1]),v.extent,l));function j(){v.wheel=null,v.end()}}function A(w,...I){if(p||!e.apply(this,arguments))return;var v=w.currentTarget,M=S(this,I,!0).event(w),R=Zt(w.view).on("mousemove.zoom",ne,!0).on("mouseup.zoom",pe,!0),D=dn(w,v),j=w.clientX,U=w.clientY;Tm(w.view),gs(w),M.mouse=[D,this.__zoom.invert(D)],ir(this),M.start();function ne(he){if(Oi(he),!M.moved){var ye=he.clientX-j,be=he.clientY-U;M.moved=ye*ye+be*be>g}M.event(he).zoom("mouse",o(N(M.that.__zoom,M.mouse[0]=dn(he,v),M.mouse[1]),M.extent,l))}function pe(he){R.on("mousemove.zoom mouseup.zoom",null),Mm(he.view,M.moved),Oi(he),M.event(he).end()}}function V(w,...I){if(e.apply(this,arguments)){var v=this.__zoom,M=dn(w.changedTouches?w.changedTouches[0]:w,this),R=v.invert(M),D=v.k*(w.shiftKey?.5:2),j=o(N(E(v,D),M,R),n.apply(this,I),l);Oi(w),s>0?Zt(this).transition().duration(s).call(k,j,M,w):Zt(this).call(_.transform,j,M,w)}}function C(w,...I){if(e.apply(this,arguments)){var v=w.touches,M=v.length,R=S(this,I,w.changedTouches.length===M).event(w),D,j,U,ne;for(gs(w),j=0;j<M;++j)U=v[j],ne=dn(U,this),ne=[ne,this.__zoom.invert(ne),U.identifier],R.touch0?!R.touch1&&R.touch0[2]!==ne[2]&&(R.touch1=ne,R.taps=0):(R.touch0=ne,D=!0,R.taps=1+!!u);u&&(u=clearTimeout(u)),D&&(R.taps<2&&(m=ne[0],u=setTimeout(function(){u=null},f)),ir(this),R.start())}}function x(w,...I){if(this.__zooming){var v=S(this,I).event(w),M=w.changedTouches,R=M.length,D,j,U,ne;for(Oi(w),D=0;D<R;++D)j=M[D],U=dn(j,this),v.touch0&&v.touch0[2]===j.identifier?v.touch0[0]=U:v.touch1&&v.touch1[2]===j.identifier&&(v.touch1[0]=U);if(j=v.that.__zoom,v.touch1){var pe=v.touch0[0],he=v.touch0[1],ye=v.touch1[0],be=v.touch1[1],le=(le=ye[0]-pe[0])*le+(le=ye[1]-pe[1])*le,ve=(ve=be[0]-he[0])*ve+(ve=be[1]-he[1])*ve;j=E(j,Math.sqrt(le/ve)),U=[(pe[0]+ye[0])/2,(pe[1]+ye[1])/2],ne=[(he[0]+be[0])/2,(he[1]+be[1])/2]}else if(v.touch0)U=v.touch0[0],ne=v.touch0[1];else return;v.zoom("touch",o(N(j,U,ne),v.extent,l))}}function $(w,...I){if(this.__zooming){var v=S(this,I).event(w),M=w.changedTouches,R=M.length,D,j;for(gs(w),p&&clearTimeout(p),p=setTimeout(function(){p=null},f),D=0;D<R;++D)j=M[D],v.touch0&&v.touch0[2]===j.identifier?delete v.touch0:v.touch1&&v.touch1[2]===j.identifier&&delete v.touch1;if(v.touch1&&!v.touch0&&(v.touch0=v.touch1,delete v.touch1),v.touch0)v.touch0[1]=this.__zoom.invert(v.touch0[0]);else if(v.end(),v.taps===2&&(j=dn(j,this),Math.hypot(m[0]-j[0],m[1]-j[1])<b)){var U=Zt(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return _.wheelDelta=function(w){return arguments.length?(i=typeof w=="function"?w:ar(+w),_):i},_.filter=function(w){return arguments.length?(e=typeof w=="function"?w:ar(!!w),_):e},_.touchable=function(w){return arguments.length?(a=typeof w=="function"?w:ar(!!w),_):a},_.extent=function(w){return arguments.length?(n=typeof w=="function"?w:ar([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),_):n},_.scaleExtent=function(w){return arguments.length?(r[0]=+w[0],r[1]=+w[1],_):[r[0],r[1]]},_.translateExtent=function(w){return arguments.length?(l[0][0]=+w[0][0],l[1][0]=+w[1][0],l[0][1]=+w[0][1],l[1][1]=+w[1][1],_):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},_.constrain=function(w){return arguments.length?(o=w,_):o},_.duration=function(w){return arguments.length?(s=+w,_):s},_.interpolate=function(w){return arguments.length?(c=w,_):c},_.on=function(){var w=d.on.apply(d,arguments);return w===d?_:w},_.clickDistance=function(w){return arguments.length?(g=(w=+w)*w,_):Math.sqrt(g)},_.tapDistance=function(w){return arguments.length?(b=+w,_):b},_}var Me=(e=>(e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom",e))(Me||{}),bs=(e=>(e.Partial="partial",e.Full="full",e))(bs||{}),ko=(e=>(e.Bezier="default",e.SimpleBezier="simple-bezier",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e))(ko||{}),Rn=(e=>(e.Strict="strict",e.Loose="loose",e))(Rn||{}),_s=(e=>(e.Arrow="arrow",e.ArrowClosed="arrowclosed",e))(_s||{}),Pi=(e=>(e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal",e))(Pi||{}),cf=(e=>(e.TopLeft="top-left",e.TopCenter="top-center",e.TopRight="top-right",e.BottomLeft="bottom-left",e.BottomCenter="bottom-center",e.BottomRight="bottom-right",e))(cf||{});const cN=["INPUT","SELECT","TEXTAREA"],dN=typeof document<"u"?document:null;function ks(e){var n,o;const i=((o=(n=e.composedPath)==null?void 0:n.call(e))==null?void 0:o[0])||e.target,a=typeof(i==null?void 0:i.hasAttribute)=="function"?i.hasAttribute("contenteditable"):!1,r=typeof(i==null?void 0:i.closest)=="function"?i.closest(".nokey"):null;return cN.includes(i==null?void 0:i.nodeName)||a||!!r}function uN(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function df(e,n,o,i){const a=n.replace("+",`
|
|
28
28
|
`).replace(`
|
|
29
29
|
|
|
30
30
|
`,`
|