modscape 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +14 -19
- package/README.md +16 -9
- package/package.json +2 -1
- package/src/index.js +10 -0
- package/src/layout.js +151 -0
- package/visualizer/package.json +1 -1
- package/visualizer-dist/assets/{index-ChTOGXCm.js → index-DTXT8yZr.js} +2 -2
- package/visualizer-dist/index.html +1 -1
|
@@ -37,7 +37,7 @@ Error generating stack: `+v.message+`
|
|
|
37
37
|
`+t.slice(i,a),i=a+1),s=l;return o+=`
|
|
38
38
|
`,t.length-i>e&&s>i?o+=t.slice(i,s)+`
|
|
39
39
|
`+t.slice(s+1):o+=t.slice(i),o.slice(1)}function P$(t){for(var e="",r=0,n,i=0;i<t.length;r>=65536?i+=2:i++)r=cf(t,i),n=xn[r],!n&&Lf(r)?(e+=t[i],r>=65536&&(e+=t[i+1])):e+=n||A$(r);return e}function z$(t,e,r){var n="",i=t.tag,a,s,l;for(a=0,s=r.length;a<s;a+=1)l=r[a],t.replacer&&(l=t.replacer.call(r,String(a),l)),(Ga(t,e,l,!1,!1)||typeof l>"u"&&Ga(t,e,null,!1,!1))&&(n!==""&&(n+=","+(t.condenseFlow?"":" ")),n+=t.dump);t.tag=i,t.dump="["+n+"]"}function yD(t,e,r,n){var i="",a=t.tag,s,l,o;for(s=0,l=r.length;s<l;s+=1)o=r[s],t.replacer&&(o=t.replacer.call(r,String(s),o)),(Ga(t,e+1,o,!0,!0,!1,!0)||typeof o>"u"&&Ga(t,e+1,null,!0,!0,!1,!0))&&((!n||i!=="")&&(i+=ZC(t,e)),t.dump&&Nf===t.dump.charCodeAt(0)?i+="-":i+="- ",i+=t.dump);t.tag=a,t.dump=i||"[]"}function I$(t,e,r){var n="",i=t.tag,a=Object.keys(r),s,l,o,c,h;for(s=0,l=a.length;s<l;s+=1)h="",n!==""&&(h+=", "),t.condenseFlow&&(h+='"'),o=a[s],c=r[o],t.replacer&&(c=t.replacer.call(r,o,c)),Ga(t,e,o,!1,!1)&&(t.dump.length>1024&&(h+="? "),h+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Ga(t,e,c,!1,!1)&&(h+=t.dump,n+=h));t.tag=i,t.dump="{"+n+"}"}function q$(t,e,r,n){var i="",a=t.tag,s=Object.keys(r),l,o,c,h,d,g;if(t.sortKeys===!0)s.sort();else if(typeof t.sortKeys=="function")s.sort(t.sortKeys);else if(t.sortKeys)throw new An("sortKeys must be a boolean or a function");for(l=0,o=s.length;l<o;l+=1)g="",(!n||i!=="")&&(g+=ZC(t,e)),c=s[l],h=r[c],t.replacer&&(h=t.replacer.call(r,c,h)),Ga(t,e+1,c,!0,!0,!0)&&(d=t.tag!==null&&t.tag!=="?"||t.dump&&t.dump.length>1024,d&&(t.dump&&Nf===t.dump.charCodeAt(0)?g+="?":g+="? "),g+=t.dump,d&&(g+=ZC(t,e)),Ga(t,e+1,h,!0,d)&&(t.dump&&Nf===t.dump.charCodeAt(0)?g+=":":g+=": ",g+=t.dump,i+=g));t.tag=a,t.dump=i||"{}"}function bD(t,e,r){var n,i,a,s,l,o;for(i=r?t.explicitTypes:t.implicitTypes,a=0,s=i.length;a<s;a+=1)if(l=i[a],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof e=="object"&&e instanceof l.instanceOf)&&(!l.predicate||l.predicate(e))){if(r?l.multi&&l.representName?t.tag=l.representName(e):t.tag=l.tag:t.tag="?",l.represent){if(o=t.styleMap[l.tag]||l.defaultStyle,aq.call(l.represent)==="[object Function]")n=l.represent(e,o);else if(sq.call(l.represent,o))n=l.represent[o](e,o);else throw new An("!<"+l.tag+'> tag resolver accepts not "'+o+'" style');t.dump=n}return!0}return!1}function Ga(t,e,r,n,i,a,s){t.tag=null,t.dump=r,bD(t,r,!1)||bD(t,r,!0);var l=aq.call(t.dump),o=n,c;n&&(n=t.flowLevel<0||t.flowLevel>e);var h=l==="[object Object]"||l==="[object Array]",d,g;if(h&&(d=t.duplicates.indexOf(r),g=d!==-1),(t.tag!==null&&t.tag!=="?"||g||t.indent!==2&&e>0)&&(i=!1),g&&t.usedDuplicates[d])t.dump="*ref_"+d;else{if(h&&g&&!t.usedDuplicates[d]&&(t.usedDuplicates[d]=!0),l==="[object Object]")n&&Object.keys(t.dump).length!==0?(q$(t,e,t.dump,i),g&&(t.dump="&ref_"+d+t.dump)):(I$(t,e,t.dump),g&&(t.dump="&ref_"+d+" "+t.dump));else if(l==="[object Array]")n&&t.dump.length!==0?(t.noArrayIndent&&!s&&e>0?yD(t,e-1,t.dump,i):yD(t,e,t.dump,i),g&&(t.dump="&ref_"+d+t.dump)):(z$(t,e,t.dump),g&&(t.dump="&ref_"+d+" "+t.dump));else if(l==="[object String]")t.tag!=="?"&&B$(t,t.dump,e,a,o);else{if(l==="[object Undefined]")return!1;if(t.skipInvalid)return!1;throw new An("unacceptable kind of an object to dump "+l)}t.tag!==null&&t.tag!=="?"&&(c=encodeURI(t.tag[0]==="!"?t.tag.slice(1):t.tag).replace(/!/g,"%21"),t.tag[0]==="!"?c="!"+c:c.slice(0,18)==="tag:yaml.org,2002:"?c="!!"+c.slice(18):c="!<"+c+">",t.dump=c+" "+t.dump)}return!0}function j$(t,e){var r=[],n=[],i,a;for(ek(t,r,n),i=0,a=n.length;i<a;i+=1)e.duplicates.push(r[n[i]]);e.usedDuplicates=new Array(a)}function ek(t,e,r){var n,i,a;if(t!==null&&typeof t=="object")if(i=e.indexOf(t),i!==-1)r.indexOf(i)===-1&&r.push(i);else if(e.push(t),Array.isArray(t))for(i=0,a=t.length;i<a;i+=1)ek(t[i],e,r);else for(n=Object.keys(t),i=0,a=n.length;i<a;i+=1)ek(t[n[i]],e,r)}function F$(t,e){e=e||{};var r=new M$(e);r.noRefs||j$(t,r);var n=t;return r.replacer&&(n=r.replacer.call({"":n},"",n)),Ga(r,0,n,!0,!0)?r.dump+`
|
|
40
|
-
`:""}var H$=F$,V$={dump:H$};function MT(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var U$=sn,$$=RI,G$=BI,Y$=qI,X$=jI,W$=TT,Q$=iq.load,K$=iq.loadAll,Z$=V$.dump,J$=An,eG={binary:$I,float:II,map:NI,null:LI,pairs:YI,set:XI,timestamp:VI,bool:PI,int:zI,merge:UI,omap:GI,seq:_I,str:DI},tG=MT("safeLoad","load"),rG=MT("safeLoadAll","loadAll"),nG=MT("safeDump","dump"),tk={Type:U$,Schema:$$,FAILSAFE_SCHEMA:G$,JSON_SCHEMA:Y$,CORE_SCHEMA:X$,DEFAULT_SCHEMA:W$,load:Q$,loadAll:K$,dump:Z$,YAMLException:J$,types:eG,safeLoad:tG,safeLoadAll:rG,safeDump:nG};function Ia(t){if(!t||typeof t!="object")throw new Error("Invalid YAML: Root must be an object");const e={tables:Array.isArray(t.tables)?t.tables:[],relationships:Array.isArray(t.relationships)?t.relationships:[],lineage:Array.isArray(t.lineage)?t.lineage:[],domains:Array.isArray(t.domains)?t.domains:[],annotations:Array.isArray(t.annotations)?t.annotations:[],layout:t.layout||{}};e.domains&&e.layout&&e.domains.forEach(n=>{n.tables.forEach(i=>{e.layout[i]?e.layout[i].parentId=n.id:e.layout[i]={x:0,y:0,parentId:n.id}})});const r=[];return e.tables.forEach(n=>{n.lineage?.upstream&&Array.isArray(n.lineage.upstream)&&n.lineage.upstream.forEach(i=>{e.lineage.some(s=>s.from===i&&s.to===n.id)||r.push({from:i,to:n.id})})}),r.length>0&&(e.lineage=[...e.lineage??[],...r]),e.tables=e.tables.map(n=>{let i=n.sampleData;if(i&&typeof i=="object"&&!Array.isArray(i)){const s=Array.isArray(i.columns)?i.columns:[],l=Array.isArray(i.rows)?i.rows:[];if(s.length>0&&l.length>0){const o=Array.isArray(n.columns)?n.columns:[];i=l.map(c=>o.map(h=>{const d=s.indexOf(h.id);return d!==-1?c[d]:null}))}else l.length>0?i=l:i=[]}const a=n.appearance?{...n.appearance}:void 0;return a&&a.sub_type&&/^type[0-7]$/.test(a.sub_type)&&!a.scd&&(a.scd=a.sub_type,a.sub_type=void 0),{...n,id:n.id||"unknown",name:n.name!==void 0?n.name:n.id||"Unnamed Table",logical_name:n.logical_name,physical_name:n.physical_name,appearance:a,implementation:n.implementation?{...n.implementation,unique_key:n.implementation.unique_key?Array.isArray(n.implementation.unique_key)?n.implementation.unique_key:[n.implementation.unique_key]:void 0,partition_by:n.implementation.partition_by?Array.isArray(n.implementation.partition_by)?n.implementation.partition_by:[n.implementation.partition_by]:void 0}:void 0,columns:Array.isArray(n.columns)?n.columns.map(s=>({...s,logical:s.logical?{...s.logical}:void 0,physical:s.physical?{...s.physical}:void 0})):[],sampleData:Array.isArray(i)?i:[]}}),e}function iG(t){try{const e=tk.load(t);return Ia(e)}catch(e){throw new Error(`YAML Parsing Error: ${e.message}`)}}let Ko=null;const pt=IU((t,e)=>({schema:null,selectedTableId:null,selectedTableIds:[],selectedEdgeId:null,selectedAnnotationId:null,highlightedNodeIds:[],hoveredColumnId:null,isModelLoading:!1,error:null,isCliMode:typeof window<"u"&&window.MODSCAPE_CLI_MODE===!0,isAutoSaveEnabled:!0,lastSavedAt:0,savingStatus:"idle",lastUpdateSource:"visual",yamlInput:"",setYamlInput:r=>{t({yamlInput:r,lastUpdateSource:"user",lastSavedAt:Date.now()}),e().saveSchema()},syncToYamlInput:()=>{const{schema:r}=e();if(r){const n=tk.dump(r,{indent:2,lineWidth:-1,noRefs:!0});t({yamlInput:n,lastUpdateSource:"visual"})}},availableFiles:[],currentModelSlug:null,isSidebarOpen:!0,isRightPanelOpen:!1,isQuickConnectBarOpen:!1,isCommandPaletteOpen:!1,isPresentationMode:!1,activeTab:"editor",activeRightPanelTab:"tables",focusNodeId:null,pathFinderResult:null,showER:!0,showLineage:!0,showAnnotations:!0,isCompactMode:!1,connectMode:null,theme:"dark",isDetailPanelSuppressed:!1,isDetailPanelMinimized:!0,setSchema:r=>{const n=Ia(r);t({schema:n}),e().syncToYamlInput()},parseAndSetSchema:r=>{try{const n=iG(r);t({schema:n,error:null}),e().saveSchema()}catch(n){t({error:n.message})}},setSelectedTableId:r=>t({selectedTableId:r,selectedEdgeId:null,selectedAnnotationId:null,isDetailPanelMinimized:r?e().isDetailPanelMinimized:!0}),setSelectedTableIds:r=>t({selectedTableIds:r}),setSelectedEdgeId:r=>t({selectedEdgeId:r,selectedTableId:null,selectedAnnotationId:null,isDetailPanelMinimized:r?e().isDetailPanelMinimized:!0}),setSelectedAnnotationId:r=>t({selectedAnnotationId:r,selectedTableId:null,selectedEdgeId:null,isDetailPanelMinimized:r?e().isDetailPanelMinimized:!0}),setHighlightedNodeIds:r=>t({highlightedNodeIds:r}),setIsDetailPanelSuppressed:r=>t({isDetailPanelSuppressed:r}),setIsDetailPanelMinimized:r=>t({isDetailPanelMinimized:r}),setHoveredColumnId:r=>t({hoveredColumnId:r}),setIsCliMode:r=>t({isCliMode:r}),setIsSidebarOpen:r=>t({isSidebarOpen:r}),setIsRightPanelOpen:r=>t({isRightPanelOpen:r}),setIsQuickConnectBarOpen:r=>t({isQuickConnectBarOpen:r}),setIsCommandPaletteOpen:r=>t({isCommandPaletteOpen:r}),setActiveTab:r=>t({activeTab:r,isSidebarOpen:!0}),setActiveRightPanelTab:r=>t({activeRightPanelTab:r,isRightPanelOpen:!0}),setIsPresentationMode:r=>t({isPresentationMode:r}),setIsAutoSaveEnabled:r=>t({isAutoSaveEnabled:r}),setLastUpdateSource:r=>t({lastUpdateSource:r}),setPathFinderResult:r=>t({pathFinderResult:r}),setFocusNodeId:r=>t({focusNodeId:r}),toggleTheme:()=>t(r=>({theme:r.theme==="dark"?"light":"dark"})),setShowER:r=>t({showER:r}),setShowLineage:r=>t({showLineage:r}),setShowAnnotations:r=>t({showAnnotations:r}),setIsCompactMode:r=>t({isCompactMode:r}),setConnectMode:r=>t({connectMode:r}),updateNodePosition:(r,n,i,a)=>{const{schema:s}=e();if(!s)return;const l=s.layout||{},o=l[r]||{},c={...l,[r]:{...o,x:Math.round(n),y:Math.round(i),...a?{parentId:a}:{}}};t({schema:{...s,layout:c},lastUpdateSource:"visual"}),e().syncToYamlInput(),e().saveSchema()},updateNodesPosition:r=>{const{schema:n}=e();if(!n)return;const a={...n.layout||{}};r.forEach(({id:s,x:l,y:o,parentId:c})=>{const h=a[s]||{};a[s]={...h,x:Math.round(l),y:Math.round(o),...c?{parentId:c}:{}}}),t({schema:{...n,layout:a},lastUpdateSource:"visual"}),e().syncToYamlInput(),e().saveSchema()},updateNodeDimensions:(r,n,i)=>{const{schema:a}=e();if(!a)return;const s={x:0,y:0,...a.layout?.[r]},l={...a.layout||{},[r]:{...s,width:n,height:i}};t({schema:{...a,layout:l}}),e().syncToYamlInput(),e().saveSchema()},saveSchema:async(r=!1)=>{const{schema:n,isCliMode:i,isAutoSaveEnabled:a,lastUpdateSource:s,currentModelSlug:l}=e();t({lastSavedAt:Date.now()}),s!=="user"&&(!i||!a&&!r||(Ko&&clearTimeout(Ko),Ko=setTimeout(async()=>{const o=e().currentModelSlug;if(l===o)try{const c=tk.dump(n,{indent:2,lineWidth:-1,noRefs:!0}),h=o?`?model=${o}`:"";await fetch(`/api/save${h}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:c})}),t({lastSavedAt:Date.now(),savingStatus:"saved"}),setTimeout(()=>t({savingStatus:"idle"}),2e3)}catch{t({savingStatus:"error"})}},1e3),t({savingStatus:"saving"})))},refreshModelData:async()=>{const{lastSavedAt:r}=e();if(!(Date.now()-r<3e3))try{const a=await(await fetch("/api/model"+window.location.search)).json();t({schema:Ia(a),selectedTableId:null,selectedEdgeId:null,selectedAnnotationId:null}),e().syncToYamlInput()}catch(i){console.error("Failed to refresh data:",i)}},addTable:(r,n,i)=>{const a=e().schema||{tables:[],relationships:[],domains:[],layout:{}},s=i?i.toLowerCase().replace(/\s+/g,"_"):`new_table_${Date.now()}`,l={id:s,name:i||"NEW_TABLE",appearance:{type:"table"},columns:[{id:"id",logical:{name:"ID",type:"Integer",isPrimaryKey:!0}}]},o={...a,tables:[...a.tables||[],l],layout:{...a.layout||{},[s]:{x:Math.round(r),y:Math.round(n)}}};t({schema:Ia(o),selectedTableId:s}),e().syncToYamlInput(),e().saveSchema()},addDomain:(r,n,i)=>{const a=e().schema||{tables:[],relationships:[],domains:[],layout:{}},s=i?i.toLowerCase().replace(/\s+/g,"_"):`new_domain_${Date.now()}`,l={id:s,name:i||"NEW_DOMAIN",description:"Domain purpose",tables:[],color:"rgba(59, 130, 246, 0.05)"},o={...a,domains:[...a.domains||[],l],layout:{...a.layout||{},[s]:{x:Math.round(r),y:Math.round(n),width:600,height:400}}};t({schema:Ia(o),selectedTableId:s}),e().syncToYamlInput(),e().saveSchema()},addRelationship:(r,n,i,a)=>{const{schema:s}=e();if(!s)return;const l={from:{table:r,column:i?.split("-")[1]},to:{table:n,column:a?.split("-")[1]},type:"one-to-many"},o={...s,relationships:[...s.relationships||[],l]};t({schema:Ia(o)}),e().syncToYamlInput(),e().saveSchema()},bulkAddRelationship:(r,n,i)=>{const{schema:a}=e();if(!a)return;const s=new RegExp("^"+n.replace(/\*/g,".*")+"$","i"),l=a.tables.filter(o=>s.test(o.id)||(o.columns||[]).some(c=>s.test(`${o.id}.${c.id}`)));if(i==="lineage"){const o=a.lineage??[],c=l.filter(h=>!o.some(d=>d.from===r.table&&d.to===h.id)).map(h=>({from:r.table,to:h.id}));t({schema:{...a,lineage:[...o,...c]}})}else{const o=l.map(c=>{let h;return n.includes(".")&&(h=n.split(".")[1]),{from:r,to:{table:c.id,column:h},type:i}});t({schema:{...a,relationships:[...a.relationships||[],...o]}})}e().syncToYamlInput(),e().saveSchema()},addLineage:(r,n)=>{const{schema:i}=e();if(!i)return;const a=i.lineage??[];a.some(s=>s.from===r&&s.to===n)||(t({schema:{...i,lineage:[...a,{from:r,to:n}]}}),e().syncToYamlInput(),e().saveSchema())},updateRelationship:(r,n)=>{const{schema:i}=e();if(!i)return;const a=[...i.relationships];a[r]={...a[r],...n},t({schema:{...i,relationships:a}}),e().syncToYamlInput(),e().saveSchema()},removeEdge:(r,n,i)=>{const{schema:a}=e();if(!a)return;const s=i==="lineage"?a.relationships:a.relationships.filter(o=>!(o.from.table===r&&o.to.table===n)),l=i==="er"?a.lineage??[]:(a.lineage??[]).filter(o=>!(o.from===r&&o.to===n));t({schema:{...a,relationships:s,lineage:l},selectedEdgeId:null}),e().syncToYamlInput(),e().saveSchema()},removeNode:r=>{const{schema:n}=e();if(!n)return;const i=(n.domains||[]).some(h=>h.id===r),a=n.tables.filter(h=>h.id!==r),s=(n.domains||[]).filter(h=>h.id!==r).map(h=>({...h,tables:h.tables.filter(d=>d!==r)})),l=n.relationships.filter(h=>h.from.table!==r&&h.to.table!==r),o=(n.lineage??[]).filter(h=>h.from!==r&&h.to!==r),c={...n.layout||{}};delete c[r],i&&Object.keys(c).forEach(h=>{c[h].parentId===r&&delete c[h].parentId}),t({schema:{...n,tables:a,domains:s,relationships:l,lineage:o,layout:c},selectedTableId:null}),e().syncToYamlInput(),e().saveSchema()},bulkRemoveTables:r=>{const{schema:n}=e();if(!n)return;const i=n.tables.filter(c=>!r.includes(c.id)),a={...n.layout||{}};r.forEach(c=>delete a[c]);const s=(n.relationships||[]).filter(c=>!r.includes(c.from.table)&&!r.includes(c.to.table)),l=(n.lineage??[]).filter(c=>!r.includes(c.from)&&!r.includes(c.to)),o=(n.domains||[]).map(c=>({...c,tables:c.tables.filter(h=>!r.includes(h))}));t({schema:{...n,tables:i,relationships:s,lineage:l,domains:o,layout:a},selectedTableIds:[]}),e().syncToYamlInput(),e().saveSchema()},updateTable:(r,n)=>{const{schema:i}=e();if(!i)return;const a=i.tables.map(s=>s.id===r?{...s,...n}:s);t({schema:{...i,tables:a}}),e().syncToYamlInput(),e().saveSchema()},updateDomain:(r,n)=>{const{schema:i}=e();if(!i)return;const a=(i.domains||[]).map(s=>s.id===r?{...s,...n}:s);t({schema:{...i,domains:a}}),e().syncToYamlInput(),e().saveSchema()},assignTableToDomain:(r,n)=>{const{schema:i}=e();if(!i)return;const a=(i.domains||[]).map(l=>{const o=l.tables.filter(c=>c!==r);return l.id===n?{...l,tables:Array.from(new Set([...o,r]))}:{...l,tables:o}}),s={...i.layout||{},[r]:{x:20,y:20,...i.layout?.[r],...n?{parentId:n}:{}}};t({schema:{...i,domains:a,layout:s}}),e().syncToYamlInput(),e().saveSchema()},bulkAssignTablesToDomain:(r,n)=>{const{schema:i}=e();if(!i)return;const a=(i.domains||[]).map(l=>{const o=l.tables.filter(c=>!r.includes(c));return l.id===n?{...l,tables:Array.from(new Set([...o,...r]))}:{...l,tables:o}}),s={...i.layout||{}};n&&r.forEach(l=>{const o=s[l]||{};s[l]={...o,x:o.x??20,y:o.y??20,parentId:n}}),t({schema:{...i,domains:a,layout:s}}),e().syncToYamlInput(),e().saveSchema()},distributeSelectedTables:r=>{const{schema:n,selectedTableIds:i}=e();if(!n||i.length<2)return;const a=i.map(o=>({id:o,pos:n.layout?.[o]||{x:0,y:0}}));r==="vertical"?a.sort((o,c)=>o.pos.y-c.pos.y):a.sort((o,c)=>o.pos.x-c.pos.x);const s={...n.layout||{}},l=a[0].pos;a.forEach((o,c)=>{s[o.id]={x:r==="vertical"?l.x:l.x+c*280,y:r==="vertical"?l.y+c*320:l.y}}),t({schema:{...n,layout:s}}),e().syncToYamlInput(),e().saveSchema()},applyLayout:r=>{const{schema:n}=e();n&&(t({schema:{...n,layout:r}}),e().syncToYamlInput(),e().saveSchema())},executePipeline:(r,n=!1)=>{const{schema:i,selectedTableIds:a}=e();if(!i)return{stages:[],outputIds:[]};const s=r.split("|").map(h=>h.trim()).filter(Boolean),l=[];let o=[],c=JSON.parse(JSON.stringify(i));return s.forEach(h=>{const d=h.split(/\s+/),g=d[0].toLowerCase(),m=d.slice(1);let y=[...o],b="",x="success";try{if(g==="select"){const w=m.join(" ");if(w==="*")y=[...c.tables.map(S=>S.id),...(c.domains||[]).map(S=>S.id)];else if(w){const S=new RegExp("^"+w.replace(/\*/g,".*")+"$","i"),k=c.tables.filter(M=>M.id===w||S.test(M.id)||S.test(M.name)).map(M=>M.id),E=(c.domains||[]).filter(M=>M.id===w||S.test(M.id)||S.test(M.name)).map(M=>M.id);y=[...k,...E]}else y=[];y.length>0?(b=`Matched ${y.length} objects`,x="success"):(x="error",b=`No objects matched "${w}"`)}else if(g==="selected")y=[...a],b=`Using ${y.length} selected tables`,x="success";else if(g==="mv"){const w=d.findIndex(k=>k.toLowerCase()==="to"),S=w>-1?d.slice(w+1).join(" "):m.join(" ");!o||o.length===0?(x="error",b='No tables to move. Add a "select" stage.'):S?(c.domains||[]).some(E=>E.id===S)?(c.domains=(c.domains||[]).map(E=>{const M=E.tables.filter(R=>!o.includes(R));return E.id===S?{...E,tables:Array.from(new Set([...M,...o]))}:{...E,tables:M}}),o.forEach(E=>{c.layout&&(c.layout[E]={x:20,y:20})}),b=`Move ${o.length} to ${S}`,x="success"):(x="error",b=`Domain "${S}" not found`):(x="active",b="Waiting for domain...")}else if(g==="stack"||g==="v"||g==="h"){const w=g==="v"||m.includes("v")||m.includes("vertical")?"vertical":"horizontal",S=o.map(E=>({id:E,pos:c.layout?.[E]||{x:0,y:0}}));w==="vertical"?S.sort((E,M)=>E.pos.y-M.pos.y):S.sort((E,M)=>E.pos.x-M.pos.x);const k=S.length>0?S[0].pos:{x:0,y:0};S.forEach((E,M)=>{c.layout&&(c.layout[E.id]={x:w==="vertical"?k.x:k.x+M*280,y:w==="vertical"?k.y+M*320:k.y})}),b=`Stacked ${o.length} ${w}`,x="success"}else if(g==="delete"){const w=o.filter(k=>c.tables.some(E=>E.id===k)),S=o.filter(k=>(c.domains||[]).some(E=>E.id===k));if(c.tables=c.tables.filter(k=>!w.includes(k.id)),c.domains=(c.domains||[]).filter(k=>!S.includes(k.id)),c.lineage=(c.lineage??[]).filter(k=>!w.includes(k.from)&&!w.includes(k.to)),S.length>0&&c.layout){const k={...c.layout};Object.keys(k).forEach(E=>{if(S.includes(k[E].parentId)){const{parentId:M,...R}=k[E];k[E]=R}S.includes(E)&&delete k[E]}),c.layout=k}y=[],b=`Deleted ${w.length} tables and ${S.length} domains`,x="success"}else if(g==="clear")c.domains=(c.domains||[]).map(w=>({...w,tables:w.tables.filter(S=>!o.includes(S))})),b=`Cleared domain for ${o.length} tables`,x="success";else if(g==="add"){const w=m[0]?.toLowerCase(),S=m.slice(1).join(" "),k=E=>{const M=E.toLowerCase().replace(/\s+/g,"_");let R=M||`new_${w}_${Date.now()}`,O=1;const N=B=>c.tables.some(D=>D.id===B)||(c.domains||[]).some(D=>D.id===B);for(;N(R);)R=`${M}_${O}`,O++;return R};if(w==="table"){const E=k(S);c.tables.push({id:E,name:S||"NEW_TABLE",columns:[{id:"id",logical:{name:"ID",type:"Integer",isPrimaryKey:!0}}]}),c.layout||(c.layout={}),c.layout[E]={x:400,y:300},b=`Added table ${E}`,x="success"}else if(w==="domain"){const E=k(S);c.domains.push({id:E,name:S||"NEW_DOMAIN",tables:[],color:"rgba(59, 130, 246, 0.05)"}),c.layout||(c.layout={}),c.layout[E]={x:400,y:300,width:600,height:400},b=`Added domain ${E}`,x="success"}}else x="error",b=`Unknown command: ${g}`}catch{x="error",b="Execution error"}l.push({command:g,args:m,inputIds:o,outputIds:y,status:x,message:b}),o=y}),!n&&l.length>0&&l.every(h=>h.status==="success")&&(t({schema:Ia(c)}),e().syncToYamlInput(),e().saveSchema()),{stages:l,outputIds:o}},toggleTableSelection:r=>{const{selectedTableId:n}=e();t(n===r?{selectedTableId:null,isDetailPanelMinimized:!0}:{selectedTableId:r,selectedEdgeId:null,selectedAnnotationId:null})},toggleEdgeSelection:r=>{const{selectedEdgeId:n}=e();t(n===r?{selectedEdgeId:null}:{selectedEdgeId:r,selectedTableId:null,selectedAnnotationId:null})},toggleAnnotationSelection:r=>{const{selectedAnnotationId:n}=e();t(n===r?{selectedAnnotationId:null}:{selectedAnnotationId:r,selectedTableId:null,selectedEdgeId:null})},addAnnotation:(r,n,i)=>{const{schema:a}=e();if(!a)return;const s=`note_${Date.now()}`,l={id:s,targetId:n,targetType:i,text:"New Note",type:"sticky",offset:r},o={...a,annotations:[...a.annotations||[],l]};t({schema:Ia(o),selectedAnnotationId:s,selectedTableId:null,selectedEdgeId:null}),n||e().setFocusNodeId(s),e().syncToYamlInput(),e().saveSchema()},updateAnnotation:(r,n)=>{const{schema:i}=e();if(!i||!i.annotations)return;const a=i.annotations.map(s=>s.id===r?{...s,...n}:s);t({schema:{...i,annotations:a}}),e().syncToYamlInput(),e().saveSchema()},removeAnnotation:r=>{const{schema:n}=e();if(!n||!n.annotations)return;const i=n.annotations.filter(a=>a.id!==r);t({schema:{...n,annotations:i},selectedAnnotationId:null}),e().syncToYamlInput(),e().saveSchema()},fetchAvailableFiles:async()=>{const r=window.__MODSCAPE_DATA__;if(r?.models){const n=r.models.map(i=>({slug:i.slug,name:i.name,path:""}));t({availableFiles:n});return}try{const i=await(await fetch("/api/files")).json();t({availableFiles:i})}catch(n){console.error("Failed to fetch files:",n)}},setCurrentModel:async r=>{Ko&&(clearTimeout(Ko),Ko=null),t({isModelLoading:!0});try{const n=window.__MODSCAPE_DATA__;let i;n?.models?i=n.models.find(l=>l.slug===r)?.schema:i=await(await fetch(`/api/model?model=${r}`)).json(),t({schema:Ia(i),currentModelSlug:r,selectedTableId:null,selectedEdgeId:null,selectedAnnotationId:null,error:null,isModelLoading:!1}),e().syncToYamlInput();const a=new URLSearchParams(window.location.search);a.set("model",r),window.history.replaceState(null,"",`${window.location.pathname}?${a.toString()}`)}catch(n){console.error("Failed to set model:",n),t({isModelLoading:!1})}},getSelectedTable:()=>{const{schema:r,selectedTableId:n}=e();return!r||!n?null:r.tables.find(i=>i.id===n)||null},getSelectedDomain:()=>{const{schema:r,selectedTableId:n}=e();return!r||!n||!r.domains?null:r.domains.find(i=>i.id===n)||null},getSelectedRelationship:()=>{const{schema:r,selectedEdgeId:n}=e();if(!r||!n)return null;if(n.startsWith("lin-")){const s=n.lastIndexOf("-"),l=parseInt(n.slice(s+1)),o=r.lineage?.[l];return o?{relationship:{from:{table:o.from},to:{table:o.to},type:"lineage"},index:l,kind:"lineage"}:null}if(!n.startsWith("er-"))return null;const i=parseInt(n.split("-")[1]),a=r.relationships?.[i];return a?{relationship:a,index:i,kind:"er"}:null},getSelectedAnnotation:()=>{const{schema:r,selectedAnnotationId:n}=e();return!r||!n||!r.annotations?null:r.annotations.find(i=>i.id===n)||null}})),xD=t=>Symbol.iterator in t,wD=t=>"entries"in t,SD=(t,e)=>{const r=t instanceof Map?t:new Map(t.entries()),n=e instanceof Map?e:new Map(e.entries());if(r.size!==n.size)return!1;for(const[i,a]of r)if(!n.has(i)||!Object.is(a,n.get(i)))return!1;return!0},aG=(t,e)=>{const r=t[Symbol.iterator](),n=e[Symbol.iterator]();let i=r.next(),a=n.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=r.next(),a=n.next()}return!!i.done&&!!a.done};function sG(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:xD(t)&&xD(e)?wD(t)&&wD(e)?SD(t,e):aG(t,e):SD({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function so(t){const e=uf.useRef(void 0);return r=>{const n=t(r);return sG(e.current,n)?e.current:e.current=n}}const RT={fact:{color:"#f87171",icon:"📊",label:"FACT"},dimension:{color:"#60a5fa",icon:"🏷️",label:"DIM"},hub:{color:"#fbbf24",icon:"🌐",label:"HUB"},link:{color:"#34d399",icon:"🔗",label:"LINK"},satellite:{color:"#a78bfa",icon:"🛰️",label:"SAT"},mart:{color:"#f5700b",icon:"📈",label:"MART"},table:{color:"#64748b",icon:"📋",label:"TABLE"}};function vq(t){let r=(t.appearance?.type?RT[t.appearance.type]:null)?.label||"";const n=t.appearance?.sub_type,i=t.appearance?.scd;if(t.appearance?.type==="fact"&&n?r=`FACT (${{transaction:"Trans.",periodic:"Periodic",accumulating:"Accum.",factless:"Factless"}[n]||n})`:t.appearance?.type&&n?r=`${t.appearance.type.toUpperCase()} (${n})`:t.appearance?.type&&(r=t.appearance.type.toUpperCase()),i){const a=`SCD ${i.replace("type","T")}`;r=r?`${r} / ${a}`:a}return r}function lG(t){switch(t){case"one-to-many":return"1..N";case"many-to-one":return"N..1";case"many-to-many":return"N..N";case"one-to-one":return"1..1";default:return""}}function oG(t){const e=[],r=new Map;t.domains?.forEach(l=>{l.tables.forEach(o=>{r.set(o,l.id)})});const n=280,i=200,a=3;t.tables.forEach((l,o)=>{const c=t.layout?.[l.id],h=o%a,d=Math.floor(o/a),g=c?.x??h*(n+40),m=c?.y??d*(i+40),y=l.appearance?.type?RT[l.appearance.type]:null,b=l.appearance?.color||y?.color||"#334155";e.push({data:{id:l.id,table:l,domainId:r.get(l.id)??null,typeColor:b,typeLabel:vq(l),typeIcon:l.appearance?.icon||y?.icon||""},position:{x:g,y:m}})});const s=new Set(t.tables.map(l=>l.id));return t.lineage?.forEach((l,o)=>{!s.has(l.from)||!s.has(l.to)||e.push({data:{id:`lin-${l.from}-${l.to}-${o}`,source:l.from,target:l.to,kind:"lineage"},classes:"lineage-edge"})}),t.relationships?.forEach((l,o)=>{!s.has(l.from.table)||!s.has(l.to.table)||e.push({data:{id:`er-${o}`,source:l.from.table,target:l.to.table,kind:"er",label:lG(l.type),fromColumn:l.from.column??null,toColumn:l.to.column??null,relType:l.type??null},classes:"er-edge"})}),e}const by=6,uG=({table:t,isSelected:e,isDimmed:r,isHighlighted:n,isHovered:i,isPendingSource:a,isConnectMode:s,zoom:l,theme:o,hoveredColumnId:c,isCompact:h})=>{const d=t.appearance?.type?RT[t.appearance.type]:null,g=t.appearance?.color||d?.color||"#334155",m=t.appearance?.icon||d?.icon||"",y=vq(t),b=t.columns&&t.columns.length>0,x=l<.35,w=x||h,S=a?"#22c55e":e?"#3b82f6":i?g:s?"#22c55e":"var(--border-main)",k=a?"0 0 0 3px #22c55e, 0 0 20px 6px rgba(34,197,94,0.5)":e?"0 0 0 3px #3b82f6, 0 0 16px 4px rgba(59, 130, 246, 0.45)":i?`0 0 0 2px ${g}, 0 0 20px 6px ${g}80`:n?"0 0 12px 3px rgba(59, 130, 246, 0.35)":s?"0 0 0 1px rgba(34,197,94,0.4)":o==="dark"?"0 4px 6px -1px rgba(0, 0, 0, 0.3)":"0 4px 12px -2px rgba(0, 0, 0, 0.1)";return A.jsxs("div",{"data-testid":"table-node","data-table-id":t.id,style:{width:"100%",height:"100%",minWidth:"220px",position:"relative",cursor:"default",opacity:r?.15:1,transition:"opacity 0.2s ease-in-out",userSelect:"none"},children:[a&&A.jsx("div",{style:{position:"absolute",top:"-10px",right:"8px",padding:"0 6px",height:"14px",backgroundColor:"#22c55e",color:"#fff",fontSize:"8px",fontWeight:900,borderRadius:"4px",display:"flex",alignItems:"center",letterSpacing:"0.05em",textTransform:"uppercase",zIndex:2,pointerEvents:"none"},children:"FROM"}),y&&A.jsx("div",{style:{position:"absolute",top:"-12px",left:"12px",height:"14px",padding:"0 6px",backgroundColor:g,color:"#ffffff",fontSize:"8px",fontWeight:900,borderRadius:"4px 4px 0 0",display:"flex",alignItems:"center",justifyContent:"center",textTransform:"uppercase",letterSpacing:"0.05em",boxShadow:"0 -2px 4px rgba(0,0,0,0.1)",zIndex:1,pointerEvents:"none"},children:y}),A.jsxs("div",{style:{width:"100%",height:"100%",backgroundColor:"var(--node-bg)",borderLeft:`2px solid ${S}`,borderRight:`2px solid ${S}`,borderBottom:`2px solid ${S}`,borderTop:`4px solid ${g}`,borderRadius:"8px",overflow:"hidden",color:"var(--text-primary)",boxShadow:k,fontFamily:"sans-serif",display:"flex",flexDirection:"column",transition:"border-color 0.2s, box-shadow 0.2s"},children:[A.jsxs("div",{style:{padding:x?"8px 10px":"12px",backgroundColor:o==="dark"?"rgba(15, 23, 42, 0.8)":"rgba(241, 245, 249, 0.9)",borderBottom:b&&!w?"1px solid var(--border-main)":"none",flexShrink:0,cursor:"grab",display:"flex",flexDirection:"column",gap:"2px"},children:[A.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[m&&A.jsx("span",{style:{fontSize:x?"14px":"18px"},children:m}),A.jsx("div",{style:{fontSize:x?"12px":"16px",fontWeight:800,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-all"},children:t.name})]}),!x&&A.jsxs(A.Fragment,{children:[t.logical_name&&t.logical_name!==t.name&&A.jsx("div",{style:{fontSize:"11px",fontWeight:500,color:"var(--text-secondary)",paddingLeft:m?"26px":"0",opacity:.8},children:t.logical_name}),A.jsx("div",{title:t.physical_name||t.id,style:{fontSize:"9px",color:o==="dark"?"#94a3b8":"#64748b",fontFamily:"monospace",letterSpacing:"0.02em",paddingLeft:m?"26px":"0",marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},children:t.physical_name||t.id})]})]}),!w&&b&&A.jsx("div",{style:{padding:0,overflowY:"auto",flex:1,cursor:"default"},children:A.jsx("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"11px"},children:A.jsxs("tbody",{children:[t.columns.slice(0,by).map((E,M)=>{const R=E.logical?.name||E.id,O=E.physical?.name||E.id,N=R!==O;return A.jsxs("tr",{style:{borderBottom:"1px solid var(--border-main)",backgroundColor:c===E.id?o==="dark"?"rgba(30, 58, 138, 0.6)":"rgba(191, 219, 254, 0.4)":"transparent"},children:[A.jsx("td",{style:{padding:"6px 12px",fontWeight:500,color:"var(--text-primary)"},children:A.jsxs("div",{style:{display:"flex",alignItems:"flex-start"},children:[A.jsxs("span",{style:{color:"var(--text-secondary)",marginRight:"6px",fontSize:"9px",fontFamily:"monospace",width:"14px",textAlign:"right",opacity:.6,marginTop:"2px"},children:[M+1,"."]}),A.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0},children:[A.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",overflow:"hidden"},children:[E.logical?.isPrimaryKey&&A.jsx("span",{style:{color:"#eab308"},children:"🔑"}),E.logical?.isForeignKey&&A.jsx("span",{style:{opacity:.8},children:"🔩"}),E.logical?.isPartitionKey&&A.jsx("span",{style:{opacity:.8},children:"📂"}),E.logical?.isMetadata&&A.jsx("span",{style:{opacity:.8},title:"Metadata/Audit Column",children:"🕒"}),E.logical?.additivity==="fully"&&A.jsx("span",{style:{color:"#4ade80"},title:"Fully Additive",children:"Σ"}),E.logical?.additivity==="semi"&&A.jsx("span",{style:{color:"#fbbf24"},title:"Semi-Additive",children:"Σ~"}),E.logical?.additivity==="non"&&A.jsx("span",{style:{color:"#f87171"},title:"Non-Additive",children:"⊘"}),A.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:E.logical?.description||R,children:R})]}),N&&A.jsx("div",{style:{fontSize:"8px",fontFamily:"monospace",opacity:.6,marginTop:"1px",paddingLeft:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:O,children:O})]})]})}),A.jsx("td",{style:{padding:"6px 12px",textAlign:"right",fontStyle:"italic",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"120px",verticalAlign:"top",opacity:.8},children:E.logical?.type||"Unknown"})]},E.id)}),t.columns.length>by&&A.jsx("tr",{children:A.jsxs("td",{colSpan:2,style:{padding:"4px 12px",fontSize:"10px",color:"var(--text-secondary)",textAlign:"center",opacity:.6},children:["+",t.columns.length-by," more"]})})]})})})]})]})},cG=ve.memo(uG);function rk(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function fG(t){if(Array.isArray(t))return t}function hG(t){if(Array.isArray(t))return rk(t)}function sl(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function dG(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,yq(n.key),n)}}function ll(t,e,r){return e&&dG(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Yn(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=DT(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(o){throw o},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
40
|
+
`:""}var H$=F$,V$={dump:H$};function MT(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var U$=sn,$$=RI,G$=BI,Y$=qI,X$=jI,W$=TT,Q$=iq.load,K$=iq.loadAll,Z$=V$.dump,J$=An,eG={binary:$I,float:II,map:NI,null:LI,pairs:YI,set:XI,timestamp:VI,bool:PI,int:zI,merge:UI,omap:GI,seq:_I,str:DI},tG=MT("safeLoad","load"),rG=MT("safeLoadAll","loadAll"),nG=MT("safeDump","dump"),tk={Type:U$,Schema:$$,FAILSAFE_SCHEMA:G$,JSON_SCHEMA:Y$,CORE_SCHEMA:X$,DEFAULT_SCHEMA:W$,load:Q$,loadAll:K$,dump:Z$,YAMLException:J$,types:eG,safeLoad:tG,safeLoadAll:rG,safeDump:nG};function Ia(t){if(!t||typeof t!="object")throw new Error("Invalid YAML: Root must be an object");const e={tables:Array.isArray(t.tables)?t.tables:[],relationships:Array.isArray(t.relationships)?t.relationships:[],lineage:Array.isArray(t.lineage)?t.lineage:[],domains:Array.isArray(t.domains)?t.domains:[],annotations:Array.isArray(t.annotations)?t.annotations:[],layout:t.layout||{}};return e.domains&&e.layout&&e.domains.forEach(r=>{r.tables.forEach(n=>{e.layout[n]?e.layout[n].parentId=r.id:e.layout[n]={x:0,y:0,parentId:r.id}})}),e.tables=e.tables.map(r=>{let n=r.sampleData;if(n&&typeof n=="object"&&!Array.isArray(n)){const a=Array.isArray(n.columns)?n.columns:[],s=Array.isArray(n.rows)?n.rows:[];if(a.length>0&&s.length>0){const l=Array.isArray(r.columns)?r.columns:[];n=s.map(o=>l.map(c=>{const h=a.indexOf(c.id);return h!==-1?o[h]:null}))}else s.length>0?n=s:n=[]}const i=r.appearance?{...r.appearance}:void 0;return i&&i.sub_type&&/^type[0-7]$/.test(i.sub_type)&&!i.scd&&(i.scd=i.sub_type,i.sub_type=void 0),{...r,id:r.id||"unknown",name:r.name!==void 0?r.name:r.id||"Unnamed Table",logical_name:r.logical_name,physical_name:r.physical_name,appearance:i,lineage:void 0,implementation:r.implementation?{...r.implementation,unique_key:r.implementation.unique_key?Array.isArray(r.implementation.unique_key)?r.implementation.unique_key:[r.implementation.unique_key]:void 0,partition_by:r.implementation.partition_by?Array.isArray(r.implementation.partition_by)?r.implementation.partition_by:[r.implementation.partition_by]:void 0}:void 0,columns:Array.isArray(r.columns)?r.columns.map(a=>({...a,logical:a.logical?{...a.logical}:void 0,physical:a.physical?{...a.physical}:void 0})):[],sampleData:Array.isArray(n)?n:[]}}),e}function iG(t){try{const e=tk.load(t);return Ia(e)}catch(e){throw new Error(`YAML Parsing Error: ${e.message}`)}}let Ko=null;const pt=IU((t,e)=>({schema:null,selectedTableId:null,selectedTableIds:[],selectedEdgeId:null,selectedAnnotationId:null,highlightedNodeIds:[],hoveredColumnId:null,isModelLoading:!1,error:null,isCliMode:typeof window<"u"&&window.MODSCAPE_CLI_MODE===!0,isAutoSaveEnabled:!0,lastSavedAt:0,savingStatus:"idle",lastUpdateSource:"visual",yamlInput:"",setYamlInput:r=>{t({yamlInput:r,lastUpdateSource:"user",lastSavedAt:Date.now()}),e().saveSchema()},syncToYamlInput:()=>{const{schema:r}=e();if(r){const n=tk.dump(r,{indent:2,lineWidth:-1,noRefs:!0});t({yamlInput:n,lastUpdateSource:"visual"})}},availableFiles:[],currentModelSlug:null,isSidebarOpen:!0,isRightPanelOpen:!1,isQuickConnectBarOpen:!1,isCommandPaletteOpen:!1,isPresentationMode:!1,activeTab:"editor",activeRightPanelTab:"tables",focusNodeId:null,pathFinderResult:null,showER:!0,showLineage:!0,showAnnotations:!0,isCompactMode:!1,connectMode:null,theme:"dark",isDetailPanelSuppressed:!1,isDetailPanelMinimized:!0,setSchema:r=>{const n=Ia(r);t({schema:n}),e().syncToYamlInput()},parseAndSetSchema:r=>{try{const n=iG(r);t({schema:n,error:null}),e().saveSchema()}catch(n){t({error:n.message})}},setSelectedTableId:r=>t({selectedTableId:r,selectedEdgeId:null,selectedAnnotationId:null,isDetailPanelMinimized:r?e().isDetailPanelMinimized:!0}),setSelectedTableIds:r=>t({selectedTableIds:r}),setSelectedEdgeId:r=>t({selectedEdgeId:r,selectedTableId:null,selectedAnnotationId:null,isDetailPanelMinimized:r?e().isDetailPanelMinimized:!0}),setSelectedAnnotationId:r=>t({selectedAnnotationId:r,selectedTableId:null,selectedEdgeId:null,isDetailPanelMinimized:r?e().isDetailPanelMinimized:!0}),setHighlightedNodeIds:r=>t({highlightedNodeIds:r}),setIsDetailPanelSuppressed:r=>t({isDetailPanelSuppressed:r}),setIsDetailPanelMinimized:r=>t({isDetailPanelMinimized:r}),setHoveredColumnId:r=>t({hoveredColumnId:r}),setIsCliMode:r=>t({isCliMode:r}),setIsSidebarOpen:r=>t({isSidebarOpen:r}),setIsRightPanelOpen:r=>t({isRightPanelOpen:r}),setIsQuickConnectBarOpen:r=>t({isQuickConnectBarOpen:r}),setIsCommandPaletteOpen:r=>t({isCommandPaletteOpen:r}),setActiveTab:r=>t({activeTab:r,isSidebarOpen:!0}),setActiveRightPanelTab:r=>t({activeRightPanelTab:r,isRightPanelOpen:!0}),setIsPresentationMode:r=>t({isPresentationMode:r}),setIsAutoSaveEnabled:r=>t({isAutoSaveEnabled:r}),setLastUpdateSource:r=>t({lastUpdateSource:r}),setPathFinderResult:r=>t({pathFinderResult:r}),setFocusNodeId:r=>t({focusNodeId:r}),toggleTheme:()=>t(r=>({theme:r.theme==="dark"?"light":"dark"})),setShowER:r=>t({showER:r}),setShowLineage:r=>t({showLineage:r}),setShowAnnotations:r=>t({showAnnotations:r}),setIsCompactMode:r=>t({isCompactMode:r}),setConnectMode:r=>t({connectMode:r}),updateNodePosition:(r,n,i,a)=>{const{schema:s}=e();if(!s)return;const l=s.layout||{},o=l[r]||{},c={...l,[r]:{...o,x:Math.round(n),y:Math.round(i),...a?{parentId:a}:{}}};t({schema:{...s,layout:c},lastUpdateSource:"visual"}),e().syncToYamlInput(),e().saveSchema()},updateNodesPosition:r=>{const{schema:n}=e();if(!n)return;const a={...n.layout||{}};r.forEach(({id:s,x:l,y:o,parentId:c})=>{const h=a[s]||{};a[s]={...h,x:Math.round(l),y:Math.round(o),...c?{parentId:c}:{}}}),t({schema:{...n,layout:a},lastUpdateSource:"visual"}),e().syncToYamlInput(),e().saveSchema()},updateNodeDimensions:(r,n,i)=>{const{schema:a}=e();if(!a)return;const s={x:0,y:0,...a.layout?.[r]},l={...a.layout||{},[r]:{...s,width:n,height:i}};t({schema:{...a,layout:l}}),e().syncToYamlInput(),e().saveSchema()},saveSchema:async(r=!1)=>{const{schema:n,isCliMode:i,isAutoSaveEnabled:a,lastUpdateSource:s,currentModelSlug:l}=e();t({lastSavedAt:Date.now()}),s!=="user"&&(!i||!a&&!r||(Ko&&clearTimeout(Ko),Ko=setTimeout(async()=>{const o=e().currentModelSlug;if(l===o)try{const c=tk.dump(n,{indent:2,lineWidth:-1,noRefs:!0}),h=o?`?model=${o}`:"";await fetch(`/api/save${h}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:c})}),t({lastSavedAt:Date.now(),savingStatus:"saved"}),setTimeout(()=>t({savingStatus:"idle"}),2e3)}catch{t({savingStatus:"error"})}},1e3),t({savingStatus:"saving"})))},refreshModelData:async()=>{const{lastSavedAt:r}=e();if(!(Date.now()-r<3e3))try{const a=await(await fetch("/api/model"+window.location.search)).json();t({schema:Ia(a),selectedTableId:null,selectedEdgeId:null,selectedAnnotationId:null}),e().syncToYamlInput()}catch(i){console.error("Failed to refresh data:",i)}},addTable:(r,n,i)=>{const a=e().schema||{tables:[],relationships:[],domains:[],layout:{}},s=i?i.toLowerCase().replace(/\s+/g,"_"):`new_table_${Date.now()}`,l={id:s,name:i||"NEW_TABLE",appearance:{type:"table"},columns:[{id:"id",logical:{name:"ID",type:"Integer",isPrimaryKey:!0}}]},o={...a,tables:[...a.tables||[],l],layout:{...a.layout||{},[s]:{x:Math.round(r),y:Math.round(n)}}};t({schema:Ia(o),selectedTableId:s}),e().syncToYamlInput(),e().saveSchema()},addDomain:(r,n,i)=>{const a=e().schema||{tables:[],relationships:[],domains:[],layout:{}},s=i?i.toLowerCase().replace(/\s+/g,"_"):`new_domain_${Date.now()}`,l={id:s,name:i||"NEW_DOMAIN",description:"Domain purpose",tables:[],color:"rgba(59, 130, 246, 0.05)"},o={...a,domains:[...a.domains||[],l],layout:{...a.layout||{},[s]:{x:Math.round(r),y:Math.round(n),width:600,height:400}}};t({schema:Ia(o),selectedTableId:s}),e().syncToYamlInput(),e().saveSchema()},addRelationship:(r,n,i,a)=>{const{schema:s}=e();if(!s)return;const l={from:{table:r,column:i?.split("-")[1]},to:{table:n,column:a?.split("-")[1]},type:"one-to-many"},o={...s,relationships:[...s.relationships||[],l]};t({schema:Ia(o)}),e().syncToYamlInput(),e().saveSchema()},bulkAddRelationship:(r,n,i)=>{const{schema:a}=e();if(!a)return;const s=new RegExp("^"+n.replace(/\*/g,".*")+"$","i"),l=a.tables.filter(o=>s.test(o.id)||(o.columns||[]).some(c=>s.test(`${o.id}.${c.id}`)));if(i==="lineage"){const o=a.lineage??[],c=l.filter(h=>!o.some(d=>d.from===r.table&&d.to===h.id)).map(h=>({from:r.table,to:h.id}));t({schema:{...a,lineage:[...o,...c]}})}else{const o=l.map(c=>{let h;return n.includes(".")&&(h=n.split(".")[1]),{from:r,to:{table:c.id,column:h},type:i}});t({schema:{...a,relationships:[...a.relationships||[],...o]}})}e().syncToYamlInput(),e().saveSchema()},addLineage:(r,n)=>{const{schema:i}=e();if(!i)return;const a=i.lineage??[];a.some(s=>s.from===r&&s.to===n)||(t({schema:{...i,lineage:[...a,{from:r,to:n}]}}),e().syncToYamlInput(),e().saveSchema())},updateRelationship:(r,n)=>{const{schema:i}=e();if(!i)return;const a=[...i.relationships];a[r]={...a[r],...n},t({schema:{...i,relationships:a}}),e().syncToYamlInput(),e().saveSchema()},removeEdge:(r,n,i)=>{const{schema:a}=e();if(!a)return;const s=i==="lineage"?a.relationships:a.relationships.filter(o=>!(o.from.table===r&&o.to.table===n)),l=i==="er"?a.lineage??[]:(a.lineage??[]).filter(o=>!(o.from===r&&o.to===n));t({schema:{...a,relationships:s,lineage:l},selectedEdgeId:null}),e().syncToYamlInput(),e().saveSchema()},removeNode:r=>{const{schema:n}=e();if(!n)return;const i=(n.domains||[]).some(h=>h.id===r),a=n.tables.filter(h=>h.id!==r),s=(n.domains||[]).filter(h=>h.id!==r).map(h=>({...h,tables:h.tables.filter(d=>d!==r)})),l=n.relationships.filter(h=>h.from.table!==r&&h.to.table!==r),o=(n.lineage??[]).filter(h=>h.from!==r&&h.to!==r),c={...n.layout||{}};delete c[r],i&&Object.keys(c).forEach(h=>{c[h].parentId===r&&delete c[h].parentId}),t({schema:{...n,tables:a,domains:s,relationships:l,lineage:o,layout:c},selectedTableId:null}),e().syncToYamlInput(),e().saveSchema()},bulkRemoveTables:r=>{const{schema:n}=e();if(!n)return;const i=n.tables.filter(c=>!r.includes(c.id)),a={...n.layout||{}};r.forEach(c=>delete a[c]);const s=(n.relationships||[]).filter(c=>!r.includes(c.from.table)&&!r.includes(c.to.table)),l=(n.lineage??[]).filter(c=>!r.includes(c.from)&&!r.includes(c.to)),o=(n.domains||[]).map(c=>({...c,tables:c.tables.filter(h=>!r.includes(h))}));t({schema:{...n,tables:i,relationships:s,lineage:l,domains:o,layout:a},selectedTableIds:[]}),e().syncToYamlInput(),e().saveSchema()},updateTable:(r,n)=>{const{schema:i}=e();if(!i)return;const a=i.tables.map(s=>s.id===r?{...s,...n}:s);t({schema:{...i,tables:a}}),e().syncToYamlInput(),e().saveSchema()},updateDomain:(r,n)=>{const{schema:i}=e();if(!i)return;const a=(i.domains||[]).map(s=>s.id===r?{...s,...n}:s);t({schema:{...i,domains:a}}),e().syncToYamlInput(),e().saveSchema()},assignTableToDomain:(r,n)=>{const{schema:i}=e();if(!i)return;const a=(i.domains||[]).map(l=>{const o=l.tables.filter(c=>c!==r);return l.id===n?{...l,tables:Array.from(new Set([...o,r]))}:{...l,tables:o}}),s={...i.layout||{},[r]:{x:20,y:20,...i.layout?.[r],...n?{parentId:n}:{}}};t({schema:{...i,domains:a,layout:s}}),e().syncToYamlInput(),e().saveSchema()},bulkAssignTablesToDomain:(r,n)=>{const{schema:i}=e();if(!i)return;const a=(i.domains||[]).map(l=>{const o=l.tables.filter(c=>!r.includes(c));return l.id===n?{...l,tables:Array.from(new Set([...o,...r]))}:{...l,tables:o}}),s={...i.layout||{}};n&&r.forEach(l=>{const o=s[l]||{};s[l]={...o,x:o.x??20,y:o.y??20,parentId:n}}),t({schema:{...i,domains:a,layout:s}}),e().syncToYamlInput(),e().saveSchema()},distributeSelectedTables:r=>{const{schema:n,selectedTableIds:i}=e();if(!n||i.length<2)return;const a=i.map(o=>({id:o,pos:n.layout?.[o]||{x:0,y:0}}));r==="vertical"?a.sort((o,c)=>o.pos.y-c.pos.y):a.sort((o,c)=>o.pos.x-c.pos.x);const s={...n.layout||{}},l=a[0].pos;a.forEach((o,c)=>{s[o.id]={x:r==="vertical"?l.x:l.x+c*280,y:r==="vertical"?l.y+c*320:l.y}}),t({schema:{...n,layout:s}}),e().syncToYamlInput(),e().saveSchema()},applyLayout:r=>{const{schema:n}=e();n&&(t({schema:{...n,layout:r}}),e().syncToYamlInput(),e().saveSchema())},executePipeline:(r,n=!1)=>{const{schema:i,selectedTableIds:a}=e();if(!i)return{stages:[],outputIds:[]};const s=r.split("|").map(h=>h.trim()).filter(Boolean),l=[];let o=[],c=JSON.parse(JSON.stringify(i));return s.forEach(h=>{const d=h.split(/\s+/),g=d[0].toLowerCase(),m=d.slice(1);let y=[...o],b="",x="success";try{if(g==="select"){const w=m.join(" ");if(w==="*")y=[...c.tables.map(S=>S.id),...(c.domains||[]).map(S=>S.id)];else if(w){const S=new RegExp("^"+w.replace(/\*/g,".*")+"$","i"),k=c.tables.filter(M=>M.id===w||S.test(M.id)||S.test(M.name)).map(M=>M.id),E=(c.domains||[]).filter(M=>M.id===w||S.test(M.id)||S.test(M.name)).map(M=>M.id);y=[...k,...E]}else y=[];y.length>0?(b=`Matched ${y.length} objects`,x="success"):(x="error",b=`No objects matched "${w}"`)}else if(g==="selected")y=[...a],b=`Using ${y.length} selected tables`,x="success";else if(g==="mv"){const w=d.findIndex(k=>k.toLowerCase()==="to"),S=w>-1?d.slice(w+1).join(" "):m.join(" ");!o||o.length===0?(x="error",b='No tables to move. Add a "select" stage.'):S?(c.domains||[]).some(E=>E.id===S)?(c.domains=(c.domains||[]).map(E=>{const M=E.tables.filter(R=>!o.includes(R));return E.id===S?{...E,tables:Array.from(new Set([...M,...o]))}:{...E,tables:M}}),o.forEach(E=>{c.layout&&(c.layout[E]={x:20,y:20})}),b=`Move ${o.length} to ${S}`,x="success"):(x="error",b=`Domain "${S}" not found`):(x="active",b="Waiting for domain...")}else if(g==="stack"||g==="v"||g==="h"){const w=g==="v"||m.includes("v")||m.includes("vertical")?"vertical":"horizontal",S=o.map(E=>({id:E,pos:c.layout?.[E]||{x:0,y:0}}));w==="vertical"?S.sort((E,M)=>E.pos.y-M.pos.y):S.sort((E,M)=>E.pos.x-M.pos.x);const k=S.length>0?S[0].pos:{x:0,y:0};S.forEach((E,M)=>{c.layout&&(c.layout[E.id]={x:w==="vertical"?k.x:k.x+M*280,y:w==="vertical"?k.y+M*320:k.y})}),b=`Stacked ${o.length} ${w}`,x="success"}else if(g==="delete"){const w=o.filter(k=>c.tables.some(E=>E.id===k)),S=o.filter(k=>(c.domains||[]).some(E=>E.id===k));if(c.tables=c.tables.filter(k=>!w.includes(k.id)),c.domains=(c.domains||[]).filter(k=>!S.includes(k.id)),c.lineage=(c.lineage??[]).filter(k=>!w.includes(k.from)&&!w.includes(k.to)),S.length>0&&c.layout){const k={...c.layout};Object.keys(k).forEach(E=>{if(S.includes(k[E].parentId)){const{parentId:M,...R}=k[E];k[E]=R}S.includes(E)&&delete k[E]}),c.layout=k}y=[],b=`Deleted ${w.length} tables and ${S.length} domains`,x="success"}else if(g==="clear")c.domains=(c.domains||[]).map(w=>({...w,tables:w.tables.filter(S=>!o.includes(S))})),b=`Cleared domain for ${o.length} tables`,x="success";else if(g==="add"){const w=m[0]?.toLowerCase(),S=m.slice(1).join(" "),k=E=>{const M=E.toLowerCase().replace(/\s+/g,"_");let R=M||`new_${w}_${Date.now()}`,O=1;const N=B=>c.tables.some(D=>D.id===B)||(c.domains||[]).some(D=>D.id===B);for(;N(R);)R=`${M}_${O}`,O++;return R};if(w==="table"){const E=k(S);c.tables.push({id:E,name:S||"NEW_TABLE",columns:[{id:"id",logical:{name:"ID",type:"Integer",isPrimaryKey:!0}}]}),c.layout||(c.layout={}),c.layout[E]={x:400,y:300},b=`Added table ${E}`,x="success"}else if(w==="domain"){const E=k(S);c.domains.push({id:E,name:S||"NEW_DOMAIN",tables:[],color:"rgba(59, 130, 246, 0.05)"}),c.layout||(c.layout={}),c.layout[E]={x:400,y:300,width:600,height:400},b=`Added domain ${E}`,x="success"}}else x="error",b=`Unknown command: ${g}`}catch{x="error",b="Execution error"}l.push({command:g,args:m,inputIds:o,outputIds:y,status:x,message:b}),o=y}),!n&&l.length>0&&l.every(h=>h.status==="success")&&(t({schema:Ia(c)}),e().syncToYamlInput(),e().saveSchema()),{stages:l,outputIds:o}},toggleTableSelection:r=>{const{selectedTableId:n}=e();t(n===r?{selectedTableId:null,isDetailPanelMinimized:!0}:{selectedTableId:r,selectedEdgeId:null,selectedAnnotationId:null})},toggleEdgeSelection:r=>{const{selectedEdgeId:n}=e();t(n===r?{selectedEdgeId:null}:{selectedEdgeId:r,selectedTableId:null,selectedAnnotationId:null})},toggleAnnotationSelection:r=>{const{selectedAnnotationId:n}=e();t(n===r?{selectedAnnotationId:null}:{selectedAnnotationId:r,selectedTableId:null,selectedEdgeId:null})},addAnnotation:(r,n,i)=>{const{schema:a}=e();if(!a)return;const s=`note_${Date.now()}`,l={id:s,targetId:n,targetType:i,text:"New Note",type:"sticky",offset:r},o={...a,annotations:[...a.annotations||[],l]};t({schema:Ia(o),selectedAnnotationId:s,selectedTableId:null,selectedEdgeId:null}),n||e().setFocusNodeId(s),e().syncToYamlInput(),e().saveSchema()},updateAnnotation:(r,n)=>{const{schema:i}=e();if(!i||!i.annotations)return;const a=i.annotations.map(s=>s.id===r?{...s,...n}:s);t({schema:{...i,annotations:a}}),e().syncToYamlInput(),e().saveSchema()},removeAnnotation:r=>{const{schema:n}=e();if(!n||!n.annotations)return;const i=n.annotations.filter(a=>a.id!==r);t({schema:{...n,annotations:i},selectedAnnotationId:null}),e().syncToYamlInput(),e().saveSchema()},fetchAvailableFiles:async()=>{const r=window.__MODSCAPE_DATA__;if(r?.models){const n=r.models.map(i=>({slug:i.slug,name:i.name,path:""}));t({availableFiles:n});return}try{const i=await(await fetch("/api/files")).json();t({availableFiles:i})}catch(n){console.error("Failed to fetch files:",n)}},setCurrentModel:async r=>{Ko&&(clearTimeout(Ko),Ko=null),t({isModelLoading:!0});try{const n=window.__MODSCAPE_DATA__;let i;n?.models?i=n.models.find(l=>l.slug===r)?.schema:i=await(await fetch(`/api/model?model=${r}`)).json(),t({schema:Ia(i),currentModelSlug:r,selectedTableId:null,selectedEdgeId:null,selectedAnnotationId:null,error:null,isModelLoading:!1}),e().syncToYamlInput();const a=new URLSearchParams(window.location.search);a.set("model",r),window.history.replaceState(null,"",`${window.location.pathname}?${a.toString()}`)}catch(n){console.error("Failed to set model:",n),t({isModelLoading:!1})}},getSelectedTable:()=>{const{schema:r,selectedTableId:n}=e();return!r||!n?null:r.tables.find(i=>i.id===n)||null},getSelectedDomain:()=>{const{schema:r,selectedTableId:n}=e();return!r||!n||!r.domains?null:r.domains.find(i=>i.id===n)||null},getSelectedRelationship:()=>{const{schema:r,selectedEdgeId:n}=e();if(!r||!n)return null;if(n.startsWith("lin-")){const s=n.lastIndexOf("-"),l=parseInt(n.slice(s+1)),o=r.lineage?.[l];return o?{relationship:{from:{table:o.from},to:{table:o.to},type:"lineage"},index:l,kind:"lineage"}:null}if(!n.startsWith("er-"))return null;const i=parseInt(n.split("-")[1]),a=r.relationships?.[i];return a?{relationship:a,index:i,kind:"er"}:null},getSelectedAnnotation:()=>{const{schema:r,selectedAnnotationId:n}=e();return!r||!n||!r.annotations?null:r.annotations.find(i=>i.id===n)||null}})),xD=t=>Symbol.iterator in t,wD=t=>"entries"in t,SD=(t,e)=>{const r=t instanceof Map?t:new Map(t.entries()),n=e instanceof Map?e:new Map(e.entries());if(r.size!==n.size)return!1;for(const[i,a]of r)if(!n.has(i)||!Object.is(a,n.get(i)))return!1;return!0},aG=(t,e)=>{const r=t[Symbol.iterator](),n=e[Symbol.iterator]();let i=r.next(),a=n.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=r.next(),a=n.next()}return!!i.done&&!!a.done};function sG(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:xD(t)&&xD(e)?wD(t)&&wD(e)?SD(t,e):aG(t,e):SD({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function so(t){const e=uf.useRef(void 0);return r=>{const n=t(r);return sG(e.current,n)?e.current:e.current=n}}const RT={fact:{color:"#f87171",icon:"📊",label:"FACT"},dimension:{color:"#60a5fa",icon:"🏷️",label:"DIM"},hub:{color:"#fbbf24",icon:"🌐",label:"HUB"},link:{color:"#34d399",icon:"🔗",label:"LINK"},satellite:{color:"#a78bfa",icon:"🛰️",label:"SAT"},mart:{color:"#f5700b",icon:"📈",label:"MART"},table:{color:"#64748b",icon:"📋",label:"TABLE"}};function vq(t){let r=(t.appearance?.type?RT[t.appearance.type]:null)?.label||"";const n=t.appearance?.sub_type,i=t.appearance?.scd;if(t.appearance?.type==="fact"&&n?r=`FACT (${{transaction:"Trans.",periodic:"Periodic",accumulating:"Accum.",factless:"Factless"}[n]||n})`:t.appearance?.type&&n?r=`${t.appearance.type.toUpperCase()} (${n})`:t.appearance?.type&&(r=t.appearance.type.toUpperCase()),i){const a=`SCD ${i.replace("type","T")}`;r=r?`${r} / ${a}`:a}return r}function lG(t){switch(t){case"one-to-many":return"1..N";case"many-to-one":return"N..1";case"many-to-many":return"N..N";case"one-to-one":return"1..1";default:return""}}function oG(t){const e=[],r=new Map;t.domains?.forEach(l=>{l.tables.forEach(o=>{r.set(o,l.id)})});const n=280,i=200,a=3;t.tables.forEach((l,o)=>{const c=t.layout?.[l.id],h=o%a,d=Math.floor(o/a),g=c?.x??h*(n+40),m=c?.y??d*(i+40),y=l.appearance?.type?RT[l.appearance.type]:null,b=l.appearance?.color||y?.color||"#334155";e.push({data:{id:l.id,table:l,domainId:r.get(l.id)??null,typeColor:b,typeLabel:vq(l),typeIcon:l.appearance?.icon||y?.icon||""},position:{x:g,y:m}})});const s=new Set(t.tables.map(l=>l.id));return t.lineage?.forEach((l,o)=>{!s.has(l.from)||!s.has(l.to)||e.push({data:{id:`lin-${l.from}-${l.to}-${o}`,source:l.from,target:l.to,kind:"lineage"},classes:"lineage-edge"})}),t.relationships?.forEach((l,o)=>{!s.has(l.from.table)||!s.has(l.to.table)||e.push({data:{id:`er-${o}`,source:l.from.table,target:l.to.table,kind:"er",label:lG(l.type),fromColumn:l.from.column??null,toColumn:l.to.column??null,relType:l.type??null},classes:"er-edge"})}),e}const by=6,uG=({table:t,isSelected:e,isDimmed:r,isHighlighted:n,isHovered:i,isPendingSource:a,isConnectMode:s,zoom:l,theme:o,hoveredColumnId:c,isCompact:h})=>{const d=t.appearance?.type?RT[t.appearance.type]:null,g=t.appearance?.color||d?.color||"#334155",m=t.appearance?.icon||d?.icon||"",y=vq(t),b=t.columns&&t.columns.length>0,x=l<.35,w=x||h,S=a?"#22c55e":e?"#3b82f6":i?g:s?"#22c55e":"var(--border-main)",k=a?"0 0 0 3px #22c55e, 0 0 20px 6px rgba(34,197,94,0.5)":e?"0 0 0 3px #3b82f6, 0 0 16px 4px rgba(59, 130, 246, 0.45)":i?`0 0 0 2px ${g}, 0 0 20px 6px ${g}80`:n?"0 0 12px 3px rgba(59, 130, 246, 0.35)":s?"0 0 0 1px rgba(34,197,94,0.4)":o==="dark"?"0 4px 6px -1px rgba(0, 0, 0, 0.3)":"0 4px 12px -2px rgba(0, 0, 0, 0.1)";return A.jsxs("div",{"data-testid":"table-node","data-table-id":t.id,style:{width:"100%",height:"100%",minWidth:"220px",position:"relative",cursor:"default",opacity:r?.15:1,transition:"opacity 0.2s ease-in-out",userSelect:"none"},children:[a&&A.jsx("div",{style:{position:"absolute",top:"-10px",right:"8px",padding:"0 6px",height:"14px",backgroundColor:"#22c55e",color:"#fff",fontSize:"8px",fontWeight:900,borderRadius:"4px",display:"flex",alignItems:"center",letterSpacing:"0.05em",textTransform:"uppercase",zIndex:2,pointerEvents:"none"},children:"FROM"}),y&&A.jsx("div",{style:{position:"absolute",top:"-12px",left:"12px",height:"14px",padding:"0 6px",backgroundColor:g,color:"#ffffff",fontSize:"8px",fontWeight:900,borderRadius:"4px 4px 0 0",display:"flex",alignItems:"center",justifyContent:"center",textTransform:"uppercase",letterSpacing:"0.05em",boxShadow:"0 -2px 4px rgba(0,0,0,0.1)",zIndex:1,pointerEvents:"none"},children:y}),A.jsxs("div",{style:{width:"100%",height:"100%",backgroundColor:"var(--node-bg)",borderLeft:`2px solid ${S}`,borderRight:`2px solid ${S}`,borderBottom:`2px solid ${S}`,borderTop:`4px solid ${g}`,borderRadius:"8px",overflow:"hidden",color:"var(--text-primary)",boxShadow:k,fontFamily:"sans-serif",display:"flex",flexDirection:"column",transition:"border-color 0.2s, box-shadow 0.2s"},children:[A.jsxs("div",{style:{padding:x?"8px 10px":"12px",backgroundColor:o==="dark"?"rgba(15, 23, 42, 0.8)":"rgba(241, 245, 249, 0.9)",borderBottom:b&&!w?"1px solid var(--border-main)":"none",flexShrink:0,cursor:"grab",display:"flex",flexDirection:"column",gap:"2px"},children:[A.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[m&&A.jsx("span",{style:{fontSize:x?"14px":"18px"},children:m}),A.jsx("div",{style:{fontSize:x?"12px":"16px",fontWeight:800,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-all"},children:t.name})]}),!x&&A.jsxs(A.Fragment,{children:[t.logical_name&&t.logical_name!==t.name&&A.jsx("div",{style:{fontSize:"11px",fontWeight:500,color:"var(--text-secondary)",paddingLeft:m?"26px":"0",opacity:.8},children:t.logical_name}),A.jsx("div",{title:t.physical_name||t.id,style:{fontSize:"9px",color:o==="dark"?"#94a3b8":"#64748b",fontFamily:"monospace",letterSpacing:"0.02em",paddingLeft:m?"26px":"0",marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},children:t.physical_name||t.id})]})]}),!w&&b&&A.jsx("div",{style:{padding:0,overflowY:"auto",flex:1,cursor:"default"},children:A.jsx("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"11px"},children:A.jsxs("tbody",{children:[t.columns.slice(0,by).map((E,M)=>{const R=E.logical?.name||E.id,O=E.physical?.name||E.id,N=R!==O;return A.jsxs("tr",{style:{borderBottom:"1px solid var(--border-main)",backgroundColor:c===E.id?o==="dark"?"rgba(30, 58, 138, 0.6)":"rgba(191, 219, 254, 0.4)":"transparent"},children:[A.jsx("td",{style:{padding:"6px 12px",fontWeight:500,color:"var(--text-primary)"},children:A.jsxs("div",{style:{display:"flex",alignItems:"flex-start"},children:[A.jsxs("span",{style:{color:"var(--text-secondary)",marginRight:"6px",fontSize:"9px",fontFamily:"monospace",width:"14px",textAlign:"right",opacity:.6,marginTop:"2px"},children:[M+1,"."]}),A.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0},children:[A.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",overflow:"hidden"},children:[E.logical?.isPrimaryKey&&A.jsx("span",{style:{color:"#eab308"},children:"🔑"}),E.logical?.isForeignKey&&A.jsx("span",{style:{opacity:.8},children:"🔩"}),E.logical?.isPartitionKey&&A.jsx("span",{style:{opacity:.8},children:"📂"}),E.logical?.isMetadata&&A.jsx("span",{style:{opacity:.8},title:"Metadata/Audit Column",children:"🕒"}),E.logical?.additivity==="fully"&&A.jsx("span",{style:{color:"#4ade80"},title:"Fully Additive",children:"Σ"}),E.logical?.additivity==="semi"&&A.jsx("span",{style:{color:"#fbbf24"},title:"Semi-Additive",children:"Σ~"}),E.logical?.additivity==="non"&&A.jsx("span",{style:{color:"#f87171"},title:"Non-Additive",children:"⊘"}),A.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:E.logical?.description||R,children:R})]}),N&&A.jsx("div",{style:{fontSize:"8px",fontFamily:"monospace",opacity:.6,marginTop:"1px",paddingLeft:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:O,children:O})]})]})}),A.jsx("td",{style:{padding:"6px 12px",textAlign:"right",fontStyle:"italic",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"120px",verticalAlign:"top",opacity:.8},children:E.logical?.type||"Unknown"})]},E.id)}),t.columns.length>by&&A.jsx("tr",{children:A.jsxs("td",{colSpan:2,style:{padding:"4px 12px",fontSize:"10px",color:"var(--text-secondary)",textAlign:"center",opacity:.6},children:["+",t.columns.length-by," more"]})})]})})})]})]})},cG=ve.memo(uG);function rk(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function fG(t){if(Array.isArray(t))return t}function hG(t){if(Array.isArray(t))return rk(t)}function sl(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function dG(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,yq(n.key),n)}}function ll(t,e,r){return e&&dG(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function Yn(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=DT(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(o){throw o},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
41
41
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,s=!0,l=!1;return{s:function(){r=r.call(t)},n:function(){var o=r.next();return s=o.done,o},e:function(o){l=!0,a=o},f:function(){try{s||r.return==null||r.return()}finally{if(l)throw a}}}}function mq(t,e,r){return(e=yq(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pG(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function gG(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,i,a,s,l=[],o=!0,c=!1;try{if(a=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;o=!1}else for(;!(o=(n=a.call(r)).done)&&(l.push(n.value),l.length!==e);o=!0);}catch(h){c=!0,i=h}finally{try{if(!o&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return l}}function vG(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
42
42
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mG(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
43
43
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rr(t,e){return fG(t)||gG(t,e)||DT(t,e)||vG()}function fg(t){return hG(t)||pG(t)||DT(t)||mG()}function yG(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function yq(t){var e=yG(t,"string");return typeof e=="symbol"?e:e+""}function qr(t){"@babel/helpers - typeof";return qr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},qr(t)}function DT(t,e){if(t){if(typeof t=="string")return rk(t,e);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rk(t,e):void 0}}var Lr=typeof window>"u"?null:window,CD=Lr?Lr.navigator:null;Lr&&Lr.document;var bG=qr(""),bq=qr({}),xG=qr(function(){}),wG=typeof HTMLElement>"u"?"undefined":qr(HTMLElement),fh=function(e){return e&&e.instanceString&&hr(e.instanceString)?e.instanceString():null},lt=function(e){return e!=null&&qr(e)==bG},hr=function(e){return e!=null&&qr(e)===xG},Zt=function(e){return!fi(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},Bt=function(e){return e!=null&&qr(e)===bq&&!Zt(e)&&e.constructor===Object},SG=function(e){return e!=null&&qr(e)===bq},qe=function(e){return e!=null&&qr(e)===qr(1)&&!isNaN(e)},CG=function(e){return qe(e)&&Math.floor(e)===e},hg=function(e){if(wG!=="undefined")return e!=null&&e instanceof HTMLElement},fi=function(e){return hh(e)||xq(e)},hh=function(e){return fh(e)==="collection"&&e._private.single},xq=function(e){return fh(e)==="collection"&&!e._private.single},_T=function(e){return fh(e)==="core"},wq=function(e){return fh(e)==="stylesheet"},kG=function(e){return fh(e)==="event"},Ys=function(e){return e==null?!0:!!(e===""||e.match(/^\s+$/))},TG=function(e){return typeof HTMLElement>"u"?!1:e instanceof HTMLElement},EG=function(e){return Bt(e)&&qe(e.x1)&&qe(e.x2)&&qe(e.y1)&&qe(e.y2)},AG=function(e){return SG(e)&&hr(e.then)},OG=function(){return CD&&CD.userAgent.match(/msie|trident|edge/i)},Bu=function(e,r){r||(r=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return"undefined";for(var a=[],s=0;s<arguments.length;s++)a.push(arguments[s]);return a.join("$")});var n=function(){var a=this,s=arguments,l,o=r.apply(a,s),c=n.cache;return(l=c[o])||(l=c[o]=e.apply(a,s)),l};return n.cache={},n},NT=Bu(function(t){return t.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),iv=Bu(function(t){return t.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),Sq=Bu(function(t,e){return t+e[0].toUpperCase()+e.substring(1)},function(t,e){return t+"$"+e}),kD=function(e){return Ys(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},zs=function(e,r){return e.slice(-1*r.length)===r},Ir="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",MG="rgb[a]?\\(("+Ir+"[%]?)\\s*,\\s*("+Ir+"[%]?)\\s*,\\s*("+Ir+"[%]?)(?:\\s*,\\s*("+Ir+"))?\\)",RG="rgb[a]?\\((?:"+Ir+"[%]?)\\s*,\\s*(?:"+Ir+"[%]?)\\s*,\\s*(?:"+Ir+"[%]?)(?:\\s*,\\s*(?:"+Ir+"))?\\)",DG="hsl[a]?\\(("+Ir+")\\s*,\\s*("+Ir+"[%])\\s*,\\s*("+Ir+"[%])(?:\\s*,\\s*("+Ir+"))?\\)",_G="hsl[a]?\\((?:"+Ir+")\\s*,\\s*(?:"+Ir+"[%])\\s*,\\s*(?:"+Ir+"[%])(?:\\s*,\\s*(?:"+Ir+"))?\\)",NG="\\#[0-9a-fA-F]{3}",BG="\\#[0-9a-fA-F]{6}",Cq=function(e,r){return e<r?-1:e>r?1:0},LG=function(e,r){return-1*Cq(e,r)},ft=Object.assign!=null?Object.assign.bind(Object):function(t){for(var e=arguments,r=1;r<e.length;r++){var n=e[r];if(n!=null)for(var i=Object.keys(n),a=0;a<i.length;a++){var s=i[a];t[s]=n[s]}}return t},PG=function(e){if(!(!(e.length===4||e.length===7)||e[0]!=="#")){var r=e.length===4,n,i,a,s=16;return r?(n=parseInt(e[1]+e[1],s),i=parseInt(e[2]+e[2],s),a=parseInt(e[3]+e[3],s)):(n=parseInt(e[1]+e[2],s),i=parseInt(e[3]+e[4],s),a=parseInt(e[5]+e[6],s)),[n,i,a]}},zG=function(e){var r,n,i,a,s,l,o,c;function h(y,b,x){return x<0&&(x+=1),x>1&&(x-=1),x<1/6?y+(b-y)*6*x:x<1/2?b:x<2/3?y+(b-y)*(2/3-x)*6:y}var d=new RegExp("^"+DG+"$").exec(e);if(d){if(n=parseInt(d[1]),n<0?n=(360- -1*n%360)%360:n>360&&(n=n%360),n/=360,i=parseFloat(d[2]),i<0||i>100||(i=i/100,a=parseFloat(d[3]),a<0||a>100)||(a=a/100,s=d[4],s!==void 0&&(s=parseFloat(s),s<0||s>1)))return;if(i===0)l=o=c=Math.round(a*255);else{var g=a<.5?a*(1+i):a+i-a*i,m=2*a-g;l=Math.round(255*h(m,g,n+1/3)),o=Math.round(255*h(m,g,n)),c=Math.round(255*h(m,g,n-1/3))}r=[l,o,c,s]}return r},IG=function(e){var r,n=new RegExp("^"+MG+"$").exec(e);if(n){r=[];for(var i=[],a=1;a<=3;a++){var s=n[a];if(s[s.length-1]==="%"&&(i[a]=!0),s=parseFloat(s),i[a]&&(s=s/100*255),s<0||s>255)return;r.push(Math.floor(s))}var l=i[1]||i[2]||i[3],o=i[1]&&i[2]&&i[3];if(l&&!o)return;var c=n[4];if(c!==void 0){if(c=parseFloat(c),c<0||c>1)return;r.push(c)}}return r},qG=function(e){return jG[e.toLowerCase()]},kq=function(e){return(Zt(e)?e:null)||qG(e)||PG(e)||IG(e)||zG(e)},jG={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Tq=function(e){for(var r=e.map,n=e.keys,i=n.length,a=0;a<i;a++){var s=n[a];if(Bt(s))throw Error("Tried to set map with object key");a<n.length-1?(r[s]==null&&(r[s]={}),r=r[s]):r[s]=e.value}},Eq=function(e){for(var r=e.map,n=e.keys,i=n.length,a=0;a<i;a++){var s=n[a];if(Bt(s))throw Error("Tried to get map with object key");if(r=r[s],r==null)return r}return r},Zd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var xy,TD;function ph(){if(TD)return xy;TD=1;function t(e){var r=typeof e;return e!=null&&(r=="object"||r=="function")}return xy=t,xy}var wy,ED;function FG(){if(ED)return wy;ED=1;var t=typeof Zd=="object"&&Zd&&Zd.Object===Object&&Zd;return wy=t,wy}var Sy,AD;function av(){if(AD)return Sy;AD=1;var t=FG(),e=typeof self=="object"&&self&&self.Object===Object&&self,r=t||e||Function("return this")();return Sy=r,Sy}var Cy,OD;function HG(){if(OD)return Cy;OD=1;var t=av(),e=function(){return t.Date.now()};return Cy=e,Cy}var ky,MD;function VG(){if(MD)return ky;MD=1;var t=/\s/;function e(r){for(var n=r.length;n--&&t.test(r.charAt(n)););return n}return ky=e,ky}var Ty,RD;function UG(){if(RD)return Ty;RD=1;var t=VG(),e=/^\s+/;function r(n){return n&&n.slice(0,t(n)+1).replace(e,"")}return Ty=r,Ty}var Ey,DD;function BT(){if(DD)return Ey;DD=1;var t=av(),e=t.Symbol;return Ey=e,Ey}var Ay,_D;function $G(){if(_D)return Ay;_D=1;var t=BT(),e=Object.prototype,r=e.hasOwnProperty,n=e.toString,i=t?t.toStringTag:void 0;function a(s){var l=r.call(s,i),o=s[i];try{s[i]=void 0;var c=!0}catch{}var h=n.call(s);return c&&(l?s[i]=o:delete s[i]),h}return Ay=a,Ay}var Oy,ND;function GG(){if(ND)return Oy;ND=1;var t=Object.prototype,e=t.toString;function r(n){return e.call(n)}return Oy=r,Oy}var My,BD;function Aq(){if(BD)return My;BD=1;var t=BT(),e=$G(),r=GG(),n="[object Null]",i="[object Undefined]",a=t?t.toStringTag:void 0;function s(l){return l==null?l===void 0?i:n:a&&a in Object(l)?e(l):r(l)}return My=s,My}var Ry,LD;function YG(){if(LD)return Ry;LD=1;function t(e){return e!=null&&typeof e=="object"}return Ry=t,Ry}var Dy,PD;function gh(){if(PD)return Dy;PD=1;var t=Aq(),e=YG(),r="[object Symbol]";function n(i){return typeof i=="symbol"||e(i)&&t(i)==r}return Dy=n,Dy}var _y,zD;function XG(){if(zD)return _y;zD=1;var t=UG(),e=ph(),r=gh(),n=NaN,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt;function o(c){if(typeof c=="number")return c;if(r(c))return n;if(e(c)){var h=typeof c.valueOf=="function"?c.valueOf():c;c=e(h)?h+"":h}if(typeof c!="string")return c===0?c:+c;c=t(c);var d=a.test(c);return d||s.test(c)?l(c.slice(2),d?2:8):i.test(c)?n:+c}return _y=o,_y}var Ny,ID;function WG(){if(ID)return Ny;ID=1;var t=ph(),e=HG(),r=XG(),n="Expected a function",i=Math.max,a=Math.min;function s(l,o,c){var h,d,g,m,y,b,x=0,w=!1,S=!1,k=!0;if(typeof l!="function")throw new TypeError(n);o=r(o)||0,t(c)&&(w=!!c.leading,S="maxWait"in c,g=S?i(r(c.maxWait)||0,o):g,k="trailing"in c?!!c.trailing:k);function E(z){var H=h,$=d;return h=d=void 0,x=z,m=l.apply($,H),m}function M(z){return x=z,y=setTimeout(N,o),w?E(z):m}function R(z){var H=z-b,$=z-x,q=o-H;return S?a(q,g-$):q}function O(z){var H=z-b,$=z-x;return b===void 0||H>=o||H<0||S&&$>=g}function N(){var z=e();if(O(z))return B(z);y=setTimeout(N,R(z))}function B(z){return y=void 0,k&&h?E(z):(h=d=void 0,m)}function D(){y!==void 0&&clearTimeout(y),x=0,h=b=d=y=void 0}function _(){return y===void 0?m:B(e())}function P(){var z=e(),H=O(z);if(h=arguments,d=this,b=z,H){if(y===void 0)return M(b);if(S)return clearTimeout(y),y=setTimeout(N,o),E(b)}return y===void 0&&(y=setTimeout(N,o)),m}return P.cancel=D,P.flush=_,P}return Ny=s,Ny}var QG=WG(),vh=dh(QG),By=Lr?Lr.performance:null,Oq=By&&By.now?function(){return By.now()}:function(){return Date.now()},KG=(function(){if(Lr){if(Lr.requestAnimationFrame)return function(t){Lr.requestAnimationFrame(t)};if(Lr.mozRequestAnimationFrame)return function(t){Lr.mozRequestAnimationFrame(t)};if(Lr.webkitRequestAnimationFrame)return function(t){Lr.webkitRequestAnimationFrame(t)};if(Lr.msRequestAnimationFrame)return function(t){Lr.msRequestAnimationFrame(t)}}return function(t){t&&setTimeout(function(){t(Oq())},1e3/60)}})(),dg=function(e){return KG(e)},Ya=Oq,Pl=9261,Mq=65599,lu=5381,Rq=function(e){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Pl,n=r,i;i=e.next(),!i.done;)n=n*Mq+i.value|0;return n},Pf=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Pl;return r*Mq+e|0},zf=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:lu;return(r<<5)+r+e|0},ZG=function(e,r){return e*2097152+r},Ds=function(e){return e[0]*2097152+e[1]},Jd=function(e,r){return[Pf(e[0],r[0]),zf(e[1],r[1])]},qD=function(e,r){var n={value:0,done:!1},i=0,a=e.length,s={next:function(){return i<a?n.value=e[i++]:n.done=!0,n}};return Rq(s,r)},Ql=function(e,r){var n={value:0,done:!1},i=0,a=e.length,s={next:function(){return i<a?n.value=e.charCodeAt(i++):n.done=!0,n}};return Rq(s,r)},Dq=function(){return JG(arguments)},JG=function(e){for(var r,n=0;n<e.length;n++){var i=e[n];n===0?r=Ql(i):r=Ql(i,r)}return r};function eY(t,e,r,n,i){var a=i*Math.PI/180,s=Math.cos(a)*(t-r)-Math.sin(a)*(e-n)+r,l=Math.sin(a)*(t-r)+Math.cos(a)*(e-n)+n;return{x:s,y:l}}var tY=function(e,r,n,i,a,s){return{x:(e-n)*a+n,y:(r-i)*s+i}};function rY(t,e,r){if(r===0)return t;var n=(e.x1+e.x2)/2,i=(e.y1+e.y2)/2,a=e.w/e.h,s=1/a,l=eY(t.x,t.y,n,i,r),o=tY(l.x,l.y,n,i,a,s);return{x:o.x,y:o.y}}var jD=!0,nY=console.warn!=null,iY=console.trace!=null,LT=Number.MAX_SAFE_INTEGER||9007199254740991,_q=function(){return!0},pg=function(){return!1},FD=function(){return 0},PT=function(){},ur=function(e){throw new Error(e)},Nq=function(e){if(e!==void 0)jD=!!e;else return jD},jt=function(e){Nq()&&(nY?console.warn(e):(console.log(e),iY&&console.trace()))},aY=function(e){return ft({},e)},la=function(e){return e==null?e:Zt(e)?e.slice():Bt(e)?aY(e):e},sY=function(e){return e.slice()},Bq=function(e,r){for(r=e="";e++<36;r+=e*51&52?(e^15?8^Math.random()*(e^20?16:4):4).toString(16):"-");return r},lY={},Lq=function(){return lY},cn=function(e){var r=Object.keys(e);return function(n){for(var i={},a=0;a<r.length;a++){var s=r[a],l=n?.[s];i[s]=l===void 0?e[s]:l}return i}},Xs=function(e,r,n){for(var i=e.length-1;i>=0;i--)e[i]===r&&e.splice(i,1)},zT=function(e){e.splice(0,e.length)},oY=function(e,r){for(var n=0;n<r.length;n++){var i=r[n];e.push(i)}},Fn=function(e,r,n){return n&&(r=Sq(n,r)),e[r]},qa=function(e,r,n,i){n&&(r=Sq(n,r)),e[r]=i},uY=(function(){function t(){sl(this,t),this._obj={}}return ll(t,[{key:"set",value:function(r,n){return this._obj[r]=n,this}},{key:"delete",value:function(r){return this._obj[r]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(r){return this._obj[r]!==void 0}},{key:"get",value:function(r){return this._obj[r]}}])})(),Ua=typeof Map<"u"?Map:uY,cY="undefined",fY=(function(){function t(e){if(sl(this,t),this._obj=Object.create(null),this.size=0,e!=null){var r;e.instanceString!=null&&e.instanceString()===this.instanceString()?r=e.toArray():r=e;for(var n=0;n<r.length;n++)this.add(r[n])}}return ll(t,[{key:"instanceString",value:function(){return"set"}},{key:"add",value:function(r){var n=this._obj;n[r]!==1&&(n[r]=1,this.size++)}},{key:"delete",value:function(r){var n=this._obj;n[r]===1&&(n[r]=0,this.size--)}},{key:"clear",value:function(){this._obj=Object.create(null)}},{key:"has",value:function(r){return this._obj[r]===1}},{key:"toArray",value:function(){var r=this;return Object.keys(this._obj).filter(function(n){return r.has(n)})}},{key:"forEach",value:function(r,n){return this.toArray().forEach(r,n)}}])})(),$u=(typeof Set>"u"?"undefined":qr(Set))!==cY?Set:fY,sv=function(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(e===void 0||r===void 0||!_T(e)){ur("An element must have a core reference and parameters set");return}var i=r.group;if(i==null&&(r.data&&r.data.source!=null&&r.data.target!=null?i="edges":i="nodes"),i!=="nodes"&&i!=="edges"){ur("An element must be of type `nodes` or `edges`; you specified `"+i+"`");return}this.length=1,this[0]=this;var a=this._private={cy:e,single:!0,data:r.data||{},position:r.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:i,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!r.selected,selectable:r.selectable===void 0?!0:!!r.selectable,locked:!!r.locked,grabbed:!1,grabbable:r.grabbable===void 0?!0:!!r.grabbable,pannable:r.pannable===void 0?i==="edges":!!r.pannable,active:!1,classes:new $u,animation:{current:[],queue:[]},rscratch:{},scratch:r.scratch||{},edges:[],children:[],parent:r.parent&&r.parent.isNode()?r.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(a.position.x==null&&(a.position.x=0),a.position.y==null&&(a.position.y=0),r.renderedPosition){var s=r.renderedPosition,l=e.pan(),o=e.zoom();a.position={x:(s.x-l.x)/o,y:(s.y-l.y)/o}}var c=[];Zt(r.classes)?c=r.classes:lt(r.classes)&&(c=r.classes.split(/\s+/));for(var h=0,d=c.length;h<d;h++){var g=c[h];!g||g===""||a.classes.add(g)}this.createEmitter(),(n===void 0||n)&&this.restore();var m=r.style||r.css;m&&(jt("Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead."),this.style(m))},HD=function(e){return e={bfs:e.bfs||!e.dfs,dfs:e.dfs||!e.bfs},function(n,i,a){var s;Bt(n)&&!fi(n)&&(s=n,n=s.roots||s.root,i=s.visit,a=s.directed),a=arguments.length===2&&!hr(i)?i:a,i=hr(i)?i:function(){};for(var l=this._private.cy,o=n=lt(n)?this.filter(n):n,c=[],h=[],d={},g={},m={},y=0,b,x=this.byGroup(),w=x.nodes,S=x.edges,k=0;k<o.length;k++){var E=o[k],M=E.id();E.isNode()&&(c.unshift(E),e.bfs&&(m[M]=!0,h.push(E)),g[M]=0)}for(var R=function(){var z=e.bfs?c.shift():c.pop(),H=z.id();if(e.dfs){if(m[H])return 0;m[H]=!0,h.push(z)}var $=g[H],q=d[H],V=q!=null?q.source():null,X=q!=null?q.target():null,ee=q==null?void 0:z.same(V)?X[0]:V[0],te;if(te=i(z,q,ee,y++,$),te===!0)return b=z,1;if(te===!1)return 1;for(var I=z.connectedEdges().filter(function(Z){return(!a||Z.source().same(z))&&S.has(Z)}),G=0;G<I.length;G++){var re=I[G],Y=re.connectedNodes().filter(function(Z){return!Z.same(z)&&w.has(Z)}),W=Y.id();Y.length!==0&&!m[W]&&(Y=Y[0],c.push(Y),e.bfs&&(m[W]=!0,h.push(Y)),d[W]=re,g[W]=g[H]+1)}},O;c.length!==0&&(O=R(),!(O!==0&&O===1)););for(var N=l.collection(),B=0;B<h.length;B++){var D=h[B],_=d[D.id()];_!=null&&N.push(_),N.push(D)}return{path:l.collection(N),found:l.collection(b)}}},If={breadthFirstSearch:HD({bfs:!0}),depthFirstSearch:HD({dfs:!0})};If.bfs=If.breadthFirstSearch;If.dfs=If.depthFirstSearch;var Pp={exports:{}},hY=Pp.exports,VD;function dY(){return VD||(VD=1,(function(t,e){(function(){var r,n,i,a,s,l,o,c,h,d,g,m,y,b,x;i=Math.floor,d=Math.min,n=function(w,S){return w<S?-1:w>S?1:0},h=function(w,S,k,E,M){var R;if(k==null&&(k=0),M==null&&(M=n),k<0)throw new Error("lo must be non-negative");for(E==null&&(E=w.length);k<E;)R=i((k+E)/2),M(S,w[R])<0?E=R:k=R+1;return[].splice.apply(w,[k,k-k].concat(S)),S},l=function(w,S,k){return k==null&&(k=n),w.push(S),b(w,0,w.length-1,k)},s=function(w,S){var k,E;return S==null&&(S=n),k=w.pop(),w.length?(E=w[0],w[0]=k,x(w,0,S)):E=k,E},c=function(w,S,k){var E;return k==null&&(k=n),E=w[0],w[0]=S,x(w,0,k),E},o=function(w,S,k){var E;return k==null&&(k=n),w.length&&k(w[0],S)<0&&(E=[w[0],S],S=E[0],w[0]=E[1],x(w,0,k)),S},a=function(w,S){var k,E,M,R,O,N;for(S==null&&(S=n),R=(function(){N=[];for(var B=0,D=i(w.length/2);0<=D?B<D:B>D;0<=D?B++:B--)N.push(B);return N}).apply(this).reverse(),O=[],E=0,M=R.length;E<M;E++)k=R[E],O.push(x(w,k,S));return O},y=function(w,S,k){var E;if(k==null&&(k=n),E=w.indexOf(S),E!==-1)return b(w,0,E,k),x(w,E,k)},g=function(w,S,k){var E,M,R,O,N;if(k==null&&(k=n),M=w.slice(0,S),!M.length)return M;for(a(M,k),N=w.slice(S),R=0,O=N.length;R<O;R++)E=N[R],o(M,E,k);return M.sort(k).reverse()},m=function(w,S,k){var E,M,R,O,N,B,D,_,P;if(k==null&&(k=n),S*10<=w.length){if(R=w.slice(0,S).sort(k),!R.length)return R;for(M=R[R.length-1],D=w.slice(S),O=0,B=D.length;O<B;O++)E=D[O],k(E,M)<0&&(h(R,E,0,null,k),R.pop(),M=R[R.length-1]);return R}for(a(w,k),P=[],N=0,_=d(S,w.length);0<=_?N<_:N>_;0<=_?++N:--N)P.push(s(w,k));return P},b=function(w,S,k,E){var M,R,O;for(E==null&&(E=n),M=w[k];k>S;){if(O=k-1>>1,R=w[O],E(M,R)<0){w[k]=R,k=O;continue}break}return w[k]=M},x=function(w,S,k){var E,M,R,O,N;for(k==null&&(k=n),M=w.length,N=S,R=w[S],E=2*S+1;E<M;)O=E+1,O<M&&!(k(w[E],w[O])<0)&&(E=O),w[S]=w[E],S=E,E=2*S+1;return w[S]=R,b(w,N,S,k)},r=(function(){w.push=l,w.pop=s,w.replace=c,w.pushpop=o,w.heapify=a,w.updateItem=y,w.nlargest=g,w.nsmallest=m;function w(S){this.cmp=S??n,this.nodes=[]}return w.prototype.push=function(S){return l(this.nodes,S,this.cmp)},w.prototype.pop=function(){return s(this.nodes,this.cmp)},w.prototype.peek=function(){return this.nodes[0]},w.prototype.contains=function(S){return this.nodes.indexOf(S)!==-1},w.prototype.replace=function(S){return c(this.nodes,S,this.cmp)},w.prototype.pushpop=function(S){return o(this.nodes,S,this.cmp)},w.prototype.heapify=function(){return a(this.nodes,this.cmp)},w.prototype.updateItem=function(S){return y(this.nodes,S,this.cmp)},w.prototype.clear=function(){return this.nodes=[]},w.prototype.empty=function(){return this.nodes.length===0},w.prototype.size=function(){return this.nodes.length},w.prototype.clone=function(){var S;return S=new w,S.nodes=this.nodes.slice(0),S},w.prototype.toArray=function(){return this.nodes.slice(0)},w.prototype.insert=w.prototype.push,w.prototype.top=w.prototype.peek,w.prototype.front=w.prototype.peek,w.prototype.has=w.prototype.contains,w.prototype.copy=w.prototype.clone,w})(),(function(w,S){return t.exports=S()})(this,function(){return r})}).call(hY)})(Pp)),Pp.exports}var Ly,UD;function pY(){return UD||(UD=1,Ly=dY()),Ly}var gY=pY(),mh=dh(gY),vY=cn({root:null,weight:function(e){return 1},directed:!1}),mY={dijkstra:function(e){if(!Bt(e)){var r=arguments;e={root:r[0],weight:r[1],directed:r[2]}}var n=vY(e),i=n.root,a=n.weight,s=n.directed,l=this,o=a,c=lt(i)?this.filter(i)[0]:i[0],h={},d={},g={},m=this.byGroup(),y=m.nodes,b=m.edges;b.unmergeBy(function($){return $.isLoop()});for(var x=function(q){return h[q.id()]},w=function(q,V){h[q.id()]=V,S.updateItem(q)},S=new mh(function($,q){return x($)-x(q)}),k=0;k<y.length;k++){var E=y[k];h[E.id()]=E.same(c)?0:1/0,S.push(E)}for(var M=function(q,V){for(var X=(s?q.edgesTo(V):q.edgesWith(V)).intersect(b),ee=1/0,te,I=0;I<X.length;I++){var G=X[I],re=o(G);(re<ee||!te)&&(ee=re,te=G)}return{edge:te,dist:ee}};S.size()>0;){var R=S.pop(),O=x(R),N=R.id();if(g[N]=O,O!==1/0)for(var B=R.neighborhood().intersect(y),D=0;D<B.length;D++){var _=B[D],P=_.id(),z=M(R,_),H=O+z.dist;H<x(_)&&(w(_,H),d[P]={node:R,edge:z.edge})}}return{distanceTo:function(q){var V=lt(q)?y.filter(q)[0]:q[0];return g[V.id()]},pathTo:function(q){var V=lt(q)?y.filter(q)[0]:q[0],X=[],ee=V,te=ee.id();if(V.length>0)for(X.unshift(V);d[te];){var I=d[te];X.unshift(I.edge),X.unshift(I.node),ee=I.node,te=ee.id()}return l.spawn(X)}}}},yY={kruskal:function(e){e=e||function(k){return 1};for(var r=this.byGroup(),n=r.nodes,i=r.edges,a=n.length,s=new Array(a),l=n,o=function(E){for(var M=0;M<s.length;M++){var R=s[M];if(R.has(E))return M}},c=0;c<a;c++)s[c]=this.spawn(n[c]);for(var h=i.sort(function(k,E){return e(k)-e(E)}),d=0;d<h.length;d++){var g=h[d],m=g.source()[0],y=g.target()[0],b=o(m),x=o(y),w=s[b],S=s[x];b!==x&&(l.merge(g),w.merge(S),s.splice(x,1))}return l}},bY=cn({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),xY={aStar:function(e){var r=this.cy(),n=bY(e),i=n.root,a=n.goal,s=n.heuristic,l=n.directed,o=n.weight;i=r.collection(i)[0],a=r.collection(a)[0];var c=i.id(),h=a.id(),d={},g={},m={},y=new mh(function(te,I){return g[te.id()]-g[I.id()]}),b=new $u,x={},w={},S=function(I,G){y.push(I),b.add(G)},k,E,M=function(){k=y.pop(),E=k.id(),b.delete(E)},R=function(I){return b.has(I)};S(i,c),d[c]=0,g[c]=s(i);for(var O=0;y.size()>0;){if(M(),O++,E===h){for(var N=[],B=a,D=h,_=w[D];N.unshift(B),_!=null&&N.unshift(_),B=x[D],B!=null;)D=B.id(),_=w[D];return{found:!0,distance:d[E],path:this.spawn(N),steps:O}}m[E]=!0;for(var P=k._private.edges,z=0;z<P.length;z++){var H=P[z];if(this.hasElementWithId(H.id())&&!(l&&H.data("source")!==E)){var $=H.source(),q=H.target(),V=$.id()!==E?$:q,X=V.id();if(this.hasElementWithId(X)&&!m[X]){var ee=d[E]+o(H);if(!R(X)){d[X]=ee,g[X]=ee+s(V),S(V,X),x[X]=k,w[X]=H;continue}ee<d[X]&&(d[X]=ee,g[X]=ee+s(V),x[X]=k,w[X]=H)}}}}return{found:!1,distance:void 0,path:void 0,steps:O}}},wY=cn({weight:function(e){return 1},directed:!1}),SY={floydWarshall:function(e){for(var r=this.cy(),n=wY(e),i=n.weight,a=n.directed,s=i,l=this.byGroup(),o=l.nodes,c=l.edges,h=o.length,d=h*h,g=function(re){return o.indexOf(re)},m=function(re){return o[re]},y=new Array(d),b=0;b<d;b++){var x=b%h,w=(b-x)/h;w===x?y[b]=0:y[b]=1/0}for(var S=new Array(d),k=new Array(d),E=0;E<c.length;E++){var M=c[E],R=M.source()[0],O=M.target()[0];if(R!==O){var N=g(R),B=g(O),D=N*h+B,_=s(M);if(y[D]>_&&(y[D]=_,S[D]=B,k[D]=M),!a){var P=B*h+N;!a&&y[P]>_&&(y[P]=_,S[P]=N,k[P]=M)}}}for(var z=0;z<h;z++)for(var H=0;H<h;H++)for(var $=H*h+z,q=0;q<h;q++){var V=H*h+q,X=z*h+q;y[$]+y[X]<y[V]&&(y[V]=y[$]+y[X],S[V]=S[$])}var ee=function(re){return(lt(re)?r.filter(re):re)[0]},te=function(re){return g(ee(re))},I={distance:function(re,Y){var W=te(re),Z=te(Y);return y[W*h+Z]},path:function(re,Y){var W=te(re),Z=te(Y),ie=m(W);if(W===Z)return ie.collection();if(S[W*h+Z]==null)return r.collection();var we=r.collection(),de=W,se;for(we.merge(ie);W!==Z;)de=W,W=S[W*h+Z],se=k[de*h+W],we.merge(se),we.merge(m(W));return we}};return I}},CY=cn({weight:function(e){return 1},directed:!1,root:null}),kY={bellmanFord:function(e){var r=this,n=CY(e),i=n.weight,a=n.directed,s=n.root,l=i,o=this,c=this.cy(),h=this.byGroup(),d=h.edges,g=h.nodes,m=g.length,y=new Ua,b=!1,x=[];s=c.collection(s)[0],d.unmergeBy(function(Me){return Me.isLoop()});for(var w=d.length,S=function(He){var $e=y.get(He.id());return $e||($e={},y.set(He.id(),$e)),$e},k=function(He){return(lt(He)?c.$(He):He)[0]},E=function(He){return S(k(He)).dist},M=function(He){for(var $e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:s,Ne=k(He),Ge=[],Ve=Ne;;){if(Ve==null)return r.spawn();var Qe=S(Ve),je=Qe.edge,dt=Qe.pred;if(Ge.unshift(Ve[0]),Ve.same($e)&&Ge.length>0)break;je!=null&&Ge.unshift(je),Ve=dt}return o.spawn(Ge)},R=0;R<m;R++){var O=g[R],N=S(O);O.same(s)?N.dist=0:N.dist=1/0,N.pred=null,N.edge=null}for(var B=!1,D=function(He,$e,Ne,Ge,Ve,Qe){var je=Ge.dist+Qe;je<Ve.dist&&!Ne.same(Ge.edge)&&(Ve.dist=je,Ve.pred=He,Ve.edge=Ne,B=!0)},_=1;_<m;_++){B=!1;for(var P=0;P<w;P++){var z=d[P],H=z.source(),$=z.target(),q=l(z),V=S(H),X=S($);D(H,$,z,V,X,q),a||D($,H,z,X,V,q)}if(!B)break}if(B)for(var ee=[],te=0;te<w;te++){var I=d[te],G=I.source(),re=I.target(),Y=l(I),W=S(G).dist,Z=S(re).dist;if(W+Y<Z||!a&&Z+Y<W)if(b||(jt("Graph contains a negative weight cycle for Bellman-Ford"),b=!0),e.findNegativeWeightCycles!==!1){var ie=[];W+Y<Z&&ie.push(G),!a&&Z+Y<W&&ie.push(re);for(var we=ie.length,de=0;de<we;de++){var se=ie[de],j=[se];j.push(S(se).edge);for(var Q=S(se).pred;j.indexOf(Q)===-1;)j.push(Q),j.push(S(Q).edge),Q=S(Q).pred;j=j.slice(j.indexOf(Q));for(var K=j[0].id(),ue=0,Se=2;Se<j.length;Se+=2)j[Se].id()<K&&(K=j[Se].id(),ue=Se);j=j.slice(ue).concat(j.slice(0,ue)),j.push(j[0]);var at=j.map(function(Me){return Me.id()}).join(",");ee.indexOf(at)===-1&&(x.push(o.spawn(j)),ee.push(at))}}else break}return{distanceTo:E,pathTo:M,hasNegativeWeightCycle:b,negativeWeightCycles:x}}},TY=Math.sqrt(2),EY=function(e,r,n){n.length===0&&ur("Karger-Stein must be run on a connected (sub)graph");for(var i=n[e],a=i[1],s=i[2],l=r[a],o=r[s],c=n,h=c.length-1;h>=0;h--){var d=c[h],g=d[1],m=d[2];(r[g]===l&&r[m]===o||r[g]===o&&r[m]===l)&&c.splice(h,1)}for(var y=0;y<c.length;y++){var b=c[y];b[1]===o?(c[y]=b.slice(),c[y][1]=l):b[2]===o&&(c[y]=b.slice(),c[y][2]=l)}for(var x=0;x<r.length;x++)r[x]===o&&(r[x]=l);return c},Py=function(e,r,n,i){for(;n>i;){var a=Math.floor(Math.random()*r.length);r=EY(a,e,r),n--}return r},AY={kargerStein:function(){var e=this,r=this.byGroup(),n=r.nodes,i=r.edges;i.unmergeBy(function(X){return X.isLoop()});var a=n.length,s=i.length,l=Math.ceil(Math.pow(Math.log(a)/Math.LN2,2)),o=Math.floor(a/TY);if(a<2){ur("At least 2 nodes are required for Karger-Stein algorithm");return}for(var c=[],h=0;h<s;h++){var d=i[h];c.push([h,n.indexOf(d.source()),n.indexOf(d.target())])}for(var g=1/0,m=[],y=new Array(a),b=new Array(a),x=new Array(a),w=function(ee,te){for(var I=0;I<a;I++)te[I]=ee[I]},S=0;S<=l;S++){for(var k=0;k<a;k++)b[k]=k;var E=Py(b,c.slice(),a,o),M=E.slice();w(b,x);var R=Py(b,E,o,2),O=Py(x,M,o,2);R.length<=O.length&&R.length<g?(g=R.length,m=R,w(b,y)):O.length<=R.length&&O.length<g&&(g=O.length,m=O,w(x,y))}for(var N=this.spawn(m.map(function(X){return i[X[0]]})),B=this.spawn(),D=this.spawn(),_=y[0],P=0;P<y.length;P++){var z=y[P],H=n[P];z===_?B.merge(H):D.merge(H)}var $=function(ee){var te=e.spawn();return ee.forEach(function(I){te.merge(I),I.connectedEdges().forEach(function(G){e.contains(G)&&!N.contains(G)&&te.merge(G)})}),te},q=[$(B),$(D)],V={cut:N,components:q,partition1:B,partition2:D};return V}},zy,OY=function(e){return{x:e.x,y:e.y}},lv=function(e,r,n){return{x:e.x*r+n.x,y:e.y*r+n.y}},Pq=function(e,r,n){return{x:(e.x-n.x)/r,y:(e.y-n.y)/r}},pu=function(e){return{x:e[0],y:e[1]}},MY=function(e){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,i=1/0,a=r;a<n;a++){var s=e[a];isFinite(s)&&(i=Math.min(s,i))}return i},RY=function(e){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,i=-1/0,a=r;a<n;a++){var s=e[a];isFinite(s)&&(i=Math.max(s,i))}return i},DY=function(e){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,i=0,a=0,s=r;s<n;s++){var l=e[s];isFinite(l)&&(i+=l,a++)}return i/a},_Y=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0;i?e=e.slice(r,n):(n<e.length&&e.splice(n,e.length-n),r>0&&e.splice(0,r));for(var l=0,o=e.length-1;o>=0;o--){var c=e[o];s?isFinite(c)||(e[o]=-1/0,l++):e.splice(o,1)}a&&e.sort(function(g,m){return g-m});var h=e.length,d=Math.floor(h/2);return h%2!==0?e[d+1+l]:(e[d-1+l]+e[d+l])/2},NY=function(e){return Math.PI*e/180},ep=function(e,r){return Math.atan2(r,e)-Math.PI/2},IT=Math.log2||function(t){return Math.log(t)/Math.log(2)},qT=function(e){return e>0?1:e<0?-1:0},Kl=function(e,r){return Math.sqrt(Nl(e,r))},Nl=function(e,r){var n=r.x-e.x,i=r.y-e.y;return n*n+i*i},BY=function(e){for(var r=e.length,n=0,i=0;i<r;i++)n+=e[i];for(var a=0;a<r;a++)e[a]=e[a]/n;return e},Yr=function(e,r,n,i){return(1-i)*(1-i)*e+2*(1-i)*i*r+i*i*n},wu=function(e,r,n,i){return{x:Yr(e.x,r.x,n.x,i),y:Yr(e.y,r.y,n.y,i)}},LY=function(e,r,n,i){var a={x:r.x-e.x,y:r.y-e.y},s=Kl(e,r),l={x:a.x/s,y:a.y/s};return n=n??0,i=i??n*s,{x:e.x+l.x*i,y:e.y+l.y*i}},qf=function(e,r,n){return Math.max(e,Math.min(n,r))},Rn=function(e){if(e==null)return{x1:1/0,y1:1/0,x2:-1/0,y2:-1/0,w:0,h:0};if(e.x1!=null&&e.y1!=null){if(e.x2!=null&&e.y2!=null&&e.x2>=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(e.w!=null&&e.h!=null&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},PY=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},zY=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},IY=function(e,r){e.x1=Math.min(e.x1,r.x1),e.x2=Math.max(e.x2,r.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,r.y1),e.y2=Math.max(e.y2,r.y2),e.h=e.y2-e.y1},zq=function(e,r,n){e.x1=Math.min(e.x1,r),e.x2=Math.max(e.x2,r),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1},zp=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.x1-=r,e.x2+=r,e.y1-=r,e.y2+=r,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},Ip=function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0],n,i,a,s;if(r.length===1)n=i=a=s=r[0];else if(r.length===2)n=a=r[0],s=i=r[1];else if(r.length===4){var l=Rr(r,4);n=l[0],i=l[1],a=l[2],s=l[3]}return e.x1-=s,e.x2+=i,e.y1-=n,e.y2+=a,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},$D=function(e,r){e.x1=r.x1,e.y1=r.y1,e.x2=r.x2,e.y2=r.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},jT=function(e,r){return!(e.x1>r.x2||r.x1>e.x2||e.x2<r.x1||r.x2<e.x1||e.y2<r.y1||r.y2<e.y1||e.y1>r.y2||r.y1>e.y2)},Is=function(e,r,n){return e.x1<=r&&r<=e.x2&&e.y1<=n&&n<=e.y2},GD=function(e,r){return Is(e,r.x,r.y)},Iq=function(e,r){return Is(e,r.x1,r.y1)&&Is(e,r.x2,r.y2)},qY=(zy=Math.hypot)!==null&&zy!==void 0?zy:function(t,e){return Math.sqrt(t*t+e*e)};function jY(t,e){if(t.length<3)throw new Error("Need at least 3 vertices");var r=function(N,B){return{x:N.x+B.x,y:N.y+B.y}},n=function(N,B){return{x:N.x-B.x,y:N.y-B.y}},i=function(N,B){return{x:N.x*B,y:N.y*B}},a=function(N,B){return N.x*B.y-N.y*B.x},s=function(N){var B=qY(N.x,N.y);return B===0?{x:0,y:0}:{x:N.x/B,y:N.y/B}},l=function(N){for(var B=0,D=0;D<N.length;D++){var _=N[D],P=N[(D+1)%N.length];B+=_.x*P.y-P.x*_.y}return B/2},o=function(N,B,D,_){var P=n(B,N),z=n(_,D),H=a(P,z);if(Math.abs(H)<1e-9)return r(N,i(P,.5));var $=a(n(D,N),z)/H;return r(N,i(P,$))},c=t.map(function(O){return{x:O.x,y:O.y}});l(c)<0&&c.reverse();for(var h=c.length,d=[],g=0;g<h;g++){var m=c[g],y=c[(g+1)%h],b=n(y,m),x=s({x:b.y,y:-b.x});d.push(x)}for(var w=d.map(function(O,N){var B=r(c[N],i(O,e)),D=r(c[(N+1)%h],i(O,e));return{p1:B,p2:D}}),S=[],k=0;k<h;k++){var E=w[(k-1+h)%h],M=w[k],R=o(E.p1,E.p2,M.p1,M.p2);S.push(R)}return S}function FY(t,e,r,n,i,a){var s=QY(t,e,r,n,i),l=jY(s,a),o=Rn();return l.forEach(function(c){return zq(o,c.x,c.y)}),o}var qq=function(e,r,n,i,a,s,l){var o=arguments.length>7&&arguments[7]!==void 0?arguments[7]:"auto",c=o==="auto"?Ws(a,s):o,h=a/2,d=s/2;c=Math.min(c,h,d);var g=c!==h,m=c!==d,y;if(g){var b=n-h+c-l,x=i-d-l,w=n+h-c+l,S=x;if(y=qs(e,r,n,i,b,x,w,S,!1),y.length>0)return y}if(m){var k=n+h+l,E=i-d+c-l,M=k,R=i+d-c+l;if(y=qs(e,r,n,i,k,E,M,R,!1),y.length>0)return y}if(g){var O=n-h+c-l,N=i+d+l,B=n+h-c+l,D=N;if(y=qs(e,r,n,i,O,N,B,D,!1),y.length>0)return y}if(m){var _=n-h-l,P=i-d+c-l,z=_,H=i+d-c+l;if(y=qs(e,r,n,i,_,P,z,H,!1),y.length>0)return y}var $;{var q=n-h+c,V=i-d+c;if($=ff(e,r,n,i,q,V,c+l),$.length>0&&$[0]<=q&&$[1]<=V)return[$[0],$[1]]}{var X=n+h-c,ee=i-d+c;if($=ff(e,r,n,i,X,ee,c+l),$.length>0&&$[0]>=X&&$[1]<=ee)return[$[0],$[1]]}{var te=n+h-c,I=i+d-c;if($=ff(e,r,n,i,te,I,c+l),$.length>0&&$[0]>=te&&$[1]>=I)return[$[0],$[1]]}{var G=n-h+c,re=i+d-c;if($=ff(e,r,n,i,G,re,c+l),$.length>0&&$[0]<=G&&$[1]>=re)return[$[0],$[1]]}return[]},HY=function(e,r,n,i,a,s,l){var o=l,c=Math.min(n,a),h=Math.max(n,a),d=Math.min(i,s),g=Math.max(i,s);return c-o<=e&&e<=h+o&&d-o<=r&&r<=g+o},VY=function(e,r,n,i,a,s,l,o,c){var h={x1:Math.min(n,l,a)-c,x2:Math.max(n,l,a)+c,y1:Math.min(i,o,s)-c,y2:Math.max(i,o,s)+c};return!(e<h.x1||e>h.x2||r<h.y1||r>h.y2)},UY=function(e,r,n,i){n-=i;var a=r*r-4*e*n;if(a<0)return[];var s=Math.sqrt(a),l=2*e,o=(-r+s)/l,c=(-r-s)/l;return[o,c]},$Y=function(e,r,n,i,a){var s=1e-5;e===0&&(e=s),r/=e,n/=e,i/=e;var l,o,c,h,d,g,m,y;if(o=(3*n-r*r)/9,c=-(27*i)+r*(9*n-2*(r*r)),c/=54,l=o*o*o+c*c,a[1]=0,m=r/3,l>0){d=c+Math.sqrt(l),d=d<0?-Math.pow(-d,1/3):Math.pow(d,1/3),g=c-Math.sqrt(l),g=g<0?-Math.pow(-g,1/3):Math.pow(g,1/3),a[0]=-m+d+g,m+=(d+g)/2,a[4]=a[2]=-m,m=Math.sqrt(3)*(-g+d)/2,a[3]=m,a[5]=-m;return}if(a[5]=a[3]=0,l===0){y=c<0?-Math.pow(-c,1/3):Math.pow(c,1/3),a[0]=-m+2*y,a[4]=a[2]=-(y+m);return}o=-o,h=o*o*o,h=Math.acos(c/Math.sqrt(h)),y=2*Math.sqrt(o),a[0]=-m+y*Math.cos(h/3),a[2]=-m+y*Math.cos((h+2*Math.PI)/3),a[4]=-m+y*Math.cos((h+4*Math.PI)/3)},GY=function(e,r,n,i,a,s,l,o){var c=1*n*n-4*n*a+2*n*l+4*a*a-4*a*l+l*l+i*i-4*i*s+2*i*o+4*s*s-4*s*o+o*o,h=9*n*a-3*n*n-3*n*l-6*a*a+3*a*l+9*i*s-3*i*i-3*i*o-6*s*s+3*s*o,d=3*n*n-6*n*a+n*l-n*e+2*a*a+2*a*e-l*e+3*i*i-6*i*s+i*o-i*r+2*s*s+2*s*r-o*r,g=1*n*a-n*n+n*e-a*e+i*s-i*i+i*r-s*r,m=[];$Y(c,h,d,g,m);for(var y=1e-7,b=[],x=0;x<6;x+=2)Math.abs(m[x+1])<y&&m[x]>=0&&m[x]<=1&&b.push(m[x]);b.push(1),b.push(0);for(var w=-1,S,k,E,M=0;M<b.length;M++)S=Math.pow(1-b[M],2)*n+2*(1-b[M])*b[M]*a+b[M]*b[M]*l,k=Math.pow(1-b[M],2)*i+2*(1-b[M])*b[M]*s+b[M]*b[M]*o,E=Math.pow(S-e,2)+Math.pow(k-r,2),w>=0?E<w&&(w=E):w=E;return w},YY=function(e,r,n,i,a,s){var l=[e-n,r-i],o=[a-n,s-i],c=o[0]*o[0]+o[1]*o[1],h=l[0]*l[0]+l[1]*l[1],d=l[0]*o[0]+l[1]*o[1],g=d*d/c;return d<0?h:g>c?(e-a)*(e-a)+(r-s)*(r-s):h-g},Hn=function(e,r,n){for(var i,a,s,l,o,c=0,h=0;h<n.length/2;h++)if(i=n[h*2],a=n[h*2+1],h+1<n.length/2?(s=n[(h+1)*2],l=n[(h+1)*2+1]):(s=n[(h+1-n.length/2)*2],l=n[(h+1-n.length/2)*2+1]),!(i==e&&s==e))if(i>=e&&e>=s||i<=e&&e<=s)o=(e-i)/(s-i)*(l-a)+a,o>r&&c++;else continue;return c%2!==0},Xa=function(e,r,n,i,a,s,l,o,c){var h=new Array(n.length),d;o[0]!=null?(d=Math.atan(o[1]/o[0]),o[0]<0?d=d+Math.PI/2:d=-d-Math.PI/2):d=o;for(var g=Math.cos(-d),m=Math.sin(-d),y=0;y<h.length/2;y++)h[y*2]=s/2*(n[y*2]*g-n[y*2+1]*m),h[y*2+1]=l/2*(n[y*2+1]*g+n[y*2]*m),h[y*2]+=i,h[y*2+1]+=a;var b;if(c>0){var x=vg(h,-c);b=gg(x)}else b=h;return Hn(e,r,b)},XY=function(e,r,n,i,a,s,l,o){for(var c=new Array(n.length*2),h=0;h<o.length;h++){var d=o[h];c[h*4+0]=d.startX,c[h*4+1]=d.startY,c[h*4+2]=d.stopX,c[h*4+3]=d.stopY;var g=Math.pow(d.cx-e,2)+Math.pow(d.cy-r,2);if(g<=Math.pow(d.radius,2))return!0}return Hn(e,r,c)},gg=function(e){for(var r=new Array(e.length/2),n,i,a,s,l,o,c,h,d=0;d<e.length/4;d++){n=e[d*4],i=e[d*4+1],a=e[d*4+2],s=e[d*4+3],d<e.length/4-1?(l=e[(d+1)*4],o=e[(d+1)*4+1],c=e[(d+1)*4+2],h=e[(d+1)*4+3]):(l=e[0],o=e[1],c=e[2],h=e[3]);var g=qs(n,i,a,s,l,o,c,h,!0);r[d*2]=g[0],r[d*2+1]=g[1]}return r},vg=function(e,r){for(var n=new Array(e.length*2),i,a,s,l,o=0;o<e.length/2;o++){i=e[o*2],a=e[o*2+1],o<e.length/2-1?(s=e[(o+1)*2],l=e[(o+1)*2+1]):(s=e[0],l=e[1]);var c=l-a,h=-(s-i),d=Math.sqrt(c*c+h*h),g=c/d,m=h/d;n[o*4]=i+g*r,n[o*4+1]=a+m*r,n[o*4+2]=s+g*r,n[o*4+3]=l+m*r}return n},WY=function(e,r,n,i,a,s){var l=n-e,o=i-r;l/=a,o/=s;var c=Math.sqrt(l*l+o*o),h=c-1;if(h<0)return[];var d=h/c;return[(n-e)*d+e,(i-r)*d+r]},Fl=function(e,r,n,i,a,s,l){return e-=a,r-=s,e/=n/2+l,r/=i/2+l,e*e+r*r<=1},ff=function(e,r,n,i,a,s,l){var o=[n-e,i-r],c=[e-a,r-s],h=o[0]*o[0]+o[1]*o[1],d=2*(c[0]*o[0]+c[1]*o[1]),g=c[0]*c[0]+c[1]*c[1]-l*l,m=d*d-4*h*g;if(m<0)return[];var y=(-d+Math.sqrt(m))/(2*h),b=(-d-Math.sqrt(m))/(2*h),x=Math.min(y,b),w=Math.max(y,b),S=[];if(x>=0&&x<=1&&S.push(x),w>=0&&w<=1&&S.push(w),S.length===0)return[];var k=S[0]*o[0]+e,E=S[0]*o[1]+r;if(S.length>1){if(S[0]==S[1])return[k,E];var M=S[1]*o[0]+e,R=S[1]*o[1]+r;return[k,E,M,R]}else return[k,E]},Iy=function(e,r,n){return r<=e&&e<=n||n<=e&&e<=r?e:e<=r&&r<=n||n<=r&&r<=e?r:n},qs=function(e,r,n,i,a,s,l,o,c){var h=e-a,d=n-e,g=l-a,m=r-s,y=i-r,b=o-s,x=g*m-b*h,w=d*m-y*h,S=b*d-g*y;if(S!==0){var k=x/S,E=w/S,M=.001,R=0-M,O=1+M;return R<=k&&k<=O&&R<=E&&E<=O?[e+k*d,r+k*y]:c?[e+k*d,r+k*y]:[]}else return x===0||w===0?Iy(e,n,l)===l?[l,o]:Iy(e,n,a)===a?[a,s]:Iy(a,l,n)===n?[n,i]:[]:[]},QY=function(e,r,n,i,a){var s=[],l=i/2,o=a/2,c=r,h=n;s.push({x:c+l*e[0],y:h+o*e[1]});for(var d=1;d<e.length/2;d++)s.push({x:c+l*e[d*2],y:h+o*e[d*2+1]});return s},jf=function(e,r,n,i,a,s,l,o){var c=[],h,d=new Array(n.length),g=!0;s==null&&(g=!1);var m;if(g){for(var y=0;y<d.length/2;y++)d[y*2]=n[y*2]*s+i,d[y*2+1]=n[y*2+1]*l+a;if(o>0){var b=vg(d,-o);m=gg(b)}else m=d}else m=n;for(var x,w,S,k,E=0;E<m.length/2;E++)x=m[E*2],w=m[E*2+1],E<m.length/2-1?(S=m[(E+1)*2],k=m[(E+1)*2+1]):(S=m[0],k=m[1]),h=qs(e,r,i,a,x,w,S,k),h.length!==0&&c.push(h[0],h[1]);return c},KY=function(e,r,n,i,a,s,l,o,c){var h=[],d,g=new Array(n.length*2);c.forEach(function(S,k){k===0?(g[g.length-2]=S.startX,g[g.length-1]=S.startY):(g[k*4-2]=S.startX,g[k*4-1]=S.startY),g[k*4]=S.stopX,g[k*4+1]=S.stopY,d=ff(e,r,i,a,S.cx,S.cy,S.radius),d.length!==0&&h.push(d[0],d[1])});for(var m=0;m<g.length/4;m++)d=qs(e,r,i,a,g[m*4],g[m*4+1],g[m*4+2],g[m*4+3],!1),d.length!==0&&h.push(d[0],d[1]);if(h.length>2){for(var y=[h[0],h[1]],b=Math.pow(y[0]-e,2)+Math.pow(y[1]-r,2),x=1;x<h.length/2;x++){var w=Math.pow(h[x*2]-e,2)+Math.pow(h[x*2+1]-r,2);w<=b&&(y[0]=h[x*2],y[1]=h[x*2+1],b=w)}return y}return h},tp=function(e,r,n){var i=[e[0]-r[0],e[1]-r[1]],a=Math.sqrt(i[0]*i[0]+i[1]*i[1]),s=(a-n)/a;return s<0&&(s=1e-5),[r[0]+s*i[0],r[1]+s*i[1]]},Tn=function(e,r){var n=nk(e,r);return n=jq(n),n},jq=function(e){for(var r,n,i=e.length/2,a=1/0,s=1/0,l=-1/0,o=-1/0,c=0;c<i;c++)r=e[2*c],n=e[2*c+1],a=Math.min(a,r),l=Math.max(l,r),s=Math.min(s,n),o=Math.max(o,n);for(var h=2/(l-a),d=2/(o-s),g=0;g<i;g++)r=e[2*g]=e[2*g]*h,n=e[2*g+1]=e[2*g+1]*d,a=Math.min(a,r),l=Math.max(l,r),s=Math.min(s,n),o=Math.max(o,n);if(s<-1)for(var m=0;m<i;m++)n=e[2*m+1]=e[2*m+1]+(-1-s);return e},nk=function(e,r){var n=1/e*2*Math.PI,i=e%2===0?Math.PI/2+n/2:Math.PI/2;i+=r;for(var a=new Array(e*2),s,l=0;l<e;l++)s=l*n+i,a[2*l]=Math.cos(s),a[2*l+1]=Math.sin(-s);return a},Ws=function(e,r){return Math.min(e/4,r/4,8)},Fq=function(e,r){return Math.min(e/10,r/10,8)},FT=function(){return 8},ZY=function(e,r,n){return[e-2*r+n,2*(r-e),e]},ik=function(e,r){return{heightOffset:Math.min(15,.05*r),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}};function qy(t,e){function r(d){for(var g=[],m=0;m<d.length;m++){var y=d[m],b=d[(m+1)%d.length],x={x:b.x-y.x,y:b.y-y.y},w={x:-x.y,y:x.x},S=Math.sqrt(w.x*w.x+w.y*w.y);g.push({x:w.x/S,y:w.y/S})}return g}function n(d,g){var m=1/0,y=-1/0,b=Yn(d),x;try{for(b.s();!(x=b.n()).done;){var w=x.value,S=w.x*g.x+w.y*g.y;m=Math.min(m,S),y=Math.max(y,S)}}catch(k){b.e(k)}finally{b.f()}return{min:m,max:y}}function i(d,g){return!(d.max<g.min||g.max<d.min)}var a=[].concat(fg(r(t)),fg(r(e))),s=Yn(a),l;try{for(s.s();!(l=s.n()).done;){var o=l.value,c=n(t,o),h=n(e,o);if(!i(c,h))return!1}}catch(d){s.e(d)}finally{s.f()}return!0}var JY=cn({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),eX={pageRank:function(e){for(var r=JY(e),n=r.dampingFactor,i=r.precision,a=r.iterations,s=r.weight,l=this._private.cy,o=this.byGroup(),c=o.nodes,h=o.edges,d=c.length,g=d*d,m=h.length,y=new Array(g),b=new Array(d),x=(1-n)/d,w=0;w<d;w++){for(var S=0;S<d;S++){var k=w*d+S;y[k]=0}b[w]=0}for(var E=0;E<m;E++){var M=h[E],R=M.data("source"),O=M.data("target");if(R!==O){var N=c.indexOfId(R),B=c.indexOfId(O),D=s(M),_=B*d+N;y[_]+=D,b[N]+=D}}for(var P=1/d+x,z=0;z<d;z++)if(b[z]===0)for(var H=0;H<d;H++){var $=H*d+z;y[$]=P}else for(var q=0;q<d;q++){var V=q*d+z;y[V]=y[V]/b[z]+x}for(var X=new Array(d),ee=new Array(d),te,I=0;I<d;I++)X[I]=1;for(var G=0;G<a;G++){for(var re=0;re<d;re++)ee[re]=0;for(var Y=0;Y<d;Y++)for(var W=0;W<d;W++){var Z=Y*d+W;ee[Y]+=y[Z]*X[W]}BY(ee),te=X,X=ee,ee=te;for(var ie=0,we=0;we<d;we++){var de=te[we]-X[we];ie+=de*de}if(ie<i)break}var se={rank:function(Q){return Q=l.collection(Q)[0],X[c.indexOf(Q)]}};return se}},YD=cn({root:null,weight:function(e){return 1},directed:!1,alpha:0}),Su={degreeCentralityNormalized:function(e){e=YD(e);var r=this.cy(),n=this.nodes(),i=n.length;if(e.directed){for(var h={},d={},g=0,m=0,y=0;y<i;y++){var b=n[y],x=b.id();e.root=b;var w=this.degreeCentrality(e);g<w.indegree&&(g=w.indegree),m<w.outdegree&&(m=w.outdegree),h[x]=w.indegree,d[x]=w.outdegree}return{indegree:function(k){return g==0?0:(lt(k)&&(k=r.filter(k)),h[k.id()]/g)},outdegree:function(k){return m===0?0:(lt(k)&&(k=r.filter(k)),d[k.id()]/m)}}}else{for(var a={},s=0,l=0;l<i;l++){var o=n[l];e.root=o;var c=this.degreeCentrality(e);s<c.degree&&(s=c.degree),a[o.id()]=c.degree}return{degree:function(k){return s===0?0:(lt(k)&&(k=r.filter(k)),a[k.id()]/s)}}}},degreeCentrality:function(e){e=YD(e);var r=this.cy(),n=this,i=e,a=i.root,s=i.weight,l=i.directed,o=i.alpha;if(a=r.collection(a)[0],l){for(var m=a.connectedEdges(),y=m.filter(function(R){return R.target().same(a)&&n.has(R)}),b=m.filter(function(R){return R.source().same(a)&&n.has(R)}),x=y.length,w=b.length,S=0,k=0,E=0;E<y.length;E++)S+=s(y[E]);for(var M=0;M<b.length;M++)k+=s(b[M]);return{indegree:Math.pow(x,1-o)*Math.pow(S,o),outdegree:Math.pow(w,1-o)*Math.pow(k,o)}}else{for(var c=a.connectedEdges().intersection(n),h=c.length,d=0,g=0;g<c.length;g++)d+=s(c[g]);return{degree:Math.pow(h,1-o)*Math.pow(d,o)}}}};Su.dc=Su.degreeCentrality;Su.dcn=Su.degreeCentralityNormalised=Su.degreeCentralityNormalized;var XD=cn({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),Cu={closenessCentralityNormalized:function(e){for(var r=XD(e),n=r.harmonic,i=r.weight,a=r.directed,s=this.cy(),l={},o=0,c=this.nodes(),h=this.floydWarshall({weight:i,directed:a}),d=0;d<c.length;d++){for(var g=0,m=c[d],y=0;y<c.length;y++)if(d!==y){var b=h.distance(m,c[y]);n?g+=1/b:g+=b}n||(g=1/g),o<g&&(o=g),l[m.id()]=g}return{closeness:function(w){return o==0?0:(lt(w)?w=s.filter(w)[0].id():w=w.id(),l[w]/o)}}},closenessCentrality:function(e){var r=XD(e),n=r.root,i=r.weight,a=r.directed,s=r.harmonic;n=this.filter(n)[0];for(var l=this.dijkstra({root:n,weight:i,directed:a}),o=0,c=this.nodes(),h=0;h<c.length;h++){var d=c[h];if(!d.same(n)){var g=l.distanceTo(d);s?o+=1/g:o+=g}}return s?o:1/o}};Cu.cc=Cu.closenessCentrality;Cu.ccn=Cu.closenessCentralityNormalised=Cu.closenessCentralityNormalized;var tX=cn({weight:null,directed:!1}),ak={betweennessCentrality:function(e){for(var r=tX(e),n=r.directed,i=r.weight,a=i!=null,s=this.cy(),l=this.nodes(),o={},c={},h=0,d={set:function(k,E){c[k]=E,E>h&&(h=E)},get:function(k){return c[k]}},g=0;g<l.length;g++){var m=l[g],y=m.id();n?o[y]=m.outgoers().nodes():o[y]=m.openNeighborhood().nodes(),d.set(y,0)}for(var b=function(){for(var k=l[x].id(),E=[],M={},R={},O={},N=new mh(function(Y,W){return O[Y]-O[W]}),B=0;B<l.length;B++){var D=l[B].id();M[D]=[],R[D]=0,O[D]=1/0}for(R[k]=1,O[k]=0,N.push(k);!N.empty();){var _=N.pop();if(E.push(_),a)for(var P=0;P<o[_].length;P++){var z=o[_][P],H=s.getElementById(_),$=void 0;H.edgesTo(z).length>0?$=H.edgesTo(z)[0]:$=z.edgesTo(H)[0];var q=i($);z=z.id(),O[z]>O[_]+q&&(O[z]=O[_]+q,N.nodes.indexOf(z)<0?N.push(z):N.updateItem(z),R[z]=0,M[z]=[]),O[z]==O[_]+q&&(R[z]=R[z]+R[_],M[z].push(_))}else for(var V=0;V<o[_].length;V++){var X=o[_][V].id();O[X]==1/0&&(N.push(X),O[X]=O[_]+1),O[X]==O[_]+1&&(R[X]=R[X]+R[_],M[X].push(_))}}for(var ee={},te=0;te<l.length;te++)ee[l[te].id()]=0;for(;E.length>0;){for(var I=E.pop(),G=0;G<M[I].length;G++){var re=M[I][G];ee[re]=ee[re]+R[re]/R[I]*(1+ee[I])}I!=l[x].id()&&d.set(I,d.get(I)+ee[I])}},x=0;x<l.length;x++)b();var w={betweenness:function(k){var E=s.collection(k).id();return d.get(E)},betweennessNormalized:function(k){if(h==0)return 0;var E=s.collection(k).id();return d.get(E)/h}};return w.betweennessNormalised=w.betweennessNormalized,w}};ak.bc=ak.betweennessCentrality;var rX=cn({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(t){return 1}]}),nX=function(e){return rX(e)},iX=function(e,r){for(var n=0,i=0;i<r.length;i++)n+=r[i](e);return n},aX=function(e,r,n){for(var i=0;i<r;i++)e[i*r+i]=n},Hq=function(e,r){for(var n,i=0;i<r;i++){n=0;for(var a=0;a<r;a++)n+=e[a*r+i];for(var s=0;s<r;s++)e[s*r+i]=e[s*r+i]/n}},sX=function(e,r,n){for(var i=new Array(n*n),a=0;a<n;a++){for(var s=0;s<n;s++)i[a*n+s]=0;for(var l=0;l<n;l++)for(var o=0;o<n;o++)i[a*n+o]+=e[a*n+l]*r[l*n+o]}return i},lX=function(e,r,n){for(var i=e.slice(0),a=1;a<n;a++)e=sX(e,i,r);return e},oX=function(e,r,n){for(var i=new Array(r*r),a=0;a<r*r;a++)i[a]=Math.pow(e[a],n);return Hq(i,r),i},uX=function(e,r,n,i){for(var a=0;a<n;a++){var s=Math.round(e[a]*Math.pow(10,i))/Math.pow(10,i),l=Math.round(r[a]*Math.pow(10,i))/Math.pow(10,i);if(s!==l)return!1}return!0},cX=function(e,r,n,i){for(var a=[],s=0;s<r;s++){for(var l=[],o=0;o<r;o++)Math.round(e[s*r+o]*1e3)/1e3>0&&l.push(n[o]);l.length!==0&&a.push(i.collection(l))}return a},fX=function(e,r){for(var n=0;n<e.length;n++)if(!r[n]||e[n].id()!==r[n].id())return!1;return!0},hX=function(e){for(var r=0;r<e.length;r++)for(var n=0;n<e.length;n++)r!=n&&fX(e[r],e[n])&&e.splice(n,1);return e},WD=function(e){for(var r=this.nodes(),n=this.edges(),i=this.cy(),a=nX(e),s={},l=0;l<r.length;l++)s[r[l].id()]=l;for(var o=r.length,c=o*o,h=new Array(c),d,g=0;g<c;g++)h[g]=0;for(var m=0;m<n.length;m++){var y=n[m],b=s[y.source().id()],x=s[y.target().id()],w=iX(y,a.attributes);h[b*o+x]+=w,h[x*o+b]+=w}aX(h,o,a.multFactor),Hq(h,o);for(var S=!0,k=0;S&&k<a.maxIterations;)S=!1,d=lX(h,o,a.expandFactor),h=oX(d,o,a.inflateFactor),uX(h,d,c,4)||(S=!0),k++;var E=cX(h,o,r,i);return E=hX(E),E},dX={markovClustering:WD,mcl:WD},pX=function(e){return e},Vq=function(e,r){return Math.abs(r-e)},QD=function(e,r,n){return e+Vq(r,n)},KD=function(e,r,n){return e+Math.pow(n-r,2)},gX=function(e){return Math.sqrt(e)},vX=function(e,r,n){return Math.max(e,Vq(r,n))},Qc=function(e,r,n,i,a){for(var s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:pX,l=i,o,c,h=0;h<e;h++)o=r(h),c=n(h),l=a(l,o,c);return s(l)},Lu={euclidean:function(e,r,n){return e>=2?Qc(e,r,n,0,KD,gX):Qc(e,r,n,0,QD)},squaredEuclidean:function(e,r,n){return Qc(e,r,n,0,KD)},manhattan:function(e,r,n){return Qc(e,r,n,0,QD)},max:function(e,r,n){return Qc(e,r,n,-1/0,vX)}};Lu["squared-euclidean"]=Lu.squaredEuclidean;Lu.squaredeuclidean=Lu.squaredEuclidean;function ov(t,e,r,n,i,a){var s;return hr(t)?s=t:s=Lu[t]||Lu.euclidean,e===0&&hr(t)?s(i,a):s(e,r,n,i,a)}var mX=cn({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),HT=function(e){return mX(e)},mg=function(e,r,n,i,a){var s=a!=="kMedoids",l=s?function(d){return n[d]}:function(d){return i[d](n)},o=function(g){return i[g](r)},c=n,h=r;return ov(e,i.length,l,o,c,h)},jy=function(e,r,n){for(var i=n.length,a=new Array(i),s=new Array(i),l=new Array(r),o=null,c=0;c<i;c++)a[c]=e.min(n[c]).value,s[c]=e.max(n[c]).value;for(var h=0;h<r;h++){o=[];for(var d=0;d<i;d++)o[d]=Math.random()*(s[d]-a[d])+a[d];l[h]=o}return l},Uq=function(e,r,n,i,a){for(var s=1/0,l=0,o=0;o<r.length;o++){var c=mg(n,e,r[o],i,a);c<s&&(s=c,l=o)}return l},$q=function(e,r,n){for(var i=[],a=null,s=0;s<r.length;s++)a=r[s],n[a.id()]===e&&i.push(a);return i},yX=function(e,r,n){return Math.abs(r-e)<=n},bX=function(e,r,n){for(var i=0;i<e.length;i++)for(var a=0;a<e[i].length;a++){var s=Math.abs(e[i][a]-r[i][a]);if(s>n)return!1}return!0},xX=function(e,r,n){for(var i=0;i<n;i++)if(e===r[i])return!0;return!1},ZD=function(e,r){var n=new Array(r);if(e.length<50)for(var i=0;i<r;i++){for(var a=e[Math.floor(Math.random()*e.length)];xX(a,n,i);)a=e[Math.floor(Math.random()*e.length)];n[i]=a}else for(var s=0;s<r;s++)n[s]=e[Math.floor(Math.random()*e.length)];return n},JD=function(e,r,n){for(var i=0,a=0;a<r.length;a++)i+=mg("manhattan",r[a],e,n,"kMedoids");return i},wX=function(e){var r=this.cy(),n=this.nodes(),i=null,a=HT(e),s=new Array(a.k),l={},o;a.testMode?typeof a.testCentroids=="number"?(a.testCentroids,o=jy(n,a.k,a.attributes)):qr(a.testCentroids)==="object"?o=a.testCentroids:o=jy(n,a.k,a.attributes):o=jy(n,a.k,a.attributes);for(var c=!0,h=0;c&&h<a.maxIterations;){for(var d=0;d<n.length;d++)i=n[d],l[i.id()]=Uq(i,o,a.distance,a.attributes,"kMeans");c=!1;for(var g=0;g<a.k;g++){var m=$q(g,n,l);if(m.length!==0){for(var y=a.attributes.length,b=o[g],x=new Array(y),w=new Array(y),S=0;S<y;S++){w[S]=0;for(var k=0;k<m.length;k++)i=m[k],w[S]+=a.attributes[S](i);x[S]=w[S]/m.length,yX(x[S],b[S],a.sensitivityThreshold)||(c=!0)}o[g]=x,s[g]=r.collection(m)}}h++}return s},SX=function(e){var r=this.cy(),n=this.nodes(),i=null,a=HT(e),s=new Array(a.k),l,o={},c,h=new Array(a.k);a.testMode?typeof a.testCentroids=="number"||(qr(a.testCentroids)==="object"?l=a.testCentroids:l=ZD(n,a.k)):l=ZD(n,a.k);for(var d=!0,g=0;d&&g<a.maxIterations;){for(var m=0;m<n.length;m++)i=n[m],o[i.id()]=Uq(i,l,a.distance,a.attributes,"kMedoids");d=!1;for(var y=0;y<l.length;y++){var b=$q(y,n,o);if(b.length!==0){h[y]=JD(l[y],b,a.attributes);for(var x=0;x<b.length;x++)c=JD(b[x],b,a.attributes),c<h[y]&&(h[y]=c,l[y]=b[x],d=!0);s[y]=r.collection(b)}}g++}return s},CX=function(e,r,n,i,a){for(var s,l,o=0;o<r.length;o++)for(var c=0;c<e.length;c++)i[o][c]=Math.pow(n[o][c],a.m);for(var h=0;h<e.length;h++)for(var d=0;d<a.attributes.length;d++){s=0,l=0;for(var g=0;g<r.length;g++)s+=i[g][h]*a.attributes[d](r[g]),l+=i[g][h];e[h][d]=s/l}},kX=function(e,r,n,i,a){for(var s=0;s<e.length;s++)r[s]=e[s].slice();for(var l,o,c,h=2/(a.m-1),d=0;d<n.length;d++)for(var g=0;g<i.length;g++){l=0;for(var m=0;m<n.length;m++)o=mg(a.distance,i[g],n[d],a.attributes,"cmeans"),c=mg(a.distance,i[g],n[m],a.attributes,"cmeans"),l+=Math.pow(o/c,h);e[g][d]=1/l}},TX=function(e,r,n,i){for(var a=new Array(n.k),s=0;s<a.length;s++)a[s]=[];for(var l,o,c=0;c<r.length;c++){l=-1/0,o=-1;for(var h=0;h<r[0].length;h++)r[c][h]>l&&(l=r[c][h],o=h);a[o].push(e[c])}for(var d=0;d<a.length;d++)a[d]=i.collection(a[d]);return a},e_=function(e){var r=this.cy(),n=this.nodes(),i=HT(e),a,s,l,o,c;o=new Array(n.length);for(var h=0;h<n.length;h++)o[h]=new Array(i.k);l=new Array(n.length);for(var d=0;d<n.length;d++)l[d]=new Array(i.k);for(var g=0;g<n.length;g++){for(var m=0,y=0;y<i.k;y++)l[g][y]=Math.random(),m+=l[g][y];for(var b=0;b<i.k;b++)l[g][b]=l[g][b]/m}s=new Array(i.k);for(var x=0;x<i.k;x++)s[x]=new Array(i.attributes.length);c=new Array(n.length);for(var w=0;w<n.length;w++)c[w]=new Array(i.k);for(var S=!0,k=0;S&&k<i.maxIterations;)S=!1,CX(s,n,l,c,i),kX(l,o,s,n,i),bX(l,o,i.sensitivityThreshold)||(S=!0),k++;return a=TX(n,l,i,r),{clusters:a,degreeOfMembership:l}},EX={kMeans:wX,kMedoids:SX,fuzzyCMeans:e_,fcm:e_},AX=cn({distance:"euclidean",linkage:"min",mode:"threshold",threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),OX={single:"min",complete:"max"},MX=function(e){var r=AX(e),n=OX[r.linkage];return n!=null&&(r.linkage=n),r},t_=function(e,r,n,i,a){for(var s=0,l=1/0,o,c=a.attributes,h=function(B,D){return ov(a.distance,c.length,function(_){return c[_](B)},function(_){return c[_](D)},B,D)},d=0;d<e.length;d++){var g=e[d].key,m=n[g][i[g]];m<l&&(s=g,l=m)}if(a.mode==="threshold"&&l>=a.threshold||a.mode==="dendrogram"&&e.length===1)return!1;var y=r[s],b=r[i[s]],x;a.mode==="dendrogram"?x={left:y,right:b,key:y.key}:x={value:y.value.concat(b.value),key:y.key},e[y.index]=x,e.splice(b.index,1),r[y.key]=x;for(var w=0;w<e.length;w++){var S=e[w];y.key===S.key?o=1/0:a.linkage==="min"?(o=n[y.key][S.key],n[y.key][S.key]>n[b.key][S.key]&&(o=n[b.key][S.key])):a.linkage==="max"?(o=n[y.key][S.key],n[y.key][S.key]<n[b.key][S.key]&&(o=n[b.key][S.key])):a.linkage==="mean"?o=(n[y.key][S.key]*y.size+n[b.key][S.key]*b.size)/(y.size+b.size):a.mode==="dendrogram"?o=h(S.value,y.value):o=h(S.value[0],y.value[0]),n[y.key][S.key]=n[S.key][y.key]=o}for(var k=0;k<e.length;k++){var E=e[k].key;if(i[E]===y.key||i[E]===b.key){for(var M=E,R=0;R<e.length;R++){var O=e[R].key;n[E][O]<n[E][M]&&(M=O)}i[E]=M}e[k].index=k}return y.key=b.key=y.index=b.index=null,!0},gu=function(e,r,n){e&&(e.value?r.push(e.value):(e.left&&gu(e.left,r),e.right&&gu(e.right,r)))},sk=function(e,r){if(!e)return"";if(e.left&&e.right){var n=sk(e.left,r),i=sk(e.right,r),a=r.add({group:"nodes",data:{id:n+","+i}});return r.add({group:"edges",data:{source:n,target:a.id()}}),r.add({group:"edges",data:{source:i,target:a.id()}}),a.id()}else if(e.value)return e.value.id()},lk=function(e,r,n){if(!e)return[];var i=[],a=[],s=[];return r===0?(e.left&&gu(e.left,i),e.right&&gu(e.right,a),s=i.concat(a),[n.collection(s)]):r===1?e.value?[n.collection(e.value)]:(e.left&&gu(e.left,i),e.right&&gu(e.right,a),[n.collection(i),n.collection(a)]):e.value?[n.collection(e.value)]:(e.left&&(i=lk(e.left,r-1,n)),e.right&&(a=lk(e.right,r-1,n)),i.concat(a))},r_=function(e){for(var r=this.cy(),n=this.nodes(),i=MX(e),a=i.attributes,s=function(k,E){return ov(i.distance,a.length,function(M){return a[M](k)},function(M){return a[M](E)},k,E)},l=[],o=[],c=[],h=[],d=0;d<n.length;d++){var g={value:i.mode==="dendrogram"?n[d]:[n[d]],key:d,index:d};l[d]=g,h[d]=g,o[d]=[],c[d]=0}for(var m=0;m<l.length;m++)for(var y=0;y<=m;y++){var b=void 0;i.mode==="dendrogram"?b=m===y?1/0:s(l[m].value,l[y].value):b=m===y?1/0:s(l[m].value[0],l[y].value[0]),o[m][y]=b,o[y][m]=b,b<o[m][c[m]]&&(c[m]=y)}for(var x=t_(l,h,o,c,i);x;)x=t_(l,h,o,c,i);var w;return i.mode==="dendrogram"?(w=lk(l[0],i.dendrogramDepth,r),i.addDendrogram&&sk(l[0],r)):(w=new Array(l.length),l.forEach(function(S,k){S.key=S.index=null,w[k]=r.collection(S.value)})),w},RX={hierarchicalClustering:r_,hca:r_},DX=cn({distance:"euclidean",preference:"median",damping:.8,maxIterations:1e3,minIterations:100,attributes:[]}),_X=function(e){var r=e.damping,n=e.preference;.5<=r&&r<1||ur("Damping must range on [0.5, 1). Got: ".concat(r));var i=["median","mean","min","max"];return i.some(function(a){return a===n})||qe(n)||ur("Preference must be one of [".concat(i.map(function(a){return"'".concat(a,"'")}).join(", "),"] or a number. Got: ").concat(n)),DX(e)},NX=function(e,r,n,i){var a=function(l,o){return i[o](l)};return-ov(e,i.length,function(s){return a(r,s)},function(s){return a(n,s)},r,n)},BX=function(e,r){var n=null;return r==="median"?n=_Y(e):r==="mean"?n=DY(e):r==="min"?n=MY(e):r==="max"?n=RY(e):n=r,n},LX=function(e,r,n){for(var i=[],a=0;a<e;a++)r[a*e+a]+n[a*e+a]>0&&i.push(a);return i},n_=function(e,r,n){for(var i=[],a=0;a<e;a++){for(var s=-1,l=-1/0,o=0;o<n.length;o++){var c=n[o];r[a*e+c]>l&&(s=c,l=r[a*e+c])}s>0&&i.push(s)}for(var h=0;h<n.length;h++)i[n[h]]=n[h];return i},PX=function(e,r,n){for(var i=n_(e,r,n),a=0;a<n.length;a++){for(var s=[],l=0;l<i.length;l++)i[l]===n[a]&&s.push(l);for(var o=-1,c=-1/0,h=0;h<s.length;h++){for(var d=0,g=0;g<s.length;g++)d+=r[s[g]*e+s[h]];d>c&&(o=h,c=d)}n[a]=s[o]}return i=n_(e,r,n),i},i_=function(e){for(var r=this.cy(),n=this.nodes(),i=_X(e),a={},s=0;s<n.length;s++)a[n[s].id()]=s;var l,o,c,h,d,g;l=n.length,o=l*l,c=new Array(o);for(var m=0;m<o;m++)c[m]=-1/0;for(var y=0;y<l;y++)for(var b=0;b<l;b++)y!==b&&(c[y*l+b]=NX(i.distance,n[y],n[b],i.attributes));h=BX(c,i.preference);for(var x=0;x<l;x++)c[x*l+x]=h;d=new Array(o);for(var w=0;w<o;w++)d[w]=0;g=new Array(o);for(var S=0;S<o;S++)g[S]=0;for(var k=new Array(l),E=new Array(l),M=new Array(l),R=0;R<l;R++)k[R]=0,E[R]=0,M[R]=0;for(var O=new Array(l*i.minIterations),N=0;N<O.length;N++)O[N]=0;var B;for(B=0;B<i.maxIterations;B++){for(var D=0;D<l;D++){for(var _=-1/0,P=-1/0,z=-1,H=0,$=0;$<l;$++)k[$]=d[D*l+$],H=g[D*l+$]+c[D*l+$],H>=_?(P=_,_=H,z=$):H>P&&(P=H);for(var q=0;q<l;q++)d[D*l+q]=(1-i.damping)*(c[D*l+q]-_)+i.damping*k[q];d[D*l+z]=(1-i.damping)*(c[D*l+z]-P)+i.damping*k[z]}for(var V=0;V<l;V++){for(var X=0,ee=0;ee<l;ee++)k[ee]=g[ee*l+V],E[ee]=Math.max(0,d[ee*l+V]),X+=E[ee];X-=E[V],E[V]=d[V*l+V],X+=E[V];for(var te=0;te<l;te++)g[te*l+V]=(1-i.damping)*Math.min(0,X-E[te])+i.damping*k[te];g[V*l+V]=(1-i.damping)*(X-E[V])+i.damping*k[V]}for(var I=0,G=0;G<l;G++){var re=g[G*l+G]+d[G*l+G]>0?1:0;O[B%i.minIterations*l+G]=re,I+=re}if(I>0&&(B>=i.minIterations-1||B==i.maxIterations-1)){for(var Y=0,W=0;W<l;W++){M[W]=0;for(var Z=0;Z<i.minIterations;Z++)M[W]+=O[Z*l+W];(M[W]===0||M[W]===i.minIterations)&&Y++}if(Y===l)break}}for(var ie=LX(l,d,g),we=PX(l,c,ie),de={},se=0;se<ie.length;se++)de[ie[se]]=[];for(var j=0;j<n.length;j++){var Q=a[n[j].id()],K=we[Q];K!=null&&de[K].push(n[j])}for(var ue=new Array(ie.length),Se=0;Se<ie.length;Se++)ue[Se]=r.collection(de[ie[Se]]);return ue},zX={affinityPropagation:i_,ap:i_},IX=cn({root:void 0,directed:!1}),qX={hierholzer:function(e){if(!Bt(e)){var r=arguments;e={root:r[0],directed:r[1]}}var n=IX(e),i=n.root,a=n.directed,s=this,l=!1,o,c,h;i&&(h=lt(i)?this.filter(i)[0].id():i[0].id());var d={},g={};a?s.forEach(function(S){var k=S.id();if(S.isNode()){var E=S.indegree(!0),M=S.outdegree(!0),R=E-M,O=M-E;R==1?o?l=!0:o=k:O==1?c?l=!0:c=k:(O>1||R>1)&&(l=!0),d[k]=[],S.outgoers().forEach(function(N){N.isEdge()&&d[k].push(N.id())})}else g[k]=[void 0,S.target().id()]}):s.forEach(function(S){var k=S.id();if(S.isNode()){var E=S.degree(!0);E%2&&(o?c?l=!0:c=k:o=k),d[k]=[],S.connectedEdges().forEach(function(M){return d[k].push(M.id())})}else g[k]=[S.source().id(),S.target().id()]});var m={found:!1,trail:void 0};if(l)return m;if(c&&o)if(a){if(h&&c!=h)return m;h=c}else{if(h&&c!=h&&o!=h)return m;h||(h=c)}else h||(h=s[0].id());var y=function(k){for(var E=k,M=[k],R,O,N;d[E].length;)R=d[E].shift(),O=g[R][0],N=g[R][1],E!=N?(d[N]=d[N].filter(function(B){return B!=R}),E=N):!a&&E!=O&&(d[O]=d[O].filter(function(B){return B!=R}),E=O),M.unshift(R),M.unshift(E);return M},b=[],x=[];for(x=y(h);x.length!=1;)d[x[0]].length==0?(b.unshift(s.getElementById(x.shift())),b.unshift(s.getElementById(x.shift()))):x=y(x.shift()).concat(x);b.unshift(s.getElementById(x.shift()));for(var w in d)if(d[w].length)return m;return m.found=!0,m.trail=this.spawn(b,!0),m}},rp=function(){var e=this,r={},n=0,i=0,a=[],s=[],l={},o=function(g,m){for(var y=s.length-1,b=[],x=e.spawn();s[y].x!=g||s[y].y!=m;)b.push(s.pop().edge),y--;b.push(s.pop().edge),b.forEach(function(w){var S=w.connectedNodes().intersection(e);x.merge(w),S.forEach(function(k){var E=k.id(),M=k.connectedEdges().intersection(e);x.merge(k),r[E].cutVertex?x.merge(M.filter(function(R){return R.isLoop()})):x.merge(M)})}),a.push(x)},c=function(g,m,y){g===y&&(i+=1),r[m]={id:n,low:n++,cutVertex:!1};var b=e.getElementById(m).connectedEdges().intersection(e);if(b.size()===0)a.push(e.spawn(e.getElementById(m)));else{var x,w,S,k;b.forEach(function(E){x=E.source().id(),w=E.target().id(),S=x===m?w:x,S!==y&&(k=E.id(),l[k]||(l[k]=!0,s.push({x:m,y:S,edge:E})),S in r?r[m].low=Math.min(r[m].low,r[S].id):(c(g,S,m),r[m].low=Math.min(r[m].low,r[S].low),r[m].id<=r[S].low&&(r[m].cutVertex=!0,o(m,S))))})}};e.forEach(function(d){if(d.isNode()){var g=d.id();g in r||(i=0,c(g,g),r[g].cutVertex=i>1)}});var h=Object.keys(r).filter(function(d){return r[d].cutVertex}).map(function(d){return e.getElementById(d)});return{cut:e.spawn(h),components:a}},jX={hopcroftTarjanBiconnected:rp,htbc:rp,htb:rp,hopcroftTarjanBiconnectedComponents:rp},np=function(){var e=this,r={},n=0,i=[],a=[],s=e.spawn(e),l=function(c){a.push(c),r[c]={index:n,low:n++,explored:!1};var h=e.getElementById(c).connectedEdges().intersection(e);if(h.forEach(function(b){var x=b.target().id();x!==c&&(x in r||l(x),r[x].explored||(r[c].low=Math.min(r[c].low,r[x].low)))}),r[c].index===r[c].low){for(var d=e.spawn();;){var g=a.pop();if(d.merge(e.getElementById(g)),r[g].low=r[c].index,r[g].explored=!0,g===c)break}var m=d.edgesWith(d),y=d.merge(m);i.push(y),s=s.difference(y)}};return e.forEach(function(o){if(o.isNode()){var c=o.id();c in r||l(c)}}),{cut:s,components:i}},FX={tarjanStronglyConnected:np,tsc:np,tscc:np,tarjanStronglyConnectedComponents:np},Gq={};[If,mY,yY,xY,SY,kY,AY,eX,Su,Cu,ak,dX,EX,RX,zX,qX,jX,FX].forEach(function(t){ft(Gq,t)});var Yq=0,Xq=1,Wq=2,ji=function(e){if(!(this instanceof ji))return new ji(e);this.id="Thenable/1.0.7",this.state=Yq,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},typeof e=="function"&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};ji.prototype={fulfill:function(e){return a_(this,Xq,"fulfillValue",e)},reject:function(e){return a_(this,Wq,"rejectReason",e)},then:function(e,r){var n=this,i=new ji;return n.onFulfilled.push(l_(e,i,"fulfill")),n.onRejected.push(l_(r,i,"reject")),Qq(n),i.proxy}};var a_=function(e,r,n,i){return e.state===Yq&&(e.state=r,e[n]=i,Qq(e)),e},Qq=function(e){e.state===Xq?s_(e,"onFulfilled",e.fulfillValue):e.state===Wq&&s_(e,"onRejected",e.rejectReason)},s_=function(e,r,n){if(e[r].length!==0){var i=e[r];e[r]=[];var a=function(){for(var l=0;l<i.length;l++)i[l](n)};typeof setImmediate=="function"?setImmediate(a):setTimeout(a,0)}},l_=function(e,r,n){return function(i){if(typeof e!="function")r[n].call(r,i);else{var a;try{a=e(i)}catch(s){r.reject(s);return}Kq(r,a)}}},Kq=function(e,r){if(e===r||e.proxy===r){e.reject(new TypeError("cannot resolve promise with itself"));return}var n;if(qr(r)==="object"&&r!==null||typeof r=="function")try{n=r.then}catch(a){e.reject(a);return}if(typeof n=="function"){var i=!1;try{n.call(r,function(a){i||(i=!0,a===r?e.reject(new TypeError("circular thenable chain")):Kq(e,a))},function(a){i||(i=!0,e.reject(a))})}catch(a){i||e.reject(a)}return}e.fulfill(r)};ji.all=function(t){return new ji(function(e,r){for(var n=new Array(t.length),i=0,a=function(o,c){n[o]=c,i++,i===t.length&&e(n)},s=0;s<t.length;s++)(function(l){var o=t[l],c=o!=null&&o.then!=null;if(c)o.then(function(d){a(l,d)},function(d){r(d)});else{var h=o;a(l,h)}})(s)})};ji.resolve=function(t){return new ji(function(e,r){e(t)})};ji.reject=function(t){return new ji(function(e,r){r(t)})};var Gu=typeof Promise<"u"?Promise:ji,ok=function(e,r,n){var i=_T(e),a=!i,s=this._private=ft({duration:1e3},r,n);if(s.target=e,s.style=s.style||s.css,s.started=!1,s.playing=!1,s.hooked=!1,s.applying=!1,s.progress=0,s.completes=[],s.frames=[],s.complete&&hr(s.complete)&&s.completes.push(s.complete),a){var l=e.position();s.startPosition=s.startPosition||{x:l.x,y:l.y},s.startStyle=s.startStyle||e.cy().style().getAnimationStartStyle(e,s.style)}if(i){var o=e.pan();s.startPan={x:o.x,y:o.y},s.startZoom=e.zoom()}this.length=1,this[0]=this},Zl=ok.prototype;ft(Zl,{instanceString:function(){return"animation"},hook:function(){var e=this._private;if(!e.hooked){var r,n=e.target._private.animation;e.queue?r=n.queue:r=n.current,r.push(this),fi(e.target)&&e.target.cy().addToAnimationPool(e.target),e.hooked=!0}return this},play:function(){var e=this._private;return e.progress===1&&(e.progress=0),e.playing=!0,e.started=!1,e.stopped=!1,this.hook(),this},playing:function(){return this._private.playing},apply:function(){var e=this._private;return e.applying=!0,e.started=!1,e.stopped=!1,this.hook(),this},applying:function(){return this._private.applying},pause:function(){var e=this._private;return e.playing=!1,e.started=!1,this},stop:function(){var e=this._private;return e.playing=!1,e.started=!1,e.stopped=!0,this},rewind:function(){return this.progress(0)},fastforward:function(){return this.progress(1)},time:function(e){var r=this._private;return e===void 0?r.progress*r.duration:this.progress(e/r.duration)},progress:function(e){var r=this._private,n=r.playing;return e===void 0?r.progress:(n&&this.pause(),r.progress=e,r.started=!1,n&&this.play(),this)},completed:function(){return this._private.progress===1},reverse:function(){var e=this._private,r=e.playing;r&&this.pause(),e.progress=1-e.progress,e.started=!1;var n=function(c,h){var d=e[c];d!=null&&(e[c]=e[h],e[h]=d)};if(n("zoom","startZoom"),n("pan","startPan"),n("position","startPosition"),e.style)for(var i=0;i<e.style.length;i++){var a=e.style[i],s=a.name,l=e.startStyle[s];e.startStyle[s]=a,e.style[i]=l}return r&&this.play(),this},promise:function(e){var r=this._private,n;switch(e){case"frame":n=r.frames;break;default:case"complete":case"completed":n=r.completes}return new Gu(function(i,a){n.push(function(){i()})})}});Zl.complete=Zl.completed;Zl.run=Zl.play;Zl.running=Zl.playing;var HX={animated:function(){return function(){var r=this,n=r.length!==void 0,i=n?r:[r],a=this._private.cy||this;if(!a.styleEnabled())return!1;var s=i[0];if(s)return s._private.animation.current.length>0}},clearQueue:function(){return function(){var r=this,n=r.length!==void 0,i=n?r:[r],a=this._private.cy||this;if(!a.styleEnabled())return this;for(var s=0;s<i.length;s++){var l=i[s];l._private.animation.queue=[]}return this}},delay:function(){return function(r,n){var i=this._private.cy||this;return i.styleEnabled()?this.animate({delay:r,duration:r,complete:n}):this}},delayAnimation:function(){return function(r,n){var i=this._private.cy||this;return i.styleEnabled()?this.animation({delay:r,duration:r,complete:n}):this}},animation:function(){return function(r,n){var i=this,a=i.length!==void 0,s=a?i:[i],l=this._private.cy||this,o=!a,c=!o;if(!l.styleEnabled())return this;var h=l.style();r=ft({},r,n);var d=Object.keys(r).length===0;if(d)return new ok(s[0],r);switch(r.duration===void 0&&(r.duration=400),r.duration){case"slow":r.duration=600;break;case"fast":r.duration=200;break}if(c&&(r.style=h.getPropsList(r.style||r.css),r.css=void 0),c&&r.renderedPosition!=null){var g=r.renderedPosition,m=l.pan(),y=l.zoom();r.position=Pq(g,y,m)}if(o&&r.panBy!=null){var b=r.panBy,x=l.pan();r.pan={x:x.x+b.x,y:x.y+b.y}}var w=r.center||r.centre;if(o&&w!=null){var S=l.getCenterPan(w.eles,r.zoom);S!=null&&(r.pan=S)}if(o&&r.fit!=null){var k=r.fit,E=l.getFitViewport(k.eles||k.boundingBox,k.padding);E!=null&&(r.pan=E.pan,r.zoom=E.zoom)}if(o&&Bt(r.zoom)){var M=l.getZoomedViewport(r.zoom);M!=null?(M.zoomed&&(r.zoom=M.zoom),M.panned&&(r.pan=M.pan)):r.zoom=null}return new ok(s[0],r)}},animate:function(){return function(r,n){var i=this,a=i.length!==void 0,s=a?i:[i],l=this._private.cy||this;if(!l.styleEnabled())return this;n&&(r=ft({},r,n));for(var o=0;o<s.length;o++){var c=s[o],h=c.animated()&&(r.queue===void 0||r.queue),d=c.animation(r,h?{queue:!0}:void 0);d.play()}return this}},stop:function(){return function(r,n){var i=this,a=i.length!==void 0,s=a?i:[i],l=this._private.cy||this;if(!l.styleEnabled())return this;for(var o=0;o<s.length;o++){for(var c=s[o],h=c._private,d=h.animation.current,g=0;g<d.length;g++){var m=d[g],y=m._private;n&&(y.duration=0)}r&&(h.animation.queue=[]),n||(h.animation.current=[])}return l.notify("draw"),this}}},Fy,o_;function uv(){if(o_)return Fy;o_=1;var t=Array.isArray;return Fy=t,Fy}var Hy,u_;function VX(){if(u_)return Hy;u_=1;var t=uv(),e=gh(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function i(a,s){if(t(a))return!1;var l=typeof a;return l=="number"||l=="symbol"||l=="boolean"||a==null||e(a)?!0:n.test(a)||!r.test(a)||s!=null&&a in Object(s)}return Hy=i,Hy}var Vy,c_;function UX(){if(c_)return Vy;c_=1;var t=Aq(),e=ph(),r="[object AsyncFunction]",n="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function s(l){if(!e(l))return!1;var o=t(l);return o==n||o==i||o==r||o==a}return Vy=s,Vy}var Uy,f_;function $X(){if(f_)return Uy;f_=1;var t=av(),e=t["__core-js_shared__"];return Uy=e,Uy}var $y,h_;function GX(){if(h_)return $y;h_=1;var t=$X(),e=(function(){var n=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!e&&e in n}return $y=r,$y}var Gy,d_;function YX(){if(d_)return Gy;d_=1;var t=Function.prototype,e=t.toString;function r(n){if(n!=null){try{return e.call(n)}catch{}try{return n+""}catch{}}return""}return Gy=r,Gy}var Yy,p_;function XX(){if(p_)return Yy;p_=1;var t=UX(),e=GX(),r=ph(),n=YX(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,s=Function.prototype,l=Object.prototype,o=s.toString,c=l.hasOwnProperty,h=RegExp("^"+o.call(c).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(g){if(!r(g)||e(g))return!1;var m=t(g)?h:a;return m.test(n(g))}return Yy=d,Yy}var Xy,g_;function WX(){if(g_)return Xy;g_=1;function t(e,r){return e?.[r]}return Xy=t,Xy}var Wy,v_;function VT(){if(v_)return Wy;v_=1;var t=XX(),e=WX();function r(n,i){var a=e(n,i);return t(a)?a:void 0}return Wy=r,Wy}var Qy,m_;function cv(){if(m_)return Qy;m_=1;var t=VT(),e=t(Object,"create");return Qy=e,Qy}var Ky,y_;function QX(){if(y_)return Ky;y_=1;var t=cv();function e(){this.__data__=t?t(null):{},this.size=0}return Ky=e,Ky}var Zy,b_;function KX(){if(b_)return Zy;b_=1;function t(e){var r=this.has(e)&&delete this.__data__[e];return this.size-=r?1:0,r}return Zy=t,Zy}var Jy,x_;function ZX(){if(x_)return Jy;x_=1;var t=cv(),e="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function i(a){var s=this.__data__;if(t){var l=s[a];return l===e?void 0:l}return n.call(s,a)?s[a]:void 0}return Jy=i,Jy}var eb,w_;function JX(){if(w_)return eb;w_=1;var t=cv(),e=Object.prototype,r=e.hasOwnProperty;function n(i){var a=this.__data__;return t?a[i]!==void 0:r.call(a,i)}return eb=n,eb}var tb,S_;function eW(){if(S_)return tb;S_=1;var t=cv(),e="__lodash_hash_undefined__";function r(n,i){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=t&&i===void 0?e:i,this}return tb=r,tb}var rb,C_;function tW(){if(C_)return rb;C_=1;var t=QX(),e=KX(),r=ZX(),n=JX(),i=eW();function a(s){var l=-1,o=s==null?0:s.length;for(this.clear();++l<o;){var c=s[l];this.set(c[0],c[1])}}return a.prototype.clear=t,a.prototype.delete=e,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,rb=a,rb}var nb,k_;function rW(){if(k_)return nb;k_=1;function t(){this.__data__=[],this.size=0}return nb=t,nb}var ib,T_;function Zq(){if(T_)return ib;T_=1;function t(e,r){return e===r||e!==e&&r!==r}return ib=t,ib}var ab,E_;function fv(){if(E_)return ab;E_=1;var t=Zq();function e(r,n){for(var i=r.length;i--;)if(t(r[i][0],n))return i;return-1}return ab=e,ab}var sb,A_;function nW(){if(A_)return sb;A_=1;var t=fv(),e=Array.prototype,r=e.splice;function n(i){var a=this.__data__,s=t(a,i);if(s<0)return!1;var l=a.length-1;return s==l?a.pop():r.call(a,s,1),--this.size,!0}return sb=n,sb}var lb,O_;function iW(){if(O_)return lb;O_=1;var t=fv();function e(r){var n=this.__data__,i=t(n,r);return i<0?void 0:n[i][1]}return lb=e,lb}var ob,M_;function aW(){if(M_)return ob;M_=1;var t=fv();function e(r){return t(this.__data__,r)>-1}return ob=e,ob}var ub,R_;function sW(){if(R_)return ub;R_=1;var t=fv();function e(r,n){var i=this.__data__,a=t(i,r);return a<0?(++this.size,i.push([r,n])):i[a][1]=n,this}return ub=e,ub}var cb,D_;function lW(){if(D_)return cb;D_=1;var t=rW(),e=nW(),r=iW(),n=aW(),i=sW();function a(s){var l=-1,o=s==null?0:s.length;for(this.clear();++l<o;){var c=s[l];this.set(c[0],c[1])}}return a.prototype.clear=t,a.prototype.delete=e,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,cb=a,cb}var fb,__;function oW(){if(__)return fb;__=1;var t=VT(),e=av(),r=t(e,"Map");return fb=r,fb}var hb,N_;function uW(){if(N_)return hb;N_=1;var t=tW(),e=lW(),r=oW();function n(){this.size=0,this.__data__={hash:new t,map:new(r||e),string:new t}}return hb=n,hb}var db,B_;function cW(){if(B_)return db;B_=1;function t(e){var r=typeof e;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?e!=="__proto__":e===null}return db=t,db}var pb,L_;function hv(){if(L_)return pb;L_=1;var t=cW();function e(r,n){var i=r.__data__;return t(n)?i[typeof n=="string"?"string":"hash"]:i.map}return pb=e,pb}var gb,P_;function fW(){if(P_)return gb;P_=1;var t=hv();function e(r){var n=t(this,r).delete(r);return this.size-=n?1:0,n}return gb=e,gb}var vb,z_;function hW(){if(z_)return vb;z_=1;var t=hv();function e(r){return t(this,r).get(r)}return vb=e,vb}var mb,I_;function dW(){if(I_)return mb;I_=1;var t=hv();function e(r){return t(this,r).has(r)}return mb=e,mb}var yb,q_;function pW(){if(q_)return yb;q_=1;var t=hv();function e(r,n){var i=t(this,r),a=i.size;return i.set(r,n),this.size+=i.size==a?0:1,this}return yb=e,yb}var bb,j_;function gW(){if(j_)return bb;j_=1;var t=uW(),e=fW(),r=hW(),n=dW(),i=pW();function a(s){var l=-1,o=s==null?0:s.length;for(this.clear();++l<o;){var c=s[l];this.set(c[0],c[1])}}return a.prototype.clear=t,a.prototype.delete=e,a.prototype.get=r,a.prototype.has=n,a.prototype.set=i,bb=a,bb}var xb,F_;function vW(){if(F_)return xb;F_=1;var t=gW(),e="Expected a function";function r(n,i){if(typeof n!="function"||i!=null&&typeof i!="function")throw new TypeError(e);var a=function(){var s=arguments,l=i?i.apply(this,s):s[0],o=a.cache;if(o.has(l))return o.get(l);var c=n.apply(this,s);return a.cache=o.set(l,c)||o,c};return a.cache=new(r.Cache||t),a}return r.Cache=t,xb=r,xb}var wb,H_;function mW(){if(H_)return wb;H_=1;var t=vW(),e=500;function r(n){var i=t(n,function(s){return a.size===e&&a.clear(),s}),a=i.cache;return i}return wb=r,wb}var Sb,V_;function Jq(){if(V_)return Sb;V_=1;var t=mW(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=t(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(e,function(s,l,o,c){a.push(o?c.replace(r,"$1"):l||s)}),a});return Sb=n,Sb}var Cb,U_;function ej(){if(U_)return Cb;U_=1;function t(e,r){for(var n=-1,i=e==null?0:e.length,a=Array(i);++n<i;)a[n]=r(e[n],n,e);return a}return Cb=t,Cb}var kb,$_;function yW(){if($_)return kb;$_=1;var t=BT(),e=ej(),r=uv(),n=gh(),i=t?t.prototype:void 0,a=i?i.toString:void 0;function s(l){if(typeof l=="string")return l;if(r(l))return e(l,s)+"";if(n(l))return a?a.call(l):"";var o=l+"";return o=="0"&&1/l==-1/0?"-0":o}return kb=s,kb}var Tb,G_;function tj(){if(G_)return Tb;G_=1;var t=yW();function e(r){return r==null?"":t(r)}return Tb=e,Tb}var Eb,Y_;function rj(){if(Y_)return Eb;Y_=1;var t=uv(),e=VX(),r=Jq(),n=tj();function i(a,s){return t(a)?a:e(a,s)?[a]:r(n(a))}return Eb=i,Eb}var Ab,X_;function UT(){if(X_)return Ab;X_=1;var t=gh();function e(r){if(typeof r=="string"||t(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Ab=e,Ab}var Ob,W_;function bW(){if(W_)return Ob;W_=1;var t=rj(),e=UT();function r(n,i){i=t(i,n);for(var a=0,s=i.length;n!=null&&a<s;)n=n[e(i[a++])];return a&&a==s?n:void 0}return Ob=r,Ob}var Mb,Q_;function xW(){if(Q_)return Mb;Q_=1;var t=bW();function e(r,n,i){var a=r==null?void 0:t(r,n);return a===void 0?i:a}return Mb=e,Mb}var wW=xW(),SW=dh(wW),Rb,K_;function CW(){if(K_)return Rb;K_=1;var t=VT(),e=(function(){try{var r=t(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Rb=e,Rb}var Db,Z_;function kW(){if(Z_)return Db;Z_=1;var t=CW();function e(r,n,i){n=="__proto__"&&t?t(r,n,{configurable:!0,enumerable:!0,value:i,writable:!0}):r[n]=i}return Db=e,Db}var _b,J_;function TW(){if(J_)return _b;J_=1;var t=kW(),e=Zq(),r=Object.prototype,n=r.hasOwnProperty;function i(a,s,l){var o=a[s];(!(n.call(a,s)&&e(o,l))||l===void 0&&!(s in a))&&t(a,s,l)}return _b=i,_b}var Nb,eN;function EW(){if(eN)return Nb;eN=1;var t=9007199254740991,e=/^(?:0|[1-9]\d*)$/;function r(n,i){var a=typeof n;return i=i??t,!!i&&(a=="number"||a!="symbol"&&e.test(n))&&n>-1&&n%1==0&&n<i}return Nb=r,Nb}var Bb,tN;function AW(){if(tN)return Bb;tN=1;var t=TW(),e=rj(),r=EW(),n=ph(),i=UT();function a(s,l,o,c){if(!n(s))return s;l=e(l,s);for(var h=-1,d=l.length,g=d-1,m=s;m!=null&&++h<d;){var y=i(l[h]),b=o;if(y==="__proto__"||y==="constructor"||y==="prototype")return s;if(h!=g){var x=m[y];b=c?c(x,y,m):void 0,b===void 0&&(b=n(x)?x:r(l[h+1])?[]:{})}t(m,y,b),m=m[y]}return s}return Bb=a,Bb}var Lb,rN;function OW(){if(rN)return Lb;rN=1;var t=AW();function e(r,n,i){return r==null?r:t(r,n,i)}return Lb=e,Lb}var MW=OW(),RW=dh(MW),Pb,nN;function DW(){if(nN)return Pb;nN=1;function t(e,r){var n=-1,i=e.length;for(r||(r=Array(i));++n<i;)r[n]=e[n];return r}return Pb=t,Pb}var zb,iN;function _W(){if(iN)return zb;iN=1;var t=ej(),e=DW(),r=uv(),n=gh(),i=Jq(),a=UT(),s=tj();function l(o){return r(o)?t(o,a):n(o)?[o]:e(i(s(o)))}return zb=l,zb}var NW=_W(),BW=dh(NW),LW={data:function(e){var r={field:"data",bindingEvent:"data",allowBinding:!1,allowSetting:!1,allowGetting:!1,settingEvent:"data",settingTriggersEvent:!1,triggerFnName:"trigger",immutableKeys:{},updateStyle:!1,beforeGet:function(i){},beforeSet:function(i,a){},onSet:function(i){},canSet:function(i){return!0}};return e=ft({},r,e),function(i,a){var s=e,l=this,o=l.length!==void 0,c=o?l:[l],h=o?l[0]:l;if(lt(i)){var d=i.indexOf(".")!==-1,g=d&&BW(i);if(s.allowGetting&&a===void 0){var m;return h&&(s.beforeGet(h),g&&h._private[s.field][i]===void 0?m=SW(h._private[s.field],g):m=h._private[s.field][i]),m}else if(s.allowSetting&&a!==void 0){var y=!s.immutableKeys[i];if(y){var b=mq({},i,a);s.beforeSet(l,b);for(var x=0,w=c.length;x<w;x++){var S=c[x];s.canSet(S)&&(g&&h._private[s.field][i]===void 0?RW(S._private[s.field],g,a):S._private[s.field][i]=a)}s.updateStyle&&l.updateStyle(),s.onSet(l),s.settingTriggersEvent&&l[s.triggerFnName](s.settingEvent)}}}else if(s.allowSetting&&Bt(i)){var k=i,E,M,R=Object.keys(k);s.beforeSet(l,k);for(var O=0;O<R.length;O++){E=R[O],M=k[E];var N=!s.immutableKeys[E];if(N)for(var B=0;B<c.length;B++){var D=c[B];s.canSet(D)&&(D._private[s.field][E]=M)}}s.updateStyle&&l.updateStyle(),s.onSet(l),s.settingTriggersEvent&&l[s.triggerFnName](s.settingEvent)}else if(s.allowBinding&&hr(i)){var _=i;l.on(s.bindingEvent,_)}else if(s.allowGetting&&i===void 0){var P;return h&&(s.beforeGet(h),P=h._private[s.field]),P}return l}},removeData:function(e){var r={field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!1,immutableKeys:{}};return e=ft({},r,e),function(i){var a=e,s=this,l=s.length!==void 0,o=l?s:[s];if(lt(i)){for(var c=i.split(/\s+/),h=c.length,d=0;d<h;d++){var g=c[d];if(!Ys(g)){var m=!a.immutableKeys[g];if(m)for(var y=0,b=o.length;y<b;y++)o[y]._private[a.field][g]=void 0}}a.triggerEvent&&s[a.triggerFnName](a.event)}else if(i===void 0){for(var x=0,w=o.length;x<w;x++)for(var S=o[x]._private[a.field],k=Object.keys(S),E=0;E<k.length;E++){var M=k[E],R=!a.immutableKeys[M];R&&(S[M]=void 0)}a.triggerEvent&&s[a.triggerFnName](a.event)}return s}}},PW={eventAliasesOn:function(e){var r=e;r.addListener=r.listen=r.bind=r.on,r.unlisten=r.unbind=r.off=r.removeListener,r.trigger=r.emit,r.pon=r.promiseOn=function(n,i){var a=this,s=Array.prototype.slice.call(arguments,0);return new Gu(function(l,o){var c=function(m){a.off.apply(a,d),l(m)},h=s.concat([c]),d=h.concat([]);a.on.apply(a,h)})}}},qt={};[HX,LW,PW].forEach(function(t){ft(qt,t)});var zW={animate:qt.animate(),animation:qt.animation(),animated:qt.animated(),clearQueue:qt.clearQueue(),delay:qt.delay(),delayAnimation:qt.delayAnimation(),stop:qt.stop()},qp={classes:function(e){var r=this;if(e===void 0){var n=[];return r[0]._private.classes.forEach(function(y){return n.push(y)}),n}else Zt(e)||(e=(e||"").match(/\S+/g)||[]);for(var i=[],a=new $u(e),s=0;s<r.length;s++){for(var l=r[s],o=l._private,c=o.classes,h=!1,d=0;d<e.length;d++){var g=e[d],m=c.has(g);if(!m){h=!0;break}}h||(h=c.size!==e.length),h&&(o.classes=a,i.push(l))}return i.length>0&&this.spawn(i).updateStyle().emit("class"),r},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var r=this[0];return r!=null&&r._private.classes.has(e)},toggleClass:function(e,r){Zt(e)||(e=e.match(/\S+/g)||[]);for(var n=this,i=r===void 0,a=[],s=0,l=n.length;s<l;s++)for(var o=n[s],c=o._private.classes,h=!1,d=0;d<e.length;d++){var g=e[d],m=c.has(g),y=!1;r||i&&!m?(c.add(g),y=!0):(!r||i&&m)&&(c.delete(g),y=!0),!h&&y&&(a.push(o),h=!0)}return a.length>0&&this.spawn(a).updateStyle().emit("class"),n},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,r){var n=this;if(r==null)r=250;else if(r===0)return n;return n.addClass(e),setTimeout(function(){n.removeClass(e)},r),n}};qp.className=qp.classNames=qp.classes;var _t={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:`"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,number:Ir,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};_t.variable="(?:[\\w-.]|(?:\\\\"+_t.metaChar+"))+";_t.className="(?:[\\w-]|(?:\\\\"+_t.metaChar+"))+";_t.value=_t.string+"|"+_t.number;_t.id=_t.variable;(function(){var t,e,r;for(t=_t.comparatorOp.split("|"),r=0;r<t.length;r++)e=t[r],_t.comparatorOp+="|@"+e;for(t=_t.comparatorOp.split("|"),r=0;r<t.length;r++)e=t[r],!(e.indexOf("!")>=0)&&e!=="="&&(_t.comparatorOp+="|\\!"+e)})();var Xt=function(){return{checks:[]}},Je={GROUP:0,COLLECTION:1,FILTER:2,DATA_COMPARE:3,DATA_EXIST:4,DATA_BOOL:5,META_COMPARE:6,STATE:7,ID:8,CLASS:9,UNDIRECTED_EDGE:10,DIRECTED_EDGE:11,NODE_SOURCE:12,NODE_TARGET:13,NODE_NEIGHBOR:14,CHILD:15,DESCENDANT:16,PARENT:17,ANCESTOR:18,COMPOUND_SPLIT:19,TRUE:20},uk=[{selector:":selected",matches:function(e){return e.selected()}},{selector:":unselected",matches:function(e){return!e.selected()}},{selector:":selectable",matches:function(e){return e.selectable()}},{selector:":unselectable",matches:function(e){return!e.selectable()}},{selector:":locked",matches:function(e){return e.locked()}},{selector:":unlocked",matches:function(e){return!e.locked()}},{selector:":visible",matches:function(e){return e.visible()}},{selector:":hidden",matches:function(e){return!e.visible()}},{selector:":transparent",matches:function(e){return e.transparent()}},{selector:":grabbed",matches:function(e){return e.grabbed()}},{selector:":free",matches:function(e){return!e.grabbed()}},{selector:":removed",matches:function(e){return e.removed()}},{selector:":inside",matches:function(e){return!e.removed()}},{selector:":grabbable",matches:function(e){return e.grabbable()}},{selector:":ungrabbable",matches:function(e){return!e.grabbable()}},{selector:":animated",matches:function(e){return e.animated()}},{selector:":unanimated",matches:function(e){return!e.animated()}},{selector:":parent",matches:function(e){return e.isParent()}},{selector:":childless",matches:function(e){return e.isChildless()}},{selector:":child",matches:function(e){return e.isChild()}},{selector:":orphan",matches:function(e){return e.isOrphan()}},{selector:":nonorphan",matches:function(e){return e.isChild()}},{selector:":compound",matches:function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()}},{selector:":loop",matches:function(e){return e.isLoop()}},{selector:":simple",matches:function(e){return e.isSimple()}},{selector:":active",matches:function(e){return e.active()}},{selector:":inactive",matches:function(e){return!e.active()}},{selector:":backgrounding",matches:function(e){return e.backgrounding()}},{selector:":nonbackgrounding",matches:function(e){return!e.backgrounding()}}].sort(function(t,e){return LG(t.selector,e.selector)}),IW=(function(){for(var t={},e,r=0;r<uk.length;r++)e=uk[r],t[e.selector]=e.matches;return t})(),qW=function(e,r){return IW[e](r)},jW="("+uk.map(function(t){return t.selector}).join("|")+")",Zo=function(e){return e.replace(new RegExp("\\\\("+_t.metaChar+")","g"),function(r,n){return n})},_s=function(e,r,n){e[e.length-1]=n},ck=[{name:"group",query:!0,regex:"("+_t.group+")",populate:function(e,r,n){var i=Rr(n,1),a=i[0];r.checks.push({type:Je.GROUP,value:a==="*"?a:a+"s"})}},{name:"state",query:!0,regex:jW,populate:function(e,r,n){var i=Rr(n,1),a=i[0];r.checks.push({type:Je.STATE,value:a})}},{name:"id",query:!0,regex:"\\#("+_t.id+")",populate:function(e,r,n){var i=Rr(n,1),a=i[0];r.checks.push({type:Je.ID,value:Zo(a)})}},{name:"className",query:!0,regex:"\\.("+_t.className+")",populate:function(e,r,n){var i=Rr(n,1),a=i[0];r.checks.push({type:Je.CLASS,value:Zo(a)})}},{name:"dataExists",query:!0,regex:"\\[\\s*("+_t.variable+")\\s*\\]",populate:function(e,r,n){var i=Rr(n,1),a=i[0];r.checks.push({type:Je.DATA_EXIST,field:Zo(a)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+_t.variable+")\\s*("+_t.comparatorOp+")\\s*("+_t.value+")\\s*\\]",populate:function(e,r,n){var i=Rr(n,3),a=i[0],s=i[1],l=i[2],o=new RegExp("^"+_t.string+"$").exec(l)!=null;o?l=l.substring(1,l.length-1):l=parseFloat(l),r.checks.push({type:Je.DATA_COMPARE,field:Zo(a),operator:s,value:l})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+_t.boolOp+")\\s*("+_t.variable+")\\s*\\]",populate:function(e,r,n){var i=Rr(n,2),a=i[0],s=i[1];r.checks.push({type:Je.DATA_BOOL,field:Zo(s),operator:a})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+_t.meta+")\\s*("+_t.comparatorOp+")\\s*("+_t.number+")\\s*\\]\\]",populate:function(e,r,n){var i=Rr(n,3),a=i[0],s=i[1],l=i[2];r.checks.push({type:Je.META_COMPARE,field:Zo(a),operator:s,value:parseFloat(l)})}},{name:"nextQuery",separator:!0,regex:_t.separator,populate:function(e,r){var n=e.currentSubject,i=e.edgeCount,a=e.compoundCount,s=e[e.length-1];n!=null&&(s.subject=n,e.currentSubject=null),s.edgeCount=i,s.compoundCount=a,e.edgeCount=0,e.compoundCount=0;var l=e[e.length++]=Xt();return l}},{name:"directedEdge",separator:!0,regex:_t.directedEdge,populate:function(e,r){if(e.currentSubject==null){var n=Xt(),i=r,a=Xt();return n.checks.push({type:Je.DIRECTED_EDGE,source:i,target:a}),_s(e,r,n),e.edgeCount++,a}else{var s=Xt(),l=r,o=Xt();return s.checks.push({type:Je.NODE_SOURCE,source:l,target:o}),_s(e,r,s),e.edgeCount++,o}}},{name:"undirectedEdge",separator:!0,regex:_t.undirectedEdge,populate:function(e,r){if(e.currentSubject==null){var n=Xt(),i=r,a=Xt();return n.checks.push({type:Je.UNDIRECTED_EDGE,nodes:[i,a]}),_s(e,r,n),e.edgeCount++,a}else{var s=Xt(),l=r,o=Xt();return s.checks.push({type:Je.NODE_NEIGHBOR,node:l,neighbor:o}),_s(e,r,s),o}}},{name:"child",separator:!0,regex:_t.child,populate:function(e,r){if(e.currentSubject==null){var n=Xt(),i=Xt(),a=e[e.length-1];return n.checks.push({type:Je.CHILD,parent:a,child:i}),_s(e,r,n),e.compoundCount++,i}else if(e.currentSubject===r){var s=Xt(),l=e[e.length-1],o=Xt(),c=Xt(),h=Xt(),d=Xt();return s.checks.push({type:Je.COMPOUND_SPLIT,left:l,right:o,subject:c}),c.checks=r.checks,r.checks=[{type:Je.TRUE}],d.checks.push({type:Je.TRUE}),o.checks.push({type:Je.PARENT,parent:d,child:h}),_s(e,l,s),e.currentSubject=c,e.compoundCount++,h}else{var g=Xt(),m=Xt(),y=[{type:Je.PARENT,parent:g,child:m}];return g.checks=r.checks,r.checks=y,e.compoundCount++,m}}},{name:"descendant",separator:!0,regex:_t.descendant,populate:function(e,r){if(e.currentSubject==null){var n=Xt(),i=Xt(),a=e[e.length-1];return n.checks.push({type:Je.DESCENDANT,ancestor:a,descendant:i}),_s(e,r,n),e.compoundCount++,i}else if(e.currentSubject===r){var s=Xt(),l=e[e.length-1],o=Xt(),c=Xt(),h=Xt(),d=Xt();return s.checks.push({type:Je.COMPOUND_SPLIT,left:l,right:o,subject:c}),c.checks=r.checks,r.checks=[{type:Je.TRUE}],d.checks.push({type:Je.TRUE}),o.checks.push({type:Je.ANCESTOR,ancestor:d,descendant:h}),_s(e,l,s),e.currentSubject=c,e.compoundCount++,h}else{var g=Xt(),m=Xt(),y=[{type:Je.ANCESTOR,ancestor:g,descendant:m}];return g.checks=r.checks,r.checks=y,e.compoundCount++,m}}},{name:"subject",modifier:!0,regex:_t.subject,populate:function(e,r){if(e.currentSubject!=null&&e.currentSubject!==r)return jt("Redefinition of subject in selector `"+e.toString()+"`"),!1;e.currentSubject=r;var n=e[e.length-1],i=n.checks[0],a=i==null?null:i.type;a===Je.DIRECTED_EDGE?i.type=Je.NODE_TARGET:a===Je.UNDIRECTED_EDGE&&(i.type=Je.NODE_NEIGHBOR,i.node=i.nodes[1],i.neighbor=i.nodes[0],i.nodes=null)}}];ck.forEach(function(t){return t.regexObj=new RegExp("^"+t.regex)});var FW=function(e){for(var r,n,i,a=0;a<ck.length;a++){var s=ck[a],l=s.name,o=e.match(s.regexObj);if(o!=null){n=o,r=s,i=l;var c=o[0];e=e.substring(c.length);break}}return{expr:r,match:n,name:i,remaining:e}},HW=function(e){var r=e.match(/^\s+/);if(r){var n=r[0];e=e.substring(n.length)}return e},VW=function(e){var r=this,n=r.inputText=e,i=r[0]=Xt();for(r.length=1,n=HW(n);;){var a=FW(n);if(a.expr==null)return jt("The selector `"+e+"`is invalid"),!1;var s=a.match.slice(1),l=a.expr.populate(r,i,s);if(l===!1)return!1;if(l!=null&&(i=l),n=a.remaining,n.match(/^\s*$/))break}var o=r[r.length-1];r.currentSubject!=null&&(o.subject=r.currentSubject),o.edgeCount=r.edgeCount,o.compoundCount=r.compoundCount;for(var c=0;c<r.length;c++){var h=r[c];if(h.compoundCount>0&&h.edgeCount>0)return jt("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(h.edgeCount>1)return jt("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;h.edgeCount===1&&jt("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},UW=function(){if(this.toStringCache!=null)return this.toStringCache;for(var e=function(h){return h??""},r=function(h){return lt(h)?'"'+h+'"':e(h)},n=function(h){return" "+h+" "},i=function(h,d){var g=h.type,m=h.value;switch(g){case Je.GROUP:{var y=e(m);return y.substring(0,y.length-1)}case Je.DATA_COMPARE:{var b=h.field,x=h.operator;return"["+b+n(e(x))+r(m)+"]"}case Je.DATA_BOOL:{var w=h.operator,S=h.field;return"["+e(w)+S+"]"}case Je.DATA_EXIST:{var k=h.field;return"["+k+"]"}case Je.META_COMPARE:{var E=h.operator,M=h.field;return"[["+M+n(e(E))+r(m)+"]]"}case Je.STATE:return m;case Je.ID:return"#"+m;case Je.CLASS:return"."+m;case Je.PARENT:case Je.CHILD:return a(h.parent,d)+n(">")+a(h.child,d);case Je.ANCESTOR:case Je.DESCENDANT:return a(h.ancestor,d)+" "+a(h.descendant,d);case Je.COMPOUND_SPLIT:{var R=a(h.left,d),O=a(h.subject,d),N=a(h.right,d);return R+(R.length>0?" ":"")+O+N}case Je.TRUE:return""}},a=function(h,d){return h.checks.reduce(function(g,m,y){return g+(d===h&&y===0?"$":"")+i(m,d)},"")},s="",l=0;l<this.length;l++){var o=this[l];s+=a(o,o.subject),this.length>1&&l<this.length-1&&(s+=", ")}return this.toStringCache=s,s},$W={parse:VW,toString:UW},nj=function(e,r,n){var i,a=lt(e),s=qe(e),l=lt(n),o,c,h=!1,d=!1,g=!1;switch(r.indexOf("!")>=0&&(r=r.replace("!",""),d=!0),r.indexOf("@")>=0&&(r=r.replace("@",""),h=!0),(a||l||h)&&(o=!a&&!s?"":""+e,c=""+n),h&&(e=o=o.toLowerCase(),n=c=c.toLowerCase()),r){case"*=":i=o.indexOf(c)>=0;break;case"$=":i=o.indexOf(c,o.length-c.length)>=0;break;case"^=":i=o.indexOf(c)===0;break;case"=":i=e===n;break;case">":g=!0,i=e>n;break;case">=":g=!0,i=e>=n;break;case"<":g=!0,i=e<n;break;case"<=":g=!0,i=e<=n;break;default:i=!1;break}return d&&(e!=null||!g)&&(i=!i),i},GW=function(e,r){switch(r){case"?":return!!e;case"!":return!e;case"^":return e===void 0}},YW=function(e){return e!==void 0},$T=function(e,r){return e.data(r)},XW=function(e,r){return e[r]()},yr=[],sr=function(e,r){return e.checks.every(function(n){return yr[n.type](n,r)})};yr[Je.GROUP]=function(t,e){var r=t.value;return r==="*"||r===e.group()};yr[Je.STATE]=function(t,e){var r=t.value;return qW(r,e)};yr[Je.ID]=function(t,e){var r=t.value;return e.id()===r};yr[Je.CLASS]=function(t,e){var r=t.value;return e.hasClass(r)};yr[Je.META_COMPARE]=function(t,e){var r=t.field,n=t.operator,i=t.value;return nj(XW(e,r),n,i)};yr[Je.DATA_COMPARE]=function(t,e){var r=t.field,n=t.operator,i=t.value;return nj($T(e,r),n,i)};yr[Je.DATA_BOOL]=function(t,e){var r=t.field,n=t.operator;return GW($T(e,r),n)};yr[Je.DATA_EXIST]=function(t,e){var r=t.field;return t.operator,YW($T(e,r))};yr[Je.UNDIRECTED_EDGE]=function(t,e){var r=t.nodes[0],n=t.nodes[1],i=e.source(),a=e.target();return sr(r,i)&&sr(n,a)||sr(n,i)&&sr(r,a)};yr[Je.NODE_NEIGHBOR]=function(t,e){return sr(t.node,e)&&e.neighborhood().some(function(r){return r.isNode()&&sr(t.neighbor,r)})};yr[Je.DIRECTED_EDGE]=function(t,e){return sr(t.source,e.source())&&sr(t.target,e.target())};yr[Je.NODE_SOURCE]=function(t,e){return sr(t.source,e)&&e.outgoers().some(function(r){return r.isNode()&&sr(t.target,r)})};yr[Je.NODE_TARGET]=function(t,e){return sr(t.target,e)&&e.incomers().some(function(r){return r.isNode()&&sr(t.source,r)})};yr[Je.CHILD]=function(t,e){return sr(t.child,e)&&sr(t.parent,e.parent())};yr[Je.PARENT]=function(t,e){return sr(t.parent,e)&&e.children().some(function(r){return sr(t.child,r)})};yr[Je.DESCENDANT]=function(t,e){return sr(t.descendant,e)&&e.ancestors().some(function(r){return sr(t.ancestor,r)})};yr[Je.ANCESTOR]=function(t,e){return sr(t.ancestor,e)&&e.descendants().some(function(r){return sr(t.descendant,r)})};yr[Je.COMPOUND_SPLIT]=function(t,e){return sr(t.subject,e)&&sr(t.left,e)&&sr(t.right,e)};yr[Je.TRUE]=function(){return!0};yr[Je.COLLECTION]=function(t,e){var r=t.value;return r.has(e)};yr[Je.FILTER]=function(t,e){var r=t.value;return r(e)};var WW=function(e){var r=this;if(r.length===1&&r[0].checks.length===1&&r[0].checks[0].type===Je.ID)return e.getElementById(r[0].checks[0].value).collection();var n=function(a){for(var s=0;s<r.length;s++){var l=r[s];if(sr(l,a))return!0}return!1};return r.text()==null&&(n=function(){return!0}),e.filter(n)},QW=function(e){for(var r=this,n=0;n<r.length;n++){var i=r[n];if(sr(i,e))return!0}return!1},KW={matches:QW,filter:WW},Qs=function(e){this.inputText=e,this.currentSubject=null,this.compoundCount=0,this.edgeCount=0,this.length=0,e==null||lt(e)&&e.match(/^\s*$/)||(fi(e)?this.addQuery({checks:[{type:Je.COLLECTION,value:e.collection()}]}):hr(e)?this.addQuery({checks:[{type:Je.FILTER,value:e}]}):lt(e)?this.parse(e)||(this.invalid=!0):ur("A selector must be created from a string; found "))},Ks=Qs.prototype;[$W,KW].forEach(function(t){return ft(Ks,t)});Ks.text=function(){return this.inputText};Ks.size=function(){return this.length};Ks.eq=function(t){return this[t]};Ks.sameText=function(t){return!this.invalid&&!t.invalid&&this.text()===t.text()};Ks.addQuery=function(t){this[this.length++]=t};Ks.selector=Ks.toString;var Vs={allAre:function(e){var r=new Qs(e);return this.every(function(n){return r.matches(n)})},is:function(e){var r=new Qs(e);return this.some(function(n){return r.matches(n)})},some:function(e,r){for(var n=0;n<this.length;n++){var i=r?e.apply(r,[this[n],n,this]):e(this[n],n,this);if(i)return!0}return!1},every:function(e,r){for(var n=0;n<this.length;n++){var i=r?e.apply(r,[this[n],n,this]):e(this[n],n,this);if(!i)return!1}return!0},same:function(e){if(this===e)return!0;e=this.cy().collection(e);var r=this.length,n=e.length;return r!==n?!1:r===1?this[0]===e[0]:this.every(function(i){return e.hasElementWithId(i.id())})},anySame:function(e){return e=this.cy().collection(e),this.some(function(r){return e.hasElementWithId(r.id())})},allAreNeighbors:function(e){e=this.cy().collection(e);var r=this.neighborhood();return e.every(function(n){return r.hasElementWithId(n.id())})},contains:function(e){e=this.cy().collection(e);var r=this;return e.every(function(n){return r.hasElementWithId(n.id())})}};Vs.allAreNeighbours=Vs.allAreNeighbors;Vs.has=Vs.contains;Vs.equal=Vs.equals=Vs.same;var ki=function(e,r){return function(i,a,s,l){var o=i,c=this,h;if(o==null?h="":fi(o)&&o.length===1&&(h=o.id()),c.length===1&&h){var d=c[0]._private,g=d.traversalCache=d.traversalCache||{},m=g[r]=g[r]||[],y=Ql(h),b=m[y];return b||(m[y]=e.call(c,i,a,s,l))}else return e.call(c,i,a,s,l)}},Pu={parent:function(e){var r=[];if(this.length===1){var n=this[0]._private.parent;if(n)return n}for(var i=0;i<this.length;i++){var a=this[i],s=a._private.parent;s&&r.push(s)}return this.spawn(r,!0).filter(e)},parents:function(e){for(var r=[],n=this.parent();n.nonempty();){for(var i=0;i<n.length;i++){var a=n[i];r.push(a)}n=n.parent()}return this.spawn(r,!0).filter(e)},commonAncestors:function(e){for(var r,n=0;n<this.length;n++){var i=this[n],a=i.parents();r=r||a,r=r.intersect(a)}return r.filter(e)},orphans:function(e){return this.stdFilter(function(r){return r.isOrphan()}).filter(e)},nonorphans:function(e){return this.stdFilter(function(r){return r.isChild()}).filter(e)},children:ki(function(t){for(var e=[],r=0;r<this.length;r++)for(var n=this[r],i=n._private.children,a=0;a<i.length;a++)e.push(i[a]);return this.spawn(e,!0).filter(t)},"children"),siblings:function(e){return this.parent().children().not(this).filter(e)},isParent:function(){var e=this[0];if(e)return e.isNode()&&e._private.children.length!==0},isChildless:function(){var e=this[0];if(e)return e.isNode()&&e._private.children.length===0},isChild:function(){var e=this[0];if(e)return e.isNode()&&e._private.parent!=null},isOrphan:function(){var e=this[0];if(e)return e.isNode()&&e._private.parent==null},descendants:function(e){var r=[];function n(i){for(var a=0;a<i.length;a++){var s=i[a];r.push(s),s.children().nonempty()&&n(s.children())}}return n(this.children()),this.spawn(r,!0).filter(e)}};function GT(t,e,r,n){for(var i=[],a=new $u,s=t.cy(),l=s.hasCompoundNodes(),o=0;o<t.length;o++){var c=t[o];r?i.push(c):l&&n(i,a,c)}for(;i.length>0;){var h=i.shift();e(h),a.add(h.id()),l&&n(i,a,h)}return t}function ij(t,e,r){if(r.isParent())for(var n=r._private.children,i=0;i<n.length;i++){var a=n[i];e.has(a.id())||t.push(a)}}Pu.forEachDown=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return GT(this,t,e,ij)};function aj(t,e,r){if(r.isChild()){var n=r._private.parent;e.has(n.id())||t.push(n)}}Pu.forEachUp=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return GT(this,t,e,aj)};function ZW(t,e,r){aj(t,e,r),ij(t,e,r)}Pu.forEachUpAndDown=function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return GT(this,t,e,ZW)};Pu.ancestors=Pu.parents;var Ff,sj;Ff=sj={data:qt.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:qt.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:qt.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:qt.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:qt.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:qt.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}};Ff.attr=Ff.data;Ff.removeAttr=Ff.removeData;var JW=sj,dv={};function Ib(t){return function(e){var r=this;if(e===void 0&&(e=!0),r.length!==0)if(r.isNode()&&!r.removed()){for(var n=0,i=r[0],a=i._private.edges,s=0;s<a.length;s++){var l=a[s];!e&&l.isLoop()||(n+=t(i,l))}return n}else return}}ft(dv,{degree:Ib(function(t,e){return e.source().same(e.target())?2:1}),indegree:Ib(function(t,e){return e.target().same(t)?1:0}),outdegree:Ib(function(t,e){return e.source().same(t)?1:0})});function Jo(t,e){return function(r){for(var n,i=this.nodes(),a=0;a<i.length;a++){var s=i[a],l=s[t](r);l!==void 0&&(n===void 0||e(l,n))&&(n=l)}return n}}ft(dv,{minDegree:Jo("degree",function(t,e){return t<e}),maxDegree:Jo("degree",function(t,e){return t>e}),minIndegree:Jo("indegree",function(t,e){return t<e}),maxIndegree:Jo("indegree",function(t,e){return t>e}),minOutdegree:Jo("outdegree",function(t,e){return t<e}),maxOutdegree:Jo("outdegree",function(t,e){return t>e})});ft(dv,{totalDegree:function(e){for(var r=0,n=this.nodes(),i=0;i<n.length;i++)r+=n[i].degree(e);return r}});var qi,lj,oj=function(e,r,n){for(var i=0;i<e.length;i++){var a=e[i];if(!a.locked()){var s=a._private.position,l={x:r.x!=null?r.x-s.x:0,y:r.y!=null?r.y-s.y:0};a.isParent()&&!(l.x===0&&l.y===0)&&a.children().shift(l,n),a.dirtyBoundingBoxCache()}}},aN={field:"position",bindingEvent:"position",allowBinding:!0,allowSetting:!0,settingEvent:"position",settingTriggersEvent:!0,triggerFnName:"emitAndNotify",allowGetting:!0,validKeys:["x","y"],beforeGet:function(e){e.updateCompoundBounds()},beforeSet:function(e,r){oj(e,r,!1)},onSet:function(e){e.dirtyCompoundBoundsCache()},canSet:function(e){return!e.locked()}};qi=lj={position:qt.data(aN),silentPosition:qt.data(ft({},aN,{allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!1,beforeSet:function(e,r){oj(e,r,!0)},onSet:function(e){e.dirtyCompoundBoundsCache()}})),positions:function(e,r){if(Bt(e))r?this.silentPosition(e):this.position(e);else if(hr(e)){var n=e,i=this.cy();i.startBatch();for(var a=0;a<this.length;a++){var s=this[a],l=void 0;(l=n(s,a))&&(r?s.silentPosition(l):s.position(l))}i.endBatch()}return this},silentPositions:function(e){return this.positions(e,!0)},shift:function(e,r,n){var i;if(Bt(e)?(i={x:qe(e.x)?e.x:0,y:qe(e.y)?e.y:0},n=r):lt(e)&&qe(r)&&(i={x:0,y:0},i[e]=r),i!=null){var a=this.cy();a.startBatch();for(var s=0;s<this.length;s++){var l=this[s];if(!(a.hasCompoundNodes()&&l.isChild()&&l.ancestors().anySame(this))){var o=l.position(),c={x:o.x+i.x,y:o.y+i.y};n?l.silentPosition(c):l.position(c)}}a.endBatch()}return this},silentShift:function(e,r){return Bt(e)?this.shift(e,!0):lt(e)&&qe(r)&&this.shift(e,r,!0),this},renderedPosition:function(e,r){var n=this[0],i=this.cy(),a=i.zoom(),s=i.pan(),l=Bt(e)?e:void 0,o=l!==void 0||r!==void 0&<(e);if(n&&n.isNode())if(o)for(var c=0;c<this.length;c++){var h=this[c];r!==void 0?h.position(e,(r-s[e])/a):l!==void 0&&h.position(Pq(l,a,s))}else{var d=n.position();return l=lv(d,a,s),e===void 0?l:l[e]}else if(!o)return;return this},relativePosition:function(e,r){var n=this[0],i=this.cy(),a=Bt(e)?e:void 0,s=a!==void 0||r!==void 0&<(e),l=i.hasCompoundNodes();if(n&&n.isNode())if(s)for(var o=0;o<this.length;o++){var c=this[o],h=l?c.parent():null,d=h&&h.length>0,g=d;d&&(h=h[0]);var m=g?h.position():{x:0,y:0};r!==void 0?c.position(e,r+m[e]):a!==void 0&&c.position({x:a.x+m.x,y:a.y+m.y})}else{var y=n.position(),b=l?n.parent():null,x=b&&b.length>0,w=x;x&&(b=b[0]);var S=w?b.position():{x:0,y:0};return a={x:y.x-S.x,y:y.y-S.y},e===void 0?a:a[e]}else if(!s)return;return this}};qi.modelPosition=qi.point=qi.position;qi.modelPositions=qi.points=qi.positions;qi.renderedPoint=qi.renderedPosition;qi.relativePoint=qi.relativePosition;var eQ=lj,ku,ol;ku=ol={};ol.renderedBoundingBox=function(t){var e=this.boundingBox(t),r=this.cy(),n=r.zoom(),i=r.pan(),a=e.x1*n+i.x,s=e.x2*n+i.x,l=e.y1*n+i.y,o=e.y2*n+i.y;return{x1:a,x2:s,y1:l,y2:o,w:s-a,h:o-l}};ol.dirtyCompoundBoundsCache=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();return!e.styleEnabled()||!e.hasCompoundNodes()?this:(this.forEachUp(function(r){if(r.isParent()){var n=r._private;n.compoundBoundsClean=!1,n.bbCache=null,t||r.emitAndNotify("bounds")}}),this)};ol.updateCompoundBounds=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();if(!e.styleEnabled()||!e.hasCompoundNodes())return this;if(!t&&e.batching())return this;function r(s){if(!s.isParent())return;var l=s._private,o=s.children(),c=s.pstyle("compound-sizing-wrt-labels").value==="include",h={width:{val:s.pstyle("min-width").pfValue,left:s.pstyle("min-width-bias-left"),right:s.pstyle("min-width-bias-right")},height:{val:s.pstyle("min-height").pfValue,top:s.pstyle("min-height-bias-top"),bottom:s.pstyle("min-height-bias-bottom")}},d=o.boundingBox({includeLabels:c,includeOverlays:!1,useCache:!1}),g=l.position;(d.w===0||d.h===0)&&(d={w:s.pstyle("width").pfValue,h:s.pstyle("height").pfValue},d.x1=g.x-d.w/2,d.x2=g.x+d.w/2,d.y1=g.y-d.h/2,d.y2=g.y+d.h/2);function m(B,D,_){var P=0,z=0,H=D+_;return B>0&&H>0&&(P=D/H*B,z=_/H*B),{biasDiff:P,biasComplementDiff:z}}function y(B,D,_,P){if(_.units==="%")switch(P){case"width":return B>0?_.pfValue*B:0;case"height":return D>0?_.pfValue*D:0;case"average":return B>0&&D>0?_.pfValue*(B+D)/2:0;case"min":return B>0&&D>0?B>D?_.pfValue*D:_.pfValue*B:0;case"max":return B>0&&D>0?B>D?_.pfValue*B:_.pfValue*D:0;default:return 0}else return _.units==="px"?_.pfValue:0}var b=h.width.left.value;h.width.left.units==="px"&&h.width.val>0&&(b=b*100/h.width.val);var x=h.width.right.value;h.width.right.units==="px"&&h.width.val>0&&(x=x*100/h.width.val);var w=h.height.top.value;h.height.top.units==="px"&&h.height.val>0&&(w=w*100/h.height.val);var S=h.height.bottom.value;h.height.bottom.units==="px"&&h.height.val>0&&(S=S*100/h.height.val);var k=m(h.width.val-d.w,b,x),E=k.biasDiff,M=k.biasComplementDiff,R=m(h.height.val-d.h,w,S),O=R.biasDiff,N=R.biasComplementDiff;l.autoPadding=y(d.w,d.h,s.pstyle("padding"),s.pstyle("padding-relative-to").value),l.autoWidth=Math.max(d.w,h.width.val),g.x=(-E+d.x1+d.x2+M)/2,l.autoHeight=Math.max(d.h,h.height.val),g.y=(-O+d.y1+d.y2+N)/2}for(var n=0;n<this.length;n++){var i=this[n],a=i._private;(!a.compoundBoundsClean||t)&&(r(i),e.batching()||(a.compoundBoundsClean=!0))}return this};var Ci=function(e){return e===1/0||e===-1/0?0:e},Li=function(e,r,n,i,a){i-r===0||a-n===0||r==null||n==null||i==null||a==null||(e.x1=r<e.x1?r:e.x1,e.x2=i>e.x2?i:e.x2,e.y1=n<e.y1?n:e.y1,e.y2=a>e.y2?a:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},Ns=function(e,r){return r==null?e:Li(e,r.x1,r.y1,r.x2,r.y2)},Kc=function(e,r,n){return Fn(e,r,n)},ip=function(e,r,n){if(!r.cy().headless()){var i=r._private,a=i.rstyle,s=a.arrowWidth/2,l=r.pstyle(n+"-arrow-shape").value,o,c;if(l!=="none"){n==="source"?(o=a.srcX,c=a.srcY):n==="target"?(o=a.tgtX,c=a.tgtY):(o=a.midX,c=a.midY);var h=i.arrowBounds=i.arrowBounds||{},d=h[n]=h[n]||{};d.x1=o-s,d.y1=c-s,d.x2=o+s,d.y2=c+s,d.w=d.x2-d.x1,d.h=d.y2-d.y1,zp(d,1),Li(e,d.x1,d.y1,d.x2,d.y2)}}},qb=function(e,r,n){if(!r.cy().headless()){var i;n?i=n+"-":i="";var a=r._private,s=a.rstyle,l=r.pstyle(i+"label").strValue;if(l){var o=r.pstyle("text-halign"),c=r.pstyle("text-valign"),h=Kc(s,"labelWidth",n),d=Kc(s,"labelHeight",n),g=Kc(s,"labelX",n),m=Kc(s,"labelY",n),y=r.pstyle(i+"text-margin-x").pfValue,b=r.pstyle(i+"text-margin-y").pfValue,x=r.isEdge(),w=r.pstyle(i+"text-rotation"),S=r.pstyle("text-outline-width").pfValue,k=r.pstyle("text-border-width").pfValue,E=k/2,M=r.pstyle("text-background-padding").pfValue,R=2,O=d,N=h,B=N/2,D=O/2,_,P,z,H;if(x)_=g-B,P=g+B,z=m-D,H=m+D;else{switch(o.value){case"left":_=g-N,P=g;break;case"center":_=g-B,P=g+B;break;case"right":_=g,P=g+N;break}switch(c.value){case"top":z=m-O,H=m;break;case"center":z=m-D,H=m+D;break;case"bottom":z=m,H=m+O;break}}var $=y-Math.max(S,E)-M-R,q=y+Math.max(S,E)+M+R,V=b-Math.max(S,E)-M-R,X=b+Math.max(S,E)+M+R;_+=$,P+=q,z+=V,H+=X;var ee=n||"main",te=a.labelBounds,I=te[ee]=te[ee]||{};I.x1=_,I.y1=z,I.x2=P,I.y2=H,I.w=P-_,I.h=H-z,I.leftPad=$,I.rightPad=q,I.topPad=V,I.botPad=X;var G=x&&w.strValue==="autorotate",re=w.pfValue!=null&&w.pfValue!==0;if(G||re){var Y=G?Kc(a.rstyle,"labelAngle",n):w.pfValue,W=Math.cos(Y),Z=Math.sin(Y),ie=(_+P)/2,we=(z+H)/2;if(!x){switch(o.value){case"left":ie=P;break;case"right":ie=_;break}switch(c.value){case"top":we=H;break;case"bottom":we=z;break}}var de=function(Me,He){return Me=Me-ie,He=He-we,{x:Me*W-He*Z+ie,y:Me*Z+He*W+we}},se=de(_,z),j=de(_,H),Q=de(P,z),K=de(P,H);_=Math.min(se.x,j.x,Q.x,K.x),P=Math.max(se.x,j.x,Q.x,K.x),z=Math.min(se.y,j.y,Q.y,K.y),H=Math.max(se.y,j.y,Q.y,K.y)}var ue=ee+"Rot",Se=te[ue]=te[ue]||{};Se.x1=_,Se.y1=z,Se.x2=P,Se.y2=H,Se.w=P-_,Se.h=H-z,Li(e,_,z,P,H),Li(a.labelBounds.all,_,z,P,H)}return e}},sN=function(e,r){if(!r.cy().headless()){var n=r.pstyle("outline-opacity").value,i=r.pstyle("outline-width").value,a=r.pstyle("outline-offset").value,s=i+a;uj(e,r,n,s,"outside",s/2)}},uj=function(e,r,n,i,a,s){if(!(n===0||i<=0||a==="inside")){var l=r.cy(),o=r.pstyle("shape").value,c=l.renderer().nodeShapes[o],h=r.position(),d=h.x,g=h.y,m=r.width(),y=r.height();if(c.hasMiterBounds){a==="center"&&(i/=2);var b=c.miterBounds(d,g,m,y,i);Ns(e,b)}else s!=null&&s>0&&Ip(e,[s,s,s,s])}},tQ=function(e,r){if(!r.cy().headless()){var n=r.pstyle("border-opacity").value,i=r.pstyle("border-width").pfValue,a=r.pstyle("border-position").value;uj(e,r,n,i,a)}},rQ=function(e,r){var n=e._private.cy,i=n.styleEnabled(),a=n.headless(),s=Rn(),l=e._private,o=e.isNode(),c=e.isEdge(),h,d,g,m,y,b,x=l.rstyle,w=o&&i?e.pstyle("bounds-expansion").pfValue:[0],S=function(at){return at.pstyle("display").value!=="none"},k=!i||S(e)&&(!c||S(e.source())&&S(e.target()));if(k){var E=0,M=0;i&&r.includeOverlays&&(E=e.pstyle("overlay-opacity").value,E!==0&&(M=e.pstyle("overlay-padding").value));var R=0,O=0;i&&r.includeUnderlays&&(R=e.pstyle("underlay-opacity").value,R!==0&&(O=e.pstyle("underlay-padding").value));var N=Math.max(M,O),B=0,D=0;if(i&&(B=e.pstyle("width").pfValue,D=B/2),o&&r.includeNodes){var _=e.position();y=_.x,b=_.y;var P=e.outerWidth(),z=P/2,H=e.outerHeight(),$=H/2;h=y-z,d=y+z,g=b-$,m=b+$,Li(s,h,g,d,m),i&&sN(s,e),i&&r.includeOutlines&&!a&&sN(s,e),i&&tQ(s,e)}else if(c&&r.includeEdges)if(i&&!a){var q=e.pstyle("curve-style").strValue;if(h=Math.min(x.srcX,x.midX,x.tgtX),d=Math.max(x.srcX,x.midX,x.tgtX),g=Math.min(x.srcY,x.midY,x.tgtY),m=Math.max(x.srcY,x.midY,x.tgtY),h-=D,d+=D,g-=D,m+=D,Li(s,h,g,d,m),q==="haystack"){var V=x.haystackPts;if(V&&V.length===2){if(h=V[0].x,g=V[0].y,d=V[1].x,m=V[1].y,h>d){var X=h;h=d,d=X}if(g>m){var ee=g;g=m,m=ee}Li(s,h-D,g-D,d+D,m+D)}}else if(q==="bezier"||q==="unbundled-bezier"||zs(q,"segments")||zs(q,"taxi")){var te;switch(q){case"bezier":case"unbundled-bezier":te=x.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":te=x.linePts;break}if(te!=null)for(var I=0;I<te.length;I++){var G=te[I];h=G.x-D,d=G.x+D,g=G.y-D,m=G.y+D,Li(s,h,g,d,m)}}}else{var re=e.source(),Y=re.position(),W=e.target(),Z=W.position();if(h=Y.x,d=Z.x,g=Y.y,m=Z.y,h>d){var ie=h;h=d,d=ie}if(g>m){var we=g;g=m,m=we}h-=D,d+=D,g-=D,m+=D,Li(s,h,g,d,m)}if(i&&r.includeEdges&&c&&(ip(s,e,"mid-source"),ip(s,e,"mid-target"),ip(s,e,"source"),ip(s,e,"target")),i){var de=e.pstyle("ghost").value==="yes";if(de){var se=e.pstyle("ghost-offset-x").pfValue,j=e.pstyle("ghost-offset-y").pfValue;Li(s,s.x1+se,s.y1+j,s.x2+se,s.y2+j)}}var Q=l.bodyBounds=l.bodyBounds||{};$D(Q,s),Ip(Q,w),zp(Q,1),i&&(h=s.x1,d=s.x2,g=s.y1,m=s.y2,Li(s,h-N,g-N,d+N,m+N));var K=l.overlayBounds=l.overlayBounds||{};$D(K,s),Ip(K,w),zp(K,1);var ue=l.labelBounds=l.labelBounds||{};ue.all!=null?zY(ue.all):ue.all=Rn(),i&&r.includeLabels&&(r.includeMainLabels&&qb(s,e,null),c&&(r.includeSourceLabels&&qb(s,e,"source"),r.includeTargetLabels&&qb(s,e,"target")))}return s.x1=Ci(s.x1),s.y1=Ci(s.y1),s.x2=Ci(s.x2),s.y2=Ci(s.y2),s.w=Ci(s.x2-s.x1),s.h=Ci(s.y2-s.y1),s.w>0&&s.h>0&&k&&(Ip(s,w),zp(s,1)),s},cj=function(e){var r=0,n=function(s){return(s?1:0)<<r++},i=0;return i+=n(e.incudeNodes),i+=n(e.includeEdges),i+=n(e.includeLabels),i+=n(e.includeMainLabels),i+=n(e.includeSourceLabels),i+=n(e.includeTargetLabels),i+=n(e.includeOverlays),i+=n(e.includeOutlines),i},fj=function(e){var r=function(l){return Math.round(l)};if(e.isEdge()){var n=e.source().position(),i=e.target().position();return qD([r(n.x),r(n.y),r(i.x),r(i.y)])}else{var a=e.position();return qD([r(a.x),r(a.y)])}},lN=function(e,r){var n=e._private,i,a=e.isEdge(),s=r==null?oN:cj(r),l=s===oN;if(n.bbCache==null?(i=rQ(e,Hf),n.bbCache=i,n.bbCachePosKey=fj(e)):i=n.bbCache,!l){var o=e.isNode();i=Rn(),(r.includeNodes&&o||r.includeEdges&&!o)&&(r.includeOverlays?Ns(i,n.overlayBounds):Ns(i,n.bodyBounds)),r.includeLabels&&(r.includeMainLabels&&(!a||r.includeSourceLabels&&r.includeTargetLabels)?Ns(i,n.labelBounds.all):(r.includeMainLabels&&Ns(i,n.labelBounds.mainRot),r.includeSourceLabels&&Ns(i,n.labelBounds.sourceRot),r.includeTargetLabels&&Ns(i,n.labelBounds.targetRot))),i.w=i.x2-i.x1,i.h=i.y2-i.y1}return i},Hf={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,includeUnderlays:!0,includeOutlines:!0,useCache:!0},oN=cj(Hf),uN=cn(Hf);ol.boundingBox=function(t){var e,r=t===void 0||t.useCache===void 0||t.useCache===!0,n=Bu(function(h){var d=h._private;return d.bbCache==null||d.styleDirty||d.bbCachePosKey!==fj(h)},function(h){return h.id()});if(r&&this.length===1&&!n(this[0]))t===void 0?t=Hf:t=uN(t),e=lN(this[0],t);else{e=Rn(),t=t||Hf;var i=uN(t),a=this,s=a.cy(),l=s.styleEnabled();this.edges().forEach(n),this.nodes().forEach(n),l&&this.recalculateRenderedStyle(r),this.updateCompoundBounds(!r);for(var o=0;o<a.length;o++){var c=a[o];n(c)&&c.dirtyBoundingBoxCache(),Ns(e,lN(c,i))}}return e.x1=Ci(e.x1),e.y1=Ci(e.y1),e.x2=Ci(e.x2),e.y2=Ci(e.y2),e.w=Ci(e.x2-e.x1),e.h=Ci(e.y2-e.y1),e};ol.dirtyBoundingBoxCache=function(){for(var t=0;t<this.length;t++){var e=this[t]._private;e.bbCache=null,e.bbCachePosKey=null,e.bodyBounds=null,e.overlayBounds=null,e.labelBounds.all=null,e.labelBounds.source=null,e.labelBounds.target=null,e.labelBounds.main=null,e.labelBounds.sourceRot=null,e.labelBounds.targetRot=null,e.labelBounds.mainRot=null,e.arrowBounds.source=null,e.arrowBounds.target=null,e.arrowBounds["mid-source"]=null,e.arrowBounds["mid-target"]=null}return this.emitAndNotify("bounds"),this};ol.boundingBoxAt=function(t){var e=this.nodes(),r=this.cy(),n=r.hasCompoundNodes(),i=r.collection();if(n&&(i=e.filter(function(c){return c.isParent()}),e=e.not(i)),Bt(t)){var a=t;t=function(){return a}}var s=function(h,d){return h._private.bbAtOldPos=t(h,d)},l=function(h){return h._private.bbAtOldPos};r.startBatch(),e.forEach(s).silentPositions(t),n&&(i.dirtyCompoundBoundsCache(),i.dirtyBoundingBoxCache(),i.updateCompoundBounds(!0));var o=PY(this.boundingBox({useCache:!1}));return e.silentPositions(l),n&&(i.dirtyCompoundBoundsCache(),i.dirtyBoundingBoxCache(),i.updateCompoundBounds(!0)),r.endBatch(),o};ku.boundingbox=ku.bb=ku.boundingBox;ku.renderedBoundingbox=ku.renderedBoundingBox;var nQ=ol,hf,yh;hf=yh={};var hj=function(e){e.uppercaseName=kD(e.name),e.autoName="auto"+e.uppercaseName,e.labelName="label"+e.uppercaseName,e.outerName="outer"+e.uppercaseName,e.uppercaseOuterName=kD(e.outerName),hf[e.name]=function(){var n=this[0],i=n._private,a=i.cy,s=a._private.styleEnabled;if(n)if(s){if(n.isParent())return n.updateCompoundBounds(),i[e.autoName]||0;var l=n.pstyle(e.name);return l.strValue==="label"?(n.recalculateRenderedStyle(),i.rstyle[e.labelName]||0):l.pfValue}else return 1},hf["outer"+e.uppercaseName]=function(){var n=this[0],i=n._private,a=i.cy,s=a._private.styleEnabled;if(n)if(s){var l=n[e.name](),o=n.pstyle("border-position").value,c;o==="center"?c=n.pstyle("border-width").pfValue:o==="outside"?c=2*n.pstyle("border-width").pfValue:c=0;var h=2*n.padding();return l+c+h}else return 1},hf["rendered"+e.uppercaseName]=function(){var n=this[0];if(n){var i=n[e.name]();return i*this.cy().zoom()}},hf["rendered"+e.uppercaseOuterName]=function(){var n=this[0];if(n){var i=n[e.outerName]();return i*this.cy().zoom()}}};hj({name:"width"});hj({name:"height"});yh.padding=function(){var t=this[0],e=t._private;return t.isParent()?(t.updateCompoundBounds(),e.autoPadding!==void 0?e.autoPadding:t.pstyle("padding").pfValue):t.pstyle("padding").pfValue};yh.paddedHeight=function(){var t=this[0];return t.height()+2*t.padding()};yh.paddedWidth=function(){var t=this[0];return t.width()+2*t.padding()};var iQ=yh,aQ=function(e,r){if(e.isEdge()&&e.takesUpSpace())return r(e)},sQ=function(e,r){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy();return lv(r(e),n.zoom(),n.pan())}},lQ=function(e,r){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy(),i=n.pan(),a=n.zoom();return r(e).map(function(s){return lv(s,a,i)})}},oQ=function(e){return e.renderer().getControlPoints(e)},uQ=function(e){return e.renderer().getSegmentPoints(e)},cQ=function(e){return e.renderer().getSourceEndpoint(e)},fQ=function(e){return e.renderer().getTargetEndpoint(e)},hQ=function(e){return e.renderer().getEdgeMidpoint(e)},cN={controlPoints:{get:oQ,mult:!0},segmentPoints:{get:uQ,mult:!0},sourceEndpoint:{get:cQ},targetEndpoint:{get:fQ},midpoint:{get:hQ}},dQ=function(e){return"rendered"+e[0].toUpperCase()+e.substr(1)},pQ=Object.keys(cN).reduce(function(t,e){var r=cN[e],n=dQ(e);return t[e]=function(){return aQ(this,r.get)},r.mult?t[n]=function(){return lQ(this,r.get)}:t[n]=function(){return sQ(this,r.get)},t},{}),gQ=ft({},eQ,nQ,iQ,pQ);var dj=function(e,r){this.recycle(e,r)};function Zc(){return!1}function ap(){return!0}dj.prototype={instanceString:function(){return"event"},recycle:function(e,r){if(this.isImmediatePropagationStopped=this.isPropagationStopped=this.isDefaultPrevented=Zc,e!=null&&e.preventDefault?(this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?ap:Zc):e!=null&&e.type?r=e:this.type=e,r!=null&&(this.originalEvent=r.originalEvent,this.type=r.type!=null?r.type:this.type,this.cy=r.cy,this.target=r.target,this.position=r.position,this.renderedPosition=r.renderedPosition,this.namespace=r.namespace,this.layout=r.layout),this.cy!=null&&this.position!=null&&this.renderedPosition==null){var n=this.position,i=this.cy.zoom(),a=this.cy.pan();this.renderedPosition={x:n.x*i+a.x,y:n.y*i+a.y}}this.timeStamp=e&&e.timeStamp||Date.now()},preventDefault:function(){this.isDefaultPrevented=ap;var e=this.originalEvent;e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){this.isPropagationStopped=ap;var e=this.originalEvent;e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=ap,this.stopPropagation()},isDefaultPrevented:Zc,isPropagationStopped:Zc,isImmediatePropagationStopped:Zc};var pj=/^([^.]+)(\.(?:[^.]+))?$/,vQ=".*",gj={qualifierCompare:function(e,r){return e===r},eventMatches:function(){return!0},addEventFields:function(){},callbackContext:function(e){return e},beforeEmit:function(){},afterEmit:function(){},bubble:function(){return!1},parent:function(){return null},context:null},fN=Object.keys(gj),mQ={};function pv(){for(var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mQ,e=arguments.length>1?arguments[1]:void 0,r=0;r<fN.length;r++){var n=fN[r];this[n]=t[n]||gj[n]}this.context=e||this.context,this.listeners=[],this.emitting=0}var Zs=pv.prototype,vj=function(e,r,n,i,a,s,l){hr(i)&&(a=i,i=null),l&&(s==null?s=l:s=ft({},s,l));for(var o=Zt(n)?n:n.split(/\s+/),c=0;c<o.length;c++){var h=o[c];if(!Ys(h)){var d=h.match(pj);if(d){var g=d[1],m=d[2]?d[2]:null,y=r(e,h,g,m,i,a,s);if(y===!1)break}}}},hN=function(e,r){return e.addEventFields(e.context,r),new dj(r.type,r)},yQ=function(e,r,n){if(kG(n)){r(e,n);return}else if(Bt(n)){r(e,hN(e,n));return}for(var i=Zt(n)?n:n.split(/\s+/),a=0;a<i.length;a++){var s=i[a];if(!Ys(s)){var l=s.match(pj);if(l){var o=l[1],c=l[2]?l[2]:null,h=hN(e,{type:o,namespace:c,target:e.context});r(e,h)}}}};Zs.on=Zs.addListener=function(t,e,r,n,i){return vj(this,function(a,s,l,o,c,h,d){hr(h)&&a.listeners.push({event:s,callback:h,type:l,namespace:o,qualifier:c,conf:d})},t,e,r,n,i),this};Zs.one=function(t,e,r,n){return this.on(t,e,r,n,{one:!0})};Zs.removeListener=Zs.off=function(t,e,r,n){var i=this;this.emitting!==0&&(this.listeners=sY(this.listeners));for(var a=this.listeners,s=function(c){var h=a[c];vj(i,function(d,g,m,y,b,x){if((h.type===m||t==="*")&&(!y&&h.namespace!==".*"||h.namespace===y)&&(!b||d.qualifierCompare(h.qualifier,b))&&(!x||h.callback===x))return a.splice(c,1),!1},t,e,r,n)},l=a.length-1;l>=0;l--)s(l);return this};Zs.removeAllListeners=function(){return this.removeListener("*")};Zs.emit=Zs.trigger=function(t,e,r){var n=this.listeners,i=n.length;return this.emitting++,Zt(e)||(e=[e]),yQ(this,function(a,s){r!=null&&(n=[{event:s.event,type:s.type,namespace:s.namespace,callback:r}],i=n.length);for(var l=function(){var h=n[o];if(h.type===s.type&&(!h.namespace||h.namespace===s.namespace||h.namespace===vQ)&&a.eventMatches(a.context,h,s)){var d=[s];e!=null&&oY(d,e),a.beforeEmit(a.context,h,s),h.conf&&h.conf.one&&(a.listeners=a.listeners.filter(function(y){return y!==h}));var g=a.callbackContext(a.context,h,s),m=h.callback.apply(g,d);a.afterEmit(a.context,h,s),m===!1&&(s.stopPropagation(),s.preventDefault())}},o=0;o<i;o++)l();a.bubble(a.context)&&!s.isPropagationStopped()&&a.parent(a.context).emit(s,e)},t),this.emitting--,this};var bQ={qualifierCompare:function(e,r){return e==null||r==null?e==null&&r==null:e.sameText(r)},eventMatches:function(e,r,n){var i=r.qualifier;return i!=null?e!==n.target&&hh(n.target)&&i.matches(n.target):!0},addEventFields:function(e,r){r.cy=e.cy(),r.target=e},callbackContext:function(e,r,n){return r.qualifier!=null?n.target:e},beforeEmit:function(e,r){r.conf&&r.conf.once&&r.conf.onceCollection.removeListener(r.event,r.qualifier,r.callback)},bubble:function(){return!0},parent:function(e){return e.isChild()?e.parent():e.cy()}},sp=function(e){return lt(e)?new Qs(e):e},mj={createEmitter:function(){for(var e=0;e<this.length;e++){var r=this[e],n=r._private;n.emitter||(n.emitter=new pv(bQ,r))}return this},emitter:function(){return this._private.emitter},on:function(e,r,n){for(var i=sp(r),a=0;a<this.length;a++){var s=this[a];s.emitter().on(e,i,n)}return this},removeListener:function(e,r,n){for(var i=sp(r),a=0;a<this.length;a++){var s=this[a];s.emitter().removeListener(e,i,n)}return this},removeAllListeners:function(){for(var e=0;e<this.length;e++){var r=this[e];r.emitter().removeAllListeners()}return this},one:function(e,r,n){for(var i=sp(r),a=0;a<this.length;a++){var s=this[a];s.emitter().one(e,i,n)}return this},once:function(e,r,n){for(var i=sp(r),a=0;a<this.length;a++){var s=this[a];s.emitter().on(e,i,n,{once:!0,onceCollection:this})}},emit:function(e,r){for(var n=0;n<this.length;n++){var i=this[n];i.emitter().emit(e,r)}return this},emitAndNotify:function(e,r){if(this.length!==0)return this.cy().notify(e,this),this.emit(e,r),this}};qt.eventAliasesOn(mj);var yj={nodes:function(e){return this.filter(function(r){return r.isNode()}).filter(e)},edges:function(e){return this.filter(function(r){return r.isEdge()}).filter(e)},byGroup:function(){for(var e=this.spawn(),r=this.spawn(),n=0;n<this.length;n++){var i=this[n];i.isNode()?e.push(i):r.push(i)}return{nodes:e,edges:r}},filter:function(e,r){if(e===void 0)return this;if(lt(e)||fi(e))return new Qs(e).filter(this);if(hr(e)){for(var n=this.spawn(),i=this,a=0;a<i.length;a++){var s=i[a],l=r?e.apply(r,[s,a,i]):e(s,a,i);l&&n.push(s)}return n}return this.spawn()},not:function(e){if(e){lt(e)&&(e=this.filter(e));for(var r=this.spawn(),n=0;n<this.length;n++){var i=this[n],a=e.has(i);a||r.push(i)}return r}else return this},absoluteComplement:function(){var e=this.cy();return e.mutableElements().not(this)},intersect:function(e){if(lt(e)){var r=e;return this.filter(r)}for(var n=this.spawn(),i=this,a=e,s=this.length<e.length,l=s?i:a,o=s?a:i,c=0;c<l.length;c++){var h=l[c];o.has(h)&&n.push(h)}return n},xor:function(e){var r=this._private.cy;lt(e)&&(e=r.$(e));var n=this.spawn(),i=this,a=e,s=function(o,c){for(var h=0;h<o.length;h++){var d=o[h],g=d._private.data.id,m=c.hasElementWithId(g);m||n.push(d)}};return s(i,a),s(a,i),n},diff:function(e){var r=this._private.cy;lt(e)&&(e=r.$(e));var n=this.spawn(),i=this.spawn(),a=this.spawn(),s=this,l=e,o=function(h,d,g){for(var m=0;m<h.length;m++){var y=h[m],b=y._private.data.id,x=d.hasElementWithId(b);x?a.merge(y):g.push(y)}};return o(s,l,n),o(l,s,i),{left:n,right:i,both:a}},add:function(e){var r=this._private.cy;if(!e)return this;if(lt(e)){var n=e;e=r.mutableElements().filter(n)}for(var i=this.spawnSelf(),a=0;a<e.length;a++){var s=e[a],l=!this.has(s);l&&i.push(s)}return i},merge:function(e){var r=this._private,n=r.cy;if(!e)return this;if(e&<(e)){var i=e;e=n.mutableElements().filter(i)}for(var a=r.map,s=0;s<e.length;s++){var l=e[s],o=l._private.data.id,c=!a.has(o);if(c){var h=this.length++;this[h]=l,a.set(o,{ele:l,index:h})}}return this},unmergeAt:function(e){var r=this[e],n=r.id(),i=this._private,a=i.map;this[e]=void 0,a.delete(n);var s=e===this.length-1;if(this.length>1&&!s){var l=this.length-1,o=this[l],c=o._private.data.id;this[l]=void 0,this[e]=o,a.set(c,{ele:o,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var r=this._private,n=e._private.data.id,i=r.map,a=i.get(n);if(!a)return this;var s=a.index;return this.unmergeAt(s),this},unmerge:function(e){var r=this._private.cy;if(!e)return this;if(e&<(e)){var n=e;e=r.mutableElements().filter(n)}for(var i=0;i<e.length;i++)this.unmergeOne(e[i]);return this},unmergeBy:function(e){for(var r=this.length-1;r>=0;r--){var n=this[r];e(n)&&this.unmergeAt(r)}return this},map:function(e,r){for(var n=[],i=this,a=0;a<i.length;a++){var s=i[a],l=r?e.apply(r,[s,a,i]):e(s,a,i);n.push(l)}return n},reduce:function(e,r){for(var n=r,i=this,a=0;a<i.length;a++)n=e(n,i[a],a,i);return n},max:function(e,r){for(var n=-1/0,i,a=this,s=0;s<a.length;s++){var l=a[s],o=r?e.apply(r,[l,s,a]):e(l,s,a);o>n&&(n=o,i=l)}return{value:n,ele:i}},min:function(e,r){for(var n=1/0,i,a=this,s=0;s<a.length;s++){var l=a[s],o=r?e.apply(r,[l,s,a]):e(l,s,a);o<n&&(n=o,i=l)}return{value:n,ele:i}}},zt=yj;zt.u=zt["|"]=zt["+"]=zt.union=zt.or=zt.add;zt["\\"]=zt["!"]=zt["-"]=zt.difference=zt.relativeComplement=zt.subtract=zt.not;zt.n=zt["&"]=zt["."]=zt.and=zt.intersection=zt.intersect;zt["^"]=zt["(+)"]=zt["(-)"]=zt.symmetricDifference=zt.symdiff=zt.xor;zt.fnFilter=zt.filterFn=zt.stdFilter=zt.filter;zt.complement=zt.abscomp=zt.absoluteComplement;var xQ={isNode:function(){return this.group()==="nodes"},isEdge:function(){return this.group()==="edges"},isLoop:function(){return this.isEdge()&&this.source()[0]===this.target()[0]},isSimple:function(){return this.isEdge()&&this.source()[0]!==this.target()[0]},group:function(){var e=this[0];if(e)return e._private.group}},bj=function(e,r){var n=e.cy(),i=n.hasCompoundNodes();function a(h){var d=h.pstyle("z-compound-depth");return d.value==="auto"?i?h.zDepth():0:d.value==="bottom"?-1:d.value==="top"?LT:0}var s=a(e)-a(r);if(s!==0)return s;function l(h){var d=h.pstyle("z-index-compare");return d.value==="auto"&&h.isNode()?1:0}var o=l(e)-l(r);if(o!==0)return o;var c=e.pstyle("z-index").value-r.pstyle("z-index").value;return c!==0?c:e.poolIndex()-r.poolIndex()},yg={forEach:function(e,r){if(hr(e))for(var n=this.length,i=0;i<n;i++){var a=this[i],s=r?e.apply(r,[a,i,this]):e(a,i,this);if(s===!1)break}return this},toArray:function(){for(var e=[],r=0;r<this.length;r++)e.push(this[r]);return e},slice:function(e,r){var n=[],i=this.length;r==null&&(r=i),e==null&&(e=0),e<0&&(e=i+e),r<0&&(r=i+r);for(var a=e;a>=0&&a<r&&a<i;a++)n.push(this[a]);return this.spawn(n)},size:function(){return this.length},eq:function(e){return this[e]||this.spawn()},first:function(){return this[0]||this.spawn()},last:function(){return this[this.length-1]||this.spawn()},empty:function(){return this.length===0},nonempty:function(){return!this.empty()},sort:function(e){if(!hr(e))return this;var r=this.toArray().sort(e);return this.spawn(r)},sortByZIndex:function(){return this.sort(bj)},zDepth:function(){var e=this[0];if(e){var r=e._private,n=r.group;if(n==="nodes"){var i=r.data.parent?e.parents().size():0;return e.isParent()?i:LT-1}else{var a=r.source,s=r.target,l=a.zDepth(),o=s.zDepth();return Math.max(l,o,0)}}}};yg.each=yg.forEach;var wQ=function(){var e="undefined",r=(typeof Symbol>"u"?"undefined":qr(Symbol))!=e&&qr(Symbol.iterator)!=e;r&&(yg[Symbol.iterator]=function(){var n=this,i={value:void 0,done:!1},a=0,s=this.length;return mq({next:function(){return a<s?i.value=n[a++]:(i.value=void 0,i.done=!0),i}},Symbol.iterator,function(){return this})})};wQ();var SQ=cn({nodeDimensionsIncludeLabels:!1}),jp={layoutDimensions:function(e){e=SQ(e);var r;if(!this.takesUpSpace())r={w:0,h:0};else if(e.nodeDimensionsIncludeLabels){var n=this.boundingBox();r={w:n.w,h:n.h}}else r={w:this.outerWidth(),h:this.outerHeight()};return(r.w===0||r.h===0)&&(r.w=r.h=1),r},layoutPositions:function(e,r,n){var i=this.nodes().filter(function(M){return!M.isParent()}),a=this.cy(),s=r.eles,l=function(R){return R.id()},o=Bu(n,l);e.emit({type:"layoutstart",layout:e}),e.animations=[];var c=function(R,O,N){var B={x:O.x1+O.w/2,y:O.y1+O.h/2},D={x:(N.x-B.x)*R,y:(N.y-B.y)*R};return{x:B.x+D.x,y:B.y+D.y}},h=r.spacingFactor&&r.spacingFactor!==1,d=function(){if(!h)return null;for(var R=Rn(),O=0;O<i.length;O++){var N=i[O],B=o(N,O);zq(R,B.x,B.y)}return R},g=d(),m=Bu(function(M,R){var O=o(M,R);if(h){var N=Math.abs(r.spacingFactor);O=c(N,g,O)}return r.transform!=null&&(O=r.transform(M,O)),O},l);if(r.animate){for(var y=0;y<i.length;y++){var b=i[y],x=m(b,y),w=r.animateFilter==null||r.animateFilter(b,y);if(w){var S=b.animation({position:x,duration:r.animationDuration,easing:r.animationEasing});e.animations.push(S)}else b.position(x)}if(r.fit){var k=a.animation({fit:{boundingBox:s.boundingBoxAt(m),padding:r.padding},duration:r.animationDuration,easing:r.animationEasing});e.animations.push(k)}else if(r.zoom!==void 0&&r.pan!==void 0){var E=a.animation({zoom:r.zoom,pan:r.pan,duration:r.animationDuration,easing:r.animationEasing});e.animations.push(E)}e.animations.forEach(function(M){return M.play()}),e.one("layoutready",r.ready),e.emit({type:"layoutready",layout:e}),Gu.all(e.animations.map(function(M){return M.promise()})).then(function(){e.one("layoutstop",r.stop),e.emit({type:"layoutstop",layout:e})})}else i.positions(m),r.fit&&a.fit(r.eles,r.padding),r.zoom!=null&&a.zoom(r.zoom),r.pan&&a.pan(r.pan),e.one("layoutready",r.ready),e.emit({type:"layoutready",layout:e}),e.one("layoutstop",r.stop),e.emit({type:"layoutstop",layout:e});return this},layout:function(e){var r=this.cy();return r.makeLayout(ft({},e,{eles:this}))}};jp.createLayout=jp.makeLayout=jp.layout;function xj(t,e,r){var n=r._private,i=n.styleCache=n.styleCache||[],a;return(a=i[t])!=null||(a=i[t]=e(r)),a}function gv(t,e){return t=Ql(t),function(n){return xj(t,e,n)}}function vv(t,e){t=Ql(t);var r=function(i){return e.call(i)};return function(){var i=this[0];if(i)return xj(t,r,i)}}var ln={recalculateRenderedStyle:function(e){var r=this.cy(),n=r.renderer(),i=r.styleEnabled();return n&&i&&n.recalculateRenderedStyle(this,e),this},dirtyStyleCache:function(){var e=this.cy(),r=function(a){return a._private.styleCache=null};if(e.hasCompoundNodes()){var n;n=this.spawnSelf().merge(this.descendants()).merge(this.parents()),n.merge(n.connectedEdges()),n.forEach(r)}else this.forEach(function(i){r(i),i.connectedEdges().forEach(r)});return this},updateStyle:function(e){var r=this._private.cy;if(!r.styleEnabled())return this;if(r.batching()){var n=r._private.batchStyleEles;return n.merge(this),this}var i=r.hasCompoundNodes(),a=this;e=!!(e||e===void 0),i&&(a=this.spawnSelf().merge(this.descendants()).merge(this.parents()));var s=a;return e?s.emitAndNotify("style"):s.emit("style"),a.forEach(function(l){return l._private.styleDirty=!0}),this},cleanStyle:function(){var e=this.cy();if(e.styleEnabled())for(var r=0;r<this.length;r++){var n=this[r];n._private.styleDirty&&(n._private.styleDirty=!1,e.style().apply(n))}},parsedStyle:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=this[0],i=n.cy();if(i.styleEnabled()&&n){n._private.styleDirty&&(n._private.styleDirty=!1,i.style().apply(n));var a=n._private.style[e];return a??(r?i.style().getDefaultProperty(e):null)}},numericStyle:function(e){var r=this[0];if(r.cy().styleEnabled()&&r){var n=r.pstyle(e);return n.pfValue!==void 0?n.pfValue:n.value}},numericStyleUnits:function(e){var r=this[0];if(r.cy().styleEnabled()&&r)return r.pstyle(e).units},renderedStyle:function(e){var r=this.cy();if(!r.styleEnabled())return this;var n=this[0];if(n)return r.style().getRenderedStyle(n,e)},style:function(e,r){var n=this.cy();if(!n.styleEnabled())return this;var i=!1,a=n.style();if(Bt(e)){var s=e;a.applyBypass(this,s,i),this.emitAndNotify("style")}else if(lt(e))if(r===void 0){var l=this[0];return l?a.getStylePropertyValue(l,e):void 0}else a.applyBypass(this,e,r,i),this.emitAndNotify("style");else if(e===void 0){var o=this[0];return o?a.getRawStyle(o):void 0}return this},removeStyle:function(e){var r=this.cy();if(!r.styleEnabled())return this;var n=!1,i=r.style(),a=this;if(e===void 0)for(var s=0;s<a.length;s++){var l=a[s];i.removeAllBypasses(l,n)}else{e=e.split(/\s+/);for(var o=0;o<a.length;o++){var c=a[o];i.removeBypasses(c,e,n)}}return this.emitAndNotify("style"),this},show:function(){return this.css("display","element"),this},hide:function(){return this.css("display","none"),this},effectiveOpacity:function(){var e=this.cy();if(!e.styleEnabled())return 1;var r=e.hasCompoundNodes(),n=this[0];if(n){var i=n._private,a=n.pstyle("opacity").value;if(!r)return a;var s=i.data.parent?n.parents():null;if(s)for(var l=0;l<s.length;l++){var o=s[l],c=o.pstyle("opacity").value;a=c*a}return a}},transparent:function(){var e=this.cy();if(!e.styleEnabled())return!1;var r=this[0],n=r.cy().hasCompoundNodes();if(r)return n?r.effectiveOpacity()===0:r.pstyle("opacity").value===0},backgrounding:function(){var e=this.cy();if(!e.styleEnabled())return!1;var r=this[0];return!!r._private.backgrounding}};function jb(t,e){var r=t._private,n=r.data.parent?t.parents():null;if(n)for(var i=0;i<n.length;i++){var a=n[i];if(!e(a))return!1}return!0}function YT(t){var e=t.ok,r=t.edgeOkViaNode||t.ok,n=t.parentOk||t.ok;return function(){var i=this.cy();if(!i.styleEnabled())return!0;var a=this[0],s=i.hasCompoundNodes();if(a){var l=a._private;if(!e(a))return!1;if(a.isNode())return!s||jb(a,n);var o=l.source,c=l.target;return r(o)&&(!s||jb(o,r))&&(o===c||r(c)&&(!s||jb(c,r)))}}}var Yu=gv("eleTakesUpSpace",function(t){return t.pstyle("display").value==="element"&&t.width()!==0&&(t.isNode()?t.height()!==0:!0)});ln.takesUpSpace=vv("takesUpSpace",YT({ok:Yu}));var CQ=gv("eleInteractive",function(t){return t.pstyle("events").value==="yes"&&t.pstyle("visibility").value==="visible"&&Yu(t)}),kQ=gv("parentInteractive",function(t){return t.pstyle("visibility").value==="visible"&&Yu(t)});ln.interactive=vv("interactive",YT({ok:CQ,parentOk:kQ,edgeOkViaNode:Yu}));ln.noninteractive=function(){var t=this[0];if(t)return!t.interactive()};var TQ=gv("eleVisible",function(t){return t.pstyle("visibility").value==="visible"&&t.pstyle("opacity").pfValue!==0&&Yu(t)}),EQ=Yu;ln.visible=vv("visible",YT({ok:TQ,edgeOkViaNode:EQ}));ln.hidden=function(){var t=this[0];if(t)return!t.visible()};ln.isBundledBezier=vv("isBundledBezier",function(){return this.cy().styleEnabled()?!this.removed()&&this.pstyle("curve-style").value==="bezier"&&this.takesUpSpace():!1});ln.bypass=ln.css=ln.style;ln.renderedCss=ln.renderedStyle;ln.removeBypass=ln.removeCss=ln.removeStyle;ln.pstyle=ln.parsedStyle;var Us={};function dN(t){return function(){var e=arguments,r=[];if(e.length===2){var n=e[0],i=e[1];this.on(t.event,n,i)}else if(e.length===1&&hr(e[0])){var a=e[0];this.on(t.event,a)}else if(e.length===0||e.length===1&&Zt(e[0])){for(var s=e.length===1?e[0]:null,l=0;l<this.length;l++){var o=this[l],c=!t.ableField||o._private[t.ableField],h=o._private[t.field]!=t.value;if(t.overrideAble){var d=t.overrideAble(o);if(d!==void 0&&(c=d,!d))return this}c&&(o._private[t.field]=t.value,h&&r.push(o))}var g=this.spawn(r);g.updateStyle(),g.emit(t.event),s&&g.emit(s)}return this}}function Xu(t){Us[t.field]=function(){var e=this[0];if(e){if(t.overrideField){var r=t.overrideField(e);if(r!==void 0)return r}return e._private[t.field]}},Us[t.on]=dN({event:t.on,field:t.field,ableField:t.ableField,overrideAble:t.overrideAble,value:!0}),Us[t.off]=dN({event:t.off,field:t.field,ableField:t.ableField,overrideAble:t.overrideAble,value:!1})}Xu({field:"locked",overrideField:function(e){return e.cy().autolock()?!0:void 0},on:"lock",off:"unlock"});Xu({field:"grabbable",overrideField:function(e){return e.cy().autoungrabify()||e.pannable()?!1:void 0},on:"grabify",off:"ungrabify"});Xu({field:"selected",ableField:"selectable",overrideAble:function(e){return e.cy().autounselectify()?!1:void 0},on:"select",off:"unselect"});Xu({field:"selectable",overrideField:function(e){return e.cy().autounselectify()?!1:void 0},on:"selectify",off:"unselectify"});Us.deselect=Us.unselect;Us.grabbed=function(){var t=this[0];if(t)return t._private.grabbed};Xu({field:"active",on:"activate",off:"unactivate"});Xu({field:"pannable",on:"panify",off:"unpanify"});Us.inactive=function(){var t=this[0];if(t)return!t._private.active};var mn={},pN=function(e){return function(n){for(var i=this,a=[],s=0;s<i.length;s++){var l=i[s];if(l.isNode()){for(var o=!1,c=l.connectedEdges(),h=0;h<c.length;h++){var d=c[h],g=d.source(),m=d.target();if(e.noIncomingEdges&&m===l&&g!==l||e.noOutgoingEdges&&g===l&&m!==l){o=!0;break}}o||a.push(l)}}return this.spawn(a,!0).filter(n)}},gN=function(e){return function(r){for(var n=this,i=[],a=0;a<n.length;a++){var s=n[a];if(s.isNode())for(var l=s.connectedEdges(),o=0;o<l.length;o++){var c=l[o],h=c.source(),d=c.target();e.outgoing&&h===s?(i.push(c),i.push(d)):e.incoming&&d===s&&(i.push(c),i.push(h))}}return this.spawn(i,!0).filter(r)}},vN=function(e){return function(r){for(var n=this,i=[],a={};;){var s=e.outgoing?n.outgoers():n.incomers();if(s.length===0)break;for(var l=!1,o=0;o<s.length;o++){var c=s[o],h=c.id();a[h]||(a[h]=!0,i.push(c),l=!0)}if(!l)break;n=s}return this.spawn(i,!0).filter(r)}};mn.clearTraversalCache=function(){for(var t=0;t<this.length;t++)this[t]._private.traversalCache=null};ft(mn,{roots:pN({noIncomingEdges:!0}),leaves:pN({noOutgoingEdges:!0}),outgoers:ki(gN({outgoing:!0}),"outgoers"),successors:vN({outgoing:!0}),incomers:ki(gN({incoming:!0}),"incomers"),predecessors:vN({})});ft(mn,{neighborhood:ki(function(t){for(var e=[],r=this.nodes(),n=0;n<r.length;n++)for(var i=r[n],a=i.connectedEdges(),s=0;s<a.length;s++){var l=a[s],o=l.source(),c=l.target(),h=i===o?c:o;h.length>0&&e.push(h[0]),e.push(l[0])}return this.spawn(e,!0).filter(t)},"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}});mn.neighbourhood=mn.neighborhood;mn.closedNeighbourhood=mn.closedNeighborhood;mn.openNeighbourhood=mn.openNeighborhood;ft(mn,{source:ki(function(e){var r=this[0],n;return r&&(n=r._private.source||r.cy().collection()),n&&e?n.filter(e):n},"source"),target:ki(function(e){var r=this[0],n;return r&&(n=r._private.target||r.cy().collection()),n&&e?n.filter(e):n},"target"),sources:mN({attr:"source"}),targets:mN({attr:"target"})});function mN(t){return function(r){for(var n=[],i=0;i<this.length;i++){var a=this[i],s=a._private[t.attr];s&&n.push(s)}return this.spawn(n,!0).filter(r)}}ft(mn,{edgesWith:ki(yN(),"edgesWith"),edgesTo:ki(yN({thisIsSrc:!0}),"edgesTo")});function yN(t){return function(r){var n=[],i=this._private.cy,a=t||{};lt(r)&&(r=i.$(r));for(var s=0;s<r.length;s++)for(var l=r[s]._private.edges,o=0;o<l.length;o++){var c=l[o],h=c._private.data,d=this.hasElementWithId(h.source)&&r.hasElementWithId(h.target),g=r.hasElementWithId(h.source)&&this.hasElementWithId(h.target),m=d||g;m&&((a.thisIsSrc||a.thisIsTgt)&&(a.thisIsSrc&&!d||a.thisIsTgt&&!g)||n.push(c))}return this.spawn(n,!0)}}ft(mn,{connectedEdges:ki(function(t){for(var e=[],r=this,n=0;n<r.length;n++){var i=r[n];if(i.isNode())for(var a=i._private.edges,s=0;s<a.length;s++){var l=a[s];e.push(l)}}return this.spawn(e,!0).filter(t)},"connectedEdges"),connectedNodes:ki(function(t){for(var e=[],r=this,n=0;n<r.length;n++){var i=r[n];i.isEdge()&&(e.push(i.source()[0]),e.push(i.target()[0]))}return this.spawn(e,!0).filter(t)},"connectedNodes"),parallelEdges:ki(bN(),"parallelEdges"),codirectedEdges:ki(bN({codirected:!0}),"codirectedEdges")});function bN(t){var e={codirected:!1};return t=ft({},e,t),function(n){for(var i=[],a=this.edges(),s=t,l=0;l<a.length;l++)for(var o=a[l],c=o._private,h=c.source,d=h._private.data.id,g=c.data.target,m=h._private.edges,y=0;y<m.length;y++){var b=m[y],x=b._private.data,w=x.target,S=x.source,k=w===g&&S===d,E=d===w&&g===S;(s.codirected&&k||!s.codirected&&(k||E))&&i.push(b)}return this.spawn(i,!0).filter(n)}}ft(mn,{components:function(e){var r=this,n=r.cy(),i=n.collection(),a=e==null?r.nodes():e.nodes(),s=[];e!=null&&a.empty()&&(a=e.sources());var l=function(h,d){i.merge(h),a.unmerge(h),d.merge(h)};if(a.empty())return r.spawn();var o=function(){var h=n.collection();s.push(h);var d=a[0];l(d,h),r.bfs({directed:!1,roots:d,visit:function(m){return l(m,h)}}),h.forEach(function(g){g.connectedEdges().forEach(function(m){r.has(m)&&h.has(m.source())&&h.has(m.target())&&h.merge(m)})})};do o();while(a.length>0);return s},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}});mn.componentsOf=mn.components;var on=function(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(e===void 0){ur("A collection must have a reference to the core");return}var a=new Ua,s=!1;if(!r)r=[];else if(r.length>0&&Bt(r[0])&&!hh(r[0])){s=!0;for(var l=[],o=new $u,c=0,h=r.length;c<h;c++){var d=r[c];d.data==null&&(d.data={});var g=d.data;if(g.id==null)g.id=Bq();else if(e.hasElementWithId(g.id)||o.has(g.id))continue;var m=new sv(e,d,!1);l.push(m),o.add(g.id)}r=l}this.length=0;for(var y=0,b=r.length;y<b;y++){var x=r[y][0];if(x!=null){var w=x._private.data.id;(!n||!a.has(w))&&(n&&a.set(w,{index:this.length,ele:x}),this[this.length]=x,this.length++)}}this._private={eles:this,cy:e,get map(){return this.lazyMap==null&&this.rebuildMap(),this.lazyMap},set map(S){this.lazyMap=S},rebuildMap:function(){for(var k=this.lazyMap=new Ua,E=this.eles,M=0;M<E.length;M++){var R=E[M];k.set(R.id(),{index:M,ele:R})}}},n&&(this._private.map=a),s&&!i&&this.restore()},rr=sv.prototype=on.prototype=Object.create(Array.prototype);rr.instanceString=function(){return"collection"};rr.spawn=function(t,e){return new on(this.cy(),t,e)};rr.spawnSelf=function(){return this.spawn(this)};rr.cy=function(){return this._private.cy};rr.renderer=function(){return this._private.cy.renderer()};rr.element=function(){return this[0]};rr.collection=function(){return xq(this)?this:new on(this._private.cy,[this])};rr.unique=function(){return new on(this._private.cy,this,!0)};rr.hasElementWithId=function(t){return t=""+t,this._private.map.has(t)};rr.getElementById=function(t){t=""+t;var e=this._private.cy,r=this._private.map.get(t);return r?r.ele:new on(e)};rr.$id=rr.getElementById;rr.poolIndex=function(){var t=this._private.cy,e=t._private.elements,r=this[0]._private.data.id;return e._private.map.get(r).index};rr.indexOf=function(t){var e=t[0]._private.data.id;return this._private.map.get(e).index};rr.indexOfId=function(t){return t=""+t,this._private.map.get(t).index};rr.json=function(t){var e=this.element(),r=this.cy();if(e==null&&t)return this;if(e!=null){var n=e._private;if(Bt(t)){if(r.startBatch(),t.data){e.data(t.data);var i=n.data;if(e.isEdge()){var a=!1,s={},l=t.data.source,o=t.data.target;l!=null&&l!=i.source&&(s.source=""+l,a=!0),o!=null&&o!=i.target&&(s.target=""+o,a=!0),a&&(e=e.move(s))}else{var c="parent"in t.data,h=t.data.parent;c&&(h!=null||i.parent!=null)&&h!=i.parent&&(h===void 0&&(h=null),h!=null&&(h=""+h),e=e.move({parent:h}))}}t.position&&e.position(t.position);var d=function(b,x,w){var S=t[b];S!=null&&S!==n[b]&&(S?e[x]():e[w]())};return d("removed","remove","restore"),d("selected","select","unselect"),d("selectable","selectify","unselectify"),d("locked","lock","unlock"),d("grabbable","grabify","ungrabify"),d("pannable","panify","unpanify"),t.classes!=null&&e.classes(t.classes),r.endBatch(),this}else if(t===void 0){var g={data:la(n.data),position:la(n.position),group:n.group,removed:n.removed,selected:n.selected,selectable:n.selectable,locked:n.locked,grabbable:n.grabbable,pannable:n.pannable,classes:null};g.classes="";var m=0;return n.classes.forEach(function(y){return g.classes+=m++===0?y:" "+y}),g}}};rr.jsons=function(){for(var t=[],e=0;e<this.length;e++){var r=this[e],n=r.json();t.push(n)}return t};rr.clone=function(){for(var t=this.cy(),e=[],r=0;r<this.length;r++){var n=this[r],i=n.json(),a=new sv(t,i,!1);e.push(a)}return new on(t,e)};rr.copy=rr.clone;rr.restore=function(){for(var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=this,n=r.cy(),i=n._private,a=[],s=[],l,o=0,c=r.length;o<c;o++){var h=r[o];e&&!h.removed()||(h.isNode()?a.push(h):s.push(h))}l=a.concat(s);var d,g=function(){l.splice(d,1),d--};for(d=0;d<l.length;d++){var m=l[d],y=m._private,b=y.data;if(m.clearTraversalCache(),!(!e&&!y.removed)){if(b.id===void 0)b.id=Bq();else if(qe(b.id))b.id=""+b.id;else if(Ys(b.id)||!lt(b.id)){ur("Can not create element with invalid string ID `"+b.id+"`"),g();continue}else if(n.hasElementWithId(b.id)){ur("Can not create second element with ID `"+b.id+"`"),g();continue}}var x=b.id;if(m.isNode()){var w=y.position;w.x==null&&(w.x=0),w.y==null&&(w.y=0)}if(m.isEdge()){for(var S=m,k=["source","target"],E=k.length,M=!1,R=0;R<E;R++){var O=k[R],N=b[O];qe(N)&&(N=b[O]=""+b[O]),N==null||N===""?(ur("Can not create edge `"+x+"` with unspecified "+O),M=!0):n.hasElementWithId(N)||(ur("Can not create edge `"+x+"` with nonexistant "+O+" `"+N+"`"),M=!0)}if(M){g();continue}var B=n.getElementById(b.source),D=n.getElementById(b.target);B.same(D)?B._private.edges.push(S):(B._private.edges.push(S),D._private.edges.push(S)),S._private.source=B,S._private.target=D}y.map=new Ua,y.map.set(x,{ele:m,index:0}),y.removed=!1,e&&n.addToPool(m)}for(var _=0;_<a.length;_++){var P=a[_],z=P._private.data;qe(z.parent)&&(z.parent=""+z.parent);var H=z.parent,$=H!=null;if($||P._private.parent){var q=P._private.parent?n.collection().merge(P._private.parent):n.getElementById(H);if(q.empty())z.parent=void 0;else if(q[0].removed())jt("Node added with missing parent, reference to parent removed"),z.parent=void 0,P._private.parent=null;else{for(var V=!1,X=q;!X.empty();){if(P.same(X)){V=!0,z.parent=void 0;break}X=X.parent()}V||(q[0]._private.children.push(P),P._private.parent=q[0],i.hasCompoundNodes=!0)}}}if(l.length>0){for(var ee=l.length===r.length?r:new on(n,l),te=0;te<ee.length;te++){var I=ee[te];I.isNode()||(I.parallelEdges().clearTraversalCache(),I.source().clearTraversalCache(),I.target().clearTraversalCache())}var G;i.hasCompoundNodes?G=n.collection().merge(ee).merge(ee.connectedNodes()).merge(ee.parent()):G=ee,G.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(t),t?ee.emitAndNotify("add"):e&&ee.emit("add")}return r};rr.removed=function(){var t=this[0];return t&&t._private.removed};rr.inside=function(){var t=this[0];return t&&!t._private.removed};rr.remove=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=this,n=[],i={},a=r._private.cy;function s(H){for(var $=H._private.edges,q=0;q<$.length;q++)o($[q])}function l(H){for(var $=H._private.children,q=0;q<$.length;q++)o($[q])}function o(H){var $=i[H.id()];e&&H.removed()||$||(i[H.id()]=!0,H.isNode()?(n.push(H),s(H),l(H)):n.unshift(H))}for(var c=0,h=r.length;c<h;c++){var d=r[c];o(d)}function g(H,$){var q=H._private.edges;Xs(q,$),H.clearTraversalCache()}function m(H){H.clearTraversalCache()}var y=[];y.ids={};function b(H,$){$=$[0],H=H[0];var q=H._private.children,V=H.id();Xs(q,$),$._private.parent=null,y.ids[V]||(y.ids[V]=!0,y.push(H))}r.dirtyCompoundBoundsCache(),e&&a.removeFromPool(n);for(var x=0;x<n.length;x++){var w=n[x];if(w.isEdge()){var S=w.source()[0],k=w.target()[0];g(S,w),g(k,w);for(var E=w.parallelEdges(),M=0;M<E.length;M++){var R=E[M];m(R),R.isBundledBezier()&&R.dirtyBoundingBoxCache()}}else{var O=w.parent();O.length!==0&&b(O,w)}e&&(w._private.removed=!0)}var N=a._private.elements;a._private.hasCompoundNodes=!1;for(var B=0;B<N.length;B++){var D=N[B];if(D.isParent()){a._private.hasCompoundNodes=!0;break}}var _=new on(this.cy(),n);_.size()>0&&(t?_.emitAndNotify("remove"):e&&_.emit("remove"));for(var P=0;P<y.length;P++){var z=y[P];(!e||!z.removed())&&z.updateStyle()}return _};rr.move=function(t){var e=this._private.cy,r=this,n=!1,i=!1,a=function(y){return y==null?y:""+y};if(t.source!==void 0||t.target!==void 0){var s=a(t.source),l=a(t.target),o=s!=null&&e.hasElementWithId(s),c=l!=null&&e.hasElementWithId(l);(o||c)&&(e.batch(function(){r.remove(n,i),r.emitAndNotify("moveout");for(var m=0;m<r.length;m++){var y=r[m],b=y._private.data;y.isEdge()&&(o&&(b.source=s),c&&(b.target=l))}r.restore(n,i)}),r.emitAndNotify("move"))}else if(t.parent!==void 0){var h=a(t.parent),d=h===null||e.hasElementWithId(h);if(d){var g=h===null?void 0:h;e.batch(function(){var m=r.remove(n,i);m.emitAndNotify("moveout");for(var y=0;y<r.length;y++){var b=r[y],x=b._private.data;b.isNode()&&(x.parent=g)}m.restore(n,i)}),r.emitAndNotify("move")}}return this};[Gq,zW,qp,Vs,Pu,JW,dv,gQ,mj,yj,xQ,yg,jp,ln,Us,mn].forEach(function(t){ft(rr,t)});var AQ={add:function(e){var r,n=this;if(fi(e)){var i=e;if(i._private.cy===n)r=i.restore();else{for(var a=[],s=0;s<i.length;s++){var l=i[s];a.push(l.json())}r=new on(n,a)}}else if(Zt(e)){var o=e;r=new on(n,o)}else if(Bt(e)&&(Zt(e.nodes)||Zt(e.edges))){for(var c=e,h=[],d=["nodes","edges"],g=0,m=d.length;g<m;g++){var y=d[g],b=c[y];if(Zt(b))for(var x=0,w=b.length;x<w;x++){var S=ft({group:y},b[x]);h.push(S)}}r=new on(n,h)}else{var k=e;r=new sv(n,k).collection()}return r},remove:function(e){if(!fi(e)){if(lt(e)){var r=e;e=this.$(r)}}return e.remove()}};function OQ(t,e,r,n){var i=4,a=.001,s=1e-7,l=10,o=11,c=1/(o-1),h=typeof Float32Array<"u";if(arguments.length!==4)return!1;for(var d=0;d<4;++d)if(typeof arguments[d]!="number"||isNaN(arguments[d])||!isFinite(arguments[d]))return!1;t=Math.min(t,1),r=Math.min(r,1),t=Math.max(t,0),r=Math.max(r,0);var g=h?new Float32Array(o):new Array(o);function m(D,_){return 1-3*_+3*D}function y(D,_){return 3*_-6*D}function b(D){return 3*D}function x(D,_,P){return((m(_,P)*D+y(_,P))*D+b(_))*D}function w(D,_,P){return 3*m(_,P)*D*D+2*y(_,P)*D+b(_)}function S(D,_){for(var P=0;P<i;++P){var z=w(_,t,r);if(z===0)return _;var H=x(_,t,r)-D;_-=H/z}return _}function k(){for(var D=0;D<o;++D)g[D]=x(D*c,t,r)}function E(D,_,P){var z,H,$=0;do H=_+(P-_)/2,z=x(H,t,r)-D,z>0?P=H:_=H;while(Math.abs(z)>s&&++$<l);return H}function M(D){for(var _=0,P=1,z=o-1;P!==z&&g[P]<=D;++P)_+=c;--P;var H=(D-g[P])/(g[P+1]-g[P]),$=_+H*c,q=w($,t,r);return q>=a?S(D,$):q===0?$:E(D,_,_+c)}var R=!1;function O(){R=!0,(t!==e||r!==n)&&k()}var N=function(_){return R||O(),t===e&&r===n?_:_===0?0:_===1?1:x(M(_),e,n)};N.getControlPoints=function(){return[{x:t,y:e},{x:r,y:n}]};var B="generateBezier("+[t,e,r,n]+")";return N.toString=function(){return B},N}var MQ=(function(){function t(n){return-n.tension*n.x-n.friction*n.v}function e(n,i,a){var s={x:n.x+a.dx*i,v:n.v+a.dv*i,tension:n.tension,friction:n.friction};return{dx:s.v,dv:t(s)}}function r(n,i){var a={dx:n.v,dv:t(n)},s=e(n,i*.5,a),l=e(n,i*.5,s),o=e(n,i,l),c=1/6*(a.dx+2*(s.dx+l.dx)+o.dx),h=1/6*(a.dv+2*(s.dv+l.dv)+o.dv);return n.x=n.x+c*i,n.v=n.v+h*i,n}return function n(i,a,s){var l={x:-1,v:0,tension:null,friction:null},o=[0],c=0,h=1/1e4,d=16/1e3,g,m,y;for(i=parseFloat(i)||500,a=parseFloat(a)||20,s=s||null,l.tension=i,l.friction=a,g=s!==null,g?(c=n(i,a),m=c/s*d):m=d;y=r(y||l,m),o.push(1+y.x),c+=16,Math.abs(y.x)>h&&Math.abs(y.v)>h;);return g?function(b){return o[b*(o.length-1)|0]}:c}})(),er=function(e,r,n,i){var a=OQ(e,r,n,i);return function(s,l,o){return s+(l-s)*a(o)}},Fp={linear:function(e,r,n){return e+(r-e)*n},ease:er(.25,.1,.25,1),"ease-in":er(.42,0,1,1),"ease-out":er(0,0,.58,1),"ease-in-out":er(.42,0,.58,1),"ease-in-sine":er(.47,0,.745,.715),"ease-out-sine":er(.39,.575,.565,1),"ease-in-out-sine":er(.445,.05,.55,.95),"ease-in-quad":er(.55,.085,.68,.53),"ease-out-quad":er(.25,.46,.45,.94),"ease-in-out-quad":er(.455,.03,.515,.955),"ease-in-cubic":er(.55,.055,.675,.19),"ease-out-cubic":er(.215,.61,.355,1),"ease-in-out-cubic":er(.645,.045,.355,1),"ease-in-quart":er(.895,.03,.685,.22),"ease-out-quart":er(.165,.84,.44,1),"ease-in-out-quart":er(.77,0,.175,1),"ease-in-quint":er(.755,.05,.855,.06),"ease-out-quint":er(.23,1,.32,1),"ease-in-out-quint":er(.86,0,.07,1),"ease-in-expo":er(.95,.05,.795,.035),"ease-out-expo":er(.19,1,.22,1),"ease-in-out-expo":er(1,0,0,1),"ease-in-circ":er(.6,.04,.98,.335),"ease-out-circ":er(.075,.82,.165,1),"ease-in-out-circ":er(.785,.135,.15,.86),spring:function(e,r,n){if(n===0)return Fp.linear;var i=MQ(e,r,n);return function(a,s,l){return a+(s-a)*i(l)}},"cubic-bezier":er};function xN(t,e,r,n,i){if(n===1||e===r)return r;var a=i(e,r,n);return t==null||((t.roundValue||t.color)&&(a=Math.round(a)),t.min!==void 0&&(a=Math.max(a,t.min)),t.max!==void 0&&(a=Math.min(a,t.max))),a}function wN(t,e){return t.pfValue!=null||t.value!=null?t.pfValue!=null&&(e==null||e.type.units!=="%")?t.pfValue:t.value:t}function eu(t,e,r,n,i){var a=i!=null?i.type:null;r<0?r=0:r>1&&(r=1);var s=wN(t,i),l=wN(e,i);if(qe(s)&&qe(l))return xN(a,s,l,r,n);if(Zt(s)&&Zt(l)){for(var o=[],c=0;c<l.length;c++){var h=s[c],d=l[c];if(h!=null&&d!=null){var g=xN(a,h,d,r,n);o.push(g)}else o.push(d)}return o}}function RQ(t,e,r,n){var i=!n,a=t._private,s=e._private,l=s.easing,o=s.startTime,c=n?t:t.cy(),h=c.style();if(!s.easingImpl)if(l==null)s.easingImpl=Fp.linear;else{var d;if(lt(l)){var g=h.parse("transition-timing-function",l);d=g.value}else d=l;var m,y;lt(d)?(m=d,y=[]):(m=d[1],y=d.slice(2).map(function(ee){return+ee})),y.length>0?(m==="spring"&&y.push(s.duration),s.easingImpl=Fp[m].apply(null,y)):s.easingImpl=Fp[m]}var b=s.easingImpl,x;if(s.duration===0?x=1:x=(r-o)/s.duration,s.applying&&(x=s.progress),x<0?x=0:x>1&&(x=1),s.delay==null){var w=s.startPosition,S=s.position;if(S&&i&&!t.locked()){var k={};Jc(w.x,S.x)&&(k.x=eu(w.x,S.x,x,b)),Jc(w.y,S.y)&&(k.y=eu(w.y,S.y,x,b)),t.position(k)}var E=s.startPan,M=s.pan,R=a.pan,O=M!=null&&n;O&&(Jc(E.x,M.x)&&(R.x=eu(E.x,M.x,x,b)),Jc(E.y,M.y)&&(R.y=eu(E.y,M.y,x,b)),t.emit("pan"));var N=s.startZoom,B=s.zoom,D=B!=null&&n;D&&(Jc(N,B)&&(a.zoom=qf(a.minZoom,eu(N,B,x,b),a.maxZoom)),t.emit("zoom")),(O||D)&&t.emit("viewport");var _=s.style;if(_&&_.length>0&&i){for(var P=0;P<_.length;P++){var z=_[P],H=z.name,$=z,q=s.startStyle[H],V=h.properties[q.name],X=eu(q,$,x,b,V);h.overrideBypass(t,H,X)}t.emit("style")}}return s.progress=x,x}function Jc(t,e){return t==null||e==null?!1:qe(t)&&qe(e)?!0:!!(t&&e)}function DQ(t,e,r,n){var i=e._private;i.started=!0,i.startTime=r-i.progress*i.duration}function SN(t,e){var r=e._private.aniEles,n=[];function i(h,d){var g=h._private,m=g.animation.current,y=g.animation.queue,b=!1;if(m.length===0){var x=y.shift();x&&m.push(x)}for(var w=function(R){for(var O=R.length-1;O>=0;O--){var N=R[O];N()}R.splice(0,R.length)},S=m.length-1;S>=0;S--){var k=m[S],E=k._private;if(E.stopped){m.splice(S,1),E.hooked=!1,E.playing=!1,E.started=!1,w(E.frames);continue}!E.playing&&!E.applying||(E.playing&&E.applying&&(E.applying=!1),E.started||DQ(h,k,t),RQ(h,k,t,d),E.applying&&(E.applying=!1),w(E.frames),E.step!=null&&E.step(t),k.completed()&&(m.splice(S,1),E.hooked=!1,E.playing=!1,E.started=!1,w(E.completes)),b=!0)}return!d&&m.length===0&&y.length===0&&n.push(h),b}for(var a=!1,s=0;s<r.length;s++){var l=r[s],o=i(l);a=a||o}var c=i(e,!0);(a||c)&&(r.length>0?e.notify("draw",r):e.notify("draw")),r.unmerge(n),e.emit("step")}var _Q={animate:qt.animate(),animation:qt.animation(),animated:qt.animated(),clearQueue:qt.clearQueue(),delay:qt.delay(),delayAnimation:qt.delayAnimation(),stop:qt.stop(),addToAnimationPool:function(e){var r=this;r.styleEnabled()&&r._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,!e.styleEnabled())return;function r(){e._private.animationsRunning&&dg(function(a){SN(a,e),r()})}var n=e.renderer();n&&n.beforeRender?n.beforeRender(function(a,s){SN(s,e)},n.beforeRenderPriorities.animations):r()}},NQ={qualifierCompare:function(e,r){return e==null||r==null?e==null&&r==null:e.sameText(r)},eventMatches:function(e,r,n){var i=r.qualifier;return i!=null?e!==n.target&&hh(n.target)&&i.matches(n.target):!0},addEventFields:function(e,r){r.cy=e,r.target=e},callbackContext:function(e,r,n){return r.qualifier!=null?n.target:e}},lp=function(e){return lt(e)?new Qs(e):e},wj={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new pv(NQ,this)),this},emitter:function(){return this._private.emitter},on:function(e,r,n){return this.emitter().on(e,lp(r),n),this},removeListener:function(e,r,n){return this.emitter().removeListener(e,lp(r),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,r,n){return this.emitter().one(e,lp(r),n),this},once:function(e,r,n){return this.emitter().one(e,lp(r),n),this},emit:function(e,r){return this.emitter().emit(e,r),this},emitAndNotify:function(e,r){return this.emit(e),this.notify(e,r),this}};qt.eventAliasesOn(wj);var fk={png:function(e){var r=this._private.renderer;return e=e||{},r.png(e)},jpg:function(e){var r=this._private.renderer;return e=e||{},e.bg=e.bg||"#fff",r.jpg(e)}};fk.jpeg=fk.jpg;var Hp={layout:function(e){var r=this;if(e==null){ur("Layout options must be specified to make a layout");return}if(e.name==null){ur("A `name` must be specified to make a layout");return}var n=e.name,i=r.extension("layout",n);if(i==null){ur("No such layout `"+n+"` found. Did you forget to import it and `cytoscape.use()` it?");return}var a;lt(e.eles)?a=r.$(e.eles):a=e.eles!=null?e.eles:r.$();var s=new i(ft({},e,{cy:r,eles:a}));return s}};Hp.createLayout=Hp.makeLayout=Hp.layout;var BQ={notify:function(e,r){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var i=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();r!=null&&i.merge(r);return}if(n.notificationsEnabled){var a=this.renderer();this.destroyed()||!a||a.notify(e,r)}},notifications:function(e){var r=this._private;return e===void 0?r.notificationsEnabled:(r.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var e=this._private;return e.batchCount==null&&(e.batchCount=0),e.batchCount===0&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(e.batchCount===0)return this;if(e.batchCount--,e.batchCount===0){e.batchStyleEles.updateStyle();var r=this.renderer();Object.keys(e.batchNotifications).forEach(function(n){var i=e.batchNotifications[n];i.empty()?r.notify(n):r.notify(n,i)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var r=this;return this.batch(function(){for(var n=Object.keys(e),i=0;i<n.length;i++){var a=n[i],s=e[a],l=r.getElementById(a);l.data(s)}})}},LQ=cn({hideEdgesOnViewport:!1,textureOnViewport:!1,motionBlur:!1,motionBlurOpacity:.05,pixelRatio:void 0,desktopTapThreshold:4,touchTapThreshold:8,wheelSensitivity:1,debug:!1,showFps:!1,webgl:!1,webglDebug:!1,webglDebugShowAtlases:!1,webglTexSize:2048,webglTexRows:36,webglTexRowsNodes:18,webglBatchSize:2048,webglTexPerBatch:14,webglBgColor:[255,255,255]}),hk={renderTo:function(e,r,n,i){var a=this._private.renderer;return a.renderTo(e,r,n,i),this},renderer:function(){return this._private.renderer},forceRender:function(){return this.notify("draw"),this},resize:function(){return this.invalidateSize(),this.emitAndNotify("resize"),this},initRenderer:function(e){var r=this,n=r.extension("renderer",e.name);if(n==null){ur("Can not initialise: No such renderer `".concat(e.name,"` found. Did you forget to import it and `cytoscape.use()` it?"));return}e.wheelSensitivity!==void 0&&jt("You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.");var i=LQ(e);i.cy=r,r._private.renderer=new n(i),this.notify("init")},destroyRenderer:function(){var e=this;e.notify("destroy");var r=e.container();if(r)for(r._cyreg=null;r.childNodes.length>0;)r.removeChild(r.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach(function(n){var i=n._private;i.rscratch={},i.rstyle={},i.animation.current=[],i.animation.queue=[]})},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};hk.invalidateDimensions=hk.resize;var Vp={collection:function(e,r){return lt(e)?this.$(e):fi(e)?e.collection():Zt(e)?(r||(r={}),new on(this,e,r.unique,r.removed)):new on(this)},nodes:function(e){var r=this.$(function(n){return n.isNode()});return e?r.filter(e):r},edges:function(e){var r=this.$(function(n){return n.isEdge()});return e?r.filter(e):r},$:function(e){var r=this._private.elements;return e?r.filter(e):r.spawnSelf()},mutableElements:function(){return this._private.elements}};Vp.elements=Vp.filter=Vp.$;var Kr={},xf="t",PQ="f";Kr.apply=function(t){for(var e=this,r=e._private,n=r.cy,i=n.collection(),a=0;a<t.length;a++){var s=t[a],l=e.getContextMeta(s);if(!l.empty){var o=e.getContextStyle(l),c=e.applyContextStyle(l,o,s);s._private.appliedInitStyle?e.updateTransitions(s,c.diffProps):s._private.appliedInitStyle=!0;var h=e.updateStyleHints(s);h&&i.push(s)}}return i};Kr.getPropertiesDiff=function(t,e){var r=this,n=r._private.propDiffs=r._private.propDiffs||{},i=t+"-"+e,a=n[i];if(a)return a;for(var s=[],l={},o=0;o<r.length;o++){var c=r[o],h=t[o]===xf,d=e[o]===xf,g=h!==d,m=c.mappedProperties.length>0;if(g||d&&m){var y=void 0;g&&m||g?y=c.properties:m&&(y=c.mappedProperties);for(var b=0;b<y.length;b++){for(var x=y[b],w=x.name,S=!1,k=o+1;k<r.length;k++){var E=r[k],M=e[k]===xf;if(M&&(S=E.properties[x.name]!=null,S))break}!l[w]&&!S&&(l[w]=!0,s.push(w))}}}return n[i]=s,s};Kr.getContextMeta=function(t){for(var e=this,r="",n,i=t._private.styleCxtKey||"",a=0;a<e.length;a++){var s=e[a],l=s.selector&&s.selector.matches(t);l?r+=xf:r+=PQ}return n=e.getPropertiesDiff(i,r),t._private.styleCxtKey=r,{key:r,diffPropNames:n,empty:n.length===0}};Kr.getContextStyle=function(t){var e=t.key,r=this,n=this._private.contextStyles=this._private.contextStyles||{};if(n[e])return n[e];for(var i={_private:{key:e}},a=0;a<r.length;a++){var s=r[a],l=e[a]===xf;if(l)for(var o=0;o<s.properties.length;o++){var c=s.properties[o];i[c.name]=c}}return n[e]=i,i};Kr.applyContextStyle=function(t,e,r){for(var n=this,i=t.diffPropNames,a={},s=n.types,l=0;l<i.length;l++){var o=i[l],c=e[o],h=r.pstyle(o);if(!c)if(h)h.bypass?c={name:o,deleteBypassed:!0}:c={name:o,delete:!0};else continue;if(h!==c){if(c.mapped===s.fn&&h!=null&&h.mapping!=null&&h.mapping.value===c.value){var d=h.mapping,g=d.fnValue=c.value(r);if(g===d.prevFnValue)continue}var m=a[o]={prev:h};n.applyParsedProperty(r,c),m.next=r.pstyle(o),m.next&&m.next.bypass&&(m.next=m.next.bypassed)}}return{diffProps:a}};Kr.updateStyleHints=function(t){var e=t._private,r=this,n=r.propertyGroupNames,i=r.propertyGroupKeys,a=function(Q,K,ue){return r.getPropertiesHash(Q,K,ue)},s=e.styleKey;if(t.removed())return!1;var l=e.group==="nodes",o=t._private.style;n=Object.keys(o);for(var c=0;c<i.length;c++){var h=i[c];e.styleKeys[h]=[Pl,lu]}for(var d=function(Q,K){return e.styleKeys[K][0]=Pf(Q,e.styleKeys[K][0])},g=function(Q,K){return e.styleKeys[K][1]=zf(Q,e.styleKeys[K][1])},m=function(Q,K){d(Q,K),g(Q,K)},y=function(Q,K){for(var ue=0;ue<Q.length;ue++){var Se=Q.charCodeAt(ue);d(Se,K),g(Se,K)}},b=2e9,x=function(Q){return-128<Q&&Q<128&&Math.floor(Q)!==Q?b-(Q*1024|0):Q},w=0;w<n.length;w++){var S=n[w],k=o[S];if(k!=null){var E=this.properties[S],M=E.type,R=E.groupKey,O=void 0;E.hashOverride!=null?O=E.hashOverride(t,k):k.pfValue!=null&&(O=k.pfValue);var N=E.enums==null?k.value:null,B=O!=null,D=N!=null,_=B||D,P=k.units;if(M.number&&_&&!M.multiple){var z=B?O:N;m(x(z),R),!B&&P!=null&&y(P,R)}else y(k.strValue,R)}}for(var H=[Pl,lu],$=0;$<i.length;$++){var q=i[$],V=e.styleKeys[q];H[0]=Pf(V[0],H[0]),H[1]=zf(V[1],H[1])}e.styleKey=ZG(H[0],H[1]);var X=e.styleKeys;e.labelDimsKey=Ds(X.labelDimensions);var ee=a(t,["label"],X.labelDimensions);if(e.labelKey=Ds(ee),e.labelStyleKey=Ds(Jd(X.commonLabel,ee)),!l){var te=a(t,["source-label"],X.labelDimensions);e.sourceLabelKey=Ds(te),e.sourceLabelStyleKey=Ds(Jd(X.commonLabel,te));var I=a(t,["target-label"],X.labelDimensions);e.targetLabelKey=Ds(I),e.targetLabelStyleKey=Ds(Jd(X.commonLabel,I))}if(l){var G=e.styleKeys,re=G.nodeBody,Y=G.nodeBorder,W=G.nodeOutline,Z=G.backgroundImage,ie=G.compound,we=G.pie,de=G.stripe,se=[re,Y,W,Z,ie,we,de].filter(function(j){return j!=null}).reduce(Jd,[Pl,lu]);e.nodeKey=Ds(se),e.hasPie=we!=null&&we[0]!==Pl&&we[1]!==lu,e.hasStripe=de!=null&&de[0]!==Pl&&de[1]!==lu}return s!==e.styleKey};Kr.clearStyleHints=function(t){var e=t._private;e.styleCxtKey="",e.styleKeys={},e.styleKey=null,e.labelKey=null,e.labelStyleKey=null,e.sourceLabelKey=null,e.sourceLabelStyleKey=null,e.targetLabelKey=null,e.targetLabelStyleKey=null,e.nodeKey=null,e.hasPie=null,e.hasStripe=null};Kr.applyParsedProperty=function(t,e){var r=this,n=e,i=t._private.style,a,s=r.types,l=r.properties[n.name].type,o=n.bypass,c=i[n.name],h=c&&c.bypass,d=t._private,g="mapping",m=function(re){return re==null?null:re.pfValue!=null?re.pfValue:re.value},y=function(){var re=m(c),Y=m(n);r.checkTriggers(t,n.name,re,Y)};if(e.name==="curve-style"&&t.isEdge()&&(e.value!=="bezier"&&t.isLoop()||e.value==="haystack"&&(t.source().isParent()||t.target().isParent()))&&(n=e=this.parse(e.name,"bezier",o)),n.delete)return i[n.name]=void 0,y(),!0;if(n.deleteBypassed)return c?c.bypass?(c.bypassed=void 0,y(),!0):!1:(y(),!0);if(n.deleteBypass)return c?c.bypass?(i[n.name]=c.bypassed,y(),!0):!1:(y(),!0);var b=function(){jt("Do not assign mappings to elements without corresponding data (i.e. ele `"+t.id()+"` has no mapping for property `"+n.name+"` with data field `"+n.field+"`); try a `["+n.field+"]` selector to limit scope to elements with `"+n.field+"` defined")};switch(n.mapped){case s.mapData:{for(var x=n.field.split("."),w=d.data,S=0;S<x.length&&w;S++){var k=x[S];w=w[k]}if(w==null)return b(),!1;var E;if(qe(w)){var M=n.fieldMax-n.fieldMin;M===0?E=0:E=(w-n.fieldMin)/M}else return jt("Do not use continuous mappers without specifying numeric data (i.e. `"+n.field+": "+w+"` for `"+t.id()+"` is non-numeric)"),!1;if(E<0?E=0:E>1&&(E=1),l.color){var R=n.valueMin[0],O=n.valueMax[0],N=n.valueMin[1],B=n.valueMax[1],D=n.valueMin[2],_=n.valueMax[2],P=n.valueMin[3]==null?1:n.valueMin[3],z=n.valueMax[3]==null?1:n.valueMax[3],H=[Math.round(R+(O-R)*E),Math.round(N+(B-N)*E),Math.round(D+(_-D)*E),Math.round(P+(z-P)*E)];a={bypass:n.bypass,name:n.name,value:H,strValue:"rgb("+H[0]+", "+H[1]+", "+H[2]+")"}}else if(l.number){var $=n.valueMin+(n.valueMax-n.valueMin)*E;a=this.parse(n.name,$,n.bypass,g)}else return!1;if(!a)return b(),!1;a.mapping=n,n=a;break}case s.data:{for(var q=n.field.split("."),V=d.data,X=0;X<q.length&&V;X++){var ee=q[X];V=V[ee]}if(V!=null&&(a=this.parse(n.name,V,n.bypass,g)),!a)return b(),!1;a.mapping=n,n=a;break}case s.fn:{var te=n.value,I=n.fnValue!=null?n.fnValue:te(t);if(n.prevFnValue=I,I==null)return jt("Custom function mappers may not return null (i.e. `"+n.name+"` for ele `"+t.id()+"` is null)"),!1;if(a=this.parse(n.name,I,n.bypass,g),!a)return jt("Custom function mappers may not return invalid values for the property type (i.e. `"+n.name+"` for ele `"+t.id()+"` is invalid)"),!1;a.mapping=la(n),n=a;break}case void 0:break;default:return!1}return o?(h?n.bypassed=c.bypassed:n.bypassed=c,i[n.name]=n):h?c.bypassed=n:i[n.name]=n,y(),!0};Kr.cleanElements=function(t,e){for(var r=0;r<t.length;r++){var n=t[r];if(this.clearStyleHints(n),n.dirtyCompoundBoundsCache(),n.dirtyBoundingBoxCache(),!e)n._private.style={};else for(var i=n._private.style,a=Object.keys(i),s=0;s<a.length;s++){var l=a[s],o=i[l];o!=null&&(o.bypass?o.bypassed=null:i[l]=null)}}};Kr.update=function(){var t=this._private.cy,e=t.mutableElements();e.updateStyle()};Kr.updateTransitions=function(t,e){var r=this,n=t._private,i=t.pstyle("transition-property").value,a=t.pstyle("transition-duration").pfValue,s=t.pstyle("transition-delay").pfValue;if(i.length>0&&a>0){for(var l={},o=!1,c=0;c<i.length;c++){var h=i[c],d=t.pstyle(h),g=e[h];if(g){var m=g.prev,y=m,b=g.next!=null?g.next:d,x=!1,w=void 0,S=1e-6;y&&(qe(y.pfValue)&&qe(b.pfValue)?(x=b.pfValue-y.pfValue,w=y.pfValue+S*x):qe(y.value)&&qe(b.value)?(x=b.value-y.value,w=y.value+S*x):Zt(y.value)&&Zt(b.value)&&(x=y.value[0]!==b.value[0]||y.value[1]!==b.value[1]||y.value[2]!==b.value[2],w=y.strValue),x&&(l[h]=b.strValue,this.applyBypass(t,h,w),o=!0))}}if(!o)return;n.transitioning=!0,new Gu(function(k){s>0?t.delayAnimation(s).play().promise().then(k):k()}).then(function(){return t.animation({style:l,duration:a,easing:t.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){r.removeBypasses(t,i),t.emitAndNotify("style"),n.transitioning=!1})}else n.transitioning&&(this.removeBypasses(t,i),t.emitAndNotify("style"),n.transitioning=!1)};Kr.checkTrigger=function(t,e,r,n,i,a){var s=this.properties[e],l=i(s);t.removed()||l!=null&&l(r,n,t)&&a(s)};Kr.checkZOrderTrigger=function(t,e,r,n){var i=this;this.checkTrigger(t,e,r,n,function(a){return a.triggersZOrder},function(){i._private.cy.notify("zorder",t)})};Kr.checkBoundsTrigger=function(t,e,r,n){this.checkTrigger(t,e,r,n,function(i){return i.triggersBounds},function(i){t.dirtyCompoundBoundsCache(),t.dirtyBoundingBoxCache()})};Kr.checkConnectedEdgesBoundsTrigger=function(t,e,r,n){this.checkTrigger(t,e,r,n,function(i){return i.triggersBoundsOfConnectedEdges},function(i){t.connectedEdges().forEach(function(a){a.dirtyBoundingBoxCache()})})};Kr.checkParallelEdgesBoundsTrigger=function(t,e,r,n){this.checkTrigger(t,e,r,n,function(i){return i.triggersBoundsOfParallelEdges},function(i){t.parallelEdges().forEach(function(a){a.dirtyBoundingBoxCache()})})};Kr.checkTriggers=function(t,e,r,n){t.dirtyStyleCache(),this.checkZOrderTrigger(t,e,r,n),this.checkBoundsTrigger(t,e,r,n),this.checkConnectedEdgesBoundsTrigger(t,e,r,n),this.checkParallelEdgesBoundsTrigger(t,e,r,n)};var bh={};bh.applyBypass=function(t,e,r,n){var i=this,a=[],s=!0;if(e==="*"||e==="**"){if(r!==void 0)for(var l=0;l<i.properties.length;l++){var o=i.properties[l],c=o.name,h=this.parse(c,r,!0);h&&a.push(h)}}else if(lt(e)){var d=this.parse(e,r,!0);d&&a.push(d)}else if(Bt(e)){var g=e;n=r;for(var m=Object.keys(g),y=0;y<m.length;y++){var b=m[y],x=g[b];if(x===void 0&&(x=g[iv(b)]),x!==void 0){var w=this.parse(b,x,!0);w&&a.push(w)}}}else return!1;if(a.length===0)return!1;for(var S=!1,k=0;k<t.length;k++){for(var E=t[k],M={},R=void 0,O=0;O<a.length;O++){var N=a[O];if(n){var B=E.pstyle(N.name);R=M[N.name]={prev:B}}S=this.applyParsedProperty(E,la(N))||S,n&&(R.next=E.pstyle(N.name))}S&&this.updateStyleHints(E),n&&this.updateTransitions(E,M,s)}return S};bh.overrideBypass=function(t,e,r){e=NT(e);for(var n=0;n<t.length;n++){var i=t[n],a=i._private.style[e],s=this.properties[e].type,l=s.color,o=s.mutiple,c=a?a.pfValue!=null?a.pfValue:a.value:null;!a||!a.bypass?this.applyBypass(i,e,r):(a.value=r,a.pfValue!=null&&(a.pfValue=r),l?a.strValue="rgb("+r.join(",")+")":o?a.strValue=r.join(" "):a.strValue=""+r,this.updateStyleHints(i)),this.checkTriggers(i,e,c,r)}};bh.removeAllBypasses=function(t,e){return this.removeBypasses(t,this.propertyNames,e)};bh.removeBypasses=function(t,e,r){for(var n=!0,i=0;i<t.length;i++){for(var a=t[i],s={},l=0;l<e.length;l++){var o=e[l],c=this.properties[o],h=a.pstyle(c.name);if(!(!h||!h.bypass)){var d="",g=this.parse(o,d,!0),m=s[c.name]={prev:h};this.applyParsedProperty(a,g),m.next=a.pstyle(c.name)}}this.updateStyleHints(a),r&&this.updateTransitions(a,s,n)}};var XT={};XT.getEmSizeInPixels=function(){var t=this.containerCss("font-size");return t!=null?parseFloat(t):1};XT.containerCss=function(t){var e=this._private.cy,r=e.container(),n=e.window();if(n&&r&&n.getComputedStyle)return n.getComputedStyle(r).getPropertyValue(t)};var da={};da.getRenderedStyle=function(t,e){return e?this.getStylePropertyValue(t,e,!0):this.getRawStyle(t,!0)};da.getRawStyle=function(t,e){var r=this;if(t=t[0],t){for(var n={},i=0;i<r.properties.length;i++){var a=r.properties[i],s=r.getStylePropertyValue(t,a.name,e);s!=null&&(n[a.name]=s,n[iv(a.name)]=s)}return n}};da.getIndexedStyle=function(t,e,r,n){var i=t.pstyle(e)[r][n];return i??t.cy().style().getDefaultProperty(e)[r][0]};da.getStylePropertyValue=function(t,e,r){var n=this;if(t=t[0],t){var i=n.properties[e];i.alias&&(i=i.pointsTo);var a=i.type,s=t.pstyle(i.name);if(s){var l=s.value,o=s.units,c=s.strValue;if(r&&a.number&&l!=null&&qe(l)){var h=t.cy().zoom(),d=function(x){return x*h},g=function(x,w){return d(x)+w},m=Zt(l),y=m?o.every(function(b){return b!=null}):o!=null;return y?m?l.map(function(b,x){return g(b,o[x])}).join(" "):g(l,o):m?l.map(function(b){return lt(b)?b:""+d(b)}).join(" "):""+d(l)}else if(c!=null)return c}return null}};da.getAnimationStartStyle=function(t,e){for(var r={},n=0;n<e.length;n++){var i=e[n],a=i.name,s=t.pstyle(a);s!==void 0&&(Bt(s)?s=this.parse(a,s.strValue):s=this.parse(a,s)),s&&(r[a]=s)}return r};da.getPropsList=function(t){var e=this,r=[],n=t,i=e.properties;if(n)for(var a=Object.keys(n),s=0;s<a.length;s++){var l=a[s],o=n[l],c=i[l]||i[NT(l)],h=this.parse(c.name,o);h&&r.push(h)}return r};da.getNonDefaultPropertiesHash=function(t,e,r){var n=r.slice(),i,a,s,l,o,c;for(o=0;o<e.length;o++)if(i=e[o],a=t.pstyle(i,!1),a!=null)if(a.pfValue!=null)n[0]=Pf(l,n[0]),n[1]=zf(l,n[1]);else for(s=a.strValue,c=0;c<s.length;c++)l=s.charCodeAt(c),n[0]=Pf(l,n[0]),n[1]=zf(l,n[1]);return n};da.getPropertiesHash=da.getNonDefaultPropertiesHash;var mv={};mv.appendFromJson=function(t){for(var e=this,r=0;r<t.length;r++){var n=t[r],i=n.selector,a=n.style||n.css,s=Object.keys(a);e.selector(i);for(var l=0;l<s.length;l++){var o=s[l],c=a[o];e.css(o,c)}}return e};mv.fromJson=function(t){var e=this;return e.resetToDefault(),e.appendFromJson(t),e};mv.json=function(){for(var t=[],e=this.defaultLength;e<this.length;e++){for(var r=this[e],n=r.selector,i=r.properties,a={},s=0;s<i.length;s++){var l=i[s];a[l.name]=l.strValue}t.push({selector:n?n.toString():"core",style:a})}return t};var WT={};WT.appendFromString=function(t){var e=this,r=this,n=""+t,i,a,s;n=n.replace(/[/][*](\s|.)+?[*][/]/g,"");function l(){n.length>i.length?n=n.substr(i.length):n=""}function o(){a.length>s.length?a=a.substr(s.length):a=""}for(;;){var c=n.match(/^\s*$/);if(c)break;var h=n.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!h){jt("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+n);break}i=h[0];var d=h[1];if(d!=="core"){var g=new Qs(d);if(g.invalid){jt("Skipping parsing of block: Invalid selector found in string stylesheet: "+d),l();continue}}var m=h[2],y=!1;a=m;for(var b=[];;){var x=a.match(/^\s*$/);if(x)break;var w=a.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!w){jt("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+m),y=!0;break}s=w[0];var S=w[1],k=w[2],E=e.properties[S];if(!E){jt("Skipping property: Invalid property name in: "+s),o();continue}var M=r.parse(S,k);if(!M){jt("Skipping property: Invalid property definition in: "+s),o();continue}b.push({name:S,val:k}),o()}if(y){l();break}r.selector(d);for(var R=0;R<b.length;R++){var O=b[R];r.css(O.name,O.val)}l()}return r};WT.fromString=function(t){var e=this;return e.resetToDefault(),e.appendFromString(t),e};var Mr={};(function(){var t=Ir,e=RG,r=_G,n=NG,i=BG,a=function(j){return"^"+j+"\\s*\\(\\s*([\\w\\.]+)\\s*\\)$"},s=function(j){var Q=t+"|\\w+|"+e+"|"+r+"|"+n+"|"+i;return"^"+j+"\\s*\\(([\\w\\.]+)\\s*\\,\\s*("+t+")\\s*\\,\\s*("+t+")\\s*,\\s*("+Q+")\\s*\\,\\s*("+Q+")\\)$"},l=[`^url\\s*\\(\\s*['"]?(.+?)['"]?\\s*\\)$`,"^(none)$","^(.+)$"];Mr.types={time:{number:!0,min:0,units:"s|ms",implicitUnits:"ms"},percent:{number:!0,min:0,max:100,units:"%",implicitUnits:"%"},percentages:{number:!0,min:0,max:100,units:"%",implicitUnits:"%",multiple:!0},zeroOneNumber:{number:!0,min:0,max:1,unitless:!0},zeroOneNumbers:{number:!0,min:0,max:1,unitless:!0,multiple:!0},nOneOneNumber:{number:!0,min:-1,max:1,unitless:!0},nonNegativeInt:{number:!0,min:0,integer:!0,unitless:!0},nonNegativeNumber:{number:!0,min:0,unitless:!0},position:{enums:["parent","origin"]},nodeSize:{number:!0,min:0,enums:["label"]},number:{number:!0,unitless:!0},numbers:{number:!0,unitless:!0,multiple:!0},positiveNumber:{number:!0,unitless:!0,min:0,strictMin:!0},size:{number:!0,min:0},bidirectionalSize:{number:!0},bidirectionalSizeMaybePercent:{number:!0,allowPercent:!0},bidirectionalSizes:{number:!0,multiple:!0},sizeMaybePercent:{number:!0,min:0,allowPercent:!0},axisDirection:{enums:["horizontal","leftward","rightward","vertical","upward","downward","auto"]},axisDirectionExplicit:{enums:["leftward","rightward","upward","downward"]},axisDirectionPrimary:{enums:["horizontal","vertical"]},paddingRelativeTo:{enums:["width","height","average","min","max"]},bgWH:{number:!0,min:0,allowPercent:!0,enums:["auto"],multiple:!0},bgPos:{number:!0,allowPercent:!0,multiple:!0},bgRelativeTo:{enums:["inner","include-padding"],multiple:!0},bgRepeat:{enums:["repeat","repeat-x","repeat-y","no-repeat"],multiple:!0},bgFit:{enums:["none","contain","cover"],multiple:!0},bgCrossOrigin:{enums:["anonymous","use-credentials","null"],multiple:!0},bgClip:{enums:["none","node"],multiple:!0},bgContainment:{enums:["inside","over"],multiple:!0},boxSelection:{enums:["contain","overlap","none"]},color:{color:!0},colors:{color:!0,multiple:!0},fill:{enums:["solid","linear-gradient","radial-gradient"]},bool:{enums:["yes","no"]},bools:{enums:["yes","no"],multiple:!0},lineStyle:{enums:["solid","dotted","dashed"]},lineCap:{enums:["butt","round","square"]},linePosition:{enums:["center","inside","outside"]},lineJoin:{enums:["round","bevel","miter"]},borderStyle:{enums:["solid","dotted","dashed","double"]},curveStyle:{enums:["bezier","unbundled-bezier","haystack","segments","straight","straight-triangle","taxi","round-segments","round-taxi"]},radiusType:{enums:["arc-radius","influence-radius"],multiple:!0},fontFamily:{regex:'^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$'},fontStyle:{enums:["italic","normal","oblique"]},fontWeight:{enums:["normal","bold","bolder","lighter","100","200","300","400","500","600","800","900",100,200,300,400,500,600,700,800,900]},textDecoration:{enums:["none","underline","overline","line-through"]},textTransform:{enums:["none","uppercase","lowercase"]},textWrap:{enums:["none","wrap","ellipsis"]},textOverflowWrap:{enums:["whitespace","anywhere"]},textBackgroundShape:{enums:["rectangle","roundrectangle","round-rectangle","circle"]},nodeShape:{enums:["rectangle","roundrectangle","round-rectangle","cutrectangle","cut-rectangle","bottomroundrectangle","bottom-round-rectangle","barrel","ellipse","triangle","round-triangle","square","pentagon","round-pentagon","hexagon","round-hexagon","concavehexagon","concave-hexagon","heptagon","round-heptagon","octagon","round-octagon","tag","round-tag","star","diamond","round-diamond","vee","rhomboid","right-rhomboid","polygon"]},overlayShape:{enums:["roundrectangle","round-rectangle","ellipse"]},cornerRadius:{number:!0,min:0,units:"px|em",implicitUnits:"px",enums:["auto"]},compoundIncludeLabels:{enums:["include","exclude"]},arrowShape:{enums:["tee","triangle","triangle-tee","circle-triangle","triangle-cross","triangle-backcurve","vee","square","circle","diamond","chevron","none"]},arrowFill:{enums:["filled","hollow"]},arrowWidth:{number:!0,units:"%|px|em",implicitUnits:"px",enums:["match-line"]},display:{enums:["element","none"]},visibility:{enums:["hidden","visible"]},zCompoundDepth:{enums:["bottom","orphan","auto","top"]},zIndexCompare:{enums:["auto","manual"]},valign:{enums:["top","center","bottom"]},halign:{enums:["left","center","right"]},justification:{enums:["left","center","right","auto"]},text:{string:!0},data:{mapping:!0,regex:a("data")},layoutData:{mapping:!0,regex:a("layoutData")},scratch:{mapping:!0,regex:a("scratch")},mapData:{mapping:!0,regex:s("mapData")},mapLayoutData:{mapping:!0,regex:s("mapLayoutData")},mapScratch:{mapping:!0,regex:s("mapScratch")},fn:{mapping:!0,fn:!0},url:{regexes:l,singleRegexMatchValue:!0},urls:{regexes:l,singleRegexMatchValue:!0,multiple:!0},propList:{propList:!0},angle:{number:!0,units:"deg|rad",implicitUnits:"rad"},textRotation:{number:!0,units:"deg|rad",implicitUnits:"rad",enums:["none","autorotate"]},polygonPointList:{number:!0,multiple:!0,evenMultiple:!0,min:-1,max:1,unitless:!0},edgeDistances:{enums:["intersection","node-position","endpoints"]},edgeEndpoint:{number:!0,multiple:!0,units:"%|px|em|deg|rad",implicitUnits:"px",enums:["inside-to-node","outside-to-node","outside-to-node-or-label","outside-to-line","outside-to-line-or-label"],singleEnum:!0,validate:function(j,Q){switch(j.length){case 2:return Q[0]!=="deg"&&Q[0]!=="rad"&&Q[1]!=="deg"&&Q[1]!=="rad";case 1:return lt(j[0])||Q[0]==="deg"||Q[0]==="rad";default:return!1}}},easing:{regexes:["^(spring)\\s*\\(\\s*("+t+")\\s*,\\s*("+t+")\\s*\\)$","^(cubic-bezier)\\s*\\(\\s*("+t+")\\s*,\\s*("+t+")\\s*,\\s*("+t+")\\s*,\\s*("+t+")\\s*\\)$"],enums:["linear","ease","ease-in","ease-out","ease-in-out","ease-in-sine","ease-out-sine","ease-in-out-sine","ease-in-quad","ease-out-quad","ease-in-out-quad","ease-in-cubic","ease-out-cubic","ease-in-out-cubic","ease-in-quart","ease-out-quart","ease-in-out-quart","ease-in-quint","ease-out-quint","ease-in-out-quint","ease-in-expo","ease-out-expo","ease-in-out-expo","ease-in-circ","ease-out-circ","ease-in-out-circ"]},gradientDirection:{enums:["to-bottom","to-top","to-left","to-right","to-bottom-right","to-bottom-left","to-top-right","to-top-left","to-right-bottom","to-left-bottom","to-right-top","to-left-top"]},boundsExpansion:{number:!0,multiple:!0,min:0,validate:function(j){var Q=j.length;return Q===1||Q===2||Q===4}}};var o={zeroNonZero:function(j,Q){return(j==null||Q==null)&&j!==Q||j==0&&Q!=0?!0:j!=0&&Q==0},any:function(j,Q){return j!=Q},emptyNonEmpty:function(j,Q){var K=Ys(j),ue=Ys(Q);return K&&!ue||!K&&ue}},c=Mr.types,h=[{name:"label",type:c.text,triggersBounds:o.any,triggersZOrder:o.emptyNonEmpty},{name:"text-rotation",type:c.textRotation,triggersBounds:o.any},{name:"text-margin-x",type:c.bidirectionalSize,triggersBounds:o.any},{name:"text-margin-y",type:c.bidirectionalSize,triggersBounds:o.any}],d=[{name:"source-label",type:c.text,triggersBounds:o.any},{name:"source-text-rotation",type:c.textRotation,triggersBounds:o.any},{name:"source-text-margin-x",type:c.bidirectionalSize,triggersBounds:o.any},{name:"source-text-margin-y",type:c.bidirectionalSize,triggersBounds:o.any},{name:"source-text-offset",type:c.size,triggersBounds:o.any}],g=[{name:"target-label",type:c.text,triggersBounds:o.any},{name:"target-text-rotation",type:c.textRotation,triggersBounds:o.any},{name:"target-text-margin-x",type:c.bidirectionalSize,triggersBounds:o.any},{name:"target-text-margin-y",type:c.bidirectionalSize,triggersBounds:o.any},{name:"target-text-offset",type:c.size,triggersBounds:o.any}],m=[{name:"font-family",type:c.fontFamily,triggersBounds:o.any},{name:"font-style",type:c.fontStyle,triggersBounds:o.any},{name:"font-weight",type:c.fontWeight,triggersBounds:o.any},{name:"font-size",type:c.size,triggersBounds:o.any},{name:"text-transform",type:c.textTransform,triggersBounds:o.any},{name:"text-wrap",type:c.textWrap,triggersBounds:o.any},{name:"text-overflow-wrap",type:c.textOverflowWrap,triggersBounds:o.any},{name:"text-max-width",type:c.size,triggersBounds:o.any},{name:"text-outline-width",type:c.size,triggersBounds:o.any},{name:"line-height",type:c.positiveNumber,triggersBounds:o.any}],y=[{name:"text-valign",type:c.valign,triggersBounds:o.any},{name:"text-halign",type:c.halign,triggersBounds:o.any},{name:"color",type:c.color},{name:"text-outline-color",type:c.color},{name:"text-outline-opacity",type:c.zeroOneNumber},{name:"text-background-color",type:c.color},{name:"text-background-opacity",type:c.zeroOneNumber},{name:"text-background-padding",type:c.size,triggersBounds:o.any},{name:"text-border-opacity",type:c.zeroOneNumber},{name:"text-border-color",type:c.color},{name:"text-border-width",type:c.size,triggersBounds:o.any},{name:"text-border-style",type:c.borderStyle,triggersBounds:o.any},{name:"text-background-shape",type:c.textBackgroundShape,triggersBounds:o.any},{name:"text-justification",type:c.justification},{name:"box-select-labels",type:c.bool,triggersBounds:o.any}],b=[{name:"events",type:c.bool,triggersZOrder:o.any},{name:"text-events",type:c.bool,triggersZOrder:o.any},{name:"box-selection",type:c.boxSelection,triggersZOrder:o.any}],x=[{name:"display",type:c.display,triggersZOrder:o.any,triggersBounds:o.any,triggersBoundsOfConnectedEdges:o.any,triggersBoundsOfParallelEdges:function(j,Q,K){return j===Q?!1:K.pstyle("curve-style").value==="bezier"}},{name:"visibility",type:c.visibility,triggersZOrder:o.any},{name:"opacity",type:c.zeroOneNumber,triggersZOrder:o.zeroNonZero},{name:"text-opacity",type:c.zeroOneNumber},{name:"min-zoomed-font-size",type:c.size},{name:"z-compound-depth",type:c.zCompoundDepth,triggersZOrder:o.any},{name:"z-index-compare",type:c.zIndexCompare,triggersZOrder:o.any},{name:"z-index",type:c.number,triggersZOrder:o.any}],w=[{name:"overlay-padding",type:c.size,triggersBounds:o.any},{name:"overlay-color",type:c.color},{name:"overlay-opacity",type:c.zeroOneNumber,triggersBounds:o.zeroNonZero},{name:"overlay-shape",type:c.overlayShape,triggersBounds:o.any},{name:"overlay-corner-radius",type:c.cornerRadius}],S=[{name:"underlay-padding",type:c.size,triggersBounds:o.any},{name:"underlay-color",type:c.color},{name:"underlay-opacity",type:c.zeroOneNumber,triggersBounds:o.zeroNonZero},{name:"underlay-shape",type:c.overlayShape,triggersBounds:o.any},{name:"underlay-corner-radius",type:c.cornerRadius}],k=[{name:"transition-property",type:c.propList},{name:"transition-duration",type:c.time},{name:"transition-delay",type:c.time},{name:"transition-timing-function",type:c.easing}],E=function(j,Q){return Q.value==="label"?-j.poolIndex():Q.pfValue},M=[{name:"height",type:c.nodeSize,triggersBounds:o.any,hashOverride:E},{name:"width",type:c.nodeSize,triggersBounds:o.any,hashOverride:E},{name:"shape",type:c.nodeShape,triggersBounds:o.any},{name:"shape-polygon-points",type:c.polygonPointList,triggersBounds:o.any},{name:"corner-radius",type:c.cornerRadius},{name:"background-color",type:c.color},{name:"background-fill",type:c.fill},{name:"background-opacity",type:c.zeroOneNumber},{name:"background-blacken",type:c.nOneOneNumber},{name:"background-gradient-stop-colors",type:c.colors},{name:"background-gradient-stop-positions",type:c.percentages},{name:"background-gradient-direction",type:c.gradientDirection},{name:"padding",type:c.sizeMaybePercent,triggersBounds:o.any},{name:"padding-relative-to",type:c.paddingRelativeTo,triggersBounds:o.any},{name:"bounds-expansion",type:c.boundsExpansion,triggersBounds:o.any}],R=[{name:"border-color",type:c.color},{name:"border-opacity",type:c.zeroOneNumber},{name:"border-width",type:c.size,triggersBounds:o.any},{name:"border-style",type:c.borderStyle},{name:"border-cap",type:c.lineCap},{name:"border-join",type:c.lineJoin},{name:"border-dash-pattern",type:c.numbers},{name:"border-dash-offset",type:c.number},{name:"border-position",type:c.linePosition}],O=[{name:"outline-color",type:c.color},{name:"outline-opacity",type:c.zeroOneNumber},{name:"outline-width",type:c.size,triggersBounds:o.any},{name:"outline-style",type:c.borderStyle},{name:"outline-offset",type:c.size,triggersBounds:o.any}],N=[{name:"background-image",type:c.urls},{name:"background-image-crossorigin",type:c.bgCrossOrigin},{name:"background-image-opacity",type:c.zeroOneNumbers},{name:"background-image-containment",type:c.bgContainment},{name:"background-image-smoothing",type:c.bools},{name:"background-position-x",type:c.bgPos},{name:"background-position-y",type:c.bgPos},{name:"background-width-relative-to",type:c.bgRelativeTo},{name:"background-height-relative-to",type:c.bgRelativeTo},{name:"background-repeat",type:c.bgRepeat},{name:"background-fit",type:c.bgFit},{name:"background-clip",type:c.bgClip},{name:"background-width",type:c.bgWH},{name:"background-height",type:c.bgWH},{name:"background-offset-x",type:c.bgPos},{name:"background-offset-y",type:c.bgPos}],B=[{name:"position",type:c.position,triggersBounds:o.any},{name:"compound-sizing-wrt-labels",type:c.compoundIncludeLabels,triggersBounds:o.any},{name:"min-width",type:c.size,triggersBounds:o.any},{name:"min-width-bias-left",type:c.sizeMaybePercent,triggersBounds:o.any},{name:"min-width-bias-right",type:c.sizeMaybePercent,triggersBounds:o.any},{name:"min-height",type:c.size,triggersBounds:o.any},{name:"min-height-bias-top",type:c.sizeMaybePercent,triggersBounds:o.any},{name:"min-height-bias-bottom",type:c.sizeMaybePercent,triggersBounds:o.any}],D=[{name:"line-style",type:c.lineStyle},{name:"line-color",type:c.color},{name:"line-fill",type:c.fill},{name:"line-cap",type:c.lineCap},{name:"line-opacity",type:c.zeroOneNumber},{name:"line-dash-pattern",type:c.numbers},{name:"line-dash-offset",type:c.number},{name:"line-outline-width",type:c.size},{name:"line-outline-color",type:c.color},{name:"line-gradient-stop-colors",type:c.colors},{name:"line-gradient-stop-positions",type:c.percentages},{name:"curve-style",type:c.curveStyle,triggersBounds:o.any,triggersBoundsOfParallelEdges:function(j,Q){return j===Q?!1:j==="bezier"||Q==="bezier"}},{name:"haystack-radius",type:c.zeroOneNumber,triggersBounds:o.any},{name:"source-endpoint",type:c.edgeEndpoint,triggersBounds:o.any},{name:"target-endpoint",type:c.edgeEndpoint,triggersBounds:o.any},{name:"control-point-step-size",type:c.size,triggersBounds:o.any},{name:"control-point-distances",type:c.bidirectionalSizes,triggersBounds:o.any},{name:"control-point-weights",type:c.numbers,triggersBounds:o.any},{name:"segment-distances",type:c.bidirectionalSizes,triggersBounds:o.any},{name:"segment-weights",type:c.numbers,triggersBounds:o.any},{name:"segment-radii",type:c.numbers,triggersBounds:o.any},{name:"radius-type",type:c.radiusType,triggersBounds:o.any},{name:"taxi-turn",type:c.bidirectionalSizeMaybePercent,triggersBounds:o.any},{name:"taxi-turn-min-distance",type:c.size,triggersBounds:o.any},{name:"taxi-direction",type:c.axisDirection,triggersBounds:o.any},{name:"taxi-radius",type:c.number,triggersBounds:o.any},{name:"edge-distances",type:c.edgeDistances,triggersBounds:o.any},{name:"arrow-scale",type:c.positiveNumber,triggersBounds:o.any},{name:"loop-direction",type:c.angle,triggersBounds:o.any},{name:"loop-sweep",type:c.angle,triggersBounds:o.any},{name:"source-distance-from-node",type:c.size,triggersBounds:o.any},{name:"target-distance-from-node",type:c.size,triggersBounds:o.any}],_=[{name:"ghost",type:c.bool,triggersBounds:o.any},{name:"ghost-offset-x",type:c.bidirectionalSize,triggersBounds:o.any},{name:"ghost-offset-y",type:c.bidirectionalSize,triggersBounds:o.any},{name:"ghost-opacity",type:c.zeroOneNumber}],P=[{name:"selection-box-color",type:c.color},{name:"selection-box-opacity",type:c.zeroOneNumber},{name:"selection-box-border-color",type:c.color},{name:"selection-box-border-width",type:c.size},{name:"active-bg-color",type:c.color},{name:"active-bg-opacity",type:c.zeroOneNumber},{name:"active-bg-size",type:c.size},{name:"outside-texture-bg-color",type:c.color},{name:"outside-texture-bg-opacity",type:c.zeroOneNumber}],z=[];Mr.pieBackgroundN=16,z.push({name:"pie-size",type:c.sizeMaybePercent}),z.push({name:"pie-hole",type:c.sizeMaybePercent}),z.push({name:"pie-start-angle",type:c.angle});for(var H=1;H<=Mr.pieBackgroundN;H++)z.push({name:"pie-"+H+"-background-color",type:c.color}),z.push({name:"pie-"+H+"-background-size",type:c.percent}),z.push({name:"pie-"+H+"-background-opacity",type:c.zeroOneNumber});var $=[];Mr.stripeBackgroundN=16,$.push({name:"stripe-size",type:c.sizeMaybePercent}),$.push({name:"stripe-direction",type:c.axisDirectionPrimary});for(var q=1;q<=Mr.stripeBackgroundN;q++)$.push({name:"stripe-"+q+"-background-color",type:c.color}),$.push({name:"stripe-"+q+"-background-size",type:c.percent}),$.push({name:"stripe-"+q+"-background-opacity",type:c.zeroOneNumber});var V=[],X=Mr.arrowPrefixes=["source","mid-source","target","mid-target"];[{name:"arrow-shape",type:c.arrowShape,triggersBounds:o.any},{name:"arrow-color",type:c.color},{name:"arrow-fill",type:c.arrowFill},{name:"arrow-width",type:c.arrowWidth}].forEach(function(se){X.forEach(function(j){var Q=j+"-"+se.name,K=se.type,ue=se.triggersBounds;V.push({name:Q,type:K,triggersBounds:ue})})},{});var ee=Mr.properties=[].concat(b,k,x,w,S,_,y,m,h,d,g,M,R,O,N,z,$,B,D,V,P),te=Mr.propertyGroups={behavior:b,transition:k,visibility:x,overlay:w,underlay:S,ghost:_,commonLabel:y,labelDimensions:m,mainLabel:h,sourceLabel:d,targetLabel:g,nodeBody:M,nodeBorder:R,nodeOutline:O,backgroundImage:N,pie:z,stripe:$,compound:B,edgeLine:D,edgeArrow:V,core:P},I=Mr.propertyGroupNames={},G=Mr.propertyGroupKeys=Object.keys(te);G.forEach(function(se){I[se]=te[se].map(function(j){return j.name}),te[se].forEach(function(j){return j.groupKey=se})});var re=Mr.aliases=[{name:"content",pointsTo:"label"},{name:"control-point-distance",pointsTo:"control-point-distances"},{name:"control-point-weight",pointsTo:"control-point-weights"},{name:"segment-distance",pointsTo:"segment-distances"},{name:"segment-weight",pointsTo:"segment-weights"},{name:"segment-radius",pointsTo:"segment-radii"},{name:"edge-text-rotation",pointsTo:"text-rotation"},{name:"padding-left",pointsTo:"padding"},{name:"padding-right",pointsTo:"padding"},{name:"padding-top",pointsTo:"padding"},{name:"padding-bottom",pointsTo:"padding"}];Mr.propertyNames=ee.map(function(se){return se.name});for(var Y=0;Y<ee.length;Y++){var W=ee[Y];ee[W.name]=W}for(var Z=0;Z<re.length;Z++){var ie=re[Z],we=ee[ie.pointsTo],de={name:ie.name,alias:!0,pointsTo:we};ee.push(de),ee[ie.name]=de}})();Mr.getDefaultProperty=function(t){return this.getDefaultProperties()[t]};Mr.getDefaultProperties=function(){var t=this._private;if(t.defaultProperties!=null)return t.defaultProperties;for(var e=ft({"selection-box-color":"#ddd","selection-box-opacity":.65,"selection-box-border-color":"#aaa","selection-box-border-width":1,"active-bg-color":"black","active-bg-opacity":.15,"active-bg-size":30,"outside-texture-bg-color":"#000","outside-texture-bg-opacity":.125,events:"yes","text-events":"no","text-valign":"top","text-halign":"center","text-justification":"auto","line-height":1,color:"#000","box-selection":"contain","text-outline-color":"#000","text-outline-width":0,"text-outline-opacity":1,"text-opacity":1,"text-decoration":"none","text-transform":"none","text-wrap":"none","text-overflow-wrap":"whitespace","text-max-width":9999,"text-background-color":"#000","text-background-opacity":0,"text-background-shape":"rectangle","text-background-padding":0,"text-border-opacity":0,"text-border-width":0,"text-border-style":"solid","text-border-color":"#000","font-family":"Helvetica Neue, Helvetica, sans-serif","font-style":"normal","font-weight":"normal","font-size":16,"min-zoomed-font-size":0,"text-rotation":"none","source-text-rotation":"none","target-text-rotation":"none",visibility:"visible",display:"element",opacity:1,"z-compound-depth":"auto","z-index-compare":"auto","z-index":0,label:"","text-margin-x":0,"text-margin-y":0,"source-label":"","source-text-offset":0,"source-text-margin-x":0,"source-text-margin-y":0,"target-label":"","target-text-offset":0,"target-text-margin-x":0,"target-text-margin-y":0,"overlay-opacity":0,"overlay-color":"#000","overlay-padding":10,"overlay-shape":"round-rectangle","overlay-corner-radius":"auto","underlay-opacity":0,"underlay-color":"#000","underlay-padding":10,"underlay-shape":"round-rectangle","underlay-corner-radius":"auto","transition-property":"none","transition-duration":0,"transition-delay":0,"transition-timing-function":"linear","box-select-labels":"no","background-blacken":0,"background-color":"#999","background-fill":"solid","background-opacity":1,"background-image":"none","background-image-crossorigin":"anonymous","background-image-opacity":1,"background-image-containment":"inside","background-image-smoothing":"yes","background-position-x":"50%","background-position-y":"50%","background-offset-x":0,"background-offset-y":0,"background-width-relative-to":"include-padding","background-height-relative-to":"include-padding","background-repeat":"no-repeat","background-fit":"none","background-clip":"node","background-width":"auto","background-height":"auto","border-color":"#000","border-opacity":1,"border-width":0,"border-style":"solid","border-dash-pattern":[4,2],"border-dash-offset":0,"border-cap":"butt","border-join":"miter","border-position":"center","outline-color":"#999","outline-opacity":1,"outline-width":0,"outline-offset":0,"outline-style":"solid",height:30,width:30,shape:"ellipse","shape-polygon-points":"-1, -1, 1, -1, 1, 1, -1, 1","corner-radius":"auto","bounds-expansion":0,"background-gradient-direction":"to-bottom","background-gradient-stop-colors":"#999","background-gradient-stop-positions":"0%",ghost:"no","ghost-offset-y":0,"ghost-offset-x":0,"ghost-opacity":0,padding:0,"padding-relative-to":"width",position:"origin","compound-sizing-wrt-labels":"include","min-width":0,"min-width-bias-left":0,"min-width-bias-right":0,"min-height":0,"min-height-bias-top":0,"min-height-bias-bottom":0},{"pie-size":"100%","pie-hole":0,"pie-start-angle":"0deg"},[{name:"pie-{{i}}-background-color",value:"black"},{name:"pie-{{i}}-background-size",value:"0%"},{name:"pie-{{i}}-background-opacity",value:1}].reduce(function(o,c){for(var h=1;h<=Mr.pieBackgroundN;h++){var d=c.name.replace("{{i}}",h),g=c.value;o[d]=g}return o},{}),{"stripe-size":"100%","stripe-direction":"horizontal"},[{name:"stripe-{{i}}-background-color",value:"black"},{name:"stripe-{{i}}-background-size",value:"0%"},{name:"stripe-{{i}}-background-opacity",value:1}].reduce(function(o,c){for(var h=1;h<=Mr.stripeBackgroundN;h++){var d=c.name.replace("{{i}}",h),g=c.value;o[d]=g}return o},{}),{"line-style":"solid","line-color":"#999","line-fill":"solid","line-cap":"butt","line-opacity":1,"line-outline-width":0,"line-outline-color":"#000","line-gradient-stop-colors":"#999","line-gradient-stop-positions":"0%","control-point-step-size":40,"control-point-weights":.5,"segment-weights":.5,"segment-distances":20,"segment-radii":15,"radius-type":"arc-radius","taxi-turn":"50%","taxi-radius":15,"taxi-turn-min-distance":10,"taxi-direction":"auto","edge-distances":"intersection","curve-style":"haystack","haystack-radius":0,"arrow-scale":1,"loop-direction":"-45deg","loop-sweep":"-90deg","source-distance-from-node":0,"target-distance-from-node":0,"source-endpoint":"outside-to-node","target-endpoint":"outside-to-node","line-dash-pattern":[6,3],"line-dash-offset":0},[{name:"arrow-shape",value:"none"},{name:"arrow-color",value:"#999"},{name:"arrow-fill",value:"filled"},{name:"arrow-width",value:1}].reduce(function(o,c){return Mr.arrowPrefixes.forEach(function(h){var d=h+"-"+c.name,g=c.value;o[d]=g}),o},{})),r={},n=0;n<this.properties.length;n++){var i=this.properties[n];if(!i.pointsTo){var a=i.name,s=e[a],l=this.parse(a,s);r[a]=l}}return t.defaultProperties=r,t.defaultProperties};Mr.addDefaultStylesheet=function(){this.selector(":parent").css({shape:"rectangle",padding:10,"background-color":"#eee","border-color":"#ccc","border-width":1}).selector("edge").css({width:3}).selector(":loop").css({"curve-style":"bezier"}).selector("edge:compound").css({"curve-style":"bezier","source-endpoint":"outside-to-line","target-endpoint":"outside-to-line"}).selector(":selected").css({"background-color":"#0169D9","line-color":"#0169D9","source-arrow-color":"#0169D9","target-arrow-color":"#0169D9","mid-source-arrow-color":"#0169D9","mid-target-arrow-color":"#0169D9"}).selector(":parent:selected").css({"background-color":"#CCE1F9","border-color":"#aec8e5"}).selector(":active").css({"overlay-color":"black","overlay-padding":10,"overlay-opacity":.25}),this.defaultLength=this.length};var yv={};yv.parse=function(t,e,r,n){var i=this;if(hr(e))return i.parseImplWarn(t,e,r,n);var a=n==="mapping"||n===!0||n===!1||n==null?"dontcare":n,s=r?"t":"f",l=""+e,o=Dq(t,l,s,a),c=i.propCache=i.propCache||[],h;return(h=c[o])||(h=c[o]=i.parseImplWarn(t,e,r,n)),(r||n==="mapping")&&(h=la(h),h&&(h.value=la(h.value))),h};yv.parseImplWarn=function(t,e,r,n){var i=this.parseImpl(t,e,r,n);return!i&&e!=null&&jt("The style property `".concat(t,": ").concat(e,"` is invalid")),i&&(i.name==="width"||i.name==="height")&&e==="label"&&jt("The style value of `label` is deprecated for `"+i.name+"`"),i};yv.parseImpl=function(t,e,r,n){var i=this;t=NT(t);var a=i.properties[t],s=e,l=i.types;if(!a||e===void 0)return null;a.alias&&(a=a.pointsTo,t=a.name);var o=lt(e);o&&(e=e.trim());var c=a.type;if(!c)return null;if(r&&(e===""||e===null))return{name:t,value:e,bypass:!0,deleteBypass:!0};if(hr(e))return{name:t,value:e,strValue:"fn",mapped:l.fn,bypass:r};var h,d;if(!(!o||n||e.length<7||e[1]!=="a")){if(e.length>=7&&e[0]==="d"&&(h=new RegExp(l.data.regex).exec(e))){if(r)return!1;var g=l.data;return{name:t,value:h,strValue:""+e,mapped:g,field:h[1],bypass:r}}else if(e.length>=10&&e[0]==="m"&&(d=new RegExp(l.mapData.regex).exec(e))){if(r||c.multiple)return!1;var m=l.mapData;if(!(c.color||c.number))return!1;var y=this.parse(t,d[4]);if(!y||y.mapped)return!1;var b=this.parse(t,d[5]);if(!b||b.mapped)return!1;if(y.pfValue===b.pfValue||y.strValue===b.strValue)return jt("`"+t+": "+e+"` is not a valid mapper because the output range is zero; converting to `"+t+": "+y.strValue+"`"),this.parse(t,y.strValue);if(c.color){var x=y.value,w=b.value,S=x[0]===w[0]&&x[1]===w[1]&&x[2]===w[2]&&(x[3]===w[3]||(x[3]==null||x[3]===1)&&(w[3]==null||w[3]===1));if(S)return!1}return{name:t,value:d,strValue:""+e,mapped:m,field:d[1],fieldMin:parseFloat(d[2]),fieldMax:parseFloat(d[3]),valueMin:y.value,valueMax:b.value,bypass:r}}}if(c.multiple&&n!=="multiple"){var k;if(o?k=e.split(/\s+/):Zt(e)?k=e:k=[e],c.evenMultiple&&k.length%2!==0)return null;for(var E=[],M=[],R=[],O="",N=!1,B=0;B<k.length;B++){var D=i.parse(t,k[B],r,"multiple");N=N||lt(D.value),E.push(D.value),R.push(D.pfValue!=null?D.pfValue:D.value),M.push(D.units),O+=(B>0?" ":"")+D.strValue}return c.validate&&!c.validate(E,M)?null:c.singleEnum&&N?E.length===1&<(E[0])?{name:t,value:E[0],strValue:E[0],bypass:r}:null:{name:t,value:E,pfValue:R,strValue:O,bypass:r,units:M}}var _=function(){for(var de=0;de<c.enums.length;de++){var se=c.enums[de];if(se===e)return{name:t,value:e,strValue:""+e,bypass:r}}return null};if(c.number){var P,z="px";if(c.units&&(P=c.units),c.implicitUnits&&(z=c.implicitUnits),!c.unitless)if(o){var H="px|em"+(c.allowPercent?"|\\%":"");P&&(H=P);var $=e.match("^("+Ir+")("+H+")?$");$&&(e=$[1],P=$[2]||z)}else(!P||c.implicitUnits)&&(P=z);if(e=parseFloat(e),isNaN(e)&&c.enums===void 0)return null;if(isNaN(e)&&c.enums!==void 0)return e=s,_();if(c.integer&&!CG(e)||c.min!==void 0&&(e<c.min||c.strictMin&&e===c.min)||c.max!==void 0&&(e>c.max||c.strictMax&&e===c.max))return null;var q={name:t,value:e,strValue:""+e+(P||""),units:P,bypass:r};return c.unitless||P!=="px"&&P!=="em"?q.pfValue=e:q.pfValue=P==="px"||!P?e:this.getEmSizeInPixels()*e,(P==="ms"||P==="s")&&(q.pfValue=P==="ms"?e:1e3*e),(P==="deg"||P==="rad")&&(q.pfValue=P==="rad"?e:NY(e)),P==="%"&&(q.pfValue=e/100),q}else if(c.propList){var V=[],X=""+e;if(X!=="none"){for(var ee=X.split(/\s*,\s*|\s+/),te=0;te<ee.length;te++){var I=ee[te].trim();i.properties[I]?V.push(I):jt("`"+I+"` is not a valid property name")}if(V.length===0)return null}return{name:t,value:V,strValue:V.length===0?"none":V.join(" "),bypass:r}}else if(c.color){var G=kq(e);return G?{name:t,value:G,pfValue:G,strValue:"rgb("+G[0]+","+G[1]+","+G[2]+")",bypass:r}:null}else if(c.regex||c.regexes){if(c.enums){var re=_();if(re)return re}for(var Y=c.regexes?c.regexes:[c.regex],W=0;W<Y.length;W++){var Z=new RegExp(Y[W]),ie=Z.exec(e);if(ie)return{name:t,value:c.singleRegexMatchValue?ie[1]:ie,strValue:""+e,bypass:r}}return null}else return c.string?{name:t,value:""+e,strValue:""+e,bypass:r}:c.enums?_():null};var Qr=function(e){if(!(this instanceof Qr))return new Qr(e);if(!_T(e)){ur("A style must have a core reference");return}this._private={cy:e,coreStyle:{}},this.length=0,this.resetToDefault()},yn=Qr.prototype;yn.instanceString=function(){return"style"};yn.clear=function(){for(var t=this._private,e=t.cy,r=e.elements(),n=0;n<this.length;n++)this[n]=void 0;return this.length=0,t.contextStyles={},t.propDiffs={},this.cleanElements(r,!0),r.forEach(function(i){var a=i[0]._private;a.styleDirty=!0,a.appliedInitStyle=!1}),this};yn.resetToDefault=function(){return this.clear(),this.addDefaultStylesheet(),this};yn.core=function(t){return this._private.coreStyle[t]||this.getDefaultProperty(t)};yn.selector=function(t){var e=t==="core"?null:new Qs(t),r=this.length++;return this[r]={selector:e,properties:[],mappedProperties:[],index:r},this};yn.css=function(){var t=this,e=arguments;if(e.length===1)for(var r=e[0],n=0;n<t.properties.length;n++){var i=t.properties[n],a=r[i.name];a===void 0&&(a=r[iv(i.name)]),a!==void 0&&this.cssRule(i.name,a)}else e.length===2&&this.cssRule(e[0],e[1]);return this};yn.style=yn.css;yn.cssRule=function(t,e){var r=this.parse(t,e);if(r){var n=this.length-1;this[n].properties.push(r),this[n].properties[r.name]=r,r.name.match(/pie-(\d+)-background-size/)&&r.value&&(this._private.hasPie=!0),r.name.match(/stripe-(\d+)-background-size/)&&r.value&&(this._private.hasStripe=!0),r.mapped&&this[n].mappedProperties.push(r);var i=!this[n].selector;i&&(this._private.coreStyle[r.name]=r)}return this};yn.append=function(t){return wq(t)?t.appendToStyle(this):Zt(t)?this.appendFromJson(t):lt(t)&&this.appendFromString(t),this};Qr.fromJson=function(t,e){var r=new Qr(t);return r.fromJson(e),r};Qr.fromString=function(t,e){return new Qr(t).fromString(e)};[Kr,bh,XT,da,mv,WT,Mr,yv].forEach(function(t){ft(yn,t)});Qr.types=yn.types;Qr.properties=yn.properties;Qr.propertyGroups=yn.propertyGroups;Qr.propertyGroupNames=yn.propertyGroupNames;Qr.propertyGroupKeys=yn.propertyGroupKeys;var zQ={style:function(e){if(e){var r=this.setStyle(e);r.update()}return this._private.style},setStyle:function(e){var r=this._private;return wq(e)?r.style=e.generateStyle(this):Zt(e)?r.style=Qr.fromJson(this,e):lt(e)?r.style=Qr.fromString(this,e):r.style=Qr(this),r.style},updateStyle:function(){this.mutableElements().updateStyle()}},IQ="single",Jl={autolock:function(e){if(e!==void 0)this._private.autolock=!!e;else return this._private.autolock;return this},autoungrabify:function(e){if(e!==void 0)this._private.autoungrabify=!!e;else return this._private.autoungrabify;return this},autounselectify:function(e){if(e!==void 0)this._private.autounselectify=!!e;else return this._private.autounselectify;return this},selectionType:function(e){var r=this._private;if(r.selectionType==null&&(r.selectionType=IQ),e!==void 0)(e==="additive"||e==="single")&&(r.selectionType=e);else return r.selectionType;return this},panningEnabled:function(e){if(e!==void 0)this._private.panningEnabled=!!e;else return this._private.panningEnabled;return this},userPanningEnabled:function(e){if(e!==void 0)this._private.userPanningEnabled=!!e;else return this._private.userPanningEnabled;return this},zoomingEnabled:function(e){if(e!==void 0)this._private.zoomingEnabled=!!e;else return this._private.zoomingEnabled;return this},userZoomingEnabled:function(e){if(e!==void 0)this._private.userZoomingEnabled=!!e;else return this._private.userZoomingEnabled;return this},boxSelectionEnabled:function(e){if(e!==void 0)this._private.boxSelectionEnabled=!!e;else return this._private.boxSelectionEnabled;return this},pan:function(){var e=arguments,r=this._private.pan,n,i,a,s,l;switch(e.length){case 0:return r;case 1:if(lt(e[0]))return n=e[0],r[n];if(Bt(e[0])){if(!this._private.panningEnabled)return this;a=e[0],s=a.x,l=a.y,qe(s)&&(r.x=s),qe(l)&&(r.y=l),this.emit("pan viewport")}break;case 2:if(!this._private.panningEnabled)return this;n=e[0],i=e[1],(n==="x"||n==="y")&&qe(i)&&(r[n]=i),this.emit("pan viewport");break}return this.notify("viewport"),this},panBy:function(e,r){var n=arguments,i=this._private.pan,a,s,l,o,c;if(!this._private.panningEnabled)return this;switch(n.length){case 1:Bt(e)&&(l=n[0],o=l.x,c=l.y,qe(o)&&(i.x+=o),qe(c)&&(i.y+=c),this.emit("pan viewport"));break;case 2:a=e,s=r,(a==="x"||a==="y")&&qe(s)&&(i[a]+=s),this.emit("pan viewport");break}return this.notify("viewport"),this},gc:function(){this.notify("gc")},fit:function(e,r){var n=this.getFitViewport(e,r);if(n){var i=this._private;i.zoom=n.zoom,i.pan=n.pan,this.emit("pan zoom viewport"),this.notify("viewport")}return this},getFitViewport:function(e,r){if(qe(e)&&r===void 0&&(r=e,e=void 0),!(!this._private.panningEnabled||!this._private.zoomingEnabled)){var n;if(lt(e)){var i=e;e=this.$(i)}else if(EG(e)){var a=e;n={x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2},n.w=n.x2-n.x1,n.h=n.y2-n.y1}else fi(e)||(e=this.mutableElements());if(!(fi(e)&&e.empty())){n=n||e.boundingBox();var s=this.width(),l=this.height(),o;if(r=qe(r)?r:0,!isNaN(s)&&!isNaN(l)&&s>0&&l>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0){o=Math.min((s-2*r)/n.w,(l-2*r)/n.h),o=o>this._private.maxZoom?this._private.maxZoom:o,o=o<this._private.minZoom?this._private.minZoom:o;var c={x:(s-o*(n.x1+n.x2))/2,y:(l-o*(n.y1+n.y2))/2};return{zoom:o,pan:c}}}}},zoomRange:function(e,r){var n=this._private;if(r==null){var i=e;e=i.min,r=i.max}return qe(e)&&qe(r)&&e<=r?(n.minZoom=e,n.maxZoom=r):qe(e)&&r===void 0&&e<=n.maxZoom?n.minZoom=e:qe(r)&&e===void 0&&r>=n.minZoom&&(n.maxZoom=r),this},minZoom:function(e){return e===void 0?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return e===void 0?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var r=this._private,n=r.pan,i=r.zoom,a,s,l=!1;if(r.zoomingEnabled||(l=!0),qe(e)?s=e:Bt(e)&&(s=e.level,e.position!=null?a=lv(e.position,i,n):e.renderedPosition!=null&&(a=e.renderedPosition),a!=null&&!r.panningEnabled&&(l=!0)),s=s>r.maxZoom?r.maxZoom:s,s=s<r.minZoom?r.minZoom:s,l||!qe(s)||s===i||a!=null&&(!qe(a.x)||!qe(a.y)))return null;if(a!=null){var o=n,c=i,h=s,d={x:-h/c*(a.x-o.x)+a.x,y:-h/c*(a.y-o.y)+a.y};return{zoomed:!0,panned:!0,zoom:h,pan:d}}else return{zoomed:!0,panned:!1,zoom:s,pan:n}},zoom:function(e){if(e===void 0)return this._private.zoom;var r=this.getZoomedViewport(e),n=this._private;return r==null||!r.zoomed?this:(n.zoom=r.zoom,r.panned&&(n.pan.x=r.pan.x,n.pan.y=r.pan.y),this.emit("zoom"+(r.panned?" pan":"")+" viewport"),this.notify("viewport"),this)},viewport:function(e){var r=this._private,n=!0,i=!0,a=[],s=!1,l=!1;if(!e)return this;if(qe(e.zoom)||(n=!1),Bt(e.pan)||(i=!1),!n&&!i)return this;if(n){var o=e.zoom;o<r.minZoom||o>r.maxZoom||!r.zoomingEnabled?s=!0:(r.zoom=o,a.push("zoom"))}if(i&&(!s||!e.cancelOnFailedZoom)&&r.panningEnabled){var c=e.pan;qe(c.x)&&(r.pan.x=c.x,l=!1),qe(c.y)&&(r.pan.y=c.y,l=!1),l||a.push("pan")}return a.length>0&&(a.push("viewport"),this.emit(a.join(" ")),this.notify("viewport")),this},center:function(e){var r=this.getCenterPan(e);return r&&(this._private.pan=r,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,r){if(this._private.panningEnabled){if(lt(e)){var n=e;e=this.mutableElements().filter(n)}else fi(e)||(e=this.mutableElements());if(e.length!==0){var i=e.boundingBox(),a=this.width(),s=this.height();r=r===void 0?this._private.zoom:r;var l={x:(a-r*(i.x1+i.x2))/2,y:(s-r*(i.y1+i.y2))/2};return l}}},reset:function(){return!this._private.panningEnabled||!this._private.zoomingEnabled?this:(this.viewport({pan:{x:0,y:0},zoom:1}),this)},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e=this._private,r=e.container,n=this;return e.sizeCache=e.sizeCache||(r?(function(){var i=n.window().getComputedStyle(r),a=function(l){return parseFloat(i.getPropertyValue(l))};return{width:r.clientWidth-a("padding-left")-a("padding-right"),height:r.clientHeight-a("padding-top")-a("padding-bottom")}})():{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,r=this._private.zoom,n=this.renderedExtent(),i={x1:(n.x1-e.x)/r,x2:(n.x2-e.x)/r,y1:(n.y1-e.y)/r,y2:(n.y2-e.y)/r};return i.w=i.x2-i.x1,i.h=i.y2-i.y1,i},renderedExtent:function(){var e=this.width(),r=this.height();return{x1:0,y1:0,x2:e,y2:r,w:e,h:r}},multiClickDebounceTime:function(e){if(e)this._private.multiClickDebounceTime=e;else return this._private.multiClickDebounceTime;return this}};Jl.centre=Jl.center;Jl.autolockNodes=Jl.autolock;Jl.autoungrabifyNodes=Jl.autoungrabify;var Vf={data:qt.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:qt.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:qt.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:qt.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};Vf.attr=Vf.data;Vf.removeAttr=Vf.removeData;var Uf=function(e){var r=this;e=ft({},e);var n=e.container;n&&!hg(n)&&hg(n[0])&&(n=n[0]);var i=n?n._cyreg:null;i=i||{},i&&i.cy&&(i.cy.destroy(),i={});var a=i.readies=i.readies||[];n&&(n._cyreg=i),i.cy=r;var s=Lr!==void 0&&n!==void 0&&!e.headless,l=e;l.layout=ft({name:s?"grid":"null"},l.layout),l.renderer=ft({name:s?"canvas":"null"},l.renderer);var o=function(y,b,x){return b!==void 0?b:x!==void 0?x:y},c=this._private={container:n,ready:!1,options:l,elements:new on(this),listeners:[],aniEles:new on(this),data:l.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:o(!0,l.zoomingEnabled),userZoomingEnabled:o(!0,l.userZoomingEnabled),panningEnabled:o(!0,l.panningEnabled),userPanningEnabled:o(!0,l.userPanningEnabled),boxSelectionEnabled:o(!0,l.boxSelectionEnabled),autolock:o(!1,l.autolock,l.autolockNodes),autoungrabify:o(!1,l.autoungrabify,l.autoungrabifyNodes),autounselectify:o(!1,l.autounselectify),styleEnabled:l.styleEnabled===void 0?s:l.styleEnabled,zoom:qe(l.zoom)?l.zoom:1,pan:{x:Bt(l.pan)&&qe(l.pan.x)?l.pan.x:0,y:Bt(l.pan)&&qe(l.pan.y)?l.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:o(250,l.multiClickDebounceTime)};this.createEmitter(),this.selectionType(l.selectionType),this.zoomRange({min:l.minZoom,max:l.maxZoom});var h=function(y,b){var x=y.some(AG);if(x)return Gu.all(y).then(b);b(y)};c.styleEnabled&&r.setStyle([]);var d=ft({},l,l.renderer);r.initRenderer(d);var g=function(y,b,x){r.notifications(!1);var w=r.mutableElements();w.length>0&&w.remove(),y!=null&&(Bt(y)||Zt(y))&&r.add(y),r.one("layoutready",function(k){r.notifications(!0),r.emit(k),r.one("load",b),r.emitAndNotify("load")}).one("layoutstop",function(){r.one("done",x),r.emit("done")});var S=ft({},r._private.options.layout);S.eles=r.elements(),r.layout(S).run()};h([l.style,l.elements],function(m){var y=m[0],b=m[1];c.styleEnabled&&r.style().append(y),g(b,function(){r.startAnimationLoop(),c.ready=!0,hr(l.ready)&&r.on("ready",l.ready);for(var x=0;x<a.length;x++){var w=a[x];r.on("ready",w)}i&&(i.readies=[]),r.emit("ready")},l.done)})},bg=Uf.prototype;ft(bg,{instanceString:function(){return"core"},isReady:function(){return this._private.ready},destroyed:function(){return this._private.destroyed},ready:function(e){return this.isReady()?this.emitter().emit("ready",[],e):this.on("ready",e),this},destroy:function(){var e=this;if(!e.destroyed())return e.stopAnimationLoop(),e.destroyRenderer(),this.emit("destroy"),e._private.destroyed=!0,e},hasElementWithId:function(e){return this._private.elements.hasElementWithId(e)},getElementById:function(e){return this._private.elements.getElementById(e)},hasCompoundNodes:function(){return this._private.hasCompoundNodes},headless:function(){return this._private.renderer.isHeadless()},styleEnabled:function(){return this._private.styleEnabled},addToPool:function(e){return this._private.elements.merge(e),this},removeFromPool:function(e){return this._private.elements.unmerge(e),this},container:function(){return this._private.container||null},window:function(){var e=this._private.container;if(e==null)return Lr;var r=this._private.container.ownerDocument;return r===void 0||r==null?Lr:r.defaultView||Lr},mount:function(e){if(e!=null){var r=this,n=r._private,i=n.options;return!hg(e)&&hg(e[0])&&(e=e[0]),r.stopAnimationLoop(),r.destroyRenderer(),n.container=e,n.styleEnabled=!0,r.invalidateSize(),r.initRenderer(ft({},i,i.renderer,{name:i.renderer.name==="null"?"canvas":i.renderer.name})),r.startAnimationLoop(),r.style(i.style),r.emit("mount"),r}},unmount:function(){var e=this;return e.stopAnimationLoop(),e.destroyRenderer(),e.initRenderer({name:"null"}),e.emit("unmount"),e},options:function(){return la(this._private.options)},json:function(e){var r=this,n=r._private,i=r.mutableElements(),a=function(E){return r.getElementById(E.id())};if(Bt(e)){if(r.startBatch(),e.elements){var s={},l=function(E,M){for(var R=[],O=[],N=0;N<E.length;N++){var B=E[N];if(!B.data.id){jt("cy.json() cannot handle elements without an ID attribute");continue}var D=""+B.data.id,_=r.getElementById(D);s[D]=!0,_.length!==0?O.push({ele:_,json:B}):(M&&(B.group=M),R.push(B))}r.add(R);for(var P=0;P<O.length;P++){var z=O[P],H=z.ele,$=z.json;H.json($)}};if(Zt(e.elements))l(e.elements);else for(var o=["nodes","edges"],c=0;c<o.length;c++){var h=o[c],d=e.elements[h];Zt(d)&&l(d,h)}var g=r.collection();i.filter(function(k){return!s[k.id()]}).forEach(function(k){k.isParent()?g.merge(k):k.remove()}),g.forEach(function(k){return k.children().move({parent:null})}),g.forEach(function(k){return a(k).remove()})}e.style&&r.style(e.style),e.zoom!=null&&e.zoom!==n.zoom&&r.zoom(e.zoom),e.pan&&(e.pan.x!==n.pan.x||e.pan.y!==n.pan.y)&&r.pan(e.pan),e.data&&r.data(e.data);for(var m=["minZoom","maxZoom","zoomingEnabled","userZoomingEnabled","panningEnabled","userPanningEnabled","boxSelectionEnabled","autolock","autoungrabify","autounselectify","multiClickDebounceTime"],y=0;y<m.length;y++){var b=m[y];e[b]!=null&&r[b](e[b])}return r.endBatch(),this}else{var x=!!e,w={};x?w.elements=this.elements().map(function(k){return k.json()}):(w.elements={},i.forEach(function(k){var E=k.group();w.elements[E]||(w.elements[E]=[]),w.elements[E].push(k.json())})),this._private.styleEnabled&&(w.style=r.style().json()),w.data=la(r.data());var S=n.options;return w.zoomingEnabled=n.zoomingEnabled,w.userZoomingEnabled=n.userZoomingEnabled,w.zoom=n.zoom,w.minZoom=n.minZoom,w.maxZoom=n.maxZoom,w.panningEnabled=n.panningEnabled,w.userPanningEnabled=n.userPanningEnabled,w.pan=la(n.pan),w.boxSelectionEnabled=n.boxSelectionEnabled,w.renderer=la(S.renderer),w.hideEdgesOnViewport=S.hideEdgesOnViewport,w.textureOnViewport=S.textureOnViewport,w.wheelSensitivity=S.wheelSensitivity,w.motionBlur=S.motionBlur,w.multiClickDebounceTime=S.multiClickDebounceTime,w}}});bg.$id=bg.getElementById;[AQ,_Q,wj,fk,Hp,BQ,hk,Vp,zQ,Jl,Vf].forEach(function(t){ft(bg,t)});var qQ={fit:!0,directed:!1,direction:"downward",padding:30,circle:!1,grid:!1,spacingFactor:1.75,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,roots:void 0,depthSort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}},jQ={maximal:!1,acyclic:!1},tu=function(e){return e.scratch("breadthfirst")},CN=function(e,r){return e.scratch("breadthfirst",r)};function Sj(t){this.options=ft({},qQ,jQ,t)}Sj.prototype.run=function(){var t=this.options,e=t.cy,r=t.eles,n=r.nodes().filter(function($e){return $e.isChildless()}),i=r,a=t.directed,s=t.acyclic||t.maximal||t.maximalAdjustments>0,l=!!t.boundingBox,o=Rn(l?t.boundingBox:structuredClone(e.extent())),c;if(fi(t.roots))c=t.roots;else if(Zt(t.roots)){for(var h=[],d=0;d<t.roots.length;d++){var g=t.roots[d],m=e.getElementById(g);h.push(m)}c=e.collection(h)}else if(lt(t.roots))c=e.$(t.roots);else if(a)c=n.roots();else{var y=r.components();c=e.collection();for(var b=function(){var Ne=y[x],Ge=Ne.maxDegree(!1),Ve=Ne.filter(function(Qe){return Qe.degree(!1)===Ge});c=c.add(Ve)},x=0;x<y.length;x++)b()}var w=[],S={},k=function(Ne,Ge){w[Ge]==null&&(w[Ge]=[]);var Ve=w[Ge].length;w[Ge].push(Ne),CN(Ne,{index:Ve,depth:Ge})},E=function(Ne,Ge){var Ve=tu(Ne),Qe=Ve.depth,je=Ve.index;w[Qe][je]=null,Ne.isChildless()&&k(Ne,Ge)};i.bfs({roots:c,directed:t.directed,visit:function(Ne,Ge,Ve,Qe,je){var dt=Ne[0],ke=dt.id();dt.isChildless()&&k(dt,je),S[ke]=!0}});for(var M=[],R=0;R<n.length;R++){var O=n[R];S[O.id()]||M.push(O)}var N=function(Ne){for(var Ge=w[Ne],Ve=0;Ve<Ge.length;Ve++){var Qe=Ge[Ve];if(Qe==null){Ge.splice(Ve,1),Ve--;continue}CN(Qe,{depth:Ne,index:Ve})}},B=function(Ne,Ge){for(var Ve=tu(Ne),Qe=Ne.incomers().filter(function(Oe){return Oe.isNode()&&r.has(Oe)}),je=-1,dt=Ne.id(),ke=0;ke<Qe.length;ke++){var De=Qe[ke],Be=tu(De);je=Math.max(je,Be.depth)}if(Ve.depth<=je){if(!t.acyclic&&Ge[dt])return null;var Ke=je+1;return E(Ne,Ke),Ge[dt]=Ke,!0}return!1};if(a&&s){var D=[],_={},P=function(Ne){return D.push(Ne)},z=function(){return D.shift()};for(n.forEach(function($e){return D.push($e)});D.length>0;){var H=z(),$=B(H,_);if($)H.outgoers().filter(function($e){return $e.isNode()&&r.has($e)}).forEach(P);else if($===null){jt("Detected double maximal shift for node `"+H.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var q=0;if(t.avoidOverlap)for(var V=0;V<n.length;V++){var X=n[V],ee=X.layoutDimensions(t),te=ee.w,I=ee.h;q=Math.max(q,te,I)}var G={},re=function(Ne){if(G[Ne.id()])return G[Ne.id()];for(var Ge=tu(Ne).depth,Ve=Ne.neighborhood(),Qe=0,je=0,dt=0;dt<Ve.length;dt++){var ke=Ve[dt];if(!(ke.isEdge()||ke.isParent()||!n.has(ke))){var De=tu(ke);if(De!=null){var Be=De.index,Ke=De.depth;if(!(Be==null||Ke==null)){var Oe=w[Ke].length;Ke<Ge&&(Qe+=Be/Oe,je++)}}}}return je=Math.max(1,je),Qe=Qe/je,je===0&&(Qe=0),G[Ne.id()]=Qe,Qe},Y=function(Ne,Ge){var Ve=re(Ne),Qe=re(Ge),je=Ve-Qe;return je===0?Cq(Ne.id(),Ge.id()):je};t.depthSort!==void 0&&(Y=t.depthSort);for(var W=w.length,Z=0;Z<W;Z++)w[Z].sort(Y),N(Z);for(var ie=[],we=0;we<M.length;we++)ie.push(M[we]);var de=function(){for(var Ne=0;Ne<W;Ne++)N(Ne)};ie.length&&(w.unshift(ie),W=w.length,de());for(var se=0,j=0;j<W;j++)se=Math.max(w[j].length,se);var Q={x:o.x1+o.w/2,y:o.y1+o.h/2},K=n.reduce(function($e,Ne){return(function(Ge){return{w:$e.w===-1?Ge.w:($e.w+Ge.w)/2,h:$e.h===-1?Ge.h:($e.h+Ge.h)/2}})(Ne.boundingBox({includeLabels:t.nodeDimensionsIncludeLabels}))},{w:-1,h:-1}),ue=Math.max(W===1?0:l?(o.h-t.padding*2-K.h)/(W-1):(o.h-t.padding*2-K.h)/(W+1),q),Se=w.reduce(function($e,Ne){return Math.max($e,Ne.length)},0),at=function(Ne){var Ge=tu(Ne),Ve=Ge.depth,Qe=Ge.index;if(t.circle){var je=Math.min(o.w/2/W,o.h/2/W);je=Math.max(je,q);var dt=je*Ve+je-(W>0&&w[0].length<=3?je/2:0),ke=2*Math.PI/w[Ve].length*Qe;return Ve===0&&w[0].length===1&&(dt=1),{x:Q.x+dt*Math.cos(ke),y:Q.y+dt*Math.sin(ke)}}else{var De=w[Ve].length,Be=Math.max(De===1?0:l?(o.w-t.padding*2-K.w)/((t.grid?Se:De)-1):(o.w-t.padding*2-K.w)/((t.grid?Se:De)+1),q),Ke={x:Q.x+(Qe+1-(De+1)/2)*Be,y:Q.y+(Ve+1-(W+1)/2)*ue};return Ke}},Me={downward:0,leftward:90,upward:180,rightward:-90};Object.keys(Me).indexOf(t.direction)===-1&&ur("Invalid direction '".concat(t.direction,"' specified for breadthfirst layout. Valid values are: ").concat(Object.keys(Me).join(", ")));var He=function(Ne){return rY(at(Ne),o,Me[t.direction])};return r.nodes().layoutPositions(this,t,He),this};var FQ={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function Cj(t){this.options=ft({},FQ,t)}Cj.prototype.run=function(){var t=this.options,e=t,r=t.cy,n=e.eles,i=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,a=n.nodes().not(":parent");e.sort&&(a=a.sort(e.sort));for(var s=Rn(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),l={x:s.x1+s.w/2,y:s.y1+s.h/2},o=e.sweep===void 0?2*Math.PI-2*Math.PI/a.length:e.sweep,c=o/Math.max(1,a.length-1),h,d=0,g=0;g<a.length;g++){var m=a[g],y=m.layoutDimensions(e),b=y.w,x=y.h;d=Math.max(d,b,x)}if(qe(e.radius)?h=e.radius:a.length<=1?h=0:h=Math.min(s.h,s.w)/2-d,a.length>1&&e.avoidOverlap){d*=1.75;var w=Math.cos(c)-Math.cos(0),S=Math.sin(c)-Math.sin(0),k=Math.sqrt(d*d/(w*w+S*S));h=Math.max(k,h)}var E=function(R,O){var N=e.startAngle+O*c*(i?1:-1),B=h*Math.cos(N),D=h*Math.sin(N),_={x:l.x+B,y:l.y+D};return _};return n.nodes().layoutPositions(this,e,E),this};var HQ={fit:!0,padding:30,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function kj(t){this.options=ft({},HQ,t)}kj.prototype.run=function(){for(var t=this.options,e=t,r=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,n=t.cy,i=e.eles,a=i.nodes().not(":parent"),s=Rn(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),l={x:s.x1+s.w/2,y:s.y1+s.h/2},o=[],c=0,h=0;h<a.length;h++){var d=a[h],g=void 0;g=e.concentric(d),o.push({value:g,node:d}),d._private.scratch.concentric=g}a.updateStyle();for(var m=0;m<a.length;m++){var y=a[m],b=y.layoutDimensions(e);c=Math.max(c,b.w,b.h)}o.sort(function(ue,Se){return Se.value-ue.value});for(var x=e.levelWidth(a),w=[[]],S=w[0],k=0;k<o.length;k++){var E=o[k];if(S.length>0){var M=Math.abs(S[0].value-E.value);M>=x&&(S=[],w.push(S))}S.push(E)}var R=c+e.minNodeSpacing;if(!e.avoidOverlap){var O=w.length>0&&w[0].length>1,N=Math.min(s.w,s.h)/2-R,B=N/(w.length+O?1:0);R=Math.min(R,B)}for(var D=0,_=0;_<w.length;_++){var P=w[_],z=e.sweep===void 0?2*Math.PI-2*Math.PI/P.length:e.sweep,H=P.dTheta=z/Math.max(1,P.length-1);if(P.length>1&&e.avoidOverlap){var $=Math.cos(H)-Math.cos(0),q=Math.sin(H)-Math.sin(0),V=Math.sqrt(R*R/($*$+q*q));D=Math.max(V,D)}P.r=D,D+=R}if(e.equidistant){for(var X=0,ee=0,te=0;te<w.length;te++){var I=w[te],G=I.r-ee;X=Math.max(X,G)}ee=0;for(var re=0;re<w.length;re++){var Y=w[re];re===0&&(ee=Y.r),Y.r=ee,ee+=X}}for(var W={},Z=0;Z<w.length;Z++)for(var ie=w[Z],we=ie.dTheta,de=ie.r,se=0;se<ie.length;se++){var j=ie[se],Q=e.startAngle+(r?1:-1)*we*se,K={x:l.x+de*Math.cos(Q),y:l.y+de*Math.sin(Q)};W[j.node.id()]=K}return i.nodes().layoutPositions(this,e,function(ue){var Se=ue.id();return W[Se]}),this};var Fb,VQ={ready:function(){},stop:function(){},animate:!0,animationEasing:void 0,animationDuration:void 0,animateFilter:function(e,r){return!0},animationThreshold:250,refresh:20,fit:!0,padding:30,boundingBox:void 0,nodeDimensionsIncludeLabels:!1,randomize:!1,componentSpacing:40,nodeRepulsion:function(e){return 2048},nodeOverlap:4,idealEdgeLength:function(e){return 32},edgeElasticity:function(e){return 32},nestingFactor:1.2,gravity:1,numIter:1e3,initialTemp:1e3,coolingFactor:.99,minTemp:1};function bv(t){this.options=ft({},VQ,t),this.options.layout=this;var e=this.options.eles.nodes(),r=this.options.eles.edges(),n=r.filter(function(i){var a=i.source().data("id"),s=i.target().data("id"),l=e.some(function(c){return c.data("id")===a}),o=e.some(function(c){return c.data("id")===s});return!l||!o});this.options.eles=this.options.eles.not(n)}bv.prototype.run=function(){var t=this.options,e=t.cy,r=this;r.stopped=!1,(t.animate===!0||t.animate===!1)&&r.emit({type:"layoutstart",layout:r}),t.debug===!0?Fb=!0:Fb=!1;var n=UQ(e,r,t);Fb&&GQ(n),t.randomize&&YQ(n);var i=Ya(),a=function(){XQ(n,e,t),t.fit===!0&&e.fit(t.padding)},s=function(g){return!(r.stopped||g>=t.numIter||(WQ(n,t),n.temperature=n.temperature*t.coolingFactor,n.temperature<t.minTemp))},l=function(){if(t.animate===!0||t.animate===!1)a(),r.one("layoutstop",t.stop),r.emit({type:"layoutstop",layout:r});else{var g=t.eles.nodes(),m=Ej(n,t,g);g.layoutPositions(r,t,m)}},o=0,c=!0;if(t.animate===!0){var h=function(){for(var g=0;c&&g<t.refresh;)c=s(o),o++,g++;if(!c)TN(n,t),l();else{var m=Ya();m-i>=t.animationThreshold&&a(),dg(h)}};h()}else{for(;c;)c=s(o),o++;TN(n,t),l()}return this};bv.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this};bv.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var UQ=function(e,r,n){for(var i=n.eles.edges(),a=n.eles.nodes(),s=Rn(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),l={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:a.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:i.size(),temperature:n.initialTemp,clientWidth:s.w,clientHeight:s.h,boundingBox:s},o=n.eles.components(),c={},h=0;h<o.length;h++)for(var d=o[h],g=0;g<d.length;g++){var m=d[g];c[m.id()]=h}for(var h=0;h<l.nodeSize;h++){var y=a[h],b=y.layoutDimensions(n),x={};x.isLocked=y.locked(),x.id=y.data("id"),x.parentId=y.data("parent"),x.cmptId=c[y.id()],x.children=[],x.positionX=y.position("x"),x.positionY=y.position("y"),x.offsetX=0,x.offsetY=0,x.height=b.w,x.width=b.h,x.maxX=x.positionX+x.width/2,x.minX=x.positionX-x.width/2,x.maxY=x.positionY+x.height/2,x.minY=x.positionY-x.height/2,x.padLeft=parseFloat(y.style("padding")),x.padRight=parseFloat(y.style("padding")),x.padTop=parseFloat(y.style("padding")),x.padBottom=parseFloat(y.style("padding")),x.nodeRepulsion=hr(n.nodeRepulsion)?n.nodeRepulsion(y):n.nodeRepulsion,l.layoutNodes.push(x),l.idToIndex[x.id]=h}for(var w=[],S=0,k=-1,E=[],h=0;h<l.nodeSize;h++){var y=l.layoutNodes[h],M=y.parentId;M!=null?l.layoutNodes[l.idToIndex[M]].children.push(y.id):(w[++k]=y.id,E.push(y.id))}for(l.graphSet.push(E);S<=k;){var R=w[S++],O=l.idToIndex[R],m=l.layoutNodes[O],N=m.children;if(N.length>0){l.graphSet.push(N);for(var h=0;h<N.length;h++)w[++k]=N[h]}}for(var h=0;h<l.graphSet.length;h++)for(var B=l.graphSet[h],g=0;g<B.length;g++){var D=l.idToIndex[B[g]];l.indexToGraph[D]=h}for(var h=0;h<l.edgeSize;h++){var _=i[h],P={};P.id=_.data("id"),P.sourceId=_.data("source"),P.targetId=_.data("target");var z=hr(n.idealEdgeLength)?n.idealEdgeLength(_):n.idealEdgeLength,H=hr(n.edgeElasticity)?n.edgeElasticity(_):n.edgeElasticity,$=l.idToIndex[P.sourceId],q=l.idToIndex[P.targetId],V=l.indexToGraph[$],X=l.indexToGraph[q];if(V!=X){for(var ee=$Q(P.sourceId,P.targetId,l),te=l.graphSet[ee],I=0,x=l.layoutNodes[$];te.indexOf(x.id)===-1;)x=l.layoutNodes[l.idToIndex[x.parentId]],I++;for(x=l.layoutNodes[q];te.indexOf(x.id)===-1;)x=l.layoutNodes[l.idToIndex[x.parentId]],I++;z*=I*n.nestingFactor}P.idealLength=z,P.elasticity=H,l.layoutEdges.push(P)}return l},$Q=function(e,r,n){var i=Tj(e,r,0,n);return 2>i.count?0:i.graph},Tj=function(e,r,n,i){var a=i.graphSet[n];if(-1<a.indexOf(e)&&-1<a.indexOf(r))return{count:2,graph:n};for(var s=0,l=0;l<a.length;l++){var o=a[l],c=i.idToIndex[o],h=i.layoutNodes[c].children;if(h.length!==0){var d=i.indexToGraph[i.idToIndex[h[0]]],g=Tj(e,r,d,i);if(g.count!==0)if(g.count===1){if(s++,s===2)break}else return g}}return{count:s,graph:n}},GQ,YQ=function(e,r){for(var n=e.clientWidth,i=e.clientHeight,a=0;a<e.nodeSize;a++){var s=e.layoutNodes[a];s.children.length===0&&!s.isLocked&&(s.positionX=Math.random()*n,s.positionY=Math.random()*i)}},Ej=function(e,r,n){var i=e.boundingBox,a={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0};return r.boundingBox&&(n.forEach(function(s){var l=e.layoutNodes[e.idToIndex[s.data("id")]];a.x1=Math.min(a.x1,l.positionX),a.x2=Math.max(a.x2,l.positionX),a.y1=Math.min(a.y1,l.positionY),a.y2=Math.max(a.y2,l.positionY)}),a.w=a.x2-a.x1,a.h=a.y2-a.y1),function(s,l){var o=e.layoutNodes[e.idToIndex[s.data("id")]];if(r.boundingBox){var c=a.w===0?.5:(o.positionX-a.x1)/a.w,h=a.h===0?.5:(o.positionY-a.y1)/a.h;return{x:i.x1+c*i.w,y:i.y1+h*i.h}}else return{x:o.positionX,y:o.positionY}}},XQ=function(e,r,n){var i=n.layout,a=n.eles.nodes(),s=Ej(e,n,a);a.positions(s),e.ready!==!0&&(e.ready=!0,i.one("layoutready",n.ready),i.emit({type:"layoutready",layout:this}))},WQ=function(e,r,n){QQ(e,r),JQ(e),eK(e,r),tK(e),rK(e)},QQ=function(e,r){for(var n=0;n<e.graphSet.length;n++)for(var i=e.graphSet[n],a=i.length,s=0;s<a;s++)for(var l=e.layoutNodes[e.idToIndex[i[s]]],o=s+1;o<a;o++){var c=e.layoutNodes[e.idToIndex[i[o]]];KQ(l,c,e,r)}},kN=function(e){return-1+2*e*Math.random()},KQ=function(e,r,n,i){var a=e.cmptId,s=r.cmptId;if(!(a!==s&&!n.isCompound)){var l=r.positionX-e.positionX,o=r.positionY-e.positionY,c=1;l===0&&o===0&&(l=kN(c),o=kN(c));var h=ZQ(e,r,l,o);if(h>0)var d=i.nodeOverlap*h,g=Math.sqrt(l*l+o*o),m=d*l/g,y=d*o/g;else var b=xg(e,l,o),x=xg(r,-1*l,-1*o),w=x.x-b.x,S=x.y-b.y,k=w*w+S*S,g=Math.sqrt(k),d=(e.nodeRepulsion+r.nodeRepulsion)/k,m=d*w/g,y=d*S/g;e.isLocked||(e.offsetX-=m,e.offsetY-=y),r.isLocked||(r.offsetX+=m,r.offsetY+=y)}},ZQ=function(e,r,n,i){if(n>0)var a=e.maxX-r.minX;else var a=r.maxX-e.minX;if(i>0)var s=e.maxY-r.minY;else var s=r.maxY-e.minY;return a>=0&&s>=0?Math.sqrt(a*a+s*s):0},xg=function(e,r,n){var i=e.positionX,a=e.positionY,s=e.height||1,l=e.width||1,o=n/r,c=s/l,h={};return r===0&&0<n||r===0&&0>n?(h.x=i,h.y=a+s/2,h):0<r&&-1*c<=o&&o<=c?(h.x=i+l/2,h.y=a+l*n/2/r,h):0>r&&-1*c<=o&&o<=c?(h.x=i-l/2,h.y=a-l*n/2/r,h):0<n&&(o<=-1*c||o>=c)?(h.x=i+s*r/2/n,h.y=a+s/2,h):(0>n&&(o<=-1*c||o>=c)&&(h.x=i-s*r/2/n,h.y=a-s/2),h)},JQ=function(e,r){for(var n=0;n<e.edgeSize;n++){var i=e.layoutEdges[n],a=e.idToIndex[i.sourceId],s=e.layoutNodes[a],l=e.idToIndex[i.targetId],o=e.layoutNodes[l],c=o.positionX-s.positionX,h=o.positionY-s.positionY;if(!(c===0&&h===0)){var d=xg(s,c,h),g=xg(o,-1*c,-1*h),m=g.x-d.x,y=g.y-d.y,b=Math.sqrt(m*m+y*y),x=Math.pow(i.idealLength-b,2)/i.elasticity;if(b!==0)var w=x*m/b,S=x*y/b;else var w=0,S=0;s.isLocked||(s.offsetX+=w,s.offsetY+=S),o.isLocked||(o.offsetX-=w,o.offsetY-=S)}}},eK=function(e,r){if(r.gravity!==0)for(var n=1,i=0;i<e.graphSet.length;i++){var a=e.graphSet[i],s=a.length;if(i===0)var l=e.clientHeight/2,o=e.clientWidth/2;else var c=e.layoutNodes[e.idToIndex[a[0]]],h=e.layoutNodes[e.idToIndex[c.parentId]],l=h.positionX,o=h.positionY;for(var d=0;d<s;d++){var g=e.layoutNodes[e.idToIndex[a[d]]];if(!g.isLocked){var m=l-g.positionX,y=o-g.positionY,b=Math.sqrt(m*m+y*y);if(b>n){var x=r.gravity*m/b,w=r.gravity*y/b;g.offsetX+=x,g.offsetY+=w}}}}},tK=function(e,r){var n=[],i=0,a=-1;for(n.push.apply(n,e.graphSet[0]),a+=e.graphSet[0].length;i<=a;){var s=n[i++],l=e.idToIndex[s],o=e.layoutNodes[l],c=o.children;if(0<c.length&&!o.isLocked){for(var h=o.offsetX,d=o.offsetY,g=0;g<c.length;g++){var m=e.layoutNodes[e.idToIndex[c[g]]];m.offsetX+=h,m.offsetY+=d,n[++a]=c[g]}o.offsetX=0,o.offsetY=0}}},rK=function(e,r){for(var n=0;n<e.nodeSize;n++){var i=e.layoutNodes[n];0<i.children.length&&(i.maxX=void 0,i.minX=void 0,i.maxY=void 0,i.minY=void 0)}for(var n=0;n<e.nodeSize;n++){var i=e.layoutNodes[n];if(!(0<i.children.length||i.isLocked)){var a=nK(i.offsetX,i.offsetY,e.temperature);i.positionX+=a.x,i.positionY+=a.y,i.offsetX=0,i.offsetY=0,i.minX=i.positionX-i.width,i.maxX=i.positionX+i.width,i.minY=i.positionY-i.height,i.maxY=i.positionY+i.height,Aj(i,e)}}for(var n=0;n<e.nodeSize;n++){var i=e.layoutNodes[n];0<i.children.length&&!i.isLocked&&(i.positionX=(i.maxX+i.minX)/2,i.positionY=(i.maxY+i.minY)/2,i.width=i.maxX-i.minX,i.height=i.maxY-i.minY)}},nK=function(e,r,n){var i=Math.sqrt(e*e+r*r);if(i>n)var a={x:n*e/i,y:n*r/i};else var a={x:e,y:r};return a},Aj=function(e,r){var n=e.parentId;if(n!=null){var i=r.layoutNodes[r.idToIndex[n]],a=!1;if((i.maxX==null||e.maxX+i.padRight>i.maxX)&&(i.maxX=e.maxX+i.padRight,a=!0),(i.minX==null||e.minX-i.padLeft<i.minX)&&(i.minX=e.minX-i.padLeft,a=!0),(i.maxY==null||e.maxY+i.padBottom>i.maxY)&&(i.maxY=e.maxY+i.padBottom,a=!0),(i.minY==null||e.minY-i.padTop<i.minY)&&(i.minY=e.minY-i.padTop,a=!0),a)return Aj(i,r)}},TN=function(e,r){for(var n=e.layoutNodes,i=[],a=0;a<n.length;a++){var s=n[a],l=s.cmptId,o=i[l]=i[l]||[];o.push(s)}for(var c=0,a=0;a<i.length;a++){var h=i[a];if(h){h.x1=1/0,h.x2=-1/0,h.y1=1/0,h.y2=-1/0;for(var d=0;d<h.length;d++){var g=h[d];h.x1=Math.min(h.x1,g.positionX-g.width/2),h.x2=Math.max(h.x2,g.positionX+g.width/2),h.y1=Math.min(h.y1,g.positionY-g.height/2),h.y2=Math.max(h.y2,g.positionY+g.height/2)}h.w=h.x2-h.x1,h.h=h.y2-h.y1,c+=h.w*h.h}}i.sort(function(S,k){return k.w*k.h-S.w*S.h});for(var m=0,y=0,b=0,x=0,w=Math.sqrt(c)*e.clientWidth/e.clientHeight,a=0;a<i.length;a++){var h=i[a];if(h){for(var d=0;d<h.length;d++){var g=h[d];g.isLocked||(g.positionX+=m-h.x1,g.positionY+=y-h.y1)}m+=h.w+r.componentSpacing,b+=h.w+r.componentSpacing,x=Math.max(x,h.h),b>w&&(y+=x+r.componentSpacing,m=0,b=0,x=0)}}},iK={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function Oj(t){this.options=ft({},iK,t)}Oj.prototype.run=function(){var t=this.options,e=t,r=t.cy,n=e.eles,i=n.nodes().not(":parent");e.sort&&(i=i.sort(e.sort));var a=Rn(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()});if(a.h===0||a.w===0)n.nodes().layoutPositions(this,e,function(re){return{x:a.x1,y:a.y1}});else{var s=i.size(),l=Math.sqrt(s*a.h/a.w),o=Math.round(l),c=Math.round(a.w/a.h*l),h=function(Y){if(Y==null)return Math.min(o,c);var W=Math.min(o,c);W==o?o=Y:c=Y},d=function(Y){if(Y==null)return Math.max(o,c);var W=Math.max(o,c);W==o?o=Y:c=Y},g=e.rows,m=e.cols!=null?e.cols:e.columns;if(g!=null&&m!=null)o=g,c=m;else if(g!=null&&m==null)o=g,c=Math.ceil(s/o);else if(g==null&&m!=null)c=m,o=Math.ceil(s/c);else if(c*o>s){var y=h(),b=d();(y-1)*b>=s?h(y-1):(b-1)*y>=s&&d(b-1)}else for(;c*o<s;){var x=h(),w=d();(w+1)*x>=s?d(w+1):h(x+1)}var S=a.w/c,k=a.h/o;if(e.condense&&(S=0,k=0),e.avoidOverlap)for(var E=0;E<i.length;E++){var M=i[E],R=M._private.position;(R.x==null||R.y==null)&&(R.x=0,R.y=0);var O=M.layoutDimensions(e),N=e.avoidOverlapPadding,B=O.w+N,D=O.h+N;S=Math.max(S,B),k=Math.max(k,D)}for(var _={},P=function(Y,W){return!!_["c-"+Y+"-"+W]},z=function(Y,W){_["c-"+Y+"-"+W]=!0},H=0,$=0,q=function(){$++,$>=c&&($=0,H++)},V={},X=0;X<i.length;X++){var ee=i[X],te=e.position(ee);if(te&&(te.row!==void 0||te.col!==void 0)){var I={row:te.row,col:te.col};if(I.col===void 0)for(I.col=0;P(I.row,I.col);)I.col++;else if(I.row===void 0)for(I.row=0;P(I.row,I.col);)I.row++;V[ee.id()]=I,z(I.row,I.col)}}var G=function(Y,W){var Z,ie;if(Y.locked()||Y.isParent())return!1;var we=V[Y.id()];if(we)Z=we.col*S+S/2+a.x1,ie=we.row*k+k/2+a.y1;else{for(;P(H,$);)q();Z=$*S+S/2+a.x1,ie=H*k+k/2+a.y1,z(H,$),q()}return{x:Z,y:ie}};i.layoutPositions(this,e,G)}return this};var aK={ready:function(){},stop:function(){}};function QT(t){this.options=ft({},aK,t)}QT.prototype.run=function(){var t=this.options,e=t.eles,r=this;return t.cy,r.emit("layoutstart"),e.nodes().positions(function(){return{x:0,y:0}}),r.one("layoutready",t.ready),r.emit("layoutready"),r.one("layoutstop",t.stop),r.emit("layoutstop"),this};QT.prototype.stop=function(){return this};var sK={positions:void 0,zoom:void 0,pan:void 0,fit:!0,padding:30,spacingFactor:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function Mj(t){this.options=ft({},sK,t)}Mj.prototype.run=function(){var t=this.options,e=t.eles,r=e.nodes(),n=hr(t.positions);function i(a){if(t.positions==null)return OY(a.position());if(n)return t.positions(a);var s=t.positions[a._private.data.id];return s??null}return r.layoutPositions(this,t,function(a,s){var l=i(a);return a.locked()||l==null?!1:l}),this};var lK={fit:!0,padding:30,boundingBox:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,r){return!0},ready:void 0,stop:void 0,transform:function(e,r){return r}};function Rj(t){this.options=ft({},lK,t)}Rj.prototype.run=function(){var t=this.options,e=t.cy,r=t.eles,n=Rn(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),i=function(s,l){return{x:n.x1+Math.round(Math.random()*n.w),y:n.y1+Math.round(Math.random()*n.h)}};return r.nodes().layoutPositions(this,t,i),this};var oK=[{name:"breadthfirst",impl:Sj},{name:"circle",impl:Cj},{name:"concentric",impl:kj},{name:"cose",impl:bv},{name:"grid",impl:Oj},{name:"null",impl:QT},{name:"preset",impl:Mj},{name:"random",impl:Rj}];function Dj(t){this.options=t,this.notifications=0}var EN=function(){},AN=function(){throw new Error("A headless instance can not render images")};Dj.prototype={recalculateRenderedStyle:EN,notify:function(){this.notifications++},init:EN,isHeadless:function(){return!0},png:AN,jpg:AN};var KT={};KT.arrowShapeWidth=.3;KT.registerArrowShapes=function(){var t=this.arrowShapes={},e=this,r=function(c,h,d,g,m,y,b){var x=m.x-d/2-b,w=m.x+d/2+b,S=m.y-d/2-b,k=m.y+d/2+b,E=x<=c&&c<=w&&S<=h&&h<=k;return E},n=function(c,h,d,g,m){var y=c*Math.cos(g)-h*Math.sin(g),b=c*Math.sin(g)+h*Math.cos(g),x=y*d,w=b*d,S=x+m.x,k=w+m.y;return{x:S,y:k}},i=function(c,h,d,g){for(var m=[],y=0;y<c.length;y+=2){var b=c[y],x=c[y+1];m.push(n(b,x,h,d,g))}return m},a=function(c){for(var h=[],d=0;d<c.length;d++){var g=c[d];h.push(g.x,g.y)}return h},s=function(c){return c.pstyle("width").pfValue*c.pstyle("arrow-scale").pfValue*2},l=function(c,h){lt(h)&&(h=t[h]),t[c]=ft({name:c,points:[-.15,-.3,.15,-.3,.15,.3,-.15,.3],collide:function(g,m,y,b,x,w){var S=a(i(this.points,y+2*w,b,x)),k=Hn(g,m,S);return k},roughCollide:r,draw:function(g,m,y,b){var x=i(this.points,m,y,b);e.arrowShapeImpl("polygon")(g,x)},spacing:function(g){return 0},gap:s},h)};l("none",{collide:pg,roughCollide:pg,draw:PT,spacing:FD,gap:FD}),l("triangle",{points:[-.15,-.3,0,0,.15,-.3]}),l("arrow","triangle"),l("triangle-backcurve",{points:t.triangle.points,controlPoint:[0,-.15],roughCollide:r,draw:function(c,h,d,g,m){var y=i(this.points,h,d,g),b=this.controlPoint,x=n(b[0],b[1],h,d,g);e.arrowShapeImpl(this.name)(c,y,x)},gap:function(c){return s(c)*.8}}),l("triangle-tee",{points:[0,0,.15,-.3,-.15,-.3,0,0],pointsTee:[-.15,-.4,-.15,-.5,.15,-.5,.15,-.4],collide:function(c,h,d,g,m,y,b){var x=a(i(this.points,d+2*b,g,m)),w=a(i(this.pointsTee,d+2*b,g,m)),S=Hn(c,h,x)||Hn(c,h,w);return S},draw:function(c,h,d,g,m){var y=i(this.points,h,d,g),b=i(this.pointsTee,h,d,g);e.arrowShapeImpl(this.name)(c,y,b)}}),l("circle-triangle",{radius:.15,pointsTr:[0,-.15,.15,-.45,-.15,-.45,0,-.15],collide:function(c,h,d,g,m,y,b){var x=m,w=Math.pow(x.x-c,2)+Math.pow(x.y-h,2)<=Math.pow((d+2*b)*this.radius,2),S=a(i(this.points,d+2*b,g,m));return Hn(c,h,S)||w},draw:function(c,h,d,g,m){var y=i(this.pointsTr,h,d,g);e.arrowShapeImpl(this.name)(c,y,g.x,g.y,this.radius*h)},spacing:function(c){return e.getArrowWidth(c.pstyle("width").pfValue,c.pstyle("arrow-scale").value)*this.radius}}),l("triangle-cross",{points:[0,0,.15,-.3,-.15,-.3,0,0],baseCrossLinePts:[-.15,-.4,-.15,-.4,.15,-.4,.15,-.4],crossLinePts:function(c,h){var d=this.baseCrossLinePts.slice(),g=h/c,m=3,y=5;return d[m]=d[m]-g,d[y]=d[y]-g,d},collide:function(c,h,d,g,m,y,b){var x=a(i(this.points,d+2*b,g,m)),w=a(i(this.crossLinePts(d,y),d+2*b,g,m)),S=Hn(c,h,x)||Hn(c,h,w);return S},draw:function(c,h,d,g,m){var y=i(this.points,h,d,g),b=i(this.crossLinePts(h,m),h,d,g);e.arrowShapeImpl(this.name)(c,y,b)}}),l("vee",{points:[-.15,-.3,0,0,.15,-.3,0,-.15],gap:function(c){return s(c)*.525}}),l("circle",{radius:.15,collide:function(c,h,d,g,m,y,b){var x=m,w=Math.pow(x.x-c,2)+Math.pow(x.y-h,2)<=Math.pow((d+2*b)*this.radius,2);return w},draw:function(c,h,d,g,m){e.arrowShapeImpl(this.name)(c,g.x,g.y,this.radius*h)},spacing:function(c){return e.getArrowWidth(c.pstyle("width").pfValue,c.pstyle("arrow-scale").value)*this.radius}}),l("tee",{points:[-.15,0,-.15,-.1,.15,-.1,.15,0],spacing:function(c){return 1},gap:function(c){return 1}}),l("square",{points:[-.15,0,.15,0,.15,-.3,-.15,-.3]}),l("diamond",{points:[-.15,-.15,0,-.3,.15,-.15,0,0],gap:function(c){return c.pstyle("width").pfValue*c.pstyle("arrow-scale").value}}),l("chevron",{points:[0,0,-.15,-.15,-.1,-.2,0,-.1,.1,-.2,.15,-.15],gap:function(c){return .95*c.pstyle("width").pfValue*c.pstyle("arrow-scale").value}})};var lo={};lo.projectIntoViewport=function(t,e){var r=this.cy,n=this.findContainerClientCoords(),i=n[0],a=n[1],s=n[4],l=r.pan(),o=r.zoom(),c=((t-i)/s-l.x)/o,h=((e-a)/s-l.y)/o;return[c,h]};lo.findContainerClientCoords=function(){if(this.containerBB)return this.containerBB;var t=this.container,e=t.getBoundingClientRect(),r=this.cy.window().getComputedStyle(t),n=function(w){return parseFloat(r.getPropertyValue(w))},i={left:n("padding-left"),right:n("padding-right"),top:n("padding-top"),bottom:n("padding-bottom")},a={left:n("border-left-width"),right:n("border-right-width"),top:n("border-top-width"),bottom:n("border-bottom-width")},s=t.clientWidth,l=t.clientHeight,o=i.left+i.right,c=i.top+i.bottom,h=a.left+a.right,d=e.width/(s+h),g=s-o,m=l-c,y=e.left+i.left+a.left,b=e.top+i.top+a.top;return this.containerBB=[y,b,g,m,d]};lo.invalidateContainerClientCoordsCache=function(){this.containerBB=null};lo.findNearestElement=function(t,e,r,n){return this.findNearestElements(t,e,r,n)[0]};lo.findNearestElements=function(t,e,r,n){var i=this,a=this,s=a.getCachedZSortedEles(),l=[],o=a.cy.zoom(),c=a.cy.hasCompoundNodes(),h=(n?24:8)/o,d=(n?8:2)/o,g=(n?8:2)/o,m=1/0,y,b;r&&(s=s.interactive);function x(O,N){if(O.isNode()){if(b)return;b=O,l.push(O)}if(O.isEdge()&&(N==null||N<m))if(y){if(y.pstyle("z-compound-depth").value===O.pstyle("z-compound-depth").value&&y.pstyle("z-compound-depth").value===O.pstyle("z-compound-depth").value){for(var B=0;B<l.length;B++)if(l[B].isEdge()){l[B]=O,y=O,m=N??m;break}}}else l.push(O),y=O,m=N??m}function w(O){var N=O.outerWidth()+2*d,B=O.outerHeight()+2*d,D=N/2,_=B/2,P=O.position(),z=O.pstyle("corner-radius").value==="auto"?"auto":O.pstyle("corner-radius").pfValue,H=O._private.rscratch;if(P.x-D<=t&&t<=P.x+D&&P.y-_<=e&&e<=P.y+_){var $=a.nodeShapes[i.getNodeShape(O)];if($.checkPoint(t,e,0,N,B,P.x,P.y,z,H))return x(O,0),!0}}function S(O){var N=O._private,B=N.rscratch,D=O.pstyle("width").pfValue,_=O.pstyle("arrow-scale").value,P=D/2+h,z=P*P,H=P*2,X=N.source,ee=N.target,$;if(B.edgeType==="segments"||B.edgeType==="straight"||B.edgeType==="haystack"){for(var q=B.allpts,V=0;V+3<q.length;V+=2)if(HY(t,e,q[V],q[V+1],q[V+2],q[V+3],H)&&z>($=YY(t,e,q[V],q[V+1],q[V+2],q[V+3])))return x(O,$),!0}else if(B.edgeType==="bezier"||B.edgeType==="multibezier"||B.edgeType==="self"||B.edgeType==="compound"){for(var q=B.allpts,V=0;V+5<B.allpts.length;V+=4)if(VY(t,e,q[V],q[V+1],q[V+2],q[V+3],q[V+4],q[V+5],H)&&z>($=GY(t,e,q[V],q[V+1],q[V+2],q[V+3],q[V+4],q[V+5])))return x(O,$),!0}for(var X=X||N.source,ee=ee||N.target,te=i.getArrowWidth(D,_),I=[{name:"source",x:B.arrowStartX,y:B.arrowStartY,angle:B.srcArrowAngle},{name:"target",x:B.arrowEndX,y:B.arrowEndY,angle:B.tgtArrowAngle},{name:"mid-source",x:B.midX,y:B.midY,angle:B.midsrcArrowAngle},{name:"mid-target",x:B.midX,y:B.midY,angle:B.midtgtArrowAngle}],V=0;V<I.length;V++){var G=I[V],re=a.arrowShapes[O.pstyle(G.name+"-arrow-shape").value],Y=O.pstyle("width").pfValue;if(re.roughCollide(t,e,te,G.angle,{x:G.x,y:G.y},Y,h)&&re.collide(t,e,te,G.angle,{x:G.x,y:G.y},Y,h))return x(O),!0}c&&l.length>0&&(w(X),w(ee))}function k(O,N,B){return Fn(O,N,B)}function E(O,N){var B=O._private,D=g,_;N?_=N+"-":_="",O.boundingBox();var P=B.labelBounds[N||"main"],z=O.pstyle(_+"label").value,H=O.pstyle("text-events").strValue==="yes";if(!(!H||!z)){var $=k(B.rscratch,"labelX",N),q=k(B.rscratch,"labelY",N),V=k(B.rscratch,"labelAngle",N),X=O.pstyle(_+"text-margin-x").pfValue,ee=O.pstyle(_+"text-margin-y").pfValue,te=P.x1-D-X,I=P.x2+D-X,G=P.y1-D-ee,re=P.y2+D-ee;if(V){var Y=Math.cos(V),W=Math.sin(V),Z=function(K,ue){return K=K-$,ue=ue-q,{x:K*Y-ue*W+$,y:K*W+ue*Y+q}},ie=Z(te,G),we=Z(te,re),de=Z(I,G),se=Z(I,re),j=[ie.x+X,ie.y+ee,de.x+X,de.y+ee,se.x+X,se.y+ee,we.x+X,we.y+ee];if(Hn(t,e,j))return x(O),!0}else if(Is(P,t,e))return x(O),!0}}for(var M=s.length-1;M>=0;M--){var R=s[M];R.isNode()?w(R)||E(R):S(R)||E(R)||E(R,"source")||E(R,"target")}return l};lo.getAllInBox=function(t,e,r,n){var i=this.getCachedZSortedEles().interactive,a=this.cy.zoom(),s=2/a,l=[],o=Math.min(t,r),c=Math.max(t,r),h=Math.min(e,n),d=Math.max(e,n);t=o,r=c,e=h,n=d;var g=Rn({x1:t,y1:e,x2:r,y2:n}),m=[{x:g.x1,y:g.y1},{x:g.x2,y:g.y1},{x:g.x2,y:g.y2},{x:g.x1,y:g.y2}],y=[[m[0],m[1]],[m[1],m[2]],[m[2],m[3]],[m[3],m[0]]];function b(K,ue,Se){return Fn(K,ue,Se)}function x(K,ue){var Se=K._private,at=s,Me="";K.boundingBox();var He=Se.labelBounds.main;if(!He)return null;var $e=b(Se.rscratch,"labelX",ue),Ne=b(Se.rscratch,"labelY",ue),Ge=b(Se.rscratch,"labelAngle",ue),Ve=K.pstyle(Me+"text-margin-x").pfValue,Qe=K.pstyle(Me+"text-margin-y").pfValue,je=He.x1-at-Ve,dt=He.x2+at-Ve,ke=He.y1-at-Qe,De=He.y2+at-Qe;if(Ge){var Be=Math.cos(Ge),Ke=Math.sin(Ge),Oe=function(ce,F){return ce=ce-$e,F=F-Ne,{x:ce*Be-F*Ke+$e,y:ce*Ke+F*Be+Ne}};return[Oe(je,ke),Oe(dt,ke),Oe(dt,De),Oe(je,De)]}else return[{x:je,y:ke},{x:dt,y:ke},{x:dt,y:De},{x:je,y:De}]}function w(K,ue,Se,at){function Me(He,$e,Ne){return(Ne.y-He.y)*($e.x-He.x)>($e.y-He.y)*(Ne.x-He.x)}return Me(K,Se,at)!==Me(ue,Se,at)&&Me(K,ue,Se)!==Me(K,ue,at)}for(var S=0;S<i.length;S++){var k=i[S];if(k.isNode()){var E=k,M=E.pstyle("text-events").strValue==="yes",R=E.pstyle("box-selection").strValue,O=E.pstyle("box-select-labels").strValue==="yes";if(R==="none")continue;var N=(R==="overlap"||O)&&M,B=E.boundingBox({includeNodes:!0,includeEdges:!1,includeLabels:N});if(R==="contain"){var D=!1;if(O&&M){var _=x(E);_&&qy(_,m)&&(l.push(E),D=!0)}!D&&Iq(g,B)&&l.push(E)}else if(R==="overlap"&&jT(g,B)){var P=E.boundingBox({includeNodes:!0,includeEdges:!0,includeLabels:!1,includeMainLabels:!1,includeSourceLabels:!1,includeTargetLabels:!1}),z=[{x:P.x1,y:P.y1},{x:P.x2,y:P.y1},{x:P.x2,y:P.y2},{x:P.x1,y:P.y2}];if(qy(z,m))l.push(E);else{var H=x(E);H&&qy(H,m)&&l.push(E)}}}else{var $=k,q=$._private,V=q.rscratch,X=$.pstyle("box-selection").strValue;if(X==="none")continue;if(X==="contain"){if(V.startX!=null&&V.startY!=null&&!Is(g,V.startX,V.startY)||V.endX!=null&&V.endY!=null&&!Is(g,V.endX,V.endY))continue;if(V.edgeType==="bezier"||V.edgeType==="multibezier"||V.edgeType==="self"||V.edgeType==="compound"||V.edgeType==="segments"||V.edgeType==="haystack"){for(var ee=q.rstyle.bezierPts||q.rstyle.linePts||q.rstyle.haystackPts,te=!0,I=0;I<ee.length;I++)if(!GD(g,ee[I])){te=!1;break}te&&l.push($)}else V.edgeType==="straight"&&l.push($)}else if(X==="overlap"){var G=!1;if(V.startX!=null&&V.startY!=null&&V.endX!=null&&V.endY!=null&&(Is(g,V.startX,V.startY)||Is(g,V.endX,V.endY)))l.push($),G=!0;else if(!G&&V.edgeType==="haystack"){for(var re=q.rstyle.haystackPts,Y=0;Y<re.length;Y++)if(GD(g,re[Y])){l.push($),G=!0;break}}if(!G){var W=q.rstyle.bezierPts||q.rstyle.linePts||q.rstyle.haystackPts;if((!W||W.length<2)&&V.edgeType==="straight"&&V.startX!=null&&V.startY!=null&&V.endX!=null&&V.endY!=null&&(W=[{x:V.startX,y:V.startY},{x:V.endX,y:V.endY}]),!W||W.length<2)continue;for(var Z=0;Z<W.length-1;Z++){for(var ie=W[Z],we=W[Z+1],de=0;de<y.length;de++){var se=Rr(y[de],2),j=se[0],Q=se[1];if(w(ie,we,j,Q)){l.push($),G=!0;break}}if(G)break}}}}}return l};var wg={};wg.calculateArrowAngles=function(t){var e=t._private.rscratch,r=e.edgeType==="haystack",n=e.edgeType==="bezier",i=e.edgeType==="multibezier",a=e.edgeType==="segments",s=e.edgeType==="compound",l=e.edgeType==="self",o,c,h,d,g,m,w,S;if(r?(h=e.haystackPts[0],d=e.haystackPts[1],g=e.haystackPts[2],m=e.haystackPts[3]):(h=e.arrowStartX,d=e.arrowStartY,g=e.arrowEndX,m=e.arrowEndY),w=e.midX,S=e.midY,a)o=h-e.segpts[0],c=d-e.segpts[1];else if(i||s||l||n){var y=e.allpts,b=Yr(y[0],y[2],y[4],.1),x=Yr(y[1],y[3],y[5],.1);o=h-b,c=d-x}else o=h-w,c=d-S;e.srcArrowAngle=ep(o,c);var w=e.midX,S=e.midY;if(r&&(w=(h+g)/2,S=(d+m)/2),o=g-h,c=m-d,a){var y=e.allpts;if(y.length/2%2===0){var k=y.length/2,E=k-2;o=y[k]-y[E],c=y[k+1]-y[E+1]}else if(e.isRound)o=e.midVector[1],c=-e.midVector[0];else{var k=y.length/2-1,E=k-2;o=y[k]-y[E],c=y[k+1]-y[E+1]}}else if(i||s||l){var y=e.allpts,M=e.ctrlpts,R,O,N,B;if(M.length/2%2===0){var D=y.length/2-1,_=D+2,P=_+2;R=Yr(y[D],y[_],y[P],0),O=Yr(y[D+1],y[_+1],y[P+1],0),N=Yr(y[D],y[_],y[P],1e-4),B=Yr(y[D+1],y[_+1],y[P+1],1e-4)}else{var _=y.length/2-1,D=_-2,P=_+2;R=Yr(y[D],y[_],y[P],.4999),O=Yr(y[D+1],y[_+1],y[P+1],.4999),N=Yr(y[D],y[_],y[P],.5),B=Yr(y[D+1],y[_+1],y[P+1],.5)}o=N-R,c=B-O}if(e.midtgtArrowAngle=ep(o,c),e.midDispX=o,e.midDispY=c,o*=-1,c*=-1,a){var y=e.allpts;if(y.length/2%2!==0){if(!e.isRound){var k=y.length/2-1,z=k+2;o=-(y[z]-y[k]),c=-(y[z+1]-y[k+1])}}}if(e.midsrcArrowAngle=ep(o,c),a)o=g-e.segpts[e.segpts.length-2],c=m-e.segpts[e.segpts.length-1];else if(i||s||l||n){var y=e.allpts,H=y.length,b=Yr(y[H-6],y[H-4],y[H-2],.9),x=Yr(y[H-5],y[H-3],y[H-1],.9);o=g-b,c=m-x}else o=g-w,c=m-S;e.tgtArrowAngle=ep(o,c)};wg.getArrowWidth=wg.getArrowHeight=function(t,e){var r=this.arrowWidthCache=this.arrowWidthCache||{},n=r[t+", "+e];return n||(n=Math.max(Math.pow(t*13.37,.9),29)*e,r[t+", "+e]=n,n)};var dk,pk,ra={},Si={},ON,MN,zl,Up,za,Rl,Bl,Ki,ru,op,_j,Nj,gk,vk,RN,DN=function(e,r,n){n.x=r.x-e.x,n.y=r.y-e.y,n.len=Math.sqrt(n.x*n.x+n.y*n.y),n.nx=n.x/n.len,n.ny=n.y/n.len,n.ang=Math.atan2(n.ny,n.nx)},uK=function(e,r){r.x=e.x*-1,r.y=e.y*-1,r.nx=e.nx*-1,r.ny=e.ny*-1,r.ang=e.ang>0?-(Math.PI-e.ang):Math.PI+e.ang},cK=function(e,r,n,i,a){if(e!==RN?DN(r,e,ra):uK(Si,ra),DN(r,n,Si),ON=ra.nx*Si.ny-ra.ny*Si.nx,MN=ra.nx*Si.nx-ra.ny*-Si.ny,za=Math.asin(Math.max(-1,Math.min(1,ON))),Math.abs(za)<1e-6){dk=r.x,pk=r.y,Bl=ru=0;return}zl=1,Up=!1,MN<0?za<0?za=Math.PI+za:(za=Math.PI-za,zl=-1,Up=!0):za>0&&(zl=-1,Up=!0),r.radius!==void 0?ru=r.radius:ru=i,Rl=za/2,op=Math.min(ra.len/2,Si.len/2),a?(Ki=Math.abs(Math.cos(Rl)*ru/Math.sin(Rl)),Ki>op?(Ki=op,Bl=Math.abs(Ki*Math.sin(Rl)/Math.cos(Rl))):Bl=ru):(Ki=Math.min(op,ru),Bl=Math.abs(Ki*Math.sin(Rl)/Math.cos(Rl))),gk=r.x+Si.nx*Ki,vk=r.y+Si.ny*Ki,dk=gk-Si.ny*Bl*zl,pk=vk+Si.nx*Bl*zl,_j=r.x+ra.nx*Ki,Nj=r.y+ra.ny*Ki,RN=r};function Bj(t,e){e.radius===0?t.lineTo(e.cx,e.cy):t.arc(e.cx,e.cy,e.radius,e.startAngle,e.endAngle,e.counterClockwise)}function ZT(t,e,r,n){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return n===0||e.radius===0?{cx:e.x,cy:e.y,radius:0,startX:e.x,startY:e.y,stopX:e.x,stopY:e.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(cK(t,e,r,n,i),{cx:dk,cy:pk,radius:Bl,startX:_j,startY:Nj,stopX:gk,stopY:vk,startAngle:ra.ang+Math.PI/2*zl,endAngle:Si.ang-Math.PI/2*zl,counterClockwise:Up})}var $f=.01,fK=Math.sqrt(2*$f),wn={};wn.findMidptPtsEtc=function(t,e){var r=e.posPts,n=e.intersectionPts,i=e.vectorNormInverse,a,s=t.pstyle("source-endpoint"),l=t.pstyle("target-endpoint"),o=s.units!=null&&l.units!=null,c=function(M,R,O,N){var B=N-R,D=O-M,_=Math.sqrt(D*D+B*B);return{x:-B/_,y:D/_}},h=t.pstyle("edge-distances").value;switch(h){case"node-position":a=r;break;case"intersection":a=n;break;case"endpoints":{if(o){var d=this.manualEndptToPx(t.source()[0],s),g=Rr(d,2),m=g[0],y=g[1],b=this.manualEndptToPx(t.target()[0],l),x=Rr(b,2),w=x[0],S=x[1],k={x1:m,y1:y,x2:w,y2:S};i=c(m,y,w,S),a=k}else jt("Edge ".concat(t.id()," has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")),a=n;break}}return{midptPts:a,vectorNormInverse:i}};wn.findHaystackPoints=function(t){for(var e=0;e<t.length;e++){var r=t[e],n=r._private,i=n.rscratch;if(!i.haystack){var a=Math.random()*2*Math.PI;i.source={x:Math.cos(a),y:Math.sin(a)},a=Math.random()*2*Math.PI,i.target={x:Math.cos(a),y:Math.sin(a)}}var s=n.source,l=n.target,o=s.position(),c=l.position(),h=s.width(),d=l.width(),g=s.height(),m=l.height(),y=r.pstyle("haystack-radius").value,b=y/2;i.haystackPts=i.allpts=[i.source.x*h*b+o.x,i.source.y*g*b+o.y,i.target.x*d*b+c.x,i.target.y*m*b+c.y],i.midX=(i.allpts[0]+i.allpts[2])/2,i.midY=(i.allpts[1]+i.allpts[3])/2,i.edgeType="haystack",i.haystack=!0,this.storeEdgeProjections(r),this.calculateArrowAngles(r),this.recalculateEdgeLabelProjections(r),this.calculateLabelAngles(r)}};wn.findSegmentsPoints=function(t,e){var r=t._private.rscratch,n=t.pstyle("segment-weights"),i=t.pstyle("segment-distances"),a=t.pstyle("segment-radii"),s=t.pstyle("radius-type"),l=Math.min(n.pfValue.length,i.pfValue.length),o=a.pfValue[a.pfValue.length-1],c=s.pfValue[s.pfValue.length-1];r.edgeType="segments",r.segpts=[],r.radii=[],r.isArcRadius=[];for(var h=0;h<l;h++){var d=n.pfValue[h],g=i.pfValue[h],m=1-d,y=d,b=this.findMidptPtsEtc(t,e),x=b.midptPts,w=b.vectorNormInverse,S={x:x.x1*m+x.x2*y,y:x.y1*m+x.y2*y};r.segpts.push(S.x+w.x*g,S.y+w.y*g),r.radii.push(a.pfValue[h]!==void 0?a.pfValue[h]:o),r.isArcRadius.push((s.pfValue[h]!==void 0?s.pfValue[h]:c)==="arc-radius")}};wn.findLoopPoints=function(t,e,r,n){var i=t._private.rscratch,a=e.dirCounts,s=e.srcPos,l=t.pstyle("control-point-distances"),o=l?l.pfValue[0]:void 0,c=t.pstyle("loop-direction").pfValue,h=t.pstyle("loop-sweep").pfValue,d=t.pstyle("control-point-step-size").pfValue;i.edgeType="self";var g=r,m=d;n&&(g=0,m=o);var y=c-Math.PI/2,b=y-h/2,x=y+h/2,w=c+"_"+h;g=a[w]===void 0?a[w]=0:++a[w],i.ctrlpts=[s.x+Math.cos(b)*1.4*m*(g/3+1),s.y+Math.sin(b)*1.4*m*(g/3+1),s.x+Math.cos(x)*1.4*m*(g/3+1),s.y+Math.sin(x)*1.4*m*(g/3+1)]};wn.findCompoundLoopPoints=function(t,e,r,n){var i=t._private.rscratch;i.edgeType="compound";var a=e.srcPos,s=e.tgtPos,l=e.srcW,o=e.srcH,c=e.tgtW,h=e.tgtH,d=t.pstyle("control-point-step-size").pfValue,g=t.pstyle("control-point-distances"),m=g?g.pfValue[0]:void 0,y=r,b=d;n&&(y=0,b=m);var x=50,w={x:a.x-l/2,y:a.y-o/2},S={x:s.x-c/2,y:s.y-h/2},k={x:Math.min(w.x,S.x),y:Math.min(w.y,S.y)},E=.5,M=Math.max(E,Math.log(l*$f)),R=Math.max(E,Math.log(c*$f));i.ctrlpts=[k.x,k.y-(1+Math.pow(x,1.12)/100)*b*(y/3+1)*M,k.x-(1+Math.pow(x,1.12)/100)*b*(y/3+1)*R,k.y]};wn.findStraightEdgePoints=function(t){t._private.rscratch.edgeType="straight"};wn.findBezierPoints=function(t,e,r,n,i){var a=t._private.rscratch,s=t.pstyle("control-point-step-size").pfValue,l=t.pstyle("control-point-distances"),o=t.pstyle("control-point-weights"),c=l&&o?Math.min(l.value.length,o.value.length):1,h=l?l.pfValue[0]:void 0,d=o.value[0],g=n;a.edgeType=g?"multibezier":"bezier",a.ctrlpts=[];for(var m=0;m<c;m++){var y=(.5-e.eles.length/2+r)*s*(i?-1:1),b=void 0,x=qT(y);g&&(h=l?l.pfValue[m]:s,d=o.value[m]),n?b=h:b=h!==void 0?x*h:void 0;var w=b!==void 0?b:y,S=1-d,k=d,E=this.findMidptPtsEtc(t,e),M=E.midptPts,R=E.vectorNormInverse,O={x:M.x1*S+M.x2*k,y:M.y1*S+M.y2*k};a.ctrlpts.push(O.x+R.x*w,O.y+R.y*w)}};wn.findTaxiPoints=function(t,e){var r=t._private.rscratch;r.edgeType="segments";var n="vertical",i="horizontal",a="leftward",s="rightward",l="downward",o="upward",c="auto",h=e.posPts,d=e.srcW,g=e.srcH,m=e.tgtW,y=e.tgtH,b=t.pstyle("edge-distances").value,x=b!=="node-position",w=t.pstyle("taxi-direction").value,S=w,k=t.pstyle("taxi-turn"),E=k.units==="%",M=k.pfValue,R=M<0,O=t.pstyle("taxi-turn-min-distance").pfValue,N=x?(d+m)/2:0,B=x?(g+y)/2:0,D=h.x2-h.x1,_=h.y2-h.y1,P=function(F,J){return F>0?Math.max(F-J,0):Math.min(F+J,0)},z=P(D,N),H=P(_,B),$=!1;S===c?w=Math.abs(z)>Math.abs(H)?i:n:S===o||S===l?(w=n,$=!0):(S===a||S===s)&&(w=i,$=!0);var q=w===n,V=q?H:z,X=q?_:D,ee=qT(X),te=!1;!($&&(E||R))&&(S===l&&X<0||S===o&&X>0||S===a&&X>0||S===s&&X<0)&&(ee*=-1,V=ee*Math.abs(V),te=!0);var I;if(E){var G=M<0?1+M:M;I=G*V}else{var re=M<0?V:0;I=re+M*ee}var Y=function(F){return Math.abs(F)<O||Math.abs(F)>=Math.abs(V)},W=Y(I),Z=Y(Math.abs(V)-Math.abs(I)),ie=W||Z;if(ie&&!te)if(q){var we=Math.abs(X)<=g/2,de=Math.abs(D)<=m/2;if(we){var se=(h.x1+h.x2)/2,j=h.y1,Q=h.y2;r.segpts=[se,j,se,Q]}else if(de){var K=(h.y1+h.y2)/2,ue=h.x1,Se=h.x2;r.segpts=[ue,K,Se,K]}else r.segpts=[h.x1,h.y2]}else{var at=Math.abs(X)<=d/2,Me=Math.abs(_)<=y/2;if(at){var He=(h.y1+h.y2)/2,$e=h.x1,Ne=h.x2;r.segpts=[$e,He,Ne,He]}else if(Me){var Ge=(h.x1+h.x2)/2,Ve=h.y1,Qe=h.y2;r.segpts=[Ge,Ve,Ge,Qe]}else r.segpts=[h.x2,h.y1]}else if(q){var je=h.y1+I+(x?g/2*ee:0),dt=h.x1,ke=h.x2;r.segpts=[dt,je,ke,je]}else{var De=h.x1+I+(x?d/2*ee:0),Be=h.y1,Ke=h.y2;r.segpts=[De,Be,De,Ke]}if(r.isRound){var Oe=t.pstyle("taxi-radius").value,Re=t.pstyle("radius-type").value[0]==="arc-radius";r.radii=new Array(r.segpts.length/2).fill(Oe),r.isArcRadius=new Array(r.segpts.length/2).fill(Re)}};wn.tryToCorrectInvalidPoints=function(t,e){var r=t._private.rscratch;if(r.edgeType==="bezier"){var n=e.srcPos,i=e.tgtPos,a=e.srcW,s=e.srcH,l=e.tgtW,o=e.tgtH,c=e.srcShape,h=e.tgtShape,d=e.srcCornerRadius,g=e.tgtCornerRadius,m=e.srcRs,y=e.tgtRs,b=!qe(r.startX)||!qe(r.startY),x=!qe(r.arrowStartX)||!qe(r.arrowStartY),w=!qe(r.endX)||!qe(r.endY),S=!qe(r.arrowEndX)||!qe(r.arrowEndY),k=3,E=this.getArrowWidth(t.pstyle("width").pfValue,t.pstyle("arrow-scale").value)*this.arrowShapeWidth,M=k*E,R=Kl({x:r.ctrlpts[0],y:r.ctrlpts[1]},{x:r.startX,y:r.startY}),O=R<M,N=Kl({x:r.ctrlpts[0],y:r.ctrlpts[1]},{x:r.endX,y:r.endY}),B=N<M,D=!1;if(b||x||O){D=!0;var _={x:r.ctrlpts[0]-n.x,y:r.ctrlpts[1]-n.y},P=Math.sqrt(_.x*_.x+_.y*_.y),z={x:_.x/P,y:_.y/P},H=Math.max(a,s),$={x:r.ctrlpts[0]+z.x*2*H,y:r.ctrlpts[1]+z.y*2*H},q=c.intersectLine(n.x,n.y,a,s,$.x,$.y,0,d,m);O?(r.ctrlpts[0]=r.ctrlpts[0]+z.x*(M-R),r.ctrlpts[1]=r.ctrlpts[1]+z.y*(M-R)):(r.ctrlpts[0]=q[0]+z.x*M,r.ctrlpts[1]=q[1]+z.y*M)}if(w||S||B){D=!0;var V={x:r.ctrlpts[0]-i.x,y:r.ctrlpts[1]-i.y},X=Math.sqrt(V.x*V.x+V.y*V.y),ee={x:V.x/X,y:V.y/X},te=Math.max(a,s),I={x:r.ctrlpts[0]+ee.x*2*te,y:r.ctrlpts[1]+ee.y*2*te},G=h.intersectLine(i.x,i.y,l,o,I.x,I.y,0,g,y);B?(r.ctrlpts[0]=r.ctrlpts[0]+ee.x*(M-N),r.ctrlpts[1]=r.ctrlpts[1]+ee.y*(M-N)):(r.ctrlpts[0]=G[0]+ee.x*M,r.ctrlpts[1]=G[1]+ee.y*M)}D&&this.findEndpoints(t)}};wn.storeAllpts=function(t){var e=t._private.rscratch;if(e.edgeType==="multibezier"||e.edgeType==="bezier"||e.edgeType==="self"||e.edgeType==="compound"){e.allpts=[],e.allpts.push(e.startX,e.startY);for(var r=0;r+1<e.ctrlpts.length;r+=2)e.allpts.push(e.ctrlpts[r],e.ctrlpts[r+1]),r+3<e.ctrlpts.length&&e.allpts.push((e.ctrlpts[r]+e.ctrlpts[r+2])/2,(e.ctrlpts[r+1]+e.ctrlpts[r+3])/2);e.allpts.push(e.endX,e.endY);var n,i;e.ctrlpts.length/2%2===0?(n=e.allpts.length/2-1,e.midX=e.allpts[n],e.midY=e.allpts[n+1]):(n=e.allpts.length/2-3,i=.5,e.midX=Yr(e.allpts[n],e.allpts[n+2],e.allpts[n+4],i),e.midY=Yr(e.allpts[n+1],e.allpts[n+3],e.allpts[n+5],i))}else if(e.edgeType==="straight")e.allpts=[e.startX,e.startY,e.endX,e.endY],e.midX=(e.startX+e.endX+e.arrowStartX+e.arrowEndX)/4,e.midY=(e.startY+e.endY+e.arrowStartY+e.arrowEndY)/4;else if(e.edgeType==="segments"){if(e.allpts=[],e.allpts.push(e.startX,e.startY),e.allpts.push.apply(e.allpts,e.segpts),e.allpts.push(e.endX,e.endY),e.isRound){e.roundCorners=[];for(var a=2;a+3<e.allpts.length;a+=2){var s=e.radii[a/2-1],l=e.isArcRadius[a/2-1];e.roundCorners.push(ZT({x:e.allpts[a-2],y:e.allpts[a-1]},{x:e.allpts[a],y:e.allpts[a+1],radius:s},{x:e.allpts[a+2],y:e.allpts[a+3]},s,l))}}if(e.segpts.length%4===0){var o=e.segpts.length/2,c=o-2;e.midX=(e.segpts[c]+e.segpts[o])/2,e.midY=(e.segpts[c+1]+e.segpts[o+1])/2}else{var h=e.segpts.length/2-1;if(!e.isRound)e.midX=e.segpts[h],e.midY=e.segpts[h+1];else{var d={x:e.segpts[h],y:e.segpts[h+1]},g=e.roundCorners[h/2];if(g.radius===0){var m={x:e.segpts[h+2],y:e.segpts[h+3]};e.midX=d.x,e.midY=d.y,e.midVector=[d.y-m.y,m.x-d.x]}else{var y=[d.x-g.cx,d.y-g.cy],b=g.radius/Math.sqrt(Math.pow(y[0],2)+Math.pow(y[1],2));y=y.map(function(x){return x*b}),e.midX=g.cx+y[0],e.midY=g.cy+y[1],e.midVector=y}}}}};wn.checkForInvalidEdgeWarning=function(t){var e=t[0]._private.rscratch;e.nodesOverlap||qe(e.startX)&&qe(e.startY)&&qe(e.endX)&&qe(e.endY)?e.loggedErr=!1:e.loggedErr||(e.loggedErr=!0,jt("Edge `"+t.id()+"` has invalid endpoints and so it is impossible to draw. Adjust your edge style (e.g. control points) accordingly or use an alternative edge type. This is expected behaviour when the source node and the target node overlap."))};wn.findEdgeControlPoints=function(t){var e=this;if(!(!t||t.length===0)){for(var r=this,n=r.cy,i=n.hasCompoundNodes(),a=new Ua,s=function(B,D){return[].concat(fg(B),[D?1:0]).join("-")},l=[],o=[],c=0;c<t.length;c++){var h=t[c],d=h._private,g=h.pstyle("curve-style").value;if(!(h.removed()||!h.takesUpSpace())){if(g==="haystack"){o.push(h);continue}var m=g==="unbundled-bezier"||zs(g,"segments")||g==="straight"||g==="straight-triangle"||zs(g,"taxi"),y=g==="unbundled-bezier"||g==="bezier",b=d.source,x=d.target,w=b.poolIndex(),S=x.poolIndex(),k=[w,S].sort(),E=s(k,m),M=a.get(E);M==null&&(M={eles:[]},l.push({pairId:k,edgeIsUnbundled:m}),a.set(E,M)),M.eles.push(h),m&&(M.hasUnbundled=!0),y&&(M.hasBezier=!0)}}for(var R=function(){var B=l[O],D=B.pairId,_=B.edgeIsUnbundled,P=s(D,_),z=a.get(P),H;if(!z.hasUnbundled){var $=z.eles[0].parallelEdges().filter(function(Re){return Re.isBundledBezier()});zT(z.eles),$.forEach(function(Re){return z.eles.push(Re)}),z.eles.sort(function(Re,ce){return Re.poolIndex()-ce.poolIndex()})}var q=z.eles[0],V=q.source(),X=q.target();if(V.poolIndex()>X.poolIndex()){var ee=V;V=X,X=ee}var te=z.srcPos=V.position(),I=z.tgtPos=X.position(),G=z.srcW=V.outerWidth(),re=z.srcH=V.outerHeight(),Y=z.tgtW=X.outerWidth(),W=z.tgtH=X.outerHeight(),Z=z.srcShape=r.nodeShapes[e.getNodeShape(V)],ie=z.tgtShape=r.nodeShapes[e.getNodeShape(X)],we=z.srcCornerRadius=V.pstyle("corner-radius").value==="auto"?"auto":V.pstyle("corner-radius").pfValue,de=z.tgtCornerRadius=X.pstyle("corner-radius").value==="auto"?"auto":X.pstyle("corner-radius").pfValue,se=z.tgtRs=X._private.rscratch,j=z.srcRs=V._private.rscratch;z.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var Q=0;Q<z.eles.length;Q++){var K=z.eles[Q],ue=K[0]._private.rscratch,Se=K.pstyle("curve-style").value,at=Se==="unbundled-bezier"||zs(Se,"segments")||zs(Se,"taxi"),Me=!V.same(K.source());if(!z.calculatedIntersection&&V!==X&&(z.hasBezier||z.hasUnbundled)){z.calculatedIntersection=!0;var He=Z.intersectLine(te.x,te.y,G,re,I.x,I.y,0,we,j),$e=z.srcIntn=He,Ne=ie.intersectLine(I.x,I.y,Y,W,te.x,te.y,0,de,se),Ge=z.tgtIntn=Ne,Ve=z.intersectionPts={x1:He[0],x2:Ne[0],y1:He[1],y2:Ne[1]},Qe=z.posPts={x1:te.x,x2:I.x,y1:te.y,y2:I.y},je=Ne[1]-He[1],dt=Ne[0]-He[0],ke=Math.sqrt(dt*dt+je*je);qe(ke)&&ke>=fK||(ke=Math.sqrt(Math.max(dt*dt,$f)+Math.max(je*je,$f)));var De=z.vector={x:dt,y:je},Be=z.vectorNorm={x:De.x/ke,y:De.y/ke},Ke={x:-Be.y,y:Be.x};z.nodesOverlap=!qe(ke)||ie.checkPoint(He[0],He[1],0,Y,W,I.x,I.y,de,se)||Z.checkPoint(Ne[0],Ne[1],0,G,re,te.x,te.y,we,j),z.vectorNormInverse=Ke,H={nodesOverlap:z.nodesOverlap,dirCounts:z.dirCounts,calculatedIntersection:!0,hasBezier:z.hasBezier,hasUnbundled:z.hasUnbundled,eles:z.eles,srcPos:I,srcRs:se,tgtPos:te,tgtRs:j,srcW:Y,srcH:W,tgtW:G,tgtH:re,srcIntn:Ge,tgtIntn:$e,srcShape:ie,tgtShape:Z,posPts:{x1:Qe.x2,y1:Qe.y2,x2:Qe.x1,y2:Qe.y1},intersectionPts:{x1:Ve.x2,y1:Ve.y2,x2:Ve.x1,y2:Ve.y1},vector:{x:-De.x,y:-De.y},vectorNorm:{x:-Be.x,y:-Be.y},vectorNormInverse:{x:-Ke.x,y:-Ke.y}}}var Oe=Me?H:z;ue.nodesOverlap=Oe.nodesOverlap,ue.srcIntn=Oe.srcIntn,ue.tgtIntn=Oe.tgtIntn,ue.isRound=Se.startsWith("round"),i&&(V.isParent()||V.isChild()||X.isParent()||X.isChild())&&(V.parents().anySame(X)||X.parents().anySame(V)||V.same(X)&&V.isParent())?e.findCompoundLoopPoints(K,Oe,Q,at):V===X?e.findLoopPoints(K,Oe,Q,at):Se.endsWith("segments")?e.findSegmentsPoints(K,Oe):Se.endsWith("taxi")?e.findTaxiPoints(K,Oe):Se==="straight"||!at&&z.eles.length%2===1&&Q===Math.floor(z.eles.length/2)?e.findStraightEdgePoints(K):e.findBezierPoints(K,Oe,Q,at,Me),e.findEndpoints(K),e.tryToCorrectInvalidPoints(K,Oe),e.checkForInvalidEdgeWarning(K),e.storeAllpts(K),e.storeEdgeProjections(K),e.calculateArrowAngles(K),e.recalculateEdgeLabelProjections(K),e.calculateLabelAngles(K)}},O=0;O<l.length;O++)R();this.findHaystackPoints(o)}};function Lj(t){var e=[];if(t!=null){for(var r=0;r<t.length;r+=2){var n=t[r],i=t[r+1];e.push({x:n,y:i})}return e}}wn.getSegmentPoints=function(t){var e=t[0]._private.rscratch;this.recalculateRenderedStyle(t);var r=e.edgeType;if(r==="segments")return Lj(e.segpts)};wn.getControlPoints=function(t){var e=t[0]._private.rscratch;this.recalculateRenderedStyle(t);var r=e.edgeType;if(r==="bezier"||r==="multibezier"||r==="self"||r==="compound")return Lj(e.ctrlpts)};wn.getEdgeMidpoint=function(t){var e=t[0]._private.rscratch;return this.recalculateRenderedStyle(t),{x:e.midX,y:e.midY}};var xh={};xh.manualEndptToPx=function(t,e){var r=this,n=t.position(),i=t.outerWidth(),a=t.outerHeight(),s=t._private.rscratch;if(e.value.length===2){var l=[e.pfValue[0],e.pfValue[1]];return e.units[0]==="%"&&(l[0]=l[0]*i),e.units[1]==="%"&&(l[1]=l[1]*a),l[0]+=n.x,l[1]+=n.y,l}else{var o=e.pfValue[0];o=-Math.PI/2+o;var c=2*Math.max(i,a),h=[n.x+Math.cos(o)*c,n.y+Math.sin(o)*c];return r.nodeShapes[this.getNodeShape(t)].intersectLine(n.x,n.y,i,a,h[0],h[1],0,t.pstyle("corner-radius").value==="auto"?"auto":t.pstyle("corner-radius").pfValue,s)}};xh.findEndpoints=function(t){var e,r,n,i,a=this,s,l=t.source()[0],o=t.target()[0],c=l.position(),h=o.position(),d=t.pstyle("target-arrow-shape").value,g=t.pstyle("source-arrow-shape").value,m=t.pstyle("target-distance-from-node").pfValue,y=t.pstyle("source-distance-from-node").pfValue,b=l._private.rscratch,x=o._private.rscratch,w=t.pstyle("curve-style").value,S=t._private.rscratch,k=S.edgeType,E=zs(w,"taxi"),M=k==="self"||k==="compound",R=k==="bezier"||k==="multibezier"||M,O=k!=="bezier",N=k==="straight"||k==="segments",B=k==="segments",D=R||O||N,_=M||E,P=t.pstyle("source-endpoint"),z=_?"outside-to-node":P.value,H=l.pstyle("corner-radius").value==="auto"?"auto":l.pstyle("corner-radius").pfValue,$=t.pstyle("target-endpoint"),q=_?"outside-to-node":$.value,V=o.pstyle("corner-radius").value==="auto"?"auto":o.pstyle("corner-radius").pfValue;S.srcManEndpt=P,S.tgtManEndpt=$;var X,ee,te,I,G=(e=($==null||(r=$.pfValue)===null||r===void 0?void 0:r.length)===2?$.pfValue:null)!==null&&e!==void 0?e:[0,0],re=(n=(P==null||(i=P.pfValue)===null||i===void 0?void 0:i.length)===2?P.pfValue:null)!==null&&n!==void 0?n:[0,0];if(R){var Y=[S.ctrlpts[0],S.ctrlpts[1]],W=O?[S.ctrlpts[S.ctrlpts.length-2],S.ctrlpts[S.ctrlpts.length-1]]:Y;X=W,ee=Y}else if(N){var Z=B?S.segpts.slice(0,2):[h.x+G[0],h.y+G[1]],ie=B?S.segpts.slice(S.segpts.length-2):[c.x+re[0],c.y+re[1]];X=ie,ee=Z}if(q==="inside-to-node")s=[h.x,h.y];else if($.units)s=this.manualEndptToPx(o,$);else if(q==="outside-to-line")s=S.tgtIntn;else if(q==="outside-to-node"||q==="outside-to-node-or-label"?te=X:(q==="outside-to-line"||q==="outside-to-line-or-label")&&(te=[c.x,c.y]),s=a.nodeShapes[this.getNodeShape(o)].intersectLine(h.x,h.y,o.outerWidth(),o.outerHeight(),te[0],te[1],0,V,x),q==="outside-to-node-or-label"||q==="outside-to-line-or-label"){var we=o._private.rscratch,de=we.labelWidth,se=we.labelHeight,j=we.labelX,Q=we.labelY,K=de/2,ue=se/2,Se=o.pstyle("text-valign").value;Se==="top"?Q-=ue:Se==="bottom"&&(Q+=ue);var at=o.pstyle("text-halign").value;at==="left"?j-=K:at==="right"&&(j+=K);var Me=jf(te[0],te[1],[j-K,Q-ue,j+K,Q-ue,j+K,Q+ue,j-K,Q+ue],h.x,h.y);if(Me.length>0){var He=c,$e=Nl(He,pu(s)),Ne=Nl(He,pu(Me)),Ge=$e;if(Ne<$e&&(s=Me,Ge=Ne),Me.length>2){var Ve=Nl(He,{x:Me[2],y:Me[3]});Ve<Ge&&(s=[Me[2],Me[3]])}}}var Qe=tp(s,X,a.arrowShapes[d].spacing(t)+m),je=tp(s,X,a.arrowShapes[d].gap(t)+m);if(S.endX=je[0],S.endY=je[1],S.arrowEndX=Qe[0],S.arrowEndY=Qe[1],z==="inside-to-node")s=[c.x,c.y];else if(P.units)s=this.manualEndptToPx(l,P);else if(z==="outside-to-line")s=S.srcIntn;else if(z==="outside-to-node"||z==="outside-to-node-or-label"?I=ee:(z==="outside-to-line"||z==="outside-to-line-or-label")&&(I=[h.x,h.y]),s=a.nodeShapes[this.getNodeShape(l)].intersectLine(c.x,c.y,l.outerWidth(),l.outerHeight(),I[0],I[1],0,H,b),z==="outside-to-node-or-label"||z==="outside-to-line-or-label"){var dt=l._private.rscratch,ke=dt.labelWidth,De=dt.labelHeight,Be=dt.labelX,Ke=dt.labelY,Oe=ke/2,Re=De/2,ce=l.pstyle("text-valign").value;ce==="top"?Ke-=Re:ce==="bottom"&&(Ke+=Re);var F=l.pstyle("text-halign").value;F==="left"?Be-=Oe:F==="right"&&(Be+=Oe);var J=jf(I[0],I[1],[Be-Oe,Ke-Re,Be+Oe,Ke-Re,Be+Oe,Ke+Re,Be-Oe,Ke+Re],c.x,c.y);if(J.length>0){var oe=h,le=Nl(oe,pu(s)),he=Nl(oe,pu(J)),_e=le;if(he<le&&(s=[J[0],J[1]],_e=he),J.length>2){var be=Nl(oe,{x:J[2],y:J[3]});be<_e&&(s=[J[2],J[3]])}}}var ze=tp(s,ee,a.arrowShapes[g].spacing(t)+y),Le=tp(s,ee,a.arrowShapes[g].gap(t)+y);S.startX=Le[0],S.startY=Le[1],S.arrowStartX=ze[0],S.arrowStartY=ze[1],D&&(!qe(S.startX)||!qe(S.startY)||!qe(S.endX)||!qe(S.endY)?S.badLine=!0:S.badLine=!1)};xh.getSourceEndpoint=function(t){var e=t[0]._private.rscratch;return this.recalculateRenderedStyle(t),e.edgeType==="haystack"?{x:e.haystackPts[0],y:e.haystackPts[1]}:{x:e.arrowStartX,y:e.arrowStartY}};xh.getTargetEndpoint=function(t){var e=t[0]._private.rscratch;return this.recalculateRenderedStyle(t),e.edgeType==="haystack"?{x:e.haystackPts[2],y:e.haystackPts[3]}:{x:e.arrowEndX,y:e.arrowEndY}};var JT={};function hK(t,e,r){for(var n=function(c,h,d,g){return Yr(c,h,d,g)},i=e._private,a=i.rstyle.bezierPts,s=0;s<t.bezierProjPcts.length;s++){var l=t.bezierProjPcts[s];a.push({x:n(r[0],r[2],r[4],l),y:n(r[1],r[3],r[5],l)})}}JT.storeEdgeProjections=function(t){var e=t._private,r=e.rscratch,n=r.edgeType;if(e.rstyle.bezierPts=null,e.rstyle.linePts=null,e.rstyle.haystackPts=null,n==="multibezier"||n==="bezier"||n==="self"||n==="compound"){e.rstyle.bezierPts=[];for(var i=0;i+5<r.allpts.length;i+=4)hK(this,t,r.allpts.slice(i,i+6))}else if(n==="segments")for(var a=e.rstyle.linePts=[],i=0;i+1<r.allpts.length;i+=2)a.push({x:r.allpts[i],y:r.allpts[i+1]});else if(n==="haystack"){var s=r.haystackPts;e.rstyle.haystackPts=[{x:s[0],y:s[1]},{x:s[2],y:s[3]}]}e.rstyle.arrowWidth=this.getArrowWidth(t.pstyle("width").pfValue,t.pstyle("arrow-scale").value)*this.arrowShapeWidth};JT.recalculateEdgeProjections=function(t){this.findEdgeControlPoints(t)};var pa={};pa.recalculateNodeLabelProjection=function(t){var e=t.pstyle("label").strValue;if(!Ys(e)){var r,n,i=t._private,a=t.width(),s=t.height(),l=t.padding(),o=t.position(),c=t.pstyle("text-halign").strValue,h=t.pstyle("text-valign").strValue,d=i.rscratch,g=i.rstyle;switch(c){case"left":r=o.x-a/2-l;break;case"right":r=o.x+a/2+l;break;default:r=o.x}switch(h){case"top":n=o.y-s/2-l;break;case"bottom":n=o.y+s/2+l;break;default:n=o.y}d.labelX=r,d.labelY=n,g.labelX=r,g.labelY=n,this.calculateLabelAngles(t),this.applyLabelDimensions(t)}};var Pj=function(e,r){var n=Math.atan(r/e);return e===0&&n<0&&(n=n*-1),n},zj=function(e,r){var n=r.x-e.x,i=r.y-e.y;return Pj(n,i)},dK=function(e,r,n,i){var a=qf(0,i-.001,1),s=qf(0,i+.001,1),l=wu(e,r,n,a),o=wu(e,r,n,s);return zj(l,o)};pa.recalculateEdgeLabelProjections=function(t){var e,r=t._private,n=r.rscratch,i=this,a={mid:t.pstyle("label").strValue,source:t.pstyle("source-label").strValue,target:t.pstyle("target-label").strValue};if(a.mid||a.source||a.target){e={x:n.midX,y:n.midY};var s=function(d,g,m){qa(r.rscratch,d,g,m),qa(r.rstyle,d,g,m)};s("labelX",null,e.x),s("labelY",null,e.y);var l=Pj(n.midDispX,n.midDispY);s("labelAutoAngle",null,l);var o=function(){if(o.cache)return o.cache;for(var d=[],g=0;g+5<n.allpts.length;g+=4){var m={x:n.allpts[g],y:n.allpts[g+1]},y={x:n.allpts[g+2],y:n.allpts[g+3]},b={x:n.allpts[g+4],y:n.allpts[g+5]};d.push({p0:m,p1:y,p2:b,startDist:0,length:0,segments:[]})}var x=r.rstyle.bezierPts,w=i.bezierProjPcts.length;function S(O,N,B,D,_){var P=Kl(N,B),z=O.segments[O.segments.length-1],H={p0:N,p1:B,t0:D,t1:_,startDist:z?z.startDist+z.length:0,length:P};O.segments.push(H),O.length+=P}for(var k=0;k<d.length;k++){var E=d[k],M=d[k-1];M&&(E.startDist=M.startDist+M.length),S(E,E.p0,x[k*w],0,i.bezierProjPcts[0]);for(var R=0;R<w-1;R++)S(E,x[k*w+R],x[k*w+R+1],i.bezierProjPcts[R],i.bezierProjPcts[R+1]);S(E,x[k*w+w-1],E.p2,i.bezierProjPcts[w-1],1)}return o.cache=d},c=function(d){var g,m=d==="source";if(a[d]){var y=t.pstyle(d+"-text-offset").pfValue;switch(n.edgeType){case"self":case"compound":case"bezier":case"multibezier":{for(var b=o(),x,w=0,S=0,k=0;k<b.length;k++){for(var E=b[m?k:b.length-1-k],M=0;M<E.segments.length;M++){var R=E.segments[m?M:E.segments.length-1-M],O=k===b.length-1&&M===E.segments.length-1;if(w=S,S+=R.length,S>=y||O){x={cp:E,segment:R};break}}if(x)break}var N=x.cp,B=x.segment,D=(y-w)/B.length,_=B.t1-B.t0,P=m?B.t0+_*D:B.t1-_*D;P=qf(0,P,1),e=wu(N.p0,N.p1,N.p2,P),g=dK(N.p0,N.p1,N.p2,P);break}case"straight":case"segments":case"haystack":{for(var z=0,H,$,q,V,X=n.allpts.length,ee=0;ee+3<X&&(m?(q={x:n.allpts[ee],y:n.allpts[ee+1]},V={x:n.allpts[ee+2],y:n.allpts[ee+3]}):(q={x:n.allpts[X-2-ee],y:n.allpts[X-1-ee]},V={x:n.allpts[X-4-ee],y:n.allpts[X-3-ee]}),H=Kl(q,V),$=z,z+=H,!(z>=y));ee+=2);var te=y-$,I=te/H;I=qf(0,I,1),e=LY(q,V,I),g=zj(q,V);break}}s("labelX",d,e.x),s("labelY",d,e.y),s("labelAutoAngle",d,g)}};c("source"),c("target"),this.applyLabelDimensions(t)}};pa.applyLabelDimensions=function(t){this.applyPrefixedLabelDimensions(t),t.isEdge()&&(this.applyPrefixedLabelDimensions(t,"source"),this.applyPrefixedLabelDimensions(t,"target"))};pa.applyPrefixedLabelDimensions=function(t,e){var r=t._private,n=this.getLabelText(t,e),i=Ql(n,t._private.labelDimsKey);if(Fn(r.rscratch,"prefixedLabelDimsKey",e)!==i){qa(r.rscratch,"prefixedLabelDimsKey",e,i);var a=this.calculateLabelDimensions(t,n),s=t.pstyle("line-height").pfValue,l=t.pstyle("text-wrap").strValue,o=Fn(r.rscratch,"labelWrapCachedLines",e)||[],c=l!=="wrap"?1:Math.max(o.length,1),h=a.height/c,d=h*s,g=a.width,m=a.height+(c-1)*(s-1)*h;qa(r.rstyle,"labelWidth",e,g),qa(r.rscratch,"labelWidth",e,g),qa(r.rstyle,"labelHeight",e,m),qa(r.rscratch,"labelHeight",e,m),qa(r.rscratch,"labelLineHeight",e,d)}};pa.getLabelText=function(t,e){var r=t._private,n=e?e+"-":"",i=t.pstyle(n+"label").strValue,a=t.pstyle("text-transform").value,s=function(re,Y){return Y?(qa(r.rscratch,re,e,Y),Y):Fn(r.rscratch,re,e)};if(!i)return"";a=="none"||(a=="uppercase"?i=i.toUpperCase():a=="lowercase"&&(i=i.toLowerCase()));var l=t.pstyle("text-wrap").value;if(l==="wrap"){var o=s("labelKey");if(o!=null&&s("labelWrapKey")===o)return s("labelWrapCachedText");for(var c="",h=i.split(`
|
|
@@ -426,7 +426,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
426
426
|
`:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Tue(this):new Sue(this)}getCursor(e,r=0,n){let i=e.doc?e:Dt.create({doc:e});return n==null&&(n=i.doc.length),this.regexp?cu(this,i,r,n):uu(this,i,r,n)}}class GF{constructor(e){this.spec=e}}function xue(t,e,r){return(n,i,a,s)=>{if(r&&!r(n,i,a,s))return!1;let l=n>=s&&i<=s+a.length?a.slice(n-s,i-s):e.doc.sliceString(n,i);return t(l,e,n,i)}}function uu(t,e,r,n){let i;return t.wholeWord&&(i=wue(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(i=xue(t.test,e,i)),new Vu(e.doc,t.unquoted,r,n,t.caseSensitive?void 0:a=>a.toLowerCase(),i)}function wue(t,e){return(r,n,i,a)=>((a>r||a+i.length<n)&&(a=Math.max(0,r-2),i=t.sliceString(a,Math.min(t.length,n+2))),(e(Yg(i,r-a))!=cr.Word||e(Xg(i,r-a))!=cr.Word)&&(e(Xg(i,n-a))!=cr.Word||e(Yg(i,n-a))!=cr.Word))}class Sue extends GF{constructor(e){super(e)}nextMatch(e,r,n){let i=uu(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let a=Math.min(e.doc.length,r+this.spec.unquoted.length);i=uu(this.spec,e,0,a).nextOverlapping()}return i.done||i.value.from==r&&i.value.to==n?null:i.value}prevMatchInRange(e,r,n){for(let i=n;;){let a=Math.max(r,i-1e4-this.spec.unquoted.length),s=uu(this.spec,e,a,i),l=null;for(;!s.nextOverlapping().done;)l=s.value;if(l)return l;if(a==r)return null;i-=1e4}}prevMatch(e,r,n){let i=this.prevMatchInRange(e,0,r);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=r||i.to!=n)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,r){let n=uu(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let a=uu(this.spec,e,Math.max(0,r-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!a.next().done;)i(a.value.from,a.value.to)}}function Cue(t,e,r){return(n,i,a)=>(!r||r(n,i,a))&&t(a[0],e,n,i)}function cu(t,e,r,n){let i;return t.wholeWord&&(i=kue(e.charCategorizer(e.selection.main.head))),t.test&&(i=Cue(t.test,e,i)),new VF(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:i},r,n)}function Yg(t,e){return t.slice(Wr(t,e,!1),e)}function Xg(t,e){return t.slice(e,Wr(t,e))}function kue(t){return(e,r,n)=>!n[0].length||(t(Yg(n.input,n.index))!=cr.Word||t(Xg(n.input,n.index))!=cr.Word)&&(t(Xg(n.input,n.index+n[0].length))!=cr.Word||t(Yg(n.input,n.index+n[0].length))!=cr.Word)}class Tue extends GF{nextMatch(e,r,n){let i=cu(this.spec,e,n,e.doc.length).next();return i.done&&(i=cu(this.spec,e,0,r).next()),i.done?null:i.value}prevMatchInRange(e,r,n){for(let i=1;;i++){let a=Math.max(r,n-i*1e4),s=cu(this.spec,e,a,n),l=null;for(;!s.next().done;)l=s.value;if(l&&(a==r||l.from>a+10))return l;if(a==r)return null}}prevMatch(e,r,n){return this.prevMatchInRange(e,0,r)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(r,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let i=n.length;i>0;i--){let a=+n.slice(0,i);if(a>0&&a<e.match.length)return e.match[a]+n.slice(i)}return r})}matchAll(e,r){let n=cu(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=r)return null;i.push(n.value)}return i}highlight(e,r,n,i){let a=cu(this.spec,e,Math.max(0,r-250),Math.min(n+250,e.doc.length));for(;!a.next().done;)i(a.value.from,a.value.to)}}const ah=yt.define(),eA=yt.define(),$s=Sn.define({create(t){return new FC(vT(t).create(),null)},update(t,e){for(let r of e.effects)r.is(ah)?t=new FC(r.value.create(),t.panel):r.is(eA)&&(t=new FC(t.query,r.value?tA:null));return t},provide:t=>th.from(t,e=>e.panel)});class FC{constructor(e,r){this.query=e,this.panel=r}}const Eue=ut.mark({class:"cm-searchMatch"}),Aue=ut.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Oue=mr.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field($s))}update(t){let e=t.state.field($s);(e!=t.startState.field($s)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return ut.none;let{view:r}=this,n=new Wa;for(let i=0,a=r.visibleRanges,s=a.length;i<s;i++){let{from:l,to:o}=a[i];for(;i<s-1&&o>a[i+1].from-500;)o=a[++i].to;t.highlight(r.state,l,o,(c,h)=>{let d=r.state.selection.ranges.some(g=>g.from==c&&g.to==h);n.add(c,h,d?Aue:Eue)})}return n.finish()}},{decorations:t=>t.decorations});function Ph(t){return e=>{let r=e.state.field($s,!1);return r&&r.query.spec.valid?t(e,r):WF(e)}}const Wg=Ph((t,{query:e})=>{let{to:r}=t.state.selection.main,n=e.nextMatch(t.state,r,r);if(!n)return!1;let i=Ae.single(n.from,n.to),a=t.state.facet(ic);return t.dispatch({selection:i,effects:[rA(t,n),a.scrollToMatch(i.main,t)],userEvent:"select.search"}),XF(t),!0}),Qg=Ph((t,{query:e})=>{let{state:r}=t,{from:n}=r.selection.main,i=e.prevMatch(r,n,n);if(!i)return!1;let a=Ae.single(i.from,i.to),s=t.state.facet(ic);return t.dispatch({selection:a,effects:[rA(t,i),s.scrollToMatch(a.main,t)],userEvent:"select.search"}),XF(t),!0}),Mue=Ph((t,{query:e})=>{let r=e.matchAll(t.state,1e3);return!r||!r.length?!1:(t.dispatch({selection:Ae.create(r.map(n=>Ae.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),Rue=({state:t,dispatch:e})=>{let r=t.selection;if(r.ranges.length>1||r.main.empty)return!1;let{from:n,to:i}=r.main,a=[],s=0;for(let l=new Vu(t.doc,t.sliceDoc(n,i));!l.next().done;){if(a.length>1e3)return!1;l.value.from==n&&(s=a.length),a.push(Ae.range(l.value.from,l.value.to))}return e(t.update({selection:Ae.create(a,s),userEvent:"select.search.matches"})),!0},Qz=Ph((t,{query:e})=>{let{state:r}=t,{from:n,to:i}=r.selection.main;if(r.readOnly)return!1;let a=e.nextMatch(r,n,n);if(!a)return!1;let s=a,l=[],o,c,h=[];s.from==n&&s.to==i&&(c=r.toText(e.getReplacement(s)),l.push({from:s.from,to:s.to,insert:c}),s=e.nextMatch(r,s.from,s.to),h.push(Ue.announce.of(r.phrase("replaced match on line $",r.doc.lineAt(n).number)+".")));let d=t.state.changes(l);return s&&(o=Ae.single(s.from,s.to).map(d),h.push(rA(t,s)),h.push(r.facet(ic).scrollToMatch(o.main,t))),t.dispatch({changes:d,selection:o,effects:h,userEvent:"input.replace"}),!0}),Due=Ph((t,{query:e})=>{if(t.state.readOnly)return!1;let r=e.matchAll(t.state,1e9).map(i=>{let{from:a,to:s}=i;return{from:a,to:s,insert:e.getReplacement(i)}});if(!r.length)return!1;let n=t.state.phrase("replaced $ matches",r.length)+".";return t.dispatch({changes:r,effects:Ue.announce.of(n),userEvent:"input.replace.all"}),!0});function tA(t){return t.state.facet(ic).createPanel(t)}function vT(t,e){var r,n,i,a,s;let l=t.selection.main,o=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!o)return e;let c=t.facet(ic);return new $F({search:((r=e?.literal)!==null&&r!==void 0?r:c.literal)?o:o.replace(/\n/g,"\\n"),caseSensitive:(n=e?.caseSensitive)!==null&&n!==void 0?n:c.caseSensitive,literal:(i=e?.literal)!==null&&i!==void 0?i:c.literal,regexp:(a=e?.regexp)!==null&&a!==void 0?a:c.regexp,wholeWord:(s=e?.wholeWord)!==null&&s!==void 0?s:c.wholeWord})}function YF(t){let e=HE(t,tA);return e&&e.dom.querySelector("[main-field]")}function XF(t){let e=YF(t);e&&e==t.root.activeElement&&e.select()}const WF=t=>{let e=t.state.field($s,!1);if(e&&e.panel){let r=YF(t);if(r&&r!=t.root.activeElement){let n=vT(t.state,e.query.spec);n.valid&&t.dispatch({effects:ah.of(n)}),r.focus(),r.select()}}else t.dispatch({effects:[eA.of(!0),e?ah.of(vT(t.state,e.query.spec)):yt.appendConfig.of(Lue)]});return!0},QF=t=>{let e=t.state.field($s,!1);if(!e||!e.panel)return!1;let r=HE(t,tA);return r&&r.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:eA.of(!1)}),!0},_ue=[{key:"Mod-f",run:WF,scope:"editor search-panel"},{key:"F3",run:Wg,shift:Qg,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Wg,shift:Qg,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:QF,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Rue},{key:"Mod-Alt-g",run:oue},{key:"Mod-d",run:bue,preventDefault:!0}];class Nue{constructor(e){this.view=e;let r=this.query=e.state.field($s).query.spec;this.commit=this.commit.bind(this),this.searchField=Wt("input",{value:r.search,placeholder:li(e,"Find"),"aria-label":li(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Wt("input",{value:r.replace,placeholder:li(e,"Replace"),"aria-label":li(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Wt("input",{type:"checkbox",name:"case",form:"",checked:r.caseSensitive,onchange:this.commit}),this.reField=Wt("input",{type:"checkbox",name:"re",form:"",checked:r.regexp,onchange:this.commit}),this.wordField=Wt("input",{type:"checkbox",name:"word",form:"",checked:r.wholeWord,onchange:this.commit});function n(i,a,s){return Wt("button",{class:"cm-button",name:i,onclick:a,type:"button"},s)}this.dom=Wt("div",{onkeydown:i=>this.keydown(i),class:"cm-search"},[this.searchField,n("next",()=>Wg(e),[li(e,"next")]),n("prev",()=>Qg(e),[li(e,"previous")]),n("select",()=>Mue(e),[li(e,"all")]),Wt("label",null,[this.caseField,li(e,"match case")]),Wt("label",null,[this.reField,li(e,"regexp")]),Wt("label",null,[this.wordField,li(e,"by word")]),...e.state.readOnly?[]:[Wt("br"),this.replaceField,n("replace",()=>Qz(e),[li(e,"replace")]),n("replaceAll",()=>Due(e),[li(e,"replace all")])],Wt("button",{name:"close",onclick:()=>QF(e),"aria-label":li(e,"close"),type:"button"},["×"])])}commit(){let e=new $F({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ah.of(e)}))}keydown(e){zae(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Qg:Wg)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Qz(this.view))}update(e){for(let r of e.transactions)for(let n of r.effects)n.is(ah)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ic).top}}function li(t,e){return t.state.phrase(e)}const Dp=30,_p=/[\s\.,:;?!]/;function rA(t,{from:e,to:r}){let n=t.state.doc.lineAt(e),i=t.state.doc.lineAt(r).to,a=Math.max(n.from,e-Dp),s=Math.min(i,r+Dp),l=t.state.sliceDoc(a,s);if(a!=n.from){for(let o=0;o<Dp;o++)if(!_p.test(l[o+1])&&_p.test(l[o])){l=l.slice(o);break}}if(s!=i){for(let o=l.length-1;o>l.length-Dp;o--)if(!_p.test(l[o-1])&&_p.test(l[o])){l=l.slice(0,o);break}}return Ue.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${n.number}.`)}const Bue=Ue.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Lue=[$s,po.low(Oue),Bue];class KF{constructor(e,r,n,i){this.state=e,this.pos=r,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let r=bn(this.state).resolveInner(this.pos,-1);for(;r&&e.indexOf(r.name)<0;)r=r.parent;return r?{from:r.from,to:this.pos,text:this.state.sliceDoc(r.from,this.pos),type:r.type}:null}matchBefore(e){let r=this.state.doc.lineAt(this.pos),n=Math.max(r.from,this.pos-250),i=r.text.slice(n-r.from,this.pos-r.from),a=i.search(ZF(e,!1));return a<0?null:{from:n+a,to:this.pos,text:i.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(e,r,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(r),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Kz(t){let e=Object.keys(t).join(""),r=/\w/.test(e);return r&&(e=e.replace(/\w/g,"")),`[${r?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Pue(t){let e=Object.create(null),r=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let a=1;a<i.length;a++)r[i[a]]=!0}let n=Kz(e)+Kz(r)+"*$";return[new RegExp("^"+n),new RegExp(n)]}function zue(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[r,n]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Pue(e);return i=>{let a=i.matchBefore(n);return a||i.explicit?{from:a?a.from:i.pos,options:e,validFor:r}:null}}class Zz{constructor(e,r,n,i){this.completion=e,this.source=r,this.match=n,this.score=i}}function Wl(t){return t.selection.main.from}function ZF(t,e){var r;let{source:n}=t,i=e&&n[0]!="^",a=n[n.length-1]!="$";return!i&&!a?t:new RegExp(`${i?"^":""}(?:${n})${a?"$":""}`,(r=t.flags)!==null&&r!==void 0?r:t.ignoreCase?"i":"")}const JF=ma.define();function Iue(t,e,r,n){let{main:i}=t.selection,a=r-i.from,s=n-i.from;return{...t.changeByRange(l=>{if(l!=i&&r!=n&&t.sliceDoc(l.from+a,l.from+s)!=t.sliceDoc(r,n))return{range:l};let o=t.toText(e);return{changes:{from:l.from+a,to:n==i.from?l.to:l.from+s,insert:o},range:Ae.cursor(l.from+a+o.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const Jz=new WeakMap;function que(t){if(!Array.isArray(t))return t;let e=Jz.get(t);return e||Jz.set(t,e=zue(t)),e}const Kg=yt.define(),sh=yt.define();class jue{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let r=0;r<e.length;){let n=Vn(e,r),i=aa(n);this.chars.push(n);let a=e.slice(r,r+i),s=a.toUpperCase();this.folded.push(Vn(s==a?a.toLowerCase():s,0)),r+=i}this.astral=e.length!=this.chars.length}ret(e,r){return this.score=e,this.matched=r,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:r,folded:n,any:i,precise:a,byWord:s}=this;if(r.length==1){let S=Vn(e,0),k=aa(S),E=k==e.length?0:-100;if(S!=r[0])if(S==n[0])E+=-200;else return null;return this.ret(E,[0,k])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let o=r.length,c=0;if(l<0){for(let S=0,k=Math.min(e.length,200);S<k&&c<o;){let E=Vn(e,S);(E==r[c]||E==n[c])&&(i[c++]=S),S+=aa(E)}if(c<o)return null}let h=0,d=0,g=!1,m=0,y=-1,b=-1,x=/[a-z]/.test(e),w=!0;for(let S=0,k=Math.min(e.length,200),E=0;S<k&&d<o;){let M=Vn(e,S);l<0&&(h<o&&M==r[h]&&(a[h++]=S),m<o&&(M==r[m]||M==n[m]?(m==0&&(y=S),b=S+1,m++):m=0));let R,O=M<255?M>=48&&M<=57||M>=97&&M<=122?2:M>=65&&M<=90?1:0:(R=kE(M))!=R.toLowerCase()?1:R!=R.toUpperCase()?2:0;(!S||O==1&&x||E==0&&O!=0)&&(r[d]==M||n[d]==M&&(g=!0)?s[d++]=S:s.length&&(w=!1)),E=O,S+=aa(M)}return d==o&&s[0]==0&&w?this.result(-100+(g?-200:0),s,e):m==o&&y==0?this.ret(-200-e.length+(b==e.length?0:-100),[0,b]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):m==o?this.ret(-900-e.length,[y,b]):d==o?this.result(-100+(g?-200:0)+-700+(w?0:-1100),s,e):r.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,r,n){let i=[],a=0;for(let s of r){let l=s+(this.astral?aa(Vn(n,s)):1);a&&i[a-1]==s?i[a-1]=l:(i[a++]=s,i[a++]=l)}return this.ret(e-n.length,i)}}class Fue{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let r=e.slice(0,this.pattern.length),n=r==this.pattern?0:r.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,r.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const Xr=We.define({combine(t){return ya(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Hue,filterStrict:!1,compareCompletions:(e,r)=>(e.sortText||e.label).localeCompare(r.sortText||r.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,r)=>e&&r,closeOnBlur:(e,r)=>e&&r,icons:(e,r)=>e&&r,tooltipClass:(e,r)=>n=>eI(e(n),r(n)),optionClass:(e,r)=>n=>eI(e(n),r(n)),addToOptions:(e,r)=>e.concat(r),filterStrict:(e,r)=>e||r})}});function eI(t,e){return t?e?t+" "+e:t:e}function Hue(t,e,r,n,i,a){let s=t.textDirection==Jt.RTL,l=s,o=!1,c="top",h,d,g=e.left-i.left,m=i.right-e.right,y=n.right-n.left,b=n.bottom-n.top;if(l&&g<Math.min(y,m)?l=!1:!l&&m<Math.min(y,g)&&(l=!0),y<=(l?g:m))h=Math.max(i.top,Math.min(r.top,i.bottom-b))-e.top,d=Math.min(400,l?g:m);else{o=!0,d=Math.min(400,(s?e.right:i.right-e.left)-30);let S=i.bottom-e.bottom;S>=b||S>e.top?h=r.bottom-e.top:(c="bottom",h=e.bottom-r.top)}let x=(e.bottom-e.top)/a.offsetHeight,w=(e.right-e.left)/a.offsetWidth;return{style:`${c}: ${h/x}px; max-width: ${d/w}px`,class:"cm-completionInfo-"+(o?s?"left-narrow":"right-narrow":l?"left":"right")}}const nA=yt.define();function Vue(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(r){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),r.type&&n.classList.add(...r.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(r,n,i,a){let s=document.createElement("span");s.className="cm-completionLabel";let l=r.displayLabel||r.label,o=0;for(let c=0;c<a.length;){let h=a[c++],d=a[c++];h>o&&s.appendChild(document.createTextNode(l.slice(o,h)));let g=s.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(l.slice(h,d))),g.className="cm-completionMatchedText",o=d}return o<l.length&&s.appendChild(document.createTextNode(l.slice(o))),s},position:50},{render(r){if(!r.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=r.detail,n},position:80}),e.sort((r,n)=>r.position-n.position).map(r=>r.render)}function HC(t,e,r){if(t<=r)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let i=Math.floor(e/r);return{from:i*r,to:(i+1)*r}}let n=Math.floor((t-e)/r);return{from:t-(n+1)*r,to:t-n*r}}class Uue{constructor(e,r,n){this.view=e,this.stateField=r,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:o=>this.placeInfo(o),key:this},this.space=null,this.currentClass="";let i=e.state.field(r),{options:a,selected:s}=i.open,l=e.state.facet(Xr);this.optionContent=Vue(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=HC(a.length,s,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",o=>{let{options:c}=e.state.field(r).open;for(let h=o.target,d;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(d=/-(\d+)$/.exec(h.id))&&+d[1]<c.length){this.applyCompletion(e,c[+d[1]]),o.preventDefault();return}if(o.target==this.list){let h=this.list.classList.contains("cm-completionListIncompleteTop")&&o.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&o.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;h!=null&&(e.dispatch({effects:nA.of(h)}),o.preventDefault())}}),this.dom.addEventListener("focusout",o=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Xr).closeOnBlur&&o.relatedTarget!=e.contentDOM&&e.dispatch({effects:sh.of(null)})}),this.showOptions(a,i.id)}mount(){this.updateSel()}showOptions(e,r){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,r,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var r;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:a,selected:s,disabled:l}=n.open;(!i.open||i.open.options!=a)&&(this.range=HC(a.length,s,e.state.facet(Xr).maxRenderedOptions),this.showOptions(a,n.id)),this.updateSel(),l!=((r=i.open)===null||r===void 0?void 0:r.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l)}}updateTooltipClass(e){let r=this.tooltipClass(e);if(r!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of r.split(" "))n&&this.dom.classList.add(n);this.currentClass=r}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),r=e.open;(r.selected>-1&&r.selected<this.range.from||r.selected>=this.range.to)&&(this.range=HC(r.options.length,r.selected,this.view.state.facet(Xr).maxRenderedOptions),this.showOptions(r.options,e.id));let n=this.updateSelectedOption(r.selected);if(n){this.destroyInfo();let{completion:i}=r.options[r.selected],{info:a}=i;if(!a)return;let s=typeof a=="string"?document.createTextNode(a):a(i);if(!s)return;"then"in s?s.then(l=>{l&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(l,i)}).catch(l=>Xn(this.view.state,l,"completion info")):(this.addInfoPane(s,i),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,r){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:i,destroy:a}=e;n.appendChild(i),this.infoDestroy=a||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let r=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)n.nodeName!="LI"||!n.id?i--:i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),r=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return r&&Gue(this.list,r),r}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let r=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),a=this.space;if(!a){let s=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight}}return i.top>Math.min(a.bottom,r.bottom)-10||i.bottom<Math.max(a.top,r.top)+10?null:this.view.state.facet(Xr).positionInfo(this.view,r,i,n,a,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,r,n){const i=document.createElement("ul");i.id=r,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",s=>{s.target==i&&s.preventDefault()});let a=null;for(let s=n.from;s<n.to;s++){let{completion:l,match:o}=e[s],{section:c}=l;if(c){let g=typeof c=="string"?c:c.name;if(g!=a&&(s>n.from||n.from==0))if(a=g,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let m=i.appendChild(document.createElement("completion-section"));m.textContent=g}}const h=i.appendChild(document.createElement("li"));h.id=r+"-"+s,h.setAttribute("role","option");let d=this.optionClass(l);d&&(h.className=d);for(let g of this.optionContent){let m=g(l,this.view.state,this.view,o);m&&h.appendChild(m)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function $ue(t,e){return r=>new Uue(r,t,e)}function Gue(t,e){let r=t.getBoundingClientRect(),n=e.getBoundingClientRect(),i=r.height/t.offsetHeight;n.top<r.top?t.scrollTop-=(r.top-n.top)/i:n.bottom>r.bottom&&(t.scrollTop+=(n.bottom-r.bottom)/i)}function tI(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function Yue(t,e){let r=[],n=null,i=null,a=h=>{r.push(h);let{section:d}=h.completion;if(d){n||(n=[]);let g=typeof d=="string"?d:d.name;n.some(m=>m.name==g)||n.push(typeof d=="string"?{name:g}:d)}},s=e.facet(Xr);for(let h of t)if(h.hasResult()){let d=h.result.getMatch;if(h.result.filter===!1)for(let g of h.result.options)a(new Zz(g,h.source,d?d(g):[],1e9-r.length));else{let g=e.sliceDoc(h.from,h.to),m,y=s.filterStrict?new Fue(g):new jue(g);for(let b of h.result.options)if(m=y.match(b.label)){let x=b.displayLabel?d?d(b,m.matched):[]:m.matched,w=m.score+(b.boost||0);if(a(new Zz(b,h.source,x,w)),typeof b.section=="object"&&b.section.rank==="dynamic"){let{name:S}=b.section;i||(i=Object.create(null)),i[S]=Math.max(w,i[S]||-1e9)}}}}if(n){let h=Object.create(null),d=0,g=(m,y)=>(m.rank==="dynamic"&&y.rank==="dynamic"?i[y.name]-i[m.name]:0)||(typeof m.rank=="number"?m.rank:1e9)-(typeof y.rank=="number"?y.rank:1e9)||(m.name<y.name?-1:1);for(let m of n.sort(g))d-=1e5,h[m.name]=d;for(let m of r){let{section:y}=m.completion;y&&(m.score+=h[typeof y=="string"?y:y.name])}}let l=[],o=null,c=s.compareCompletions;for(let h of r.sort((d,g)=>g.score-d.score||c(d.completion,g.completion))){let d=h.completion;!o||o.label!=d.label||o.detail!=d.detail||o.type!=null&&d.type!=null&&o.type!=d.type||o.apply!=d.apply||o.boost!=d.boost?l.push(h):tI(h.completion)>tI(o)&&(l[l.length-1]=h),o=h.completion}return l}class xu{constructor(e,r,n,i,a,s){this.options=e,this.attrs=r,this.tooltip=n,this.timestamp=i,this.selected=a,this.disabled=s}setSelected(e,r){return e==this.selected||e>=this.options.length?this:new xu(this.options,rI(r,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,r,n,i,a,s){if(i&&!s&&e.some(c=>c.isPending))return i.setDisabled();let l=Yue(e,r);if(!l.length)return i&&e.some(c=>c.isPending)?i.setDisabled():null;let o=r.facet(Xr).selectOnOpen?0:-1;if(i&&i.selected!=o&&i.selected!=-1){let c=i.options[i.selected].completion;for(let h=0;h<l.length;h++)if(l[h].completion==c){o=h;break}}return new xu(l,rI(n,o),{pos:e.reduce((c,h)=>h.hasResult()?Math.min(c,h.from):c,1e8),create:Jue,above:a.aboveCursor},i?i.timestamp:Date.now(),o,!1)}map(e){return new xu(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new xu(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Zg{constructor(e,r,n){this.active=e,this.id=r,this.open=n}static start(){return new Zg(Kue,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:r}=e,n=r.facet(Xr),a=(n.override||r.languageDataAt("autocomplete",Wl(r)).map(que)).map(o=>(this.active.find(h=>h.source==o)||new Ai(o,this.active.some(h=>h.state!=0)?1:0)).update(e,n));a.length==this.active.length&&a.every((o,c)=>o==this.active[c])&&(a=this.active);let s=this.open,l=e.effects.some(o=>o.is(iA));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||a.some(o=>o.hasResult()&&e.changes.touchesRange(o.from,o.to))||!Xue(a,this.active)||l?s=xu.build(a,r,this.id,s,n,l):s&&s.disabled&&!a.some(o=>o.isPending)&&(s=null),!s&&a.every(o=>!o.isPending)&&a.some(o=>o.hasResult())&&(a=a.map(o=>o.hasResult()?new Ai(o.source,0):o));for(let o of e.effects)o.is(nA)&&(s=s&&s.setSelected(o.value,this.id));return a==this.active&&s==this.open?this:new Zg(a,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Wue:Que}}function Xue(t,e){if(t==e)return!0;for(let r=0,n=0;;){for(;r<t.length&&!t[r].hasResult();)r++;for(;n<e.length&&!e[n].hasResult();)n++;let i=r==t.length,a=n==e.length;if(i||a)return i==a;if(t[r++].result!=e[n++].result)return!1}}const Wue={"aria-autocomplete":"list"},Que={};function rI(t,e){let r={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(r["aria-activedescendant"]=t+"-"+e),r}const Kue=[];function eH(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(JF);if(n&&e.activateOnCompletion(n))return 12}let r=t.isUserEvent("input.type");return r&&e.activateOnTyping?5:r?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Ai{constructor(e,r,n=!1){this.source=e,this.state=r,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,r){let n=eH(e,r),i=this;(n&8||n&16&&this.touches(e))&&(i=new Ai(i.source,0)),n&4&&i.state==0&&(i=new Ai(this.source,1)),i=i.updateFor(e,n);for(let a of e.effects)if(a.is(Kg))i=new Ai(i.source,1,a.value);else if(a.is(sh))i=new Ai(i.source,0);else if(a.is(iA))for(let s of a.value)s.source==i.source&&(i=s);return i}updateFor(e,r){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Wl(e.state))}}class Du extends Ai{constructor(e,r,n,i,a,s){super(e,3,r),this.limit=n,this.result=i,this.from=a,this.to=s}hasResult(){return!0}updateFor(e,r){var n;if(!(r&3))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let a=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),l=Wl(e.state);if(l>s||!i||r&2&&(Wl(e.startState)==this.from||l<this.limit))return new Ai(this.source,r&4?1:0);let o=e.changes.mapPos(this.limit);return Zue(i.validFor,e.state,a,s)?new Du(this.source,this.explicit,o,i,a,s):i.update&&(i=i.update(i,a,s,new KF(e.state,l,!1)))?new Du(this.source,this.explicit,o,i,i.from,(n=i.to)!==null&&n!==void 0?n:Wl(e.state)):new Ai(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new Du(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Ai(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Zue(t,e,r,n){if(!t)return!1;let i=e.sliceDoc(r,n);return typeof t=="function"?t(i,r,n,e):ZF(t,!0).test(i)}const iA=yt.define({map(t,e){return t.map(r=>r.map(e))}}),Un=Sn.define({create(){return Zg.start()},update(t,e){return t.update(e)},provide:t=>[FE.from(t,e=>e.tooltip),Ue.contentAttributes.from(t,e=>e.attrs)]});function aA(t,e){const r=e.completion.apply||e.completion.label;let n=t.state.field(Un).active.find(i=>i.source==e.source);return n instanceof Du?(typeof r=="string"?t.dispatch({...Iue(t.state,r,n.from,n.to),annotations:JF.of(e.completion)}):r(t,e.completion,n.from,n.to),!0):!1}const Jue=$ue(Un,aA);function Np(t,e="option"){return r=>{let n=r.state.field(Un,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<r.state.facet(Xr).interactionDelay)return!1;let i=1,a;e=="page"&&(a=N9(r,n.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,l=n.open.selected>-1?n.open.selected+i*(t?1:-1):t?0:s-1;return l<0?l=e=="page"?0:s-1:l>=s&&(l=e=="page"?s-1:0),r.dispatch({effects:nA.of(l)}),!0}}const ece=t=>{let e=t.state.field(Un,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(Xr).interactionDelay?!1:aA(t,e.open.options[e.open.selected])},VC=t=>t.state.field(Un,!1)?(t.dispatch({effects:Kg.of(!0)}),!0):!1,tce=t=>{let e=t.state.field(Un,!1);return!e||!e.active.some(r=>r.state!=0)?!1:(t.dispatch({effects:sh.of(null)}),!0)};class rce{constructor(e,r){this.active=e,this.context=r,this.time=Date.now(),this.updates=[],this.done=void 0}}const nce=50,ice=1e3,ace=mr.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Un).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(Un),r=t.state.facet(Xr);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Un)==e)return;let n=t.transactions.some(a=>{let s=eH(a,r);return s&8||(a.selection||a.docChanged)&&!(s&3)});for(let a=0;a<this.running.length;a++){let s=this.running[a];if(n||s.context.abortOnDocChange&&t.docChanged||s.updates.length+t.transactions.length>nce&&Date.now()-s.time>ice){for(let l of s.context.abortListeners)try{l()}catch(o){Xn(this.view.state,o)}s.context.abortListeners=null,this.running.splice(a--,1)}else s.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(a=>a.effects.some(s=>s.is(Kg)))&&(this.pendingStart=!0);let i=this.pendingStart?50:r.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(a=>a.isPending&&!this.running.some(s=>s.active.source==a.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let a of t.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Un);for(let r of e.active)r.isPending&&!this.running.some(n=>n.active.source==r.source)&&this.startQuery(r);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Xr).updateSyncTime))}startQuery(t){let{state:e}=this.view,r=Wl(e),n=new KF(e,r,t.explicit,this.view),i=new rce(t,n);this.running.push(i),Promise.resolve(t.source(n)).then(a=>{i.context.aborted||(i.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:sh.of(null)}),Xn(this.view.state,a)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Xr).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],r=this.view.state.facet(Xr),n=this.view.state.field(Un);for(let i=0;i<this.running.length;i++){let a=this.running[i];if(a.done===void 0)continue;if(this.running.splice(i--,1),a.done){let l=Wl(a.updates.length?a.updates[0].startState:this.view.state),o=Math.min(l,a.done.from+(a.active.explicit?0:1)),c=new Du(a.active.source,a.active.explicit,o,a.done,a.done.from,(t=a.done.to)!==null&&t!==void 0?t:l);for(let h of a.updates)c=c.update(h,r);if(c.hasResult()){e.push(c);continue}}let s=n.active.find(l=>l.source==a.active.source);if(s&&s.isPending)if(a.done==null){let l=new Ai(a.active.source,0);for(let o of a.updates)l=l.update(o,r);l.isPending||e.push(l)}else this.startQuery(s)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:iA.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Un,!1);if(e&&e.tooltip&&this.view.state.facet(Xr).closeOnBlur){let r=e.open&&N9(this.view,e.open.tooltip);(!r||!r.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:sh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Kg.of(!1)}),20),this.composing=0}}}),sce=typeof navigator=="object"&&/Win/.test(navigator.platform),lce=po.highest(Ue.domEventHandlers({keydown(t,e){let r=e.state.field(Un,!1);if(!r||!r.open||r.open.disabled||r.open.selected<0||t.key.length>1||t.ctrlKey&&!(sce&&t.altKey)||t.metaKey)return!1;let n=r.open.options[r.open.selected],i=r.active.find(s=>s.source==n.source),a=n.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(t.key)>-1&&aA(e,n),!1}})),oce=Ue.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),lh={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},$l=yt.define({map(t,e){let r=e.mapPos(t,-1,On.TrackAfter);return r??void 0}}),sA=new class extends Js{};sA.startSide=1;sA.endSide=-1;const tH=Sn.define({create(){return Et.empty},update(t,e){if(t=t.map(e.changes),e.selection){let r=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:n=>n>=r.from&&n<=r.to})}for(let r of e.effects)r.is($l)&&(t=t.update({add:[sA.range(r.value,r.value+1)]}));return t}});function uce(){return[fce,tH]}const UC="()[]{}<>«»»«[]{}";function rH(t){for(let e=0;e<UC.length;e+=2)if(UC.charCodeAt(e)==t)return UC.charAt(e+1);return kE(t<128?t:t+1)}function nH(t,e){return t.languageDataAt("closeBrackets",e)[0]||lh}const cce=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),fce=Ue.inputHandler.of((t,e,r,n)=>{if((cce?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let i=t.state.selection.main;if(n.length>2||n.length==2&&aa(Vn(n,0))==1||e!=i.from||r!=i.to)return!1;let a=pce(t.state,n);return a?(t.dispatch(a),!0):!1}),hce=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=nH(t,t.selection.main.head).brackets||lh.brackets,i=null,a=t.changeByRange(s=>{if(s.empty){let l=gce(t.doc,s.head);for(let o of n)if(o==l&&em(t.doc,s.head)==rH(Vn(o,0)))return{changes:{from:s.head-o.length,to:s.head+o.length},range:Ae.cursor(s.head-o.length)}}return{range:i=s}});return i||e(t.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},dce=[{key:"Backspace",run:hce}];function pce(t,e){let r=nH(t,t.selection.main.head),n=r.brackets||lh.brackets;for(let i of n){let a=rH(Vn(i,0));if(e==i)return a==i?yce(t,i,n.indexOf(i+i+i)>-1,r):vce(t,i,a,r.before||lh.before);if(e==a&&iH(t,t.selection.main.from))return mce(t,i,a)}return null}function iH(t,e){let r=!1;return t.field(tH).between(0,t.doc.length,n=>{n==e&&(r=!0)}),r}function em(t,e){let r=t.sliceString(e,e+2);return r.slice(0,aa(Vn(r,0)))}function gce(t,e){let r=t.sliceString(e-2,e);return aa(Vn(r,0))==r.length?r:r.slice(1)}function vce(t,e,r,n){let i=null,a=t.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:r,from:s.to}],effects:$l.of(s.to+e.length),range:Ae.range(s.anchor+e.length,s.head+e.length)};let l=em(t.doc,s.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+r,from:s.head},effects:$l.of(s.head+e.length),range:Ae.cursor(s.head+e.length)}:{range:i=s}});return i?null:t.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function mce(t,e,r){let n=null,i=t.changeByRange(a=>a.empty&&em(t.doc,a.head)==r?{changes:{from:a.head,to:a.head+r.length,insert:r},range:Ae.cursor(a.head+r.length)}:n={range:a});return n?null:t.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function yce(t,e,r,n){let i=n.stringPrefixes||lh.stringPrefixes,a=null,s=t.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:$l.of(l.to+e.length),range:Ae.range(l.anchor+e.length,l.head+e.length)};let o=l.head,c=em(t.doc,o),h;if(c==e){if(nI(t,o))return{changes:{insert:e+e,from:o},effects:$l.of(o+e.length),range:Ae.cursor(o+e.length)};if(iH(t,o)){let g=r&&t.sliceDoc(o,o+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:o,to:o+g.length,insert:g},range:Ae.cursor(o+g.length)}}}else{if(r&&t.sliceDoc(o-2*e.length,o)==e+e&&(h=iI(t,o-2*e.length,i))>-1&&nI(t,h))return{changes:{insert:e+e+e+e,from:o},effects:$l.of(o+e.length),range:Ae.cursor(o+e.length)};if(t.charCategorizer(o)(c)!=cr.Word&&iI(t,o,i)>-1&&!bce(t,o,e,i))return{changes:{insert:e+e,from:o},effects:$l.of(o+e.length),range:Ae.cursor(o+e.length)}}return{range:a=l}});return a?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function nI(t,e){let r=bn(t).resolveInner(e+1);return r.parent&&r.from==e}function bce(t,e,r,n){let i=bn(t).resolveInner(e,-1),a=n.reduce((s,l)=>Math.max(s,l.length),0);for(let s=0;s<5;s++){let l=t.sliceDoc(i.from,Math.min(i.to,i.from+r.length+a)),o=l.indexOf(r);if(!o||o>-1&&n.indexOf(l.slice(0,o))>-1){let h=i.firstChild;for(;h&&h.from==i.from&&h.to-h.from>r.length+o;){if(t.sliceDoc(h.to-r.length,h.to)==r)return!1;h=h.firstChild}return!0}let c=i.to==e&&i.parent;if(!c)break;i=c}return!1}function iI(t,e,r){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=cr.Word)return e;for(let i of r){let a=e-i.length;if(t.sliceDoc(a,e)==i&&n(t.sliceDoc(a-1,a))!=cr.Word)return a}return-1}function xce(t={}){return[lce,Un,Xr.of(t),ace,wce,oce]}const aH=[{key:"Ctrl-Space",run:VC},{mac:"Alt-`",run:VC},{mac:"Alt-i",run:VC},{key:"Escape",run:tce},{key:"ArrowDown",run:Np(!0)},{key:"ArrowUp",run:Np(!1)},{key:"PageDown",run:Np(!0,"page")},{key:"PageUp",run:Np(!1,"page")},{key:"Enter",run:ece}],wce=po.highest($v.computeN([Xr],t=>t.facet(Xr).defaultKeymap?[aH]:[]));class aI{constructor(e,r,n){this.from=e,this.to=r,this.diagnostic=n}}class ql{constructor(e,r,n){this.diagnostics=e,this.panel=r,this.selected=n}static init(e,r,n){let i=n.facet(oh).markerFilter;i&&(e=i(e,n));let a=e.slice().sort((m,y)=>m.from-y.from||m.to-y.to),s=new Wa,l=[],o=0,c=n.doc.iter(),h=0,d=n.doc.length;for(let m=0;;){let y=m==a.length?null:a[m];if(!y&&!l.length)break;let b,x;if(l.length)b=o,x=l.reduce((k,E)=>Math.min(k,E.to),y&&y.from>b?y.from:1e8);else{if(b=y.from,b>d)break;x=y.to,l.push(y),m++}for(;m<a.length;){let k=a[m];if(k.from==b&&(k.to>k.from||k.to==b))l.push(k),m++,x=Math.min(k.to,x);else{x=Math.min(k.from,x);break}}x=Math.min(x,d);let w=!1;if(l.some(k=>k.from==b&&(k.to==x||x==d))&&(w=b==x,!w&&x-b<10)){let k=b-(h+c.value.length);k>0&&(c.next(k),h=b);for(let E=b;;){if(E>=x){w=!0;break}if(!c.lineBreak&&h+c.value.length>E)break;E=h+c.value.length,h+=c.value.length,c.next()}}let S=Bce(l);if(w)s.add(b,b,ut.widget({widget:new Rce(S),diagnostics:l.slice()}));else{let k=l.reduce((E,M)=>M.markClass?E+" "+M.markClass:E,"");s.add(b,x,ut.mark({class:"cm-lintRange cm-lintRange-"+S+k,diagnostics:l.slice(),inclusiveEnd:l.some(E=>E.to>x)}))}if(o=x,o==d)break;for(let k=0;k<l.length;k++)l[k].to<=o&&l.splice(k--,1)}let g=s.finish();return new ql(g,r,al(g))}}function al(t,e=null,r=0){let n=null;return t.between(r,1e9,(i,a,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!n)n=new aI(i,a,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new aI(n.from,a,n.diagnostic)}}),n}function Sce(t,e){let r=e.pos,n=e.end||r,i=t.state.facet(oh).hideOn(t,r,n);if(i!=null)return i;let a=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(s=>s.is(sH))||t.changes.touchesRange(a.from,Math.max(a.to,n)))}function Cce(t,e){return t.field(ci,!1)?e:e.concat(yt.appendConfig.of(Lce))}const sH=yt.define(),lA=yt.define(),lH=yt.define(),ci=Sn.define({create(){return new ql(ut.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let r=t.diagnostics.map(e.changes),n=null,i=t.panel;if(t.selected){let a=e.changes.mapPos(t.selected.from,1);n=al(r,t.selected.diagnostic,a)||al(r,null,a)}!r.size&&i&&e.state.facet(oh).autoPanel&&(i=null),t=new ql(r,i,n)}for(let r of e.effects)if(r.is(sH)){let n=e.state.facet(oh).autoPanel?r.value.length?uh.open:null:t.panel;t=ql.init(r.value,n,e.state)}else r.is(lA)?t=new ql(t.diagnostics,r.value?uh.open:null,t.selected):r.is(lH)&&(t=new ql(t.diagnostics,t.panel,r.value));return t},provide:t=>[th.from(t,e=>e.panel),Ue.decorations.from(t,e=>e.diagnostics)]}),kce=ut.mark({class:"cm-lintRange cm-lintRange-active"});function Tce(t,e,r){let{diagnostics:n}=t.state.field(ci),i,a=-1,s=-1;n.between(e-(r<0?1:0),e+(r>0?1:0),(o,c,{spec:h})=>{if(e>=o&&e<=c&&(o==c||(e>o||r>0)&&(e<c||r<0)))return i=h.diagnostics,a=o,s=c,!1});let l=t.state.facet(oh).tooltipFilter;return i&&l&&(i=l(i,t.state)),i?{pos:a,end:s,above:t.state.doc.lineAt(a).to<s,create(){return{dom:Ece(t,i)}}}:null}function Ece(t,e){return Wt("ul",{class:"cm-tooltip-lint"},e.map(r=>uH(t,r,!1)))}const Ace=t=>{let e=t.state.field(ci,!1);(!e||!e.panel)&&t.dispatch({effects:Cce(t.state,[lA.of(!0)])});let r=HE(t,uh.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},sI=t=>{let e=t.state.field(ci,!1);return!e||!e.panel?!1:(t.dispatch({effects:lA.of(!1)}),!0)},Oce=t=>{let e=t.state.field(ci,!1);if(!e)return!1;let r=t.state.selection.main,n=al(e.diagnostics,null,r.to+1);return!n&&(n=al(e.diagnostics,null,0),!n||n.from==r.from&&n.to==r.to)?!1:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},Mce=[{key:"Mod-Shift-m",run:Ace,preventDefault:!0},{key:"F8",run:Oce}],oh=We.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...ya(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:lI,tooltipFilter:lI,needsRefresh:(e,r)=>e?r?n=>e(n)||r(n):e:r,hideOn:(e,r)=>e?r?(n,i,a)=>e(n,i,a)||r(n,i,a):e:r,autoPanel:(e,r)=>e||r})}}});function lI(t,e){return t?e?(r,n)=>e(t(r,n),n):t:e}function oH(t){let e=[];if(t)e:for(let{name:r}of t){for(let n=0;n<r.length;n++){let i=r[n];if(/[a-zA-Z]/.test(i)&&!e.some(a=>a.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function uH(t,e,r){var n;let i=r?oH(e.actions):[];return Wt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Wt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((a,s)=>{let l=!1,o=m=>{if(m.preventDefault(),l)return;l=!0;let y=al(t.state.field(ci).diagnostics,e);y&&a.apply(t,y.from,y.to)},{name:c}=a,h=i[s]?c.indexOf(i[s]):-1,d=h<0?c:[c.slice(0,h),Wt("u",c.slice(h,h+1)),c.slice(h+1)],g=a.markClass?" "+a.markClass:"";return Wt("button",{type:"button",class:"cm-diagnosticAction"+g,onclick:o,onmousedown:o,"aria-label":` Action: ${c}${h<0?"":` (access key "${i[s]})"`}.`},d)}),e.source&&Wt("div",{class:"cm-diagnosticSource"},e.source))}class Rce extends ba{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Wt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class oI{constructor(e,r){this.diagnostic=r,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=uH(e,r,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class uh{constructor(e){this.view=e,this.items=[];let r=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)sI(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:a}=this.items[this.selectedIndex],s=oH(a.actions);for(let l=0;l<s.length;l++)if(s[l].toUpperCase().charCodeAt(0)==i.keyCode){let o=al(this.view.state.field(ci).diagnostics,a);o&&a.actions[l].apply(e,o.from,o.to)}}else return;i.preventDefault()}},n=i=>{for(let a=0;a<this.items.length;a++)this.items[a].dom.contains(i.target)&&this.moveSelection(a)};this.list=Wt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:r,onclick:n}),this.dom=Wt("div",{class:"cm-panel-lint"},this.list,Wt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>sI(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ci).selected;if(!e)return-1;for(let r=0;r<this.items.length;r++)if(this.items[r].diagnostic==e.diagnostic)return r;return-1}update(){let{diagnostics:e,selected:r}=this.view.state.field(ci),n=0,i=!1,a=null,s=new Set;for(e.between(0,this.view.state.doc.length,(l,o,{spec:c})=>{for(let h of c.diagnostics){if(s.has(h))continue;s.add(h);let d=-1,g;for(let m=n;m<this.items.length;m++)if(this.items[m].diagnostic==h){d=m;break}d<0?(g=new oI(this.view,h),this.items.splice(n,0,g),i=!0):(g=this.items[d],d>n&&(this.items.splice(n,d-n),i=!0)),r&&g.diagnostic==r.diagnostic?g.dom.hasAttribute("aria-selected")||(g.dom.setAttribute("aria-selected","true"),a=g):g.dom.hasAttribute("aria-selected")&&g.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new oI(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),a?(this.list.setAttribute("aria-activedescendant",a.id),this.view.requestMeasure({key:this,read:()=>({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:o})=>{let c=o.height/this.list.offsetHeight;l.top<o.top?this.list.scrollTop-=(o.top-l.top)/c:l.bottom>o.bottom&&(this.list.scrollTop+=(l.bottom-o.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function r(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)r();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)r()}moveSelection(e){if(this.selectedIndex<0)return;let r=this.view.state.field(ci),n=al(r.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:lH.of(n)})}static open(e){return new uh(e)}}function Dce(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function Bp(t){return Dce(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const _ce=Ue.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Bp("#d11")},".cm-lintRange-warning":{backgroundImage:Bp("orange")},".cm-lintRange-info":{backgroundImage:Bp("#999")},".cm-lintRange-hint":{backgroundImage:Bp("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function Nce(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Bce(t){let e="hint",r=1;for(let n of t){let i=Nce(n.severity);i>r&&(r=i,e=n.severity)}return e}const Lce=[ci,Ue.decorations.compute([ci],t=>{let{selected:e,panel:r}=t.field(ci);return!e||!r||e.from==e.to?ut.none:ut.set([kce.range(e.from,e.to)])}),Tse(Tce,{hideOn:Sce}),_ce];var uI=function(e){e===void 0&&(e={});var{crosshairCursor:r=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(dce)),e.defaultKeymap!==!1&&(n=n.concat(aue)),e.searchKeymap!==!1&&(n=n.concat(_ue)),e.historyKeymap!==!1&&(n=n.concat(hoe)),e.foldKeymap!==!1&&(n=n.concat(Ele)),e.completionKeymap!==!1&&(n=n.concat(aH)),e.lintKeymap!==!1&&(n=n.concat(Mce));var i=[];return e.lineNumbers!==!1&&i.push(Ise()),e.highlightActiveLineGutter!==!1&&i.push(Fse()),e.highlightSpecialChars!==!1&&i.push(ese()),e.history!==!1&&i.push(noe()),e.foldGutter!==!1&&i.push(Rle()),e.drawSelection!==!1&&i.push(Vae()),e.dropCursor!==!1&&i.push(Xae()),e.allowMultipleSelections!==!1&&i.push(Dt.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&i.push(vle()),e.syntaxHighlighting!==!1&&i.push(sF(Ble,{fallback:!0})),e.bracketMatching!==!1&&i.push(Fle()),e.closeBrackets!==!1&&i.push(uce()),e.autocompletion!==!1&&i.push(xce()),e.rectangularSelection!==!1&&i.push(pse()),r!==!1&&i.push(mse()),e.highlightActiveLine!==!1&&i.push(sse()),e.highlightSelectionMatches!==!1&&i.push(fue()),e.tabSize&&typeof e.tabSize=="number"&&i.push(Yv.of(" ".repeat(e.tabSize))),i.concat([$v.of(n.flat())]).filter(Boolean)};const Pce="#e5c07b",cI="#e06c75",zce="#56b6c2",Ice="#ffffff",ig="#abb2bf",mT="#7d8799",qce="#61afef",jce="#98c379",fI="#d19a66",Fce="#c678dd",Hce="#21252b",hI="#2c313a",dI="#282c34",$C="#353a42",Vce="#3E4451",pI="#528bff",Uce=Ue.theme({"&":{color:ig,backgroundColor:dI},".cm-content":{caretColor:pI},".cm-cursor, .cm-dropCursor":{borderLeftColor:pI},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Vce},".cm-panels":{backgroundColor:Hce,color:ig},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:dI,color:mT,border:"none"},".cm-activeLineGutter":{backgroundColor:hI},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:$C},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:$C,borderBottomColor:$C},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:hI,color:ig}}},{dark:!0}),$ce=Bh.define([{tag:xe.keyword,color:Fce},{tag:[xe.name,xe.deleted,xe.character,xe.propertyName,xe.macroName],color:cI},{tag:[xe.function(xe.variableName),xe.labelName],color:qce},{tag:[xe.color,xe.constant(xe.name),xe.standard(xe.name)],color:fI},{tag:[xe.definition(xe.name),xe.separator],color:ig},{tag:[xe.typeName,xe.className,xe.number,xe.changed,xe.annotation,xe.modifier,xe.self,xe.namespace],color:Pce},{tag:[xe.operator,xe.operatorKeyword,xe.url,xe.escape,xe.regexp,xe.link,xe.special(xe.string)],color:zce},{tag:[xe.meta,xe.comment],color:mT},{tag:xe.strong,fontWeight:"bold"},{tag:xe.emphasis,fontStyle:"italic"},{tag:xe.strikethrough,textDecoration:"line-through"},{tag:xe.link,color:mT,textDecoration:"underline"},{tag:xe.heading,fontWeight:"bold",color:cI},{tag:[xe.atom,xe.bool,xe.special(xe.variableName)],color:fI},{tag:[xe.processingInstruction,xe.string,xe.inserted],color:jce},{tag:xe.invalid,color:Ice}]),cH=[Uce,sF($ce)];var Gce=Ue.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Yce=function(e){e===void 0&&(e={});var{indentWithTab:r=!0,editable:n=!0,readOnly:i=!1,theme:a="light",placeholder:s="",basicSetup:l=!0}=e,o=[];switch(r&&o.unshift($v.of([sue])),l&&(typeof l=="boolean"?o.unshift(uI()):o.unshift(uI(l))),s&&o.unshift(cse(s)),a){case"light":o.push(Gce);break;case"dark":o.push(cH);break;case"none":break;default:o.push(a);break}return n===!1&&o.push(Ue.editable.of(!1)),i&&o.push(Dt.readOnly.of(!0)),[...o]},Xce=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Wce{constructor(e,r){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=r,this.timeoutMS=r,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(r=>{try{r()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class gI{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var GC=null,Qce=()=>typeof window>"u"?new gI:(GC||(GC=new gI),GC),vI=ma.define(),Kce=200,Zce=[];function Jce(t){var{value:e,selection:r,onChange:n,onStatistics:i,onCreateEditor:a,onUpdate:s,extensions:l=Zce,autoFocus:o,theme:c="light",height:h=null,minHeight:d=null,maxHeight:g=null,width:m=null,minWidth:y=null,maxWidth:b=null,placeholder:x="",editable:w=!0,readOnly:S=!1,indentWithTab:k=!0,basicSetup:E=!0,root:M,initialState:R}=t,[O,N]=ve.useState(),[B,D]=ve.useState(),[_,P]=ve.useState(),z=ve.useState(()=>({current:null}))[0],H=ve.useState(()=>({current:null}))[0],$=Ue.theme({"&":{height:h,minHeight:d,maxHeight:g,width:m,minWidth:y,maxWidth:b},"& .cm-scroller":{height:"100% !important"}}),q=Ue.updateListener.of(ee=>{if(ee.docChanged&&typeof n=="function"&&!ee.transactions.some(G=>G.annotation(vI))){z.current?z.current.reset():(z.current=new Wce(()=>{if(H.current){var G=H.current;H.current=null,G()}z.current=null},Kce),Qce().add(z.current));var te=ee.state.doc,I=te.toString();n(I,ee)}i&&i(Xce(ee))}),V=Yce({theme:c,editable:w,readOnly:S,placeholder:x,indentWithTab:k,basicSetup:E}),X=[q,$,...V];return s&&typeof s=="function"&&X.push(Ue.updateListener.of(s)),X=X.concat(l),ve.useLayoutEffect(()=>{if(O&&!_){var ee={doc:e,selection:r,extensions:X},te=R?Dt.fromJSON(R.json,ee,R.fields):Dt.create(ee);if(P(te),!B){var I=new Ue({state:te,parent:O,root:M});D(I),a&&a(I,te)}}return()=>{B&&(P(void 0),D(void 0))}},[O,_]),ve.useEffect(()=>{t.container&&N(t.container)},[t.container]),ve.useEffect(()=>()=>{B&&(B.destroy(),D(void 0)),z.current&&(z.current.cancel(),z.current=null)},[B]),ve.useEffect(()=>{o&&B&&B.focus()},[o,B]),ve.useEffect(()=>{B&&B.dispatch({effects:yt.reconfigure.of(X)})},[c,l,h,d,g,m,y,b,x,w,S,k,E,n,s]),ve.useEffect(()=>{if(e!==void 0){var ee=B?B.state.doc.toString():"";if(B&&e!==ee){var te=z.current&&!z.current.isDone,I=()=>{B&&e!==B.state.doc.toString()&&B.dispatch({changes:{from:0,to:B.state.doc.toString().length,insert:e||""},annotations:[vI.of(!0)]})};te?H.current=I:I()}}},[e,B]),{state:_,setState:P,view:B,setView:D,container:O,setContainer:N}}var efe=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],fH=ve.forwardRef((t,e)=>{var{className:r,value:n="",selection:i,extensions:a=[],onChange:s,onStatistics:l,onCreateEditor:o,onUpdate:c,autoFocus:h,theme:d="light",height:g,minHeight:m,maxHeight:y,width:b,minWidth:x,maxWidth:w,basicSetup:S,placeholder:k,indentWithTab:E,editable:M,readOnly:R,root:O,initialState:N}=t,B=Rne(t,efe),D=ve.useRef(null),{state:_,view:P,container:z,setContainer:H}=Jce({root:O,value:n,autoFocus:h,theme:d,height:g,minHeight:m,maxHeight:y,width:b,minWidth:x,maxWidth:w,basicSetup:S,placeholder:k,indentWithTab:E,editable:M,readOnly:R,selection:i,onChange:s,onStatistics:l,onCreateEditor:o,onUpdate:c,extensions:a,initialState:N});ve.useImperativeHandle(e,()=>({editor:D.current,state:_,view:P}),[D,z,_,P]);var $=ve.useCallback(V=>{D.current=V,H(V)},[H]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var q=typeof d=="string"?"cm-theme-"+d:"cm-theme";return A.jsx("div",kk({ref:$,className:""+q+(r?" "+r:"")},B))});fH.displayName="CodeMirror";var mI={};class Jg{constructor(e,r,n,i,a,s,l,o,c,h=0,d){this.p=e,this.stack=r,this.state=n,this.reducePos=i,this.pos=a,this.score=s,this.buffer=l,this.bufferBase=o,this.curContext=c,this.lookAhead=h,this.parent=d}toString(){return`[${this.stack.filter((e,r)=>r%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,r,n=0){let i=e.parser.context;return new Jg(e,[],r,n,n,0,[],0,i?new yI(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,r){this.stack.push(this.state,r,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var r;let n=e>>19,i=e&65535,{parser:a}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),l=a.dynamicPrecedence(i);if(l&&(this.score+=l),n==0){this.pushState(a.getGoto(this.state,i,!0),this.reducePos),i<a.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(i,this.reducePos);return}let o=this.stack.length-(n-1)*3-(e&262144?6:0),c=o?this.stack[o-2]:this.p.ranges[0].from,h=this.reducePos-c;h>=2e3&&!(!((r=this.p.parser.nodeSet.types[i])===null||r===void 0)&&r.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSize<h&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=h));let d=o?this.stack[o-1]:0,g=this.bufferBase+this.buffer.length-d;if(i<a.minRepeatTerm||e&131072){let m=a.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,c,m,g+4,!0)}if(e&262144)this.state=this.stack[o];else{let m=this.stack[o-3];this.state=a.getGoto(m,i,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(i,c)}storeNode(e,r,n,i=4,a=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,l=this.buffer.length;if(l==0&&s.parent&&(l=s.bufferBase-s.parent.bufferBase,s=s.parent),l>0&&s.buffer[l-4]==0&&s.buffer[l-1]>-1){if(r==n)return;if(s.buffer[l-2]>=r){s.buffer[l-2]=n;return}}}if(!a||this.pos==n)this.buffer.push(e,r,n,i);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let l=!1;for(let o=s;o>0&&this.buffer[o-2]>n;o-=4)if(this.buffer[o-1]>=0){l=!0;break}if(l)for(;s>0&&this.buffer[s-2]>n;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,i>4&&(i-=4)}this.buffer[s]=e,this.buffer[s+1]=r,this.buffer[s+2]=n,this.buffer[s+3]=i}}shift(e,r,n,i){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let a=e,{parser:s}=this.p;this.pos=i;let l=s.stateFlag(a,1);!l&&(i>n||r<=s.maxNode)&&(this.reducePos=i),this.pushState(a,l?n:Math.min(n,this.reducePos)),this.shiftContext(r,n),r<=s.maxNode&&this.buffer.push(r,n,i,4)}else this.pos=i,this.shiftContext(r,n),r<=this.p.parser.maxNode&&this.buffer.push(r,n,i,4)}apply(e,r,n,i){e&65536?this.reduce(e):this.shift(e,r,n,i)}useNode(e,r){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(r,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,r=e.buffer.length;for(;r>0&&e.buffer[r-2]>e.reducePos;)r-=4;let n=e.buffer.slice(r),i=e.bufferBase+r;for(;e&&i==e.bufferBase;)e=e.parent;return new Jg(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,r){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,r,4),this.storeNode(0,this.pos,r,n?8:4),this.pos=this.reducePos=r,this.score-=190}canShift(e){for(let r=new tfe(this);;){let n=this.p.parser.stateSlot(r.state,4)||this.p.parser.hasAction(r.state,e);if(n==0)return!1;if((n&65536)==0)return!0;r.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let r=this.p.parser.nextStates(this.state);if(r.length>8||this.stack.length>=120){let i=[];for(let a=0,s;a<r.length;a+=2)(s=r[a+1])!=this.state&&this.p.parser.hasAction(s,e)&&i.push(r[a],s);if(this.stack.length<120)for(let a=0;i.length<8&&a<r.length;a+=2){let s=r[a+1];i.some((l,o)=>o&1&&l==s)||i.push(r[a],s)}r=i}let n=[];for(let i=0;i<r.length&&n.length<4;i+=2){let a=r[i+1];if(a==this.state)continue;let s=this.split();s.pushState(a,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(r[i],this.pos),s.reducePos=this.pos,s.score-=200,n.push(s)}return n}forceReduce(){let{parser:e}=this.p,r=e.stateSlot(this.state,5);if((r&65536)==0)return!1;if(!e.validAction(this.state,r)){let n=r>>19,i=r&65535,a=this.stack.length-n*3;if(a<0||e.getGoto(this.stack[a],i,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;r=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(r),!0}findForcedReduction(){let{parser:e}=this.p,r=[],n=(i,a)=>{if(!r.includes(i))return r.push(i),e.allActions(i,s=>{if(!(s&393216))if(s&65536){let l=(s>>19)-a;if(l>1){let o=s&65535,c=this.stack.length-l*3;if(c>=0&&e.getGoto(this.stack[c],o,!1)>=0)return l<<19|65536|o}}else{let l=n(s,a+1);if(l!=null)return l}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let r=0;r<this.stack.length;r+=3)if(this.stack[r]!=e.stack[r])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,r){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(r)))}reduceContext(e,r){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(r)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let r=new yI(this.curContext.tracker,e);r.hash!=this.curContext.hash&&this.emitContext(),this.curContext=r}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class yI{constructor(e,r){this.tracker=e,this.context=r,this.hash=e.strict?e.hash(r):0}}class tfe{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let r=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],r,!0);this.state=i}}class ev{constructor(e,r,n){this.stack=e,this.pos=r,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,r=e.bufferBase+e.buffer.length){return new ev(e,r,r-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new ev(this.stack,this.pos,this.index)}}function Lp(t,e=Uint16Array){if(typeof t!="string")return t;let r=null;for(let n=0,i=0;n<t.length;){let a=0;for(;;){let s=t.charCodeAt(n++),l=!1;if(s==126){a=65535;break}s>=92&&s--,s>=34&&s--;let o=s-32;if(o>=46&&(o-=46,l=!0),a+=o,l)break;a*=46}r?r[i++]=a:r=new e(a)}return r}class ag{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const bI=new ag;class rfe{constructor(e,r){this.input=e,this.ranges=r,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=bI,this.rangeIndex=0,this.pos=this.chunkPos=r[0].from,this.range=r[0],this.end=r[r.length-1].to,this.readNext()}resolveOffset(e,r){let n=this.range,i=this.rangeIndex,a=this.pos+e;for(;a<n.from;){if(!i)return null;let s=this.ranges[--i];a-=n.from-s.to,n=s}for(;r<0?a>n.to:a>=n.to;){if(i==this.ranges.length-1)return null;let s=this.ranges[++i];a+=s.from-n.to,n=s}return a}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let r of this.ranges)if(r.to>e)return Math.max(e,r.from);return this.end}peek(e){let r=this.chunkOff+e,n,i;if(r>=0&&r<this.chunk.length)n=this.pos+e,i=this.chunk.charCodeAt(r);else{let a=this.resolveOffset(e,1);if(a==null)return-1;if(n=a,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let s=this.rangeIndex,l=this.range;for(;l.to<=n;)l=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>l.to&&(this.chunk2=this.chunk2.slice(0,l.to-n)),i=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),i}acceptToken(e,r=0){let n=r?this.resolveOffset(r,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,r){this.token.value=e,this.token.end=r}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:r}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=r,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),r=this.pos+e.length;this.chunk=r>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,r){if(r?(this.token=r,r.start=e,r.lookAhead=e+1,r.value=r.extended=-1):this.token=bI,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,r){if(e>=this.chunkPos&&r<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,r-this.chunkPos);if(e>=this.chunk2Pos&&r<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,r-this.chunk2Pos);if(e>=this.range.from&&r<=this.range.to)return this.input.read(e,r);let n="";for(let i of this.ranges){if(i.from>=r)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,r)))}return n}}class _u{constructor(e,r){this.data=e,this.id=r}token(e,r){let{parser:n}=r.p;nfe(this.data,e,r,this.id,n.data,n.tokenPrecTable)}}_u.prototype.contextual=_u.prototype.fallback=_u.prototype.extend=!1;_u.prototype.fallback=_u.prototype.extend=!1;class tm{constructor(e,r={}){this.token=e,this.contextual=!!r.contextual,this.fallback=!!r.fallback,this.extend=!!r.extend}}function nfe(t,e,r,n,i,a){let s=0,l=1<<n,{dialect:o}=r.p.parser;e:for(;(l&t[s])!=0;){let c=t[s+1];for(let m=s+3;m<c;m+=2)if((t[m+1]&l)>0){let y=t[m];if(o.allows(y)&&(e.token.value==-1||e.token.value==y||ife(y,e.token.value,i,a))){e.acceptToken(y);break}}let h=e.next,d=0,g=t[s+2];if(e.next<0&&g>d&&t[c+g*3-3]==65535){s=t[c+g*3-1];continue e}for(;d<g;){let m=d+g>>1,y=c+m+(m<<1),b=t[y],x=t[y+1]||65536;if(h<b)g=m;else if(h>=x)d=m+1;else{s=t[y+2],e.advance();continue e}}break}}function xI(t,e,r){for(let n=e,i;(i=t[n])!=65535;n++)if(i==r)return n-e;return-1}function ife(t,e,r,n){let i=xI(r,n,e);return i<0||xI(r,n,t)<i}const oi=typeof process<"u"&&mI&&/\bparse\b/.test(mI.LOG);let YC=null;function wI(t,e,r){let n=t.cursor(gr.IncludeAnonymous);for(n.moveTo(e);;)if(!(r<0?n.childBefore(e):n.childAfter(e)))for(;;){if((r<0?n.to<e:n.from>e)&&!n.type.isError)return r<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(t.length,Math.max(n.from+1,e+25));if(r<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return r<0?0:t.length}}class afe{constructor(e,r){this.fragments=e,this.nodeSet=r,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?wI(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?wI(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let r=this.trees.length-1;if(r<0)return this.nextFragment(),null;let n=this.trees[r],i=this.index[r];if(i==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let a=n.children[i],s=this.start[r]+n.positions[i];if(s>e)return this.nextStart=s,null;if(a instanceof Cr){if(s==e){if(s<this.safeFrom)return null;let l=s+a.length;if(l<=this.safeTo){let o=a.prop(Ct.lookAhead);if(!o||l+o<this.fragment.to)return a}}this.index[r]++,s+a.length>=Math.max(this.safeFrom,e)&&(this.trees.push(a),this.start.push(s),this.index.push(0))}else this.index[r]++,this.nextStart=s+a.length}}}class sfe{constructor(e,r){this.stream=r,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new ag)}getActions(e){let r=0,n=null,{parser:i}=e.p,{tokenizers:a}=i,s=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,o=0;for(let c=0;c<a.length;c++){if((1<<c&s)==0)continue;let h=a[c],d=this.tokens[c];if(!(n&&!h.fallback)&&((h.contextual||d.start!=e.pos||d.mask!=s||d.context!=l)&&(this.updateCachedToken(d,h,e),d.mask=s,d.context=l),d.lookAhead>d.end+25&&(o=Math.max(d.lookAhead,o)),d.value!=0)){let g=r;if(d.extended>-1&&(r=this.addActions(e,d.extended,d.end,r)),r=this.addActions(e,d.value,d.end,r),!h.extend&&(n=d,r>g))break}}for(;this.actions.length>r;)this.actions.pop();return o&&e.setLookAhead(o),!n&&e.pos==this.stream.end&&(n=new ag,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,r=this.addActions(e,n.value,n.end,r)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let r=new ag,{pos:n,p:i}=e;return r.start=n,r.end=Math.min(n+1,i.stream.end),r.value=n==i.stream.end?i.parser.eofTerm:0,r}updateCachedToken(e,r,n){let i=this.stream.clipPos(n.pos);if(r.token(this.stream.reset(i,e),n),e.value>-1){let{parser:a}=n.p;for(let s=0;s<a.specialized.length;s++)if(a.specialized[s]==e.value){let l=a.specializers[s](this.stream.read(e.start,e.end),n);if(l>=0&&n.p.parser.dialect.allows(l>>1)){(l&1)==0?e.value=l>>1:e.extended=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,r,n,i){for(let a=0;a<i;a+=3)if(this.actions[a]==e)return i;return this.actions[i++]=e,this.actions[i++]=r,this.actions[i++]=n,i}addActions(e,r,n,i){let{state:a}=e,{parser:s}=e.p,{data:l}=s;for(let o=0;o<2;o++)for(let c=s.stateSlot(a,o?2:1);;c+=3){if(l[c]==65535)if(l[c+1]==1)c=Fa(l,c+2);else{i==0&&l[c+1]==2&&(i=this.putAction(Fa(l,c+2),r,n,i));break}l[c]==r&&(i=this.putAction(Fa(l,c+1),r,n,i))}return i}}class lfe{constructor(e,r,n,i){this.parser=e,this.input=r,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new rfe(r,i),this.tokens=new sfe(e,this.stream),this.topTerm=e.top[1];let{from:a}=i[0];this.stacks=[Jg.start(this,e.top[0],a)],this.fragments=n.length&&this.stream.end-a>e.bufferLength*4?new afe(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,r=this.minStackPos,n=this.stacks=[],i,a;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let l=e[s];for(;;){if(this.tokens.mainToken=null,l.pos>r)n.push(l);else{if(this.advanceStack(l,n,e))continue;{i||(i=[],a=[]),i.push(l);let o=this.tokens.getMainToken(l);a.push(o.value,o.end)}}break}}if(!n.length){let s=i&&cfe(i);if(s)return oi&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw oi&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+r);this.recovering||(this.recovering=5)}if(this.recovering&&i){let s=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,a,n);if(s)return oi&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(n.length>s)for(n.sort((l,o)=>o.score-l.score);n.length>s;)n.pop();n.some(l=>l.reducePos>r)&&this.recovering--}else if(n.length>1){e:for(let s=0;s<n.length-1;s++){let l=n[s];for(let o=s+1;o<n.length;o++){let c=n[o];if(l.sameState(c)||l.buffer.length>500&&c.buffer.length>500)if((l.score-c.score||l.buffer.length-c.buffer.length)>0)n.splice(o--,1);else{n.splice(s--,1);continue e}}}n.length>12&&(n.sort((s,l)=>l.score-s.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let s=1;s<n.length;s++)n[s].pos<this.minStackPos&&(this.minStackPos=n[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,r,n){let i=e.pos,{parser:a}=this,s=oi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,h=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(i);d;){let g=this.parser.nodeSet.types[d.type.id]==d.type?a.getGoto(e.state,d.type.id):-1;if(g>-1&&d.length&&(!c||(d.prop(Ct.contextHash)||0)==h))return e.useNode(d,g),oi&&console.log(s+this.stackID(e)+` (via reuse of ${a.getName(d.type.id)})`),!0;if(!(d instanceof Cr)||d.children.length==0||d.positions[0]>0)break;let m=d.children[0];if(m instanceof Cr&&d.positions[0]==0)d=m;else break}}let l=a.stateSlot(e.state,4);if(l>0)return e.reduce(l),oi&&console.log(s+this.stackID(e)+` (via always-reduce ${a.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let o=this.tokens.getActions(e);for(let c=0;c<o.length;){let h=o[c++],d=o[c++],g=o[c++],m=c==o.length||!n,y=m?e:e.split(),b=this.tokens.mainToken;if(y.apply(h,d,b?b.start:y.pos,g),oi&&console.log(s+this.stackID(y)+` (via ${(h&65536)==0?"shift":`reduce of ${a.getName(h&65535)}`} for ${a.getName(d)} @ ${i}${y==e?"":", split"})`),m)return!0;y.pos>i?r.push(y):n.push(y)}return!1}advanceFully(e,r){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return SI(e,r),!0}}runRecovery(e,r,n){let i=null,a=!1;for(let s=0;s<e.length;s++){let l=e[s],o=r[s<<1],c=r[(s<<1)+1],h=oi?this.stackID(l)+" -> ":"";if(l.deadEnd&&(a||(a=!0,l.restart(),oi&&console.log(h+this.stackID(l)+" (restarted)"),this.advanceFully(l,n))))continue;let d=l.split(),g=h;for(let m=0;m<10&&d.forceReduce()&&(oi&&console.log(g+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,n));m++)oi&&(g=this.stackID(d)+" -> ");for(let m of l.recoverByInsert(o))oi&&console.log(h+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,n);this.stream.end>l.pos?(c==l.pos&&(c++,o=0),l.recoverByDelete(o,c),oi&&console.log(h+this.stackID(l)+` (via recover-delete ${this.parser.getName(o)})`),SI(l,n)):(!i||i.score<d.score)&&(i=d)}return i}stackToTree(e){return e.close(),Cr.build({buffer:ev.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let r=(YC||(YC=new WeakMap)).get(e);return r||YC.set(e,r=String.fromCodePoint(this.nextStackID++)),r+e}}function SI(t,e){for(let r=0;r<e.length;r++){let n=e[r];if(n.pos==t.pos&&n.sameState(t)){e[r].score<t.score&&(e[r]=t);return}}e.push(t)}class ofe{constructor(e,r,n){this.source=e,this.flags=r,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}}const XC=t=>t;class ufe{constructor(e){this.start=e.start,this.shift=e.shift||XC,this.reduce=e.reduce||XC,this.reuse=e.reuse||XC,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class tv extends V9{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let r=e.nodeNames.split(" ");this.minRepeatTerm=r.length;for(let l=0;l<e.repeatNodeCount;l++)r.push("");let n=Object.keys(e.topRules).map(l=>e.topRules[l][1]),i=[];for(let l=0;l<r.length;l++)i.push([]);function a(l,o,c){i[l].push([o,o.deserialize(String(c))])}if(e.nodeProps)for(let l of e.nodeProps){let o=l[0];typeof o=="string"&&(o=Ct[o]);for(let c=1;c<l.length;){let h=l[c++];if(h>=0)a(h,o,l[c++]);else{let d=l[c+-h];for(let g=-h;g>0;g--)a(l[c++],o,d);c++}}}this.nodeSet=new VE(r.map((l,o)=>Zn.define({name:o>=this.minRepeatTerm?void 0:l,id:o,props:i[o],top:n.indexOf(o)>-1,error:o==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(o)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=q9;let s=Lp(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;l<this.specializerSpecs.length;l++)this.specialized[l]=this.specializerSpecs[l].term;this.specializers=this.specializerSpecs.map(CI),this.states=Lp(e.states,Uint32Array),this.data=Lp(e.stateData),this.goto=Lp(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(l=>typeof l=="number"?new _u(s,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,r,n){let i=new lfe(this,e,r,n);for(let a of this.wrappers)i=a(i,e,r,n);return i}getGoto(e,r,n=!1){let i=this.goto;if(r>=i[0])return-1;for(let a=i[r+1];;){let s=i[a++],l=s&1,o=i[a++];if(l&&n)return o;for(let c=a+(s>>1);a<c;a++)if(i[a]==e)return o;if(l)return-1}}hasAction(e,r){let n=this.data;for(let i=0;i<2;i++)for(let a=this.stateSlot(e,i?2:1),s;;a+=3){if((s=n[a])==65535)if(n[a+1]==1)s=n[a=Fa(n,a+2)];else{if(n[a+1]==2)return Fa(n,a+2);break}if(s==r||s==0)return Fa(n,a+1)}return 0}stateSlot(e,r){return this.states[e*6+r]}stateFlag(e,r){return(this.stateSlot(e,0)&r)>0}validAction(e,r){return!!this.allActions(e,n=>n==r?!0:null)}allActions(e,r){let n=this.stateSlot(e,4),i=n?r(n):void 0;for(let a=this.stateSlot(e,1);i==null;a+=3){if(this.data[a]==65535)if(this.data[a+1]==1)a=Fa(this.data,a+2);else break;i=r(Fa(this.data,a+1))}return i}nextStates(e){let r=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=Fa(this.data,n+2);else break;if((this.data[n+2]&1)==0){let i=this.data[n+1];r.some((a,s)=>s&1&&a==i)||r.push(this.data[n],i)}}return r}configure(e){let r=Object.assign(Object.create(tv.prototype),this);if(e.props&&(r.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);r.top=n}return e.tokenizers&&(r.tokenizers=this.tokenizers.map(n=>{let i=e.tokenizers.find(a=>a.from==n);return i?i.to:n})),e.specializers&&(r.specializers=this.specializers.slice(),r.specializerSpecs=this.specializerSpecs.map((n,i)=>{let a=e.specializers.find(l=>l.from==n.external);if(!a)return n;let s=Object.assign(Object.assign({},n),{external:a.to});return r.specializers[i]=CI(s),s})),e.contextTracker&&(r.context=e.contextTracker),e.dialect&&(r.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(r.strict=e.strict),e.wrap&&(r.wrappers=r.wrappers.concat(e.wrap)),e.bufferLength!=null&&(r.bufferLength=e.bufferLength),r}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let r=this.dynamicPrecedences;return r==null?0:r[e]||0}parseDialect(e){let r=Object.keys(this.dialects),n=r.map(()=>!1);if(e)for(let a of e.split(" ")){let s=r.indexOf(a);s>=0&&(n[s]=!0)}let i=null;for(let a=0;a<r.length;a++)if(!n[a])for(let s=this.dialects[r[a]],l;(l=this.data[s++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[l]=1;return new ofe(e,n,i)}static deserialize(e){return new tv(e)}}function Fa(t,e){return t[e]|t[e+1]<<16}function cfe(t){let e=null;for(let r of t){let n=r.p.stoppedAt;(r.pos==r.p.stream.end||n!=null&&r.pos>n)&&r.p.parser.stateFlag(r.state,2)&&(!e||e.score<r.score)&&(e=r)}return e}function CI(t){if(t.external){let e=t.extend?1:0;return(r,n)=>t.external(r,n)<<1|e}return t.get}const fu=63,kI=64,ffe=1,hfe=2,hH=3,dfe=4,dH=5,pfe=6,gfe=7,pH=65,vfe=66,mfe=8,yfe=9,bfe=10,xfe=11,wfe=12,gH=13,Sfe=19,Cfe=20,kfe=29,Tfe=33,Efe=34,Afe=47,Ofe=0,oA=1,yT=2,ch=3,bT=4;class jl{constructor(e,r,n){this.parent=e,this.depth=r,this.type=n,this.hash=(e?e.hash+e.hash<<8:0)+r+(r<<4)+n}}jl.top=new jl(null,-1,Ofe);function Df(t,e){for(let r=0,n=e-t.pos-1;;n--,r++){let i=t.peek(n);if(Za(i)||i==-1)return r}}function xT(t){return t==32||t==9}function Za(t){return t==10||t==13}function vH(t){return xT(t)||Za(t)}function Gl(t){return t<0||vH(t)}const Mfe=new ufe({start:jl.top,reduce(t,e){return t.type==ch&&(e==Cfe||e==Efe)?t.parent:t},shift(t,e,r,n){if(e==hH)return new jl(t,Df(n,n.pos),oA);if(e==pH||e==dH)return new jl(t,Df(n,n.pos),yT);if(e==fu)return t.parent;if(e==Sfe||e==Tfe)return new jl(t,0,ch);if(e==gH&&t.type==bT)return t.parent;if(e==Afe){let i=/[1-9]/.exec(n.read(n.pos,r.pos));if(i)return new jl(t,t.depth+ +i[0],bT)}return t},hash(t){return t.hash}});function Uu(t,e,r=0){return t.peek(r)==e&&t.peek(r+1)==e&&t.peek(r+2)==e&&Gl(t.peek(r+3))}const Rfe=new tm((t,e)=>{if(t.next==-1&&e.canShift(kI))return t.acceptToken(kI);let r=t.peek(-1);if((Za(r)||r<0)&&e.context.type!=ch){if(Uu(t,45))if(e.canShift(fu))t.acceptToken(fu);else return t.acceptToken(ffe,3);if(Uu(t,46))if(e.canShift(fu))t.acceptToken(fu);else return t.acceptToken(hfe,3);let n=0;for(;t.next==32;)n++,t.advance();(n<e.context.depth||n==e.context.depth&&e.context.type==oA&&(t.next!=45||!Gl(t.peek(1))))&&t.next!=-1&&!Za(t.next)&&t.next!=35&&t.acceptToken(fu,-n)}},{contextual:!0}),Dfe=new tm((t,e)=>{if(e.context.type==ch){t.next==63&&(t.advance(),Gl(t.next)&&t.acceptToken(gfe));return}if(t.next==45)t.advance(),Gl(t.next)&&t.acceptToken(e.context.type==oA&&e.context.depth==Df(t,t.pos-1)?dfe:hH);else if(t.next==63)t.advance(),Gl(t.next)&&t.acceptToken(e.context.type==yT&&e.context.depth==Df(t,t.pos-1)?pfe:dH);else{let r=t.pos;for(;;)if(xT(t.next)){if(t.pos==r)return;t.advance()}else if(t.next==33)mH(t);else if(t.next==38)wT(t);else if(t.next==42){wT(t);break}else if(t.next==39||t.next==34){if(uA(t,!0))break;return}else if(t.next==91||t.next==123){if(!Nfe(t))return;break}else{yH(t,!0,!1,0);break}for(;xT(t.next);)t.advance();if(t.next==58){if(t.pos==r&&e.canShift(kfe))return;let n=t.peek(1);Gl(n)&&t.acceptTokenTo(e.context.type==yT&&e.context.depth==Df(t,r)?vfe:pH,r)}}},{contextual:!0});function _fe(t){return t>32&&t<127&&t!=34&&t!=37&&t!=44&&t!=60&&t!=62&&t!=92&&t!=94&&t!=96&&t!=123&&t!=124&&t!=125}function TI(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function EI(t,e){return t.next==37?(t.advance(),TI(t.next)&&t.advance(),TI(t.next)&&t.advance(),!0):_fe(t.next)||e&&t.next==44?(t.advance(),!0):!1}function mH(t){if(t.advance(),t.next==60){for(t.advance();;)if(!EI(t,!0)){t.next==62&&t.advance();break}}else for(;EI(t,!1););}function wT(t){for(t.advance();!Gl(t.next)&&rv(t.next)!="f";)t.advance()}function uA(t,e){let r=t.next,n=!1,i=t.pos;for(t.advance();;){let a=t.next;if(a<0)break;if(t.advance(),a==r)if(a==39)if(t.next==39)t.advance();else break;else break;else if(a==92&&r==34)t.next>=0&&t.advance();else if(Za(a)){if(e)return!1;n=!0}else if(e&&t.pos>=i+1024)return!1}return!n}function Nfe(t){for(let e=[],r=t.pos+1024;;)if(t.next==91||t.next==123)e.push(t.next),t.advance();else if(t.next==39||t.next==34){if(!uA(t,!0))return!1}else if(t.next==93||t.next==125){if(e[e.length-1]!=t.next-2)return!1;if(e.pop(),t.advance(),!e.length)return!0}else{if(t.next<0||t.pos>r||Za(t.next))return!1;t.advance()}}const Bfe="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function rv(t){return t<33?"u":t>125?"s":Bfe[t-33]}function WC(t,e){let r=rv(t);return r!="u"&&!(e&&r=="f")}function yH(t,e,r,n){if(rv(t.next)=="s"||(t.next==63||t.next==58||t.next==45)&&WC(t.peek(1),r))t.advance();else return!1;let i=t.pos;for(;;){let a=t.next,s=0,l=n+1;for(;vH(a);){if(Za(a)){if(e)return!1;l=0}else l++;a=t.peek(++s)}if(!(a>=0&&(a==58?WC(t.peek(s+1),r):a==35?t.peek(s-1)!=32:WC(a,r)))||!r&&l<=n||l==0&&!r&&(Uu(t,45,s)||Uu(t,46,s)))break;if(e&&rv(a)=="f")return!1;for(let c=s;c>=0;c--)t.advance();if(e&&t.pos>i+1024)return!1}return!0}const Lfe=new tm((t,e)=>{if(t.next==33)mH(t),t.acceptToken(wfe);else if(t.next==38||t.next==42){let r=t.next==38?bfe:xfe;wT(t),t.acceptToken(r)}else t.next==39||t.next==34?(uA(t,!1),t.acceptToken(yfe)):yH(t,!1,e.context.type==ch,e.context.depth)&&t.acceptToken(mfe)}),Pfe=new tm((t,e)=>{let r=e.context.type==bT?e.context.depth:-1,n=t.pos;e:for(;;){let i=0,a=t.next;for(;a==32;)a=t.peek(++i);if(!i&&(Uu(t,45,i)||Uu(t,46,i))||!Za(a)&&(r<0&&(r=Math.max(e.context.depth+1,i)),i<r))break;for(;;){if(t.next<0)break e;let s=Za(t.next);if(t.advance(),s)continue e;n=t.pos}}t.acceptTokenTo(gH,n)}),zfe=U9({DirectiveName:xe.keyword,DirectiveContent:xe.attributeValue,"DirectiveEnd DocEnd":xe.meta,QuotedLiteral:xe.string,BlockLiteralHeader:xe.special(xe.string),BlockLiteralContent:xe.content,Literal:xe.content,"Key/Literal Key/QuotedLiteral":xe.definition(xe.propertyName),"Anchor Alias":xe.labelName,Tag:xe.typeName,Comment:xe.lineComment,": , -":xe.separator,"?":xe.punctuation,"[ ]":xe.squareBracket,"{ }":xe.brace}),Ife=tv.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:Mfe,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[zfe],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Rfe,Dfe,Lfe,Pfe,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),qfe=qg.define({name:"yaml",parser:Ife.configure({props:[X9.add({Stream:t=>{for(let e=t.node.resolve(t.pos,-1);e&&e.to>=t.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.from<e.to)return t.baseIndentFor(e);if(e.name=="BlockLiteral")return t.baseIndentFor(e)+t.unit;if(e.name=="BlockSequence"||e.name=="BlockMapping")return t.column(e.from,1);if(e.name=="QuotedLiteral")return null;if(e.name=="Literal"){let r=t.column(e.from,1);if(r==t.lineIndent(e.from,1))return r;if(e.to>t.pos)return null}}return null},FlowMapping:Nz({closing:"}"}),FlowSequence:Nz({closing:"]"})}),K9.add({"FlowMapping FlowSequence":yle,"Item Pair BlockLiteral":(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function jfe(){return new lle(qfe)}const Ffe=()=>{const{error:t,isCliMode:e,yamlInput:r,setYamlInput:n,parseAndSetSchema:i,savingStatus:a,lastUpdateSource:s,theme:l,currentModelSlug:o}=pt(),[c,h]=ve.useState(r),d=ve.useRef(null),g=ve.useRef(null),m=ve.useRef(!0);ve.useEffect(()=>{if(!g.current?.view)return;const w=g.current.view,S=w.state.doc.toString();w.dispatch({changes:{from:0,to:S.length,insert:r},annotations:Sr.addToHistory.of(!1)}),h(r)},[o]),ve.useEffect(()=>{if(!g.current?.view)return;const w=g.current.view,S=w.state.doc.toString();if(m.current&&r){w.dispatch({changes:{from:0,to:S.length,insert:r},annotations:Sr.addToHistory.of(!1)}),h(r),m.current=!1;return}s!=="user"&&S!==r&&(w.dispatch({changes:{from:0,to:S.length,insert:r},userEvent:"remote-edit"}),h(r))},[r,s]);const y=ve.useCallback(w=>{h(w),!(!w||w.trim()==="")&&(d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{n(w),i(w)},300))},[n,i]),b=()=>{g.current?.view&&KE(g.current.view)},x=()=>{g.current?.view&&Ug(g.current.view)};return A.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-hidden p-4 pt-2 h-full sidebar-content",children:[A.jsxs("div",{className:"flex items-center justify-between px-1",children:[e?A.jsxs("div",{className:"flex items-center gap-4",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-500 animate-pulse"}),A.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${l==="dark"?"text-slate-500":"text-slate-400"}`,children:"Auto-sync active"})]}),A.jsxs("div",{className:"flex items-center gap-1.5 min-w-[60px]",children:[a==="saving"&&A.jsxs("div",{className:"flex items-center gap-1 text-slate-400 animate-pulse",children:[A.jsx(Xre,{size:10,className:"animate-spin"}),A.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Saving"})]}),a==="saved"&&A.jsxs("div",{className:"flex items-center gap-1 text-emerald-500",children:[A.jsx(Rre,{size:10}),A.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",children:"Saved"})]}),a==="error"&&A.jsxs("div",{className:"flex items-center gap-1 text-red-500",children:[A.jsx(Qp,{size:10}),A.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Error"})]})]})]}):A.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 bg-blue-500/10 border border-blue-500/30 rounded-md",children:[A.jsx(Qp,{size:12,className:"text-blue-400"}),A.jsx("span",{className:"text-[10px] text-blue-300 font-medium uppercase tracking-tight",children:"Sandbox Mode"})]}),A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsxs("div",{className:`flex rounded-lg p-0.5 border ${l==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"}`,children:[A.jsx("button",{onClick:b,className:`p-1.5 rounded-md transition-all active:scale-95 ${l==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Undo (Ctrl+Z)",children:A.jsx(Sne,{size:14})}),A.jsx("div",{className:`w-px h-4 self-center mx-0.5 ${l==="dark"?"bg-slate-700/50":"bg-slate-200"}`}),A.jsx("button",{onClick:x,className:`p-1.5 rounded-md transition-all active:scale-95 ${l==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Redo (Ctrl+Y)",children:A.jsx(cne,{size:14})})]}),A.jsxs("div",{className:"flex items-center gap-1 text-slate-400 dark:text-slate-600 cursor-help",title:"Pro Tip: Use Ctrl+Z to undo visual changes!",children:[A.jsx(SE,{size:12}),A.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:"Undo Active"})]})]})]}),A.jsxs("div",{className:`relative flex-1 flex flex-col min-h-0 border rounded-md overflow-hidden transition-colors ${l==="dark"?"border-slate-700 bg-[#282c34]":"border-slate-200 bg-white"}`,children:[A.jsx(fH,{ref:g,value:c,height:"100%",theme:l==="dark"?cH:"light",extensions:[jfe()],onChange:y,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},className:"flex-1 text-sm overflow-auto"}),t&&c===r&&A.jsxs("div",{className:"absolute bottom-4 left-4 right-4 p-3 bg-red-900/90 border border-red-500/50 rounded-md text-red-100 text-xs flex gap-2 items-start z-10 shadow-2xl backdrop-blur-sm animate-in fade-in slide-in-from-bottom-2",children:[A.jsx(Qp,{size:14,className:"shrink-0 mt-0.5 text-red-400"}),A.jsx("span",{children:t})]})]}),A.jsx("div",{className:"flex justify-between items-center pt-1 shrink-0",children:A.jsx("div",{className:"text-[10px] text-slate-500 italic",children:e?"Changes are automatically reflected and saved to file.":"Changes are reflected instantly but reset on reload."})})]})},Hfe=()=>{const{availableFiles:t,currentModelSlug:e,setCurrentModel:r,isSidebarOpen:n,theme:i}=pt();if(!n||t.length<=0)return null;const a=e||t[0]?.slug;return A.jsxs("div",{className:"px-4 mb-4",children:[A.jsx("div",{className:"flex items-center justify-between mb-1.5 px-1",children:A.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Current Model"})}),A.jsxs("div",{className:"relative group",children:[A.jsx("select",{value:a,onChange:s=>r(s.target.value),className:`w-full pl-9 pr-8 py-2 rounded-md text-sm appearance-none focus:outline-none focus:ring-1 focus:ring-blue-500/50 transition-all shadow-sm cursor-pointer ${i==="dark"?"bg-slate-800 border-slate-700 text-slate-100 hover:bg-slate-750":"bg-white border-slate-200 text-slate-900 hover:bg-slate-50 shadow-slate-200/50"}`,children:t.map(s=>A.jsx("option",{value:s.slug,className:i==="light"?"bg-white text-slate-900":"bg-slate-800 text-slate-100",children:s.name},s.slug))}),A.jsx(Hl,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-blue-500 pointer-events-none"}),A.jsx(Ha,{size:14,className:`absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none transition-colors ${i==="dark"?"text-slate-500 group-hover:text-slate-300":"text-slate-400 group-hover:text-slate-600"}`})]})]})},Vfe=()=>{const{schema:t,bulkAddRelationship:e,theme:r}=pt(),[n,i]=ve.useState("er"),[a,s]=ve.useState(""),[l,o]=ve.useState(""),[c,h]=ve.useState("one-to-many"),[d,g]=ve.useState(!1),[m,y]=ve.useState(!1),[b,x]=ve.useState(0),[w,S]=ve.useState(!1),k=ve.useRef(null),E=ve.useRef(null),M=ve.useMemo(()=>{if(!t)return[];const D=[];return t.tables.forEach(_=>{D.push(_.id),n==="er"&&_.columns?.forEach(P=>{D.push(`${_.id}.${P.id}`)})}),D},[t,n]),R=ve.useMemo(()=>a?M.filter(D=>D.toLowerCase().includes(a.toLowerCase())).slice(0,8):[],[a,M]),O=ve.useMemo(()=>{const D=l.toLowerCase(),_=M.filter(P=>P.toLowerCase().includes(D));if(n==="er"&&D.includes(".")){const P=D.split(".")[1]||"";_.unshift(`*.${P}`)}return _.slice(0,8)},[l,M,n]);ve.useEffect(()=>{k.current?.focus()},[]);const N=()=>{if(!a||!l)return;const D=a.split("."),_=D[0],P=D[1];e({table:_,column:P},l,c),S(!0),setTimeout(()=>S(!1),1500),o(""),E.current?.focus()},B=(D,_)=>{D.stopPropagation();const P=_==="source"?R:O;D.key==="ArrowDown"?(D.preventDefault(),x(z=>(z+1)%(P.length||1))):D.key==="ArrowUp"?(D.preventDefault(),x(z=>(z-1+(P.length||1))%(P.length||1))):D.key==="Enter"&&(P[b]?_==="source"?(s(P[b]),g(!1),E.current?.focus()):(o(P[b]),y(!1)):_==="target"&&a&&l&&N())};return A.jsxs("div",{className:"flex-1 flex flex-col gap-6 p-4 overflow-auto sidebar-content",children:[A.jsxs("div",{className:"flex flex-col gap-4",children:[A.jsxs("section",{className:"relative",children:[A.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[A.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-slate-500",children:"Source"}),A.jsxs("div",{className:`flex rounded-full p-0.5 border ${r==="dark"?"bg-slate-950/50 border-slate-800":"bg-slate-100 border-slate-200"}`,children:[A.jsxs("button",{onClick:()=>{i("er"),h("one-to-many")},className:`px-2 py-0.5 rounded-full flex items-center gap-1 transition-all ${n==="er"?r==="dark"?"bg-slate-700 text-blue-400 shadow-sm":"bg-white text-blue-600 shadow-sm":"text-[9px] font-bold text-slate-500 hover:text-slate-400 uppercase tracking-tighter"}`,children:[A.jsx(Sk,{size:10}),A.jsx("span",{className:"text-[9px] font-black uppercase tracking-tighter",children:"ER"})]}),A.jsxs("button",{onClick:()=>{i("lineage"),h("lineage")},className:`px-2 py-0.5 rounded-full flex items-center gap-1 transition-all ${n==="lineage"?r==="dark"?"bg-slate-700 text-blue-400 shadow-sm":"bg-white text-blue-600 shadow-sm":"text-[9px] font-bold text-slate-500 hover:text-slate-400 uppercase tracking-tighter"}`,children:[A.jsx(wE,{size:10}),A.jsx("span",{className:"text-[9px] font-black uppercase tracking-tighter",children:"Flow"})]})]})]}),A.jsx("input",{ref:k,type:"text",placeholder:n==="er"?"table.column":"table_id",className:`w-full px-4 py-2.5 rounded-xl text-sm font-bold outline-none transition-all border-2 border-transparent ${r==="dark"?"bg-slate-800 text-white placeholder-slate-600 focus:border-blue-500/50":"bg-slate-50 text-slate-900 focus:border-blue-500/30"}`,value:a,onChange:D=>{s(D.target.value),g(!0),x(0)},onFocus:()=>g(!0),onBlur:()=>setTimeout(()=>g(!1),200),onKeyDown:D=>B(D,"source")}),d&&R.length>0&&A.jsx("div",{className:`absolute top-full left-0 right-0 mt-1 rounded-xl shadow-xl border-2 overflow-hidden z-[110] ${r==="dark"?"bg-slate-800 border-slate-700":"bg-white border-slate-200"}`,children:R.map((D,_)=>A.jsx("div",{className:`px-4 py-2 text-xs font-bold cursor-pointer ${b===_?"bg-blue-600 text-white":r==="dark"?"hover:bg-slate-700 text-slate-300":"hover:bg-slate-100 text-slate-600"}`,onMouseDown:()=>{s(D),E.current?.focus()},children:D},D))})]}),A.jsx("section",{className:"flex justify-center -my-2 relative z-10",children:A.jsxs("div",{className:`flex items-center gap-3 px-3 py-1 rounded-full border shadow-sm ${r==="dark"?"bg-slate-800 border-slate-700":"bg-white border-slate-100"}`,children:[n==="er"?A.jsxs("select",{className:"bg-transparent text-[10px] font-black uppercase tracking-widest outline-none cursor-pointer text-blue-500",value:c,onChange:D=>h(D.target.value),children:[A.jsx("option",{value:"one-to-many",children:"1 : N"}),A.jsx("option",{value:"one-to-one",children:"1 : 1"}),A.jsx("option",{value:"many-to-one",children:"N : 1"}),A.jsx("option",{value:"many-to-many",children:"N : N"})]}):A.jsx(Ha,{size:14,className:"text-blue-500 animate-pulse"}),A.jsx("div",{className:"w-px h-3 bg-slate-700/50"}),A.jsx(xre,{size:12,className:"text-slate-500"})]})}),A.jsxs("section",{className:"relative",children:[A.jsx("label",{className:"text-[9px] font-black uppercase tracking-widest text-slate-500 mb-1.5 block",children:"Target"}),A.jsx("input",{ref:E,type:"text",placeholder:n==="er"?"target.column or *.column":"target_table",className:`w-full px-4 py-2.5 rounded-xl text-sm font-bold outline-none transition-all border-2 border-transparent ${r==="dark"?"bg-slate-800 text-white placeholder-slate-600 focus:border-blue-500/50":"bg-slate-50 text-slate-900 focus:border-blue-500/30"}`,value:l,onChange:D=>{o(D.target.value),y(!0),x(0)},onFocus:()=>y(!0),onBlur:()=>setTimeout(()=>y(!1),200),onKeyDown:D=>B(D,"target")}),m&&O.length>0&&A.jsx("div",{className:`absolute top-full left-0 right-0 mt-1 rounded-xl shadow-xl border-2 overflow-hidden z-[110] ${r==="dark"?"bg-slate-800 border-slate-700":"bg-white border-slate-200"}`,children:O.map((D,_)=>A.jsx("div",{className:`px-4 py-2 text-xs font-bold cursor-pointer ${b===_?"bg-blue-600 text-white":r==="dark"?"hover:bg-slate-700 text-slate-300":"hover:bg-slate-100 text-slate-600"}`,onMouseDown:()=>{o(D)},children:A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("span",{children:D}),D.startsWith("*")&&A.jsx("span",{className:"px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 text-[8px] font-black uppercase",children:"Bulk"})]})},D))})]})]}),A.jsxs("div",{className:"mt-auto flex flex-col gap-3",children:[A.jsxs("button",{onClick:N,className:`w-full py-3 rounded-xl text-[10px] font-black uppercase tracking-[0.2em] shadow-lg transition-all active:scale-[0.98] flex items-center justify-center gap-2 group ${w?"bg-emerald-600 text-white":"bg-blue-600 hover:bg-blue-700 text-white"}`,children:[w?A.jsx(u6,{size:14}):A.jsx(CE,{size:14,className:"group-hover:animate-bounce"}),w?"Connected!":"Connect Objects"]}),A.jsxs("div",{className:"flex items-center justify-center gap-2 text-[9px] text-slate-500 font-bold uppercase tracking-tight text-center",children:[A.jsx(SE,{size:10,className:"text-blue-500 shrink-0"}),A.jsxs("span",{children:["Tip: Use ",A.jsx("kbd",{className:`px-1.5 py-0.5 rounded font-bold ${r==="dark"?"bg-slate-700 text-blue-400":"bg-slate-200 text-blue-700"}`,children:"*.id"})," for bulk linking"]})]})]})]})},bH=""+new URL("../favicon.svg",import.meta.url).href,Ufe=()=>{const{isSidebarOpen:t,setIsSidebarOpen:e,showAnnotations:r,setShowAnnotations:n,showER:i,setShowER:a,showLineage:s,setShowLineage:l,connectMode:o,setConnectMode:c,isCompactMode:h,setIsCompactMode:d,addTable:g,addDomain:m,addAnnotation:y,theme:b,getSelectedTable:x,getSelectedDomain:w}=pt(),[S,k]=ve.useState(!1),E=()=>{const z=window.__modscapeCy;if(!z)return{x:window.innerWidth/2,y:window.innerHeight/2};const H=z.pan(),$=z.zoom(),q=window.innerWidth/2,V=window.innerHeight/2;return{x:(q-H.x)/$,y:(V-H.y)/$}},M=x(),R=w(),O=()=>{const z=E();m(z.x-300,z.y-200)},N=()=>{const z=E();g(z.x-160,z.y-125)},B=()=>{const z=M||R,H=E();r||n(!0),z?y({x:50,y:-50},z.id,M?"table":"domain"):y({x:H.x-60,y:H.y-40})},D=(z,H="text-blue-500")=>`
|
|
427
427
|
flex items-center justify-center w-10 h-10 rounded-xl transition-all relative group
|
|
428
428
|
${z?`bg-blue-600/10 ${H} shadow-inner`:b==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800/30":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}
|
|
429
|
-
`,_=({text:z})=>A.jsxs("div",{className:"absolute left-14 px-2 py-1 bg-slate-800 text-white text-[10px] font-bold rounded opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-[60] border border-slate-700 shadow-xl",children:[z,A.jsx("div",{className:"absolute top-1/2 -left-1 -translate-y-1/2 border-4 border-transparent border-r-slate-800"})]}),P=({keys:z,label:H})=>A.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-slate-100 dark:border-slate-800 last:border-0",children:[A.jsx("span",{className:"text-xs font-medium text-slate-500",children:H}),A.jsx("div",{className:"flex gap-1",children:z.map($=>A.jsx("kbd",{className:"px-1.5 py-0.5 bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded text-[10px] font-bold font-mono text-slate-600 dark:text-slate-300 min-w-[20px] text-center shadow-sm",children:$},$))})]});return A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:`w-14 h-full flex flex-col items-center py-4 border-l transition-colors z-50 ${b==="dark"?"bg-slate-950 border-slate-800":"bg-slate-50 border-slate-200"}`,children:[A.jsx("button",{onClick:()=>e(!t),className:`mb-6 p-2 rounded-xl transition-all ${b==="dark"?"hover:bg-slate-800 text-slate-400 hover:text-white":"hover:bg-white hover:shadow-md text-slate-500 hover:text-slate-900"}`,children:t?A.jsx(c6,{size:20}):A.jsx("img",{src:bH,alt:"Logo",className:"w-6 h-6 rounded-md shadow-lg"})}),A.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[A.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"View"}),A.jsxs("div",{className:"flex flex-col gap-2",children:[A.jsxs("button",{onClick:()=>l(!s),className:D(s,"text-blue-400"),children:[A.jsx(C4,{size:20}),A.jsx(_,{text:s?"Hide Lineage Edges":"Show Lineage Edges"})]}),A.jsxs("button",{onClick:()=>a(!i),className:D(i,"text-slate-400"),children:[A.jsx(Sk,{size:20}),A.jsx(_,{text:i?"Hide ER Edges":"Show ER Edges"})]}),A.jsxs("button",{onClick:()=>n(!r),className:D(r,"text-amber-500"),children:[A.jsx(zu,{size:20}),A.jsx(_,{text:r?"Hide Annotations":"Show Annotations"})]}),A.jsxs("button",{onClick:()=>d(!h),className:D(h,"text-slate-400"),children:[A.jsx(bne,{size:20}),A.jsx(_,{text:h?"Show Columns":"Hide Columns"})]})]})]}),A.jsx("div",{className:`w-8 border-t mb-4 ${b==="dark"?"border-slate-800":"border-slate-200"}`}),A.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[A.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"Add"}),A.jsxs("div",{className:"flex flex-col gap-2",children:[A.jsxs("button",{onClick:O,className:D(!1,"text-blue-400"),children:[A.jsx(p6,{size:20}),A.jsx(_,{text:"Add Domain (D)"})]}),A.jsxs("button",{onClick:N,className:D(!1,"text-emerald-400"),children:[A.jsx(jre,{size:20}),A.jsx(_,{text:"Add Table (T)"})]}),A.jsxs("button",{onClick:B,className:D(!1,"text-amber-400"),children:[A.jsxs("div",{className:"relative",children:[A.jsx(zu,{size:20}),A.jsx(Gf,{size:10,className:"absolute -bottom-1 -right-1 text-amber-500 font-bold stroke-[3px]"})]}),A.jsx(_,{text:"Add Sticky Note (S)"})]}),A.jsxs("button",{onClick:()=>c(o==="lineage"?null:"lineage"),className:D(o==="lineage","text-blue-400"),children:[A.jsx(C4,{size:20}),A.jsx(_,{text:o==="lineage"?"Exit Lineage Mode (Esc)":"Draw Lineage Edge (C)"})]}),A.jsxs("button",{onClick:()=>c(o==="er"?null:"er"),className:D(o==="er","text-emerald-400"),children:[A.jsx(Sk,{size:20}),A.jsx(_,{text:o==="er"?"Exit ER Mode (Esc)":"Draw ER Edge"})]})]})]}),A.jsx("div",{className:`w-8 border-t mb-6 ${b==="dark"?"border-slate-800":"border-slate-200"}`}),A.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[A.jsxs("button",{onClick:()=>window.__modscapeAutoLayout?.(),className:D(!1,"text-orange-400"),children:[A.jsx(Ene,{size:20}),A.jsx(_,{text:"Auto Layout (left → right)"})]}),A.jsxs("button",{onClick:()=>k(!0),className:D(S),children:[A.jsx(f6,{size:20}),A.jsx(_,{text:"Shortcut Guide"})]})]})]}),S&&A.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 animate-in fade-in duration-200",children:[A.jsx("div",{className:"absolute inset-0 bg-slate-950/40 backdrop-blur-sm",onClick:()=>k(!1)}),A.jsxs("div",{className:`relative w-full max-w-sm shadow-2xl rounded-2xl border p-6 animate-in zoom-in-95 duration-200 ${b==="dark"?"bg-slate-900 border-slate-700":"bg-white border-slate-200"}`,children:[A.jsxs("div",{className:"flex items-center justify-between mb-6",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg",children:A.jsx(h6,{size:18,className:"text-blue-500"})}),A.jsx("h2",{className:"font-bold text-base",children:"Shortcut Guide"})]}),A.jsx("button",{onClick:()=>k(!1),className:"p-1 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-full transition-colors text-slate-400",children:A.jsx(Oh,{size:20})})]}),A.jsxs("div",{className:"space-y-6",children:[A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"General"}),A.jsx(P,{label:"Command Palette",keys:["Ctrl","K"]}),A.jsx(P,{label:"Quick Connect",keys:["L"]}),A.jsx(P,{label:"Find Entities",keys:["/"]}),A.jsx(P,{label:"Switch Theme",keys:["\\"]})]}),A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Quick Create"}),A.jsx(P,{label:"New Table",keys:["T"]}),A.jsx(P,{label:"New Domain",keys:["D"]}),A.jsx(P,{label:"New Sticky Note",keys:["S"]})]}),A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Canvas Control"}),A.jsx(P,{label:"Pan / Scroll",keys:["↑","↓","←","→"]}),A.jsx(P,{label:"Clear Selection",keys:["Esc"]}),A.jsx(P,{label:"Delete Selected",keys:["Del","⌫"]})]})]}),A.jsx("div",{className:"mt-8 pt-4 border-t border-slate-100 dark:border-slate-800 flex justify-center",children:A.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"Pro-tip: Focus the canvas to use shortcuts."})})]})]})]})},$fe=ve.memo(()=>{const{isSidebarOpen:t,isCliMode:e,theme:r,savingStatus:n,activeTab:i,setActiveTab:a}=pt(so(s=>({isSidebarOpen:s.isSidebarOpen,isCliMode:s.isCliMode,theme:s.theme,savingStatus:s.savingStatus,activeTab:s.activeTab,setActiveTab:s.setActiveTab})));return A.jsxs("div",{className:`relative h-full flex flex-row border-r transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[456px]":"w-14"} ${r==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[A.jsxs("div",{className:`flex-1 flex flex-col min-w-0 overflow-hidden transition-all duration-300 sidebar-content ${r==="dark"?"bg-slate-900":"bg-white"} ${t?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,style:{width:t?"400px":"0px"},children:[A.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${r==="dark"?"border-slate-800":"border-slate-100"}`,children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("img",{src:bH,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),A.jsx("h1",{className:`text-base font-bold tracking-tight ${r==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"}),e&&A.jsx("span",{className:"px-1.5 py-0.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-500 text-[10px] font-bold rounded uppercase ml-1 animate-pulse",title:"Connected & Syncing",children:"Live"})]}),n==="saving"&&A.jsx("span",{className:"text-[10px] text-slate-500 animate-pulse uppercase font-bold tracking-widest",children:"Saving..."})]}),A.jsx("div",{className:"mt-4",children:A.jsx(Hfe,{})}),A.jsx("div",{className:"px-4 mt-6",children:A.jsxs("div",{className:`flex p-1 rounded-xl ${r==="dark"?"bg-slate-800/50":"bg-slate-100"}`,children:[A.jsxs("button",{onClick:()=>a("editor"),className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${i==="editor"?r==="dark"?"bg-slate-700 text-blue-400 shadow-lg":"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-400"}`,children:[A.jsx(zre,{size:14}),"Editor"]}),A.jsxs("button",{onClick:()=>a("connect"),className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${i==="connect"?r==="dark"?"bg-slate-700 text-blue-400 shadow-lg":"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-400"}`,children:[A.jsx(CE,{size:14}),"Connect"]})]})}),A.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden mt-4",children:i==="connect"?A.jsx(Vfe,{}):A.jsx(Ffe,{})}),A.jsx("div",{className:`p-3 border-t flex items-center justify-between ${r==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:A.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v2.0.0"})})]}),A.jsx(Ufe,{})]})}),Gfe=ve.memo(()=>{const{schema:t,theme:e,setSelectedTableId:r,setFocusNodeId:n,isRightPanelOpen:i,activeRightPanelTab:a}=pt(so(y=>({schema:y.schema,theme:y.theme,setSelectedTableId:y.setSelectedTableId,setFocusNodeId:y.setFocusNodeId,isRightPanelOpen:y.isRightPanelOpen,activeRightPanelTab:y.activeRightPanelTab}))),[s,l]=ve.useState(""),[o,c]=ve.useState(new Set),h=ve.useRef(null);ve.useEffect(()=>{if(i&&a==="tables"){const y=setTimeout(()=>h.current?.focus(),300);return()=>clearTimeout(y)}},[i,a]);const d=y=>{const b=new Set(o);b.has(y)?b.delete(y):b.add(y),c(b)},g=y=>{r(y),n(y)},m=ve.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const y={},b=new Set;t.domains?.forEach(S=>{y[S.id]=[]}),t.tables.forEach(S=>{const k=t.domains?.find(M=>M.tables.includes(S.id));(S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase()))&&k&&(y[k.id].push(S),b.add(S.id))});const x=(t.domains||[]).filter(S=>{const k=y[S.id].length>0,E=S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase());return k||E&&s!==""}).map(S=>({...S,tables:y[S.id]})),w=t.tables.filter(S=>(S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase()))&&!b.has(S.id)&&!t.domains?.some(E=>E.tables.includes(S.id)));return{domains:x,unassigned:w}},[t,s]);return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"relative mb-4 shrink-0",children:[A.jsx(Tu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),A.jsx("input",{ref:h,type:"text",value:s,onChange:y=>l(y.target.value),placeholder:"Search tables...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),A.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[m.domains.map(y=>{const b=o.has(y.id);return A.jsxs("section",{className:"flex flex-col",children:[A.jsxs("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${e==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>d(y.id),children:[A.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[b?A.jsx(Eg,{size:12,className:"text-slate-500"}):A.jsx(Ha,{size:12,className:"text-slate-500"}),A.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:y.color||"#3b82f6"}}),A.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:y.name}),A.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${e==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:y.tables.length})]}),A.jsx("button",{onClick:x=>{x.stopPropagation(),g(y.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",children:A.jsx(Wp,{size:12})})]}),!b&&A.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:[y.tables.map(x=>A.jsxs("button",{onClick:()=>g(x.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${e==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[A.jsxs("span",{className:"flex flex-col min-w-0",children:[A.jsx("span",{className:"truncate",children:x.name}),x.name!==x.id&&A.jsx("span",{className:"truncate font-mono text-[9px] opacity-50",children:x.id})]}),A.jsx(Wp,{size:10,className:"opacity-0 group-hover:opacity-100 shrink-0"})]},x.id)),y.tables.length===0&&A.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables"})]})]},y.id)}),m.unassigned.length>0&&A.jsxs("section",{className:"flex flex-col",children:[A.jsx("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${e==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>d("unassigned"),children:A.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[o.has("unassigned")?A.jsx(Eg,{size:12,className:"text-slate-500"}):A.jsx(Ha,{size:12,className:"text-slate-500"}),A.jsx(f6,{size:12,className:"text-slate-500 shrink-0"}),A.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),A.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${e==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:m.unassigned.length})]})}),!o.has("unassigned")&&A.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:m.unassigned.map(y=>A.jsxs("button",{onClick:()=>g(y.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${e==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[A.jsxs("span",{className:"flex flex-col min-w-0",children:[A.jsx("span",{className:"truncate",children:y.name}),y.name!==y.id&&A.jsx("span",{className:"truncate font-mono text-[9px] opacity-50",children:y.id})]}),A.jsx(Wp,{size:10,className:"opacity-0 group-hover:opacity-100 shrink-0"})]},y.id))})]})]})]})}),Yfe=t=>{const e={},r=(n,i,a,s,l)=>{e[n]||(e[n]=[]),e[n].push({from:n,to:i,type:a,id:s,metadata:l}),e[i]||(e[i]=[]),e[i].push({from:i,to:n,type:a,id:s,metadata:l})};return t.relationships?.forEach((n,i)=>{r(n.from.table,n.to.table,"er",`er-${i}`,n)}),t.lineage?.forEach((n,i)=>{r(n.from,n.to,"lineage",`lin-${n.from}-${n.to}-${i}`,{direction:"upstream"})}),e},Xfe=(t,e,r)=>{if(e===r)return[];const n=Yfe(t),i=[e],a=new Set([e]),s={};for(;i.length>0;){const l=i.shift();if(l===r){const c=[];let h=r;for(;h!==e;){const d=s[h];c.unshift(d),h=d.from}return c}const o=n[l]||[];for(const c of o)a.has(c.to)||(a.add(c.to),s[c.to]={from:l,to:c.to,edge:c},i.push(c.to))}return null},Wfe=()=>{const{schema:t,theme:e,setPathFinderResult:r,setFocusNodeId:n}=pt(),[i,a]=ve.useState(""),[s,l]=ve.useState(""),[o,c]=ve.useState(null),[h,d]=ve.useState(!1),g=ve.useMemo(()=>t?.tables||[],[t]),m=()=>{if(!t||!i||!s)return;const b=Xfe(t,i,s);if(c(b),d(!0),b){const x=Array.from(new Set([i,...b.map(S=>S.to)])),w=b.map(S=>S.edge.id);r({nodeIds:x,edgeIds:w})}else r(null)},y=()=>{c(null),d(!1),r(null)};return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"space-y-4 mb-6",children:[A.jsxs("div",{children:[A.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"From Table"}),A.jsxs("select",{value:i,onChange:b=>a(b.target.value),className:`w-full p-2 rounded-md text-sm border shadow-sm focus:ring-1 focus:ring-blue-500/50 outline-none ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsx("option",{value:"",children:"Select source..."}),g.map(b=>A.jsx("option",{value:b.id,children:b.name},b.id))]})]}),A.jsxs("div",{children:[A.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"To Table"}),A.jsxs("select",{value:s,onChange:b=>l(b.target.value),className:`w-full p-2 rounded-md text-sm border shadow-sm focus:ring-1 focus:ring-blue-500/50 outline-none ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsx("option",{value:"",children:"Select target..."}),g.map(b=>A.jsx("option",{value:b.id,children:b.name},b.id))]})]}),A.jsxs("div",{className:"flex gap-2 pt-2",children:[A.jsxs("button",{onClick:m,disabled:!i||!s,className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-md text-xs font-bold transition-all ${!i||!s?"bg-slate-100 text-slate-400 cursor-not-allowed":"bg-blue-600 text-white hover:bg-blue-500 shadow-lg shadow-blue-500/20 active:scale-95"}`,children:[A.jsx(Tu,{size:14}),"FIND PATH"]}),h&&A.jsx("button",{onClick:y,className:`p-2 rounded-md border transition-all hover:bg-slate-100 dark:hover:bg-slate-800 ${e==="dark"?"border-slate-700 text-slate-400":"border-slate-200 text-slate-500"}`,title:"Clear search results",children:A.jsx(Oh,{size:14})})]})]}),A.jsxs("div",{className:"flex-1 overflow-auto pr-1",children:[h&&!o&&A.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[A.jsx(Qp,{size:32,className:"text-slate-300 mb-2"}),A.jsx("p",{className:"text-sm text-slate-500 italic",children:"No path found between these tables."})]}),o&&A.jsxs("div",{className:"space-y-1",children:[A.jsx("div",{className:`p-3 rounded-lg border border-l-4 border-l-blue-500 mb-4 ${e==="dark"?"bg-slate-800/30 border-slate-700":"bg-blue-50/50 border-blue-100"}`,children:A.jsxs("p",{className:"text-xs font-medium text-slate-500",children:["Path found with ",A.jsx("span",{className:"font-bold text-blue-500",children:o.length})," steps"]})}),A.jsxs("div",{className:"relative pl-4 space-y-0",children:[A.jsx("div",{className:"absolute left-1 top-2 bottom-2 w-0.5 bg-slate-200 dark:bg-slate-800"}),A.jsxs("div",{className:"relative mb-4",children:[A.jsx("div",{className:"absolute -left-[15px] top-1 w-2.5 h-2.5 rounded-full bg-blue-500 border-2 border-white dark:border-slate-900"}),A.jsx("button",{onClick:()=>n(i),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(b=>b.id===i)?.name})]}),o.map((b,x)=>A.jsxs("div",{className:"mb-4",children:[A.jsxs("div",{className:`flex items-center gap-2 my-2 py-1 px-2 rounded border w-fit transition-colors ${e==="dark"?"bg-slate-800/50 border-slate-700 text-slate-400":b.edge.type==="er"?"bg-emerald-50 border-emerald-100 text-emerald-700":"bg-blue-50 border-blue-100 text-blue-700"}`,children:[b.edge.type==="er"?A.jsx(Hl,{size:10,className:e==="dark"?"text-emerald-500":"text-emerald-600"}):A.jsx(wE,{size:10,className:e==="dark"?"text-blue-400":"text-blue-600"}),A.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:b.edge.type==="er"?`ER (${b.edge.metadata.type})`:"Lineage"})]}),A.jsxs("div",{className:"relative",children:[A.jsx("div",{className:"absolute -left-[15px] top-1 w-2.5 h-2.5 rounded-full bg-slate-400 border-2 border-white dark:border-slate-900"}),A.jsx("button",{onClick:()=>n(b.to),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(w=>w.id===b.to)?.name})]})]},x))]})]})]})]})},Qfe=()=>{const{schema:t,theme:e,setSelectedAnnotationId:r,setFocusNodeId:n}=pt(),[i,a]=ve.useState(""),s=ve.useMemo(()=>t?.annotations?t.annotations.filter(o=>o.text.toLowerCase().includes(i.toLowerCase())):[],[t,i]),l=o=>{r(o),n(o)};return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"relative mb-4 shrink-0",children:[A.jsx(Tu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),A.jsx("input",{type:"text",value:i,onChange:o=>a(o.target.value),placeholder:"Search notes...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),A.jsxs("div",{className:"flex-1 space-y-2 overflow-auto pr-1",children:[s.length===0&&i&&A.jsxs("div",{className:"text-center py-10 text-slate-500 italic text-sm",children:['No notes matching "',i,'"']}),s.map(o=>A.jsxs("button",{onClick:()=>l(o.id),className:`w-full p-3 text-left rounded-lg border transition-all group relative ${e==="dark"?"bg-slate-800/40 border-slate-700 hover:border-blue-500/50 hover:bg-slate-800/60":"bg-white border-slate-200 hover:border-blue-300 hover:bg-blue-50/30 shadow-sm"}`,children:[A.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[A.jsx(zu,{size:12,className:o.type==="callout"?"text-blue-400":"text-amber-400"}),A.jsx("span",{className:"text-[10px] font-bold uppercase tracking-tighter text-slate-500",children:o.type==="callout"?"Callout":"Sticky Note"}),A.jsx(Wp,{size:12,className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity text-blue-500"})]}),A.jsx("p",{className:`text-xs line-clamp-3 leading-relaxed ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:o.text}),o.targetId&&A.jsxs("div",{className:"mt-2 flex items-center gap-1.5 opacity-60",children:[A.jsx("div",{className:"w-1 h-1 rounded-full bg-slate-400"}),A.jsxs("span",{className:"text-[9px] font-medium truncate italic",children:["Attached to ",o.targetId]})]})]},o.id)),!i&&s.length===0&&A.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[A.jsx(d6,{size:48,className:"mb-4 text-slate-400"}),A.jsx("p",{className:"text-sm font-medium",children:"No annotations in this model yet."})]})]})]})},Kfe=ve.memo(()=>{const{isRightPanelOpen:t,setIsRightPanelOpen:e,activeRightPanelTab:r,setActiveRightPanelTab:n,theme:i,isPresentationMode:a,setIsPresentationMode:s,toggleTheme:l}=pt(so(h=>({isRightPanelOpen:h.isRightPanelOpen,setIsRightPanelOpen:h.setIsRightPanelOpen,activeRightPanelTab:h.activeRightPanelTab,setActiveRightPanelTab:h.setActiveRightPanelTab,theme:h.theme,isPresentationMode:h.isPresentationMode,setIsPresentationMode:h.setIsPresentationMode,toggleTheme:h.toggleTheme}))),o=h=>`
|
|
429
|
+
`,_=({text:z})=>A.jsxs("div",{className:"absolute left-14 px-2 py-1 bg-slate-800 text-white text-[10px] font-bold rounded opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-[60] border border-slate-700 shadow-xl",children:[z,A.jsx("div",{className:"absolute top-1/2 -left-1 -translate-y-1/2 border-4 border-transparent border-r-slate-800"})]}),P=({keys:z,label:H})=>A.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-slate-100 dark:border-slate-800 last:border-0",children:[A.jsx("span",{className:"text-xs font-medium text-slate-500",children:H}),A.jsx("div",{className:"flex gap-1",children:z.map($=>A.jsx("kbd",{className:"px-1.5 py-0.5 bg-slate-100 dark:bg-slate-800 border border-slate-200 dark:border-slate-700 rounded text-[10px] font-bold font-mono text-slate-600 dark:text-slate-300 min-w-[20px] text-center shadow-sm",children:$},$))})]});return A.jsxs(A.Fragment,{children:[A.jsxs("div",{className:`w-14 h-full flex flex-col items-center py-4 border-l transition-colors z-50 ${b==="dark"?"bg-slate-950 border-slate-800":"bg-slate-50 border-slate-200"}`,children:[A.jsx("button",{onClick:()=>e(!t),className:`mb-6 p-2 rounded-xl transition-all ${b==="dark"?"hover:bg-slate-800 text-slate-400 hover:text-white":"hover:bg-white hover:shadow-md text-slate-500 hover:text-slate-900"}`,children:t?A.jsx(c6,{size:20}):A.jsx("img",{src:bH,alt:"Logo",className:"w-6 h-6 rounded-md shadow-lg"})}),A.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[A.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"View"}),A.jsxs("div",{className:"flex flex-col gap-2",children:[A.jsxs("button",{onClick:()=>l(!s),className:D(s,"text-blue-400"),children:[A.jsx(C4,{size:20}),A.jsx(_,{text:s?"Hide Lineage Edges":"Show Lineage Edges"})]}),A.jsxs("button",{onClick:()=>a(!i),className:D(i,"text-slate-400"),children:[A.jsx(Sk,{size:20}),A.jsx(_,{text:i?"Hide ER Edges":"Show ER Edges"})]}),A.jsxs("button",{onClick:()=>n(!r),className:D(r,"text-amber-500"),children:[A.jsx(zu,{size:20}),A.jsx(_,{text:r?"Hide Annotations":"Show Annotations"})]}),A.jsxs("button",{onClick:()=>d(!h),className:D(h,"text-slate-400"),children:[A.jsx(bne,{size:20}),A.jsx(_,{text:h?"Show Columns":"Hide Columns"})]})]})]}),A.jsx("div",{className:`w-8 border-t mb-4 ${b==="dark"?"border-slate-800":"border-slate-200"}`}),A.jsxs("div",{className:"flex flex-col items-center mb-4 gap-2",children:[A.jsx("div",{className:"text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80 mb-1",children:"Add"}),A.jsxs("div",{className:"flex flex-col gap-2",children:[A.jsxs("button",{onClick:O,className:D(!1,"text-blue-400"),children:[A.jsx(p6,{size:20}),A.jsx(_,{text:"Add Domain (D)"})]}),A.jsxs("button",{onClick:N,className:D(!1,"text-emerald-400"),children:[A.jsx(jre,{size:20}),A.jsx(_,{text:"Add Table (T)"})]}),A.jsxs("button",{onClick:B,className:D(!1,"text-amber-400"),children:[A.jsxs("div",{className:"relative",children:[A.jsx(zu,{size:20}),A.jsx(Gf,{size:10,className:"absolute -bottom-1 -right-1 text-amber-500 font-bold stroke-[3px]"})]}),A.jsx(_,{text:"Add Sticky Note (S)"})]}),A.jsxs("button",{onClick:()=>c(o==="lineage"?null:"lineage"),className:D(o==="lineage","text-blue-400"),children:[A.jsx(C4,{size:20}),A.jsx(_,{text:o==="lineage"?"Exit Lineage Mode (Esc)":"Draw Lineage Edge (C)"})]}),A.jsxs("button",{onClick:()=>c(o==="er"?null:"er"),className:D(o==="er","text-emerald-400"),children:[A.jsx(Sk,{size:20}),A.jsx(_,{text:o==="er"?"Exit ER Mode (Esc)":"Draw ER Edge"})]})]})]}),A.jsx("div",{className:`w-8 border-t mb-6 ${b==="dark"?"border-slate-800":"border-slate-200"}`}),A.jsxs("div",{className:"mt-auto flex flex-col gap-2",children:[A.jsxs("button",{onClick:()=>window.__modscapeAutoLayout?.(),className:D(!1,"text-orange-400"),children:[A.jsx(Ene,{size:20}),A.jsx(_,{text:"Auto Layout (left → right)"})]}),A.jsxs("button",{onClick:()=>k(!0),className:D(S),children:[A.jsx(f6,{size:20}),A.jsx(_,{text:"Shortcut Guide"})]})]})]}),S&&A.jsxs("div",{className:"fixed inset-0 z-[200] flex items-center justify-center p-4 animate-in fade-in duration-200",children:[A.jsx("div",{className:"absolute inset-0 bg-slate-950/40 backdrop-blur-sm",onClick:()=>k(!1)}),A.jsxs("div",{className:`relative w-full max-w-sm shadow-2xl rounded-2xl border p-6 animate-in zoom-in-95 duration-200 ${b==="dark"?"bg-slate-900 border-slate-700":"bg-white border-slate-200"}`,children:[A.jsxs("div",{className:"flex items-center justify-between mb-6",children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg",children:A.jsx(h6,{size:18,className:"text-blue-500"})}),A.jsx("h2",{className:"font-bold text-base",children:"Shortcut Guide"})]}),A.jsx("button",{onClick:()=>k(!1),className:"p-1 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-full transition-colors text-slate-400",children:A.jsx(Oh,{size:20})})]}),A.jsxs("div",{className:"space-y-6",children:[A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"General"}),A.jsx(P,{label:"Command Palette",keys:["Ctrl","K"]}),A.jsx(P,{label:"Quick Connect",keys:["L"]}),A.jsx(P,{label:"Find Entities",keys:["/"]}),A.jsx(P,{label:"Switch Theme",keys:["\\"]})]}),A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Quick Create"}),A.jsx(P,{label:"New Table",keys:["T"]}),A.jsx(P,{label:"New Domain",keys:["D"]}),A.jsx(P,{label:"New Sticky Note",keys:["S"]})]}),A.jsxs("section",{children:[A.jsx("h3",{className:"text-[10px] font-black uppercase tracking-widest text-slate-400 mb-3",children:"Canvas Control"}),A.jsx(P,{label:"Pan / Scroll",keys:["↑","↓","←","→"]}),A.jsx(P,{label:"Clear Selection",keys:["Esc"]}),A.jsx(P,{label:"Delete Selected",keys:["Del","⌫"]})]})]}),A.jsx("div",{className:"mt-8 pt-4 border-t border-slate-100 dark:border-slate-800 flex justify-center",children:A.jsx("p",{className:"text-[10px] text-slate-400 italic",children:"Pro-tip: Focus the canvas to use shortcuts."})})]})]})]})},$fe=ve.memo(()=>{const{isSidebarOpen:t,isCliMode:e,theme:r,savingStatus:n,activeTab:i,setActiveTab:a}=pt(so(s=>({isSidebarOpen:s.isSidebarOpen,isCliMode:s.isCliMode,theme:s.theme,savingStatus:s.savingStatus,activeTab:s.activeTab,setActiveTab:s.setActiveTab})));return A.jsxs("div",{className:`relative h-full flex flex-row border-r transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[456px]":"w-14"} ${r==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[A.jsxs("div",{className:`flex-1 flex flex-col min-w-0 overflow-hidden transition-all duration-300 sidebar-content ${r==="dark"?"bg-slate-900":"bg-white"} ${t?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,style:{width:t?"400px":"0px"},children:[A.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${r==="dark"?"border-slate-800":"border-slate-100"}`,children:[A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("img",{src:bH,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),A.jsx("h1",{className:`text-base font-bold tracking-tight ${r==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"}),e&&A.jsx("span",{className:"px-1.5 py-0.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-500 text-[10px] font-bold rounded uppercase ml-1 animate-pulse",title:"Connected & Syncing",children:"Live"})]}),n==="saving"&&A.jsx("span",{className:"text-[10px] text-slate-500 animate-pulse uppercase font-bold tracking-widest",children:"Saving..."})]}),A.jsx("div",{className:"mt-4",children:A.jsx(Hfe,{})}),A.jsx("div",{className:"px-4 mt-6",children:A.jsxs("div",{className:`flex p-1 rounded-xl ${r==="dark"?"bg-slate-800/50":"bg-slate-100"}`,children:[A.jsxs("button",{onClick:()=>a("editor"),className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${i==="editor"?r==="dark"?"bg-slate-700 text-blue-400 shadow-lg":"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-400"}`,children:[A.jsx(zre,{size:14}),"Editor"]}),A.jsxs("button",{onClick:()=>a("connect"),className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-lg text-[10px] font-black uppercase tracking-widest transition-all ${i==="connect"?r==="dark"?"bg-slate-700 text-blue-400 shadow-lg":"bg-white text-blue-600 shadow-sm":"text-slate-500 hover:text-slate-400"}`,children:[A.jsx(CE,{size:14}),"Connect"]})]})}),A.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden mt-4",children:i==="connect"?A.jsx(Vfe,{}):A.jsx(Ffe,{})}),A.jsx("div",{className:`p-3 border-t flex items-center justify-between ${r==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:A.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v2.0.1"})})]}),A.jsx(Ufe,{})]})}),Gfe=ve.memo(()=>{const{schema:t,theme:e,setSelectedTableId:r,setFocusNodeId:n,isRightPanelOpen:i,activeRightPanelTab:a}=pt(so(y=>({schema:y.schema,theme:y.theme,setSelectedTableId:y.setSelectedTableId,setFocusNodeId:y.setFocusNodeId,isRightPanelOpen:y.isRightPanelOpen,activeRightPanelTab:y.activeRightPanelTab}))),[s,l]=ve.useState(""),[o,c]=ve.useState(new Set),h=ve.useRef(null);ve.useEffect(()=>{if(i&&a==="tables"){const y=setTimeout(()=>h.current?.focus(),300);return()=>clearTimeout(y)}},[i,a]);const d=y=>{const b=new Set(o);b.has(y)?b.delete(y):b.add(y),c(b)},g=y=>{r(y),n(y)},m=ve.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const y={},b=new Set;t.domains?.forEach(S=>{y[S.id]=[]}),t.tables.forEach(S=>{const k=t.domains?.find(M=>M.tables.includes(S.id));(S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase()))&&k&&(y[k.id].push(S),b.add(S.id))});const x=(t.domains||[]).filter(S=>{const k=y[S.id].length>0,E=S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase());return k||E&&s!==""}).map(S=>({...S,tables:y[S.id]})),w=t.tables.filter(S=>(S.name.toLowerCase().includes(s.toLowerCase())||S.id.toLowerCase().includes(s.toLowerCase()))&&!b.has(S.id)&&!t.domains?.some(E=>E.tables.includes(S.id)));return{domains:x,unassigned:w}},[t,s]);return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"relative mb-4 shrink-0",children:[A.jsx(Tu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),A.jsx("input",{ref:h,type:"text",value:s,onChange:y=>l(y.target.value),placeholder:"Search tables...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),A.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[m.domains.map(y=>{const b=o.has(y.id);return A.jsxs("section",{className:"flex flex-col",children:[A.jsxs("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${e==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>d(y.id),children:[A.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[b?A.jsx(Eg,{size:12,className:"text-slate-500"}):A.jsx(Ha,{size:12,className:"text-slate-500"}),A.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:y.color||"#3b82f6"}}),A.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:y.name}),A.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${e==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:y.tables.length})]}),A.jsx("button",{onClick:x=>{x.stopPropagation(),g(y.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",children:A.jsx(Wp,{size:12})})]}),!b&&A.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:[y.tables.map(x=>A.jsxs("button",{onClick:()=>g(x.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${e==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[A.jsxs("span",{className:"flex flex-col min-w-0",children:[A.jsx("span",{className:"truncate",children:x.name}),x.name!==x.id&&A.jsx("span",{className:"truncate font-mono text-[9px] opacity-50",children:x.id})]}),A.jsx(Wp,{size:10,className:"opacity-0 group-hover:opacity-100 shrink-0"})]},x.id)),y.tables.length===0&&A.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables"})]})]},y.id)}),m.unassigned.length>0&&A.jsxs("section",{className:"flex flex-col",children:[A.jsx("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${e==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>d("unassigned"),children:A.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[o.has("unassigned")?A.jsx(Eg,{size:12,className:"text-slate-500"}):A.jsx(Ha,{size:12,className:"text-slate-500"}),A.jsx(f6,{size:12,className:"text-slate-500 shrink-0"}),A.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${e==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),A.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${e==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:m.unassigned.length})]})}),!o.has("unassigned")&&A.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${e==="dark"?"border-slate-800":"border-slate-100"}`,children:m.unassigned.map(y=>A.jsxs("button",{onClick:()=>g(y.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${e==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[A.jsxs("span",{className:"flex flex-col min-w-0",children:[A.jsx("span",{className:"truncate",children:y.name}),y.name!==y.id&&A.jsx("span",{className:"truncate font-mono text-[9px] opacity-50",children:y.id})]}),A.jsx(Wp,{size:10,className:"opacity-0 group-hover:opacity-100 shrink-0"})]},y.id))})]})]})]})}),Yfe=t=>{const e={},r=(n,i,a,s,l)=>{e[n]||(e[n]=[]),e[n].push({from:n,to:i,type:a,id:s,metadata:l}),e[i]||(e[i]=[]),e[i].push({from:i,to:n,type:a,id:s,metadata:l})};return t.relationships?.forEach((n,i)=>{r(n.from.table,n.to.table,"er",`er-${i}`,n)}),t.lineage?.forEach((n,i)=>{r(n.from,n.to,"lineage",`lin-${n.from}-${n.to}-${i}`,{direction:"upstream"})}),e},Xfe=(t,e,r)=>{if(e===r)return[];const n=Yfe(t),i=[e],a=new Set([e]),s={};for(;i.length>0;){const l=i.shift();if(l===r){const c=[];let h=r;for(;h!==e;){const d=s[h];c.unshift(d),h=d.from}return c}const o=n[l]||[];for(const c of o)a.has(c.to)||(a.add(c.to),s[c.to]={from:l,to:c.to,edge:c},i.push(c.to))}return null},Wfe=()=>{const{schema:t,theme:e,setPathFinderResult:r,setFocusNodeId:n}=pt(),[i,a]=ve.useState(""),[s,l]=ve.useState(""),[o,c]=ve.useState(null),[h,d]=ve.useState(!1),g=ve.useMemo(()=>t?.tables||[],[t]),m=()=>{if(!t||!i||!s)return;const b=Xfe(t,i,s);if(c(b),d(!0),b){const x=Array.from(new Set([i,...b.map(S=>S.to)])),w=b.map(S=>S.edge.id);r({nodeIds:x,edgeIds:w})}else r(null)},y=()=>{c(null),d(!1),r(null)};return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"space-y-4 mb-6",children:[A.jsxs("div",{children:[A.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"From Table"}),A.jsxs("select",{value:i,onChange:b=>a(b.target.value),className:`w-full p-2 rounded-md text-sm border shadow-sm focus:ring-1 focus:ring-blue-500/50 outline-none ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsx("option",{value:"",children:"Select source..."}),g.map(b=>A.jsx("option",{value:b.id,children:b.name},b.id))]})]}),A.jsxs("div",{children:[A.jsx("label",{className:"text-[10px] font-bold text-slate-500 uppercase tracking-widest block mb-1.5",children:"To Table"}),A.jsxs("select",{value:s,onChange:b=>l(b.target.value),className:`w-full p-2 rounded-md text-sm border shadow-sm focus:ring-1 focus:ring-blue-500/50 outline-none ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsx("option",{value:"",children:"Select target..."}),g.map(b=>A.jsx("option",{value:b.id,children:b.name},b.id))]})]}),A.jsxs("div",{className:"flex gap-2 pt-2",children:[A.jsxs("button",{onClick:m,disabled:!i||!s,className:`flex-1 flex items-center justify-center gap-2 py-2 rounded-md text-xs font-bold transition-all ${!i||!s?"bg-slate-100 text-slate-400 cursor-not-allowed":"bg-blue-600 text-white hover:bg-blue-500 shadow-lg shadow-blue-500/20 active:scale-95"}`,children:[A.jsx(Tu,{size:14}),"FIND PATH"]}),h&&A.jsx("button",{onClick:y,className:`p-2 rounded-md border transition-all hover:bg-slate-100 dark:hover:bg-slate-800 ${e==="dark"?"border-slate-700 text-slate-400":"border-slate-200 text-slate-500"}`,title:"Clear search results",children:A.jsx(Oh,{size:14})})]})]}),A.jsxs("div",{className:"flex-1 overflow-auto pr-1",children:[h&&!o&&A.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[A.jsx(Qp,{size:32,className:"text-slate-300 mb-2"}),A.jsx("p",{className:"text-sm text-slate-500 italic",children:"No path found between these tables."})]}),o&&A.jsxs("div",{className:"space-y-1",children:[A.jsx("div",{className:`p-3 rounded-lg border border-l-4 border-l-blue-500 mb-4 ${e==="dark"?"bg-slate-800/30 border-slate-700":"bg-blue-50/50 border-blue-100"}`,children:A.jsxs("p",{className:"text-xs font-medium text-slate-500",children:["Path found with ",A.jsx("span",{className:"font-bold text-blue-500",children:o.length})," steps"]})}),A.jsxs("div",{className:"relative pl-4 space-y-0",children:[A.jsx("div",{className:"absolute left-1 top-2 bottom-2 w-0.5 bg-slate-200 dark:bg-slate-800"}),A.jsxs("div",{className:"relative mb-4",children:[A.jsx("div",{className:"absolute -left-[15px] top-1 w-2.5 h-2.5 rounded-full bg-blue-500 border-2 border-white dark:border-slate-900"}),A.jsx("button",{onClick:()=>n(i),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(b=>b.id===i)?.name})]}),o.map((b,x)=>A.jsxs("div",{className:"mb-4",children:[A.jsxs("div",{className:`flex items-center gap-2 my-2 py-1 px-2 rounded border w-fit transition-colors ${e==="dark"?"bg-slate-800/50 border-slate-700 text-slate-400":b.edge.type==="er"?"bg-emerald-50 border-emerald-100 text-emerald-700":"bg-blue-50 border-blue-100 text-blue-700"}`,children:[b.edge.type==="er"?A.jsx(Hl,{size:10,className:e==="dark"?"text-emerald-500":"text-emerald-600"}):A.jsx(wE,{size:10,className:e==="dark"?"text-blue-400":"text-blue-600"}),A.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:b.edge.type==="er"?`ER (${b.edge.metadata.type})`:"Lineage"})]}),A.jsxs("div",{className:"relative",children:[A.jsx("div",{className:"absolute -left-[15px] top-1 w-2.5 h-2.5 rounded-full bg-slate-400 border-2 border-white dark:border-slate-900"}),A.jsx("button",{onClick:()=>n(b.to),className:"text-xs font-bold hover:text-blue-500 transition-colors",children:g.find(w=>w.id===b.to)?.name})]})]},x))]})]})]})]})},Qfe=()=>{const{schema:t,theme:e,setSelectedAnnotationId:r,setFocusNodeId:n}=pt(),[i,a]=ve.useState(""),s=ve.useMemo(()=>t?.annotations?t.annotations.filter(o=>o.text.toLowerCase().includes(i.toLowerCase())):[],[t,i]),l=o=>{r(o),n(o)};return A.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[A.jsxs("div",{className:"relative mb-4 shrink-0",children:[A.jsx(Tu,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),A.jsx("input",{type:"text",value:i,onChange:o=>a(o.target.value),placeholder:"Search notes...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${e==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),A.jsxs("div",{className:"flex-1 space-y-2 overflow-auto pr-1",children:[s.length===0&&i&&A.jsxs("div",{className:"text-center py-10 text-slate-500 italic text-sm",children:['No notes matching "',i,'"']}),s.map(o=>A.jsxs("button",{onClick:()=>l(o.id),className:`w-full p-3 text-left rounded-lg border transition-all group relative ${e==="dark"?"bg-slate-800/40 border-slate-700 hover:border-blue-500/50 hover:bg-slate-800/60":"bg-white border-slate-200 hover:border-blue-300 hover:bg-blue-50/30 shadow-sm"}`,children:[A.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[A.jsx(zu,{size:12,className:o.type==="callout"?"text-blue-400":"text-amber-400"}),A.jsx("span",{className:"text-[10px] font-bold uppercase tracking-tighter text-slate-500",children:o.type==="callout"?"Callout":"Sticky Note"}),A.jsx(Wp,{size:12,className:"ml-auto opacity-0 group-hover:opacity-100 transition-opacity text-blue-500"})]}),A.jsx("p",{className:`text-xs line-clamp-3 leading-relaxed ${e==="dark"?"text-slate-300":"text-slate-600"}`,children:o.text}),o.targetId&&A.jsxs("div",{className:"mt-2 flex items-center gap-1.5 opacity-60",children:[A.jsx("div",{className:"w-1 h-1 rounded-full bg-slate-400"}),A.jsxs("span",{className:"text-[9px] font-medium truncate italic",children:["Attached to ",o.targetId]})]})]},o.id)),!i&&s.length===0&&A.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center opacity-40",children:[A.jsx(d6,{size:48,className:"mb-4 text-slate-400"}),A.jsx("p",{className:"text-sm font-medium",children:"No annotations in this model yet."})]})]})]})},Kfe=ve.memo(()=>{const{isRightPanelOpen:t,setIsRightPanelOpen:e,activeRightPanelTab:r,setActiveRightPanelTab:n,theme:i,isPresentationMode:a,setIsPresentationMode:s,toggleTheme:l}=pt(so(h=>({isRightPanelOpen:h.isRightPanelOpen,setIsRightPanelOpen:h.setIsRightPanelOpen,activeRightPanelTab:h.activeRightPanelTab,setActiveRightPanelTab:h.setActiveRightPanelTab,theme:h.theme,isPresentationMode:h.isPresentationMode,setIsPresentationMode:h.setIsPresentationMode,toggleTheme:h.toggleTheme}))),o=h=>`
|
|
430
430
|
flex items-center justify-center w-10 h-10 rounded-xl transition-all relative group
|
|
431
431
|
${h?"bg-blue-600/10 text-blue-500 shadow-inner":i==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800/30":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}
|
|
432
432
|
`,c=({text:h})=>A.jsxs("div",{className:"absolute right-14 px-2 py-1 bg-slate-800 text-white text-[10px] font-bold rounded opacity-0 group-hover:opacity-100 pointer-events-none transition-opacity whitespace-nowrap z-[60] border border-slate-700 shadow-xl",children:[h,A.jsx("div",{className:"absolute top-1/2 -right-1 -translate-y-1/2 border-4 border-transparent border-l-slate-800"})]});return A.jsxs("div",{className:`relative h-full flex flex-row transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[456px]":"w-14"}`,children:[A.jsxs("div",{className:`w-14 h-full flex flex-col items-center py-4 border-l transition-colors z-50 ${i==="dark"?"bg-slate-950 border-slate-800":"bg-slate-50 border-slate-200"}`,children:[A.jsx("button",{onClick:()=>e(!t),className:`mb-6 p-2 rounded-xl transition-all ${i==="dark"?"hover:bg-slate-800 text-slate-400 hover:text-white":"hover:bg-white hover:shadow-md text-slate-500 hover:text-slate-900"}`,children:t?A.jsx(Eg,{size:20}):A.jsx(c6,{size:20})}),A.jsxs("div",{className:"flex flex-col gap-2 mb-6",children:[A.jsxs("button",{onClick:()=>{n("tables"),e(!0)},className:o(r==="tables"&&t),children:[A.jsx(Gre,{size:20}),A.jsx(c,{text:"Tables & Entities"})]}),A.jsxs("button",{onClick:()=>{n("path"),e(!0)},className:o(r==="path"&&t),children:[A.jsx(hne,{size:20}),A.jsx(c,{text:"Path Finder"})]}),A.jsxs("button",{onClick:()=>{n("notes"),e(!0)},className:o(r==="notes"&&t),children:[A.jsx(d6,{size:20}),A.jsx(c,{text:"Note Search"})]})]}),A.jsxs("div",{className:"mt-auto flex flex-col gap-2 pb-2",children:[A.jsxs("button",{onClick:()=>s(!0),className:o(a),children:[A.jsx(lne,{size:20}),A.jsx(c,{text:"Presentation Mode"})]}),A.jsxs("button",{onClick:l,className:o(!1),children:[i==="dark"?A.jsx(Ck,{size:20}):A.jsx(Jre,{size:20}),A.jsx(c,{text:i==="dark"?"Light Mode":"Dark Mode"})]})]})]}),A.jsxs("div",{className:`flex-1 flex flex-col min-w-0 overflow-hidden transition-all duration-300 sidebar-content ${i==="dark"?"bg-slate-900":"bg-white"} ${t?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,style:{width:t?"400px":"0px"},children:[A.jsx("div",{className:`p-4 border-b flex items-center justify-between ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:A.jsxs("h2",{className:`text-sm font-bold tracking-tight uppercase ${i==="dark"?"text-white":"text-slate-900"}`,children:[r==="tables"&&"Tables",r==="path"&&"Path Finder",r==="notes"&&"Note Search"]})}),r==="tables"&&A.jsx(Gfe,{}),r==="path"&&A.jsx(Wfe,{}),r==="notes"&&A.jsx(Qfe,{})]})]})}),Zfe=ve.memo(()=>{const{schema:t,isCommandPaletteOpen:e,setIsCommandPaletteOpen:r,executePipeline:n,setHighlightedNodeIds:i,setFocusNodeId:a,theme:s}=pt(so(E=>({schema:E.schema,isCommandPaletteOpen:E.isCommandPaletteOpen,setIsCommandPaletteOpen:E.setIsCommandPaletteOpen,executePipeline:E.executePipeline,setHighlightedNodeIds:E.setHighlightedNodeIds,setFocusNodeId:E.setFocusNodeId,theme:E.theme}))),[l,o]=ve.useState(""),[c,h]=ve.useState(0),[d,g]=ve.useState(null),m=ve.useRef(null),y=ve.useRef(null),b=ve.useMemo(()=>l.trim()?n(l,!0):{stages:[],outputIds:[]},[l,n]),x=ve.useMemo(()=>{if(!t)return[];if(!l.trim().toLowerCase())return[{id:"select",label:"Select tables...",icon:A.jsx(tne,{size:14}),desc:"select [pattern] or select *",action:()=>o("select ")},{id:"search",label:"Find table...",icon:A.jsx(Tu,{size:14}),desc:"Jump to entity",action:()=>o("search ")},{id:"add-table",label:"Add table...",icon:A.jsx(Gf,{size:14}),desc:"Create a new table node",action:()=>o("add table ")},{id:"add-domain",label:"Add domain...",icon:A.jsx(Gf,{size:14}),desc:"Create a new domain container",action:()=>o("add domain ")},{id:"fit",label:"Fit View",icon:A.jsx(Qre,{size:14}),desc:"Show entire model",action:()=>w("fit")},{id:"theme",label:"Switch Theme",icon:A.jsx(Ck,{size:14}),desc:"Toggle dark/light mode",action:()=>o("theme ")}];const M=l.split("|"),R=M[M.length-1],O=R.trim().split(/\s+/),N=O[0].toLowerCase(),B=M.slice(0,-1).join("|")+(M.length>1?"|":"");if(N==="select"){const D=O.slice(1).join(" ").toLowerCase();return(t.tables||[]).filter(_=>_.id.toLowerCase().includes(D)||_.name.toLowerCase().includes(D)).slice(0,8).map(_=>({id:_.id,label:_.name,icon:A.jsx(Tu,{size:14}),desc:`Table: ${_.id}`,action:()=>o(`${B} select ${_.id}`)}))}if(N==="mv"){const D=O.findIndex(z=>z.toLowerCase()==="to"),_=D>-1?O.slice(D+1).join(" ").toLowerCase():O.slice(1).join(" ").toLowerCase(),P=D>-1?O.slice(0,D+1).join(" "):"mv";return(t.domains||[]).filter(z=>z.id.toLowerCase().includes(_)||z.name.toLowerCase().includes(_)).slice(0,8).map(z=>({id:z.id,label:z.name,icon:A.jsx(nne,{size:14}),desc:`Domain: ${z.id}`,action:()=>o(`${B} ${P} ${z.id}`)}))}if(N==="theme"){const D=O.slice(1).join(" ").toLowerCase();return["dark","light"].filter(_=>_.includes(D)).map(_=>({id:_,label:_,icon:A.jsx(Ck,{size:14}),desc:"UI Appearance",action:()=>o(`${B} theme ${_}`)}))}if(N==="search"||N==="find"||!["mv","add","select","theme","fit"].includes(N)){const D=N==="search"||N==="find"?O.slice(1).join(" ").toLowerCase():R.trim().toLowerCase();return(t.tables||[]).filter(_=>_.id.toLowerCase().includes(D)||_.name.toLowerCase().includes(D)).slice(0,10).map(_=>({id:_.id,label:`Go to ${_.name}`,icon:A.jsx(Tu,{size:14}),desc:_.id,action:()=>{N==="search"||N==="find"||M.length===1?(a(_.id),r(!1)):o(`${B} select ${_.id}`)}}))}return[]},[t,l,a,r]);ve.useEffect(()=>{i(e?b.outputIds:[])},[e,b.outputIds,i]),ve.useEffect(()=>{if(y.current){const E=y.current.children[c];E&&E.scrollIntoView({block:"nearest",behavior:"smooth"})}},[c]),ve.useEffect(()=>{e&&(o(""),g(null),h(0),setTimeout(()=>m.current?.focus(),10))},[e]);const w=E=>{const M=E||l;if(!M.trim())return;if(M==="fit"){window.__modscapeFitView?.(),S("success","View fitted");return}const R=n(M,!1);if(R.stages.length>0&&R.stages.every(O=>O.status==="success"))S("success","Pipeline executed successfully");else{const O=R.stages.find(N=>N.status==="error");O&&S("info",O.message)}},S=(E,M)=>{g({type:E,msg:M}),setTimeout(()=>{g(null),E==="success"&&o("")},1500)},k=E=>{E.stopPropagation(),E.key==="Escape"?r(!1):E.key==="ArrowDown"?(E.preventDefault(),h(M=>(M+1)%(x.length||1))):E.key==="ArrowUp"?(E.preventDefault(),h(M=>(M-1+(x.length||1))%(x.length||1))):E.key==="Tab"?(E.preventDefault(),x.length>0&&x[c]&&x[c].action()):E.key==="Enter"&&(E.preventDefault(),w())};return e?A.jsxs("div",{className:`fixed inset-0 z-[2000] flex items-start justify-center pt-[15vh] px-4 backdrop-blur-[2px] animate-in fade-in duration-200 ${s==="dark"?"bg-slate-950/20":"bg-white/20"}`,children:[A.jsx("div",{className:"absolute inset-0",onClick:()=>r(!1)}),A.jsxs("div",{className:`relative w-full max-w-2xl rounded-2xl shadow-[0_32px_64px_-12px_rgba(0,0,0,0.5)] border-2 overflow-hidden animate-in slide-in-from-top-4 duration-300 ${s==="dark"?"bg-slate-900 border-slate-700 text-white":"bg-white border-slate-200 text-slate-900"}`,children:[A.jsxs("div",{className:`flex items-center px-4 py-4 gap-3 border-b ${s==="dark"?"border-slate-800/50":"border-slate-100"}`,children:[A.jsx("div",{className:"p-1.5 bg-blue-600 rounded-lg text-white shadow-lg shadow-blue-500/20",children:A.jsx(h6,{size:18})}),A.jsx("input",{ref:m,type:"text",placeholder:"select * | mv Core | stack v",className:`flex-1 bg-transparent border-none outline-none text-lg font-bold tracking-tight ${s==="dark"?"placeholder-slate-600":"placeholder-slate-400"}`,value:l,onChange:E=>{o(E.target.value),h(0)},onKeyDown:k}),A.jsx("kbd",{className:`px-1.5 py-0.5 rounded text-[10px] font-black border ${s==="dark"?"bg-slate-800 text-slate-500 border-slate-700":"bg-slate-100 text-slate-400 border-slate-200"}`,children:"ESC"})]}),d?A.jsxs("div",{className:`px-4 py-6 flex flex-col items-center justify-center gap-3 animate-in zoom-in-95 duration-200 ${d.type==="success"?"text-emerald-500":"text-blue-500"}`,children:[A.jsx("div",{className:`p-3 rounded-full ${d.type==="success"?"bg-emerald-500/10":"bg-blue-500/10"}`,children:d.type==="success"?A.jsx(u6,{size:32}):A.jsx(SE,{size:32})}),A.jsx("span",{className:"text-sm font-black uppercase tracking-widest",children:d.msg})]}):A.jsxs(A.Fragment,{children:[l.trim()&&A.jsxs("div",{className:`px-4 py-4 border-b flex flex-col gap-3 ${s==="dark"?"bg-slate-950/20":"bg-slate-50/50"}`,children:[A.jsxs("div",{className:"flex items-center justify-between",children:[A.jsx("h4",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-slate-500",children:"Execution Plan"}),A.jsx(CE,{size:12,className:"text-blue-500 animate-pulse"})]}),A.jsx("div",{className:"flex flex-col gap-2",children:b.stages.length>0?b.stages.map((E,M)=>A.jsxs("div",{className:"flex items-center gap-3 group",children:[A.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-bold ${E.status==="success"?"bg-emerald-500/20 text-emerald-500":E.status==="active"?"bg-blue-500 text-white animate-pulse":"bg-slate-800 text-slate-500"}`,children:M+1}),A.jsx("div",{className:"flex flex-col",children:A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("span",{className:"text-xs font-black uppercase tracking-wider",children:E.command}),A.jsx("span",{className:"text-[10px] text-slate-500 font-medium",children:E.message})]})})]},M)):A.jsx("div",{className:"text-[10px] text-slate-500 italic",children:"Parsing command..."})})]}),A.jsxs("div",{className:"flex flex-col",children:[x.length>0&&A.jsx("div",{ref:y,className:"max-h-[300px] overflow-auto py-2 border-b border-slate-800/30",children:x.map((E,M)=>A.jsxs("div",{className:`px-4 py-3 flex items-center justify-between cursor-pointer transition-colors ${c===M?"bg-blue-600 text-white":s==="dark"?"hover:bg-slate-800 text-slate-300":"hover:bg-slate-50 text-slate-600"}`,onClick:()=>E.action(),children:[A.jsxs("div",{className:"flex items-center gap-3",children:[A.jsx("div",{className:c===M?"text-white":"text-slate-500",children:E.icon}),A.jsxs("div",{className:"flex flex-col",children:[A.jsx("span",{className:"text-sm font-bold",children:E.label}),E.desc&&A.jsx("span",{className:`text-[10px] ${c===M?"text-blue-100":"text-slate-500"}`,children:E.desc})]})]}),c===M&&A.jsx(Eg,{size:14,className:"opacity-50"})]},`${E.id}-${M}`))}),l.includes("|")&&A.jsxs("div",{className:"p-4 flex flex-col gap-3",children:[A.jsx("div",{className:"flex items-center justify-between",children:A.jsxs("h4",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-slate-500",children:["Working Set (",b.outputIds.length,")"]})}),A.jsx("div",{className:"flex flex-wrap gap-1.5 max-h-[120px] overflow-auto",children:b.outputIds.length>0?b.outputIds.map(E=>A.jsx("div",{className:`px-2 py-0.5 rounded text-[10px] font-bold border ${s==="dark"?"bg-blue-500/10 border-blue-500/20 text-blue-400":"bg-blue-50 border-blue-100 text-blue-600"}`,children:E},E)):A.jsx("div",{className:"text-[10px] text-slate-500 italic",children:"No tables in current scope"})})]})]})]}),A.jsxs("div",{className:`px-4 py-3 border-t flex items-center justify-between ${s==="dark"?"bg-slate-950/30 border-slate-800/50":"bg-slate-50/50 border-slate-100"}`,children:[A.jsxs("div",{className:"flex items-center gap-4 text-[9px] font-bold text-slate-500 uppercase",children:[A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("kbd",{className:`px-1 rounded border ${s==="dark"?"bg-slate-800 border-slate-700":"bg-slate-100 border-slate-200"}`,children:"↑↓"}),A.jsx("span",{children:"Navigate"})]}),A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("kbd",{className:`px-1 rounded border ${s==="dark"?"bg-slate-800 border-slate-700":"bg-slate-100 border-slate-200"}`,children:"Tab"}),A.jsx("span",{children:"Select"})]}),A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx("kbd",{className:`px-1 rounded border ${s==="dark"?"bg-slate-800 border-slate-700":"bg-slate-100 border-slate-200"}`,children:"Enter"}),A.jsx("span",{children:"Execute"})]})]}),A.jsxs("div",{className:"flex items-center gap-2",children:[A.jsx("div",{className:`w-2 h-2 rounded-full ${b.outputIds.length>0?"bg-emerald-500 animate-pulse":"bg-slate-700"}`}),A.jsxs("span",{className:"text-[9px] font-black text-slate-500 uppercase tracking-widest",children:[b.outputIds.length," target entities"]})]})]})]})]}):null}),Jfe=()=>{const{isPresentationMode:t,setIsPresentationMode:e,theme:r}=pt();return t?A.jsx("div",{className:"fixed top-6 right-6 z-[100] flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500",children:A.jsx("button",{onClick:()=>e(!1),className:`p-2.5 rounded-full border shadow-2xl backdrop-blur-md transition-all hover:rotate-90 active:scale-90 ${r==="dark"?"bg-slate-900/80 border-slate-700 text-slate-400 hover:text-white":"bg-white/80 border-slate-200 text-slate-500 hover:text-slate-900"}`,title:"Exit Presentation Mode (Esc)",children:A.jsx(Oh,{size:20})})}):null},ehe=()=>{const{getSelectedTable:t,getSelectedDomain:e,getSelectedRelationship:r,selectedTableIds:n,setSelectedTableIds:i,distributeSelectedTables:a,setSelectedTableId:s,setSelectedEdgeId:l,setSelectedAnnotationId:o,theme:c}=pt(),h=t(),d=e(),g=r(),m=n.length>1;if(!h&&!d&&!g&&!m)return null;const y=()=>{s(null),i([]),l(null),o(null)};return A.jsxs("div",{className:`absolute top-4 right-4 z-10 flex items-center gap-3 border rounded-xl shadow-2xl p-1.5 px-4 animate-in fade-in slide-in-from-top-4 duration-300 ${c==="dark"?"bg-slate-900/90 backdrop-blur-md border-blue-500/30":"bg-white/90 backdrop-blur-md border-blue-200 shadow-blue-500/5"}`,children:[A.jsxs("div",{className:`flex items-center gap-2 border-r pr-4 mr-1 ${c==="dark"?"border-slate-700":"border-slate-100"}`,children:[m?A.jsx(Vre,{size:16,className:"text-blue-500"}):A.jsxs(A.Fragment,{children:[h&&A.jsx(Hl,{size:16,className:"text-emerald-500"}),d&&A.jsx(p6,{size:16,className:"text-blue-500"}),g&&(g.relationship.type==="lineage"?A.jsx(wE,{size:16,className:"text-blue-400"}):A.jsx(zu,{size:16,className:"text-amber-500"}))]}),A.jsxs("div",{className:"flex flex-col leading-tight",children:[A.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-500",children:m?"Multi-Selection":`Selected ${h?"Table":d?"Domain":g?.relationship.type==="lineage"?"Lineage":"Relation"}`}),A.jsx("span",{className:`text-xs font-semibold truncate max-w-[180px] ${c==="dark"?"text-slate-200":"text-slate-800"}`,children:m?`${n.length} tables selected`:h?h.name:d?d.name:g?`${g.relationship.from.table} → ${g.relationship.to.table}`:""})]})]}),A.jsxs("div",{className:"flex items-center gap-1",children:[m&&A.jsxs("div",{className:"flex items-center gap-1 mr-2 pr-2 border-r border-slate-700/30",children:[A.jsx("button",{onClick:()=>a("vertical"),className:"flex items-center justify-center w-8 h-8 hover:bg-blue-500/20 text-slate-400 hover:text-blue-400 rounded-lg transition-all",title:"Align Vertically (V)",children:A.jsx(yre,{size:16})}),A.jsx("button",{onClick:()=>a("horizontal"),className:"flex items-center justify-center w-8 h-8 hover:bg-blue-500/20 text-slate-400 hover:text-blue-400 rounded-lg transition-all",title:"Align Horizontally (H)",children:A.jsx(vre,{size:16})})]}),A.jsx("button",{onClick:y,className:`flex items-center justify-center w-8 h-8 rounded-lg transition-all ${c==="dark"?"hover:bg-slate-800 text-slate-500 hover:text-slate-300":"hover:bg-slate-100 text-slate-400 hover:text-slate-600"}`,title:"Clear Selection (Esc)",children:A.jsx(Oh,{size:16})})]})]})};function the(){const{schema:t,setSelectedTableId:e,selectedTableId:r,selectedEdgeId:n,setSelectedEdgeId:i,selectedAnnotationId:a,setSelectedAnnotationId:s,focusNodeId:l,setFocusNodeId:o,removeNode:c,bulkRemoveTables:h,removeEdge:d,removeAnnotation:g,showAnnotations:m,addTable:y,addDomain:b,addAnnotation:x,theme:w,isPresentationMode:S,setIsPresentationMode:k,refreshModelData:E,fetchAvailableFiles:M,isModelLoading:R,isCliMode:O,distributeSelectedTables:N,selectedTableIds:B,toggleTableSelection:D,toggleEdgeSelection:_,connectMode:P,setConnectMode:z,currentModelSlug:H}=pt(so(K=>({schema:K.schema,setSelectedTableId:K.setSelectedTableId,selectedTableId:K.selectedTableId,selectedEdgeId:K.selectedEdgeId,setSelectedEdgeId:K.setSelectedEdgeId,selectedAnnotationId:K.selectedAnnotationId,setSelectedAnnotationId:K.setSelectedAnnotationId,focusNodeId:K.focusNodeId,setFocusNodeId:K.setFocusNodeId,removeNode:K.removeNode,bulkRemoveTables:K.bulkRemoveTables,removeEdge:K.removeEdge,removeAnnotation:K.removeAnnotation,showAnnotations:K.showAnnotations,addTable:K.addTable,addDomain:K.addDomain,addAnnotation:K.addAnnotation,theme:K.theme,isPresentationMode:K.isPresentationMode,setIsPresentationMode:K.setIsPresentationMode,refreshModelData:K.refreshModelData,fetchAvailableFiles:K.fetchAvailableFiles,isModelLoading:K.isModelLoading,isCliMode:K.isCliMode,distributeSelectedTables:K.distributeSelectedTables,selectedTableIds:K.selectedTableIds,toggleTableSelection:K.toggleTableSelection,toggleEdgeSelection:K.toggleEdgeSelection,connectMode:K.connectMode,setConnectMode:K.setConnectMode,currentModelSlug:K.currentModelSlug}))),$=ve.useRef(null),q=ve.useRef(null),V=ve.useRef(null),X=ve.useCallback(K=>{$.current=K},[]),ee=ve.useCallback(K=>{q.current=K},[]),te=ve.useCallback(K=>{V.current=K},[]);ve.useEffect(()=>{if(!H)return;const K=setTimeout(()=>$.current?.(),300);return()=>clearTimeout(K)},[H]);const I=ve.useRef(null),G=ve.useRef(null),re=ve.useRef(1e3);ve.useEffect(()=>{if(!O)return;const K=()=>{const ue=window.location.protocol==="https:"?"wss:":"ws:",Se=new WebSocket(`${ue}//${window.location.host}`);Se.onopen=()=>{re.current=1e3},Se.onmessage=at=>{try{const Me=JSON.parse(at.data);Me.type==="update"?E():Me.type==="files_changed"&&M()}catch{}},Se.onclose=()=>{I.current=null,G.current&&window.clearTimeout(G.current),G.current=window.setTimeout(()=>{re.current=Math.min(re.current*1.5,3e4),K()},re.current)},Se.onerror=()=>Se.close(),I.current=Se};return K(),()=>{I.current&&(I.current.onclose=null,I.current.close()),G.current&&window.clearTimeout(G.current)}},[O,E,M]),ve.useEffect(()=>{l&&q.current&&(q.current(l),o(null))},[l,o]),ve.useEffect(()=>{window.__modscapeFitView=()=>$.current?.(),window.__modscapeAutoLayout=()=>V.current?.()},[]),ve.useEffect(()=>{const K=ue=>{if(ue.key==="Escape"){if(S){k(!1);return}if(pt.getState().connectMode){pt.getState().setConnectMode(null);return}e(null),i(null),s(null),pt.getState().setSelectedTableIds([]);return}const Se=document.activeElement;if(Se?.tagName==="INPUT"||Se?.tagName==="TEXTAREA"||Se?.isContentEditable||Se?.closest(".cm-editor")||Se?.closest(".sidebar-content")||ue.repeat)return;const Me=ue.key.toLowerCase();if(Me==="/"){ue.preventDefault(),pt.getState().setIsRightPanelOpen(!0),pt.getState().setActiveRightPanelTab("tables");return}if(Me==="k"&&(ue.ctrlKey||ue.metaKey)){ue.preventDefault(),pt.getState().setIsCommandPaletteOpen(!pt.getState().isCommandPaletteOpen);return}if(Me==="l"){ue.preventDefault();const He=pt.getState().activeTab;pt.getState().setActiveTab(He==="connect"?"editor":"connect"),pt.getState().setIsSidebarOpen(!0);return}if((Me==="v"||Me==="h")&&B.length>1){ue.preventDefault(),N?.(Me==="v"?"vertical":"horizontal");return}if(ue.key==="Backspace"||ue.key==="Delete"){if(B.length>1){h(B),pt.getState().setSelectedTableIds([]);return}if(!r&&!a){if(n){if(n.startsWith("lin-")){const He=n.lastIndexOf("-"),$e=parseInt(n.slice(He+1)),Ne=t?.lineage?.[$e];Ne&&d(Ne.from,Ne.to,"lineage")}else{const He=t?.relationships?.find(($e,Ne)=>`er-${Ne}`===n);He&&d(He.from.table,He.to.table,"er")}i(null)}return}}if((ue.key==="Backspace"||ue.key==="Delete")&&(r||a)){a?(g(a),s(null)):r&&(c(r),e(null));return}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[S,k,e,i,s,r,n,a,B,N,t,c,h,d,g]);const Y=ve.useCallback(K=>{D(K)},[D]),W=ve.useCallback(K=>{_(K.id)},[_]),Z=ve.useCallback(()=>{e(null),i(null),s(null),pt.getState().setSelectedTableIds([])},[e,i,s]),ie=ve.useCallback(K=>{e(null),i(null),s(K)},[e,i,s]),we=ve.useCallback(K=>{s(null),i(null),D(K)},[s,i,D]),de=ve.useCallback((K,ue,Se)=>{K==="lineage"?pt.getState().addLineage(ue,Se):pt.getState().addRelationship(ue,Se)},[]),se=ve.useCallback((K,ue)=>{y(K,ue)},[y]),j=ve.useCallback((K,ue)=>{b(K,ue)},[b]),Q=ve.useCallback((K,ue)=>{m||pt.getState().setShowAnnotations(!0),x({x:K,y:ue})},[x,m]);return A.jsxs("div",{className:"flex-1 relative h-full flex flex-col overflow-hidden",children:[A.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[!S&&A.jsx(ehe,{}),A.jsx(Jfe,{}),A.jsx(Zfe,{}),P&&A.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-50 pointer-events-none",children:A.jsxs("div",{className:`flex items-center gap-2 px-4 py-1.5 backdrop-blur-md rounded-full shadow-xl border ${w==="dark"?"bg-slate-950/70 border-green-500/50":"bg-white/80 border-green-500/40"}`,children:[A.jsx("div",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),A.jsxs("span",{className:`text-[10px] font-black uppercase tracking-widest ${w==="dark"?"text-green-400":"text-green-600"}`,children:[P==="lineage"?"Lineage":"ER"," Connect Mode"]}),A.jsx("div",{className:`w-px h-3 ${w==="dark"?"bg-green-500/20":"bg-green-500/30"}`}),A.jsx("span",{className:`text-[10px] font-bold ${w==="dark"?"text-green-400/70":"text-green-600/70"}`,children:"Click source → target · Esc to exit"}),A.jsx("button",{className:"pointer-events-auto ml-1 opacity-60 hover:opacity-100 transition-opacity",onClick:()=>z(null),children:A.jsx("span",{className:`text-[10px] font-bold ${w==="dark"?"text-green-400":"text-green-600"}`,children:"✕"})})]})}),R&&A.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,zIndex:10,pointerEvents:"none"},children:[A.jsx("div",{style:{width:36,height:36,border:`3px solid ${w==="dark"?"#334155":"#e2e8f0"}`,borderTopColor:w==="dark"?"#60a5fa":"#3b82f6",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),A.jsx("span",{style:{fontSize:13,color:w==="dark"?"#94a3b8":"#64748b",fontWeight:500},children:"Loading model…"})]}),A.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),t&&A.jsx(ure,{onNodeClick:Y,onEdgeClick:W,onPaneClick:Z,onAnnotationClick:ie,onDomainClick:we,onAddTableAt:se,onAddDomainAt:j,onAddAnnotationAt:Q,onFitView:X,onFocusNode:ee,onEdgeCreated:de,onAutoLayout:te})]}),!S&&A.jsx(Mne,{})]})}function rhe(){const[t,e]=ve.useState(!1),{isCliMode:r,fetchAvailableFiles:n,setCurrentModel:i,setSchema:a,theme:s,isPresentationMode:l}=pt(),o=!!window.__MODSCAPE_DATA__;return ve.useEffect(()=>{if(r){n().then(()=>{const h=new URLSearchParams(window.location.search).get("model");h?i(h):fetch("/api/model").then(d=>d.json()).then(d=>a(d))}),e(!0);return}if(o){const c=window.__MODSCAPE_DATA__;c?.models?.length>0&&n().then(()=>{const d=new URLSearchParams(window.location.search).get("model");d?i(d):(a(c.models[0].schema),c.models[0].slug&&i(c.models[0].slug))})}e(!0)},[r,o,n,i,a]),t?A.jsxs("div",{className:`flex h-screen w-screen overflow-hidden font-sans transition-colors duration-300 ${s==="dark"?"dark bg-slate-950 text-slate-100":"bg-slate-50 text-slate-900"}`,children:[!l&&A.jsx($fe,{}),A.jsx(the,{}),!l&&A.jsx(Kfe,{})]}):null}AI.createRoot(document.getElementById("root")).render(A.jsx(ve.StrictMode,{children:A.jsx(rhe,{})}));
|